← The Cycle Rank of the Box Graph of an Automatic Wordv1 · 20 Nov 2026 · Full text from the LaTeX source · PDF · DOI 10.5281/zenodo.24383884

The cycle rank of the box graph of an automatic word

Eric Guideng Independent researcher, Las Vegas, Nevada
(Date: November 19, 2026)
Abstract.

For an infinite word 𝐰, Bell asked whether the number C⁢(N) of connected components of the variety of degree-(N+1) truncated point modules of the monomial algebra A𝐰 is k-regular whenever 𝐰 is k-automatic, and reformulated it as the number of connected components of a graph GN on the factors of length N+1 of 𝐰. We show that the question is exactly a question about cycles: C⁢(N)=p𝐰⁢(N+1)−E⁢(N)+β1⁢(GN), where p𝐰 is the subword complexity, E⁢(N) the number of edges and β1 the cycle rank, and the first two terms are k-regular because they are first-order definable. So C is k-regular if and only if β1⁢(GN) is. For binary words, GN is a forest as soon as at most one position carries two or more edges. Using Walnut we prove that this holds for every N for the period-doubling, paperfolding, Thue–Morse, Rudin–Shapiro and Mephisto waltz words, with C⁢(N)=p𝐰⁢(N+1)−(N+1) for the first two and C⁢(N)=p𝐰⁢(N+1)−2 for the last three. For the ternary word fixed by 0↦012, 1↦120, 2↦201 we prove that GN has exactly three triangles for every N≥1, so β1⁢(GN)=3 and C⁢(N)=p𝐰⁢(N+1)−6: cycles occur, and the answer is still positive. Letter permutations preserving the factors act on GN, and the proofs use them to reduce to one pair of letters. This answers Bell’s question for these six words. We conjecture that β1⁢(GN) is eventually constant for every word of linear subword complexity, which would answer the question in general.

Key words and phrases:
Automatic sequences, k-regular sequences, subword complexity, point modules, monomial algebras, Walnut
2020 Mathematics Subject Classification:
Primary 68R15; Secondary 11B85, 16S38, 03D05
ORCID 0009-0005-3166-0065

1. Introduction

Let 𝐰=w0⁢w1⁢w2⁢⋯ be a right-infinite word over a finite alphabet Σ, let p𝐰⁢(n) be the number of distinct factors of length n of 𝐰, and let X𝐰 be the closure of the orbit of 𝐰 under the left shift. Bell and Greenfeld describe the point modules of the graded monomial algebra A𝐰, whose degree-n component has dimension p𝐰⁢(n), through families of factors with a common right-infinite continuation [5]. In [4] Bell counts the irreducible components of the variety 𝒫N⁢(A𝐰) of truncated point modules: they correspond to the maximal extendable boxes S0⁢S1⁢⋯⁢SN, with Si⊆Σ, and for k-automatic 𝐰 their numbers are k-regular. He closes with the following question [4, §8].

Question 1 (Bell).

For a k-automatic word 𝐰, is the number of connected components of 𝒫N⁢(A𝐰) always k-regular?

Bell restates it in terms of words. Let GN be the graph whose vertices are the factors of length N+1 of 𝐰, with u and v joined when they differ in exactly one position and there is a right-infinite word 𝐳 with u⁢𝐳,v⁢𝐳∈X𝐰. Then the number of connected components of 𝒫N⁢(A𝐰) is the number C⁢(N) of connected components of GN [4, §8]. Bell notes that the first-order method of Charlier, Rampersad and Shallit [8], which gives his counts of boxes, does not apply directly, since connectedness is not a first-order property.

Our first result isolates exactly what is not first-order. Write E⁢(N) for the number of edges of GN and β1⁢(GN)=E⁢(N)−p𝐰⁢(N+1)+C⁢(N) for its cycle rank, the dimension of its cycle space.

Theorem A (5).

For every infinite word 𝐰, C⁢(N)=p𝐰⁢(N+1)−E⁢(N)+β1⁢(GN). If 𝐰 is k-automatic, then N↦p𝐰⁢(N+1) and N↦E⁢(N) are k-regular, so C is k-regular if and only if N↦β1⁢(GN) is. In particular, if GN is a forest for every N, then C⁢(N)=p𝐰⁢(N+1)−E⁢(N) is k-regular.

The edges of GN carry a label, the position at which their two words differ. For binary words this gives a simple test for cycles (7): if at most one position carries two or more edges, GN is a forest. The labels and the edge counts are first-order, so the test can be decided with Walnut [9, 10].

Theorem B (8 and 10).

For every N≥1, the graph GN has the following edges and components:

  1. (1)

    period-doubling and paperfolding: exactly one edge at each position r≤N; GN is a forest and C⁢(N)=p𝐰⁢(N+1)−(N+1);

  2. (2)

    Thue–Morse, Rudin–Shapiro and the Mephisto waltz: exactly two edges, both at position 0, exchanged by the flip 0↔1; GN is a forest and C⁢(N)=p𝐰⁢(N+1)−2;

  3. (3)

    the 3-automatic word fixed by φ:0↦012, 1↦120, 2↦201: exactly three triangles {0⁢s,1⁢s,2⁢s}, with s the prefixes of length N of the three fixed points of φ, permuted by the rotation 0→1→2→0; β1⁢(GN)=3 and C⁢(N)=p𝐰⁢(N+1)−6.

Hence 1 has a positive answer for these six words.

So cycles do occur, and in the third case they do not prevent a positive answer. The letter symmetries organize the proofs: a permutation of the letters that preserves the factors of 𝐰 is an automorphism of every GN (3), so it is enough to prove the statements for one pair of letters, and the other edges and triangles follow. In the tribonacci word GN has one triangle, and in every case we computed the cycle rank is constant from N=1 on (2). We conjecture that this always happens.

Conjecture C (11).

For every infinite word of linear subword complexity, β1⁢(GN) is eventually constant. In particular, 1 has a positive answer for every automatic word.

2. The box graph

We use the notation of the introduction. A word u is a factor of 𝐰 if u=wi⁢wi+1⁢⋯⁢wi+|u|−1 for some i; the finite factors of the elements of X𝐰 are exactly the factors of 𝐰, so 𝐳∈X𝐰 if and only if every prefix of 𝐳 is a factor of 𝐰.

Definition 2.

Two factors u,v of the same length have a common continuation if there is a right-infinite word 𝐳 with u⁢𝐳,v⁢𝐳∈X𝐰. The box graph GN has the factors of length N+1 as vertices, and an edge between u and v if they differ in exactly one position r∈{0,…,N} and have a common continuation; r is the label of the edge. We write E⁢(N) for the number of edges, C⁢(N) for the number of connected components, and β1⁢(GN)=E⁢(N)−p𝐰⁢(N+1)+C⁢(N).

By König’s lemma, u and v have a common continuation if and only if for every m≥0 there is a word y of length m with u⁢y and v⁢y both factors of 𝐰 [4]. Every factor is a vertex, since a factor u of length N+1 spans a zero-dimensional extendable box [4]; an extendable box of positive dimension is a connected subgraph of GN, and two maximal extendable boxes give intersecting components of 𝒫N⁢(A𝐰) exactly when they share a word. This is why C⁢(N) is the number of connected components of 𝒫N⁢(A𝐰) [4, §8].

The integer β1⁢(GN) is the cycle rank of GN: it is nonnegative, and it vanishes if and only if GN is a forest. An extendable box with two branching positions gives a 4-cycle, and an extendable box with a coordinate set of size 3 gives a triangle; cycles may also run through several boxes.

Lemma 3 (symmetry).

Let π be a permutation of Σ, applied letter by letter to words, that maps the set of factors of 𝐰 to itself. Then π⁢(X𝐰)=X𝐰, and π induces an automorphism of every GN that preserves the labels of the edges.

Proof.

A right-infinite word lies in X𝐰 exactly when all its prefixes are factors, and π preserves this property and its inverse does too, as π permutes the finite set of factors of each length. So u⁢𝐳,v⁢𝐳∈X𝐰 implies π⁢(u)⁢π⁢(𝐳),π⁢(v)⁢π⁢(𝐳)∈X𝐰, and π preserves the positions at which two words differ. ∎

Lemma 4 (short heads).

If GN has an edge with label r≥1, then there are letters c and a≠b and a right-infinite word 𝐲 with c⁢a⁢𝐲,c⁢b⁢𝐲∈X𝐰.

Proof.

Write the two words of the edge as h⁢a⁢t and h⁢b⁢t with |h|=r, and let 𝐳 be a common continuation. Let c be the last letter of h. Since X𝐰 is closed under the shift, c⁢a⁢t⁢𝐳 and c⁢b⁢t⁢𝐳 lie in X𝐰; put 𝐲=t⁢𝐳. ∎

3. The reduction to cycles

Let 𝐰 be k-automatic. We work, as Bell does, in the first-order structure (ℕ,+,<,(Pa)a∈Σ) with Pa⁢(i)⇔wi=a. Every relation definable in it is k-recognizable [6], and we use the counting theorem of Charlier, Rampersad and Shallit in the form stated in [4, §5]: if R⊆ℕ1+s is k-recognizable and every fibre RN={𝐱:(N,𝐱)∈R} is finite, then N↦|RN| is k-regular [8].

Theorem 5.

Let 𝐰 be an infinite word over a finite alphabet. Then C⁢(N)=p𝐰⁢(N+1)−E⁢(N)+β1⁢(GN) for every N. If 𝐰 is k-automatic, the sequences N↦p𝐰⁢(N+1) and N↦E⁢(N) are k-regular, and the following are equivalent:

  1. (1)

    N↦C⁢(N) is k-regular;

  2. (2)

    N↦β1⁢(GN) is k-regular.

Proof.

The identity is the definition of β1. Put n=N+1 and define, with all quantifiers over ℕ,

Feq⁢(i,j,n) :∀t⁢(t<n⇒wi+t=wj+t),
Fo⁢(i,n) :∀j⁢(j<i⇒¬⁢Feq⁢(j,i,n)),
Dif⁢(i,j,n,r) :r<n∧wi+r≠wj+r∧∀t⁢((t<n∧t≠r)⇒wi+t=wj+t),
Cc⁢(i,j,n) :∀m⁢∃c,d⁢(Feq⁢(c,i,n)∧Feq⁢(d,j,n)∧∀t⁢(t<m⇒wc+n+t=wd+n+t)),

where wx=wy abbreviates ⋁a∈Σ(Pa⁢(x)∧Pa⁢(y)). Fo⁢(i,n) says that i is the first occurrence of its factor of length n; Dif says that the factors at i and j differ exactly at position r; and, by König’s lemma, Cc says that they have a common continuation. So

p𝐰⁢(N+1) =|{i:Fo⁢(i,n)}|,
E⁢(N) =|{(i,j):i<j∧Fo⁢(i,n)∧Fo⁢(j,n)∧∃r⁢Dif⁢(i,j,n,r)∧Cc⁢(i,j,n)}|,

each a fibre count of a definable relation with finite fibres, since a factor has one first occurrence. Both are k-regular by the counting theorem. Since k-regular sequences form a ring [1], C−β1=p𝐰(⋅+1)−E is k-regular, which gives the equivalence. ∎

Corollary 6.

If 𝐰 is k-automatic and β1⁢(GN) is eventually constant, in particular if GN is a forest for all large N, then C is k-regular.

Proof.

An eventually constant sequence is k-regular [1]. ∎

4. A cycle test for binary words

Lemma 7.

Let |Σ|=2. If at most one label is carried by two or more edges of GN, then GN is a forest. In particular GN is a forest if every label is carried by at most one edge, or if all edges carry the same label.

Proof.

Over a binary alphabet, crossing an edge with label r changes the letter at position r and no other. Along a cycle every letter returns to its value, so every label occurs on the cycle an even number of times. If only one label r occurred, the cycle would alternate between a word and the word obtained by changing position r, and would not be simple. So a cycle uses two distinct labels, each at least twice, and two labels are each carried by at least two edges of GN. ∎

Over larger alphabets the lemma fails: the words a⁢s, b⁢s, c⁢s may be joined pairwise by edges with label 0, and this happens in 6.

When all edges of a binary word carry the label 0, an edge is a pair {0⁢s,1⁢s} with |s|=N, determined by s; so E⁢(N) is the number of words s of length N such that 0⁢s and 1⁢s are factors with a common continuation, that is, such that s is a prefix of some 𝐳 with 0⁢𝐳,1⁢𝐳∈X𝐰.

5. Six words

word k morphism coding
period-doubling 2 0↦01, 1↦00 —
paperfolding 2 a↦a⁢b, b↦c⁢b, c↦a⁢d, d↦c⁢d a,b↦1, c,d↦0
Thue–Morse 2 0↦01, 1↦10 —
Rudin–Shapiro 2 a↦a⁢b, b↦a⁢c, c↦d⁢b, d↦d⁢c a,b↦0, c,d↦1
Mephisto waltz 3 0↦001, 1↦110 —
Table 1. The words of 8: each is the fixed point starting with the first letter listed, followed by the coding.
Theorem 8.

Let 𝐰 be one of the words of 1. For every N≥0, GN is a forest, and:

  1. (1)

    for period-doubling and paperfolding, every label r∈{0,…,N} is carried by exactly one edge, so E⁢(N)=N+1 and C⁢(N)=p𝐰⁢(N+1)−(N+1);

  2. (2)

    for Thue–Morse, Rudin–Shapiro and the Mephisto waltz and N≥1, every edge has label 0 and there are exactly two edges, so C⁢(N)=p𝐰⁢(N+1)−2.

In particular C is k-regular for each of the five words, with k as in 1.

Proof.

Each word is the image under a coding of the fixed point of a k-uniform morphism, so it is k-automatic, read by the automaton whose states are the letters and whose transitions on the digit d are the d-th letters of the images [2]; the automata are the files X*.txt of the ancillary material. We encode Feq, Dif and Cc of 5 in Walnut [9], with Edge:=Dif∧Cc, and decide the following sentences, where n=N+1:

  • (S1)

    every edge with n≥2 has label 0;

  • (S2)

    two edges with the same label join the same pair of factors;

  • (S3)

    every label r<n is carried by an edge;

  • (L1)

    for every N≥1 there are exactly two factors s of length N such that 0⁢s and 1⁢s are factors with a common continuation.

Walnut returns TRUE for (S2) and (S3) on period-doubling and paperfolding, and for (S1) and (L1) on Thue–Morse, Rudin–Shapiro and the Mephisto waltz. For (1), every label is carried by exactly one edge, so GN is a forest by 7 and E⁢(N)=N+1. For (2), all edges have label 0, so GN is a forest by 7, and by the remark after it E⁢(N) is the number of words s in (L1), which is 2. In both cases C⁢(N)=p𝐰⁢(N+1)−E⁢(N), and C is k-regular by 5, as N+1 and the constant 2 are k-regular. ∎

As controls, Walnut returns TRUE for the existence of edges at n=5 and n=40 on all five words, FALSE for (S1) on period-doubling and paperfolding, and FALSE for the statement that exactly one word s satisfies (L1). For N=0 the graph is a single edge {0,1} and C⁢(0)=1 for all five words.

Remark 9 (the flip).

For Thue–Morse, Rudin–Shapiro and the Mephisto waltz, Walnut also returns TRUE for: (F0) the factors are closed under the flip 0↔1; and (F1) the two words s of (L1) are flips of each other. By 3 the flip is an automorphism of GN, and it exchanges the two edges.

Theorem 10.

Let 𝐰 be the fixed point starting with 0 of φ:0↦012, 1↦120, 2↦201, and let σ be the rotation 0→1→2→0 of the letters. For every N≥1, the edges of GN are those of the three triangles {0⁢s,1⁢s,2⁢s}, where s runs over the prefixes of length N of the fixed points φ∞⁢(0)=𝐰, φ∞⁢(1)=σ⁢(𝐰) and φ∞⁢(2)=σ2⁢(𝐰). These triangles are disjoint, so E⁢(N)=9, β1⁢(GN)=3 and C⁢(N)=p𝐰⁢(N+1)−6, which is 3-regular.

Proof.

Since σ⁢φ=φ⁢σ, σ permutes the three fixed points, σ⁢(φ∞⁢(e))=φ∞⁢(e+1) with e mod 3. Let PN be the set of their prefixes of length N; it has three elements, with first letters 0, 1, 2, and σ⁢(PN)=PN. Walnut returns TRUE for:

  • (R0)

    the factors of 𝐰 are closed under σ;

  • (R2)

    for N≥1, a factor s of length N has 0⁢s and 1⁢s factors with a common continuation if and only if s∈PN;

  • (R3)

    every element of PN is a factor;

  • (T)

    for each e, the words x of length 2 with x⁢φ∞⁢(e)∈X𝐰 are exactly 01, 12, 20;

and FALSE for the control obtained from (R2) by replacing PN with the prefixes of 𝐰 alone. By (R0) and 3, σ is a label-preserving automorphism of each GN, and every unordered pair of distinct letters is σj⁢{0,1} for some j.

Left extensions of infinite words. Let 𝐲 be right-infinite with a⁢𝐲,b⁢𝐲∈X𝐰 for letters a≠b. Applying σ−j with σ−j⁢{a,b}={0,1}, we get 0⁢𝐲′,1⁢𝐲′∈X𝐰 for 𝐲′=σ−j⁢(𝐲). For every N≥1 the prefix of length N of 𝐲′ satisfies the condition of (R2), so it lies in PN; as the elements of PN are determined by their first letters, 𝐲′ is one of the three fixed points, and so is 𝐲=σj⁢(𝐲′).

All labels are 0. If GN had an edge with label r≥1, 4 would give letters c and a≠b and 𝐲 with c⁢a⁢𝐲,c⁢b⁢𝐲∈X𝐰. By the previous paragraph 𝐲 is a fixed point, and then c⁢a and c⁢b are two words of (T) with the same first letter, which do not exist.

The edges with label 0. An edge with label 0 is a pair {a⁢s,b⁢s} with a≠b and a common continuation. Applying σ−j as above gives the pair {0⁢σ−j⁢(s),1⁢σ−j⁢(s)}, so σ−j⁢(s)∈PN by (R2), and s∈σj⁢(PN)=PN. Conversely, for s∈PN and any pair {a,b}=σj⁢{0,1}, (R2) and (R3) give an edge {0⁢σ−j⁢(s),1⁢σ−j⁢(s)}, and σj carries it to an edge joining a⁢s and b⁢s. So the edges are exactly the triangles {0⁢s,1⁢s,2⁢s} with s∈PN; they are disjoint since the three words s differ. A disjoint union of three triangles and isolated vertices has cycle rank 3, and C⁢(N)=p𝐰⁢(N+1)−9+3. The sequence is 3-regular by 5. ∎

For N=0 the graph is the single triangle on the letters, and C⁢(0)=1.

6. Cycles

word class E⁢(N) β1⁢(GN) status
period-doubling, paperfolding 2-automatic N+1 0 8, all N
Thue–Morse, Rudin–Shapiro 2-automatic 2 0 8, all N≥1
Mephisto waltz 3-automatic 2 0 8, all N≥1
Cantor, 1↦101, 0↦000 3-automatic 4 (N≥3) 0 computed, N≤24
vtm, a↦a⁢b⁢c, b↦a⁢c, c↦b 2-automatic 2 0 computed, N≤24
0↦012, 1↦120, 2↦201 3-automatic 9 3 10, all N≥1
Fibonacci, 0↦01, 1↦0 Sturmian 1 0 computed, N≤24
tribonacci, 0↦01, 1↦02, 2↦0 Arnoux–Rauzy 4 1 computed, N≤24
Table 2. Edges and cycle rank of GN for N≥1. “Computed” means direct enumeration by box_graph.py, with continuations of length 8⁢(N+1) and 16⁢(N+1) agreeing.

2 collects the results and the computations. Two of the words have cycles: the ternary word of 10, with three triangles, and the tribonacci word, an Arnoux–Rauzy word of complexity 2⁢n+1 [3], where GN has one triangle and one further edge, with label 1, so β1⁢(GN)=1.

In every example the cycles are triangles of label-0 edges. Edges with label 0 are always few when the complexity is linear: if a⁢s and b⁢s (a≠b) are factors, then s is left special, and the number of left special factors of length N is at most p𝐰⁢(N+1)−p𝐰⁢(N)+1, which is bounded when p𝐰 is linear [7]; so at most (|Σ|2) edges with label 0 hang on each of a bounded number of words s. Edges with other labels need not be few, since period-doubling has one at every position, but in every example they close no cycle.

Conjecture 11.

For every infinite word of linear subword complexity, β1⁢(GN) is eventually constant. In particular, by 6, 1 has a positive answer for every automatic word, since automatic words have linear subword complexity [2].

A weaker statement already suffices for 1: by 5, it is enough that β1⁢(GN) be k-regular. The binary case is a natural first test. By 7 a cycle of a binary word needs two labels each carried by at least two edges, and in none of the binary words of 2 do two labels carry two edges each.

Question 12.

Is GN a forest for all large N for every binary word of linear subword complexity?

Code and data availability

The ancillary files are box_graph.py, which builds the words of 1 and 2 and computes p𝐰⁢(N+1), E⁢(N), C⁢(N), β1⁢(GN) and the edge labels for N≤24 by direct enumeration, and checks the triangles of the ternary word of 6, with its log; and the directory walnut/, which contains the word automata X*.txt (written by mkwords.py), the command files with the sentences (S1)–(S3), (L1), (F0), (F1), (R0), (R2), (R3), (T) and the controls, the script run_all.sh, and the logs. The Walnut computations used Walnut version 4.0.0, built from its source, with a 6 GB heap; all of them together take about five minutes. The sentences for 10 are stated for the pair of letters 0,1 and for words of length 2 only, and the rotation σ supplies the rest; the corresponding sentences for all pairs of letters and all labels exceed that heap.

References

  • [1] J.-P. Allouche and J. Shallit, The ring of k-regular sequences, Theoret. Comput. Sci. 98 (1992), 163–197.
  • [2] J.-P. Allouche and J. Shallit, Automatic Sequences: Theory, Applications, Generalizations, Cambridge University Press, 2003.
  • [3] P. Arnoux and G. Rauzy, Représentation géométrique de suites de complexité 2⁢n+1, Bull. Soc. Math. France 119 (1991), 199–215.
  • [4] J. Bell, Boxes in infinite words: complexity, automata, and point modules, arXiv:2611.21772, 2026.
  • [5] J. P. Bell and B. Greenfeld, Noncommutative point spaces of symbolic dynamical systems, Adv. Math. 469 (2025), 110211.
  • [6] V. Bruyère, G. Hansel, C. Michaux and R. Villemaire, Logic and p-recognizable sets of integers, Bull. Belg. Math. Soc. Simon Stevin 1 (1994), 191–238.
  • [7] J. Cassaigne, Special factors of sequences with linear subword complexity, in: Developments in Language Theory II (Magdeburg, 1995), World Scientific, 1996, 25–34.
  • [8] E. Charlier, N. Rampersad and J. Shallit, Enumeration and decidable properties of automatic sequences, Internat. J. Found. Comput. Sci. 23 (2012), 1035–1066.
  • [9] H. Mousavi, Automatic theorem proving in Walnut, arXiv:1603.06017, 2016.
  • [10] J. Shallit, The Logical Approach to Automatic Sequences: Exploring Combinatorics on Words with Walnut, London Math. Soc. Lecture Note Ser. 482, Cambridge University Press, 2022.

Cite: Guideng, E. (2026). The Cycle Rank of the Box Graph of an Automatic Word (v1). Zenodo. Guideng Institute, Las Vegas, NV, USA. https://doi.org/10.5281/zenodo.24383884