In general, ground joinability is undecidable even for terminating rewrite systems [7]. Below, we formalize two sufficient criteria.
4.1 A Simple Criterion
We start with the criterion that Bachmair et al. [3] proposed when they introduced ordered completion.
Lemma 7
(
) Suppose > is a ground total reduction order over \(\mathcal {F}\) with a minimal constant. Then, \(\mathcal {E}_{>}\) is \(\mathcal {F}\)-ground complete whenever for all \(s \approx t \in CP _{>}(\mathcal {E}^{\leftrightarrow })\) it holds that \(s \downarrow _{\mathcal {E}_{>}} t\), or \(s \approx t = (s' \approx t')\sigma \) for some \(s' \approx t' \in \mathcal {E}^{\leftrightarrow }\). \(\square \)
A minimal constant c is needed to turn arbitrary ordered rewrite steps into ordered rewrite steps over \(\mathcal {T}(\mathcal {F})\): when performing an ordered rewrite step using an equation \(u \approx v\) with \(V = \mathcal {V}\mathsf {ar}(v)\setminus \mathcal {V}\mathsf {ar}(u) \ne \varnothing \), a step over \(\mathcal {T}(\mathcal {F})\) is obtained by instantiating all variables in V to c. We illustrate the criterion on an example.
Example 1
The following equational system \(\mathcal {E}_0\) is derived by ConCon while checking infeasibility of a critical pair of the conditional rewrite system Cops #361:
In an ordered completion run, MædMax transforms \(\mathcal {E}_0\) into the following rules \(\mathcal {R}\) and equations \(\mathcal {E}\):
Ground confluence of this system can be established by means of Lemma 7. For example, the extended overlap between the first two equations gives rise to the extended critical pair
, which is just an instance of the second equation (and similarly for the other extended critical pairs).
4.2 Ground Joinability via Order Closures
The criterion discussed in Subsect. 4.1 is rather weak. For instance, it cannot handle associativity and commutativity, as illustrated next [9, Example 1.1].
Example 2
Consider the system \(\mathcal {E}\) consisting of the three equations
and the reduction order \(>_\mathsf {kbo}\) with \(w_0 = 1\) and
. The first equation can be oriented from left to right, whereas the other ones are unorientable.
We obtain the following extended critical peak from equations (2) and (1):
The resulting extended critical pair is neither an instance of an equation in \(\mathcal {E}\) nor joinable. Thus the criterion of Lemma 7 does not apply.
However, this extended critical pair is ground joinable, which we show in the following. The reduction order \(>_\mathsf {kbo}\) is contained in an \(\mathcal {F}'\)-ground total one on any extension of the signature \(\mathcal {F}' \supseteq \mathcal {F}\) (using the well-order theorem and incrementality of KBO). Thus, for any grounding substitution \(\sigma \) the terms
,
, and
are totally ordered. Suppose for instance that
. Then there is an ordered rewrite sequence witnessing joinability:
If, on the other hand,
holds, there is a joining sequence as well:
By ensuring the existence of a joining sequence for all possible relationships between
,
, and
, ground joinability can be established. Using this approach to show that all extended critical pairs are ground joinable, it can be verified that \(\mathcal {E}\) is in fact ground complete.
The ground joinability test by Martin and Nipkow [9] is based on the idea illustrated in Example 2 above: perform a case analysis by considering ordered rewriting using all extensions of > to instantiations of variables. Below, we give the corresponding formal definitions used in
. For any relation R on terms, let \(\sigma (R)\) denote the relation such that \(s\sigma \mathrel {\sigma (R)} t\sigma \) holds if and only if \(s \mathrel {R} t\).
Definition 2
(
) A closure \(\mathcal {C}\) is a mapping between relations on terms that satisfies the following properties:
-
(1)
If \(s \mathrel {\mathcal {C}(R)} t\) then \(s\sigma \mathrel {\mathcal {C}(\sigma (R))} t\sigma \), for all relations R, substitutions \(\sigma \), and terms s and t.
-
(2)
If \(R \subseteq R'\) then \(\mathcal {C}(R) \subseteq \mathcal {C}(R')\), for all relations on terms R and \(R'\).
The closure \(\mathcal {C}\) is compatible with a relation on terms R if \(\mathcal {C}(R) \subseteq R\) holds.
In the remainder of this section we assume \(\mathcal {F}\) to be the signature of the input problem, we consider an \(\mathcal {F}\)-ground total reduction order > as well as a closure \(\mathcal {C}\) that is compatible with >. Furthermore, we assume for every finite set of variables \(V \subseteq \mathcal {V}\) and every equivalence relation \(\equiv \) on V a representation function \(\mathsf {rep}_{\equiv }\) such that for any \(x \in V\) we have \(x \equiv \mathsf {rep}_{\equiv }(x)\), \(\mathsf {rep}_{\equiv }(x) \in V\) and \(x \equiv y\) implies \(\mathsf {rep}_{\equiv }(x) = \mathsf {rep}_{\equiv }(y)\). Given an equivalence relation \(\equiv \) on V, let \(\hat{\equiv }\) denote the substitution such that \(\hat{\equiv }(x) = \mathsf {rep}_{\equiv }(x)\) for all \(x \in V\).
Definition 3
(
) Given an ES \(\mathcal {E}\) and a reduction order >, terms s and t are \(\mathcal {C}\)-joinable, written \(s \downarrow _\mathcal {E}^\mathcal {C}t\), if for all equivalence relations \(\equiv \) on \(\mathcal {V}\mathsf {ar}(s,t)\) and every order \(\succ \) on the equivalence classes of \(\equiv \) it holds that
Example 3
For instance, consider the terms
and
from Example 2. One possible equivalence relation \(\equiv \) on
is given by the equivalence classes
and
; one possible order on these is
(corresponding to the second example for an order on the instantiations
and
in Example 2). By taking \(\mathcal {C}\) to be the KBO closure (see Definition 5 below), we have
and
. Using the ES \(\mathcal {E}\) from Example 2 we thus obtain the ordered rewrite sequence
Ground joinability follows from \(\mathcal {C}\)-joinability. Since this is the key result for the ground joinability criterion of this subsection, we also sketch its proof.
Lemma 8
(
) If \(s \downarrow _\mathcal {E}^\mathcal {C}t\) then \(s \downarrow ^{\textsf {g}}_{\mathcal {E}_{>}} t\).
Proof
We assume \(s \downarrow _\mathcal {E}^\mathcal {C}t\) and consider a grounding substitution \(\sigma \) to show \(s\sigma \downarrow _{\mathcal {E}_{>}} t\sigma \). There is some equivalence relation \(\equiv \) on \(\mathcal {V}\mathsf {ar}(s,t)\) such that \(x \mathrel {\equiv } y\) holds if and only if \(\sigma (x) = \sigma (y)\) for all \(x,y \in \mathcal {V}\mathsf {ar}(s,t)\). Note that this implies \(s\sigma = s\hat{\equiv }\sigma \) and \(t\sigma = t\hat{\equiv }\sigma \).
We can define an order \(\succ \) on the equivalence classes of \(\equiv \) such that \([x]_\equiv \succ [y]_\equiv \) if and only if \(\sigma (x) > \sigma (y)\). Hence \({\sigma (\succ )} \subseteq {>}\) holds, and by Definition 2(2) we have \(\mathcal {C}(\sigma (\succ )) \subseteq \mathcal {C}(>)\). Compatibility implies \(\mathcal {C}(>) \subseteq {>}\), and thus \(\mathcal {C}(\sigma (\succ )) \subseteq {>}\).
From Definition 2(1) we can show that \(u \rightarrow _{\mathcal {E}_{\mathcal {C}(\succ )}} v\) implies \(u\sigma \rightarrow _{\mathcal {E}_{\mathcal {C}(\sigma (\succ ))}} v\sigma \) for all terms u and v. So using the assumption \(s \downarrow _\mathcal {E}^\mathcal {C}t\) we can apply \(\sigma \) to a conversion of the form (1) to obtain
Ordered rewriting is monotone with respect to the order, and hence \(\mathcal {C}(\sigma (\succ )) \subseteq {>}\) implies \({\rightarrow _{\mathcal {E}_{\mathcal {C}(\sigma (\succ ))}}} \subseteq {\rightarrow _{\mathcal {E}_{>}}}\). Thus (2) implies the existence of a conversion
where the \(\leftrightarrow _{{\mathcal {E}_{>}}}\) step exists as any two \(\mathcal {F}\)-ground terms are comparable in >. \(\square \)
Note that the proof above uses the monotonicity assumption for closures (Definition 2(2)), which is not present in [9]. The following counterexample illustrates that monotonicity is indeed necessary.
Example 4
Consider the ES \(\mathcal {E}= \{\mathsf {f}(x) \approx \mathsf {a}\}\) and suppose that \({>} = \mathcal {C}(>)\) is an LPO with precedence \(\mathsf {a}> \mathsf {b}> \mathsf {c} > \mathsf {f}\). Moreover, take \(s = \mathsf {f}(\mathsf {b})\) and \(t = \mathsf {f}(\mathsf {c})\). Any order \(\succ \) as in Definition 3 is empty since \(\mathcal {V}\mathsf {ar}(s,t) = \varnothing \). As \(\mathcal {C}\) is not required to be monotone, the relation \(\mathcal {C}(\succ )\) may contain \((\mathsf {f}(\mathsf {b}),\mathsf {a})\) and \((\mathsf {f}(\mathsf {c}),\mathsf {a})\). Then \(s \rightarrow _{\mathcal {E}_{\mathcal {C}(\succ )}} \mathsf {a}\) and \(t \rightarrow _{\mathcal {E}_{\mathcal {C}(\succ )}} \mathsf {a}\) imply \(s \downarrow _\mathcal {E}^\mathcal {C}t\) even though \(s \downarrow ^{\textsf {g}}_{\mathcal {E}_{>}} t\) does not hold.
Below, we define an inductive predicate \(\mathsf {gj}\) which is used to conclude ground joinability of a given equation.
Definition 4
(
) Given an ES \(\mathcal {E}\) and a reduction order >, \(\mathsf {gj}\) is defined inductively by the following rules:
This test differs from the one due to Martin and Nipkow [9] by the two \(\mathsf {rewrite}\) rules, which were added to allow for more efficient checks, as illustrated next.
Example 5
Consider the ES \(\mathcal {E}\)
together with a KBO that can orient the second equation (for instance, one can take as precedence
and let all function symbol weights as well as \(w_0\) be 1). Then
holds by the \(\mathsf {step}\) rule,
follows by an application of \(\mathsf {rewrite\ left}\), and
by \(\mathsf {rewrite\ right}\). By Lemma 9 below it thus follows that the equation
is ground joinable.
However, the criterion by Martin and Nipkow [9] lacks the \(\mathsf {rewrite}\) steps. Hence ground joinability of
can only be established by applying the \(\mathsf {closure}\) rule. This amounts to checking ground joinability with respect to 81 relations between the four variables. Since the number of variable relations is in general exponential, the criterion stated in Definition 4 can in practice be exponentially more efficient than the test by Martin and Nipkow [9].
Using Lemma 8 it is not hard to show the following correctness results.
Lemma 9
(
) Suppose for all \(s \approx t\) in \(\mathcal {E}\) we have \(s > t\) or \(t \approx s\) in \(\mathcal {E}\). Then \(\mathsf {gj}(s,t)\) implies \(s \downarrow ^{\textsf {g}}_{\mathcal {E}_{>}} t\). \(\square \)
Lemma 10
(
) If for all \(s \approx t\) in \(\mathcal {E}\) we have \(s > t\) or \(t \approx s\) in \(\mathcal {E}\) and \(CP _{>}(\mathcal {E}) \subseteq {\downarrow ^{\textsf {g}}_{\mathcal {E}_{>}}}\) then \(\mathcal {E}\) is ground confluent with respect to >. \(\square \)
This test can not only handle Example 2 but also the group theoretic problem from the introduction. Moreover, it subsumes Lemma 7 since whenever for some equation \(s \approx t\) we have \(s \downarrow ^{\textsf {g}}_{\mathcal {E}_{>}} t\) by Lemma 7 then \(\mathsf {gj}(s,t)\) holds.
Closures for Knuth-Bendix Orders. Definition 2 requires abstract properties on closures. In the following we define closures for KBO as used in
.
Similar to the already existing definition of KBO in
[17] we define the closure \(\mathrel {>_{\mathsf {kbo}}^{R}}\) as follows.
Definition 5
(
) Let R be a relation on terms, > a precedence on \(\mathcal {F}\), and \((w,w_0)\) a weight function. The KBO closure \(\mathrel {>_{\mathsf {kbo}}^{R}}\) is a relation on terms inductively defined as follows: \(s \mathrel {>_{\mathsf {kbo}}^{R}} t\) if \(s \mathrel {R} t\), or \(|s|_x \geqslant |t|_x\) for all \(x \in \mathcal {V}\) and either
-
(a)
\(w(s) > w(t)\), or
-
(b)
\(w(s) = w(t)\) and one of
-
(1)
\(s \not \in \mathcal {V}\) and \(t \in \mathcal {V}\), or
-
(2)
\(s = f({s}_1,\ldots , {s}_{n})\), \(t = g({t}_1,\ldots , {t}_{m})\) and \(f > g\), or
-
(3)
\(s = f({s}_1,\ldots , {s}_{n})\), \(t = f({t}_1,\ldots , {t}_{n})\) and there is some \(i \leqslant n\) such that \(s_j = t_j\) for all \(1 \leqslant j < i\) and \(s_i \mathrel {>_{\mathsf {kbo}}^{R}} t_i\)
Note that even though Definition 5 resembles the usual definition of KBO, it defines a closure of a relation R in a KBO-like way rather than a reduction order. For instance, if
, as in Example 3, then
holds.
We prove that \(\mathrel {>_{\mathsf {kbo}}^{R}}\) is indeed a closure that is compatible with \(>_\mathsf {kbo}\) based on the same weight function and precedence.
Lemma 11
Let R be a relation on terms, > a precedence on \(\mathcal {F}\), and \((w,w_0)\) a weight function. Then all of the following hold:
-
(a)
If \(s >_\mathsf {kbo}t\) then \(s \mathrel {>_{\mathsf {kbo}}^{R}} t\) for all terms s and t.
-
(b)
If \(R \subseteq R'\) then \({\mathrel {>_{\mathsf {kbo}}^{R}}} \subseteq {\mathrel {>_{\mathsf {kbo}}^{R'}}}\).
-
(c)
If \(s \mathrel {>_{\mathsf {kbo}}^{R}} t\) then \(s\sigma \mathrel {>_{\mathsf {kbo}}^{\sigma (R)}} t\sigma \), for all substitutions \(\sigma \), and terms s and t.
-
(d)
The closure \(\mathrel {>_{\mathsf {kbo}}^{R}}\) is compatible with \(>_\mathsf {kbo}\).