HAL Id: hal-00749289
https://hal.inria.fr/hal-00749289
Submitted on 7 Nov 2012
HAL
is a multi-disciplinary open access archive for the deposit and dissemination of sci- entific research documents, whether they are pub- lished or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers.
L’archive ouverte pluridisciplinaire
HAL, estdestinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.
Michel Latteux, Yves Roos
To cite this version:
Michel Latteux, Yves Roos. On One-Rule Grid Semi-Thue Systems. Fundamenta Informaticae, Pol- skie Towarzystwo Matematyczne, 2012, Words, Graphs, Automata and Languages. Special Issue Honoring the 60th Birthday of Professor Tero Harju, 116 (1-4), pp.189-204. �10.3233/FI-2012-678�.
�hal-00749289�
On One-Rule Grid Semi-Thue Systems
Michel Latteux
Laboratoire d’Informatique Fondamentale de Lille Universit´e Lille 1
Yves Roos
Laboratoire d’Informatique Fondamentale de Lille Universit´e Lille 1
Abstract. The family of one-rule grid semi-Thue systems, introduced by Alfons Geser, is the family of one-rule semi-Thue systems such that there exists a lettercthat occurs as often in the left-hand side as the right-hand side of the rewriting rule. We prove that for any one-rule grid semi-Thue systemS, the setS(w)of all words obtainable fromwusing repeatedly the rewriting rule ofSis a constructible context-free language. We also prove the regularity of the setLoop(S)of all words that start a loop in a one-rule grid semi-Thue systemsS.
Keywords: one-rule semi-Thue system, termination, grid semi-Thue system.
1. Introduction
Semi-Thue systems, that are the non-symmetrical version of Thue systems introduced by Axel Thue in 1914, serve as a model for rewriting systems. Thus they are of primordial interest for computa- tional problems. For several years they have been intensively studied and several deep results have been obtained [10, 3, 2, 21, 19, 22]. However some intriguing decidability problems remain open.
With a semi-Thue systemS, one associates the setS1of words that start an infinite derivation in S. The recursiveness ofS1is called the termination problem forSand the emptiness ofS1is the uniform termination problem forS. The best result on the setS1is that the termination problem and the uniform termination problem are undecidable for 3-rules semi-Thue systems ([14]). Clearly the termination problem is decidable for length-preserving semi-Thue systems, contrarily to the uni- form termination problem that has been shown undecidable for length-preserving semi-Thue systems
([1]). This result remains true for 9-rules semi-Thue systems ([19]) and for length-two semi-Thue systems ([18]).
Another set naturally associated with semi-Thue systems is the setLoop(S)that brings together the wordswthat start a non-null derivation inStoward a word containingwas a factor. For length- preserving semi-Thue systems, the emptiness ofLoop(S)is equivalent to the emptiness ofS1but this equivalence does not hold for arbitrary semi-Thue systems, as shown in [7] where a 2-rules semi-Thue systemS is presented withLoop(S) = ;and S1 6= ;. Moreover, for an arbritary semi-Thue systemS, the setLoop(S)need not be recursive.
One-rule semi-Thue systems are the simplest rewriting systems. Indeed, they are defined by two words l, r,notedS = {l −! r}. For a wordw,S(w)is the set of words obtainable fromw by replacing repeatedlylbyr. It is clear that, except the particular casel=r,w2S1if and only if the setS(w)is infinite. However, despite numerous efforts for more than twenty years, these decidability problems remain open and have become challenging problems. We observe that these problems can be explained in a few minutes to non-scientific people and surely they point out a deep lack of understanding of the rewriting notion. To get new ideas in order to solve these difficult problems, it seems natural to examine closely particular one-rule semi-Thue systems. Several interesting partial results have been obtained in that direction([20, 23, 16, 5, 6, 17]). Here we continue the study of a natural subclass of one-rule semi-Thue systems, introduced by Alfons Geser in [4], and called one-rule grid semi-Thue systems.
It is obvious that the systemS={l−!r}withl6=ris uniformly terminating if|r| |l|or if there is a letterxsuch that|r|x <|l|x. So, when studying the termination, we can assume that there is a letterxsuch that|r|x >|l|xand there is no letterysuch that|r|y<|l|y. Then a borderline case is when there is a unique letterxsuch that|r|x>|l|xand|r|y=|l|yfory6=x. The family of one-rule grid semi-Thue system satisfies a slightly more general condition. This family, that we denoteSgrid, is composed of all one-rule semi-Thue systems having a lettercsuch that|r|c = |l|c = k > 01. In [4], Alfons Geser has given a nice decidable characterization of one-rule grid semi-Thue systems that are uniformly terminating by proving that such a system is non-uniformly terminating if and only if it has a loop of length 1 or 2. To know whether a one-rule semi-Thue system has a loop of length 1 or 2 was previously shown decidable by Winfried Kurth in [11].
First, we give a new formulation of this decidable characterization of non-uniformly terminating systems inSgrid: there exist wordsx, ysuch thatlyis a left factor ofxrandxlis a right factor ofry.
We show that the wordsxandyare unique and give a simple way to compute these two words. This permits, when considering a nonterminating systemS = {l−! r} 2 Sgrid, to give a very precise form of the two wordslandrand to get as a consequence that if|r|c=|l|c=kis oddlneeds to be a factor ofr.
Then we prove that, for anySinSgrid, the setLoop(S)is a constructible regular language by giving a simple rational expression. This property can not be generalized to arbitrary 1-rule semi-Thue system: for instanceLoop({c−!caca})is not regular. Concerning the link betweenLoop(S)and S1, it is proved in [4] that the familySgridsatisfies the equalityS1=S−1(A⇤Loop(S)A⇤), that is w2S1if and only if there is a derivation fromwto a word in the regular languageA⇤Loop(S)A⇤ whereAis the alphabet oflr. Unfortunately, up to now, this relation does not imply thatS1is a regular language as shown in [20] whenl2a⇤b⇤. Then we prove that for anySinSgridand for any
1In the original definition of Alfons Geser, a one-rule grid semi-Thue system is a one rule semi-Thue systemS={l−!r} having a lettercsuch that|r|c |l|c. In this paper we do not consider the case|r|c<|l|cfor whichSis trivially uniformly terminating.
wordw, the setS(w)is a constructible context-free language. Note that this result does not hold for arbitrary one-rule semi-Thue systems ([12]). As a matter of fact,S(w)is a bounded context-free language. So we get both the decidability of the termination problem2inSgridand the decidability of the common descendant problem inSgrid. In the last section, we give an argument in favour of the regularity ofS1by proving that it is a regular language in the case|r|c=|l|c= 2.
2. Preliminaries and Notations
In the following,Awill denote a finite alphabet,A⇤the free monoid overAandεthe empty word inA⇤. For a wordw2A⇤and a lettera2A,|w|denotes the length of the wordwand|w|adenotes the number of occurrences of the letterain the wordw.
Two wordsuandvareconjugateif there exist wordsxandysuch thatu=xyandv=yx. It is well known that two wordsuandvare conjugate if and only if there exists a wordzsuch thatuz=zv.
A worduis afactorof a wordvif there exist two wordsw1andw2such thatv=w1uw2and we denote byF(v)the set of the factors of the wordv. We denote byRF(w)(respectivelyLF(w)) the set ofright factors(respectivelyleft factors) of the wordw, that is:
RF(w) ={v2A⇤| 9u2A⇤, w=uv}, LF(w) ={u2A⇤| 9v2A⇤, w=uv}.
A semi-Thue system over an alphabetAis a subsetS✓A⇤⇥A⇤. Members ofSare denotedl−!
S r (orl −! rif there is no ambiguity). One-step derivation, denoted−!
S (−!if no ambiguity), is the binary relation over words defined by :8u, v2A⇤, u−!viff there existsl−!r2Sandα, β2A⇤ such thatu=αlβandv=αrβ. The relation−!⇤ (resp. −+!) is the reflexive and transitive closure (resp. transitive closure) of the relation−!and, for any wordw2A⇤, we shall denoteS(w)the set S(w) ={w02A⇤ | w−!⇤
S w0}andS−1(w) ={w02A⇤ | w0−!⇤
S w}. We extend these notations to languages: for any languageL✓ A⇤,S(L) = [w2LS(w)andS−1(L) = [w2LS−1(L). For a derivationw = w0 ! w1· · · ! wn = w0,nis called the length of the derivation that will be denoted byw−!n w0.
We notew −!1
S iff there is an infinite derivation starting onwand we denote byS1the setS1 = {w2A⇤ | w−!1
S }.
For a semi-Thue systemS, for any positive integern, we denoteLoopn(S) ={w2A⇤ | 9x, y2 A⇤, w−!n xwy}andLoop(S) =[n>0Loopn(S).
The termination problemfor the alphabet Aand the semi-Thue system S ✓ A⇤ ⇥ A⇤ is the following:
instance:a wordw2A⇤
2This result already appears implicitly inside proofs used by Alfons Geser in [4] to solve the uniform termination problem in Sgrid.
question: Does every derivation (moduloS) starting onwhave finite length? (that is doesw 62 S1?)
Theuniform termination problemfor a classSof semi-Thue systems is the following : instance:an alphabetAand a finite semi-Thue systemS✓A⇤ ⇥ A⇤which belongs toS question:Do all derivations (moduloS) starting from all wordsw2A⇤have finite length? (that is
doesS1=;?)
To get shorter, we say that a systemS is nonterminatingif the uniform termination problem has a negative answer forS. In the sequel, we focus onSgrid, the family of one-rule grid semi-Thue systems.
Definition 2.1. A one-rule grid semi-Thue systemS ={u! v}is a one-rule semi-Thue system such that there exists a lettercwith|u|c=|v|c=k >0.
3. Uniform termination in S
gridIn this section, we state some consequences of the following Geser’s result:
Proposition 3.1. ([4]) A one-rule grid semi-Thue systemS={u!v}is non-uniformly terminat- ing iff one of the following properties is satisfied3:
1. uis a factor ofv.
2. there exist wordsg, h, ksuch thatu=gh,v=hkandgghis a factor ofhkk.
Example 3.1. The simplest example of one-rule grid semi-Thue system satisfying the property 2 of proposition 3.1 but not the property 1 isS ={cac−!acca}withg =c,h= ac,k =caand ggh=ccacis a factor ofhkk=accaca.
LetS={u!v} 2 Sgrid. The wordsuandvbelong toA⇤whereAis an alphabet that contains a lettercwith|u|c=|v|c=k >0. If we denoteB=A\ {c}, then
• u=lcu1. . . uk−1cr
• v=l0cv1. . . vk−1cr0
for some wordsl, r, l0, r0, u1, . . . , uk−1, v1, . . . , vk−12B⇤. We get, as a consequence of the propo- sition 3.1, the following corollary that is also directly proved in [13]:
Corollary 3.1. LetS={u!v} 2 Sgridwithu6=v. ThenSis nonterminating iff one of the two following properties is satisfied:
(i) uis a factor ofv
(ii) there existx, y, s, e2A⇤such thatxv=uyeandvy=sxu.
3More precisely, Alfons Geser proved in [4] that a one-rule grid semi-Thue systemS={u!v}is non-uniformly terminating if and only ifLoop1(S)[Loop2(S)6=;that is proved decidable by Winfried Kurth in [11].
Proof: Clearly, if (ii) is satisfied,Sis nonterminating sincexu −! xv = uye −! vye = sxue.
Now, ifu 62 F(v)and if the property 2 of the proposition 3.1 is satisfied, thenhkk = sgghefor somes, e. Since|g|c = |k|c, it followss, e 2B⇤. Suppose thatg, k2 B⇤then, sinceh 2l0cA⇤ and hkk = sgghe, we getl0 = sggl0 that impliesg = εandu = h 2 F(v), a contradiction.
Thus|g|c = |k|c > 0andk = yefor somey 2 A⇤. Takingx =g, we getxv = ghk = uye, vye=vk=hkk=sgghe=sxue, hencevy=sxu. ut
The following lemma states that ifu6=vthe conditions (i) and (ii) of the corollary 3.1 are mutually exclusive. This lemma also clarifies the relationship between the words x, y, sand ewhen the property (ii) of the corollary 3.1 is satisfied.
Lemma 3.1. LetS = {u ! v} 2 Sgrid. If the property (ii) of the corollary 3.1 is satisfied and u6=v, we have
(i) |x|c=|y|c>0ands, e2B+, (ii) u62F(v),
(iii) u=xu00=u0ywhereu00is the longest word inRF(u)\LF(v)andu0is the longest word in LF(u)\RF(v),
(iv) xandyare conjugate;sandeare conjugate.
Proof: If the property (ii) of the corollary 3.1 is satisfied, there areeandsinA⇤such thatxv=uye (1) andvy=sxu(2). From (1), we get|x|c=|ye|cand from (2),|y|c=|sx|c. So|x|c=|y|cand
|e|c=|s|c= 0that ise, s2B⇤. Moreover|x|c=|y|c >0otherwisexandybelong toB⇤and, from (1), we obtainxl0 =land from (2),l0 =sxl. It followsx=s=εand we similarly obtain y =e=ε. This leads to the contradictionu=v. Hencex2lcA⇤andy2A⇤crsovbelongs to slcA⇤\A⇤creandl0=sl,r0=re.
Let us now suppose thatuis a factor ofv. We prove that this leads to a contradiction. Indeed, if v=s0ue0for somee0, s0 2B⇤, then the equality (1) givesxs0ue0 =uye2A⇤cre0\A⇤creand it follows thate0=e. Similarly equality (2) impliess0=sand we obtainxs0u=uyandue0y=xu.
Thereforee0=s0=εandu=v; this contradiction proves (ii).
We can now finish the proof of (i): from (1) and (2), we getxsxu=xvy=uyeythat impliesu2 LF((xsx)⇤). Supposes=εthenu2LF((x)⇤)andvy =xu2 LF(x⇤). It followsv2LF(x⇤) that impliesu2F(v), a contradiction. Similarly we can showe6=ε.
For (iii), let us first observe that|x|<|u|and|y|<|u|: otherwise, we may assume that|y| |x|;
then|x| ≥ |u|andx=uzfor some wordz. It follows thatxu=uzu2RF(vy)with|y| |x|=
|zu|anduis a factor ofvwhich leads to a contradiction. Then we haveu =xu00 = u0ywithu00 inRF(u)\LF(v)andu0 inLF(u)\RF(v). We shall now prove thatu00 is the longest word in RF(u)\LF(v)and we could similarly show thatu0is the longest word inLF(u)\RF(v).
We havex=lcu1. . . uj−1cu0jwithu0j2LF(uj)and, if we denotepthe first index such thatup6=
vp(pexists sinceu62F(v)), we havej p. Assume now thatj < pand setz =lcu1. . . up−jc, then we havexsz 2 LF(u)andsxz 2 LF(v). But this impliess = εandup = up−j = vp, a contradiction. Thusp =j and it followsuj = u0jslandvj = u0jlwiths6= ε. Moreover, since ye2RF(ue)\RF(v)with|x|c=|y|c, we obtaink≥2pandxsx02LF(u),sxx02LF(v), with x0=lcu1. . . up−1c.
In order to show thatu00 is the longest word inRF(u)\LF(v), assume that there exists somez such that|z|<|x|andu2LF(zv). Then|z|c <|x|c,zsx2 LF(xsx0)andsxsx =szsxtwith t6=ε. Hencexsis not a primitive word andxs= (xrs)q+1wherexrsis the primitive root ofxs.
That impliesx= (xrs)qxrandx0= (xrs)x0rwithx0r2LF(xr),|x0r|c=|xr|c>0,z= (xrs)ixr withi < qandzsx = xzs. Sinceu 2 LF(zv), we havexsx0 2 LF(zsxx0) = LF(xszx0)and x0 = (xrs)qx0r 2 LF(zx0) = LF((xrs)ixr(xrs)qx0r). Thus(xrs)q−ix0r 2 LF(xr(xrs)qx0r)and sx0r2LF(xrs). But that impliess=ε, a contradiction that finishes the proof of (iii). Observe that it implies the unicity ofxandy. Moreover, if there are severalcsuch that|u|c=|v|c, the value of xandydoes not depend on the choice of a particularc.
Let us now prove (iv). Since|x|c = |y|c, we can writex =x0cx1. . . cxtandy = y0cy1. . . cyt with80 i t, xi, yi 2 B⇤. From (1) and (2), we can deducexvy = xsxu = uyey and it follows thatyeyandxsxare conjugate. Thuscytey0c . . . cyty0c 2F((xsx)⇤). Sinces, e 2B+, it is easy to verify that we must haveytey0 =xtsx0andyty0 = xtx0. Suppose that|yt| ≥ |xt| (the case|yt| |xt|is symmetric) thenyt = xtzfor somezand it followszy0 = x0. Then we getxtzey0=xtszy0sosandeare conjugate. Now from the equalityyteyy0=xtsxx0we obtain xtzeyy0=xtsxzy0that implieszey=szy=sxzthereforexandyare conjugate. ut
Since the equalities vy = sxuandxv = uyeimplyxvy = xsxu = uyey, it follows thatu 2 LF((xsx)⇤), u 2 RF((yey)⇤), v 2 LF((sxx)⇤) and v 2 RF((yye)⇤). Then we can state the precise form ofuandvfor a nonterminating one-rule grid semi-Thue system:
Proposition 3.2. S2 Sgridis nonterminating iff one of the following three conditions is satisfied 1. u2F(v)
2. u= (xsx)nx0andv= (sxx)nsx0withn >0andx02LF(x)\LF(sx) 3. u= (xsx)nxsx0andv= (sxx)nsxx0ewithn≥0, x=x0x00andx00s=ex00.
Proof: Let us first observe that these three conditions are sufficient by verifying that for any system S satisfying 1, 2 or 3,Loop(S) 6= ;. It is clear for 1 since, in this case, u 2 Loop1(S). IfS satisfies 2 then x(xsx)nx0 2 Loop2(S): indeed, in this case we getx = x0x00 andsx0 = x0x000 for some wordsx00, x000andx(xsx)nx0 −!x(sxx)nsx0 = (xsx)nx0x00sx0 −! (sxx)nsx0x00sx0 = sx(xsx)nx0x000. Finally, ifSsatisfies 3,x(xsx)nxsx0 −!x(sxx)nsxx0e= (xsx)nxsx0x00x0e−! (sxx)nsxx0ex00x0e= (sxx)nsxx0x00sx0e=sx(xsx)nxsx0e, thereforex(xsx)nxsx02Loop2(S).
It now remains to prove that the condition (1 or 2 or 3) is necessary.
Suppose that 1 is not satisfied, then we can consider three cases sinceu2LF((xsx)⇤):
(i) u= (xsx)nx0withx=x0x00.
First we can observe thatv= (sxx)nsx0sincev2LF((sxx)⇤)and|v|=|u|+|s|. Moreover n >0since|x|c<|u|c. It remains to prove thatx02LF(sx). The property (iii) of the lemma 3.1 givesy 2RF(u), thereforey =x00x0 since|x|=|y|. From the equalityxv =uyewe obtainx(sxx)nsx0= (xsx)nx0x00x0eandx02LF(sx0)since|e|=|s|.
(ii) u= (xsx)nxs0withs02LF(s).
Since v 2 LF((sxx)⇤) and|v| = |u|+|s|, it followsv = (sxx)nsxx0 with|x0| = |s0|.
Thenx0 2B⇤since|u|c =|v|cands2 B⇤. It follows thatx=x0x00for somex00. Let us now consider the factorizationx=zctwitht2 B⇤(we know that|x|c >0) then we obtain
u = u1cts0and v = v1ctx0 with|ts0| = |tx0|andts0, tx0 2 B⇤,u1, v1 2 A⇤. This is a contradiction sinceu=u1crandv=v1crewith|re|>|r|. The caseu= (xsx)nxs0with s02LF(s)is finally impossible.
(iii) u= (xsx)nxsx0withx02LF(x).
Sincev2 LF((sxx)⇤)and, from the property (iv) of the lemma 3.1,|v|=|u|+|e|, we get v = (sxx)nsxx0x000 with|x000| = |e|. Moreoverv 2 RF((yye)⇤) thereforex000 = eand v = (sxx)nsxx0e. Now, from the equalityxv = uye, we can deduce thaty = x00x0 since
|x|=|y|. Let us consider now the equalityvy=sxu: we get(sxx)nsxx0ey=sx(xsx)nxsx0 and it followsx0ey=xsx0. Sincex=x0x00andy=x00x0, we finally obtainex00=x00s.
u t Example 3.2. LetS={a2ca5c−!a4ca3ca2}. In this case,s=e=a2and from the property (iii) of the lemma 3.1,x=a2ca. Then we are in the case 3 of the proposition 3.2 withn= 0,x0=a2c andx00=a.
The condition 2 of the proposition 3.2 impliesx0 2 LF(sx0)sox0 2 B⇤. It follows that|u|c = 2n|x|c is even. Similarly, the condition 3 of the proposition 3.2 implies that x00 2 B⇤. Then
|x0|c=|x|cand|u|c= 2n|x|cis even. We obtain:
Corollary 3.2. LetS = {u −! v} such that|u|c = |v|c is odd. ThenS is nonterminating iff u2F(v).
4. The construction of Loop( S ) with S in S
gridThe aim of this section is to prove that for any systemS= {u−!v}inSgrid, the setLoop(S)is a constructible regular language. Clearly, ifu=vthenLoop(S) =A⇤uA⇤and in the rest of this section, we suppose thatu6=v.
We shall use the following lemma:
Lemma 4.1. LetS = {u−! v}inSgrid that is nonterminating withu 62 F(v). Ifz0cw0cz00 −!4 z4cw4cz40 withz0, z00, z4, z042B⇤and|w0|=|w4|thenz0cw0cz00 2B⇤(xu+uy)B⇤.
Proof: We consider the derivationz0cw0cz00−!z1cw1cz10 −!z2cw2cz02−!z3cw3cz30 −!z4cw4cz40 withzi, zi0 2 B⇤. Observe first that|cw0c|c > |u|cotherwise we can not apply a derivation step on z1cw1cz01sinceu 62 F(v). That implies that the first and the last occurrences of the letterc can not be both involved in a same step of the derivation. From the proposition 3.2,|wi+1|=|wi| if the derivation involves the first or the last occurrence of the letterc, else|wi+1| >|wi|. From the hypothesis, we are in the first case and8i,|wi| =|w0|. We can also suppose thatz0 = land z00 =r. Thenu2LF(lcw0cr)[RF(lcw0cr)and we consider the caselcw0cr=uy0−!vy0. Since su62LF(v), we necessarily haveu2RF(vy0). It follows thatvy0=sx1u−!sx1v=suy1e−! svy1e=s2x2ue. We can verify that|y0|=|y1|andy0, y12RF(u). Finallyy0=y1and we get vy0=sx1uandx1v=uy0e. Now, from the property (ii) of the corollary 3.1 and from the property (iii) of the lemma 3.1, we gety0=y,x1 =xthat implylcw0cr =uy. Observe that ifz06=lor z00 6=r we still havez0cw0cz00 2 B⇤uyB⇤. Ifu2 RF(lcw0cr), thenz0cw0cz002 B⇤xuB⇤that
proves the lemma. ut
Let us denote, for any wordw2A⇤cA⇤,int(w) = (B⇤)−1w(B⇤)−1\cA⇤\A⇤c.
Lemma 4.2. LetSbe nonterminating withu6=v.
1. Ifw−!⇤ w0withu2F(v)or|w|c>|u|c, then|int(w0)| ≥ |int(w)|, 2. ifw−+!w0!−⇤ zwz0then|int(w)|=|int(w0)|
Proof: For the property 1, it is sufficient to prove thatw−!w0implies|int(w0)| ≥ |int(w)|. That is clear ifu2 F(v)since|v|>|u|andint(v) = int(u). Ifu 62F(v)then the property (ii) of the corollary 3.1 is satisfied. Since|w|c>|u|cwe have to consider three cases:
1. w=zuw00andw0=zvw00withz2B⇤,w002(A⇤\B⇤), 2. w=w00uzandw0=w00vzwithz2B⇤,w002(A⇤\B⇤), 3. w=w00uw000withw00, w0002(A⇤\B⇤).
Let us consider the case 1. From the property (iv) of the lemma 3.1, |int(u)| = |int(v)|+|e|, moreoveru2A⇤crandv2A⇤creso we get|int(w0)|=|int(w)|. The second case can be proved similarly and for the third case, we clearly obtain |int(w0)| > |int(w)|since|u| < |v|. For the property 2, we haveint(zwz0) = int(w)andw2S1. So, ifu62F(v),|w|c>|u|cfrom the lemma 4.1. Then property 1 yields:|int(w)| |int(w0)| |int(zwz0)|=|int(w)|. ut
Lemma 4.3. If the property (ii) of the corollary 3.1 is satisfied andu6=vthen 1. v62F(xuB⇤),
2. v62F(B⇤uy), 3. xu62A⇤uA+, 4. uy62A+uA⇤.
Proof: From the property (iii) of the lemma 3.1,u=gywheregis the longest word inLF(u)\ RF(v). Assume first thatv2F(xu). Sincev2slcA⇤andxu2lcA⇤,v62LF(xu). Thenu=g0y0 withg02LF(u)\RF(v)and|y0|<|x|=|y|. Thus|g|<|g0|, a contradiction. Assume now that v2F(xuB⇤). Sincev2A⇤creandu2A⇤cr, we getv2RF(xue)andv=ue, a contradiction.
Assume now thatxu2A⇤uA+. Consider the equalityvy=sxu. Ifu2LF(xu)thenv=su, a contradiction. Otherwise, u= g0y0 withg0 2 LF(u)\RF(v)and|y0| < |y|. Thus|g| <|g0|, a
contradiction. Properties 2 and 4 can be proved similarly. ut
We obtain as a consequence:
Corollary 4.1. If the property (ii) of the corollary 3.1 is satisfied andu 6= vthenS−1(B⇤(xu+ uy)B⇤) =B⇤(xu+uy)B⇤.
Proof: Let us prove thatS−1(B⇤xuB⇤)✓B⇤(xu+uy)B⇤. It is clearly sufficient to consider a single step of derivation. Letw1uw2 −!w1vw2=w01xuw20 withw1, w22A⇤andw01, w022B⇤. From the lemma 4.3,v62 F(xuB⇤)therefore there existt2 B⇤andz2A⇤such thatw01=w1t, w2=zw02andtxu=vz. Sincev2slcA⇤andx2lcA⇤it followst=sthat impliesz=yand w1uw2=w1uyw022B⇤uyB⇤. We can prove similarly thatS−1(B⇤uyB⇤)✓B⇤(xu+uy)B⇤.
u t
Proposition 4.1.
1. Ifv=suwiths2B+thenLoop(S) = RF(s⇤)uA⇤, 2. Ifv=uewithe2B+thenLoop(S) =A⇤uLF(e⇤), 3. Ifv=suewiths, e2B+thenLoop(S) = RF(s⇤)uLF(e⇤).
Proof: LetS={u−!su}withs2B+andw2Loop(S). Thenw=αuβ−!αsuβ−!⇤ zαuβz0 withz, z0 2 B⇤. From the lemma 4.2, we have|int(αsuβ)| = |int(αuβ)|and, sinces 2 B+, we get α 2 B⇤. Moreover we obtain by induction on the lengthn > 0of the derivation that zαuβz0 = αsnuβ. It followsαsn = zαandα 2 RF(αsi⇥n)for any integeri >0. Therefore α2RF(s⇤)andLoop(S)✓RF(s⇤)uA⇤. Since the converse inclusion is immediate we finally get Loop(S) = RF(s⇤)uA⇤. The other cases can be proved similarly. ut Lemma 4.4. If the property (ii) of the corollary 3.1 is satisfied andu6=vthen for any wordα, β2 B⇤
1. S(αxuβ) ={αsnxuenβ|n≥0} [ {αsn−1uyenβ|n >0}, 2. S(αuyβ) ={αsnuyenβ|n≥0} [ {αsn−1xuenβ|n >0}.
Proof: We prove thatS(αxuβ) ={αsnxuenβ |n ≥ 0} [ {αsn−1uyenβ | n >0}: from the lemma 4.3, xu 62 A⇤uA+anduy 62 A+uA⇤ therefore the first steps of a derivation fromw are w =αxuβ −!αxvβ =αuyeβ−!αvyeβ =αsxueβand the property is proved by induction on the length of the derivation. The second property of this lemma can be proved similarly. ut Proposition 4.2. If the property (ii) of the corollary 3.1 is satisfied andu6=vthen
Loop(S) = RF(s⇤)(xu+uy)LF(e⇤)
Proof: Letw 2Loop(S)thenw −!n zwz0withz, z0 2B⇤andn > 0. We can supposen ≥ 4 and there exists a derivationw −! w1 −! w2 −! w3 !− w4 −!⇤ zwz0withz, z0 2 B⇤. From the lemma 4.2, we get |int(w4)| = |int(w)|and, from the lemma 4.1, we getw = αxuβ orw = αuyβwithα, β 2 B⇤. Let us suppose thatw = αxuβthenS(w) = {αsnxuenβ | n ≥ 0} [ {αsn−1uyenβ | n > 0}from the lemma 4.4. Moreover, from the lemma 4.3 we deduce that xu 6= uysinceu 62 LF(xu). On the other hand, from the property (iii) of the lemma 3.1, we have xu 2 lcA⇤cr and uy 2 lcA⇤cr then it follows that int(uy) 6= int(xu) = int(w). That implies that ifw =αxuβ −+! zwz0 = zαxuβz0we must havezαxuβz0 =αsnxuenβfor some n >0thereforeα2RF(s⇤)andβ2LF(e⇤). The casew=αuyβis symmetric and we finally get Loop(S)✓RF(s⇤)(xu+uy)LF(e⇤). We can easily verify the converse inclusion sincexu−!⇤ sxue
anduy−!⇤ suye. ut
We directly obtain from the two previous propositions:
Corollary 4.2. IfS2 SgridthenLoop(S)is a constructible regular language.
The conditionS2 Sgridin the corollary 4.2 is necessary as shown by the following example:
Example 4.1. ConsiderS = {c −! caca}. We shall show thatLoop(S)\c(ca)+a⇤ = L = c{(ca)nap |n > p≥0}. Sincec −!⇤ (ca)n−1can−1, it follows that forn > p≥0,c(ca)nap −!⇤ c(ca)napan−1−p(ca)n−1apandL✓Loop(S). For the reverse inclusion, remark that(ca+a)⇤isS- closed. So, ifcw=c(ca)nap−!⇤ αcwβfor someα, β2A⇤, thenα=εandw−+!wβwith|β|c>
0. Thusβ=β0ap,(ca)n−!⇤ (ca)napβ02LF(S(c))andp < nsince8z2LF(S(c)),2|z|c>|z|a.
5. Testing membership in S
1with S in S
gridThe aim of this section is to show that the termination problem of a systemS2 Sgridis decidable.
Recall that this problem is, givenS2 Sgridand a wordw2A⇤to know whetherw2S1. Clearly, for a systemS= {u−!v}withu2 F(v),S1 =A⇤uA⇤and we conjecture that for any system S2 Sgridthe setS1is a constructible regular language. This is true when|u|c =|v|c = 2as it is proved in the next section but here we must find another way in order to prove thatS1is a recursive language for anyS 2 Sgrid. More precisely, we show that for anyS 2 Sgridand any wordw, the setS(w)is a constructible bounded context-free language.
Definition 5.1. ([9]) A languageL✓A⇤is said to beboundedif there exist wordsw1, . . . , wn2A⇤ such thatL✓w⇤1. . . w⇤n.
As a matter of fact, it would be sufficient to prove that for anyS 2 Sgridand any wordw, the set S(w)is a constructible context-free language in order to decide whetherS(w)is finite. Nevertheless bounded languages have nice structural properties that will also permit to solve in this section the common descendant problem for anyS2 Sgridthat is to decide, given two wordswandw0, whether S(w)\S(w0)is not empty. We also observe that the imageS(w)of a wordwby an arbitrary one-rule semi-Thue systemSneed not be context-free([12]).
Following Alfons Geser in [4], we first establish that if a derivation is applied to a word long enough, this word can then be factorized so that the derivation applies independently on each factor of the word. Let us denoteN0= max{|cui| |i < k}andN = max{N0,|l|,|r|}.
Lemma 5.1. Letw=z0cm0m00cz00withm0, m00 2B⇤andz0, z00 2A⇤. If|m0| ≥N and|m00| ≥ N thenS(w) =S(z0cm0)S(m00cz00).
Proof: ClearlyS(z0cm0)S(m00cz00)✓S(w). Conversely, letw02S(w), we prove by induction on the lengthnof the derivation fromwtow0thatw0 2S(z0cm0)S(m00cz00). The base casew =w0 is immediate. Otherwisew −!w00 −−−!n−1 w0. Since|m0m00| > N, the first step of the derivation applies on an occurrence ofuthat can only appear inz0cm0or inm00cz00. Suppose it is inz0cm0, thenz0cm0−!z10cm01withm012B⇤,|m10| ≥ |m0|andw00=z10cm01m00cz00. Now, we can apply the induction hypothesis onw00−−−!n−1 w0:w02S(z10cm01)S(m00cz00)✓S(z0cm0)S(m00cz00). The other
case can be proved similarly. ut
We directly deduce:
Lemma 5.2. Letzcwcz0withz, z0 2B⇤andw 2A⇤. If|cwc| ≥2⇥(|w|c+ 2)⇥N then there exist two constructible wordsw0, w00 2 (A⇤\B⇤)such thatzcwcz0 = w0w00 andS(zcwcz0) = S(w0)S(w00).
Then we can state:
Proposition 5.1. LetS2 Sgridsatisfying the property (ii) of the corollary 3.1.
1. For any wordw2A⇤, the setS(w)is a bounded context-free language.
2. S1=S−1(A⇤(xu+uy)A⇤)=S−1(A⇤Loop(S)A⇤).
Proof: The proof is based on an induction over|w|c. For the property 2, we have only to prove S1✓S−1(A⇤(xu+uy)A⇤)since the inclusionsS−1(A⇤(xu+uy)A⇤)✓S−1(A⇤Loop(S)A⇤)✓ S1are clear.
• If|w|c<|xu|cthenS(w)is finite (therefore bounded context-free) from the lemma 4.1,
• If|w|c=|xu|cthen
– ifw62 B⇤(xu+uy)B⇤thenw 62S−1(B⇤(xu+uy)B⇤)from the corollary 4.1 and it follows thatS(w)is finite from the lemma 4.1,
– ifw 2 B⇤(xu+uy)B⇤then, from the lemma 4.4,S(w)is a (constructible) bounded context-free language andwis inS−1(A⇤(xu+uy)A⇤)
• If|w|c>|xu|c, we make a new induction onKw= 2⇥(|w|c)⇥N− |int(w)|. IfKw 0 then it follows from the lemma 5.2 that there exist two constructible wordsw0, w002(A⇤\B⇤) such thatw=w0w00andS(w) = S(w0)S(w00). As|w0|c <|w|cand|w00|c <|w|c, we can apply the induction hypothesis and it follows thatS(w)is a constructible bounded context-free language. IfKw>0, let us denoteS1={w02A⇤|w−−!<4 w0}andS2={w02A⇤|w−!4 w0}. ClearlyS(w) =S1[(S
w02S2S(w0)). The family of bounded languages is closed by finite union, consequently it remains to prove that for any wordw0inS2,S(w0)is a bounded context-free language. Sincew 62 B⇤(xu+uy)B⇤it follows from the lemma 4.1 and the lemma 4.2 that, for any wordw0 2 S2,|int(w0)| >|int(w)|. ThenKw0 < Kw and, by the induction hypothesis,S(w0)is a bounded context-free language, moreover ifw0 2 S1then w02S−1(A⇤(xu+uy)A⇤)and it follows thatw2S−1(A⇤(xu+uy)A⇤)which concludes the proof of the proposition.
u t
Whenu2F(v), a similar proof can be used to show that the property 1 is also satisfied in this case.
Then we get as a corollary:
Corollary 5.1. The termination problem is decidable for any systemS2 Sgrid.
Since it is proved in [8] that the non-emptiness of the intersection of two bounded context-free languages is decidable, we also obtain:
Corollary 5.2. The common descendant problem is decidable for any systemS2 Sgrid.
6. The special case | u |
c= | v |
c= 2
It has been shown in the section 4 thatLoop(S)is regular forSinSgridand that this result does not hold for arbitrary one-rule semi-Thue system. The status ofS1is different. G´eraud S´enizergues has proved in [20] thatS1is regular whenu2a⇤b⇤, but the regularity ofS1is an open problem for arbitrary one-rule semi-Thue system. Note that the regularity ofS1does not hold for two-rules grid semi-Thue system as shown by the exampleS={aca−!c, cc−!cca}since it is easy to see that S1 =A⇤cA⇤cA⇤cA⇤[ {aicapcaq |pi+q}. We conjecture thatS1is a constructible regular language for anySinSgrid. As we are unable to prove this fact, we give an argument in favour by proving it in the simpler case|u|c =|v|c= 2. The following proof shows also that the structure of S1can be involved and that the proof in the general caseSinSgridcould be tricky.
Clearly the question arises only whenSsatisfies the property (ii) of the corollary 3.1 since, when u2F(v),S1=A⇤uA⇤. Then we consider in the following a nonterminating systemS={u−!v}
withu=lcu1cr,v=slcv1cre,xv=uyeandvy=sxuforu1, v1, s, e2B⇤andx, y2A⇤. Then there exist wordsu01andu001such thatu1=u01sl=reu001, v1=u01l=ru001, x=lcu01andy=u001cr Let us denoteS1min=S1\(A S1[S1A)and, for any wordw2A⇤,Lw=S−1(A⇤w)\(S1[ A S−1(A⇤w))andRw=S−1(wA⇤)\(S1[S−1(wA⇤)A).
Lemma 6.1. Smin1 ✓Lxlcu1cRr[Llcu1cRry.
Proof: Let us considerw02S1minand letnbe the length of the shortest derivation fromw0to any word inA⇤(xu+uy)A⇤. Let us suppose that there exists a derivation fromw0town2A⇤(xu)A⇤. Thenw0−!⇤ w1−!⇤ wi
−!⇤ wnandwn=pncqncrnwithpn2A⇤xl,qn=u1andrn2rA⇤. For any i2[0, n], let us consider the factorizationwi=picqicriwith|pi|c=|pn|candqi2B⇤. We claim thatq0= u1, else letjbe the greatest index such thatqj 6=u1. Thenwj+1 =pj+1cu1crj+1and pj+1−!⇤ pn, rj+1−!⇤ rn. This will lead to the following contradiction: there exists a derivation from w0to a word inA⇤(xu+uy)A⇤whose length is strictly less thann. It follows that for anyi,qi=u1 andp0−!⇤ pn,r0−!⇤ rnthereforep02S−1(A⇤xl), r02 S−1(rA⇤). Sincew02S1min, it follows p02Lxl, r02Rrandw02Lxlcu1cRr. Let us distinguish two cases for the stepwj!wj+1:
1. qj=u01l, rj=u1crzandrj+1=v1crez.
Thenpncu012A⇤lcu01=A⇤xandw0=pncqjcrj=pncu10lcu1crz2A⇤xuA⇤. Clearly, the length of the derivationw0
−!⇤ wj=pjcqjcrj
−⇤
!w0=pncqjcrjis strictly smaller thann.
2. qj=ru001, pj=zlcu1andpj+1=zslcv1.
Thenu001crn2u100crA⇤=yA⇤andw0=pjcqjcrn=zlcu1cru001crn2A⇤uyA⇤. Clearly, the length of the derivationw0
−!⇤ wj=pjcqjcrj
−⇤
!w0=pjcqjcrnis strictly smaller thann.
u t
Lemma 6.2. S−1(A⇤u)\A⇤cu1cr✓S1.
Proof: Letw2S−1(A⇤u)\A⇤cu1cr. Then there exists a derivation:w0!w1−!⇤ wi −!⇤ wn2 A⇤u. Letjbe the greatest index such thatwj 62 A⇤cu1cr. Thenwj = pjuu001cr 2 A⇤uy, and it
followsw2S−1(A⇤uy)✓S1. ut
Let us denoteF = {cv1} [ {cu1crz | v1 =rez}. Remark thatF is finite andS−1(A⇤l)F ✓ S−1(A⇤xl).
Lemma 6.3. Lxl✓LlF.
Proof: Letw2Lxl. Thenw−!⇤ zxl=zlcv1. Let us consider two cases:
1. Ifw=w0cv1, we can deduce thatw0 −!⇤ zl, sow0 2S−1(A⇤l). Sincew=w0cv162S1, it followsw0 62 S1and sincew 62AS−1(A⇤xl), it followsw0 62AS−1(A⇤l). Thenw0 2 Ll andw=w0cv12LlF.
2. Elsew=w0crzwithz2B⇤andrz6=v1. Thenw−!⇤ puz!pvz −!⇤ p0cv1. We show that rez=v1. Indeed, if it is not the case,pslcv1cr2S−1(A⇤u)\A⇤cu1cr✓S1which implies pvz 2 S1andw 2 S1. Sincew =w0crz −!⇤ puz, it followsw0cr 2 S−1(A⇤u)\S1 ✓ A⇤cu1cr, sow0crz =w00cu1crz −!⇤ pvz 2 A⇤xl. Finallyw00 2 S−1(A⇤l), w00 62S1and w0062AS−1(A⇤l)which impliesw002Llandw2LlF.
u t
Let us denote H = {z | l 2 RF(rez)\RF(rz)}. Remark thatHis finite andS−1(A⇤u)H ✓ S−1(A⇤l).
Lemma 6.4. Ll✓l+LuH.
Proof: Letw2 Ll. Ifw2 A⇤lthenw=lotherwisew =w0crzwithl 62RF(rz). Then there exists a derivationw−!⇤ puz−!pvzwithpvz2A⇤crez\S−1(A⇤l). Suppose thatl62RF(rez), thenpslcv1cr 2 S−1(A⇤u)\A⇤cu1crand it follows from the lemma 6.2 thatpvz, and thus also w, is inS1. This contradiction impliesl 2 RF(rez)thereforez 2 H andw0cr 2 S−1(A⇤u).
Moreoverw62S1andw62AS−1(A⇤l)imply thatw0cr62 S1andw0cr62AS−1(A⇤u). Finally
w0cr2Luandw2LuH. ut
Lemma 6.5. Lu✓Llcu1cr.
Proof: Letw 2 Lu ✓ S−1(A⇤u)\S1 ✓ A⇤cu1cr. Then w = w0cu1cr −!⇤ w00cu1cr with w00 2 A⇤l. It follows thatw0 2 S−1(A⇤l). Moreoverw0 62S1andw0 62 AS−1(A⇤l)that imply
w02Llandw2Llcu1cr. ut
Since, clearly,S−1(A⇤l)cu1crH✓S−1(A⇤l), it follows from the lemmata 6.4 and 6.5 thatLl ✓ l(cu1crH)⇤✓S−1(A⇤l). Then, from the lemma 6.3, we getLxl✓l(cu1crH)⇤F ✓S−1(A⇤l)F ✓ S−1(A⇤xl):
Lemma 6.6. Ll✓l(cu1crH)⇤✓S−1(A⇤l)andLxl✓l(cu1crH)⇤F ✓S−1(A⇤xl).
Symmetrically, denotingF0={v1c} [ {zlcu1c|v1=zsl}andH0={z|r2LF(zsl)\LF(zl)}, we get: