Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Information Processing Letters 22 (1986) 125-131

North-Holland

3 March 1986

SQUARE-FREE W O R D S O N PARTIALLY C O M M U T A T I V E FREE M O N O I D S *


Arturo CARPI
Institute of Fundamental Mathematics, University of Rome, 00100 Rome, Italy

Aldo DE LUCA
Department of Applied Mathematics "'R. Caccioppoli", University of Napoli, Via Mezzocannone 8, 80134 Napoli, Italy
Communicated by L. Boasson
Received March 1985
Revised May 1985

We give a characterization of the partially commutative free monoids having an infinite number of square-free elements. We
prove that it is decidable whether a given partially commutative free monoid contains infinitely many square-free words.

Keywords: Square-free words, partially commutative free monoids

1. Introduction

Since the beginning of this century, many papers


have been devoted to the investigation of squarefree words. This problem has several applications
in various fields, such as game theory, symbolic
dynamics, group theory, and formal language theory.
The first work on this subject was due to Thue
[11] who proved that the set of square-free words
on an alphabet A is infinite, provided A contains
at least three letters.
In this article we are concerned with square-free
elements of partially commutative free monoids.
Roughly speaking, partially commutative free
monoids are obtained by considering words in
which only some pairs of letters can commute.
These objects have been studied for the first time
by Cartier and Foata [3] who used them in a
combinatorial problem. More recently, several
authors have been .interested in the study of ra* T h i s research was partially supported by the Italian Ministry
of Education.

tional subsets of partially commutative free monoids (cf., for instance, [2,4,5] and references therein).
The main result of this article is a characterization of the partially commutative free monoids
containing an infinite number of square-free elements. It shows that it is effectively decidable
whether a given partially commutative free monoid
contains infinitely many square-free words.

2. Preliminaries

Let A* be the free monoid generated by a finite


alphabet A. The length of a word w ~ A* is denoted by Iwl. A is the empty word and A += A * \
{ A } the free semigroup over A.
Let 0 _ A X A be a symmetric relation and the congruence in A* generated by the set of pairs
(ab, ba) such that (a, b) ~ 0. The quotient monoid
M(A, 0 ) = A * \ - is said to be the partially commutatioe free monoid on A (relatively to 0). The
canonical epimorphism of A* onto M(A, 0) is
denoted by .
A word w ~ A* is square-free if it contains no

0020-0190/86/$3.50 1986, Elsevier Science Publishers B.V. (North-Holland)

125

Volume 22, Number 3

INFORMATION PROCESSING LETTERS

factor of the form uu with u 4: A. Similarly, an


element m ~ M(A, 0) is said to be square-free if it
cannot be factorized as
m = rs2t
with s ~ 1. In other words, the square-free elements of M(A, 0) are the congruence classes (mod
- ) which contain only square-free words. We
denote by Lz(M) the set of the square-free elements of a partially c o m m u t a t i v e free m o n o i d
M = M(A, 0).
It is w o r t h noting that the previous notion of a
square-free element of M(A, 0) is quite different
from the n o t i o n of a permutation-free word of A*
in the sense of Pleasants [10] or, m o r e general,
from the concept of a O-permutation-free word of
A* as i n t r o d u c e d in [8].
We recall that, for any given symmetric relation
0 an A, a word w ~ A* is 0-permutation-free if w
does not contain factors such as ff', f, f' ~ A +, with
f - f', where - is the congruence generated by the
set of pairs (ab, ba) such that (a, b ) ~ 0. If f' can
be any p e r m u t a t i o n of f (this occurs if 0 =
A A), then w is simply called permutation-free.
It is clear that if w A* is such that the congruence class of w ( m o d - ) is a square-free element of M(A, 0), then w is a e-permutation-free
wordofA*. Otherwise, in fact, w = hff'k, f, f' ~ A +,
h, k ~ A*, and f - f'. This would imply w - hf 2k
which is a contradiction.
The converse of the preceding statement, however, is not true in general. This is s h o w n by the
following easy example. Let A = (a, b, c}, 0 =
((a, b)} a n d w---cabaca; w is permutation-free
and, thus, also 0-permutation-free. However, the
c o n g r u e n c e class ( m o d - ) of w is not a square-free
element of M(A, 0) since cabaca - cba2ca.
A n infinite word on A is a function a : N ~ A.
We use the notation
a=a0al...an...

(ai~A,i>~0).

3 March 1986

A m o r p h i s m h : A* ~ B* is said to be square-free
if h(w) is square-free for all the square-free words
w ~ A*. Berstel [1] and C r o c h e m o r e [6] have given
tests to decide whether a given morphism, defined
on a finite alphabet, is square-free.

3. Conditions sufficient for the infiniteness of


Lz(M(A, 0))
We call inalterable (relatively to 0) any word
(finite or infinite) which contains no factor of the
f o r m ab with (a, b) ~ 0, a :g b.
If w ~ A* is an inalterable square-free word,
then its congruence class (mod - ) does not contain other words and, therefore, it is a square-free
element of M(A, 0). Hence, if there exist arbitrarily long square-free words of A* which are
inalterable relatively to 0 (or, equivalently, if there
exists an infinite inalterable square-free word),
t h e n L2(M(A, 0)) is infinite.
T h e following proposition gives sufficient conditions for the existence of an infinite inalterable
square-free world.

Proposition 3.1. Let M = M(A, 0) be a partially


commutative free monoid verifying one of the following conditions:
(i) There exist three distinct letters a, b, c ~ A
such that
(a, b), (b, c), (c, a) ~ 0.
(ii) There exist four distinct letters a, b, c, d ~ A
such that
(a, b), (a, c), (a, d) ~ 0.
(iii) There exist four distinct letters a, b, c, d ~ A
such that
(a, c), (c, b), (b, d), (d, a ) ~ O.
(iv) There exist five distinct letters a, b, c, d, e
A such that

A factor of a is any word of the form a i a i + 1 a i +j


(i, j >~ 0). We say that an infinite word is square-free
if all of its factors are square-free. If h is a
m o r p h i s m defined on A*, we define the image of a
by setting

Then there exists an infinite inalterable square-free


word (and, therefore, L 2 ( M ) is infinite).

h(a) = h ( a 0 ) h ( a l ) . . . h ( a , )

Proof. If condition (i) is verified, then all the

126

....

(a, b), (b, c), (c, d), (d, e ) ~ O.

V o l u m e 22, N u m b e r

INFORMATION

PROCESSING

infinite square-free words over (a, b, c} are inalterable.


By means of one of the algorithms given in [1]
or in [6], one easily verifies that the morphism
~,: (a, b, c}* ~ {a, b, c, d}* defined by
~,(a) = ab,

v ( b ) = ac,

~,(c) = ad

is square-free. Hence, if condition (ii) is verified,


an infinite inalterable square-free word can be
obtained by applying ~, to an infinite square-free
word on {a, b, c).
N o w let t be an infinite square-free word over
three letters a, b, and c while d is the infinite
square-free word over four letters a, b, c, and d
obtained f r o m t by inserting a letter d between
adjacent a's and b's. For instance, if t is the
Thue-sequence

LETTERS

3 March 1986

(B) If s ~ (ba, bc, dc, de), then there exists a


unique letter x such that sx is a factor of a;
moreover, one has x ~ (b, d}. Symmetrically, if
r ~ (ab, cb, cd, ed}, then there exists a unique
letter y such that yr is a factor of a; moreover,
y ~ {b, d}.
We now prove by reductio ad absurdum that a is
square-free. In fact, suppose that a contains a
square. Then there exist two integers m >i 0 and
n > 0 such that
amain+

1 . . .am+n_

1 = am+nam+n+

1 . .am+2n_

1.

(1)

t = abcacbabcbac . . . .

O n e has n >/2 because a contains no factor xx


with x ~ A. By (A), one has that am+ n_ l ~ (a, C, e }
or am+ . ~ {a, c, e}. We suppose am+n_ 1
{a, c, e} (in the other case one can proceed symmetrically). Then by (1) and (A) one has

then

am+n_2am+n_

1 = am+2n_2am+2n_

{ba, bc, dc, de}

d = adbcacbdadbcbdac ....
Let us now suppose that condition (iii) is verified.
Since d is inalterable, it follows that L2(M(A, 0))
is infinite. W e observe that the same result can be
obtained in a m o r e direct way by considering the
sequence of D e a n [7] which is an infinite squarefree word over four letters a, b, c, and d without
the factors of length 2: ab, ba, dc, and cd.
Let us n o w suppose that condition (iv) is verified. Let b = b0blb 2 . . . be an infinite overlap-free
word on the alphabet (b, d}, that is, an infinite
word which contains no factor of the form xuxux
with x ~ {b, d}, u E (b, d}*. Such a w o r d exists,
as proved b y T h u e [11,12] (cf. also [9]). Let a =
a 0 a l a 2 . . . be the infinite word on the alphabet A
defined by
a 2 n ----- b n ,

!
a2n+l

if a2n = a2n+2

if

a2n 4= a2n+2

b,

if a2n = a2n+2 = d

(n >~ 0).

F r o m the definition of a one derives the following


facts:
(A) The only factors of length 2 of a are ab, ba,
bc, cb, cd, dc, de, ed, and, therefore, a is inalterable.

and, therefore, in view of (B), a m = a m


{b, d}. Hence, a contains the factor
V-----amam+
(U = am+

1. . .am+2n=amUamUa
1 . . .am+n_

1 = am+n+

+ n

a m+ 2,

m
1 . . .am+2n_l).

By deleting in v all the occurrences of a, c, and e


one obtains a factor of b of the form
VC=amUamUam

(~E (b,d}*).

This is a contradiction since b is overlap-free. We


conclude that a is an infinite inalterable square-free
word. []
Remark. One can ask oneself the question whether
infinite square-free words exist which are not inalterable relatively to 0, and such that all their
(finite) factors are square-free elements of M(A, 0).
In these cases, of course, L2(M(A, 0)) is infinite.
The answer is, in general, positive. For instance, if
A = {a, b, c, d} and 0 = ((c; d)}, then the infinite
w o r d obtained from an infinite square-free word
on {a, b, c} by replacing the letter c with cd is not
inalterable but such that all its finite factors are
square-free elements of M(A, 0). A less trivial
e x a m p l e is the following. Let 0 = {(a, b), (c, d)}
a n d 13: (a, b, c}* --, {a, b, c, d}* be the morphism
127

Volume 22, Number 3

INFORMATION PROCESSING LETTERS

defined b y
13(a) = acbd,

[3(b) = bcad,

It is evident that the morphisms "rrA~: A * ~


(i = 1, 2) defined b y

13(c) = abd.

If t is the T h u e sequence over {a, b, c}, then let


s = 13(O be the infinite sequence o b t a i n e d b y
applying 13 to t. O n e can prove that s, which is not
inalterable relatively to 0, is such that all its (finite)
factors are square-free elements of M(A, 0).

%,(a)=

ifa~Ai,

ifa~Ai,

4. Decidability for the infiniteness of L2(M(A, 0))


In this section we shall prove that L 2 ( M ( A , 0))
is infinite only when at least one of the conditions
of Proposition 3.1 is satisfied.
Let there exist a partition of the alphabet A,
A = A 1 u A 2 (A~ N A 2 =~0) such that each letter
of A 1 c o m m u t e s with all the letters of A 2. If
M i = O(A*) (i = 1, 2), then M = M(A, 0) is generated by M~ U M 2 and each element of M 1
commutes with the elements of M 2. Hence, one
has
(2)

We remark that M i = M(A~, 0~), where 0~ is the


restriction of 0 to A~ ( i = 1, 2). W e state the
following proposition.

Proposition 4.1. Let M = M(A, 0) be a partially


commutative free monoid such that
A=A1UA

2,

Alf3A2=~,

AIA2___0.

Then one has


L2(M ) = L2(M,)L2(M2) ,

A*

are such that if u, v ~ A* and u - v, then % , ( u )


%,(v). Hence, one has
Wi = 'TrAi (WlW2) - % , ( 0 ( % , ( s ) ) 2 % , ( 0

M = M, M 2"

3 March 1986

(i=1,2).

Since O(w 1) and O(w2) are square-free, one derives


~rA,(s) = rA~(S) = A, but this is a contradiction because s is nonempty. []
By iterated applications of the preceding
proposition one obtains a decomposition
L2(M(A, 0))=L2(M1)L2(M2)...L2(Mn)

where M i = M ( A i , 0i) ( i = 1 , 2 . . . . ,n) are partially c o m m u t a t i v e free m o n o i d s such that there


exists no partition A i = A~ U A'~' with A ' i X A,' G 0.
The following proposition concerns m o n o i d s of
this kind.

Proposition 4.2. Let M = M(A, 0) be a partially


commutative free monoid such that no partition A =
A1 L) A 2 exists with A1 A 2 G O.
I f Im I >/5, then at least one of conditions (ii) or
(iv) of Proposition 3.1 is verified (and, therefore,
L2(M ) is infinite).

Proof. Let ala 2 . . . a n (a i~A,l.%<i.%<n) be an


inalterable word of maximal length such that a~
aj for i :# j. If n >/5, then condition (iii) of Proposition 3.1[ is verified. If, on the contrary, n ~< 4, one
has, from the hypothesis,

where M i = 0 ( A * ) (i = 1, 2).
(aa, a 2 . . . .
Proof. By (2), all m ~ L 2 ( M ) can be factorized as
m = m l m 2 (m i ~ M i , i = 1, 2) and, obviously, m 1
and m 2 are square-free. This proves the inclusion
L2(M) G L 2 ( M 1 ) L 2 ( M 2 ) .
Let us n o w s u p p o s e that the inverse inclusion
does not hold true. Then there exist w o r d s % ~ A~',
w2 ~ A~, r, t, s ~ A* such that 0 ( w l ) ~ L2(M1),
~(w2) ~ L2(M2), s :~ A and
wlw2 -- rs 2 t.
128

, a n } x ( A \ ( a l , a2, . . , a , } ) ~ 0

and therefore there exist b ~ A \ (a 1, a 2 . . . . . a n },


and a k (1 ~< k ~< n) such that (ak, b) ff 0. By the
maximality of n, b a l a 2 . . . a n a n d a l a 2 . . . anb are
not inalterable, and, therefore, one has k 4= 1 and
k ~ n. Hence, condition (ii) of Proposition 3.1 is
verified b y the letters a k, b, a k - 1, and a k + 1. []
W e are n o w able to prove o u r main result. It
provides an effective procedure to decide whether
L2(M(A, 0)) is infinite.

Volume 22, Number 3

INFORMATION PROCESSING LETTERS

Proposition 4.3. L2(M(A, 0)) is infinite if and only


if one of the following four conditions is satisfied:
(i) There exist three distinct letters a, b, c ~ A
such that
(a, b), (b, c), (c, a) ff O.

3 March 1986

Indeed there are only two cases in which all


these requirements are verified. These are illustrated by the following graphs (in which the
nodes represent the letters of A and the arcs join
the letters which can commute):

(ii) There exist four distinct letters a, b, c, d ~ A


such that
(a, b), (a, c), (a, d) ff O.
(iii) There exist four distinct letters a, b, c, d ~ A
such that
(a, c), (c, b), (b, d), (d, a) ff O.
(iv) There exist five distinct letters a, b, c, d, e
A such that
(a, b), (b, c), (c, d), (d, e)ff 0
Proof. If one of the preceding four conditions is
satisfied, then by Proposition 3.1 one has that
L2(M(A, 0)) is infinite. Hence, it is sufficient to
prove that if none of these conditions is verified,
then L2(M(A, 0)) is finite. If IAI < 2 , then
L2(M(A, 0)) is finite since there exists no
square-free word of length larger than 3 over two
letters. Therefore, we suppose IAI > 2 and proceed by induction on IA I . We distinguish two
cases.
Case 1. There exists a partition A = A mU A 2
(AI, A 2 =/:~) such that A 1 X A 2 c 0.
Case 2. Such a partition does not exist.
In Case 1, with the-notation of Proposition 4.1,
one has
L2(M(A, 0 ) ) = L 2 ( M a ) L 2 ( M 2 ) .
By the induction hypothesis, L2(Ma) and L2(M2)
are both finite, and, therefore, also L2(M(A, 0)) is
finite.
In Case 2, one derives from Proposition 4.2 that
]A ] .%<4. Hence, to complete the proof, it is sufficient to verify that whenever M(A, 0) is a partially
commutative free monoid such that:
(1) 3 < I n l < 4 ,
(2) no partition A = A 1 U A 2 exists with A~
A2 __c0,
(3) none of the conditions (i)-(iv) is verified,
L2(M(A, 0)) is finite.

(a)

(b)

In case (a), one easily verifies that all the words of


length larger than 7 are congruent (mod - ) to
some word containing a square and, therefore,
L2(M(A, 0)) is finite.
In case (b), a manual verification of the finiteness of L2(M(A, 0)) is more elaborate, since, in
this case, Lz(M(A, 0)) contains a rather large
number of elements. This verification is given in
Appendix A. []

Acknowledgment
We wish to thank the anonymous referee for his
(or her) useful suggestions.

Appendix A
We want to show that if A = {a, b, c, d} and
0 = {(a, b), (b, c), (c, d)}, then L2(M(A, 0)) is
finite. Let us define the following subsets of A*:
R = qb-'(L2 ( M ( A , 0))),
R, = R \ 0 - ' 0 ( A * { a b c ,

dcb}A*),

R 2 = R, \ 0 - 1 0 (A * {ab, cd}A*).
The following facts only require some patience to
be verified. They can be derived from Figs. 1, 2,
and 3, which give the initial parts of the trees
representing abcA* c3 R, abA* n R1, and bA* n
R 2.
(1) If a b c s ~ R , s ~ A * ,
t sl >/12, then s dadbdacadab~ for some g ~ A*.
(2) Symmetrically, if rbcd ~ R, r ~ A*, ]r t >/
12, then r - ~cdadbdacada for some ~ c A*.
(3) If abs ~ R1, s ~ A*, Ist >7 12, then s - s0dc
g, where s o = dacadbda for some g ~ A*.
129

INFORMATION PROCESSING LETTERS

Volume 22, Number 3


~b

a/

%,

\b
abe
/
d/ .

all

all

II

b,,

2b
dc

,, a H

,,Ull

a
b ~e

3 March 1986

. b II

a/b-,.

c __ a ~

d/

c -- b~

~d
a~d

II

bll

Fig. 1. abcA* (~ R.
a~b

Ib

a--a

d~a

a tl

--c

a II

c/a

~ c
Fig. 2. abA* (~ R l.

(4) S y m m e t r i c a l l y , if d c r ~ R 1, r ~ A*, Ir l >/


12, t h e n r - r 0 a b L w h e r e r o = a d b d a c a d for s o m e
~A*.
(5) If b s ~ R 2, s e A * ,
Isl>~8, then s~
{dacadb, dadbd}A*.
(6) S y m m e t r i c a l l y , if rb ~ R2, r ~ A*, [r I >i 8,
then r ~ A*{bdacad, dbdad}.

L e t us n o w s u p p o s e t h a t R c o n t a i n s a w o r d w
such that I w l > 84. T h e n o n e c a n f a c t o r i z e w as
w = vlv2v3v4vsv6
with
Iv 1 [ = 11,
Iv6[ = 12

d<

c tl

b/

C~a

II

Iv21= [v41=8,
and

Iv5[=42,

[v3[ > 3.

O n e has w 1 = v2v3v4v5 E R 1. In fact, o n e w o u l d


o t h e r w i s e derive w - r a b c s or w - r d c b s f o r s o m e
r, s ~ A* such that Jr I >/ Iv1 ] = 11 a n d Is I >i Iv6 I
= 12. W e shall c o n s i d e r h e r e o n l y the first case
since the s e c o n d o n e can b e d e a l t with in an
a n a l o g o u s way. F r o m (1) a n d (2) o n e w o u l d h a v e
w - rabcs - r a b c d a d b d a c a d a b ~

d~
- ~ ( c d a d b d a c a d a b ) 2 g,

d~bll
Fig. 3. bA*~R 2.
130

r, s ~ A * ,

w h i c h is a c o n t r a d i c t i o n .
L e t us n o w s h o w that w: = v2v3v4 ~ R a. If it
were not true, o n e w o u l d h a v e w~ - tabs or wl -

Volume 22, Number 3

I N F O R M A T I O N PROCESSING LETTERS

tdcs f o r s o m e t, s ~ A*, Is[ ~ IvsI = 4 2 .


tabs, then by (3) a n d (4) o n e obtains

If w 1 -

s - sodcs,

g ~ A*,

IN I >/32,

dc~ ~ R ] ,

g - roab? ,

? E A*,

Ir [ >~ 22,

ab? ~ R~,

- sodcs',

s' E A*,

[s'[ >~ 12,

dcs' ~ R~,

s ' - roabr',

r'~ h*.

This yields the c o n t r a d i c t i o n


w 2 - t(abs0dcr 0)2abr'.
One arrives at a similar c o n t r a d i c t i o n w h e n w~ tdcs with Is I >~ 42.
Moreover, one has that v3 ff A * b A * . In fact,
one would otherwise have w 2 = rbs for some r, s
A* with I r I, I s I >/ Iv2 I = Iv41 = 8. Hence, in view
of (5) and (6), w 2 w o u l d c o n t a i n o n e of the factors
(bdacad)2b,

b d a c ( a d b d ) 2,

(dbda)2cadb,

(dbda)2dbd,

which is a contradiction.
By the s y m m e t r y of 0, o n e also has v3 ff A ' c A *
and, therefore, v3 ~ { a, d }*. This is a c o n t r a d i c t i o n
because v 3 is square-free a n d there exists n o
square-free w o r d of length larger t h a n 3 on a
two-letter alphabet. W e c o n c l u d e that R is finite
and, therefore, also L2(M(A, 0)) is finite.

3 March 1986

References

[1] J. Berstel, Sur les mots sans carr~ drfinis par un morphisme, in: Lecture Notes in Computer Science 71
(Springer, Berlin, 1979) 16-25.
[2] A. Bertoni, M. Brambilla, G. Mauri and N. Sabadini, An
application of the theory of free partially commutative
monoids: Asymptotic densities of trace languages, in: Lecture Notes in Computer Science 118 (Springer, Berlin,
198t) 205-215.
[3] P. Cartier and D. Foata, Probl~mes Combinatoires de
Commutation et Rdarrangements, Lecture Notes in
Mathematics 85 (Springer, Berlin, 1969).
[4] R. Cori and Y. Metivier, Rational subsets of some partially abelian monoids, Preprint No. 8418, U.E.R. de
Mathrmatiques et Informatique, Univ. de Bordeaux 1,
1984.
[5] R. Cori and D. Perrin, Sur la reconnaissabilit~ dans les
monoides partiellement commutatifs libres, RAIRO I.T.,
to appear.
[6] M. Crochemore, Sharp characterization of square-free
morphisms, Theoret. Comput. Sci. 18 (1982) 221-226.
[7] R. Dean, A sequence without repeats on x, x - l , y, v 1,
Amer. Math. Monthly 72 (1965) 383-385.
[8] M.R. Formisano, Mots infinis sans carr6 partiellement
abrliens sur trois lettres, Preprint No. 84.19, U.E.R. de
Mathrmatiques et Informatique, Univ. de Bordeaux 1,
1984.
[9] M. Lothaire, Combinatorics on Words, Encyclopedia of
Mathematics and its Applications 17 (Addison-Wesley,
Reading, MA, 1983).
[10] P. Pleasants, Nonrepetitive sequences, Proc. Cambridge
Phil. Soc. 68 (1970) 267-274.
[11] A. Thue, Ober unendliche Zeichenreihen, Norske Vid.
Selsk. Skr. 1. Mat. Nat. K1. Christiania 7 (1906) 1-22.
[12] A. Thue, Uber die gegenseitige Lage gleicher Teile gewisser
Zeichenreihen, Norske Vid. Selsk. Skr. I. Mat. Nat. KI.
Christiania 1 (1912) 1-67.

131

You might also like