1 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, 15, 24]. 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 [25], and indeed the third author proved its validity for all automatic sequences [23]. 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 [20] proved that if \(a:\mathbb {N}\rightarrow \mathbb {C}\) is a primitiveFootnote 1 automatic sequence then it is disjoint from any bounded, aperiodic, multiplicativeFootnote 2 function \(u : \mathbb {N}\rightarrow \mathbb {C}\), i.e.

$$\begin{aligned} \lim _{N\rightarrow \infty }\frac{1}{N}\sum _{n=1}^Na(n){\overline{u}}(n)=0. \end{aligned}$$

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 sequenceFootnote 3 which was studied, e.g. in [13]. One can easily guess that multiplicative automatic sequences must possess additional interesting properties. For example, it is proved in [27] 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 [20] to Weyl almost periodicity (in the primitive case). Relatively recently, multiplicative automatic sequence have been studied in numerous papers, [1, 3, 4, 6, 7, 12, 17,18,19, 21, 22, 26], and [30]. A particular focus was put on the study of the case of completely multiplicative automatic sequences [1, 21] with a complete classification given in [22].

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 [18] and the first author [19]. Although, it is also possible to provide an ergodic theory type proof of the aforementioned conjecture following [20], we will not do it here but use the main result of [19] and prove a complete classification of automatic sequences which are multiplicative. The main result of the paper is the following:Footnote 4

Theorem 1

Let \(a: \mathbb {N}\rightarrow \mathbb {C}\) be a multiplicative and automatic sequence. Then a is p-automatic for some prime p and takes the form

$$\begin{aligned} a(n) = f_1(\nu _p(n)) \cdot f_2(n/p^{\nu _p(n)}), \end{aligned}$$
(1)

where \(f_1: \mathbb {N}_0\rightarrow \mathbb {C}\) is eventually periodic, \(f_1(0) = 1\) and \(f_2: \mathbb {N}\rightarrow \mathbb {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.Footnote 5 Moreover, the classification of completely multiplicative automatic sequences obtained by Li [22] appears as a special case of Theorem 1, see Sect. 7 for details.

To further motivate Theorem 1, let us put it in a wider context. For a sequence \(f :\mathbb {N}\rightarrow \mathbb {C}\), it is natural to inquire that the associated generating series \(F(z) = \sum _{n \ge 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 2

Let K be a field of characteristic 0, let \(f: \mathbb {N}\rightarrow K\) be a multiplicative function, and suppose that its generating series \(F (z) = \sum _{n\ge 1}f (n) z^n\) is algebraic over K(z). Then either there is a natural number k and a periodic multiplicative function \(\chi : \mathbb {N}\rightarrow K\) such that \(f (n) = n^k \chi (n)\) for all n, or f(n) is eventually zero.

An 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 done by Christol for \(q=2\) [8], and by Christol, Kamae, Mendès and Rauzy for general prime powers q [9].

Theorem 3

Let \(q = p^k\) be a prime power, let \(\mathbb {F}_q\) be a finite field of size q, and \((a(n))_{n\ge 0}\) a sequence with values in \(\mathbb {F}_q\). Then, the sequence \((a(n))_{n\ge 0}\) is p-automatic if and only if the formal power series \(\sum _{n\ge 0} a(n) X^n\) is algebraic over \(\mathbb {F}_q(X)\).

Thus, Theorem 1 can also be applied to obtain a characterization of all multiplicative functions \(a: \mathbb {N}\rightarrow \mathbb {F}_q\) such that \(\sum _{n\ge 1} a(n) X^n\) is algebraic over \(\mathbb {F}_q(X)\).

The paper is structured as follows. In Sect. 2 we give an overview of relevant basic facts about automatic sequences. Then we provide some comments on the main theorem in Sect. 3, to put it into the correct context. In Sect. 4 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 Sects. 5 and 6 for the dense and sparse case, respectively. Section 7 finishes the paper with some remarks.

1.1 Notation

Throughout the paper we let \(\mathbb {N}_0\) denote the non-negative integers and \(\mathbb {N}\) the positive integers. Furthermore, \(\mathbb {C}\) denotes the complex numbers and pq will always be prime numbers.

2 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 Eilenberg [14] characterizes automatic sequences in terms of their kernels. For a sequence \((f(n))_{n \ge 0}\) and \(\lambda \ge 2\), the \(\lambda \)-kernel of f is the set of all the possible restrictions of f to an infinite arithmetic progression whose step is a power of \(\lambda \), that is, the set

$$\begin{aligned} \left\{ (f(n \lambda ^k + r))_{n\ge 0} \ : \ k \ge 0, 0 \le r < \lambda ^{k}\right\} . \end{aligned}$$
(2)

Lemma 1

([14]) Given an integer \(\lambda \ge 2\), a sequence \(f: \mathbb {N}_0 \rightarrow \mathbb {C}\) is \(\lambda \)-automatic if and only if the \(\lambda \)-kernel of f, given by (2), is finite.

We can extend the definition of \(\lambda \)-automaticity to \(\lambda =1\) by declaring that a sequence f is 1-automatic if and only if it is eventually periodic. In this case, f is \(\lambda \)-automatic for any \(\lambda \in \mathbb {N}\).

Note that, given k and r, the first element of a sequence in (2) is f(r) and since r runs over all natural numbers as \(k\rightarrow \infty \), any automatic sequence takes only finitely many values.

The following lemma shows that the class of complex-valued automatic sequences is closed under addition, multiplication, and any other entry-wise operation.

Lemma 2

Let \(\lambda \in \mathbb {N}\) and let \((f(n))_{n \ge 0}\) and \((g(n))_{n \ge 0}\) be \(\lambda \)-automatic sequences.

  1. 1.

    The sequence \(\big ( \pi (f(n)) )_{n \ge 0}\) is \(\lambda \)-automatic for any map \(\pi \);

  2. 2.

    The sequence \(\big ((f(n),g(n))\big )_{n \ge 0}\) is \(\lambda \)-automatic.

Proof

It is enough to show that the \(\lambda \)-kernels of the relevant sequences are finite. If the \(\lambda \)-kernel of f and g have cardinalities N and M respectively, then the \(\lambda \)-kernel of \(\pi \circ f\) has at most N elements and the \(\lambda \)-kernel of (fg) has at most NM elements. \(\square \)

It is evident that if f is a \(\lambda \)-automatic sequence, then so are all the sequences in its \(\lambda \)-kernel. More generally, one can check that if f is \(\lambda \)-automatic then so is its restriction to any arithmetic progression \(n \mapsto f(an+b)\) (\(a \in \mathbb {N}\), \(b \in \mathbb {N}_0\)). We also have the following classical results about being automatic in two different bases.

Lemma 3

For any \(\lambda \in \mathbb {N}\) and \(k \ge 1\), a sequence is \(\lambda \)-automatic if and only if it is \(\lambda ^k\)-automatic.

Proof

Indeed, the \(\lambda ^k\)-kernel is contained in the \(\lambda \)-kernel, while the \(\lambda \)-kernel is contained in the union of \(\lambda ^k\)-kernels of the sequences \(n \mapsto f(\lambda ^j n + s)\) with \(j,s \in \mathbb {N}\) such that \(0 \le j < k\) and \(0 \le s < \lambda ^j\). \(\square \)

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.

Theorem 4

([10]) If a sequence f is both \(\lambda \) and \(\mu \)-automatic, where \(\lambda \) and \(\mu \) are multiplicatively independent integers (i.e. \(\log \lambda /\log \mu \notin \mathbb {Q}\)) then f is eventually periodic.

2.1 The Pumping Lemma

The Pumping Lemma (for automatic sequences) is a classical tool, which is most often used to show that some particular sequence is not automatic. We state here a slightly simplified version of it 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 \ldots w_n\) over the alphabet \(\{0,1,\ldots ,\lambda -1\}\) the corresponding integer (so that w is its base \(\lambda \) representation), i.e. \([w]_{\lambda } := w_0 \lambda ^n + w_1 \lambda ^{n-1} + \ldots + w_n \lambda ^{0}\).

Lemma 4

Let f be a \(\lambda \)-automatic sequence. Then there exists \(n_0 \in \mathbb {N}\) such that for all \(n \ge n_0\) there exist words uvw over the alphabet \(\{0,1,\ldots , \lambda -1\}\) (where v is non-empty) such that \([uvw]_{\lambda } = n\) and \(f([uv^kw]_{\lambda }) = f(n)\) for all \(k\ge 0\).Footnote 6

We can rewrite the condition \(n = [uvw]_{\lambda }\) as

$$\begin{aligned} n = [u]_{\lambda } \cdot \lambda ^{\left| vw \right| } + [v]_{\lambda } \cdot \lambda ^{\left| w \right| } + [w]_{\lambda }. \end{aligned}$$

Similarly, we find

$$\begin{aligned}{}[uv^kw]_{\lambda }&= [u]_{\lambda } \cdot \lambda ^{\left| v^kw \right| } + [v]_{\lambda } \cdot \lambda ^{\left| v^{k-1}w \right| } + \ldots + [v]_{\lambda } \cdot \lambda ^{\left| w \right| } + [w]_{\lambda }\\&= [u]_{\lambda } \cdot \lambda ^{k \left| v \right| + \left| w \right| } + [v]_{\lambda } \cdot \lambda ^{(k-1)\left| v \right| + \left| w \right| } + \ldots + [v]_{\lambda } \cdot \lambda ^{\left| w \right| } + [w]_{\lambda }\\&= [u]_{\lambda } \cdot \lambda ^{k \left| v \right| + \left| w \right| } + [v]_{\lambda } \lambda ^{\left| w \right| } \frac{\lambda ^{k\left| v \right| } - 1}{\lambda ^{\left| v \right| }-1} + [w]_{\lambda }. \end{aligned}$$

Thus, we have the following version of the Pumping Lemma for automatic sequences, where we put \(\ell _1 = \left| w \right| , \ell _2 = \left| v \right| , \ell _3 = \left| u \right| \) and \(x = [u]_{\lambda }, y = [v]_{\lambda }, z = [w]_{\lambda }\).

Lemma 5

Let f be a \(\lambda \)-automatic sequence. Then there exists \(n_0 > 0\) such that for every integer \(n \ge n_0\) there exist integers \(\ell _1, \ell _3 \ge 0\), \(\ell _2 \ge 1\) and \(x< \lambda ^{\ell _3}, y< \lambda ^{\ell _2}, z<\lambda ^{\ell _1}\) such that

$$\begin{aligned} n = x \lambda ^{\ell _{1} + \ell _{2}} + y \lambda ^{\ell _{1}} + z, \end{aligned}$$

and

$$\begin{aligned} f(n) = f\left( x \lambda ^{\ell _{1} + k \cdot \ell _{2}} + y \lambda ^{\ell _1} \frac{\lambda ^{k \cdot \ell _{2}}-1}{\lambda ^{\ell _{2}}-1}+ z \right) \end{aligned}$$

for all \(k \ge 0\).

3 Comments on the main theorem

To see Theorem 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 \ge 1\), \(\nu _p(n)\) denotes the p-adic valuation of n, that is, the unique integer k such that \(p^k \mid n\) and \(p^{k+1} \not \mid n\). The map \(\nu _p :\mathbb {N}\rightarrow \mathbb {N}_0\) is completely additive, that is,

$$\begin{aligned} \nu _p(mn)=\nu _p(m)+\nu _p(n) \end{aligned}$$
(3)

for all \(m,n \ge 1\). It is a standard observation that if \(m,n \ge 1\) and \(\nu _p(n) \ne \nu _p(m)\) then

$$\begin{aligned} \nu _p(m+n) = \min \left( \nu _p(m),\nu _p(n)\right) . \end{aligned}$$
(4)

Since \(\nu _p\) takes the value 0 at least at one of any pair of coprime integers, it also follows that

$$\begin{aligned} \nu _p (mn) = \max (\nu _p(m),\nu _p(n)) \end{aligned}$$
(5)

for any \(m,n \ge 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 6

Let \(f_1 :\mathbb {N}_0 \rightarrow \mathbb {C}\) be a sequence with \(f_1(0) = 1\). Then the sequence \(a_1 :\mathbb {N}\rightarrow \mathbb {C}\) given by \(a_1(n) = f_1(\nu _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 \mapsto a_1(p^k n + r)\) in the p-kernel of \(a_1\), where \(k \ge 0\) and \(0 \le r < p^k\).

Suppose first that \(r \ne 0\), and consequently it can be written in the form \(r = p^{\ell } r'\) where \(p \not \mid r'\) and \(0 \le \ell < k\). Then it follows from (4) that

$$\begin{aligned} a_1(p^k n + r) = f_1(\ell ) \end{aligned}$$

for all \(n \ge 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

$$\begin{aligned} a_1(p^k n + r) = f_1(\nu _p(n)+k). \end{aligned}$$

Since \(f_1\) is eventually periodic, the number of sequences of the form \(m \mapsto f_1(m + k)\) with \(k \ge 0\) is finite. As a consequence, the p-kernel of \(a_1\) is also finite, as needed. \(\square \)

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.

Lemma 7

Let \(f: \mathbb {N}\rightarrow \mathbb {C}\) be eventually periodic and multiplicative. Then either

  1. 1.

    f is periodic or

  2. 2.

    f is finitely supported.

Proof

Since f is eventually periodic, there exists a periodic sequence \(h :\mathbb {N}\rightarrow \mathbb {C}\) with some period \(d \ge 1\) and a threshold \(n_0\) such that \(f(n) = h(n)\) for all \(n \ge n_0\).

We next elucidate the connection between f and h. For any \(n \ge 1\) and any \(s \ge n_0/nd\), the integers n and \(1+snd\) are coprime, so

$$\begin{aligned} \begin{aligned} h(n)&= h\big ( n(1+snd) \big ) \\&= f\big ( n(1+snd) \big ) = f(n)f(1+snd) = f(n)h(1). \end{aligned} \end{aligned}$$
(6)

If \(h(1) = 0\) then h would be identically 0, in which case f is finitely supported and we are done. Otherwise, \(h(1) \ne 0\) and \(f(n) = h(n)/h(1)\) is periodic. \(\square \)

Lemma 8

Let \(f_2 :\mathbb {N}\rightarrow \mathbb {C}\) be eventually periodic and multiplicative. Then the sequence \(a_2 :\mathbb {N}\rightarrow \mathbb {C}\) given by \(a_2(n) = f_2(n/p^{\nu _p(n)})\) is multiplicative and p-automatic.

Proof

The multiplicativity of \(a_2\) follows immediately from the multiplicativity of \(f_2\) and the discussion above. Proceeding as in the proof of Lemma 6, we will show that the kernel of \(a_2\) is finite. Pick a sequence \(n \mapsto a_2(p^k n + r)\) with \(k \ge 0\) and \(0 \le r < p^k\). If \(r = 0\) then

$$\begin{aligned} a_2(p^k n + r) = a_2(n) \end{aligned}$$

for all \(n \ge 0\), which contributes in total one sequence to the p-kernel.

Suppose next that \(r \ne 0\) and write \(r = p^{\ell } r'\) with \(p \not \mid r'\). Hence, for all \(n \ge 0\), we have

$$\begin{aligned} a_2(p^k n + r) = f_2(p^{k-\ell } n + r'). \end{aligned}$$

In this situation it will be convenient to split into two cases, depending on which of the alternatives holds in Lemma 7 applied to \(f_2\). If \(f_2\) is periodic with a period d then \(n \mapsto a_2(p^k n + r)\) coincides with one of the (at most) \(d^2\) sequences of the form \(n \mapsto f_2(i n + j)\) with \(0 \le i,j < d\). If \(f_2\) is finitely supported then for all but finitely many choices of k and r, the sequence \(n \mapsto a_2(p^k n + r)\) is identically zero on \(\mathbb {N}\). In either case, the p-kernel of \(a_2\) is finite. \(\square \)

Combining Lemmata 6 and 8 (and the basic observations that p-automatic sequences are closed under products), we have just proved the following:

Lemma 9

Let \(f_1 :\mathbb {N}_0 \rightarrow \mathbb {C}\), \(f_2 :\mathbb {N}\rightarrow \mathbb {C}\) be eventually periodic sequences and assume further that \(f_1(0) = 1\) and \(f_2\) is multiplicative. Then the sequence

$$\begin{aligned} n\mapsto f_1(\nu _p(n))f_2(n/p^{\nu _p(n)}) \end{aligned}$$

is multiplicative and p-automatic.

Further remarks:

  • The sequence \(n\mapsto f_1(\nu _p(n))\) is ToeplitzFootnote 7, and hence almost periodicFootnote 8. Indeed, \(\nu _p(n)=\nu _p(n+spn)\) for each \(s\ge 0\) as \(\nu _p(n+spn)=\nu _p(n(sp+1))=\nu _p(n)+\nu _p(sp+1)=\nu _p(n)\). Hence, each position n has a period (namely pn).

  • If \(f_2\) is periodic (with some period d) then the sequence \(n\mapsto f_2(n/p^{\nu _p(n)})\) is Toeplitz, and hence almost periodic. Indeed, assume that \(n=p^\alpha (pm+j)\) with \(0<j<p\), i.e. \(\nu _p(n)=\alpha \). We have

    $$\begin{aligned}&f_2((n+sp^{\alpha +1}d)/p^{\nu _p(n+sp^{\alpha +1}d)})= f_2(p^\alpha (pm+psd+j)/p^{\nu _p(p^\alpha (pm+psd+j))})\\&=f_2(pm+psd+j)=f_2(pm+j)=f_2(n/p^{\nu _p(n)}). \end{aligned}$$
  • This shows in particular that \(n\mapsto f_1(\nu _p(n))f_2(n/p^{\nu _p(n)})\) is a primitive p-automatic sequence by [11, Theorem 5] whenever \(f_1\) is eventually periodic and \(f_2\) is periodic.

  • If \(f_2(1)=1\) and \(f_2(n) = 0\) otherwiseFootnote 9 then \(f_2(n/2^{\nu _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\ge 0\) and \(f_1(n)= 0\) otherwise, then

    $$\begin{aligned} n\mapsto f_1(\nu _2(n))f_2(n/2^{\nu _2(n)}) \end{aligned}$$

    takes value 1 at \(2^m\) with \(m\ge 0\) even, and the value 0 otherwise. The corresponding automatic sequence is not almost periodic, and hence not primitive by [11, Theorem 5].

The main result of the paper, i.e. Theorem 1, says that the examples given by Lemma 9 above exhaust all possible automatic sequences which are multiplicative.

As a partial converse to Lemma 9, any, not necessarily automatic, multiplicative sequence \((a(n))_{n \ge 1}\) admits a decomposition

$$\begin{aligned} a(n) = f_1(\nu _p(n)) f_2(n/p^{\nu _p(n)}), \end{aligned}$$
(7)

where \(f_1\) and \(f_2\) are necessarily given by \(f_1(k) = a(p^k)\) for all \(k \ge 0\) and \(f_2(m) = a(m)\) for all \(m \ge 1\) with \(p \not \mid m\). Since we are only interested in \(f_2(m)\) when \(p \not \mid m\), we may choose that \(f_2(m) = 0\) for all \(m \ge 0\) with \(p \mid m\), which in particular ensures that \(f_2\) is multiplicative.

Below, we record two facts which imply that if a is additionally p-automatic then \(f_1\) is eventually periodic and \(f_2\) is p-automatic. Hence, the content of Theorem 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 \ge 1\) is eventually periodic.

Lemma 10

(Corollary 5.5.3 [2]) If f is a \(\lambda \)-automatic sequence for some \(\lambda \in \mathbb {N}\) then the sequence \(k \mapsto f(\lambda ^k)\) is eventually periodic.

Proof

Since the \(\lambda \)-kernel of f is finite, there exist integers \(k > \ell \ge 0\) such that \(f(\lambda ^k n) = f(\lambda ^\ell n)\) for all \(n \ge 1\). In particular, \(f(\lambda ^{m}) = f(\lambda ^{m+k-l})\) for all \(m \ge l\). \(\square \)

Lemma 11

If f is a p-automatic sequence, where p is a prime, then the sequence \({\tilde{f}}\) given by \({\tilde{f}}(n) = f\left( n/p^{\nu _p(n)} \right) \) is also p-automatic.

Proof

By Lemma 1, it will suffice to verify that the p-kernel of \({\tilde{f}}\) is finite; in fact, we show that it has at most one element more than the kernel of f.

Pick any \(k \ge 0\) and \( r \in \{0,\ldots , p^k-1\}\). If \(r = 0\) then, for all \(n \in \mathbb {N}\), we have

$$\begin{aligned} {\tilde{f}}( p^k n + r) = {{\tilde{f}}}(n). \end{aligned}$$

Moreover, if \(r \ne 0\), then we can decompose \(r = p^{\ell } r'\), where \(p \not \mid r'\) which, for any \(n \ge 0\), implies that

$$\begin{aligned} {\tilde{f}}(p^k n + r) = f(p^{k-\ell } n + r'). \end{aligned}$$

It remains to notice that the sequence \((f(p^{k-\ell } n + r'))_{n \ge 0}\) belongs to the kernel of f. \(\square \)

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 accepts \({{\tilde{f}}}\).

As already mentioned, the decomposition given by (7) is essentially unique. We record this and previous observations in the following proposition.

Proposition 1

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 \mid n\).

Proof

The existence of such a decomposition has already been proved. For uniqueness, suppose that \(a(n) = f_1(\nu _p(n)) \cdot f_2(n/p^{\nu _p(n)})= g_1(\nu _p(n)) \cdot g_2(n/p^{\nu _p(n)})\) were two distinct decompositions as described above. For any integer n with \(p \not \mid n\), we have

$$\begin{aligned} f_2(n) = f_1(0)f_2(n) = a(n) = g_1(0)g_2(n) = g_2(n). \end{aligned}$$

If \(p \mid 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\not \mid n_0\) and \(f_2(n_0) \ne 0\). Taking \(n = p^k n_0\) for an arbitrary \(k \ge 0\), we conclude that

$$\begin{aligned} f_1(k) f_2(n_0) = a(p^k n_0) = g_1(k)f_2(n_0). \end{aligned}$$

It follows that \(f_1 = g_1\). \(\square \)

Remark 3

By Lemma 7, 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 Sect. 4.2.

4 Auxiliary lemmata

4.1 Dirichlet characters

In this subsection we recall some basic properties of Dirichlet characters.

Definition 1

We call a function \(\chi : \mathbb {Z}\rightarrow \mathbb {C}\) a Dirichlet character of modulus k if:

  • \(\chi (n) = \chi (n+k)\) for all \(n \in \mathbb {Z}\),

  • \(\chi (n) = 0\) if and only if \((n,k) > 1\),

  • \(\chi (m n) = \chi (m) \chi (n)\) for all \(m, n \in \mathbb {Z}\).

Of course, a Dirichlet character of modulus k is determined by a character of the multiplicative group \((\mathbb {Z}/k\mathbb {Z})^*\) (which takes values in roots of unity of degree \(\phi (k)\), where \(\phi \) denotes the Euler totient function). The Dirichlet character determined by the trivial (constant equal to 1) character of \((\mathbb {Z}/k\mathbb {Z})^*\) is called the principal character and is denoted by \({\widetilde{\chi }}\). Note that if d|k and \(\eta \) is a Dirichlet character of modulus d then

$$\begin{aligned} \chi :=\eta \cdot {\widetilde{\chi }} \end{aligned}$$

is a Dirichlet character of modulus k. In this case, we say that \(\chi \) is a character induced from \(\eta \).

Let \(\chi _1, \chi _2\) be Dirichlet characters of modulus \(k_1, k_2\) respectively \((k_1, k_2) = 1\). Then one sees directly that \(\chi _1 \cdot \chi _2\) is a Dirichlet character of modulus \(k_1 \cdot k_2\) as the product of (completely) multiplicative functions is again (completely) multiplicative.

Moreover, if we additionally assume that \((k_1,k_2)=1\) then this reasoning can be reversed. One can also decompose a Dirichlet character \(\chi \) of modulus \(k = k_1 k_2\) as the product of Dirichlet characters of modulus \(k_1\) and \(k_2\). Indeed, we define

$$\begin{aligned} \chi _{k_i}(n) := \chi (n_{i}), \end{aligned}$$

where \(n_{i}\) is uniquely defined modulo \(k_1 k_2\) by

$$\begin{aligned} n_{i}&\equiv n \bmod k_i\\ n_{i}&\equiv 1 \bmod k/k_i. \end{aligned}$$

One can easily seeFootnote 10 that \(\chi _{k_i}\) is a Dirichlet character of modulus \(k_i\) and \(\chi (n) = \chi _{k_1}(n) \cdot \chi _{k_2}(n)\) for all \(n\in \mathbb {Z}\).

4.2 Solution of Bell–Bruin–Coons conjecture

Conjecture 1

(Bell-Bruin-Coons) For any multiplicative automatic function \(f:\mathbb {N}\rightarrow \mathbb {C}\) there exists an eventually periodic function \(g:\mathbb {N}\rightarrow \mathbb {C}\) such that \(f(p) =g(p)\) for all primes p.

This conjecture was recently solved independently by the first author [19] and Klurman and Kurlberg [17]. We recall the slightly stronger form obtained in [19].

Theorem 5

(Theorem 1 of [19]) If \(a:\mathbb {N}\rightarrow \mathbb {C}\) is an automatic multiplicative sequence then there exist a threshold \(p_*\) and a function \(\chi : \mathbb {N}\rightarrow \mathbb {C}\) which is either a Dirichlet character or identically zero such that \(a(n) = \chi (n)\) for all \(n \in \mathbb {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 \(\chi \) 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 \(\chi \) in Theorem 5, then replacing \(\chi \) by the induced character of modulus \(k' =\mathrm{lcm}(k, p_{*}!)\) (and replacing k by \(k'\)), we conclude that \(a(n)=\chi (n)\) for all \(n\in \mathbb {N}\) coprime to k. This lets us reformulate the theorem above in the following form, which will be more convenient.

Corollary 1

Let \(a: \mathbb {N}\rightarrow \mathbb {C}\) be an automatic multiplicative sequence. Then there exist coprime integers h and \(\lambda \) and a sequence \(\chi :\mathbb {N}\rightarrow \mathbb {C}\) which is either identically zero or a Dirichlet character of modulus \(h \lambda \) such that a is \(\lambda \)-automatic and \(a(n) = \chi (n)\) for all \(n \in \mathbb {N}\) that are coprime to \(h \lambda \).

Proof

Pick a base \(\lambda _0 \in \mathbb {N}\) such that a is \(\lambda _0\)-automatic. By the remark above, there exist an integer \(k \in \mathbb {N}\) and a sequence \(\chi _0\) which is either identically zero or a Dirichlet character of modulus k such that \(a(n) = \chi _0(n)\) for all n coprime to k. Now, we can decompose \(k = k_1 \cdot k_2\) so that \((\lambda _0, k_2) = 1\) and \(k_1 \mid \lambda _0^{\ell }\) for some \(\ell \in \mathbb {N}\). We take \(\lambda := \lambda _0^{\ell }\), \(h := k_2\) and see that a is \(\lambda \)-automatic by virtue of Lemma 3. Furthermore, inducing to modulus \(h\lambda \), we obtain \(\chi \) which is either identically zero or a Dirichlet character of modulus \(h \lambda \) and the result follows. \(\square \)

Since the integer \(h\lambda \) will play a crucial role, it is convenient to make the following definition.

Definition 2

We let \({\mathcal {C}}\) denote the set of integers coprime to \(h \lambda \).

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 the remarks after Lemma 9), while in the sparse case it is not.

5 Proof of the Main Theorem in the dense case

Let a be an automatic multiplicative sequence, as in the assumptions of Theorem 1, and let \(h,\lambda \) and \(\chi \) be given as in Corollary 1. In this section we prove Theorem 1 in the dense case, meaning that we assume that \(\chi \) is a Dirichlet character of modulus \(h\lambda \). It will be convenient to denote \(\alpha (p) := \nu _p(h\lambda )\) for p prime.

As we have seen in Sect. 4.1, we can decompose \(\chi \) into the product of Dirichlet characters of coprime moduli:

$$\begin{aligned} \chi = \chi _h \cdot \chi _{\lambda } = \prod _{p \mid h \lambda } \chi _{p^{\alpha (p)}}. \end{aligned}$$

As a consequence, for \(n \in {\mathcal {C}}\), we have

$$\begin{aligned} a(n) = \chi (n) = \prod _{p \mid h\lambda } \chi _{p^{\alpha (p)}}(n). \end{aligned}$$
(8)

For a general \(n \in \mathbb {N}\), we can find a decomposition

$$\begin{aligned} n = n' \cdot \prod _{p \mid h\lambda } p^{\nu _p(n)} \end{aligned}$$
(9)

as the product of prime divisors of \(h \lambda \) and an element of \({\mathcal {C}}\), with \(n'\) given by

$$\begin{aligned} n' = n/ \prod _{p \mid h\lambda } p^{\nu _p(n)}. \end{aligned}$$
(10)

Since a is multiplicative and the factors \(n'\) and \(p^{\nu _p(n)}\) (for \(p \mid h\lambda \)) in (9) are pairwise coprime, it follows that

$$\begin{aligned} a(n) = a(n') \cdot \prod _{p \mid h\lambda } a(p^{\nu _{p}(n)}). \end{aligned}$$
(11)

We note that \(n'\) given by (10) belongs to \({\mathcal {C}}\). Hence, we can replace the first occurrence of a in the decomposition (11) with \(\chi \). This and (8) allows us to rewrite (11) as follows

$$\begin{aligned} a(n)&= \prod _{p \mid h\lambda } \chi _{p^{\alpha (p)}} \left( \frac{n}{ \prod _{q \mid h\lambda } q^{\nu _q(n)} } \right) \cdot \prod _{p \mid h\lambda } a(p^{\nu _p(n)}). \end{aligned}$$
(12)

Our next goal is to simplify the decomposition given in (12) above. Towards this end, we introduce a new piece of notation (cf. notation \(n_{i}\) in Sect. 4.1 ). For \(p \mid h\lambda \), we let \({\bar{p}}\) be an integer determined uniquely modulo \(h\lambda \) by the following system of congruences:

$$\begin{aligned} \begin{aligned} {\overline{p}}&\equiv 1 \bmod p^{\alpha (p)}\\ {\overline{p}}&\equiv p \bmod h \lambda /p^{\alpha (p)}. \end{aligned} \end{aligned}$$
(13)

This definition is set up so that, in particular, for each \(p \mid h\lambda \), we have

$$\begin{aligned} \chi _{h\lambda /p^{\alpha (p)}}(p)=\chi ({\overline{p}}). \end{aligned}$$
(14)

We are now ready to write (12) in a more condensed form.

Proposition 2

With the notation from (13), for all \(n \in \mathbb {N}\), we have

$$\begin{aligned} a(n) = \prod _{p \mid h\lambda } \chi _{p^{\alpha (p)}}\left( \frac{n}{p^{\nu _{p}(n)}} \right) \cdot \frac{a(p^{\nu _{p}(n)})}{\chi ({\overline{p}})^{\nu _{p}(n)}}. \end{aligned}$$

Proof

It follows from (12) and the fact that Dirichlet characters are completely multiplicative that

$$\begin{aligned} a(n)&= \prod _{p \mid h\lambda } \left( \chi _{p^{\alpha (p)}}\left( \frac{n}{p^{\nu _p(n)}} \right) a(p^{\nu _p(n)}) \prod _{\begin{array}{c} q \mid h\lambda \\ q \ne p \end{array}} \chi _{p^{\alpha (p)}}(q)^{-\nu _q(n)} \right) . \end{aligned}$$
(15)

Exchanging the order of multiplication in the innermost product yields:

$$\begin{aligned} \prod _{p \mid h\lambda } \left( \prod _{\begin{array}{c} q \mid h\lambda \\ q \ne p \end{array}} \chi _{p^{\alpha (p)}}(q)^{\nu _q(n)} \right)&= \prod _{q \mid h\lambda } \left( \prod _{\begin{array}{c} p \mid h\lambda \\ p \ne q \end{array}} \chi _{p^{\alpha (p)}}(q)^{\nu _q(n)} \right) \end{aligned}$$
(16)
$$\begin{aligned}&= \prod _{q \mid h \lambda } \chi _{h\lambda /q^{\alpha (q)}}\left( q \right) ^{\nu _q(n)}. \end{aligned}$$
(17)

It remains to recall (14) and insert (16) into (15). \(\square \)

The factors in the decomposition produced by Proposition 2 correspond to different prime divisors p of \(h\lambda \). We are already satisfied with the factors coming from \(p \mid \lambda \) and proceed to prove additional properties for \(p \mid h\). Therefore, we will use the following lemma.

Lemma 12

Let p be a prime number and \(f: \mathbb {N}\rightarrow \mathbb {C}\) be such that \(\gamma \mapsto f(p^{\gamma })\) is eventually constant. Then

$$\begin{aligned} n \mapsto f(p^{\nu _p(n)}) \end{aligned}$$

is periodic.

If \(\gamma \mapsto f(p^{\gamma })\) is eventually equal to zero, then

$$\begin{aligned} n \mapsto f(p^{\nu _p(n)}) \cdot \chi \left( \frac{n}{p^{\nu _p(n)}} \right) \end{aligned}$$
(18)

is periodic for any Dirichlet character \(\chi \) of modulus \(p^{\alpha }\), for an arbitrary \(\alpha \in \mathbb {N}\).

Proof

We denote by \(\gamma _p\) the least integer such that the sequence \(\gamma \mapsto f(p^\gamma )\) is constant for \(\gamma \ge \gamma _p\). If \(\nu _p(n)\ge \gamma _p\), then also \(\nu _p(n+kp^{\gamma _p})\ge \gamma _p\) for each \(k\ge 0\), so the sequence

$$\begin{aligned} k\mapsto f(p^{\nu _p(n+kp^{\gamma _p})}) \end{aligned}$$
(19)

is also constant. If \(\nu _p(n)<\gamma _p\) then

$$\begin{aligned} \nu _p(n+kp^{\gamma _p})=\nu _p(n) \end{aligned}$$

for each \(k\ge 0\), so the more the sequence (19) is constant. It follows that the sequence

$$\begin{aligned} n\mapsto f(p^{\nu _{p}(n)}) \end{aligned}$$

is \(p^{\gamma _p}\) periodic.

Let us now assume that \(f(p^{\gamma }) = 0\) for all \(\gamma \ge \gamma _p\). Suppose first that \(\nu _p(n) < \gamma _p\). We see directly that \(\nu _p(n + kp^{\gamma _p+\alpha }) = \nu _p(n)\) for any \(k \in \mathbb {N}\). Thus,

$$\begin{aligned} f(p^{\nu _p(n+kp^{\gamma _p + \alpha })}) \cdot \chi \left( \frac{n+kp^{\gamma _p+\alpha }}{p^{\nu _p(n+kp^{\gamma _p+\alpha })}} \right)&= f(p^{\nu _p(n)}) \cdot \chi \left( \frac{n}{p^{\nu _p(n)}} + kp^{\gamma _p + \alpha -\nu _p(n)} \right) \\&= f(p^{\nu _p(n)}) \cdot \chi \left( \frac{n}{p^{\nu _p(n)}} \right) , \end{aligned}$$

where the last equality holds, since \(\chi \) is \(p^{\alpha }\)-periodic. Suppose now that \(\nu _p(n) \ge \gamma _p\). Obviously, \(\nu _p(n+kp^{\gamma _p+\alpha }) \ge \gamma _p\), for every \(k \in \mathbb {N}\). Thus,

$$\begin{aligned} f(p^{\nu _p(n+kp^{\gamma _p + \alpha })}) \cdot \chi \left( \frac{n+kp^{\gamma _p+\alpha }}{p^{\nu _p(n+kp^{\gamma _p+\alpha })}} \right) = 0 \end{aligned}$$

and we have shown in total, that (18) is periodic with period \(p^{\gamma _p + \alpha }\). \(\square \)

Lemma 13

For any prime \(q \mid h\), the sequence

$$\begin{aligned} n \mapsto \chi _{q^{\alpha (q)}}\left( \frac{n}{q^{\nu _{q}(n)}} \right) \cdot \frac{a(q^{\nu _{q}(n)})}{\chi ({\overline{q}})^{\nu _{q}(n)}} \end{aligned}$$

is periodic.

Proof

The proof splits into two parts. We first show that \(\gamma \mapsto a(q^{\gamma })/\chi ({\overline{q}})^{\gamma }\) is eventually constant. Then we distinguish the case where this sequence eventually equals zero. If this is the case, then we are done by the second part of Lemma 12. If the sequence is not eventually equal to zero, then we also need to show that \(\chi _{q^{\alpha (q)}}\) is trivial, i.e. constant and equal to 1 on integers coprime to q. In this case we apply the first part of Lemma 12 and see that

$$\begin{aligned} n \mapsto \frac{a(q^{\nu _{q}(n)})}{\chi ({\overline{q}})^{\nu _{q}(n)}} \end{aligned}$$

is periodic.

Let us consider the finite \(\lambda \)-kernel of a. It follows by the pigeonhole principle that there exist \(k\ge 1\) and \(r_1< r_2 < \lambda ^k\) such that

$$\begin{aligned} r_1 \equiv r_2 \equiv 1 \bmod h \lambda \end{aligned}$$
(20)

and

$$\begin{aligned} a(n \lambda ^{k} + r_1) = a(n \lambda ^{k} + r_2) \end{aligned}$$
(21)

for all \(n \in \mathbb {N}\). By the LHS congruence in (20) it follows that there exists \(\beta \ge \alpha (q)\) such that

$$\begin{aligned} r_2 - r_1 = q^{\beta } r, \end{aligned}$$
(22)

where \((r,q) = 1\).

We will show that the sequence \((a(q^\gamma )/\chi ({\overline{q}})^{\gamma })\) is constant for \(\gamma \ge \beta +\alpha (q)\). Let us fix \(\gamma \) and \(s \in \mathbb {N}\), such that \(\gamma \ge \beta +\alpha (q), 0<s<q^{\alpha (q)}\) and \((s,q) = 1\). Using the fact that \((\lambda ,h)=1\) and then the Chinese Remainder Theorem, we find some n such that

$$\begin{aligned} \begin{aligned} n \lambda ^k + r_1&\equiv s\cdot q^{\gamma } \bmod q^{\gamma + \alpha (q)}\\ n \lambda ^k + r_1&\equiv 1 \bmod h/q^{\alpha (q)}. \end{aligned} \end{aligned}$$
(23)

We will show that

$$\begin{aligned} a(n\lambda ^k+r_1)=\chi _{q^{\alpha (q)}}(s) \cdot a(q^\gamma )/\chi ({\overline{q}})^\gamma \end{aligned}$$
(24)

and

$$\begin{aligned} a(n\lambda ^k+r_2)=a(q^\beta )/\chi ({\overline{q}})^{-\beta } \chi _{q^{\alpha (q)}}(r). \end{aligned}$$
(25)

Suppose that (24) and (25) have already been proved. Then, by (25), \(a(n\lambda ^k+r_2)\) is independent of n, therefore, independent of s and \(\gamma \). If \(a(q^{\beta }) = 0\), then we conclude by (21) and (24) that \(a(q^{\gamma })/\chi ({\overline{q}})^{\gamma }\) is eventually equal to zero. If \(a(q^{\beta }) \ne 0\), then we see that \(a(n\lambda ^k + r_1) \ne 0\) and it is independent of s and \(\gamma \), showing that \(\chi _{q^{\alpha (q)}}\) is trivial and \(a(q^{\gamma })/\chi ({\overline{q}})^{\gamma }\) is eventually constant.

We will now show (24) and (25) (we proceed similarly to (12)). Denote \(\nu _q(n\lambda ^k+r_i)=:m_i\), \(i=1,2\). Our aim will be to determine \(m_i\) and to show that \(((n\lambda ^k+r_i)/q^{m_i},h\lambda )=1\) which, by the multiplicativity of a, yields

$$\begin{aligned} a(n\lambda ^k + r_i) = a(q^{m_i}) \cdot a\left( \frac{n \lambda ^k + r_i}{q^{m_i}} \right) = a(q^{m_i}) \cdot \chi \left( \frac{n \lambda ^k + r_i}{q^{m_i}} \right) . \end{aligned}$$

Then we decompose \(\chi = \chi _{\lambda } \cdot \chi _{q^{\alpha (q)}} \cdot \chi _{h/q^{\alpha (q)}}\) and it only remains to determine the residues of \(\left( n\lambda ^k + r_i \right) /{q^{m_i}}\) modulo \(\lambda , q^{\alpha (q)}\) and \(h/q^{\alpha (q)}\).

We now determine \(m_1\) by showing that \(m_1=\gamma \) and also show that \(((n\lambda ^k+r_1)/q^{\gamma },h\lambda )=1\). Indeed, by (20) and (23), we have

$$\begin{aligned}&\frac{n\lambda ^k + r_1}{q^{\gamma }} \equiv s \bmod q^{\alpha (q)},\\&\frac{n\lambda ^k + r_1}{q^{\gamma }} \equiv (q^{\gamma })^{-1} \bmod \lambda , \quad \quad \frac{n\lambda ^k + r_1}{q^{\gamma }}\equiv (q^{\gamma })^{-1} \bmod h/q^{\alpha (q)}, \end{aligned}$$

where \((q^{\gamma })^{-1}\) on the right hand side congruences means, respectively, the reciprocals of \(q^\gamma \) in \((\mathbb {Z}/\lambda \mathbb {Z})^*\) and \((Z/(h/q^{\alpha })\mathbb {Z})^*\). Thus, we have by the discussion above, the multiplicativity of Dirichlet characters and the definition of \({\overline{q}}\),

$$\begin{aligned} a(n\lambda ^k + r_1)&= a(q^{\gamma })\cdot \chi _{\lambda }((q^{\gamma })^{-1}) \chi _{q^{\alpha (q)}}(s) \cdot \chi _{h/q^{\alpha (q)}}((q^{\gamma })^{-1})\\&= \chi _{q^{\alpha (q)}}(s) \frac{a(q^{\gamma })}{\chi _{\lambda }(q^{\gamma }) \chi _{h/q^{\alpha (q)}}(q^{\gamma })}\\&= \chi _{q^{\alpha (q)}}(s) \frac{a(q^{\gamma })}{\chi ({\overline{q}})^{\gamma }}, \end{aligned}$$

which shows (24).

As \(\gamma \ge \beta + \alpha (q)\), we have \(\nu _{q}(n \lambda ^k + r_2) = \beta \). Indeed, we find similarly to the previous computation (using (20), (22) and (23)) that

$$\begin{aligned} \frac{n\lambda ^k + r_2}{q^{\beta }} = \frac{n\lambda ^k + r_1 + r q^{\beta }}{q^{\beta }}&\equiv r \bmod q^{\alpha (q)}\\ \frac{n\lambda ^k + r_2}{q^{\beta }}&\equiv (q^{\beta })^{-1} \bmod \lambda \quad \quad \frac{n\lambda ^k + r_2}{q^{\beta }}&\equiv (q^{\beta })^{-1} \bmod h/q^{\alpha (q)}, \end{aligned}$$

which shows (25) and the proof is complete.Footnote 11

\(\square \)

5.1 Prime base

Now, we are in a position to prove Theorem 1 in the case, where \(\lambda \) is a prime power. First, we recall that if \(\lambda = p^{\alpha }\) for some prime p and \(\alpha \ge 1\), then a being \(\lambda \)-automatic is equivalent to a being p-automatic thanks to Lemma 3. Moreover, we recall that we continue to assume that we are in the dense case (see Sect. 4.2).

Proposition 3

If \(\lambda = p^\alpha \) is a power of a prime p then the automatic sequence a can be written in the form

$$\begin{aligned} a(n) = f_1(\nu _p(n)) \cdot f_2\left( \frac{n}{p^{\nu _p(n)}} \right) , \end{aligned}$$
(26)

where \(f_1(0) = 1\), \(f_1\) is eventually periodic and \(f_2\) is multiplicative and periodic.

Proof

We recall that by Proposition 2,

$$\begin{aligned} a(n) = \chi _{p^{\alpha (p)}}\left( \frac{n}{p^{\nu _{p}(n)}} \right) \cdot \frac{a(p^{\nu _{p}(n)})}{\chi ({\overline{p}})^{\nu _{p}(n)}} \cdot \prod _{q \mid h} \chi _{q^{\alpha (q)}}\left( \frac{n}{q^{\nu _{q}(n)}} \right) \cdot \frac{a(q^{\nu _{q}(n)})}{\chi ({\overline{q}})^{\nu _{q}(n)}}. \end{aligned}$$

By Lemma 13 and Lemma 9 we can replace the last product by a periodic and multiplicative function g, which gives in total

$$\begin{aligned} a(n)&= \chi _{p^{\alpha (p)}}\left( \frac{n}{p^{\nu _{p}(n)}} \right) \cdot \frac{a(p^{\nu _{p}(n)})}{\chi ({\overline{p}})^{\nu _{p}(n)}} \cdot g(n)\\&= \chi _{p^{\alpha (p)}}\left( \frac{n}{p^{\nu _{p}(n)}} \right) g\left( \frac{n}{p^{\nu _{p}(n)}} \right) \cdot \frac{a(p^{\nu _{p}(n)})}{\chi ({\overline{p}})^{\nu _{p}(n)}} \cdot g(p^{\nu _p(n)}). \end{aligned}$$

Thus, we choose \(f_1 (\gamma ) = a(p^{\gamma })/\chi ({\overline{p}})^{\gamma } \cdot g(p^{\gamma })\) and \(f_2 = \chi _{p^{\alpha (p)}} \cdot g\). We see directly, that \(f_2\) fulfills the requirements of the proposition and it only remains to consider \(f_1\). As a is multiplicative we conclude that \(a(1) = 1\) and, therefore also \(f_1(0) = 1\). The function \(f_1\) is eventually periodic, as it is the product of three periodic functions: we see by Lemma 10 that \(\gamma \mapsto a(p^{\gamma })\) is eventually periodic. The function \(\gamma \mapsto 1/\chi ({\overline{p}})^{\gamma }\) is periodic, as \(\chi ({\overline{p}})\) is a root of unity. We recall that g is periodic, say with period \(k = k' \cdot p^{\alpha }\), where \(\gcd (k', p) = 1\). It follows directly from Euler’s theorem that \(\gamma \mapsto p^{\gamma } \mod k'\) is periodic with period \(\phi (k')\) and, clearly, \(\gamma \mapsto p^{\gamma } \mod p^{\alpha }\) is eventually constant. Thus, \(\gamma \mapsto p^{\gamma } \mod k\) is eventually periodic, by the Chinese Remainder Theorem.

\(\square \)

5.2 Composite case

It remains to consider the case where \(\lambda \) is composite. The main content of the argument is contained in the following analogue of Lemma 13.

Lemma 14

Suppose that \(\lambda \) is not a prime power. For any prime \(p \mid \lambda \), the sequence

$$\begin{aligned} n \mapsto \chi _{p^{\alpha (p)}}\left( \frac{n}{p^{\nu _{p}(n)}} \right) \cdot \frac{a(p^{\nu _{p}(n)})}{\chi ({\overline{p}})^{\nu _{p}(n)}} \end{aligned}$$

is periodic.

Proof

The proof is structured very similarly to the proof of Lemma 13. The proof splits again into two parts. We first show that \(\gamma \mapsto a(p^{\gamma })/\chi ({\overline{p}})^{\gamma }\) is eventually constant. Then we distinguish the case where this sequence eventually equals zero. If this is the case, then we are done by the second part of Lemma 12. If the sequence is not eventually equal to zero, then we also need to show that \(\chi _{p^{\alpha (p)}}\) is trivial, i.e. constant and equal to 1 on integers coprime to p. In this case we apply the first part of Lemma 12 and see that

$$\begin{aligned} n \mapsto \frac{a(p^{\nu _{p}(n)})}{\chi ({\overline{p}})^{\nu _{p}(n)}} \end{aligned}$$

is periodic.

Let us consider the finite \(\lambda \)-kernel of a. It follows by the pigeonhole principle that there exist \(k\ge 1\) and \(r_1< r_2 < (\lambda /p^{\alpha (p)})^k\) such that

$$\begin{aligned} r_1 \equiv r_2 \equiv 1 \bmod h \lambda \end{aligned}$$
(27)

and

$$\begin{aligned} a(n \lambda ^{k} + p^{\alpha (p)k} r_1) = a(n \lambda ^{k} + p^{\alpha (p)k} r_2) \end{aligned}$$
(28)

for all \(n \in \mathbb {N}\). (This is the only step, where we need the assumption that \(\lambda \) is not a prime power, ensuring \(\lambda /p^{\alpha (p)} > 1\).) We note that, by (27), we have \(r_2-r_1=p^\beta r\) for some \(\beta \ge \alpha (p)\) and r with \(p \not \mid r\).

Take any \(\gamma , s \in \mathbb {N}\) such that \(\gamma \ge \alpha (p) + \beta , 0<s<p^{\alpha (p)}\) and \((s,p) = 1\). Since \((\lambda /p^{\alpha (p)}, p) = 1\) and \((\lambda , h) = 1\), we can find — using the Chinese Remainder Theorem — an integer n such that

$$\begin{aligned} \begin{aligned} n \cdot (\lambda /p^{\alpha (p)})^k + r_1&\equiv s \cdot p^{\gamma } \bmod {p^{\gamma + \alpha (p)}},\\ n \cdot \lambda ^k + r_1 p^{\alpha (p) k}&\equiv 1 \bmod {h}, \end{aligned} \end{aligned}$$

which can equivalently be written as

$$\begin{aligned} \begin{aligned} n \cdot \lambda ^k + r_1 p^{\alpha (p)k}&\equiv s \cdot p^{\gamma +\alpha (p)k} \bmod {p^{\gamma + (k+1)\alpha (p)}},\\ n \cdot \lambda ^k + r_1 p^{\alpha (p) k}&\equiv 1 \bmod {h}. \end{aligned} \end{aligned}$$
(29)

Our goal is now again to compute \(a(n \lambda ^k + p^{\alpha (p)k} r_i)\) similarly to (12). Therefore, we will first determine \(\nu _p(n \lambda ^k + p^{\alpha (p)k} r_i) =: m_i\) and then show that \(\left( \left( n \lambda ^k + p^{\alpha (p) k} r_i \right) /{p^{m_i}}, h \lambda \right) = 1\). Thus, we will find by the multiplicativity of a,

$$\begin{aligned} a(n \lambda ^k + p^{\alpha (p) k} r_i) = a(p^{m_i}) \cdot a\left( \frac{n \lambda ^k + p^{\alpha (p) k} r_i}{p^{m_i}} \right) = a(p^{m_i}) \cdot \chi \left( \frac{n \lambda ^k + p^{\alpha (p) k} r_i}{p^{m_i}} \right) . \end{aligned}$$

Then we will decompose \(\chi = \chi _{p^{\alpha (p)}} \cdot \chi _{\lambda /p^{\alpha (p)}} \cdot \chi _{h}\), so that it will only remain to determine the residues of \(\left( n \lambda ^k + p^{\alpha (p) k} r_i \right) /{p^{m_i}}\) modulo \(p^{\alpha (p)}, \lambda /p^{\alpha (p)}\) and h.

We claim that \(m_1 = \nu _p(n\lambda ^k + p^{\alpha (p)k}r_1) = \gamma + \alpha (p)k\). Indeed, we have by (29) (for (30) and (31)) and (27) (for (32))

$$\begin{aligned} \frac{n \lambda ^k + p^{\alpha (p) k} r_1}{p^{\gamma + \alpha (p) k}}&\equiv s \bmod p^{\alpha (p)}, \end{aligned}$$
(30)
$$\begin{aligned} \frac{n \lambda ^k + p^{\alpha (p) k} r_1}{p^{\gamma + \alpha (p) k}}&\equiv (p^{\gamma + \alpha (p) k})^{-1} \bmod h, \end{aligned}$$
(31)
$$\begin{aligned} \frac{n \lambda ^k + p^{\alpha (p) k} r_1}{p^{\gamma + \alpha (p) k}}&\equiv (p^{\gamma })^{-1} \bmod \lambda /p^{\alpha (p)}. \end{aligned}$$
(32)

Thus, by (30), (31), (32), the complete multiplicativity of Dirichlet characters and  (14), we obtain

$$\begin{aligned} a(n \lambda ^k + p^{\alpha (p) k} r_1)&= a(p^{\gamma + \alpha (p) k}) \cdot \chi _{p^{\alpha (p)}}(s) \cdot \chi _{\lambda /p^{\alpha (p)}}((p^{\gamma })^{-1}) \cdot \chi _{h}((p^{\gamma + \alpha (p) k})^{-1})\\ {}&= \chi _{p^{\alpha (p)}}(s) \cdot \frac{a(p^{\gamma + \alpha (p) k})}{\chi ({\overline{p}})^{\gamma + \alpha (p) k}} \cdot \chi _{\lambda /p^{\alpha (p)}}(p^{\alpha (p)k}). \end{aligned}$$

We next consider \(a(n\lambda ^k + p^{\alpha (p)k}r_2)\). We claim that \(m_2 = \nu _p(n \lambda ^k + p^{\alpha (p)k}r_2) = \beta + \alpha (p) k\). Indeed, we have by \(r_2 - r_1 = r p^{\beta }\),

$$\begin{aligned} \frac{n \lambda ^k + p^{\alpha (p)k} r_2}{p^{\beta + \alpha (p)k}} = \frac{n \lambda ^k + r_1p^{\alpha (p) k} + r p^{\beta + \alpha (p) k}}{p^{\beta + \alpha (p)k}} \equiv r \bmod p^{\alpha (p)}, \end{aligned}$$

as \(\gamma \ge \beta + \alpha (p)\). Moreover, we find by \(r_1 \equiv r_2 \bmod h \lambda \), and (31), (32),

$$\begin{aligned} \frac{n\lambda ^k + p^{\alpha (p)k}r_2}{p^{\beta + \alpha (p) k}}&\equiv (p^{\beta + \alpha (p)k})^{-1} \bmod h,\end{aligned}$$
(33)
$$\begin{aligned} \frac{n\lambda ^k + p^{\alpha (p)k}r_2}{p^{\beta + \alpha (p) k}}&\equiv (p^{\beta })^{-1} \bmod \lambda /p^{\alpha (p)}. \end{aligned}$$
(34)

Now, we have by the same arguments as above,

$$\begin{aligned} a(n\lambda ^k + p^{\alpha (p)k} r_2)&= a(p^{\beta + \alpha (p)k}) \cdot \chi _{p^{\alpha (p)}}(r) \cdot \chi _{h}((p^{\beta + \alpha (p) k})^{-1}) \cdot \chi _{\lambda /p^{\alpha (p)}}((p^{\beta })^{-1})\\ {}&= \frac{a(p^{\beta + \alpha (p)k}) \cdot \chi _{p^{\alpha (p)}}(r) \cdot \chi _{\lambda /p^{\alpha (p)}}(p^{\alpha (p)k})}{\chi ({\overline{p}})^{\beta + \alpha (p)k}}. \end{aligned}$$

Thus, we have in total by (28),

$$\begin{aligned} \chi _{p^{\alpha (p)}}(s) \cdot \frac{a(p^{\gamma + \alpha (p) k})}{\chi ({\overline{p}})^{\gamma + \alpha (p) k}} = \frac{a(p^{\beta + \alpha (p)k}) \cdot \chi _{p^{\alpha (p)}}(r)}{\chi ({\overline{p}})^{\beta + \alpha (p)k}}, \end{aligned}$$

for all \(\gamma \) and \(s\in \mathbb {N}\) such that \(\gamma \ge \alpha (p) + \beta , 0<s<p^{\alpha (p)}\) and \((s,p) = 1\), where the right hand side of the above equality is independent of \(\gamma \) and s. Thus the claims follow by the same reasoning as in the proof of Lemma 13. \(\square \)

As the product of periodic sequences is again periodic, we conclude the composite case.

Corollary 2

Suppose that \(\lambda \) is not a prime power. Then a is periodic and fulfills trivially Theorem 1.

6 Proof of Theorem 1 in the sparse case

Throughout this section we assume that \(a(n) = 0\) for all \(n > 1\) with \((n, \lambda h) = 1\).

The proof of the following proposition can be seen as a variant of Schützenberger’s proof [28] that no infinitely supported automatic sequence can only be supported on prime numbers.

Proposition 4

Let \(a: \mathbb {N}\rightarrow \mathbb {C}\) be a \(\lambda \)-automatic multiplicative sequence and let \(h \in \mathbb {N}\) be such that \(a(n) = 0\) for all \(n \in \mathbb {N}\) that are coprime to \(h\lambda \). Suppose that \(\alpha \mapsto a(p^{\alpha })\) is not finitely supported for some prime p. Then a is p-automatic.

Proof

Assume that \(\alpha \mapsto a(p^\alpha )\) is not finitely supported. Then p cannot be coprime with \(h\lambda \) as we are in the sparse case. So \(p|h\lambda \). There are two cases then: either p|h and we will show that this is in fact impossible, or \(p|\lambda \) in which case we will show that a is p-automatic.

Suppose first that there exists \(q \mid h\) such that \(a(q^{\alpha }) \ne 0\) for infinitely many \(\alpha \in \mathbb {N}\). Thus, we can apply Lemma 5 (the Pumping lemma) to \(q^i\) for some large i. Therefore, there exists a decomposition \(q^i = x \lambda ^{k+\ell } + y \lambda ^{k} + z\) (with \(\ell \ge 1\)) such that

$$\begin{aligned} a(q^i) = a\left( x \lambda ^{k+(n+1)\ell }+ y \lambda ^{k} \left( \lambda ^{0} + \lambda ^{\ell } + \ldots + \lambda ^{n \ell } \right) + z \right) \ne 0 \end{aligned}$$
(35)

for all \(n \in \mathbb {N}\).

Since \(\lambda ^\ell \) is coprime with h (hence with \(q^i\)), it is also coprime with \((\lambda ^\ell -1)hq^i\). Therefore, for some \(L\ge 1\), we have \(\lambda ^{L\ell }\equiv 1\) mod \((\lambda ^\ell -1)hq^i\). It follows that

$$\begin{aligned} \lambda ^{0} + \lambda ^{\ell } + \ldots + \lambda ^{(L-1)\ell } = (\lambda ^{L\ell } - 1)/(\lambda ^\ell - 1) \equiv 0 \bmod {hq^i}. \end{aligned}$$

Let us consider the integer

$$\begin{aligned} m := x \lambda ^{k + (L+1) \ell }+ y \lambda ^{k} \left( \lambda ^{0} + \lambda ^{\ell } + \ldots + \lambda ^{L \ell } \right) + z. \end{aligned}$$

From the definition of m it follows that for some \(r\ge 1\), we have

$$\begin{aligned} m&=x\lambda ^{k+\ell }\lambda ^{L\ell }+y\lambda ^k(rhq^i+\lambda ^{L\ell })+z\\&=q^i + x\lambda ^{k+\ell }(\lambda ^{L\ell }-1) + y\lambda ^k(rhq^i+\lambda ^{L\ell }-1). \end{aligned}$$

Therefore (as clearly \(\lambda ^{L\ell }\equiv 1\) mod \(hq^i\)),

$$\begin{aligned} m \equiv q^i \bmod {hq^i}. \end{aligned}$$
(36)

Moreover, as \(z\equiv q^i\) mod \(\lambda \), we also have

$$\begin{aligned} m \equiv q^i \bmod \lambda . \end{aligned}$$
(37)

From the two above congruences (36), (37) it follows that \(m \equiv q^i \bmod q^i h \lambda \) and consequently \(m/q^i \equiv 1 \bmod h \lambda \). Thus, \((q^i, m/q^i) = 1\) and, by the multiplicativity of a, we have \(a(m) = a(q^i) \cdot a(m/q^i)\). Since \((m/q^i, h \lambda ) = 1\) and \(m/q^i > 1\), we have \(a(m/q^i) = 0\), as we are in the sparse case. But by (35), \(a(q^i)=a(m)\ne 0\) which leads to a contradiction.

Suppose now that \(a(p^{\alpha }) \ne 0\) for infinitely many \(\alpha \) for some prime \(p \mid \lambda \). By the same reasoning as before, we find that for some large enough i, we can find a decomposition \(p^i = x \lambda ^{k + \ell }+ y \lambda ^{k} + z\) (with \(\ell \ge 1\)) such that

$$\begin{aligned} a(p^i) = a(x \lambda ^{k + (n+1) \ell } + y \lambda ^{k} \left( \lambda ^{0} + \lambda ^{\ell } + \ldots + \lambda ^{n \ell } \right) + z) \ne 0 \end{aligned}$$
(38)

for all \(n \in \mathbb {N}\). Similarly to the previous case, note that \(\lambda ^\ell \) is coprime with \((\lambda ^\ell -1)h\), so for some \(L\ge 1\), we have \( \lambda ^{L\ell }=1\) mod \((\lambda ^\ell -1)h\), and so also \(\lambda ^{nL\ell }\equiv 1\) mod \((\lambda ^{\ell }-1)h\) for each \(n\ge 1\). As a consequence,

$$\begin{aligned} \lambda ^0+ \lambda ^{\ell } + \dots + \lambda ^{nL\ell } \equiv 1 \bmod {h} \end{aligned}$$

for all integers \(n \in \mathbb {N}\). Thus,

$$\begin{aligned} \begin{aligned} m(n)&:= x \lambda ^{k + (nL+1) \ell } + y \lambda ^{k} \left( \lambda ^{0} + \lambda ^{\ell } + \ldots + \lambda ^{nL \ell } \right) + z\\&\equiv x \lambda ^{k + \ell } + y \lambda ^k + z = p^i \bmod h. \end{aligned} \end{aligned}$$
(39)

In particular, m(n) is coprime to h for all \(n \in \mathbb {N}\). Moreover,

$$\begin{aligned} m(n) \equiv z \equiv p^i \bmod \lambda , \end{aligned}$$
(40)

so m(n) is coprime to \(h\lambda /p^{\alpha (p)}\).

Since we have \(a(m(n)) = a(p^i) \ne 0\) by (38) and we are in the sparse case, all prime factors of m(n) divide \(h \lambda \). But by (39) and (40), we obtain that p is the only common prime factor of m(n) and \(h\lambda \). It follows that for each \(n \in \mathbb {N}\) there exists an integer k(n) such that \(m(n) = p^{k(n)}\). We can estimate k(n) by

$$\begin{aligned} k(n)&= \log _p( m(n) ) = \log _p \left( x \lambda ^{k + (nL+1) \ell } + y \lambda ^k \frac{\lambda ^{(nL+1)\ell } - 1}{\lambda ^\ell - 1} + z \right) \\&= (k + (nL+1) \ell )\log _p(\lambda ) + \log _p \left( x + \frac{y}{\lambda ^\ell - 1} \right) + o(1) \end{aligned}$$

as \(n \rightarrow \infty \). In particular, the sequence \((k + (nL+1) \ell )\log _p(\lambda ) \bmod 1\) converges (in \(\mathbb {R}/\mathbb {Z}\)) as \(n \rightarrow \infty \). This is only possible if \(\log _p(\lambda ) \in \mathbb {Q}\), since otherwise the above sequence would be dense. Consequently, \(\lambda \) is a power of p and a is p-automatic. \(\square \)

Proof of Theorem 1 in the sparse case

Let us consider the set

$$\begin{aligned} P := \{p \in \mathbb {P}: \alpha \mapsto a(p^{\alpha }) \text { is not finitely supported} \}. \end{aligned}$$

We distinguish the following cases:

  • \(\left| P \right| \ge 2\): Let \(p_1, p_2 \in P\) be distinct. Using Proposition 4, we find that a is \(p_1\)-automatic and \(p_2\)-automatic. By Cobham’s Theorem 4, a is eventually periodic. Moreover, by Lemma 7, 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(\nu _p(n))f_2(n/p^{\nu _p(n)})\) (cf. Proposition 1) 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 in view of Lemma 10.

  • \(P = \emptyset \): Since we are in the sparse case, all primes p such that \(a(p^\alpha ) \ne 0\) for some \(\alpha \) are divisors of \(h\lambda \). For each prime divisor p of \(h\lambda \), there are finitely many exponents \(\alpha \) such that \(a(p^\alpha ) \ne 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 (with \(f_1\) and \(f_2\) eventually zero).

  • \(P = \{p\}\): By Proposition 4, a is p-automatic. We can write a as \(a(n)=f_1(\nu _{p}(n))f_2(n/p^{\nu _{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 \(\alpha \mapsto f_2(q^\alpha )\) has finite support for all primes q. By the same argument as in the case \(P = \emptyset \), \(f_2\) is finitely supported, and hence eventually periodic.

\(\square \)

7 Remarks

7.1 Completely multiplicative case

We now derive the main result of [22] from Theorem 1:

Proposition 5

Assume that a is a completely multiplicative automatic sequence. Then there exists a prime p such that

$$\begin{aligned} a(n)=\epsilon ^{\nu _p(n)}\chi (n/p^{\nu _p(n)}),\;n\in \mathbb {N}, \end{aligned}$$

for a root of unity \(\epsilon \) and \(\chi \) a Dirichlet character or the support of a is contained in \(\{p^k:\,k\ge 0\}\).

Proof

By Theorem 1 (and Lemma 7), we can write \(a(n) = f_1(\nu _p(n)) \cdot f_2\left( {n}/{p^{\nu _p(n)}} \right) \), 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 \(\epsilon \) 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. \(\square \)

7.2 Associated dynamical systems

When \(a:\mathbb {N}\rightarrow \mathbb {C}\) is automatic and \(A=a(\mathbb {N})\) is the “alphabet” of a, then we let \(X_a\subset A^{\mathbb {Z}}\) denote the subshift generated by a.Footnote 12 We hence obtain a topological dynamical system \((X_a,S)\), where S stands for the left shift, \(S\big ( (x_n)_{n \in \mathbb {Z}} ) = (x_{n+1})_{n \in \mathbb {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 \(\mu _a\). Such subshifts originating from primitive automatic sequences have been thoroughly studied (see for example [24]).

Remark 4

In general, the dynamical system generated by an automatic sequence need not be uniquely ergodic, see again for example [24]. However, automatic multiplicative sequences generate uniquely ergodic systems. Indeed, in the sparse case we have only finitely many primes \(p_1,\ldots ,p_k\) such that the support of a is contained in the set

$$\begin{aligned} D:=\{p_1^{\alpha _1}... p_k^{\alpha _k}:\, \alpha _i\in \mathbb {N}_0,\;i=1,\ldots ,k\} \end{aligned}$$

which already follows from Corollary 1. 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 the comments after Lemma 9, a is Toeplitz. Thus, we have minimality for \((X_a, S)\), which implies unique ergodicity for automatic sequences, see for example [24].

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

$$\begin{aligned} M(a)=\lim _{N\rightarrow \infty }\frac{1}{N}\sum _{n=1}^Na(n) \end{aligned}$$

does exist. We will compute its value in the next subsection.

7.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 6

Let \((a(n))_{n \ge 0}\) be an automatic multiplicative sequence. Then M(a)

is given by

$$\begin{aligned} M(a) = M(f_2) \cdot \sum _{k\ge 0} \frac{f_1(k)}{p^{k}}, \end{aligned}$$
(41)

where \(f_1\), \(f_2\) and p are given by Theorem 1.

Proof

For \(\alpha , r \in \mathbb {N}\) such that \(0 \le r < p\), consider the infinite arithmetic progression \(P(\alpha ,r) = p^{\alpha +1} \mathbb {N}_0 + p^\alpha r\). Since \(\bigcup _{\alpha =0}^{\infty } \bigcup _{r=1}^{p-1} P(\alpha ,r) = \mathbb {N}\) and

\(\sum _{\alpha =0}^{\infty } \sum _{r=1}^{p-1} d(P(\alpha ,r)) = 1\), it is an elementary exercise in analysis that

$$\begin{aligned} M(a) = \sum _{\alpha =0}^{\infty } \sum _{r=1}^{p-1} M\left( a 1_{P(\alpha ,r)}\right) , \end{aligned}$$
(42)

where \(1_X\) denotes the indicator function of the set X and \(d(X) = M(1_X)\) denotes its density. For each \(\alpha \ge 0\) and \(r \in \{1, \ldots , p-1\}\) we can compute

$$\begin{aligned} M\left( a 1_{P(\alpha ,r)}\right)&= \lim _{N \rightarrow \infty } \frac{1}{p^{\alpha } N} \sum _{n=0}^{N-1} a\left( p^{\alpha +1} n+p^{\alpha }r\right) \\&= \frac{f_1(\alpha )}{p^\alpha } \lim _{N \rightarrow \infty } \frac{1}{N} \sum _{n=0}^{N-1} f_2\left( pn+r\right) . \end{aligned}$$

Note that the last limit exists because \(f_2\) is eventually periodic. Since \(f_2(pn) = 0\) for all \(n \ge 0\), we also have \(M\left( a 1_{P(\alpha ,0)}\right) = 0\). Combining the above formulae, for any \(\alpha \ge 0\), we conclude that

$$\begin{aligned} \sum _{r=1}^{p-1} M\left( a 1_{P(\alpha ,r)}\right) = \frac{f_1(\alpha )}{p^\alpha } M(f_2). \end{aligned}$$
(43)

Now, (41) follows by substituting (43) in (42). \(\square \)

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 7). It is also possible that \(M(a)=0\) even though \(M(f_2) \ne 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\ge 1\), and \(f_2\) is any principal character.

Finally, note that in the dense case a is never aperiodic because a is Toeplitz (see the remarks after Lemma 9).