Beta. Content is under active construction and has not been peer-reviewed. Report errors on GitHub.Disclaimer

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.

CoreTier 2Stable~35 min

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 {0,1}{0,1}\{0,1\}^* \to \{0,1\} 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

Definition

Cardinality

Two sets AA and BB have the same cardinality, written A=B|A| = |B|, if there exists a bijection f:ABf: A \to B (as defined in sets, functions, and relations). Cardinality extends the notion of "size" from finite sets to infinite ones.

Definition

Countable Set

A set SS is countable if SN|S| \leq |\mathbb{N}|. Equivalently, SS is countable if it is finite or there exists a bijection f:NSf: \mathbb{N} \to S. A countably infinite set has cardinality 0\aleph_0.

Definition

Uncountable Set

A set SS is uncountable if no surjection f:NSf: \mathbb{N} \to S exists. Equivalently, no enumeration s1,s2,s3,s_1, s_2, s_3, \ldots can list all elements of SS.

Countability Results

Z\mathbb{Z} is countable. List the integers as 0,1,1,2,2,3,3,0, 1, -1, 2, -2, 3, -3, \ldots This is an explicit bijection with N\mathbb{N}.

Q\mathbb{Q} is countable. Arrange all fractions a/ba/b in a grid indexed by (a,b)(a, b) and traverse diagonally (Cantor's pairing argument), skipping duplicates.

A countable union of countable sets is countable. If A1,A2,A_1, A_2, \ldots are each countable, then i=1Ai\bigcup_{i=1}^{\infty} A_i is countable. Enumerate by diagonalizing over the index ii and the enumeration within each AiA_i.

Main Theorems

Theorem

Uncountability of the Reals

Statement

The set R\mathbb{R} is uncountable. More precisely, the interval [0,1][0, 1] is uncountable: there is no surjection from N\mathbb{N} onto [0,1][0, 1].

Intuition

Any proposed list of real numbers in [0,1][0, 1] must miss at least one. The diagonal argument constructs that missing number explicitly by differing from the nn-th listed number in its nn-th decimal digit.

Proof Sketch

Suppose r1,r2,r3,r_1, r_2, r_3, \ldots is a list of all numbers in [0,1][0, 1]. Write each rnr_n in decimal. Define a new number dd whose nn-th digit differs from the nn-th digit of rnr_n (e.g., if the digit is 5, make it 6; otherwise make it 5). Then drnd \neq r_n for every nn because they differ in the nn-th digit. So d[0,1]d \in [0, 1] is not in the list. Contradiction.

Why It Matters

This is the first proof that different sizes of infinity exist. It establishes that R>N|\mathbb{R}| > |\mathbb{N}|, which has consequences throughout mathematics. In CS: the set of Turing machines is countable, the set of languages over {0,1}\{0,1\} is uncountable, so most languages are undecidable.

Failure Mode

The proof requires care with decimal representations. Numbers like 0.999=1.0000.999\ldots = 1.000\ldots have two representations. The standard fix is to avoid using 0 and 9 as replacement digits (use only digits 5 and 6, for instance).

Theorem

Cantor's Theorem

Statement

For any set SS, the power set P(S)\mathcal{P}(S) has strictly greater cardinality than SS:

S<P(S)|S| < |\mathcal{P}(S)|

There is no surjection from SS onto P(S)\mathcal{P}(S).

Intuition

There are always more subsets of SS than elements of SS. The proof generalizes the diagonal argument: given any function f:SP(S)f: S \to \mathcal{P}(S), construct the "anti-diagonal" set D={sS:sf(s)}D = \{s \in S : s \notin f(s)\}, which cannot be in the range of ff.

Proof Sketch

Let f:SP(S)f: S \to \mathcal{P}(S) be any function. Define D={sS:sf(s)}D = \{s \in S : s \notin f(s)\}. For any sSs \in S: if sDs \in D, then sf(s)s \notin f(s), so Df(s)D \neq f(s). If sDs \notin D, then sf(s)s \in f(s), so Df(s)D \neq f(s). Either way Df(s)D \neq f(s), so ff is not surjective.

Why It Matters

This produces an infinite hierarchy of infinities: N<P(N)<P(P(N))<|\mathbb{N}| < |\mathcal{P}(\mathbb{N})| < |\mathcal{P}(\mathcal{P}(\mathbb{N}))| < \cdots. Since P(N)=R=20|\mathcal{P}(\mathbb{N})| = |\mathbb{R}| = 2^{\aleph_0}, this also shows R>N|\mathbb{R}| > |\mathbb{N}| as a corollary.

Failure Mode

The construction of DD is not circular, though it may appear so. The set DD is well-defined for any given ff. The proof shows no single ff can work, not that DD depends on an unknown ff.

Common Confusions

Watch Out

Countable does not mean you can list elements in order

Q\mathbb{Q} is countable, but any enumeration of the rationals is necessarily not in their natural order. "Countable" means a bijection with N\mathbb{N} exists; it says nothing about preserving any structure.

Watch Out

The rationals are dense but countable

Q\mathbb{Q} is dense in R\mathbb{R} (between any two reals there is a rational), yet Q\mathbb{Q} is countable while R\mathbb{R} is not. Density is a topological property. Cardinality is a set-theoretic one. They are independent.

Exercises

ExerciseCore

Problem

Prove that the set of all finite-length binary strings {0,1}\{0, 1\}^* is countable.

ExerciseAdvanced

Problem

Use Cantor's theorem to show that the set of all functions f:N{0,1}f: \mathbb{N} \to \{0, 1\} 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

Last reviewed: April 2026

Prerequisites

Foundations this topic depends on.

Next Topics