Multiplicative automatic sequences

We obtain a complete classification of complex-valued sequences which are both multiplicative and automatic.


Introduction
A sequence is automatic if it is accepted by a finite automaton. Such sequences are interesting objects to investigate from various points of view: computer science, information theory, linguistics, as well as dynamics and number theory, see e.g. [2], [12], [21]. In particular, a recent motivation to study dynamics of systems determined by automatic sequences appeared in the context of the celebrated Sarnak's conjecture on Möbius disjointness [22], and indeed the third author proved its validity for all automatic sequences [20]. If the Möbius function is replaced with an arbitrary bounded multiplicative function then the relevant disjointness question has a more complicated answer. Indeed, the second and the third author in [16] proved that if a : N → C is a primitive automatic sequence then it is disjoint with any bounded, aperiodic, multiplicative 1 function u : N → C, i.e. The arithmetic Möbius function is of course aperiodic (and multiplicative), but it is easy to find examples of bounded multiplicative functions which are not aperiodic. In fact, Dirichlet characters provide a rich supply of (completely) multiplicative sequences that are periodic (and hence automatic). Multiplicative functions which are automatic have been known for a long time. Probably the most prominent example of a (non-periodic) multiplicative automatic sequence is a variant of the period-doubling sequence 2 which was first studied in [11]. One can easily guess that multiplicative automatic sequences must possess additional interesting properties. For example, it is proved in [24] that any sequence obeying the slightly stronger assumptions of being automatic, completely multiplicative and not taking the value 0 must be Besicovitch almost periodic. This has been strengthened in [16] to Weyl almost periodicity (in the primitive case). Relatively recently, multiplicative automatic sequence have been studied in numerous papers, [1,3,4,6,7,10,13,14,15,17,18,23,26]. A particular focus was put on the study of the case of completely multiplicative automatic sequences [1], [17] with the complete classification given in [18].
Returning to the classification problem in full generality (without the assumption of complete multiplicativity), Bell, Bruin and Coons in [3] (see Conjecture 7.3 therein) conjectured that for each such sequence a there exists an eventually periodic function g such that a(p) = g(p) for every prime p. This conjecture has been proved recently (in a stronger form), independently by Klurman-Kurlberg [13] and the first author [15]. Although, it is also possible to provide an ergodic theory type proof of the aforementioned conjecture following [16], we will not do it here but use the main result of [15] and prove a complete classification of automatic sequences which are multiplicative. The main result of the paper is the following: 3 Theorem 1.1. Let a : N → C be a multiplicative and automatic sequence. Then a is p-automatic for some prime p and takes the form a(n) = f 1 (ν p (n)) · f 2 (n/p νp(n) ), (1) where f 1 : N 0 → C is eventually periodic, f 1 (0) = 1 and f 2 : N → C is multiplicative, eventually periodic and vanishes at all multiples of p. Furthermore, any sequence given by (1) with these conditions is multiplicative and p-automatic and this decomposition is unique unless a(n) is eventually periodic. Remark 1. The condition that f 2 vanishes at the multiples of p seems superfluous, but ensures the uniqueness of the decomposition if a(n) is not eventually periodic. 4 Moreover, the classification of completely multiplicative automatic sequences obtained by Li [18] appears as a special case of Theorem 1.1, see Section 8 for details.
To further motivate Theorem 1.1, let us put it in a wider context. For a sequence f : N → C, it is natural to inquire that the associated generating series F (z) = n≥1 f (n)z n is algebraic. Since many sequences of number-theoretic interest are multiplicative, the problem of verifying algebraicity of generating series of multiplicative sequences has been thoroughly investigated. The definitive result in this area is the following theorem by Bell, Bruin and Coons [3]. It is a generalization of the complex-valued case solved by Bézivin [5].
Theorem 1.2. Let K be a field of characteristic 0, let f : N → K be a multiplicative function, and suppose that its generating series F (z) = n≥1 f (n)z n is algebraic over K(z). Then either there is a natural number k and a periodic multiplicative function χ : N → K such that f (n) = n k χ(n) for all n, or f (n) is eventually zero.
The analogous question can be posed for sequences taking values in finite fields. In this case, there is a classical characterization of algebraic formal power series due to Christol [8]. Theorem 1.3. Let q = p k be a prime power, let F q be a finite field of size q, and (a(n)) n≥0 a sequence with values in F q . Then, the sequence (a(n)) n≥0 is p-automatic if and only if the formal power series n≥0 a(n)X n is algebraic over F q (X). Thus, Theorem 1.1 can also be applied to obtain a characterization of all multiplicative functions a : N → F q such that n≥1 a(n)X n is algebraic over F q (X).
The paper is structured as follows. In Section 2 we give an overview of relevant basic facts about automatic sequences. Then we provide some comments on the main theorem in Section 3, to put it into the correct context. Section 4 is dedicated to some more results about automatic sequences, most of which are classical. In Section 5 we give some final auxiliary results and review the solution of Bell-Bruin-Coons conjecture. The proof of the main theorem is then split into two Sections 6 and 7 for the dense and sparse case, respectively. Section 8 finishes the paper with some remarks. 4 Let us assume that we have a decomposition like in Theorem 1.1, but without asking f 2 to vanish at multiples of p. Then we can define a multiplicative function via g 2 (p k ) = 0, g 2 (q k ) = f 2 (q k ) for all primes q = p and k ≥ 1. It follows directly that we can replace f 2 by g 2 in (1) and g 2 is also eventually periodic as it is just the product of f 2 with the indicator function of integers coprime to p which is periodic.
Notation. Throughout the paper we let N 0 denote the non-negative integers and N the positive integers. Furthermore, C denotes the complex numbers and p, q will always be prime numbers.

Automatic sequences
In this section we review some basic facts concerning automatic sequences. We assume no familiarity with the subject, and for the convenience of the reader we sketch the proofs of even some well-known facts. For a comprehensive introduction, see [2].
There are several equivalent ways to define automatic sequences: primarily, these are sequences that are accepted by finite automata, or the letter-to-letter codings of fixed points of substitutions of constant length. A classical theorem due to Cobham [9] characterizes automatic sequences in terms of their kernels. For a sequence (f (n)) n≥0 and λ ≥ 2, the λ-kernel of f is the set of all the possible restrictions of f to an infinite arithmetic progression whose step is a power of λ, that is, the set ). Given an integer λ ≥ 2, a sequence f : N 0 → C is λ-automatic if and only if the λ-kernel of f , given by (2), is finite.
We can extend the definition of λ-automaticity to λ = 1 by declaring that a sequence f is 1-automatic if and only if it is eventually periodic.
In this case, f is λ-automatic for any λ ∈ N.
Note that, given k and r, the first element of the sequence (2) is f (r) and since r runs over all natural numbers as k → ∞, any automatic sequence takes only finitely many values.
The following lemma shows that the class of complex-valued automatic sequences is closed under the addition, multiplication, and any other entry-wise operation.
Proof. It is enough to show that the λ-kernels of the relevant sequences are finite. If the λ-kernel of f and g have cardinalities N and M respectively, then the λ-kernel of π • f has at most N elements and the λ-kernel of (f, g) has at most NM elements.
It is evident that if f is a λ-automatic sequence, then so are all the sequences in its λ-kernel. More generally, one can check that if f is λ-automatic then so is its restriction to any arithmetic progression n → f (an + b) (a ∈ N, b ∈ N 0 ). We also have the following classical results about being automatic in two different bases. Lemma 2.3. For any λ ∈ N and k ≥ 1, a sequence is λ-automatic if and only if it is λ k -automatic.
Proof. Indeed, the λ k -kernel is contained λ-kernel, while the λ-kernel is contained in the union of λ k -kernels of the sequences n → f (λ j n + s) with 0 ≤ j < k, 0 ≤ s < λ j .
Another classical theorem of Cobham asserts that this equivalence is essentially the only case when a sequence is automatic with respect to two different bases.

Comments on the main theorem
To see Theorem 1.1 in its proper context, in this section we discuss examples of multiplicative automatic sequences and point out some easy observations on decompositions of the type given by (1).
Let p be a prime. Recall that for n ≥ 1, ν p (n) denotes the p-adic valuation of n, that is, the unique integer k such that p k | n and p k+1 ∤ n. The map ν p : N → N 0 is completely additive, that is, for all m, n ≥ 1. It is a standard observation that if m, n ≥ 1 and ν p (n) = ν p (m) then (4) ν p (m + n) = min (ν p (m), ν p (n)) .
Since ν p takes the value 0 at least at one of any pair of coprime integers, it also follows that for any m, n ≥ 1 with (m, n) = 1. As a consequence, we immediately obtain a class of examples of p-automatic multiplicative sequences coming from p-adic valuations.
Lemma 3.1. Let f 1 : N 0 → C be a sequence with f 1 (0) = 1. Then the sequence a 1 : N → C given by a 1 (n) = f 1 (ν p (n)) is multiplicative. If f 1 is eventually periodic, then a 1 is p-automatic.
Proof. The first part of the statement follows directly from (5). For the second part, we verify that the p-kernel of a 1 is finite. Consider any sequence n → a 1 (p k n + r) in the p-kernel of a 1 , where k ≥ 0 and 0 ≤ r < p k . Suppose first that r = 0, and consequently it can be written in the form r = p ℓ r ′ where p ∤ r ′ and 0 ≤ ℓ < k. Then it follows from (4) that for all n ≥ 0. Since f 1 takes on finitely many values, there are only finitely many constant sequences in the p-kernel of a 1 that arise this way.
Suppose next that r = 0. Then Since f 1 is eventually periodic, the number of sequences of the form m → f 1 (m + k) with k ≥ 0 is finite. As a consequence, the p-kernel of a 1 is also finite, as needed.
At the opposite extreme we have examples of p-automatic multiplicative sequences which are invariant under multiplication by p. Before we proceed, we need the following general observation. (1) f is periodic or (2) f is finitely supported.
Proof. Since f is eventually periodic, there exists a periodic sequence h : N → C with some period d ≥ 1 and a threshold n 0 such that f (n) = h(n) for all n ≥ n 0 .
We next elucidate the connection between f and h. For any n ≥ 1 and any s ≥ n 0 /nd, the integers n and 1 + snd are coprime, so If h(1) = 0 then h would be identically 0, in which case f is finitely supported and we are done. Otherwise, h(1) = 0 and f (n) = h(n)/h(1) is periodic.
3. Let f 2 : N → C be eventually periodic and multiplicative. Then the sequence a 2 : N → C given by a 2 (n) = f 2 (n/p νp(n) ) is multiplicative and p-automatic.
Proof. The multiplicativity of a 2 follows immediately by the multiplicativity of f 2 and the discussion above. Proceeding as in the proof of Lemma 3.1, we will show that the kernel of a 2 is finite. Pick a sequence n → a 2 (p k n + r) with k ≥ 0 and 0 ≤ r < p k . If r = 0 then a 2 (p k n + r) = a 2 (n) for all n ≥ 0, which contributes in total one sequence to the p-kernel.
Suppose next that r = 0 and write r = p ℓ r ′ with p ∤ r ′ . Hence, for all n ≥ 0, we have a 2 (p k n + r) = f 2 (p k−ℓ n + r ′ ).
In this situation it will be convenient to split into two cases, depending on which of the alternatives holds in Lemma 3.2 applied to f 2 . If f 2 is periodic with a period d then n → a 2 (p k n+ r) coincides with one of the (at most) d 2 sequences of the form n → f 2 (in + j) with 0 ≤ i, j < d. If f 2 is finitely supported then for all but finitely many choices of k and r, the sequence n → a 2 (p k n + r) is identically zero on N. In either case, the p-kernel of a 2 is finite.
Combining Lemmas 3.1 and 3.3 (and the basic observations that pautomatic sequences are closed under products), we have just proved the following: Lemma 3.4. Let f 1 : N 0 → C, f 2 : N → C be eventually periodic sequences and assume further that f 1 (0) = 1 and f 2 is multiplicative. Then the sequence is multiplicative and p-automatic.
• If f 2 is periodic (with some period d) then the sequence n → f 2 (n/p νp(n) ) is Toeplitz, and hence almost periodic. Indeed, assume that n = p α (pm + j) with 0 < j < p, i.e. ν p (n) = α. We have • This shows in particular that n → f 1 (ν p (n))f 2 (n/p νp(n) ) is a primitive p-automatic sequence by [9, Theorem 5] whenever f 1 is eventually periodic and f 2 is periodic.
• If f 2 (1) = 1 and f 2 (n) = 0 otherwise 6 then f 2 (n/2 ν 2 (n) ) is 1 if n = 2 k and it is 0 otherwise. The automatic sequence we obtain is not, in general, primitive. For instance, if f 1 (n) = 1 for all even n ≥ 0 and f 1 (n) = 0 otherwise, then takes value 1 at 2 m with m ≥ 0 even, and the value 0 otherwise. The corresponding automatic sequence is not primitive.
The main result of the paper, i.e. Theorem 1.1, says that the examples given by Lemma 3.4 above exhaust all possible automatic sequences which are multiplicative.
As a partial converse to Lemma 3.4, any, not necessarily automatic, multiplicative sequence (a(n)) n≥1 admits a decomposition where f 1 and f 2 are necessarily given by For concreteness we assume that f 2 (m) = 0 for all m ≥ 0 with p | m, which in particular ensures that f 2 is multiplicative. Below, we record two facts which imply that if a is additionally pautomatic then f 1 is eventually periodic and f 2 is p-automatic. Hence, the content of Theorem 1.1 is that automatic multiplicative sequences are always automatic with respect to bases that are prime and any p-automatic multiplicative sequence a with a(pn) = a(n) for all n ≥ 1 is eventually periodic. Lemma 3.5 (Corollary 5.5.3 [2]). If f is a λ-automatic sequence for some λ ∈ N then the sequence k → f (λ k ) is eventually periodic.
Lemma 3.6. If f is a p-automatic sequence, where p is a prime, then the sequencef given byf (n) = f n/p νp(n) is also p-automatic.
Proof. By Lemma 2.1, it will suffice to verify that the p-kernel off is finite; in fact, we show that it has at most one element more than the kernel of f . Pick any k ≥ 0 and 0 ≤ r < p k . If r = 0 then, for all n ∈ N, we havẽ Conversely, if r = 0, then we can decompose r = p ℓ r ′ , where p ∤ r ′ which, for any n ≥ 0, implies that It remains to notice that the sequence (f (p k−ℓ n + r ′ )) n≥0 belongs to the kernel of f . Remark 2. The statement above is immediate when automatic sequences are viewed through the lens of automata. Indeed, it is enough to modify a single transition in an automaton which accepts f (reading input from the least significant digit) to obtain an automaton which acceptsf .
As already mentioned, the decomposition given by (7) is essentially unique. We record this and previous observations in the following proposition.
Proposition 3.7. Let p be a prime and let a be a p-automatic multiplicative sequence that is not identically zero. Then there exist unique sequences f 1 and f 2 such that (7) holds, f 1 is eventually periodic, f 2 is automatic and multiplicative, f 1 (0) = 1 and f 2 (n) = 0 for all n with p | n.
Proof. The existence of such a decomposition has already been proved. For uniqueness, suppose that a(n) = f 1 (ν p (n))·f 2 (n/p νp(n) ) = g 1 (ν p (n))· g 2 (n/p νp(n) ) were two distinct decompositions as described above. For any integer n with p ∤ n, we have If p | n then f 2 (n) = g 2 (n) = 0. Hence, f 2 = g 2 . Since a is not identically zero, there exists n 0 such that p ∤ n 0 and f 2 (n 0 ) = 0. Taking n = p k n 0 for an arbitrary k ≥ 0, we conclude that It follows that f 1 = g 1 .
Remark 3. By Lemma 3.2, we know that f 2 in (7) is either finitely supported, which corresponds to the "sparse case" or periodic, which corresponds to the "dense case", see a discussion in Section 5.2.

More about automatic sequences
In this section we collect some results about automatic sequences that we will need in what follows. We call a sequence (a(n)) n≥1 almost periodic if each word that appears in a, appears in a with bounded gaps, that is, if for each n 0 ≥ 1 and ℓ ≥ 0, the set {n ∈ N 0 : a(n 0 ) = a(n), . . . , a(n 0 + ℓ) = a(n + ℓ)} is syndetic.
Lemma 4.1 (Theorem 5 in [9]). An automatic sequence a is primitive if and only if it is almost periodic.
Recall that the product of two λ-automatic (complex-valued) sequences is again λ-automatic (λ ∈ N). Unfortunately, the product of two primitive automatic sequences need not again be primitive. However, we can preserve primitivity under some stronger conditions. Lemma 4.2. Let (a 1 (n)) n≥0 be a primitive automatic sequence and (a 2 (n)) n≥0 be a Toeplitz sequence. Then a 1 (n), a 2 (n) n≥0 is almost periodic. In particular, if a 1 and a 2 are additionally λ-automatic, then the sequence (f (a 1 (n), a 2 (n))) n≥0 is primitive and λ-automatic for any map f : Proof. Take any pair of words that appear simultaneously in a 1 and a 2 , say, w 1 = a 1 [n 0 , n 0 + k] = (a 1 (n 0 ), . . . , a 1 (n 0 + k)) and w 2 = a 2 [n 0 , n 0 + k]. As a 2 is a Toeplitz sequence, we know that w 2 appears in a 2 along an arithmetic progression with common difference r > n 0 + k. Let us consider the r-block compression of a 1 , where we group r consecutive elements into one new, i.e. (a 1 [nr, nr + r − 1]) n≥0 . This new sequence is again λ-automatic and primitive by [9,Section 6], and thus the set of positions n such that w 1 appears in a 1 at position nr + n 0 (meaning that a[nr + n 0 , nr + n 0 + k] = w 1 ) has bounded gaps. Thus, w 1 and w 2 appear at the same positions with bounded gaps and the result follows.
When a : N → C is automatic and A = a(N) is the "alphabet" of a, then we let X a ⊂ A Z denote the subshift generated by a. 7 We hence obtain a topological dynamical system (X a , S), where S stands for the left shift, S (x n ) n∈Z ) = (x n+1 ) n∈Z . We recall that a is primitive if and only if (X a , S) is minimal. In fact, this condition is further equivalent to the assertion that (X a , S) is strictly ergodic, in which case the unique invariant measure is denoted by µ a .
Such subshifts originating from primitive automatic sequences have been thoroughly studied (see for example [21]). We recall an important fact about the continuous eigenvalues 8 of these systems. We will need the notion of the height of a primitive, aperiodic, λ-automatic sequence a, which is defined via h(a) = max{n ≥ 1 : (n, λ) = 1, n | gcd{m : a(1) = a(m + 1)}}.
Then the continuous eigenvalues of X a are exactly {e 2πis/(λ k ·h(a)) : k ∈ N, s ∈ Z} ([21, Theorem 6.1]). 9 In what follows we will need the following Cobham-type result: Let a = (a(n)) n≥1 be a primitive λ-automatic sequence, which is also given as for some v ≥ 1, where the a j are primitive q j -automatic sequences for some integers q j . If q j (1 ≤ j ≤ v) are pairwise coprime and also coprime to λ, then a is periodic.
Proof. We first group all the periodic sequences a j into one new coordinate, so that we can write a(n) = f (a 1 (n), . . . , a w (n), g(n)), where g(n) is periodic and a j (n) are not.
We consider now the subshifts X a , X a 1 , . . . X aw , X g , which are all uniquely ergodic as the corresponding sequences are primitive and automatic. We note that the continuous eigenvalues of the dynamical system (X a , µ a , S) are exactly e 2πis/(λ k ·h(a)) for all k ∈ N, s ∈ Z, remembering that h(a) denotes the height of a and h(a) is coprime to λ. Furthermore, we consider the product system ).
Although this system need not be ergodic 10 , the eigenvalues of the product system are of the form e 2πiα 1 /q k 1 1 . . . · e 2πiαw/q kw w · e 2πiβ/ℓ , where α j , β ∈ N and ℓ divides the product of the heights h(a j ) of a j and the period of g.
However, the map f yields a continuous map from from the product system (X a 1 ×. . .×X aw ×X g , S w+1 ) to X a . Since X a is uniquely ergodic, the image of the product measure must be µ a , so (X a , µ a , S) is a factor of the product system (8). Thus, its eigenvalues are a subset of the eigenvalues of the product system. As (q j , λ) = 1 for all j, this means that (X a , µ a , S) has only finitely many eigenvalues, and thus (see [19,Theorem 5]) X a has to be finite, i.e. a is periodic.
We state now a slightly simplified version of the Pumping Lemma for automatic sequences which can be immediately obtained from the Pumping Lemma for regular languages. Therefore, we need to define for a word w = w 0 w 1 . . . w n over the alphabet {0, 1, . . . , λ − 1} the corresponding integer (so that w is the base λ representation), i.e.
Lemma 4.4. Let f be a λ-automatic sequence. Then there exists n 0 ∈ N such that for all n ≥ n 0 there exist words u, v, w over the alphabet We can rewrite the condition n = [uvw] λ as Similarly, we find Thus, we have the following version of the Pumping Lemma for automatic sequences, where we put ℓ 1 = |w| , ℓ 2 = |v| , ℓ 3 = |u| and Lemma 4.5. Let f be a λ-automatic sequence. Then there exists n 0 > 0 such that for every integer n ≥ n 0 there exist integers ℓ 1 , ℓ 3 ≥ 0, ℓ 2 ≥ 1 and x < λ ℓ 3 , y < λ ℓ 2 , z < λ ℓ 1 such that n = xλ ℓ 1 +ℓ 2 + yλ ℓ 1 + z, Of course, a Dirichlet character of modulus k is determined by a character of the multiplicative group (Z/kZ) * (which takes values in roots of unity of degree φ(k), where φ denotes the Euler totient function). The Dirichlet character determined by the trivial (constant equal to 1) character of (Z/kZ) * is called the principal character and is denoted by χ. Note that if d|k and η is a Dirichlet character of modulus d then is a Dirichlet character of modulus k. In this case, we say that χ is a character induced from η.
Moreover, if we additionally assume that (k 1 , k 2 ) = 1 then this reasoning can be reversed. One can also decompose a Dirichlet character χ of modulus k = k 1 k 2 as the product of Dirichlet characters of modulus k 1 and k 2 . Indeed, we define where n i is uniquely defined modulo k 1 k 2 by One can easily see 12 that χ k i is a Dirichlet character of modulus k i and χ(n) = χ k 1 (n) · χ k 2 (n) for all n ∈ Z.

Solution of Bell-Bruin-Coons conjecture.
Conjecture 5.2 (Bell-Bruin-Coons). For any multiplicative automatic function f : N → C there exists an eventually periodic function g : N → C such that f (p) = g(p) for all primes p.
This conjecture was recently solved independently by the first author [15] and Klurman and Kurlberg [14]. We recall the slightly stronger form obtained in [15]. Theorem 5.3 (Theorem 1 of [15]). If a : N → C is an automatic multiplicative sequence then there exist a threshold p * and a function χ : N → C which is either a Dirichlet character or identically zero such that a(n) = χ(n) for all n ∈ N not divisible by any prime p < p * .
It will be convenient to refer to a multiplicative automatic sequence as being sparse or dense if the function χ in the theorem above is identically zero or a Dirichlet character, respectively. Likewise, we will refer to the corresponding cases of our main theorem as the sparse case and the dense case.
We note that if k is a modulus of χ in Theorem 5.3, then replacing χ by the induced character of modulus k ′ = lcm(k, p * !) (and replacing k by k ′ ), we conclude that a(n) = χ(n) for all n ∈ N coprime to k. This lets us reformulate the theorem above in the following form, which will be more convenient.
Corollary 5.4. Let a : N → C be an automatic multiplicative sequence. Then there exist coprime integers h and λ and a sequence χ : N → C which is either identically zero or a Dirichlet character of modulus hλ such that a is λ-automatic and a(n) = χ(n) for all n ∈ N that are coprime to hλ.
Proof. Pick a base λ 0 ∈ N such that a is λ 0 -automatic. By the remark above, there exist an integer k ∈ N and a sequence χ 0 which is either identically zero or a Dirichlet character of modulus k such that a(n) = χ 0 (n) for all n coprime to k. Now, we can decompose k = k 1 · k 2 so that (λ 0 , k 2 ) = 1 and k 1 | λ ℓ 0 for some ℓ ∈ N. We take λ := λ ℓ 0 , h := k 2 and see that a is λ-automatic. Furthermore, inducing to modulus hλ, we obtain χ which is either identically zero or a Dirichlet character of modulus hλ and the result follows.
Since the integer hλ will play a crucial role, it is convenient to make the following definition.
Definition 5.5. We let C denote the set of integers coprime to hλ.
We also recall that the terms "sparse" and "dense" were introduced above. We would like to stress that in the dense case a must be primitive (in fact, a must be Toeplitz, see Lemma 6.4 below), while in the sparse case it is not (except when it is identically zero).

Proof of the Main Theorem in the dense case
Let a be an automatic multiplicative sequence, as in the assumptions of Theorem 1.1, and let h, λ and χ be given as in Corollary 5.4. In this section we prove Theorem 1.1 in the dense case, meaning that we assume that χ is a Dirichlet character of modulus hλ. It will be convenient to denote α(p) := ν p (hλ) for p prime.
As we have seen in Subsection 5.1, we can decompose χ into the product of Dirichlet characters of coprime moduli: As a consequence, for n ∈ C, we have For a general n ∈ N, we can find a decomposition (10) n = n ′ · p|hλ p νp(n) as the product of prime divisors of hλ and an element of C, with n ′ given by (11) n ′ = n/ p|hλ p νp(n) .
Since a is multiplicative and the factors n ′ and p νp(n) (for p | hλ) in (10) are pairwise coprime, it follows that a(n) = a(n ′ ) · p|hλ a(p νp(n) ).
We note that n ′ given by (11) belongs to C. Hence, we can replace the first occurrence of a in the decomposition (12) with χ. This and (9) allows us to rewrite (12) as follows a(n) = p|hλ χ p α(p) n q|hλ q νq(n) · p|hλ a(p νp(n) ).
Our next goal is to simplify the decomposition given in (13) above. Towards this end, we introduce a new piece of notation (cf. notation n i in Section 5.1). For p | hλ, we letp be an integer determined uniquely modulo hλ by the following system of congruences: This definition is set up so that, in particular, for each p | hλ, we have (15) χ hλ/p α(p) (p) = χ(p).
We are now ready to write (13) in a more condensed form.
Proposition 6.1. With the notation from (14), for all n ∈ N, we have Proof. It follows from (13) and the fact that Dirichlet characters are completely multiplicative that Exchanging the order of multiplication in the innermost product yields: It remains to recall (15) and insert (17) into (16).
The factors in the decomposition produced by Proposition 6.1 correspond to different prime divisors p of hλ. We are already satisfied with the factors coming from p | λ and proceed to prove additional properties for p | h. Lemma 6.2. For any prime q | h, the sequence γ → a(q γ )/χ(q) γ is eventually constant.
Proof. Since the λ-kernel of a is finite, it follows by the pigeonhole principle that there exist k ≥ 1 and r 1 < r 2 < λ k such that and a(nλ k + r 1 ) = a(nλ k + r 2 ) (20) for all n ∈ N. By the LHS congruence in (19) it follows that there exists β ≥ α(q) such that where (r, q) = 1.
We will now show (23) and (24) (we proceed similarly to (13)). Denote ν q (nλ k + r i ) =: m i , i = 1, 2. Our aim will be to determine m i and to show that ((nλ k + r i )/q m i , hλ) = 1 which, by the multiplicativity of a, yields Then we decompose χ = χ λ · χ q α(q) · χ h/q α(q) and it only remains to determine the residues of nλ k + r i /q m i modulo λ, q α(q) and h/q α(q) . We now determine m 1 by showing that m 1 = γ and also show that ((nλ k + r 1 )/q γ , hλ) = 1. Indeed, by (19) and (22), we have where q −γ on the RHS congruences means, respectively, the reciprocals of q γ in (Z/λZ) * and (Z/(h/q α )Z) * . Thus, we have by the discussion above, the multiplicativity of Dirichlet characters and the definition of q, which shows (23). As γ ≥ β + α(q), we have ν q (nλ k + r 2 ) = β. Indeed, we find similarly to the previous computation (using (19), (21) and (22)) that which shows (24) and the proof is complete. 13 As a consequence, we obtain the following periodicity result.
is periodic.
We will also need the following result which in particular shows that a (in the dense case) is primitive.
Lemma 6.4. The sequence a is Toeplitz.
Proof. We need to prove that for each n ≥ 1 there exists M ≥ 1 such that a(n) = a(n + sM) for each integer s ≥ 0. Pick any n ≥ 1 and let M = n 2 hλ. Then n + sM = n(1 + snhλ) and the two factors are coprime for each s ≥ 0. Hence, where the last two equalities hold because 1 + snhλ ≡ 1 mod hλ.
6.1. Prime base. Now, we are in a position to prove Theorem 1.1 in the case, where λ is a prime power. First, we recall that when λ = p α for some prime p and α ≥ 1, we can actually replace λ by p thanks to Lemma 2.3. Moreover, we recall that we continue to assume that we are in the dense case (see Subsection 5.2). Proposition 6.5. If λ = p α is a power of a prime p then the sequence a can be written in the form where f 1 (0) = 1, f 1 is eventually periodic and f 2 is multiplicative and periodic.
Proof. We define a multiplicative functionã : N → C by setting a(p k ) := a(p) k for all k ≥ 1 andã(q ℓ ) := a(q ℓ ) for all remaining primes q = p and ℓ ≥ 1. Since a is multiplicative, this definition ensures that a(m) = a(m) for all m ∈ C.
Recall thatp is, directly by definition (14), coprime to hλ. In particular, a(p) = χ(p) is a root of unity (of order φ(hλ)). It follows thatã is also λ-automatic: indeed, it is the product of the sequences a(p) νp(n) and a(n/p νp(n) ), which are λ-automatic by Lemma 3.1 and Lemma 3.6 respectively. Using the nomenclature introduced in Section 5.2,ã is also dense; indeed, it agrees with the same Dirichlet character χ on sufficiently large primes 14 . We are now in a position to apply Proposition 6.1, which yields the decomposition (we recall that α = α(p)) where we use the fact thatã(p β ) = χ(p) β for all β ≥ 0 to find The sequence h 1 is multiplicative by Lemma 3.1applied to f 1 (m) = a(q m ) and f 1 (m) = χ(q) m and it is periodic by Proposition 6.3 and the fact thatã(q m ) = a(q m ) for all m ≥ 1, q | h.
We can equivalently rewrite (28) in the form The sequence on the LHS is p-automatic as it is the quotient of two p-automatic sequences (for the denominator, see Lemma 3.3). Moreover, it is primitive by Lemma 6.4, asã is primitive (in fact Toeplitz; see Lemma 4.2) and the sequence n → χ p α (n/p νp(n) ) is Toeplitz (see remarks after Lemma 3.4). On the other hand, the sequence on the right hand side of (30) is the product of primitive q-automatic sequences for q | h (recall that h 1 is periodic hence automatic in any base). Thus, by Proposition 4.3, the sequence h 2 given by (30) has to be periodic.
Recall that by Proposition 3.7, a can be written in the form (26) with f 1 eventually periodic and f 2 multiplicative and vanishing on multiples of p. In fact, f 2 is given by f 2 (n) = a(n) =ã(n) for n coprime to p, so In particular, f 2 is periodic, as needed.
6.2. Composite case. It remains to consider the case where λ is composite. The main content of the argument is contained in the following analogue of Lemma 6.2. Lemma 6.6. Suppose that λ is not a prime power and p is a prime divisor of λ. Then the sequence γ → a(p γ )/χ(p) γ is eventually constant.
Proof. We recall that α(p) = ν p (hλ) = ν p (λ) ≥ 1. Since the λ-kernel of a is finite, it follows from the pigeonhole principle that there exist k ≥ 1 and r 1 < r 2 < (λ/p α(p) ) k such that and a(nλ k + p α(p)k r 1 ) = a(nλ k + p α(p)k r 2 ) (32) for all n ∈ N. (This is the only step, where we need the assumption that λ is not a prime power, ensuring λ/p α(p) > 1.) We note that, by (31), we have r 2 − r 1 = p β r for some β ≥ α(p) and r with p ∤ r.
As a direct consequence of Lemma 6.6, we obtain the following (the proof is essentially the same as the proof of Proposition 6.3). Proposition 6.7. Suppose that λ is not a prime power. Then the sequence n → p|λ a(p νp(n) ) χ(p) νp(n) is periodic.
Our goal is to show that (if λ is not a prime power), the sequence a(n) is eventually periodic. We distinguish two cases. Proposition 6.8. Assume that λ is not a prime power and there exists a prime p | λ such that γ → a(p γ ) is not finitely supported. Then a is eventually periodic.
As c is periodic (and in particular µ-automatic), it follows that a is also µ-automatic. Thus, a is eventually periodic by Theorem 2.4. Proposition 6.9. Assume that λ is not a prime power and the map γ → a(p γ ) is finitely supported for each p | λ. Then a is periodic.
Proof. Recall that Proposition 6.1 gives the representation of a as the product of factors corresponding to different primes. We claim that for each prime p | λ, the corresponding factor is periodic, with period p α(p)+δ(p) where δ(p) ≥ 0 is an integer such that a(p γ ) = 0 for all γ ≥ δ(p). Indeed, if n ≡ n ′ mod p α(p)+δ(p) then either ν p (n), ν p (n ′ ) ≥ δ(p) (in which case both factors vanish) or ν p (n) = ν p (n ′ ) < δ(p), in which case n/p νp(n) ≡ n ′ /p νp(n ′ ) (mod p α(p) ) in which case both factors are equal.
Applying the above observation and Proposition 6.3 to the decomposition produced by Proposition 6.1, we conclude that where g(n) is a periodic function. In other words, a(n) is a the product of primitive q-automatic sequences for q | h (in particular, (q, λ) = 1) and a periodic sequence. Thus, the conclusion follows from Proposition 4.3.
Proof of Theorem 1.1 in the dense case. We now recall the most important steps in the proof of Theorem 1.1 in the dense case.
We then show in Lemma 6.2 and Proposition 6.3 that the factors n → a(p νp(n) )/χ(p) νp(n) are periodic for every p | h. Independently of these results, we show in Lemma 6.4 that any dense, automatic and multiplicative sequence is Toeplitz and, therefore, primitive. Then, the section splits into two parts corresponding to the cases depending upon λ is a prime power or composite. In the first case we need to show that a can be decomposed in the form of (1). In the second case we aimed at showing that a is eventually periodic, as any multiplicative periodic sequence can be written in the form of (1).
The remainder of the proof of the first case is handled in Proposition 6.5.
In the case of λ being composite we first show in Lemma 6.6 and Proposition 6.7 (similarly to Lemma 6.2 and Proposition 6.3) that the factors n → a(p νp(n) )/χ(p) νp(n) are also periodic for every p | λ. Then we show in Proposition 6.8 that γ → a(p γ ) needs to be finitely supported for every p | λ unless a is (eventually) periodic. We finally conclude the proof for the composite case with Proposition 6.9, i.e. we show that a has to be periodic, when λ is composite and a is dense. 7. Proof of Theorem 1.1 in the sparse case Throughout this section we assume that a(n) = 0 for all n > 1 with (n, λh) = 1.
The proof of the following proposition can be seen as a variant of Schuetzenberger's proof [25] that no infinitely supported automatic sequence can only be supported on prime numbers. Proposition 7.1. Suppose that α → a(p α ) is not finitely supported for some prime p. Then a is p-automatic.
Proof. Assume that α → a(p α ) is not finitely supported. Then p cannot be coprime with hλ as we are in the sparse case. So p|hλ. There are two cases then: either p|h and we will show that this is in fact impossible, or p|λ in which case we will show that a is p-automatic.
From the definition of m it follows that for some r ≥ 1, we have Therefore (as clearly λ Lℓ ≡ 1 mod hλ), Moreover, as z ≡ q i mod λ, we also have (43) m ≡ q i mod λ.
From the two above congruences (42), (43) it follows that m ≡ q i mod q i hλ and consequently m/q i ≡ 1 mod hλ. Thus, (q i , m/q i ) = 1 and, by the multiplicativity of a, we have a(m) = a(q i ) · a(m/q i ). Since (m/q i , hλ) = 1 and m/q i > 1, we have a(m/q i ) = 0, as we are in the sparse case. But by (41), a(q i ) = a(m) = 0 which leads to a contradiction. Suppose now that a(p α ) = 0 for infinitely many α for some prime p | λ. By the same reasoning as before, we find that for some large enough i, we can find a decomposition p i = xλ k+ℓ +yλ k +z (with ℓ ≥ 1) such that a(p i ) = a(xλ k+(n+1)ℓ + yλ k λ 0 + λ ℓ + . . . + λ nℓ + z) = 0 (44) for all n ∈ N. Similarly to the previous case, note that λ ℓ is coprime with (λ ℓ − 1)h, so for some L ≥ 1, we have λ Lℓ = 1 mod (λ ℓ − 1)h, and so also λ nLℓ = 1 mod (λ ℓ − 1)h for each n ≥ 1. As a consequence, In particular, m(n) is coprime to h for all n ∈ N. Moreover, so m(n) is coprime to hλ/p α(p) .
Since we have a(m(n)) = a(p i ) = 0 by (44) and we are in the sparse case, all prime factors of m(n) divide hλ. But by (45) and (46), we obtain that p is the only common prime factor of m(n) and hλ. It follows that for each n ∈ N there exists an integer k(n) such that m(n) = p k(n) . We can estimate k(n) by as n → ∞. In particular, the sequence (k + (nL + 1)ℓ) log p (λ) mod 1 converges (in R/Z) as n → ∞. This is only possible if log p (λ) ∈ Q, since otherwise the above sequence would be equidistributed. Consequently, λ is a power of p and a is p-automatic.
Proof of Theorem 1.1 in the sparse case. Let us consider the set P := {p ∈ P : α → a(p α ) is not finitely supported}.
We distinguish the following cases: • |P | ≥ 2: Let p 1 , p 2 ∈ P be distinct. Using Proposition 7.1, we find that a is p 1 -automatic and p 2 -automatic. By Cobham's Theorem 2.4, a is eventually periodic. Moreover, by Lemma 3.2, a is either periodic or finitely supported. In both cases, a is p-automatic for every prime p and we can write it in the form a(n) = f 1 (ν p (n))f 2 (n/p νp(n) ) (cf. Proposition 3.7) with f 2 (n) = a(n) for n not divisible by p and f 1 (k) = a(p k ) which is the form required by Theorem 1.1 in view of Lemma 3.5.
• P = ∅: Since we are in the sparse case, all primes p such that a(p α ) = 0 for some α are divisors of hλ. For each prime divisor p of hλ, there are finitely many exponents α such that a(p α ) = 0. Hence, there are only finitely many prime powers on which a takes non-zero values. Since a is multiplicative, it follows that a has finite support. It is now easy to write it in the form of Theorem 1.1 (with f 1 and f 2 eventually zero).
• P = {p}: By Proposition 7.1, a is p-automatic. We can write a as a(n) = f 1 (ν p (n))f 2 (n/p νp(n) ), where f 1 (k) = a(p k ) is eventually periodic and f 2 vanishes on multiples of p and agrees with a elsewhere.
In particular, f 2 is a sparse automatic multiplicative sequence such that α → f 2 (q α ) has finite support for all primes q. By the same argument as in the case P = ∅, f 2 is finitely supported, and hence eventually periodic.
8. Remarks 8.1. Completely multiplicative case. We now derive the main result of [18] from Theorem 1.1: Proposition 8.1. Assume that a is a completely multiplicative automatic sequence. Then there exists a prime p such that a(n) = ǫ νp(n) χ(n/p νp(n) ), n ∈ N, for a root of unity ǫ and χ a Dirichlet character or the support of a is contained in {p k : k ≥ 0}.
Proof. By Theorem 1.1 (and Lemma 3.2), we can write a(n) = f 1 (ν p (n))· f 2 n/p νp(n) , where f 2 is either finitely supported and multiplicative or periodic and multiplicative. As a is completely multiplicative, we note that f 1 (k) = f 1 (1) k and f 1 (1) is either a root of unity ǫ or 0 as a takes only finitely many values. In particular, we have that a is periodic if f 1 (1) = 0. As a is completely multiplicative, f 2 is completely multiplicative because f 2 vanishes on the multiples of p. As f 2 is eventually periodic, it follows by [1, Proposition 2.2] that f 2 is either a Dirichlet character or f 2 (n) = 0 for all n > 1. This finishes the proof.

Associated dynamical systems.
Remark 4. In general, the dynamical system generated by an automatic sequence need not be uniquely ergodic, see for example [21]. However, automatic multiplicative sequences generate uniquely ergodic systems. Indeed, in the sparse case we have only finitely many primes p 1 , . . . , p k such that the support of a is contained in the set D := {p α 1 1 ...p α k k : α i ∈ N 0 , i = 1, . . . , k} which already follows from Corollary 5.4. Now, the set D has upper Banach density zero, so the only invariant measure for the system (X a , S) is given by the fixed point given by the all zero sequence. In the dense case, by Lemma 6.4, we have minimality (which implies unique ergodicity for automatic sequences, see for example [21]).
Remark 5. Since (X a , S) is always uniquely ergodic, all points in X a are generic. It follows that a itself has to have a mean. In other words the limit M(a) = lim N →∞ 1 N N n=1 a(n) does exist. We will compute its value in the next subsection. 8.3. Averages. Let us briefly discuss the average M(a) of an automatic multiplicative sequence a(n). Recall that M(a) is guaranteed to exists (cf. Remark 5).
Proposition 8.2. Let (a(n)) n≥0 be an automatic multiplicative sequence. Then M(a) is given by where f 1 , f 2 and p are given by Theorem 1.1.
Note that the last limit exists because f 2 is eventually periodic. Since f 2 (pn) = 0 for all n ≥ 0, we also have M a1 P (α,0) = 0. Combining the above formulae, for any α ≥ 0, we conclude that Remark 6. Note M(a) = 0 if M(f 2 ) = 0, which in particular includes the case when f 2 is finitely supported (see Lemma 3.2). It is also possible that M(a) = 0 even though M(f 2 ) = 0. Indeed, this is the case for instance when p = 2, f 1 is given by f 1 (0) = 1, f 1 (k) = −1 for all k ≥ 1, and f 2 is any principal character. Finally, note that in the dense case a is never aperiodic because of Lemma 6.4.