Existence of Base-N Representation

Theorem
Given a number $$x \in \left[{0 \,. \, . \ 1}\right) \ $$, there exists a representation of that number in a base-$p$ positional system.

Specifically, there exists a series $$\left \langle{a_n}\right \rangle$$ such that:


 * $$0 \le a_n < p \ $$, and


 * $$\sum_{n=1}^\infty \frac{a_n} {p^n} \ $$ converges to $x \ $.

Unless the series terminates (i.e. $$a_n = 0 \ $$ for all sufficiently large $$n \ $$), then this representation is unique.

If the series does terminate, then there is exactly one other series which satisfies the criteria of the theorem.

Existence of Representation
Define $$a_j = \left \lfloor{\left({ x-\sum_{i=1}^{j-1} \frac{a_i}{p^i} }\right) p^j} \right \rfloor \ $$, where we accept the abuse of notation $$\sum_{i=1}^0 a_ip^{-i} =0 \ $$. This recursive definition allows for all $$a_n \ $$ to be computed.


 * Lemma: This will always be less than $$p \ $$.


 * Proof: Suppose to the contrary $$\exists n \ $$ such that $$a_n\geq p \ $$. Then


 * $$a_n = \lfloor \left({ x-\sum_{i=1}^{n-1} \frac{a_i}{p^i} }\right) p^n \rfloor \geq p \ $$


 * But then we can pull out the final term of the sum and divide by p to get


 * $$\left({ x-\sum_{i=1}^{n-2} \frac{a_i}{p^i} }\right) p^{n-1} \geq 1+a_{n-1} \ $$


 * This left-hand side is of course just


 * $$a_{n-1}+\text{something in} \ [0,1) \geq 1+a_{n-1} \ $$


 * which is impossible.

Define $$s_n = \sum_{i=1}^n a_ip^{-i} \ $$. Since both $$a_i,p^{-i}>0 \ \forall i \ $$, this series is increasing, and bounded above by $$x \ $$ by construction: at every point in the series, we add precisely as many $$p^{-n-1} \ $$ as will fit in $$x-s_n \ $$ without going over $$x \ $$:
 * Lemma: $$s_n\leq x \forall n \ $$
 * Proof: We have $$s_1=a_1p^{-1}=\lfloor xp \rfloor p^{-1}\leq xpp^{-1}=x \ $$. Suppose we have $$s_j<x \ $$ for some j.  By definition,  $$s_{j+1}-s_j=a_{j+1}p^{-1-j} \ $$.  But $$a_{j+1}p^{-1-j} = \lfloor (x-s_j)p^{1+j}  \rfloor p^{-1-j} \leq (x-s_j) $$.  So $$s_{j+1}-s_j\leq x-s_j \implies s_{j+1}\leq x \ $$.  Now suppose we have instead $$s_j=x \ $$.  Again we have $$s_{j+1}-s_j=a_{j+1}p^{-1-j} \ $$, but now $$a_{j+1}p^{-1-j} = \lfloor (x-s_j)p^{1+j}  \rfloor p^{-1-j} = 0 \implies s_{j+1}=s_j=x \ $$.  This completes the induction proof.

It remains to be shown this series converges to x. Observe that in the sum $$s_{k-1}+a_kp^{-k}=s_k \ $$, we have defined $$a_k =\lfloor \left({ x-\sum_{i=1}^{k-1} \frac{a_i}{p^i} }\right) p^k \rfloor\ $$ to count precisely how many $$p^{-k} \ $$ will fit in $$x-s_{k-1} \ $$. We could never have $$x-s_k \geq p^{-k} \ $$ because that would mean $$a_k \ $$ had undercounted by 1.

Therefore, $$x-s_k < p^{-k}\ $$.

Let $$\epsilon >0 \ $$. Then setting $$z=-\log_p \epsilon \ $$. Then if $$N>z, \ x-s_N<p^{-N}<p^{\log_p} \epsilon = \epsilon \ $$. Since $$\left\{{s_k }\right\} \ $$ is increasing, bounded above by $$x \ $$, and comes arbitrarily close to x, we have $$\left\{{s_n}\right\} \to x \ $$.

Uniqueness of Representation
Let $$\left\{{a_n}\right\} \ $$ be the series defined in a, and let $$b_n \ $$ be some series of integers $$0\leq b_na_m \or b_ma_m \ $$, then $$s_{m-1}+b_mp^{-m}=t_{m-1}+b_mp^{-m}=t_m >x \ $$, and since $$\left\{{t_n}\right\} \ $$ is always increasing, it can never converge to $$x \ $$.

Now consider the second case, $$b_m<a_m \ $$. First, we will need a lemma:


 * Lemma: $$( \exists N : \forall n\geq N, \ a_n=0) \iff (x=qp^{1-N} ) \ $$
 * Proof:
 * ($$\Rightarrow$$)
 * Suppose $$\exists N : \forall n\geq N, \ a_n=0 \ $$. Then $$x=\sum_{n=1}^\infty a_np^{-n} = \sum_{n=1}^{N-1} a_np^{-n}$$.  But $$a_np^{-n} = a_np^{N-1-n} p^{1-N} \ $$. Since $$x \ $$ is a sum of these terms of $$p^{N-1} \ $$, we must have $$x=qp^{N-1} \ $$ for some $$q\in\N \ $$.
 * ($$\Leftarrow$$)
 * Suppose $$x=qp^{1-N}$$. Observe that since $$p^{1-N}|s_{N-1} \ $$, we must have $$s_{N-1}=x \ $$.  Since $$\left\{{s_n}\right\} \to x \ $$ and is strictly increasing, we must have all successive terms equal to zero.

Now suppose that $$x=qp^{-k} \ $$ for some k. We wish to show that there are only two series which converge to x; the series $$\left\{{a_n }\right\} \ $$ as defined above, and another series we describe now.

Consider the series $$\left\{{a_n }\right\} \ $$ when $$x=qp^{-k} \ $$.

Now we define:
 * $$b_n = \begin{cases}

a_n & : n < k \\ a_n-1 & : n = k \\ p-1 & : n > k \end{cases} $$

Then we see that $$\sum_{j=1}^\infty b_jp^{-j} = \left({ \sum_{j=1}^{k-1} b_jp^{-j} }\right) + (a_k-1)p^{-k} + \sum_{j=k+1}^\infty (p-1)p^{-j} \ $$

$$= \left({ \sum_{j=1}^{k-1} a_jp^{-j} }\right) + a_kp^{-k}-p^{-k} + \sum_{j=k+1}^\infty (p-1)p^{-j} = \left({ \sum_{j=1}^{k} a_jp^{-j} }\right) - p^{-k} + \sum_{j=k+1}^\infty (p^{1-j}-p^{-j}) \ $$

$$=x-p^{-k} + \sum_{j=k+1}^\infty (p^{1-j}-p^{-j})=x-p^{-k} +p^{-k}\sum_{j=0} \left({ p^{-j}}\right) - p^{-k-1}\sum_{j=0} \left({ p^{-j} }\right) \ $$

$$=x-p^{-k} +p^{-k} \left({ \frac{1}{1-p^{-1}} }\right) - p^{-k-1}\left({ \frac{1}{1-p^{-1}} }\right) = x-p^{-k}+\frac{p^{-k}-p^{-k-1}}{1-p^{-1}} = x-p^{-k}+p^{-k}\frac{1-p^{-1}}{1-p^{-1}}=x $$

So, this series converges to $$x \ $$ as well.

Let us suppose, finally, that $$x\neq qp^{-k} \ $$ for any k. We have already shown that if the first differing term of another series $$b_n \ $$ is greater than the corresponding term $$a_n \ $$, the sum series cannot converge to x. Now we examine the case $$b_m < a_m \ $$ at the first differing term. As we saw above, if the first term to differ is only one less, ie, $$b_m = a_m-1 \ $$, then it is necessary for every other term afterwards to be increased from $$0 \ $$ to $$p-1 \ $$ in order to make up for this deficit. The remaining terms of course, cannot be increased more than this, or they would violate the condition that all terms be less than $$p \ $$. Since in the case $$x\neq qp^{-k} \ $$, there are no infinite strings of zeroes, we cannot decrease any one term and increase the succeeding terms by $$p-1 \ $$.

Also see

 * Basis Expansion