Counting the Real ($\mathbb{R}$) numbers [duplicate]

Real numbers are proved to be uncountable so there should be no way to count them.

Having said that, I would still like to try to present a method for counting them. First I'll count the non-negative Real numbers and then I'll generalize that to all the Real numbers.

For easier presentation I'll use binary numeral system, but the same can be applied to any numeral system.

Let's map all the non-negative Real numbers to a table where the number's integer part represents the row and the reversed fractional part represents the column:

int\rev frac 0 1 10 11
0 0.0 0.1 0.01 0.11
1 1.0 1.1 1.01 1.11
10 10.0 10.1 10.01 10.11
11 11.0 11.1 11.01 11.11

For example $1.01$ maps to row $1$ and column $10$. We need to reverse (read backwards) the fractional part because otherwise $.01$ would map to the same column as $.1$. With digit reversal we guarantee that we get unique colums for same fractional parts.

Having done that we can now enumerate all the non-negative Real numbers by diagonally counting them:

i\f 0 1 10 11
0 0 1 3 6
1 2 4 7 ...
10 5 8 ... ...
11 9 ... ... ...

We can transform this to a function that maps from non-negative Reals ($\mathbb{R}$) to Natural ($\mathbb{N}_0$) numbers:

$$ f(x) = (\sum_{n=1}^{i} {n+1}) + (\sum_{m=1}^{f} m+i) $$

where $i$ is the integer part and $f$ is the reversed fractional part of Real number $x$.

For example number $11.0010001111_2$ ($\approx3.14_{10}$ in binary) would be enumerated as the $468031_{10}$th non-negative binary Real number.

We can generalize this to all the Real numbers by adding the "negative" rows to the table and alternating diagonal counting to the positive end negative sides:

i\f 0 1 10 11
-11 19 ... ... ...
-10 11 17 ... ...
-1 5 9 15 ...
-0 1 3 7 13
0 0 2 6 12
1 4 8 14 ...
10 10 16 ... ...
11 18 ... ... ...

For example $-0.01$ maps to row $-0$ and column $10$ so it is enumerated as $7$.

This transforms to a function:

$$ f(x) = \begin{cases} 2((\sum_{n=1}^{i} {n+1}) + (\sum_{m=1}^{f} m+i)), & \text{if } 0 \leq i \\ 2((\sum_{n=1}^{-i} {n+1}) + (\sum_{m=1}^{f} m+(-i))) + 1, & \text{otherwise} \end{cases} $$

Here the number $11.0010001111_2$ ($\approx3.14_{10}$ in binary) would be enumerated as the $936062_{10}$th binary Real number.

In decimal system the $3.14$ would be enumerated as the $312$th decimal Real number.

There is a little problem that this method counts $0.0$ twice (as $0.0$ and $-0.0$). To fix this we remove the $0.0_2$ to $0_{10}$ enumeration and let $0.0_2$ be enumerated as $1_{10}$. Therefore we now map from $\mathbb{R}$ to $\mathbb{N}$ (and not $\mathbb{N}_0$).

By using the presented method we can enumerate $\mathbb{R}$ and have a bijection between $\mathbb{R}$ and $\mathbb{N}$.

But this would mean that $\mathbb{R}$ is countable which, as far as I know, is proven (by different methods) that it is not. So my question is, what is wrong with the enumeration method presented here and/or with my understanding of countability? :)


Solution 1:

Very early on in your construction, you say:

and the reversed fractional part represents the column

You did not define what "the reversed fractional part" of a real number is. Without defining this term, your mapping is not really defined, so it is impossible to tell why it does not surjectively map $\mathbb N$ to $\mathbb R$.


In fact, as far as I see from your post, the first table that you write only contains numbers that have a finite binary representation. So, the table contains numbers such as $0.1, 0.001, 0.101101001001$, but it does not contain numbers with an infinite binary representation, so numbers such as $\frac13$. Therefore, what you have constructed is the inverse of a mapping from $\mathbb N$ to a subset of the set of all rational numbers $\mathbb Q$.

In other words, the domain of your mapping is a subset of $\mathbb Q$, and as such, it is no surprise it is countable.