Strongly qth Power–Free Strings

Strongly qth Power–Free Strings

Annals of Discrete Mathematics 17 (1983) 247-252 @ North-Holland Publishing Company STRONGLY qTH POWER-FREE STRINGS L.J. CUMMINGS Universify of Water...

372KB Sizes 0 Downloads 49 Views

Annals of Discrete Mathematics 17 (1983) 247-252 @ North-Holland Publishing Company

STRONGLY qTH POWER-FREE STRINGS L.J. CUMMINGS Universify of Waterloo, Waferloo, Ontario, Canada, N2L 3Gl It is shown that searching a string over a finite alphabet for ‘powers’ of a substring is made easier by searching for overlapping substrings instead. A proof is given that a string without overlapping substrings can always be extended with alphabet symbol provided only that it does not terminate in the square of a substring.

At the Second International Conference on Combinatorial Mathematics sponsored by the New York Academy of Sciences Read proposed the problem of enumerating all strings of length n over a finite alphabet which avoid repeated adjacent substrings [8]. The intimately related question of the existence of such strings and their construction has appeared in surprisingly diverse areas of mathematics. The Norwegian number theorist Thue wrote three fundamental papers on this topic [9], [lo], and [ l l ] early this century but his results were not widely circulated and have been frequently rediscovered. Thue’s first paper showed constructively the existence of an infinite string on 3 symbols which was ‘square-free’ [ll]. We remark that the construction of a square-free string a l . . a, over a finite alphabet 2 is equivalent to finding a colouring of M = (1,. . . ,m } with 2 colours such that not only will adjacent elements have different colours, but adjacent intervals will have distinct patterns of colours. This notion has been extended to obtain colourings of the integer lattice points in the Euclidean plane with the property that no two rectangles with a common edge will have the same colour pattern [l]. Indeed, it can be generalized to square-free and cube-free colourings of the class of all ordinals [8]. We consider only finite strings of the form

s = uoalu2.

* *

,

where the terms a, are taken from a finite set 2,called the alphabet. The length of I S I is denoted by I S I. For consideration of strings defined by ordinals other than the order type of the positive integers see [l] and [7]. The usual term ‘sequence’ is avoided here because we are interested in substrings of S which have the form B = &a,+,* * a i + k - l , 0 c i, 1 k,

-

247

L.J. Cummings

248

making the natural term 'subsequence' inappropriate. The substrings a. 0 s j are the initial substrings of S. We say that S contains B 2if, for some i,

* *

a,,

j = 0, 1,. . . ,k - 1.

&+, = U i + k + j ,

When q copies of B are adjacent in S we say that S contains B4. If S does not contain B 2for any substring B then S is square-free. A slightly weaker condition [6] has proved useful: S is strongly cube-free if S contains no substring of the form B2al . a, where a l . * a, is an initial substring of B. More generally, S is strongly (4 + 1)th power-free if it contains no substring of the form

-

B q a l . a,, r < I B 1,

(1)

with a l - - .a, a nonempty initial substring of B. Any strongly qth power-free string is (q + 1)st power-free. Fife [6] has given a method for generating all infinite strongly cube-free strings when r = 1. If A = a l * a, and B = bl * * b, are substrings of S then A overlaps B in k positions if

-

bl

= Un-k+l

'

* '

bk = a,.

If A = B then A is a self-overlapping substring which we call an (n,k)-substring. Theorem 1 proves that an (n,k ) substring induces a substring of the form (1). Proofs of the following three theorems appear in [3].

Theorem 1. If S is any string ouer a finite alphabet which contains an (n,k ) substring A = a l * * a, (1 < n ) then S contains the substring

B q a l . .* a,, where B = a ] ..

an-k

and

Here [XIdenotes the least integer strictly greater than x and 1x1 is the greatest integer less than or equal to x.

Corollary 1. Let S be a string ouer a finite alphabet containing an (n,k ) substring A = a l * a,. Then, (i) k = 1 implies S contains (al - U , - , ) ~ U ~ , (ii) k = n - 1 implies S contains a 7 +'. More generally than (ii) we have the following.

Corollary 2. Let S be a string ouer a finite alphabet containing an (n,k ) substring A = a l - * . a, then r = 0 if and only if n - k n.

1

Strongly qth power-free strings

249

Theorem 2. If a string S over a finite alphabet contains a substring P = B qa,. . . a, with 1 < 1 B 1, where a l * * a, is initial in B and 1 < q, then either (i) O < r, or (ii) O = r and 2 < q implies there is an (n, k ) substring inducing P. Theorem 3. If q = 2, then a string B 2 over a finite alphabet is induced by a self-overlapping substring if and only if B is periodic. Remark. If B 2 is induced by an ( n , k ) substring then B' is a*" for some a E C until n = 6 and k = 4. Theorem 3 shows that a square cannot in general be detected by searching for self-overlapping substrings. However, any strongly cube-free string can be detected in this way. If q = 2, then from Theorem 1 we see that p s n < 2 p where p = n - k. It follows that 2k < n. Accordingly, if we wish to search for substrings of the form (1) with q = 2 (and in light of Theorem 3, 0 < r ) we need only search for (n, k ) substrings with k s Ln/2J. More generally, for any q it follows easily that

Unfortunately, this is not immediately useful since we cannot assume, a priori, knowledge o f n, the length of the overlapping substring. If a string of length n is to be searched for a substring of the form (1) and only q is assumed to be given, the following theorem gives bounds on n and k for possible (n,k ) substrings.

Theorem 4. If a string of length m contains an (n,k ) substring then l U ¶ A c n Sr + m ( q - 1 ) 4 4

7

(2)

Proof. As in Theorem 1 , the occurrence of an (n,k ) substring in a string S of length m induces a substring

B4a1. - a,, 1 < q, 0 < r < n

- k,

-

where B = a , * a n - k .Since a string of length n overlapping itself in k positions creates a string of length 2n - k we have

2n - k = q ( n - k ) + r.

(4)

L..I Cummings .

250

Rewriting (4) we obtain (2 - q ) n

+ (q - l)k

= r.

Viewing (5) as a Diophantine equation in n and k, the general solution is given by the equations

n=r+a(q-l),

k

=T

+

(Y

(4 - 2),

I

ff

= 0 , + 1 , ... .

Now 1 S k < n implies a# 0. Since our string has length rn we have 3 s 2n - k S rn which implies

Using (6) we obtain (2) and similarly, 2n - rn

S

k G 2 n implies (3).

Suppose we wish to search an arbitrary string S = al * * a, for the occurrence of a pattern (1) where q is kept fixed. If (1) is induced by an (n,k)-substring of S then necessarily the affected portion of S has length t = 2 n - k = qb

+r,

where b denotes I B 1. The proof of Theorem 1 implies n - k = b. Accordingly (7) yields

n

= (q - 1)b

+ r.

(7)

(8)

Since k = n - b we further see that

k = (q - 2)b + r.

(9)

First, suppose we search the string S of length rn directly for the occurrence of (1). We must therefore test the first rn - t + 1 symbols of S as possible starting symbols of (1). For each successive choice of the starting symbol we can make the r(q + 1) comparisons &+j+w

= &+&+j,

j = 1,. . .,r ; w

-

=o,. ..,q,

(10)

involving the ‘remainder’ & + @ + I * * a+@+, first. The remaining (b - r)q comparisons necessary in the worst case are Ui+j+k

= Ui+wb+j,

i = r -k 1 , . . .,b, W = 0,. . ., q - 1.

Fig. 1.

(1 1)

Strongly qth power-free strings

25 1

The number of comparisons involved in (10) and ( 1 1 ) is therefore

(m-t

+ l ) [ r ( q+ 1 ) +

( b - r ) q ] = ( m - t + 1)t.

Now suppose we search S for the occurrence of an ( n - k)-substring where n and k have been determined by equations (2) and (3). Accordingly we consider the first m - t 1 symbols of S as possible starting symbols of the (n, k)substring and make the comparisons

+

a.,+, . = a ., + m - k + j ,

j = 1 ,..., m,

in each case. Now the total number of comparisons is just

(m-t

+ l)n,

and we see that there are ( n - t + l ) b fewer comparisons required in searching for an (n, k)-substring than in searching directly for ( 1 ) . Dekking [ 6 ] has shown that any infinite string over ( 0 , l ) without overlapping substrings is progressively repetitive; i.e., contains squares B Zfor arbitrarily long substrings B. In Theorem 5 it is shown that strongly qth power-free strings are easily constructed without considering the algebraic machinery of morphisms. Berstel [2] has shown that it is decidable whether a string of arbitrary length constructed by iteration of a morphism is square-free. Theorem 5 is further evidence of the limitations of constructive techniques which use morphisms. Theorem 5. Any string without self-overlapping substrings which does not terminate in a square can be extended by an arbitrary alphabet symbol to a string with the same property. Proof. Let S be such a string, but suppose that Sx has an ( n , k ) substring a , . . a. for some x E 2. By Theorem 1 , Sx contains a substring of the form ( 1 ) . If 1 < k it follows that a l * a,-l would be an ( n - 1 , k - 1 ) self-overlapping substring of S, contrary to assumption. But when k = 1 we have a, = a t and

-

S=*

*

+

al

* *

a,-lal * . * an-i,

contradicting the assumption that S did not terminate in a square. References [ I ] D.R. Bean, A. Ehrenfeucht and G.F. McNulty, Avoidable patterns in string of symbols. Pacific

J. Math. 85 (1979) 261-294. [2] J. Berstel, Sur les mots sans carre definis par un morphisme, Proc. of the 6th Internat. Coll. on Automata, Languages and Programming, Lecture Notes in Computer Science, No. 71 (Springer, Berlin, 1979) pp. 16-29.

252

L.J. Cummings

[3] L.J. Cummings, Overlapping substrings and Thue’s problem, Proc. of the 3rd Caribbean Conf. in Combinatorics and Computing (University of the West Indies, Cave Hill, 1981) pp. 99-109. [4] F.M. Dekking, On repetitions of blocks in binary sequences, J. Comb. Theory, Ser. A 20 (1976) 292-299. [ 5 ) F.M. Dekking, Strongly non-repetitive sequences and progression-free sets, J. Comh. Theory, Ser. A 27 (1979) 181-185. [6] E.D. Fife, Binary sequences which contain no BBb, Trans. Amer. Math. SOC.261 (1980) 115-136. [7] J. Larson, R. Laver and G. McNulty, Square-free and cube-free colorings of the ordinals, Pacific J. Math. 89 (1980) 137-141. [8] R.C. Read, Problem no. 32,Znd Internat. Conf. on Combinatorial Mathematics, Annals of the N.Y. Academy of Sciences, Vol. 319 (N.Y. Academy of Sciences, New York, 1979). [9] A. Thue, Uber unendliche Zeichenreihen, T. Nagell, I. Selberg, S. Selbert and K. Thalberg, eds., Selected Mathematical Papers of Axel Thue (Universitetsforlaget Oslo-Bergen-Troms, 1977) pp. 139-158. [lo] A. Thue, Uber du gegenseitige Lage gleischer Teile gewisser Zeichenreihen, ibid., pp. 413-477. [ 111 A. Thue, Probleme uber Veranderungen von Zeichenreihen nach gegebenen Regeln, ibid., pp. 493-524.