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 ; it is well-founded, closed under contexts and substitutions, has the subterm property, and is total on ground terms. All equations of are regular. "Ground" means ground over , and means that is an equational consequence of , which by Birkhoff's theorem holds iff by replacement of equals.
Lemma 1 (regularity is kept). Every equation that the run queues or adds to is regular.
Proof. Equations of are regular by assumption. If is regular and by one replacement with an instance , then and have the same variables, because and have the same variables. A simplified equation at line L6 and a critical pair are obtained from a regular equation, or from the regular pair , by such replacements. Equations re-queued at lines L4 and L9 were regular already.
Lemma 2 (invariant). At line L2, the equational consequences of , where is the set of queued equations, are those of , and every equation of is a consequence of .
Proof. Initially and . Line L4 queues critical pairs of , and line L11 queues critical pairs of and the new equation; a critical pair is the result of two replacements on , so it is a consequence of . Line L5 removes from ; line L6 replaces it by with and , so is a consequence of and one of . Line L7 drops it only if or it is a variant of an equation of , so it is still a consequence of . Line L9 moves equations from to and line L10 adds to . No step changes the set of consequences, and every new equation is a consequence of the old set.
So when line L4 returns , the queue is empty and and have the same consequences.
Lemma 3 (ordered rewriting). For any set of equations, terminates, and if then for every substitution .
Proof. Each step replaces by with inside a context, so ; is well-founded. For the second part, implies , and .
In particular the normalizations at lines L3 and L6 stop. For the rest, let be the set returned at line L4. By line L3, every ordered critical pair of has , so for some .
Lemma 4 (local confluence on ground terms). If is ground and , then for some .
Proof. Let the steps use with at and with at , where each is a direction of an equation of and . Every term reachable from is ground, by Lemma 1. We may assume that is a prefix of or that the two are disjoint.
Disjoint positions. Apply the other step to each of and ; both give the same term.
Critical overlap. and is a non-variable position of . Rename the variables of the second equation apart; then , so and have a most general unifier with on these variables. If held, closure under substitution would give , contradicting the step; the same holds for the second equation. So with and is an ordered critical pair of , and . Since and , Lemma 3 and closure under contexts join and at .
Variable overlap. where is a variable . Let be the inner step at , and let agree with except . From , rewrite each other occurrence of in the copy of by the same inner step; this reaches . From , rewrite every occurrence of in ; this reaches . The terms and are ground. If they are equal, we are done. If , one step with joins them. Otherwise by totality. Then is not a variable: is not a variable, and by regularity it contains properly if is a variable, so the subterm property would give . So is a usable direction, by regularity, and one step with it joins the two terms.
Theorem. If the run returns at line L4, then for all ground terms and , iff .
Proof. If , then by the steps, so by Lemma 2. Conversely let . By Lemma 2 and Birkhoff's theorem, where each step replaces an instance of one side of an equation of by ; by Lemma 1 the are ground, so and are ground. By totality, each step with is an ordered rewrite step from to or back, using the direction whose instance decreases. On ground terms, 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 , where the normal forms are unique.
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 steps and checks at line L3, at line L4 or at line L12.