University of Amsterdam Programming Research Group
a
b0
b1
b2
a
b0
c0
c0
d0
c1
c1
c2
c2
. . .
. . .
b1
b2
d1 d2
Transformations of Reduction Systems
Bas Luttik Piet Rodenburg Report P9615
October 1996
University of Amsterdam Department of Computer Science Programming Research Group
Transformations of reduction systems
Bas Luttik Piet Rodenburg
Report P9615
October 1996
Bas Luttik Programming Research Group Department of Computer Science University of Amsterdam
Computer Science Department of Software Technology CWI
Kruislaan 403 NL-1098 SJ Amsterdam The Netherlands
P.O. Box 94079 NL-1090 GB Amsterdam The Netherlands tel. +31 20 592 4247 e-mail:
[email protected]
Piet Rodenburg Programming Research Group Department of Computer Science University of Amsterdam Kruislaan 403 NL-1098 SJ Amsterdam The Netherlands tel. +31 20 525 7589 e-mail:
[email protected]
Universiteit van Amsterdam, 1996
Transformations of Reduction Systems Bas Luttik1 2
Piet Rodenburg1
;
1 University of Amsterdam, Programming Research Group Kruislaan 403, NL-1098 SJ Amsterdam, The Netherlands 2 CWI, Department of Software Technology P.O. Box 94079, NL-1090 GB Amsterdam, The Netherlands
[email protected]
[email protected]
Abstract
We consider transformations of reduction systems in an abstract setting. We study some sets of correctness criteria for such transformations, adapt a notion of simulation proposed by Kamperman and Walters, and show that the resulting !-simulation behaves well w.r.t. the criteria. We apply our results in an investigation of a transformation proposed by Thatte, and prove that this transformation preserves semicompleteness for weakly persistent systems.
1 Introduction With the emergence of the use of Reduction Systems as semantical basis of programming paradigms, the use of transformation methods for Reduction Systems is growing. Some systems are more suitable for execution on a machine than others, for instance because they have a normalizing reduction strategy that is easily decidable, or because they are in a speci c format. Transformation methods are then used to translate an arbitrary system into such a suitable system. Evidently, such a transformation should not be applied if it does not induce some sensible connection between the transform and its original. Only if a transformation ful lls a number of prede ned criteria, it should be called correct. Naturally, the answer to the question of whether the connection between transform and original is a sensible one is rather subjective. It depends largely on the application and little can be said in general. However, if the transformation is part of an implementation of Reduction Systems on automata, then there are some widely accepted intuitions: In Concurrency Theory and Automata Theory much research has been done towards satisfactory connections, there called \simulation relations" (see for instance [LV95]). These relations induce a preorder on the class of automata, such that if automaton A simulates automaton B , then A can be seen as an implementation of B . In papers dealing with transformations for Reduction Systems and their correctness, it is usually proved that the normal form relations of the original and its transform are related [Tha85, Tha88, Ver95a, Ver95b]. This is because the normal form relation of a Reduction System is its computational content; it relates input and result. Kamperman and Walters initiated a new approach towards correctness proofs of transformations for Reduction Systems [KW96, Kam96]. In order to make correctness of their transformation for Term Rewriting Systems plausible, they prove that the transform \simulates" the original. Fokkink and Van de Pol prove that the simulation relation of Kamperman 1
2
2. PRELIMINARIES
and Walters implies preservation of the normal form relation. They de ne a notion of correct transformation in which a connection between the normal form relations of original and transform gures as a principal component [FP96]. In this paper we set up a general framework in which correctness criteria can be expressed and which ts the various notions in the literature. As a derivative of the notion of Kamperman and Walters, we de ne a notion of simulation that we call !-simulation. We study its preservation properties and prove that the existence of a termination preserving !-simulation implies correctness as de ned by Fokkink and Van de Pol. We apply our results to a transformation proposed by Thatte. This transformation was introduced in 1985 in [Tha85] for regular Term Rewriting Systems. In [Tha88], Thatte claimed that it preserved con uence and (up to some translation on terms) the normal form relation for nonoverlapping systems, but it was shown by Verma in [Ver95b] that this claim was false. Verma, for his part, tried to x Thatte's proof by imposing an extra condition (weak persistence) on the domain of the transformation [Ver95b]. However, we discovered some fundamental errors in his proof (see appendix A) and after we had noti ed Verma of these, he found a counterexample [Ver96]. We investigate Thatte's transformation for a number of classes of Term Rewriting Systems. We give an improved de nition of weak persistence and show that Thatte's transform preserves con uence for the particular classes of weakly persistent systems that Verma mentions in [Ver95b]. Finally, we will obtain a proof that Thatte's transformation preserves semi-completeness.
Acknowledgements. We thank Wan Fokkink, Jasper Kamperman and Jaco van de Pol for the many discussions on correctness criteria. Furthermore, we thank Jan Bergstra for stimulating us to continue this work.
2 Preliminaries
An Abstract Reduction System (ARS) is a pair hA; (! )2I i consisting of a set A and a family of binary relations ! on A (indexed by some set I ), also called reduction or rewrite relations. We reserve a; b; c; : : : (possibly subscripted) for elements of A, and we use ! ; ! ; ! ; : : : or simply ! to refer to rewrite relations. A, B, and C (sometimes primed or subscripted) will be used to denote ARSs. If for a; b 2 A we have ha; bi 2! then we write a ! b and call b a `one-step (-)reduct of a'. The transitive closure of ! is written as !+ . So a !+ b if there is a nite sequence of `reduction steps' (a reduction) a = a0 ! a1 ! ! an = b, where n 1. We also write a !n b if we want to be explicit about the number of reduction steps. We write a !0 b if a = b and denote by or ! the transitive re exive closure of ! . That is, a b i a !n b for some n 2 !. If a b, then b is called a reduct of a, and a is said to reduce to b. We write for the converse relation of ! and this same convention ports to all other `reduction relations' that we will de ne. So, for instance, and + denote the converses of and !+ . If an ARS is of the form hA; !i, i.e. it involves only one reduction relation (jI j = 1), then we call it simple S . Each ARS A = hA; (! )2I i is straightforwardly mapped onto a simple ARS hA; 2I ! i; the latter is called the simple ARS underlying A. If X is a set and R a binary relation we denote the set fy j 9x 2 X (xRy)g by [X ]R. In the particular case that R is the transitive re exive closure of the reduction relation of
3 an ARS A = hA; !i and X A, we denote [X ]R by [X ]A , or [X ] when A is understood. The substructure of A with domain [X ] we denote by A[X ]; instead of A[range()] we write A[]. If y 2 [X ]R , we say that y is reachable (from X by R). Let A = hA; !i be an ARS and a 2 A. If 8b; c 2 A 9d 2 A (c a ! b =) c d b), then a is weakly con uent (or: weakly Church-Rosser ) (notation: A j= WCR(a)); if 8a 2 A(A j= WCR(a)),then A is weakly con uent (A j= WCR). If 8b; c 2 A 9d 2 A (c a b =) c d b), then a is con uent (or: Church-Rosser ) notation: A j= CR(a)); if 8a 2 A(A j= CR(a)), then A is con uent (A j= CR). We say that a is a normal form if there is no b 2 A such that a ! b. Furthermore, a has a normal form if a n for some normal form n 2 A; in this case a is weakly terminating (or: weakly normalizing ) (notation: A j= WN(a)). If 8a 2 A(A j= WN(a)), then A is weakly normalizing (A j= WN). If there is no sequence (an )n2! such that a0 = a and an ! an+1 , then a is terminating (or: strongly normalizing, noetherian ) (notation: A j= SN(a)). If 8a 2 A(A j= SN(a)), then A is strongly normalizing (A j= SN). If 8b; c 2 A(a b & a c & b; c are normal forms =) b = c), then a has the unique normal form property (notation: A j= UN(a)). If 8a 2 A(A j= UN(a)), then A has the unique normal form property (A j= UN, A is uniquely normalizing ). We also write A 6j= WCR(a) if a 2 A is not weakly con uent, etc. All these properties generalize to arbitrary ARSs as follows: hA; (! )2I i has property X if its underlying simple ARS hA; S2I ! i has property X. A con uent and terminating ARS is called complete ; a con uent and weakly terminating ARS is called semi-complete. Trivially, the implications CR =) UN and UN & WN =) CR hold. Another well-known implication is SN & WCR =) CR (Newman's Lemma). The set of normal forms of A we denote by NF(A). Furthermore, nfA denotes the normal form relation of A, i.e. nfA = fha; bi 2 A NF(A) j b is a normal form of ag. If a 2 A reduces to a unique normal form n, then we denote this n by nfA (a); if A j= UN then nfA is a (partial) function. If A is clear from the context, then we just write nf instead of nfA . We use NF , nf for normal forms w.r.t. a particular relation ! of an ARS hA; (! )2I i.
3 Correctness Criteria
A criterion for correctness of some transformation of ARS A = hA; ! i into B = hB; ! i essentially consists of two parts. On the one hand, the elements of A must be in some way connected to those of B . In order to establish such a connection we will use a pair of functions, one from A to B and one from B to A, and we will identify the transformation with this pair of functions. All possibilities we encountered in literature t into this framework. On the other hand, there must be some connection between the reduction relations ! and ! . Especially this part is open to discussion. Until now there has not been much consensus about how to express this connection and we do not believe that such consensus is to be expected in the near future. We classify the various opinions we found roughly into two categories: the direct approach and the indirect approach. By the direct approach we mean that the main interest lies in proving that certain properties are invariant under the transformation, such as the normal form relation, con uence, and termination. By its abstract formulation this approach hardly gives any direction for
4
3. CORRECTNESS CRITERIA
the prover, but it seems to be more powerful in the sense that more transformations can be proven \correct". However, much information about the exact relation that exists between the reduction relations of the original and its transform remains rather implicit. The indirect approach has more to do with the structure of the reduction relations in terms of the reduction steps. Some connection between the reduction steps is established. Therefore, we could also call this approach operational or behavioural. It leads to notions that resemble the notions of simulation that occur in Automata Theory and Concurrency Theory (see for example [LV95]). We will describe both approaches independently in the following sections. However, we feel that the division does not have to be all that strict. To emphasize this, we will apply a mix of both approaches in our example transformation. The preservation of reduction graphs in combination with a speci c mapping between the elements of the two systems has a number of pleasant consequences in terms of the preservation of properties. We will describe and prove these in section 4. As we did with the properties CR, SN etc., we will de ne all our correctness notions for simple ARSs. They generalize to arbitrary ARSs with more than one reduction relation in the same way as in section 2.
3.1 Simulations
To express a connection between the objects of the original system hA; ! i and its transform hB; ! i we use a pair of mappings h; i. These mappings provide the there and back translations from the original to its transform () and from the transform to its original ( ).1 We will demand that these translations are consistent with each other for all a 2 A, in the sense that their composition is the identity function on A. Unless otherwise stated we will adapt the convention that A refers to the ARS hA; ! i, B to hB; ! i, etc. Definition 3.1 (inspired by [FP96]) Let A and B be ARSs. A simulation of A by B is a pair h; i of a function : A ! B and a partial function : B ! A such that 1. range() domain( ); and 2. = id(A). a We call A the domain of the simulation h; i and B the codomain or the transform. We say B is reachable if B = B[]. Often in the sequel we shall have = ?1 ; we shall write to refer to the simulation h; ?1 i. In another important special case we have A B and = id(A) (see [Kam96]).
3.2 Preservation of Properties
Most authors of papers on transformations require some form of preservation of the normal form relation. The following de nition has been adapted from Fokkink and Van de Pol [FP96]. Definition 3.2 (Preservation of Normal Forms) Let h; i be a simulation of A by B such that NF(B[]) domain( ). h; i preserves the normal form relation if for all a 2 A:
f (n) j n 2 nfB [(a)]g = nfA [a] 1 In [FP96] these mappings are also called parse and print, respectively.
3.3 Preservation of Reduction Graphs
h; i weakly preserves the normal form relation if for all a 2 A: f (n) j n 2 nfB [(a)]g nfA [a]
5
a
It is easy to see that these requirements do not guarantee that B is strongly normalizing or con uent if A is, even if B = B[]. Accordingly, Fokkink and Van de Pol consider a further requirement on termination behaviour in range(), while Thatte [Tha85, Tha88] and Verma [Ver95b] base their correctness arguments on the preservation of con uence. Definition 3.3 (Preservation of Properties) Let h; i be a simulation of A by B and suppose X is a property de ned for elements of ARSs (i.p. X 2 fSN; WN; CR; WCR; UNg). h; i preserves X if for all a 2 A: A j= X(a) =) B j= X((a)). a The reachable transform of a weakly normalizing ARS by a weak termination preserving simulation need not be weakly normalizing. However, for termination preserving transformations we have: Proposition 3.4 Let B be the reachable transform of A by h; i. If A j= SN and h; i preserves termination, then B j= SN. Proposition 3.5 Let B be the reachable transform of A by h; i. If A j= CR and h; i preserves con uence, then B j= CR. Proof By contraposition. Suppose B 6j= CR. Then B 6j= CR(b) for some b 2 B , and since B = B[], there is some a 2 A such that (a) b. Clearly B 6j= CR((a)), hence A 6j= CR(a). The analogous result for weak con uence does not hold. Example 3.1 Consider the ARSs A1 = hfa; bg; fa ! bgi and A2 = hfa; b; c; dg; fa ! c; c ! b; c ! dgi with the simulation id(fa; bg). Note that A1 j= WCR and A2 j= WCR(a), A2 j= WCR(b), so id(fa; bg) preserves weak con uence. Also A2 is reachable; but A2 6j= WCR(c). Fokkink and Van de Pol call B a correct transformation of A if there isa simulation h; i that preserves the normal form relation and termination.
3.3 Preservation of Reduction Graphs
Kamperman and Walters advocate a form of preservation of reduction graphs as a correctness criterion. They call a simulation h; i of A by B sound if each reduction in B simulates a reduction in A and complete if each reduction in A is actually simulated by a reduction in B. For their original de nitions we refer to [Kam96]. Their approach is interesting, because it turns out that if one wants correctness via the direct approach of the previous section one often needs to prove soundness and completeness as lemmas (see [Tha85, Ver95b]). We will de ne a notion of preservation of reduction graphs that is based on the notions of Kamperman and Walters, but diers slightly. In the next section we will provide further justi cation for the claim that such reduction conservation in combination with a simulation of the form h; ?1 i is useful as a correctness criterion, by studying its consequences. Definition 3.6 (Preservation of Reduction Graphs) A simulation h; i of A by B preserves reduction graphs if it satis es 1. if a ! b (a; b 2 A), then (a) !+ (b); 2. if a !+ b for a 2 domain( ) and b 2 B , then 9c 2 domain( )( (a) !+ (c) ^ b c).
a
4. !-SIMULATION
6
The rst condition above is a generalization of completeness as in [Kam96]. One obtains the soundness condition of [Kam96] by substituting , for !+ , !+ in the second condition above.
4
!-Simulation
We study the implications of preservation of reduction graphs for the preservaton of properties as in De nition 3.3. It turns out that for such a simulation mapping we get the preservation of the normal form relation and con uence for free. First we introduce some extra terminology. Definition 4.1 (!-simulation2 ) An !-simulation is a reduction graph preserving simulation of the form h; ?1 i. If is an !-simulation of A by B, then we write A ! B; we say B !-simulates A (A ! B) if there is an !-simulation of A and B. a
4.1 A Preorder
If the composition of two correct transformations is again a correct transformation, i.e. `: : : is correctly simulated by : : : ' is a transitive relation of ARSs, it may be considerably easier to prove complicated transformations correct. We could view a transformation as a composition of transformations that are easier to deal with. This method is known as `stepwise re nement' (see [LV95]). All criteria de ned in section 3.2 trivially induce preorders (transitive re exive relations) on the class of ARSs. It is moreover easy to see that !-simulation is re exive. Transitivity is a little less clear. Lemma 4.2 If A ! B ! C then A ! C. Proof Let = . It is clear satis es the rst conditions of De nition 3.6. We verify the second condition. Assume a !+ b for a 2 range() and b 2 C . We need to derive the existence of a c 2 range() such that ?1 (a) !+ ?1 (c) and b c. Because B ! C, there is a c2 2 range( ) with ?1 (a) !+ ?1 (c2 ) and b c2 , and because A ! B, there is a c1 2 range(), such that ?1 (c2 ) c1 and ?1 ( ?1 (a)) !+ ?1 (c1 ). It now remains to show that b (c1 ). Note that from ?1 (c2 ) c1 and the rst condition satis ed by B ! C we nd that c2 (c1 ). Combining this reduction with b c2 , we nd b (c1 ), so we may take c = (c1 ). Corollary 4.3 !-simulation induces a preorder on the class of ARSs.
4.2 Preservation of Normal Forms
The existence of an !-simulation implies a close connection between the normal form relations of the two systems. Proposition 4.4 If A ! B, then for a; b 2 A we have: i. n 2 NF(A) i (n) 2 NF(B); 2 We use the name \!-simulation" because of the familiarity of this notion with the simulation notions that occur in Concurrency Theory (see [LV95]). The ! emphasizes the fact that possibly one step in the
original is simulated by in nitely many steps in the transform.
4.3 Preservation of Con uence
7
ii. if b n 2 NF(B), and b 2 range(), then n 2 range() and ?1 (b) ?1 (n).
Proof
i. If (n) 62 NF(B), then (n) ! b for some b 2 B , and using the second condition of De nition 3.6 we nd that there must be a c 2 range(), such that n !+ ?1 (c), so n 62 NF(A). On the other hand, if n 62 NF(A) then there exists a 2 A such that n ! a. By the rst condition of De nition 3.6 we nd (n) !+ (a), so (n) 62 NF(B). ii. Assume b n 2 NF(B) and b 2 range(). If b = n, then trivially ?1 (b) ?1 (n). If b !+ n, then by the second condition of De nition 3.6 9c 2 range()(?1 (b) !+ ?1 (c) ^ n c), and n = c since n 2 NF(B).
Corollary 4.5 If A ! B, then preserves the normal form relation.
4.3 Preservation of Con uence
An arbitrary simulation h; i that preserves reduction graphs does not necessarily preserve con uence: Example 4.1 Consider ARSs hfa; bg; fa ! bgi and hfc; d1 ; d2 g; fc ! d1 ; c ! d2 gi and de ne and by: (a) = c (c) = a (b) = d1 (d1 ) = b (d2 ) = b It is clear that h; i preserves reduction graphs as de ned in De nition 3.6. Furthermore, it is clear that B is reachable. However, A j= CR(a) while it is not the case that B j= CR((a)). The problem in the above counterexample lies in the fact that 6= ?1 . If we assume a mapping of the form h; ?1 i then we exclude the above example and w.r.t. con uence the situation takes a pleasant turn.
Theorem 4.6 (Confluence) If A ! B, then we have for all a 2 A: A j= CR(a) =) B j= CR((a)). Proof Fix an a 2 A and assume CR(a) and c (a) b, with b; c 2 [range()]B . If (a) !0 b, or (a) !0 c then there is nothing to prove, so assume (a) !+ b and (a) !+ c. Then by the second condition of De nition 3.6 there are d1 ; d2 2 A such that a !+ d1 , a !+ d2 , b (d1 ) and b (d2 ). Because A j= CR(a), d1 and d2 must have a common reduct d, i.e. d1 d d2 , which, by the rst
condition of De nition 3.6 and a simple induction argument, implies that we also have (d1 ) (d) (d2 ). In other words, b and c have a common reduct in B, so B j= CR((a)). The reverse does not hold: Example 4.2 Consider the following ARSs (see also Figure 1 below): A
= h fag [ fbi ; ci j i 2 !g;
A0 =
fa ! b0 ; a ! c0 g [ fbi ! bi+1 ; ci ! ci+1 j i 2 !g i and h fag [ fbi ; ci ; di j i 2 !g; fa ! b0 ; a ! c0 g [ fbi ! bi+1 ; ci ! ci+1 j i 2 !g [ fbi ! di ; ci ! di ; di ! bi+2 ; di ! ci+2 j i 2 !g i
4. !-SIMULATION
8
Clearly, all objects of A0 are reachable. We show that A ! id(A) A0 . Note that each reduction in A is also a reduction in A0 (this veri es the rst condition) and that each di has a reduction to all bj ; cj with j > i + 1. This means that: 1. each a !+ di can be followed by di ! bi+2 to simulate a !+ bi+2 ; 2. each bi !+ dj can be followed by dj ! bj+2 to simulate bi !+ bj+2 ; 3. each ci !+ dj can be followed by dj ! cj+2 to simulate ci !+ cj+2 .
Moreover it is clear that CR(a) does not hold in A, while in A0 each pair of elements has a common reduct.
a
b0
b1
b2
a
b0
c0
c0
d0
c1
c1
c2
c2
.. .
.. .
A
b1
b2
d1 d2 A0
Figure 1: Counterexample: !-simulation does not preserve con uence in the reverse direction. Next, we show that !-simulation does not preserve weak con uence in either direction. By Theorem 4.6 we already know that we need a system with at least one element that is WCR, but not CR. We use the famous counterexample by R. Hindley that shows that WCR does not imply CR. Example 4.3 Consider the following ARSs (see also Figure 2): A = A0 =
hfa; b; c; dg; fb ! a; b ! c; c ! b; c ! dgi hfa; b; c; dg; fb ! a; b ! c; c ! b; c ! d; b ! dgi
It is easy to see that A ! A0 , as well as A0 ! A, where = id(fa; b; c; dg). Note that operationally, b ! d adds nothing to the original system. It is just a shortcut for the reduction b ! c ! d. Neither of the systems is CR, but obviously A j= WCR, while A0 j= WCR(b) does not hold; we have a b ! d, but a and d have no common reduct.
4.4 Preservation of Termination
Unfortunately, the existence of an !-simulation does not imply that the simulation map preserves termination. We obtain the following counterexample:
4.5 Correctness of Transformations
a
b
c
9
d
a
b
c
d
A0
A
Figure 2: Counterexample: !-simulation does not preserve WCR in either direction. Example 4.4 Let A = hfa; cg; fa ! cgi and A0 = hfa; b; cg; fa ! b; b ! b; b ! cgi be ARSs. Then A ! A0 , with = id(fa; cg), because the only reduction possible in A is a ! c and in A0 we have a !+ c by a ! b ! c and that b c, so all reductions a !+ b, i.e.
a ! b a ! b ! b a ! b ! b ! b .. .
can be followed by b c. It is also easy to see that A0 is reachable, but A j= SN(a), while A0 has the in nite reduction b ! b ! b ! . However, !-simulation does preserve weak termination in both directions: Theorem 4.7 (Weak Termination) If A ! B, then we have for all a 2 A: A j= WN(a) () B j= WN((a)).
Proof
()) Suppose that A j= WN(a) for some a 2 A. Then a n, where n is some normal form, and thus (a) (n) (by the rst condition of De nition 3.6 and induction) and (n) 2 NF(B) (by Proposition 4.4(i)). Thus, B j= WN((a)). (() If B j= WN((a)), then (a) n for some n 2 NF(B). By Proposition 4.4(i{ii) a ?1 (n) and ?1 (n) 2 NF(A), so A j= WN(a).
Moreover, note that if A ! B then by the second condition of De nition 3.6 every reachable element reduces to an element in the range of , so we get: Corollary 4.8 If A ! B, then we have: A j= WN () B j= WN.
4.5 Correctness of Transformations
Recall that Fokkink and Van de Pol [FP96] call a transformation correct if it preserves both the normal form relation and termination. They called a transformation weakly correct if it weakly preserved the normal form relation and preserved both weak termination and termination. Note that by Theorem 4.7 !-simulation preserves weak termination. However, as Example 4.4 demonstrates, it does not preserve termination, so according to Fokkink and Van de Pol, !-simulation is not a sucient correctness criterion. It does preserve the normal form relation (Corollary 4.5). Theorem 4.9 If is a simulation of A by B, then: (A ! B + preserves termination) =) B is a correct transformation of A
10
5. TERM REWRITING SYSTEMS
Note furthermore that !-simulation in combination with preservation of termination is essentially stronger then the transformation correctness of [FP96]. This follows from the fact that correctness does not imply preservation of con uence (see Example 4.1), while !-simulation does (Theorem 4.6). The following example is to emphasize that this not only comes from the fact that in Example 4.1 a simulation map with 6= ?1 is used: Example 4.5 De ne A = hfa; bg; fa ! a; a ! bgi and B = hfa; b; cg; fa ! b; a ! c; c ! cgi. Note that = id(fa; bg) preserves termination and the normal form relation, but there is no !-simulation between these two systems.
5 Term Rewriting Systems
A Term Rewriting System (TRS) R is a pair h; Ri of a signature and a set of reduction rules (rewrite rules) R. A signature is a nonempty set of function symbols (we treat constant symbols as nullary function symbols). We x a countably in nite set V of variables, denoted by x1 ; x2 ; x3 ; : : : or x; y; z .
5.1 Terms
The set T;V of terms over in variables from V is de ned as usual. Terms that contain each variable x 2 V at most once are called linear. To make explicit that a term contains no variables other than x1 ; : : : ; xn we will sometimes write t(x1 ; : : : ; xn ). Contexts are `terms' containing an occurrence of a special symbol 2, denoting an empty place. A context is generally denoted by C [ ]. If t 2 T;V and t is substituted for 2, then the result is C [t] 2 T;V . The notion of a path (or occurrence, or position ) is used to refer to subterms in a term t. For any term t 2 T;V the set of occurrences O(t) in t is inductively de ned as follows: 1. x 2 V =) O(x) = fg; 2. f 2 and t1 ; : : : ; tn 2 T;V (n 0) =) O(f (t1 ; : : : ; tn )) = fg [ fi:u j 1 i n and u 2 O(ti )g. To the subterm of t reached by p we refer as t=p. The concatenation of p and q (p and q both paths) we denote by p:q so that t=p:q denotes the subterm reached by q in the subterm t=p. We write o < q when there is a nonempty path p such that o:p = q; o q when o < q or o = q; and we say that o and q are disjoint if o 6 q and q 6 o. We moreover divide O(t) into a set OF (t) of function symbol occurrences and a set OV (t) of variable occurrences:
OF (t) = fo 2 O(t) j t=o is a nonvariable subterm of tg and
OV (t) = fo 2 O(t) j t=o is a variableg If o 2 OF (t), then we will denote by t(o) the outermost symbol of t=o, i.e. if t=o = f (t1 ; : : : ; tn ), then t(o) = f . If o is an occurrence of symbol f in t and o 6= , then o is an inner occurrence of f in t. If is a substitution, t(x1 ; : : : ; xn ) 2 T;V and (xi ) = ti for 1 i n, then (t) = t = t(t1 ; : : : ; tn ). For s; t 2 T;V we say that s overlaps t if there are substitutions ; and an occurrence o 2 OF (t), such that (t=o) = (s). Sometimes we need to be explicit about where the overlap takes place. Therefore we also say that s overlaps t at o. If o = then s root overlaps t and if o 6= then s nonroot overlaps t.
5.2 Rules
11
We extend these notions of overlap to sets of terms. A set X T;V is said to be nonoverlapping if : 9s; t 2 X (s nonroot overlaps t). If 8s; t 2 X (s overlaps t =) s = t) then X is said to have no overlap.
5.2 Rules
A reduction rule over is a pair hl; ri with l; r 2 T;V . We usually write l ! r and we assume that l 62 V and that the variables of r occur in l. A set R of rewrite rules generates a reduction relation !R on T;V as follows. For s; t 2 T;V we write s !R t if there is an occurrence o 2 O(s), a substitution and a rule l ! r in R, such that s=o = l and t = s[o r ]. Here s[o r ] denotes the result of replacing the term s=o in s at occurrence o by r . To be speci c about the position in s o R t. In case o = , then we at which the reduction takes place, we sometimes write s ?! r call this a root reduction (notation: s ?!R t), while if o 6= we call it a nonroot reduction nr R t). A root reduction is also called a contraction. (notation: s ?! An instance l of a lefthand side l of a rule l ! r in R is called a reducible expression (short: redex or l-redex ). A subtemplate of R is a nonvariable proper subterm of a lefthand side of a rule in R. An instance of a subtemplate l0 of R is called an l0 -pseudo-redex, or pseudo-redex for short. o R t with o 62 OF (l0 ), then we write s ?! nt0 R t; we drop the If s is an l0 -pseudo-redex and s ?! l 0 subscript l if the speci c subtemplate is not important. on R sn (n 1), and o 2 O(s). We de ne o2 R ?! 1 R s1 ?! Let be a reduction, say s ?o! the set of descendants desc(o; ) of o over as follows: o1 R C [r(t0 ; : : : ; t0 )], then 1. If n = 1 and s = C [l(t1 ; : : : ; tm)] ?! m 1
8; < desc(o; ) = : fo1 :p0 :q j r(p0 ) = xi g fo1 g
if o = o1 :p and p 2 OF (l) if o = o1 :p:q and l=p = xi otherwise
Note that there may be more than one rule l ! r that applies. If this is the case, then we take the union of the sets of descendants we get via the respective rules. o2 R ?o?? o1 R s1 ?! n?! 1 R sn?1 , then desc(o; ) = 2. IfS n > 1, and 0 is the reduction s ?! o n d2desc(o;0 ) desc(d; sn?1 ?!R sn ).
The underlying ARS of R is hT;V ; !R i. We generally identify R with its underlying ARS.
5.3 Subclasses
By imposing (syntactic) restrictions on the rules we can de ne subclasses of the class of TRSs. For instance, assume a TRS R = h; Ri: if the base LR of R is linear then R is called left-linear ;
if the base LR of R is nonoverlapping then R is called nonoverlapping; if R is nonoverlapping and in addition 8hl; ri; hl0 ; r0 i2R 8; (l = (l0 ) =) r = (r0 ) ) then R is called consistent ;
12
6. THATTE'S TRANSFORMATION FOR LEFT-LINEAR SYSTEMS
if R is nonoverlapping and in addition the lefthand sides of no two distinct rules overlap at the root, then R is called nonambiguous ; if 8hl; ri; hl0 ; r0 i2R 8; (l = (l0 ) =) 9t 2 T;V (r R t R (r0 ) )), then R is said to have con uent root overlaps.
Proposition 5.1
nonambiguity =) consistency =) nonoverlapping & con uent root overlaps
Proposition 5.2
Every nonoverlapping TRS with con uent root overlaps is weakly con uent. Corollary 5.3 Every nonambiguous (consistent) TRS is weakly con uent. If a TRS is both nonambiguous and left-linear, then it is called orthogonal and if it is both consistent and left-linear, then we call it regular. In term rewriting orthogonal and regular systems are of special importance, mainly because descendants of redexes are still redexes. This leads to the following result: Corollary 5.4 Every regular TRS is con uent. Proof See [BKM89] for a proof of con uence for orthogonal TRSs (there called regular). It is easy to verify that their proof generalizes to regular systems.
6 Thatte's Transformation for Left-Linear Systems In [Tha85], Satish R. Thatte introduced a transformation for TRSs that turns an arbitrary regular system into a constructor-based system. The characteristic property of these systems is that there signatures may be partitioned into sets of de ned symbols (appearing only as outermost function symbols of lefthand sides of rules) and constructor symbols (not appearing as outermost symbols). Constructor-based systems are not only interesting for reasons of clarity; regular constructor-based systems are important in the context of strong sequentiality, a property that implies the existence of a normalizing reduction strategy. Strong sequentiality is decidable for regular systems, but the decision procedure is complicated. Thatte in [Tha87] introduces an alternative in the form of `left sequentiality' for which the decision procedure is much simpler. He proves that for regular constructor-based systems this property coincides with strong sequentiality. Klop and Middeldorp conjecture that this is not the case for regular systems in general [KM91].
6.1 The Transformation
Definition 6.1 Let R = h; Ri be a TRS.
We de ne the set of de ned symbols of R by
F R = ff 2 j 9t1 ; : : : ; tn 2 T;V (f (t1 ; : : : ; tn ) 2 LR )g and the set of argument symbols of R by
AR = fl(o) j l 2LR ^ o 2 OF (l) ^ o 6= g Denote by C R the set of constructor symbols (constructors ) of R, that is, C R = ? F R . R is called constructor-based if AR C R (or equivalently: F R \ AR = ;). If no confusion can arise, then we will drop the superscript R. a
6.2 Correctness for Nonoverlapping Left-Linear TRSs
13
Systems that are not constructor-based have a symbol that is both de ned and appears in some argument of a lefthand side, i.e. such a symbol has a dual r^ole. The idea is to remove this duality by adding a fresh symbol cf for each f 2 F \A, that will act as the constructor variant of f (take over the r^ole of f as a constructor). Let R = h; Ri be a TRS. We construct from R a system R] = h] ; R] i as follows. We rst extend by adding a fresh symbol cf of arity n (a constructor variant) for each f 2 F \ A of arity n: ] = [ fcf j f 2 F \ Ag We need translations from -terms to ] -terms and vice versa. Therefore, we de ne functions h : T] ;V ! T;V and c : T;V ! T] ;V . The function h replaces each occurrence of a constructor variant cf by its corresponding f 2 F \ A, while c does the inverse: it replaces each f 2 F \ A by its constructor variant cf . In addition, we de ne a mapping ic : T;V ! T] ;V that replaces each inner occurrence of a symbol f 2 F \ A by its constructor variant f , i.e. ic(f (t1 ; : : : ; tn )) = f (c(t1 ); : : : ; c(tn )). For convenience we write th , tc and tic for h(t), c(t) and ic(t), respectively. We de ne two sets of rules R] 1 and R] 2 . R] 1 will consist of transformed versions of rules in R: R] 1 = fhlic; ri j hl; ri 2 Rg. In R] 2 we put rules to transform a symbol f 2 F R \ AR into its constructor variant. That is, R] 2 is the smallest set satisfying: If u is a subtemplate of a rule in R, with u = f (t1 ; : : : ; tn ) and f 2 F R \AR , then huic ; uci 2 R] 2 . We let R] = R] 1 [R] 2 . In the sequel we will write h] ; R] 1 [R] 2 i if we are interested in the TRS with underlying ARS hT] ;V ; (! )2fR] 1 ;R]2 g i and h] ; R] i if we mean the TRS with underlying simple ARS hT] ;V ; !R] i. Also, R]2 = hT] ;V ; !R] 2 i. Clearly R] is a constructor-based TRS; and R]2 is complete (i.e. strongly normalizing and con uent). Thatte proved in [Tha85]: Lemma 6.2 Let R = h; Ri be a TRS, with transform R] . Then: i. Given t1 ; t2 2 T] ;V : t1 !R] t2 =) th1 R th2 . ii. Given t1 ; t2 2 T;V : t1 !R t2 =) t1 !+R] t2 .
6.2 Correctness for Nonoverlapping Left-Linear TRSs
If R is a nonoverlapping left-linear TRS, then so is R] . In particular, a lefthand side of an R] 2 -rule cannot overlap an R] 1 -lefthand side: nonroot overlaps are impossible because R] is constructor-based, and root overlap would imply overlap in R. For a TRS R, let R be the map nfR]2 T;V . Since R] 2 -rules just replace symbols, and distinct symbols by distinct new symbols, R is clearly injective. The following lemma expresses that every ] -term t that is reachable from an element in the range of R is reachable from th by an R] 2 -reduction. Lemma 6.3 Let R = h; Vi be a TRS. If s 2 range(R ), t 2 T] ;V , then s R] t =) th R] 2 t. Proof By Induction on the length of the reduction s R] t. If s !0R] t, then t = nfR] 2 (th ). Suppose the lemma holds for reductions s R] t0 of length n 2 ! and s nR] t0 !R] t. If t0 !R] 2 t, then we are done because by induction hypothesis (t0 )h R] 2 t0 and
14
6. THATTE'S TRANSFORMATION FOR LEFT-LINEAR SYSTEMS clearly th = (t0 )h . If t0 !R] 1 t, say by application of an R] 1 -rule l ! r in a context C [ ] using a substitution (i.e. t0 = C [l ] !R] 1 C [r ] = t), then C [ ]h R] 2 C [ ] (since the R] 2 -rules are left-linear and have no overlap with R] 1 -rules). Moreover, if l = l(x1 ; : : : ; xn ) = l(t1 ; : : : ; tn ), then thi R] 2 ti for all 1 i n, since (t0 )h R] 2 t0 . Finally, note that the righthand sides of the R] 1 -rules are -terms.
Lemma 6.4 (R] 1 -R] 2 Strip Lemma) Let R = h; Ri be a nonoverlapping left-linear TRS. For all s; s0 ; t 2 T] ;V : s0 R] 2 s !R] 1 t implies that there is a t0 2 T] ;V such that s0 !R] 1 t0 R] 2 t. Proof First we show that s0 o?2 R] 2 s ?o!1 R] 1 t implies that there is a t0 2 T] ;V such that s0 !R] 1 t0 R] 2 t.
We distinguish cases according to the relative positions of o1 and o2 in s: o1 = o2 : This is impossible. If o1 = o2 , then (s=o1 )h = (s=o2 )h would be both an instance of a proper subterm of a lefthand side of a rule in R as well an instance of some lefthand side of a rule. o1 < o2 : Let l ! r be the R] 1 -rule applied at s=o1 and o2 = o1 :p. Because R] is nonoverlapping, it must be the case that p 62 OF (l). Thus, in t we can contract all descendants of o2 using the same rule as the one applied in s !R] 2 s0 , yielding a term u and t R] 2 u. On the other hand, again because R] is nonoverlapping and left-linear, in s0 it is still possible to reduce s0 =o1 , which clearly results in the same u. o2 < o1 : Similar (but note that o2 has only one descendant, viz. o2 , and that by construction and by left-linearity of R a righthand side of an R] 2 -rule cannot contain the same variable more than once). o1 and o2 disjoint: Obvious. Now the lemma follows by induction on the length of the reduction s R] 2 s0 .
Theorem 6.5
If R = h; Ri is a nonoverlapping left-linear TRS, then R is an !-simulation of R by R] . Proof We prove that the two conditions of De nition 3.6 hold. First, assume s !R t for s; t 2 T;V . We have to show that R (s) !+R] R (t). If s !R t then there are an o 2 O(s), a substitution , and an R-rule l ! r, such that s=o = l and t = s[o r ]. Furthermore, R] is constructed in such a way that s=o = l R] 2 (lic ) , and because hlic ; ri 2 R] 1 we nd s R] 2 s[o (lic ) ] !R] 1 s[o r ] = t. Now s[o (lic ) ] R] 2 R (s), so by Lemma 6.4 there is some t0 2 T] ;V such that R (s) !R] 1 t0 and t R] 2 t0 . Clearly, both t R] 2 R (t) and t0 R] 2 R (t), so R (s) !+R] R (t). The following diagram illustrates the procedure just described: s
R] # 2
R] s[o (l R] # 2
2
(s) =============== (s)
s !+
)]
ic
R]
1
Lem. 6.4
R]
! t ================== t R] R] # # !t R] (t) 2
2
0
1
2
Secondly, assume R] t for some s 2 range(R ) and t 2 T] ;V . According to De nition 3.6 we have to show the existence of a term t0 2 range(R ) such that ?R 1 (s) !+R ?R 1 (t0 ) and t R] t0 .
15 By Lemma 6.3 th R] 2 t. Moreover, because R] 2 is complete, and because R (th ) is obtained from th by an R] 2 -reduction we nd t R] 2 R (th ). So we take t0 = R (th ) and it remains to show that ?R 1 (s) = sh !+R th = ?R 1 (R (th )). Since s is an R] 2 -normal form, the rst step of the reduction to t must be an application of a R] 1 -rule, so we have s !R] 1 s0 R] t. Furthermore, s !R] 1 s0 implies sh !R (s0 )h . So by Lemma 6.2(i) and induction w.r.t. the length of the reduction s0 R] t, we get (s0 )h R th . Therefore sh !R (s0 )h R th , i.e. ?R 1 (s) !+R th .
Theorem 6.6 Let R = h; Ri be a TRS. The simulations hid(T;V ); hi and R preserve termination. Proof Observe that (1) t !R] 1 t0 implies th !R (t0 )h ; and (2) t !R]2 t0 implies th = (t0 )h . Now, assume s 2 T;V is terminating in R, while s has an in nite reduction in R] . Because h] ; R] 2 i is SN and T] ;V contains only nite terms, there must be in nitely many R] 1 -steps in this reduction, so it can be written as follows:
s R] 2 s0 !R] 1 s1 R] 2 s1 0 !R] 1 R] 2 sn?1 0 !R] 1 sn !R] 2 However, because of (1) and (2) together, this corresponds to
s = sh0 !R sh1 !R !R shn !+R which contradicts the assumption that s was terminating in R. So hid(T;V ); hi preserves termination, and since s R] 2 R (s) R preserves termination as well.
From Theorems 6.5 and 6.6 we get by Theorem 4.9 that if R is a nonoverlapping and left-linear TRS, then R] is a correct transformation of R as in [FP96].
7 Enlarging the Domain of Thatte's Transformation In 1988, Thatte tried to extend his result to a larger class of nonoverlapping con uent systems (without the restriction of left-linearity) [Tha88]. He based his correctness argument on the presumed fact that for the given class of rewrite systems his transformation resulted in a system that was con uent for reachable terms. Unfortunately, Thatte's proof for the class of nonoverlapping con uent systems does not work, and a counterexample of Rakesh M. Verma [Ver95b] shows that his theorem does not even hold. Inspired by his counterexample, Verma somewhat restricted the domain of the transformation and stated the theorem that for this domain the transformation preserved con uence. However, we discovered some fundamental errors in Verma's proof (see appendix A), and after we had noti ed him of these, he discovered a counterexample for his theorem [Ver96]. In this section we will discuss and simplify the restriction of the domain for Thatte's transformation that Verma proposed in [Ver95b]. We conclude with some positive preservation results.
7.1 Weak Persistence
In [Tha88] Thatte stated the following as a theorem: Claim 7.1 ([Tha88])
If R = h; Ri is nonoverlapping and con uent, then R] [T;V ] is con uent. This is clearly the same as stating that the simulation mapping hid(T;V ); hi (h as de ned in the previous section) preserves con uence. Verma refutes this claim. We will repeat
16
7. ENLARGING THE DOMAIN OF THATTE'S TRANSFORMATION
his counterexample and show that it also works for the mapping R that we used in the previous section. In appendix B we give the nontrivial proof that the original TRS of Verma's counterexample is con uent. From his counterexample, Verma derived an extra restriction that is necessary to obtain a con uence preserving simulation map. We will de ne this restriction (Verma called it `weak persistence') at the end of this section. Example 7.1 ([Ver95b]) Consider the TRS R = h; Ri and its transform R] = h] ; R] i, where = ff; g; h; a; cg and ] = [ fcf g. R and R] respectively consist of the rules: 8 h(c (x; x)) ! h(a); 9 8 h(f (x; x)) ! h(a); 9 >= < = ] >< f (x;f g(x)) ! a; R = : f (x; g(x)) ! a; ; ; R = c ! g(c); > >: f (x; x) c ! g(c) ! cf (x; x) ; In Lemma B.1 (see appendix B) we show that R is indeed con uent. However, R] is not con uent for reachable terms. Consider the -term f (g(c); c).3 Note that it is a R] 2 -normal form, so under (id(T;V ); h) as well as under R this term is simulated in R] by f (g(c); c). Furthermore, f (g(c); c) !R] 1 f (g(c); g(c)) so f (g(c); g(c)) is a reachable term under both simulation maps. However, R] j= CR(f (g(c); g(c))) does not hold (see the diagram below). f (g (c); g (c))
R #
]
R! ]
1
R !
f (g (c); g (g (c)))
]
a
1
2
cf (g (c); g (c))
R #
]
1
It is clear that cf (g(c); g(c)) never reduces to a, because there is no rule that removes the cf -symbol from this term. The problem in the above counterexample lies in the fact that R (although it is a nonoverlapping TRS) contains some ambiguity. For instance, for the -term h(f (g(c); g(c))), we have two dierent kinds of reductions to h(a): 1. the reductions using h(f (x; x)) ! h(a), e.g. h(f (g(c); g(c)) !R h(a); and 2. the reductions using f (x; g(x)) ! a, e.g. h(f (g(c); g(c)) !R h(f (g(c); g(g(c)))) !R h(a). Note that in the reductions of the rst kind f acts as a constructor symbol, while in the reductions of the second kind it acts as a de ned symbol. Intuitively, the rst step in the second reduction, that is, the application of the rule c ! g(c) to the second argument of f , switches the r^ole of f from constructor to de ned symbol. Note that this switch is not rigid, because if we apply c ! g(c) to the rst argument of f in h(f (g(c); g(g(c))) the rule h(f (x; x)) ! h(a) is applicable again. In R] things are a bit dierent. We still have this switching capability, but now we also have the possibility of making the switch rigid. In the situation where f appears in its r^ole of constructor (say in terms f (t; t)) we can now make that situation explicit by applying the rule f (x; x) ! cf (x; x), and then there is no return.
h
i
3 Verma uses the term f (c; c). This term works for the mapping id(T;V ); h , but not for our mapping R .
7.2 Conditions for Weak Persistence
17
To avoid this situation, Verma introduces his `weak persistence'. Informally, this notion makes sure that instances of terms in which the outermost symbol acts as a constructor symbol (instances of proper subterms of lefthand sides of rules) do not reduce to instances of lefthand sides of rules. Definition 7.2 (Weak Persistence) Let R = h; Ri be a TRS. We say that R is weakly persistent if there is no subtemplate s of R and s-pseudo-redex nt t1 ^ t1 ? t 2 T;V such that 9t1 ; t2 2 T;V (t ?! !r R t2 ). a s R nt r We refer to section 5.2 for de nitions of `subtemplate', `pseudo-redex', ?!R and ?!R . Note that R of Example 7.1 is not weakly persistent, because the switching reductions are the nontemplate reductions of the above de nition. The above formulation of weak persistence diers from that of Verma, but de nes an equivalent notion: Lemma 7.3 Let R = h; Ri be a TRS. The following statements are equivalent: 1. R is weakly persistent as in [Ver95b]. 2. R is weakly persistent as de ned in De nition 7.2.
Proof
(1 ) 2) Suppose R is weakly persistent as in [Ver95b]; we show that the conditions of De nition 7.2 are met. Let s be a subtemplate of R and t an s-pseudo-redex. nt t1 for some t1 2 T;V . Clearly, the root of t is untouched in Moreover, let t ?! s R nr this reduction (i.e. t ?! !r R t2 for R t1 ) and thus it cannot be the case that t1 ? some t2 2 T;V , for this would contradict weak persistence according to Verma. (2 ) 1) Contraposition. Suppose s is a subtemplate and t is an s-pseudo-redex contradicting the weak persistence of R as in [Ver95b], i.e. there are a t1 2 T such that nr t1 and an o 2 O(t1 ) \ OF (s) with t1 =o a redex. We show that t=o is an t ?! R
s=o-pseudo-redex that contradicts weak persistence as in De nition 7.2 of R. nt t1 . If t = t1 First observe that without loss of generality we may assume that t ?! s R nr nr nr 0 0 0 this is clear and if t = t0 ?!R t1 ?!R ?!R tn = t1 (n 1), then the the rst nt R t0 does not hold, would already contradict t0i+1 (0 < i < n) such that t0i ?! i+1 s weak persistence according to Verma, so we could have taken t1 = t0i and o = o0 , nr R t0 . for t0i =o0 the contracted redex of t0i ?! i+1 Furthermore, observe that s=o is a subtemplate of R, so t=o is an s=o-pseudo-redex, t=o ?s=o ?nt!R t1 =o and there is some rule of R applicable at the root of t1 =o. Thus, we conclude that the existence of a pseudo-redex contradicting weak persistence according to Verma implies the existence of a a pseudo-redex contradicting weak persistence as in De nition 7.2.
7.2 Conditions for Weak Persistence
Verma states the theorem that each subclass of TRSs that meets some requirements contains only weakly persistent systems. As corollaries of this, Verma obstains that the following systems are weakly persistent: 1. left-linear nonoverlapping systems with con uent root overlaps; 2. nonoverlapping strongly normalizing systems with con uent root overlaps; and
18
7. ENLARGING THE DOMAIN OF THATTE'S TRANSFORMATION
3. the subclass consisting of systems h [ fDi ; E g; R [ Di i (i = k or i = s), where it is assumed that Dk ; Ds ; E 62 , h; Ri is a regular TRS, Ds = fDs (x; x) ! E g, and Dk = fDk (x; x) ! E (x)g (these systems appear in [Klo80]). In this section we will give proofs of the above mentioned theorem, using our own de nition, and for Verma's corollaries. To show the weak persistence of the rst type of systems mentioned above we use the following proposition (instead of Verma's theorem). Proposition 7.4 i. Every weakly persistent TRS is nonoverlapping. ii. Every left-linear nonoverlapping TRS is weakly persistent.
Proof
i. Let R = h; Ri be a weakly persistent TRS, and assume that l; l0 2 LR , o 2 O(l), o 6= , and is a substitution such that (l=o) = (l0 ). Obviously, l=o is a subtemplate of R, so (l=o) is both a l=o-pseudo-redex and a l0 -redex. This contradicts weak persistence. ii. Suppose R = h; Ri is not weakly persistent. Then there is a substitution and some proper subterm s (say at position o 2 O(l)) of lefthand side l of some rule in R, nt s0 and s0 ? such that s ?! !r R t. But clearly, because sr is a linear term, there s R must be some substitution , such that s0 = s . Now s ?!R t implies that there is some rule (l0 ; r) 2 R and a substitution , such that (l0 ) = s = (l=o) . Thus, there is overlap and R is not nonoverlapping. Now it is trivial by the above proposition that left-linear nonoverlapping systems with con uent root overlaps (systems of the rst type) are weakly persistent. Theorem 7.5 (Theorem 9 of [Ver95b]) Let C be a class of nonoverlapping, uniquely normalizing TRSs h; Ri closed under name permutations and extensions R := R[fl ! ag (l 2 T;V , a a new constant symbol, i.e. a 62 ) such that: flg is nonoverlapping; for all nonvariable subterms t1 of a lefthand side m of a rule in R and t2 of l: : 9; ((t1 ) = (l) _ (t2 ) = (m)) Then C only contains weakly persistent systems. Proof Assume that C is as above, R 2 C and R = h; Ri is not weakly persistent. There must be a subtemplate s of some lefthand side l of a rule in R and an s-pseudont R t1 , with t1 a redex for a rule l1 ! r1 in R (t = (l1 ), for redex t, such that t ?! s substitution ). Assume that q; d; c 62 [ and de ne G = h?; Gi by G := h [ [ fq; d; eg; R [ fq (s0 ) ! d; l10 ! egi in which s0 and l0 are obtained by underlining function symbols at all occurrences except the root. It is easy to verify that the extension is such that it implies that G 2 C (note that if l10 overlaps s0 , then l1 overlaps s, quod non). Now, to arrive at a contradiction, we prove that G is not uniquely normalizing. Let t = (s); u1 = q( (s0 )). By our choice of u1 and construction of G, there is a term u2 nt0 R q (u2 ) and u2 is an instance of l0 . Now u1 ? !r G d corresponding to t1 , such that u1 ?q?? 1 (s! ) 0 via q(s ) ! d and q(u2 ) !G q(e). Clearly, both d and q(e) are normal forms, so G is not uniquely normalizing. We conclude that there cannot be a C satisfying all conditions mentioned that contains a system that is not weakly persistent.
7.3 Positive Results
19
Note that the requirement that classes as meant in the above theorem should be closed under extensions fl ! ag in which a is a constant, leads to an essentially stronger theorem, than if the requirement on a had been that is is just an arbitrary normal form. Furthermore, Verma included in his formulation of the theorem the requirement that l should be linear if all R 2 C are left-linear. This requirement does not play a r^ole in the proof and is only to make the theorem also applicable to subclasses of the class of left-linear, nonoverlapping systems (these classes trivially are not closed under extension with a nonlinear rule). However, Proposition 7.4(ii) already states that the whole class of left-linear, nonoverlapping systems only contains weakly persistent systems. As corollaries of the above theorem we now get that nonoverlapping strongly normalizing TRSs as well as some of the nonlinear systems mentioned in [Klo80] are weakly persistent. Corollary 7.6 Nonoverlapping, strongly normalizing TRSs with con uent root overlaps are weakly persistent. Proof We show that the class of nonoverlapping, strongly normalizing TRSs with con uent root overlaps meets the conditions of Theorem 7.5. Note that if R = h; Ri is a nonoverlapping TRS with con uent root overlaps, then R j= WCR by Proposition 5.2. In addition R j= SN by assumption, so by an application of Newman's Lemma R j= CR. Thus, we get that R j= UN. Moreover, if a rule l ! a is added (R+ = R[fl ! ag), such that l has no overlap with a rule in R, then (trivially) the resulting system is nonoverlapping and has con uent root overlaps. Finally, the resulting system is still strongly normalizing, for if it has an in nite reduction
s0 !R+ s1 !R+ !R+ sn !R+
(si 2 T[fag;V ; i 2 !)
then we construct an in nite reduction in R as follows (and the result follows by contraposition). Notice that in the above reduction there must be in nitely many applications of R-rules. Let : T[fag;V ! T;V be the function that replaces in t 2 T[fag;V each occurrence of the symbol a by the T;V -term l. If for s; t 2 T[fag;V and s !R t, then (s) !R (t). Moreover, if s !R+ t by an application of the rule l ! a, then (s) = (t). Therefore, the above in nite reduction translates to
(s0 ) R (s1 ) R !R (sn ) !R (si 2 T[fag;V ; i 2 !) and there are in nitely many i 2 ! such that si !R si+1 .
Corollary 7.7 The subclass of systems h [ fDi; E g; R [ Di i (i = k or i = s), where it is assumed that Dk ; Ds ; E 62 , h; Ri is a regular TRS, Ds = fDs (x; x) ! E g, and Dk = fDk (x; x) ! E (x)g contains only weakly persistent TRSs. Proof Note that a regular system extended in the way Theorem 7.5 describes is still regular. Furthermore, Klop proves in [Klo80] that the mentioned systems are con uent, so they are uniquely normalizing as well.
7.3 Positive Results
In this section we collect a number of positive preservation results that we obtained for Thatte's transformation. In particular, we show that for the systems that we proved weakly persistent in the previous section Thatte's transformation preserves con uence. For most of these systems we even get !-simulations.
20
7. ENLARGING THE DOMAIN OF THATTE'S TRANSFORMATION
According to a counterexample due to Verma [Ver96], weak persistence is not a sucient condition to obtain that Thatte's transformation preserves con uence. We will show, however, that it is sucient to guarantee that Thatte's transformation preserves the unique normal form property and weak termination. As a corollary of this, we obtain that Thatte's transformation is correct as in [FP96] for uniquely normalizing, weakly persistent systems and that it preserves semi-completeness for weakly persistent systems. First, recall that systems of the rst type mentioned in the previous section are in the scope of section 6; the present section deals with the other two. Definition 7.8 Let R = h; Ri be a TRS. We say that R has linear constructor variants if all subtemplates s with outermost symbol from F \ A (i.e. s = f (t1 ; : : : ; tn ) where f 2 F \ A, t1 ; : : : ; tn 2 T;V ) are linear. a Observe that if R is a nonoverlapping TRS with linear constructor variants, then h] ; R] 2 i is still left-linear. Therefore, Lemma 6.3 still holds for this class of systems (the proof of this lemma only uses the left-linearity of the R] 2 -rules). Unfortunately, Lemma 6.4 does not hold for this class. Below, we will prove a weaker version, which will turn out to be enough. In the proof of this weaker version we need the following proposition. Proposition 7.9 Let R = h; Ri be a nonoverlapping TRS with linear constructor variants. For all s; s0 ; t 2 T] ;V : if s0 R] 2 s R] 2 t, then there is a t0 2 T] ;V such that s0 R] 2 t0 , t !iR] 2 t0 and i 2 f0; 1g. Proof Induction w.r.t. the length of the reduction s R]2 t. The case where s !0R] 2 t is trivial: take t0 = s0 . If s !nR] 2 u !R] 2 t and the lemma holds for reductions of length n, then the induction hypothesis yields a u0 2 T] ;V such that s0 R] 2 u0 and u !iR] 2 u0 (i 2 f0; 1g). If i = 0, then u = u0 and thus s R] 2 u !R] 2 t, so we are done. o2 ] u0 . If o1 = o2 , then we take t0 = u0 = t, o1 ] t and u ?! If i = 1 then assume that u ?! R2 R2 0 and if o1 and o2 are disjoint, then in t, u we contract the single descendant of o1 , o2 respectively yielding u0 !R] 2 t0 R] 2 t. If o1 < o2 , or o2 < o1 , then since all rules in R] 2 are left-linear by assumption, so t=o2 and u0 =o1 are again R] 2 -redexes. Contraction of these redexes yields u0 !R] 2 t0 R] 2 t. Lemma 7.10 (Weak R] 1 -R] 2 Strip Lemma) Let R = h; Ri be a nonoverlapping TRS
with linear constructor variants. For all s; s0 ; t 2 T] ;V : if s0 R] 2 s !R] 1 t, then there are t0 ; t00 2 T] ;V such that s0 R] 2 t0 !R] 1 t00 R] 2 t. o1 ] t implies that there are t0 ; t00 2 T ] such that Proof We rst show that s0 o?2 R] 2 s ?! R1 ;V 0 0 00 s R] 2 t !R] 1 t R] 2 t by distinguishing cases according to the relative positions of o1 and o2 in s. The case where o1 = o2 is impossible as in the proof of Lemma 6.4, and for the cases where o1 and o2 are disjoint the proofs are trivial. We prove the remaining cases: o1 < o2 : Suppose s ! t was an application of a (possibly nonlinear) R] 1 -rule l ! r and o2 = o1 :p:q, where p 2 OV (l). If l=p is a variable that occurs only once in l, then nothing is the matter; we reason exactly as in the proof of Lemma 6.4. If, o 2 ] s0 however, the variable l=p occurs more than once in l then the reduction s ?! R2 disturbs the redex s=o1 . Now observe that the redex can be restored by applying the same R] 2 -rule to other occurrences of s=o2 , so there is a term s00 2 T] ;V such that s0 R] 2 s00 and s00 =o1 is again an l-redex. Contraction of this redex yields a term u that is reachable from t by contracting all descendants of the disjoint redexes
7.3 Positive Results
21
contracted in the reduction s R] 2 s00 .4 o2 < o1 : Since R has linear constructor variants, all rules in R] 2 are left-linear. Therefore, in t=o2 is still an R] 2 -redex. For the remainder of this case the proof is trivial. Now the lemma follows by induction w.r.t. the length of the reduction s R] 2 s0 . The case where s 0R]2 s0 is trivial. If s !nR] 2 u !R] 2 s0 and the lemma holds for reductions of length n, then the induction hypothesis yields terms u0 ; v 2 T] ;V such that u R]2 u0 !R] 1 v and t R] 2 v. By Proposition 7.9 there exists v0 2 T] ;V such that s0 R] 2 v0 and u0 !iR] 2 v0 with i 2 f0; 1g. If i = 0 then u0 = v0 , so we are done. If i = 1 then by the above there are v00 ; w 2 T] ;V such that v0 R] 2 v00 !R] 1 w and v R] 2 w. The proof for this latter case is depicted in the diagram below.
R
!t R R # # R R u u !v R R R # # # s R v R v R !w ]
s
]
]
(IH)
2
]
]
1
2
]
0
]
Prop. 7.9
2
0
2
1
]
2
0
]
2
2
00
]
2
]
1
Theorem 7.11 If R = h; Ri is a nonoverlapping TRS with linear constructor variants, then R is an !-simulation of R by R] .
Proof We need to prove that the two conditions of De nition 3.6 hold.
For the rst condition we argue as in the proof of Theorem 6.5, using Lemma 7.10 instead of Lemma 6.4. For the second condition we can apply the same argument as in the proof of Theorem 6.5, literally. It is an immediate consequence of the above theorem that Thatte's transformation preserves con uence for systems of the third type (Theorem 4.6). Moreover, it follows from the above theorem, using Theorem 6.6, that R] is a correct transformation of R if R is a nonoverlapping TRS with linear constructor variants. We now proceed with a proof that Thatte's transformation preserves the uniquely normalizing property for the class of weakly persistent systems. For the rst time we will really need weak persistence. More speci cally, we need the following consequence of weak persistence: Proposition 7.12 Let R = h; Ri be a weakly persistent TRS. r R t, then If s 2 T] ;V is reachable from T;V and there is a t 2 T;V such that sh ?! s() = sh (). Proof Assume s 2 T] ;V reachable, s = cf (s1 ; : : : ; sn ), sh = f (sh1 ; : : : ; shn ) (cf the conr R t for some t 2 T;V . structor variant of f ) and sh ?! Since s is reachable, there is a u 2 T;V such that u R] s and at some point in this reduction an R] 2 -rule l ! r must be applied to obtain the cf -symbol. Note that without loss of generality we may assume that this application is at the root, so there are u1 ; : : : ; un 2 T] ;V such that u R] l(u1 ; : : : ; un ) !R] 2 r(u1 ; : : : ; un ) R] s.
4 Note that, because of the way we de ned this concept, the sets of descendants of these redexes over the reduction s !R] 1 t are equal.
22
7. ENLARGING THE DOMAIN OF THATTE'S TRANSFORMATION By construction of R] , r consists entirely of constructor symbols and variables, so nt ] s. r(u1 ; : : : ; un) ?! r R nt h It is easy to see that then also (r(u1 ; : : : ; un))h ??! h(r ) R s (see Lemma 6.2(i); Thatte's proof of this lemma is applicable here). Moreover, by construction of R] , rh is a subtemplate of R. However, then we have a contradiction with the assumption that R is r R t. weakly persistent, because sh ?!
Definition 7.13 Let R = h; Ri be a TRS. We call s 2 T] ;V balanced, if (u0 )h = (u00 )h =) u0 = u00 for all subterms u0 ; u00 of s. a Proposition 7.14 Let R = h; Ri be a weakly persistent TRS and let s 2 T] ;V be a balanced term that is reachable from T;V . If sh !R t for some t 2 T;V by application of a rule l ! r at occurrence o 2 O(sh ), then there is a substitution and an l0 2 T] ;V such that s=o = (l0 ) , (l0 )h = l, and s R] 2 s[o (lic ) ] !R] 1 s[o r ]. Proof Let be such that sh =o = l . Note that if sh =o1 = sh =o2 , then s=o1 = s=o2 for all o1 ; o2 2 O(s), since s is balanced, so there is an l0 2 T] ;V and a substitution such that (l0 )h = l and s=o = (l0 ) (in particular, if l contains some variable x more than once, then l0 contains x exactly at the same occurrences). Moreover, l0 () = s(o) = sh (o) = lic(o) by Proposition 7.12 and the construction of R] 1 . Therefore, l0 R] 2 lic by construction of R] 2 , so s R] 2 s[o (lic ) ]. Now lic ! r is a rule in R] 1 , so s[o (lic ) ] !R] 1 s[o r ].
The following proposition is an immediate consequence of the above. Proposition 7.15 Let R = h; Ri be a weakly persistent TRS. If s 2 NF(R] ) is reachable from T;V and balanced, then sh 2 NF(R). In the proof of the following lemma we will speak of `linearized versions' of terms. We will informally introduce this notion. Let s be a term, possibly containing some variables more than once. s0 is a linearized version of s if s0 is a linear term that can be obtained from s by renaming occurrences of variables such that o1 6= o2 =) s=o1 6= s=o2 for all o1 ; o2 2 OV (s). For instance, if s = f (x; x; y; y) then f (x1 ; x2 ; y1 ; y2 ) would be a linearized version of s. Of course, every term has in nitely many distinct linear versions. This will not impose a problem, because we are only interested in the instances of such linearized versions and all linearized versions of a term are instances of each other. Lemma 7.16 Let R = h; Ri be a weakly persistent and uniquely normalizing TRS. For all s; t 2 NF(R] ) reachable from T;V : sh = th =) s = t. Proof Fix s; t 2 NF(R] [T;V ]) and assume that sh = th , but s 6= t; we derive a contradiction. Since both s and t are in normal form, all their subterms are in normal form. Therefore, without loss of generality, we may assume that s and t are balanced terms (if s is not balanced, then there are subterms u0 ; u00 of s such that u0 6= u00 , while (u0 )h = (u00 )h , so we take s = u0 and t = u00 ; if t is not balanced then we apply a similar argument; repeating this will eventually yield balanced terms for s and t, because we only consider nite terms). Moreover, because trivially all subterms of a balanced term are balanced, we may assume without loss of generality that s and t are minimal in the sense that s and t only dier at the root, i.e. o 6= =) s=o = t=o for all o 2 O(s); O(t) (again we can nd such minimal terms by inspection of s and t: if s; t are not minimal, then for some o 6= we have s=o 6= t=o, so we take s = s=o and t = t=o; this will eventually yield that s, t are minimal, by niteness of terms).
7.3 Positive Results
23
If s and t are minimal, then s = cf (s1 ; : : : ; sn ) and t = f (t1 ; : : : ; tn ) and si = ti for all 1 i n (or vice versa, but in that case we just interchange s and t). Since s is reachable, there is a u 2 T;V such that u R] s and at some point in this reduction some R] 2 -rule l ! r is applied to obtain the cf -symbol. Without loss of generality we may assume that this application is at the root, so there are u1 ; : : : ; un 2 T] ;V such that u R] l(u1 ; : : : ; um ) !R] 2 r(u1 ; : : : ; um ) R] s. Moreover, by construction of R] 2 , all symbols at nonvariable positions in r are construcnt ] s. Therefore, s is an instance of a linearized version tor symbols, so r(u1 ; : : : ; um ) ?! r R of r and t is an instance of a linearized version of l (using minimality and the construction of R] 2 ). Since by assumption t was in normal form, it cannot be an instance of l, so l contains at least one variable more than once, say at occurrences o1 ; o2 2 OV (l), and t=o1 6= t=o2 . This implies s=o1 6= s=o2 . However, l(u1; : : : ; um)=o1 = l(u1; : : : ; um )=o2 = ui for some 1 i m, so, because nt ] s, we nd s=o2 ] ui ] s=o1 . From this l(u1; : : : ; um) !R] 2 r(u1 ; : : : ; um ) ?! R R r R h h h (s=o2 ) R ui R (s=o1 ) follows (using Lemma 6.2(i)). Since s is balanced (s=o1 )h 6= (s=o2 )h . Moreover, since s=o1 ; s=o2 2 NF(R] [T;V ]) are balanced terms, we nd (s=o1 )h ; (s=o2 )h 2 NF(R) (using Proposition 7.15). Now we have reached a contradiction, because by assumption R was uniquely normalizing. Corollary 7.17 Let R = h; Ri be a weakly persistent and uniquely normalizing TRS. If s 2 NF(R] ) is reachable from T;V , then s is balanced. Proof Contraposition. If s is not balanced, then there are subterms u0 ; u00 of s such that (u0 )h = (u00 )h and u0 6= u00 , then u0 and u00 cannot be both in normal form, for this would
contradict Lemma 7.16. However, in that case s is not in normal form either.
Corollary 7.18 Let R = h; Ri be a weakly persistent, uniquely normalizing TRS. If n 2 NF(R] ), n0 2 T] ;V are both reachable from T;V and nh = (n0 )h , then n0 R] 2 n. Proof Since s !R] 1 t =) sh !R th , and R]2 is strongly normalizing: nfR]2 (n0 ) 2 NF(R] ). Clearly, (nfR] 2 (n0 ))h = nh , so by Lemma 7.16 nfR] 2 (n0 ) = n. Theorem 7.19 Let R = h; Ri be a weakly persistent TRS; the simulations hid(T;V ); hi
and R preserve the unique normal form property. Proof First we prove that hid(T;V ); hi preserves UN. Fix s 2 T;V and suppose R j= UN(s). In order to prove that R] j= UN(s) we show that if n1 R] s R] n2 , then n1 = n2 . Note that by Corollary 7.17 n1 and n2 are both balanced. Using Lemma 6.2(i), we nd that s R nh1 and s R nh2 . Moreover, nh1 ; nh2 2 NF(R) by Proposition 7.15. Since R is uniquely normalizing, nh1 = nh2 and thus, by Lemma 7.16, n1 = n2 , so R] j= UN(s). So hid(T;V ); hi preserves UN, and since s R] 2 R (s), R preserves UN as well.
Lemma 7.20 Let R = h; Ri be a weakly persistent, uniquely normalizing TRS. If R j= WN, then R] [T;V ] j= WN. Proof We inductively de ne for s 2 T] ;V : 1. if s 2 [ V , then depth(s) = 0; and 2. if s = f (s1 ; : : : ; sj ) and f 2 ] , then depth(s) = 1 + max1ij (depth(si )). Now we show by induction to depth(s) that R] j= WN(s) for all s reachable from T;V . If depth(s) = 0, then sh = s (recall that ] ? does not contain constant symbols). Because R j= WN(s), s R nfR (s) , so s R] nfR (s) by Lemma 6.2(ii) and nfR (s) R] 2 nfR] (s) by completeness of R]2 .
24
7. ENLARGING THE DOMAIN OF THATTE'S TRANSFORMATION Suppose that R] j= WN(s0 ) for all s0 2 T] ;V with depth(s0 ) k1 (IH1). Let s = f (s1 ; : : : ; sj ) with depth(s) = k1 + 1. By induction hypothesis there are n1 ; : : : ; nj 2 NF(R] ) such that s R] f (n1 ; : : : ; nj ) for 1 i j . We distinguish two cases: (1) f 2 ] ? ; and (2) f 2 . The rst case is trivial since f (n1 ; : : : ; nm ) is already in R] -normal form. Therefore it remains to show that R] j= WN(f (n1 ; : : : ; nj )) for f 2 . Instead of proving R] j= WN(f (n1 ; : : : ; nj )) directly, we prove R] j= WN(t(n1 ; : : : ; nm)) for all t 2 T;V , n1 ; : : : ; nm 2 NF(R] ) with depth(ni ) k1 (1 i m). Obviously, R] j= WN(f (n1 ; : : : ; nj )) then follows. Induction to the length of the reduction (t(n1 ; : : : ; nm ))h R nfR ((t(n1 ; : : : ; nm))h ). If (t(n1 ; : : : ; nm ))h 2 NF(R), then t(n1 ; : : : ; nm) R] 2 nfR] (t(n1 ; : : : ; nm )) follows by completeness of R]2 . Suppose for reductions of length k2 it holds (IH2) and assume (t(n1 ; : : : ; nm ))h !R t0 !kR2 nfR ((t(n1 ; : : : ; nm ))h ) with t0 2 T;V . Observe that if t(n1 ; : : : ; nm ) is not balanced, then it contains subterms u1; u2 such that uh1 = uh2 , while u1 6= u2 . Note that O(u1 ) = O(u2 ) and let o 2 O(u1 ) be a minimal position such that u1 (o) 6= u2(o), i.e. there is no q 2 O(u1 ) such that u1 (o) 6= u2 (o) and q < o. Now, u1 =o = f (v1 ; : : : ; vl ) and u2 =o = cf (w1 ; : : : ; wl ) for some f 2 with constructor variant cf (it may be necessary to interchange u1 and u2 to arrive in this situation). Moreover u2 =o 2 NF(R] ), since t does not contain symbols of the form cf . Therefore, u1=o R] 2 u2 =o by Corollary 7.18. Clearly, there are nitely many such o and they are all disjoint, so by a repetition of this argument we obtain that there is a balanced t00 2 T] ;V such that t(n1 ; : : : ; nm) R] 2 t00 . Notice that this t00 does not contain subterms u with u() 2 ] ? and depth(u) > k1 . Since t00 is balanced, by Proposition 7.14 there are t000 ; t 2 T] ;V such that t00 R] 2 t000 !R] 1 t and (t )h = t0 . It is easy to verify that t still does not contain subterms u with u() 2 ] ? and depth(u) > k1 . Therefore, (IH2) is applicable and yields R] j= WN(t ) and since t(n1 ; : : : ; nm ) R] t we nd R] j= WN(t(n1 ; : : : ; nm )).
Theorem 7.21 Let R = h; Ri be a weakly persistent, weakly normalizing TRS; the simulations hid(T;V ); hi and R preserve con uence. Proof If R j= CR and R j= WN, then by Theorem 7.19 R] j= UN and by Lemma 7.20 R] j= WN. Since WN & UN =) CR, we nd R] j= CR for terms reachable from T;V .
Thus, both simulations preserve con uence.
Corollary 7.22 Let R be a weakly persistent TRS; the simulations hid(T;V ); hi and R preserve semi-completeness. Trivially, if R = h; Ri be a weakly persistent, strongly normalizing TRS,the the simulations hid(T;V ); hi and R preserve con uence. Moreover, by Corollary 7.6, systems that are nonoverlapping, strongly normalizing and have con uent root overlaps are weakly persistent. Therefore it now follows that Thatte's transformation preserves con uence for systems of the second type. We conclude this section with a proof that Thatte's transformation is correct according to [FP96] for weakly persistent, uniquely normalizing TRSs. Theorem 7.23 (Correctness) If R = h; Ri is a weakly persistent and uniquely normalizing TRS, then R] is a correct transformation of R as in [FP96]. Proof By Theorem 6.6 the simulation hid(T;V ); hi preserves termination, so it suces to show that it also preserves the normal form relation (De nition 3.2). Note that h is de ned for all terms in T] ;V , so trivially it is de ned on all reachable normal forms in R] . fnh j n 2 nfR] [s]g nfR [s]: If s R] n and n 2 NF(R] ), then by Corollary 7.17 n is a
REFERENCES
25
balanced term, so by Proposition 7.15 nh 2 NF(R). Moreover, by Lemma 6.2(i) s R nh , so nh 2 nfR [s]. nfR [s] fnh j n 2 nfR] [s]g: If s R n0 and n0 2 NF(R), then by Lemma 6.2(ii) s R] n0 and using Lemma 6.2(i) and completeness of R]2 we nd n0 R] 2 n with n 2 nfR] [s] and clearly n0 = nh .
References [BKM89] Jan A. Bergstra, Jan Willem Klop, and Aart Middeldorp. Termherschrijfsystemen. Kluwer Programmatuurkunde. Kluwer Bedrijfswetenschappen B.V., 1989. In Dutch. [FP96]
Wan Fokkink and Jaco C. van de Pol. Correct transformation of rewrite systems for implementation purposes. Logic Group Preprint Series 164, Utrecht University, Department of Philosophy, 1996.
[Kam96] J.F.Th. Kamperman. Compilation of Term Rewriting Systems. PhD thesis, University of Amsterdam, Department of Computer Science, 1996. Available at http://www.cwi.nl/~jasper/. [Klo80] Jan Willem Klop. Combinatory Reduction Systems. PhD thesis, Mathematisch Centrum, Amsterdam, 1980. [KM91] Jan Willem Klop and Aart Middeldorp. Sequentiality in orthogonal term rewriting systems. Journal of Symbolic Computation, 12:161{195, 1991. [KW96] J.F.Th. Kamperman and H.R. Walters. Minimal Term Rewriting Systems. In Magne Haveraaen, Olaf Owe, and Ole-Johan Dahl, editors, Recent Trends in Data Type Speci cation, volume 1130 of Lecture Notes in Computer Science, pages 274{ 290. Springer Verlag, 1996. [LV95]
Nancy Lynch and Frits Vaandrager. Forward and backward simulations: I. untimed systems. Information and Computation, 121(2):214{233, September 1995.
[Tha85] Satish R. Thatte. On the correspondence between two classes of reduction systems. Information Processing Letters, 20(1985):83{85, February 1985. [Tha87] Satish R. Thatte. A re nement of strong sequentiality for term-rewriting with constructors. Information and Computation, 72(1):46{65, 1987. [Tha88] Satish Thatte. Implementing rst-order rewriting with constructor systems. Theoretical Computer Science, 61:83{92, 1988. [Ver95a] Rakesh M. Verma. A theory of using history for equational systems with applications. Journal of the Association of Computing Machinery, 42(5):984{1020, September 1995. [Ver95b] Rakesh M. Verma. Transformations and con uence for rewrite systems. Theoretical Computer Science, 152(2):269{283, 1995. [Ver96] Rakesh M. Verma. Personal communication, October 1996.
26
A. COUNTEREXAMPLES FOR VERMA'S PROOF
A Counterexamples for Verma's Proof In this section we present the counterexamples we found for a remark in Verma's proof of [Ver95b, Lemma 13] and his [Ver95b, Lemma 12]. In the proof of his Lemma 13 [Ver95b] Verma claimes that if R = h; Ri is a weakly persistent system with transform R] = h] ; R] 1 [R] 2 i and s 2 T] ;V [T;V ], then sh R] 2 s in R] . The following example demonstrates that this is not true. Example A.1 Consider the TRS R = h; Ri, with transform R] = h] ; R] i. Here = fa; b; f; g; hg and ] = [ fcf g. R and R] respectively consist of the rules:
8 8 g(f (x; x)) ! a; 9 = ] >< fg((ca;f (bx;) x)) < ! a; ; ; R = > h(x) R = : f (a; b) h(x) ! b : f (x; x)
! ! ! !
a; a; b; cf (x; x)
9 >= >;
Observe that R j= SN5 and R is nonambiguous. Applying Corollary 5.3 and Newman's Lemma we nd R j= CR, so R has the unique normal form property. Now, if R would not be weakly persistent, then there would be some term t 2 T;V such that f (t; t) R f (a; b). However, a and b are both normal forms in R, so that a R t R b, which contradicts R j= UN. Therefore, R is weakly persistent. In R] we have f (h(b); h(b)) !R] 2 cf (h(b); h(b)) !R] 1 cf (h(b); b). This reduction demonstrates that the term cf (h(b); b) is reachable, under both simulation mappings hid(T;V ); hi and (for the latter note that (f (h(b); h(b))) = cf (h(b); h(b))). But (cf (h(b); b))h = f (h(b); b) is in R] 2 -normal form. In fact, the above example also demonstrates that weak persistence is not sucient to establish R ! R] . In R we have f (h(b); h(b)) !R f (h(b); b), but (f (h(b); b)) = f (h(b); b) and in R] we do not have cf (h(b); h(b)) !+R] f (h(b); b). This is a violation of the rst condition of De nition 3.6. Recall that R ! R] would have implied con uence right away (Theorem 4.6). We now adapt the above counterexample a little to obtain a counterexample to Verma's Lemma 12: Claim A.1 (Lemma 12 in [Ver95b]) Let R = h; Ri be a weakly persistent TRS with transform R] = h] ; R] i. If s 2 T] ;V [T;V ]; t 2 T;V and sh !R t, then there is a t0 2 T] ;V such that s R] t0 and (t0 )h = t. Example A.2 Consider the TRS R = h; Ri, with transform R] = h] ; R] i. Here = fa; b; f; g; hg and ] = [ fcf g. R and R] respectively consist of the rules:
8 g(c (x; x)) 8 g(f (x; x)) ! a; 9 < = ] >< f (a;f b) R = : f (a; b) ! a; ; ; R = > h(x; x) h(x; x) ! x : f (x; x)
! ! ! !
a; a; x; cf (x; x)
9 >= >;
It is easy to adapt the argument of Example A.1 to obtain R j= SN, R j= CR, R j= UN and weak persistence. The term cf (h(b; b); b) is reachable, as witnessed by the reduction:
f (h(b; b); h(b; b)) !R] 2 cf (h(b; b); h(b; b)) !R] 1 cf (h(b; b); b)
jj jj j
j
5 If we take s = OF (s) as a complexity measure, then s
!R t in R implies jtj < jsj.
27 Furthermore, in R we have h(f (h(b; b); b); f (h(b; b); b)) !R f (h(b; b); b). Now, take s = h(f (h(b; b); b); cf (h(b; b); b)); it is clear that sh = h(f (h(b; b); b); f (h(b; b); b)), so Verma's Lemma 12 suggests the existence of a t0 2 T] ;V such that s R] t0 and (t0 )h = f (h(b; b); b). However, there is no such t0 . We argue as follows. First note that s is not a redex of R] (while sh is a redex of R). The only redexes in s are the h(b; b) at occurrences 1:1 and 2:1. Moreover, contraction of either one of these two redexes does not yield any new redexes and neither of the resulting terms (say s0 ) satisfy (s0 )h = f (h(b; b); b). So in our search for such a term we will have to contract them both. That is, we get the reduction h(f (h(b; b); b); cf (h(b; b); b)) R] 1 h(f (b; b); cf (b; b)). Still, we have not found our t0 , because h(f (b; b); cf (b; b))h 6= f (h(b; b); b), but we created one new redex: f (b; b). Thus, the only possibility we have is to contract this redex: h(f (b; b); cf (b; b)) !R] 2 h(cf (b; b); cf (b; b)). Again, this reduction does not yield the t0 we were looking for, so we contract this whole term (note that this is the only redex): h(cf (b; b); cf (b; b)) !R] 1 cf (b; b). Since, cf (b; b) is a normal form, it is our last option for t0 , but cf (b; b)h = f (b; b) 6= f (h(b; b); b). This refutes Verma's claim.
B A Con uence Proof for Verma's Counterexample Lemma B.1 The TRS R = h; Rc [ Rf i, where = fa; c; f; g; hg, Rc = fc ! g(c)g and Rf = fh(f (x; x)) ! h(a); f (x; g(x)) ! ag is con uent. Proof Note that if s !Rc t, then OF (s) OF (t). Now, we will rst prove three simple
facts: 1. h; Rc i j= CR. Because it is clearly regular, this is an immediate consequence of Corollary 5.4. o f t1 =) 9t; t0 2 T;V (t2 Rc t0 ? !o Rf t Rc t1 ), and 2. 8s; t1; t2 2 T;V (t2 Rc s ?! R for all positions o1 ; : : : ; on of redexes contracted in the reduction t2 Rc t0 , it holds that oi > o (1 i n). Either s=o = f (u; g(u)) or s=o = h(f (u; u)). Note that o 2 OF (t2 ) and that t2 =o = f (u1 ; g(u2)) or t2 =o = h(f (u1 ; u2 )). If u1 = u2 , then the same rule as applied in s !Rf t1 is still applicable. In this case we take t0 = t2 . If u1 6= u2, then they have a common reduct u0 by the previous fact. We take t0 = f (u0; g(u0 )) or t0 = h(f (u0 ; u0 )) respectively, and t2 Rc t0 . The redexes contracted in this reduction clearly all lie below o, and the Rf -rule can be applied to t0 =o, so t0 !Rf t. Finally, contracting all descendants over s !Rf t1 of redexes contracted in the reduction s Rc t2 Rc t0 , results in t1 Rc t. o2 Rf t2 , with for all 3. For all s; t1 ; t01 ; t2 ; t02 2 T;V : t1 o?1 Rf t01 Rc s Rc t02 ?! redex positions p1 ; : : : ; pm and q1 ; : : : ; qn contracted in s Rc t01 and s Rc t02 , respectively, pi > o1 and qj > o2 (1 i m, 1 j n), implies that there is a t 2 T;V , such that t1 R t R t2 . The cases where o1 6< o2 and o2 6< o1 (so either o1 = o2 , or they are disjunct) are trivial. Moreover, if o1 < o2 , or o2 < o1 , and s=o1 = h(s=o2 ), or s=o2 = h(s=o1 ), then we nd that t1 =o1 = h(a) = t2 =o1 , or t1 =o2 = h(a) = t2 =o2 , respectively, and thus t1 = t2 . So assume o1 < o2 and not s=o1 = h(s=o2 ). Either s=o1 = f (u; g(u)) or s=o1 = h(f (u; u)), and t2 =o1 = f (u1; g(u2 )), or t2 =o1 = h(f (u1 ; u2 )), with u = u1 , or u = u2. Clearly, we can reduce t2 =o1 to f (u0; g(u0 )), or to h(f (u0 ; u0)), using the o2 f t2 (either u0 = u1 , or u0 = u2 ) to obtain a same rules as applied in s Rc t02 ?! R o1 f t1 . This gives us the 0 term t , and then apply the same rule as applied in t01 ?! R o 0 1 reduction t2 R t ?!Rf t1 . The case where o2 < o1 and not s=o2 = h(s=o1 ) goes similarly.
28
B. A CONFLUENCE PROOF FOR VERMA'S COUNTEREXAMPLE We de ne on s 2 T;V a complexity measure jjsjj = jfo 2 OF (s) j s(o) = f gj. Clearly jjsjj < ! for all s 2 T;V and if s !Rf s0 , then jjsjj < jjs0 jj. With the above facts at hand, we will derive con uence for all terms 8s 2 T;V (R j= CR(s)), using induction w.r.t. jjsjj. The base case follows immediately from the rst fact, for if t1 R s R t2 and jjsjj = 0, then s Rc t1 and s Rc t2 . Assume that t1 R s R t2 , with jjsjj = n + 1 and 8t 2 T;V (R j= CR(t)) with jjtjj = n (IH). Note that if both reductions only contain applications of Rc -rules, then we get a common reduct using the rst fact. If only one of the reductions contains applications of Rf -rules, then we have the following diagram:
! Rt R R IH R R # # # # t R R R ! R t If both reductions contain applications of Rf -rules then we can tile the following diagram: R s R ! Rt s
c
R
(1)
2
R
c
f
c
c
1
c
(2)
c
(
)
f
c
f
1
R
c
#
(1)
R
c
R #
c
(2)
R c
R #
c
R
f
(2)
(3) f
R
c
t2
c
f
IH )
(
R # R #
R #
R # ! R
IH )
(
R
R
R
# R # R # t