Skip to Content
AlgorithmsAlgorithms
  • Article
  • Open Access

20 February 2025

22 Pages

Automata and Arithmetics in Canonical Number Systems

and
Department of Computer Science, Faculty of Informatics, University of Debrecen, Kassai Str. 26, 4028 Debrecen, Hungary
*
Author to whom correspondence should be addressed.
†
These authors contributed equally to this work.

Abstract

In this paper, we discuss canonical number systems (CNSs), which are generalizations of positional number systems to polynomials over the integers. We defined the information quantity of a polynomial A ∈ Z [ x ] relative to the base of the CNS and proved that it has a strong relation with the length of the representation in the number system. Based on this result, we showed that for every CNS polynomial P, there exists a finite transducer automaton executing the addition operation of polynomials in canonical representation of base P. Finally, we observed the size—i.e., the number of states—of such automata.

1. Introduction

In their first appearance, canonical number systems (CNSs) were natural generalizations of the positional numeral systems of rational integers to algebraic integers. D. E. Knuth, in his famous book [1] (Ch. 4), studied the history of the radix representation of integers. He described various canonical number systems, and he proved that the complex number − 1 + i  is a possible base of the number system representing Gaussian integers. His result was further generalized by I. Kátai and J. Szabó. In [2], they proved the existence of other bases, but still in the set of Gaussian integers. Later, I. Kátai and B. Kovács in [3], B. Kovács in [4], and B. Kovács and A. Pethő in [5] and [6] extended the concept of canonical number systems for the ring of algebraic integers and they proved their existence in some particular cases. In [7], A. Pethő first used the notion, and S. Akiyama and A. Pethő in [8] continued the development of results of CNSs over polynomials. A. Pethő and P. Varga in [9] dealt with canonical number systems over Euclidean domains.
In [4], a simple condition is given for the construction of CNSs, but in general, they are not easy to find. A. Kovács [10] presented a complete description of binary canonical number systems of degrees not greater than 8. Later, P. Burcsi and A. Kovács [11] extended the results for CNSs of degrees 9, 10, and 11.
The arithmetic in a canonical number system is similar to that of rational integers within the classical digit representation. However, calculating the digits requires a more complex reduction operation.
P. J. Grabner, P. Kirschenhofer, and H. Prodinger in [12] introduced the concept of counting automata (increasing by 1) for Gaussian integers, which was generalized to quadratic number fields by J. M. Thuswardner [13]. J. Allouche, K. Scheicher, and R. F. Tichy in [14] proved the existence of addition and multiplication by a constant in algebraic number fields. K. Scheicher and J. M. Thuswaldner in [15] introduced a fractal approach for the detailed analysis of counting automata.
Transducers were extensively studied by S. Eilenberg in Automata, Languages and Machines [16], and further developed by W. Kuich and A. Salomaa in Semirings, Automata, Languages [17].
In the present paper, we prove that for every CNS polynomial, an automaton can be constructed to perform digit-wise addition (Theorem 5). This relies on several assertions, which are detailed in Section 2. We implement a program for the calculation of addition automata in binary CNSs and summarize our experiments in Section 4.
The rest of the paper is organized as follows.
In Section 2, we introduce the concepts and key results related to canonical number systems. We also define a useful measure for the information quantity of a polynomial and outline its fundamental properties. One of the main results of the section is Theorem 3, which establishes a general bound on geometric sums of complex numbers α with modulus greater than 1, under the condition that α is not a positive real number. The proof of this statement requires some further lemmas concerning the behavior of geometric sums, which we address in the subsequent paragraphs. Using these lemmas, we present an algorithm, which is designed to calculate a reasonably small constant appearing in Theorem 3. In the last part of the section, we prove Theorem 4, which discusses the relationship between the length of a polynomial A in canonical representation and the information quantity of A. The constants referenced in this theorem are derived using Theorem 3, and thus can be calculated by an algorithm explained after the theorem.
In Section 3, we define the concept of finite transducer automata. In Theorem 5, we show that for every canonical number system, there exists a transducer automaton executing the addition operation for polynomials in canonical representation. The proof is constructive, and the automaton produced is minimal (Theorem 6). Using arguments from the previous results, in Theorem 7, we show that there is no finite transducer automaton capable of performing multiplication in canonical number systems.
In the final section, we present our experimental results regarding the construction of minimal addition automata in particular canonical number systems.

3. Automata and Canonical Number Systems

As we have seen before, adding and multiplying by a constant are implementable with automata in CNSs. In this section, we prove that an automaton exists that executes the digit-wise addition. The existence of such an automaton is not obvious since the length of the sum of two algebraic integers represented in the canonical number system may have a shorter length than the summands’.
Definition 4. 
The 6-tuple A = ( k , S , X , Y , s , δ ) is called a finite transducer automaton with k input tape if
  • k ∈ Z + ;
  • S is a finite, non-empty set of states;
  • X is a finite set of at least two elements (the input alphabet);
  • Y is a finite set of at least two elements (the output alphabet);
  • s ∈ S is the initial state;
  • δ : S × X k ⟶ S × Y is a unique mapping.
Remark 9. 
We follow the convention for extending the transducer automaton to operate on words of the input alphabet and having the result as a word of the output alphabet.
In the following, if a ¯ = ( a 0 … a n − 1 ) ∈ N * is a finite word, then we will use the notation Q a ( x ) = a n − 1 x n − 1 + … + a 0 for the corresponding polynomial.
Theorem 5. 
Let ( P , N ) be a CNS. Then, there exists a finite transducer automaton A with two input tapes, such that c ¯ = A ( a ¯ , b ¯ ) for all a ¯ , b ¯ , c ¯ ∈ N * if φ ( Q c ) = φ ( Q a + Q b ) .
Remark 10. 
In Theorem 5, we assume that the length of the words a ¯ , b ¯ , c ¯ are equal. If not, we extend them with the necessary amount of 0s on the right.
Remark 11. 
In [19], there is a similar result, but the proof there is not constructive. Furthermore, based on our proof, we can state the minimality of our construction, as it is done in Theorem 6.
Proof of Theorem 5. 
We prove the statement by constructing the addition automaton A = ( 2 , S , X , Y , s , δ ) , where X = Y = N . We will define S ⊆ N [ x ] and δ in an appropriate way, and we will prove that S is finite. Assume that N = N .
Let S be the smallest set such that
  • 0 ∈ S ;
  • if A ∈ S , B ∈ N [ x ] , b ∈ N , and 0 ≤ a < 2 N − 1 such that φ x B ( x ) + b = φ A ( x ) + a then B ∈ S .
We define the transition function δ : S × N 2 ⟶ S × N by δ A , a 1 , a 2 = B , b , if φ x B ( x ) + b = φ A ( x ) + a 1 + a 2 .
Let a ¯ , b ¯ ∈ N * , A 0 = 0 , and Q 0 = Q a + Q b . If 0 ≤ i , let A i + 1 be defined by δ A i , a i , b i = A i + 1 , c i , and Q i + 1 ( x ) = Q i ( x ) + ( c i − a i − b i ) x i . By the definition of δ , we have
φ Q i + 1 ( x ) + A i + 1 ( x ) x i + 1 = φ Q i ( x ) + A i ( x ) x i = φ Q a + Q b ,
for all 0 ≤ i .
Let n = 1 + max deg ( Q a ) , deg ( Q b ) and k = 1 + deg ( A i ) . Then, deg Q n < n , Q c = Q n + k = Q n + A n x n ∈ N [ x ] , and φ ( Q c ) = φ ( Q a + Q b ) .
Hence, by Theorem 4, and by Lemma 1(iii),
n + k = deg ( Q c ) + 1 = L ( Q c ) ≤ I ( Q c ) + C 2 ≤ max I ( Q a ) , I ( Q b ) + I ( 2 ) + C 2 = n + I ( 2 ) + C 2 ,
where C 2 is the constant c 2 in Theorem 4.
This yields that
deg A i < k ≤ I ( 2 ) + C 2 .
Since S is defined to be the smallest set satisfying (1) and (2), every A ∈ S may appear as the last carry A n . Thus, for all A ∈ S ⊆ N [ x ] , deg A < I ( 2 ) + C 2 , which implies that S is finite. □
Remark 12. 
Observe now the properties of the states defined in the proof of Theorem 5. Let A ( x ) = a k x k + a k − 1 x k − 1 + … + a 0 , where a k ≠ 0 and A ( x ) ∈ S . Assume that the automaton is in state A, and there are no more digits arriving from the input. Then, by the definition of the transition function δ, the output of the automaton starting from this state is the sequence a 0 a 1 … a k . This means that different states represent different tail releases of the output, i.e., if the automaton is state B ≠ A , then the output without input is different to a 0 a 1 … a k .
Theorem 6. 
The addition automaton, constructed in the proof of Theorem 5, is minimal.
Proof. 
In the definition of A in the proof of the previous theorem, S is the smallest possible set satisfying the given properties. This means that for any A ∈ S , there exist proper inputs a ¯ , b ¯ such that A ( a ¯ , b ¯ ) terminates in state A.
Let S = { A 1 , A 2 , … , A n } and a ¯ 1 , a ¯ 2 , … , a ¯ n , b ¯ 1 , b ¯ 2 , … , b ¯ n are such that A ( a ¯ i , b ¯ i ) terminates in state A i for all i ∈ { 1 , … , n } .
Assume that there exists an automaton A ′ , which executes the same addition as A , but | S ′ | < | S | , i.e., A ′ has strictly fewer states. Then, by the pigeonhole principle, there exist 1 ≤ i < j ≤ n such that A ′ ( a ¯ i , b ¯ i ) and A ′ ( a ¯ j , b ¯ j ) terminates in the same states. By Remark 12, automaton A continues with different tail releases from the states A i and A j , but A ′ continues in the same way if there are no more input digits. This is a contradiction because we assumed that A and A ′ execute the same operation. Hence, the assumption of the existence of A ′ is wrong. □
Although we can not be sure there is no linear time algorithm for multiplication, we have the following.
Theorem 7. 
Let ( P , N ) be a CNS. Then, there are no finite transducer automaton S with two input tapes, such that c ¯ = S ( a ¯ , b ¯ ) for all a ¯ , b ¯ , c ¯ ∈ N * if φ ( Q c ) = φ ( Q a · Q b ) .
Proof. 
On the contrary, assume that A = ( 2 , S , N , N , s , δ ) executes the multiplication, and N = N .
Let a ¯ , c ¯ ∈ N * satisfying φ ( Q c ) = φ Q a 2 . Then by Lemma 1(vi), and by Theorem 4,
deg Q c = L ( Q c ) − 1 ≥ I Q c − C 1 − 1 = 2 I Q a − C 1 − 1 ≥ 2 L Q a − C 2 − C 1 = 2 deg Q a − 2 C 2 − C 1 + 1 .
Set n = 1 + deg Q a , and Q i = c i x i + ⋯ + c 0 for all 0 ≤ i . (If deg Q c < i , then Q i = Q c .) Since the automaton executes the multiplication, there exist s 0 , s 1 , ⋯ ∈ S such that s 0 = s , and δ s i , a i , a i = s i + 1 , c i , for all 0 ≤ i .
If n ≤ i , then a i = 0 , and Q c , n ( x ) = Q c ( x ) − Q n ( x ) x n is determined purely by s n . Since deg Q c , n ≥ n − 2 C 2 − c 1 + 1 , there are infinitely many different Q c , n , whence there are infinitely many different corresponding states. However, this is a contradiction since we assumed that A is a finite automaton. □

4. Estimation of the Number of States of an Addition Automaton

In this section, we show an example of how to execute addition and how to construct the addition automaton based on the addition algorithm in a given polynomial CNS. We also provide the result of an experiment where we determined the addition automata for different CNSs.

4.1. Example of the Computation in the Number System x 2 + x + 2 , { 0 , 1 }

Let x 2 + x + 2 be the base polynomial and { 0 , 1 } is the digit set. By Theorem 1, we know that this is a CNS.
Let γ 1 = 110101 and γ 2 = 101111 be 6-bit long binary ‘numbers’ in the above CNS, and let γ = γ 1 + γ 2 . The calculation of the digits of γ is similar to the usual binary arithmetic, but the carry propagation is a bit more advanced. In the classical binary system, we use the fact that 1 ( − 2 ) 2 = 1 · 2 1 + ( − 2 ) · 2 0 = 0 (i.e., we use the x − 2 polynomial as the base). In the present system, according to this observation, 1 1 2 x 2 + x + 2 = 0 .
The addition process works as follows:
  • Initialization
    The two numbers, γ 1 and γ 2 , are digit-wise added without any further computations. The result is γ ′ = 211212 .
  • Reduction
    Starting from the least significant digit on the right, we reduce the augmented digits, which are not in the digit set { 0 , 1 } . In this CNS, this is the only value 2. However, as in the classical binary systems, we have to take into account the possible carries, arriving from lower digits. How can we calculate this carry?
    In the case of the last digit, we assume that there is no carry; more precisely, the value of the carry is 0. To eliminate the last digit 2, we should subtract 1 1 2 . The result is ( − 1 ) ( − 1 ) 0 , which is split into two parts: the calculated digit at the given position and the carry for the next position. In our case, the digit is 0, while the carry is ( − 1 ) ( − 1 ) .
    For the next digit, we add the carry arriving from the right to the value given at the position: 1 + ( − 1 ) ( − 1 ) = ( − 1 ) 0 . Since 0 is a valid digit, we do not need any further operation at this position. The carry for the next position is ( − 1 ) .
    The next augmented digit is 2. Adding the carry, we obtain 2 + ( − 1 ) = 1 , so the next calculated digit is 1, and the carry is 0.
    We continue the iteration until γ ′ is completely processed and the carry becomes 0.
The algorithm described above can be visualized by Table 2.
Table 2. Computation in the binary number system.
Based on the algorithm for calculating the sum, we may construct the corresponding addition automaton. The states of the automaton are the possible carries during the computation. We start from the carry 0 and calculate the transition according to the possible inputs (augmented digit). The value of the transition is a pair ( C , d ) , where C is the next carry and d is the output digit. The new carries are added to the automaton, and until we have unexplained transitions, we continue the construction of the automaton.
The process generates the transition function of the automaton, as illustrated in Table 3.
Table 3. State transition table.
The values of the cells in the table contain pairs: the next state (carry) and the output (digit), according to the present state (carry) and the input (augmented digit). If a new unexplored carry appears in the transition value, then a new column is added to the table. We continue to fill out the table until no new carry appears. By Theorem 5, the algorithm will terminate in finitely many steps.

4.2. Analysis of Binary Polynomial CNS’s

As we have observed before, the states of the addition automaton may represent the possible carries. According to construction, these are polynomials in N [ x ] . Since the degrees of the state polynomials are bounded by the constant c = I ( 2 ) + c 2 of Theorem 4, we may state the following simple result.
Theorem 8. 
Let ( P , N ) be a CNS, and A be the minimal automaton implementing the addition. Then, the number of states of A is bounded by | N | c .
We have made an experiment on the construction of addition automata for different CNS polynomials. We determined and counted the number of states for binary Kovács-type CNS polynomials of different degrees. (i.e., the coefficients of P have the property 1 = p d ≤ p d − 1 ≤ … ≤ p 0 = 2 .) A. Kovács in [10] listed the canonical polynomials of binary number systems until degree 8. According to this result, we know, for instance, that the only binary CNS polynomials of degree 3 satisfying the conditions of Theorem 1, are x 3 + 2 , x 3 + x 2 + x + 2 , and x 3 + 2 x 2 + 2 x + 2 . Using the construction of the proof of Theorem 5, we implemented a computer program to calculate the addition automaton for a given CNS polynomial. We determined all different CNS polynomials of degrees from 3 to 10 in the form given in Theorem 1, and constructed the corresponding addition automaton. We collected the size of these automata, which are expressed by the number of states. The results are summarized in Table 4. The table contains the size (number of states) of the smallest and largest automata for different degree CNS polynomials.
Table 4. Number of states of addition automata.
As we advanced to higher degree CNS polynomials, the experiment ran into memory limitations. When we computed the transition function of the automaton in question, we had to store the states and the effect of the input digits. To save some space, we did not care about the output, and we just represented the state transitions. Since the number of states was increasing exponentially with the degree of the CNS polynomials, even for degree 10, we ran out of memory during the tests. The experiment was executed on a computer with an Intel Core i9-9900K CPU on 3.60GHz equipped with 64 GB of RAM. The running time did not limit the computation since it took only some hours.

5. Conclusions

The presented research demonstrates the feasibility of constructing finite transducer automata for digit-wise addition of polynomials in canonical number systems (Theorem 5). The constructive proof provided also establishes that the resulting automata are minimal (Theorem 6). The proof of Theorem 5 is based on the relation between the length of a polynomial A in canonical representation and the information quantity of A (Theorem 4), as well as on the additive property of the information quantity (Lemma 1(iii)). For practical applications, it is reasonable to compute the constants appearing in Theorem 4 with a reasonably good approximation of the possible minimum values. To achieve this, we developed Algorithm 1, which is based on an improved upper bound for geometric sums (Theorem 3).
The study also exposed a fundamental limitation: as is proven in Theorem 7, no finite transducer automaton can be created for the multiplication of polynomials in canonical representation. At present, we do not know whether an algorithm exists that can execute the multiplication of n digit numbers (or analogously degree n polynomials) in O ( n ) time; however, based on the above result, we cannot do this with constant memory usage.

Author Contributions

The authors T.H. and V.P. equally contributed to every component of the research, writing, reviewing and management of the manuscript. All authors have read and agreed to the published version of the manuscript.

Funding

This research was partially supported by the project TKP2021-NKTA of the University of Debrecen, Hungary. Project no. TKP2021-NKTA-34 has been implemented with the support provided by the Ministry of Culture and Innovation of Hungary from the National Research, Development and Innovation Fund, financed under the TKP2021-NKTA funding scheme. The APC was funded by the University of Debrecen.

Data Availability Statement

There were no new data created, and there were no particular data used during the research.

Conflicts of Interest

The authors declare no conflicts of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript; or in the decision to publish the results.

References

  1. Knuth, D.E. The Art of Computer Programming, Volume 2: Seminumerical Algorithms; Addison-Wesley: Boston, MA, USA, 1981. [Google Scholar]
  2. Kátai, I.; Szabó, J. Canonical number-systems for complex integers. Acta Sci. Math. 1975, 37, 255–260. [Google Scholar]
  3. Kátai, I.; Kovács, B. Canonical number systems in algebraic number fields. Acta Math. Hung. 1981, 37, 159–164. [Google Scholar] [CrossRef] [Scilit]
  4. Kovács, B. Integral domains with canonical number systems. Publ. Math. 1989, 36, 153–156. [Google Scholar] [CrossRef] [Scilit]
  5. Kovács, B.; Pethő, A. Number systems in integral domains, especially in orders of algebraic number fields. Acta Sci. Math. 1991, 55, 287–299. [Google Scholar]
  6. Kovács, B.; Pethő, A. On a representation of algebraic integers. Stud. Sci. Math. Hung. 1992, 27, 169–172. [Google Scholar]
  7. Pethő, A. On a polynomial transformation and its application to the construction of a public key cryptosystem. In Computational Number Theory: Proceedings of the Colloquium on Computational Number Theory held at Kossuth Lajos University, Debrecen, Hungary, 4–9 September 1989; Pethő, A., Pohst, M.E., Williams, H.C., Zimmer, H.G., Eds.; De Gruyter: Berlin, Germany; New York, NY, USA, 1991; pp. 31–44. [Google Scholar]
  8. Akiyama, S.; Pethő, A. On a canonical number systems. Theor. Comput. Sci. 2002, 270, 921–933. [Google Scholar] [CrossRef] [Scilit]
  9. Pethő, A.; Varga, P. Canonical number systems over imaginary quadratic Euclidean domains. Colloq. Math. 2016, 146, 1–22. [Google Scholar] [CrossRef] [Scilit]
  10. Kovács, A. Generalized binary number systems. Ann. Univ. Sci. Budapest, Sect. Comp 2001, 20, 195–206. [Google Scholar]
  11. Burcsi, P.; Kovács, A. Exhaustive search methods for CNS polynomials. Monatshefte Math. 2008, 155, 421–430. [Google Scholar] [CrossRef] [Scilit]
  12. Grabner, P.J.; Kirschenhofer, P.; Prodinger, H. The sum-of-digits function for complex bases. J. Lond. Math. Soc. 1998, 57, 20–40. [Google Scholar] [CrossRef] [Scilit]
  13. Thuswaldner, J.M. Elementary properties of the sum of digits function in quadratic number fields. In Applications of Fibonacci Numbers; Et Al Bergum, G.E., Ed.; Kluwer Academic Publisher: Alphen aan den Rijn, The Netherlands, 1998; Volume 7, pp. 405–414. [Google Scholar]
  14. Allouche, J.; Scheicher, K.; Tichy, R.F. Regular Maps in Generalized Number Systems. Math. Slovaca 2000, 50, 41–58. [Google Scholar]
  15. Scheicher, K.; Thuswaldner, J.M. Canonical Number Systems, Counting Automata Furthermore, Fractals. Math. Proc. Camb. Philos. Soc. 2007, 133, 163–182. [Google Scholar] [CrossRef] [Scilit]
  16. Samuel, E. Automata, Languages, and Machines; Academic Press: New York, NY, USA, 1974. [Google Scholar]
  17. Kuich, W.; Salomaa, A. Semirings, Automata, Languages; Springer: Berlin/Heidelberg, Germany, 1986. [Google Scholar]
  18. Akiyama, S.; Borbély, T.; Brunotte, H.; Pethő, A.; Thuswaldner, J.M. On a generalization of the radix representation—A survey. Fields Inst. Commun. 2004, 41, 19–27. [Google Scholar]
  19. Berthé, V.; Rigo, M. (Eds.) Combinatorics, Automata and Number Theory; Cambridge University Press: Cambridge, UK, 2015. [Google Scholar]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.