# The set of finite unions of intervals with rational endpoints is countable.

I don't know how to prove the following:

Let

$K:=\lbrace G : G$ is a union of finitely many intervals with rational endpoints$\rbrace$.

Prove that $K$ is countably infinite.

Here is my approach:

The set of intervals with rational endpoints is countably infinite as there is a bijection between this set and $\mathbb{Q}\times \mathbb{Q}$. However, I don't know how to continue.

• How about the set $K_n$ that consists of unions of $n$ disjoint intervals with rational endpoints? And how about $\bigcup_n K_n$? – gniourf_gniourf Feb 14 '16 at 18:25
• Imagine we have enumerated the intervals (we probably need to include the four kinds of interval). Let $I_1,I_2,\dots$ be an enumeration. Then we can enumerate the set of finite sequences of intervals. For any finite sequence of natural numbers $a_1,a_2,\dots,a_k$ can be mapped to $p_1^{a_1}\cdots p_k^{a_k}$, where the $p_i$ are the primes in increasing order. – André Nicolas Feb 14 '16 at 18:30
Hint. Let $E$ be the set of intervals with rational endpoints. You already proved it is a countably infinite set. You need now to prove that the set $U$ of finite unions of elements of $E$ is also countably infinite. Clearly $U = \bigcup_{n \geq 0} U_n$, where $U_n$ is the set of union of $n$ elements of $E$. Since a countable union of countable sets is countable, it remains to show that each set $U_n$ is countable. Can you prove that last part?
• Can I use this with a fixed $n$ and use the fact that there is an injection between $U_n$ and the set of the link (whit $n$ fixed)? – Who knows Feb 14 '16 at 19:30