← Recreational maths

Lab · Rational numbers

Every fraction exactly once

The Calkin–Wilf tree lists every positive fraction once, already in lowest terms. Its level-by-level reading is Stern's sequence, and its left–right paths turn continued fractions into binary, which is what Minkowski's question-mark function does.

Start with $1/1$ and give every fraction $a/b$ two children: $\frac{a}{a+b}$ on the left and $\frac{a+b}{b}$ on the right. Neil Calkin and Herbert Wilf noticed in 2000 that the resulting infinite binary tree contains every positive rational number, each exactly once, and always in lowest terms. Reading it row by row gives an explicit list of the rationals, $$\tfrac11,\ \tfrac12,\ \tfrac21,\ \tfrac13,\ \tfrac32,\ \tfrac23,\ \tfrac31,\ \tfrac14,\ \tfrac43,\ \tfrac35,\ \tfrac52,\ \dots$$ which proves they are countable without any zigzag through a grid and without skipping duplicates. Type a fraction to trace its path back to the root.

Three views of one structure

The tree. Going up the tree is a step of the subtractive Euclidean algorithm: the parent of $a/b$ is $a/(b-a)$ if $a < b$ and $(a-b)/b$ if $a > b$. Since that algorithm always reaches $1/1$ and every step is forced, each fraction has exactly one path to the root. The runs of left and right moves on that path are the continued fraction digits.

Stern's diatomic sequence. Define $s(0) = 0$, $s(1) = 1$, $s(2n) = s(n)$, $s(2n+1) = s(n) + s(n+1)$. Moritz Stern studied it in 1858. The $n$-th fraction in the row-by-row list is $s(n)/s(n+1)$, so consecutive terms of this one sequence enumerate the rationals. Its graph is a fractal of arches whose peaks are Fibonacci numbers.

Minkowski's question-mark function. Minkowski defined ?(x) in 1904 to send quadratic irrationals to rationals. In terms of continued fractions, $$?\big([0; a_1, a_2, a_3, \dots]\big) = 2\left(2^{-a_1} - 2^{-(a_1 + a_2)} + 2^{-(a_1 + a_2 + a_3)} - \cdots\right),$$ so the binary expansion of ?(x) consists of runs of lengths $a_1, a_2, a_3, \dots$. It is continuous and strictly increasing, yet its derivative is $0$ almost everywhere: almost every $x$ has continued fraction digits whose average is infinite (see the continued fraction lab), which makes the runs long and ?(x) flat.

Full proof: every positive fraction appears exactly once, in lowest terms

Lowest terms. If $\gcd(a, b) = 1$ then $\gcd(a, a + b) = \gcd(a + b, b) = 1$. The root $1/1$ is in lowest terms, so by induction every node is.

Every fraction appears. Induct on $a + b$ for a reduced fraction $a/b$. If $a + b = 2$ it is the root. Otherwise $a \ne b$. If $a < b$, the fraction $a/(b-a)$ is reduced with smaller sum, so by induction it is in the tree, and $a/b$ is its left child. If $a > b$, the same argument with $(a-b)/b$ and the right child.

Only once. Left children are less than $1$ and right children are greater than $1$, so a node's position as a left or right child is determined by its value, and its parent is determined too ($a/(b-a)$ or $(a-b)/b$). If $a/b$ appeared twice, the two occurrences would have equal parents; repeating, we would reach two different occurrences of $1/1$. But $1/1$ is not a child of anything (a child always has numerator or denominator at least $2$), so it occurs only at the root. $\square$

Further reading

  • N. Calkin and H. S. Wilf, Recounting the rationals, American Mathematical Monthly 107 (2000).
  • S. Northshield, Stern's diatomic sequence 0, 1, 1, 2, 1, 3, 2, 3, 1, 4, …, American Mathematical Monthly 117 (2010).
  • M. Aigner and G. M. Ziegler, Proofs from THE BOOK, 6th ed., Springer, 2018, the chapter on countable sets.