---
title: Reversible Graph Rewriting
url: https://www.emergentmind.com/topics/reversible-graph-rewriting
type: topic
---

# Reversible Graph Rewriting

Searching arXiv for recent and foundational papers on reversible graph rewriting.
Reversible graph rewriting studies graph transformation systems in which a forward transformation can be undone, reconstructed, or paired with a backward transformation under explicit structural conditions. In the literature, this is not a single notion. It appears as symmetry under inverse generator rules in site-graph rewriting, as reversibility conditions on sesqui-pushout rewrites, as local invertibility between adjacent space-like cuts in asynchronous graph dynamics, and as global causal graph dynamics whose inverse is again causal. By contrast, several graph-rewriting frameworks provide determinism, traceability, algebraic dualization, or controlled execution without establishing reversibility in this stronger sense [1503.06022], [2012.01661], [2510.03296], [1502.04368].

## 1. Meanings of reversibility in graph rewriting

A first meaning of reversibility is qualitative symmetry of the transition system. In thermodynamic site-graph rewriting, a generator rule is a pair of contact maps
\[
r=(r_L:L\to C,\; r_R:R\to C)
\]
with the same agents and sites on both sides and differing only in edge structure. The inverse rule
\[
r^\star := (r_R,r_L)
\]
is also valid, and the generator set is assumed closed under inversion, \(G=G^\star\). The induced labelled transition system is therefore symmetric: every transition has a reverse transition. In that framework, this symmetry is the qualitative notion of reversibility [1503.06022].

A second meaning is categorical reversibility of an individual rewrite step. In the reversible sesqui-pushout variant adopted from Danos et al., a rule has the form
\[
r: L \xleftarrow{\,r^-\,} P \xrightarrow{\,r^+\,} R
\]
and an instance is a monomorphism \(m:L\hookrightarrow G\). The rewrite is reversible iff the restrictive square is also a pushout and the expansive square is also a final pullback complement. The reverse rule is
\[
r^{-1}: R \xleftarrow{\,r^+\,} P \xrightarrow{\,r^-\,} L.
\]
The point of the definition is that the rewrite diagram can be read both forward and backward, excluding side effects that destroy information needed for undo. The same source stresses that reversible SqPO rewriting is not the same as DPO rewriting, because SqPO still permits cloning [2012.01661].

A third meaning is local space-time reversibility for asynchronous rewriting. In that setting, global evolution is not even a function, because rewrites are applied at non-deterministically chosen locations. Reversibility is therefore formulated by requiring that two sufficiently close snapshots, or space-like cuts, mutually determine each other. Formally, a local operator \(A_{(-)}\) is reversible iff there exists a backward neighborhood scheme and a local operator \(B_{(-)}\) satisfying left and right local inverse conditions,
\[
B_xA_xG=G,\qquad A_xB_xH=H,
\]
with matching local neighborhoods on both sides. Reversibility is thus a locality-preserving inverse property, not merely a set-theoretic inverse [2510.03296].

A fourth meaning is reversibility of synchronous causal graph dynamics. There, a dynamics \((F,R_\bullet)\) is invertible if \(F\) is a bijection on the state space of pointed graphs modulo isomorphism, and it is reversible if the inverse dynamics \((F^{-1},S_\bullet)\) is again a causal graph dynamics. In that model, reversibility is stronger than abstract bijectivity because the inverse must preserve continuity, shift-invariance, and boundedness [1502.04368].

## 2. Categorical mechanisms and boundary-sensitive rewrite formats

Category-theoretic graph rewriting isolates reversibility questions around complements, interfaces, and uniqueness. Over finitely presented C-sets, DPO rewriting uses a match \(m:L\to G\), a pushout complement, and then a pushout. Pushout complements need not exist and need not be unique, but identification and dangling conditions guarantee existence, and the first morphism being monic forces uniqueness. In that setting, DPO is the cleanest candidate for invertible rewriting up to isomorphism, whereas SPO and SqPO broaden expressivity by allowing deletion or addition in unknown context and therefore weaken uniqueness of reconstruction. PBPO+ makes boundary behavior more explicit by adding a separate type graph \(L'\) and an adherence morphism \(G\to L'\), so that the rule controls the rewriting of the boundary of a match rather than only the matched subobject [2111.03784].

Surface-embedded graph rewriting makes the interface itself a first-class object. A boundary graph has exactly two vertices, \(\partial\) and \(\bar\partial\), and a partitioning span
\[
L \xleftarrow{\,l\,} B \xrightarrow{\,c\,} C
\]
records how a graph is cut into a rewritten part and a context part. In that category, pushouts of partitioning spans exist, pushout complements of boundary embeddings exist, and pushout complements are unique up to the re-pairing problem. The re-pairing problem reconstructs the missing half of the boundary identification, and the paper proves that it has a solution that is unique in the sense specified in the proof. This makes the rewrite local and boundary-aware, while also exposing a residual source of ambiguity: with rotation systems, different re-pairings can produce different local topology at \(\bar\partial\) [2210.08914].

PBPO+ adds another form of control by strong matching. For linear term rewrite systems, the encoding into PBPO+ preserves termination globally:
\[
R \text{ is terminating on } Ter \iff R^\wedge \text{ is terminating on } \Sigma^\wedge.
\]
The match square prevents the matching morphism from collapsing context elements of the host graph onto the pattern \(t_L(L)\subseteq L'\). That result is about preservation of termination rather than reversibility, but it suggests that explicit typing and strong matching can constrain host-context interactions in ways that are relevant to recoverability questions [2106.13826].

## 3. Thermodynamic and stochastic reversible rewriting

Thermodynamic graph rewriting develops reversibility as a stochastic discipline built on reversible qualitative moves. The state space is the category of realizable site graphs typed by a contact graph \(C\). A finite set \(P\) of connected contact maps is designated as energy patterns, and an energy cost function
\[
\varepsilon : P \to \mathbb{R}
\]
assigns a real cost to each pattern. For a mixture \(x\), the occurrence vector \(P(x)\in\mathbb{N}^P\) counts embeddings of each pattern, and the energy is
\[
E(x)=\varepsilon\cdot P(x)=\sum_{c\in P}\varepsilon(c)\,|_C(c,x)|.
\]
Generators determine the qualitative dynamics, while energy patterns and costs determine the long-term probability of reachable graphs [1503.06022].

The central technical issue is ambiguous energy balance: a local generator rule may induce different energy changes in different contexts. The refinement mechanism resolves this by constructing finitely many \(P\)-balanced subrules. A growth policy reveals exactly the context required so that every relevant occurrence of every pattern is either always fully contained or always avoided. The resulting refinement
\[
G_P := \biguplus_{g\in G} {}^P(g)
\]
is finite, exhaustive, non-empty, closed under inversion, and \(P\)-balanced. Each refined rule carries a definite balance vector \(\phi\in\mathbb{Z}^P\), independent of the host context [1503.06022].

Once rates are assigned to refined rules, the system becomes a CTMC. The compatibility equation
\[
\log k(g^\star_{\phi^\star}) - \log k(g_\phi) = \varepsilon \cdot \phi
\]
forces the ratio of reverse to forward rates to match the induced energy difference. This yields detailed balance:
\[
q(y,x)\,e^{-\varepsilon\cdot P(y)} = q(x,y)\,e^{-\varepsilon\cdot P(x)},
\]
and the Boltzmann distribution
\[
\pi_x(y)=\frac{e^{-\varepsilon\cdot P(y)}}{\sum_{z\in L_G(x)} e^{-\varepsilon\cdot P(z)}}
\]
is the unique fixed point on each finite connected component. In this literature, reversible graph rewriting therefore means both inverse qualitative moves and thermodynamical consistency of the stochastic dynamics [1503.06022].

## 4. Algebraic formalisms and inverse-like structures

The algebraic theory of rule diagrams recasts graph rewriting as an associative algebra of compositions. A rule diagram
\[
d=(I,O,r,m,s,t)
\]
encodes input graph, output graph, connected linear rules, and matches between successive components. The rule diagram algebra is the vector space spanned by isomorphism classes of such diagrams, with composition defined by summing over all admissible one-to-one matches. This composition is bilinear, associative, and unital, with empty diagram \(d_{\emptyset}\) as unit. Actual graph rewriting systems arise only after reduction to restricted rule algebras for
\[
T\in\{DPO,\;SPO_A,\;SPO_B,\;SPO_{AB}\},
\]
where dangling edges are either forbidden or repaired by specific strategies [1612.06240].

The closest algebraic analogue of reversal is dualization,
\[
d^\dagger = (O,I,r^\dagger,m^\dagger,s,t),
\]
which satisfies
\[
(d_1 *_{} d_2)^\dagger = d_2^\dagger *_{} d_1^\dagger,\qquad (d^\dagger)^\dagger=d.
\]
The full rule diagram algebra is also a connected filtered Hopf algebra. Its antipode satisfies, for products of primitive basis diagrams,
\[
S(d_1*\cdots * d_n)=(-1)^n d_n * \cdots * d_1.
\]
These constructions provide anti-involution and convolution-inverse structure at the algebraic level [1612.06240].

The same work makes the limitation explicit. Dualization is not an inverse to composition; it is an anti-involution, not a group inverse. The restricted rule algebras implementing DPO and SPO rewriting are associative and unital, but they do not carry a compatible coalgebra structure and are therefore not Hopf algebras. The paper does not show that every graph rewriting rule has an actual inverse rule, that DPO or SPO rewriting is reversible as a transition system, or that the rewriting systems define groupoids or reversible dynamics. Algebraic inversion is therefore formal and structural rather than operational [1612.06240].

## 5. Space-time reversibility and reversible causal dynamics

Space-time reversible graph rewriting is formulated over directed acyclic labelled port graphs
\[
G = (I_G, B_G, E_G, \sigma_G)
\]
satisfying acyclicity, border-attachment, and port-saturation. Its core bridge is an equivalence between local operators and deterministic causal rewrite systems. A family of rules \(\{D_x^j\to G_x^j\}\) is required to be functional, renaming-invariant, mutex-domain, context-preserving, and \(S\)-preserving, and the paper proves that any neighborhood scheme together with a local operator determines such a causal rewrite system, and conversely. Reversibility then admits three equivalent characterizations: existence of a local inverse, axiomatic reversibility, and the requirement that the transposed rules \(\{E_x^j\to D_x^j\}\) form a backward causal rewrite system. The inverse, when it exists, is unique [2510.03296].

The axiomatic characterization isolates injectivity, surjectivity, and back-reachability. Reversibility is therefore not only about undoing a local change, but about doing so while preserving the same causal-cone structure. The framework also analyzes when the backward dynamics inherits commutativity. Time-symmetric commutativity, the two-two condition, and bounded-neighborhood hypotheses are all presented as sufficient routes to a commutative inverse. The main example is a reversible time-dilation construction in which gray vertices store information that would otherwise be lost when particles cross a bar between regions of different time resolution; the reverse step splits the gray chain to recover the hidden particle [2510.03296].

Reversible causal graph dynamics develops a synchronous counterpart. The state space consists of bounded-degree pointed graphs modulo isomorphism, and a dynamics \((F,R_\bullet)\) is causal precisely when it is shift-invariant, continuous, and bounded. A central theorem states that if \((F,R_\bullet)\) is an invertible causal graph dynamics, then it is reversible: \(F^{-1}\) is again a causal graph dynamics. The same theory proves an almost-vertex-preserving theorem: there exists \(p\) such that if \(|V(X)|>p\), then the vertex-tracking map \(R_X\) is bijective. Reversible dynamics may therefore create or delete vertices, but only on finitely many small exceptional graphs. A second major result gives a block representation,
\[
F(X)=\left(\prod_X \mu\right)\cdot\left(\prod_X (F'^{-1}\circ \mu \circ F')\right)(X),
\]
which is the graph-dynamics analogue of a finite-depth circuit of local reversible gates [1502.04368].

## 6. Hierarchies, audit trails, implementations, and non-reversible contrasts

Reversible graph rewriting becomes particularly concrete in graph hierarchies. A hierarchy of objects is a DAG whose nodes are objects and whose edges are arrows, subject to a commutativity condition requiring all paths between the same pair of nodes to be equal. A rule hierarchy is a hierarchy in the category of SqPO rules, and its application to a graph hierarchy requires commuting instances and coherent propagation through the restrictive phase. A hierarchy rewrite is reversible iff each individual object rewrite is reversible and the reverse hierarchy is applicable. In adhesive categories, the composition of two reversible rewrites is reversible, and the same closure result extends to hierarchy rewrites. This categorical machinery is used to define audit trails that store the current graph or hierarchy together with a compact history of rules and right-hand side instances, enabling rollback, delta compression, switching between versions, and merging of diverged versions. The prototype system is implemented in the ReGraph Python library [2012.01661].

Generic implementations of categorical rewriting supply the constructions needed for such systems. Over finitely presented C-sets, the computational framework in Catlab provides efficient pushout complements, pullback complements, final pullback complements, and CSP-based search for homomorphisms, monomorphisms, and isomorphisms. The same work emphasizes that DPO offers the clearest route to invertible or recoverable rewriting, while SPO and SqPO weaken uniqueness by allowing deletion or addition in unknown context. Structured cospans and distributed graphs then extend these ideas to open systems and compositional assemblies, where reversal may only make sense relative to interfaces or colimit structure [2111.03784].

Several common misconceptions are clarified by contrasting cases. Egel provides an eager, deterministic, pointer-based graph-rewriting semantics with a runtime invariant that terms always form a tree or DAG, but it is not reversible: reduction overwrites thunks with results, the original unreduced structure is not retained, and the runtime does not preserve a full history of prior graph states [2004.09843]. PORGY and its strategy language provide controlled, traceable rewriting on located graphs, with explicit positions, sequencing, conditionals, iteration, atomic grouping, and trace visualization, but they do not define inverse rules, rollback semantics, causal consistency, or any formal notion of reversibility [1012.5560].

Reversible graph rewriting is therefore best understood as a family of precise technical doctrines rather than a single property. Inverse rule closure, detailed balance, complement uniqueness, locality-preserving inverse operators, reversible SqPO diagrams, and reversible causal graph dynamics all address reversibility, but they do so at different semantic levels and with different structural commitments. The strongest results arise when interfaces are explicit, complements are canonical or controlled, and backward evolution is required to satisfy the same locality or causality constraints as forward evolution.

Source: https://www.emergentmind.com/topics/reversible-graph-rewriting