Foundations
Cantor's Theorem and Uncountability
Cantor's diagonal argument proves the reals are uncountable. The power set of any set has strictly greater cardinality. These results are the origin of the distinction between countable and uncountable infinity.
Why This Matters
Not all infinite sets are the same size. The natural numbers, the integers, and the rationals are all countable: you can list them. The real numbers are not. This distinction is not a curiosity. It is the reason that complexity measures like VC dimension exist.
The set of all computer programs is countable (they are finite strings over a finite alphabet). The set of all functions from to is uncountable. So most functions cannot be computed by any program. In ML terms: the hypothesis class of all possible classifiers is uncountably infinite, which is why you must restrict to a learnable subclass and measure its complexity.
Core Definitions
Countable Set
A set is countable if there exists an injection . Equivalently, is countable if it is finite or if there exists a bijection (countably infinite).
Uncountable Set
A set is uncountable if it is infinite and there is no bijection between and . No listing can exhaust .
Cardinality
Two sets and have the same cardinality, written , if there exists a bijection . We write if there exists an injection from to . The Cantor-Bernstein theorem says: if and , then .
Power Set
The power set of , written , is the set of all subsets of :
For finite with , we have .
Main Theorems
Uncountability of the Reals
Statement
The set of real numbers is uncountable. More precisely, the interval is uncountable.
Intuition
No matter how you try to list the reals in as a sequence , there is always a real number your list misses. The diagonal argument constructs this missing number explicitly.
Proof Sketch
Assume for contradiction that is countable. List all elements as , writing each in decimal as . Construct a new number where (and to avoid issues with non-unique representations). Then but for every , since and differ in the -th decimal digit. This contradicts the assumption that the list contains all of .
Why It Matters
This is the first proof that infinity is not a single concept. There are strictly more real numbers than natural numbers. The argument pattern (diagonalization) reappears throughout mathematics and computer science: the halting problem, Godel's incompleteness theorems, and the existence of non-computable functions all use variants of it.
Failure Mode
The proof does not work for the rationals. Every rational has a terminating or repeating decimal, and the number constructed by the diagonal argument is generically irrational. The rationals are countable despite being dense in .
Cantor's Theorem
Statement
For any set , there is no surjection from onto . Therefore : the power set is strictly larger.
Intuition
You cannot pair up elements of with subsets of so that every subset gets paired. There are always leftover subsets. The proof constructs one such leftover subset explicitly using diagonalization.
Proof Sketch
Let be any function. Define . Claim: is not in the range of . If for some , then , a contradiction. So is not surjective. Since the injection shows , we conclude .
Why It Matters
Cantor's theorem guarantees an infinite hierarchy of infinite cardinalities: . There is no largest infinity. This is also the template for Russell's paradox (consider the set of all sets that do not contain themselves), which motivated axiomatic set theory.
Failure Mode
The theorem requires the axioms of separation (to form the set ) and power set (for to exist). In weaker set theories or constructive settings, the precise formulation matters.
Connection to Computability
The set of all Turing machines (equivalently, all programs) is countable: each program is a finite string, and the set of finite strings over any finite alphabet is countable. But the set of all functions has cardinality , which by Cantor's theorem is uncountable.
Therefore: most functions from to are not computable. No program computes them. This is not a conjecture; it follows directly from a counting argument.
Connection to ML
The hypothesis class of all binary classifiers on (all functions ) has cardinality , which is uncountably infinite. The ERM generalization bound for finite hypothesis classes gives a gap of , which is infinite for uncountable .
This is why complexity measures exist. VC dimension, Rademacher complexity, and covering numbers are all ways to assign a finite "effective size" to an infinite hypothesis class, making generalization bounds non-vacuous.
Common Confusions
The rationals are dense but countable
Density and countability are independent properties. The rationals are dense in (between any two reals there is a rational), yet is countable. Density is a topological property; countability is a set-theoretic one.
Cantor's theorem does not say which cardinality the reals have
Cantor proved , but did not determine whether (the next cardinal after ). The claim is the Continuum Hypothesis, which is independent of ZFC. It can be neither proved nor disproved from the standard axioms.
Exercises
Problem
Prove that the set of all finite binary strings is countable.
Problem
Using Cantor's theorem, prove that there exists a function that is not computable by any Turing machine.
Problem
Let be the set of all binary classifiers on . Show that is uncountable and explain why the finite-class ERM bound does not apply.
References
Canonical:
- Halmos, Naive Set Theory (1960), Sections 1-4 and 25
- Enderton, Elements of Set Theory (1977), Chapter 6
Connection to CS:
- Sipser, Introduction to the Theory of Computation (2013), Section 4.2
Connection to ML:
-
Shalev-Shwartz & Ben-David, Understanding Machine Learning (2014), Chapter 2
-
Munkres, Topology (2000), Chapter 1 (set theory review)
Next Topics
- Zermelo-Fraenkel set theory: the axiomatic framework that makes Cantor's arguments rigorous
- Godel's incompleteness theorems: another limit result using diagonalization
Last reviewed: April 2026
Builds on This
- Godel's Incompleteness TheoremsLayer 0A