Decision problems in Ordered Rewriting Hubert Comon
Paliath Narendran
Michael Rusinowitch
CNRS & LSV ENS de Cachan 61 Av. du Prsident Wilson F-94235 Cachan cedex France
SUNY at Albany Dep. of Comp. Science Albany, NY 12222 USA
INRIA-Lorraine and CRIN 615, rue du jardin botanique BP 101 54602 Villers les Nancy cedex France
[email protected]
[email protected]
[email protected]
November 10, 1997
1 Introduction Since the Knuth and Bendix landmark paper [12], a lot of work has been devoted to the completion of term rewriting systems. The basic idea of completion, as stated in [2], is to add consequences of equational axioms in order to simplify the equational proofs, according to a given well-founded ordering. Ultimately, the simplest proofs are rewrite proofs. Such proofs can always be obtained from canonical rewrite systems, yielding a decidable word problem. There are however several drawbacks in the original Knuth-Bendix completion procedure: rst, it can run forever and second, it may fail. The rst weakness cannot be avoided as the word problem is in general undecidable for equational theories. On the other hand, the failure of Knuth-Bendix completion occurs when the procedure encounters an equation which cannot be oriented using the given ordering. A typical example is the commutativity axiom x + y = y + x. It is not possible to use this axiom from left to right (nor from right to left) without losing the termination of rewriting. Several solutions have been proposed to overcome this problem and we refer to [6] for a survey. Let us point out one of them which seemed simple and promising: instead of trying to orient the equation in one way or another for all instances, orient it, depending on the actual instances which are used. For instance, assume that the ordering is lexicographic (i.e., compare rst the left arguments and in case of equality, compare the second arguments). Then x + y = y + x can be used from left to right on the term t + t if t > t . This is what has been called ordered rewriting. It has been introduced in [7] and improved in several ways. The most successful improvement consists in viewing the equations as constrained rules: s = t can be viewed as two rules: s ! t j s > t and t ! s j t > s. The semantics of such constrained systems and the generalization of completion techniques to constrained rules are investigated in several papers. Let us mention [11] for a survey and [17] where the completeness of basic superposition with ordering constraints is established. Besides completion, several questions concerning ordered rewriting were left open. The main one (listed as open problem #64 in the list of open problems in rewriting, 1993) is the decidability of con uence. Con uence is known to be undecidable for arbitrary nite term rewriting systems. What about ordered rewriting? The question is raised in [15] in general and for lexicographic path orderings in particular. In this [15], the problem is reduced to solving ordering constraints in the set 1
2
1
2
1
of normal forms. However the question of con uence is left open. In the present paper we answer the question, showing that, for total lexicographic path orderings, the con uence of ordered rewriting is decidable. More precisely, we show that there is a terminating algorithm which, given a nite set of equations and a lexicographic path ordering, answers \yes" if the induced ordered rewriting relation is con uent and \no" otherwise. This is quite a surprising result (in favour of ordered rewriting) since extending the notion of reduction we go from undecidability to decidability. Thinking a little more, there is a clue for this result: ordered rewriting is always terminating, and the source of undecidability might be non-termination. However, the picture is not so simple. For instance we show that, if we start from a nite set of constrained equations, then con uence is undecidable (while ordered rewriting is still terminating). Unfortunately, such constrained equations may occur along the completion procedure starting with unconstrained equations. This relativizes the scope of our decidability result and also shows its signi cance. Let us explain the main problem of deciding con uence in the case of ordered rewriting. Since the reduction relation is always terminating, con uence reduces to local con uence and, as in the case of unconstrained equations, it reduces checking the joinability of critical pairs. Such critical pairs are constrained equations s = t j c where c is a conjunction of ordering constraints recording the conditions under which the equation is derivable. The problem now is to decide whether the original set of equations may reduce (using only ordered rewriting) all instances of s = t, satisfying c, to a tautology. This is not so easy because simpli cation of constrained equations is undecidable [4]: given a term s and a constrained rule l ! r j c, whether or not all instances of s can be reduced by the rule is undecidable. Our con uence result hence heavily relies on the fact that c is not any constraint, but the constraint l > r. On the other hand, we do not consider only a given term s, but also constrained equations s = t j c0 . Going further, we investigate the use of ordered rewriting in a classical application of rewrite systems: the proof-by-consistency approach to proving inductive theorems [9, 8, 1]. Here again, the result is the opposite of what happens in the case of nite term rewriting systems: we show that ground reducibility is undecidable for ordered rewriting. The paper is organized as follows. We mainly focus on our decidability result: the decidability of con uence. Our proof follows the same lines as [15]. Hence we rst recall in section 2 the basic notions of ordered rewriting, as well as some results on ordering constraints. In section 3, we introduce Nieuwenhuis's con uence trees and we show how to solve constraints over the set of normal forms and derive the decidability of con uence. In section 4 we sketch the undecidability of con uence for a nite set of constrained equations. In section 5, we show that ground reducibility is undecidable for ordered rewriting. Finally, in section 6, we state some possible extensions and implications of our decidability result in other areas and discuss some of the strengths and weaknesses of ordered rewriting.
2 Ordered rewriting and Con uence trees
2.1 Terms We adopt the terminology and the notations of [6]. T (F ; X ) is the set of nite terms built on an alphabet F of function symbols, each of them having a xed arity and an alphabet X of ( rst-order) variable symbols. T (F ) is the set of terms which do not contain any variables. Positions in a term are strings of positive integers, corresponding to paths in the tree representation of the term. The 2
set of positions of a term t is written Pos(t). If p is a position of t, then tjp is the subterm of t at position p and t[u]p is the term obtained by replacing tjp with u at position p in t. The equality between two terms (identity) will be written in order to distinguish it from the equality symbol (relation) at the syntactic level, which is written = as usual.
2.2 Lexicographic path orderings Assuming that F is a well-founded ordering on F , the lexicographic path ordering on T (F ) [5] is de ned by:
s f (s ; : : : ; sn) lpo g(t ; : : : ; tm) t 1
1
i
Either there is some i 2 [1::n] such that si lpo t Or f >F g and, for all i 2 [1::m], s >lpo ti Or else f = g (and n = m) and (s ; : : : ; sn)lpo(t ; : : : ; tn) and for all i 2 [1::m], s >lpo ti . where , the lexicographic extension of , is de ned by: (s ; : : : ; sn ) (t ; : : : ; tn ) i there is an index i such that 8j < i, sj tj and si > ti . (For all orderings on terms, > stands for n .) 1
1
1
Example 1 Assume F = ff; succ; 0g with f >F f (0; succ(succ(0)))).
succ(
succ
1
>F 0. Then f (0; succ(f (succ(0); 0))) >lpo
The lexicographic path ordering is a simpli cation ordering : it contains the tree embedding. This implies in particular that it is well founded and monotonic: if s >lpo t, then f (: : : ; s; : : : ) >lpo f (: : : ; t; : : : ) (see e.g. [6] for more details). Also, F is total on F i lpo is total on T (F ). We chose this ordering (on which the notion of ordered rewriting will rely) because of these properties. There are other possible choices, which do not necessarily yield the same results.
2.3 Ordering constraints By constraints we mean the following logical system:
Syntax: Formulas are Boolean combinations (using the connectives ^; _; :) of atomic formulas which have one of the forms: s = t or s > t where s; t 2 T (F ; X ). Semantics: The formulas are interpreted in T (F ); the Boolean connectives have their usual meaning and an assignment of the free variables of s > t (resp. s = t) satis es s > t (resp. s = t) i s >lpo t (resp. s t ).
We write j=T F c when the assignment satis es the constraint c. (
)
Example 2 Let F be as in the previous example. The assignment = fx 7! succ(0); y 7! succ(succ(0))g satis es the constraint f (0; x) > y > x (which is shorthand for f (0; x) > y ^ y > x). There is no assignment satisfying the constraint succ(x) > y > x. 3
Note that : can be removed from the syntax of the constraint when the ordering is total since :(s > t) is logically equivallent to (s = t) _ (t > s) and :(s = t) is logically equivalent to (s > t) _ (t > s). We will also consider the satisfaction of constraints over extended signatures. The relevance of such interpretations is explained in e.g. [20] and we will come back later to it. An assignment satis es the constraint c over extended signatures (which we write j=eT F c) when there is an F 0 F and an ordering F extending F such that j=T F c. (
0
Example 3 signature.
(
)
0)
x) > y > x is unsatis able in T (F ). It is however satis able over an extended
succ(
Satis ability over extended signatures reduces to a particular satis ability problem:
Theorem 2.1 (A. Rubio [20]) j=eT F c i j=T F c where F equal to F ] fsucc; 0g (succ is unary and 0 is a constant) and F is de ned as F [ff >F succ j f 2 Fg [ fsucc >F 0g. (
(
)
0
0)
0
0
0
The satis ability problem for both j=T F and j=eT F is decidable: (
)
(
)
Theorem 2.2 ([3, 16]) The satis ability problem of lpo-ordering constraints is NP-complete (both in the standard case and in the extended signature case).
A rst key step in the proof of this theorem is to show that any constraint is (eectively) equivalent to a nite disjunction of simple systems. Simple systems are particular constraints of the form
S = s # s : : : #n sn def
1
1
2
+1
where #i is either = or > and such that: 1. S is closed under subterm: every strict subterm of si is some sj , for j > i. 2. for every distinct indices i; j , si 6 sj . The equational part of a simple system S , which we write eqpart(S ), is the (simpli ed, according to uni cation rules) set of equations occurring in S . The inequational part of S is the simple system I where I is the set of inequalities occurring in S and is the most general uni er of eqpart(S ).
2.4 Ordered rewriting We assume from now on that F is total and we write F e the extention of F with fsucc; 0g at the lower end, as in the previous paragraph. > Let E be a set of equations. The ordered rewriting relation de ned by E , ?! (with respect to E e the lexicographic path ordering) is the smallest binary relation on T (F ) such that: > s ?! t if s = t 2 E and s >lpo t E
4
> > f (: : : ; s; : : : ) ?! f (: : : ; t; : : : ) if s ?! t E E
Example 4 Assume F and F are de ned by >F + >F and E = fx + y = y + x; x + (y + z) = (x + y ) + z g. > > > Then (succ(0) + 0) + 0 ?! (0 + succ(0)) + 0 ? ! 0 + ( succ(0) + 0) ? ! 0 + (0 + succ(0)), the latter E E E term being irreducible. A constrained rule s ! t j c where s; t 2 T (F ; X ) and c is a constrained, is a denotation of the (possibly in nite) set of rules [[s ! t j c]] = fs ! t j j=eT F cg (
)
> The relation ?! is actually the usual rewrite relation on T (F e) associated with the set of E constrained rules fs ! t j s > tg [ ft ! s j t > sg. Similarly, a constrained equation s = t j c denotes the set of instances s = t such that j=eT F c and the associated ordered rewriting relation is de ned accordingly. (
)
2.5 Con uence, critical pairs and the word problem A critical pair between two equations u = v and s = t of an ordered rewrite system is a constrained equation u [t ]p = v j s > t ^ u > v where is the most general uni er of ujp and s and the constraint is satis able. Let ! be a binary relation on D, we write ? ! its transitive and re exive closure. ! is said to be con uent if,
8d; d ; d 2 D; (d ? d ?! d ) ) (9d 2 D; d ?! d ? d ) 1
2
1
2
3
1
3
2
Newman's lemma states that, for a terminating relation, con uence is equivalent to the following weaker property called local con uence:
8d; d ; d 2 D; (d ? d ?! d ) ) (9d 2 D; d ?! d ? d ) 1
2
1
2
3
1
3
2
For term rewriting (resp. ordered rewriting) local con uence itself reduces to the con uence of critical pairs: > Lemma 2.3 Given a nite set of equations, ?! is con uent i, for every critical pair u = v j c, E > < for every such that j=eT F c, there is a term w such that u( ?! ) w ( ? ) v. E E (
)
This result is essentially due to J. Hsiang and M. Rusinowitch [7]. See also [2]. The word problem for a set of equations E is to check, given an equation s = t, whether or not it is a logical consequence of E . The following proposition relates con uence of ordered rewriting and the word problem (see e.g. [20]). 5
> Lemma 2.4 If ?! is con uent, then the word problem is decidable for E . E
To prove this, the key idea is the following: consider the equation t = u and replace the variables x ; : : : ; xn occurring in t = u with succ(0); : : : ; succn(0) respectively, yielding an equation t^ = u^. If u = v is a logical consequence of E , then the equation ^t = u^ should be a logical consequence of E . Conversely, since succ and 0 are symbols which do not occur in E , if ^t = u^ is logical consequence of E , then so is u = v . 1
We detailed this remark in order to show the relevance of extended signatures. The above proposition shows that the de nition of ordered rewriting as a relation on T (F e ) (instead of T (F ; X )) is not a restriction.
3 Decidability of con uence of ordered rewriting We follow the ideas of [15] where con uence trees are introduced.
3.1 Con uence trees We de ne a con uence tree for E as a variant of the one de ned in [15]. The nodes of a con uence tree are constrained equations. The root is an equation s = t such that s = t j C is a critical pair of E . The successors of a node are derived by constrained rewriting, decomposition or instantiation. By constrained rewriting a constrained equation e j C can be rewritten with l = r 2 E into e[r] j C ^ r < l and into the complementary equations e j C ^ r > l and e j C ^ r = l i
(i) ejp l (ii) C ^ r < l is satis able (iii) x 0 for every variable x in r not occuring in l By decomposition e j C can be rewritten into fe j S ; : : : ; e j Si ; : : : ; e j Sn g, n 2, where fS ; : : : ; Si; : : : ; Sng is a non-empty set of satis able simple systems for C obtained, e.g., as in [16]. By instantiation e j C can be rewritten into e j ineqpart(C ), where C is a simple system with eqpart(C ) = (y = s ^ : : : ^ yn = sn ) and the substitution is de ned by: (yi ) si for 1 i n. 1
1
1
1
Lemma 3.1 (Nieuwenhuis [15]) Every con uence tree is nite. For the sake of completeness we outline the proof of this lemma which is similar to Lemma 6.1 of [15]. Proof: The tree is nitely branching. Hence by Konig's lemma one only needs to prove that every path is nite. Only a nite number of instantiations can be applied on a branch since they reduce the number of variables of the descendant nodes. 6
Only a nite number of nodes obtained by constrained rewriting can occur on a branch. Otherwise we can assume that there exists a long branch with two nodes ei j Ci ; ej j Cj (i < j ), such that ei is embedded in ej (by Kruskal's theorem) and there is a constrained rewriting node between ei j Ci and ej j Cj . Then ej < ei ^ Cj should be satis able but this contradicts the fact that the LPO ordering contains the embedding relation. Note that since we cannot apply in nitely many constrained rewriting steps on a branch we cannot have in nitely many nodes with complementary equations either. Since decomposition can be applied only once to a node, this shows that the tree is nite. 2
Lemma 3.2 (Nieuwenhuis [15]) If E is non-con uent, then there is a critical pair u = v j C such that, for every con uence tree rooted with u = v , there is a leaf s = t j C and a substitution such that j=eT F C and s and t are distinct. Proof: As we have seen in the previous section, E is not con uent i there is a critical pair u = v j C and a substitution such that j=eT F C and u and v are not joinable. 0
(
0
)
(
)
0
Consider a con uence tree with u = v at the root and a ground substitution . We can prove by induction that there is a path from the root to a leaf such that for every node ei j Ci on the path there exists an instance ei i where 1. i j=eT F Ci 2. u = v rewrites to eii Let s = t j C be the leaf ending this path where is the substitution such that u = v rewrites to s = t . If u and v are not joinable then s and t are necessarily distinct. 2 (
)
Example 5 Consider again the simple example 4. Critical pairs are as follows: fx + (y + z) = (y + x) + z j x > y; x + (y + z) = z + (x + y) j x + y > zg
Other pairs yield unsatis able constraints or renamings of the above pairs. Then a con uence tree rooted with x + (y + z ) = (y + x) + z is depicted in gure 1. Framed nodes are leaves of the con uence tree. (This tree contains in total 16 nodes, 10 of which are depicted). We can see that the set of equations is not con uent as there are leaves which are not tautologies. Our goal is precisely to prove the following theorem:
Theorem 3.3 For any ( nite, unconstrained) E , the ordered rewriting relation is con uent if and
only if for every critical pair, some (and then every) con uence tree rooted with the corresponding equation has leaf nodes which are tautologies. The \if part" is clear from lemma 3.2 and lemma 2.3. To prove the \only if" part we develop more machinery in the next section. More precisedly, we show that if there is a leaf s = t j C of a con uence tree such that s 6 t, then there is a substitution such that j=eT F C and t and s are distinct irreducible terms. Then, if u = v is the root of the con uence tree, u and v have > distinct sets of normal forms, which shows that ?! is not con uent. E (
7
)
x
x
+ (z + y ) =
y
+ (z + y ) =
+ (z + x)
x
y
@PPPPP P @ + (x + z )
+ (z + y ) =
j y > z^x > z
y
j y > z
z
j y > z
+ (x + z ) ^x = z
+ (z + y ) =
y
x
x
+ (y + z ) = (y + x) +
x
+ (y + z ) =
x
hhhhhh hhhhhh y
+ (x + z )
+ (y + z ) =
+ (z + y ) =
y
z
y
+ (x + z )
@
+ (x + z )
j y > z > x
@
x
j y
=
z
x
.. .
+ (x + z ) =
x
+ (y + z ) =
y
+ (x + z )
.. .
j y < z
+ (x + z )
+ (z + z )
j y > z
Figure 1: An example of a con uence tree
3.2 Irreducibility Graphs We de ne a graph, which is a constraint, conjunctions of inequalities of the form s < t with a certain (\almost-linear") structure. A graph G(t; t0; S ) on terms t and t0 and additional relations S is an lpo-closed set of pairs (p < q) such that
(i) subterms of t and t0 are totally ordered, forming a simple system L (called the \spine" of the
graph) (ii) every variable x is in L. In other words all variables occuring in some p < q, occur in either t or t0 . (iii) if (u < v) is in the graph, then u is in L. (iv) inequalities of S belong to the graph. A set of inequalities is lpo-closed i for every two nonvariable terms s f (s ; s ) and t g (t ; t ) such that s < t (i.e., node t is reachable from node s), one of the following holds: 1
2
+
(a) s < t or s t (b) s < t or s t (c) (f z ^ x > z. The following is an irreducibility graph Gi(x + (y + z); y + (z + x)): (z + y ) + x
(z + x) + y x+z y+z _ _ _ _ x + (z + y) > y + (z + x) > z + x > z + y > x > y > z
the spine is the lower line:
x + (z + y) > y + (z + x) > z + x > z + y > x > y > z and S consists of the other inequalities. A substitution is alien i, for every variable x, the root symbol of x is succ, and, for distinct variables x; y , x 6 y. (Recall that 0 and succ are not in the initial signature F .) We de ne the minimal solution of a simple system (0 < t < : : : < tn ) as the one that is built incrementally by induction on i as follows: 1
if ti is a variable then ti = succ(ti? ) 1
Lemma 3.4 If a graph G(t; t0; S ) is consistent (i.e., admits a solution), then the minimal solution
of the spine L will satisfy the graph.
Proof: Let be the minimal solution of the spine L. We have to show that for any pair of terms (s; t) such that s < t in the graph, s y > f (x) $ = x j $>x x = y j $>x>y m(x) = x
for every f 2 F
and a copy of some rules in Ru;v ; let E be 1
(x) = (x) j $ > x
for every rule $ ! $ 2 Ru;v
Basically, the rst equation in E expresses what we want: the solutions for y of m(f (x)) > y > f (x) are the terms succn (f (x)) (n > 1). Moreover, if E = Ru;v [ E [ E is the resulting set of 0
0
11
1
constrained equations, we claim that for every term s 2 T (F e), s has a unique normal form w.r.t. E which belongs to T (F ). We will write s^ this normal form. Let us rst prove this claim. 1
0
0
[[E ]] = fsuccn (f (x)) ! f (x) j f 2 F ; n 1g [f$ ! u j u 2 T (fm; succ; 0g)g [fs ! t j s; t 2 T (fm; succ; 0g); s > tg [fm(x) ! xg 0
According to the three last sets of rules, the only irreducible term in T (f$; m; succ; 0g) is 0 and every term in this set reduces to 0. The rst set of rules eliminates all occurrences of succ which are above a symbol f > $. Moreover [[E ]] is con uent since all critical pairs are trivially joinable. >! if ??! is the reduction relation with respect Moreover, on T (F e ), ?R??! ?? ! ? ? ! ? ? E E E E to E until a normal form is reached. This can be shown by induction on the number of rewriting > steps. This implies more generally that ?! ??E! ??E! ??E>! E 0
u;v
1
!
0
!
!
0
1
0
0
!
!
0
0
1
> is con uent i R is ground con uent, which proves undecidability. Now, we claim that ?! u;v E First assume that Ru;v is ground con uent (on T (F )). Then E is ground con uent on T (F ). > > Since ?! is terminating, we only have to show the local con uence. Assume s E>? s ?! s E E > !1 sb and by where s ; s ; s 2 T (F e). Then by the above commutation property, sb E>?? sb ?? E 1 ??! ? ? ? , which shows the ground con uence of E , s and s are joinable by E : s ?? ! ? E0 E1 E1 E0 1
0
1
0
1
2
1
1
1
1
2
1
0
0
2
2
1
con uence. > > Conversely, assume that ?! is con uent. Then ?? ! is con uent on T (F ) since a term in E E T (F ) can only be rewritten by rules in E . Replacing 0 with $ we get the con uence of Ru;v on T (F ). 2 1
0
0
1
5 Undecidability of ground reducibility for ordered rewriting Let us recall that a term t is ground reducible w.r.t. a rewrite system R i all instances t 2 T (F ) > of t are reducible by R. This de nition extends to ordered rewriting, replacing R with ?! when E E is a nite set of (unconstrained) equations. Ground reducibility is decidable for arbitrary nite term rewriting systems [19]. We show here that it is undecidable for nite sets of equations:
Theorem 5.1 The problem: Input: A nite set of (unconstrained) equations E , a term t, a lexicographic path ordering. > Question: Is t ground reducible w.r.t. ?! ? E is undecidable.
12
Proof Our reduction is from the halting problem for two-counter machines. First, let us recall this
computation model. A (deterministic) two counter machines is a tuple (q ; Qf ; Q; ) where Q is a nite set of states, Qf Q is the set of nal states, q is the initial state and is a transition function from Q to a nite set of actions A, consisting of one of the following: 0
0
1. 2. 3. 4.
pairs (1; q 0) where q 0 2 Q pairs (2; q 0) where q 0 2 Q pairs (1; q 0; q 00 ) where q 0; q 00 2 Q pairs (2; q 0; q 00 ) where q 0; q 00 2 Q
We assume that is unde ned on states q 2 Qf . A con guration of the machine consists in two non-negative integers n ; n and a state q 2 Q. A move of the machine from con guration (n ; n ; q ) to (m ; m ; q 0) (written (n ; n ; q ) ` (m ; m ; q 0)) is possible i there is a transition (q ) = a and 1
1
2
1
2
2
1
2
1
2
1. Either a = (i; q 0) and mi = ni + 1 and mj = nj for fi; j g = f1; 2g 2. Or a = (i; q 0; q 00 ) and mi = ni = 0 and mj = nj for fi; j g = f1; 2g 3. Or a = (i; q 00; q 0) and mi = ni ? 1 0 and mj = nj for fi; j g = f1; 2g The input of such a machine is a non-negative integer n, corresponding to the initial con guration (n; 0; q ). The machine halts on the input n i there is a nite sequence of transitions yielding a con guration (n0 ; m0; qf ) with qf 2 Qf . The following problem is undecidable [14]: 0
Input: A two counter machine M and a non-negative integer n Question: Does M halt on n? In order to encode two-counter machines, we consider an alphabet F = Q [fa; b; 0g where every symbol of Q (the set of states of the machine) is a ternary symbol, a; b are unary symbols and 0 is a constant. F is ordered according to q > a > b > 0 for every q 2 Q and the states are ordered in an arbitrary way. We let tn be the term q (an (0); 0; x) and we are going to show that tn is not ground reducible (w.r.t. a set of equations which is de ned below) i M halts on n. Intuitively, we are going to design E in such a way that irreducible ground instances of tn encode (halting) sequences of successive con gurations of the machine, as depicted on gure 2. On this gure, con gurations of the machine are (nj ; mj ; qj ). We divide the set of equations into 2 parts: the rst part is independent of and is designed in such a way that only sequences of possible con gurations (not necessarily consecutive ones) are kept as irreducible terms. The second set (the main one) encodes the computations of the machine. 0
13
q
?n ? @@ a 0 qi ? @ ? @ 0 a n am q 0
1
1
0
i2
1
0
.. .
qi
? @ ? @ an am 0 k
k
k
0
0
Figure 2: Representation of a sequence of con gurations
The rst set of equations
1. q (x; y; 0) = 0 For every non-inal state q 2. q (x; y; a(z )) = 0 for every state q 3. q (q 0(x ; x ; x ); x ; x ) = 0 for every states q; q 0 4. q (x ; q 0(x ; x ; x ); x ) = 0 for every states q; q 0 5. a(q (x; y; z )) = 0 for every state q 6. b(x) = x All these equations can actually be turned into rules from left to right. Irreducible ground terms w.r.t. these rules are the terms ak (0) and the terms of the form: 1
1
2
3
2
3
4
4
5
5
qi
?n ? m@@ 1
a 0
1
a
0
qi
1
2
.. .
qi
? @ ? @ an am 0 k
0
k
k
0
where qi is a nal state. Let S be this set of ground terms. In what follows, we only have to consider the applicability of the rules on S . k
1
1
The second set of equations 14
7. q (x ; x ; q 0(x ; x ; x )) = 0
If q; q 0 2 Q and 8i; 8q 00: (q ) 6= (i; q 0) &(q ) 6= (i; q 0; q 00)&(q ) 6= (i; q 00 ; q 0) 8. q (x; y; q 0(x ; y ; z )) = q (x; y; q 0(b(a(x)); y ; z )) If (q ) = (1; q 0). 0 0 9. q (x; y; q (a(x ); y ; z )) = q (b(x ); y; q (a(x ); y ; z )) If (q ) = (1; q 0). Before going further, let us comment on these equations. Equations (7) simply reduce terms which cannot correspond to consecutive con gurations: if a term t 2 S is irreducible w.r.t. (7), then, for every j , (qi ) 2 f(i ; qi ); (i ; qi ; q 00 ); (i ; q 00; qi )g for some i 2 f1; 2g and some q 00 2 Q. Now, we have to move the counters in the right way. (8), when applied from left to right reduces a term q (an (0); am (0); q 0(an (0); am (0); t) when an (0) > b(a(an (0))), i.e. when n > 1 + n . (8) cannot be applied from right to left on terms of S since b does not occur in any term of S . (9), when applied from left to right reduces a term q (an (0); am (0); q 0(an (0); am (0); t) when an (0) > b(an ? (0)), i.e. when n n . As before, (9) cannot be applied from right to left on terms from S . Putting together (8) and (9), if we assume that ther is a rule (q ) = (1; q 0), a term 1
2
3
1
4
1
5
1
1
1
1
1
1
1
1
1
1
1
j
j
j +1
j +1
j
j +1
j
j
2
1
2
1
1
2
2
1
1
2
2
1
1
1
1
2
1
1
2
1
q(an (0); am (0); q 0(an (0); am (0); t) 1
1
2
2
is irreducible (at the root) i n = n + 1. Now, in a similar way, we force the second counter to be remain constant (i.e. m = m ) for such transition rules: 10. q (x; y; q 0(x ; y ; z )) = q (x; b(y ); q 0(x ; y ; z )) If (q ) = (1; q 0) 11. q (x; y; q 0(x ; y ; z )) = q (x; y; q 0(x ; b(y ); z )) If (q ) = (1; q 0) 10. forces irreducible terms to satisfy y