# Leigh.Samphier/Sandbox/Canonical P-adic Expansion of Rational is Eventually Periodic/Necessary Condition

## Theorem

Let $\struct {\Q_p, \norm {\,\cdot\,}_p}$ be the $p$-adic numbers for some prime $p$.

Let $x$ be a rational number.

Then:

the canonical expansion of $x$ is eventually periodic

## Proof 1

$\blacksquare$

## Proof 2

Let $x$ be a rational number.

Let $\ldots d_n \ldots d_2 d_1 d_0 . d_{-1} d_{-2} \ldots d_{-m}$ be the canonical expansion of $x$.

It is sufficient to show that the canonical expansion $\ldots d_n \ldots d_2 d_1 d_0$ is eventually periodic.

Let $y$ be the $p$-adic number with canonical expansion:

$\ldots d_n \ldots d_2 d_1 d_0$

We have:

$y = x - \ds \sum_{i \mathop = -m}^{-1} d_i p^i$

So:

$y$ is a rational number

By definition of $p$-adic integer:

$y$ is a $p$-adic integer

Let:

$y = \dfrac a b : a \in \Z, b \in Z_{> 0}$ are coprime
$p \nmid b$
$b, p$ are coprime

### Lemma 1

$\forall n \in \N: \exists A_n, r_n \in \Z$ :
$(1) \quad \dfrac a b = A_n + p^{n+1} \dfrac {r_n} b$
$(2) \quad 0 \le A_n \le p^{n+1} - 1$
$(3) \quad \dfrac {a - \paren{p^{n+1} - 1} b } {p^{n+1}} \le r_n \le \dfrac a {p^{n+1}}$

$\Box$

### Lemma 2

$\exists n_0 \in \N : \forall n \ge n_0 : -b \le r_n \le 0$

$\Box$

### Lemma 3

$\ds \lim_{n \mathop \to \infty} A_n = \dfrac a b$

$\Box$

### Lemma 4

$\forall n \in \N: r_n = d_n b + p r_{n+1}$

$\Box$

### Lemma 5

$\exists \mathop m, l \in \N : \forall n \ge m: r_n = r_{n + l}$ and $d_n = d_{n + l}$

$\Box$

It follows that $\ldots d_n \ldots d_2 d_1 d_0$ is eventually periodic.

$\blacksquare$