Apparent inconsistency of Lebesgue measure

"As the rationals are dense in $\mathbb{R}$ we must have $\mathbb{R}\subset \bigcup_{n=1}^\infty I_n$."

This is false. Pick your favorite irrational number $x$. For every $n$, there exist infinitely many rationals $q_m$ such that $q_m$ is within $a_n/2$ of $x$. But the least such $m$ may be much larger than $n$. In particular, it does not follow that there exists some $n$ such that $x$ is within $a_n/2$ of $q_n$, which is what is necessary to have $x\in \bigcup_{n=1}^\infty I_n$.


One can explicitly demonstrate the failure of the argument for $\mathbb R_+$. Generalize to $\mathbb R$ as needed.

Consider the following maps $f:\mathbb N_+^2 \rightarrow \mathbb N_+$ and $g: \mathbb N_+^2 \rightarrow \mathbb Q_+$ \begin{eqnarray} f(\{k,m\}) &=& (k + m - 2 )(k + m - 1) + m \\ g(\{k,m\}) &=& k/m. \end{eqnarray} You can verify that $f$ is a bijection and $g$ is onto, and thus $h(n) = g(f^{-1}(n))$ maps from $\mathbb N_+$ onto a dense subset of $\mathbb R_+$. Now consider the set $$ U = \bigcup_{n=1}^\infty \left(h(n) - \frac{a_n}{2},h(n) + \frac{a_n}{2}\right). $$ Using the sequence $\{a_n = n^{-2}\}_{n=1}^\infty$, I can prove $\phi = (1+\sqrt{5})/2\notin U$.

First, note that $h$ orders the ratios $k/m$ first by increasing $k+m$, then by increasing $m$. Because of this, if $h(n)$ is a continued fraction convergent of $\phi$, then $|h(n') - \phi| > |h(n) - \phi|$ for all $n' < n$. The continued fraction convergents of $\phi$ are of the form $F_{i+1}/F_i$, where $F_i$ are Fibonnaci numbers, and occur when $n_i = (F_{i+1} + F_{i} - 2)(F_{i+1} + F_{i} - 1)/2 + F_{i}\ge F_{i}F_{i+1}$. One can prove from the Fibonacci formula that the error on these convergents is always larger than $0.4F_{i}^2$.

Now consider $n_i \le n < n_{i+1}$. Then we have $a_n = n^{-2} \le n_i^{-2}\le F_{i}^{-2}F_{i+1}^{-2}$ and $|h(n) - \phi| > |h(n_{i+1})-\phi| > 0.4 F_{i+1}^{-2}$. If $\phi\in U$, there must be an $n$ with $|h(n) - \phi| < a_n/2$ for some $n$. This would then imply $0.4 < F_{i}^{-2}/2$, which can only be satisfied for $F_i = 1$. Thus such an $n$ would have to satisfy $n < n_3 = 8$. Since it can be checked that none of these works, $\phi \notin U$.


(Extended from a comment) Recall that a subset $\mathcal{D}$ of $\mathbb{R}$ is called dense if its closure $\bar{\mathcal{D}}$ is all of $\mathbb{R}$. From this definition, you can readily check that the followings are equivalent for dense subsets $\mathcal{D} \subset \mathbb{R}$:

$$ \text{$\mathcal{D}$ is closed in $\mathbb{R}$} \qquad \Leftrightarrow \qquad \text{$\mathcal{D} = \mathbb{R}$}. $$

In particular, you can't tell much how porous your set $\mathcal{D}$ will be only by knowing the density of $\mathcal{D}$. There are lots of dense subsets of $\mathbb{R}$ which is not closed (and hence not all of $\mathbb{R})$.

Example. If we pick a sequence $(r_n)_{n=1}^{\infty}$ of positive numbers satisfying $\sum_{n=1}^{\infty} r_n < \infty$, then

$$ U = \bigcup_{n=1}^{\infty} (q_n - r_n, q_n + r_n)$$

is an open set such that $\mathbb{Q} \subset U$ but $\operatorname{Leb}(U) \leq \sum_{n=1}^{\infty} 2r_n < \infty$. So there are open dense subsets of $\mathbb{R}$ with finite length. Notice also that $\operatorname{Leb}(U)$ can be made arbitrarily small by choosing suitable $(r_n)$. Another interesting feature of this example is that the boundary $\partial U$ has infinite length! In this way, you may think of $U$ as tiny pores of a highly porous material, such as a sponge.