---
title: Intervals, Uncountability, and Decimals
module: Foundations and the Real Number System
moduleNumber: 1
lessonNumber: 4
order: 104
summary: >
  Intervals are classified, and ℝ is proved uncountable two ways: a nested-interval
  construction and the decimal diagonal argument. Decimal expansions are built as
  suprema of truncations, which pins the source of their non-uniqueness (the
  0.4999… equals 0.5000… identity) and the identification of the rationals with the
  eventually-repeating expansions. The middle-thirds Cantor set is an uncountable set
  of measure zero.
topics: [Foundations and the Real Number System]
sources:
  - book: Lebl
    ref: "Ch. 1 — Real Numbers; §1.4 Intervals and the size of ℝ; §1.5 Decimal representation of the reals"
draft: false
---

The rationals and the reals are both infinite and both dense, yet they are not the same size:
$\mathbb{Q}$ is countable and $\mathbb{R}$ is not. Two independent proofs establish that
$\mathbb{R}$ is uncountable, and decimal expansions, built as suprema of finite truncations,
account for both why $0.4999\ldots = 0.5000\ldots$ and why the rationals are precisely the
eventually-repeating expansions. The
[power-set diagonal argument](/real-analysis/foundations/sets-logic-functions) reappears,
applied to the digits of real numbers.

## Intervals

For $a < b$ in $\mathbb{R}$, the four **bounded intervals** are

$$
[a,b] = \{x : a \le x \le b\}, \quad (a,b) = \{x : a < x < b\},
$$
$$
(a,b] = \{x : a < x \le b\}, \quad [a,b) = \{x : a \le x < b\},
$$

with $[a,b]$ **closed**, $(a,b)$ **open**, and the mixed forms **half-open**. Allowing an
endpoint to be $\pm\infty$ gives the **unbounded intervals** $[a,\infty)$, $(a,\infty)$,
$(-\infty,b]$, $(-\infty,b)$, and $(-\infty,\infty) = \mathbb{R}$. What unifies all nine types
is a single order property: an interval is a set with at least two points that contains
everything between any two of its members.[^lebl-14]

> **Proposition (Characterization of intervals).** A set $I \subset \mathbb{R}$ is an interval
> if and only if it has at least two points and, whenever $a, c \in I$ and $a < b < c$, also
> $b \in I$.

This "no gaps" description is what makes intervals the right domains for the intermediate value
theorem later on: a [connected](/real-analysis/metric-spaces/connectedness) piece of the line
and an interval are the same thing.

All intervals have the same cardinality, regardless of length. The map $x \mapsto 2x$ is a
bijection $[0,1] \to [0,2]$, and $x \mapsto
\tan x$ is a bijection $(-\pi/2, \pi/2) \to \mathbb{R}$. So a bounded open interval has the same
cardinality as the entire real line. Cardinality does not detect length, the property that
distinguishes $[0,1]$ from $[0,2]$; measuring length requires a different theory, developed
much later.

## ℝ is uncountable: nested intervals

The rationals are countable — they can be [listed](/real-analysis/foundations/sets-logic-functions).
The reals cannot, and the first proof is Cantor's original argument of 1874. It is cleanest
stated as a direct construction: any countable subset of $\mathbb{R}$
that is dense must still miss a point.[^lebl-14]

> **Theorem (Cantor).** $\mathbb{R}$ is uncountable.

> **Proof.** Let $X = \{x_1, x_2, x_3, \dots\}$ be any countable subset of $\mathbb{R}$ dense
> enough that every open interval meets it. (If $\mathbb{R}$ were countable we could take
> $X = \mathbb{R}$.) Build two sequences of endpoints. Set $a_1 = x_1$, $b_1 = x_1 + 1$, so
> $x_1 \notin (a_1, b_1)$. Having chosen $a_{k-1} < b_{k-1}$, let $a_k = x_n$ for the smallest $n$
> with $x_n \in (a_{k-1}, b_{k-1})$, and let $b_k = \frac{a_k + b_{k-1}}{2}$. Then
>
> $$
> a_{k-1} < a_k < b_k < b_{k-1}, \qquad x_1, \dots, x_k \notin (a_k, b_k).
> $$
>
> The nested open intervals $(a_1, b_1) \supset (a_2, b_2) \supset \cdots$ each exclude one more
> term of the list. Every $a_n$ is below every $b_m$, so by the
> [separated-sets proposition](/real-analysis/foundations/ordered-fields-completeness)
> $y := \sup\{a_n\}$ exists and satisfies $a_n < y < b_n$ for all $n$. Thus $y \in (a_n, b_n)$
> while $x_n \notin (a_n, b_n)$, forcing $y \ne x_n$ for every $n$. So $y \notin X$, and $X$
> misses a real. No list exhausts $\mathbb{R}$. $\blacksquare$

The argument rests on the fact that a decreasing chain of closed intervals in $\mathbb{R}$
always has a common point (a direct consequence of completeness), whereas in $\mathbb{Q}$ such
a chain can close in on a gap and meet nowhere. This **nested interval property** is a recurring
form of completeness, equivalent to the least-upper-bound axiom.

$$
% caption: A decreasing chain of closed intervals in the complete line always shares
% a single common point; the same chain in the rationals could close on a gap.
\begin{tikzpicture}[scale=1.0, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\definecolor{red}{HTML}{C0392B}
% five nested brackets, each narrower, stacked vertically
\foreach \lft/\rgt/\r/\lab in {0.4/9.4/0/1, 1.7/8.2/0.75/2, 3.0/7.0/1.5/3, 3.9/6.2/2.25/4, 4.5/5.7/3.0/5} {
  \draw[acc, thick] (\lft,\r) -- (\rgt,\r);
  \draw[acc, thick] (\lft,\r+0.14) -- (\lft,\r-0.14);
  \draw[acc, thick] (\rgt,\r+0.14) -- (\rgt,\r-0.14);
  \node[anchor=east, text=acc] at (0.15,\r) {$I_\lab$};
}
% node labels on the widest interval
\node[anchor=north, text=acc] at (0.4,-0.14) {$a_1$};
\node[anchor=north, text=acc] at (9.4,-0.14) {$b_1$};
% the common point
\draw[red, thick, dashed] (5.1,-0.3) -- (5.1,3.4);
\fill[red] (5.1,3.0) circle (2.2pt);
\node[text=red, anchor=south] at (5.1,3.45) {common point};
\end{tikzpicture}
$$

## Decimal expansions from scratch

Decimals are the everyday name for reals, but "$0.d_1 d_2 d_3\ldots$" needs a definition — an
infinite string of digits is not obviously a number. The definition uses completeness: a
decimal is the supremum of its finite truncations. Restricting to $[0,1]$ loses nothing, since
adding an integer part recovers the rest of the line. A **digit** is an integer in
$\{0, 1, \dots, 9\}$, and for a digit string $0.d_1 d_2 d_3 \ldots$ the $n$-th **truncation** is

$$
D_n = \frac{d_1}{10} + \frac{d_2}{10^2} + \cdots + \frac{d_n}{10^n}.
$$

> **Definition (Decimal representation).** The string $0.d_1 d_2 d_3 \ldots$ **represents** the
> number $x = \sup_{n \in \mathbb{N}} D_n$.

Two facts make this a genuine correspondence between strings and numbers in $[0,1]$.[^lebl-15]

> **Proposition (Decimals and reals).**
> 1. Every digit string $0.d_1 d_2 d_3 \ldots$ represents a unique $x \in [0,1]$, with
>    $D_n \le x \le D_n + 10^{-n}$ for all $n$.
> 2. Every $x \in (0,1]$ is represented by some string, and there is a unique such string
>    satisfying the strict bound $D_n < x \le D_n + 10^{-n}$ for all $n$.

Part (1) holds because $D_n$ is bounded above by the all-nines string, whose truncations sum by
the geometric formula to $1 - 10^{-n} < 1$, so the supremum exists in $[0,1]$ by completeness.
Part (2) constructs the digits greedily: at each step the Archimedean property supplies the
largest digit keeping $D_n < x$, and the resulting truncations converge up to $x$ because
$x - D_n \le 10^{-n}$ can be made arbitrarily small. The construction is a shrinking-interval
process: choosing $d_1$ selects one of ten subintervals of length $10^{-1}$, choosing $d_2$
selects one of ten sub-subintervals of length $10^{-2}$, and the nested intervals close on the
single point $x$.

$$
% caption: Each decimal digit selects one of ten equal subintervals; the nested
% choices form a chain of shrinking intervals converging to the represented number.
\begin{tikzpicture}[scale=1.0, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\definecolor{red}{HTML}{C0392B}
% level 0: [0,1]
\draw[black] (0,2.4) -- (9,2.4);
\draw[black] (0,2.26) -- (0,2.54);
\draw[black] (9,2.26) -- (9,2.54);
\node[anchor=east] at (-0.15,2.4) {[0,1]};
% ten ticks
\foreach \k in {1,...,9} \draw[black] (\k*0.9,2.32) -- (\k*0.9,2.48);
% chosen third block d1 = 3  -> [0.3,0.4]
\draw[acc!20, line width=8pt] (2.7,2.4) -- (3.6,2.4);
\node[text=acc, anchor=south] at (3.15,2.55) {$d_1=3$};
% level 1: zoom of [0.3,0.4]
\draw[black] (0,1.2) -- (9,1.2);
\draw[black] (0,1.06) -- (0,1.34);
\draw[black] (9,1.06) -- (9,1.34);
\node[anchor=east] at (-0.15,1.2) {[0.3,0.4]};
\foreach \k in {1,...,9} \draw[black] (\k*0.9,1.12) -- (\k*0.9,1.28);
\draw[acc!20, line width=8pt] (0.9,1.2) -- (1.8,1.2);
\node[text=acc, anchor=south] at (1.35,1.35) {$d_2=1$};
% guide lines from chosen block to next zoom
\draw[black, dashed] (2.7,2.32) -- (0,1.34);
\draw[black, dashed] (3.6,2.32) -- (9,1.34);
% level 2 collapse marker
\draw[red, thick, dashed] (1.35,1.06) -- (1.35,0.4);
\fill[red] (1.35,0.4) circle (2.2pt);
\node[text=red, anchor=north] at (1.35,0.33) {$x$ = 0.31...};
\end{tikzpicture}
$$

### Non-uniqueness of expansions

The greedy construction in part (2) enforces the strict inequality $D_n < x$, and that is what
makes _its_ representation unique. Dropping the strict requirement admits a second string for
certain numbers.

> **Worked example.** The number $\tfrac12$ has two decimal representations. The greedy
> construction always undershoots ($D_n < x$), so it picks the largest admissible digit at each
> step, producing $0.4999\ldots$; the terminating string $0.5000\ldots$ represents $\tfrac12$ as
> well. Both have the same supremum of truncations:
> $$
> \sup_n \Bigl(\tfrac{4}{10} + \tfrac{9}{10^2} + \cdots + \tfrac{9}{10^n}\Bigr) = \tfrac12 =
> \tfrac{5}{10}.
> $$
> The all-nines tail sums geometrically to $\tfrac{4}{10} + \tfrac{1}{10} = \tfrac12$, matching
> the terminating form.

The only numbers with two representations are those that terminate — expansions ending in all
$0$s, which also admit an all-$9$s form. Every other real has exactly one decimal expansion.
The ambiguity occurs in any positional system, and it is precisely
the case $D_n = x$ where a truncation hits the number exactly.

## ℝ is uncountable: the decimal diagonal

With representations in hand, Cantor's better-known 1891 proof is a short diagonal argument —
the same argument used for the [power set](/real-analysis/foundations/sets-logic-functions),
now reading the diagonal digits of a claimed list.[^lebl-15]

> **Theorem (Cantor).** The interval $(0,1]$ is uncountable.

> **Proof.** Let $\{x_1, x_2, x_3, \dots\}$ be any countable set in $(0,1]$, and write each in its
> unique representation $x_n = 0.d_1^{n} d_2^{n} d_3^{n}\ldots$ Define a new digit string
> $y = 0.e_1 e_2 e_3 \ldots$ by reading the diagonal digit $d_n^{n}$ and changing it:
>
> $$
> e_n = \begin{cases} 1 & \text{if } d_n^{n} \ne 1, \\ 2 & \text{if } d_n^{n} = 1. \end{cases}
> $$
>
> Every $e_n \in \{1,2\}$ is nonzero, so $y$ avoids the all-$0$/all-$9$ ambiguity and is a unique
> representation of a real in $(0,1]$. By construction the $n$-th digit of $y$ differs from the
> $n$-th digit of $x_n$, so $y \ne x_n$ for every $n$. Hence $y$ is on no list, and $(0,1]$ is
> uncountable. $\blacksquare$

$$
% caption: The decimal diagonal: read the circled diagonal digit of each listed
% number and change it, producing a number differing from every row.
\begin{tikzpicture}[scale=1.0, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\definecolor{red}{HTML}{C0392B}
\foreach \row/\r/\rl in {%
  {1,3,2,1,0}/0/1, {7,9,4,1,3}/1/2, {3,0,1,3,4}/2/3, {8,9,2,5,6}/3/4, {1,6,0,2,4}/4/5} {
  \node[anchor=east] at (-0.2,-\r*0.7) {$x_{\rl}$ = 0.};
  \foreach \dig [count=\c from 0] in \row {
    \node at (\c*0.7,-\r*0.7) {\dig};
  }
  \node at (5*0.7,-\r*0.7) {...};
}
\foreach \d in {0,1,2,3,4} {
  \draw[red, thick] (\d*0.7,-\d*0.7) circle (0.24);
}
\node[anchor=west, text=red] at (4.3,-0.7) {diagonal: 1 9 1 5 4};
\node[anchor=west, text=acc] at (4.3,-1.4) {changed: 2 1 2 1 1};
\node[anchor=west, text=acc] at (4.3,-2.1) {$y$ = 0.21211... is new};
\end{tikzpicture}
$$

## Rationals are the repeating decimals

Decimals also detect rationality exactly. Long division of $p/q$ produces a remainder in
$\{0, 1, \dots, q-1\}$ at each step; with only finitely many possible remainders, some
remainder recurs, and from that point the digits cycle.[^lebl-15]

> **Proposition (Rationals repeat).** If $x \in (0,1]$ is rational with expansion
> $0.d_1 d_2 d_3\ldots$, then the digits are eventually periodic: there are $N, P \in
> \mathbb{N}$ with $d_n = d_{n+P}$ for all $n \ge N$.

The converse holds too (an eventually periodic decimal is a rational, summing a geometric
series), so the rationals coincide with the eventually-repeating expansions. Every
non-repeating decimal, such as $0.101001000100001\ldots$, is therefore irrational, which gives
an easy supply of irrational numbers and a second route to the uncountability of the
irrationals: the repeating strings are countable, but the strings are not.

## The Cantor set

Digit expansions in base three yield a standard example of an uncountable set of length
zero. Fix base
three, so a number in $[0,1]$ is $0.t_1 t_2 t_3 \ldots$ with each $t_j \in \{0, 1, 2\}$, and
remove at every stage the points whose expansion needs the digit $1$. Concretely, delete the
open middle third of each remaining interval and repeat.

$$
% caption: The first stages of the middle-thirds construction; each step deletes
% the open middle third of every remaining segment, leaving the Cantor set in the limit.
\begin{tikzpicture}[scale=1.0, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
% stage 0
\draw[acc, line width=5pt] (0,3.0) -- (9,3.0);
\node[anchor=west] at (9.3,3.0) {stage 0};
% stage 1: remove (3,6)
\draw[acc, line width=5pt] (0,2.2) -- (3,2.2);
\draw[acc, line width=5pt] (6,2.2) -- (9,2.2);
\node[anchor=west] at (9.3,2.2) {stage 1};
% stage 2
\draw[acc, line width=5pt] (0,1.4) -- (1,1.4);
\draw[acc, line width=5pt] (2,1.4) -- (3,1.4);
\draw[acc, line width=5pt] (6,1.4) -- (7,1.4);
\draw[acc, line width=5pt] (8,1.4) -- (9,1.4);
\node[anchor=west] at (9.3,1.4) {stage 2};
% stage 3
\foreach \lft in {0,0.667,2,2.667,6,6.667,8,8.667} {
  \draw[acc, line width=5pt] (\lft,0.6) -- (\lft+0.333,0.6);
}
\node[anchor=west] at (9.3,0.6) {stage 3};
\end{tikzpicture}
$$

What remains is the set of numbers whose base-three expansion uses only $0$ and $2$.
Mapping each such expansion to the binary string obtained by halving every digit gives a
bijection with all binary strings, i.e. with $\mathcal{P}(\mathbb{N})$, so the **Cantor set** is
uncountable — as large as $\mathbb{R}$ itself. Yet its total length is zero.

> **Worked example.** The total length removed in the middle-thirds construction is $1$. Stage
> $k$ deletes $2^{k-1}$ open intervals, each of length $3^{-k}$, so the removed length is
> $$
> \sum_{k=1}^{\infty} 2^{k-1}\, 3^{-k} = \frac13 \sum_{k=0}^{\infty} \Bigl(\frac23\Bigr)^k
> = \frac13 \cdot \frac{1}{1 - \tfrac23} = 1.
> $$
> What remains from the unit interval therefore has length zero, while the set itself is
> uncountable: cardinality and length are independent measures of size.

The Cantor set returns as a standard source of counterexamples in the study of
[metric spaces](/real-analysis/metric-spaces/compactness) and integration.

[^lebl-14]: **Lebl**, _Basic Analysis I_, §1.4 — Intervals and the size of $\mathbb{R}$: the nine interval types and their order characterization, the equal cardinality of all intervals, and Cantor's 1874 nested-interval proof that $\mathbb{R}$ is uncountable.
[^lebl-15]: **Lebl**, _Basic Analysis I_, §1.5 — Decimal representation of the reals: decimals as suprema of truncations, existence and uniqueness of representations with the strict bound, the terminating-number ambiguity, the decimal diagonal proof of uncountability, and the eventual periodicity of rational expansions. The middle-thirds set is the base-three analogue of this representation machinery.
