Foundations
Cardinality and Countability
Two sets have the same cardinality when a bijection exists between them. The naturals, integers, and rationals are countable. The reals are uncountable, proved by Cantor's diagonal argument.
Prerequisites
Why This Matters
The distinction between countable and uncountable sets has direct consequences for computability and learning theory. The set of all computer programs is countable (each program is a finite string). The set of all functions is uncountable. Therefore, most functions cannot be computed by any program. Similarly, most hypothesis classes in learning theory are uncountable, which is why we need complexity measures like VC dimension rather than simply counting hypotheses.
Core Definitions
Cardinality
Two sets and have the same cardinality, written , if there exists a bijection (as defined in sets, functions, and relations). Cardinality extends the notion of "size" from finite sets to infinite ones.
Countable Set
A set is countable if . Equivalently, is countable if it is finite or there exists a bijection . A countably infinite set has cardinality .
Uncountable Set
A set is uncountable if no surjection exists. Equivalently, no enumeration can list all elements of .
Countability Results
is countable. List the integers as This is an explicit bijection with .
is countable. Arrange all fractions in a grid indexed by and traverse diagonally (Cantor's pairing argument), skipping duplicates.
A countable union of countable sets is countable. If are each countable, then is countable. Enumerate by diagonalizing over the index and the enumeration within each .
Main Theorems
Uncountability of the Reals
Statement
The set is uncountable. More precisely, the interval is uncountable: there is no surjection from onto .
Intuition
Any proposed list of real numbers in must miss at least one. The diagonal argument constructs that missing number explicitly by differing from the -th listed number in its -th decimal digit.
Proof Sketch
Suppose is a list of all numbers in . Write each in decimal. Define a new number whose -th digit differs from the -th digit of (e.g., if the digit is 5, make it 6; otherwise make it 5). Then for every because they differ in the -th digit. So is not in the list. Contradiction.
Why It Matters
This is the first proof that different sizes of infinity exist. It establishes that , which has consequences throughout mathematics. In CS: the set of Turing machines is countable, the set of languages over is uncountable, so most languages are undecidable.
Failure Mode
The proof requires care with decimal representations. Numbers like have two representations. The standard fix is to avoid using 0 and 9 as replacement digits (use only digits 5 and 6, for instance).
Cantor's Theorem
Statement
For any set , the power set has strictly greater cardinality than :
There is no surjection from onto .
Intuition
There are always more subsets of than elements of . The proof generalizes the diagonal argument: given any function , construct the "anti-diagonal" set , which cannot be in the range of .
Proof Sketch
Let be any function. Define . For any : if , then , so . If , then , so . Either way , so is not surjective.
Why It Matters
This produces an infinite hierarchy of infinities: . Since , this also shows as a corollary.
Failure Mode
The construction of is not circular, though it may appear so. The set is well-defined for any given . The proof shows no single can work, not that depends on an unknown .
Common Confusions
Countable does not mean you can list elements in order
is countable, but any enumeration of the rationals is necessarily not in their natural order. "Countable" means a bijection with exists; it says nothing about preserving any structure.
The rationals are dense but countable
is dense in (between any two reals there is a rational), yet is countable while is not. Density is a topological property. Cardinality is a set-theoretic one. They are independent.
Exercises
Problem
Prove that the set of all finite-length binary strings is countable.
Problem
Use Cantor's theorem to show that the set of all functions is uncountable. Then explain why this implies most functions are not computable.
References
Canonical:
- Halmos, Naive Set Theory, Chapters 15-16
- Enderton, Elements of Set Theory, Chapter 6
Current:
-
Jech, Set Theory, 3rd millennium ed., Chapter 1
-
Munkres, Topology (2000), Chapter 1 (set theory review)
Next Topics
- Measure theory foundations: cardinality underlies why we need measure theory (not all subsets of are measurable)
Last reviewed: April 2026
Prerequisites
Foundations this topic depends on.
- Sets, Functions, and RelationsLayer 0A
- Basic Logic and Proof TechniquesLayer 0A