Labelings for Decreasing Diagrams

This article is concerned with automating the decreasing diagrams technique of van Oostrom for establishing confluence of term rewrite systems. We study abstract criteria that allow to lexicographically combine labelings to show local diagrams decreasing. This approach has two immediate benefits. First, it allows to use labelings for linear rewrite systems also for left-linear ones, provided some mild conditions are satisfied. Second, it admits an incremental method for proving confluence which subsumes recent developments in automating decreasing diagrams. The techniques proposed in the article have been implemented and experimental results demonstrate how, e.g., the rule labeling benefits from our contributions.


Introduction
The decreasing diagrams technique of van Oostrom [15] is a complete method for showing confluence of countable abstract rewrite systems. The main idea of the approach is to show confluence by establishing local confluence under the side condition that rewrite steps of the joining sequences must decrease with respect to some well-founded order. For term rewrite systems however, the main problem for automation of decreasing diagrams is that in general infinitely many local peaks must be considered. To reduce this problem to a finite set of local peaks one can label rewrite steps with functions that satisfy special properties. In [16] van Oostrom presented the rule labeling that allows to conclude confluence of linear rewrite systems by checking decreasingness of the critical peaks (those emerging from critical overlaps). The rule labeling has been implemented by Aoto [1] and Hirokawa and Middeldorp [12]. Already in [16] van Oostrom presented constraints that allow to apply the rule labeling to left-linear systems. This approach has been implemented and extended by Aoto [1]. Our framework subsumes the above ideas.
The contributions of this article comprise the extraction of abstract constraints on a labeling such that for a (left-)linear rewrite system decreasingness of the (parallel) critical peaks ensures confluence. We show that the rule labeling adheres to our constraints and present additional labeling functions. Furthermore such labeling functions can be combined lexicographically to obtain new labeling functions satisfying our constraints. This approach allows the formulation of an abstract criterion that makes virtually every labeling function for linear rewrite systems also applicable to left-linear systems. Consequently, confluence of the TRS in Example 1 can be established automatically, e.g., by the rule labeling, while current approaches based on the decreasing diagrams technique [1,12] as well as other confluence criteria like Knuth and Bendix' criterion or orthogonality (and its refinements) fail.

:
x + y → y + x 10 : s(x) × y → (x × y) + y This system is locally confluent since all its 34 critical pairs are joinable.
The remainder of this article is organized as follows. After recalling preliminaries in Section 2 we present constraints (on a labeling) such that decreasingness of the critical peaks ensures confluence for (left-)linear rewrite systems in Section 3. Three of these constraints are based on relative termination while the fourth employs persistence. We focus on parallel rewriting in Section 4. The merits of these approaches are assessed in Section 5 by discussing the relationship to the recent literature. Implementation issues are addressed in Section 6 before Section 7 gives an empirical evaluation of our results. Section 8 concludes.
This article is an updated and extended version of [25], which presents the first incremental approach for labeling decreasing diagrams. Besides a number of small improvements, the article contains three new major contributions: -Section 3.2.3, presenting a new labeling measuring the contracted redex, -Section 3.2.4, which uses persistence to enhance the applicability of Llabelings for left-linear systems, -Section 4, which studies parallel rewriting to make any weak LL-labeling applicable to showing confluence of left-linear systems without additional (relative termination) constraints. The latter generalizes and incorporates recent findings from [7], which studies the rule labeling for parallel rewriting.
Let F be a signature and let V be a set of variables disjoint from F . By T (F , V) we denote the set of terms over F and V. The expression |t| x indicates how often variable x occurs in term t. Positions are strings of natural numbers, i.e., elements of N * + . The set of positions of a term t is defined as Pos(t) = {ǫ} if t is a variable and as Pos(t) = {ǫ}∪{iq | q ∈ Pos(t i )} if t = f (t 1 , . . . , t n ). We write p q if q = pp ′ for some position p ′ , in which case q\p is defined to be p ′ . Furthermore p < q if p q and p = q. Finally, p q if neither p q nor q < p.
Positions are used to address subterm occurrences. The subterm of t at position p ∈ Pos(t) is defined as t| p = t if p = ǫ and as t| p = t i | q if p = iq. We write s[t] p for the result of replacing s| p with t in s. The set of function symbol positions Pos F (t) is {p ∈ Pos(t) | t| p / ∈ V} and Pos V (t) = Pos(t) \ Pos F (t). The set of variables occurring in a term t is denoted by Var(t). We let t| P = {t| p | p ∈ P } if t is a term and P a set of positions.
A rewrite rule is a pair of terms (l, r), written l → r, such that l is not a variable and all variables in r are contained in l. A rewrite rule l → r is duplicating if |l| x < |r| x for some x ∈ V. A term rewrite system (TRS) is a signature together with a finite set of rewrite rules over this signature. In the sequel signatures are implicit. By R d and R nd we denote the duplicating and non-duplicating rules of a TRS R, respectively. A rewrite relation is a binary relation on terms that is closed under contexts and substitutions. For a TRS R we define → R to be the smallest rewrite relation that contains R. As usual → = , → + , and → * denotes the reflexive, transitive, and reflexive and transitive closure of →, respectively.
A relative TRS R/S is a pair of TRSs R and S with the induced rewrite relation → R/S = → * S · → R · → * S . Sometimes we identify a TRS R with the relative TRS R/∅ and vice versa. A TRS R (relative TRS R/S) is terminating if → R (→ R/S ) is well-founded. Two relations and > are called compatible if · > · ⊆ >. A monotone reduction pair ( , >) consists of a preorder and a well-founded order > such that and > are compatible and closed under contexts and substitutions. We recall how to prove relative termination incrementally according to Geser [9].
Theorem 2 A relative TRS R/S is terminating if R = ∅ or there exists a monotone reduction pair ( , >) such that R ∪ S ⊆ and (R \ >)/(S \ >) is terminating.
⊓ ⊔ A critical overlap (l 1 → r 1 , p, l 2 → r 2 ) µ of a TRS R consists of variants l 1 → r 1 and l 2 → r 2 of rewrite rules of R without common variables, a position p ∈ Pos F (l 2 ), and a most general unifier µ of l 1 and l 2 | p . If p = ǫ then we require that l 1 → r 1 and l 2 → r 2 are not variants. From a critical overlap (l 1 → r 1 , p, l 2 → r 2 ) µ we obtain a critical peak l 2 µ[r 1 µ] p ← l 2 µ → r 2 µ and a critical pair l 2 µ[r 1 µ] p ←⋊→ r 2 µ.
Let R be a left-linear TRS. If l → r ∈ R and p is a position, we call the pair π = p, l → r a redex pattern, and write l π , r π , p π for its left-hand side, right-hand side, and position, respectively. We write → π (or → pπ,lπ→rπ ) for a rewrite step at position p π using the rule l π → r π . A redex pattern π matches a term t if t| pπ is an instance of l π . If π matches t, there is a unique reduct t π with t → π t π . We let Pos F (π) = {p π q | q ∈ Pos F (l π )}. Two redex patterns π 1 and π 2 are parallel (π 1 π 2 ) if p π1 p π2 and orthogonal (π 1 ⊥ π 2 ) if Pos F (π 1 ) ∩ Pos F (π 2 ) = ∅. We write P ⊥ Q if π ⊥ π ′ for all π ∈ P and π ′ ∈ Q. Two redex patterns critically overlap if they are not orthogonal. If P is a set of pairwise parallel redex patterns matching a term t, we denote by t → P t ′ the parallel rewrite step from t to t ′ by P , where t ′ = t π1···πn if P = {π 1 , . . . , π n }. We allow P to be abbreviated to a set of positions in t → P t ′ .
We write A, {→ α } α∈I to denote the ARS A, → where → is the union of → α for all α ∈ I. Let A, {→ α } α∈I be an ARS and let > be a relation on I. We write → < α1... αn for the union of → β where β < α i for some 1 i n. We call → α and → β decreasing (with respect to and >) if An ARS A, {→ α } α∈I is decreasing if there exists a preorder and a wellfounded order > such that and > are compatible and → α and → β are decreasing for all α, β ∈ I with respect to and >.
The following theorem is a reformulation of a result obtained by van Oostrom [15] (where is the identity relation). While allowing a preorder does not add power, it is more convenient for our purposes.

Labelings for Rewrite Steps
In this section we present constraints (on a labeling) such that decreasingness of the critical peaks ensures confluence of linear (Section 3.1) and left-linear (Section 3.2) TRSs. Furthermore, we show that if two labelings satisfy these conditions then also their lexicographic combination satisfies them. For a local peak there are three possibilities (modulo symmetry): q p and p\q ∈ Pos F (l 2 ) (critical overlap), -q < p and p\q / ∈ Pos F (l 2 ) (variable overlap).
These cases are visualized in Figure 1. Figure 1(a) shows the shape of a local peak where the steps take place at parallel positions. Here we have s → p,l1→r1 t and u → p,l1→r1 v as well as s → q,l2→r2 u and t → q,l2→r2 v, i.e., the steps drawn at opposing sides in the diagram are due to the same rules. The question mark in Figure 1(b) conveys that joinability of critical overlaps may depend on auxiliary rules. Variable overlaps (Figure 1(c)) can again be joined by the rules involved in the diverging step. More precisely, if q ′ is the unique position in Labelings are used to compare rewrite steps. In the sequel we denote the set of all rewrite steps for a TRS R by Λ R and elements from this set by capital Greek letters Γ and ∆. Furthermore if Γ = s → p,l→r t then C[Γ σ] denotes the rewrite step C[sσ] → p ′ p,l→r C[tσ] for any substitution σ and context C with C| p ′ = .
Definition 4 Let R be a TRS. A labeling function ℓ : Λ R → W is a mapping from rewrite steps into some set W . A labeling (ℓ, , >) for R consists of a labeling function ℓ, a preorder , and a well-founded order > such that and > are compatible and for all rewrite steps Γ, ∆ ∈ Λ R , contexts C and substitutions σ: All labelings we present satisfy > ⊆ , which allows to avoid tedious case distinctions, and we assume this property henceforth. We do so without loss of generality, because ((> ∪ ) * , >) satisfies the conditions of Definition 4 if ( , >) does.
In the sequel W , , and > are left implicit when clear from the context and a labeling is identified with the labeling function ℓ. We use the terminology that a labeling ℓ is monotone and stable if properties 1 and 2 of Definition 4 hold. Abstract labels, i.e., labels that are unknown, are represented by lowercase Greek letters α, β, γ, and δ. We write s → π α t (or simply s → α t) if ℓ(s → π t) = α. Often we leave the labeling ℓ implicit and just attach labels to arrows. A local peak t ← s → u is called decreasing for ℓ if there are labels α and β such that t α ← s → β u, and → α and → β are decreasing with respect to and >. To employ Theorem 3 for TRSs, decreasingness of the ARS T (F , V), {→ w } w∈W must be shown.
In this article we investigate conditions on a labeling such that local peaks according to (parallel) and (variable overlap) are decreasing automatically. This is desirable since in general there are infinitely many local peaks corresponding to these cases (even if the underlying TRS has finitely many rules). There are also infinitely many local peaks according to (critical overlap) in general, but for a finite TRS they are captured by the finitely many critical overlaps. Still, it is undecidable if they are decreasingly joinable [12].
For later reference, Figure 2 shows labeled peaks for the case (parallel) (Figure 2(a)) and (variable overlap) if the rule l 2 → r 2 in (1) is linear (Figure 2(b)) and left-linear (Figure 2(c)), respectively. In Figure 2(c) the expression γ denotes a sequence of labels γ 1 , . . . , γ n . In the subsequent analysis we will always use the fact that the local peaks in Figure 2 can be closed by the rules involved in the peak (applied at opposing sides in the diagram).

Linear TRSs
The next definition presents sufficient abstract conditions on a labeling such that local peaks according to the cases (parallel) and (variable-linear) in Figure 2 are decreasing. We use the observation that the former can be seen as an instance of the latter to shorten proofs.
Definition 5 Let ℓ be a labeling for a TRS R. We call ℓ an L-labeling (for R) if for local peaks according to (parallel) and (variable-linear) we have α γ and β δ in Figures 2(a) and 2(b), respectively.
The local diagram in Figure 3(a) visualizes the conditions on an L-labeling more succinctly. We call the critical peaks of a TRS R Φ-decreasing if there exists a Φ-labeling ℓ for R such that the critical peaks of R are decreasing for ℓ.
The next theorem states that L-labelings may be used to show confluence of linear TRSs.
Theorem 6 Let R be a linear TRS. If the critical peaks of R are L-decreasing then R is confluent.
Proof By assumption the critical peaks of R are decreasing for some L-labeling ℓ. We establish confluence of R by Theorem 3, i.e., show decreasingness of the ARS T (F , V), → R where rewrite steps are labeled according to ℓ. Since R is linear, local peaks have the shape (parallel), (variable-linear), or (critical overlap). By definition of an L-labeling the former two are decreasing. Now consider a local peak according to (critical overlap), i.e., for the peak in (1) we have q p and p\q ∈ Pos F (l 2 ). Let p ′ = p\q. Then t| q ← s| q → u| q must be an instance of a critical peak l 2 µ[r 1 µ] p ′ ← l 2 [l 1 µ] p ′ = l 2 µ → r 2 µ which is decreasing by assumption. By monotonicity and stability of ℓ we obtain decreasingness of the local peak (1).

⊓ ⊔
We recall the rule labeling of van Oostrom [16], parametrized by a mapping i : R → N. Often i is left implicit. The rule labeling satisfies the constraints of an L-labeling.
Proof First we show that (ℓ i rl , N , > N ) is a labeling. The preorder N and the well-founded order > N are compatible. Furthermore ℓ i rl (s → π t) = i(l π → r π ) which ensures monotonicity and stability of ℓ i rl . Hence (ℓ i rl , N , > N ) is a labeling. Next we show the properties demanded in Definition 5. For local peaks according to cases (parallel) and (variable-linear) we recall that the steps drawn at opposite sides in the diagram, e.g., the steps labeled with α and γ (β and δ) in Figures 2(a) and 2(b), are due to applications of the same rule. Hence α = γ and β = δ in Figures 2(a) and 2(b), which shows the result.
⊓ ⊔ Inspired by [12] we propose a labeling based on relative termination.
Lemma 8 Let R be a TRS and ℓ rt (s → t) = s. Then ℓ S rt = (ℓ rt , → * R , → + S/R ) is an L-labeling for R, provided → S ⊆ → R and S/R is terminating.
Proof Let = → * R and > = → + S/R . First we show that (ℓ rt , , >) is a labeling. By definition of relative rewriting, and > are compatible and > is wellfounded by the termination assumption of S/R. Since rewriting is closed under contexts and substitutions, ℓ S rt is monotone and stable and hence a labeling. Next we show the properties demanded in Definition 5. The assumption → S ⊆ s t u v α 1 β 1 ⊓ ⊔ The L-labeling from the previous lemma allows to establish a decrease with respect to some steps of R. The next lemma allows to combine L-labelings. Let ). Furthermore (x 1 , x 2 ) 12 (y 1 , y 2 ) if and only if x 1 > 1 y 1 or x 1 1 y 1 and x 2 2 y 2 and (x 1 , x 2 ) > 12 (y 1 , y 2 ) if and only if x 1 > 1 y 1 or x 1 1 y 1 and x 2 > 2 y 2 .
Next we show that ℓ 1 × ℓ 2 satisfies the requirements of Definition 5. If ℓ 1 and ℓ 2 are L-labelings then the diagram of Figure 2(b) has the shape as in Figure 3(a) and 3(b), respectively. It is easy to see that the lexicographic combination is again an L-labeling (cf. Figure 3(c)). ⊓ ⊔

Left-linear TRSs
For left-linear TRSs the notion of an LL-labeling is introduced. 2 The following Definition exploits that Figure 2(b) is an instance of Figure 2(c).
Definition 10 A labeling ℓ for a TRS R is an LL-labeling (for R) if 1. in Figure 2(a), α γ and β δ, 2. in Figure 2(c), α γ and β δ for all permutations of the rewrite steps of u → v, where α γ means α γ i for 1 i n, and 3. in Figure 2(c), α > γ for some permutation of the rewrite steps of u → v, where α > γ means α γ 1 and α > γ i for 2 i n.
A labeling ℓ is a weak LL-labeling if the first two conditions are satisfied.
The next theorem states that LL-labelings allow to show confluence of left-linear TRSs.
Theorem 12 Let R be a left-linear TRS. If the critical peaks of R are LLdecreasing then R is confluent.
Proof By assumption the critical peaks of R are decreasing for some LLlabeling ℓ. We establish confluence of R by Theorem 3, i.e., we show decreasingness of the ARS T (F , V), → R by labeling rewrite steps according to ℓ. By definition of an LL-labeling local peaks according to (parallel) and (variableleft-linear) are decreasing. The reasoning for local peaks according to (critical overlap) is the same as in the proof of Theorem 6.
⊓ ⊔ The rule labeling from Lemma 7 is a weak LL-labeling but not an LLlabeling since in Figure 2(c) we have α = γ i for 1 i n which does not satisfy α > γ if n > 1. (See also [12,Example 9].) We return to this problem and propose two solutions (in Sections 3.2.4 and 4) after presenting simpler (weak) LL-labelings based on measuring duplicating steps (Section 3.2.1), the context above the contracted redex (Section 3.2.2), and the contracted redex (Section 3.2.3).

Measuring duplicating steps
The L-labeling from Lemma 8 can be adapted to an LL-labeling. Figures 2(a) and 2(c). We have > ⊆ . Hence α γ and α δ in Figure 2(a) and, if l 2 → r 2 in (1) is linear, also in Figure 2(c) as γ is empty or γ = γ in this case. If l 2 → r 2 is not linear then it must be duplicating and hence α > γ i for 1 i n. Because α δ, ℓ R d rt is an LL-labeling for R. ⊓ ⊔ To combine the previous lemma with the rule labeling we study how different labelings can be combined.
From Theorem 12 and Lemmata 13 and 14 we obtain the following result.

Corollary 16
Let R be a left-linear TRS. If R d /R nd is terminating and all critical peaks of R are weakly LL-decreasing then R is confluent.
Proof By Lemma 13 ℓ R d rt is an LL-labeling. By assumption the critical peaks of R are decreasing for some weak LL-labeling ℓ. By Lemma 14 also ℓ R d rt × ℓ is an LL-labeling. It remains to show decreasingness of the critical peaks for ℓ R d rt × ℓ. This is obvious since for terms s, t, u with s Hence decreasingness for ℓ implies decreasingness for ℓ R d rt × ℓ. Confluence of R follows from Theorem 12.

⊓ ⊔
We revisit the example from the introduction.

Example 17
Recall the TRS R from Example 1. The polynomial interpretation shows termination of R d /R nd . It is easy to check that ℓ i rl with i(3) = i(6) = 2, i(4) = i(10) = 1, and i(l → r) = 0 for all other rules l → r ∈ R establishes decreasingness of the 34 critical peaks. For example, the peaks can be joined decreasingly as follows: The next example is concise and constitutes a minimal example to familiarize the reader with Corollary 16.
Example 18 Consider the TRS R consisting of the three rules The rule labeling that takes the rule numbers as labels shows the only critical peak decreasing, Hence we obtain the confluence of R by Corollary 16.

Remark 19
Using ℓ i rl (·) = 0 as weak LL-labeling, Corollary 16 gives a condition (termination of R d /R nd ) such that t → = u or u → = t for all critical pairs t ←⋊→ u implies confluence of a left-linear TRS R. This partially answers one question in RTA LooP #13. 3

Measuring the context above the contracted redex
In [16,Example 20] van Oostrom suggests to count function symbols above the contracted redex, demands that this measurement decreases for variables that are duplicated, and combines this with the rule labeling. Consequently local peaks according to Figure 2(c) are decreasing. Below we exploit this idea but incorporate the following beneficial generalizations. First, we do not restrict to counting function symbols (which has been adopted and extended by Aoto in [1]) but represent the constraints as a relative termination problem. This abstract formulation allows to strictly subsume the criteria from [1,16] (see Section 5) because more advanced techniques than counting symbols can be applied for proving termination. Additionally, our setting also allows to weaken these constraints significantly (cf. Lemma 27).
The next example motivates the need for an LL-labeling that does not Example 20 Consider the TRS R consisting of the six rules Since the duplicating rule admits an infinite sequence, Corollary 16 cannot succeed.
In the sequel we let G be the signature consisting of unary function symbols f 1 , . . . , f n for every n-ary function symbol f ∈ F .
We define a partial mapping ⋆ from terms in the original signature and positions T (F , V) × N * + to terms in T (G, V) as follows: and |r| y 1.
The next example illustrates the transformation ⋆(·).

Example 22 Consider the TRS
and the TRS R ⋆ = which is empty.
Due to the next lemma a termination proof of ⋆(R) yields an LL-labeling.

Lemma 23
Let R be a TRS and ℓ ⋆ (s → π t) = ⋆(s, p π ). Then (ℓ ⋆ , , >) is an LL-labeling, provided ( , >) is a monotone reduction pair, R ⋆ > ⊆ >, and Proof Because ( , >) is a monotone reduction pair, (ℓ ⋆ , , >) is a labeling for R. Note that monotonicity and stability are with respect to the signature G. To see that the constraints of Definition 10 are satisfied we argue as follows.
For Figure 2(a) we have α = γ and β = δ because the steps drawn at opposing sides in the diagram take place at the same positions and the function symbols above these positions stay the same. Next we consider Figure 2(b), i.e., the right linear case. Recall the peak (1). Again we have β = δ because q < p. To see α γ consider the step s → q,l2→r2 u and let q ′ be the unique position in then there is no step and we are done. Otherwise let q ′′ be the position in r 2 with |r 2 | q ′′ = x. By construction R ⋆ = contains the rule ⋆(l 2 , q ′ ) → ⋆(r 2 , q ′′ ). Combining the assumption R ⋆ = ⊆ with monotonicity and stability of ℓ ⋆ yields ⋆(s, p) ⋆(u, qq ′′ r), i.e., α γ. Next we consider Figure 2(c) for the duplicating case. Recall the peak (1). Again we have β = δ because q < p. To see α > γ (for any permutation of the steps) consider the step s → q,l2→r2 u and let q ′ be the unique position in Pos V (l 2 ) such that qq ′ r = p for some position r.
Combining the assumption R ⋆ > ⊆ > with monotonicity and stability of ℓ ⋆ yields ⋆(s, p) > ⋆(u, p ′ i ) for p ′ i ∈ P . Since u → P v we obtain α > γ i for 1 i n and hence the desired α > γ.

Remark 24
It is also possible to formulate Lemma 23 as a relative termination criterion without the use of a monotone reduction pair. However, the monotone reduction pair may admit more labels to be comparable (in the critical diagrams) because of the inclusions From Lemma 23 we obtain the following corollary.
Corollary 25 Let R be a left-linear TRS and let ℓ be a weak LL-labeling. Let orients both rules in R ⋆ > strictly. To show decreasingness of the three critical peaks (two of which are symmetric) we use the labeling ℓ ⋆ × ℓ i rl with i(f(h(x)) → h(g(f(x), x, f(h(a))))) = 1 and all other rules receive label 0. For the moment we label a step s → π t with the interpretation of ⋆(s, p π ). E.g., a which allows to prove confluence of R by Corollary 25.
By definition of α > γ (cf. Definition 10) we observe that the definition of ⋆(R) can be relaxed. If can be put in R ⋆ = (since the steps labeled γ in Figure 2(c) are at parallel positions we can choose the first closing step such that α γ 1 ). This improved version of We obtain the following variant of Lemma 23.
Obviously any ⋆ ⋆ (R) inherits termination from ⋆(R). The next example shows that the reverse statement does not hold. In Section 6 we show how the intrinsic indeterminism of ⋆ ⋆ (R) is eliminated in the implementation.
Example 28 Consider the TRS R from Example 1. The TRS R ⋆ > consists of the rules while R ⋆ = consists of the rules Let R ⋆ † denote the rules in R ⋆ > marked with †. Termination of ⋆(R) cannot be established (because R ⋆ † is non-terminating) but we stress that moving these rules into R ⋆ = yields a valid ⋆ ⋆ (R) which can be proved terminating by the polynomial interpretation with that interprets the remaining function symbols by the identity function. We remark that Corollary 25 with the labeling from Lemma 27 establishes confluence of R. Since all reductions in the 34 joining sequences have only + above the redex and + 1N (x) = + 2N (x) = x, the ℓ ⋆ labeling attaches x to any of these steps. The rule labeling that assigns i(3) = i(6) = 2, i(4) = i(10) = 1, and 0 to all other rules shows the 34 critical peaks decreasing.

Measuring the contracted redex
Instead of the labeling ℓ ⋆ , which is based on the context above the contracted redex, one can also use the contracted redex itself for labeling.
Proof Because ( , >) is a monotone reduction pair, (ℓ △ , , >) is a labeling for R. To see that the constraints of Definition 10 are satisfied we argue as follows. For Figure 2(a) we have α = γ and β = δ. For Figure 2(c) we have α = γ 1 = · · · = γ n (since the same redex is contracted) and β δ by the assumption R ⊆ and monotonicity and stability of .
⊓ ⊔ The following definition collects the constraints, such that variable overlaps can be made decreasing.
Definition 30 For a TRS R let R △ = {l → x | l → r ∈ R and |r| x > 1}.
Due to the next result a termination proof of R △ /R enables a weak LLlabeling to establish confluence.
Corollary 31 Let R be a left-linear TRS and let ℓ be a weak LL-labeling. Let ( , >) be a monotone reduction pair showing termination of R △ /R. If the critical peaks of R are decreasing for ℓ △ × ℓ then R is confluent.
Proof Note that ℓ △ × ℓ is a weak LL-labeling (cf. Remark 15). Next we show decreasingness. For Figure 2(a) we have α = γ and β = δ since the same redexes are contracted. For Figure 2(b) again α = γ while the assumption ⊆ R ensures β δ. Finally, in the duplicating case of Figure 2(c) we have β > α by the relative termination assumption and since α γ i we obtain β > γ i and hence decreasingness.
⊓ ⊔ Remark 32 Note that the labeling ℓ △ × ℓ from Corollary 31 is not an LLlabeling. The point is that there are multiple ways of ensuring decreasingness of Figure 2(c). For LL-labelings, we use α > γ, while in Corollary 31, β > γ i for 1 i n does the job. This is also the reason why ℓ × ℓ △ cannot be used in Corollary 31. Consider the TRS with the rules 1 : f(x) → g(x, x) and 2 : a → b. Let ℓ rl be the rule labeling attaching the rule numbers as labels. Then the variable overlap is not decreasing for ℓ rl × ℓ △ .
We demonstrate Corollary 31 on the TRS from Example 18.
Example 33 Consider the TRS from Example 18. The polynomial interpretation establishes relative termination of {f(g(x, a)) → x}/R and shows the critical peak decreasing when labeling steps with the interpretation of the redex, i.e., , f(x)) = u for the peak and t → 0 f(g(x, a)) → (2x+2y+1) 2 u for the join.

Exploiting Persistence
In this section we show how to exploit persistence of confluence [3,8]  Definition 34 Let S be a set of sorts equipped with a partial order ≤. A signature F , V is S-sorted if every n-ary function symbol f ∈ F is equipped with a sort declaration α 1 × · · · × α n → α where α 1 , . . . , α n , α ∈ S and every variable x ∈ V has exactly one sort α ∈ S. We write S(f ) = α, S(f, i) = α i for 1 i n, and S(x) = α, respectively. We let V α = {x ∈ V | S(x) = α} and require that V α is infinite for all α ∈ S. The set of S-sorted terms, T S (F , V), is the union of the sets T α (F , V) for α ∈ S that are inductively defined as follows: The notion of S-sorted terms properly extends many-sorted terms. Indeed, if we let ≤ be the identity relation then T ≤α (F , V) = T α (F , V), which means that the i-th argument of f in an S-sorted term must have sort S(f, i).

Definition 35
We extend S(·) and S(·, ·) to S-sorted terms t and non-root We are particularly interested in the case where rewriting restricted to Ssorted terms coincides with ordinary rewriting with initial terms restricted to S-sorted ones. This property is captured by S-compatible TRSs.
Definition 37 A TRS R is S-compatible if for every rule l → r ∈ R there exists a sort α ∈ S such that l ∈ T α (F , V) and r ∈ T ≤α (F , V), and S(l, p) = S(l| p ) for all p ∈ Pos V (l).
Lemma 38 If R is S-compatible then T S (F , V) and T ≤α (F , V) for every α ∈ S are closed under rewriting by R.
Proof This is easily proved by induction. The key observation is that t → R t ′ implies S(t) = S(t ′ ) unless the rewrite step happens at the root. In the latter case, S(t ′ ) ≤ S(t). In either case, t ∈ T ≤α (F , V) implies t ′ ∈ T ≤α (F , V).
⊓ ⊔ The following result is a special case of [8, Theorem 6.2].

Theorem 39 An S-compatible left-linear TRS R is confluent on T (F , V) if and only if it is confluent on T S (F , V). ⊓ ⊔
Example 40 Consider the duplicating TRS R with rules Recall that L-labelings (in particular, rule labelings) that are not LL-labelings are not applicable to non-linear TRSs because the variable overlap diagram (Figure 2(c)) is not decreasing. Let S = {0, 1} with the following sort declarations: x : 0 The TRS R is S-compatible and hence we may restrict rewriting to S-sorted terms without affecting confluence by Theorem 39. This has the beneficial effect that variable overlaps are ruled out. To see how, note that no subterms of sort 1 can appear inside terms of sort 0. Consider the left-hand side f(x) of R. We have S(f(x), 1) = 0, so that any term substituted for x must have sort 0. Further note that both left-hand sides have sort 1. Consequently, no rule application may be nested below f(x) → g(f(x), f(x)) and hence variable overlaps are ruled out. Therefore, we may use L-labelings to show confluence of R even though R is not linear, and in fact the rule labeling which takes the rule numbers as labels allows us to join the sole (modulo symmetry) critical peak Formally, we define T α (F , V) = {t | t t ′ for some t ′ ∈ T ≤α (F , V)}, to capture which terms may occur as subterms of terms of sort α or below.
Theorem 41 Let R be a left-linear S-compatible TRS such that the variable l| p occurs at most once in r whenever l → r ∈ R and l ′ → r ′ ∈ R with l ′ ∈ T S(l,p) (F , V) for some p ∈ Pos V (l). Then R is confluent if all its critical peaks R are L-decreasing.
Proof By Theorem 39 we may restrict rewriting to S-sorted terms. The proof follows that of Theorem 6, except in the analysis of local peaks, where rightlinearity of R is used, which is not among our assumptions. Instead, we argue as follows: Since R is left-linear, any local peak has the shape (parallel), (critical overlap), or (variable-left-linear). In the latter case, the step s → q,l ′ →r ′ t is nested below s → p,l→r u, and it is easy to see that this implies l ′ ∈ T S(l,q ′ ) (F , V) for some variable position q ′ of l such that pq ′ q. Consequently the variable x = l| q ′ occurs at most once in r by assumption, and the parallel step (which contains one rewrite step for every occurrence of x in r) is empty or a single step, resulting in a decreasing diagram.
⊓ ⊔ As a refinement of Theorem 41, instead of ruling out duplicating (variableleft-linear) overlaps completely, we can also add additional constraints on the labeling for the remaining variable overlaps.
Definition 42 Let ℓ be a weak LL-labeling for an S-compatible TRS R. We call ℓ persistent if whenever l ′ ∈ T S(l,p) (F , V) for some p ∈ Pos V (l), either |r| l|p 1 or β > γ in Figure 2 for all resulting variable overlaps with l ′ → r ′ below l → r.
Theorem 43 Let R be a left-linear TRS. If the critical peaks of R are persistent weak LL-decreasing then R is confluent.
Proof The proof follows along the lines of the proof of Theorem 41. In the case of a duplicating variable-left-linear overlap, the additional constraints ensure that the resulting diagram is decreasing.
⊓ ⊔ Example 44 Suppose we extend the TRS from Example 40 with the rule a → b, using the same sorts: Theorem 41 is no longer applicable, because rule 3 may be nested below rule 1, which is duplicating. However, by the preceding remark, any rule labeling with ℓ i rl (1) > ℓ i rl (3) will make the corresponding variable overlaps decreasing.

Labelings for Parallel Rewriting
In this section, rather than labeling individual rewrite steps, we will label parallel rewrite steps instead. This is inspired by the parallel moves lemma, which says that any peak t ← s → u of two non-overlapping parallel rewrite steps can be joined in a diamond as t → · ← u, and diamonds are comparatively easy to label decreasingly, as we saw in Section 3.1.
The main problem is to label parallel steps such that variable overlaps are decreasing. The multiset of the single steps' labels does not work since {α} mul {α, . . . , α}. Hence we use sets to label parallel steps which we denote by capital Greek letters. Sets of labels are ordered by the Hoare preorder of ( , >), which we denote as ( H , > H ) defined by For readability we drop the subscript H when attaching labels to rewrite steps as in → The following lemma states obvious properties of Hoare preorders which we implicitly use in the sequel.

If ( , >) is a monotone reduction pair then
As we have seen in Section 3.2, constructing LL-labelings is quite a bit harder than constructing L-labelings, because of the duplicated steps in the variable-left-linear case (Figure 2(c)). Here, we use weak LL-labelings for labeling single and parallel rewrite steps. Throughout this section we assume a given left-linear TRS R, and a weak LL-labeling ℓ with corresponding labeling function for parallel steps ℓ , as introduced in the following definition.
Definition 47 We lift a weak LL-labeling ℓ to parallel steps t → P t ′ as follows. For each π ∈ P , we have a rewrite step t → π t π . We label t → P t ′ by ℓ (t → P t ′ ) = {ℓ(t → π t π ) | π ∈ P }.
So a parallel rewrite step is labeled by the set of the labels of the single steps making up the parallel step. We indicate labels along with the step, writing t → P Γ t ′ . The next example shows that the labels change when decomposing a parallel step into a sequence of single steps, i.e., the label of the parallel step may be different from the union of labels of the single steps. However, the proof of Lemma 49 reveals that for weak LL-labelings the labels never increase when sequencing a parallel step. Lemma 49 Fig. 4: Weak LL-labeling applied to parallel steps.
Proof 1. First note that since P Q, a term u with s → P ∪Q u exists. We have we use induction on |P | + |Q|. We consider several base cases. If |P | = 0 or |Q| = 0 then the result follows by definition of parallel rewriting. If |P | = |Q| = 1 the result follows from the fact that ℓ is a weak LL-labeling, Definition 10(1) (Figure 2(a)). For the induction step, assume without loss of generality that |P | > 1 and let P = {π} ⊎ P ′ . The proof is illustrated in Figure 4. The parallel P -step can be decomposed into a π-step and a P ′ -step. Since {π}, P ′ ⊆ P , the labels are less than or equal to Γ . We apply the induction hypothesis to the peaks {π} Γ ← t 2 → P ′ Γ t P ′ 2 yielding t 2 → P Γ u, noting that the union of two sets from Γ is again in Γ , and finally t 1 The existence of parallel rewrite steps sσ ′ → s ′ σ ′ and s ′ σ → s ′ σ ′ follows easily from the definition of parallel steps. Again, Γ H Γ ′ and ∆ H ∆ ′ can be established by induction on the size of the parallel rewrite steps, this time using the variable overlap property Definition 10(2) in the base case. Now if σ(x) = σ ′ (x) for all x ∈ Var(s ′ | Q ), then s ′ σ → P ′ s ′ σ ′ satisfies P ′ Q. Performing the same rewrite steps on sσ, we obtain a parallel rewrite step sσ → P ′ s ⋆ with P ′ ⊆ P and therefore Γ ⋆ = ℓ (sσ → P ′ s ⋆ ) ⊆ ℓ (sσ → P sσ ′ ) = Γ . Finally, using the first part of this lemma, we can combine the two parallel steps from sσ into a single one, sσ Proof Assume that ℓ is a weak LL-labeling. The first condition of this lemma is identical to Definition 10(1). For the second condition, β δ follows from Definition 10(2). To establish {α} H ℓ (u → P v), we need to show that α ℓ(u → π u π ) for all π ∈ P . For each π, we can arrange that ℓ(u → π u π ) = γ 1 by choosing u → π u π as the first step in the permutation of u → v, and then α γ 1 follows from Definition 10(2), establishing the claim.
Next assume that ℓ satisfies the conditions of this lemma. Then Definition 10(1) holds. To show Definition 10(2), note that β δ holds by assumption. Consider the parallel rewrite step u → P v and a permutation π 1 , . . . , π n of P . We can decompose u → P v into u → π1 γ1 · · · → πn γn v. By Lemma 49(1) applied to the peaks The following lemma is used to reduce the number of parallel peaks that have to be considered in the proof of Theorem 54.
Lemma 51 Let s → * < Γ · → ∆ · → * < Γ ∆ t and s → * < Γ · → ∆ · → * < Γ ∆ u be two rewrite sequences such that all rewrite steps in the sequence to t are at or below a position p and the rewrite steps in the sequence to u are parallel to p. Then the two rewrite sequences can be merged into s → * Proof Let the two sequences be s → * Using Lemma 49(1) repeatedly, we can derive a sequence which establishes the claim.

⊓ ⊔
In order to perform a critical pair analysis for parallel rewrite steps, we need parallel critical pairs [10,21]. Fig. 5: Part of the proof of Theorem 54.
Definition 52 Let l → r be a rule in a TRS R and P be a non-empty set of pairwise parallel redex patterns such that every π ∈ P overlaps with l. By choosing variants of rules from R appropriately, we may assume that the sets Var(l π ) for π ∈ P and Var(l) are pairwise disjoint. Assume that the unification problem {l| pπ ≈ l π | π ∈ P } has a solution and let σ be a most general unifier. Then there is a unique term l P such that lσ → P l P . We call l P ← ⋊→ rσ a parallel critical pair, and l P ← lσ → rσ a parallel critical peak.
Note that every standard critical pair also is a parallel critical pair. The following lemma states how critical pair analysis for a peak consisting of a parallel and a root rewrite step is done.
Lemma 53 Let R be a left-linear TRS and t P ← s → π u with p π = ǫ. Then either P ⊥ π or there are substitutions σ → σ ′ and a parallel critical pair Note that left-linearity is essential for the substitutions σ and σ ′ to exist in Lemma 53. We are now ready to state and prove the main theorem of this section.
Theorem 54 A left-linear TRS R is confluent if all its parallel critical peaks t P Γ ← s → ∆ u can be joined decreasingly as Proof We show that → is decreasing, which implies confluence of R. Let t P Γ ← s → Q ∆ u with Γ, ∆ ⊆ W . It suffices to show that Below we show that (2) holds whenever P = {π} or Q = {π} with p π = ǫ. Then for all p ∈ min {p π | π ∈ P ∪ Q}, t P Γ ← s → Q ∆ u induces a peak t| p P ′ Γ0 ← s| p → Q ′ ∆0 u| p , where P ′ = {π} or Q ′ = {π} for some π with p π = ǫ. So for each p, we obtain a joining sequence for t| p and u| p of shape (2). By the monotonicity of labelings, this results in joining sequences which are mutually parallel since the positions p ∈ min(P ∪ Q) are mutually parallel. By repeated application of Lemma 51 those sequences can be combined into a single sequence of the same shape. In order to show (2) for P = {π} or Q = {π} with p π = ǫ, assume without loss of generality that Q = {π}. If P ⊥ π then s = l π σ and, because l π is linear, there is a substitution σ ′ with t = l π σ ′ and σ(x) → σ ′ (x) for all variables x ∈ V. We conclude by Lemma 49(2). Otherwise P and π overlap, and by Lemma 53, there are a parallel critical peak t ′ P ′ ← s ′ → u ′ and substitutions σ, σ ′ such that σ → σ ′ and This case is illustrated in Figure 5. By assumption there are u ′′ , v and v ′ with Var(v| Q ′ ) ⊆ Var(s| P ′ ) such that we can join t ′ and u ′ decreasingly, and consequently, using the stability of labelings we obtain Furthermore, making repeated use of Lemma 49 (2), We have σ(x) = σ ′ (x) for x ∈ Var(s| P ′ ) for otherwise s → Γ t would not be a parallel step. Together with Var(v| Q ′ ) ⊆ Var(s| P ′ ), the parallel steps u ′′ σ → Γ vσ and vσ → Γ vσ ′ can be combined into a single → Γ step by Lemma 49(2). Thus we can join t and u decreasingly with common reduct v ′ σ ′ , completing the proof.

⊓ ⊔
To conclude the section we demonstrate Theorem 54 on two examples. Both are based on rule labeling.
Example 55 Consider the TRS R consisting of the following five rules with labels 2 > 1 > 0: There are six parallel critical peaks that can all be joined decreasingly as required by Theorem 54: c Therefore, R is confluent.
Example 56 Let R be the TRS (Cops #62) consisting of the (labeled) rules There are 12 critical pairs, 6 of which are trivial. One easily verifies that the remaining 6 pairs can be joined decreasingly, using the order 1 > 0. Hence the confluence of R follows from Theorem 54.

Assessment
In this section we relate the results from this article to each other (Section 5.1) and to the recent literature [1,12] (Section 5.2).  Example 57 It is easy to adapt the TRS from Example 18 such that ⋆(R) becomes non-terminating. Consider the TRS R

Interrelationships
for which termination of R d /R nd and decreasingness of the critical peaks is proved similar to Example 18. Note that f 1 (g 1 (x)) → g 2 (f 1 (g 1 (x))) ∈ R ⋆ > is non-terminating. 4 Example 20 shows that Corollary 16 does not subsume Corollary 31 while the following example rules out the reverse implication.
Example 58 Next consider the TRS consisting of the rules The derivation a(a(c)) → a(b(a(c))) → △ a(a(c)) → · · · shows that R △ /R is non-terminating. On the other hand, R (and hence R d /R nd ) is terminating as shown by the following matrix interpretation over N 2 : Furthermore, the TRSs in Examples 57 and 58 clarify the relationship of Corollaries 25 and 31. Hence neither of Corollaries 16, 25, and 31 yields a necessary confluence criterion for left-linear systems. Taking the direct sum (after renaming function symbols) of the TRSs which show that neither criterion subsumes the other is confluent by Toyama's celebrated modularity result [20]. But the combined TRS does not satisfy either precondition of our corollaries.
Next we compare the results for rewrite steps (Theorem 6), persistence (Theorem 43) and parallel rewriting (Theorem 54) where we use the rule labeling as underlying L-labeling.
Clearly Theorem 6 is subsumed by Theorem 41 for rule labelings, which in turn is subsumed by Theorem 43 for rule labelings. The next two examples show that persistence does not subsume the parallel version, and that the parallel version does not subsume the plain version for linear TRSs (because of the variable condition).
Example 59 For the TRS consisting of the rules the variable overlap of rule 1 with itself cannot be ruled out using persistence. Hence in Theorem 43, we get an unsatisfiable constraint 1 > 1 on the rule labels. However the rule labeling based on parallel rewriting (Theorem 54) is successful taking the rule numbers as labels.
Example 60 Consider the linear TRS consisting of the single rule Note that all steps are labeled the same, because they use the same rule. There is only one (parallel) critical peak, ((z + y) + x) + u ← ((x + y) + z) + u → (u + z) + (x + y), which may be joined as ((z + y) + x) + u → ((x + y) + z) + u ← (u + z) + (x + y). Confluence of R can be established by Theorem 6 using the rule labeling from Lemma 7. On the other hand, trying to use Theorem 54 fails for this joining sequence, because Var(((z + y) + x) + u) ⊆ Var((z + y) + x). All other ways of joining the critical peak fail to be decreasing because they require more than one parallel rewrite step from ((z + y) + x) + u or (u + z) + (x + y), e.g. ((z + y) + x) + u → ((x + y) + z) + y → (y + z) + (x + y).

Related work
In this section we relate our results to [1,12].
To compare our setting with the main result from [12] we define the critical pair steps CPS(R) = {s → t, s → u | t ← s → u is a critical peak of R}. Furthermore let CPS ′ (R) be the critical pair steps which do not give rise to trivial critical pairs.
Using the LL-labeling ℓ PCPS ′ (R) rt from Theorem 54 we obtain the following corollary. Here PCPS ′ (R) are the parallel critical pair steps which do not give rise to trivial parallel critical pairs.
Corollary 62 A left-linear TRS R whose parallel critical pairs are joinable is confluent if PCPS ′ (R)/R is terminating.
Proof We need to show that the relative termination assumption eliminates the variable condition in Theorem 54. If PCPS ′ (R)/R is terminating then for any (non-trivial) parallel critical peak t P Γ ← s → ∆ u we obtain t → * < Γ · * < ∆ ← u, hence Q can be chosen to be empty and ∅ = Var(v| ∅ ) ⊆ Var(s| P ) trivially holds. 5 ⊓ ⊔ We stress that despite the preconditions in Corollary 62 being stronger than the ones in Theorem 61, this does not harm applicability in practice. To this end observe that termination of PCPS ′ (R)/R is equivalent to termination of CPS ′ (R)/R. Furthermore joinability of the parallel critical pairs is a necessary condition for confluence just as local confluence is.
Due to the flexibility of the ℓ S rt labeling we can also choose S to be (a subset of) the critical diagram steps CDS(R) = {s → t i , s → u j | t 0 ← s → u 0 is a critical peak in R, t 0 → * t n = u m * ← u 0 , 0 i n, and 0 j m}. Using CDS(R) allows to detect a possible decrease also somewhere in the joining part of the diagrams. 6 This incorporates (and generalizes) the idea of critical valleys [17]. However, we remark that our setting does not (yet) follow another recent trend, i.e., to drop development closed critical pairs (see [11,17]). We leave this for future work.
Next we show that Corollary 25 generalizes the results from [1,Sections 5 and 6]. It is not difficult to see that the encoding presented in [1,Theorem 5.4] can be mimicked by Corollary 25 where linear polynomial interpretations over N of the shape as in (1) ( are used to prove termination of ⋆(R) and ℓ ⋆ × ℓ rl is employed to show LLdecreasingness of the critical peaks. In contrast to [1,Theorem 5.4], which explicitly encodes these constraints in a single formula of linear arithmetic, our abstract formulation has the following advantages. First, we do not restrict to weight functions but allow powerful machinery for proving relative termination and second our approach allows to combine arbitrarily many labelings lexicographically (cf. Lemma 14). Furthermore we stress that our abstract treatment of ⋆(R) allows to implement Corollary 25 based on ⋆ ⋆ (R) (cf. Section 6) which admits further gains in power (cf. Example 1 as well as Section 7). The idea of the extension presented in [1, Example 6.1] amounts to using ℓ rl × ℓ ⋆ instead of ℓ ⋆ × ℓ rl , which is an application of Lemma 14 in our setting. Finally, the extension discussed in [1, Example 6.3] suggests to use linear polynomial interpretations over N of the shape as in (2) to prove termination of ⋆(R). Note that these interpretations are still weight functions. This explains why the approach from [1] fails to establish confluence of the TRSs in Examples 18 and 20 since a weight function cannot show termination of the rules f 1 (g 1 (x)) → g 1 (f 1 (x)) and f 1 (h 1 (x)) → h 1 (g 1 (f 1 (x))), respectively.
Note that both recent approaches [1,12] based on decreasing diagrams fail to prove the TRS R from Example 1 confluent. The former can, e.g., not cope with the non-terminating rule × 1 (x) → + 0 (× 1 (x)) in R ⋆ > (cf. Example 28) while overlaps with the non-terminating rule x + y → y + x ∈ R prevent the latter approach from succeeding. In contrast, Examples 17 and 28 give two confluence proofs based on our setting.

Implementation
In this section we sketch how the results from this article can be implemented.
Before decreasingness of critical peaks can be investigated, the critical pairs must be shown to be convergent. For a critical pair t ←⋊→ u in our implementation we consider all joining sequences such that t → n · n ← u and there is no smaller n that admits a common reduct. While in theory longer joining sequences might be easier to label decreasingly, preliminary experiments revealed that the effort due to the consideration of additional diagrams decreased performance.
To exploit the possibility for incremental confluence proofs by lexicographically combining labels (cf. Lemmata 9 and 14) our implementation labels rewrite steps with lists of labels. While the labels according to ℓ rt can be chosen to be natural numbers (see below) this trick does not extend to ℓ ⋆ (see Remark 64). Since our labeling functions are implemented by encoding the constraints in non-linear (integer) arithmetic it is straightforward to combine existing labels (some partial progress) with the search for a new labeling that shows the critical peaks decreasing.
It is straightforward to implement Corollary 16. After establishing termination of R d /R nd (e.g., by an external termination prover) any weak LL-labeling can be tried to show the critical peaks decreasing. In [1,12] it is shown how the rule labeling can be implemented by encoding the constraints in linear arithmetic.
We sketch how to implement the labeling ℓ S rt from Lemma 8 as a relative termination problem. First we fix a suitable set S, i.e., the critical diagram steps (see Section 5). Facing the relative termination problem S/R we try to simplify it according to Theorem 2 into some S ′ /R ′ . Note that it is not necessary to finish the proof. By Theorem 2 the relative TRS (S \ S ′ )/R is terminating and hence by Lemma 8 ℓ S\S ′ rt is an L-labeling. Let = → * R and > = → + (S\S ′ )/R . Since and > can never increase by rewriting, it suffices to exploit the first decrease with respect to >. Next we show how critical diagrams are labeled with natural numbers. Consider a rewrite sequence v 1 → R v 2 → R · · · → R v l . Take the smallest k such that v 1 → v k+1 ∈ S but v 1 → v k+1 / ∈ S ′ and set ℓ rt (v i → v i+1 ) = 1 for 1 i k and ℓ rt (v i → v i+1 ) = 0 for k < i < l. If no such k exists set ℓ rt (v i → v i+1 ) = 1 for 1 i < l. We demonstrate the above idea on an example.
Example 63 Consider the following TRS R from [4]: We show how the labels for the critical peak H(I(J(x))) 1 ← H(I(x)) → 1 K(J(x)) and the joining sequences H(I(J(x))) → 1 K(J(J(x))) → 0 K(J(K(J(x)))) 1 ← K(J(x)) can be established by ℓ S rt . Let S be the TRS consisting of the critical diagram steps from the above diagram, i.e., H(I(x)) → H(I(J(x))) H(I(x)) → K(J(J(x))) H(I(x)) → K(J(x)) H(I(x)) → K(J(K(J(x)))) The interpretation K N (x) = H N (x) = J N (x) = x and I N (x) = x + 1 allows to "simplify" termination of the problem S/R according to Theorem 2. Since the rules that reduce the number of I ′ s are dropped from S (and R), those rules admit a decrease in the labeling.
The above trick does not work to implement Corollary 25, since s Here the solution is to employ only techniques (for proving the relative TRS ⋆(R) terminating) that can label a rewrite step with a concrete number. To this end we use matrix interpretations [6] which are a very powerful method for proving termination of relative rewrite systems that allow to compute a variant of ℓ ⋆ .

Remark 64
We use the following encoding to avoid matrix interpretations as labels. Let the local peak have labels t α1 ← s → α2 u. Then a step v → γ w is labeled by the pair ( Here ? means that the labels are incomparable, e.g., consider the interpretations 2x + 1 ?x + 2. As a matter of fact, our previous implementation (reported in [25]) had a bug, as it did not track incomparable labels properly.
Finally, we explain why ⋆ ⋆ (R) need not be computed explicitly to implement Corollary 25 with the labeling from Lemma 27. The idea is to start with ⋆(R) and incrementally prove termination of R ⋆ > /R ⋆ = until some S 1 /S 2 is reached. If all left-hand sides in S 1 are distinct then they must have been derived from different combinations (l, x) with l → r ∈ R and x ∈ Var(l). 7 Hence they are exactly those rules which should be placed in R ⋆ = . We show the idea by means of an example.
Example 65 We revisit Example 1 and try to prove termination of ⋆(R). By an application of Theorem 2 with the interpretation given in Example 1 the problem is termination equivalent to R † /R ⋆ = and by another application of Theorem 2 the same proof can be used to show termination of (R ⋆ > \ R ⋆ † )/(R ⋆ = ∪ R ⋆ † ) which is a suitable candidate for ⋆ ⋆ (R) since the rules in R ⋆ † have different lefthand sides.
The implementation of the redex labeling ℓ △ is similar to the one of ℓ ⋆ . We have also implemented Theorems 41 and 43. The requirements of Theorem 41 can be checked effectively by the following characterization of t ∈ T α (F , V): Remark 66 The condition t ∈ T α (F , V) holds if and only if t is S-sorted and S(t) (≤ ∪ ⊳ 1 ) * α, where the relation ⊳ 1 on sorts relates argument types to result types: S(f, i) ⊳ 1 S(f ) for all function symbols f ∈ F of arity n and 1 i n. method pre CR(ℓ rl ) CR(ℓrt) CR Theorem 6  69  42  36  44  Theorem 41  92  46  40  48  Theorem 43  92  53  --Corollary 16  65  47  40  49  Corollary 25⋆  66  48  41  50  Corollary 25 ⋆ ⋆  69  51  43  53  Corollary 31  65  47  41  49  Theorem 54  92  55 55 57 We only implemented the simplest case of Theorem 43, where ℓ is a rule labeling. First, using Remark 66, we determine for which rules l → r ∈ R, l ′ → r ′ ∈ R, it is possible to nest l ′ → r ′ below a duplicating variable of l → r. We add constraints i(l → r) > i(l ′ → r ′ ) to our constraint satisfaction problem for the rule labeling. The hard work is done by an SMT solver.
To postpone the expensive computation (and labeling) of parallel critical pairs as long as possible we implemented Theorem 54 according the following lazy approach. We first find ordinary weak LL-labelings for the critical diagrams, as described earlier in this section. Only if confluence cannot be established by considering this weak LL-labeling for (non-parallel) critical peaks, we generate parallel critical peaks together with joining sequences. Finally, we check whether the weak LL-labeling joins all resulting diagrams (critical and parallel critical) decreasing as per Theorem 54. This check is also responsible for combining single steps into a parallel one for the joining sequence. We confess that this implementation for Theorem 54 is somewhat opportunistic but allows to reuse partial progress (the weak LL-labeling) while postponing parallel critical pairs as long as possible.

Experiments
The results from the article have been implemented and form the core of the confluence prover CSI [24]. For experiments 8 using version 0.4 of the tool we considered the current 265 Cops. In the experiments we focus on the 146 Cops which have been referenced from the confluence literature. From these systems 92 are left-linear. Our experiments have been performed on a notebook equipped with an Intel R quad core processor i7-2640M running at a clock rate of 2.8 GHz and 4 GB of main memory.
For 3 systems not even local confluence could be established within a time limit of 60 seconds. All other tests finished within this time limit. Table 2 shows an evaluation of the results from this article. The first column indicates which criterion has been used to investigate confluence. A ⋆ means that the corresponding corollary is implemented using ⋆(R) whereas ⋆ ⋆ refers  to ⋆ ⋆ (R). The column labeled pre shows for how many systems the precondition of the respective criterion is satisfied, e.g., for Theorem 6 the precondition is linearity while for Corollary 16 the precondition is termination of R d /R nd . The columns labeled CR(ℓ) give the number of systems for which confluence could be established using labeling ℓ. (For Corollary 25 implicitly ℓ ⋆ is also employed. Similarly Corollary 31 employs ℓ △ .) The column labeled CR corresponds to the full power of each result, i.e., when the lexicographic combination of all labelings is used. From the table we draw the following conclusions. On this test bed the labeling function ℓ rl can handle more systems than ℓ rt when considering single steps but for parallel rewriting both labelings succeed on equally many systems. Still, in both settings most power is obtained when using all labelings. In practice the study of parallel rewriting (Theorem 54) is beneficial. This suggests that the preconditions to obtain weak LL-labelings are severe.
-ACP is a powerful confluence prover which implements numerous confluence criteria from the literature. Its distinctive feature is the strong support for problems with AC semantics [2]. -CSI gains most of its power from the labeling framework presented here.
In addition it implements development closed critical pairs [18] and persistence [8]. Recently, the techniques introduced in [2] and [13] have also been integrated. -saigawa also heavily exploits relative termination, remarkably also to analyze confluence of non-left-linear systems [13].
From Tables 2 and 3 we conclude that our framework admits a state-ofthe-art confluence prover for left-linear systems.

Conclusion
In this article we studied how the decreasing diagrams technique can be automated. We presented conditions (subsuming recent related results) that ensure confluence of a left-linear TRS whenever its critical peaks are decreasing. The labelings we proposed can be combined lexicographically which allows incremental proofs of confluence and has a modular flavor in the following sense: Whenever a new labeling function is invented, the whole framework gains power. We discussed several situations (Examples 1, 18, 20, 57) where traditional confluence techniques fail but our approach easily establishes confluence.
We have also considered parallel rewriting resulting in a significantly more powerful approach. We leave the study of → • and the integration of development closed critical pairs as in [11,17] as future work.
Recently confluence by decreasing diagrams (for abstract rewrite systems) has been formalized in the theorem prover Isabelle/HOL [22,23]. Since the generated (incremental) labeling proofs are often impossible to check for humans it seems a natural point for future work to also formalize the labeling framework to enable automatic certification of confluence proofs. Since our setting is based on a single method (decreasing diagrams) while still powerful it offers itself as a perfect candidate for future certification efforts.