Regular maps in generalized number systems J.-P. Allouche, K. Scheicher and R. F. Tichy
Abstract
This paper extends some results of Allouche and Shallit for q-regular sequences to numeration systems in algebraic number elds and to linear numeration systems. We also construct automata that perform addition and multiplication by a xed number.
1 Introduction A sequence is called q-automatic if its n-th term can be generated by a nite state machine from the q-ary digits of n. The concept of automatic sequences was introduced in 1969 and 1972 by Cobham [8, 9]. In 1979 Christol [6] (see also Christol, Kamae, Mendes France and Rauzy [7]) discovered a nice arithmetic property of automatic sequences: a sequence with values in a nite eld of characteristic p is p-automatic if and only if the corresponding power series is algebraic over the eld of rational functions over this nite eld. A brief survey on this subject is given in [2], see also [10]. Some generalizations of this concept were studied in [27, 23, 24, 3], see also the survey [1]. An automatic sequence has to take its values in a nite set. To relax this condition, Allouche and Shallit [5] introduced the notion of q-regular sequences. To give a hint of what q-regularity is, let us consider the following example. If S(n) is the sum of the binary digits of n, then the sequence n ?! S(n) mod 2 is 2-automatic, (this is the well known Prouhet-Thue-Morse sequence), whereas the sequence n ?! S(n) is 2-regular. Shallit [27] generalized the concept of q-automaticity to number systems with respect to linear recurring base sequences. The purpose of this paper is to generalize q-regularity to number systems in algebraic number elds as well as to number systems with respect to linear recurring bases.
2 Canonical number systems in algebraic elds Let Q be the eld of rational numbers. Let IK = Q() be the simple extension eld generated by the algebraic number , and let ZZIK be the ring of algebraic
Regular maps in generalized number systems
2
integers in IK. For 2 IK the symbol N( ) denotes the norm of and N = f0; 1; : : :; jN( )j? 1g. We say that f ; Ng is a canonical number system (CNS) in ZZIK for some 2 ZZIK , if every 2 ZZIK n f0g can be uniquely represented as
= a0 + a1 + : : : + ah h ; ai 2 N ; ah 6= 0; i = 0; 1; : : :; h: This concept is a natural generalization of the base number systems in ZZ. For an extensive literature we refer to Knuth [19]. The canonical number systems in the ring of integers of quadratic number elds were characterized by Katai, Szabo [17] and Katai, Kovacs [15, 16]. Kovacs [20] gave a necessary and sucient condition for the existence of CNS in ZZIK . Theorem 2.1 (Kovacs) Let IK = Q() be an extension of degree n, n 3. There is a CNS in ZZIK if and only if there exists 2 ZZIK such that f1; ; : : :; n?1g is an integral base of ZZIK . Kovacs and Peth}o [21] characterized all those integral domains that have number systems. Scheicher [25, 26] recently gave a new proof of the above theorem generalizing a result of Thuswaldner [28]. The main tool of his proof is the following Lemma 2.1 Let 2 ZZIK , and let f1; : : :; n?1g be an integral base of ZZIK . Let be a zero of the polynomial xn + bn?1xn?1 + : : : + b0 with bi 2 ZZ; b0 2; and b0 b1 : : : bn?1 1; and let D = f0; 1; : : :; b0 ? 1g. Then f ; Dg is a CNS in ZZIK . Furthermore there exists a nite automaton with at most 2n+1 ? 1 states that is able to add 1 to every 2 ZZIK . Each state qj can be interpreted as an additional carry. Such a carry qj has the form qj = ( bi1 ? bi2 + bi3 ? : : :) + ( bi1 +1 ? bi2 +1 + bi3 +1 ? : : :) (1) + ( bi1 +2 ? bi2 +2 + bi3 +2 ? : : :) 2 + : : :: where fi1; i2 ; ; ik g is a nonempty subset of f0; : : :; ng.
3 The set of -regular functions
Let IK = Q() be an extension of degree n, and let f ; Ng be a CNS in ZZIK . Let E be a commutative Noetherian ring, and let R be a subring of E. De nition 3.1 Let s : ZZIK ! E. The function s is called -automatic, if s(x) is a nite state function of the base{ expansion of x, (see also [3]).
Regular maps in generalized number systems
3
The -kernel of s is the set of functions K (s) = fs( k x + l); k 0; l 2 ZZIK;k g where
9 8k?1 = B and c 2 ZZIK;b each function s( b x + c) can be expressed as a linear combination X s( b x + c) = di s( bi x + ci ) i
with bi < B and ci 2 ZZIK;bi . The result will then follow from Theorem 3.1 (e). Let us write b = fr + u, with 0 u < f, and c = q fr + t, with t 2 ZZIK;fr . From 3.1 (e), there exists an E such that for all r > E we can write s(( f )r y + t) =
X i
di s(( f )ri y + ti );
where ri < E and ti 2 ZZIK;fri . Now put y = u x + q. We nd X s(( f )r y + t) = s( b x + c) = di s( fri +u x + q fri + ti ) =
X
i fr ci = q i
i dis( bi x + ci);
+ ti . Note that bi < fE + f and q 2 ZZIK;u . where bi = fri + u and So ci = q fri + ti 2 ZZIK;u+fri = ZZIK;bi : Thus we may take B = f(E + 1). Hence s(x) is -regular. 2
Regular maps in generalized number systems
7
Theorem 3.6 Consider the ring of Gaussian integers ZZIK = fx + y I : x; y 2 ZZg, where I 2 = ?1. Let = ?a + I , with a 2 IN n f0g. If s(x) is a -regular function, then there exists a constant c such that js(x)j = O(jxjc). Proof.
Let x=
kX ?1 j =0
Then, by [14] Proposition 2.6, we have
dj j :
p
2 2 loga2 +1 jxj ? 2 loga2 +1 a a2a++2 4 ? 4 k ? 1
2 loga2 +1 jxj ? loga2 +1 Thus Theorem 3.1 (g) gives
p
!
2 1 ? a a2a++2 4 + 4:
k b + 2 loga2 +1 jxj:
V (x) = Bd0 Bd1 Bdk?1 V (0): Let j j be a vector-norm, let k k be a matrix-norm, compatible with j j (hence jMvj kM kjvj). Thus we see js(x)j jV (x)j kBd0 kkBd1 k kBdk?1 kjV (0)j: Now let c = max0ik?1 kBi k, and d = kV (0)k. Then
js(x)j cb+2 loga2 +1 jxj d d0jxjc0 :
2
Example 3.1 We give here some examples of -regular functions. (a) Polynomials in x are -regular functions since 1 and x are -regular functions. (b) The index-function (x) is -regular since, for j 2 ZZIK;k , we have ( k x+ j) = jN( )jk (x) + (j)1. (c) Suppose X x = dj j for dj 2 f0; : : :; jN( )j ? 1g:
j 0
Regular maps in generalized number systems
8
In this expansion let h be the least index j such that dj 6= 0. Then h is called the -residue of x. We will construct an array A( ) = (a(i; j))i;j 0 in the following way. The rst row of A( ) contains the elements j , j 0, i.e., a(1; j) = j ?1 . Column 1 contains the elements of ZZIK with -residue 1. Generally column j contains the elements with -residue j ?1 . If, for example N( ) = 2, then the lexicographic ordering of the elements of ZZIK is (1); (01); (11); (001); (101); : : :: Then we have 2 (1) (01) (001) 3 6 (011) (0011) 77 : A( ) = 64 (11) (101) (0101) (00101) 5
Thus every element of ZZIK occurs exactly once in A( ).
De nition 3.2 (see [18]) The paraphrase{function p : ZZIK ! IN is de-
ned as follows
p (x) = the index of the row of A( ) in which x occurs: Thus, if x = a(i; j) then p (x) = i.
Remark 3.2 We get the paraphrase by ordering the elements of ZZIK lexicographically, beginning with the least signi cant digit. Theorem 3.7 The paraphrase p (x) is -regular. Proof.
If e x+f = a(m; n) then p ( e x+f) = m. Now f can be written as f = n?1 z for 0 n?1 < e. Thus e x+f = e x+ n?1 z = n?1 ( e?n+1 x+z) and p ( e x + f) = p ( e?n+1 x + z): (If e x+f = a(m; n), then e?n+1 x+z = a(m; 1).) A simple consideration gives that (x) (2) p (x) = (x) ? jN( )j
Regular maps in generalized number systems
9
for all x that occur in the rst column of A( ). Hence p ( e?n+1 x + z)
( e?n+1x + z)
=
( e?n+1 x + z) ?
=
jN( )je?n (jN( )j ? 1) (x) +
jN( ) j jN( ) e?n+1(x) + (z) j e ? n +1 = jN( )j (x) + (z) ? jN( )j
(z) (z) ? jN( )j 1:
Since (x) and 1 are -regular p (x) is -regular. 2 (d) The trace Tr(x) is {regular. Since n + bn?1 n?1 + : : : + b0 = 0, there exist aki 2 ZZ such that nX ?1 k = aki i : Thus
i=0
Tr( k x + l) =
nX ?1 i=0
akiTr( i x) + Tr(l):
Theorem 3.8 Let R be a Noetherian ring without zero divisors, and let a 2 R. Then, the function s(x) = a(x) is -regular if and only if a = 0 or a is a root of unity. Proof.
One direction is trivial: Let ak = 1, k 2 IN. Since (x) is regular, (x) mod k is automatic. Thus a(x) = a(x) mod k is automatic. Thus a(x) is regular. Assume now that a (x) is -regular. Then, there exist r < 1 and j , with 0 j < r, such that
X
0jj i j 1 m m2 : : : mm From this, we can see that the functions j(x) are linearly independent if and only if the numbers 1; 2 ; : : :; m are distinct.
Regular maps in generalized number systems
10
Hence the numbers ajN ( )jfi are not all distinct and we must have f f ajN ( )j i = ajN ( )j j for some i; j with i 6= j. Since ZZIK does not have any zero-divisor, then, either a = 0 or a is a root of unity. 2
4 The Pattern Transformation The following construction of a kind of Fourier{transformation of a function A : ZZIK ! ZZ is analogous to the pattern transformation of [22] (see also [4]). Let f ; Ng be a CNS on ZZIK . If (x) is the index{function with respect to f ; Ng, then is a bijection from ZZIK to IN. Thus, there exists an isomorphism between the group M = (fA : ZZIK ! ZZg; +) and the group (ZZIN ; +) of all integer sequences under termwise addition. Let A 2 M and let (A) = minfn 0 : A(? 1 (n)) 6= 0g: Then M becomes a metric group with distance function (A; B) = 2? (A?B) : Let P be a pattern, i.e., a nite sequence of digits from D. We will denote the set of all patterns by P . Thus P = D . Let eP (Q) be the pattern{function which counts the number of occurrences of the pattern P in the word Q. We assume that the pattern Q has as many leading zeros at the left hand side as the pattern P has. Furthermore let aP (Q) = (?1)eP (Q) . Let : ZIK ! P , (x) = (dL?1dL?2 : : :d0), be the {expansion of x. Then we can prove the following. Theorem 4.1 Let f ; Ng be a CNS in ZIK . Let A : ZIK ! ZZ. Then there exists a function A^ : ZIK ! ZZ, such that X ^ ?1 A(x) = A(0) + A( (P))eP ((x)): P2 P
The set feP ((x))g is dense in M . Proof.
By subtracting A(0) from A(x), we can assume that A(0) = 0. Find minfn : A(? 1 (n)) 6= 0g =: n1 and let y1 = ? 1(n1 ). Then A(x) = A(y1 )e(y1 ) ((x)) for all x with (x) n1 : Thus ? A(x); A(y1 )e(y1 ) ((x)) 2? (n1 +1) :
Regular maps in generalized number systems
11
^ ?1 (y1 )) = A(y1 ) and A( ^ ?1 (y)) = 0 for (y) < n1. De ne A( We can repeat this procedure with A(x) ? A(y1 )e(y1 ) ((x)) instead of A(x) to nd an y2 , such that A(x) ? A(y1 )e(y1 ) ((x)) ? [A(y2 ) ? A(y1 )e(y1 ) ((y2 ))]e(y2 ) ((x)) = A(x) for all x with (x) (y2 ) = n2 . By induction, we can nd a sequence n1 < n2 < : : : such that X ^ ?1 A( (y))e(y) ((x)) = 0 A(x) ? y:(y)nj
for all x with (x) nj . In other words
0 1 X ? 1 ^ (y))e(y) ((x)))A 2?(nj +1) : @A(x); A( y:(y)nj
Since nj ! 1 as j ! 1 we obtain the claimed formula. ^ ?1 (y)) easily follows from The uniqueness of the pattern{transform A( e(x) ((x)) = 1 and e(x) ((y)) = 0 for (y) < (x): 2 Theorem 4.2 The function eP ((x)) is {regular for any pattern P . Proof.
Let us introduce the following notation: if w = w1w2 : : :wk is any string and j k, then take(j; w) = w1 : : :wj : We claim that each element of the {kernel can be written as a linear combination of the functions eP (( f x + a)), with 0 f < jP j, and a 2 ZIK;f , and the constant function 1. Proof. Consider an element of the {kernel eP (( f x + a)), with a 2 ZIK;f . Then if f jP j ? 1, this function already is in the above list. Consider now f jP j. Then ( f x + a) can be written as (x)(a). Then eP (( f x + a)) = eP (( jP j?1 x + c)) + eP ((a)); where c = ? 1 (take(jP j; (a))). Now the rst term on the right is in the list above, and the second term is a constant multiple of the constant function 1. Hence eP (( f x + a)) is a ZZ{linear combination of elements in the list.2 Remark 4.1 The function eP ((ax + b)) is {regular for a; b 2 ZIK .
Regular maps in generalized number systems
12
5 Linear recurring bases 5.1 The (u; b) numeration
The notion of numeration systems based on linear recurrent sequences was introduced by Fraenkel in [11]. We will follow here the notations of Shallit in [27]. Let (un)n be a linear recurrence over ZZ satisfying the following properties: (i) u0 = 1; (ii) (un)n is strictly increasing; (iii) there exist K 1, M 1 and K coecients in N, 1 b1 = 1; b2; : : :; bK M such that, for all n M, one has un =
X
1iK
un?bi :
The M + K integers (u; b) = (u0; u1; : : :; uM ?1; b1; b2; : : :; bK ) suce to characterize the sequence (un )n . Note that some of the bi's can be equal, actually allowing positive integers as coecients. Now any integer N is represented in base (u; b) as follows: if N < uM ?1 , then use any algorithm (for instance the greedy one) to express N as a sum of ui 's for 0 i < M ? 1, otherwise, by induction, let j be the unique integer such that uj ?1 N uj , then there exists a unique k 2 [1; K] such that:
X
1ik?1
uj ?bi N
1 such that j ?1 uj ?1 n < uj if jnj = j. Thus lnn : j 1 + ln Theorem 5.1 (e) gives V (n) = Bn0 Bn1 Bnj?1 V (0): See now Theorem 3.6 2.
6 Computational results The second author has written a computer program that constructs nite automata for addition and multiplication by a xed number in integral domains. It searches for all possible states of the automaton and stores them in a tree. The state of the automaton corresponds to the carry in the actual step. If u and v are xed algebraic numbers, the automaton will compute the digits of uz + v from the digits of z. If u = 1 and v = 1 the automaton is just the odometer. The automaton uses the following algorithm for multiplication by a xed number: let nX ?1 z = zj j : j =0
Let cj be the carry and dj be the output at the j'th step. (1) Let c0 = v be the initial carry. (2) for j = 0; 1; do dj and cj +1 uniquely follow from u zj + cj = dj + cj +1 . (v can be considered as initial carry when calculating u z + v. In case of pure multiplication we have v = 0.) Example 6.1 Let m (x) = x2 + 2x + 2. Thus = ?1 i and N( ) = 2. The automaton which multiplies a number by 2 is given in Figure 1.
Regular maps in generalized number systems
0
zj cj
0
?2 ?1 1 1 ?1 ?1 2 ?3 2 0 ?3 3 ?2 0 ?2
1 0 ?1 0 1 ?2 2 ?1 ?1 2 ?2 1 0
0 dj cj +1 dj 0 0 0 0 0 1 1 0 1 1 0 1 1 0 0 1 1 1 1 1 1 2 1 1 0 ?1 ?1 0 1 2 2 1 0 0 ?1 0 0 ?1 0 0 1 3 2 1 1 0 ?1 1 0 0 1 0 0 1 0 0 0 2 1 0
16
1 cj +1 ?2 ?1 ?1 0 ?1 ?1 ?2 ?1 ?1 0 0 0 ?3 ?2 0 1 ?2 ?2 ?3 ?1 1 1 ?2 ?2 ?2 0 ?1 ?1 0 0
Figure 1: The transducer for multiplication by 2.
Remark 6.1 Multiplication cannot be generally performed by a nite automaton for linear recurring bases. Take for example the Fibonacci-base u0 = 1, u1 = 2, un = un?1 + un?2. This base satis es the identity 2
m X
k=0
u3k = u3m+2 ? 1:
The (u; b)-representation of u3m+2 ? 1 is either (010 101) or (101 101). This is dependent of m being even or odd. Thus the automaton has to store the whole (u; b)-representation to compute the least signi cant digit of the product. This cannot be done by a nite automaton. This counterexample was given by G. Barat, during his visit in Graz in 1996. For related general results, see [12, 13]
Acknowledgments. Part of this work was done when JPA visited Graz in 1995. JPA wants to thank heartily his colleagues for their very warm hospitality, and J. Shallit for many interesting conversations on these topics. The authors thank the referee for its precise and useful comments.
Regular maps in generalized number systems
17
References [1] J.-P. Allouche. q-regular sequences and other generalizations of q-automatic sequences. Lecture Notes in Computer Science, 583:15{23, 1992. [2] J.-P. Allouche. Finite automata and arithmetic. Seminaire Lotharingien de Combinatoire, B30c:1{23, 1993. [3] J.-P. Allouche, E. Cateland, W. J. Gilbert, H.-O. Peitgen, J. Shallit, and G. Skordev. Automatic maps in exotic numeration systems. Theory Comput. Syst. (Math. Systems Theory), 30:285{331, 1997. [4] J.-P. Allouche, P. Morton, and J. Shallit. Pattern spectra, substring enumeration, and automatic sequences. Theoret. Comput. Sci., 94:161{174, 1992. [5] J.-P. Allouche and J. Shallit. The ring of k-regular sequences. Theoret. Comput. Sci., 98:163{187, 1992. [6] G. Christol. Ensembles presque-periodiques k-reconnaissables. Theoret. Comput. Sci., 9:141{145, 1979. [7] G. Christol, T. Kamae, M. Mendes France, and G. Rauzy. Suites algebriques, automates et substitutions. Bull. Soc. Math. Fr., 108:401{419, 1980. [8] A. Cobham. On the base-dependence of sets of numbers recognizable by nite automata Math. Systems Theory, 3:186{192, 1969. [9] A. Cobham. Uniform tag sequences. Math. Systems Theory, 6:164{192, 1972. [10] F. M. Dekking, M. Mendes France, and A. J. van der Poorten. Folds! Math. Intelligencer, 4:130{138, 173{181, 190{195, 1982. [11] A. S. Fraenkel. Systems of numeration. Amer. Math. Monthly, 92:105{114, 1985. [12] C. Frougny. Con uent linear numeration systems. Theoret. Comput. Sci., 106:183{219, 1992. [13] C. Frougny and B. Solomyak. On representation of integers in linear numeration systems. In: Ergodic Theory of ZZd actions, Proceedings of the Warwick Symposium, Warwick, UK, 1993{94, Eds. M. Pollicott et al. Cambridge University Press, Lond. Math. Soc. Lect. Note Ser., 228:345{368, 1996. [14] P. G. Grabner, P. Kirschenhofer, and H. Prodinger. The sum of digits function for complex bases. J. London Math. Soc., (to appear).
Regular maps in generalized number systems
18
[15] I. Katai and B. Kovacs. Kanonische Zahlensysteme in der Theorie der quadratischen algebraischen Zahlen. Acta Sci. Math. (Szeged), 42:99{107, 1980. [16] I. Katai and B. Kovacs. Canonical number systems in imaginary quadratic elds. Acta Math. Acad. Sci. Hung., 37:159{164, 1981. [17] I. Katai and J. Szabo. Canonical number systems for complex integers. Acta Sci. Math. (Szeged), 37:255{260, 1975. [18] C. Kimberling. Numeration systems and fractal sequences. Acta Arith., 73:103{117, 1995. [19] D. E. Knuth. The Art of Computer Programming, Vol. 2, Seminumerical Algorithms, 2nd ed. Addison Wesley, Reading, 1981. [20] B. Kovacs. CNS rings. in: Topics in Classical Number Theory, vol. II, Colloq. Math. Soc. Janos Bolyai, Ed. G. Halasz, North Holland, 34:961{ 971, 1984. [21] B. Kovacs and A. Peth}o. Number systems in integral domains, especially in orders of algebraic number elds. Acta Sci. Math. Szeged, 55:287{299, 1991. [22] P. Morton and W. Mourant. Paper folding, digit patterns and groups of arithmetic fractals. Proc. Lond. Math. Soc., 59:253{293, 1989. [23] O. Salon. Suites automatiques a multi-indices et algebricite. C. R. Acad. Sci. Paris, Serie I, 305:501{504, 1987. [24] O. Salon. Proprietes arithmetiques des automates multidimensionnels. These, Universite Bordeaux I, 1989. [25] K. Scheicher. Kanonische Ziernsysteme und Automaten, (to appear). [26] K. Scheicher. Zierndarstellungen, lineare Rekursionen und Automaten. PhD thesis, TU Graz, 1997. [27] J. Shallit. A generalization of automatic sequences. Theoret. Comput. Sci., 61:1{16, 1988. [28] J. Thuswaldner. Elementary properties of canonical number systems in quadratic elds, (to appear). Jean-Paul Allouche, CNRS, LRI, B^atiment 490, F-91405 Orsay Cedex (France)
[email protected] Klaus Scheicher, Mathematical Institute, TU Graz, Steyrergasse 30, A-8010 Graz (Austria)
[email protected] Robert F.Tichy, Mathematical Institute, TU Graz, Steyrergasse 30, A-8010 Graz (Austria)
[email protected]