Construction of some nonautomatic sequences by cellular automata

. It is known that if p is a prime number, the columns of linear CA are p - automatic sequences and all p -automatic sequences can be realized by some linear CA with memory. We give some constructions of (nonlinear) CA that realize certain nonautomatic sequences. First, we show through a recoding that from a construction with additional symbols, we can construct a CA using only the symbols occurring in the sequence. This answers a question posed by Rowland and Yassawi. Then, we propose a construction for the characteristic sequence of the integer polynomials, which are nonautomatic sequences by the Minsky–Papert criterion. We also provide a construction based on the indicator of Fibonacci numbers for the Fibonacci word, which is an emblematic nonautomatic sequence.


Introduction
A one-dimensional cellular automaton (CA) is a dynamical system (A Z , F ), where A is a finite set, and where the map F : A Z → A Z is defined by a local rule which acts uniformly and synchronously on the configuration space. Precisely, there exists an integer r ≥ 0 called the radius of the CA, and a local rule f : A 2r+1 → A such that ∀x ∈ A Z , ∀k ∈ Z, F (x) k = f ((x k+i ) −r≤i≤r ). By the Curtis-Hedlund-Lyndon theorem, a map F : A Z → A Z is a CA if and only if it is continuous with respect to the product topology, and it commutes with the shift map σ defined by σ(x) k = x k−1 , ∀x ∈ A Z , ∀k ∈ Z.
Let A be a finite set containing an element denoted by 0, and let F : A Z → A Z be a CA. We say that F is 0-quiescent if F (0 Z ) = 0 Z . A configuration x ∈ A Z is said to be finite if the set {k ∈ Z : x k = 0} is finite. We denote by C 0 (A) the set of finite configurations of A Z .
In the present paper, we study the set of sequences of A N that can occur as a column sequence in the space-time diagram of some one-dimensional CA, with a finite initial configuration. Precisely, we study the set S of sequences having the form (F n (x) 0 ) n≥0 , where F is a 0-quiescent CA on A Z and where x ∈ C 0 (A). Thus, S = (F n (x) 0 ) n≥0 ∈ A N : F is a 0-quiescent CA on A Z and x ∈ C 0 (A) .
With the terminology introduced by Mazoyer and Terrier, this corresponds to the notion of Fischer's produced sequences [11,Def. 5]. We will use in particular the following closure property of S: if u ∈ S then, for any sequence v that differs from u in a finite number of positions only, we also have v ∈ S. Mazoyer and Terrier have also investigated further properties of the set S above, and proved that it is stable by different operations. Here, we are particularly interested in clarifying the relationship to (non)automaticity of the underlying sequences, and we propose effective constructions for some specific families of sequences.
When A = F p , a CA F is said to be linear if it defines an F p -linear map. Equivalently, this means that the local rule of F can be written as f ((x i ) −r≤i≤r ) = r i=−r α i x i , for some r ≥ 0 and coefficients α i ∈ F p . A deterministic finite automaton with output (DFAO) is a 6-tuple (Q, Σ k , δ, s 0 , A, ω) where Q is a finite set of states, Σ k = {0, 1, . . . , k − 1}, s 0 ∈ Q is the initial state, A is a finite alphabet, ω : Q −→ A is the output function, and δ : Q × Σ k −→ Q is the transition function. A sequence (u n ) n 0 of elements in A is k-automatic if there is a DFAO (Q, Σ k , δ, s 0 , A, ω) such that u n = ω(δ(s 0 , (n) k )) for all n 0, where (n) k is the word constituted by the digits of the standard base-k representation of n. We refer to the book of Allouche and Shallit [1,Sections 5,6] for the robustness of the concept of automatic sequences and their various characterizations.
In 1993, Litow and Dumas [10] proved that if p is a prime number, every column of a linear CA over F p (with a finite initial configuration) is p-automatic. In 2015, Rowland and Yassawi [14] established a converse statement. Namely, for any p-automatic sequence, they show how to obtain that sequence as a column of a linear CA with memory, with eventually periodic initial conditions.
Let us now consider nonautomatic sequences. By the results above, they cannot be realized by a linear CA. However, for some nonautomatic sequences having a simple algorithmic description, we can reasonably think that they can be obtained with other kinds of CA. Throughout the present article, we will focus on binary sequences, that is, we will assume that the set of symbols is A = {0, 1}. Then, a sequence u ∈ A N is characterized by the set of positions k ∈ N such that u k = 1. For a subset E of N, we denote by u = 1 E the sequence defined by u k = 1 ⇐⇒ k ∈ E.
Let f : N → N be an increasing function and π f (x) = #{n : f (n) ≤ x}. Minsky and Papert [12] showed that if lim x→∞ π f (x)/x = 0 and lim n→∞ f (n+1)/f (n) = 1, then the sequence is a polynomial of degree d ≥ 2 such that P (N) ⊂ N, and P is strictly increasing on N, then the Minsky-Papert criterion is satisfied (since π P (x) is of order x 1/d ), meaning that the sequence 1 P (N) is nonautomatic. Note that the case of nonrecognizability of the squares was known before the work of Minsky and Papert, namely, it follows from work of Büchi [3] concerning second order weak arithmetic. Ritchie [13] gave a short proof of this fact in the case for squares in base-2 expansions (see also [1,Section 5.5,p.166]). However, as shown in particular by Delacourt, Poupet, Sablik and Theyssier [5], there exists a simple CA giving the characteristic function of the squares in its column, using only three additional symbols corresponding to walls and left and right signals.
Another example of nonautomatic sequence is given by u = 1 P , where P denotes the set of prime numbers. With the help of the prime number theorem, the Minsky-Papert criterion can also be used to prove the nonautomaticiy of this sequence. This means that the primes cannot be recognized by a finite automaton. A first intricate construction of that sequence as a column of CA was provided by Fischer [6], then a simpler one was proposed by Korec [8], using only a few signals having different speeds.
In the present article, we describe two constructions of nonautomatic sequences, one that realizes the characteristic function of any polynomial of any arbitrary fixed degree d ≥ 2 (Section 3), and one that realizes the Fibonacci word (Section 4) which is an emblematic morphic and nonautomatic word.
Before presenting our constructions, we show that any sequence that can be obtained with the help of auxiliary symbols from a larger set B ⊃ A can also be obtained with a CA defined on A Z (Prop. 1). Our proof is based on a binary recoding of the elements of B, a technique already used for the construction of primes [8]. As a consequence of this result, in order to prove that a sequence belongs to S, it is sufficient to provide a CA that uses additional states, and this is what we will do. In particular, this recoding answers a question asked by Rowland and Yassawi, since it shows that any 3-automatic sequence on a 2-letter alphabet occurs as a column of a (nonlinear) 2-state space-time diagram [14, third question on p. 80].
In contrast with these results, we also give an elementary proof of the fact that there are computable sequences that lie outside of S, meaning that the class of computable sequences is "richer" than the set of sequences obtained via CA (Prop. 5). We end with some open questions, asking whether some concrete sequences that are relevant in number theory or in combinatorics can be obtained by a CA or not.

Binary recoding
Let us recall that for the rest of the article, we will consider a binary set of symbols: A = {0, 1}. Proposition 1. Let B be a finite set of symbols such that B A, let F : B Z → B Z be a 0-quiescent CA, and let x ∈ B Z be a finite configuration. If ∀n ∈ N, F n (x) 0 ∈ A, then, Proof. Without loss of generality, let us assume that B = {0, . . . , k−1} for some k ≥ 3. We recode the k symbols of the alphabet B by binary words of length 2k − 1, using the map τ : B → A 2k−1 defined as follows: From a configuration x ∈ B Z , the concatenation of the blocks τ (x i ) for i ∈ Z gives rise to a new configurationx ∈ A Z , where we assume that the block τ (x 0 ) starts at position 0 in the new configuration, meaning that (x i ) 0≤i≤2k−2 = τ (x 0 ). With this recoding, it is possible to determine locally the boundaries between the blocks in the new configuration, except if we have a long range of 0's. But in that case, since F is 0-quiescent, we know that the local function will output a 0. So, using this recoding, we can define a new CA G : A Z → A Z of radius (2k − 1)r + 2k − 2 = (2k − 1)(r + 1) − 1 that mimics on A Z the action of the original CA F : B Z → B Z , and G is itself a 0-quiescent CA. Since the first letter of τ (0) and τ (1) are respectively 0 and 1, if there is no occurence of symbols from B \ A in the central column, then we will have: ∀n ∈ N, F n (x) 0 = G n (x) 0 .
Example 1. In particular, if B = {0, 1, 2}, the recoding τ above is defined by: τ (0) = 00000, τ (1) = 11000, τ (2) = 101000, and the construction answers a question asked by Rowland and Yassawi [14]. Indeed, it proves that any 3-automatic sequence (u n ) n≥0 on a binary alphabet occurs as a column of a (nonlinear) 2-state space-time diagram. On Fig. 1, we present an illustration for the 3-automatic sequence defined by u n = 1 T , where T = {3 n : n ∈ N}. We can use the method of Rowland and Yassawi [14] to obtain this sequence as a column of a linear CA with memory 2, with a finite initial configuration. Let us denote by φ(m, n) the value of the cell on column m ∈ Z and line n ∈ N. The local rule obtained to generate the space-time diagram is given, for all m ∈ Z and n ≥ 2, by: φ(m, n+2) = φ(m+1, n)+φ(m−2, n). In particular there are only 0's on all lines of even rank. For a better readability, we represent 0's by empty cells. Time axis is oriented upward. The four first lines correspond to initial conditions, and the sequence (u n ) n≥0 appears in the red framed column. Fig. 2 shows the space-time diagram after recoding.

Remark 1. For a larger alphabet
it is also possible to recode the elements of B by blocks made by elements of A only. Let us assume that B = {0, . . . , k − 1}, with k > q. We recode the k symbols of the alphabet B by words of length 2k − 1, using the map ω : B → A 2k−1 defined as follows: Remark 2. In order to optimize the size of the blocks in the recoding, we can use some further results on non-overlapping codes [2]. Two words u and v (not necessarily distinct) are said to be overlapping if a non-empty proper prefix of u is equal to a non-empty proper suffix of v, or the converse. A code C ⊆ A n is non-overlapping if for all (not necessarily distinct) u, v ∈ C, the words u and v are non-overlapping. For an integer k ∈ {0, . . . , n − 1}, we can build a non-overlapping code C (k) n of length n by considering the family of words c ∈ A n satisfying the following properties: c i = 0 for 1 i k, c k+1 = 1, c n = 1, and the sequence c k+2 , c k+3 , . . . , c n−1 does not contain k consecutive 0's (see [4,7,9]). Let us denote by F (k) n the number of codewords obtained, that is, the cardinality of C (k) n . One can check that the sequence (F n , which corresponds to the k-step Fibonacci sequence.
If B is an alphabet with k letters, we can match each letter k ≥ 1 with a codeword of a non-overlapping code, and match 0 with the block of 0 · · · 0 of the same size. The set obtained is no more exactly a non-overlapping code, but it is enough for our purpose, since we can determine locally the boundaries between blocks as soon as there is one occurence of 1, and the CA F is assumed to be 0-quiescent. For example, for a length n = 9, if we consider the words starting with two 0's, with a 1 at the third position and a 1 at the last position, the construction above provides 13 codewords, and with the recoding of the symbol 0 by a block of 0's, this allows to handle an alphabet of 14 letters. In comparison, with the map τ introduced earlier, as soon as the alphabet contains more than 5 letters, the length of the recoding is already larger than 9.
Remark 3. Prop. 1 can be strengthened in the following way. Let π : B → A define a symbolto-symbol projection from B to A. Assume that u ∈ B N occurs as a column of a CA on B with a finite initial configuration, and consider the sequence v = π(u), defined by v n = π(u n ) for all n ∈ N. Then, the sequence v occurs as a column of a CA on A with a finite initial configuration.

Polynomial sequences
In this section we present a CA that realizes the indicator function of any given polynomial P (under suitable conditions) in column 0, thus showing that 1 P (N) ∈ S. As seen in Section 1, these are typical sequences that are nonautomatic. By the results of Mazoyer and Terrier [11], these sequences are constructible by CA, as the underlying set can be obtained by successive addition and multiplication operations. Our aim here is to generalize the geometric construction for squares due to Mazoyer and Terrier [11,Fig. 5], and used again by Delacourt, Poupet, Sablik and Theyssier [5,Section 3], that involves the notion of walls (i.e. signals of speed 0) and of directed left and right signals. While the constructions proposed by Mazoyer and Terrier for polynomials of higher degree use several signals zigzaging between the trajectories of other signals and the resulting sequence, our construction allows to realize 1 P (N) by hits of just one single signal at column 0.
To start with, let us shortly recall the construction concerning squares [5]. A signal (represented by an arrow, see Fig. 3) starts on level 1 to the NE-direction (right signal). Every time it meets the wall (represented by a vertical bar), the wall gets shifted by one cell to the right and the signal changes its direction from right to left. When the signal meets the 0-column, then a 1 appears, and it changes again its direction from left to right.
This construction can be generalized. We first show a way to generate from a constructed sequence the summatory sequence in column 0. Note that Mazoyer and Terrier proved a similar result for their geometric construction [11,Corollary 2].
Proposition 2. Let f : N −→ N be an ultimately strictly increasing function, and let g denote its summatory sequence defined by g(n) = n k=0 f (k) for all n ≥ 0. Suppose that u = 1 f (N) belongs to S. Then v = 1 g(N) also belongs to S.
Proof. Let us call F the CA that constructs u = 1 f (N) and denote by G the CA that we are going to construct for v = 1 g (N) . For the proof, it is sufficient to treat the case when f is strictly increasing for all n ≥ 0, since we can treat a finite number of exceptions by introducing some appropriate initial conditions for G.
Suppose first that the following condition holds: In a second step, we will show how to transform the construction in order to handle the case when ( ) is not satisfied. But for the sake of clearness, we first assume that ( ) holds. This condition allows to split the construction into three steps. Suppose we have a 1 on some line in column 0. We now show how to generate the next hit on column 0. Define a signal of speed 2 that moves to the right. When this signal meets a wall, that is a column f (i) for some integer i, the signal changes direction to the left (same absolute speed). When this signal meets the column 0 we mark a new 1. Depending on the parity, there are two ways for such a signal and a wall to meet. Either the two signals are in two columns side by side and then, the signal of speed −2 starts in the same column of the last symbol of the signal of speed 2 but one line above, or there is a cell between the two signals and then, the signal of speed −2 starts in the same column of the last symbol of the signal of speed 2 but two lines above. In both cases, we annihilate the wall after the signal has passed. Since f is strictly increasing, we do not have two walls in a same column, and the procedure is well-defined.
Let us now assume that we have so far constructed the first lines of the CA, in other words, we have a 1 in column 0 at lines f (0), f (0) + f (1), . . . , f (0) + · · · + f (i) for some i. We use the previous rules to continue the process. In particular, the 1 on the column 0 at line f (0)+· · ·+f (i) sends a signal of speed 2 to the intersection with the wall in column f (i + 1). If f (i + 1) is odd, we are in the case where the two signals are in two columns side by side. The distance crossed by the signal of speed 2 is f (i+1)−1 2 from the initial 1 and the signal of speed −2 runs the same distance. We place the new 1 in column 0 one line above. Therefore, this new 1 is on the line: If f (i + 1) is even, we are in the other case and the new 1 in column 0 is on the line: Note that the condition ( ), which can be rewritten as: ensures that the wall at column f (i + 1) has already been created when the signal of speed 2 arrives at column f (i + 1). Depending on the exact form of the function f , the condition ( ) is not always satisfied. In the case where ( ) is satisfied for n ≥ n 0 , in order to cope with this problem, one possibility consists in considering the first lines of the space-time diagram as initial conditions (which is not a loss of generality, since it amounts to introducing some auxiliary symbols in the initial configuration only, in such a way that they will fix the first few lines of the space-time diagram). Another possibility is to move the construction of the points f (i) under the main diagonal several lines lower, so that the walls appear sufficiently early. We can then use the procedure given above exactly in the same way. If there are infinitely many values of n such that ( ) is not satisfied, we use another strategy: we change the signals of speed 2 and −2 at the step (iii) to signals of speed 1 and −1. In this case, the sequence that is constructed is not 1 g(N) but 1 2g(N) . Nevertheless, we can recover 1 g (N) with the CA G 2 .
Example 2 (Construction of the characteristic sequence of the sum of the squares, see Fig. 3).
Let f (n) = n 2 and g(n) = n k=0 k 2 = n(n + 1)(2n + 1)/6. Here, the condition ( ) is satisfied for n ≥ 2, and for the construction of 1 g(N) , we consider the first three lines of the space-time diagram as an initial condition.  [5] (left) and for the sum of squares (right).
In Example 2, a polynomial of degree 3 is realized. This suggests that the method can be generalized to obtain the characteristic sequence of any polynomial with higher degree as a column of a CA. To begin with, we show by an explicit construction that the characteristic sequence of the cubes belongs again to S.
Example 3 (Construction of the characteristic sequence of the cubes, see Fig. 4). For all n ∈ N we have (n + 1) 3 − n 3 = 3n 2 + 3n + 1. With the construction of the squares, it is straightforward to obtain the characteristic sequence of 3n 2 : In fact, it suffices to divide the speed of signals of speed ±1 by 3 (see Fig. 4, left). The red, blue and black cells in column 0 correspond to the term 3n . Thus, the construction of the characteristic sequence of the polynomial 3n 2 + 3n + 1 follows. The eight first lines are initial conditions. Now, to obtain the characteristic sequence of the cubes (see Fig. 4, right), we observe that for all n 1, n−1 k=0 (k + 1) 3 − k 3 = n 3 and we use the construction given in the proof of Prop. 2. The first five lines are initial conditions. The construction under the diagonal is moved three lines down. We finally arrive at our main result. Theorem 1. Let P (X) ∈ Q[X] denote a polynomial of degree d ≥ 1 with P (N) ⊂ N. Then the sequence u = 1 P (N) belongs to S and can be realized by the hitting of one single signal in column 0.
Proof. The result of Theorem 1 is clear for all polynomials of degree 1. Indeed, if P has the form P (X) = aX + b with a ∈ N, b ∈ Z, one can construct the sequence by the trajectory of a signal that hits a wall in column a/2 (we fix the initial conditions in order to take into account the translation of b). Note that we can deal with rational coefficients by multiplying and dividing accordingly the speed of the symbols. Suppose now that the statement is true for all polynomials of degree k < d, for some d ≥ 2. We show that we can realize any polynomial P of degree d with only one hitting in column 0. For this purpose, we observe that Q(X) = P (X + 1) − P (X) is a polynomial of degree at most d − 1. Furthermore, since P (N) ⊂ N, the leading coefficient of P is positive, so that there exists c ∈ N, depending only on P , such that the polynomial Q(X) = Q(X + c) satisfiesQ(N) ⊂ N.
By induction, we know that 1Q (N) is constructible. Taking care of the finite initial conditions due to the introduction of the integer c and to the occurrence of P (0), Prop. 2 implies that 1 P (N) belongs to S, and is realized by the hitting of just one signal.

Fibonacci word
The Fibonacci sequence is the recursive sequence defined by F 0 = 0, F 1 = 1, and ∀n ≥ 0, F n+2 = F n+1 + F n . We denote by F the set of numbers that appear in the Fibonacci sequence, that is, F = {F n : n ∈ N}. We propose a construction of the sequence u = 1 F , which by definition, satisfies: u n = 1 ⇐⇒ ∃k ∈ N, n = F k . Our construction presents some similarities with the one proposed by Mazoyer and Terrier for general linear recursions [11,Prop. 4]. Proof. We propose an explicit construction that uses signals of speed 0 (walls), ±1, and 2. Let us assume that on line F n , we have marked the positions 0, F n−2 , F n−1 and F n . We show how to produce the same marking at time F n+1 . In particular, the procedure will enable us to spot the points of ordinate F n in the column 0 of the space-time diagram. The dynamics is as follows.
-From point (0, F n ), we send a signal of speed 1.
-From point (F n−2 , F n ) we send a signal of speed 1 and one of speed 2.
-From point (F n−1 , F n ) we send a signal of speed 0 (wall) and one of speed −1.
-From point (F n , F n ) we send a signal of speed 0 (wall) and one of speed 1.
Using elementary arguments based only on the definition of the Fibonacci sequence, one can show that the intersections of these different signals on line F n+1 give points at positions 0, F n−1 , F n and F n+1 , as illustrated on Fig. 5. In order to complete the construction, one only has to choose appropriate initialisation symbols.
The Fibonacci word is the morphic sequence v ∈ A N which is the unique fixed point of the substitution σ defined by 0 → 01 and 1 → 0. Let us define recursively a collection of finite words by w 1 = 0 and for any n ≥ 1, w n+1 = σ(w n ). The first words obtained are thus:  Proof (sketch). It follows from the definition that for any n ≥ 1, the length of the word w n is equal to F n . Furthermore, one can check that for any n ≥ 1, we have: where the symbol · represents the concatenation of words. It follows that if the word w n has already been computed, in order to obtain the word w n+1 , one can first concatenate after w n the sequence w n−2 , which is the one that appears at the last F n−2 positions of w n , and then the sequence w n−3 , which appears in w n between positions F n−2 and F n−2 + F n−3 = F n−1 . This can be done with a finite state cellular automaton: the block w n−2 appearing at the end of w n is translated to the right until reaching a wall placed at position F n−2 /2 and then translated to the left. And in the same way, the block w n−3 appearing between positions F n−2 and F n−1 is translated to the right until reaching a wall placed at position (F n−2 + F n−1 )/2 = F n /2 and then translated to the left. Note that the walls at positions F n−2 /2 and (F n−2 + F n−1 )/2 can be computed without much difficulty. The construction of the wall at position F n−2 /2 appears on Fig. 5. For the construction of the wall at position (F n−2 + F n−1 )/2, one can send signals of respective speeds 1 and −1 from positions F n−2 and F n−1 at time F n−1 .

Other computable sequences and open questions
Since S is countable, whereas A N is uncountable, there exist sequences of A N that do not belong to S. A sequence (u n ) n≥0 ∈ A N is computable if there exists an algorithm, or more formally, a Turing machine, which on the input n, calculates u n , for any n ≥ 0. In other words, this means that the set {n ∈ N : u n = 1} is accepted by a Turing machine that always halts. It follows easily from the definition that all the sequences of S are computable. Next proposition gives an elementary proof of the fact that S is strictly contained in the set of computable sequences, using a diagonal argument. We refer to the article of Mazoyer and Terrier [11,Prop. 12 and 13] for further characterizations of S in terms of computability.
Proposition 5. There exist computable sequences that do not belong to S.
Proof. For an integer r ≥ 0, let us denote by F r the set of CA F : A Z → A Z of radius r. The set F r is a finite set, of cardinality 2 2r+1 , and it can be enumerated in a canonical way, for example using Wolfram code [15]. So, the set F = ∪ r≥0 F r of all CA F : A Z → A Z is countable, and one can define a computable surjection φ : N → F.
The set C 0 (A) of finite configurations on A Z is also countable, and can be enumerated by a computable surjection ψ : N → C 0 (A). Let now τ : N → N 2 be a computable surjection, and let us consider the following map: 1 ) and x = ψ(τ (k) 2 ).
The map Π above is surjective. Let us consider the sequence (u n ) n≥0 defined by u n = 1 − Π(n) n , for any n ≥ 0. This sequence is computable, and does not belong to the image of Π, so it does not belong to S.
The proposition above provides an example of sequence that cannot be obtained by a CA. Nevertheless, this sequence has an abstract form, and it is an open problem to exhibit a more concrete example of (computable) sequence that does not belong to S. We conclude with some open questions.
1. We have seen that the Fibonacci word belongs to S. More generally, does any morphic sequence belong to S? Is there a canonical way to construct the CA using directly the form of the defining morphism of the sequence, at least for k-step reccurences over words? 2. A sequence of A N is said to be normal if all finite strings of equal length occur with equal asymptotic frequency. None of the sequences that we have evocated here is normal. Is it possible to come up with a CA that gives a normal sequence such as the Champernowne sequence (concatenation of natural numbers in base 10 : 12345678910111213. . . ), or the Copeland-Erdős sequence (concatenation of prime numbers in base 10 : 2357111317192329. . . )? 3. Do the binary expansions of √ 2 = (1.011010100000100 . . .) or π = (11.00100100001111 . . .) belong to S? Note that it is not known whether the binary digits of these two constants give rise to normal sequences. 4. There is a close connection between one-dimensional linear CA and p-automatic sequences.
Do there exist analogous statements for higher dimensional linear CA? Also, is it possible to realize any multivariate polynomial with the help of a suitable higher dimensional (nonlinear) CA? 5. Linear CA provide examples of permutive CA. What kind of sequences can be obtained with permutive CA?