Theoretical Computer

The transformation of graphs and graph-like structures is ubiquitous in computer science. When a system is described by graph-transformation rules, it is often desirable that the rules are both terminating and conﬂuent so that rule applications in an arbitrary order produce unique resulting graphs. However, there are application scenarios where the rules are not globally conﬂuent but conﬂuent on a subclass of graphs that are of interest. In other words, non-resolvable conﬂicts can only occur on graphs that are considered as “garbage”. In this paper, we introduce the notion of conﬂuence up to garbage and generalise Plump’s critical pair lemma for double-pushout graph transformation, providing a suﬃcient condition for conﬂuence up to garbage by non-garbage critical pair analysis. We apply our results in two case studies about eﬃcient language recognition: we present backtracking-free graph reduction systems which recognise a class of ﬂow diagrams and a class of labelled series-parallel graphs, respectively. Both systems are non-conﬂuent but conﬂuent up to garbage. We also give a critical pair condition for subcommutativity up to garbage which, together with closedness, implies conﬂuence up to garbage even in non-terminating systems. © 2021 The Author(s). Published by Elsevier B.V. This is an open access article under the CC BY license (http://creativecommons.org/licenses/by/4.0/).


Introduction
Rule-based graph transformation and graph grammars date back to the late 1960s.The most developed theoretical framework is the so-called double-pushout (DPO) approach to graph transformation [1,2].When specifying systems in computer science by DPO graph transformation rules, it is often desirable that the rules are both terminating and confluent so that rule applications in an arbitrary order produce unique resulting graphs.For example, [3] contains 23 case studies of confluent and terminating graph reductions systems which specify pointer structures such as cyclic lists, balanced binary trees and red-black trees.Confluence is also important in the context of evaluating functional expressions by graph reduction, see for example [4].
However, there are application scenarios where the rules are not confluent but confluent on a subclass of graphs that are of interest.In other words, non-resolvable conflicts can only occur on graphs that are considered as "garbage".An example is the class of so-called extended flow diagrams discussed in Subsection 5.3.The reduction rules for these graphs give rise to ten critical pairs, nine of which are strongly joinable.But a single pair is not joinable and hence the rules are not confluent.The non-joinable pair represents a conflict in graphs containing a type of cycle that cannot occur in extended flow diagrams.Hence these graphs can be considered as garbage which in this case consists of all graphs that are not extended flow diagrams.
In this paper, we introduce the notions of confluence up to garbage and termination up to garbage in graph transformation.We generalise Plump's Critical Pair Lemma [5,6] and Newmann's Lemma [7] and thereby allow to check confluence up to garbage via non-garbage critical pair analysis.We apply our results to language recognition by backtracking-free graph reduction, showing how to establish that a graph language can be decided by a system which is confluent up to garbage.We present two case studies with backtracking-free graph reduction systems which recognise a class of labelled series-parallel graphs and a class of flow diagrams, respectively.Both systems are non-confluent but confluent up to garbage.
The rest of this paper is organised as follows.Section 2 reviews abstract reduction systems, graphs and morphisms, the double-pushout approach to graph transformation, graph languages, and confluence checking by critical pair analysis.In Section 3, confluence up to garbage and closedness properties are introduced, and a generalisation of Newman's Lemma is presented.We also compare confluence up to garbage with confluence modulo an equivalence relation.In Section 4, we generalise the Critical Pair Lemma to confluence up to garbage and discuss the generation of non-garbage critical pairs.This includes sufficient conditions for automating the generation process.Section 5 is devoted to the main application of confluence up to garbage, the recognition of graph languages by backtracking-free graph reduction.We present two case studies which illustrate this application.In Section 6, we show that subcommutativity up to garbage together with closedness implies confluence up to garbage, even in the absence of termination.Finally, in Section 7, we briefly mention related work, discuss potential generalisations and future work, and conclude.
This paper is an extended version of our ICGT 2020 paper [8], which was in turn partly developed from Campbell's BSc Thesis [9].Throughout this paper, we provide more detail and examples than previously.We have included a new subsection on the relationship between confluence up to garbage and confluence modulo an equivalence relation.Section 5 has been revised with more succinct terminology and more details of the critical pair analyses included.Section 6 on subcommutativity up to garbage is entirely new.We give a second version of our generalised critical pair lemma in this setting, showing how critical pair analysis can be used to check for subcommutativity up to garbage.This property implies confluence up to garbage even in non-terminating systems, provided that non-garbage is closed under reduction.This is relevant for applications because confluence up to garbage in such systems implies that non-garbage graphs can be reduced to at most one irreducible graph.

Preliminaries
We review some terminology for binary relations, the DPO approach to graph transformation, graph languages, and confluence checking.

Abstract reduction systems
An abstract reduction system (ARS) is a pair (A, →) where A is a class and → a binary relation on A. Write = − → for the reflexive closure of →, + − → for the transitive closure, and * − → for the reflexive transitive closure.Given x, x i , y, y 1 , y 2 ∈ A (i ≥ 0), we say that: 1. y is a successor to x if x + − → y, and a direct successor if x → y; 2. x and y are joinable if there is a z such that x * − → z * ← − y; 3. x and y are subcommutative if there is a z such that x Theorem 2.1 (Noetherian induction [10]).Given an ARS (A, →), the principle of Noetherian induction holds if and only if → is terminating.

Lemma 2.2. Subcommutativity implies confluence, and confluence implies local confluence.
Theorem 2.3 (Newman's Lemma [7]).Let → be a terminating relation.Then → is confluent if and only if it is locally confluent.

Labelled graphs and morphisms
We will be working with directed labelled graphs [11].A signature is a pair = ( V , E ) of finite sets of node and edge labels from which a graph can be labelled.A graph over is a tuple G = (V , E, s, t, l, m) where V is a finite set of nodes, E is a finite set of edges, s : E → V is the source function, t : E → V is the target function, l : V → V is the node labelling function, and m : E → E is the edge labelling function.We may write the components of Graphs G and H are isomorphic, denoted by G ∼ = H , if there exists a bijective graph morphism G → H .
It is well known that graphs and morphisms over a fixed signature form a category.Graph morphisms are injective (surjective, bijective) if and only if they are monomorphisms (epimorphisms, isomorphisms) in the categorical sense.We denote by G( ) the class of all graphs over .

Double-pushout graph transformation
A rule is a pair of inclusions r = L ← K → R , where L is the left-hand side (LHS), K the interface, and R the right-hand side (RHS).A match of r in a graph G is an injective morphism L → G.An application of rule r to G with match g : L → G requires to construct two pushouts as in Fig. 1.We write G ⇒ r,g H for this application and call the diagram in Fig. 1 a direct derivation.
Given r and the match g : L → G, the direct derivation of Fig. 1 exists if and only if the dangling condition is satisfied: nodes in g(L − K ) must not be incident to edges in G − g(L).In this case the graphs D and H are determined uniquely up to isomorphism [2].We call the injective morphism h the comatch of the rule application.
Given a set of rules R, we write G ⇒ R H if H is obtained from G by applying any of the rules from R.
G by one or more rule applications, and We can view a graph transformation system as ARS (G( ), ⇒ R ), giving us the definition of local confluence, confluence, subcommutativity, and termination for graph transformation systems.

Graph languages
A graph language is an isomorphism-closed class of graphs, and the size of a graph language is defined to be the number of non-isomorphic graphs in the language.Just like we can define string languages using string grammars, we can define graph languages using graph grammars, where we rewrite some start graph using a set of graph transformation rules.Derived graphs are then defined to be in the language exactly when they are terminally labelled.A graph transformation system T = ( , R) consists of a signature and a finite set of rules with graphs over .By adding a subsignature of non-terminals N and a start graph S over , we obtain a graph grammar G = ( , N, R, S).We say that a graph G is terminally labelled if l(V ) ∩ N V = ∅ and m(E) ∩ N E = ∅.Thus, we can define the graph language generated by G: and G is terminally labelled.So we have a non-deterministic membership checking algorithm, by running the rules in reverse.

Confluence checking
In 1970, Knuth and Bendix showed that confluence checking of terminating term rewriting systems is decidable [12].Moreover, it suffices to compute all critical pairs and check their joinability [13,10].Unfortunately, for terminating graph transformation systems, confluence is not decidable in general, and joinability of critical pairs does not imply local confluence.In 1993, Plump showed that strong joinability of all critical pairs is sufficient but not necessary to show local confluence [5,6].
In order to define critical pairs and critical pair isomorphism, we first must define what we mean by an instance of a derivation based on a morphism and what it means for two derivations to be parallelly independent.
Fig. 3. Parallelly independent direct derivations.Let the derivation : G 0 ⇒ * G n be given by pushouts (1), . . ., (n) and suppose there are pushouts (1 ), . . ., (n ) whose vertical morphisms are injective (Fig. 2).Then, the derivation : G 0 ⇒ * G n consisting of the composed pushouts (1 + 1 ), . . ., (n + n ) is an instance of based on the morphism G 0 → G 0 .Moreover, we define the subgraph Use to be all items x such that there is some i ≥ 0 with ) is the image of the associated rule's left hand side graph under the match L → G i .
We say two direct derivations 3).Otherwise, we say they are parallelly dependent.
We say two parallelly dependent direct derivations 4).It is easy to see that every graph transformation system has, up to isomorphism, only finitely many critical pairs.The track morphism of a direct derivation G ⇒ H is defined to be the partial morphism tr G⇒H = in • in −1 , where in and in are the bottom left and right morphisms in Fig. 1, respectively.We define tr G⇒ * H inductively as the composition of track morphisms.The set of persistent nodes of a critical pair That is, those nodes that are not deleted by the application of either rule.

A critical pair
: H 1 ⇐ G ⇒ H 2 is strongly joinable (strongly subcommutative) if it is joinable (subcommutative) without deleting any of the persistent nodes, and the persistent nodes are identified when joining.That is, there exists a graph Example 2.4.Consider the rules s 2 and s 4 from Example 3.8.Fig. 5 shows a strongly joinable critical pair and its joining derivations.
Theorem 2.5 (Critical pair lemma [5,6]).A graph transformation system T is locally confluent if all its critical pairs are strongly joinable.← → r 2 : ← → It's easy to see that the result also holds if one only considers non-isomorphic critical pairs, which can result in a large speedup in practice, since for large rules, there can often be many isomorphic critical pairs.
The original proof of the Critical Pair Lemma needs the Commutativity, Clipping and Embedding Theorems, which we shall now provide, and use in the proof of our Generalised Critical Pair Lemma (Theorem 4.8).[14]).If H 1 ⇐ r 1 ,g 1 G ⇒ r 2 ,g 2 H 2 are parallelly independent, then there is a graph G and derivations

Theorem 2.6 (Commutativity
Theorem 2.7 (Clipping [15]).Given a derivation : G ⇒ * H and an injective morphism h : G → G such that Use ⊆ h(G), there exists a derivation : G ⇒ * H such that is an instance of based on h.

Given a derivation
: G ⇒ * H , the subgraph of G, Persist , consists of all items x such that tr G⇒ * H (x) is defined.[15]).Let : G ⇒ * H be a derivation, h : G → G an injective graph morphism, B be the discrete subgraph of G consisting of all nodes x such that h(x) is incident to an edge in G − h(G).If B ⊆ Persist , then there exists a derivation : G ⇒ * H such that is an instance of based on h.Moreover, there exists a pushout of t : B → H along h : B → C where C = (G − h(G)) ∪ h(B ) and t is the restriction of tr G⇒ * H to B .

Closedness and confluence up to garbage
The purpose of this section is to introduce the notion of "up to garbage" and lay some foundations that we can use in the remainder of the paper.We divide the section into three subsections, finishing by relating "up to garbage" with the existing notion of "modulo an equivalence relation".

Closedness and garbage
We start with the definition of closedness, and what it means for an item to be considered garbage.
The idea is that D represents the good input, and the garbage is the objects that are not in this class.In the context of graph transformation, D will be a graph language, but need not be explicitly generated by a graph grammar.For example, it could be defined by some (monadic second-order [16]) logical formula, a finite listing of graphs, or a type graph language (Subsection 4.3).Finite languages and type graph languages will be of particular interest to us due to the fact they have decidable subgraph membership problem (Subsection 4.3).
The closedness problem is defined in the obvious way:

Definition 3.3 (Closedness problem).
Instance: A GT system T = ( , R) and a graph grammar G over .
Question: Is L(G) closed under T ?
It turns out that this is undecidable in general, even if we restrict to decidable languages and terminating GT systems.In 1998, Fradet and Le Métayer showed the following result: Theorem 3.4 (Undecidable closedness [17]).The closedness problem is undecidable in general, even for terminating GT systems T with only one rule, and G an edge replacement grammar.

Confluence and subcommutativity up to garbage
In this subsection, we generalise the familiar definitions of local confluence, confluence, subcommutativity, and termination to permit ignoring garbage.Definition 3.5.Given an ARS (A, →), D ⊆ A, x, x 0 ∈ D, and x i , y 1 , y 2 ∈ A (i ≥ 1), we say that: The following is an immediate consequence of inclusion: Lemma 3.6.Let (A, →) be an ARS, D ⊆ A, E ⊆ D, and P be the property of confluence up to garbage, local confluence up to garbage, subcommutativity up to garbage, or termination up to garbage.Then P on D implies P on E.
Our next two examples show that confluence up to garbage need not correspond to confluence.That is, a system can be non-confluent, but confluent up to garbage.
Example 3.7.Consider again the rules in Fig. 6.It is easy to see that the GT system containing both rules is terminating, but not confluent.It is, however, both confluent up to garbage on the language of unlabelled discrete graphs and subcommutative up to garbage on the language of unlabelled discrete graphs.
Example 3.8.Consider the rules in Fig. 7.They are terminating, since they are size reducing.Moreover, the language of all linked lists with edge labels a or b and its complement (over the same signature) are closed under the rules.These rules are confluent up to garbage on linked lists, since any non-trivial linked list is necessarily reduced to the length one linked list labelled by a, and the length zero and one linked lists are already in normal form.By comparison, the rules are not locally confluent due to the counterexample in Fig. 8 (recall that we assume injective matching).
It is easy to see that confluence up to garbage always implies local confluence up to garbage, and subcommutativity up to garbage implies local confluence up to garbage, however subcommutativity up to garbage need not imply confluence up to garbage.Similarly, in the presence of termination, local confluence up to garbage need not imply confluence up to garbage.Our next example demonstrates this.
Example 3.9.Let D be the language of linked lists containing at least two edges and T be the GT system with rules from Fig. 9. Then r 2 and r 3 cannot be applied to any graph in D, and r 1 will always be applicable in a unique way, with the effect of deleting the last node and its edge.It is thus immediate that T is subcommutative up to garbage on D, and thus also locally confluent up to garbage on D. T is not, however, confluent up to garbage on D due to the following two-step counterexample in Fig. 10.
Our next two results show that closedness is the missing ingredient to recovering the familiar relationships between local confluence, confluence, subcommutativity, and termination, in our generalised setting of "up to garbage".Lemma 3.10.Let (A, →) be an ARS and D ⊆ A.
1.If D is closed under → and → is subcommutative up to garbage on D, then → is confluent up to garbage on D; 2. If → is confluent up to garbage on D, then → is locally confluent up to garbage on D.
Proof.The first part can be seen by Noetherian Induction, due to the fact that closedness ensures applicability of the induction hypothesis, and the second part follows immediately from the definitions.Theorem 3.11 (Generalised Newman's Lemma).Let (A, →) be an ARS and D ⊆ A. If → is terminating up to garbage on D and D is closed under →, then → is confluent up to garbage on D if and only if → it is locally confluent up to garbage on D.
Proof.One direction can be seen by Noetherian Induction (Fig. 11), since closedness ensures applicability of the induction hypothesis, and the other follows from the second part of Lemma 3.10.

Confluence and subcommutativity modulo garbage
In this subsection, we show that our notion of confluence up to garbage can be related to the existing notion of confluence modulo.
First, we recall the definition of local confluence (confluence, subcommutativity) modulo an equivalence relation.If the relation is the identity relation, then we recover the standard definitions of local confluence (confluence, subcommutativity).Definition 3.12 ([13]).Given an ARS (A, →), an equivalence ∼ on A, and x, x i , y, y 1 , y 2 ∈ A (i ≥ 0), we say that: 1. x and y are ∼-joinable if there is are We now show that confluence up to garbage can be encoded as confluence modulo an equivalence, and vice versa.Theorem 3.13 (Encoding confluence up to garbage).Let (A, →) be an ARS, D ⊆ A, and define the equivalence ∼ on A by x ∼ y exactly when x = y or x, y ∈ A − D. Then:

Generalised critical pair lemma
Recall that strong joinability of all critical pairs is a sufficient condition for local confluence (Theorem 2.5).This was first shown by Plump in 1993 [5].Combining this with Newman's Lemma (Theorem 2.3), we have a checkable condition for confluence of a GT system.Unlike for string and term rewriting, joinability is not sufficient to show local confluence, as demonstrated by the following example due to Plump [6]: Example 4.1.Consider the terminating GT system with the rules from Fig. 12.The only critical pair (Fig. 13) is joinable, but not strongly, and the system is not locally confluent due to the counterexample in Fig. 14.In this section, we generalise Plump's critical pair analysis for confluence up to garbage.We delay the treatment of subcommutativity up to garbage to Section 6, for ease of reading.

Subgraph closure and subgraph closed languages
In the original proof of the Critical Pair Lemma for (hyper)graphs [5], the argument is that if a pair of derivations is not parallelly independent, then it must be the case that a critical pair can be embedded within it.In our new setting, the possible start graphs will be restricted, since some of the graphs will be garbage.We are only interested in those critical pairs with start graphs that can be embedded in non-garbage graphs.This is exactly the statement that the start graph of the critical pair is in the subgraph closure of the non-garbage graphs.We start this subsection by defining subgraph closure.Clearly, the smallest possible set containing D is just the union of all subgraphs of the elements of D, up to isomorphism.This is the unique subgraph closure of D. D always exists, however it needs not be decidable, even when D is!It is not obvious what conditions on D ensure that D is decidable.If we move to the setting of string rewriting, there are some known cases where this can be solved.
The classes of regular and context-free string languages are closed under substring closure, and the substring membership problem is decidable for context-free grammars [18] due to the fact that showing closure is constructive.We return to the issue of deciding subgraph membership in Subsection 4.3.
Example 4.4.The following graph languages are subgraph closed, over any signature : 1. the empty language ∅ and the language of all graphs G( ); 2. the language of discrete graphs; 3. the language of acyclic graphs; 4. the language of planar graphs; 5. the language of k-colourable graphs for any fixed k ≥ 2; 6. the language of bounded degree graphs for any fixed bound; 7. the language of bounded treewidth graphs for any fixed bound.
Example 4.5.The subgraph closure of the language of trees is the language of forests.The subgraph closure of the language of connected graphs is the language of all graphs.

Generalising the critical pair lemma
We now define non-garbage critical pairs, which allow us to ignore certain pairs, which if all are strongly joinable, will allow us to conclude local confluence up to garbage, even in the presence of (local) non-confluence on all graphs.Definition 4.6.Let T = ( , R) be a GT system and D ⊆ G( ) a language.A critical pair Proof.Recall from Subsection 2.5 that any GT system has only finitely many critical pairs.Filtering out those that are garbage or isomorphic is certainly only going to leave us with a finite number of critical pairs.Of course, just because there are only finitely many non-garbage critical pairs, it doesn't mean that generation of them is effective, in general.In order to avoid interrupting the flow, we will discuss this further in Subsection 4.3.We now proceed to present the main result: Theorem 4.8 (Generalised critical pair lemma).Let T = ( , R) be a GT system and D ⊆ G( ) a language.If all T 's D-non-garbage critical pairs are strongly joinable, then T is locally confluent up to garbage on D.
Proof.Our proof is a generalisation of Plump's original proof of the Critical Pair Lemma for (hyper)graph transformation systems (Theorem 2.5).We need to show that every pair of derivations H 1 ⇐ r 1 ,g 1 G ⇒ r 2 ,g 2 H 2 such that G is non-garbage can be joined.There are two cases to consider.Firstly, if the derivations are parallelly independent, then by Theorem 2.6, the result is immediate.Otherwise, we must consider the case that they are not parallelly independent.By Theorem 2.7, we can factor out a pair T 1 ⇐ S ⇒ T 2 .Since critical pairs are, by construction, the overlaps of rule left hand sides, it must be the case that this pair is actually a critical pair.Moreover, since G ∈ D, then S ∈ D and so the critical pair must be non-garbage, and must be strongly joinable to U .We can now apply Theorem 2.8 to T 1 ⇒ * U and T 2 ⇒ * U , separately, giving result graphs M 1 and M 2 (applicability of the theorem is a consequence of strong joinability) (Fig. 15).To see that M 1 and M 2 are isomorphic follows from elementary properties of pushouts along monomorphisms [6].
Just as with the original Critical Pair Lemma in Subsection 2.5, it is sufficient to only check the non-isomorphic critical pairs for strong joinability due to the fact that derivations based on a critical pair can be reset as derivations based on any other isomorphic critical pair simply by passing through the isomorphism.Thus, if all T 's non-isomorphic D-non-garbage critical pairs are strongly joinable, then T is locally confluent up to garbage on D.
The most common use case of this generalised critical pair will be the following corollary, where the aim is not to show local confluence up to garbage, but confluence up to garbage, given termination up to garbage: Corollary 4.9.Let T = ( , R) be a GT system and D ⊆ G( ) a language.If D is closed under T , T is terminating up to garbage on D, and all T 's non-isomorphic D-non-garbage critical pairs are strongly joinable, then T is confluent up to garbage on D.
Proof.By the above theorem, T is locally confluent up to garbage, so by the Generalised Newman's Lemma (Theorem 3.11), T is confluent up to garbage.Example 4.10.Recall from Subsection 3.2, the non-confluent GT system from Example 3.8 (Fig. 7).We can use Corollary 4.9 to show that this system is confluent up to garbage on the language of acyclic graphs with edge labels a and b, D. First, we observe that the rules (Example 3.8) are terminating, and that D is closed under the rules.Next, we observe that the system has 16 non-isomorphic critical pairs.(Here and in later examples we used a tool of the first author to find all critical Pair/Property Joinable pairs. 2 ) Fig. 16 shows, for each of the pairs, if they are joinable, strongly joinable, or D-non-garbage.From this, we can see that every non-garbage critical pair is strongly joinable, and so the system is confluent up to garbage on D.
Checking for local confluence up to garbage is undecidable in general, even when D is decidable and the system is terminating and closed.Moreover, local confluence up to garbage is actually undecidable in general for a terminating nonlength-increasing string rewriting system and D a regular string language [19].The following (corrected) example due to Fig. 18.Non-strongly joinable pair for Example 4.11.
r 2 : ← → Plump [6] demonstrates that a GT system can be confluent and terminating, with all critical pairs joinable, and at least one not strongly joinable: Example 4.11.The GT system with rules in Fig. 17 is terminating and confluent, and all its critical pairs are strongly joinable apart from the pair in Fig. 18 which is only joinable.
We now extend this even further, showing that there is a GT system T that is not confluent and an infinite language of graphs D such that D is closed under T , T is terminating on D, T is confluent on D, all T 's D-non-garbage critical pairs are joinable, and at least one of them is not strongly joinable: Example 4.12.Let D be the language of all graphs that are trees with exactly one looped edge added to one of the nodes, T be the GT system with rules in Fig. 19.Fig. 20 shows the four non-isomorphic critical pairs of the We can there is a garbage pair which is non-joinable, which tells us that T is not locally confluent.By direct argument, one can see that D is closed under T , T is terminating on D, and T is confluent on D, however there is a non-strongly joinable non-garbage critical pair.
In Subsection 4.3, we will discuss generation of the set of non-isomorphic non-garbage critical pairs of a given GT system, discussing sufficient conditions on D for this process to be effective.In Subsection 4.4 we discuss testing for strong joinability of a given non-garbage critical pair.

Generation of non-garbage critical pairs
In general, there is no algorithm that, when given a DPO grammar and a graph, can decide if the graph is contained in the language generated by the grammar.That is, the universal membership problem is undecidable.It is easy to see that the similar problem of whether a graph is in the subgraph closure of the language generated by a DPO grammar is undecidable in general too.This means that, unlike for critical pairs, generation of all the non-garbage critical pairs is not possible in general, due the impossibility of deciding subgraph membership.Though, if we are provided with an algorithm for testing if a graph is a subgraph of a graph of D, then we can generate the set of non-isomorphic D-non-garbage critical pairs.

Definition 4.13 (Universal subgraph membership problem).
Instance: A graph grammar G over a graph G over .Question: Is G ∈ L(G)?In practice, it is often the case that one can determine if a graph is contained in the subgraph closure of a language, and so undecidability is not too much of a concern.For example, if a graph language is known to only contain acyclic graphs, critical pairs with start graphs containing a cycle can be discarded as garbage.Moreover, it may not even be necessary to decide if a critical pair is garbage, if one can show that it is strongly joinable instead.
Here are some types of graph languages for which membership in the subgraph closure is decidable: 1.If D is finite, then membership in the subgraph closure can be decided simply by checking if the given graph is a subgraph of any graph in the language.2. If D is subgraph-closed, then membership in the subgraph closure is the same as membership in D. Hence, membership is decidable if D is the class of discrete graphs, bounded degree graphs for some fixed bound, acyclic graphs, k-colourable graphs or planar graphs (see [20] for how to decide membership in the latter three classes).If D is the class of bounded treewidth graphs, for a fixed bound, membership can be decided by the algorithm in [21].3.If D is specified by a so-called type graph (see below), then D is also subgraph-closed and membership is decidable.
Type graph languages are studied by Corradini, König, and Nolte in [22].Example 4.16.It is easy to see that the language of 2-colourable unlabelled graphs, D, can be specified by the type graph in Fig. 21.Consider the GT system with the two rules in Fig. 22.It is easy to see that D is closed under these rules (due to the fact that they are never applicable), that they are terminating (due to the fact that they are size reducing), and that there are five non-isomorphic critical pairs (Fig. 23, where the third pair is repeated twice more, formally with different matches), all of which are garbage (which we can machine check because D is specified by a type graph).Thus, by Corollary 4.9, the rules are confluent up to garbage on D.
We are not aware of any other general families of grammars, or otherwise, for which we can solve the subgraph membership problem.We do not believe this problem is even decidable for hyperedge replacement grammars.This conjecture is not incompatible with this problem being easy for type graph languages, the class of graph languages generated by hyperedge replacement grammars is incomparable with the class of graph languages specified by type graphs.

Checking for strong joinability
We briefly, explicitly discuss the process for checking if a pair of direct derivations is strongly joinable in a given GT system.
If a GT system is terminating, then it is decidable whether a pair of direct derivations is joinable or strongly joinable due to the fact that GT systems are finitely branching up to isomorphism, so there can only be finitely many successor graphs, up to isomorphism.It is then simply a matter of checking if there is an isomorphism between any of the successor graphs which behaves correctly with respect to the preserved nodes, as in the definition of strong joinability.
Alternatively, if a GT system is only terminating up to garbage on some language D and D is closed under T , then similarly, one can test joinability and strong joinability due to the fact that closedness ensures only finitely many successor graphs, as above.

Summary
We have presented our Generalised Critical Pair Lemma and Generalised Newman's Lemma, which together allow one to check for confluence up to garbage on some language D in the presence of termination and closedness.If there is an algorithm for solving the subgraph membership problem of D, then we can effectively generate the set of non-isomorphic D-non-garbage critical pairs and effectively test each of them for strong joinability.This process will always terminate, however may not provide a conclusive answer.
If the analysis completes with all the non-isomorphic D-non-garbage critical pairs being strongly joinable, then we can conclude the system is confluent up to garbage on D. If the analysis completes with a non-joinable D-non-garbage critical pair that has its start graph in D, then we can conclude the system is not confluent up to garbage on D. In any other scenario, we cannot directly make a conclusion.
Finally, sometimes one might want to show confluence of a GT system T on a language D which is not necessarily closed under T .That is, either D is not closed under T , or indeed closure is simply unknown.In this scenario, one should attempt to show confluence on some larger language E containing D. For example, if D contains only acyclic graphs, a good choice for E could be the language of acyclic graphs over the same signature.Transitivity of confluence up to garbage (Lemma 3.6) tells us that if we establish that T is confluent up to garbage on E, then it is also confluent up to garbage on D.

Backtracking-free language recognition
In this section, we introduce a general notion of what it means to recognise a language, and what it means to be a backtracking-free specification.We then demonstrate the applicability of our earlier results by showing that there are backtracking-free specifications for the languages of labelled series-parallel graphs and extended flow diagrams, even in the absence of confluence.We thus have algorithms, specified by reduction rules, that can check membership of these languages without needing to backtrack.

Backtracking-free specifications
Given a graph transformation system and a start graph, we can think of the pair as a graph grammar, generating a graph language.If the reversed system is terminating, then membership testing is decidable, but in general, non-deterministic in the sense that a deterministic algorithm must backtrack if it produces a normal form not equal to the start graph, to determine if another derivation sequence could have reached it.It is easy to see that confluence is a sufficient condition to give determinism, however confluence is often not easily obtainable in practice.For this reason, we will consider the weaker property of confluence up to garbage on the generated language.
Using the results from the last section, it is often possible to prove local confluence up to garbage using the Generalised Critical Pair and then, in the presence of termination and closure, use the Generalised Newman's Lemma to show confluence up to garbage.Language recognition by confluent graph reduction has been considered before by Bakewell, Plump, and Runciman, in the context of pointer structures [3,23], but without the concept of confluence up to garbage.
Before continuing, we must provide a formal definition of what it means to recognise a language, and that grammars satisfy our definition by considering their rules in reverse, abstracting away from grammars, with a more general definition that accounts for the fact that reduction systems may need auxiliary symbols, not in the input, in the same way grammars can use non-terminals.Definition 5.1 (Language recognition).Let T = ( , R) be a GT system, A ⊆ an input signature, and S a finite set of graphs over .Then we say that (T , S) recognises a language L over A if for all graphs G over A, [G] for some S ∈ S.

Theorem 5.2 (Membership checking). Given a grammar
Proof.The key is that rules and derivations are invertible, which means that if S can be derived from G using the reverse rules, then G can be derived from S using the original rules so is in the language.If S cannot be derived from G, then G cannot be in the language since that would imply there was a derivation sequence from S to G which we could invert to give a contradiction.
We are now ready to define backtracking-free specifications, and show that such systems can test for language membership without backtracking.

Definition 5.3 (Backtracking-free specification).
Let T = ( , R) be a GT system, A ⊆ an input signature, and S a finite set of graphs over .Then we say that (T , S) is a backtracking-free specification for a language L over A if (T , S) recognises L over A, T is terminating on G(A), and T is confluent on L. Theorem 5.4.Given a backtracking-free specification (T , S) for a language L over A ⊆ and an input graph G over A, the following algorithm is correct: Compute a normal form of G by deriving successor graphs using T as long as possible.If the result graph is isomorphic to some S ∈ S, the input graph is in the language.Otherwise, the graph is not in the language.
Proof.Suppose G is not in L.Then, since T is terminating on G(A) our algorithm must be able to find a normal form of G, say H , and because T recognises L, it must be the case that H is not isomorphic to S, and so the algorithm correctly decides that G is not in L. Now, suppose that G is in L.Then, because T is terminating, as before, we must be able to derive some normal form, H .But then, since T is both confluent on L and recognises L, it must be the case that H is isomorphic to S, and so the algorithm correctly decides that G is in L.
For the remainder of this section, we look at two examples that demonstrate how we can use our Generalised Newman's Lemma and Generalised Critical Pair Lemma to verify if we have a backtracking-free specification for a language, given a grammar that generates the language.

Backtracking-free specification of series-parallel graphs
Series-parallel graphs were introduced by Duffin [24] as a model of electrical networks.A more general version of the class was introduced by Lawler [25] and Monma and Sidney [26] as a model for scheduling problems.Definition 5.5.Series-parallel graphs are inductively defined: 1. P = s t is a series-parallel graph where s is the source and t the sink.
2. The class of series-parallel graphs is closed under parallel composition and sequential composition, where parallel composition identifies the two sources and the two sinks, and sequential composition identifies the sink of one graph with the source of the other graph.
Fig. 24 shows an example series-parallel graph.Duffin showed that a graph is series-parallel if and only if it can be reduced to P by a sequence of series and parallel reductions.We can rephrase this, giving a graph grammar that generates the language: Pair/Property Joinable Strongly Joinable ✓ ✓ Fig. 26.Series-parallel critical pair analysis.
By traditional critical pair analysis, one can establish that the reversed rules are confluent (Fig. 26), however, we run into a problem if we want to consider arbitrarily labelled graphs.Consider the case where the edge alphabet is of size 2, rather than size 1.The obvious modification to the rules is to use all combinations of labels in LHS graphs (Figs. 7 and 27), however Hristakiev and Plump [28] observed that when doing the equivalent of this in GP 2, we no longer have confluence.
Definition 5.7.The class of labelled series-parallel graphs (LSPs) is all series-parallel graphs, but with arbitrary edge labels chosen from E = {a, b}.
The GT system with the 7 rules from Figs. 7 and 27 has 26 non-isomorphic critical pairs.16 of the critical pairs are conflicts between the sequential reduction rules (Fig. 16) and the remaining 10 are conflicts between the parallel reduction rules (Fig. 28).There are no critical pairs between the series rules and the parallel rules.The non-joinable pairs confirm we no longer have confluence, however the fact that the language of labelled series-parallel graphs is closed under the rules, the rules are terminating, and all the non-garbage critical pairs are strongly joinable, allows us to conclude the rules are confluent up to garbage on the language of labelled series-parallel graphs.Proof.We denote by L the language of all labelled series-parallel graphs.Our rules are structurally the same as the unlabelled rules, so because our LHS graphs are arbitrarily labelled, language recognition of L over follows from Theorem 5.6.Formally, our above discussion used Corollary 4.9 to establish that T is confluent up to garbage on L, as required.
Finally, we remark that this construction generalises for arbitrary edge label alphabets, and not just those of size 2. The number of conflicts is simply much larger, however the critical pair analysis will always conclude in the same way.Thus, we have shown that the obvious generalisation of the series-parallel reduction rules to a non-trivial edge labelling set admits a back-tracking free specification, even though the system is not confluent.

Backtracking-free specification of extended flow diagrams
In 1976, Farrow, Kennedy and Zucconi presented semi-structured flow graphs, defining a grammar with confluent reduction rules [29].Plump has considered a restricted version of this language: extended flow diagrams (EFDs) [6].The reduction rules for extended flow diagrams are a backtracking-free specification for the EFDs, despite not being confluent.
Throughout this subsection, we will use a shorthand notation for rules, where we assume all interface graphs contain no edges, and any node that appears in the interface graph will be labelled by a subscript number on both sides of the rule, writing only the left-hand side and right-hand side graphs.We also highlight persistent nodes within critical pairs in blue, for ease of reading.The colouring has no special meaning, other than that.
We now define extended flow diagrams using a grammar: Proof.By Theorem 5.2, T recognises L(EFD) over , and one can see that it is terminating since each rule is size reducing.We now proceed by performing critical pair analysis on T .There are ten non-isomorphic critical pairs: 1.The pair exactly as in Fig. 30; 2. The pair in Fig. 30 with nodes 1 and 4 identified; 3. The pair exactly as in Fig. 31; 4. The pair in Fig. 31 with nodes 1 and 5 identified; 5.The pair in Fig. 31 with nodes 2 and 5 identified; 6.The pair exactly as in Fig. 32; 7. The pair exactly as in Fig. 33; 8.The pair in Fig. 33 with nodes 1 and 5 identified; 9.The pair exactly as in Fig. 34; 10.The pair exactly as in Fig. 35; Pairs 1 through 9 are strongly joinable, and pair 10 is not joinable.Now observe that Lemma 5.10 tells us that EFDs cannot contain such cycles.With this knowledge, we define D to be all graphs such that directed cycles contain at least one t-labelled edge (over ).
Clearly, D is subgraph closed, and then by our Generalised Critical Pair Lemma (Theorem 4.8), we have that T is locally confluent on D. Next, it is easy to see that D is closed under T , so we can use Generalised Newman's Lemma (Theorem 3.11) to conclude confluence on D and thus, by Lemma 3.6, T is confluent on L(EFD).Thus, T is a backtracking-free specification for L(EFD) over , as required.

Subcommutativity
In this section, we study critical pair analysis with a view to establish subcommutativity up to garbage, rather than confluence up to garbage, as previously in Section 3. We have already introduced subcommutativity in Section 2 and subcommutativity up to garbage in Section 3.      We start by giving the main result of this section: Just as before, it suffices to only analyse the non-isomorphic critical pairs.A notable difference is that closure and termination are no longer needed to check for joinability, since we are only looking for strong subcommutativity of critical pairs.However, as noted in Subsection 3.2, closedness is required in order for subcommutativity up to garbage to imply confluence up to garbage (see Example 3.9 and Lemma 3.10).
Revisiting our examples in Section 5, all 4 of the critical pairs of the series-parallel reduction system are actually strongly subcommutative, all 18 non-garbage critical pairs of the labelled series-parallel reduction rules are strongly subcommutative, and so are the 9 non-garbage critical pairs of the extended flow diagram reduction system.
We finish this subsection with a simple example demonstrating termination is not a requirement to establish subcommutativity up to garbage.Example 6.3.Let D be the language of discrete graphs and T be the GT system with the three rules in Fig. 36.There are two non-isomorphic critical pairs, all of which are garbage (Fig. 37), which allow us to immediately conclude subcommutativity of T up to garbage on D (Theorem 6.1).Notice D is closed under T , which means T is also confluent to garbage on D (Lemma 3.10).
Notice these rules aren't terminating, even up to garbage on discrete graphs, thus naive machine checking for strong joinability of these pairs would not terminate, however we only need to check for subcommutativity.

Conclusion, related and future work
In this paper we have introduced local confluence, confluence, subcommutativity, and termination up to garbage for DPO graph transformation systems, and shown that Newmann's Lemma and Plump's Critical Pair Lemma can be generalised, providing us with checkable conditions for confluence and subcommutativity up to garbage, using only critical pairs.Of course, confluence up to garbage of terminating graph transformation systems is undecidable in general, however, now we can detect more positive cases of confluence up to garbage using non-garbage critical pair analysis, where we previously would have been unable to draw a conclusion due to non-strong joinability of some critical pairs.We have directly applied our results to recognition of languages, looking specifically at the class of extended flow diagrams and the class of labelled series-parallel graphs.We have backtracking-free algorithms that apply reduction rules as long as possible, with correctness established via non-garbage critical pair analysis.We also anticipate there to be other applications, since there are many other reasons one would want to show confluence up to garbage, such as considering GT systems as computing functions where we restrict the domain [11].Indeed, one might only be interested in the non-garbage critical pairs themselves, and classification of conflicts [30,31].

Generalisations
Our results also work if we relax the injectivity requirement of the K → R morphism in rules.One should note that the two equivalent definitions of parallel independence we have in Subsection 2.5 were specialised for injective rules only.
More generally, two direct derivations H 1 ⇐ r 1 ,g 1 G ⇒ r 2 ,g 2 H 2 are parallelly independent if there are morphisms is injective [11].Our results also work in the setting of hypergraph transformation, as well as just graph transformation, with almost identical proofs.We think it is extremely likely our results hold for any M-adhesive system with the usual restrictions [32], by modification of the original proof of the Generalised Critical Lemma from Campbell's BSc Thesis [9], which operates by showing completeness of the non-garbage critical pairs.In an unpublished report, we have also shown that these results hold for graph transformation with relabelling [33], which is important, since the setting is not Madhesive [34] and is the graph transformation framework used by GP 2 [35,36].

Related work
Lambers, Ehrig and Orejas investigated essential critical pairs [37] and the continued work by others including Born and Taentzer [30].That said, all of our examples exhibit only essential critical pairs, so checking if a critical pair is essential only has the effect of slowing down the analysis in our examples.Please note that in this paper we are not interested in the actual critical pairs or even the property of confluence, but the weaker property of confluence up to garbage.This property still gives a lot of the benefits of confluence such as backtracking-free reduction.Blakewell, Plump and Runciman investigate the of graph reduction for specifying pointer structures [3].Of particular interest in this context are confluent (up to garbage) reduction systems.Confluence modulo is also studied in other areas of computer science such as constraint handling rules (CHR), see for example [38].

Future work
Confluence analysis of GT systems (and related systems) still remains a generally under-explored area.Future work includes the investigation of any relation with essential critical pairs and developing further checkable sufficient conditions under which one can decide if a graph is in the subgraph closure of a language, beyond those in Subsection 4.3.Finally, applying our theory in a rooted context and to GP 2 is future work [36].It is likely that the theory will be applicable there, since program preconditions correspond exactly to non-garbage input, and so it is only natural to be interested in confluence up to garbage, rather than confluence.We would also expect there to be analogues of our results for other kinds of rewriting systems such as string and term rewriting.
It is also not obvious what the relation is between confluence up to garbage and graphs satisfying negative constraints or nested application conditions [39,32].Moreover, developing a stronger version of the Generalised Critical Pair Lemma that allows for the detection of persistent nodes that need not be identified in the joined graph would allow conclusions of confluence up to garbage where it was previously not determined.

Definition 4 . 2 .Lemma 4 . 3 .
Let D ⊆ G( ) be a language over some signature .Then D is subgraph closed if for all graphs G, H , such that H ⊆ G, if G ∈ D, then H ∈ D. The subgraph closure of D, denoted D, is the smallest language (with respect to inclusion) containing D that is subgraph closed.Given a language D ⊆ G( ), D always exists, and is unique.Moreover, D = D if and only if D is subgraph closed.Proof.The key observations are that the subgraph relation is transitive, and each graph has only finitely many subgraphs.

Lemma 4 . 14 .
The universal subgraph membership problem is undecidable.Proof.By reduction of undecidability of the emptiness problem, since ∅ / ∈ L(G) if and only if L(G) = ∅.

Definition 4 . 15 (
Type graph language).Given a signature and a graph G ∈ G( ), define the type graph language L (G) = {H ∈ G( ) | there exists a graph morphism H → G}.

Theorem 6 . 1 .Corollary 6 . 2 .
Let T = ( , R) and D ⊆ G( ).If all T 's D-non-garbage critical pairs are strongly subcommutative, then T is subcommutative up to garbage on D. Proof.Easy modification of the proof of the original theorem (Theorem 4.8).Let T = ( , R) and D ⊆ G( ).If all T has no D-non-garbage critical pairs, then T is subcommutative up to garbage on D.
t 2 , and t 1 ∼ t 2 .Due to closedness, we have y, t 1 , z, t 2 ∈ D. Putting this together with the fact that t 1 ∼ t 2 tells us that in fact t 1 = t 2 .Thus all such derivations are joinable.Finally, if x / ∈ D, we don't need to consider joinability.Thus, → is confluent up to garbage on D, as required.Thus, if both A − D and D are closed under →, then the notions of confluence (local confluence, subcommutativity) up to garbage and modulo garbage exactly correspond: Let (A, →) be an ARS, D ⊆ A, and define the equivalence ∼ on A by x ∼ y exactly when x = y or x, y ∈ A − D. If A − D and D are closed under →, then → is P up to garbage on D if and only if → is P modulo ∼, where P is the property confluence, local confluence, or subcommutativity.
under → and → is P up to garbage on D, then → is P modulo ∼; 2. if D is closed under → and → is P modulo ∼, then → is P up to garbage on D, where P is the property confluence, local confluence, or subcommutativity.Proof.We deal only with confluence.Local confluence and subcommutativity are trivial modifications of the same argument.Suppose A − D is closed under → and → is confluent up to garbage on D. Then, for all derivations x * − → y, x * − → z such that x ∈ D, there is a t ∈ A such that y * − → t and z * − → t.Clearly t ∼ t, so all such derivations are ∼-joinable.Suppose now that x / ∈ D. Then by closedness, y, z / ∈ D too, so y ∼ z, so all such derivations are ∼-joinable.Thus → is confluent modulo ∼, as required.Suppose D is closed under → and → is confluent modulo ∼.Then, for all derivations x * − → y, x * − → z such that x ∈ D, there are t 1 , t 2 ∈ A such that y * − → t 1 , z * − →