The sum of digits functions of the Zeckendorf and the base phi expansions

We consider the sum of digits functions for both base phi, and for the Zeckendorf expansion of the natural numbers. For both sum of digits functions we present morphisms on inﬁnite alphabets such that these functions viewed as inﬁnite words are letter-to-letter projections of ﬁxed points of these morphisms. We characterize the ﬁrst differences of both functions a) with generalized Beatty sequences, or unions of generalized Beatty sequences, and b) with morphic sequences.


Introduction
Perhaps the most famous word in language theory is the Thue-Morse word s 2 := 0110100110010110 . . . , fixed point of the morphism μ : 0 → 01, 1 → 10. Here a morphism is a map from infinite words to infinite words that preserves the concatenation operation on the set of words. The remarkable property of s 2 is that it can also be obtained from binary expansions: s 2 (N) gives the parity of the sum of digits in the binary expansion of the natural number N. The sum of digits in base 2 written as an infinite word equals s TM := 0112122312232334, . . . , and s TM is fixed point of the morphism j → j, j +1 on the infinite alphabet {0, 1, 2, . . . }. The reason for this is simple: the number 2N has the same number of digits as N, and 2N + 1 has one more digit than N.
The question arises: do similar connections to language theory hold for expansions in other bases? For expansions in integer bases b, b a natural number, it is not hard to establish that the answer is positive. In this paper we consider the case where the powers of 2 are replaced by the Fibonacci numbers (the Zeckendorf expansion), respectively the powers of the golden mean ϕ = (1 + √ 5)/2 (the base phi expansion). For both expansions we give in Theorem 3, respectively Theorem 11 a morphism on an infinite alphabet, such that the sum of digits functions of these expansions considered as infinite words are letter-to-letter projections of fixed points of these morphisms. This means that the sum of digits functions are morphic words, defined in general as letter-to-letter projections of fixed points of morphisms.
We then will show how these results permit to give precise information on the first differences of the sum of digits For base two it is simple to see that the points of increase of the sum of digits function s TM are given by the even numbers, and that the points of constancy and decrease are given by the numbers 1 mod 4, respectively 3 mod 4.
We will prove (Theorem 4 and Theorem 12) for both the Zeckendorf representation and the base phi expansion that the points of increase, constancy and decrease are all given by unions of generalized Beatty sequences, as studied in [1]. These are sequences V of the type V (n) = p nα + q n + r, n ≥ 1, where α is a real number, and p, q, and r are integers. Here we denoted the floor function by · .
We will also prove that the first differences of the sequences of points of increase, constancy and decrease are all morphic sequences. See Theorem 5 for the Zeckendorf representation, and Theorem 13 for the base phi expansion.
A prominent role in this paper, both for base phi and the Zeckendorf expansion, is played by ( nϕ ), the well known lower Wythoff sequence.

Lemma 1. ([1])
Let V = (V (n)) n≥1 be the generalized Beatty sequence defined by V (n) = p nϕ + qn + r, and let V be the sequence of its first differences. Then V is the Fibonacci word on the alphabet {2p + q, p + q}. Conversely, if x a,b is the Fibonacci word on the alphabet {a, b}, then any V with V = x a,b is a generalized Beatty sequence V = ((a − b) nϕ ) + (2b − a)n + r) for some integer r.
Let A(n) = nϕ , and B(n) = nϕ 2 . It is well known that A and B form a pair of Beatty sequences, i.e., they are disjoint with union N. In the next lemma, V A is the composition given by V A(n) = V (A(n)).

Lemma 2. ([1])
Let V be a generalized Beatty sequence given by V (n) = p nϕ + qn + r, n ≥ 1. Then V A and V B are generalized Beatty sequences with parameters (p V A , q V A , r V A ) = (p + q, p, r − p) and (p VB , q VB , r VB ) = (2p + q, p + q, r).
Proof. See the Comments of sequence A007895 in [15] for a proof of this.
Let I Z , C Z and D Z be the functions listing the points of increase, constancy, and decrease of the function s Z . We have 1 3, 5, 8, 11, 13, 16,  When (a n ) and (b n ) are two increasing sequences, indexed by N, then we mean by the union of (a n ) and (b n ) the increasing sequence whose terms go through the set {a n , b n : n ∈ N}. The points of constancy are more difficult to characterize with the fixed point x τ than the points of increase. We therefore take another approach. Write Z (N) = . . . w, where w is a word of length 4. Then w can be any word of the 0-1-words of length 4 containing no 11. Obviously, the three words w = 0000, w = 0100 and w = 1000 give points of increase.
Furthermore the numbers N with Z (N) ending in w = 0001, 1001 and w = 0010 give We see that these give points of constancy.
Finally, we show that the N with Z (N) having suffix w = 0101 or w = 1010 give points of decrease. In the following two computations the . =-sign indicates that we use also non-admissible Zeckendorf representations.
In both cases at least one digit 1 is lost, so these N are the points of decrease. With this knowledge we can apply Theorem 2.3 and Proposition 2.8 in the paper [9], obtaining that one part of I Z is given by the generalized Beatty sequence (2 nϕ + n − 2) and the other part is given by (3 nϕ + 2n − 3).
It is not a simple matter to see that this union is given by the single generalized Beatty sequence (2 nϕ + n − 4), where the index starts at n = 2.

The triple of sequences
is known as the 'first classical complementary triple', i.e., these are three disjoint sequences with union N. See page 334 in [1]. The third sequence of this triple, V (1, 1, −1), can be written as a disjoint union of the two sequences V (3, 2, −1) and V (2, 1, −2), by Lemma 2. Thus forms a complementary quadruple. If we subtract 2 from all terms of these four sequences, the first gives I Z , the second and the third together, Next, we give a characterization of I Z , C Z and D Z in terms of morphisms.

Theorem 5.
The points of increase of the function s Z are given by the sequence I Z , which has I Z (1) = 0, and I Z is the fixed point of the Fibonacci morphism 3 → 32, 2 → 3.
The points of constancy of the function s Z are given by the sequence C Z , which has C Z (1) = 1, and C Z is the fixed point of the 2-block Fibonacci morphism on the alphabet {1, 4, 3} given by The points of decrease of the function s Z are given by the sequence D Z , which has D Z (1) = −1, and D Z is the fixed point of the Fibonacci morphism 5 → 53, 3 → 5.
For an interval I , let C Z (I) denote the points of increase lying in the interval I . Also, let C Z (I) denote the first differences of the points of increase lying in the interval I , considered as a word on the alphabet {1, 2, 3, 4}. At first sight, the latter definition is problematic, as one has to know the first point of increase after the last element of C Z (I). However, we shall only consider intervals I = n and I = n+1 , which both are followed by n+1 , and one verifies easily that the first point of increase in n+1 is always the second point. Actually, this follows directly from the following lemma.
Proof. We used the notation A + y = {x + y : x ∈ A} for a set A, and a number y. The lemma follows from the basic Zeckendorf recursion: the numbers N in n+1 all have a digit 1 added to the expansion of the number N − F n+1 .
Suppose the result has been proved till n.
(i) By equation (1), Proof of Theorem 5. The statements on I Z and D Z follow immediately from Lemma 1.
The statement on C Z follows from Proposition 7, part (i), since h n (3) = h n (1) for all n > 0.

The base phi expansion
A natural number N is written in base phi ( [2]) if N has the form with digits d i = 0 or 1, and where d i d i+1 = 11 is not allowed. Ignoring leading and trailing 0's, the sum is actually finite, and the base phi representation of a number N is unique ( [2]).
We write these expansions as The case of base phi is considerably more complicated than the Zeckendorf case. We need several preparations, before we can prove Theorem 11 in Section 3.2, Theorem 12 in Section 3.3 and Theorem 13 in Section 3.4.

The recursive structure theorem
The result of this section was anticipated in [10], [11], and [16], and proved in [8].
For n ≥ 2 we are interested in three consecutive intervals given by To formulate the next theorem, it is notationally convenient to extend the semigroup of words to the free group of words. For example, one has 110 −1 01 −1 00 = 100. We code the Lucas intervals with four symbols 0 , 1 , 2 and 3 (for extra readability these symbols are in color in the web version of this article), by a code in the following way: We then code 2 3 , and in general by induction, suggested by Theorem 8: Let σ be the morphism on the alphabet { 0 , 1 , 2 , 3 } defined by Proof. By induction. For n = 0: ( 2 ) = 2 , ( 3 ) = 3 . The induction step: Also, using the simple identity σ ( 2 ) 3 σ ( 2 ) = σ 2 ( 2 ) in the last step: We will now show that the fixed point x σ of the morphism σ is quasi-Sturmian, and determine its complexity function p σ , i.e., p σ (n) is the number of words of length n that occurs in x σ . Let g a,b the morphism on the alphabet {a, b} given by The morphism g a,b is well-known, and closely related to the Fibonacci morphism. In fact, x g = bx a,b , if x g is the fixed point of g a,b , and x a,b is the fixed point of the Fibonacci morphism a → ab, b → a (see [3]).

Proposition 10.
The fixed point x σ of σ is equal to the decoration δ(x g ) of the fixed point x g of g = g a,b . The decoration morphism δ is given by δ(a) = 2 3 , δ(b) = 0 1 . For all n ≥ 1 one has p σ (n) = n + 3.
Thus σ δ = δ g, which implies σ n δ = δ g n for all n. Since x σ has prefix 0 1 = δ(b), with b the prefix of x g , this implies the first part of the proposition. For the second part, Proposition 8 in [4] is not conclusive, as we do not know a priori the constant n 0 . But there is a direct computation possible. The complexity function of the Sturmian word x g is given by p(n) = n + 1. We have, distinguishing between words of even and odd length, and then splitting according to words occurring at even or odd positions in x σ , p σ (2n) = p(n) + p(n + 1) = n + 1 + n + 2 = 2n + 3, p σ (2n + 1) = p(n + 1) + p(n + 1) = 2n + 4.
Proposition 10 in combination with the main result of the paper [13], explains why the factors of x σ have a simple return word structure. This lies at the basis of Theorem 12 in Section 3.3.

A morphic sequence representation of s β
The image under a morphism δ of the fixed point x of a morphism, will be called a decoration of x. It is well known that such a δ(x) is a morphic sequence, i.e., the letter to letter projection of the fixed point of a morphism. This is the way we formulate the morphic sequence result in the next theorem. under a morphism δ of a fixed point of a morphism γ . The alphabet is {0, 1, ..., j, ...} × { 0 , 1 , 2 , 3 }, and γ is the morphism given

Theorem 11. The function s β , as a sequence, is a decoration of a morphic sequence on an infinite alphabet, i.e., (s β (N)) is an image
The decoration map is given by the morphism δ: We illustrate Theorem 11 with the following table. Remark. In the paper [7] the base phi analogue of the Thue-Morse sequence, i.e., the sequence (s β (N) mod 2), is shown to be a morphic sequence. This result follows also from Theorem 11, by mapping 2 j to 0, and 2 j + 1 to 1. The morphisms found in this way are on a larger alphabet than the morphism in [7].

Theorem 12. The sequence I β , the points of increase of the function s β , is given by the union of the two generalized Beatty sequences
( nϕ + 2n) n≥0 , and (4 nϕ + 3n + 1) n≥0 .

Proof. I: Points of increase
Any occurrence of a 0 gives two points of increase, namely the pair 0 + j, 1 + j, and the pair 1 + j, 2 + j. Here we use that 0 is always followed by 1 . Similarly, any occurrence of a 2 gives a point of increase 2 + j, 3 + j.
As a consequence we obtain the numbers N which are point of increase by the sequences of occurrences of 0 , and those of 2 . How do we obtain these sequences? We have to study the return words to 0 , and 2 . The sets of these return words are respectively { 0 1 2 3 , 0 1 2 3 2 3 }, and { 2 3 , 2 3 0 1 }.

II: Points of constancy
Any occurrence of a 1 gives a point of constancy, namely the pair 2 + j, 2 + j. Here we use that 1 is always followed by 2. Similarly, any occurrence of a 3 gives a point of constancy 3 + j, 3 + j.
But there are more points of constancy. At the inner boundary of 2 3 in the quadruple 0 1 2 3 occurs 3, 3.
However, this is not the case at the inner boundary of the interval 2 3 in the triple 3  As a consequence we obtain the numbers N which are point of increase by the sequences of occurrences of 1 , 3 , σ ( 1 ), and σ ( 3 ). As before, all four have a set of two return words, and a descendant morphism that is equal to g. For 1 the δ-images have lengths 11 and 7, for 3 the δ-images have lengths 7 and 4, for σ ( 1 ), the δ-images have lengths 29 and 18, and for σ ( 3 ) the δ-images have lengths 18 and 11. Application of Lemma 1 then gives the four generalized Beatty sequences of C β in Theorem 12.
The next point of decrease is at N = 11, occurring at the inner boundary of the adjacent 4 5 . The third point of decrease is at N = 15, which lies inside 5 . The coding of 5 is ( 5 ) = 3 2 3 = σ ( 3 ). As in the previous section, this gives the sequence V (7,4,0) for the occurrences of the decrease points N = 11, and later shifts. Then V (7,4,4) gives the occurrences of the decrease points N = 15 = 11 + 4, and later shifts. Again, since any k for k > 5 can be written as a union of intervals 0 1 2 3 , 4 , and 5 , we have covered all possibilities. This finishes the D β part of Theorem 12.

Morphisms for the first differences
As for the Zeckendorf expansion, we have seen in the previous section that the points of constancy have a more complicated structure than the points of increase or the points of decrease. This phenomenon expresses itself also in the 'morphic versions' of the characterization. The points of constancy of the function s β are given by the sequence C β , which has C β (1) = 2, and C β is a morphic sequence, given by the letter-to-letter projection 1 → 1, 2 → 2, 3 → 3, 3 → 3, 4 → 4 of the fixed point of the morphism on the alphabet {1, 2, 3, 3 , 4} given by The points of decrease of the function s β are given by the sequence D β , which has D β (1) = 6, and D β is the shift by one of the fixed points of the morphism on the alphabet {2, 4, 5, 7} given by 2 → 542, 4 → 542, 5 → 7, 7 → 7542.
Proof. We use in all three cases the return words to 0 which are b := 0 1 2 3 and a := 0 1 2 3 2 3 to follow the occurrences of the points of increase, constancy and decrease. The important property of these return words is that the first occurrence of the points of increase is at the same position in the decorated a and b, and the same holds for the points of constancy and decrease.

Proof. I: Points of increase
We take in to account the increase in the differences of the occurrences of the increase points in the decorations δ( of the extended return words a and b. For a these differences are 1, 2, 4 and 4. For b the differences between the occurrences of the increase points are 1, 2, and 4. Recall here, that the last 4 comes from the first increase point of the next word. It follows that we can obtain I β by decorating the fixed point of the morphism g given by a → baa, b → ba with the two words 124 and 1244. To turn this decorated fixed point in to a fixed point, we apply the natural algorithm (cf. the proof of Corollary 9 in [5]). In this case this gives the following block map on the alphabet {a 1 , a 2 , a 3 , The most efficient way to turn this in to a morphism: The associated letter-to-letter map λ is given by λ(a 1 a 2 a 3 a 4 ) = 1244, λ(b 1 b 2 b 3 ) = 124. We see that we can consistently merge a 1 and b 1 to the letter 1, a 2 and b 2 to the letter 2, and a 3 and b 3 to the letter 4. Renaming a 4 by 4, this then yields the morphism 1 → 12, 2 → 4, 4 → 1244 as generating morphism for I β .

II: Points of constancy
We follow the same strategy as in part I. The differences of the occurrences of points of constancy in the decorated versions of a and b are now 2, 1, 4 and 3, 1, 3, 4. Decorating the fixed point of the morphism g on {a, b} by a → 214, and b → 3134 this time leads to a morphism on the alphabet {1, 2, 3, 3 , 4} given by 1 → 43, 2 → 21, 3 → 21, 3 → 13 43, 4 → 13 4.

III: Points of decrease
The differences of the occurrences of points of decrease in the decorated versions of a and b are 7 and 5, 4, 2. Decorating the fixed point of the morphism g a,b by a → 7, and b → 542 this time leads to a morphism on the alphabet {2, 4, 5, 7} given by 2 → 542, 4 → 542, 5 → 7, 7 → 7542.

Alternative proofs of Theorem 12 and 13
The proofs of Theorem 12 and 13 have been based entirely on the properties of the infinite morphism γ of Theorem 11.
The question rises whether there is also a more local approach based on the digit blocks of the expansion as was used for the points of constancy, and the points of decrease of the Zeckendorf sum of digits function. Here we give a sketch of how this might be achieved for the points of increase of the base phi expansion. We say a number N is of type B if d 1 d 0 d −1 (N) = 000, and of type E if d 2 d 1 d 0 (N) = 001. One can then prove the following.

Proposition 14.
A number N is a point of increase of (s β (N)) if and only if N is of type B or of type E.
Next, Theorem 5.1 from the paper [6] gives that type B occurs along the generalized Beatty sequence ( nϕ + 2n) n≥0 , and one can deduce from Remark 6.3 in the same paper that type E occurs along the generalized Beatty sequence (4 nϕ + 3n + 1) n≥0 . This gives the alternative proof of the I B -part of Theorem 12, based on Proposition 14.
We next give a proof of the I B part of Theorem 13, directly from Theorem 12 by a purely combinatorial argument.
Recall that the sequences bx a,b are fixed points of the morphisms g a,b from Equation (2) given by g a,b (a) = baa, g a,b (b) = ba.
The return words of 3 in I B are 34 and 344. We code these words by the differences that they yield between successive occurrences of 3's, i.e., by the letters 7 and 11. Then, since This derived morphism happens to be equal to g 11,7 , the morphism giving the sequence I E . This implies that to merge the two sequences I B and I E to obtain I , one has to replace the 3's in I B by 1, 2. This decoration of I B , induces a morphism μ on the alphabet {1, 2, 4} in the usual way, given by μ(1) = 12, μ(2) = 4, μ(4) = 1244.
This proves the theorem.