Abstract 1 Introduction 2 Preliminaries 3 Lower Bound 4 Upper Bound 5 Limitations of our Approach 6 Final Remarks References

Improved Bounds on the Maximum Number of Distinct Squares in Circular Words

Panagiotis Charalampopoulos ORCID King’s College London, UK    Manal Mohamed ORCID King’s College London, UK    Jakub Radoszewski ORCID University of Warsaw, Poland    Wojciech Rytter ORCID University of Warsaw, Poland    Tomasz Waleń ORCID University of Warsaw, Poland    Wiktor Zuba ORCID University of Warsaw, Poland
Abstract

We investigate the asymptotic growth of function 𝖢𝖲(n), which maps n to the maximum number of distinct squares in a circular word of length n (that is, the maximum number of distinct squares of length at most n in a word ww of length 2n). We improve upon the lower bound of 1.25n established by Amit and Gawrychowski [SPIRE 2017] and the straightforward upper bound of 2n, which follows from the recent result of Brlek and Li [Comb. Theory, 2025] stating that there are fewer than n squares in standard (i.e., non-circular) words of length n. (Previously, Amit and Gawrychowski gave an upper bound of 3215n using a weaker upper bound on squares in standard words.) Specifically, we show that 𝖢𝖲(n) 1.8n and that, for infinitely many n, 𝖢𝖲(n) 1.5n𝒪(n).

For the lower bound, we exploit the combinatorial structure of Fibonacci words to construct a family of square-rich circular words. For the upper bound, we exploit density properties of the starting positions of long squares, adapting an approach of Amit and Gawrychowski.

Keywords and phrases:
circular words, squares, repetitions
Funding:
Jakub Radoszewski: Supported by the Polish National Science Center, grant no. 2022/46/E/ST6/00463.
Copyright and License:
[Uncaptioned image] © Panagiotis Charalampopoulos, Manal Mohamed, Jakub Radoszewski, Wojciech Rytter,
Tomasz Waleń, and Wiktor Zuba; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Mathematics of computing Combinatorics on words
Editors:
Philip Bille and Nicola Prezza

1 Introduction

The study of square and symmetric fragments of words is central in combinatorics and algorithms on words. A square is a word of the form uu for a word u. Here, we focus on square fragments of circular words. That is, for a standard word w, we study the square fragments that occur in any rotation of w or, equivalently, the square fragments of ww that are of length at most |w|.

The earliest result concerning squares in words is the construction of square-free ternary words of all lengths by Thue [19]. The analogue of this problem for circular words is more intricate. Currie [4] showed that square-free circular words over the ternary alphabet exist for all lengths except for 5, 7, 9, 10, 14, and 17 using a computer-aided proof. Shur [16] later gave a computer-free proof that also implied an exponential (in the length) lower bound on the number of such words of any fixed length.

Let 𝖲𝖰(n) be the maximum number of distinct squares in a (standard) word of length n. Fraenkel and Simpson [7] proved that 𝖲𝖰(n)<2n and conjectured that 𝖲𝖰(n)<n. The resolution of this conjecture took more than two decades. Milestone results include the upper bound of 2nlogn due to Ilie [9], the upper bound of 116n due to Deza, Franek, and Thierry [5], and the upper bound of 1.5n due to Thierry [18]. Finally, Brlek and Li [3] confirmed the Fraenkel-Simpson conjecture using a graph-theoretic approach, establishing that 𝖲𝖰(n)<n.

Let 𝖢𝖲(n) denote the maximum number of distinct squares in a circular word of length n. The growth of 𝖢𝖲(n) was first studied by Amit and Gawrychowski [1] who showed an upper bound of 3215n and a lower bound of 1.25n (for infinitely many n). Note that this work was published when the best known upper bound for standard squares was 𝖲𝖰(n)116n. Further, observe that the number of squares of length at most n in a word ww is at most 𝖲𝖰(2|w|). The result of Brlek and Li [3] thus implies that 𝖢𝖲(n)𝖲𝖰(2n)<2n.

Our results.

Here, we improve upon both the upper bound of 2n that follows from [3] and the lower bound of 1.25n from [1] for 𝖢𝖲(n). Specifically, we show that 𝖢𝖲(n)1.8n for all n and that 𝖢𝖲(n)1.5n𝒪(n) for infinitely many n.

Our lower and upper bounds are presented in Section 3 and Section 4, respectively. Then, Section 5 discusses the limitations of our approach.

Discussion.

As we remark at the end of Section 4, the proof of the 3215n upper bound of Amit and Gawrychowski could be modified to yield an upper bound of 137n by incorporating the upper bound of n for standard squares. However, the resulting argument remains technically involved. We establish a stronger upper bound of 1.8n and also a (still stronger) upper bound of 116n which is considerably simpler.

2 Preliminaries

A word u=u[0]u[n1] is a sequence of length |u|=n of letters from some alphabet. For any two integers i,j[0..|u|), u[i..j] and u[i..j+1) denote the fragment u[i]u[j] if ij and the empty word otherwise. A fragment u[0..j] is called a prefix of u. A prefix of u is called a proper prefix of u if its length is smaller than n. A fragment u[i..n1] is called a suffix of u.

We say that integer p[1..|u|] is a period of a word u if u[i]=u[i+p] for all i[0..|u|p). We denote the smallest period of u by per(u). We say that u is periodic if per(u)12|u|; otherwise u is called non-periodic.

Lemma 1 (Periodicity Lemma [6]).

If a word u has periods p and q such that p+q|u|+gcd(p,q), then gcd(p,q) is also a period of u.

A word u is called primitive if the equality u=vk for a positive integer k implies that k=1. Primitive words satisfy the following synchronization property that follows from the periodicity lemma: a primitive word u occurs in u2 only as a prefix and as a suffix.

For a word u, for any integer i[0..|u|), we call u[i..|u|)u[0..i) a rotation of u.

For a word w, we denote by 𝐒n(w) the set of squares of length at most n that occur w. Thus, the set of squares of a circular word w equals 𝐒n(w2), where n=|w|.

Fibonacci words are defined by the recurrence

F0=b,F1=a,Ft=Ft1Ft2 for t2.

The number of distinct squares in the (standard) word Fn is equal to 2|Fn2|2; see [8]. As a warm-up, we show an exact bound on the number of squares in circular Fibonacci words.

Fact 2.

If n2, |𝐒|Fn|(FnFn)|=|Fn|2.

Proof.

Every square in Fn is a square of a rotation of some shorter Fibonacci word; see [10, Theorem 2.3]. The same holds for Fn2 since Fn2 is a prefix of the infinite Fibonacci word for n3, and for n2 it can be easily verified.

For n=2, we have 𝐒|Fn|(FnFn)= as expected. Assume n3. The set 𝐒|Fn|(Fn2) does not contain F02=bb and Fn12 (because 2|Fn1|>|Fn|). Let us show by induction that for all k[1..n2], each rotation of Fk2 occurs in Fn2. Correctness in the base cases of n{3,4} can be easily checked. Assume that n5 and the property holds for n1. By the hypothesis, Fn12 contains all rotations of Fk2 for k[1..n3]. Since n4, Fn12 is a prefix of Fn2, so all these squares are also in 𝐒|Fn|(Fn2). Moreover, Fn has a suffix Fn2 and a prefix Fn22 (since n23). Hence, Fn2 has a fragment Fn23, so each rotation of Fn22 occurs in Fn2.

In total, we obtain |F1|+|F2|++|Fn2|=|Fn|2 squares. All these squares are different because each Fibonacci word is primitive.

Example 3.

We have

F2=ab,F3=aba,F4=abaab,F5=abaababa,F6=abaababaabaab.

For F6, we have

𝐒13(F6)={a2,(ab)2,(ba)2,(aba)2,(aab)2,(baa)2,(abaab)2,(baaba)2},

and

𝐒13(F62)=𝐒n(F6){(aabab)2,(ababa)2,(babaa)2}.

In particular, F6 has 8=2|F3|2 distinct squares, while the circular F6 contains 11=|F6|2 distinct squares in total.

3 Lower Bound

We use Fibonacci words as building blocks. For any word v of length at least two, let 𝐜𝐮𝐭(v):=v[0..|v|2) be the word obtained from v by deleting its two last letters. Let 𝐞𝐱(v) denote the word v with the last two letter exchanged, that is, 𝐞𝐱(v):=𝐜𝐮𝐭(v)v[|v|1]v[|v|2].

Example 4.

𝐜𝐮𝐭(abcde)=abc and 𝐞𝐱(abcd)=abdc.

The following (folklore) property of Fibonacci words follows by a straightforward inductive argument.

Observation 5.

For t2, we have 𝐜𝐮𝐭(Ft)=𝐜𝐮𝐭(Ft2Ft1) and 𝐞𝐱(Ft)=Ft2Ft1.

The next observation follows directly from the synchronization property of primitive words; see Figure 1.

Figure 1: Illustration of Observation 6(a). For the primitive word u=abcd and its proper prefix u=ab, the word u2u contains |u|+1 distinct squares of length |u2|: (abcd)2, (bcda)2, (cdab)2.
Figure 2: The structure of 𝒲k,t for k=2 and t2: 𝒲k,t=A2BA3BA4B, where A=Ft and B=Ft1. We have 𝒲k,t=(AABA)2AABA, where A=𝐞𝐱(A). We have α=|Ftk|=2|A| and |𝒲2,t|=3α+3|AB|.
Observation 6 (Squares in periodic fragments).
  1. (a)

    If u is a proper prefix of a primitive word u, then uuu contains |u|+1 distinct squares of length |uu|.

  2. (b)

    uk contains at least k12|u| words that are rotations of words in {u2j1j12k} and are pairwise distinct.

Before describing our construction, we first identify the primitive roots of the squares under consideration. These roots correspond to rotations of squares of words of the following types.

Observation 7 (Primitive words).

For any i>0 and t1, the words Ft1,FtiFt1, and FtiFt1Ft are primitive.

Proof.

For any t1, words Ft1 and FtkFt1 are standard Sturmian words for k1. Since every standard Sturmian word is primitive (cf. [15]), it follows that all words of the form Ft1 and FtiFt1 are primitive. Moreover, since any rotation of a primitive word is primitive, the word FtiFt1Ft is primitive as its rotation Fti+1Ft1 is primitive.

The construction.

We define an infinite family of words. For any k,t+, let

𝒲k,t:=FtkFt1Ftk+1Ft1Ftk+2Ft1.

Note that 𝒲k,t is parametrized by both k and t (eventually, we will set k:=|Ft|), and let n:=|𝒲k,t|. For convenience, we express bounds on the lengths of fragments and the number of square fragments in terms of

α:=|Ftk|=k|Ft|.

Note that we have

|𝒲k,t|=(3k+3)|Ft|+3|Ft1|= 3α+ 3|Ft+1|. (1)

Squares in 𝓦𝒌,𝒕 and 𝓦𝒌,𝒕𝟐.

We show that the words 𝒲k,t are almost cubes (except the last two letters); see Figure 2 for an illustration.

Lemma 8.

For all k,t+, we have that 𝐜𝐮𝐭(𝒲k,t)=𝐜𝐮𝐭((FtkFt1Ft)3). Further, 𝒲k,t contains at least α distinct squares which are rotations of (Ftk+1Ft1)2.

Proof.

We have

𝒲k,t=FtkFt1Ftk+1Ft1Ftk+2Ft1=(FtkFt1Ft)(FtkFt1Ft)FtkFtFt1.

By Observation 5,

𝐜𝐮𝐭(𝒲k,t)=(FtkFt1Ft)(FtkFt1Ft)(Ftk𝐜𝐮𝐭(Ft1Ft))=𝐜𝐮𝐭((FtkFt1Ft)3).

Hence, 𝐜𝐮𝐭((FtkFt1Ft)3) is a prefix of 𝒲k,t. Now, FtkFt1Ft is primitive due to Observation 7 and the second part of the statement follows by a direct application of Observation 6.

Lemma 9.

If t2 and k>0, 𝒲k,t2 contains more than 2α distinct squares that are rotations of (FtkFt1)2 and (Ftk+2Ft1)2.

Proof.

We denote 1:=(FtkFt1)3 and 2:=(Ftk+1Ft1Ft)2Ftk. We show that both 1 and 2 occur in 𝒲k,t2; see Figure 3. Then we obtain the statement using Observation 7 and Observation 6.

Figure 3: Illustration of Lemma 9: Structure of 𝒲k,t2 for k=3. The upper periodic fragment 1=(FtkFt1)3 in 𝒲3,t2 does not occur in 𝒲3,t. The lower periodic fragment is 2=(Ftk+1Ft1Ft)2Ftk. Together, these two periodic fragments contain at least 2α distinct squares of length at most n.

We first show that 1 occurs in 𝒲k,t2. The word

𝒲k,t2=FtkFt1Ftk+1Ft1 Ftk+2Ft1FtkFt1Ftk+1Ft1Ftk+2Ft1

has a fragment equal to Ftk+2Ft1FtkFt1Ftk+1, which in turn has a fragment equal to (FtkFt1)(FtkFt1)FtkFt1=1. Thus, 𝒲k,t2 contains more than α distinct squares which are rotations of (FtkFt1)2.

Next, we show that 2 occurs in 𝒲k,t2. The word

𝒲k,t2=FtkFt1 Ftk+1Ft1Ftk+2Ft1FtkFt1Ftk+1Ft1Ftk+2Ft1

contains a fragment equal to

Ftk+1Ft1FtFtk+1Ft1FtFtk1Ft1Ftk+1

which itself has a fragment equal to

(Ftk+1Ft1Ft)(Ftk+1Ft1Ft)Ftk1Ft1Ft

which is equal to 𝐞𝐱((Ftk+1Ft1Ft)2FtkFt1), since Ft1Ft=𝐞𝐱(FtFt1). Now, observe that 2=(Ftk+1Ft1Ft)2Ftk is a prefix of this fragment. Thus 𝒲k,t2 contains |Ftk|+1=α+1 distinct squares which are rotations of (Ftk+1Ft1Ft)2.

Since FtkFt1 and Ftk+2Ft1 have different lengths, all considered square fragments are distinct and this concludes the proof.

Lemma 10.

If k|Ft| then 𝒲k,t contains at least α𝒪(|Ft|) distinct squares which are rotations of (FtjFt1)2 for 0<j<k.

Proof.

The word 𝒲k,t contains the fragment Ftk+1Ft1Ftk+2; see Figure 4. For each jk it contains the fragment

FtjFt1Ftj+2= FtjFt1FtjFt1Ft2Ft1Ft2=FtjFt1FtjFt1𝐞𝐱(Ft1Ft2)Ft2,

which contains the fragment (FtjFt1)2𝐜𝐮𝐭(Ft).

By Observations 6 and 7, each such fragment, (FtjFt1)2𝐜𝐮𝐭(Ft), contains |𝐜𝐮𝐭(Ft)|+1=|Ft|1 distinct squares that are rotations of (FtjFt1)2.

Summing over all 0<j<k, we obtain at least (|Ft|1)(k1)=α𝒪(|Ft|) distinct squares of the claimed form.

Figure 4: Illustration of Lemma 10. For k=4,t=4, let A=Ft=abaab,B=Ft1=aba, and C=𝐜𝐮𝐭(Ft)=aba. Then 𝒲k,t contains the fragment FtkFt1Ftk+2, which in turn contains the fragments (AjB)2C, for 1jk. Each of these fragments implies |C|+1=|Ft|1 squares. Altogether (including the case j=0), they contain (|Ft|1)k+|Ft1| squares, but Lemma 10 excludes the squares generated for j=0 and j=k to avoid double counting.

The fact that Ftk+2 occurs in 𝒲k,t and Observations 6 and 7 imply the following:

Lemma 11.

𝒲k,t contains at least 12α distinct squares that are rotations of the words in {Ft2j1jk+22}.

We are now ready to prove the main result of this section.

Theorem 12.

There are infinitely many integers n for which 𝖢𝖲(n)1.5n𝒪(n).

Proof.

Let us set k:=|Ft|. Then α=k2 and |Ft|=𝒪(n). From Equation 1, the length of 𝒲k,t is n=3α+𝒪(n) and hence α=13n𝒪(n).

By Lemmas 8, 9, 10, and 11, the word 𝒲k,t2 contains at least 4.5αΘ(|Ft|) squares (of length at most n). They are all distinct. Indeed, the squares from Lemmas 8, 9, and 10 are rotations of (FtjFt1)2, for different j[1..k+2], so they have different lengths for different j. The squares from Lemma 11 are of the form (Ftj)2 for jk, and we have |Ftj1Ft1|<|Ftj|<|FtjFt1|.

Therefore, the circular word 𝒲k,t contains

4.5(13n𝒪(n))= 1.5n𝒪(n)

distinct squares, as required.

4 Upper Bound

Let us fix a word w of length n. We denote w~=ww. Our aim is to show that |𝐒n(w~)|1.8n.

High-level idea of the proof.

If there exists a fragment (a δ-window) of w of (small) length δ that contains no starting position of a long square, then it is easy to show that there are at most 2nδ distinct squares in the circular word w. If no such fragment exists, we call w δ-dense. Hence, we reduce the problem to showing that primitive δ-dense words do not exist – a simple upper bound of 1.5n can be shown for non-primitive words. We view a square uu as a “transporter” which shifts long fragments of w by |u| positions (from the first copy of u to the second one). By choosing a long non-periodic fragment (called a sample) s, we consider only those distances |u| that correspond to the distances between occurrences of the sample in ww which start in the first copy of w. The number of these occurrences is very small (bounded by a constant). Then, using samples, we show that if w is primitive, then w is not δ-dense.

Observation 13.

If w is a rotation of w, then 𝐒n(ww)=𝐒n(ww).

Lemma 14.

If w is a rotation of w that is not primitive, then |𝐒n(w~)|1.5n.

Proof.

Suppose w=uk for some integer k2. Then 𝐒n(w~)=𝐒n(ww)=𝐒n(uw). Consequently, due to [3], we have |𝐒n(w~)|=|𝐒n(uw)||u|+|w|=(1+1k)n. Since k2, it follows that |𝐒n(w~)|1.5n.

Corollary 15.

If w~ contains a square of length exactly n, then |𝐒n(w~)|1.5n.

By the above corollary, we may henceforth assume that w is primitive and w~ does not contain any square of length n.

 Remark 16.

Circular words that are themselves squares can still contain many squares. It was shown in [1] that there exists an infinite family of words wk, each of which is a square, such that 𝐒n(wkwk)1.25|wk|o(|wk|).

Definition 17.

Let w be a word of length n. A square fragment uu starting at position j in w is called a δ-square fragment with respect to an interval [i..i+δ) if

ij<i+δandn(ji)<|uu|<n. (2)

Observe that if j<δ is the last occurrence in ww of a square uu, then uu is a δ-square with respect to the interval I=[0..δ).

Definition 18.

A word w is called δ-dense if, for every length-δ fragment I of w, there exists a δ-square fragment with respect to I. (See Figure 5.)

Figure 5: Illustration of the notion of δ-density. The shown word is a prefix of w[i..). Here, uu is a δ-square fragment with respect to the interval I=[i..i+δ) (shown in blue): there exists a position j in the interval I where a square uu starts and satisfies |uu|+(ji)>n. The word w is δ-dense if such a square uu exists for each interval [i..i+δ) with i+.

We first consider the easy case when w~ is not δ-dense.

Lemma 19 (Upper bound for words that are not δ-dense).

If w~ is not δ-dense, where 0<δ12n, then |𝐒n(w~)|2nδ.

Proof.

By Corollary 15, if w~ contains a square fragment of length exactly n, |𝐒n(w~)|1.5n. Henceforth we assume that w~ does not have such a fragment. Since w~ is not δ-dense, by the definition, there exists an interval I=[i..i+δ) in w such that no δ-square fragment exists with respect to I. That is, for every square fragment uu starting at some position jI, |uu|<n(ji). Equivalently, the longest square starting at any position qI has length at most n(qi). After a rotation (cf. Observation 13), we may assume that i=0, so that I=[0..δ). Now, let us consider the suffix w~ of w~ of length 2nδ. Every square fragment of w~ occurs entirely within w~. Therefore, all distinct squares appear in a fragment of length 2nδ. The combination of this fact and the result of [3] implies that |𝐒n(w~)|2nδ.

Our aim is to show that no δ-dense words exist when w is primitive and δ is sufficiently small.

The next lemma states that each fragment of w~ of length 12nδ has a copy to its right at a well-specified distance d. See Figure 6 for an illustration.

Lemma 20 (Transporting Lemma).

Assume w is δ-dense with positive integer δ12n. Let F be a fragment of length at most 12nδ that occurs at some position in in w. Then, F also occurs in w at position i+ for some (12(nδ)..12n).

Proof.

Since w is δ-dense, there exists a position j in (iδ..i] where a δ-square fragment x=uu occurs in w. By the definition of a δ-square, its total length satisfies n(j(iδ))<|uu|<n. It follows that the half-length |u| satisfies 12(nδ)<|u|<12n.

By Equation 2, the square x=uu ends at a position ziδ+n, so the first half u of the square ends at a position ziδ+12ni+|F|. Therefore the fragment F is completely contained within u. The second half of x also contains a copy of F shifted by a distance |u|. Therefore, F also occurs at position i+|u|.

Figure 6: Illustration of the Transporting Lemma (Lemma 20). The sample is shown in blue, and the δ-length interval with respect to which the δ-square occurs is shown in red.

We use the following fact from [1], whose proof relies on the periodicity lemma.

Fact 21 ([1, Lemma 4]).

Let w be a word and let a and b be letters. If both aw and wb are periodic, then they have the same period.

Corollary 22.

If w is primitive and [1..n], then w~ contains a non-periodic fragment 𝐬 of length . We refer to this as an -sample.

Proof.

Let us assume that w~ does not contain a non-periodic fragment of length . Then, by Fact 21, all length- fragments of ww are periodic with the same period, i.e., the whole w~ has a period at most 12. By the periodicity lemma (Lemma 1), w~=ww has a period p such that p12n and p divides n. Hence, w is non-primitive.

We show that, for every primitive word w, w~ is not δ-dense for a certain parameter δ0.5n. Together with Lemmas 14 and 19, this implies that |𝐒n(w~)|2nδ.

Simple Upper Bound

First we give a simple and intuitive proof for δ=16n.

Lemma 23.

If w is primitive and n=|w|6, then w~ is not 16n-dense.

Proof.

We prove this by contradiction. Assume that w~ is 16n-dense. Let 𝐬 be a 13n-sample that is non-periodic (as guaranteed by Corollary 22). After a suitable rotation of ww, we can assume that 𝐬 occurs at positions 0 and n. Due to Lemma 20, 𝐬 also occurs at position i=d+d, where d,d(1256n..12n); see Figure 7. Consequently, 𝐬 occurs at distinct positions n and i that are at distance at most 16n|𝐬|/2. Hence, 𝐬 is periodic, a contradiction.

Figure 7: Illustration of the proof of Lemma 23.

Lemmas 14, 19, and 23 imply that 𝖢𝖲(n)2n16n=116n, after a trivial verification of the cases when n<6.

Stronger Upper Bound

Next, we strengthen the upper bound using a more refined argument.

Lemma 24.

If w is primitive, with n=|w|5, then w~ is not 0.2n-dense.

Proof.

We prove this by contradiction. Assume that w~ is δ-dense for δ=0.2n. Let 𝐬 be a non-periodic sample of length =0.3n, (as guaranteed by Corollary 22, since 1 for n4). Let 𝐀 denote the set of starting positions of 𝐬 in ww.

After a suitable rotation of ww, we may assume that positions 0 and n belong to 𝐀. Let 𝐀=𝐀[0..n), 𝐀={a0,,a|𝐀|1} with a0<<a|𝐀|1 and define i=a(i+1)mod|𝐀|ai for i[0..|𝐀|).

For each occurrence at position ai, let di be the shift distance given by the Transporting-Lemma (Lemma 20). This lemma applies since +δ12n, and it ensures that di(120.8n..0.5n).

Then, there exists some i[0..|𝐀|) such that (ai+di)modn=ai. We denote 𝗌𝗎𝖼𝖼(i):=i, we define 𝗌𝗎𝖼𝖼(i):=𝗌𝗎𝖼𝖼(imod|𝐀|).

Claim 25.

For each i[0..|𝐀|), 𝗌𝗎𝖼𝖼(𝗌𝗎𝖼𝖼(i))=(i1)modn and i(0.15n..0.2n).

Proof.

Let 𝗌𝗎𝖼𝖼(i)=i and 𝗌𝗎𝖼𝖼(i)=i′′. The sum of two consecutive shift distances di+di(0.8n..n). Hence, ai+di+di<ai+n, and there is no occurrence of 𝐬 in w between ai+di+di and ai+n; otherwise, 𝐬 would be periodic. Therefore, 𝗌𝗎𝖼𝖼(𝗌𝗎𝖼𝖼(i))=(i1)modn. Moreover,

(i1)modnn(0.8n+1)<0.2n,as claimed.

Claim 26.

For each i[0..|𝐀|), 𝗌𝗎𝖼𝖼(i)=(i+3)modn.

Proof.

Each shift di from the Transporting-Lemma lies in (0.4n..0.5n) (as 120.8n120.8n), while each i lies in interval (0.15n..0.2n) by Claim 25.

Since 20.2n0.4n<di<0.5n<40.15n, each shift spans exactly three intervals. Hence, 𝗌𝗎𝖼𝖼(i)=(i+3)modn.

The interval bounds from Claim 25 imply that |𝐀|=6. But then, by Claim 26, 𝗌𝗎𝖼𝖼(𝗌𝗎𝖼𝖼(0))|𝐀|1, contradicting Claim 25. This completes the proof.

By Lemmas 14, 19, and 24, we obtain the upper bound 𝖢𝖲(n)2n0.2n=1.8n, after a trivial verification of the cases when n<5.

Theorem 27.

𝖢𝖲(n)1.8n.

 Remark 28.

If we used the sample size 0.25n as in [1], we would obtain a weaker upper bound of 137n.

5 Limitations of our Approach

It appears that by taking larger values of δ, one could possibly strengthen Lemma 24, showing that every primitive word is not δ-dense, and thereby obtaining a stronger upper bound of 2nδ. However, we show that for δ=13n+4 this approach no longer works.

We say that a square uu kills a position i in w if uu is a δ-square fragment with respect to the interval [i..i+δ).

Observation 29.
  1. (a)

    A square uu such that n(δ1)<|uu|<n starting at position j in w kills all positions contained modulo n in the interval [j(δ1)..j+|uu|n).

  2. (b)

    For a periodic fragment R with n(δ1)<2per(R)<n starting at position j in w, all positions contained modulo n in the interval

    IR=[j(δ1)..j+|R|n1] (3)

    are killed by the |R|2per(R)+1 squares of length 2per(R) that are induced by R; see Figure 8.

Figure 8: Let w=a4ba5ba6b (fragment shown in brown) and δ=10. The figure shows a word (w)2 for a rotation w of w. The square fragments in w induced by the periodic fragment R (shown in red) together kill all positions contained modulo n in the interval IR indicated by the yellow rectangle.
Fact 30.

There exist arbitrarily long primitive words w that are δ-dense for δ=13|w|+4.

Proof.

Let us take 𝒲k,1=akbak+1bak+2b of length n=3k+6 and δ=k+6=13n+4. Using Equation 3, it is easy to see that each position of 𝒲k,1 is killed by one of the following three periodic fragments:

  • The fragment R1=(akba)2ak occurring at position 0 kills positions in the interval

    [0(k+5).. 0+(3k+4)n1]modn[2k+1..n3].
  • The fragment R2=(ak+1ba)2ak1 occurring at position k+1 kills positions in the interval

    [(k+1)(k+5)..(k+1)+(3k+5)n1]modn[n4..n1][0..k1];

    cf. Figure 8.

  • The fragment R3=(akb)2ak occurring at position 2k+5 kills positions in the interval

    [(2k+5)(k+5)..(2k+5)+(3k+2)n1]modn[k..2k].

The union of the intervals [0..k1], [k..2k], [2k+1..n3], and [n4..n1] covers all positions in 𝒲k,1. This implies that every position is killed by a suitable δ-square fragment. Hence, 𝒲k,1 is δ-dense.

6 Final Remarks

We have shown that 1.5n𝒪(n)𝖢𝖲(n)1.8n, where the lower bound holds for infinitely many n. We conjecture that the lower bound is tight, that is, that 𝖢𝖲(n)1.5n.

Tight bounds related to repetitions and symmetries are usually non-trivial. This was, for instance, the case for bounds on standard squares (see [7, 9, 12, 5, 18, 3]) and powers ([11, 13, 14]), runs (the “runs theorem”; see [2] and references therein), and palindromes in circular words ([17]). For example, the abstract of [17] states: “In this paper we show, with a very complicated proof, …”).

Possibly, the elegant graph-theoretic proof of the recent upper bound for standard squares in [3] can be adapted to establish an 1.5n upper bound for distinct squares in circular words.

References

  • [1] Mika Amit and Pawel Gawrychowski. Distinct squares in circular words. In String Processing and Information Retrieval - 24th International Symposium, SPIRE 2017, volume 10508 of Lecture Notes in Computer Science, pages 27–37. Springer, 2017. doi:10.1007/978-3-319-67428-5_3.
  • [2] Hideo Bannai, Tomohiro I, Shunsuke Inenaga, Yuto Nakashima, Masayuki Takeda, and Kazuya Tsuruta. The "runs" theorem. SIAM Journal on Computing, 46(5):1501–1514, 2017. doi:10.1137/15M1011032.
  • [3] Srecko Brlek and Shuo Li. On the number of squares in a finite word. Combinatorial Theory, 5(1), 2025. doi:10.5070/C65165014.
  • [4] James D. Currie. There are ternary circular square-free words of length n for n >= 18. Electronic Journal of Combinatorics, 9(1), 2002. doi:10.37236/1671.
  • [5] Antoine Deza, Frantisek Franek, and Adrien Thierry. How many double squares can a string contain? Discrete Applied Mathematics, 180:52–69, 2015. doi:10.1016/J.DAM.2014.08.016.
  • [6] Nathan J. Fine and Herbert S. Wilf. Uniqueness theorems for periodic functions. Proceedings of the American Mathematical Society, 16(1):109–114, 1965. doi:10.2307/2034009.
  • [7] Aviezri S. Fraenkel and Jamie Simpson. How many squares can a string contain? Journal of Combinatorial Theory, Series A, 82(1):112–120, 1998. doi:10.1006/JCTA.1997.2843.
  • [8] Aviezri S. Fraenkel and Jamie Simpson. The exact number of squares in Fibonacci words. Theoretical Computer Science, 218(1):95–106, 1999. doi:10.1016/S0304-3975(98)00252-7.
  • [9] Lucian Ilie. A note on the number of squares in a word. Theoretical Computer Science, 380(3):373–376, 2007. doi:10.1016/J.TCS.2007.03.025.
  • [10] Costas S. Iliopoulos, Dennis W. G. Moore, and William F. Smyth. A characterization of the squares in a Fibonacci string. Theoretical Computer Science, 172(1-2):281–291, 1997. doi:10.1016/S0304-3975(96)00141-7.
  • [11] Marcin Kubica, Jakub Radoszewski, Wojciech Rytter, and Tomasz Waleń. On the maximum number of cubic subwords in a word. European Journal of Combinatorics, 34(1):27–37, 2013. doi:10.1016/J.EJC.2012.07.012.
  • [12] Nguyen Huong Lam. On the number of squares in a string. AdvOL-Report, 2, 2013.
  • [13] Shuo Li. On the number of k-powers in a finite word. Advances in Applied Mathematics, 139:102371, 2022. doi:10.1016/J.AAM.2022.102371.
  • [14] Shuo Li, Jakub Pachocki, and Jakub Radoszewski. A note on the maximum number of k-powers in a finite word. Electronic Journal of Combinatorics, 31(3), 2024. doi:10.37236/11270.
  • [15] Gwénaël Richomme, Kalle Saari, and Luca Q. Zamboni. Standard factors of Sturmian words. RAIRO - Theoretical Informatics and Applications, 44(1):159–174, 2010. doi:10.1051/ITA/2010011.
  • [16] Arseny M. Shur. On ternary square-free circular words. Electronic Journal of Combinatorics, 17(1), 2010. doi:10.37236/412.
  • [17] Jamie Simpson. Palindromes in circular words. Theoretical Computer Science, 550:66–78, 2014. doi:10.1016/J.TCS.2014.07.012.
  • [18] Adrien Thierry. A proof that a word of length n has less than 1.5n distinct squares, 2020. arXiv:2001.02996.
  • [19] Axel Thue. Über unendliche Zeichenreihen. Norske Videnskabers Selskabs Skrifter Mat.-Nat. Kl., 7:1–22, 1906.