ELSEVIER
Information
Processing
Letters 6 1 ( 1997) 9 1-96
Information Processing Letters
On termination of confluent one-rule string-rewriting systems Kayoko Shikishima-Tsuji
a, Masashi Katsura b, Yuji Kobayashi
’
a Faculty of Liberal Arts, Tenri Universify, Tenri 632. Japan b Department of Mathematics. Kyoto Sangyo University, Kyoto 603, Japan ’ Department of lnforntarion Science, Toho Univerdy, Funabashi 274. Japan Received 12 April 1996; revised 21 October 1996 Communicated by H. Ganzinger
Abstract The termination
of a confluent one-rule string-rewriting
system R = (s + I} is reduced to that of another one-rule system of a
K = {s’ -B t’) such that s’ is self-overlap-free &of). A necessary and sufficient condition is given for termination one-rule system R = {s --+t} such that s is sof and s overlaps r once on both sides. 0 1997 Elsevier Science B.V. Keywords:
String-rewriting
system; Confluent
system; Decidability;
Termination
1. Introduction and statements of theorems Though the word problem for one-relator groups has been known to be solvable [9], it is not known whether the same problem for one-relation monoids is solvable (see [7]). If a monoid admits a finite complete (confluent and terminating) rewriting system, then the word problem is solvable by normal form algorithm (see [2]). For confluence of one-rule systems, Kurth [61 and Wrathall [ 121 gave a complete characterization. But for termination of one-rule systems no general characterization is known, nor even its decidability. Termination is undecidable for finite string-rewriting systems [5], and actually it is undecidable for three-rule string-rewriting systems as recently proved by Matiyasevich and Senizergues [8]. Thus the decidability of termination is open for oneand two-rule string-rewriting systems. On the other hand termination is undecidable for left-linear one0020-0190/97/$17.00 0 1997 Elsevier Science B.V. All rights reserved PII SOO20-0190(96)00200I
problem
rule term-rewriting systems [3]. For the termination problem of general term-rewriting systems we refer to a survey paper by Dershowitz [4]. The first systematical study focusing on termination of one-rule string-rewriting systems was attempted by Kurth [6], and has been succeeded by McNaughton [9]. Zantema and Geser [13] gave a termination criterion for some very special one-rule systems (see also Ill]). However, it seems that we are still far from a general resolution of the problem. In this paper we study termination of one-rule string-rewriting systems that are confluent. Let 2 be a finite alphabet and let R = {s + t) with s,t E 2 * be a one-rule string-rewriting system. If 1s ) > 1t 1and s # t, then R always terminates, so we are only interested in length-increasing systems. To state our results we need a notion of overlap and the set OVL(x, y) of the overlaps of a word x with another word y. A word x is called self-overlap-free
92
K. Shikishima-Tsuji
et al. /Information
(sof), if it does not overlap itself, that is, OVL(x) = OVL( X, X>= 6. See Section 2 for the precise definitions. Now our first theorem asserts that the termination of the system R can be reduced to that of another one-rule system in which the left-hand side of the rule is sof. Theorem 1. Let R = (s --) t) be a conjluent one-rule system with 1s 1 < I t I over 2. Then, there exists a confluent one-rule system R’ = {s’ + t’) over another alphabet 2’ satisfying the following properties: (1) Is’1 G ISI, It’1 4 Irl. (2) s’ is sof. (3) R is terminaring if and only if so is R’. (4) R’ is effectively constructed from R. Corollary
1. The termination for confluent one-rule sysrems is decidable, if and only if it is decidable for
systems with a single rule whose left-hand side is sof. The following corollaries to Theorem 1 give useful sufficient conditions for termination of a confluent one-rule system R = {s + t). Corollary 2. If s is not a subword of c and OVL(s, t) Z OVL(s) or OVL(t, s> G OVL(s) holds, then R is termina&q. Corollary 3. Ifs is not a subword oft and s = ua’u
whereuE$*‘, ing.
a E J$ and k 3 0, then R is terminat-
If s = zez’, where e is a positive integer and z’ is a prefix of z E .Z+, then we write s = zk with rational k=e+ )z’I/Iz(. Corollary
4. If s is nor a subword of t and s = zk where k > 2 and z E Z+, then R is terminating.
The second theorem gives a necessary and suffcient condition of termination for a one-rule system R = {s --) t) such that s is sof and both OVL(s, t> and OVL(t, s) are singletons. Theorem
2.
such that s is sof, and OVL(s, OVL(t, s) = 1 p) are singletons. Then,
system
Processing Letters 61 11997) 91-96
nating, if and only ifs is not a subword of r and t is not of the form czsa us, p with v E 2 * , where s, , sp E S+ are determined by s = s, (Y = &. Thus, a system of the type in Theorem 2 is non-terminating if and only if it is a one- or two-loop system 16, Satz 5.5 and Satz 5.71. Corollary 5. Termination of confluent one-rule systems R = (s + t) such that I OVL(s, t> I Q IOVL(s)I +l and lOVL(t, s)l Q IOVL(s)I +l is decidable.
2. Notations and conventions Let .Z be a finite alphabet. The free monoid generated by .Z is denoted by _Z* . The set 2 * - (1) removing the empty word 1 from 2 * is denoted by Zf. The length I u I of a word u = ala* . . . a, (a,, a2,..., a,, E 2) is the number n. A (sfring-)rewriting system (or semi-Thue system) R on 2 is a subset of l?‘X 2 *, and an element (s, t) of R is called a (rewriting) rule and written as s -+ 1. If R consists of one element, R is called a one-rule (string-jrewriting system. The single-step reduction relation +R (or denoted simply +) induced by R is defined as follows: Let x,y E B * , then x -)R y if and only if there are a rule s + t E R and words u,v E 2 * such that x = usu and y = utu. If x,, + R x1 + R . . * + R x,, we write x0 +i X,.The reduction relation + i (or denoted simply + * ) on 2’ induced by R is the reflexive and transitive closure of --) R; --) i = UI,, + i. A word x E Z * is reducible (with respect to R), if there is a word y E .$ * such that x + R y, otherwise, x is irreducible. For X,y E 2 * if x + i y, y is called a descendant of x. We say that a rewriting system R is confluent forany w,x,y~Z:’ suchthat w +; x, w +i y exists common descendant there is no infinite sequence x1, x2, . . . of such that x1 + R x2 + R * +. . the other hand, R is weakly terminating if every word in 2 * has an irreducible descendant. R is said to terminate on a subset S of 2 , if any rewriting starting with a word in S terminates. R is said to weakly terminate on S, l
termi-
K. Shikishima-Tsujiet al./Information ProcessingLetters 61 Cl997) 91-96 if each x ES has an irreducible descendant. R is said to (weakly) terminate on a word x if it (weakly) terminates on the set {x). A word x E 2 * is primitive, if there is no word such that x = zk with integer k > 2. Let zE$* If there are words w E 2” and x’, y’ E X,YEZ’. s* such that x = uw, y = WV and uv # 1, we say that x overlaps y on the left or y overlaps x on the right and w is an overlap of x with y. The set of all overlaps of x with y is denoted by OVL(x, y): OVL( x, Y) = { wEZf forsome
jx=uw, U,UE~*
y=wu with uv#l}.
The set OVL(x, x> is abbreviated to OVL(x). If OVL(x) = #, x is said to be self-overlap-free (sof for short).
3. Wrathall’s
theorem and useful lemmas
Confluence of one-rule rewriting systems is completely characterized by Wrathall [12] as follows. Theorem (Wrathall). A one-rule rewriting system R = (s + t} is confluent, if and only if either of the following conditions are satisfied: (a) s = zkt with a primitive word z and an integer k > 1, and OVL(s) = OVL(t) U (Z’t 1 i = 0, l,..., k-l}, (b) OVL( s) c OVL( t). If R satisfies (a) in the above theorem, then I s I > I t I and R is terminating. So we may only consider the case (b) for termination of confluent one-rule rewriting systems. The following can be easily proved from the above theorem. Corollary 6. Let R = {s + t} be a conj7uent one-rule system such that ( s / < I t I. Then we have
ovL( S) E ovL( t) n ovL( S, t) n OvL( t, s). Let R be a rewriting system over 2 which is not necessarily a one-rule system. A word x E .F, * is minimal right (resp. left) reducible (with respect to R), if x is reducible but every proper prefix (resp. suffix) of x is irreducible. Let 2, (resp. RZ) denote the set of all minimal right (resp. left) reducible words. The following three lemmata are useful to study
93
termination of rewriting systems. Similar results were given by Kurth [6] and McNaughton [9]. Lemma 1 (cf. [9, Theorem 2.31). A rewriting system R is weakly terminating, if it weakly terminates on the set Z, (or ,Z). Proof. Suppose that R is weakly terminating on Z, and let x E 2 * If a word x is irreducible there is nothing to prove. If x is not irreducible, then x is written as x = z. a, ... ak with z E Z, and al,. . . , a, E 2. We shall prove that x has an irreducible descendant by induction on k. By assumption there is an irreducible descendant i of z. If k = 0, then z^ is an irreducible descendant of x. Suppose k > 0. If y = _?. a, . . . ak is irreducible, then it is an irreducible descendant of x. Otherwise, y = ,7_’. ai . . . a, for some z’ E Z, and i with 2 < i < k. By the induction hypothesis y has an irreducible descendant, which is a descendant of x as well. 0 Lemma 2 (cf. [9, Theorem 1.71). Let R be a confluent rewriting system in which every rule increases the length. Then, R terminates on a word x, if it weakly terminates on x. Proof. Let R be an irreducible descendant of x. Assume that there is an infinite sequence x=x, -‘R x2+ ‘... Choose i so that I xi 1 > I 2 I. Since R is confluent and P is irreducible, there must be a reduction xi -+ i P. This is impossible because R is length-increasing. 0 Combining
Lemma
1 with Lemma 2 we have
Corollary 7. A Zength-increasing confruent system is terminating, if and only if it weakly terminates on the set Z, (or ,Z). The following result immediately follows from Corollary 7 for confluent one-rule systems, but it is generally true for one-rule systems not necessarily confluent. Lemma 3 [6, Satz 4.351. A one-rule system (s + t} is terminating, if s is not a subword of t, and OVL(s, t)=PI or OVL(t, s>=@.
94
K. Shikishima-Tsuji et al./lnformation
Let a be a sof word. If u,, . . . , u, are different words in Z: * -Z*cd*, then B=((Yu ,,..., cryu,} forms a code, that is, B is a free generator of the submonoid of 2 * generated by B. Let T be an alphabet with the same cardinality r as B, then there is an isomorphism f: r * + B *. Define a mapping $:T’* *J5* by4(v)=flu>.cr for u~r*.Then 4 is bijective onto B *a. Let I) : B *a + r * be the inverse of 4. These coding functions were introduced by Adjan and Oganesjan [ 11to attack the word problem for one-relation monoids. Any x E J$ *as * is written as x = Z’X’Z”, Z’J” E 2z * - z *ff,z * ,
(*)
x’~B*a
with suitable B. Now let R = {s + t} be a one-rule system such that s,t E B *a. Let (T= I)(S), T= t)(t) and we consider S = {(T-P T} to be a rewriting system over r. The following lemma which will be used to prove Theorem 1 can be easily proved. Lemma 4. (1) Ifu
+ i w, then 4(u) + i 4(w). (2) Suppose rhat x is writren us ( * >. If x + i y,
then
y is
written
as y = z’ y’z’ with y’ E B *a and
q(x’) -+g $00. (3) OVL(s),
OVL((T) “‘;U’”
OVL(t), OVL( s, t> C B *a and = $(OVL(s)) - {I), OVL(T) = - (1) and OVL((+, T) = $(OVL(s, t))
(4) u is a subword subword oft.
of r if and only if s is a
Processing Letters 61 (1997) 91-96
&r*+B*aand~:B*a-+r*.LetS={(T-+T)
with (T= JI( s) and T = t)(t). It is easy to see by (1) of Lemma 4 that R is non-terminating provided so is S. Conversely, Suppose that R is non-terminating and there is an infinite sequence xl + R x2 --) R . . . . Choose a suitable B, containing B so that x, is written as x, = z’x’,z”, z’,z” E 2 * - 2 *a2 * , x’, E B,*a. Let Ti be a corresponding alphabet to B, and let (6] and I), be the corresponding coding functions. By (2) of Lemma 4 for any i > 0, xi = z’xiz” with x\ E B,*a, and we have an infinite sequence I,!J, +s ..., where S is considered to be a system over r,. It follows that S, even if it is considered to be a system over r, is non-terminating. We claim next that S is confluent. In fact, by (3) of Lemma 4, OVL( (T) c OVL(T), and the confluence of S follows from Wrathall’s Theorem. If (+ is sof, the system S is a required one. Otherwise, we continue this procedure. Since IOVL(o)l = IOVL(s)I - 1 and OVL(T) >OVL((+) by (3) of Lemma 4, we will get a desired system in IOVL( s) I steps. 0 Proof of Corollary
1. Let R = {s + t) be a confluent one-rule system. If I s I > I t I, then R is terminating if and only if s # r. If I s I < I t 1, then we can effectively obtain the system R’ = (s’ + t’) with sof s’ by Theorem 1, and R is terminating if and only if so is R’. Cl Proof of Corollary
4. Proofs of the theorems Proof of Theorem
1. We may assume that s is not sof. Let a be the shortest word in OVL(s), then a is sof. By Wrathall’s Theorem, a is in OVL(t). Hence s and t are uniquely decomposed as s=cYu,au* ... ffu,a,
and t=aum+,aumc2
...
au,a
with ui E ,Z * - 2 *a2 * for i = 1,. . . , n. Let B be the set of distinct elements of au,, cruz, . . . , au, and let r be a new alphabet with the same cardinality as B. As stated before Lemma 4, we have an isomorphism f: r * + B * and bijective mappings
2. Let (T and r be as in the proof. If OVL( s, t) c OVL(s), then OVL((r , T) c OVL( ~1. Thus, the system R’ = {s’ + t’} in Theorem 1 satisfies OVL(s’, t’) = @. Since s’ is not a subword of / by (4) of Lemma 4, R’ is terminating by Lemma 3. Therefore, R is also terminating by Theorem 1. Cl
above
Proof of Corollary 3. If u = 1, then s = a’, and the left-hand side of the rule of the system R’ = (s’ + t’} in Theorem 1 becomes a letter b and this letter does not appear in the right-hand side t’. Clearly, R’ is terminating and so is R. Suppose that u + 1, and let a be the shortest word in OVL(s). If u is not sof, a
is the shortest word in OVL(u), while if u is sof, u = a. If a # a, we have t,Ns) = $(u)b$(u), and
K. Shikishima-Tsuji et al./Information
on
the
other
hand
if
~1 = a,
then
Jl(s> =
q!du>b”‘$(u), where I) is the coding function and b is a letter in the new alphabet r. Thus, repeating our reduction, we get a system the left-hand side of which is a power of a letter (the case u = 1). 0 Proof of Corollary 4. Since the case k = 2 is contained in Corollary 3, we assume k > 2. Let s = zk = .zez’ with integer e > 2, z’ E ,Y, where z’ is a nonempty prefix z’ of z. Let (Y be the shortest word in OVL(s). If z’ is not sof, then cr is the shortest word in OVL(z’), and with the coding function I+!J we have (+= I/J(S) = (~(z~)>‘I/J(z’> = ($(~a))” with k’=e+ I$(z’)l/l$(za)l. Ontheotherhand if z’ is sof, then (Y= z’ and (T = (@( zcu))‘. Thus repeating the reduction we get a system the left-hand •I side of which is just a square (the case k = 2). Proof of Theorem 2. Since s is sof, t is of the form aup with UE,Z* - ,Z * s_E*. If t is of the form (rspus,p with UEX’, then we have an infinite sequence: s, “SP = sss ~tsp=(Ys~us~ps~=Lyspus~s -as,us,t=aspu(s*nsp)us*p-,
Processing Letters 61 (1997) 91-96
95
Proof of Corollary 5. Let R = (s + t} be a confluent one-rule system such that lOVL(s, t) I G IOVL(s)l +1 and IOVL(t, s>l G ]OVL(s)I +l. Then, the system R’ = (s’ + t’} in Theorem 1 satisfies IOVL(s’, t’)l < 1 and IOVL(t’, ~‘11 < 1. By Lemma 3 and Theorem 2 it is decidable whether R’ terminates. •i
5. Examples Example 1. Let Z: = (a, b), s = ababbabuub, t = ubbubuubuubububbub and R = (s + t}. Then, OVL(s) = (ub) c OVL(t) = {ab, ubbub} and R is confluent by Wrathall’s Theorem. Let B = (ub, ubu, ubb} and r= (x, y, z}, and define an isomorphism f: r * -+ B * by f(x) = ub, f(y) = ubu, f(z) = ubb. Then, using the coding function 9 associated with f, we have u = I)(S) = xty and r = $(t) = zyyxrz. Thus we have a new system R’ = (CT -+ 7) over r. Since OVL(a) = 8, OVL(a, T)= (zy),OvL(~, a)=(xz)and7=(zy).y.x.(xz), R’ is non-terminating by Theorem 2. Hence R is not terminating by Theorem 1.
.I..
Hence, R is not terminating. Conversely, suppose that R is not terminating. By Corollary 7, there is a word z E 2 * such that no proper prefix of zs contains s and every reduction sequence starting with zs does not terminate. Let k be the maximal nonnegative integer such that z = z’ . s: with z E .Z *, We have a reduction sequence:
Example 2. Let 2 = (a, b), s = ububbubuub, t = ubbubuububububbub, and R = (s + t). Then, OVL(s) = (ub) c OVL(r) = (ub, ubbub). By the same coding functions as in Example 1 we have a new system R’ = (xzy + zyxrxz} over r= (x, y, z). We find that R’ is terminating by Theorem 2, and so is R by Theorem 1.
Zs~Zt=Z’s~rrup=z’s,k-‘SUp + z’s;- ’ tup = z’spx(
up)’
+ * zqup)‘+‘. Since OVL(s, t) = (cy) and OVL(t, s) = (/3), we see OVL(s, au) = {(Y} and OVL(up, s) = (p). Moreover we see OVL( LX,s) = OVL(s, /3 > = fl because s is sof. Since z’cr(~/3)~” is reducible and contains s = $4~~ as subword, ss must be a prefix of U. By a dual argument we can also show that s, is a s=) = 8, it follows that suffix of u. Since OVL(s ? ~=s~os,forsomev~~ ,andhencet=cY~~vs,P. 0
References [I] S.I. Adjan and G.U. Oganesjan,
On the word and divisibility problems in semigroups with a single defining relation, Izo. Akad. Nauk SSSR (Ser. Mat.) 42 (1978) 219-225 (in Russian); English translation: Math. USSR Izu. 12 (1978) 207212. [2] R.V. Book and F. Otto, String-Rewriting Systems (Springer, New York, 1993). [3] M. Dauchet, Simulation of Turing machines by a left-linear rewrite rule, in: Rewriting Techniques and Applications, Lecture Notes in Computer Science, Vol. 355 (1989) 10% 120. (41 N. Dcrshowitz, Termination of rewriting, J. Symbolic Computation 3 (1987) 69-115.
96
K. Shikishima-Tsuji et al. /information Processing Letters 61 (1997) 91-%
151 G. Huet and D. Lankfort, On the uniform halting problem for term rewriting systems, Tech. Rept. 283, INRIA, 1978. [61 W. Kurth, Termination and Konfluenz von Semi-Thue-systemen mit nur einer Regel, Dissertation, Technische UniversitP Clausthai, 1990. [71 G. Lallement, Some algorithms for semigroups and monoids presented by a single relation, in: Lecture Notes in Mathematics, Vol. 1320 (Springer, Berlin, 1986) 176-182. [81 Y. Matiyasevich and G. SCnizergues, Decision problems for semi-Thue systems with a few rules, in: Proc. LICS’%, to appear. [9] Magnus, Das Identititsproblem Rir Gruppen mit einer definiemnden Relation, Math. Ann. 106 (1932) 295-307.
[IO] R. McNaughton, The uniform halting problem for one-rule semi-Thue systems, Tech. Rept. No. 94-18. Rensselaer Polytechnic Institute, 1994. [ll] G. SCnizergues, Gn the termination-problem for one-rule semi-Thue systems, in: Proc. RTA’%, Lecture Notes in Computer Science, Vol. I103 (Springer, Berlin, 1996) 302316. 1121C. Wrathall, Confluence of one-rule Thue systems, in: Word Equations and Related Topics, Lecture Notes in Computer Science Vol. 572 (Springer, Berlin, 1992) 237-246. [I31 H. Zantema and A. Geser, A complete characterization of termination of Oplr + l’O’, in: Lecture Notes in Computer Science, Vol. 914 (Springer, Berlin, 1995) 41-55.