Pierre Guillot

CAYLEY GRAPHS AND AUTOMATIC SEQUENCES

published or not. The documents may come

1. Introduction 1.1. Basic definitions. Let p ≥ 2 be an integer, which in practice will often be a prime. A p-automaton is, first and foremost, a directed graph on a finite set Q, whose elements are called the states ; the following extra decoration is required :

• There is a distinguished state, called the initial state.

• The arrows are labeled with the integers i such that 0 ≤ i < p.

• The vertices are labeled using a map τ : Q → ∆. Here ∆ is a finite set called the alphabet. Typically τ will be surjective, but may very well fail to be injective.

Finally, the following property must be satisfied: out of each state (vertex), there is precisely one arrow labeled i, for each 0 ≤ i < p. For example, here is a 2automaton.

1 1 0 0 A B Fig. 1 In this example the alphabet is ∆ = {A, B} ; the initial state is the state bearing the label A. On our pictures we usually depict the initial state in a darker colour.

This definition is equivalent to others in the literature, and it will serve our purposes well, at the cost of (mildly) surprising some readers.

An automaton produces a sequence (a n ) n≥1 of elements of ∆ using the following recipe. Read the digits of n written in base p, from right to left, and follow the corresponding arrows in the graph, starting from the initial state ; the label of the state reached in this fashion is a n . Using the automaton from Figure 1, one obtains the celebrated Thue-Morse sequence, starting with BBABAABBAABABBABAABABBAABBABAABB . . . Many readers familiar with the Thue-Morse sequence will complain that there is an A missing at the beginning. However, we chose to define the sequence associated to an automaton for n ≥ 1 (rather than n ≥ 0), and we make no apology for this unorthodox decision: the results of the present paper will irremediably fail to hold for sequences defined from 0.

A sequence of elements of ∆ which is the output of at least one p-automaton is called p-automatic. There is a vast literature on automatic sequences (see [START_REF] Allouche | Theory, applications, generalizations[END_REF]), and most results do not depend on whether the sequences start from 0 or 1.

The automaton on Figure 2 appeared in [START_REF] Rowland | Automatic congruences for diagonals of rational functions[END_REF] and [START_REF] Rowland | What is . . . an automatic sequence?[END_REF]. On this picture we have written several labels next to a given arrow as a way of saving space. There are in fact, for example, three arrows going from d 1 to d 3 , with labels 2, 3 and 4 respectively.

The sequence produced by this automaton is (A(n) mod 7) n≥1 where A(n) is the Apéry number

A(n) = n k=0 n k 2 n + k k 2 .
(More precisely if the output for a given n is d i , then A(n) mod 7 is i. We chose the alphabet to be ∆ = {d 1 , . . . , d 6 } rather than {1, . . . , 6} to emphasize that d i is a formal symbol and that no arithmetic is performed with these outputs in the sequel.)

In [START_REF] Rowland | What is . . . an automatic sequence?[END_REF], Rowland comments that this automaton is "particularly symmetric". In this paper we investigate those sequences which are produced by automata with a lot of symmetry.

One may think of an automaton as a particular kind of computing machine, which outputs a n when fed n. If one adopts this point of view, the question of symmetry is not natural: one hardly cares for symmetric computers or computer programs. However, it turns out that the answer to this surprising question is very simple and satisfying (especially for p = 2).

First, we need to define what we mean by symmetry. Suppose G is a group with distinguished generators t 0 , t 1 , . . . , t p-1 . Its Cayley graph is built as follows: the set of vertices is G itself, and there is one arrow with the label i placed between g and gt i (for all g ∈ G and 0 ≤ i < p).

Both our examples above involve Cayley graphs. If we take the symmetric group S 2 , generated by t 0 = I (the identity permutation) and t 1 = (1, 2), we get precisely the graph underlying Figure 1. As for Figure 2, consider the permutations

t 0 = t 6 = I , t 1 = t 5 = (1, 5, 4, 6, 2, 3) , t 2 = t 3 = t 4 = (1, 3, 2, 6, 4, 5) ,
and the group G that they generate (which is cyclic of order 6); what we have on the figure is precisely the corresponding Cayley graph.

Note that a Cayley graph always has a distinguished vertex, namely the identity of G. Also, the characteristic property for automata is satisfied as well as it "dual", namely: at each vertex there is exactly one arrow with the label i going out, and also exactly one arrow with the label i coming in. However to turn a Cayley graph into an automaton, one needs to provide a map τ : G → ∆.

1.2. Two types of sequences with symmetry. We propose to give necessary and sufficient conditions for an automatic sequence to be produced by an automaton whose underlying graph is a Cayley graph. These have a vertex-transitive group of automorphisms, and are thus very symmetric objects indeed.

Here is some notation to formulate these conditions. Let the integer p be fixed throughout. For i, j ≥ 0 with j < p i , we define the subsequence a (i,j) of the sequence a by a (i,j) n = a p i n+j for n ≥ 1 (not n ≥ 0 !). We let N (a) = {a (i,j) : i, j ≥ 0, j < p i } be the set of such sequences. (As we shall recall below, it is well-known that N (a) is finite if and only if a is p-automatic.) Further, a relation for the sequence a is a pair (i, j) such that a (i,j) = a ; we exclude (i, j) = (0, 0), which we do not consider as a relation. We write rel(a) for the set of all relations of a.

We will say that a is homogeneous if ∀u ∈ N (a) , N (u) = N (a) and rel(u) = rel(a) .

Further, call two sequences a and b equivalent, and write a ∼ b, when there is a bijection ϕ : ∆ → ∆ , where ∆ resp. ∆ is the alphabet of a resp. b, such that b n = ϕ(a n ) for all n ≥ 1. We call a sequence a self-similar if a ∼ u for all u ∈ N (a). Selfsimilar sequences are homogeneous; to see this, note that when u ∈ N (a) one always has N (u) ⊂ N (a), and if a ∼ u we draw |N (u)| = |N (a)| so that N (u) = N (a), and rel(u) = rel(a) is then obvious.

For example, if a is the Thue-Morse sequence, then N (a) has just two elements, namely a 0,0 = a and a 1,1 = (a 2n+1 ) n≥1 . We have a 1,0 = (a 2n ) n≥1 = a so (1, 0) ∈ rel(a), giving an example of relation; more importantly, we have a 1,1 ∼ a since a 1,1 is simply obtained by switching A and B. So a is self-similar.

Our first result is the following (results for general p-sequences are presented below).

Theorem 1.1 -Let (a) be a 2-automatic sequence. Then (a) is homogeneous if and only if it can be produced by an automaton whose underlying graph is the Cayley graph associated to a group G, and such that the map τ : G → ∆ has the following property: the subgroup H of elements h ∈ G verifying τ (hg) = τ (g), for all g ∈ G, is normal in G.

Moreover, (a) is self-similar if and only if it can be produced by an automaton whose underlying graph is the Cayley graph associated to a group G, and such that the alphabet can be identified with G/K for some subgroup K, with τ : G → G/K the natural map. (In the text there is also an even weaker type of sequence, corresponding to a weaker type of symmetry. The automata involved are those which have been called permutation automata or reversible automata in the literature.)

The second statement is probably the most satisfying: a kind of symmetry in the graph translates precisely into another sort of symmetry within the sequence. Note also that the condition on the subgroup H, in the first statement, is satisfied if τ is conjugation-invariant in the sense that τ (y -1 xy) = τ (x). For example τ may be the character of a representation. Finally, we point out that one may replace G by G/H (since H is normal), and obtain a smaller automaton still producing a. We turn to questions of minimality.

1.3. Canonical automata. These results are entangled with another question. When a is an automatic sequence, is there a way to canonically construct an automaton which produces a? It turns out that the answer is affirmative for homogeneous 2-sequences (and so also self-similar sequences).

We shall in fact define an oriented graph Γ(a) from any p-automatic sequence a (for any p), whose set of vertices is N (a). We also define a monoid G(a) of selfmaps of N (a), having generators t 0 , . . . , t p-1 , and Γ(a) is the "Schreier graph" of this monoid (we define Schreier graphs below). There is a distinguished vertex in Γ(a), namely a itself. We shall prove that whenever G(a) is actually a group, and not just a monoid, then there is a natural map τ : N (a) → ∆ (indeed τ (u) is the first term of the sequence t -1 1 (u)). Thus Γ(a) is a full-blown automaton in this case.

We establish the following.

Theorem 1.2 -Let (a) be a 2-automatic sequence. Then (a) is homogeneous if and only if G(a) is a group and Γ(a) is its Cayley graph. In this case Γ(a) produces (a).

For a general p, the statements of the two theorems stated so far do not hold in such generality. Indeed consider the sequence a n = the leftmost digit of n when written in base p. One can show that a is p-automatic, with N (a) = {a}, so that the graph Γ(a) has only one vertex. Clearly it cannot be turned into an automaton producing a, unless p = 2.

However, a great deal remains true. Here, let us state the following.

Theorem 1.3 -Let G be a group with distinguished generators t 0 , . . . , t p-1 . Suppose the corresponding Cayley graph is turned into an automaton, with initial state 1, by means of the map τ : G → G/K for some subgroup K. Let (a) be the p-automatic sequence produced. Then (a) is self-similar, the monoid G(a) is a group and Γ(a) is its Cayley graph. If moreover the intersection of all the conjugates of K is trivial, then G can be identified with G(a), and Γ(a) can be identified with the graph underlying the automaton.

A natural choice is K = {1}, and the alphabet is then G itself. Both examples at the beginning of this introduction are of this kind: we have noticed that the graphs on Figure 1 and Figure 2 are Cayley graphs, and since the labeling map τ is injective, we may see it as simply giving names to the elements of the group (for example on Figure 2 the unit of G is called d 1 , the element t 1 = t 5 is called d 5 , the element t 2 = t 3 = t 4 is called d 3 ).

Remark 1.4. If we combine the results stated so far, for p = 2, we see that a 2automatic, self-similar sequence determines, and is entirely determined up to equivalence by, a finite group G, two generators t 0 and t 1 , and a conjugacy class of subgroups such that the intersection of all the subgroups in the class is trivial. This is tantamount to specifying a conjugacy class of subgroups of finite index in the free groups on two generators t 0 , t 1 . In turn, many interesting objects, comprising the theory of dessins d'enfants as in [START_REF] Guillot | An elementary approach to dessins d'enfants and the Grothendieck-Teichmüller group[END_REF], are in bijection with 2-automatic, self-similar sequences.

1.4. Rational fractions. We give an application to the study of certain rational fractions associated to automatic sequences.

The following holds in full generality. It may be known to the experts, but the author was not able to find a statement in the literature.

Theorem 1.5 -Let a be a p-automatic sequence, and assume that the elements of the alphabet ∆ are taken in a ring. Define

L(a, x) = n≥1 a n x (n) ,
where (n) is the length of n when written in base p. Then L(a, x) is a rational fraction.

Moreover, there is an explicit formula for computing L(a, x), involving the incidence matrix of the graph Γ(a).

The reason why this result has not received much attention is perhaps that the graph Γ(a), in general, is difficult to determine explicitly. This is where our previous considerations will be useful: we have just given a recipe for constructing an automatic sequence from a group G with distinguished generators, in such a way that Γ(a) is just the Cayley graph of G (and thus is explicitly known to us from the outset). We have also pointed out that our two running examples are of this kind.

For the Thue-Morse sequence a, seeing the alphabet {A, B} as a subset of the ring Z[A, B], we find

L(a, x) = -Ax 2 + Bx 2 -Bx 2x -1 .
For the 7-automatic sequence b produced by the automaton on Figure 2, we work with the ring Z[d 1 , d 2 , . . . , d 6 ] and find:

L(b, x) = d 1 P 1 + d 2 P 2 + d 3 P 3 + d 4 P 4 + d 5 P 5 + d 6 P 6 -441x 6 -336x 5 -300x 4 + 128x 3 + 24x 2 -12x + 1 where P 1 = 497x 6 + 380x 5 + 136x 4 -80x 3 + 2x 2 + x , P 2 = -112x 6 + 96x 5 + 70x 4 -63x 3 + 9x 2 , P 3 = 28x 6 -148x 5 + 102x 4 + 42x 3 -27x 2 + 3x , P 4 = 98x 6 -179x 5 + 105x 4 -28x 3 + 4x 2 , P 5 = -203x 6 + 123x 5 + 68x 4 + 28x 3 -18x 2 + 2x , and P 6 = 70x 6 + 70x 5 -175x 4 + 35x 3 .
These rational fractions contain information, in particular, about the frequencies of letters. Write a[n, d i ] for the number of occurences of the symbol d i among the first n terms of the sequence a. The frequency of d i is

lim n→∞ a[n, d i ] n ,
when this limit exists. We will be able to prove or disprove the existence of

lim n→∞ a[p n , d i ] p n ,
as well as evaluate its value, when a is p-automatic and we know L(a, x). Let us be content, in this introduction, with the following.

Theorem 1.6 -Suppose a is p-automatic, on the alphabet {d 1 , . . . , d k }, and let

L(a, x) = i d i P i (x) D(x)
where

P i (x), D ∈ Z[x].
Assume that the roots of D have absolute value ≥ 1 p , that the only root of D of absolute value 1 p is 1 p itself, and that this root is simple. Then

lim n→∞ a[p n , d i ] p n = P i ( 1 p ) j P j ( 1 p )
.

For our sequence b related to the Apéry numbers, the denominator is

(-1) • (3x + 1) • (7x -1) • (x 2 + x + 1) • (21x 2 -9x + 1) ,
and the theorem applies. The polynomials P i might look very different from one another, but for all i we have

P i 1 7 = 570 16807 .
Thus the "frequencies" all agree, and since they sum up to 1, they must be equal to 1 6 .

It is tempting to presume that, a self-similar sequence being so symmetric, the frequencies will always be 1 n where n is the order of the group (= the size of the alphabet, the number of vertices). However we have a counter-example, of a 2-automatic sequence, which is self-similar with G(a) of order 8, for which the denominator has both 1 2 and -1 2 as roots. Our more general statement implies that the limit (as above) does not exist, the values oscillating between 1 6 and 1 12 . Yet the average is still 1 2 ( 1 6 + 1 12 ) = 1 8 .

1.5. Organization. We complete the definitions in Section 2. The theorems stated in the introduction are proved in Section 3, albeit in a different order. Section 4 presents the rational fractions associated to automatic sequences, and their application to the computation of frequencies.

A few more preliminaries

The rather long introduction contained a number of definitions which will not be repeated. In this section we complete the set of definitions and make a few technical points.

2.1. The need for sequences starting from 1. Consider the following 2automaton:

0, 1 0, 1 0, 1 d1 d2 d3
The usual practice is to associate to this automaton a sequence (a n ) n≥0 following the recipe we gave in the introduction for n ≥ 1, and with a 0 = the initial state. We leave it as an exercise to the reader to check that a has then 9 subsequences of the form (a 2 i n+j ) n≥0 with j < 2 i ; moreover, these 9 sequences come in 3 groups, each consisting of three sequences which agree for n ≥ 1 but have different 0-th terms.

By contrast, if we consider (a n ) n≥1 and the subsequences belonging to N (a) as above, then there are just three of them. In general one has: Lemma 2.1 -Let Q be the set of states of a p-automaton producing the sequence (a n ) n≥1 . The map Q -→ N (a) , which associates to q ∈ Q the sequence obtained by taking q to be the initial state, is surjective.

Proof. Let q 0 be the original initial state (producing a). To produce the sequence (a p i n+j ) n≥1 , follow the arrows from q 0 according to the digits of j written in base p, padded with 0's on the left so that i moves are made.

The example above shows that the lemma would fail for sequences starting from 0, since Q has 3 elements and we have found 9 subsequences.

On the other hand, for sequences starting from 1, the lemma proves that N (a) is finite when a is automatic. The converse is also true: when N (a) is finite, then a is p-automatic (note that the number p is used in the definition of N (a) even if it is absent from the notation). The classical proof (see for example [START_REF] Allouche | Theory, applications, generalizations[END_REF]) is usually given for sequences starting from 0, but it is trivial to deduce the same statement for sequences starting from 1.

From now on, all sequences will start from 1. We may use the simple phrase "subsequence of a" to mean specifically a subsequence of the form (a p i n+j ) n≥1 with j < p i , when the context makes it clear. 2.2. Schreier graphs. We shall introduce sequences which are more general than homogeneous sequences (namely sequences "with global relations of all types", see below), corresponding to a class of graphs more general than Cayley graphs.

Let G be a group (typically finite) with distinguished generators t 0 , t 1 , . . . , t p-1 . If G acts on a finite set Q, then one may form the Schreier graph, whose set of vertices is Q, and which includes a directed arrow bearing the label i between each q ∈ Q and its image under the action of t i , for 0 ≤ i < p. For example, when Q = G and the action is simply multiplication (on the right), the corresponding Schreier graph is just the Cayley graph. On the other hand, if G is the dihedral group of orthogonal, planar transformations preserving a square, generated by a rotation t 0 and a symmetry t 1 , then the Schreier graph corresponding to the action on the four corners of the square is

1 1 1 1 0 0 0 0 c1 c2 c3 c4
It is easy to decide whether a given directed graph is a Schreier graph. This happens if and only if the property observed above for Cayley graph holds, namely, at each vertex there is exactly one arrow with the label i going out, and also exactly one arrow with the label i coming in. One can then construct a permutation t i of Q whose action is dictated by the arrows in the graph, and define G to be the group generated by the t i 's.

Let us say that a directed graph is connected if there is at least one vertex q 0 such that any other vertex q can be reached from q 0 by following directed arrows. The next lemma is well-known, and pretty trivial, but we include it for convenience. Lemma 2.2 -Let G be a finite group, with distinguished generators, acting on the set Q. Then the corresponding Schreier graph can be identified with the Cayley graph (non-canonically) if and only if it is connected and |Q| = |G|.

Proof. Let q 0 be as in the definition of connectedness (the arbitrary choice is why the identification will not be canonical). The map G → Q which maps g to q g 0 (the result of letting g act on q 0 ) is surjective by connectedness, and so also injective for reasons of cardinality. The desired identification follows.

The converse holds trivially. Moreover we see a posteriori that any q 0 ∈ Q could have been taken. Finally, note that the above definitions make sense if G is only a monoid rather than a group. The graph Γ(a), alluded to in the introduction, is precisely the Schreier graph of a certain monoid. We turn to this.

The graph Γ(a)

. Let a be p-automatic. We define maps

t i : N (a) -→ N (a) by t i (u) = (u pn+i ) n≥1
for 0 ≤ i < p. (The notation t i is for "times p plus i".) The monoid generated by these (a submonoid of the monoid of all self-maps of N (a)) will be written G(a).

We are particularly interested in situations when G(a) is a group, or equivalently when each t i is a bijection, hence the notation. Typical elements of G(a) will be written g or h. Many formulae will be simplified by the following convention. We define the composition of G(a) as follows: gh means first g and then h. Accordingly we will write u g rather than g(u) (for g ∈ G(a), u ∈ N (a)), and we have u gh = (u g ) h .

Place an arrow with the label i between u and u ti , for all u and all i. We now have the directed graph Γ(a), with labeled arrows, and also with the distinguished vertex a. Note that Γ(a) is the Schreier graph for the action of the monoid G(a) on the set N (a).

It is important to realize that Γ(a) is connected. More precisely, there is a sequence of directed arrows leading from a to any u ∈ N (a). This will follow from the computations which we describe now.

Basic calculations.

The following calculations will be used many times, often implicitly. Let p be fixed, as ever. We define operations t i for 0 ≤ i < p on polynomials by

f ti = f (pX + i) for f ∈ Z[X] .
When w is a word in the alphabet {t 0 , . . . , t i }, then f w has the obvious meaning.

We are solely interested in the polynomials X w , which are all of the form p i X + j with j < p i , by an immediate induction; we claim that each such polynomial is obtained for some w. This will prove that Γ(a) is connected.

In fact, we shall be more precise. To the polynomial p i X + j with j < p i we associate a word in the alphabet {0, 1, . . . , p-1}, denoted [p i X +j], by the following rule: write j in base p, and pad the results with 0's on the left so as to have i digits in total. For example with p = 2 one has [X] = the empty word,

[2X] = 0, [2X + 1] = 1, [16X + 3] = 0011.
An obvious remark is that [p i X + j] = [p k X + ] imply that i = k and j = . Besides, one has

[(p i X + j) ts ] = s[p i X + j] = the word [p i X + j] with an s on the left . As a result, if [p i X + j] = d i-1 • • • d 1 d 0 , then by putting w = t d0 t d1 • • • t di-1 , we have X w = p i X + j.
(Incidentally this show that w can be recovered from X w , and so X w = X w imply w = w . We will not have much use for this remark.)

What is important is that this establishes the claim. The relationship with the connectedness of N (a) is clear, since we have given a definition of u w for u ∈ N (a), and we have u w = u (i,j) where X w = p i X + j (the notation u (i,j) is explained in the introduction). We will sometimes go back and forth between the w-and (i, j)notation.

The operation t 1 is (slightly) more important than the others (since the theory is richer for 2-automatic sequences), so one final comment will be handy. When we put X = 1, the number p i + j is written in base p as [(p i X + 1) t1 ] = 1[p i X + j] = the word [p i X + j] with a 1 on the left.

2.5. The type of a relation; global relations. The type of a relation (i, j) ∈ rel(a) is the leftmost digit in [p i X + j], or equivalently, is 0 when j < p i-1 and is the leftmost digit of j written in base p otherwise. Let us say that (i, j) is a global relation for a if

(i, j) ∈ u∈N (a)
rel(u) ;

and let us say that a has global relations of all types if there is (at least) a global relation (i, j) of type r for each 0 ≤ r < p.

Lemma 2.3 -Let (a) be a p-automatic sequence.

(1) Let r be an interger with 0 ≤ r < p. Then there is u ∈ N (a) such that rel(u) contains a relation of type r.

(2) If (a) is homogeneous, then (a) has global relations of all types.

Property (2) of this lemma will imply that, in practice, we will almost never have to worry about the types of relations.

Proof. (1) The elements a, a tr , (a tr ) tr = a t 2 r , . . ., a t k r , . . ., defined for all k ≥ 0, cannot be all different, since they are taken from the finite set N (a). So there must exist k ≥ 0 and m > 0 such that

a t k+m r = a t k r .
In other words u t m r = u where u = a t k r . Let (i, j) be such that X t m r = p i X + j, as above ; since [p i X + j] = rrrr • • • (m times), the type of (i, j) is certainly r. Moreover u (i,j) = u t m r = u, so (i, j) ∈ rel(u).

(2) When a is homogeneous, rel(u) is the same for all u ∈ N (a). By the first point, this set contains relations of all types.

The main theorems

We now have all the tools to embark on a proof of the theorems stated in the introduction. These will be obtained in a completely different order.

3.1. Sequences with global relations of all types. These sequences seem perhaps less interesting for their own sake than homogeneous or self-similar sequences (and condition (R1) below is admittedly a bit artificial). However it is technically quite easy to start with their properties, and subsequently refine the results to deal with other types of sequences.

( †)
if τ (q hg 0 ) = τ (q g 0 ) for all g ∈ G then q h 0 = q 0 . (Here q 0 is the initial state, and q g 0 is the image of q 0 under the action of g ∈ G.) In this case G can be identified with G(a), and Q with N (a). This identification preserves the distinguished generators.

Recall that an action of G is called faithful if no element of G except for the identity acts as the identity permutation. The study of any group action reduces to the study of a faithful action.

Proof. Suppose (R1) holds. In graph-theoretic words, condition (R1) says that each vertex of N (a) is at the end of an arrow bearing the label r, for each r. Thus t r is a surjective map N (a) → N (a), and it must be a bijection since N (a) is finite, a being automatic. So G(a) is a group, which is (R2). Now assume (R2), and let us prove that (R3) holds with G = G(a) and Q = N (a). The Schreier graph Γ(a) can be turned into an automaton if we define τ : N (a) → ∆ by τ (u) = the first term of u t -1 1 . (Indeed the sequence u is of the form u n = v 2n+1 for a unique v ∈ N (a), or in other words there is an arrow with the label 1 from v to u, so surely we must define the label at u to be v 1 .) We must prove that Γ(a) then produces a.

Indeed, suppose n

= d i d i-1 • • • d 1 d 0 in base 2, let w = t d0 • • • t di .
Following the arrows accordingly in Γ(a) starting from a leads us to a w . Now we know that d i = 1, since p = 2, so let w = w t 1 and let v = a w , so that a w = v t1 . The label τ (a w ) is v 1 by definition, and we must show that it is a n . However v = a w = a (i,j) where X w = 2 i X + j, with notation as in §2.4 ; that is v n = a 2 i n+j for n ≥ 1, so in particular v 1 = a 2 i +j . Here the very last remark in §2.4 is that

2 i + j, when written in base 2, is 1[2 i X + j] = 1d i-1 d i-2 • • • d 1 d 0 ,
which is also how n is written, so 2 i + j = n. This proves (R3).

We check the minimality condition. That τ (a hg ) = τ (a g ) for all g ∈ G is equivalent to claiming that the sequence obtained from the automaton with a h as the initial state is again a. However, the map from Lemma 2.1 is now a surjective map N (a) → N (a), which must also be injective, showing that a h = a.

That (R3) implies (R1) is almost obvious. The sequence a is produced, when R3 holds, by an automaton in which each state is at the end of an arrow marked r, for all r. Using the surjective map Q → N (a) from Lemma 2.1, we deduce that any u ∈ N (a) is of the form v tr , for all r, and that is condition (R1) reworded.

Here we use the fact that the map Q → N (a) is compatible with the generators t i , in the sense that if it maps q to u, then it maps q ti to u ti ; this holds obviously, even when there is no group in sight and q ti is simply taken to mean the state at the end of the arrow with label i originating at q.

The same observation will prove the last statements. For suppose condition ( †) is satisfied. We claim that the map Q → N (a) is then injective. Since the action of G is transitive, any q ∈ Q is of the form q h 0 , where q 0 is the initial state. Suppose h, k ∈ G are such that the sequences produced by choosing q h 0 and q k 0 as initial state, respectively, coincide. Then τ (q hx 0 ) = τ (q kx 0 ) for all x ∈ G, and in particular for x = k -1 g we find τ (q hk -1 g 0 ) = τ (q g 0 ) for all g ∈ G, so q hk -1 0 = q 0 by ( †), and q h 0 = q k 0 . This proves the claim. This provides the required identification of Q with N (a), compatible with the bijections denoted by t i on each of these sets. The corresponding permutation groups can also be identified, and these are G (because the action is assumed to be faithful) and G(a) (by definition).

It remains to note that when ( †) does not hold, the map Q → N (a) is not injective (but still surjective), so Q has more elements than N (a).

Large parts of this proof work in the general case of p-automatic sequences for any p. We state this separately: Proposition 3.2 -Let G be a finite group generated by t 0 , . . . , t p-1 , and suppose that G acts faithfully and transitively on a finite set Q. Suppose that the corresponding Schreier graph is turned into an automaton by choosing an initial state q 0 ∈ Q and a labeling map τ : Q → ∆ satisfying the same minimality condition ( †) as above. Let (a) be the p-automatic sequence produced.

Then (a) has global relations of all types, the monoid G(a) is a group which can be identified with G, and Γ(a) can be identified with the graph underlying the automaton.

Example 3.3 -We prove that Proposition 3.1 does not hold for p > 2. Indeed for any p, let a n = the last digit of n written in base p. All the subsequences of the form (a p i n+j ) n≥1 coincide with the original sequence, so N (a) = {a} and a is p-automatic. However the graph Γ(a) has only one vertex, and no matter the decoration we elect to place on Γ(a), the automaton obtained can only produce the constant sequence. This will be different from a except for p = 2. So a cannot be produced by Γ(a), even though it certainly has all the relations one could ask for (so R1 holds). Proof. We start by noting that (H1) implies (R1) (Lemma 2.3), (H2) implies (R2) and (H3) implies (R3) (trivially). So by Proposition 3.1, we may conduct the proof assuming that all three properties (R1-R2-R3) hold.

Assume (H1). For u ∈ N (a), we let Stab(u) denote its stabilizer under the action of G(a) (that is, the group of g ∈ G(a) such that u g = u). The fact that Γ(a) is connected (or equivalently, that the action of G(a) is transitive) implies that the various groups Stab(u) are all conjugate as u runs through N (a). Also, the intersection of all these is the trivial subgroup {1}, since it consists of elements g fixing everything in N (a), while G(a) is a group of permutations of this set by definition.

However (H1) says that rel(u) does not depend on the choice of u, and if follows that Stab(u) is also independent of the particular subsequence u. Finally we see that the subgroups Stab(u), being all equal with trivial intersection, are all trivial. For cardinality reasons, this implies that |N (a)| = |G(a)|, and so Γ(a) can be identified with the Cayley graph of G(a) (Lemma 2.2). Thus (H2) holds.

When (H2) is assumed, Proposition 3.1 gives (H3) with G = G(a) and H = {1} (so that, in particular, H is normal in G). The "moreover" statements will also be clear, but we should finish the equivalence first.

So assume (H3). Replacing G by G/H if necessary (which makes sense since H is assumed to be normal), we are reduced to the case H = {1}. By Proposition 3.1, we can and we do identify G with G(a) and Q with N (a). Following arrows leading from any u ∈ N (a) to a (and in a Cayley graph, this is always possible), we see that a ∈ N (u), so N (a) = N (u). Further, consider the condition (i, j) ∈ rel(u). It is equivalent to the requirement that the element of G(a) obtained as the word in the generators t r corresponding to the word [2 i X +j] as in §2.4 be an element of Stab(u) (this is just a game with notation). However for all u we have Stab(u) = {1} since we are in a Cayley graph, and we see that the condition (i, j) ∈ rel(u) actually does not depend on u. So rel(u) = rel(a). We have (H1).

For general p-sequences, what remains true is: Theorem 3.5 -Let G be a group with distinguished generators t 0 , . . . , t p-1 . Suppose the corresponding Cayley graph is turned into an automaton, with initial state 1, by means of a map τ : G → ∆ such that the subgroup H of elements satisfying τ (hg) = τ (g) for all g ∈ G is normal in G. Let (a) be the p-automatic sequence produced.

Then a is homogeneous, the monoid G(a) is a group and Γ(a) is its Cayley graph. If moreover H = {1}, then G can be identified with G(a), and Γ(a) can be identified with the graph underlying the automaton.

3.3. Self-similar sequences.

Theorem 3.6 -Let a be a 2-automatic sequence, on an alphabet ∆ (we assume that all the letters of ∆ are actually used). The following statements are equivalent.

(S1) The sequence (a) is self-similar. (S2) The sequence (a) can be obtained by an automaton whose underlying graph is the Cayley graph of a group G with distinguished generators (with 1 as the initial state), and whose labeling map is the natural map τ : G → G/K ∼ = ∆ for some subgroup K.

Moreover, if the intersection of all the conjugates of K is trivial, then G can be identified with G(a).

We stress that G/K is not K\G: it is the set of classes gK for g ∈ G, and there is an action on the left on this set. Other actions so far have been on the right. This seems inevitable.

Proof. Assume (S1). The sequence (a), being self-similar, is also homogeneous. From Theorem 3.4, it can be produced by the automaton with underlying graph Γ(a), the Cayley graph of the group G = G(a), and we view τ as defined on G. Now any u ∈ N (a) is of the form a h for a unique h ∈ G. The sequence a is given by a n = τ (g n ) where g n ∈ G is written as the word in the t r 's corresponding to the digits of n is base 2 ; the sequence a h is given by a h n = τ (hg n ).

By hypothesis, to each h we can attach a bijection ϕ

h : ∆ → ∆ such that ϕ h (a n ) = a h n for all n ≥ 1, or τ (hg n ) = ϕ h (τ (g n )). Let us write h•δ instead of ϕ h (δ), for δ ∈ ∆, so that τ (hg) = h • τ (g)
for all g ∈ G. The map τ was assumed to be surjective, so this last relation ensures that h, δ → h • σ is a (left) action of G on ∆ ; moreover this action is compatible with τ and the left action of G on itself. The latter action is transitive, and thus, so must be the former. If K is the stabilizer of any point in ∆, we can then identify ∆ with G/K. We have proved (S2).

The proof that (S2) implies (S1) is trivial: we define ϕ h to be the action of h on ∆ = G/K.

The "moreover" statement follows from that of Theorem 3.4.

Theorem 3.7 -Let G be a group with distinguished generators t 0 , . . . , t p-1 . Suppose the corresponding Cayley graph is turned into an automaton, with initial state 1, by means of the map τ : G → G/K for some subgroup K. Let (a) be the p-automatic sequence produced. Then (a) is self-similar, the monoid G(a) is a group and Γ(a) is its Cayley graph. If moreover the intersection of all the conjugates of K is trivial, then G can be identified with G(a), and Γ(a) can be identified with the graph underlying the automaton.

4. Rational fractions associated to automatic sequences 4.1. Defining the rational fractions. Suppose (a n ) n≥1 is a p-automatic sequence on an alphabet which is a subset of a ring R. We define L(a, x 0 , . . . , x p-1 ) =

n≥1 a n x 0(n) 0 • • • x p-1(n) p-1 ∈ R[[x 0 , . . . , x p-1 ]]
where i (n) is the number of occurences of the digit i when writing n in base p. We also define L(a, x) = L(a, x, x, . . . , x)

= n≥1 a n x (n) ∈ R[[x]]
where (n) is the length of n when written in base p.

Theorem 4.1 -Under the assumption that a is p-automatic, the power series L(a, x 0 , . . . , x p-1 ) is a rational fraction. In fact one can write L(a, x 0 , . . . , x p-1 ) as a coefficient of the column vector

(I -M ) -1 C
where M ∈ Z[x 0 , . . . , x p-1 ] is the weighted adjacency matrix of the graph Γ(a), we write I for the identity matrix, and C is a column vector whose entries are homogeneous polynomials in R[x 1 , . . . , x p-1 ] of degree 1 (that is, linear forms).

During the course of the proof we shall make precise the term "weighted adjacency matrix", as well as give an expression for C.

Proof. Let u ∈ N (a). We write L = L(u, x 0 , . . . , x p-1 ) and L ti = L(u ti , x 0 , . . . , x p-1 ). Note that

n≥1 u pn+i x 0(pn+i) 0 • • • x p-1 (pn+i) p-1 = x i L ti .
As a result, by partitioning the integers according to their values mod p, one has

(*) L = u 1 x 1 + • • • + u p-1 x p-1 + x 1 L t1 + • • • + x p-1 L tp-1 .
Now fix an arbitrary order on N (a). We shall work with matrices and vectors which are indexed by the elements of N (a), with this order.

We start with the matrix M defined by

M u,v = u t i =v
x i , which we call "the weighted adjacency matrix of Γ(a)" (see also the definition of the matrix A below). Next, define the column vectors Λ and C by

Λ u = L(u, x 0 , . . . , x p-1 ) , C u = u 1 x 1 + • • • + u p-1 x p-1 .
Equation (*) above can now be written

(I -M )Λ = C .
It remains to prove that I -M , a matrix with entries in Z[x 0 , . . . , x p-1 ], is invertible in the field of fractions Q[x 0 , . . . , x p-1 ]. For this it suffices to check that its determinant is not the zero polynomial, and in turn, it suffices to show this after evaluating at

x 0 = x 1 = • • • = x p-1 = x.
In this situation M = xA where A u,v is the number of indices i such that u ti = v, and we call A the adjacency matrix of Γ(a). Now

det(I -xA) = x N det( 1 x I -A) = x N χ A ( 1 x
) .

Here N = |N (a)| and χ A is the characteristic polynomial of A, which has degree N . The proof is complete.

Corollary 4.2 -The power series L(a, x) is a rational fraction, given by a coefficient of the column vector

(I -xA) -1 xT ,
where A is the adjacency matrix of Γ(a) as defined above, and

T u = u 1 + • • • + u p-1 .
4.2. Examples. We shall examine our two running examples. From now on when we deal with a sequence on an alphabet {d 1 , . . . , d r }, we assume that the ring R is Z[d 1 , . . . , d r ].

Example 4.3 -The Thue-Morse sequence a is produced by the automaton on Figure 1. It is a Cayley graph, for the group of order two G = {±1} with t 0 = 1 and t 1 = -1. The labeling map τ is a bijection between the elements of G and {A, B}. Theorem 3.7 implies that a is self-similar and, most importantly here, G(a) is nothing but G itself, and Γ(a) is the directed graph underlying the automaton. There are 2 sequences in N (a), corresponding to the two possible initial states, and these are a and a t1 = a (1,1) = (a 2n+1 ) n≥1 . Say N (a) is ordered so that a is the first element. The matrix M is thus, using the letters x and y rather than x 0 and x 1 :

M = x y y x .
Writing L and L t1 for the rational fractions associated to a and a t1 respectively, we have

Λ = L L t1 , C = xa 1 xa t1 1 = xB xA .
We only need to compute

(I -M ) -1 = 1 -x 2 + y 2 + 2x -1 x -1 -y -y x -1 so that Λ = (I -M ) -1 C = 1 -x 2 + y 2 + 2x -1 -xyA + (x 2 -x)B (x 2 -x)A -xyB and in particular L(a, x, y) = -xyA + (x 2 -x)B -x 2 + y 2 + 2x -1 and L(a, x) = L(a, x, x) = -x 2 A + (x 2 -x)B 2x -1 .
Notice how L(a t1 , x) is obtained from L(a, x) by exchanging A and B, and likewise for L(a t1 , x, y) and L(a, x, y).

Example 4.4 -Let b be the 7-automatic sequence produced by the automaton on Figure 2. We compte L(b, x) (from now on we shall be interested in single-variable rational fractions, for simplicity).

We have already observed in the introduction that the underlying graph is the Cayley group for a group G, which is cyclic of order 6, and we have specified the generators t 0 , . . . , t 6 as permutations. The 6 labels are all distinct, so we have a self-similar sequence, as dealt with by Theorem 3.7. The set N (a) is in bijection with the set of states, and since these are labeled d 1 , . . ., d 6 , we have a natural order. The adjacency matrix is then

A =         2 0 3 0 2 0 0 2 2 0 0 3 2 3 2 0 0 0 0 0 0 2 3 2 3 0 0 2 2 0 0 2 0 3 0 2         .
To construct the vector T , for each integer i we compute the indices j 1 = t 1 (i), . . . , j 6 = t 6 (i), and the i-th line of T is

d j1 + • • • + d j6 . Explicitly T =         d 1 + 3d 3 + 2d 5 d 2 + 2d 3 + 3d 6 2d 1 + 3d 2 + d 3 d 4 + 3d 5 + 2d 6 3d 1 + 2d 4 + d 5 2d 2 + 3d 4 + d 6         .
The fraction L(b, x) is then the first line of (I -xA) -1 xT . This straightforward task was performed by a computer, and the result is that which we have given in the introduction. 4.3. Applications to the frequency of letters. The fraction L(a, x) is useful in providing information on the frequency of letters within a. Recall that we write a[n, d i ] for the number of occurences of d i among the first n terms of a. The next lemma provides the connection, and its proof is immediate.

Lemma 4.5 -The expansion of L(a, x) is L(a, x) = n≥1 (m 1,n d 1 + • • • + m r,n d r )x n
where m i,n is the number of integers m, having length n when written in base p, such that a m = d i . As a result, if

L(a, x) = d 1 P 1 + • • • + d r P r D with P i , D ∈ Z[x]
, and if we write

P i D = n≥1 s n x n , then n j=1 s j = a[p n , d i ] .
We now make a few technical points.

n j=1 s j p n = k N (α k ) Res( 1 D , α k ) α 2 k -α k e -niθ k + o(1) .
Proof. We examine a few particular cases for D and N . Suppose first that N = 1 and

1 D = 1 (x -α) m = c (1 -γx) m where γ = 1 α and c = 1 α m is constant.
Here we assume that |α| > 1 p so |γ| < p. In this case s n = P (n)γ n where P is a polynomial of degree < m. Choose a

constant C > 0 such that |P (n)| ≤ Cn m-1 for all n ≥ 1. Thus n j=1 s j p n ≤ Cn m |γ|(1 + |γ| + • • • |γ| n-1 ) p n = C|γ|n m |γ| -1 • |γ| n -1 p n = o(1) . Now suppose α = 1 p e iθ , that N = 1 and that 1 D = 1 X -α = - γ 1 -γx where γ = 1 α , so that s n = -γ n+1 . Now n j=1 s j p n = γ 2 γ -1 • γ n -1 p n = γ 2 1 -γ (e -niθ + o(1)) = 1 α 2 -α e -niθ + o(1) .
The general case is obtained by writing the partial fraction decomposition of N D . The Proposition and the Lemma together show: Theorem 4.7 -Suppose that a is p-automatic, on the alphabet {d 1 , . . . , d r }, and that L(a, x) = .

d 1 P 1 + • • • + d r P r D with P i , D ∈ Z[x].
Proof. The first equality follows directly from the Theorem, while the second is drawn by observing that the various limits, as i ranges from 1 to r, all exist and sum up to 1. We shall study the corresponding sequence a, and indulge in all the details. The first thing to notice is that each state has two incoming arrows with labels 0 and 1, and also two outgoing arrows with labels 0 and 1, so we are in the presence of a Schreier graph. To check that it is in fact a Cayley graph, we have no choice but consider the group G generated by the permutations t 0 = (1, 3, 4, 7)(5, 6, 8, 2) and t 1 = (1, 2, 4, 6)(5, 3, 8, 7) .

One checks that G has order 8, and indeed is isomorphic to the group of quaternions (for example by asking a computer). Lemma 2.2 guarantees that we have a Cayley graph. The labeling map τ : G → {d 1 , . . . , d 8 } is injective, so the alphabet is essentially G itself, and we have a self-similar sequence. By Theorem 3.7, the graph Γ(a) is simply that on Figure 3.

To proceed with the computations of L(a, x), we order the sequences in N (a) according to the labels on their initial states, so that the first sequence is that with initial state d 1 , the second is that with initial state d 2 , and so on. The sequence a itself, according to the picture, has initial state d 6 , so it is the sixth in this order.

The adjacency matrix is then

A =            
0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 1 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0

            ,
and the vector T is: For these indices, we conclude that when n is large and even, the ratio a[2 n , d i ]/2 n is close to 1 8 -1 24 = 1 12 , but when n is odd the ratio is close to 1 8 + 1 24 = 1 6 . For i ∈ {2, 3, 6, 7}, on the other hand, we find P i ( 1 2 ) = P i (-1 2 ) = -3 16 , and so a[2 n , d i ] 2 n = 1 8 + (-1) n 1 24 + o(1) .

T =            
The ratio in this case is close to 1 6 when n is even and large, and close to 1 12 if n is odd and large.

In particular, none of the ratios a[2 n ,di]

2 n
converges. Also note that when n is even, approximately two thirds of the first 2 n terms of the sequence a are in the set {d 2 , d 3 , d 6 , d 8 }. When n is odd, exactly the opposite is true.

  Fig.2

Proposition 3. 1 -

 1 Let (a) be a 2-automatic sequence. Then the following statements are equivalent. (R1) The sequence (a) has global relations of all types. (R2) The monoid G(a) is a group. (R3) The sequence (a) can be produced by an automaton whose underlying graph is the Schreier graph of a group G with distinguished generators, acting faithfully and transitively on a set Q. Moreover, we have the following minimality statement. Suppose that G, Q and τ (the labeling map G → ∆) are as in (R3). Then |Q| ≥ |N (a)|, with equality precisely when the condition below holds:

3. 2 .

 2 Homogeneous sequences. Theorem 3.4 -Let (a) be a 2-automatic sequence. Then the following statements are equivalent. (H1) The sequence (a) is homogeneous. (H2) The monoid G(a) is a group, and Γ(a) is its Cayley graph. (H3) The sequence (a) can be produced by an automaton whose underlying graph is the Cayley graph of a group G with distinguished generators (with 1 as the initial state), and with the property that the subgroup H of elements satisfying τ (hg) = τ (g) for all g ∈ G is normal in G. Moreover in (H3) we can arrange to have G = G(a), and H = {1}. Conversely, suppose we start with G as in (H3) and that H = {1}. Then G can be identified with G(a). This identification preserves the distinguished generators.

Proposition 4. 6 -

 6 Let D ∈ C[x]. Assume that the roots of D have absolute value ≥ 1 p , and let the roots of absolute value 1 p be written α k = 1 p e iθ k for k = 1, 2, . . . Assume further that each α k is a simple root, and that D(0) = 0. Finally, let N ∈ C[x] be any polynomial. If we write N D = n≥0 s n x n , then we have the following estimate:

Example 4. 9 -

 9 As explained in the introduction, the corollary applies to the sequence b of Apéry numbers mod 7, produced by the automaton on Figure2. The polynomials P i , different as they are, give the same value at 1 7 . It follows thatlim n→+∞ b[7 n , d i ] 7 n = 1 6 .4.4. A complete example. Consider the 2-automaton below.

Fig. 3

 3 Fig.3

  first sequence starts with d 2 , the second with d 4 , etc). The fraction L(a, x) is the 6-th line in the vector(I -xA) -1 xT ,and we findL(a, x) = d 1 P 1 + • • • + d 8 P 8 8x 4 + 2x 2 -1 with P 1 = 2x 5 + 2x 3 -x , P 2 = x 4 -x 2 , P 3 = -3x 4 , P 4 = 2x 5 -2x 3 , P 5 = -2x 5 -x 3 , P 6 = -3x 4 , P 7 = x 4 -x 2 , P 8 = -2x 5 -x 3 .So the denominator is D = (2x -1) • (2x + 1) • (2x 2 + 1) , its roots being

  Assume that the (complex) roots of D have absolute value ≥ 1 p , and let the roots of absolute value 1 p be written α k = 1 p e iθ k for k = 1, 2, . . . Assume further that each α k is a simple root. Suppose that the only root of D of absolute value 1 p is 1 p (and that this root is simple). Then

	Then one has
	a[p n , d i ] p n	=	k	P i ( 1 p ) Res( 1 D , α k ) α 2 k -α k
	Corollary 4.8 -lim n→+∞	a[p n , d i ] p n	=	p 2 1 -p	P i	1 p	Res	1 D	,	1 p
						=	P i ( 1 p )

e -niθ k + o(1) .

j P j ( 1 p )