Uncountable sets and the diagonal argument
The integers, the fractions and every finite piece of text can all be put in one endless list. Is there any infinite set that no list can ever finish, however cleverly it is arranged?
Where you are 4 in Infinite sets
Why this exists
Countable sets listed the integers, the pairs of natural numbers, the rationals, every finite string and every polynomial with integer coefficients. Each time a clever route reached every member. It is natural to suspect that every infinite set can be listed. Throughout, \mathbb{N} = \{0, 1, 2, \dots\}.
It cannot. Georg Cantor proved in 1874 that the real numbers cannot be listed, by an argument about nested intervals; the argument taught here, which turns any proposed list against itself, appeared in a later paper of his, from 1891. It shows that infinite sets come in more than one size, and it is one of the most reused ideas in mathematics.
Definition
Day 1: uncountable sets
A set is uncountable when it is not countable, that is, when it is neither finite nor countably infinite (Countable sets).
An infinite binary sequence s assigns a term s(k) \in \{0, 1\} to each place k \in \mathbb{N}, and is written s = (s(0), s(1), s(2), \dots). Two sequences are equal when they agree in every place. The set of all of them is written \{0, 1\}^{\mathbb{N}}.
A decimal expansion of a number x in [0, 1) is a sequence of digits d_1, d_2, d_3, \dots, each in \{0, 1, \dots, 9\}, with
Every number in [0, 1) has at least one decimal expansion. That fact is stated without proof here; it rests on the completeness of the real line (Irrational and real numbers). Some numbers have two: 0.4999\ldots and 0.5000\ldots are the same number, \displaystyle \frac{1}{2}.
Day 2: functions to \{0, 1\}
A function f : \mathbb{N} \to \{0, 1\} assigns 0 or 1 to each natural number. A number is transcendental when it is not algebraic, that is, not a root of any nonzero polynomial with integer coefficients.
Intuition
Picture any proposed list of binary sequences as a table that never ends, row n holding the sequence s_n. Read down the diagonal, the digits s_0(0), s_1(1), s_2(2), \dots, and flip each one. The flipped diagonal is itself a sequence, t. It cannot be row 0, because it differs from row 0 in place 0; it cannot be row 1, because it differs from row 1 in place 1; and so on down every row. So t is missing from the list, whatever the list was.
The list was arbitrary, so no list holds every sequence. The argument does not fail for want of a better list: it takes the list as its input and builds the missing member from it.
Results
Day 1
1. A test for uncountable. A nonempty set A is countable if and only if some function f : \mathbb{N} \to A is onto. So A is uncountable exactly when every function \mathbb{N} \to A misses a member of A. A list here may repeat members.
2. Binary sequences. \{0, 1\}^{\mathbb{N}} is uncountable.
3. Two expansions. If two different decimal expansions give the same number, then at the first place where they differ, their digits differ by 1; after that place, the expansion with the smaller digit has only 9s and the other has only 0s. So an expansion in which neither 0 nor 9 ever appears is the only expansion of its number.
4. The interval. The open interval (0, 1) is uncountable.
5. The real line. \mathbb{R} is uncountable, and it is the same size as (0, 1).
Day 2
6. Bigger sets. A set with an uncountable subset is uncountable.
7. Irrationals. The set \mathbb{R} \setminus \mathbb{Q} of irrational numbers is uncountable.
8. Transcendental numbers. The set of transcendental real numbers is uncountable, while the algebraic numbers are only countably many. In this counting sense almost every real number is not algebraic.
9. Functions. The set of functions \mathbb{N} \to \{0, 1\} is the set \{0, 1\}^{\mathbb{N}}, so it is uncountable.
Why it is true
Result 1. Proof. Let A be nonempty. If A = \{a_1, \dots, a_r\} is finite, the function f(n) = a_{\min(n + 1, r)} is onto. If A is countably infinite, a bijection \mathbb{N} \to A is onto. Conversely, if some f : \mathbb{N} \to A is onto, A is countable by Result 4 of Countable sets. \square
Result 2. Proof. We argue by contradiction. Suppose \{0, 1\}^{\mathbb{N}} is countable. It is nonempty, so by Result 1 there is an onto function f : \mathbb{N} \to \{0, 1\}^{\mathbb{N}}. Write s_n = f(n), so s_n(k) is the term of the nth sequence in place k. Define a sequence t by
Each t(n) is 0 or 1, so t \in \{0, 1\}^{\mathbb{N}}. Since f is onto, t = s_m for some m. Compare the two in place m: on one hand t(m) = s_m(m), because t = s_m; on the other t(m) = 1 - s_m(m) by definition. So 2 s_m(m) = 1, which no value s_m(m) \in \{0, 1\} satisfies. This contradiction shows \{0, 1\}^{\mathbb{N}} is not countable. \square
Result 3. Proof. Let c and d be different expansions of the same number and let j be the first place where they differ; name them so that c_j < d_j. The places before j agree, so subtracting them leaves
Every digit is at most 9 and \sum_{k > j} 9 \cdot 10^{-k} = 10^{-j}, so the left side is at most c_j 10^{-j} + 10^{-j} = (c_j + 1) 10^{-j}, with equality only if c_k = 9 for every k > j. Every digit is at least 0 and d_j \ge c_j + 1, so the right side is at least (c_j + 1) 10^{-j}, with equality only if d_j = c_j + 1 and d_k = 0 for every k > j. The two sides are equal, so both equalities hold. An expansion with no 0 and no 9 can be neither c nor d, so no other expansion gives its number. \square
Result 4. Proof. For decimals it is tidier to number a list from 1; a list a_1, a_2, \dots is a function \mathbb{N} \to (0, 1) shifted by one place. Suppose (0, 1) is countable. By Result 1 there is a list a_1, a_2, a_3, \dots in which every number in (0, 1) appears. For each n fix one decimal expansion of a_n, and let e_n be its nth digit. Put
and let x = 0.c_1 c_2 c_3 \dots. Every digit of x is 4 or 5, so \displaystyle \frac{4}{9} = 0.444\ldots \le x \le 0.555\ldots = \frac{5}{9}, and x \in (0, 1). So x = a_m for some m. Then 0.c_1 c_2 \dots and the chosen expansion of a_m are two expansions of one number, and they are different, since c_m \ne e_m. But the expansion of x uses no 0 and no 9, so by Result 3 it is the only expansion of x. This contradiction proves the result. \square
The digits 4 and 5 are what make the proof honest. Differing from a_m in one digit does not by itself make x a different number, since 0.4999\ldots and 0.5000\ldots differ in every digit and are equal. Keeping 0s and 9s out of x gives it a single expansion, and then a different digit does mean a different number.
Result 5. Proof. Matching two sets one to one built a bijection h : (0, 1) \to \mathbb{R}, namely \displaystyle h(x) = \frac{1 - x}{x} - \frac{x}{1 - x}, so the two sets are the same size. If \mathbb{R} were countable, there would be an injection g : \mathbb{R} \to \mathbb{N} (Result 4 of Countable sets), and g \circ h would be an injection (0, 1) \to \mathbb{N}, making (0, 1) countable, against Result 4. \square
Result 6. Proof. Let U \subseteq B with U uncountable. If B were countable, its subset U would be countable by Result 5 of Countable sets. \square
Result 7. Proof. \mathbb{R} = \mathbb{Q} \cup (\mathbb{R} \setminus \mathbb{Q}), and \mathbb{Q} is countable. If \mathbb{R} \setminus \mathbb{Q} were countable, the union of two countable sets would be countable (Result 7 of Countable sets), so \mathbb{R} would be, against Result 5. \square
Result 8. Proof. The algebraic numbers are countable (Result 11 of Countable sets, given there with a sketch). The same argument as for Result 7, with the algebraic reals in place of \mathbb{Q}, shows the rest of \mathbb{R} is uncountable. \square
Result 9. A sequence s \in \{0, 1\}^{\mathbb{N}} is a rule giving each place k a term s(k) \in \{0, 1\}, which is exactly a function \mathbb{N} \to \{0, 1\}: one set under two names, so Result 2 applies.
Worked examples
Day 1: ones, then zeros
Let s_n be the sequence with n ones followed by zeros forever: s_n(k) = 1 if k < n and s_n(k) = 0 if k \ge n. Find the flipped diagonal t of this list, and show directly that t is not in it.
SolutionThe diagonal term is s_n(n), and n < n is false, so s_n(n) = 0 for every n. Flipping gives t(n) = 1 - 0 = 1: the sequence t = (1, 1, 1, \dots) of all ones.
Directly: s_n has the term 0 in place n and t has 1 there, so t \ne s_n. Indeed every s_n has only finitely many ones and t has infinitely many.
Day 1: keeping the new sequence in the set
Let S be the set of binary sequences with no two 1s in adjacent places, so (1, 0, 1, 0, 0, \dots) \in S but (0, 1, 1, 0, \dots) \notin S. Prove S is uncountable.
SolutionPlain flipping can leave S. The list in which every s_n is (0, 0, 0, \dots) is a list of members of S (repeats are allowed in Result 1), and its flipped diagonal is (1, 1, 1, \dots), which is not in S. So the new sequence must be built to stay in S.
Let s_0, s_1, s_2, \dots be any list of members of S. Use only the even places:
Then t \in S: any two adjacent places include an odd one, where t is 0. And t \ne s_n, because they differ in place 2n. So every function \mathbb{N} \to S misses a member, and S is nonempty, so S is uncountable by Result 1. The diagonal need not be the literal diagonal: any rule that spends a different place on each s_n works.
Day 1: building a missing number
A list of (0, 1) begins \displaystyle a_1 = \frac{1}{2}, written 0.4999\ldots, then \displaystyle a_2 = \frac{1}{3}, \displaystyle a_3 = \frac{1}{7}, \displaystyle a_4 = \sqrt{2} - 1, a_5 = \pi - 3, \displaystyle a_6 = \frac{5}{11}. Find the first six digits of the number x that the proof of Result 4 builds, and check x \ne a_1. What changes if a_1 is written 0.5000\ldots instead?
SolutionThe rule is c_n = 4 if the nth digit of a_n is 5, and c_n = 5 otherwise. The diagonal digits are: place 1 of 0.4999\ldots is 4; place 2 of 0.3333\ldots is 3; place 3 of 0.142857\ldots is 2; place 4 of 0.41421356\ldots is 2; place 5 of 0.14159265\ldots is 9; place 6 of 0.454545\ldots is 5. So c_1, \dots, c_6 are 5, 5, 5, 5, 5, 4 and
Since \displaystyle x \ge 0.55 > \frac{1}{2}, indeed x \ne a_1, although x and 0.5000\ldots agree in the first place. Written 0.5000\ldots, the first diagonal digit is 5, so c_1 = 4 and x = 0.455554\ldots; now \displaystyle x \le 0.46 < \frac{1}{2}. Either way x misses a_1, which is the point of Result 3: the rule never has to know which expansion was listed.
Day 2: numbers written with 3s and 7s
Let K be the set of numbers 0.d_1 d_2 d_3 \dots whose every digit is 3 or 7. Prove K is the same size as \{0, 1\}^{\mathbb{N}}, and find the members of K that correspond to (1, 0, 0, 0, \dots) and (0, 1, 0, 1, \dots).
SolutionSend a sequence s to the number \beta(s) whose digit in place k + 1 is 3 + 4 s(k), that is, 3 for a term 0 and 7 for a term 1. Every member of K arises this way, so \beta is onto K. It is one to one: if s \ne s', then \beta(s) and \beta(s') have different digit strings, and both strings avoid 0 and 9, so by Result 3 they cannot name the same number. So \beta is a bijection and, as in the proof of Result 5, K is uncountable. By Result 6, so is every set containing K, which proves \mathbb{R} uncountable a second way.
The first sequence gives \displaystyle 0.7333\ldots = \frac{7}{10} + \frac{3}{90} = \frac{11}{15}. The second gives \displaystyle 0.373737\ldots = \frac{37}{99} (Turning a repeating decimal into a fraction).
Day 2: irrational members of K
Prove that the irrational members of the set K of the previous example form an uncountable set, and name one irrational member.
SolutionK \cap \mathbb{Q} is a subset of the countable set \mathbb{Q}, so it is countable. Now K = (K \cap \mathbb{Q}) \cup (K \setminus \mathbb{Q}). If K \setminus \mathbb{Q} were countable, K would be a union of two countable sets and so countable, but K is uncountable. So K \setminus \mathbb{Q} is uncountable.
For one member, write 3, then one 7, then 3, then two 7s, and so on: x = 0.37\,377\,3777\,37777\ldots. A rational number’s expansion eventually repeats one block forever (Converting between fractions and decimals). Here, past any point where such a block might start, some run of 7s is longer than two copies of the block, so a whole copy lies inside the run and the block is all 7s; then the tail would be 7s forever, yet a 3 follows every run. So x is irrational. The counting argument says far more: all but countably many members of K are like it.
Day 2: where the argument stops
List the finite binary strings by length, and in dictionary order within a length: w_0 is the empty string, then w_1 = 0, w_2 = 1, w_3 = 00, and so on. Try the diagonal argument on this list and say what it proves.
SolutionThe 2^L strings of length L occupy positions 2^L - 1 to 2^{L+1} - 2. Places in a string of length L are 0, \dots, L - 1, and the string w_n of length L has n \ge 2^L - 1 \ge L. So w_n has no place n at all: the diagonal digit w_n(n) does not exist for any n. For example, w_3 = 00 has places 0 and 1 only.
Padding each string with 0s forever makes the list a list of sequences, and then every diagonal digit is a padded 0, so the flipped diagonal is (1, 1, 1, \dots). That is an infinite sequence, not a finite string. The argument correctly shows that the padded strings, the sequences with finitely many ones, are not all of \{0, 1\}^{\mathbb{N}}. It says nothing against the list of strings, which Countable sets proved complete.
Day 2: increasing functions
Prove that the set of strictly increasing functions \mathbb{N} \to \mathbb{N} is uncountable.
SolutionBy Result 9 a function s : \mathbb{N} \to \{0, 1\} is a binary sequence. Send it to g_s(n) = 2n + s(n). This is strictly increasing:
It is one to one in s, because s(n) = g_s(n) - 2n recovers s. So the image of s \mapsto g_s is a subset of the increasing functions that is the same size as \{0, 1\}^{\mathbb{N}}, hence uncountable (as in Result 5, an injection into \mathbb{N} from it would give one from \{0, 1\}^{\mathbb{N}}). By Result 6 the increasing functions are uncountable. For instance s = (0, 1, 1, 0, \dots) gives g_s = (0, 3, 5, 6, \dots).
Boundaries
The new object must belong to the set. Flipping the diagonal of a list of members of a set proves nothing unless the flipped object is itself a member, as the sequences with no adjacent 1s showed. The same point is why the decimal proof chooses its digits from \{4, 5\}: any two digits from 1 to 8 would do, but a rule that may use 0 or 9 can fail. If a_1 = 0.5000\ldots and the rule picks c_1 = 4 and then 9s, it builds 0.4999\ldots, which differs from a_1 in every digit and equals it.
It does not make \mathbb{Q} uncountable. Run on a list of the rationals in (0, 1), the argument builds a number in (0, 1) that is not on the list, so that number is irrational (Exercise 16). The argument proves only that a set is uncountable when the new object lands back in the set, and for \mathbb{Q} it never does.
Finite strings are out of reach. On a list of finite strings there is no diagonal to read, and padding produces an infinite sequence instead of a string.
Uncountable is not one size. The argument shows some sets are bigger than \mathbb{N}; it does not say all uncountable sets are the same size. Whether some set is strictly bigger than \mathbb{N} and strictly smaller than \mathbb{R} is the continuum hypothesis, which the usual axioms of set theory can neither prove nor refute.
Where this goes next
The diagonal argument is a pattern, not a fact about digits. Cantor's theorem: no set matches its power set runs it on any set and its power set: a subset of \mathbb{N} matches the binary sequence that marks its members, and the same flip shows that no set matches its own power set, so there is no largest infinity.
Exercises
Day 1: building missing members
- Let s_n(k) = 1 when n + k is even and 0 when it is odd. Find the flipped diagonal t, and say how many different sequences this list contains.
- Let s_n(k) be the digit in the 2^k place of n written in base 2, so s_6 = (0, 1, 1, 0, 0, \dots). Find the flipped diagonal t, and describe exactly which sequences the list contains.
- A list begins \displaystyle a_1 = \frac{1}{4}, \displaystyle a_2 = \frac{2}{3}, \displaystyle a_3 = \frac{3}{8}, \displaystyle a_4 = \frac{1}{6}, \displaystyle a_5 = \frac{5}{9}, each written with its expansion that ends in 0s or repeats without 9s. Find the first five digits of x from the proof of Result 4. How does x change if a_3 is written 0.374999\ldots?
- Prove that every number whose digits are all 4 or 5 lies in \displaystyle \left[\frac{4}{9}, \frac{5}{9}\right].
- Write both decimal expansions of \displaystyle \frac{7}{20} and of \displaystyle \frac{13}{40}, and explain why \displaystyle \frac{2}{7} has only one.
- Prove that the set of binary sequences with infinitely many 1s is uncountable.
Day 1: reasoning
- Prove that if there is an injection from an uncountable set A into a set B, then B is uncountable.
- Prove that the set of numbers in (0, 1) that have two decimal expansions is countable.
- Prove that every list of binary sequences misses infinitely many sequences, not just one.
Day 2: consequences
- Let a < b be real numbers and let C be any countable set of real numbers. Prove that the interval (a, b) contains a number that is not in C.
- Prove that between any two real numbers a < b there are uncountably many transcendental numbers.
- With g_s(n) = 2n + s(n) from the last worked example, find g_s(0), \dots, g_s(5) for s = (1, 1, 0, 1, 0, 0, \dots). Which s gives g_s(n) = 2n + 1 for odd n and 2n for even n? Is n \mapsto 3n some g_s?
- Write the first ten terms of the sequence that is the function p(n) = 1 if n is prime and p(n) = 0 otherwise. Which function is the sequence (1, 0, 0, 1, 0, 0, \dots)?
- In the list w_0, w_1, w_2, \dots of finite binary strings from the example “Where the argument stops”, which string is w_{20}, and at which position is 1101?
Day 2: reasoning
- Find the flaw. Ebo writes each natural number’s digits in reverse followed by 0s forever, so 12 becomes 2100\ldots, lists these, and builds a digit string t differing from the nth string in place n, using only 4s and 5s. “So t is a natural number not on the list, and \mathbb{N} is uncountable.”
- Let a_1, a_2, \dots be a list of the rational numbers in (0, 1). Prove that the number x built from it in the proof of Result 4 is irrational.
- Prove that the set of real numbers x with x^2 irrational is uncountable.
- Let F be the set of functions f : \mathbb{N} \to \mathbb{N} with f(n) \le n for every n. Prove F uncountable by a diagonal argument run directly on a list of F, and explain why the new function cannot be made to differ from f_n in place n itself.
- A binary sequence is eventually periodic when, after some place, one finite block repeats forever. Prove that the eventually periodic sequences form a countable set, and conclude that the others form an uncountable one.
Answers
- s_n(n) = 1 since 2n is even, so t = (0, 0, 0, \dots). The list holds two sequences: s_n = (1, 0, 1, 0, \dots) for even n and (0, 1, 0, 1, \dots) for odd n.
- n < 2^n, so the 2^n place of n is 0: s_n(n) = 0 and t = (1, 1, 1, \dots). Base-2 numerals are unique, so the list holds each sequence with finitely many 1s exactly once, and nothing else.
- Diagonal digits 2, 6, 5, 6, 5 (from 0.25, 0.666\ldots, 0.375, 0.1666\ldots, 0.555\ldots), so x = 0.55454\ldots. With 0.374999\ldots the third digit is 4, so c_3 = 5 and x = 0.55554\ldots.
- Each digit lies between 4 and 5, so x lies between \displaystyle \sum_{k \ge 1} 4 \cdot 10^{-k} = \frac{4}{9} and \displaystyle \sum_{k \ge 1} 5 \cdot 10^{-k} = \frac{5}{9}, comparing the series term by term.
- \displaystyle \frac{7}{20} = 0.35000\ldots = 0.34999\ldots and \displaystyle \frac{13}{40} = 0.325000\ldots = 0.324999\ldots. By Result 3 a number with two expansions has one ending in 0s, so it is \displaystyle \frac{m}{10^j}. But \displaystyle 10^j \cdot \frac{2}{7} is not an integer, since the prime 7 divides neither 2 nor 10.
- Proof. Given any list s_0, s_1, \dots of such sequences, put t(2n) = 1 - s_n(2n) and t(2n + 1) = 1. Then t has a 1 in every odd place, so infinitely many, and t \ne s_n in place 2n. The set is nonempty, so Result 1 applies. \square
- Proof. Let j : A \to B be an injection. If B were countable, with injection g : B \to \mathbb{N}, then g \circ j would be an injection A \to \mathbb{N}, making A countable. \square
- Proof. By Result 3 such a number has an expansion ending in 0s, so it equals \displaystyle \frac{m}{10^j} for integers m, j, and is rational. The set is a subset of \mathbb{Q}, so countable. \square
- Proof. Suppose a list s_0, s_1, \dots misses only u_1, \dots, u_r. Then u_1, \dots, u_r, s_0, s_1, \dots is a list (the term in position n is u_{n+1} for n < r and s_{n-r} after) that misses nothing, against Result 2. \square
- Proof. The map \varphi(x) = a + (b - a)x is a bijection (0, 1) \to (a, b), with inverse \displaystyle y \mapsto \frac{y - a}{b - a}. So (a, b) is uncountable: an injection g : (a, b) \to \mathbb{N} would make g \circ \varphi an injection (0, 1) \to \mathbb{N}, against Result 4. If every number of (a, b) were in C, then (a, b) would be a subset of a countable set and so countable (Result 5 of Countable sets). \square
- Proof. By Exercise 10, (a, b) is uncountable. Its algebraic members form a subset of the countable set of algebraic numbers, so they are countable. If its transcendental members were countable too, (a, b) would be a union of two countable sets and so countable. \square
- g_s(0), \dots, g_s(5) are 1, 3, 4, 7, 8, 10. s = (0, 1, 0, 1, \dots), with s(n) = 1 exactly for odd n. No: g_s(2) is 4 or 5, and 3 \cdot 2 = 6.
- (0, 0, 1, 1, 0, 1, 0, 1, 0, 0). The function with f(n) = 1 when 3 \mid n and 0 otherwise.
- Length-4 strings start at position 15 with 0000, so w_{20} is the sixth of them, 0101 (5 in base 2). 1101 is 13 in base 2, so it is at position 15 + 13 = 28.
- The listed strings are exactly those with finitely many nonzero digits, and t uses only 4s and 5s, so it has infinitely many. It is the reversed digit string of no natural number. The argument shows these strings do not exhaust all digit strings, nothing about \mathbb{N}.
- Proof. x \in (0, 1) and, as in the proof of Result 4, x \ne a_n for every n. Every rational number in (0, 1) is some a_n, so x is not rational. \square
- Proof. If x^2 = q is rational then q \ge 0 and \displaystyle x = \sqrt{q} or \displaystyle x = -\sqrt{q}. So the reals with x^2 rational are the union of the images of the nonnegative rationals under \displaystyle q \mapsto \sqrt{q} and \displaystyle q \mapsto -\sqrt{q}, two countable sets, so countable. The rest of \mathbb{R} is uncountable, as in Result 7. \square
- Proof. Every f \in F has f(0) = 0, so no new function can differ from f_0 in place 0. Shift by one: given a list f_0, f_1, \dots of F, put g(0) = 0 and g(n + 1) = 1 if f_n(n + 1) = 0, otherwise g(n + 1) = 0. Then g(m) \le m for all m, so g \in F, and g \ne f_n in place n + 1. F is nonempty, so Result 1 applies. \square
- Proof. An eventually periodic sequence is u followed by v repeated forever, for a finite string u and a nonempty finite string v. Send the string u\#v over \{0, 1, \#\} to that sequence. This is onto the eventually periodic sequences from a subset of the countable set of strings (Countable sets, Results 5 and 9), so they are countable (Result 4 there). The rest of \{0, 1\}^{\mathbb{N}} is uncountable, by the argument of Result 7. \square