Cantor's Diagonal Argument Explained Carefully
Work through the diagonal argument slowly, handle the 0.999 subtlety, answer the usual objections and see where else it applies.
Key takeaways
- The argument takes an arbitrary list and constructs a number that differs from the nth entry in the nth decimal place.
- Because it works against every list, no list of real numbers can be complete.
- Using only the digits 4 and 5 in the new number avoids the problem that some numbers have two decimal expansions.
- The same diagonal pattern shows that every set has more subsets than elements and that some problems cannot be solved by any program.
Cantor's diagonal argument proves that the real numbers cannot be listed. Give it any infinite list of real numbers between 0 and 1, and it builds a real number between 0 and 1 that is missing from that list.
So there are strictly more real numbers than counting numbers, although both collections are infinite. The proof is short, but its details matter, and most doubts about it come from skipping one of them.
What is being claimed
A set is countable if its members can be arranged in a list, first, second, third and so on, that eventually reaches every one. The integers and the fractions are countable, as Hilbert's Hotel illustrates.
The claim is that the real numbers in the interval from 0 to 1 are uncountable: every list leaves something out. Notice the shape of the statement. It is about all possible lists, including clever ones that nobody has thought of. So the proof must not assume anything about how the list was made.
The construction on a sample list
Write each number as an infinite decimal. Here are the first five entries of some list, with the diagonal digit marked in brackets.
r1 = 0.[5] 0 0 0 0 ...
r2 = 0. 3 [3] 3 3 3 ...
r3 = 0. 1 4 [1] 5 9 ...
r4 = 0. 7 1 8 [2] 8 ...
r5 = 0. 4 1 4 2 [1] ... The diagonal digits are 5, 3, 1, 2, 1. Now build a new number d digit by digit with a fixed rule:
- if the nth digit of the nth number is 5, write 4;
- otherwise, write 5.
diagonal: 5 3 1 2 1 ...
d = 0. 4 5 5 5 5 ... Is d on the list? It is not r1, since they differ in the first digit. It is not r2, since they differ in the second. In general d differs from the nth number in the nth digit. Therefore d is nowhere on the list.
Why the diagonal?
To be different from one number, d only has to differ from it in one decimal place. You have infinitely many places available and infinitely many numbers to avoid, so assign one place to each number. Place 1 is used to get away from r1, place 2 to get away from r2, and so on.
The diagonal is simply the tidiest assignment. You could just as well use place 2n to escape the nth number and fill the odd places with anything. That freedom shows that a single list misses not one number but a great many. With a free choice of 4 or 5 in every odd place, you get as many missing numbers as there are infinite sequences of two symbols.
It also shows what would go wrong with finite strings. A table of all two-digit strings built from 4 and 5 has four rows but only two columns. The diagonal covers just two rows, so the string you build can perfectly well sit in row three or four. The argument needs at least as many places as there are entries. For infinite decimals and an infinite list, the two match.
The proof in general
Let r₁, r₂, r₃, ... be any sequence of real numbers in the interval [0, 1]. Choose a decimal expansion for each, and let rₙₖ denote the kth digit of rₙ. Define the kth digit of d to be 4 if rₖₖ = 5, and 5 otherwise.
Then d is a real number between 0 and 1. For each n, the nth digit of d is different from rₙₙ. So d ≠ rₙ, provided that different digits really do mean different numbers. That proviso needs a moment.
Hence no sequence contains every real number in [0, 1]. Since the whole real line contains that interval, the real numbers are uncountable too.
The 0.999 subtlety
Some numbers have two decimal expansions. For instance 0.5000... and 0.4999... are the same number, as discussed in whether 0.999 repeating equals 1. So two expansions that differ in a digit could, in principle, name one number.
This only happens when one expansion ends in all zeros and the other in all nines. The number d contains only the digits 4 and 5, so it has exactly one decimal expansion. If d were equal to rₙ as a number, then any expansion of rₙ would have to be that unique expansion of d. But the expansion we chose for rₙ differs from it at place n. So the gap is closed.
A sloppy rule such as "add 1 to each diagonal digit, turning 9 into 0" can produce a tail of zeros or nines, and then the proof as stated has a hole. Choosing safe digits is the standard fix.
Objections and answers
"Just add d to the list." You can, for instance by putting it first. The result is a new list, and the argument applies to it as well, giving another missing number. No amount of patching produces a complete list.
"The same argument would prove the fractions uncountable." Fractions can be listed. Apply the construction to that list and you get a number d not on it. That is no contradiction, because d need not be a fraction. Indeed it cannot be. Its expansion never eventually repeats, as rational numbers must.
"What about the counting numbers? Diagonalize them." Changing digits along a diagonal of whole numbers would require infinitely many nonzero digits, and that is not a whole number.
"You can never finish building d." Nothing needs finishing. Each digit is determined by a rule, and the rule defines the whole expansion at once, just as a rule defines 1/3 = 0.333... .
"The proof is by contradiction, so it constructs nothing." It is often presented that way: assume a complete list, find a missing number. But the core is direct. From any given list you get a specific number outside it.
A cleaner version with two symbols
Replace decimals with infinite sequences of 0s and 1s. Given a list of such sequences, form a new one by flipping the nth bit of the nth sequence. There is no double-representation issue, because the objects are the sequences themselves.
This is close to what Cantor published in 1891, using two letters. He had already proved in 1874 that the real numbers are uncountable, by a different method based on nested intervals.
Each sequence of bits also describes a subset of the counting numbers: bit n says whether n belongs. So the flipping argument shows that the subsets of the counting numbers cannot be listed.
Diagonalizing any set
The idea extends to every set A. Suppose f assigns to each element x of A a subset f(x) of A. Define
D = { x in A : x is not in f(x) } If D = f(d) for some d, then d belongs to D exactly when d does not belong to f(d) = D. That is impossible. So f misses D, and there is no surjection from A onto its power set. This is Cantor's theorem, covered in why power sets are always bigger. Its close relative is Russell's paradox.
Try it on A = {1, 2, 3} with f(1) = {1, 2}, f(2) = ∅ and f(3) = {1, 3}. Then 1 is in f(1), 2 is not in f(2), and 3 is in f(3). So D = {2}, which is indeed none of the three listed sets.
Where the pattern returns
| Result | What is listed | What escapes |
|---|---|---|
| Uncountability of the reals | Real numbers | A number differing on the diagonal |
| Cantor's theorem | Subsets indexed by elements | The set of elements outside their own subset |
| Halting problem | Computer programs | A behavior that contradicts each program's prediction |
| Incompleteness | Provable statements | A statement referring to its own unprovability |
The last two involve more machinery, but the family resemblance is real. See Turing machines and the halting problem for the computing version. A direct consequence is that there are only countably many programs, so there are real numbers that no program can compute.
How to check someone else's version
Diagonal arguments are often retold loosely, online and off. Run a version through these questions.
- Does it start with an arbitrary list, without assuming any order or pattern?
- Is the new object of the same kind as the listed ones, for instance a real number in the stated interval?
- Does the rule guarantee a difference from the nth entry for every n?
- If it uses decimals, does it avoid the double expansions?
- Is the conclusion limited to "no list is complete"?
A purported counterexample usually fails at the first or second point. Someone might offer the list 0.1, 0.2, ..., 0.9, 0.01, 0.11 and so on, built by reversing the digits of each counting number. Every finite decimal appears on it. But 1/3 = 0.333... has infinitely many digits and never appears, so the list is not complete, exactly as the theorem predicts.
What it does not show
The argument shows that the reals form a larger infinity than the counting numbers. It does not say how much larger, or whether some size lies strictly between. That question is the continuum hypothesis, which the standard axioms of set theory leave open.