The Daily Reckoning
Can You List Every Infinite String of Zeros and Ones?
Assume every endless binary sequence has been numbered. One diagonal walk then constructs a sequence that the list must have missed.
- Difficulty
- Intermediate
- Area
- Logic and foundations
- Reading time
- 9 minutes
- Prerequisites
- Sets and functions · One-to-one correspondence · Proof by contradiction
Suppose someone claims to have numbered every endless sequence made from s and s:
You cannot inspect the whole list. Each row is infinite, and there are infinitely many rows. Yet one precise construction can prove that the list is incomplete.
The construction does not search for a gap. It manufactures a new sequence designed to disagree with row , row , row , and every later row.
Escape along the diagonal
The diagram below shows the first six rows and first six positions of an imagined list. Move through its four stages. The highlighted diagonal takes one bit from each row; flipping those bits produces the escape sequence.
Step-through proof
Build the sequence that the list cannot contain
Step 1: Pretend these rows begin a complete list of every infinite binary sequence.
| row | bit 1 | bit 2 | bit 3 | bit 4 | bit 5 | bit 6 | … |
|---|---|---|---|---|---|---|---|
| s1 | 0 | 1 | 0 | 0 | 1 | 1 | … |
| s2 | 1 | 1 | 0 | 1 | 0 | 0 | … |
| s3 | 0 | 0 | 0 | 1 | 1 | 0 | … |
| s4 | 1 | 0 | 1 | 1 | 0 | 1 | … |
| s5 | 0 | 1 | 1 | 0 | 0 | 1 | … |
| s6 | 1 | 0 | 0 | 1 | 1 | 0 | … |
| d | 1 | 0 | 1 | 0 | 1 | 1 | … |
The six-row display is only a window into an infinite argument. If the proposed list continues through every positive integer, the diagonal rule continues with it. Row is defeated at bit .
The claim, stated precisely
Let be the set of all infinite binary sequences. An element of has the form
Here, is the bit in position . A set is countable if its elements can be placed in a finite list or in a list indexed by the positive integers . Equivalently, an infinite set is countable when there is a one-to-one correspondence between that set and the positive integers.
Cantor’s diagonal claim: the set is uncountable. No sequence
can contain every element of .
To prove the claim, assume the opposite. Suppose a complete list exists. Write the bit in row and position as , so row is
Now define a new infinite sequence
by the rule
The symbol means the bit where row meets position : a diagonal entry. Because each bit is either or , subtracting it from flips it.
For every positive integer ,
Therefore differs from in at least position . It follows that
for every row . The supposedly complete list omits , contradicting the assumption that the list contains every infinite binary sequence. Thus is uncountable.
The proof does not depend on the entries chosen for the proposed list. Give the list any order and any rows; the same rule builds a sequence outside it.
Worked example: defeating six named rows
Consider the visible prefixes
Read the diagonal from upper left to lower right:
Flip every diagonal bit:
Now compare deliberately, not visually:
- differs from at bit : .
- differs from at bit : .
- differs from at bit : .
- differs from at bit : .
- differs from at bit : .
- differs from at bit : .
The displayed prefix already rules out the six displayed rows. In the full proof, the same comparison rules out every row of the infinite list.
Why finite strings behave differently
Every finite binary string can be listed. Group the strings by length, then use dictionary order within each group:
The symbol denotes the empty string, whose length is zero. Every finite string has some finite length , so it appears in the finite block containing all strings of length .
Infinite sequences have no final length block. The diagonal construction exploits one new position for each proposed row. “Made from only two symbols” does not imply “countable.”
Try the diagonal rule
Problem 1
An imagined list begins with these four rows:
Find the first four bits of the diagonal escape sequence . State which position proves that differs from each displayed row.
Reveal the solution
The diagonal is
Flip those four bits:
The first bit separates from , the second bit separates from , the third bit separates from , and the fourth bit separates from .
Problem 2
Explain why the set of all computer programs written in a fixed programming language is countable, even when programs may be arbitrarily long.
Reveal the solution
A program is a finite string over a finite alphabet of characters. List every one-character string, then every two-character string, then every three-character string, continuing by length. Discard strings that are not syntactically valid programs.
Removing invalid strings leaves a list that still contains every valid program. Therefore the set of programs in the language is countable.
From trigonometric series to different infinities
Georg Cantor did not begin by trying to rank infinities. At the University of Halle, Eduard Heine asked him to study when a function has a unique representation as a trigonometric series. Exceptional sets of points forced Cantor to decide when two infinite collections should count as the same size. The University of St Andrews biography of Cantor traces that path from analysis into set theory.
In 1873 Cantor showed that the rational and algebraic numbers are countable. His 1874 paper gave his first proof that the real numbers are not countable. The short diagonal proof came later, in the 1891 paper Über eine elementare Frage der Mannigfaltigkeitslehre (“On an elementary question of the theory of manifolds”). Cantor phrased the argument with two-valued functions—the same structure as infinite binary sequences.
The surrounding mathematical culture was not uniformly welcoming. Leopold Kronecker rejected Cantor’s treatment of completed infinities, and his editorial influence delayed Cantor’s 1877 work on dimension until Richard Dedekind intervened. Cantor nevertheless helped found the German Mathematical Society in 1890 and chaired its first meeting in Halle in 1891. The dispute was not only personal: it exposed a divide over which infinite objects mathematics was entitled to treat as completed wholes.
What the diagonal unlocks
Each infinite binary sequence identifies a subset of the positive integers: include in the subset exactly when bit equals . The lesson’s proof therefore shows that the power set of the positive integers—the set of all their subsets—is larger than the positive integers themselves. Cantor’s general theorem goes further: for every set , its power set has strictly greater cardinality than .
The contrast with programs has a sharp consequence. Programs are finite strings, so there are only countably many programs. Infinite binary sequences are uncountable. Most infinite binary sequences therefore cannot be produced, bit by bit, by any program. This is a counting statement, not a practical complaint about slow computers.
A close relative of diagonal reasoning also marks the limits of automated analysis. In his 1936 paper “On Computable Numbers, with an Application to the Entscheidungsproblem”, Alan Turing encoded machines and showed that no general procedure can settle every question of whether a machine will continue computing. Modern tools can prove termination for many particular programs, but no sound algorithm can decide termination correctly for every possible program and input.
One idea to remember
To defeat a purported complete list, do not search it. Build one object whose th feature is chosen to disagree with the th entry. One disagreement per row is enough to escape them all.
To continue, compare this construction with Gödel’s limits on formal proof or study Cantor’s theorem for arbitrary power sets.
Sources
- Georg Cantor, Über eine elementare Frage der Mannigfaltigkeitslehre, Jahresbericht der Deutschen Mathematiker-Vereinigung, volume 1, 1891, pages 75–78.
- J. J. O’Connor and E. F. Robertson, “Georg Ferdinand Ludwig Philipp Cantor”, MacTutor History of Mathematics, University of St Andrews, updated October 1998.
- José Ferreirós, “The Early Development of Set Theory”, Stanford Encyclopedia of Philosophy, substantive revision December 3, 2025.
- A. M. Turing, “On Computable Numbers, with an Application to the Entscheidungsproblem”, Proceedings of the London Mathematical Society, series 2, volume 42, 1937, pages 230–265; received May 28, 1936.