3

How many unique, prime binary sequences are there of length $n$, modulo rotations?

I have from here the number of binary sequences modulo rotations, but that does not appear deduct for non-prime sequences, by which I mean cycles which are repetitions of shorter cycles, for example $\overline{0101}_2$ is to be excluded when counting the cardinality of the length $4$ rotations, because it is a length $2$ rotation.

$\overline{0}_2$ and $\overline{1}_2$ are the unique binary cycles of length $1$, so there are two of length $1$.

Excluding those, then $\overline{01}_2$ and $\overline{10}_2$ are the cycles of length two, but these are the same modulo rotation so there's one.

Length three, we have $\overline{001}_2\cong\overline{010}_2\cong\overline{100}_2$ and $\overline{011}_2\cong\overline{101}_2\cong\overline{110}_2$ so again there are two.

Length four, I'm counting out $\overline{0101}_2$ and $\overline{1010}_2$ because those aren't "prime", they're duplicates of the length two cycle. That leaves $\overline{0111}_2\cong\overline{1110}_2\cong\overline{1101}_2\cong\overline{1011}_2$ and $\overline{1000}_2\cong\overline{0001}_2\cong\overline{0010}_2\cong\overline{0100}_2$ - so there are two distinct ones of length four.

Five is a prime number so only the length one cycles to exclude - leaving I think six possibilities: $\overline{00001}_2\neq\overline{00011}_2\neq\overline{00111}_2\neq\overline{01111}_2\neq\overline{10101}_2\neq\overline{01010}_2$

Six - we exclude the cycles of length $1,2,3$ giving us $111110,000001,110000,001111,111000,101000,010111,110010,001101$

Unless I've made a mistake we have the sequence $2,1,2,2,6,9\ldots$ or $1,2,1,2,2,6,9\ldots$ if we count one empty string, neither of which has a relevant record in OEIS.

I've included the p-adic numbers tag because these count the number of distinct $2$-adic orbits under the action of truncation.

1 Answers1

3

The standard terminology is that a word is aperiodic if it doesn't consist of repetitions of another word. Given an aperiodic word we can consider its cyclic rotations, and among all of them there is a unique smallest one in lexicographic order; so these words correspond bijectively to orbits of aperiodic words modulo cyclic rotation. They're called Lyndon words, and they can be counted using Mobius inversion as follows.

Write $M(a, n)$ for the number of Lyndon words of length $n$ on an alphabet of size $a$. An arbitrary word of length $n$ factors uniquely as a cyclic rotation of a Lyndon word of length $d$, raised to the power of $\frac{n}{d}$, for some $d \mid n$. This gives

$$a^n = \sum_{d \mid n} d M(a, d)$$

and Mobius inversion applied to this expression gives the necklace polynomial

$$M(a, n) = \frac{1}{n} \sum_{d \mid n} \mu \left( \frac{n}{d} \right) a^d$$

where $\mu$ is the Mobius function.

Now for some amusing trivia: when $a = q$ is a power of a prime this also counts irreducible polynomials of degree $n$ over $\mathbb{F}_q$ (also by a Mobius inversion argument) and these can be put in bijection with Lyndon words; see this math.SE question. When $n = p$ is prime we get that $\frac{a^p - a}{p}$ is an integer so this gives a bijective proof of Fermat's little theorem. When $n$ is composite we get a "necklace congruence" $\sum_{d \mid n} \mu \left( \frac{n}{d} \right) a^d \equiv 0 \bmod n$ which gives a generalization of Fermat's little theorem different from the totient theorem. The necklace polynomials also count the dimensions of the graded pieces of the free Lie algebra on $a$ generators.

For $a = 2$ this sequence is A001037 on the OEIS; you have a mistake in your sequence at $n = 4$ because you missed $0011$.

Qiaochu Yuan
  • 419,620
  • thanks, that was fast! – it's a hire car baby Sep 14 '22 at 18:07
  • 3
    This used to be a pet subject of mine and I wrote a few blog posts about it as a teenager: https://qchu.wordpress.com/2009/08/23/newtons-sums-necklace-congruences-and-zeta-functions/, https://qchu.wordpress.com/2009/11/04/newtons-sums-necklace-congruences-and-zeta-functions-ii/, https://qchu.wordpress.com/2009/11/03/the-cyclotomic-identity-and-lyndon-words/. – Qiaochu Yuan Sep 14 '22 at 18:09
  • I also edited in the details of the Mobius inversion argument because I remembered that it was very short. – Qiaochu Yuan Sep 14 '22 at 18:13
  • So when $a=p$ is prime, the irreducible polynomials of degree $n$ over $\Bbb F_p$ biject with the orbits of $\Bbb Q_p$ under the action of truncation, leaving $n$ the order of cyclicity of the truncated string. This enumerates and classifies the number of connected orbits of Collatz-like problems. For example the sole length two binary Lyndon word $01$ corresponds with the sequence $2,1,\ldots$ in which all known integers terminate, and which is the only terminal of order two. Happy to chat if you think you could take this research further as I am at the limit of my abilities. – it's a hire car baby Sep 14 '22 at 19:48
  • I don't understand what you mean. What is "truncation" as an operation on $\mathbb{Q}_p$? How can this operation possibly have fewer than uncountably many orbits? – Qiaochu Yuan Sep 14 '22 at 20:03
  • Sorry, they biject with the countably many orbits which eventually stabilise in a repeating sequence of length $n$. So e.g. $-\frac13\cdot2^\Bbb Z+\Bbb Z[\frac12]$ is all one orbit under truncation and it terminates in $-\frac13$ or $-\frac23$ and one of these is the length two Lyndon word. – it's a hire car baby Sep 14 '22 at 20:13
  • Okay, so what is "truncation"? – Qiaochu Yuan Sep 14 '22 at 20:18
  • Deleting characters from the right, e.g. changing $\overline{01}1_2$ to $\overline{01}_2$ (although by including all of $\Bbb Q_2$ I'm allowing moving the binary point as well.) – it's a hire car baby Sep 14 '22 at 20:22
  • The bijection is derived from the fact that when you truncate an infinite repeating sequence by one character, you are essentially cycling the repeating string by one character. The finite non-repeating part of the string just gets deleted so the quotient by the action of truncation essentially ignores the non-repeating part of the number. – it's a hire car baby Sep 14 '22 at 20:31
  • Anyway, great answer with some extra useful things to learn about so thank-you for that. – it's a hire car baby Sep 15 '22 at 07:42