Cyclotomic properties of polynomials associated with automatic sequences

We show that polynomials associated with automatic sequences satisfy a certain recurrence relation when evaluated at a root of unity, which generalizes a result of Brillhart, Lomont and Morton on the Rudin--Shapiro polynomials. We study the minimal order of such a relation and the integrality of its coefficients.


Introduction
The behavior of polynomials whose coefficients are consecutive terms of automatic sequences has been an object of interest of several authors (we recall the definition of an automatic sequence in Section 2). Probably the most widely studied examples have been the famous Rudin-Shapiro polynomials P n , Q n , first studied by Shapiro [7] and Rudin [6] in the context of Fourier analysis. They are defined by P 0 (x) = Q 0 (x) = 1 and for n ≥ 0 the recurrence P n+1 (x) = P n (x) + x 2 n Q n (x), (1) The coefficients of P n form a 2-automatic sequence {r(n)} n≥0 , called the Rudin-Shapiro sequence, which can be equivalently defined by r(0) = 1 and for n ≥ 0 r(2n) = r(n), r(2n + 1) = (−1) n r(n).
The direct motivation behind our work is the central result of the paper [2] by Brillhart, Lomont and Morton, who proved that the values of P n and Q n at roots of unity satisfy a certain type of recurrence relation. More precisely, for an rth root of unity ω (not necessarily primitive), where r > 1 is odd, an integer s ≥ 2 such that 2 s ≡ 1 (mod r) and an auxiliary sequence of polynomials C n ∈ Z[x] (denoted A n in the original paper) the following result holds.
In the same paper the authors also give many results concerning the integrality of the central coefficient C s (ω). In particular, if r is an odd prime power and 2 is a primitive root modulo r, then it turns out that C s (ω) ∈ Z.
The associated Thue-Morse polynomials T (n; x) = n−1 m=0 t(m)x m have been considered by Doche and Mendès France [4], who studied the average number of their real zeros as n tends to infinity. Doche [3] also studied generalizations of the Thue-Morse sequence in the same context. Again, it is fairly easy to show that the Thue-Morse polynomials evaluated at a root of unity of odd order satisfy a two-term recurrence relation (see Section 3). It seems natural to ask whether or not a similar type of recurrence is satisfied at roots of unity by values of polynomials associated with other automatic sequences. If yes, what can be said about the minimal number of coefficients in such a recurrence and the integrality of these coefficients? In this paper we consider a general kautomatic sequence {a(n)} n≥0 with values in C and the polynomials A(n; x) = n−1 m=0 a(m)x m , of degree at most n−1. Theorem 10 of Section 5 answers our first question positively for a general automatic sequence and demonstrates two ways to derive a relation of the form similar as in Theorem 2. (In fact, we show that Theorem 1 also holds for polynomials associated with the Rudin-Shapiro sequence of degree other than 2 n − 1.) In Section 6 we bound the minimal number of terms in such a recurrence relation, linking it with certain properties of an automaton inducing the sequence {a(n)} n≥0 . Section 7 is dedicated to studying the integrality of the coefficients of the considered recurrence relation. In the final section we present the proofs of all the results in this paper.

Preliminaries
Following [1, we recall the definition and basic facts concerning deterministic finite automata with output and automatic sequences. Let Q be a finite set of states, Σ the finite input alphabet, δ : Q × Σ → Q the transition function, q 0 ∈ Q the initial state, ∆ the output alphabet and τ : Q → ∆ the output function. The sextuple A = (Q, Σ, δ, q 0 , ∆, τ) is called a deterministic automaton with output (DFAO). Denote by Σ * the set of finite words created from letters in Σ, together with the empty word ǫ. We can extend the definition of δ to Q × Σ * by putting δ(q, ǫ) = q for all q ∈ Q and δ(q, wa) = δ(δ(q, w), a) for all q ∈ Q, w ∈ Σ * and a ∈ Σ. In other words, the transition function reads the input letter by letter, starting from the left. A state q ∈ Q is called accessible if there exists a word w ∈ Σ * such that δ(q 0 , w) = q. The automaton A defines a finite-state function f : Σ * → ∆ by f (w) = τ(δ(q 0 , w)). For any word w = w 1 · · · w l ∈ Σ * denote w R = w l · · · w 1 . It can be showed that if f is a finite state function, then f R : Σ * → ∆ defined by f R (w) = f (w R ) is also a finite state function, i.e., there exists a DFAO [1,Theorem 4.3.3] for a constructive proof). In this situation we will say that A ′ reads the input from the right (backward). We always assume that A reads the input from the left (forward), unless stated otherwise.
Let k ≥ 2 be an integer base and let Σ k = {0, 1, . . . , k − 1}. We call a DFAO with input alphabet Σ k a k-DFAO. For w ∈ Σ * k we denote by [w] k the integer represented in base k by w (we allow leading zeros). Conversely, for any nonnegative integer n we use the notation (n) k for the base-k expansion of n without leading zeros (we put (0) k = ǫ for any k). We say that a sequence {a(n)} n≥0 with values in ∆ is k-automatic if there exists a k-DFAO A = (Q, Σ k , δ, q 0 , ∆, τ) such that a(n) = τ(δ(q 0 , w)) for all n ≥ 0 and w with [w] k = n. For the purpose of this paper we will say that A forward-induces {a(n)} n≥0 . By the earlier discussion, we may also define a k-automatic sequence using a k-DFAO A = (Q, Σ k , δ, q 0 , ∆, τ) reading the input starting with the least significant digit, that is a(n) = τ(δ(q 0 , w R )) for all n ≥ 0 and w with [w] k = n. In this case we will say that A backward-induces {a(n)} n≥0 . In the situation where it is irrelevant whether A forward-or backwardinduces {a(n)} n≥0 , we will say that A induces {a(n)} n≥0 . It is in fact enough to assume that a(n) = τ(δ(q 0 , (n) k )) for some k-DFAO A for the sequence to be kautomatic. In this case it suffices to add to Q a single state q ′ 0 and modify the transition and output functions accordingly in order to obtain a new k-DFAO A ′ , which forward-induces {a(n)} n≥0 (see [1,Theorem 5.2.1] for more details).

The Thue-Morse polynomials
In this section we study some recurrence properties of the Thue-Morse polynomials T (n; x) evaluated at roots of unity of odd order. We note that the Thue-Morse sequence is both forward-and backward-induced by the 2-DFAO in Figure 1, and can be equivalently defined by where s 2 (n) is the sum of digits in the binary expansion of n. First, we recall some standard properties of the polynomials T (n; x).
. The derivation for T (n; x) of a similar type of recurrence as in Theorem 1 is almost immediate. More precisely, let r ≥ 1 be odd, let ω be an rth root of unity (not necessarily primitive), and fix s ≥ 1 such that 2 s ≡ 1 (mod r). By putting x = ω in identity (iii) of Proposition 2, we obtain the following result.
A more difficult question concerns the integrality of the coefficient T (2 s ; ω) and computation of its value. We point out that this number is an algebraic integer, hence T (2 s ; ω) ∈ Z if and only if T (2 s ; ω) ∈ Q.
Let r 0 ≥ 1 be minimal such that ω r 0 = 1 and let s 0 denote the multiplicative order of 2 modulo r 0 . Clearly, r and s are multiples of r 0 and s 0 , respectively. We can thus restrict ourselves to studying the value T (2 s 0 ; ω), since for any positive integer m we have T (2 ms 0 ; ω) = (T (2 s 0 ; ω)) m . We leave out the trivial case r 0 = 1 from the following considerations, as then ω = 1, s 0 = 1 and T (2; 1) = 0. Let ϕ be the Euler totient function and let ψ 2 ∈ Gal(Q(ω)/Q) denote the Galois automorphism of Q(ω) taking ω to ω 2 . We start with a general observation.
Using this observation, we can determine the possible values of T (2 s 0 ; ω) when r 0 is an odd prime power and either 2 is a primitive root modulo r 0 or s 0 = ϕ(r 0 )/2 is odd.
Proposition 5. Assume that r 0 = p α , where p is an odd prime number. We have the following: We now turn our attention to the situation when r 0 has two or more distinct prime factors. In the following proposition we give the only possible integral values of T (2 s 0 ; ω) and exhibit two special cases when it is possible to determine whether T (2 s 0 ; ω) is an integer. Direct computation shows that the converse implication in Proposition 6(ii) does not hold. We have performed numerical calculations of T (2 s 0 ; ω) in Mathematica for odd r 0 ∈ [3, 10 5 ] having at least two distinct prime factors and ω = exp(2πi/r 0 ). The choice of ω for each fixed r 0 may only affect the value T (2 s 0 ; ω) if this coefficient is not integral, which is irrelevant in the following discussion. Our aim has been to investigate how often T (2 s 0 ; ω) = 1 and T (2 s 0 ; ω) = −1, as this distinction does not follow from the results above. By Proposition 4 and Proposition 6(iii) we can restrict our attention to the set R of r 0 such that s 0 is even and 2 s 0 /2 ≡ −1 (mod r 0 ). This condition holds for 32921 out of all 40315 considered values r 0 . We further partition R depending on whether T (2 s 0 ; ω) = 1, T (2 s 0 ; ω) = −1 or T (2 s 0 ; ω) ∈ Z as well as whether ϕ(r 0 ) = 2s 0 or ϕ(r 0 ) > 2s 0 . In Table 1 below we give the cardinality of each such subset.  Table 1. Numerical results concerning the integrality of T (2 s 0 ; ω) The case ϕ(r 0 ) = 2s 0 corresponds to Proposition 6(ii), thus T (2 s 0 ; ω) ∈ {1, −1} for all such r 0 . We see that the value 1 is attained in about 48.2% of cases. However, we have not been able to identify a general rule determining whether T (2 s 0 ; ω) = 1 or T (2 s 0 ; ω) = −1. The second case ϕ(r 0 ) > 2s 0 reveals some "unexpected", though rare, occurences of T (2 s 0 ; ω) ∈ {1, −1}, which are not covered by Proposition 6(ii). More precisely, we have T (2 s 0 ; ω) = 1 approximately 4.2% of the time, while T (2 s 0 ; ω) = −1 occurs about 5.4% of the time.

The polynomial matrix associated with an automaton
In this section we start working towards obtaining a recurrence relation (formulated precisely in Section 5) involving polynomials associated with an arbitrary automatic sequence. Consider a k- The matrix M(x) carries all the relevant information concerning the transitions between states in A and does not depend on the output. Note that M(1) is the transpose of the incidence matrix associated with A (cf. [1, Section 8.2]). We also denote for t ≥ 0 . These matrices will play an important role in the results of Section 5. Below we establish some of their basic properties.
Roughly speaking, both m ij (k t ; x) and m R ij (k t ; x) describe all paths of length t between the states q i and q j . We may also look at M(k t ; x) and M R (k t ; x) as polynomials in x with matrix coefficients. For w ∈ Σ * k let M w be the d × d integer matrix whose entry m w,ij at position (i, j) ∈ {0, 1, . . . , d − 1} 2 is equal to 1 if δ(q i , w) = q j and 0 otherwise. In particular, M ǫ is the d × d identity matrix. The following observation provides an alternative description of M(k t ; x) and M R (k t ; x), where the matrices M w play the role of the coefficients of an appropriate polynomial.
We also define for integers n ≥ 1 and t such that k t−1 + 1 ≤ n ≤ k t , the matrices to be the truncation of M(k t ; x), viewed as a polynomial in x (in the case of M R this will not be needed).
As we will see in the following sections, a recurrence relation of the desired form derived using M(x) may not have minimal order. In some cases it is possible to construct another square matrix M (x), which leads to a better result in the above sense. First, we associate with each q i ∈ Q a finite state function . We can think of f i (w) as the output that A would return at input w ∈ Σ * k , if the initial state were changed to q i . Assume, after renumbering the states in In other words, to construct M (x) we add for each i = 0, 1, . . . , c the vector , . . . , α pc ] to the ith row of of M(x) and delete the rows and columns with indices greater than c.
Observe that, unlike M(x), the matrix M (x) (its dimension, in particular) depends on the output of the k-DFAO considered. The above construction raises the problem of finding linear dependence relations among the f i , if any exist. We discuss a possible solution and further implications in Section 6 below.
Similarly as with M(x), we may define for t ≥ 0 the matrices Take integers n ≥ 1 and t such that k t−1 + 1 ≤ n ≤ k t and write where each M m is a square matrix of dimension c + 1. Then we define We illustrate the construction of M(x) and M (x) with two simple examples.
Example 1. The Rudin-Shapiro sequence is both forward-and backward-induced by the 2-DFAO displayed in Figure 2.
The associated polynomial matrix is As in the previous example, it is not hard to check that Not coincidentally, the relation (1) defining the Rudin-Shapiro polynomials can be written as A similar type of a polynomial recurrence relation is derived in Proposition 9 of Section 5 for the polynomials associated with any automatic sequence.
Example 2. Let {b(n)} n≥0 be the Baum-Sweet sequence, given by b(n) = 1 if (n) 2 contains no block of zeros of odd length, and b(n) = 0 otherwise. This is a 2-automatic sequence backward-induced by the 2-DFAO displayed in Figure 3. The associated polynomial matrix is However, the finite-state function f 2 is constantly 0, thus we can consider the matrix

Recurrence relations at roots of unity
Let {a(n)} n≥0 be a k-automatic sequence with values in C and define the polynomials similarly as in Section 1. Let ω be an rth root of unity (not necessarily primitive) with r and k relatively prime and let s ≥ 1 be an integer such that k s ≡ 1 (mod r). The main goal of this section is to establish a recurrence relation, valid for all n ≥ 1, which is of the form We retain the notation introduced in Section 4. To begin with, we show a general polynomial recurrence relation involving A(n; x), whose form depends on whether A computes {a(n)} n≥0 by reading the input starting from the most or the least significant digit. With each state q i ∈ Q we associate two sequences of polynomials F i (n; x), F R i (n; x), where for positive integers n ≥ 1 and t such that

It is clear that if
. . , f d−1 } and the matrix M (x) corresponds to this set. Consider the column vectors We have the following polynomial recurrence relations.
Proposition 9. For all integers u ≥ 1 and n ≥ 1 we have Note that in the expressions on the right hand side of (9) and (10), the pairs of arguments (n; x k u ) and (k u ; x) essentially switch roles. Now, fix r ≥ 1 and let ω be any rth root of unity. Take s ≥ 1 such that k s ≡ 1 (mod r). We are ready to state the main result in this section. Assume that one of the following conditions holds:
Then for all n ≥ 1 we have l m=0 C m (ω)A(k ms n; ω) = 0.
Observe that in Theorem 10 we can always choose a polynomial C(x, y) which only depends on ω through s, in the following sense: for s ≥ 1 fixed, one of the conditions in Theorem 10 is satisfied for all rth roots of unity ω, whenever r divides k s − 1. Indeed, if A forward-induces {a(n)} n≥0 , then it suffices to take C(x, y) to be the characteristic polynomial of M (k s ; x) over the field of rational functions C(x). Similarly if A backward-induces {a(n)} n≥0 , then one can take the characteristic polynomial of M R (k s ; x). We illustrate Theorem 10 by continuing the two examples of the previous section.
Example 3. We consider the polynomials R(n; x) = n−1 m=0 r(m)x m , corresponding to the Rudin-Shapiro sequence. If n = 2 u , then R(n; x) coincides with the Rudin-Shapiro polynomial P u (x).
We can similarly derive a recurrence relation involving an rth root of unity ω for any odd r and appropriate s. It is straigforward to check that det( M R (2 s ; x)) = (−2) s x 2 s −1 , thus by considering the characteristic polynomial of M R (k s ; x) we obtain a recurrence relation of the form R(2 2s n; ω) − C s (ω)R(2 s n; ω) + (−2) s R(n; ω) = 0, where C s (x) = tr( M (2 s ; x)) is a polynomial with integer coefficients. This improves the result Theorem 1 in the sense that the obtained recurrence relation works also for n other than powers of 2.
A similar procedure, starting with the matrix M(x), only yields a 5-term recurrence relation. On the other hand, it holds regardless of the output of the 2-DFAO.  (2 s ; x)).

The order of the recurrence
The examples in the previous section show that the minimal order l of the recurrence relation of the form (8) can be bounded from above by the dimension of span C {f 0 , . . . , f d−1 }, which in turn is at most the number of states in a k-DFAO inducing the sequence {a(n)} n≥0 . In this section we make these observations more precise and discuss a method to find linear dependence relations among f 0 , . . . , f d−1 . We apply the results to a certain class of pattern counting sequences. Before stating any results we give a simple example, which demonstrates that l might depend on the choice of r and ω. Clearly, the values T (n; ω) satisfy a three-term recurrence relation of the form (8), and it is not immediately clear whether or not the number of terms can be reduced, like in the case of usual Thue-Morse polynomials. Observe that 2 t(n) = 1 − t(n) for any n ≥ 1, thus Denote C = T (2 s ; ω) for simplicity of notation. We have for all n ≥ 1 Therefore, if there exists a two-term recurrence relation of the form T (2 s n; ω) = C T (n; ω), valid for all n ≥ 1, then we must have C = C = 1. Conversely, if C = 1, then T (2 s n; ω) = T (n; ω) for all n ≥ 1. We have seen in Section 3 that in this case r must have at least two distinct prime factors, but it is hard to determine in general for which r we have T (2 s ; ω) = 1.
Example 5 discourages us from considering the minimal number of terms in (8) for each r and ω individually. Indeed, even for the fairly simple sequence { t(n)} n≥0 it seems very difficult to determine the answer without direct calculation.
Therefore, for a k-automatic sequence {a(n)} n≥0 , it seems reasonable to consider a global bound on the minimal number of terms in the recurrence (8), independent of r, s and ω. More precisely, we consider the minimal l ≥ 1 such that for each r ≥ 1, rth root of unity ω and s ≥ 1 such that k s ≡ 1 (mod r) there exists a recurrence relation of the form (8) satisfied for all n ≥ 1, where C 0 , . . . , C l ∈ C[x] depend only on s, with C l nonzero. We denote this number, which depends solely on the sequence {a(n)} n≥0 , by l min . Our aim is to obtain a bound on l min , relying on the properties of an automaton inducing {a(n)} n≥0 . As we have already observed, such a bound can immediately be obtained from Theorem 10. More precisely, we have the following result.

Proposition 11. Assume that the sequence {a(n)} n≥0 is (forward-or backward-) induced by a k-DFAO A with d states. Then
In particular, l min ≤ d.
In order to achieve the best possible bound, we may first remove all inaccessible states from A. Note that the bound l min ≤ d, while in general not optimal, is applicable regardless of the output of A. Unfortunately, we have neither been able to find an example where the inequality of Proposition 11 is sharp, nor managed to prove that equality holds. We therefore ask the following question.
Question 12. Assume that A has no inaccessible states. Does the equality In its statement question deliberately did not specify whether A forward-or backward-induces {a(n)} n≥0 . In fact, we believe that such an assumption does not affect the answer, since the construction described in Section 4 and the result of Theorem 10 are almost identical in both cases. This raises another question, which seems interesting in its own right. Observe that an affirmative answer to Question 12 would immediately give an affirmative answer to Question 13 in the case when the considered automata forwardand backward-induce {a(n)} n≥0 , respectively.
We will now give a straightforward approach to determine linear dependence relations among the finite-state functions f 0 , . . . , f d−1 . Let S ⊂ Q d be the set of all distinct d-tuples (δ(q 0 , w), . . . , δ(q d−1 , w)) with w ∈ Σ * k . In other words, this is the set of states in the d-fold product of A with itself (in the sense of [5, p. 22]) that are accessible from (q 0 , . . . , q d−1 ). We can find them using the following simple algorithm. Define the function δ d : ((q j 0 , . . . , q j d−1 ), a) = (δ(q j 0 , a) . . . , δ(q j d−1 , a)).
The set S i contains precisely the d-tuples of the form (δ(q 0 , w), . . . , δ(q d−1 , w)) with |w| = i, that do not belong in any S j with j < i. It is clear that the S i are pairwise disjoint and that there exists i 0 ≥ 0 such that S i is empty for i > i 0 , and otherwise nonempty. We have The number i 0 can be roughly estimated from above by d d .
Choose w 1 , . . . , w e ∈ Σ * k such that the d-tuples (δ(q 0 , w j ), . . . , δ(q d−1 , w j )) are all distinct and form the whole set S. The following proposition asserts that it is necessary and sufficient for our purpose to consider linear dependence relations among the functions f i restricted to the set {w 1 , . . . , w e } (each such restriction can be considered a vector in C e ).

Proposition 14. We have
Although Proposition 14 allows us to determine all the linear dependence relations among the f i , in some cases it may be easier to use the following condition. Roughly speaking, it says that if A contains subautomata having the same structure and their output vectors are linearly dependent, then the same linear dependence carries over to the finite state functions corresponding to the states of these subautomata. To simplify the notation write f q = f i , when q = q i .
Proposition 15. Let Q ′ ⊂ Q be nonempty and such that δ(Q ′ × Σ * k ) ⊂ Q ′ . Assume that a function ρ : Q ′ → Q ′ satisfies δ(ρ(q), j) = ρ(δ(q, j)) for each q ∈ Q ′ and j ∈ Σ k . Let m ≥ 1 be minimal such that ρ m = ρ j for some j < m. Choose a state q ′ ∈ Q ′ and let β 0 , . . . , β m−1 ∈ C. Then . We illustrate the use of this criterion in the example below. Example 6. Consider the 2-DFAO in Figure 4. We will show that regardless of the output, dim(span Then ρ satisfies the assumption in Corollary 15. Choose q ′ = q 1 , so that δ({q ′ } × Σ * 2 ) = {q 1 , q 2 }. Proposition 15 with m = 4 says that an equality of the form where β 0 , β 1 , β 2 , β 3 ∈ C, is equivalent to Proposition 15 turns out to be useful when studying certain pattern counting sequences. Let e k:v (n) denote the number of occurrences of a pattern v = ǫ in the base-k expansion of n without leading zeros. which counts the number of (possibly overlapping) occurrences of the pattern v modulo m. Such a sequence {a(n)} n≥0 is k-automatic. In particular, for k = 2, v = 1, and m = 2 we get the Thue-Morse sequence, whereas k = 2, v = 11 and m = 2 yields the Rudin-Shapiro sequence. The following result, whose proof utilizes Proposition 15, gives a sharper bound on l min for this class of automatic sequences.

The integrality of coefficients
In this section we investigate the integrality of coefficients of the recurrence relation (8) for a general k-automatic sequence {a(n)} n≥0 under some mild assumptions. Let C(x, y) ∈ C[x, y] be the characteristic polynomial (in y) either of M(k s ; x), in the case when A forward-induces {a(n)} n≥0 , or of M R (k s ; x), when A backward-induces {a(n)} n≥0 . Write where C m (x) ∈ C[x] (recall that c denotes the dimension of M (x)). As we have mentioned earlier, the recurrence relation (8) holds with the numbers C m (ω) playing the role of the coefficients. Let r 0 ≥ 1 be minimal such that ω r 0 = 1 and let s 0 denote the multiplicative order of k modulo r 0 . Let ψ k be the automorphsim of Q(ω) mapping ω to ω k . It turns out that if the entries of M (x) are polynomials with rational coefficients, then we can explicitly indicate a subfield of Q(ω) of dimension ϕ(r 0 )/s 0 over Q, containing all C m (ω). The second part of Proposition 4 is a special case of this result.
Theorem 17. If m ij ∈ Q[x] for all i, j ∈ {0, 1, . . . , c}, then the elements C m (ω) lie in the subfield of L ⊂ Q(ω) fixed by the subgroup ψ k generated by ψ k .
The assumption m ij ∈ Q[x] is satisfied whenever M (x) corresponds to a set of generators of span Q {f 0 , . . . , f d−1 }, in particular if we consider M (x) = M(x). In the case of r 0 is squarefree we can give a more explicit description of L. Let f = ϕ(r 0 )/s 0 and consider the Gaussian periods η 0 , . . . , η f −1 , defined Then η 0 , . . . , η f −1 form an integral basis of L over Q. It is also easy to show that in this case L = Q(η 0 ). Indeed, we have Q(η 0 ) ⊂ L. To prove the reverse inclusion, observe that η 0 , . . . , η f −1 are all the distinct Galois conjugates of η 0 . Hence, [Q(η 0 ) : Q] = f , which proves our claim. The following immediate corollary of Theorem 17 is a partial generalization of Proposition 5(i) for an arbitrary k-automatic sequence.
In general, we cannot expect C m (ω) to be integers unless m ij ∈ Z[x] (in such case C m (ω) is both rational and an algebraic integer, hence an integer). This is not a concern if all C m (ω) are rational , since we can multiply the recurrence by an appropriate integer to clear their denominators. Even if the numbers C m (ω) are not rational, it is possible to obtain a recurrence relation of desired form with integer coefficients.

Proofs
In this section we present the proofs of the results in this paper, along with some auxiliary lemmas. In each case we retain the notation from the corresponding section.

Proofs of results in Section 3.
Proof of Proposition 2. The identity (i) is an immediate consequence of (2), and further implies (ii). Part (iii) is [4,Lemma 8.1] (keep in mind the shift in indexing the polynomials), but can also be obtained straight from (i) and (ii). Equality (iv) is obviously true for s = 0. By (ii) and induction on s we get Before proceeding to the further proofs we fix some additional notation. Let ϕ denote the Euler totient function and let Φ n be the nth cyclotomic polynomial. Let ψ m ∈ Gal(Q(ω)/Q) denote the automorphism taking ω to ω m , where m ∈ Z is coprime to r 0 . In particular, we write z = ψ −1 (z) for complex conjugation. The multiplicative group (Z/r 0 Z) × and Gal(Q(ω)/Q) are isomorphic and of order ϕ(r 0 ). Let 2 denote the cyclic subgroup of (Z/r 0 Z) × generated by 2.
Proof of Proposition 4. We have where we used Proposition 2(iv). The first part of the claim follows immediately.
To prove the second part we observe that T (2 s 0 ; ω 2 ) = T (2 ( s 0 ); ω), hence this number is invariant under the action of the subgroup of Gal(Q(ω)/Q) generated by ψ 2 . This subgroup is of order s 0 and the result follows from the fundamental theorem of Galois theory.

Proofs of results in Section 4.
Proof of Proposition 7. The formula (3) holds for t = 0. For t ≥ 0 by induction we have The proof of (4) is analogous.
The following auxilliary result shows that the map v → M v is a homomorphism of monoids.
Proof. Fix i, j and let q l = δ(q i , v), that is, m v,il = 1. Then by definition m vw,ij = 1 if and only if δ(q l , w) = δ(q i , vw) = q j . This is further equivalent to m w,lj = 1, which proves our claim.
Proof of Proposition 8. The equality (5) is true for t = 0. For t ≥ 0 by induction we have where in the second equality we used Lemma 21. The proof of (6) is analogous.
First, we prove that our claim holds for n = k t (in fact, we only need n = k), and with F , M replaced by F, M. We have where we used Lemma 22 and Proposition 8. Similarly, Choose i ∈ {0, 1, . . . , c}. Putting t = 1 in (12) and using (7), we obtain and thus F (k u+1 ; x) = M(x k u ) F (k u ; x). By induction, for any t ≥ 1 we get Now, take any n ≥ 1 and t such that k t−1 + 1 ≤ n ≤ k t . By truncating the terms of degree ≥ k u n in (14) we obtain (9). The identity (10) can be proved by an analogous reasoning, starting from (13).
The result follows by considering the first entry in this vector. Case (ii) is slightly easier to prove. By the assumption that A backward-induces {a(n)} n≥0 we have A(n; x) = F R 0 (n; x) for all n ≥ 1. Similarly as before we get M R (k ms ; ω) = ( M R (k s ; ω)) m . As a consequence, by (10) we have F R (k ms n; ω) = ( M R (k s ; ω)) m F R (n; ω) for all n ≥ 1. From the assumption C(ω, M R (k s ; ω)) = 0 we obtain l m=0 C m (ω) F R (k ms n; ω) = 0. and the result follows.
Proof of Proposition 15. Let q ∈ δ({q ′ } × Σ * k ) and v ∈ Σ * k . We have δ(q, v))), and the result follows, since δ(q, v) ∈ δ({q ′ } × Σ * k ). Proof of Proposition 16. Let v = v 1 · · · v e with v i ∈ Σ k and put v 0 = ǫ for a more consistent description. First, we construct a k-DFAO A = (Q, Σ k , δ, q 0 , ∆, τ) which returns a(n) given the input (n) k . Put Q = {0, 1, . . . , m − 1} × {0, 1, . . . , e − 1} and q 0 = (0, 0). We define the transition function δ in such a way, that arriving at a state (p, t) ∈ Q means the following: • counting modulo m, so far p occurences of v in (n) k have been found, • t is the largest number such that the part of the input read so far is of the form wv 0 · · · v t for some w ∈ Σ * k . More precisely, fix j ∈ Σ k , the current symbol in the input. Let t ′ be the length of the longest suffix of v 0 v 1 · · · v t j which is also a proper prefix of v (keeping in mind that |v 0 | = 0). Roughly speaking, this means that after reading j, we will have read t ′ symbols of the next (potential) occurrence of v. Now we consider two possibilities. If t = e − 1 and j = v e , then we define δ((p, e − 1), v e ) = (p + 1 mod m, t ′ ). Roughly speaking, this means that the symbol currently being read successfully completes an occurrence of v and we start counting again towards the next occurrence (the definition of t ′ takes into account the possiblility of overlapping ocurrences of v). In all the other cases we let δ((p, t), j) = (p, t ′ ), in particular δ((p, t), v t+1 ) = (p, t + 1) for t < e − 1. Finally, let τ(p, t) = ξ p m . It is clear from the interpretation of the states (p, t) that indeed τ(δ(q 0 , (n) k )) = a(n).
If v 1 = 0, then δ(q 0 , 0) = q 0 , thus A forward-induces {a(n)} n≥0 . Otherwise, recall from Section 2 that we can add to A a new initial state q ′ 0 to create a k-DFAO A ′ , in which the structure of A is preserved and which forward-induces {a(n)} n≥0 . Now, in order to use Prop 15, define ρ : Q → Q by ρ(p, t) = (p + 1 mod m, t).
Then clearly δ(ρ(q), j) = ρ(δ(q, j)) and τ(ρ(q)) = ξ m τ(ρ(q)) for all q ∈ Q and j ∈ Σ k . By Proposition 15 it follows that for each q ∈ Q f ρ(q) = ξ m f q , where f q denotes the finite-state function corresponding to q. Since ρ has exactly e = |v| orbits, there are at most |v| linearly independent finite state functions f q for q ∈ Q. If v begins with 0, we also need to account for the finite-state function corresponding to q ′ 0 . This ends the proof by Proposition 14. 8.5. Proofs of results in Section 7.