1. Introduction
Positional number systems are fundamental in mathematics (see [
1]). The development and spread of the number system with base 10 is a major achievement of ancient/medieval mathematics. The advent of computers gave special importance to the number system with base 2. These number systems encode natural numbers as a finite sequence of digits. The positions in a sequence of digits are local values weighted by the digits. The sum of these weighted values is a number, coded by the representation.
In the number system with base 2, the digits are (they are called bits), and the values of the positions are …, 16, 8, 4, 2, 1. This basic theorem of the binary system can be formulated as follows.
Theorem 1. Every natural number can be written uniquely as the sum of distinct powers of two, where the order of the members of the sum does not matter.
First note that the empty sum is also considered; its value is 0. The value of a sum with one term is the value of the only term. Second, we eliminate the freedom in the order of the terms by listing them following increasing order, that is, writing down the number
n The digits 0 do not contribute to the value; hence, we do not include them in the sum.
The ternary number system can be introduced in a similar way. In the number system with base 3, the digits are 0, 1, and 2, and the local values are …, 81, 27, 9, 3, 1.
The decimal number system can be discussed similarly. All number systems are suitable for the unique encoding of natural numbers. If we want to consider integers, the usual method is to introduce signed numbers. Following a sign, we encode the absolute value of a number. The mathematical beauty is somewhat compromised: and are two codes for the same number.
It helps if you use negative digits. Then, the positive/negative numbers can be handled homogeneously. This option was first published by J. Colson [
2]. Later, independently, A. Cauchy [
3] also discovered this possibility. A survey on the subject was published in Kvant [
4].
If we have digits
(or more generally, a subset of the integers that is closed under taking opposite), then the sign change will be the sign changes of the digits. This advantage was also noticed by Shannon [
5].
When designing multiple computer architectures, this advantage was considered [
6,
7,
8,
9,
10,
11,
12,
13]. The digits
, 0, and 1 can be called
trits. Their technical realization is possible. Two early architectures build on this [
12,
13,
14]. Many have looked in more depth at the ternary computers [
15,
16]. Currently, binary architecture—thanks to its explosive development—is the single dominant technology.
We highlight two possibilities where integers are represented by a finite sequence of digits.
The first is the balanced ternary system. In this number system, the digits
, 0, 1 are powers of 3 of the local values [
17]. The advantage of this number system is that all integers can be represented and the representation is unique. Donald Knuth’s well-known statement, in his excellent book [
18], describes this system as ”Perhaps the prettiest number system of all is the balanced ternary notation,…”
The second is the negabinary. Here, the number system is based on . The local values are the powers of , and the digits 0 and 1. We can expand and consider it as with a possible sign.
In this note, we propose several new numeral systems based on our main theorem, Theorem 2. We present six options to produce a scheme for a unique representation of integers. In spite of their simplicity, I was able to find only one of them in the literature [
20].
We call the new number system the alternating binary number system. The idea is that the local values are the same as in the binary system: …, 16, 8, 4, 2, 1 (the powers of two). The digits are . Our main addition assumption is that the non-zero digits must alternate. The representation of a given integer using the above rules will be ambiguous. But this ambiguity is limited: all non-zero integers will have exactly two representations. The basic theorem of our paper is the following statement.
Theorem 2. Every non-zero integer n has exactly two representations aswhere , , for ; furthermore, any two consecutive signs differ. Alternation means the and .
In exactly one of the two forms, ψ is undefined or (this is called type I). The other has at least two terms and (this is called type II).
The theorem implies a new numeral system, a new coding of integers with a finite sequence of digits. The sum of the theorem contains the non-zero digits of an alternating binary representation. As usual, we write
instead of the
digit. The
and 1 digits are at the corresponding location of the code. The powers of two, which are not present at the sum, correspond to 0 digits. For example,
The digit associated with
is the first digit of the code, which is referred to as the most significant digit. A single 0 digit is the code of the empty sum:
. Given a representation/code, a sequence of digits, the number
n, can be decoded.
Although uniqueness is not true, the two representations are strongly related. One representation ends with . The other ends with . Otherwise, the two representations are the same.
In the next section, we give a proof of this. We briefly mention several conventions which lead to a unique representation.
Finally, we provide the graph theoretical explanation of our main theorem. This is a crucial part of our paper. It can be seen that there are numerous ways to design number systems. After describing the number system, it is no longer difficult to understand the existence and uniqueness of the representation. In some cases, the existence and uniqueness can be automated [
23,
24]. We present the path we took to introduce our number system.
In this paper, denotes the natural of natural numbers , denotes the set of integers, and denotes the set of positive integers.
2. The Proof of Theorem 2
The proof will be a simple series of simple claims and their proof.
1. Suppose that
is a non-empty alternative binary representation of the number
n. Then,
n is not 0 and its sign is equal to the sign of
.
Indeed,
where the “brackets” are positive. (Brackets contain two terms, with the possible exception of the last one which might have only one term.)
2. 0 has a single representation, the empty sum.
3. It is enough to prove the theorem for positive integers, assuming that the most significant digit is .
4. Let n be a positive integer and take an alternative binary representation of it with terms. Consider the representation first of the representation and denote their sum by . If k is even, then . If k is odd, then .
Indeed,
where the “brackets” have positive values.
5. Each positive integer n has an alternating binary representation.
Let us write down n in the binary number system, i.e., as the sum of different powers of two (with strictly decreasing order of exponents). Substitute for each power of two: . We obtain a new representation of our initial number as the sum of signed powers of two; furthermore, the signs alternate. The exponents will be decreasing but not strictly decreasing. There can be only two powers of the same exponent, they must follow each other, and they must have different signs. Thus, they cancel. By performing the cancellations, we obtain a representation of our starting number in the alternating binary number system.
6. Let n be a power of two, i.e., for a suitable natural number k. Then, n has exactly two alternating binary binary representations: and .
We know (4.) that .
7. If n is between two consecutive powers of two (for a suitable natural number k we have ), then the first term of each representation of n is necessarily .
Again, we know (4.) that .
8. If (), then every representation of n is where is the representation of the number
9. If (), then is strictly smaller than n.
Then, the proof is completed by a simple induction.
In the case of a non-zero number in one of the two options for the representation, the last is non-zero, and the preceding digit is , or , where . There are several simple ways to make the representation unique.
Theorem 3. The alternating binary representation will be unique if any of the following additional conditions are satisfied:
- (a)
The last non-zero digit must be 1.
- (b)
The last non-zero digit must be .
- (c)
The last non-zero digit must be immediately preceded by a 0 digit (or we have only one non-zero digit).
- (d)
The last non-zero digit must be immediately preceded by a non-zero digit.
- (e)
The number of non-zero digits is odd.
- (f)
The number of non-zero digits is even.
The proofs are straightforward.
If we choose any of the rules above, we obtain a numeral system. For example, we can fix (c) as the basic rule of binary alternating coding of integers. We will denote the
digit as
and we use subscript
when representing
n using place-value notation. We list a few integers with small absolute value and their representation.
3. Connection to Graph Theory
Let be a triple. The elements of V are called vertices; V is the vertex set of G. The elements of E are called edges; E is the edge set G. I is an incidence relation between V and E (). If and are incident, then we say that the vertex v is an endpoint of the edge e. We call G a graph if every edge has two endpoints.
These two endpoints may coincide, in which case e is called a loop. If an edge e has two endpoints u and v, then we say that u and v are connected by e or u and v are adjacent. If two edges have the same two endpoints, then we say that they are parallel edges. If there are no parallel edges in a graph, we only need to describe when two vertices are connected to define the graph. Moreover, if a graph contains no loops, then we call it a simple graph.
If V and E are finite sets, then G is a (finite) graph. If V or E are infinite, then G is an infinite graph.
Definition 1. Let be the infinite graph without parallel edges whose vertices are the natural numbers and two vertices are connected if and only if their sum is a power of two.
Notice that, because for every vertex that is a power of two, a loop is present in our graph. These are the only loops in . Let be the simple graph that is obtained by removing the loops that are incident to the powers of two.
It is easy to see that is a graph of infinitely many vertices, each of which has infinite neighbors. Let v be a vertex of . If k is the natural number satisfying , then the neighbors of v are , , and , where K is an arbitrary natural number . If , then the neighbors of v are 0 and for every natural numbers.
Lemma 1. For positive , the vertex v has exactly one neighbor that is smaller than v.
Let
be the finite graph is obtained from
such that
with
n elements and the edges
are the edges of
connecting two nodes from
(see
Figure 1).
Theorem 4. The graph is a tree.
Proof. We can think about
as a result of the following sequence of graph extensions:
The initial graph
is a graph with one node (1) and no edge, i.e.,
is the smallest tree. Each expansion step is a “branching” (we extend our actual graph with a new vertex and a new edge that connects the new node to an old one). This operation preserves connectivity and cycle-freeness. That is, the operation forms a tree from a tree. □
Corollary 1. is a tree.
Thus, there is exactly one path from any vertex, let us call it n, to the vertex 0. We assume that .
For each edge, label it with the sum of its two endpoints. Thus, we obtain an edge-labeled graph (the labels are powers of two). As the path from n to 0 is traversed, the labels of its edges strictly decrease. The walks with strictly decreasing labels from n to 0 are exactly the paths from n to 0 (that happen to be unique).
This is not true in . There is a second walk from n to 0 with strictly decreasing edge labels, a walk where the penultimate step is a loop.
The above graph theoretic remark and the alternating binary number system are closely related. The next theorem formalizes this.
Theorem 5. Let n be a positive integer. Let be the set of walks in with strictly decreasing edge labels. Let be the set of alternating binary representations of n.
Then, there is a bijection between and .
Remember that is almost the same as the graph (a tree), except there are additional loops at the neighbors of 0. Hence, consists of two walks: the unique path P in , and a walk that is the same as P, except that just before reaching 0 we go along a loop. The bijection, presented below, proves that also has two elements, which is the statement of Theorem 2. We can consider Corollary 1 as the graph theoretical analog of Theorem 2.
Proof. Let be an arbitrary alternating binary representation of n (an element of ). We introduce the following numbers: , , , , …, 0. These numbers: , , , …, , are vertices in , and they form a sequence of vertices of walk from n to 0. The labels of the edges are .
Conversely, let us take a walk from n to 0 in (an element of ). Let be the sequence of its nodes. is an element of , where s is a sign depending on the parity of ℓ.
The two mappings are inverses of each other; hence, they prove the theorem. □
We recall that after obtaining the two walks in we can agree on a condition that makes the route unique. These conditions can be based on the ending of the walk or on parity of the length. At the end of the previous section, we fixed condition (c) in Theorem 3 and gave examples for the concrete representation of small numbers. It is easy to check that condition (c) corresponds to the agreement that the representation is based on the path in the tree .
4. Graphs Related to Fibonacci Numbers and the
Related Numeral System
In this chapter, we apply the previously introduced graph theory technique. The positional values of the binary system are the powers of two. Now, we start with the Zeckendorff numeral system [
25,
26,
27,
28]. Its positional values are the Fibonacci numbers.
Denote by
the Fibonacci sequence ([
29] A000045) defined as
(
) with
and
. We refer to
as the Fibonacci numbers. So, when we mention Fibonacci numbers, we mean elements of the Fibonacci sequence with indices at least 2.
In analogy to the previously introduced graph, we define a new graph.
Definition 2. Our graph has a vertex set consisting of natural numbers. We connect vertices u and v if is a Fibonacci number.
Specifically, 0 is adjacent to exactly the Fibonacci numbers.
In the graph , there will be loops. First, note that every third Fibonacci number is even. For the sake of completeness, we acknowledge this commonly known fact.
Lemma 2. (for ) is even if and only if n is divisible by 3.
Proof. . We prove by induction that for every positive integer k, is even, and and are odd. For the base case , this is known.
We assume that for the claim is true: is even, and and are odd. We need to prove that is even, and and are odd. This is straightforward from , , and . □
If , then . Thus, forms an edge in , creating a loop.
The graph is not a tree, not only because of the loop edges but also because it contains many 4-cycles.
Lemma 3. If are non-negative integers such that , , and , then . Specifically, form the vertices of a 4-cycle.
Proof. We only need to check that
will be a Fibonacci number with the right index.
Thus, the statement is obvious. □
Definition 3. Let be a positive integer. Define , , . The cycle in the graph F is formed by the edges , , , and .
Note that the cycles and are the same; only the roles of u and v are exchanged.
Lemma 4. The points of the cycle (, , , ) are connected by only one additional edge beside the edges of the cycle: . If u is a positive integer that is not a Fibonacci number, then among the points of , only the edges of the cycle are present.
Proof. The points of the cycle are: , , , . is obviously an edge since is a Fibonacci number. and v may be connected. Because , their sum lies between two consecutive Fibonacci numbers, meaning it cannot be a Fibonacci number.
Let
a be a positive integer:
. The points of the
cycle are:
,
,
,
. Assume that
is an edge of
. Then,
is a Fibonacci number
furthermore,
Therefore,
can only take one value as a Fibonacci number:
. This value cannot be the label on this edge because it corresponds to the label of the uu’ edge (and the vv’ edge too). Hence,
cannot be an edge. By the symmetry of
u and
v, we obtain that
is not an edge either. □
It will be shown that these cycles, along with the loop edges, are the essential cycles in F. Therefore, it is not difficult to sparsify the F graph to obtain a tree. This is in spite of the fact that some of the 4-cycles share a common edge; hence, they form longer cycles in .
Definition 4. Let be the graph obtained from by removing the edges connecting 0 to Fibonacci numbers with odd indices, the loop edges, and the edges of the 4-cycles .
Theorem 6. is a tree.
The theorem points out a spanning tree of : .
Proof. Let be the spanning subgraph of formed by the vertices and the edges between them. It is sufficient to show that for any n, this graph is cycle-free and connected.
For small values of
n, it is easy to verify the statement. See
on
Figure 2.
By induction, we prove that is a tree. Assume that we know this for . We add the vertices to it and check that our graph remains a tree. We do this by proving that by adding any of these numbers it will be connected to exactly one earlier (smaller) node.
In the case of , this is true. In , there are two earlier neighbors of it: 0, and . If is even, then 0 is connected to , but is the deleted edge of in . If is odd, then is a deleted edge, but is a remaining edge of in .
The same logic works in the case of , where . In , there are two earlier neighbors of it: , and . The two connecting edges are in two 4-cycles. In one of them, the edge is deleted; in the other, it is not deleted. has exactly one earlier neighbor in . □
As previously, we can label the edges. The label of an edge will be the sum of the numbers corresponding to its endpoints. The labels are Fibonacci numbers.
Lemma 5. Consider as a graph with labeled edges. In this case, the edge labeling possesses the following two properties:
- (a)
The edges incident to 0 have labels that are even-indexed Fibonacci numbers.
- (b)
The labels of two adjacent (sharing a common endpoint) edges cannot correspond to Fibonacci numbers with consecutive indices.
Proof. The labeling can also be introduced for the edges of graph . It is worth noting that both statements are false in . In , both statements become true due to the definition of , which is a result of sparsifying .
In , all Fibonacci numbers appear on edges incident to 0. In the definition of , we precisely excluded those edges whose labels correspond to odd-indexed Fibonacci numbers. This yields statement (a).
Let us consider two adjacent edges in with label Fibonacci numbers that correspond to consecutive indices. Suppose these two edges are and with labels and . Then, due to the cycle, the edge is not present in . This confirms statement (b). □
The claim of this lemma and the fact that is a tree leads to a new numeral system. The logic is the same: we have a tree defined on the set of natural numbers. From a vertex n, there is unique path to 0. This path can be converted to a representation of n. The existence and uniqueness follow from graph theory.
Theorem 7 (Fibonacci-alternating representation).
Every natural number n can be written uniquely as a sumwith , where denotes (i.e., ); furthermore, is even. This sum is called the alternating representation of n. The proof of Theorem 7 is based on Theorem 6.
Proof. Any natural number n can be considered as a vertex in . There is a unique path in . Let be the sequence of its nodes. , where s is a sign depending on the parity of ℓ. The values of the expressions in the brackets are Fibonacci numbers. We obtain the existence of the presentation.
For the uniqueness, assume that we have two representations of n. Both of them can be interpreted as the path in (see the proof of the binary case). Since is a tree, we obtain a contradiction that proves the theorem. □
As previously, we can extend this representation to integers. We give a few examples of this new representation that we denote by
indices:
The new numeral system is based on a spanning tree of . The graph has many cycles. Finding a spanning tree of it is not natural. There are several ways to construct one.
It is possible to describe a different spanning tree and introduce a new numeral system with Fibonacci numbers as place-values. Such numeral systems already exist; for example, see [
30,
31] for considered numeral systems. The connection between them and graph theory has not been explored so far.
5. Conclusions
The representations we described are very simple (one can say beautiful). Our results may inspire new research. The new number system raises many questions. How can basic operations be performed with numbers based on the new representation? How can numbers in the conventional notation be converted to the new one? What is the complexity of our algorithms? These questions have led to numerous results in the case of previous number systems (see [
16,
32,
33,
34,
35,
36,
37]).
A new number system stimulates new research. The Zeckendorf number system is a good example [
25]. After the introduction of that number system, research in several directions was initiated. The distribution of digits and algorithms for arithmetic were studied [
38]. Later versions with negative digits [
30,
31,
39] were developed. Many other areas of mathematics were connected to these notions. We mention only one, the research of automatic sequences.
The graph
in the last section is also natural; the proof of the fact that
is a tree is simple. Finally, I found some hints to this claim in the literature. The graph
arises naturally when one considers “Problems with Powers of Two”, the problem introduced by B. Haran and N.J.A. Sloane [
40]. In the Online Encyclopedia of Integer Sequences (QEIS), T. Scheuerle makes a comment to A352178 [
41]. He is probably formulating this claim.
After stating the theorems on representing integers, the uniqueness and existence of the state representation can be easily proven through elementary means, much like we did with the binary system. There are automated proofs as well. However, the essence of everything lies in stating the theorem; this is where mathematics begins.
Our article highlights that graphs can be defined in various ways from numbers. Often, a spanning tree for these graphs can be naturally identified. This tree can be viewed as a tree rooted at 0. Each vertex/natural number has a unique path leading to 0. This corresponds to a number-theoretic representation of n. The recognition of this relationship between graph theory and number systems seems entirely novel.