Proofs: Narrowing
These are the human proofs of Narrowing, at full length.
Narrowing is sound for every system and complete for convergent systems full
This proof shows: correctness.
We use the pseudocode of the page and the notation of the term rewriting pages: a signature , variables , terms , positions as sequences of positive integers, and , substitutions written after the term, so means , rules with and , and for the reflexive transitive closure. The goal is kept as the term for a binary symbol that does not occur in . A node is a triple of a goal , a substitution on the variables , and a depth . Line L9 renames each rule apart, with variables that occur nowhere else in the run.
The unifiers that line L4 and line L8 compute are fully applied, so they are idempotent: no variable of the domain occurs in the range. An idempotent most general unifier of and has this property: for every unifier of and , . Indeed, for some , so .
Theorem. Let be the depth bound.
- Termination. The procedure stops.
- Soundness. For every system and every answer , and for a term with .
- Completeness. Let be terminating and confluent, and let be a substitution on with in normal form for every and . Let be the length of an innermost reduction of to its normal form. If , the procedure returns an answer such that for all , for one substitution .
Termination
Each node has at most children, one per position and rule, and children are created only for . By induction on , finitely many nodes of each depth are created, and none of depth more than . Each node is removed from the queue once, and each removal does a finite amount of work.
Soundness
Lemma 1. For every node in the queue, .
Proof. Induction on . The node of line L1 has , the identity and . A child is created at line L9 from , a position with , a renamed rule , and with . Then is a redex, and , which is the child goal. By the induction hypothesis , and rewriting is closed under substitutions, so . The child substitution is on .
Proof of soundness. An answer comes from a node with at line L4, where unifies and , and on . By Lemma 1 and closure under substitutions, . Since does not occur in , no step is at the root, so each step rewrites inside one argument. With , and with . Line L4 renames the fresh variables of bijectively, which keeps this property.
Soundness does not use termination or confluence.
Completeness
A substitution is normalized on a set of variables if is a normal form for every . A subterm of a normal form is a normal form.
Lemma 2 (lifting). Let be a node with , and let be a substitution, normalized on , with for all . Let be an innermost step. Then line L9 creates a child and there is a substitution , normalized on , with for all and .
Proof. The step uses a rule at a position of with . It is innermost, so every proper subterm of is a normal form; since is not a variable, is a proper subterm of for each , so is normalized on .
The position is a position of with . Otherwise is at or below an occurrence of a variable of , and is a subterm of , which is a normal form, but is a redex. Also is not the root, since does not occur in .
At line L9 the procedure tries the position and the rule , renamed apart. We may assume that is this renamed copy, with adjusted; its variables occur neither in nor in the range of nor in the domain of . Let , which is well defined because the domains are disjoint. Then , so and unify, line L8 finds the idempotent most general unifier , and line L9 creates the child with and substitution . By the property of idempotent most general unifiers, . Set . Then:
- .
- For : , because the variables of are not variables of the rule.
- Let . Then occurs in for some . So is a subterm of , which is or , a normal form. So is a normal form.
Proof of completeness. is confluent and , so and have the same normal form . Since does not occur in , the normal form of is , and is terminating, so an innermost reduction exists.
We show by induction on : there is a node that the procedure creates, and a substitution normalized on , with for and . For take the node of line L1 and , which is normalized on . For the step from to , the step is an innermost step of , and , so Lemma 2 applies.
Every created node is eventually removed at line L3, since the queue is first in, first out and the procedure terminates. When line L4 runs on the node with , unifies and because . So the most general unifier exists and . The answer is on , and for , . Line L4 renames the fresh variables of by a bijection , which gives the answer with ; if the same answer was found before, it is already in the list. Take .
Remarks
Why normalized solutions. The theorem covers only solutions whose values are normal forms. For a convergent this is no loss: replacing each by its normal form gives a normalized solution that is equal modulo . Without the condition the lifting fails: with , the goal has the solution , and the only answer is , of which is not an instance.
Why the innermost reduction. Lemma 2 needs to be normalized, so that the new is normalized again. An innermost step gives this for free. The depth needed is the length of an innermost reduction, so a breadth-first search with finds the answer.
Without termination or confluence. Soundness holds for every system. Completeness fails without confluence: for , the goal holds modulo , but and are normal forms with no common reduct, and narrowing finds nothing.