Graph Rewriting and Relabeling with PBPO+: A Unifying Theory for Quasitoposes

We extend the powerful Pullback-Pushout (PBPO) approach for graph rewriting with strong matching. Our approach, called PBPO+, allows more control over the embedding of the pattern in the host graph, which is important for a large class of rewrite systems. We argue that PBPO+ can be considered a unifying theory in the general setting of quasitoposes, by demonstrating that PBPO+ can define a strict superset of the rewrite relations definable by PBPO, AGREE and DPO. Additionally, we show that PBPO+ is well suited for rewriting labeled graphs and some classes of attributed graphs, by introducing a lattice structure on the label set and requiring graph morphisms to be order-preserving.


Introduction
Injectively matching a graph pattern P into a host graph G induces a classification of G into three parts: (i) a match graph M , the image of P ; (ii) a context graph C, the largest subgraph disjoint from M ; and (iii) a patch J, the set of edges that are in neither M nor C. For example, if P and G are respectively then M , C and J are indicated in green (bold), black and red (dotted), respectively. We call this kind of classification a patch decomposition.
Guided by the notion of patch decomposition, we recently introduced the expressive Patch Graph Rewriting (PGR) formalism [1]. Like most graph rewriting formalisms, PGR rules specify a replacement of a left-hand side (lhs) pattern L by a right-hand side (rhs) R. Unlike most rewriting formalisms, however, PGR rules allow one to (a) constrain the permitted shapes of patches around a match for L, and (b) specify how the permitted patches should be transformed, where transformations include rearrangement, deletion and duplication of patch edges.
Whereas PGR is defined set theoretically, in this paper we propose a more elegant categorical approach, called PBPO + , inspired by the same ideas. The name derives from the fact that the approach is obtained by strengthening the matching mechanism of the Pullback-Pushout (PBPO) approach by Corradini et al. [2]. Categorical approaches have at least three important advantages over set theoretic ones: (i) the classes of structures the method can be applied to is vastly generalized, (ii) typical meta-properties of interest (such as parallelism and concurrency) are more easily studied, and (iii) it makes it easier to compare to existing categorical frameworks.
After discussing the preliminaries in Section 2, we introduce PBPO + in Section 3, and then provide a detailed comparison with PBPO in Section 4. We argue that PBPO + is preferable in situations where matching is not controlled, such as when specifying generative grammars or modeling execution.
Next, we study PBPO + in the setting of quasitoposes in Section 5. Quasitoposes generalize toposes, which can be described as capturing "set-like" categories [3,Preface]. Quasitoposes include not only the categories of sets, directed multigraphs [4] and typed graphs [5] (all of which are toposes), but also a variety of structures such as Heyting algebras (considered as categories) [3], and the categories of simple graphs (equivalently, binary relations) [6], fuzzy sets [3], algebraic specifications [6] and safely marked Petri Nets [6]. Most importantly, we show that, using regular monic matching, PBPO + has enough expressive power in the quasitopos setting to generate any rewrite relation generated by the PBPO, AGREE [5,7], or DPO [8] rewrite formalisms, while the converse statements are not true. Thus, in this setting, PBPO + can be viewed as a unifying theory, additionally enabling the definition of new rewrite relations.
In Section 6, we adopt a more applied perspective, and show that PBPO + easily lends itself for rewriting labeled graphs and certain attributed graphs. To this end, we define a generalization of the usual category of labeled graphs, Graph (L,≤) , in which the set of labels forms a complete lattice (L, ≤). Not only does the combination of PBPO + and Graph (L,≤) enable constraining and transforming the patch graph in flexible ways, it also allows naturally modeling notions of relabeling, variables and sorts in rewrite rules. As we will clarify in the Discussion (Section 7), such mechanisms have typically been studied in the context of Double Pushout (DPO) rewriting [8], where the requirement to construct a pushout complement leads to technical complications and restrictions. This paper extends the paper presented at ICGT2021 [9]. In the conference paper, we showed that in the setting of toposes, PBPO + can define all rewrite relations definable by PBPO [9,Section 4.3]. For the present extension, we have generalized this result to quasitoposes (additionally improving the proof), and integrated it into the wider quasitopos study provided in Section 5, which is completely new material. Additionally, we have improved the proofs and presentation in Section 3, and we relate category Graph (L,≤) to the category of fuzzy sets in Section 5.
Remark 1. We have recently published a gentle tutorial on PBPO + [10], targeted especially to readers unacquainted with category theory.
The following well-known lemma (also known as the pasting law for pullbacks) is used frequently throughout the paper. A graph is unlabeled if L is a singleton. A premorphism between graphs G and G ′ is a pair of maps Definition 5 (Category Graph [13]). The category Graph has graphs as objects, parameterized over some global (and usually implicit) label set L, and homomorphisms as arrows.
Remark 6. Graph can also be obtained as a slice of a presheaf category (see Corradini et al. [7, for details), by virtue of which one immediately obtains that it is a topos, and hence a quasitopos.
The definition below formally fixes some graph terminology (see Section 1).
Definition 7 (Patch Decomposition [1]). Given a premorphism x : X → G, we call the image M = im(x) of x the match graph in G, G − M the context graph C induced by x (i.e., C is the largest subgraph disjoint from M ), and the set of edges E G − E M − E C the set of patch edges (or simply, patch) induced by x.

PBPO +
We introduce PBPO + , which strengthens the matching mechanism of PBPO [2]. In Section 4, we compare the two approaches in detail.
L is the lhs pattern of the rule, L ′ its (context) type and t L the (context) typing of L. Similarly for the interface K. R is the rhs pattern or replacement for L.
We often depict the pushout shows the schematic effect of applying the rewrite rule. We reduce the opacity of R ′ to emphasize that it is not part of the rule definition.
Example 9 (Rewrite Rule in Graph). A simple example of a rule for unlabeled graphs is the following: In this and subsequent examples a vertex is a non-empty set {x 1 , . . . , x n } represented by a box x 1 · · · x n ; and each morphism ϕ For notational convenience, we will usually use examples that ensure uniqueness of each ϕ (in particular, we ensure that ϕ E is uniquely determined). Colors are purely supplementary, and elements in L ′ and K ′ have reduced opacity if they do not lie in the images of t L and t K , respectively.
Definition 10 (Strong Match). A match morphism m : L → G L and an adherence morphism α : G L → L ′ form a strong match for a context typing Remark 11 (Preimage Interpretation). In both Set and Graph, and many other categories of structured sets, the strong match diagram of Definition 10 states that the preimage of t L (L) under α : Proposition 12. Assume C has pullbacks. Let a strong match as in Definition 10 be given. Then m is monic iff t L is monic.
Proof. If t L is monic, monicity of m follows by pullback stability. For the other direction, assume m is monic. Suppose t L • x = t L • y for a parallel pair of morphisms x, y : the two pullback squares compose by the pullback lemma. Hence there exist a unique z such that 1 X = 1 X • z = z and m • y = m • x • z. Hence z can be canceled and m • y = m • x. By monicity of m, x = y. Thus t L is monic.

⊓ ⊔
Because of Proposition 12, if match morphisms m are required to be monic (as often is the case), rules with non-monic t L will not give rise to strong matches, and so will not give rise to rewrite steps.

Proposition 13 (Unique First Factor). In any category, if diagrams
Proof. The universal morphism obtained from the pullback square is 1 A . ⊓ ⊔ Proposition 13 implies that because of the strong match property, m is uniquely defined by α and t L . However, in practice it is usually more natural to first fix a match m, and to subsequently verify whether it can be extended into a suitable adherence morphism. For certain choices of t L , α may moreover be uniquely determined by m (if it exists). See Theorem 49 for an example.
In reading the following definition, it may be helpful to refer to Example 17 alongside it.
Definition 14 (PBPO + Rewrite Step). A PBPO + rewrite rule ρ (left), a match morphism m : L → G L and an adherence morphism α : PBPO + G R on arbitrary G L and G R if the properties indicated by the commuting diagram (right) It can be seen that the rewrite step diagram consists of a match square, a pullback square for extracting (and possibly duplicating) parts of G L , and finally a pushout square for gluing these parts along pattern R.
We must prove that there indeed exists a unique u such that t K = u ′ u in the rewrite step diagram. The following lemma establishes this and two other facts.
Lemma 15 (On u). In any category, let the pullback of the rewrite rule and the pullbacks of the rewrite step be given. Then there exists a unique morphism u : K → G K satisfying t K = u ′ • u. Moreover, the following properties hold: are pullbacks; and 2. if m or t K is monic, then u is monic.
Proof. Consider the commuting diagram where morphism u satisfying t K = u ′ • u and m • l = g L • u is inferred by the universal property of the bottom square. Because the outer square is the pullback of the rewrite rule, m • l = g L • u is a pullback by the pullback lemma. Moreover, this shows that monicity of u follows from monicity of t K (g • f is monic ⇒ f is monic) or monicity of m and pullback stability. The accumulated squares can be represented as the commutative cube which shows that square t K •1 K = t K = u•u ′ is a pullback square by Corollary 3. Finally, because it is a pullback square, it follows from Proposition 13 that for Definition 14. Then in the rewrite step diagram, there exists a morphism w ′ : G R → R ′ such that t R = w ′ • w, and Proof. The argument is similar to the initial part of the proof of Lemma 15, but now uses the dual statement of the pullback lemma.
which will guide our depictions of rewrite steps. We will omit the match diagram in such depictions.
Example 17 (Rewrite Step). Applying the rule given in Example 9 to G L (as depicted below) has the following effect: This example illustrates (i) how permitted patches can be constrained (e.g., L ′ forbids patch edges targeting y), (ii) how patch edge endpoints that lie in the image of t L can be redefined, (iii) how patch edges can be deleted, and (iv) how patch edges can be duplicated.
In the examples of this section, we have restricted our attention to unlabeled graphs. In Section 6, we introduce a new category Graph (L,≤) , and show that is more suitable than Graph for rewriting labeled graphs using PBPO + . Section 6 can largely be read independently of Sections 4 and 5, which situate PBPO + and are more foundational in character.

Relating PBPO + and PBPO
In Section 4.1, we recall and compare the PBPO definitions for rule, match and step, clarifying why PBPO + is shorthand for PBPO with strong matching. We then argue why strong matching is usually desirable in Section 4.2.

PBPO: Rule, Match & Step
Definition 18 (PBPO Rule [2]). A PBPO rule ρ is a commutative diagram as shown on the right. The bottom span can be regarded as a typing for the top span. The rule is in canonical form if the left square is a pullback and the right square is a pushout.
Every PBPO rule is equivalent to a rule in canonical form [2], and in PBPO + , rules are limited to those in canonical form.
The pullback construction used to establish a match in PBPO + (Definition 10) implies t L = α • m. Thus PBPO matches are more general than the strong match used in PBPO + (Definition 10). More specifically for Graph, PBPO allows mapping elements of the host graph G L not in the image of m : L → G L onto the image of t L , whereas PBPO + forbids this. In the next subsection, we will argue why it is often desirable to forbid such mappings.

Definition 20 (PBPO Rewrite
Step [2]). A PBPO rule ρ (as in Defini- where (i) u : K → G K is uniquely determined by the universal property of pullbacks and makes the top-left square commuting, and (ii) w ′ : G R → R ′ is uniquely determined by the universal property of pushouts and makes the bottomright square commuting, and (iii) t L = α • m.
The strong match square of PBPO + allows simplifying the characterization of u, as shown in the proof to Lemma 15. This simplification is not possible for PBPO (see Remark 21). The bottom-right square is omitted in the definition of a PBPO + rewrite step, but can be reconstructed through a pushout (modulo isomorphism). So this difference is not essential.
Remark 21. In a PBPO rewrite step, not every morphism u : K → G K satisfying u ′ • u = t K corresponds to the arrow uniquely determined by the top-left pullback. This can be seen in the example of a (canonical) PBPO rewrite rule and step depicted in: Because our previous notational convention breaks for this example, we indicate two morphisms by dotted arrows. The others can be inferred. Morphism u : K → G K (as determined by the top-left pullback) is indicated. However, it can be seen that three other morphisms v :

The Case for Strong Matching
The two following examples serve to illustrate why we find it necessary to strengthen the matching criterion when matching is not controlled.
Example 22. In PBPO + , an application of the rule in an unlabeled graph G L removes a loop from an isolated vertex that has a single loop, and preserves everything else. In PBPO, a match is allowed to map all of G L into the component determined by vertex {x}, so that the rule deletes all of G L 's edges at once. (Before studying the next example, the reader is invited to consider what the effect of the PBPO rule is if R and R ′ are replaced by L and L ′ , respectively.) Example 23. Consider the following PBPO rule application to a host graph G L (the morphisms are defined in the obvious way). Intuitively, host graph G L is spiralled over the pattern of L ′ . The pullback then duplicates all elements mapped onto x ∈ V L ′ and any incident edges directed at a node mapped into y ∈ V L ′ . The pushout, by contrast, affects only the image of u : The two examples show how locality of transformations cannot be enforced using PBPO. They also illustrate how it can be difficult to characterize the class of host graphs G L and adherences α that establish a match, even for trivial left-hand sides. Finally, Example 23 in particular highlights an asymmetry that we find unintuitive: if one duplicates and then merges/extends pattern elements of L ′ , the duplication affects all elements in the α-preimage of t L (L) (which could even consist of multiple components), whereas the pushout affects only u(K) ⊆ G K . In PBPO + , by contrast, transformations of the pattern affect the pattern only, and the overall applicability of a rule is easy to understand if the context graph is relatively simple (e.g., as in Example 17).

Remark 24 (Γ -preservation).
A locality notion has been defined for PBPO called Γ -preservation [2]. Γ is some subobject of L ′ , and a rewrite step roughly meaning that this preimage is neither modified nor duplicated). Similarly, a rule is Γ -preserving if the rewrite steps it gives rise to are Γ -preserving. If one chooses Γ to be the context graph (the right component) of L ′ in Example 22, then the rule, interpreted as a PBPO rule, is Γ -preserving. Nonetheless, PBPO does not prevent the mapping of arbitrarily large parts of the context graph of G L onto the image of t L (in Example 22, the left component of L ′ ) which usually is modified. In this sense, the rule can still give rise to nonlocal effects.

PBPO + as a Unifying Theory for Quasitoposes
For this section, we need the following vocabulary.
Some of the most well-known graph rewriting formalisms include DPO [8], SPO [14], SqPO [15] and AGREE [5,7]. In the conference version of this paper [9], we conjectured that in Graph and with monic matching, which implies conflictfreeness of SPO matches, holds, and that the other comparisons do not hold. In this diagram, the claims AGREE ≺ PBPO + and DPO ≺ PBPO + were the two open ones: the claim PBPO ≺ PBPO + was established in the conference paper for toposes [9, Lemma 32] (and thus in particular for Graph), and SPO ≺ SqPO [15,Proposition 13] and SqPO ≺ AGREE [5, Theorem 2] were known for categories more general than Graph in the literature.
The main contribution of this section is that we establish Diagram (1) (but without SPO: see Remark 26 below) much more generally: namely, for C any quasitopos, and assuming regular monic matching (Theorem 73). Of these claims, only SqPO ≺ AGREE follows as a corollary of the previously cited theorem [5, Theorem 2]. Quasitoposes include not only the categories of sets, directed multigraphs [4] and typed graphs [5] (all of which are toposes), but also a variety of structures such as Heyting algebras (considered as categories) [3], and the categories of simple graphs (equivalently, binary relations) [6], fuzzy sets [3], algebraic specifications [6] and safely marked Petri Nets [6]. Behr et al. [16] recently proposed quasitoposes as a natural setting for non-linear rewriting.
This section is structured as follows. In Section 5.1 we provide all the required definitions and results pertaining to quasitoposes. We then first prove a useful sufficient condition for determinism of PBPO + rules in Section 5.2. This result is independent of the main result of this section. Next, we work towards the main result, establishing PBPO ≺ PBPO + , AGREE ≺ PBPO + and DPO ≺ PBPO + for quasitoposes in Sections 5.3, 5.4 and 5.5, respectively.
Remark 26 (Modeling SPO). Deciding SPO ≺ PBPO + for quasitoposes (with regular monic matching) appears relatively involved due to the fact that SPO is defined for partial morphisms, rather than total ones. For this reason, we consider the question to be beyond the scope of the present paper. However, we conjecture that for any SPO rule, which is a partial morphism ρ : L ⇀ R, the PBPO + rule models it, where the top span is the span representation of ρ (Definition 29), and the hooked arrows → are regular monomorphisms. For the meaning of the given pullback square, see the M-partial map classifier definition (Definition 30).

Remark 27 (Double Pullback Rewriting).
There also exists the double pullback rewriting (DPU) approach by Bauderon [17] and Bauderon and Jacquet [18]. As a first approximation, a double pullback rule ρ is of the form L l → A r ← R; a match is a morphism m : G → L; and a step from G to H is given by a diagram where (q, u) is a pullback complement. On top of this, constraints on rules, occurrences and steps are added in order to make the method well-behaved. The constraints are rather technical and vary slightly between [17] and [18]. We have provided a detailed comparison between PBPO + and DPU in a recent PBPO + tutorial [10]. The most relevant conclusion is that although DPU uses pullbacks (which are generic), the details are defined for slice categories of simple graphs [18,Definition 3], and it is not clear to what extent these can be generalized (let alone be generalized to (quasi)toposes). So it is not evident how DPU can be fit into the general picture.

Quasitoposes
The following definitions on M-partial map classification derive from work by Cockett and Lack on restriction categories [19,20], but we follow the presentations of Corradini et al. [5] and Behr et al. [16].
Definition 28 (Stable System of Monics [19]). A stable system of monics M in C is a class of monos in C that includes all isomorphisms, is closed under We use → to denote M-monos.
Examples of stable systems of monics in any category include the class of all monos and the class of all isomorphisms.
Consider how in set theory, any partial function g : A ⇀ B with domain A ′ ⊆ A can be represented by a total injective function m : X ↣ A (typically an inclusion) and total function f : The following definition is the categorical generalization of this idea.
Definition 29 (M-Partial Map). Let M be a stable system of monics. An Alternatively in set theory, one can extend set B to B ⋆ = B ⊎ {⋆}, where ⋆ represents undefined elements. Then any partial map g : This extension is minimal in the sense that The following definition is the categorical generalization of this idea.
Definition 30 (M-Partial Map Classifier [5]). Let M be a stable system of monics in C. An M-partial map classifier (T, η) in C consists of a functor T : C → C and a natural transformation η : Example 31. As explained in the running text above, in Set there exists a monopartial map classifier (T, η) with T (B) = B ⊎ {⋆} and η B the inclusion.
In the category of unlabeled directed graphs, there exists a mono-partial map if e ∈ E and π 1 (e) otherwise; and t ⋆ (e) = t(e) if e ∈ E and π 2 (e) otherwise (π i the i'th projection). An example is given by where the dotted edges represent the edges e ∈ V ⋆ × V ⋆ . It can be seen that for any partial homomorphism ψ : → G a partial map span representation of ψ, and η G and m are inclusions.
The generalization to labeled graphs is straightforward: between any two nodes u, v ∈ V ⋆ and l ∈ L, there is one l-labeled edge representing an undefined l-edge between u and v.
The following two definitions are standard in algebraic graph rewriting. Recall that a monomorphism is regular if it is an equalizer for a parallel pair of morphisms. We write rm(C) to denote the class of regular monomorphisms of a category C.
Definition 35 (Quasitopos [3,22,23]). A category C is a quasitopos if it has all finite limits and colimits, it is locally cartesian closed, and it has a regularsubobject classifier.
In this paper we rely on various results about quasitoposes: the notions of local cartesian closure and regular-subobject classifier will not be used directly, and therefore need not be understood. We could have equivalently defined quasitoposes in terms of regular-partial map classifiers and additional properties [3,22], but because these definitions appear less standardized, we decided against it.
The following results for quasitoposes will be used throughout the section. We cite original sources, but stress our indebtedness to the summary provided by Behr  Example 38 (Simple Graphs). The category of simple graphs SimpleGraph has pairs of sets G = (V, E) with E ⊆ V × V as objects, and the usual graph homomorphisms ψ as arrows. SimpleGraph is not a topos, but it is a quasitopos (see, e.g., [16, Section 2.1]). The regular monos of SimpleGraph are injective homomorphisms that reflect edges (i.e., for regular monos ψ : G → H, (ψ(v), ψ(w)) ∈ E H implies (v, w) ∈ E G ). A modeling example using simple graphs can be found in [ S. Any complete lattice has a global maximum ⊤ and global minimum ⊥, respectively.
A complete lattice L is infinitely distributive if holds for all x ∈ L and S ⊆ L.
Observe that pullbacks and pushouts in a complete lattice, considered as a category, correspond to meets and joins, respectively. The regular monos in a complete Heyting algebra L are exactly the identities. So the regular mono-partial map classifier is not very interesting. However, some toposes can be endowed with a complete Heyting algebra as in the following definition, which gives rise to more interesting classifiers.
Example 41 (L-Fuzzy Set [3, Chapter 8], [26]). An L-fuzzy set (A, α) consists of a set A and a membership function α : A → L, where L is a complete lattice. An L-fuzzy set morphism from (A, α) to (B, β) is a function ϕ : A → B such that α(x) ≤ β • ϕ(x) for all x ∈ A. L-fuzzy sets have been well studied, in particular in the context of fuzzy logics.
The regular monomorphisms in the category of L-fuzzy sets are the L-fuzzy set morphisms ϕ that preserve membership (i.e., α(x) = β • ϕ(x)). The category of L-fuzzy sets is known to be a quasitopos if L is a complete Heyting algebra (see Stout [27,Corollary 8] and Goguen [26,Proposition 4]). The regular mono-partial map classifier (T, η) then sends sets S = (A, α) to T (S) = (A ⊎ {⋆}, α ∪ {(⋆ → ⊤)}), with η S : S → T (S) the inclusion. An example of how this can be used to redefine the membership of an element using PBPO + is given by where a, b, c, ⋆ are set elements, and superscripts denote membership values in L. Morphisms α and u ′ map b and c onto ⋆; all other elements are mapped by way of inclusion. The rule can be seen to change the fuzziness of an element with fuzziness x to u, in any context. The context is not changed.
Rewriting fuzzy sets is only slightly more interesting than rewriting sets. But in Section 6, we define the category Graph (L,≤) , which is essentially the category of "fuzzy graphs" (Example 41), and argue that it is a very useful graph category for modeling and relabeling. We have proven very recently that this category is a quasitopos if L is a complete Heyting algebra [28].

Determinism
For this subsection, we need the following definition.
for any G L , G R , G ′ R ∈ Obj(C), match morphism m : L → G L and adherence morphisms α, β : G L → L ′ .
By uniqueness of (co)limits, it is easy to see that in any category C, PBPO + rewriting is deterministic, if, for any match morphism m : L → G L , there exists at most one adherence morphism α : G L → L ′ that establishes a strong match square. In the setting where C is a quasitopos, we define the following concept, which we can use to prove a more useful sufficient condition on the type morphism t L . Proof. Let α and β each make the left square of a pullback square. Because the right square is a pullback square, both t L α and t L β make the outer square a pullback square, using the pullback lemma. By the uniqueness property of the partial map classifier, t L α = t L β. By monicity of t L , α = β.

⊓ ⊔
Definition 48 (Classifying PBPO + Rule). A PBPO + rule ρ is said to be We can now state the following sufficient condition. Note that in categories with strict initial objects (such as Set and Graph), another sufficient condition for determinism is having K ′ initial. Then the result of any rewrite step is R. This observation implies that necessary conditions for determinism cannot be phrased merely in terms of type graphs and matching.
Remark 50. For some categories, we conjecture that a sufficient condition for determinism of a rule ρ (with type morphism t L : L ↣ L ′ ) is the case where there exists a commuting diagram for some restricted classifier x : L → L ′′ , and monic and epic morphism f : L ′′ → L ′ . For instance, in category Graph (L,≤) (Section 6), this property corresponds to relaxing the labels of a restricted classifier x : L → L ′′ . We are interested in knowing in which classes of categories this property holds.

PBPO + Models PBPO
In the conference version of the present paper, we proved that in any topos, any PBPO rule can be modeled by a class of PBPO + rules [9, Corollary 1]. In this subsection, we generalize this result to the setting of quasitoposes (any topos is a quasitopos). Additionally, we streamline the original proof significantly. In order to prove our result, we first need to establish a technical result about slice categories C/X. We let (A, f : A → X) denote the objects of C/X; and U X the forgetful functor U X : C/X → C.
Proposition 51 ([3, (17.3, Remarks)]). Let f be a morphism in C/X. We have 1. f is monic ⇐⇒ U X f is monic; 2. if C has finite products, then: f is epic ⇐⇒ U X f is epic; and 3. if f is a regular mono, then U X f is a regular mono.
⊓ ⊔ Wyler additionally remarks the following for categories C with finite products: if a morphism U X f : A → X is a regular mono in C, then the morphism f : (A, f ) → (X, 1 X ) is a regular mono in C/X [3, (17.3, Remarks)]. We prove that U X in fact reflects all regular monomorphisms, i.e., that if U X f is a regular mono (with any codomain) in C, then so is f in C/X (Corollary 56 below).
again using Proposition 52. We then obtain the unique u : A ′ → A such that f u = f ′ from the fact that f is an equalizer for g and h. In a diagram: Proposition 54. Let f : (A, a) → (B, b) and g, h : (B, b) → (C, c) be morphisms in C/X. If U X f is an equalizer for U X g, U X h in C, then f is an equalizer for g, h in C/X.
Proof. First, gf = hf in C/X because U X f is an equalizer for U X g, U X h in C, and composition is lifted from C. For universality, suppose gf ′ = hf ′ for some f ′ : (A ′ , a ′ ) → (B, b) in C/X. By definition of the slice category and its forgetful functor, and so one obtains a unique arrow u : a) is an arrow in C/X. Uniqueness in C/X follows because any other arrow would violate the uniqueness property on the level of C.
In a diagram, where solid and dashed arrows represent respectively objects and morphisms in C/X: Proposition 55. If C has finite products and U X f : A → B is an equalizer for g, h : B → C in C, then f is an equalizer for ⟨1 B , g⟩, ⟨1 B , h⟩ : Proof. Observe that morphisms g and h may not give rise to morphisms in C/X. However, by hypothesis, we can construct the product B × C in C. From this we can infer the morphism b • π 1 : B × C → X and the product maps ⟨1 B , g⟩, ⟨1 B , h⟩ : B → B × C. Crucially, b • π 1 is an object in C/X and the product maps are morphisms in C/X, By Proposition 53, U X f is an equalizer for the product maps in C. By Proposition 54, f is an equalizer for the product maps in C/X. ⊓ ⊔ Corollary 56. If C has finite products and X ∈ Obj(C), then U X reflects regular monomorphisms. Proof.
Let U X f : A → B be a regular monomorphism in C. By definition this means U X f is an equalizer for some g, h : B → C in C. By Proposition 55, f is an equalizer for ⟨1 B , g⟩, ⟨1 B , h⟩ : Proposition 58. If all slice categories C/X of a category C have M-partial map classifiers and the forgetful functor U X : C/X → C reflects and preserves M-morphisms, then C has all M-materializations.
Proof. The proof is analogous to the proof of Corradini et al. for M the class of all monos, available on arXiv [31]. The difference is that we require reflection and preservation of M-morphisms, rather than relying implicitly on these properties for monos.
Proof. Using Corollary 56 and Proposition 58, the fact that quasitoposes have rm-partial map classifiers, and the fact that the quasitopos property is stable under slicing.

⊓ ⊔
Definition 60 (Compacted Rule). Let C be a quasitopos. For any canonical PBPO rule ρ and any factorization t L = f • e where e is epic (note that f is uniquely determined by e, because e is right-cancellative), the compacted PBPO + rule ρ e is defined as the bold subdiagram of where the outer diagram is rule ρ, and L e Theorem 61. Let C be a quasitopos. For any canonical PPBO rule ρ with type morphism t L : L → L ′ , the class of PBPO + rules compact(ρ) models it, that is, → ⟨f ⟩ f ′′ → L ′ be its materialization. Then by the materialization property, there exists a unique β : G L → ⟨f ⟩ such that f ′ = βm ′ is a pullback and α = f ′′ β commutes. The middle two rows of diagram show that the pullback f ′ = βm ′ defines a strong match and therefore a step PBPO + G R for rule ρ e ∈ compact(ρ).
⊇: We start with the middle two rows of the diagram of direction ⊆, and with f ′ = βm ′ a pullback. Observe that m ′ is necessarily regular by regular monicity of f ′ and pullback stability of regular monos. Then from the definition of ρ e it is immediate that the outer diagram defines a PBPO step using rule ρ, match m and adherence morphism α.
⊓ ⊔ Definition 62. We let PBPO → denote the rewriting framework obtained by modifying PBPO to allow regular monic matches only. That is, PBPO G R and m is a regular mono.
Proof. For any (epi, regular mono)-factorization m = m ′ e of a regular mono m, e is a regular mono (Proposition 36), and hence an isomorphism (Proposition 37). Thus one can specialize the claim and proof of Theorem 61 to compact ∼ = (ρ) rather than compact(ρ).
1. There exists a single PBPO + rule τ such that ⇒ ρ PBPO → = ⇒ τ PBPO + . 2. If t L of ρ is a regular mono, then there exists a single PBPO + rule τ such that ⇒ ρ PBPO = ⇒ τ PBPO + . Proof. For the first claim, we are left with only one rule after identifying all isomorphic objects in the category. For the second claim, if t L of ρ is a regular mono, then for all strong matches t L = αm, m is a regular mono by pullback stability. Thus ⇒ ρ PBPO = ⇒ ρ PBPO → , and the first claim can be applied. ⊓ ⊔

PBPO + Models AGREE
AGREE is short for "Algebraic Graph REwriting with controlled Embedding" and is a rewriting framework introduced by Corradini et al. [5,7]. In categories where both SqPO and AGREE are applicable, AGREE can roughly be thought of as adding a filtering mechanism on top of the cloning operations that were originally introduced by SqPO. Moreover, an interesting technical aspect of AGREE is that it was the first formalism to utilize partial map classifiers for the definition of rewrite steps.
Definition 65 (AGREE Rewriting [5,7]). Assume C has M-partial map classifiers for a stable system of monics M. An AGREE rewrite rule is of the form , it is a step from object G L to object G R induced by rule ρ and match morphism m : L → G L .
The proposition below is stated for M the class of all monos in [2].

Proposition 66 (Relating AGREE and PBPO [2, Proposition 3.1]).
Assume C has M-partial map classifiers for a stable system of monics M. In the diagram let the bold subdiagram depict an AGREE rule ρ, and the entire diagram a PBPO rule ρ PBPO , where the right square is a pushout. Then for any match m ∈ M,

⊓ ⊔
Observe that Proposition 66 relies on a particular choice of adherence morphism α = m. Thus it does not establish that PBPO models AGREE. In fact, we have the following.
Proposition 67. In Graph with M the class of all monos, AGREE ̸ ≺ PBPO.
Proof. The AGREE rule ρ given by matches and deletes a single node x and any of its incident edges, in any context. The context itself is preserved. Given the depicted G L and match m, the depicted α = m : G L → T (L) is by definition the only possible adherence morphism. By contrast, PBPO allows an adherence morphism that maps y onto x, so that G K and G R are both empty. So ⇒ ρ PBPO ,m PBPO ̸ ⊆ ⇒ ρ,m AGREE . Moreover, it is easy to see that the problem cannot be avoided by redefining the interpretation, because any redefinition will necessarily have x in L ′ , with x deleted in K ′ .
⊓ ⊔ Similar arguments can be constructed for other categories satisfying the conditions of Proposition 66, including Set. For PBPO + , however, we have the following result.
Proposition 68 (Relating AGREE and PBPO + ). Assume C has M-partial map classifiers for a stable system of monics M. In the diagram let the bold subdiagram depict an AGREE rule ρ, and the entire diagram a PBPO + rule ρ PBPO + . Then for any match m ∈ M and adherence α estab- Proof. By virtue of the partial map classifier, m is the only adherence morphism establishing a strong match for PBPO + .

PBPO + Models DPO
The Double Pushout (DPO) approach to graph rewriting by Ehrig et al. [8] is one of the earliest and most well studied algebraic graph rewriting methods.
Definition 70 (DPO Rewriting [8]) defines a DPO rewrite step G L ⇒ ρ,m DPO G R , i.e., a step from G L to G R using rule ρ and match morphism m : L → G L .
Definition 71 (DPO as PBPO + ). Let C be a category with M-partial map classifiers, in which pushouts along M-morphisms exist, are pullbacks, and where M-morphisms are stable under pushout.
In the diagram let the top span depict a DPO rule ρ, and the left square a pushout (which is a pullback). Then the entire diagram defines a PBPO + rule ρ PBPO + .
Theorem 72 (PBPO + Models DPO). Let C be a quasitopos. Then for any DPO rule ρ, ρ PBPO + is well-defined, and for any M-morphism m : L → G L , Proof. Well-definedness of ρ PBPO + follows from Definition 33, Lemma 34, and the fact that any quasitopos is M-adhesive for M = rm(C). Direction ⊆: Suppose that is a DPO step induced by ρ. Then by Lemma 34, the left square is a pullback, and by stability of M-morphisms under pushout and pullback, u, g L ∈ M.
Because u ∈ M, we obtain the classifying arrow u : G K → T (K) that makes the square u • u = η K • 1 K a pullback. Additionally, from the pushout property of the top left square, we obtain a unique morphism α : G L → L ′ satisfying t L = α • m and α • g L = l ′ • u: By the dual of the pullback lemma, it follows that the bottom left commuting square is a pushout. Because it is a pushout along an M-morphism, it is also a pullback.
It remains to show that square t L •1 L = α•m is a pullback. For this, consider the cubical arrangement in which the bottom square is a pushout along an M-morphism, the back faces are pullbacks and the top square is a pushout. By M-adhesivity, the bottom square is an M-VK square. From this it follows that the front face is a pullback square. Thus Diagram (2) defines a PBPO + step. Direction ⊇: We are given a PBPO + step where the pullback squares can be represented as the commutative cube By Lemma 15, we know that the back face is a pullback square. Because the floor is a pushout, and the vertical faces are all pullbacks, it follows that the top face of the cube is a pushout, using the fact that pushouts are stable under pullback in rm-quasiadhesive categories. Unless one employs a meta-notation or restricts to unlabeled graphs, as we did in Section 3, it is sometimes impractical to use PBPO + in the category Graph.
The following example illustrates the problem.
Example 75. Suppose the set of labels is L = {0, 1}. To be able to injectively match pattern L = 0 0 1 in any context, one must inject it into the type graph L ′ shown on the right in which every dotted loop represents two edges (one for each label), and every dotted non-loop represents four edges (one for each label, in either direction). For general L, to allow any context, one needs to include |L| additional vertices in L ′ , and |L| complete graphs over V L ′ .
1 0 0 0 1 Beyond this example, and less easily alleviated with meta-notation, in Graph it is impractical or impossible to express rules that involve (i) arbitrary labels (or classes of labels) in the application condition; (ii) relabeling; or (iii) allowing and capturing arbitrary subgraphs (or classes of subgraphs) around a match graph. As we will discuss in Section 7, these features have been non-trivial to express in general for algebraic graph rewriting approaches.
We define a category which allows flexibly addressing all of these issues. Recall the definition of a complete lattice (Definition 39).
Definition 76 (Graph (L,≤) ). For a complete lattice (L, ≤), we define the category Graph (L,≤) , where objects are graphs labeled from L, and arrows are graph premorphisms ϕ : In terms of graph structure, the pullbacks and pushouts in Graph (L,≤) are the usual pullbacks and pushouts in Graph. The only difference is that the labels that are identified by the cospan of the pullback (resp. span of the pushout) are replaced by their meet (resp. join).
Remark 77 (Fuzzy Graph Rewriting). The idea to label graphs using labels that form a complete lattice, for the purpose of rewriting, is not new. To the best of our knowledge, Mori and Kawahara were the first to propose this [32], using a single pushout construction. There also exists a series of papers by Parasyuk and Yershov, in which fuzzy graph transformations are studied using single pushouts [33] and double pushouts [34,35]. Because PBPO + rules have both a pattern span and a type span (unlike in the single and double pushout approaches), both lower and upper bounds can be specified on fuzzy values. Moreover, that fuzzy graphs lend themselves well for general relabeling purposes has not yet been observed.
Remark 78. Analogous to the situation for L-fuzzy sets (Example 41), we have proven very recently that Graph (L,≤) is a quasitopos if L is a complete Heyting algebra [28].
One very simple but useful complete lattice is the following.
Definition 79 (Flat Lattice). Let L ⊥,⊤ = L ⊎ {⊥, ⊤}. We define the flat lattice induced by L as the poset (L ⊥,⊤ , ≤), in which ⊥ < l < ⊤ for all l ∈ L are the only non-trivial relations. Here, we refer to L as the base label set.
One feature flat lattices provide is a kind of "wildcard element" ⊤.
Example 80 (Wildcards). Using flat lattices, L ′ of Example 75 can be fully expressed for any base label set L ∋ 0, 1 as shown on the right (node identities are omitted). The visual syntax and naming shorthands of PGR [1] (or variants thereof) could be leveraged to simplify the notation further. As the following example illustrates, the expressive power of a flat lattice stretches beyond wildcards: it also enables relabeling of graphs. (Henceforth, we will depict a node x with label u as x u .) Example 81 (Relabeling). As vertex labels we employ the flat lattice induced by the set { a, b, c, . . . }, and assume edges are unlabeled for notational simplicity. The diagram displays a rule (L, L ′ , K, K ′ , R) for overwriting an arbitrary vertex's label with c, in any context. The middle row is an application to a host graph G L .
Example 81 demonstrates how (i) labels in L serve as lower bounds for matching, (ii) labels in L ′ serve as upper bounds for matching, (iii) labels in K ′ can be used to decrease matched labels (in particular, ⊥ "instructs" to "erase" the label by overwriting it with ⊥, and ⊤ "instructs" to preserve labels), and (iv) labels in R can be used to increase labels. First erasing a label in K ′ and then increasing it using another label in R effectively establishes an arbitrary relabeling from Complete lattices also support modeling sorts.
Example 82 (Sorts). Let p 1 , p 2 , . . . ∈ P be a set of processes and d 1 , d 2 , . . . ∈ D a set of data elements. Assume a complete lattice over labels P ∪ D ∪ {P, D, £, @}, arranged as in the diagram ∀i ∈ N : Moreover, assume that the vertices x, y, . . . in the graphs of interest are labeled with a p i or d i , and that edges are labeled with a £ or @. In such a graph, an edge x di @ − → y pj encodes that process p j holds a local copy of datum d i (x will have no other connections); and a chain of edges x pi £ − → y d k £ − → z d l £ − → · · · £ − → u pj encodes a directed FIFO channel from process p i to process p j ̸ = p i , containing a sequence of elements d k , d l , . . .. An empty channel is modeled as x pi £ − → u pj .
Receiving a datum through an incoming channel (and storing it locally) can be modeled using the following rule: The rule illustrates how sorts can improve readability and provide type safety. For instance, the label D in L ′ prevents empty channels from being matched.
More precisely, always the last element d of a non-empty channel is matched. K ′ duplicates the node holding d: for duplicate x 1 , the label is forgotten but the connection to the context retained, allowing it to be fused with y; and for x 2 , the connection is forgotten but the label retained, allowing it to be connected to y as an otherwise isolated node.
Finally, a very powerful feature provided by the coupling of PBPO + and Graph (L,≤) is the ability to model a general notion of variable, used for matching (possibly disjoint) parts of the context. This is achieved by using multiple context nodes in L ′ (i.e., nodes not in the image of t L ).
Example 83 (Variables). The rule f (g(x), y) → h(g(x), g(y), x) on ordered trees can be precisely modeled in PBPO + by the rule if one restricts the set of rewritten graphs to straightforward representations of trees: nodes are labeled by symbols, and edges are labeled by n ∈ N, the position of its target (argument of the symbol).
In another paper [36], we developed the idea of Example 83 further, and showed that any linear term rewriting system R can be faithfully represented by a PBPO + graph rewrite system encoding E(R), with the additional property that R terminates iff E(R) terminates on finite graphs [36, Theorem 62].

Discussion
We discuss our rewriting (Section 7.1) and relabeling (Section 7.2) contributions in turn.

Rewriting
Other graph rewriting approaches that bear certain similarities to PBPO + (see also the discussion in [2]) include the double-pullout graph rewriting approach by Kahl [37]; the cospan SqPO approach by Mantz [38,Section 4.5]; and the recent drag rewriting framework by Dershowitz and Jouannaud [39]. Double-pullout graph rewriting also uses pullbacks and pushouts to delete and duplicate parts of the context (extending DPO), but the approach is defined in the context of collagories [40], and to us it is not yet clear in what way the two approaches relate. Cospan SqPO can be understood as being almost dual to SqPO: rules are cospans, and transformation steps consists of a pushout followed by a final pullback complement. An interesting question is whether PBPO + can also model cospan SqPO. Drag rewriting is a non-categorical approach to generalizing term rewriting, and like PBPO + , allows relatively fine control over the interface between pattern and context, thereby avoiding issues related to dangling pointers and the construction of pushout complements. Because drag rewriting is noncategorical and drags have inherently more structure than graphs, it is difficult to relate PBPO + and drag rewriting precisely. These could all be topics for future investigation.
Let us note that the combination of PBPO + and Graph (L,≤) does not provide a strict generalization of Patch Graph Rewriting (PGR) [1], our conceptual precursor to PBPO + (Section 1). This is because patch edge endpoints that lie in the context graph can be redefined in PGR (e.g., the direction of edges between context and pattern can be inverted), but not in PBPO + . Beyond that, PBPO + is more general and expressive. Therefore, at this point we believe that the most distinguishing and redeeming feature of PGR is its visual syntax, which makes rewrite systems much easier to define and communicate. In order to combine the best of both worlds, our aim is to define a similar syntax for (a suitable restriction of) PBPO + in the future.

Relabeling
The coupling of PBPO + and Graph (L,≤) allows relabeling and modeling sorts and variables with relative ease, and does not require a modification of the rewriting framework. Most existing approaches study these topics in the context of DPO, where the requirement to ensure the unique existence of a pushout complement requires restricting the method and proving non-trivial properties: -Parisi-Presicce et al. [41] limit DPO rules L ← K → R to ones where K → R is monic (meaning merging is not possible), and where some settheoretic consistency condition is satisfied. Moreover, the characterization of the existence of rewrite step has been shown to be incorrect [42], supporting the idea that pushout complements are not easy to reason about. -Habel and Plump [42] study relabeling using the category of partially labeled graphs. They allow non-monic morphisms K → R, but they nonetheless add two restrictions to the definition of a DPO rewrite rule. Among others, these conditions do not allow hard overwriting arbitrary labels as in Example 81. Moreover, the pushouts of the DPO rewrite step must be restricted to pushouts that are also pullbacks. Finally, unlike the approach suggested by Parisi-Presice et al., Habel and Plump's approach does not support modeling notions of sorts and variables. Our result that PBPO + can model DPO in Graph extends to this relabeling approach in the following sense: given a DPO rule over graphs partially labeled from L that moreover satisfies the criteria of [42], we conjecture that there exists a PBPO + rule in Graph (L ⊥,⊤ ,≤) that models the same rewrite relation when restricting to graphs totally labeled over the base label set L.
Later publications largely appear to build on the approach [42] by Habel and Plump. For example, Schneider [43] gives a non-trivial categorical formulation; Hoffman [44] proposes a two-layered (set-theoretic) approach to support variables; and Habel and Plump [45] generalize their approach to M, N -adhesive systems (again restricting K → R to monic arrows). Independent of Habel and Plump's approach, there also exists an approach for DPO by Kahl, in which attributed graphs are considered as coalgebras [46], providing support for relabeling operations. Relating Kahl's approach to ours is outside the scope of the present paper.
The transformation of attributed structures has been explored in a very general setting by Corradini et al. [2], which involves an elegant comma category construction and suitable restrictions of the PBPO notions of rewrite rule and rewrite step. We leave relating their and our approach to future work.