# Generalization of automatic sequences for numeration systems on a regular language

## 1 Introduction

In , P. Lecomte and I have defined a numeration system as being a triple $`S=(L,\mathrm{\Sigma },<)`$ where $`L`$ is an infinite regular language over a totally ordered alphabet $`(\mathrm{\Sigma },<)`$. The lexicographic ordering of $`L`$ gives a one-to-one correspondence $`r_S`$ between the set of the natural numbers $`\mathrm{I}\mathrm{N}`$ and the language $`L`$.

For a given subset $`X`$ of $`\mathrm{I}\mathrm{N}`$, a question arise naturally. Is it possible to find a numeration system $`S`$ such that $`\mathrm{r}_S(X)`$ is recognizable by finite automata ? (In this case, $`X`$ is said to be $`S`$-recognizable.) For example, the set $`\{n^2:n\mathrm{I}\mathrm{N}\}`$ is $`S`$-recognizable for some $`S`$ and the arithmetic progressions $`p+q\mathrm{I}\mathrm{N}`$ are $`S`$-recognizable for any $`S`$. An interesting question is thus the following: is there a system $`S`$ such that the set of primes is $`S`$-recognizable ?

To answer this question I show that a subset of $`\mathrm{I}\mathrm{N}`$ is $`S`$-recognizable if and only if its characteristic sequence can be generated by an ‘automatic’ method. The term automatic refers, as we shall see further, to a generalization of the $`k`$-automatic sequences for numeration systems on a regular language.

The $`k`$-automatic sequences are well-known and have been extensively studied since the 70’s . The construction of this kind of sequences is based on the representation of the integers in the base $`k`$. For a given integer $`n`$, one represents this number in base $`k`$ using the greedy algorithm and obtains a word $`[n]_k`$ over the alphabet $`\{0,\mathrm{},k1\}`$. Next one gives $`[n]_k`$ to a deterministic finite automaton with output and obtains the $`n^{th}`$ term of a sequence which is said to be a $`k`$-automatic sequence.

These sequences have been already generalized in different ways . In particular, a method used by J. Shallit to generalize the $`k`$-automatic sequences is to consider some kind of linear numeration system instead of the standard numeration system with integer base $`k`$ . Two properties of the systems encountered in  are precisely that the set of all the representations is regular and that the lexicographic ordering is respected.

Here, instead of giving $`[n]_k`$ to a deterministic finite automaton with output, we feed it with $`\mathrm{r}_S(n)`$ to obtain an output which is the $`n^{th}`$ term of an $`S`$-automatic sequence for a numeration system $`S`$. Having thus introduced the concept of $`S`$-automatic sequences, we can follow two paths. Learn their intrinsic properties but also use them as a tool to check if a subset of $`\mathrm{I}\mathrm{N}`$ is $`S`$-recognizable.

Our article has the following articulation. In the first section, we recall some definitions and we introduce a teaching example which could be very instructive for the reader not familiar with automatic sequences. In the second section, we adapt the classical results concerning the fiber and the kernel of an automatic sequence.

Initially, A. Cobham showed the equivalence between the $`k`$-automatic sequences and the sequences obtained by iterating a uniform morphism (also called uniform tag system ). In the third section, we show that an $`S`$-automatic sequence is always generated by a substitution (i.e., an iterated non-uniform morphism followed by one application of another morphism). From this, we deduce that the number of distinct factors of length $`l`$ in an $`S`$-automatic sequence is in $`O(l^2)`$. We also show how to construct $`S`$-automatic sequences with at least the same complexity that infinite words obtained by iterated morphisms.

In the last section, we will be able to show that for any numeration system $`S`$, the set of primes is never $`S`$-recognizable. We use the fact that to be $`S`$-recognizable, the characteristic sequence of the set must be generated by a substitution. Hence we use some results of C. Mauduit about the density of the infinite words obtained by substitution .

## 2 Basic definitions and notations

In this paper, capital greek letters represent finite alphabet. We denote by $`\mathrm{\Sigma }^{}`$ the set of the words over $`\mathrm{\Sigma }`$ ($`\epsilon `$ is the empty word) and by $`\mathrm{\Sigma }^\omega `$ the set of the infinite words over $`\mathrm{\Sigma }`$. If $`K`$ is a set then $`\mathrm{\#}K`$ denotes the cardinality of $`K`$ and if $`w`$ is a string then $`|w|`$ denotes the length of $`w`$. For $`1i|w|`$, $`w_i`$ is the $`i^{th}`$ letter of $`w`$. The same notation holds for infinite words, in this case $`i\mathrm{I}\mathrm{N}\{0\}`$.

First, recall some definitions about the numeration systems we are dealing with. For more about these systems see .

###### Definition 1

A numeration system $`S`$ is a triple $`(L,\mathrm{\Sigma },<)`$ where $`L`$ is an infinite regular language over the totally ordered alphabet $`(\mathrm{\Sigma },<)`$.

For each $`n\mathrm{I}\mathrm{N}`$, $`\mathrm{r}_S(n)`$ denotes the $`(n+1)^{th}`$ word of $`L`$ with respect to the lexicographic ordering and is called the $`S`$-representation of $`n`$.

Remark that the map $`\mathrm{r}_S:\mathrm{I}\mathrm{N}L`$ is an increasing bijection. For $`wL`$, we set $`\mathrm{val}_S(w)=\mathrm{r}_S^1(w)`$. We call $`\mathrm{val}_S(w)`$ the numerical value of $`w`$.

Examples of such systems are the numeration systems defined by a recurrence relation whose characteristic polynomial is the minimum polynomial of a Pisot number . (Indeed, with this hypothesis, the set of representations of the integers is a regular language.) The standard numeration systems with integer base and also the Fibonacci system belong to this class.

###### Definition 2

Let $`S`$ be a numeration system. A subset $`X`$ of $`\mathrm{I}\mathrm{N}`$ is $`S`$-recognizable if $`\mathrm{r}_S(X)`$ is recognizable by finite automata.

Let us introduce the concept of $`S`$-automatic sequence which naturally generalizes the $`k`$-automatic sequences based on the representation of the integers in base $`k`$. For more about $`k`$-automatic sequences see for instance .

###### Definition 3

A deterministic finite automaton with output (DFAO) $`M`$ is a $`6`$-uple $`(K,s,\mathrm{\Sigma },\delta ,\mathrm{\Delta },\tau )`$ where $`K`$ is the finite set of the states, $`s`$ is the start state, $`\mathrm{\Sigma }`$ is the input alphabet, $`\delta :K\times \mathrm{\Sigma }K`$ is the transition function, $`\mathrm{\Delta }`$ is the output alphabet and $`\tau :K\mathrm{\Delta }`$ is the output function.

###### Definition 4

Let $`S=(L,\mathrm{\Sigma },<)`$ be a numeration system. A sequence $`u\mathrm{\Delta }^\omega `$ is $`S`$-automatic if there exists a DFAO $`M=(K,s,\mathrm{\Sigma },\delta ,\mathrm{\Delta },\tau )`$ such that for all $`n\mathrm{I}\mathrm{N}`$,

$$u_{n+1}=\tau (\delta (s,\mathrm{r}_S(n))).$$

If the context is clear, we write $`\tau (w)`$ in place of $`\tau (\delta (s,w))`$.

###### Remark 1

A subset $`X\mathrm{I}\mathrm{N}`$ is $`S`$-recognizable if and only if its characteristic sequence $`\chi _X\{0,1\}^\omega `$ is $`S`$-automatic.

In the following we will often encounter two more ‘classical’ ways of obtaining infinite sequences.

###### Definition 5

Let $`\phi :\mathrm{\Sigma }\mathrm{\Sigma }^{}`$ be a morphism of monoid such that for some $`\sigma \mathrm{\Sigma }`$, $`\phi (\sigma )\sigma \mathrm{\Sigma }^{}`$. The word $`u_\phi =\phi ^\omega (\sigma )`$ is a fixed point of $`\phi `$ and we say that $`u_\phi `$ is generated by an iterated morphism.

A morphism is uniform if $`|\phi (\sigma _1)|=\mathrm{}=|\phi (\sigma _n)|`$, $`\mathrm{\Sigma }=\{\sigma _1,\mathrm{},\sigma _n\}`$.

###### Definition 6

A substitution $`T`$ is a triple $`(\phi ,h,c)`$ such that $`\phi :\mathrm{\Sigma }\mathrm{\Sigma }^{}`$ and $`h:\mathrm{\Sigma }\mathrm{\Delta }^{}`$ are morphisms of monoids. Moreover $`c\mathrm{\Sigma }`$, $`\phi (c)c\mathrm{\Sigma }^{}`$ and for any $`\sigma \mathrm{\Sigma }`$, $`h(\sigma )=\epsilon `$ or $`h(\sigma )\mathrm{\Delta }`$ ($`h`$ is said to be a weak coding). We said that the word $`u_T=h(\phi ^\omega (c))`$ over $`\mathrm{\Delta }`$ is generated by the substitution $`T`$.

If $`h(\sigma )=\epsilon `$ for some $`\sigma `$ then $`h`$ is said to be erasing otherwise $`h`$ is said to be non-erasing.

### 2.1 A teaching example

We consider the numeration system $`S=(a^{}b^{},\{a,b\},a<b)`$, the alphabets $`\mathrm{\Sigma }=\{a,b\}`$, $`\mathrm{\Delta }=\{0,1,2,3\}`$ and the following DFAO

As usual the start state is indicated by an unlabeled arrow. The first words of $`a^{}b^{}`$ are

$$\epsilon ,a,b,aa,ab,bb,aaa,aab,abb,bbb,\mathrm{}$$

and thus feeding the automaton with these words we obtain the first terms of the sequence $`u\mathrm{\Delta }^\omega `$,

$$u=01023031200231010123023031203120231002310123010123\mathrm{}.$$

###### Remark 2

The sequence $`u`$ is not ultimately periodic. One can observe that the distance between two occurrences of the block ‘$`00`$’ is not bounded. Indeed,

$$\tau (w)=0r,s\mathrm{I}\mathrm{N}:w=a^{4r}b^s$$
(1)   
thus a block ‘$`00`$’ comes from two consecutive words $`b^{4r1}`$ and $`a^{4r}`$, $`r1`$ and the number of words of length $`n`$ in $`a^{}b^{}`$ is $`n+1`$, $`n\mathrm{I}\mathrm{N}`$.

###### Remark 3

The sequence $`u`$ is not generated by an iterated morphism $`\phi `$. First observe that

$$\tau (w)=\left\{\begin{array}{c}1\hfill \\ 2\hfill \\ 3\hfill \end{array}\right\}r,s\mathrm{I}\mathrm{N}:w=\{\begin{array}{c}a^{4r+1}b^{3s},a^{4r+2}b^{3s+1},a^{4r+3}b^{3s+2}\hfill \\ a^{4r+1}b^{3s+2},a^{4r+2}b^{3s},a^{4r+3}b^{3s+1}\hfill \\ a^{4r+1}b^{3s+1},a^{4r+2}b^{3s+2},a^{4r+3}b^{3s}.\hfill \end{array}$$

Suppose that there exists a morphism $`\phi `$ such that $`u=lim_{n+\mathrm{}}\phi ^n(0)`$.

1) If $`\phi (0)0102\mathrm{\Delta }^{}`$ then the block ‘$`0102`$’ must appear at least twice in $`u`$ since ‘$`0`$’ appears twice in $`u`$. If the first ‘$`0`$’ of the block is obtained from a word $`a^{4r}b^s`$ with $`r1`$ then the second ‘$`0`$’ is obtained from $`a^{4r2}b^{s+2}`$ which leads to a contradiction in view of (1). If the first ‘$`0`$’ is obtained from $`b^s`$ with $`s1`$ then the second ‘$`0`$’ come from $`a^sb`$ and we have $`s=4t`$. The ‘$`2`$’ is obtained from $`a^{4t1}b^2`$ which also leads to a contradiction.

2) If $`\phi (0)=01`$ then in view of the first terms of $`u`$, $`\phi (1)023031200231\mathrm{\Delta }^{}`$. We show that ‘$`023031200`$’ appears only once in $`u`$. Suppose that we can find another block of this kind. Thus the last two ‘$`0`$’ come from words $`b^{4r1}`$ and $`a^{4r}`$ with $`r2`$. Since we consider all the words of $`a^{}b^{}`$ lexicographically ordered, the first ‘$`0`$’ of the block come from $`a^7b^{4r8}`$ which is in contradiction with (1).

3) If $`\phi (0)=010`$ then $`\phi (1)23031200231\mathrm{\Delta }^{}`$ and $`\phi (010)01023031200\mathrm{\Delta }^{}`$. The block ‘$`010`$’ appears at least twice in $`u`$ but we know that ‘$`023031200`$’ appears only once.

We shall see further that $`u`$ is generated by a substitution.

## 3 First results about $`S`$-automatic sequences

Some classical results about $`k`$-automatic sequences can be easily restated .

###### Definition 7

Let $`a\mathrm{\Delta }`$ and $`S=(L,\mathrm{\Sigma },<)`$ , the $`S`$-fiber $`_S(u,a)`$ of a sequence $`u\mathrm{\Delta }^\omega `$ is defined as follows

$$_S(u,a)=\{\mathrm{r}_S(n):u_n=a\}.$$

###### Theorem 8

Let $`u`$ be an infinite sequence over $`\mathrm{\Delta }`$ and $`S=(L,\mathrm{\Sigma },<)`$. The sequence $`u`$ is $`S`$-automatic if and only if for all $`a\mathrm{\Delta }`$, $`_S(u,a)`$ is a regular subset of $`L`$.

Proof. If $`u`$ is $`S`$-automatic then we have a DFAO $`M=(K,s,\mathrm{\Sigma },\delta ,\mathrm{\Delta },\tau )`$ which is used to generate $`u`$. Let $`L(M^{})`$ be the language recognized by the DFA $`M^{}=(K,s,\mathrm{\Sigma },\delta ,F)`$ where the set of final states $`F`$ only contains the states $`k`$ such that $`\tau (k)=a`$. Therefore $`_S(u,a)`$ is regular since it is the intersection of the two regular sets $`L(M^{})`$ and $`L`$.

The condition is sufficient. Let $`\mathrm{\Delta }=\{a_1,\mathrm{},a_n\}`$. Remark that if $`ij`$, $`_S(u,a_i)_S(u,a_j)=\mathrm{}`$ and $`L=_{i=1}^n_S(u,a_i)`$. For all $`i=1,\mathrm{},n`$, $`_S(u,a_i)`$ is accepted by a DFA $`M_i=(K_i,s_i,\mathrm{\Sigma },\delta _i,F_i)`$. From these automata we construct a DFAO $`M=(K,s,\mathrm{\Sigma },\delta ,\mathrm{\Delta },\tau )`$ to generate $`u`$ using the numeration system $`S`$. The set $`K`$ is $`K_1\times \mathrm{}\times K_n`$, the initial state is $`(s_1,\mathrm{},s_n)`$. For all states $`(q_1,\mathrm{},q_n)K`$ and for all $`\sigma \mathrm{\Sigma }`$, $`\delta ((q_1,\mathrm{},q_n),\sigma )=(\delta _1(q_1,\sigma ),\mathrm{},\delta _n(q_n,\sigma ))`$. If there is a unique $`i`$ such that $`q_iF_i`$ then $`\tau ((q_1,\mathrm{},q_n))=a_i`$ otherwise the state cannot be reached by a word of $`L`$ and the output is not important. The sequence $`u`$ is obtained from $`S`$ and the DFAO $`M`$ thus $`u`$ is $`S`$-automatic. $`\mathrm{}`$

The notion of $`k`$-kernel of a $`k`$-automatic sequence can be transposed as follows.

###### Definition 9

Let $`S=(L,\mathrm{\Sigma },<)`$ and $`u`$ be an infinite sequence. For each $`w\mathrm{\Sigma }^{}`$, we set $`𝒦_w=\{vL|z\mathrm{\Sigma }^{}:v=wz\}.`$ One can enumerate $`𝒦_w`$ lexicographically with respect to $`<`$, $`𝒦_w=\{wz_0<wz_1<\mathrm{}\}`$. Thus for each $`w\mathrm{\Sigma }^{}`$, one can construct the subsequence $`nu_{\mathrm{val}_S(wz_n)}`$ (remark that the subsequence can be finite or even empty).

###### Theorem 10

Let $`S=(L,\mathrm{\Sigma },<)`$. A sequence $`u\mathrm{\Delta }^\omega `$ is $`S`$-automatic if and only if $`\{nu_{\mathrm{val}_S(wz_n)}:w\mathrm{\Sigma }^{}\}`$ is finite.

Proof. If $`u`$ is $`S`$-automatic, we have a DFAO $`M=(K,s,\mathrm{\Sigma },\delta ,\mathrm{\Delta },\tau )`$ used to generate $`u`$ and we define the equivalence relation $`_1`$ over $`\mathrm{\Sigma }^{}`$ by $`x_1y`$ if and only if $`\delta (s,x)=\delta (s,y)`$. In the same way, the minimal automaton of $`L`$ provides an equivalence relation $`_2`$. The two relations have a finite index thus the relation $`_{1,2}`$ given by $`x_{1,2}y`$ if and only if $`x_1y`$ and $`x_2y`$ has also a finite index. Remark that each class of $`_{1,2}`$ gives one of the sequences $`nu_{\mathrm{val}_S(wz_n)}`$. Indeed, $`x_2y`$ implies that $`\{z\mathrm{\Sigma }^{}:xzL\}=\{z\mathrm{\Sigma }^{}:yzL\}`$ thus $`𝒦_x=\{xz_0<xz_1<\mathrm{}\}`$ and $`𝒦_y=\{yz_0<yz_1<\mathrm{}\}`$ with the same $`z_0,z_1,\mathrm{}`$.

The condition is sufficient. We show how to construct a DFAO. The states are the subsequences $`q_w=(nu_{\mathrm{val}_S(wz_n)})`$. The initial state is $`q_\epsilon `$ (i.e., the subsequence obtained from the empty word). The transition function $`\delta `$ is given by $`\delta (q_w,\sigma )=q_{w\sigma }`$ and the output function $`\tau `$ is given by $`\tau (q_w)=u_{\mathrm{val}_S(w)}`$. $`\mathrm{}`$

## 4 Complexity of $`S`$-automatic sequences

The complexity function $`p_u`$ of an infinite sequence $`u`$ maps $`n\mathrm{I}\mathrm{N}`$ to the number $`p_u(n)`$ of distinct factors of length $`n`$ which occur at least once in $`u`$. In this section, we will show that the complexity of an $`S`$-automatic sequence is in $`O(n^2)`$ as a consequence that every $`S`$-automatic sequence is generated by a substitution.

Recall that an infinite word $`w`$ generated by iterated morphism has a complexity such that

$$c_1f(n)p_w(n)c_2f(n)$$

where $`f(n)`$ is one of the following functions $`1`$, $`n`$, $`n\mathrm{log}\mathrm{log}n`$, $`n\mathrm{log}n`$ or $`n^2`$ . For a survey on the complexity function, see for example .

The next remark shows that an $`S`$-automatic sequence can reach at least the same complexity as a word generated by morphism.

###### Remark 4

For every infinite word $`w`$ generated by an iterated morphism $`\phi `$ over an alphabet $`\mathrm{\Delta }`$ we can construct an $`S`$-automatic sequence $`u`$ such that $`n\mathrm{I}\mathrm{N},`$ $`p_w(n)p_u(n)`$.

We show how to proceed on the following example,

$$\mathrm{\Delta }=\{0,1\},\phi :\{\begin{array}{c}00101\hfill \\ 111.\hfill \end{array}$$

It is well-known that $`w=\phi ^\omega (0)`$ is such that $`p_w`$ is of complexity $`O(n\mathrm{log}\mathrm{log}n)`$ . To the morphism $`\phi `$, we associate a finite automaton $`M`$ (if the morphism is not uniform then $`M`$ is not deterministic). The set of states is $`\mathrm{\Delta }`$, all the states are final and the transition function $`\delta `$ is obtained by reading the productions of $`\phi `$ from left to right. For this purpose, we introduce a new ordered alphabet $`\mathrm{\Sigma }`$ such that $`\mathrm{\#}\mathrm{\Sigma }=sup_{x\mathrm{\Delta }}|\phi (x)|`$. Here, $`0`$ gives the initial state (for we consider the word $`\phi ^\omega (0)`$) and $`1`$ the other state. Thus with $`\mathrm{\Sigma }=\{a<b<c<d\}`$, we have $`\delta (0,a)=[\phi (0)]_1=0`$, $`\delta (0,b)=[\phi (0)]_2=1`$, $`\mathrm{}`$ and $`M`$ is then

As is customary, the final states are denoted by double circles. The language accepted by $`M`$ is $`L=\{a,c\}^{}\{b,d\}\{a,b\}^{}\{a,c\}^{}`$. The numeration system $`S`$ is thus $`(L,\mathrm{\Sigma },a<b<c<d)`$. This kind of construction can also be found in . Now from $`M`$ we simply construct a DFAO $`M^{}`$

The way we find the output can be easily understood. The third state can have any output for this state is never reached with a word belonging to $`L`$. One remarks that the $`S`$-automatic sequence obtained with $`M^{}`$ and $`S`$ is

$$u=\phi (0)\phi ^2(0)\phi ^3(0)\mathrm{}$$

and thus every factor of $`w=\phi ^\omega (0)`$ belongs to $`u`$.

We now show that every $`S`$-automatic sequence is generated by a substitution.

###### Lemma 11

Let $`\mathrm{\Sigma }=\{\sigma _1<\mathrm{}<\sigma _n\}`$, $`M=(K,s,\mathrm{\Sigma },\delta ,F)`$ be a DFA and $`\alpha K`$. The morphism $`\phi _M:K\{\alpha \}(K\{\alpha \})^{}`$ defined by

$$\{\begin{array}{c}\alpha \alpha s\hfill \\ k\delta (k,\sigma _1)\mathrm{}\delta (k,\sigma _n),kK\hfill \end{array}$$

produces the sequence $`u_\phi `$ of the states reached by the words of $`\mathrm{\Sigma }^{}`$ i.e., $`i\mathrm{I}\mathrm{N}\{0\}`$, $`u_{i+1}=\delta (s,w_i)`$ where $`w_i`$ is the $`i^{th}`$ element of $`(\mathrm{\Sigma }^{},<)`$.

Proof. One can check easily by constructing $`\phi (\alpha )`$, $`\phi ^2(\alpha )`$, $`\phi ^3(\alpha )`$ (which are prefixes of $`u_\phi `$) that $`u_\phi `$ satisfies the property. $`\mathrm{}`$

###### Proposition 12

Every $`S`$-automatic sequence is generated by a substitution.

Proof. Let $`S=(L,\mathrm{\Sigma },<)`$, $`M_L=(K,s,\mathrm{\Sigma },\delta ,F)`$ be a DFA accepting $`L`$ and $`u`$ be an $`S`$-automatic sequence obtained with the DFAO $`=(K^{},s^{},\mathrm{\Sigma },\delta ^{},\mathrm{\Delta },\tau )`$. From these two automata, we construct the product automaton $`M=(K\times K^{},(s,s^{}),\mathrm{\Sigma },\nu )`$ where $`\nu ((k,k^{}),\sigma )=(\delta (k,\sigma ),\delta ^{}(k^{},\sigma ))`$. We do not give explicitly the final states of $`M`$. By Lemma 11, we associate to this automaton a morphism $`\phi _M:(K\times K^{})\{\alpha \}((K\times K^{})\{\alpha \})^{}`$. To conclude the proof, we construct the erasing morphism $`h:(K\times K^{})\{\alpha \}\mathrm{\Delta }^{}`$ defined by

$$\{\begin{array}{ccc}\hfill h(\alpha )& =\epsilon \hfill & \\ \hfill h((k,k^{}))& =\epsilon \hfill & \mathrm{if}kF\hfill \\ & =\tau (k^{})\hfill & \mathrm{otherwise}.\hfill \end{array}$$

Indeed, $`\phi ^\omega (\alpha )`$ is the sequence of the states reached by the words of $`\mathrm{\Sigma }^{}`$ in $`M`$ but we are only interested in the words belonging to $`L`$ and in the corresponding output of $``$. Thus $`u`$ is generated by $`(\phi _M,h,\alpha )`$. $`\mathrm{}`$

Dealing with erasing morphisms whenever one wants to determine the complexity function of a sequence is painful. So the next lemma permits to get rid of erasing morphisms.

###### Lemma 13

 If $`f`$ and $`g`$ are arbitrary morphisms with $`f(g^\omega (a))`$ an infinite word, then there exists a non-erasing morphism $`k`$ and a coding $`h`$ (i.e., a letter-to-letter morphism $`h`$) such that $`f(g^\omega (a))=h(k^\omega (a))`$. $`\mathrm{}`$

###### Theorem 14

The complexity of an automatic sequence is in $`O(n^2)`$. Moreover, there exists an automatic sequence $`v`$ and a positive constant $`d^{}`$ such that $`n>0`$, $`p_v(n)d^{}n^2`$.

Proof. Let $`u`$ be an $`S`$-automatic sequence. By Proposition 12, $`u`$ is generated by a substitution $`(\phi ,h,\alpha )`$ and by Lemma 13 we can suppose that $`h`$ is non-erasing. The word $`u_\phi =\phi ^\omega (\alpha )`$ is generated by an iterated morphism and thus $`p_{u_\phi }(n)dn^2`$. To conclude, since $`u=h(u_\phi )`$, recall that if $`v`$, $`w`$ are two infinite words and if $`h`$ is a non-erasing morphism such that $`h(v)=w`$ then there exist positive constants $`a`$, $`b`$ such that $`p_w(n)ap_v(n+b)`$ .

2) We show that there exist a language $`L`$ over an ordered alphabet and a DFAO such that the corresponding automatic sequence $`v`$ has a complexity function $`p_v(n)d^{}n^2`$.

The morphism

$$\phi :\{\begin{array}{c}001\hfill \\ 112\hfill \\ 22\hfill \end{array}$$

generates the word $`w=\phi ^\omega (0)`$. Since $`2`$ is a bounded letter (i.e., $`|\phi ^n(2)|`$ is bounded) and $`2^n`$ is a factor of $`w`$ for an arbitrary $`n`$, there exists a positive constant $`d^{}`$ such that $`p_w(n)d^{}n^2`$ (see ). Using the same technique as in Remark 4, we construct an $`S`$-automatic sequence $`v`$ such that $`p_v(n)p_w(n)`$. One find easily that the regular language used in the numeration system $`S`$ is $`L=a^{}a^{}ba^{}a^{}ba^{}ba^{}`$. $`\mathrm{}`$

To conclude this section, we refine in a very simple way Proposition 12 to give a characterization of the $`S`$-automatic sequences.

Let $`T=(\phi ,h,c)`$ and $`T^{}=(\phi ^{},h^{},c^{})`$ be two substitutions such that $`\phi :\mathrm{\Sigma }\mathrm{\Sigma }^{}`$, $`h:\mathrm{\Sigma }\mathrm{\Delta }^{}`$,$`\phi ^{}:\mathrm{\Sigma }^{}\mathrm{\Sigma }^{}`$ and $`h^{}:\mathrm{\Sigma }^{}\mathrm{\Delta }^{}`$. A morphism of substitutions $`m:TT^{}`$ is a surjective morphism $`m:\mathrm{\Sigma }\mathrm{\Delta }\mathrm{\Sigma }^{}\mathrm{\Delta }^{}`$ such that

1. $`m(c)=c^{}`$, $`m(\mathrm{\Sigma })=\mathrm{\Sigma }^{}`$, $`m(\mathrm{\Delta })=\mathrm{\Delta }^{}`$
2. $`m(\phi (\sigma ))=\phi ^{}(m(\sigma ))`$, $`\sigma \mathrm{\Sigma }`$
3. $`m(h(\sigma ))=h^{}(m(\sigma ))`$, $`\sigma \mathrm{\Sigma }`$.

For a regular language $`L`$ on the totally ordered alphabet $`(\mathrm{\Sigma },<)`$ and for a DFAO $`M=(K,s,\mathrm{\Sigma },\delta ,\mathrm{\Delta },\tau )`$, one can construct the canonical substitution $`T_{(L,<,M)}`$ by proceeding in the same way as in Proposition 12 with $`M_L`$ equals to the minimal automaton of $`L`$ and the DFAO $``$ equals to a reduced and accessible copy of $`M`$.

To reduce $`M`$, one have to merge the states $`p`$, $`q`$ such that for all $`w\mathrm{\Sigma }^{}`$, $`\tau (\delta (p,w))=\tau (\delta (q,w))`$.

###### Definition 15

A substitution $`T`$ is an $`(L,<,M)`$-substitution if there exists a morphism $`m:TT_{(L,<,M)}`$. This kind of construction has already been introduced in  for linear numeration systems based on a Pisot number.

The next theorem is obvious and we state it without proof.

###### Theorem 16

Let $`S=(L,\mathrm{\Sigma },<)`$. The sequence $`u\mathrm{\Delta }^\omega `$ is $`S`$-automatic if and only if $`u`$ is generated by a $`(L,<,M)`$-substitution for some DFAO $`M`$. $`\mathrm{}`$

## 5 Application to $`S`$-recognizable sets of integers

Proposition 12 gives a necessary condition for a set $`X`$ of integers to be $`S`$-recognizable. The characteristic sequence $`\chi _X\{0,1\}^\omega `$ has to be generated by a substitution. Thus this proposition can be used as an interesting tool to show that a subset of $`\mathrm{I}\mathrm{N}`$ is not $`S`$-recognizable for any numeration system $`S`$.

In the following $`𝒫`$ is the set of primes and $`\chi _𝒫`$ is its characteristic sequence. We show that $`𝒫`$ is never $`S`$-recognizable but first we construct by hand a subset of $`\mathrm{I}\mathrm{N}`$ which cannot be $`S`$-recognizable for its characteristic sequence is too complex.

###### Example 1

For $`n3`$, consider the $`\left(\begin{array}{c}n\\ 3\end{array}\right)`$ words belonging to $`\{0,1\}^n`$ which contains exactly three ‘$`1`$’ and concatenate these words lexicographically ordered to obtain the word $`w_{n3}`$. To conclude consider the infinite word

$$w=w_0w_1w_2\mathrm{}=\underset{w_0}{\underset{}{111}}\underset{w_1}{\underset{}{\mathrm{0111\hspace{0.17em}1011\hspace{0.17em}1101\hspace{0.17em}1110}}}\underset{w_2}{\underset{}{\mathrm{00111\hspace{0.17em}01011}\mathrm{}}}\mathrm{}$$

By construction, it is obvious that for all positive constants $`C`$, there exists $`n_0`$ such that $`nn_0:p_w(n)>Cn^2`$. Thus $`w`$ cannot be generated by a substitution and the corresponding subset $`W`$ such that $`\chi _W=w`$,

$$W=\{0,1,2,4,5,6,7,9,10,11,12,14,15,16,17,21,22,23,25,27,28,\mathrm{}\},$$

is never $`S`$-recognizable.

###### Proposition 17

For any numeration system $`S`$, $`𝒫`$ is not $`S`$-recognizable.

Proof. In , C. Mauduit shows using some density arguments that $`\chi _𝒫\{0,1\}^\omega `$ is not generated by a substitution $`(\phi ,h,\alpha )`$ where $`h`$ sends all the letters on $`0`$ except one. A slight adaptation of the proof leads to the conclusion for any letter-to-letter morphism $`h`$. $`\mathrm{}`$

## 6 Acknowledgments

The author would like to warmly thank J.-P. Allouche for pointing out very useful references and for some fruitful comments and also P. Lecomte for his support and for fruitful conversations.