Primitive word
Project: Topoi of automata
Contents
A nonempty word is primitive if it is not a proper power of another word. The motivating problem is the primitive word conjecture: is the set of primitive words a context-free language? Over a $q$-letter alphabet, primitive words behave like the elements of the algebraic closure $\overline{\mathbb F_q}$: they have the same counts, and rotating a word corresponds to the Frobenius. These analogies are classical (Moreau 1872; Golomb 1969; Reutenauer 1988); we collect them here, and the perfect shuffle of cards gives a concrete instance.
1. Idea§
Let $q$ be a prime power. The analogy between primitive words over an alphabet with $q$ letters and the elements of $\overline{\mathbb F_q}$ has the following entries. In the table, $a_n(q)$ is the number given by the counting formula.
2. Definition§
We write $v^k$ for the concatenation of $k$ copies of a word $v$.
Definition 2.1 (Primitive word)§
A primitive word is a nonempty word $w$ that is not a proper power: there are no word $v$ and no integer $k\ge2$ with $w=v^k$. Write $\mathrm{PW}_\Sigma$ for the set of primitive words over an alphabet $\Sigma$.
See Lischke.
Example 2.2 (Length three)§
Over $\Sigma=\{a,b\}$, the word $abab=(ab)^2$ is not primitive. Of the eight words of length $3$, only $aaa=a^3$ and $bbb=b^3$ are not primitive, so the primitive words of length $3$ are $aab$, $aba$, $baa$, $abb$, $bba$ and $bab$.
3. Counting§
We count the primitive words of each length. The count is a polynomial in the number of letters, and for a prime power it also counts elements of a finite field.
Fact 3.1 (Counting primitive words)§
Let $a_n(q)$ be the number of primitive words of length $n$ over $q$ letters. Every nonempty word is a power $u^k$ of exactly one primitive word $u$, so $q^n=\sum_{d\mid n}a_d(q)$. By Möbius inversion, with the Möbius function $\mu$,
Fact 3.2 (Same count in $\overline{\mathbb F_q}$)§
If $q$ is a prime power, the elements of $\overline{\mathbb F_q}$ of degree $n$ over $\mathbb F_q$ satisfy the same inversion formula with $\#\mathbb F_{q^n}=q^n$, so they are also $a_n(q)$ in number.
This classical coincidence (Gauss; Moreau 1872; Metropolis–Rota 1983) was pointed out to Hora by Yuhi Kamio.
Example 3.3 (Small lengths)§
Over $\Sigma=\{a,b\}$, the numbers of primitive words of length $1,\dots,6$ are $2,2,6,12,30,54$; those of length $2$ are $ab$ and $ba$. The same numbers count the elements of $\overline{\mathbb F_2}$ of degree $1,\dots,6$ over $\mathbb F_2$. See OEIS A027375.
Remark 3.4 (Dirichlet series)§
Let $a_n(z)=\sum_{d\mid n}\mu(n/d)z^d\in\mathbb C[z]$, so that $a_n(q)$ counts primitive words. Let $\mathrm{Li}_s(z)=\sum_{n\ge1}z^n/n^s$ be the polylogarithm and $\zeta(s)=\sum_{n\ge1}1/n^s$ the Riemann zeta function. As formal Dirichlet series,
This restates the Möbius inversion. See [Hor25a, Appendix A].
4. Rotation and Frobenius§
Rotation acts on primitive words as the Frobenius acts on $\overline{\mathbb F_q}$. Both are continuous actions of the group $\hat{\mathbb Z}$ of profinite integers, and the set of primitive words is characterized by a universal property among such actions: an equivariant map to it from a continuous $\hat{\mathbb Z}$-set is the same thing as a map from this set to the alphabet.
Definition 4.1 (Rotation action)§
Rotation is the map $a_1a_2\cdots a_n\mapsto a_2\cdots a_na_1$ on words. It preserves primitivity and defines a $\mathbb Z$-action on $\mathrm{PW}_\Sigma$ with finite orbits, hence a continuous action of $\hat{\mathbb Z}$ on the discrete set $\mathrm{PW}_\Sigma$.
Example 4.2 (Rotation orbits)§
Over $\Sigma=\{a,b\}$, the six primitive words of length $3$ form two rotation orbits.
Rotating a primitive word of length $n$ gives $n$ different words. The word $abab$ is not primitive, and its rotation orbit $\{abab,baba\}$ has only two elements.
Remark 4.3 (Necklaces)§
The rotation classes of primitive words are the aperiodic necklaces.
Lemma 4.4 (Continuous $\hat{\mathbb Z}$-sets)§☆
Let $\mathbf{Cont}(\hat{\mathbb Z})$ be the category of discrete sets with a continuous action of $\hat{\mathbb Z}$. Restriction along $\mathbb Z\to\hat{\mathbb Z}$ identifies $\mathbf{Cont}(\hat{\mathbb Z})$ with the full subcategory of $\mathbb Z$-sets in which every orbit is finite.
Proof§
We compare the actions orbit by orbit. In a continuous $\hat{\mathbb Z}$-set the stabilizers are open, hence of finite index, so the orbits are finite. Conversely, a finite $\mathbb Z$-orbit is isomorphic to some $\mathbb Z/n$, on which the action extends along $\hat{\mathbb Z}\to\mathbb Z/n$. The extension is unique, and $\mathbb Z$-equivariant maps are $\hat{\mathbb Z}$-equivariant, because $\mathbb Z$ is dense in $\hat{\mathbb Z}$ and the sets are discrete.
Lemma 4.5 (Primitive words as periodic sequences)§☆
A sequence $s\in\Sigma^{\mathbb Z}$ is periodic if there is $n\ge1$ with $s_{k+n}=s_k$ for all $k$. Sending a word $w=a_0\cdots a_{n-1}$ to the sequence $w^\infty\colon k\mapsto a_{k\bmod n}$ is a bijection from $\mathrm{PW}_\Sigma$ onto the set of periodic sequences in $\Sigma^{\mathbb Z}$, and it takes rotation to the shift $s\mapsto(k\mapsto s_{k+1})$.
Proof§
The inverse reads off one least period. The periods of a sequence form a subgroup of $\mathbb Z$, so the least period $d$ of $w^\infty$ divides $n$ and $w=(a_0\cdots a_{d-1})^{n/d}$; as $w$ is primitive, $d=n$, and $w$ is recovered from $s=w^\infty$ as $s_0\cdots s_{n-1}$. Conversely, if $s$ has least period $n$, then $w=s_0\cdots s_{n-1}$ satisfies $w^\infty=s$ and is primitive, since $w=u^m$ with $m\ge2$ would make the length of $u$ a smaller period. Rotating $w$ shifts $w^\infty$ by one.
Proposition 4.6 (Universality of primitive words)§☆
With the rotation action, $\mathrm{PW}_\Sigma$ is the cofree continuous $\hat{\mathbb Z}$-set on $\Sigma$, that is, the standard coinduced set $C(\hat{\mathbb Z},\Sigma)$ of locally constant maps [Ser97, I.2.5]: for every continuous $\hat{\mathbb Z}$-set $X$, naturally in $X$,
An equivariant map $f$ corresponds to the map that sends a point $x$ to the first letter of the word $f(x)$.
Proof§
We pass through the cofree $\mathbb Z$-set $\Sigma^{\mathbb Z}$ with the shift: the equivariant maps from a $\mathbb Z$-set $X$ to $\Sigma^{\mathbb Z}$ are the maps $x\mapsto(k\mapsto g(x\cdot k))$, one for each $g\colon X\to\Sigma$. If every orbit of $X$ is finite, these sequences are periodic, so by the periodic sequences lemma the map factors uniquely through an equivariant $f$:
By the lemma on continuous $\hat{\mathbb Z}$-sets, this is the bijection $\mathbf{Cont}(\hat{\mathbb Z})(X,\mathrm{PW}_\Sigma)\cong\mathbf{Set}(X,\Sigma)$.
Remark 4.7 (Periodic sequences)§
In terms of topoi, the homomorphism $\mathbb Z\to\hat{\mathbb Z}$ induces a hyperconnected geometric morphism $h\colon\mathbf{PSh}(\mathbb Z)\to\mathbf{Cont}(\hat{\mathbb Z})$ from the topos of $\mathbb Z$-sets. Its direct image $h_*$ takes the elements with a finite orbit, and $\mathrm{PW}_\Sigma\cong h_*(\Sigma^{\mathbb Z})$ is the set of periodic sequences in the cofree $\mathbb Z$-set $\Sigma^{\mathbb Z}$. See [Hor25a, §4].
Fact 4.8 (Rotation is Frobenius [Len85])§
Let $\Sigma=\mathbb F_q$, and regard $\mathrm{PW}_{\mathbb F_q}$ as the periodic $\mathbb F_q$-sequences with pointwise addition. Then $\mathrm{PW}_{\mathbb F_q}$ with rotation and $\overline{\mathbb F_q}$ with the action of $\mathrm{Gal}(\overline{\mathbb F_q}/\mathbb F_q)\cong\hat{\mathbb Z}$, in which $1\in\hat{\mathbb Z}$ acts by the Frobenius $x\mapsto x^q$, are isomorphic smooth representations of $\hat{\mathbb Z}$ over $\mathbb F_q$, that is, $\mathbb F_q$-vector spaces with a linear action of $\hat{\mathbb Z}$ in which the stabilizer of every vector is open.
See Len85, Theorem 1.
Remark 4.9 (Normal basis theorem)§
Since periodic sequences are the locally constant maps $\hat{\mathbb Z}\to\mathbb F_q$, this is the case $\overline{\mathbb F_q}/\mathbb F_q$ of Lenstra's normal basis theorem for infinite Galois extensions [Len85, Theorem 1]; the finite stages are in [Reu88]. Yugo Takanashi pointed out this connection to Hora.
5. Open problems§
Problem 5.1 (Primitive word conjecture)§
Is $\mathrm{PW}_\Sigma$ a context-free language when $\#\Sigma\ge2$? Dömösi, Horváth and Ito conjectured in 1991 that it is not, and the problem is open. See the survey of Lischke and the book of Dömösi and Ito.
Fact 5.2 (Not unambiguous [Pet94])§
For an alphabet $\Sigma$ with at least two letters, the language $\mathrm{PW}_\Sigma$ is not unambiguous context-free, since its generating function is transcendental.
See Petersen.
Remark 5.3 (Topos-theoretic approach)§
Hora hopes to approach the primitive word conjecture by topos-theoretic Galois theory; see p. 7 of Topoi of automata (SLACS 2025).
Question 5.4 (Analytic continuation)§
Does $\sum_{n\ge1}a_n(2)\,n^{-s}$ define a meromorphic function on $\mathbb C$? See [Hor25a, Appendix A].
6. Related concepts§
7. References§
- [Mor72] C. Moreau, Sur les permutations circulaires distinctes, Nouvelles annales de mathématiques (2) 11 (1872), 309–314.
- [Gol69] Solomon W. Golomb, Irreducible polynomials, synchronization codes, primitive necklaces, and the cyclotomic algebra, in Combinatorial Mathematics and its Applications, University of North Carolina Press (1969), 358–370.
- [Reu88] Christophe Reutenauer, Mots circulaires et polynômes irréductibles, Annales des sciences mathématiques du Québec 12 (1988), 275–285.
- [MR83] Nicholas Metropolis and Gian-Carlo Rota, Witt vectors and the algebra of necklaces, Advances in Mathematics 50 (1983), 95–125.
- [Ser97] Jean-Pierre Serre, Galois Cohomology, Springer (1997), I.2.5.
- [Hor25a] Ryuya Hora, Notes on primitive words, personal note, 2025, unpublished.
- [Hor25b] Ryuya Hora, Topoi of automata, slides, SLACS 2025, 31 October 2025, p. 7.
- [HK24] Ryuya Hora and Yuhi Kamio, Quotient toposes of discrete dynamical systems, Journal of Pure and Applied Algebra (2024), 107657.
- [Len85] Hendrik W. Lenstra, Jr., A normal basis theorem for infinite Galois extensions, Indagationes Mathematicae (Proceedings) 88 (1985).
- [DHI91] Pál Dömösi, Sándor Horváth and Masami Ito, On the connection between formal languages and primitive words, Proceedings of the First Session on Scientific Communication, University of Oradea, 1991, 59–67.
- [Pet94] Holger Petersen, The ambiguity of primitive words, STACS 94, Lecture Notes in Computer Science 775 (1994), 679–690.
- [Lis11] Gerhard Lischke, Primitive words and roots of words, Acta Universitatis Sapientiae, Informatica 3(1) (2011), 5–34.
- [DI14] Pál Dömösi and Masami Ito, Context-free languages and primitive words, World Scientific, 2014.