Flow-Preserving Rewrite Rules
- Flow-Preserving Rewrite Rules are mechanisms that preserve designated structural invariants across different rewriting systems.
- In algebraic graph rewriting, frameworks like AGREE allow explicit control over embedding, enabling selective preservation of context connections.
- These rules underpin deterministic behavior in MBQC and maintain type safety in dependent type theory, offering practical benefits in system design.
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 (Corradini et al., 2014). 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 (McElvanney et al., 2022). In dependent type theory, an analogous requirement is subject reduction: if a term rewrites, its type must be preserved (Blanqui, 2020). 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 (Corradini et al., 2014, McElvanney et al., 2022, Blanqui, 2020).
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 (Corradini et al., 2014). 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 (McElvanney et al., 2023, Backens, 3 Jul 2026). 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 (Blanqui, 2020).
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 (Corradini et al., 2014).
An AGREE rule has the form
where and are the usual interface maps and 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 with pullbacks, a stable system of monos , an -partial map classifier , and pushouts along monos.
Rule application proceeds in two phases. First, for a mono match , one forms
and then constructs 0 as the pullback of
1
Second, one takes the pushout of
2
to obtain the rewritten object 3. 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 4 is local if
5
is an isomorphism, and a rewrite step is local if
6
is an isomorphism. The key proposition states that if 7 is a local rule, then every rewrite step generated by 8 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 9. A further result shows that polarized node cloning on graphs is also subsumed by choosing 0 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