User:Dionyziz/Countable rationals

Let us prove that the set of positive rational numbers Q+ is countable:

$$\mathbb{Q^+} \sim \mathbb{N}$$

All we need to do is prove that there exists a bijection:

$$\exists q: \mathbb{Q^+} \mapsto \mathbb{N}$$

Let:

$$g: \mathbb{N} \mapsto \mathbb{Q^+}: g( x ) = x$$

Then g is an injection.

Let:

$$f: \mathbb{Q^+} \mapsto \mathbb{N}: f( x / y ) = f( v / w ) = (w_{th} prime)^v$$

Where w and v are coprimes (as every x / y can be written as v / w; thanks cmad)

Then f is an injection (by unique prime factorization).

Because f and g are injections from Q+ to N and from N to Q+ respectively, there exists a bijection from Q+ to N (by the Cantor–Bernstein–Schroeder theorem).

Hence, Q+ is countable. QED

Using the same logic, the set Q-* of non-positive rationals is also countable (if we use f(0) = 0 as a special case).

Hence, the union set of rationals is also countable:

$$\mathbb{Q} = \mathbb{Q^+} \cup \mathbb{Q^-*}$$