Real Numbers are Uncountably Infinite/Cantor's Diagonal Argument

Theorem
The set of real numbers $\R$ is uncountably infinite.

Proof
We show that the unit interval $\left[{0 \,.\,.\, 1}\right)$ is uncountable, from which uncountability of $\R$ follows immediately.

Aiming for a contradiction, suppose that $\left[{0 \,.\,.\, 1}\right)$ is countable.

Clearly $\left[{0 \,.\,.\, 1}\right)$ is not finite because $\displaystyle \frac 1 n \in \left[{0 \,.\,.\, 1}\right)$ are distinct for all $n \in \N$.

Therefore an injection $\left[{0 \,.\,.\, 1}\right) \hookrightarrow \N$ enumerates $\left[{0 \,.\,.\, 1}\right)$ with a subset of the natural numbers.

By relabeling, we can associate each $x \in \left[{0 \,.\,.\, 1}\right)$ to exactly one natural number to obtain a bijection.

(By hypothesis, such a mapping can be constructed).

Let $g$ be such a correspondence:

where juxtaposition of digits describes the decimal expansion of a number.

By Existence of Base-$N$ Representation, any decimal expansion of a real number exists and is unique, or else has exactly two representative strings.

In this case, if there are exactly two representations, one will have an infinite trail of $9$s, and one will terminate.

Restrict $g$ such that there exists no infinite strings of $9$s in the decimal expansions in the question, i.e. to the set:


 * $S := \left\{{f: \N \to \left\{{0, 1, 2, \ldots, 9}\right\} }\middle\vert\,{ \forall M \in \N: \exists m \ge M: f \left({m}\right)\ne 9}\right\}$

of sequences in $\left\{{0, 1, 2, \ldots, 9}\right\}$ not ending in infinitely many $9$s.

Define $g'$ as the restriction of $g$ to $S$:


 * $g' := g \restriction S$

That is, construct $g'$ such that there exist no infinite strings of $9$s in the decimal expansions in question.

From Injection to Image is Bijection, $g'$ is one-to-one, and consequently is onto.

For every $k \in \N$ define $f_k = d_{kk} + 1$ taken modulo $10$.

That is, $f: 0 \mapsto 1, 1 \mapsto 2, \dots, 8 \mapsto 9, 9 \mapsto 0$.

Let $y$ be defined by the decimal expansion:


 * $y = 0.f_1 f_2 f_3 \ldots$

Now:
 * $y$ differs from $g' \left({1}\right)$ in the first digit of the decimal expansion
 * $y$ differs from $g' \left({2}\right)$ the second digit of the decimal expansion

and generally the $n^\text{th}$ digit of the decimal expansion of $g' \left({n}\right)$ and $y$ is different.

So $y$ can be none of the numbers $g' \left({n}\right)$ for $n \in \N$.

But $g'$ is a surjection.

From this contradiction it is deduced that $\left[{0 \,.\,.\, 1}\right)$ is not countable.

Historical Note
This proof was first demonstrated by.