The set of rational numbers is countable

https://arbital.com/p/rationals_are_countable

by Patrick Stevens Jul 3 2016

Although there are "lots and lots" of rational numbers, there are still only countably many of them.


The set Q of rational numbers is countable: that is, there is a bijection between Q and the set N of natural numbers.

Proof

By the Schröder-Bernstein theorem, it is enough to find an injection NQ and an injection QN.

The former is easy, because N is a subset of Q so the identity injection nn1 works.

For the latter, we may define a function QN as follows. Take any rational in its lowest terms, as pq, say. %%note:That is, the GCD of the numerator p and denominator q is 1.%% At most one of p and q is negative (if both are negative, we may just cancel 1 from the top and bottom of the fraction); by multiplying by 11 if necessary, assume without loss of generality that q is positive. If p=0 then take q=1.

Define s to be 1 if p is positive, and 2 if p is negative.

Then produce the natural number 2p3q5s.

The function f:pq2p3q5s is injective, because prime factorisations are unique so if f(pq)=f(ab) (with both fractions in their lowest terms, and q positive) then |p|=|a|,q=b and the sign of p is equal to the sign of a. Hence the two fractions were the same after all.