Information Processing Letters 24 (1987) 281-284 North-Holland
16 March 1987
USING STRING-REWRITING FOR SOLVING THE WORD PROBLEM FOR FINITELY PRESENTED GROUPS Klaus M A D L E N E R and Friedrich OTTO Fachbereich Informatik, Universitiit Kaiserslautern, Postfach 3049, 6750 Kaiserslautern, Fed. Rep. Germany Communicated by L. Boasson Received June 1986
As shown by Jantzen (1985), the presentation (a, b ; abba) does not allow a finite complete string-rewriting system. Here, a finite string-rewriting system R on {a, b} is given such that R is equivalent to R 0 = {(abba, e)}, R is noetherian, and R is confluent on [e]. Hence, by using R, the word problem for the above presentation can be solved through the technique of string-rewriting.
Keywords: Monoid-presentation, word problem, string-rewriting system, noetherian, confluence, confluence on a given congruence class
Introduction General replacement systems such as term-rewriting systems and graph grammars have many applications for abstract data types, formula manipulation, program transformation, theorem proving, etc. Here we are dealing with string-rewriting systems which form a special class of term-rewriting systems. These systems can be used to describe formal languages and to solve decision problems for finitely generated monoids and groups, and they have attracted a lot of attention recently (see [2,3] for an overview on string-rewriting systems and their various applications). If Y. is a finite alphabet, and R is a finite string-rewriting system on x, the ordered pair (E ; R) is a finite (monoid-) presentation with generators ~ and defining relations R, the monoid it presents being the factor m o n o i d of the free m o n o i d E* generated by ~ by the congruence ~t. Here, the congruence ~ ~ is the equivalence relation generated by the one-step reduction relation =~R defined through: u =*gv if and only if 3x, y ~ E * , ( : , r ) ~ R : u = x E y and v = xry. If R is noetherian, then each congruence class
contains irreducible words, i.e., words to which no rule of R applies, and each finite sequence of reductions has a finite extension reaching such an irreducible word. If in addition R is confluent, then each congruence class contains a unique irreducible word only, which can be taken as a normal form for this class. Thus, if R is noetherian and confluent (complete, canonical), then the word problem for the presentation (E ; R) can be solved in an elegant way through the technique of stringrewriting: Given u, v ~ E*, reduce u and v to their respective normal forms fi and ~,. N o w u ~ ~ v if and only if fi = ~. T h e complexity of this algorithm is linearly b o u n d e d by the length of the sequences of reductions generated. In particular, if R is length-reducing, the induced algorithm is linearly time b o u n d e d [1]. Unfortunately, there exist finite presentations (Y~; R) such that the word problem for (Y.; R) is easily decidable, but the given presentation does n o t admit a finite complete string-rewriting system, i.e., there does n o t exist a finite complete string-rewriting system R' on E such that the congruences generated by R and R' coincide [4,6]. If the monoid presented by (Y. ; R) is a group, then
0020-0190/87/$3.50 © 1987, Elsevier Science Publishers B.V. (North-Holland)
281 B~31iotheek Centmm voor Wiskunde en |nformetica
Volume 24, Number 5
INFORMATION PROCESSING LETTERS
in order to solve the word problem for (E ; R) it is sufficient to solve the membership problem for the congruence class [e] g, since u ,~, ~ v if and only if u - i v o ~ e . Here, - I " E * ~ E * is a function, which for each w ~ E * gives a word w ' ~ E * satisfying w w ' , ~ ~ e. Such a function can be determined effectively, provided (Z ; R) is in fact a group [7]. Hence, in order to solve the word problem for (E ; R) through the technique of string-rewriting, it is sufficient to find a finite noetherian string-rewriting system R' on E such that R and R' are equivalent, i.e., they generate the same congruence on E*, and R' is confluent on [e]g, i.e., for all words w ~ Y*, if w ~ I' e, then w
16 March 1987
1.3. Theorem. Using the process of rewriting modulo the string-rewriting system R, the word problem for (Y~;R0) can be solved in time O(n2), but not in time O(n). This compares to the linear-time algorithm given in [5], which is not based on the technique of rewriting.
2. Proofs
We define an ordering < on E* as follows: x < y if and only if
In the following we shall be considering the presentation (E ; R0), where E = {a, b} and R 0 = {(abba, e)}. As can easily be seen, the monoid G 1 presented by (E ; R0) is a group, and according to Jantzen [4] the given presentation does not allow a finite complete string-rewriting system.
Ixl < lYl or Ixl -- lYl and X
1. Results
2.1. Lemma. The string-rewriting system R noetherian.
Let
is
R 1 = { (baa, aab), (bba, abb) }, R 2 = { ( a a b b , e)}
and
R=RIUR
2.
1.1. Theorem. R is a finite noetherian string-rewriting system on Y. satisfying the following two conditions: (i) R is equivalent to Ro, and (ii) R is confluent on [e]Ro.
2.2. Lemma. R is equivalent to R o. Proof. On the one hand,
abba = R, aabb
= , R2
e,
on the other hand, bba ~ Ro abbabba ~ Ro abb,
In a sense, the string-rewriting system R is optimal with respect to the above properties, since we have the following.
hence aabb ~ go*abba =*Ro e
and
1.2. Theorem. There does not exist a finite lengthreducing string-rewriting system R" on Y such that: (i) R' is equivalent to Ro, and (iJ) R l is confluent on [e]R o.
bbaa ~ R0 * abba
Finally, we have the following result on the complexity of the algorithm for the word problem for ( Y ; R 0 ) that is based on rewriting using the string-rewriting system R.
Thus, R and R 0 are equivalent.
282
:=~ Ro
e,
which in turn gives aab ~ ~0 aabbbaa ,~, ~0 baa. []
In [4], Jantzen states the following result that will be crucial for our arguments.
Volume 24, Number 5
INFORMATION PROCESSING LETTERS
2.3. L e m m a ([4]). (a) For all w ~ Y.*, there exist nonnegative integers i, j, k such that w =" * a i (ba)Jb k. R1
16 March 1987
According to L e m m a 2.3(b) this m e a n s that j = m, i = d + 2p, and k = n + 2p for s o m e integer p ~ Z. Since d~< 1 or n ~ 1, p >/0 implying Iwl = i + 2 j
+k=
d+ 2m+n+4p>~
(b) Whenever ai(ba)Jb k o ~ a~'(ba)mb n, j = m, i = d + 2p and k = n + 2p for some integer p~Z. Let w ~ ~ * such that w ~ ~ e. T h e n there exist integers i,j, k ~ N such that w ~ ~ ai(ba)Jb k. Since w ~ ~ e, this implies that ai(ba)Jb k ~ ~ a ° ( b a ) ° b °, which in turn yields j = 0 and i = 2p = k for some integer p E N. Thus, w =~* ai(ba)Jb k = a2Pb 2p ='i~ 2 e, R1
which implies the following. 2.4. Corollary. R is confluent on [e]R. This completes the proof of T h e o r e m 1.1. F o r k >~ 1, let v k := (ba)kbEk (ab)ka 2k. Then v k = ' ~ a2k(ba)k(ab)kb 2k = ' ~ a ' k b 4k = ' ~ e, i.e., (v k Ik>~ 1} ___[e]R. W e n o w claim that no factor of length 2k of v k is congruent to any word of shorter length, i.e., whenever u is a factor of v k such that lul -< 2k, u is m i n i m a l in its congruence class with respect to length. To p r o v e this claim we n e e d the following lemma. 2.5. Lemma. Let w e Z * such that w ~ ae(ba)mb n. I f d<~ 1 or if n < 1, then [w [ >t d + 2 m +n.
Proof. By L e m m a 2.3(a) there exist nonnegative integers i, j, k such that w ~ ~ ai(ba)Jb k, a n d hence, ai(ba)Jb k ~-~ ~ a e ( b a ) ~ o ~.
d+ 2m+n. []
Thus, a word of the f o r m at(ba)mb n with d~< 1 or n ~< 1 is minimal in its congruence class. If u is a factor of v k satisfying l u [ ~ 2 k , then u = ae(ba)mb n for some nonnegative integers d, m, n, satisfying d~< 1 or n ~< 1. Hence, n o factor of v k of length at m o s t 2k is c o n g r u e n t to any word of shorter length. N o w assume that there exists a finite length-reducing string-rewriting system R' on Z that is equivalent to R 0 a n d that is confluent o n [e]Ro. Then, v k ='1~ e for all k >~ 1. Let ~ : = max{
I
x*-(t, r) ~
R'},
and let k >~ ~t. Since v k ='2' e, there is a rule (d, r) R' such that this rule applies to v k, i.e., d is a factor of v k. Since I d [ ~< t~ ~< k < 2k, and since do~r with I d l > [ r l , d is a factor of length smaller t h a n 2k of v k that is c o n g r u e n t to a shorter word, thus contradicting the above observation. This completes the p r o o f of T h e o r e m 1.2. Let IWla (respectively Iwlb) d e n o t e the n u m ber of occurrences of the letter a (respectively b) in w. Since each application of a rule of R 1 m e a n s the shifting of occurrences of the letter a to the left a n d of occurrences of the letter b to the right, each =" R,-reducti°n sequence starting with w Z* is of length at most [W[a" Iw G T h e only rule of R 2 is length-reducing. Thus, the length of each =,R-reduction sequence that starts with w ~ Z* is b o u n d e d above by Iwla" IWlb + ¼ " Iwl. Using the technique of left-most reduction [1] this gives the following. 2.6. L e m m a . The word problem for (Y. ; R0) can be solved in O(n 2) time by using the process of rewriting modulo the string-rewriting system R. It remains to prove a quadratic lower b o u n d for the lengths of the reduction sequences generated by R. F o r k, d E N ÷ , let Uk,e: = (ba)kb2e(ab) u. Then, Uk, e = ' ~ b 2e. 283
Volume 24, Number 5
I N F O R M A T I O N PROCESSING LETTERS
2.7. Lemma. If Uk,e =,~ b 2e, i.e., if Uk,e reduces to b 2t in i steps, then i >~ ( d + 1)- k. Proof. Using the rule b2a---, ab 2, the occurrences of a in (ab) k must be shifted across b 2¢ before the rule aabb ~ e can be applied. For this, t'. k applications of the rule b2a ~ ab 2 are needed. Further, k applications of the rule aabb ~ e must be performed. Hence, i >/(~+ 1)- k. In fact, ( f + 1). k reduction steps are not only necessary but also sufficient to reduce Uk,¢ to b2( [] Using the same kind of reasoning it can be shown that v k ='Ri e implies i >t l k 2 " In particular, these results show the following, thus completing the proof of Theorem 1.3. 2.8. Corollary. The algorithm for solving the word problem for (Y~ ; R0) that is induced by the process of rewriting modulo the string-rewriting system R is not of time complexity O(f(n)) for any function fin) = o(n 2).
3. Concluding remarks We have seen that in some cases the word problem for a finite presentation (Y~;R) can be solved rather efficiently by using the technique of string-rewriting, although the given presentation does not allow a finite string-rewriting system that
284
16 March 1987
is noetherian and confluent. This result was obtained by weakening the property of confluence to the property of confluence on [e]R. In a forthcoming paper [8], the second author investigates the problem of deciding whether or n o t a given finite noetherian string-rewriting system is confluent on a given congruence class.
References [1] R.V. Book, Confluent and other types of Thue systems, J. Assoc. Comput. Mack 29 (1982) 171-183. [2] R.V. Book, Thue systems and the Church-Rosser property: Replacement systems, specification of formal languages and presentations of monoids, in: L. Cummings, ed., Combinatorics on Words: Progress and Perspectives (Academic Press, New York, 1983) 1-38. [3] R.V. Book, Thue systems as rewriting systems, in: J.P. Jouannaud, ed., Rewriting Techniques and Applications, Lecture Notes in Computer Science, Vol. 202 (Springer, Berlin, 1985) 63-94. [4] M. Jantzen, A note on a special one-rule semi-Thue system, Inform. Process. Lett. 21 (1985) 135-140. [5] M. Jantzen, Thue congruences and complete string-rewriting systems, Habilitationsschrift, Univ. Hamburg, 1986. [6] D. Kapur and P. Narendran, A finite Thue system with decidable word problem and without equivalent finite canonical system, Theoret. Comput. Sci. 35 (1985) 337-344. [7] F. Otto, On deciding whether a monoid is a free monoid or a group, Acta Informatica 23 (1986) 99-110. [8] F. Otto, On deciding the confluence of a finite string-rewriting system on a given confluence class, Internal Rept. 159/86, Univ. of Kaiserslautern, 1986.