| OCR Text |
Show Proof: Let A and B be input terms. Assume that A is the one that gets reduced when needed, and B serves as the pattern to be matched. Consider a term as a tree and function symbols as labels of the nodes in the t ree. If all the reduction sequences starting from A are terminating, the lemma trivially holds. Assume that there is an infinite reduction sequence from A. The definition of cyclic functions says that if a reduction sequence is infinite, we then have an infmite tree where for any node in the tree, the label of which will be eventually become a constructor or a constant function symbol. On the other hand, the term B is never reduced, thus when A has gone through enough number of reductions, it either matches with B, or can never match with B, because the constructors and constants never change. D 110 Note that this lemma coincides with the way we use infinite data structure generators; they generate potentially infinite trees. For exa mple, suppose we have the function f(X) = X A f(X+1 ) . The reduction sequence for the term f(O) generates the infinite term 0 A 1 A 2 A 3 A On the other hand, the cyclic functions are exactly what we want to avoid in typical function programming. The condition in Lemma 6-3 can be further relaxed by dividing EON into two subsets of the equations, EON1 and EON2, where EON1 represents a canonical (confluent and terminating) term rewriting system, and EON2 consists of the set of equations EON - EON 1, that is, the rest of equations in EON. We then require only that EON2 contain no cyclic functions. 6.1.3 An Interpreter for Function Reductions An interpreter for function reductions is presented in Figure 16. The top level driving process is called Reduce. It is not difficult to see that if the interpreter terminates for a given input term M and returns an output term N, then none of the subterms in N (including N itself) is reducible. N is usually called the normal form of M. |