Algorithm Search⌘K

Proofs: Unfailing completion

These are the human proofs of Unfailing completion, at full length.

A saturated result of unfailing completion decides the ground word problem full

This proof shows: correctness.

We use the definitions and the pseudocode of the page. >> is the lexicographic path ordering for a total precedence on Σ\Sigma; it is well-founded, closed under contexts and substitutions, has the subterm property, and is total on ground terms. All equations of EE are regular. "Ground" means ground over Σ\Sigma, and s=Ets =_E t means that s≈ts \approx t is an equational consequence of EE, which by Birkhoff's theorem holds iff s↔E∗ts \leftrightarrow_E^* t by replacement of equals.

Lemma 1 (regularity is kept). Every equation that the run queues or adds to AA is regular.

Proof. Equations of EE are regular by assumption. If u≈vu \approx v is regular and s↔ts \leftrightarrow t by one replacement with an instance uσ≈vσu\sigma \approx v\sigma, then ss and tt have the same variables, because uσu\sigma and vσv\sigma have the same variables. A simplified equation at line L6 and a critical pair u1σ[v2σ]p≈v1σu_1\sigma[v_2\sigma]_p \approx v_1\sigma are obtained from a regular equation, or from the regular pair u1σ≈v1σu_1\sigma \approx v_1\sigma, by such replacements. Equations re-queued at lines L4 and L9 were regular already. □\square

Lemma 2 (invariant). At line L2, the equational consequences of A∪QA \cup Q, where QQ is the set of queued equations, are those of EE, and every equation of A∪QA \cup Q is a consequence of EE.

Proof. Initially A=∅A = \emptyset and Q=EQ = E. Line L4 queues critical pairs of AA, and line L11 queues critical pairs of AA and the new equation; a critical pair is the result of two replacements on u1σu_1\sigma, so it is a consequence of AA. Line L5 removes s≈ts \approx t from QQ; line L6 replaces it by s′≈t′s' \approx t' with s↔A∗s′s \leftrightarrow_A^* s' and t↔A∗t′t \leftrightarrow_A^* t', so s≈ts \approx t is a consequence of A∪{s′≈t′}A \cup \{s' \approx t'\} and s′≈t′s' \approx t' one of A∪{s≈t}A \cup \{s \approx t\}. Line L7 drops it only if s′=t′s' = t' or it is a variant of an equation of AA, so it is still a consequence of AA. Line L9 moves equations from AA to QQ and line L10 adds s′≈t′s' \approx t' to AA. No step changes the set of consequences, and every new equation is a consequence of the old set. □\square

So when line L4 returns AA, the queue is empty and AA and EE have the same consequences.

Lemma 3 (ordered rewriting). For any set AA of equations, →A\to_A terminates, and if c→Adc \to_A d then cρ→Adρc\rho \to_A d\rho for every substitution ρ\rho.

Proof. Each step replaces uσu\sigma by vσv\sigma with uσ>vσu\sigma > v\sigma inside a context, so c>dc > d; >> is well-founded. For the second part, uσ>vσu\sigma > v\sigma implies uσρ>vσρu\sigma\rho > v\sigma\rho, and cρ∣p=u(σρ)c\rho|_p = u(\sigma\rho). □\square

In particular the normalizations at lines L3 and L6 stop. For the rest, let AA be the set returned at line L4. By line L3, every ordered critical pair c≈dc \approx d of AA has c↓A=d↓Ac{\downarrow}_A = d{\downarrow}_A, so c→A∗w←A∗dc \to_A^* w \leftarrow_A^* d for some ww.

Lemma 4 (local confluence on ground terms). If ss is ground and t1←As→At2t_1 \leftarrow_A s \to_A t_2, then t1→A∗w←A∗t2t_1 \to_A^* w \leftarrow_A^* t_2 for some ww.

Proof. Let the steps use u1→v1u_1 \to v_1 with σ1\sigma_1 at p1p_1 and u2→v2u_2 \to v_2 with σ2\sigma_2 at p2p_2, where each ui→viu_i \to v_i is a direction of an equation of AA and uiσi>viσiu_i\sigma_i > v_i\sigma_i. Every term reachable from ss is ground, by Lemma 1. We may assume that p1p_1 is a prefix of p2p_2 or that the two are disjoint.

Disjoint positions. Apply the other step to each of t1t_1 and t2t_2; both give the same term.

Critical overlap. p2=p1qp_2 = p_1 q and qq is a non-variable position of u1u_1. Rename the variables of the second equation apart; then u1∣qσ1=u2σ2u_1|_q\sigma_1 = u_2\sigma_2, so u1∣qu_1|_q and u2u_2 have a most general unifier τ\tau with σ1∪σ2=τρ\sigma_1 \cup \sigma_2 = \tau\rho on these variables. If v1τ>u1τv_1\tau > u_1\tau held, closure under substitution would give v1σ1>u1σ1v_1\sigma_1 > u_1\sigma_1, contradicting the step; the same holds for the second equation. So c≈dc \approx d with c=u1τ[v2τ]qc = u_1\tau[v_2\tau]_q and d=v1τd = v_1\tau is an ordered critical pair of AA, and c→A∗w←A∗dc \to_A^* w \leftarrow_A^* d. Since t2=s[cρ]p1t_2 = s[c\rho]_{p_1} and t1=s[dρ]p1t_1 = s[d\rho]_{p_1}, Lemma 3 and closure under contexts join t1t_1 and t2t_2 at s[wρ]p1s[w\rho]_{p_1}.

Variable overlap. p2=p1qq′p_2 = p_1 q q' where u1∣qu_1|_q is a variable xx. Let xσ1→Arx\sigma_1 \to_A r be the inner step at q′q', and let σ1′\sigma_1' agree with σ1\sigma_1 except xσ1′=rx\sigma_1' = r. From t2t_2, rewrite each other occurrence of xσ1x\sigma_1 in the copy of u1σ1u_1\sigma_1 by the same inner step; this reaches s[u1σ1′]p1s[u_1\sigma_1']_{p_1}. From t1=s[v1σ1]p1t_1 = s[v_1\sigma_1]_{p_1}, rewrite every occurrence of xσ1x\sigma_1 in v1σ1v_1\sigma_1; this reaches s[v1σ1′]p1s[v_1\sigma_1']_{p_1}. The terms u1σ1′u_1\sigma_1' and v1σ1′v_1\sigma_1' are ground. If they are equal, we are done. If u1σ1′>v1σ1′u_1\sigma_1' > v_1\sigma_1', one step with u1→v1u_1 \to v_1 joins them. Otherwise v1σ1′>u1σ1′v_1\sigma_1' > u_1\sigma_1' by totality. Then v1v_1 is not a variable: u1u_1 is not a variable, and by regularity it contains v1v_1 properly if v1v_1 is a variable, so the subterm property would give u1σ1′>v1σ1′u_1\sigma_1' > v_1\sigma_1'. So v1→u1v_1 \to u_1 is a usable direction, by regularity, and one step with it joins the two terms. □\square

Theorem. If the run returns AA at line L4, then for all ground terms ss and tt, s=Ets =_E t iff s↓A=t↓As{\downarrow}_A = t{\downarrow}_A.

Proof. If s↓A=t↓As{\downarrow}_A = t{\downarrow}_A, then s=Ats =_A t by the steps, so s=Ets =_E t by Lemma 2. Conversely let s=Ets =_E t. By Lemma 2 and Birkhoff's theorem, s=w0↔w1↔⋯↔wn=ts = w_0 \leftrightarrow w_1 \leftrightarrow \cdots \leftrightarrow w_n = t where each step replaces an instance uσu\sigma of one side of an equation of AA by vσv\sigma; by Lemma 1 the wiw_i are ground, so uσu\sigma and vσv\sigma are ground. By totality, each step with wi≠wi+1w_i \neq w_{i+1} is an ordered rewrite step from wiw_i to wi+1w_{i+1} or back, using the direction whose instance decreases. On ground terms, →A\to_A terminates by Lemma 3 and is locally confluent by Lemma 4, so it is confluent by Newman's lemma, and confluence turns the chain into s↓A=t↓As{\downarrow}_A = t{\downarrow}_A, where the normal forms are unique. ■\blacksquare

Termination of the procedure. Each pass through lines L5 to L11 increases the step count. A pass through line L3 that does not return queues at least one pair, so the next pass is through line L5. So the loop ends after at most BB steps and B+1B + 1 checks at line L3, at line L4 or at line L12. ■\blacksquare

Back to Unfailing completion