Topology
Compact Set
The topology that makes maxima exist
A subset K of a topological space is compact if every collection of open sets that covers K has a finite subcollection that still covers K. In metric spaces this is equivalent to sequential compactness — every sequence in K has a convergent subsequence with limit in K — and to being complete and totally bounded. Compactness is the property that makes "infinite" behave like "finite" for analytic purposes: continuous functions on compact sets attain their extrema, are uniformly continuous, and map compact sets to compact sets.
- DefinitionEvery open cover has finite subcover
- Metric equivalenceSequentially compact
- In ℝⁿClosed and bounded (Heine-Borel)
- Continuous imageCompact
- Continuous f : K → ℝAttains max and min
Watch the 60-second explainer
A condensed visual walkthrough — narrated, captioned, under a minute.
The open-cover definition
Let X be a topological space and K ⊆ X. An open cover of K is a collection { U_α : α ∈ A } of open subsets of X with K ⊆ ⋃_α U_α. The cover is finite if A is a finite index set, and a subcover is a sub-collection whose union still contains K.
K is compact if every open cover of K has a finite subcover.
The definition is striking because it is "every", not "some". You aren't allowed to choose the cover — every imaginable open cover, however cleverly designed, must reduce to a finite subcover. This is what gives compactness its leverage.
An equivalent dual formulation in terms of closed sets: K is compact iff every collection of closed subsets of K with the finite intersection property (every finite sub-collection has non-empty intersection) has non-empty total intersection. This dual form is sometimes more convenient for proofs.
Three equivalent definitions in metric spaces
For metric spaces (and more generally first-countable Hausdorff spaces), three apparently different definitions coincide:
| Definition | Statement | Generalizes to | Easy to verify when… | Hard to verify when… |
|---|---|---|---|---|
| Cover compactness | Every open cover has a finite subcover | Arbitrary topological spaces | The space has an obvious finite description | You must reason about all covers |
| Sequential compactness | Every sequence has a convergent subsequence with limit in K | First-countable spaces (incl. all metric spaces) | Working with explicit sequences | Non-metric topologies — sequences may be too weak |
| Complete + totally bounded | Every Cauchy sequence converges in K, and K is covered by finitely many ε-balls for every ε | Metric spaces | You already know completeness and can construct ε-nets | Verifying total boundedness in infinite dimensions |
| Closed + totally bounded (in complete ambient space) | K closed in X, X complete, K totally bounded | Metric spaces, useful subset criterion | The ambient space's completeness is known | Same as above |
| Bolzano-Weierstrass property | Every infinite subset has an accumulation point in K | Metric spaces | Working with explicit limit-point arguments | Non-Hausdorff or non-first-countable settings |
| Closed and bounded (Heine-Borel) | K closed in ℝⁿ and contained in some ball | Only ℝⁿ (and a few isomorphic spaces) | Quick verification in finite dimensions | Infinite-dimensional spaces — the criterion fails |
The last row is critical: closed-and-bounded characterizes compactness only in finite-dimensional Euclidean space. In ℓ², in C([0, 1]), in any infinite-dimensional Banach space, the closed unit ball is closed and bounded but not compact.
Heine-Borel theorem
A subset K of ℝⁿ (with the standard Euclidean metric) is compact if and only if K is closed and bounded.
Proof sketch. (⇒) If K is compact, it is bounded — cover K with the unit balls B(x, 1) and extract a finite subcover; the union is bounded. K is also closed — if y ∉ K, separate y from K with disjoint open balls (Hausdorff property), pull a finite subcover, and the complement of K contains an open ball around y, so K^c is open.
(⇐) If K is closed and bounded, embed K in a closed cube [−R, R]ⁿ for large enough R. We prove [−R, R]ⁿ is compact, which implies K is compact (closed subset of compact is compact). Suppose, for contradiction, an open cover { U_α } of [−R, R]ⁿ has no finite subcover. Bisect each side and split the cube into 2ⁿ sub-cubes; at least one has no finite subcover. Repeat. The result is a nested sequence of cubes whose diameter shrinks to 0; their unique common point p is in some U_β, which contains an open ball around p, which contains some sub-cube — contradicting that the sub-cube had no finite subcover. □
Heine-Borel works because ℝⁿ is finite-dimensional. The proof's bisection argument needs only finitely many splits per round, and there are no "transverse" directions to escape into.
Why Heine-Borel fails outside ℝⁿ
Consider ℓ², sequences (xₙ) of real numbers with Σ|xₙ|² < ∞, with the inner-product metric. Let e_k = (0, …, 0, 1, 0, …) with 1 in the k-th coordinate. The set { e_k : k = 1, 2, … } has all elements of norm 1, so it lies inside the closed unit ball. The unit ball is closed and bounded.
But d(e_i, e_j) = √(1 + 1) = √2 for any i ≠ j. So no subsequence of (e_k) is Cauchy, hence no subsequence converges. The closed unit ball in ℓ² is not sequentially compact, hence not compact.
The general principle (Riesz's lemma / Riesz's theorem): the closed unit ball of a normed vector space is compact iff the space is finite-dimensional.
The extreme value theorem
If K is a non-empty compact set and f : K → ℝ is continuous, then f attains a maximum and minimum on K.
Proof. The image f(K) is compact (continuous image of compact is compact), so f(K) is closed and bounded in ℝ. A bounded subset of ℝ has a finite supremum M and infimum m. Closedness means M ∈ f(K) and m ∈ f(K), so there are points x*, x_* ∈ K with f(x*) = M, f(x_*) = m. □
This is the fundamental existence theorem of optimization. Without compactness, suprema may exist as limits but not be attained: f(x) = x on (0, 1) has supremum 1 but no maximum.
Compactness preserved or destroyed
| Operation | Preserves compactness? | Why |
|---|---|---|
| Closed subset of compact | Yes | Cover the closed subset, throw in the open complement, extract a finite subcover. |
| Continuous image f(K) | Yes | Pull back any open cover of f(K) through f and use compactness of K. |
| Finite union K₁ ∪ K₂ ∪ … ∪ Kₙ | Yes | Combine finite subcovers from each. |
| Arbitrary intersection of compact sets in Hausdorff space | Yes (each is closed, intersection is closed and inside any one) | Hausdorff implies compact ⟹ closed. |
| Finite Cartesian product K₁ × K₂ | Yes | Tube lemma; bounded number of factors lets the cover argument work. |
| Arbitrary product of compact spaces | Yes (Tychonoff's theorem) | Equivalent to the axiom of choice. |
| Open subset of compact | Generally NO | (0, 1) is open inside compact [0, 1] but not itself compact. |
| Quotient by an equivalence relation | Yes if quotient map is continuous | Continuous image preserves compactness. |
| Removing a single point | Generally NO | [0, 1] \ {0} = (0, 1] is bounded but not compact. |
Why compactness matters in practice
- Existence of optimizers. The extreme value theorem is why optimization problems on closed bounded regions in ℝⁿ have solutions. Without compactness (e.g. unbounded domains, or removing limit points), supremum may exist but not be attained.
- Uniform continuity. Heine-Cantor: a continuous function on a compact set is uniformly continuous. This drives error analysis in numerical integration and approximation theory.
- Convergence of subsequences. Bolzano-Weierstrass: every bounded sequence in ℝⁿ has a convergent subsequence. The workhorse of every existence proof in dynamical systems and PDEs that proceeds by extracting limits.
- Probability and convergence. Tightness of measures (a probabilistic compactness condition) drives Prokhorov's theorem: a tight family of probability measures has a weakly convergent subsequence. The basis of the central limit theorem and limit theorems for stochastic processes.
- Functional analysis. Compact operators (those mapping bounded sets to relatively compact sets) generalize finite-rank operators and have a clean spectral theory — the spectral theorem for compact self-adjoint operators is the infinite-dimensional analogue of diagonalization.
- Algebraic topology. Compact spaces have well-behaved cohomology; non-compact spaces require extra machinery (compactly supported cohomology). Compactness is needed for Lefschetz, Poincaré duality, and most fixed-point theorems.
Compact and non-compact, side by side
- Compact: [0, 1], [0, 1]ⁿ, the unit sphere Sⁿ⁻¹ ⊂ ℝⁿ, the Cantor set, every finite set, every closed bounded subset of ℝⁿ, the Hilbert cube ∏ [0, 1/n] ⊂ ℓ², any closed subset of a compact space, the one-point compactification ℝ ∪ {∞}.
- Not compact: ℝ itself (unbounded), (0, 1) (not closed), {1/n : n ≥ 1} (limit point 0 missing), the closed unit ball in ℓ² (not totally bounded), any unbounded set in ℝⁿ, the rationals [0, 1] ∩ ℚ (not complete in ℝ), the integers ℤ in ℝ (unbounded).
Tychonoff's theorem and the axiom of choice
The product of any family of compact spaces is compact. For finite products this is elementary; for arbitrary (even uncountable) products it is a deep result, equivalent to the axiom of choice.
Tychonoff's theorem powers the existence of free ultrafilters, the Banach-Alaoglu theorem (the closed unit ball of the dual of a normed space is weak-* compact), and the construction of Stone-Čech compactifications. Removing the axiom of choice makes the theorem fail — a hint that compactness is more subtle than its elementary statement suggests.
Local compactness
A space X is locally compact if every point has a compact neighborhood. ℝⁿ is locally compact even though it isn't compact, and locally compact Hausdorff spaces support a particularly rich theory: Riesz representation theorem (regular Borel measures correspond to positive linear functionals on Cc(X)), Pontryagin duality for locally compact abelian groups, and the existence of a Haar measure on locally compact groups.
Most "real-world" spaces are locally compact: ℝⁿ, manifolds, finite-dimensional Lie groups. Many infinite-dimensional spaces (Hilbert spaces, function spaces) are not, and this is the technical reason analysis on them is harder.
Common mistakes
- "Compact = closed and bounded" outside ℝⁿ. The single most pervasive error. Heine-Borel is a finite-dimensional miracle; in any infinite-dimensional Banach space the closed unit ball is closed and bounded but not compact. Always work from total-boundedness or sequential compactness in infinite dimensions.
- Confusing bounded with totally bounded. In ℝⁿ they coincide; in infinite-dimensional metric spaces they don't. Bounded means "contained in some ball"; totally bounded means "for every ε there is a finite ε-net". Total boundedness is the right strengthening for compactness.
- Forgetting that subsets must be closed. The interval [0, 1] is compact but the sub-interval (0, 1) is not. If you want a compact subset, take a closed subset of a compact set.
- Conflating sequential compactness with cover compactness in non-metric spaces. In general topological spaces these can differ. The two notions coincide in metric spaces, more generally in first-countable Hausdorff spaces, and in many practical settings — but not in all.
- Believing continuous bijection ⟹ homeomorphism. Generally false. True if the domain is compact and the codomain is Hausdorff: a continuous bijection from a compact space to a Hausdorff space is automatically a homeomorphism, because closed sets map to compact sets which are closed.
- Treating "open and bounded" as a stand-in for compact. An open ball is bounded but never compact (its boundary points are missing). Compactness needs closure.
Frequently asked questions
Why isn't bounded enough? Why also closed?
The half-open interval (0, 1] is bounded but not compact. The sequence 1/n stays in (0, 1] but converges to 0 — outside the set — so no subsequence converges within the set. Closing the interval to [0, 1] adds the limit point 0 and restores compactness. "Closed" in this context means "contains all its limit points".
Why does the open-cover definition matter?
It generalizes to arbitrary topological spaces, where "sequence" is too weak (limits may not detect what's happening) and "closed-and-bounded" may not even be defined. The open-cover formulation is also what makes compactness preserve under continuous images: f(K) is compact whenever K is, regardless of what space K lives in.
What's a non-trivial example of a closed-and-bounded set that isn't compact?
The closed unit ball in ℓ², the space of square-summable sequences. The standard basis vectors e₁ = (1, 0, 0, …), e₂ = (0, 1, 0, …), … all have norm 1 and lie in the unit ball, but d(eᵢ, eⱼ) = √2 for i ≠ j, so no subsequence is Cauchy, let alone convergent. Heine-Borel is a finite-dimensional miracle.
Why does compactness guarantee a maximum?
If f : K → ℝ is continuous and K is compact, then f(K) is compact (continuous image of compact is compact), hence closed-and-bounded in ℝ. A bounded set has a finite supremum; closedness ensures the supremum is attained. So min and max both exist — the extreme value theorem in its sharpest form.
What is total boundedness?
A subset K of a metric space is totally bounded if for every ε > 0, K can be covered by finitely many ε-balls. It is strictly stronger than boundedness in infinite dimensions. Total boundedness plus completeness equals compactness (the Hausdorff criterion); in ℝⁿ total boundedness reduces to ordinary boundedness.
Can the Cantor set be compact even though it's uncountable and has no interior?
Yes. The Cantor set is closed (it's the intersection of closed sets in [0, 1]) and bounded, so by Heine-Borel it is compact in ℝ. Compactness has nothing to do with size in the cardinality sense or interior-richness — it's about how covers and sequences behave.