betaFeedback

WorksMathematics

Avoiding squares over words with lists of size three

Abstract

We prove that every sequence of lists of size three admits an infinite square-free word, establishing that the Thue choice number of the path is three. More precisely, the number of compatible square-free words of length nn is at least c(5/4)nc(5/4)^n, where c>0c>0 is an absolute constant. The proof combines a computer-assisted construction of weights with the weighted counting method previously introduced by the author. We first consider words avoiding only squares of bounded period and use a finite state model to certify a uniform lower bound on their growth. The counting argument then controls the loss caused by excluding longer squares. The main new ingredient is a coarser description of the states, which makes the computation feasible without restricting the union of the lists. The same computation yields a deterministic polynomial-time strategy for constructing an infinite square-free word when each list is chosen adversarially after the preceding letters have been fixed.

Introduction

A square is a word xxxx with xx nonempty. A word is square-free if none of its factors is a square. For instance, hotshots is a square while minimize is square-free. In 1906, Thue constructed an infinite ternary word avoiding squares [26, 27]. Since then, many generalizations of Thue’s result have been studied, including the list version of the problem. Given a sequence of lists L=(Li)i≥1L = (L_i)_{i \ge1}, a word ww respects LL if wi∈Liw_i \in L_i for every position ii of ww. The Thue choice number of the path, denoted by πch(P)\pi_{\mathrm{ch}}(P), is the least integer kk such that for every infinite sequence LL of lists of size at least kk, there exists an infinite square-free word respecting LL. The historical motivation for the study of the Thue choice number of the path is the generalization of the notion of nonrepetitive sequences to nonrepetitive colorings of graphs, which has received a lot of attention over the years (see for instance the recent survey of Wood [28], or some of the results on the nonrepetitive chromatic number of graphs of bounded degree [7, 10, 15, 20]).

Grytczuk, Przybyło and Zhu proved that πch(P)≤4\pi_{\mathrm{ch}}(P) \le4, and conjectured that πch(P)=3\pi_{\mathrm{ch}}(P) = 3 [14]. This question, first mentioned in [11], has appeared in a large number of papers, most often in its graph-theoretic form [1, 2, 3, 5, 6, 7, 8, 9, 11, 13, 17, 18, 19, 20, 21, 22, 25, 28, 29]. In [22], I proved that lists of size three suffice when all lists are subsets of a common set of size 4. Here, we remove the restriction on the alphabet and settle the full conjecture.

Theorem 1.1. There is a constant c>0c > 0 such that, for every sequence L=(Li)i≥1L = (L_i)_{i \ge1} of lists of size at least three and every n≥0n \ge0, there are at least

c(54)nc\left(\frac{5}{4}\right)^n

square-free words of length nn respecting LL.

In particular, there exists an infinite square-free word respecting LL, hence πch(P)=3\pi_{\mathrm{ch}}(P) = 3.

Our proof technique is essentially the one used in [22]. In the conclusion of [22], I argued that this technique would probably settle the conjecture if one could carry out computations roughly 10710^7 times more expensive than those performed there1. The main idea of that proof was to start by considering the language Lp\mathcal{L}_p of words over {1,2,3,4}\{1,2,3,4\} that avoid squares of length at most 2p2p. This language is defined by a finite set of forbidden factors, and can thus be recognized by a finite automaton, which can be used to compute a lower bound on the growth rate of Lp\mathcal{L}_p. More precisely, we computed a number α\alpha, an analogue of the growth rate of Lp\mathcal{L}_p when an adversary can forbid one arbitrary transition out of each state (which corresponds to having only 3 out of the 4 letters available). From there, we used the counting argument from [20] and techniques from [16, 24] to bound the influence of longer squares. For p=21p = 21, we could verify that α\alpha was large enough to satisfy our conditions. When working with arbitrary alphabets, the only obstacle preventing this technique from proving the general conjecture was the computational cost of the automaton.

The technique from [22] was also recently used in [3] to prove that every sequence of lists of size 2 admits an infinite cube-free word, with no restriction on the union of the lists. The proof in [3] is a direct adaptation of the proof from [22] to the cube-free setting, but the computer verification is more manageable in this case, so no restriction on the union of the alphabets was needed. Moreover, Bui and I gave a second proof that relies on exactly the same computer verification, but has slightly different consequences. In particular, it implies that if the sequence of lists is computable, then there exists a computable cube-free word that respects it. In fact, consider the setting where the sequence of lists is replaced by an adversary who chooses each list only after we have chosen the previous letters of the word. In this setting, there is a strategy, computable in polynomial time2 that produces a cube-free word respecting the lists. This second technique also works here, and we get the following result.

Theorem 1.2. Consider the following game. At each step n+1n+1, an adversary reveals a set Ln+1L_{n+1} of at least three letters, which may depend on the letters w1,…,wnw_1,\ldots,w_n already chosen, and we choose wn+1∈Ln+1w_{n+1} \in L_{n+1}. There is a deterministic strategy, computing each move in time polynomial in nn, that guarantees that the infinite word w1w2⋯w_1w_2\cdots is square-free.

In fact, this theorem is a corollary of the following result.

Theorem 1.3. There is a map bb, computable in polynomial time, from finite words to letters, such that every infinite word w1w2⋯w_1w_2\cdots satisfying wn+1∉{wn,b(w1⋯wn)}w_{n+1} \notin\{w_n,b(w_1\cdots w_n)\} for all n≥1n \ge1 is square-free. The first letter w1w_1 can be chosen arbitrarily.

One way to understand this statement is through another game: at each step n+1n+1 with n≥1n \ge1, given the current word w1⋯wnw_1 \cdots w_n, we can forbid two letters xx and yy, and the adversary chooses wn+1w_{n+1} with the only constraint that it differs from xx and yy. Theorem 1.3 states that the map bb provides a strategy to keep the word square-free forever against any strategy from an opponent, when we start from the empty word. Note that we clearly have to forbid wnw_n at step n+1n+1, since otherwise the adversary could choose wn+1=wnw_{n+1}=w_n and create a square, so the only real choice is the second forbidden letter, which is given by b(w1⋯wn)b(w_1\cdots w_n). This does not mean that we can win the game starting from any square-free word (after 0102010, we would need to forbid 0, 1 and 2 for the next letter). Forbidding the letter given by bb not only helps avoid squares at the next step, but also makes it easier to avoid squares in the future.

The article is organized as follows. In § 2, we present a weighted counting criterion that reduces the proof of Theorem 1.1 to the existence of a function ff satisfying some local inequalities. In § 3, we prove that the existence of the same function ff (with some extra computability conditions) also implies Theorem 1.3. The rest of the article is then devoted to the construction of such a function ff. In § 4, we associate with every word a state, from a finite set that encode sufficient information to recover information about short squares. We then prove in § 5 and § 6, that if we can find a function fsf_s over the states that satisfies some local inequalities, then we can construct the desired function ff over the words. Under the assumption that this function fsf_s exists, we can then deduce Theorems 1.1, 1.2 and 1.3. Finally, in § 7, we provide some details about the implementation of the computations that verify the existence of the function fsf_s for p=21p=21. We conclude with some open problems in § 8.

A weighted counting argument

Fix p≥2p \ge2, and let Gp\mathcal{G}_p be the set of finite words containing no square of period at most pp, where the period of xxxx is ∣x∣|x|. The following form of the counting argument isolates the properties needed from the weights.

Theorem 2.1. Suppose that a function f:Gp→[0,M]f:\mathcal{G}_p \to[0,M], with M<∞M < \infty and f(ε)>0f(\varepsilon)>0, satisfies the following conditions for some α>0\alpha>0:

(i) For every w∈Gpw \in\mathcal{G}_p and every set BB of three letters,

∑a∈Bwa∈Gpf(wa)≥αf(w).(1)\sum_{\substack{a \in B\\wa\in\mathcal{G}_p}} f(wa) \ge\alpha f(w). \tag*{(1)}

(ii) If yxx∈Gpyxx \in\mathcal{G}_p and ∣x∣>p|x|>p, then f(yxx)=f(yx)f(yxx)=f(yx).

If β>1\beta>1 satisfies

α−β1−pβ−1≥β,(2)\alpha-\frac{\beta^{1-p}}{\beta-1}\ge\beta, \tag*{(2)}

then every list assignment with lists of size three has at least f(ε)βn/Mf(\varepsilon)\beta^n/M compatible square-free words of length nn, for every n≥0n \ge0.

Proof. Fix the lists, and let SnS_n be the set of compatible square-free words of length nn. For a finite set U⊆GpU \subseteq\mathcal{G}_p, write U^=∑w∈Uf(w)\widehat{U}=\sum_{w\in U} f(w). We prove by induction that for all i≥0,i \ge0,

S^i+1≥βS^i.(3)\widehat{S}_{i+1} \ge\beta\widehat{S}_i. \tag*{(3)}

Suppose that (3) holds for all i<ni<n. We will prove that (3) holds for i=ni=n.

Let Hn+1H_{n+1} consist of the words obtained by extending a word of SnS_n by a letter of Ln+1L_{n+1} without creating a square of period at most pp. Then by (1), we get

S^n+1=∑w∈Sna∈Ln+1wa∈Gpf(wa)≥∑w∈Snαf(w)=αS^n.\widehat{S}_{n+1}=\sum_{\substack{w\in S_n\\ a\in L_{n+1}\\ wa\in G_p}}f(wa)\geq\sum_{w\in S_n}\alpha f(w)=\alpha\widehat{S}_n.

Some of these extensions do not bellong to Sn+1S_{n+1}, if they create a square of period larger than pp. Precisely, every word in Hn+1∖Sn+1H_{n+1}\setminus S_{n+1} has a square suffix of period larger than pp, since its prefix of length nn is square-free. For p<i≤⌊(n+1)/2⌋p<i\leq\lfloor(n+1)/2\rfloor, let FiF_i be the set of words in Hn+1H_{n+1} ending in a square of period ii. Then, Sn+1=Hn+1∖⋃i=p+1⌊(n+1)/2⌋FiS_{n+1}=H_{n+1}\setminus\bigcup_{i=p+1}^{\lfloor(n+1)/2\rfloor}F_i, and

S^n+1≥αS^n−∑i=p+1⌊(n+1)/2⌋F^i(4)\widehat{S}_{n+1}\geq\alpha\widehat{S}_n-\sum_{i=p+1}^{\lfloor(n+1)/2\rfloor}\widehat{F}_i \tag*{(4)}

By definition, every w∈Fiw\in F_i can be written as w=yxxw=yxx with ∣x∣=i>p|x|=i>p, and since every proper prefix of ww is square-free, we have yx∈Sn+1−iyx\in S_{n+1-i}. Thus the map

Fi⟶Sn+1−i,yxx⟼yxF_i\longrightarrow S_{n+1-i},\qquad yxx\longmapsto yx

is well-defined and injective, since ww can be recovered from yxyx by appending its suffix of length ii. Moreover, condition (ii) gives f(yxx)=f(yx)f(yxx)=f(yx), so this map preserves weights. This implies,

F^i≤S^n+1−i≤β1−iS^n,\widehat{F}_i\leq\widehat{S}_{n+1-i}\leq\beta^{1-i}\widehat{S}_n,

where the last inequality follows from applying the induction hypothesis (3) for all j∈{n+1−i,…,n−1}j\in\{n+1-i,\ldots,n-1\}. Substituting in (4), we obtain

S^n+1≥αS^n−∑i=p+1⌊(n+1)/2⌋β1−iS^n≥(α−∑i=p+1∞β1−i)S^n=(α−β1−pβ−1)S^n≥βS^n\widehat{S}_{n+1}\geq\alpha\widehat{S}_n-\sum_{i=p+1}^{\lfloor(n+1)/2\rfloor}\beta^{1-i}\widehat{S}_n\geq\left(\alpha-\sum_{i=p+1}^{\infty}\beta^{1-i}\right)\widehat{S}_n=\left(\alpha-\frac{\beta^{1-p}}{\beta-1}\right)\widehat{S}_n\geq\beta\widehat{S}_n

where the last inequality is simply our hypothesis (2). This concludes the proof that for all i≥0i\geq0, S^i+1≥βS^i\widehat{S}_{i+1}\geq\beta\widehat{S}_i. Finally, M∣Sn∣≥S^n≥f(ε)βnM|S_n|\geq\widehat{S}_n\geq f(\varepsilon)\beta^n, as desired.

The function ff might at first seem a bit abstract, and it is not clear how to prove the existence of such a function. However, avoiding squares of period at most pp is a local property, and the function ff can be constructed so that it only depends on the suffix of length at most 2p2p of its input. Moreover, by symmetry all letters play a similar role, hence it is natural to ask that the function ff only depend on the last 2p2p letters, up to renaming. For a given pp, there are only finitely many possibilities for the last 2p2p letters of a word, up to renaming. The best way to construct ff is to construct a set of states that encode enough information about the last 2p2p letters of a word, up to renaming, and then define ff as a function on these states. This was already the approach used in [22], and Theorem 2.1 is simply a more abstract rewriting of [22 Theorem 5].

In [22], the states were “exact” in the sense that they encoded enough information so that there was a bijection between the transitions of a word and the transitions of its state. The set of states was too large to fit in a computer, and we had to settle for a weaker result. In the current paper, we will use a coarser set of states, which loses some of this information for the states that have many outgoing transitions. This implies that the constant α\alpha will be slightly smaller than with exact states, but this effect is negligible while making the set of states much smaller and allowing us to finish the computations. In the remainder of the proof we construct ff as a function of a finite “state” depending on the last 2p2p letters of the word. This is done in Sections 4 to 7. Before that, we prove in Section 3 that the existence of such a function ff also implies Theorem 1.3.

The computational consequences of the same condition

For the algorithmic statements, we take the alphabet to be N\mathbb{N}. Given a function f:Gp→[0,M]f:\mathcal{G}_p \to[0,M] and a real number β>1\beta>1, we define the potential ωf,β(u)\omega_{f,\beta}(u) of any word u∈Gpu\in\mathcal{G}_p as follows:

ωf,β(u)=∑v such that:uv∈Gpuv=xyy with ∣v∣<∣y∣f(uv)β−∣v∣.\omega_{f,\beta}(u)=\sum_{\substack{v\ \text{such that:}\\ uv\in\mathcal{G}_p\\ uv=xyy\ \text{with }|v|<|y|}} f(uv)\beta^{-|v|}.

This function is the main ingredient used to define the function bb from Theorem 1.3. First note that, if uu ends with a square, then one of the summands corresponds to v=εv=\varepsilon, and thus ωf,β(u)≥f(u)\omega_{f,\beta}(u)\ge f(u). This implies the following lemma.

Lemma 3.1. If uu is square-free and aa is a letter such that ua∈Gpua\in\mathcal{G}_p and ωf,β(ua)<f(ua)\omega_{f,\beta}(ua)<f(ua), then uaua is square-free.

The core of our proof is that under our assumptions, if ωf,β(u)<f(u)\omega_{f,\beta}(u)<f(u) then at most two letters aa satisfy ua∉Gpua\notin\mathcal{G}_p or ωf,β(ua)≥f(ua)\omega_{f,\beta}(ua)\ge f(ua). By forbidding these two letters, we can ensure that ua∈Gpua\in\mathcal{G}_p and ωf,β(ua)<f(ua)\omega_{f,\beta}(ua)<f(ua) at the next step, and we can then apply the same argument inductively. We now prove one step of the induction in the following lemma.

Lemma 3.2. Let ff and β\beta satisfy the hypotheses of Theorem 2.1, and let u∈Gpu\in\mathcal{G}_p be such that ωf,β(u)<f(u)\omega_{f,\beta}(u)<f(u). Then every set of three letters contains a letter aa such that ua∈Gpua\in\mathcal{G}_p and ωf,β(ua)<f(ua)\omega_{f,\beta}(ua)<f(ua). Equivalently, at most two letters aa satisfy ua∉Gpua\notin\mathcal{G}_p or ωf,β(ua)≥f(ua)\omega_{f,\beta}(ua)\ge f(ua).

Proof. We first bound the sum of the potentials of all the extensions of uu by a letter3:

∑aua∈Gpωf,β(ua)=∑aua∈Gp∑v such that:uav∈Gpuav=xyy with ∣v∣<∣y∣f(uav)β−∣v∣≤∑v′ such that:uv′∈Gpuv′=xyy with 1≤∣y∣,∣v′∣≤∣y∣f(uv′)β1−∣v′∣≤βωf,β(u)+∑v′ such that:uv′∈Gpuv′=xyy with 1≤∣v′∣=∣y∣f(uv′)β1−∣v′∣.\begin{aligned} \sum_{\substack{a\\ ua\in\mathcal{G}_p}}\omega_{f,\beta}(ua) &=\sum_{\substack{a\\ ua\in\mathcal{G}_p}} \sum_{\substack{v\ \text{such that:}\\ uav\in\mathcal{G}_p\\ uav=xyy\ \text{with }|v|<|y|}} f(uav)\beta^{-|v|}\\ &\le\sum_{\substack{v'\ \text{such that:}\\ uv'\in\mathcal{G}_p\\ uv'=xyy\ \text{with }1\le|y|,|v'|\le|y|}} f(uv')\beta^{1-|v'|}\\ &\le\beta\omega_{f,\beta}(u)+ \sum_{\substack{v'\ \text{such that:}\\ uv'\in\mathcal{G}_p\\ uv'=xyy\ \text{with }1\le|v'|=|y|}} f(uv')\beta^{1-|v'|}. \end{aligned}

where the last inequality is obtained by splitting the sum according to whether ∣v′∣<∣y∣|v'|<|y| or ∣v′∣=∣y∣|v'|=|y|, and noticing that the terms with ∣v′∣<∣y∣|v'|<|y| form a subset of the terms in the definition of ωf,β\omega_{f,\beta}. In the last sum, we have uv′=xyyuv'=xyy with ∣v′∣=∣y∣|v'|=|y|, so u=xyu=xy and v′=yv'=y. Since uv′∈Gpuv'\in\mathcal{G}_p, we have ∣y∣>p|y| > p, so condition (ii) gives f(uv′)=f(u)f(uv') = f(u). Moreover, for each positive integer ℓ\ell there exists at most one such v′v' of length ℓ\ell, namely the suffix of length ℓ\ell of uu. Thus we get

∑a∈Aua∈Gpωf,β(ua)≤βωf,β(u)+∑ℓ=p+1∞f(u)β1−ℓ=βωf,β(u)+β1−pβ−1f(u)≤βωf,β(u)+f(u)(α−β),\begin{aligned} \sum_{\substack{a\in\mathcal{A}\\ ua\in\mathcal{G}_p}} \omega_{f,\beta}(ua) \le\beta\omega_{f,\beta}(u) + \sum_{\ell=p+1}^{\infty} f(u)\beta^{1-\ell} \\ &= \beta\omega_{f,\beta}(u) + \frac{\beta^{1-p}}{\beta-1}f(u) \\ &\le\beta\omega_{f,\beta}(u) + f(u)(\alpha-\beta), \end{aligned}

where the last inequality follows from condition (2). Now let BB be a set of three letters. Since ωf,β(u)<f(u)\omega_{f,\beta}(u) < f(u), the preceding bound and (1) give

∑a∈Bua∈Gpωf,β(ua)≤∑a∈Aua∈Gpωf,β(ua)<αf(u)≤∑a∈Bua∈Gpf(ua).\sum_{\substack{a\in B\\ ua\in\mathcal{G}_p}} \omega_{f,\beta}(ua) \le\sum_{\substack{a\in\mathcal{A}\\ ua\in\mathcal{G}_p}} \omega_{f,\beta}(ua) < \alpha f(u) \le\sum_{\substack{a\in B\\ ua\in\mathcal{G}_p}} f(ua).

This implies that there is at least one letter a∈Ba\in B such that ua∈Gpua\in\mathcal{G}_p and ωf,β(ua)<f(ua)\omega_{f,\beta}(ua)<f(ua), as desired. Hence at most two letters aa satisfy ua∉Gpua\notin\mathcal{G}_p or ωf,β(ua)≥f(ua)\omega_{f,\beta}(ua)\ge f(ua), as we could have chosen BB to be the set of these three letters otherwise.

We now prove Theorem 1.3 as a corollary of Lemma 3.2, under the assumption that there exist ff and β\beta satisfying the hypotheses of Theorem 2.1, with ff computable in polynomial time and independent of the names of the letters. We check in § 6 that the function ff constructed there has these properties.

Lemma 3.3. Let ff and β\beta satisfy the hypotheses of Theorem 2.1. Assume moreover that β\beta is rational, that ff takes rational values and is computable in polynomial time, and that ff does not depend on the names of the letters: f(π(w))=f(w)f(\pi(w))=f(w) for every w∈Gpw\in\mathcal{G}_p and every injective map π\pi from letters to letters, applied letter by letter. Then there is a map bb, computable in polynomial time, from finite words to letters, such that every infinite word w1w2⋯w_1w_2\cdots satisfying wn+1∈{wn‾,b(w1⋯wn)}w_{n+1}\in\{\overline{w_n},b(w_1\cdots w_n)\} for all n≥1n\ge1 is square-free. The first letter w1w_1 can be chosen arbitrarily.

Proof. For u∈Gpu\in\mathcal{G}_p, let Bad⁡(u)\operatorname{Bad}(u) be the set of letters aa such that ua∉Gpua\notin\mathcal{G}_p or ωf,β(ua)≥f(ua)\omega_{f,\beta}(ua)\ge f(ua). For every nonempty u∈Gpu\in\mathcal{G}_p with ωf,β(u)<f(u)\omega_{f,\beta}(u)<f(u), we have ∣Bad⁡(u)∣≤2|\operatorname{Bad}(u)|\le2 by Lemma 3.2. Moreover, since ωf,β(u)<f(u)\omega_{f,\beta}(u)<f(u), every letter not occurring in uu lies outside Bad⁡(u)\operatorname{Bad}(u). Indeed, for such a letter aa, we have ua∈Gpua\in\mathcal{G}_p and ωf,β(ua)=0\omega_{f,\beta}(ua)=0. If aa is the last letter of uu, then a∈Bad⁡(u)a\in\operatorname{Bad}(u), since ua∉Gpua\notin\mathcal{G}_p. Hence ∣Bad⁡(u)∖{a}∣≤1|\operatorname{Bad}(u)\setminus\{a\}|\le1, and we define b(u)b(u) to be this other bad letter if it exists, and 00 otherwise.4 For every other finite word uu, set b(u)=0b(u)=0.

Let w1w2⋯w_1w_2\cdots satisfy wn+1∈{wn‾,b(w1⋯wn)}w_{n+1}\in\{\overline{w_n},b(w_1\cdots w_n)\} for all nn.

We prove by induction that every prefix uu is square-free and satisfies ωf,β(u)<f(u)\omega_{f,\beta}(u)<f(u). This holds for u=εu=\varepsilon, since ωf,β(ε)=0<f(ε)\omega_{f,\beta}(\varepsilon)=0<f(\varepsilon). If it holds for u=w1⋯wnu=w_1\cdots w_n, then wn+1∉Bad⁡(u)w_{n+1}\notin\operatorname{Bad}(u), so uwn+1∈Gpuw_{n+1}\in\mathcal{G}_p and ωf,β(uwn+1)<f(uwn+1)\omega_{f,\beta}(uw_{n+1})<f(uw_{n+1}), and uwn+1uw_{n+1} is square-free by Lemma 3.1.

It remains to verify that bb is computable in polynomial time. Let uu be a finite word of length nn. If u=εu=\varepsilon or u∉Gpu\notin\mathcal{G}_p, return 0. Otherwise, in the definition of ωf,β(u)\omega_{f,\beta}(u), the word vv is determined by ∣y∣|y| and ∣v∣|v|. Enumerating these pairs and discarding duplicate completions vv gives a sum of O(n2)O(n^2) terms, each computable in polynomial time. Since β\beta and the values of ff are rational, these terms are rational numbers of polynomial size, and ωf,β(u)\omega_{f,\beta}(u) can be compared exactly with f(u)f(u) in polynomial time. If ωf,β(u)≥f(u)\omega_{f,\beta}(u) \ge f(u), return 0. Otherwise, every letter of Bad⁡(u)\operatorname{Bad}(u) already occurs in uu. For each such occurring letter aa, first test whether ua∈Gpua \in G_p and, if so, compare ωf,β(ua)\omega_{f,\beta}(ua) with f(ua)f(ua). This determines Bad⁡(u)\operatorname{Bad}(u) and b(u)b(u) in polynomial time.

Finite states and deletion of long squares

For a word w=w1⋯wnw = w_1 \cdots w_n with n≥pn \ge p, write w[j]=wn+1−jw[j] = w_{n+1-j} for its letter at distance jj from the right end (in particular, w[1]w[1] is the last letter of ww). For 1≤q≤p1 \le q \le p, let

rq(w)=max⁡{r∈{0,…,n−q}:w[j]=w[j+q] for 1≤j≤r}.r_q(w) = \max\{r \in\{0,\ldots,n-q\}: w[j] = w[j+q]\text{ for }1 \le j \le r\}.

Thus rq(w)r_q(w) is the largest integer rr such that the suffix of length q+rq+r of ww has period qq. If w∈Gpw \in G_p, then rq(w)≤q−1r_q(w) \le q-1. From this definition, for any letter aa,

rq(wa)={rq(w)+1,q≤n and a=w[q],0,otherwise.(5)r_q(wa) = \begin{cases} r_q(w)+1, & q \le n\text{ and }a=w[q],\\ 0, & \text{otherwise}. \end{cases} \tag*{(5)}

In particular, for w∈Gpw \in G_p, and any letter aa,

wa∈Gp⟺∀q≤min⁡(n,p) such that a=w[q],rq(w)<q−1.(6)wa \in G_p \Longleftrightarrow\forall q \le\min(n,p)\text{ such that }a=w[q],\quad r_q(w)<q-1. \tag*{(6)}

Indeed, a square of period at most pp in wawa is necessarily a suffix of wawa, and if it has period qq then a=w[q]a=w[q] and rq(w)≥q−1r_q(w)\ge q-1.

To avoid treating short words separately, fix p+1p+1 letters c0,c1,…,cpc_0,c_1,\ldots,c_p that do not belong to the alphabet Σ\Sigma of the lists, and put ρ=cp⋯c1c0\rho=c_p\cdots c_1c_0. Each symbol of ρ\rho occurs exactly once in ρw\rho w and never in ww, so no square of ρw\rho w contains a symbol of ρ\rho. Hence ρw∈Gp\rho w\in G_p if and only if w∈Gpw\in G_p, and the squares of ρw\rho w are those of ww. We will only use the states of the words ρw\rho w, which have length at least p+1p+1.

All letters play the same role, so we can always assume up to symmetry that the last two letters of a word are 1 and 0. In order to decrease the number of states, we will remember the positions of all occurrences of 0 and 1, but we will forget the details about all other letters. To avoid losing too much information, we will still keep track of the overlaps of the last pp letters given by the different values of rqr_q for 1≤q≤p1 \le q \le p. More precisely, for w∈Gpw \in G_p with ∣w∣≥p|w| \ge p and 1≤j≤p1 \le j \le p, let

λj(w)={0,w[j]=w[1],1,w[j]=w[2],⋆,otherwise.\lambda_j(w)= \begin{cases} 0, & w[j]=w[1],\\ 1, & w[j]=w[2],\\ \star, & \text{otherwise}. \end{cases}

Define the state of ww by

σ(w)=(λp(w),…,λ1(w);rp(w),…,r1(w)).(7)\sigma(w)=(\lambda_p(w),\ldots,\lambda_1(w);r_p(w),\ldots,r_1(w)). \tag*{(7)}

The label ⋆\star does not mean that all the corresponding positions carry the same letter. It means that the only information that we have to distinguish these letters consists of the values of the rq(w)r_q(w): the maximality condition in the definition of rq(w)r_q(w) implies that the letters at positions rq(w)+1r_q(w)+1 and rq(w)+1+qr_q(w)+1+q are different, whenever rq(w)+1+q≤nr_q(w)+1+q\le n.

For definiteness, let ApA_p be the finite set of tuples A=(λp,…,λ1;rp,…,r1)A=(\lambda_p,\ldots,\lambda_1;r_p,\ldots,r_1) with 0≤rq≤q−10\le r_q\le q-1, labels in {0,1,⋆}\{0,1,\star\}, λ1=0\lambda_1=0 and λ2=1\lambda_2=1. Every word in GpG_p of length at least pp has a state in ApA_p, although not every tuple in Ap\mathcal{A}_p is realized by a word. The state of the prefix ρ\rho, which we call the start state, is

A0=σ(ρ)=(⋆,…,⋆,1,0;0,…,0).A_0=\sigma(\rho)=(\star,\ldots,\star,1,0;0,\ldots,0).

To define the function ff from Theorem 2.1, we will define a weight function D:Ap→Z≥0D:\mathcal{A}_p\to\mathbb{Z}_{\geq0}, and then set f(w)=D(σ(ρw))f(w)=D(\sigma(\rho w)). The following lemma ensures that any function ff defined in this way has the second property needed to apply Theorem 2.1, that is, if yxx∈Gpyxx\in\mathcal{G}_p and ∣x∣>p|x|>p, then f(yxx)=f(yx)f(yxx)=f(yx).

Lemma 4.1. If yxx∈Gpyxx\in\mathcal{G}_p and ∣x∣>p|x|>p, then σ(yxx)=σ(yx)\sigma(yxx)=\sigma(yx).

Proof. Write u=yxxu=yxx, v=yxv=yx and i=∣x∣i=|x|. We first claim that for all q∈{1,…,p}q\in\{1,\ldots,p\},

q+rq(u)<∣x∣.(8)q+r_q(u)<|x|. \tag*{(8)}

Otherwise, xx has period qq. Put d=i−qd=i-q, so 1≤d≤q−11\leq d\leq q-1. The prefix of xx of length dd equals its suffix of length dd. These two copies meet at the junction in xxxx, forming a square of period d<pd<p, contrary to u∈Gpu\in\mathcal{G}_p.

For all q∈{1,…,p}q\in\{1,\ldots,p\}, q+rq(u)+1≤∣x∣q+r_q(u)+1\leq|x| implies that the suffix of length q+rq(u)q+r_q(u) of xx has period qq, but not the suffix of length q+rq(u)+1q+r_q(u)+1. So the value of rq(u)r_q(u) is uniquely determined by xx, independently of yy. In particular, rq(u)=rq(v)r_q(u)=r_q(v) for all q∈{1,…,p}q\in\{1,\ldots,p\}. The labels of the states also agree, as they depend only on the suffix of length p<∣x∣p<|x|.

Extensions and possible letter types

We now define state transitions corresponding to the addition of a letter. For every letter aa and word w∈Gpw\in\mathcal{G}_p with ∣w∣≥p|w|\geq p, define the type of aa after ww to be its occurrence set in the suffix of length pp:

Tw(a)={j∈{1,…,p}:w[j]=a}.T_w(a)=\{j\in\{1,\ldots,p\}:w[j]=a\}.

Distinct letters have disjoint types. The type of aa after ww can be seen as choosing a letter from the suffix, or a letter absent from it. We will define a corresponding notion of type for states, which will be a set of positions in the suffix of length pp encoded by the state.

For a state A=(λp,…,λ1;rp,…,r1)A=(\lambda_p,\ldots,\lambda_1;r_p,\ldots,r_1), we let

Z0(A)={j:λj=0},Z1(A)={j:λj=1},Wild⁡(A)={j:λj=⋆}.Z_0(A)=\{j:\lambda_j=0\},\qquad Z_1(A)=\{j:\lambda_j=1\},\qquad\operatorname{Wild}(A)=\{j:\lambda_j=\star\}.

Consider a set XX equal to Z0(A)Z_0(A) or Z1(A)Z_1(A), or contained in Wild⁡(A)\operatorname{Wild}(A). The type XX is allowed if rq<q−1r_q<q-1 for every q∈Xq\in X. In particular, by this definition the type Z0(A)Z_0(A) is never allowed. Intuitively, a type is allowed if adding the corresponding letter does not create a square of period at most pp (see Lemma 5.1). For an allowed XX, we define the successor

Φ(A,X)=(λp′,…,λ1′;rp′,…,r1′)\Phi(A,X)=(\lambda'_p,\ldots,\lambda'_1;r'_p,\ldots,r'_1)

where

rq′={rq+1,q∈X,0,q∉X,1≤q≤p.(9)r'_q= \begin{cases} r_q+1, & q\in X,\\ 0, & q\notin X, \end{cases} \qquad1\leq q\leq p. \tag*{(9)}

and, for 1≤j≤p1\leq j\leq p,

λj′={0,j=1 or j−1∈X,1,λj−1=0,⋆,otherwise.(10)\lambda'_j= \begin{cases} 0, & j=1\text{ or }j-1\in X,\\ 1, & \lambda_{j-1}=0,\\ \star, & \text{otherwise}. \end{cases} \tag*{(10)}

The following lemma shows that the successor of a state is well-defined, and that it corresponds to the state of a word after adding a letter of the corresponding type.

Lemma 5.1. Let w∈Gpw \in\mathcal{G}_p be a word of length at least pp, and aa be a letter. Then wa∈Gpwa \in\mathcal{G}_p if and only if Tw(a)\mathcal{T}_w(a) is allowed at σ(w)\sigma(w). When it is allowed,

σ(wa)=Φ(σ(w),Tw(a)).\sigma(wa) = \Phi(\sigma(w), \mathcal{T}_w(a)).

Proof. The set Tw(a)\mathcal{T}_w(a) records exactly the positions occupied by aa among the last pp letters. Legality and the overlap update therefore follow from (6) and (5). After a legal extension, the distinguished letters are aa and the previous last letter. The positions in Tw(a)\mathcal{T}_w(a) acquire label 00, the former 00-positions acquire label 11, and all other positions acquire label ⋆\star. Shifting the positions by one gives (10).

We have proven that the states behave nicely, but for any given state we need to be able to tell what type of letter is possible after the state. A letter that is not one of the last two letters of ww is called an outside letter: its type is contained in Wild⁡(σ(w))\operatorname{Wild}(\sigma(w)), and we call the subsets of Wild⁡(A)\operatorname{Wild}(A) outside types. However, some subset of Wild⁡(A)\operatorname{Wild}(A) do not correspond to the occurrence set of an outside letter. The labels of a state only contain information about the positions of 00 and 11 (the two types Z0(A)Z_0(A) and Z1(A)Z_1(A) are easily defined). However, we still have some partial information about the other positions which impose some pair of letters to be identical or different.

The overlaps given by the (rq)1≤q≤p(r_q)_{1 \leq q \leq p} force certain ⋆\star positions to carry the same letter. Similarly, choosing an outside type X⊆Wild⁡(A)X \subseteq\operatorname{Wild}(A) forces all positions of XX to carry the same letter. If all of these constraints impose the presence of a square, then XX cannot be the occurrence set of an outside letter (since the suffix of length pp of a word in Gp\mathcal{G}_p is square-free). Moreover, the rqr_q are maximal: whenever rq+1+q≤pr_q + 1 + q \leq p, the letters at positions rq+1r_q + 1 and rq+1+qr_q + 1 + q are distinct, so an outside type cannot include both of these positions.

Formally, for X⊆Wild⁡(A)X \subseteq\operatorname{Wild}(A), let ≡A,X\equiv_{A,X} be the equivalence relation on {1,…,p}\{1,\ldots,p\} generated by

j≡A,Xj+q(1≤q≤p, 1≤j≤rq, j+q≤p),j≡A,Xj′(λj=λj′∈{0,1}, or j,j′∈X).(11)\begin{aligned} j &\equiv_{A,X} j+q &&(1 \leq q \leq p,\ 1 \leq j \leq r_q,\ j+q \leq p),\\ j &\equiv_{A,X} j' &&(\lambda_j=\lambda_{j'} \in\{0,1\},\ \text{or } j,j' \in X). \tag*{(11)} \end{aligned}

That is, two positions are equivalent for ≡A,X\equiv_{A,X} if they are forced to carry the same letter by the overlaps rqr_q, by the labels, or because they both belong to XX. Let sX=sX(p)⋯sX(1)s_X=s_X(p)\cdots s_X(1) be the word whose letter sX(j)s_X(j) is the ≡A,X\equiv_{A,X}-class of jj, and define

Xout(A):={X⊆Wild⁡(A):X is a union of ≡A,∅-classes,sX is square-free, andrq+1̸≡A,Xrq+1+q whenever rq+1+q≤p}.(12)\mathcal{X}_{\mathrm{out}}(A) := \left\{ X \subseteq\operatorname{Wild}(A) : \begin{array}{l} X\text{ is a union of }\equiv_{A,\varnothing}\text{-classes},\\ s_X\text{ is square-free, and}\\ r_q+1 \not\equiv_{A,X} r_q+1+q\text{ whenever }r_q+1+q\leq p \end{array} \right\}. \tag*{(12)}

and

X(A):={Z0(A),Z1(A)}∪Xout(A).\mathcal{X}(A):=\{Z_0(A),Z_1(A)\}\cup\mathcal{X}_{\mathrm{out}}(A).

We now prove that the set of types of a word is contained in the set of types of its state.

Lemma 5.2. If w∈Gpw \in\mathcal{G}_p with ∣w∣≥p|w| \geq p and aa is a letter, then Tw(a)∈X(σ(w))\mathcal{T}_w(a) \in\mathcal{X}(\sigma(w)).

Proof. If aa is one of the last two letters of ww, then Tw(a)=Z0(σ(w))\mathcal{T}_w(a)=Z_0(\sigma(w)) or Tw(a)=Z1(σ(w))\mathcal{T}_w(a)=Z_1(\sigma(w)), so the assertion is immediate. Otherwise, Tw(a)⊆Wild⁡(σ(w))\mathcal{T}_w(a)\subseteq\operatorname{Wild}(\sigma(w)). The two positions of each generating pair of (11) carry the same letter in ww: by definition of rqr_q, by definition of the labels, or because both carry aa. Hence any two ≡σ(w),Tw(a)\equiv_{\sigma(w),\mathcal{T}_w(a)}-equivalent positions carry the same letter. In particular, a position equivalent to a position of Tw(a)\mathcal{T}_w(a) carries aa, so it lies in Tw(a)\mathcal{T}_w(a), and Tw(a)\mathcal{T}_w(a) is a union of ≡σ(w),∅\equiv_{\sigma(w),\emptyset}-classes. A square in sTw(a)s_{\mathcal{T}_w(a)} would give a square of period at most pp in ww, which is impossible since w∈Gpw \in\mathcal{G}_p. Finally, if rq+1+q≤pr_q+1+q \le p, the maximality of rqr_q gives w[rq+1]≠w[rq+1+q]w[r_q+1] \ne w[r_q+1+q], so these two positions are not equivalent.

Remark. The relation (11) and the word sXs_X only use the last pp positions, but the rqr_q provide information about the positions up to 2p−12p-1. Keeping X⊆Wild⁡(A)X \subseteq\operatorname{Wild}(A) and the first condition in (12) unchanged, one may extend ≡A,X\equiv_{A,X} and sXs_X to the positions 1,…,2p−11,\ldots,2p-1, using all the pairs j≡A,Xj+qj \equiv_{A,X} j+q with 1≤j≤rq1 \le j \le r_q. Requiring the extended word to be square-free eliminates a few more types. For instance, let p=6p=6 and w=cadaedbaw=\textit{cadaedba}. Then σ(w)=(⋆,0,⋆,⋆,1,0;1,0,1,0,0,0)\sigma(w)=(\star,0,\star,\star,1,0;1,0,1,0,0,0). Definition (12) gives

Xout(σ(w))={∅,{3},{4},{6},{3,6},{4,6}}.\mathcal{X}_{\mathrm{out}}(\sigma(w))=\{\emptyset,\{3\},\{4\},\{6\},\{3,6\},\{4,6\}\}.

In particular, the type X={4,6}X=\{4,6\} passes the test on the last six positions, where sXs_X reads x0xκ10x0x\kappa10, writing xx, 00, κ\kappa and 11 for the classes of XX, of the positions labelled 00, of position 33 and of the positions labelled 11. But r6=1r_6=1 forces the letter at position 77 to be the last letter, so the positions 7,6,5,47,6,5,4 read 0x0x0x0x, a square of period 22. No word with this state has a letter occupying exactly the positions 44 and 66, and the extended definition would remove this type.

Lemma 5.2 holds for this extended definition, with the same proof. On the one hand, this experimentally reduces the number of reachable states by about 13%13\% and improves the certified constant by less than 2⋅10−52\cdot10^{-5}. On the other hand, each state costs about 20%20\% more to process and, since the tables are allocated by “doubling”, this does not improve the memory or running time. We therefore stick to the simpler definition.

The finite weight inequalities

Let D:Ap→Z≥0D:A_p\to\mathbb{Z}_{\ge0}. For a state AA and a type t∈X(A)t\in\mathcal{X}(A), define its extension weight by

vD(A,t)={D(Φ(A,t)),t is allowed,0,otherwise.v_D(A,t)= \begin{cases} D(\Phi(A,t)), & t\text{ is allowed},\\ 0, & \text{otherwise}. \end{cases}

An admissible triple at AA is a multiset {X1,X2,X3}\{X_1,X_2,X_3\} of elements of X(A)\mathcal{X}(A) such that Xi∩Xj=∅X_i\cap X_j=\emptyset whenever i≠ji\ne j. Thus a nonempty set cannot occur twice, whereas ∅\emptyset may occur several times. With the convention min⁡∅=+∞\min\emptyset=+\infty, let

TD(A)=min⁡admissible triples {t1,t2,t3}∑j=13vD(A,tj).(13)T_D(A)=\min_{\text{admissible triples }\{t_1,t_2,t_3\}}\sum_{j=1}^{3}v_D(A,t_j). \tag*{(13)}

Definition 6.1. A weight certificate with constant α>0\alpha>0 is a function D:Ap→Z≥0D:A_p\to\mathbb{Z}_{\ge0} such that

  • D(A0)>0D(A_0)>0, and

  • TD(A)≥αD(A)T_D(A)\ge\alpha D(A) for every A∈ApA\in A_p.

Proposition 6.2. If DD is a weight certificate with constant α\alpha, then f(w)=D(σ(ρw))f(w)=D(\sigma(\rho w)) satisfies the hypotheses of Theorem 2.1, with the same constant α\alpha and M=max⁡AD(A)M=\max_A D(A).

Proof. First note that ApA_p is finite, hence D(A)D(A) and f(w)f(w) are bounded. Moreover, f(ϵ)=D(A0)>0f(\epsilon)=D(A_0)>0. So we only need to check the two conditions (i) and (ii) of Theorem 2.1. Let w∈Gpw \in\mathcal{G}_p, so that ρw∈Gp\rho w \in\mathcal{G}_p, and let B⊆ΣB \subseteq\Sigma have size three. Since BB contains three distinct letters, the types of these letters after ρw\rho w are pairwise disjoint, and by Lemma 5.2 each type belongs to X(σ(ρw))\mathcal{X}(\sigma(\rho w)). They therefore form an admissible triple at σ(ρw)\sigma(\rho w). Using Lemma 5.1, we obtain

∑a∈Bwa∈Gpf(wa)=∑a∈Bρwa∈GpD(σ(ρwa))=∑a∈Bρwa∈GpD(Φ(σ(ρw),Tρw(a)))=∑a∈BvD(σ(ρw),Tρw(a))≥TD(σ(ρw))≥αD(σ(ρw))=αf(w).\begin{aligned} \sum_{\substack{a \in B\\ wa \in\mathcal{G}_p}} f(wa) &= \sum_{\substack{a \in B\\ \rho wa \in\mathcal{G}_p}} D(\sigma(\rho wa)) \\ &= \sum_{\substack{a \in B\\ \rho wa \in\mathcal{G}_p}} D(\Phi(\sigma(\rho w),T_{\rho w}(a))) \\ &= \sum_{a \in B} v_D(\sigma(\rho w),T_{\rho w}(a)) \\ &\geq T_D(\sigma(\rho w)) \\ &\geq\alpha D(\sigma(\rho w)) \\ &= \alpha f(w). \end{aligned}

If yxx∈Gpyxx \in\mathcal{G}_p is over Σ\Sigma and ∣x∣>p|x| > p, then ρyxx∈Gp\rho yxx \in\mathcal{G}_p, so Lemma 4.1 gives

f(yxx)=D(σ(ρyxx))=D(σ(ρyx))=f(yx),f(yxx) = D(\sigma(\rho yxx)) = D(\sigma(\rho yx)) = f(yx),

which concludes our proof.

What remains is to find a weight certificate with a sufficiently large constant α\alpha to apply Theorem 2.1.

Proposition 6.3 (Computer-assisted). For p=21p = 21, there is a weight certificate with constant

α=13005441000000=1.300544.\alpha= \frac{1300544}{1000000} = 1.300544.

This proposition is proved by computer, and we provide the details of the computation in the next section. First we show how to deduce Theorem 1.1 and Theorem 1.3 from it.

Proof of Theorem 1.1. First reduce every list to size three. Take the certificate of Proposition 6.3 and set β=5/4\beta= 5/4. Condition (2) is equivalent to

(α−β)(β−1)β20≥1,(\alpha-\beta)(\beta-1)\beta^{20} \geq1,

which is easily verified to hold with the given values of α\alpha and β\beta. Proposition 6.2 and Theorem 2.1 now give the claimed bound, with c=D(A0)/max⁡AD(A)>0c = D(A_0)/\max_A D(A) > 0, independently of the lists.

The compatible square-free words form a finitely branching tree under extension by one letter, with a vertex at every depth. By König’s lemma, this tree has an infinite branch, giving an infinite square-free word respecting the lists.

Proof of Theorem 1.3. Let f(w)=D(σ(ρw))f(w) = D(\sigma(\rho w)), where DD is the certificate of Proposition 6.3, and let β=5/4\beta= 5/4. As in the proof of Theorem 1.1, ff and β\beta satisfy the hypotheses of Theorem 2.1. Moreover, β\beta is rational and DD takes integer values. The state σ(ρw)\sigma(\rho w) is determined by the last 2p2p letters of ρw\rho w, since rq(ρw)≤q−1r_q(\rho w) \leq q - 1 for every q≤pq \leq p, and DD is given by a finite table, so ff is computable in polynomial time. Finally, σ(ρw)\sigma(\rho w) only depends on which positions of ρw\rho w carry the same letter, and the letters of ρ\rho do not belong to Σ\Sigma, so ff does not depend on the names of the letters. Lemma 3.3 therefore gives Theorem 1.3.

Computation of the weight certificate

The proof of Proposition 6.3 is computer-assisted. The code is available at https://github.com/matthieu-rosenfeld/Avoiding-squares-over-lists-of-size-3.

The first critical part of the verification is to be able to generate the types and successors of a given state. To generate the types of a state AA we essentially use the definition of X(A)\mathcal{X}(A), which is a finite check. Practical details involve a few extra tricks like precomputing the equivalence classes of ≡A,∅\equiv_{A,\varnothing} and some information about the square-freeness to be able to efficiently generate and validate all the types of a state. The computation of the successor Φ(A,X)\Phi(A,X) is straightforward using (9) and (10). Crucially, we do not store the set of types associated with a state, but rather generate it each time we need it. This is much slower, but it saves a lot of memory and memory is the main limiting factor in our computation.

For the set of states, we do not consider the set of all states, but only the set RR of states reachable from the start state A0A_0, that is, obtained from A0A_0 by successive moves A↦Φ(A,X)A \mapsto\Phi(A,X) with X∈X(A)X \in\mathcal{X}(A) allowed. For this we simply use a breadth-first search starting from A0A_0 and generate all the successors of each state. For all other states, we implicitly set D(A)=0D(A)=0, which is allowed by the definition of a weight certificate.

From there, we also need to be able to compute the operator TD(A)T_D(A) for each state AA. Since there are finitely many types, this could be done by enumerating all triples of types. However, we can make this much more efficient by noting that the type Z0(A)Z_0(A) is always forbidden and has zero extension weight, so it is always optimal to include it in a minimizing triple. So we only need to enumerate triples of types that contain Z0(A)Z_0(A), which reduces the number of triples to check significantly.

In order to find the weights D(A)D(A), we initially give each state in RR the integer weight S=108S=10^8. At each iteration, we compute TD(A)T_D(A) for every A∈RA \in R. Unless the stopping criterion is met, we then normalize by setting

Dnew(A)=⌊STD(A)max⁡B∈RTD(B)⌋.D_{\mathrm{new}}(A)=\left\lfloor\frac{S T_D(A)}{\max_{B\in R}T_D(B)}\right\rfloor.

If the denominator is zero, the iteration stops. Note that this is easily parallelizable since for the most part we read D(A)D(A) and write TD(A)T_D(A), so we can do this in parallel for all states without conflict. For p∈{4,…,21}p \in\{4,\ldots,21\} the iteration seems to converge quite rapidly. The reported run for p=21p=21 stops after 109 iterations. At each iteration, the code computes the minimum ratio over states of positive weight, rounded down to six decimal places:

α=1106min⁡A∈RD(A)>0⌊106TD(A)D(A)⌋.\alpha=\frac{1}{10^6}\min_{\substack{A\in R\\D(A)>0}}\left\lfloor\frac{10^6T_D(A)}{D(A)}\right\rfloor.

For p=21p=21, we get α=1300544/1000000=1.300544\alpha=1300544/1000000=1.300544 after 109 iterations, which is enough to prove Theorem 1.1.

Although the general algorithm is quite simple, the implementation is slightly more tricky as it involves a lot of details to make it efficient. First, we perform all computations with integers, rounding in the appropriate direction, so that the inequalities TD(A)≥αD(A)T_D(A)\geq\alpha D(A) hold exactly for the final integer weights. We tried to encode everything as tightly as possible to minimize memory consumption as it is the main limiting factor. In particular, storing a state requires only 64×3=19264\times3=192 bits (slightly less in fact, but we have to work with multiples of 64 bits anyway). The code also contains a simple implementation of a hash table (with open addressing and linear probing) to store the states, their weights and the next weight (D(A)D(A) and TD(A)T_D(A)), which allows us to save even more space and improve cache locality. We also use specific encodings of the states allowing to use bitwise operations for some of the manipulations that would have required using more costly loops otherwise.

The reported run for p=21p = 21 has the following size.

QuantityReported value
States in RR405 488 434
States with positive integer weight394 977 967
Iterations109
Memory use20.0 GiB
Running time518 h 24 min

Table 1.

The run reports that D(A0)>0D(A_0) > 0, and its final ratio computation establishes

TD(A)≥13005441000000D(A)(A∈R).(14)T_D(A) \ge\frac{1300544}{1000000}D(A) \qquad(A \in R). \tag*{(14)}

For states of zero weight, these inequalities follow from nonnegativity. These are the computational claims used in Proposition 6.3.

Open problems

The number of square-free words. In the proof of Theorem 1.1, we could have taken β=1.2685\beta= 1.2685, which improves slightly on the constant 5/45/4. We conjecture that the worst case is when all the lists are identical: for every sequence LL of lists of size three, the number of square-free words of length nn compatible with LL would be at least the number of ternary square-free words of length nn. In particular, the constant 5/45/4 could then be replaced by the growth rate 1.3017…1.3017\ldots of ternary square-free words [24]. Even in the online setting of Theorem 1.2, it seems that the strategy of the adversary that minimizes the number of square-free words of length nn that we can construct is to always give the same list.

The erase-repetition game. The technique of [22] was also used in [23] to show that Ann wins the nonrepetitive game over four letters and the erase-repetition game over six letters. Whether Ann wins the erase-repetition game over five or four letters is still open. Experiments done in [23] suggest that the technique could prove that she wins over five letters, the limit being again mostly computational, so improvements similar to the one presented here might settle this question.

List packing. Like the Thue choice number, the next problem comes from graph colouring. The list packing number χℓ∗(G)\chi_\ell^*(G) of a graph GG is the least kk such that, for every assignment of lists of size kk to the vertices of GG, there are kk proper colourings from these lists that differ at every vertex [4]. Inspired by this notion, Grytczuk proposed the following strengthening of the Thue choice number of the path. Let πch∗(P)\pi_{\mathrm{ch}}^*(P) be the least integer kk such that, for every k×nk \times n matrix whose columns consist of kk distinct letters, one can permute the letters inside each column so that every row is a square-free word. By compactness, this amounts to asking that, for every sequence LL of lists of size kk, there are kk infinite square-free words respecting LL that differ at every position. Each row is a square-free word respecting the lists given by the columns, so πch(P)≤πch∗(P)\pi_{\mathrm{ch}}(P) \le\pi_{\mathrm{ch}}^*(P). Grytczuk conjectures that πch∗(P)=3\pi_{\mathrm{ch}}^*(P) = 3, which would strengthen the existence part of Theorem 1.1; the case k=3k = 3 was asked at the open problem session of WORDS 2025, as filling a 3×n3 \times n chessboard [12]. He also informed me that πch∗(P)≤6\pi^*_{\mathrm{ch}}(P) \le6 (personal communication).

Acknowledgements and use of AI

The main technique behind this article was developed in [22], with the objective of settling this problem, and was later used in [3]. It would have required computational power that is currently out of reach. Since [22], I spent a considerable amount of time trying to do what is done in the present article, that is, to find a way to merge the states of the construction of [22] that greatly reduces their number, while losing so little information that the growth constant α\alpha is preserved. I gave Claude (Anthropic) and ChatGPT (OpenAI) the same prompts: the goal of pushing the computation of [22] to an unbounded alphabet, followed by the suggestion of merging similar states while keeping their worst behaviour.

After a couple of exchanges, Claude found such a way of merging the states: for each of the last pp positions, remember only whether it carries one of the few most recent letters (this became the last two letters in the article), together with the length of the repetition in progress for each period q≤pq \le p. Claude also gave the argument showing that this abstraction is sound. ChatGPT, on the other hand, did not produce an answer: the conversation stopped several times. In both cases, a single interaction used up the whole token budget, but with different consequences.

Claude then wrote a first, unreadable version of the code that carried out the computations needed to complete the proof6, as well as first drafts of the proofs, which I then rewrote. The states used in the present article are considerably simpler than the ones found by Claude, but they are based on the same idea. I then rewrote the code in a more readable and verifiable way, with assistance from Claude. Note that the original unreadable code of Claude is slightly faster than the code provided with this article (it does not compute exactly the same thing, but the main explanation is that it uses optimizations that make the code much more difficult to read and verify for a small performance gain). Both Claude and ChatGPT were used for proofreading, and suggested improvements to the text. ChatGPT was also used to generate its own version of the code to verify that both versions produce the same output. I take full responsibility for the content of this article.

References

  1. [1]Noga Alon and Joel H. Spencer. The Probabilistic Method. John Wiley & Sons, Hoboken, NJ, 4 edition, 2016.
  2. [2]Bartłomiej Bosek, Jarosław Grytczuk, Barbara Nayar, and Bartosz Zaleski. Nonrepetitive list colourings of the integers. Annals of Combinatorics, 25:393–403, 2021.DOI
  3. [3]Vuong Bui and Matthieu Rosenfeld. There exist infinite cube-free words over any sequence of binary alphabets, 2025. arXiv:2512.03670.arxiv.org/abs/2512.03670
  4. [4]Stijn Cambie, Wouter Cames van Batenburg, Ewan Davies, and Ross J. Kang. Packing list-colourings. Random Structures & Algorithms, 64(1):62–93, 2024. arXiv:2110.05230.DOI
  5. [5]Daniel W. Cranston. Graph Coloring Methods. Daniel W. Cranston, Richmond, Virginia, 2024.
  6. [6]Sebastian Czerwiński and Jarosław Grytczuk. Nonrepetitive colorings of graphs. Electronic Notes in Discrete Mathematics, 28:453–459, 2007.DOI
  7. [7]Vida Dujmović, Gwenaël Joret, Jakub Kozik, and David R. Wood. Nonrepetitive colouring via entropy compression. Combinatorica, 36(6):661–686, 2016.DOI
  8. [8]Francesca Fiorenzi, Pascal Ochem, Patrice Ossona de Mendez, and Xuding Zhu. Thue choosability of trees. Discrete Applied Mathematics, 159(17):2045–2049, 2011.DOI
  9. [9]Adam Gagol, Gwenaël Joret, Jakub Kozik, and Piotr Micek. Pathwidth and nonrepetitive list coloring. The Electronic Journal of Combinatorics, 23(4):P4.40, 2016.DOI
  10. [10]Daniel Gonçalves, Mickaël Montassier, and Alexandre Pinlou. Entropy compression method applied to graph colorings, 2014. arXiv:1406.4380.
  11. [11]Jarosław Grytczuk. Nonrepetitive colorings of graphs—a survey. International Journal of Mathematics and Mathematical Sciences, 2007, 2007. Article ID 74639, 10 pp.DOI
  12. [12]Jarosław Grytczuk. Square-free words on a chessboard. Open problem session, WORDS 2025, Nancy, 2025. https://words2025.loria.fr/files/2025/07/webpage-open-problems.pdf.
  13. [13]Jarosław Grytczuk, Jakub Kozik, and Piotr Micek. New approach to nonrepetitive sequences. Random Structures & Algorithms, 42(2):214–225, 2013.DOI
  14. [14]Jarosław Grytczuk, Jakub Przybyło, and Xuding Zhu. Nonrepetitive list colourings of paths. Random Structures & Algorithms, 38(1–2):162–173, 2011.DOI
  15. [15]Jochen Harant and Stanislav Jendroľ. Nonrepetitive vertex colorings of graphs. Discrete Mathematics, 312(2):374–380, 2012.DOI
  16. [16]Roman M. Kolpakov. On the number of repetition-free words. Journal of Applied and Industrial Mathematics, 1(4):453–462, 2007.DOI
  17. [17]Jakub Kozik and Piotr Micek. Nonrepetitive choice number of trees. SIAM Journal on Discrete Mathematics, 27(1):436–446, 2013.arxiv.org/abs/1207.5155
  18. [18]Iztok Peterin, Jens Schreyer, Erika Fecková Škrabuláková, and Andrej Taranenko. A note on the Thue chromatic number of lexicographic products of graphs. Discussiones Mathematicae Graph Theory, 38:635–643, 2018.
  19. [19]Jakub Przybyło. On the facial Thue choice index via entropy compression. Journal of Graph Theory, 77(3):180–189, 2014.
  20. [20]Matthieu Rosenfeld. Another approach to non-repetitive colorings of graphs of bounded degree. The Electronic Journal of Combinatorics, 27(3):P3.43, 2020.
  21. [21]Matthieu Rosenfeld. How far away must forced letters be so that squares are still avoidable? Mathematics of Computation, 89(326):3057–3071, 2020.
  22. [22]Matthieu Rosenfeld. Avoiding squares over words with lists of size three amongst four symbols. Mathematics of Computation, 91(337):2489–2500, 2022.arxiv.org/abs/2104.09965
  23. [23]Matthieu Rosenfeld. Ann wins the nonrepetitive game over four letters and the erase-repetition game over six letters. European Journal of Combinatorics, 118:103924, 2024.arxiv.org/abs/2107.14022
  24. [24]Arseny M. Shur. Two-sided bounds for the growth rates of power-free languages. In Volker Diekert and Dirk Nowotka, editors, Developments in Language Theory, volume 5583 of Lecture Notes in Computer Science, pages 466–477, Berlin, Heidelberg, 2009. Springer.DOI
  25. [25]Erika Škrabuláková. The Thue choice number versus the Thue chromatic number of graphs, 2015. arXiv:1508.02559.arxiv.org/abs/1508.02559
  26. [26]Axel Thue. Über unendliche Zeichenreihen. Norske Vid. Selsk. Skr. I. Mat. Nat. Kl. Christiania, 1906(7):1–22, 1906.
  27. [27]Axel Thue. Über die gegenseitige Lage gleicher Teile gewisser Zeichenreihen. Norske Vid. Selsk. Skr. I. Mat. Nat. Kl. Christiania, 1912(1):1–67, 1912.
  28. [28]David R. Wood. Nonrepetitive graph colouring. The Electronic Journal of Combinatorics, page DS24, 2021. Dynamic Survey.DOI
  29. [29]Huanhua Zhao and Xuding Zhu. (2 + ε)-nonrepetitive list colouring of paths. Graphs and Combinatorics, 32(4):1635–1640, 2016.DOI

Paper details

vlnc:W_udt4897v
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 11

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Mathematics

Claude, ChatGPT

View statement
Looking for related papers…
Contents