---
title: Flow-Preserving Rewrite Rules
url: https://www.emergentmind.com/topics/flow-preserving-rewrite-rules
type: topic
---

# Flow-Preserving Rewrite Rules

Flow-preserving rewrite rules are rewrite rules constrained so that a designated structural invariant survives rewriting. The invariant is domain-specific. In algebraic graph transformation, the preserved structure is the embedding of retained items into the surrounding context graph, including which incident connections survive [1411.4597]. In measurement-based quantum computation (MBQC), the preserved structure is the existence of flow, gflow, or Pauli flow, which guarantees deterministic implementability through an admissible correction scheme and partial order [2205.02009]. In dependent type theory, an analogous requirement is subject reduction: if a term rewrites, its type must be preserved [2010.16111]. The term therefore names a family of preservation disciplines rather than a single uniform formalism.

## 1. Terminological scope and common structure

The phrase “flow-preserving” is used differently across the rewriting literature. In MBQC it refers literally to the preservation of a flow witness on a labelled open graph. In algebraic graph rewriting it refers to controlled preservation of how preserved items connect to the ambient graph. In dependent type theory it is used for preservation of typing under rewriting, which the cited work explicitly frames as a form of flow preservation through subject reduction [1411.4597][2205.02009][2010.16111].

A recurring source of confusion is that preservation of the rewritten object is not the same as preservation of its surrounding structure. AGREE separates preservation of items from preservation of their connections [1411.4597]. MBQC papers separate preservation of flow from preservation of interpretation: some rule systems preserve both the linear-map semantics and flow, while later work studies rules that preserve only the existence of flow [2304.08166][2607.03250]. In dependent types, the safe criterion is not merely that left- and right-hand sides can be typed in some environment, but that every typable instance of the left-hand side rewrites to a term of the same type [2010.16111].

This suggests a common pattern: ordinary rewriting often lets contextual propagation be handled automatically, whereas flow-preserving variants make that propagation an explicit proof obligation or rule parameter.

## 2. Controlled embedding in algebraic graph rewriting

In algebraic graph rewriting, standard DPO, SPO, and SqPO formalisms describe deletion, copying, merging, and creation of items, but do not let the rule designer directly choose which context connections of preserved items should survive a rewrite. AGREE, “Algebraic Graph Rewriting with controllEd Embedding,” was introduced to address exactly this limitation [1411.4597].

An AGREE rule has the form
\[
\rho=(K \xrightarrow{l} L,\; K \xrightarrow{r} R,\; K \xrightarrow{t} T_K),
\]
where \(l\) and \(r\) are the usual interface maps and \(t:K\to T_K\) is an explicit embedding morphism. This extra component is the distinctive mechanism of the framework: the rule specifies not only what is preserved, but also how the preserved part is re-embedded into the rewritten context. The framework is developed in a category \(\mathcal C\) with pullbacks, a stable system of monos \(M\), an \(M\)-partial map classifier \((T,\eta)\), and pushouts along monos.

Rule application proceeds in two phases. First, for a mono match \(m:L\to G\), one forms
\[
l'=\varphi(t,l):T_K\to T(L), \qquad m=\varphi(m,\mathrm{id}_L):G\to T(L),
\]
and then constructs \(D\) as the pullback of
\[
G \to T(L) \leftarrow T_K.
\]
Second, one takes the pushout of
\[
D \xleftarrow{n} K \xrightarrow{r} R
\]
to obtain the rewritten object \(H\). The first phase is the control point: it is where the embedding morphism determines how the matched subobject interacts with the surrounding context.

The conceptual distinction emphasized by AGREE is between preservation of items and preservation of connections. In standard algebraic rewriting, if a node is preserved, then its incident edges to the unmatched context are typically preserved automatically or determined categorically. AGREE allows these to diverge. A node may survive while some incident edges are selectively kept, dropped, or transformed. The paper notes that this can have non-local effects: preserving a single element may still modify the complement of the matched image in the host object.

To characterize when such effects are absent, the framework introduces strict complements. A rule \(\rho=(l,r,t)\) is local if
\[
t \setminus \mathrm{id}_K : T_K \setminus K \to T(K)\setminus K
\]
is an isomorphism, and a rewrite step is local if
\[
g \setminus l : D\setminus K \to G\setminus L
\]
is an isomorphism. The key proposition states that if \(\rho\) is a local rule, then every rewrite step generated by \(\rho\) is local. AGREE also proves that its first phase constructs final pullback complements via the partial map classifier, and that SqPO with monic matches is recovered as the special case \(t=\eta_K\). A further result shows that polarized node cloning on graphs is also subsumed by choosing \(t\) from the polarized classifier.

The motivating examples illustrate the intended “flow-preserving” behavior. A copied web page may duplicate only outgoing hyperlinks, not incoming ones. A cloned Linux process may alter its environment differently from the original. A social-network anonymization rule may clone a subgraph while preserving only public links. In each case, the identity of

Source: https://www.emergentmind.com/topics/flow-preserving-rewrite-rules