Skip to content

Compactness

In this lesson you’ll define compactness by open covers, learn what it buys you, prove that continuous images of compact sets are compact, and use it to recover the extreme value theorem in a line.

An open cover of XX is a family of open sets whose union is XX.

XX is compact if every open cover has a finite subcover.

The two quantifiers matter and are easy to swap by accident. It is every cover that must reduce, and it must reduce to some finite subfamily. Exhibiting one cover with a finite subcover proves nothing; exhibiting one cover without one proves non-compactness.

The figure works both directions. On the left, a cover of [0,1][0,1] is reduced by a greedy left-to-right sweep, and the number of sets needed is computed. On the right, the cover of (0,1](0,1] by the sets (1n,2)\left(\frac1n,2\right) resists: any finite subfamily has a largest nn, and everything in (0,1n]\left(0,\frac1n\right] is left out. The figure computes the length of that gap for the subfamily shown.

Those two intervals differ by a single point, and that point is the whole difference.

For KXK\subseteq X, compactness is checked in the subspace topology - equivalently, using covers by sets open in XX. Both formulations give the same answer, and the second is usually more convenient.

Heine–Borel theorem. A subset of Rn\mathbb{R}^n is compact if and only if it is closed and bounded.

This is the theorem that makes compactness usable in analysis, and it is worth being clear that it is a theorem about Rn\mathbb{R}^n, not a definition. In general metric spaces closed and bounded does not imply compact: the closed unit ball of an infinite-dimensional Hilbert space is closed and bounded and not compact.

Examples in Rn\mathbb{R}^n: [a,b][a,b] is compact; (0,1)(0,1) is not, being non-closed; [0,)[0,\infty) is not, being unbounded; a sphere is compact; Z\mathbb{Z} is not.

Continuous images. If f:XYf:X\to Y is continuous and XX is compact, then f(X)f(X) is compact.

Proof. Let {Vi}\{V_i\} cover f(X)f(X). The preimages {f1(Vi)}\{f^{-1}(V_i)\} cover XX and are open, so finitely many suffice, and the corresponding ViV_i cover f(X)f(X). ∎

Extreme value theorem. A continuous real function on a compact space is bounded and attains its maximum and minimum.

Proof. f(X)f(X) is a compact subset of R\mathbb{R}, hence closed and bounded by Heine–Borel. A nonempty closed bounded set contains its supremum and infimum, so both are attained. ∎

One line, once you have the right invariant. That is the same pattern as connectedness giving the intermediate value theorem.

Other standard consequences:

  • Closed subsets of compact spaces are compact.
  • Compact subsets of Hausdorff spaces are closed. Without Hausdorff this fails.
  • A continuous bijection from a compact space to a Hausdorff space is a homeomorphism - the free inverse-continuity from lesson 6.
  • On a compact metric space, every continuous function is uniformly continuous.
  • Finite products. A product of compact spaces is compact; for infinite products this is Tychonoff’s theorem, which is equivalent to the axiom of choice.
  • A compact space has the finite intersection property: a family of closed sets with all finite intersections nonempty has nonempty total intersection.

[0,1][0,1] is compact and its subspace (0,1)(0,1) is not. Only closed subspaces inherit compactness, which is the same pattern seen with completeness.

Because it is preserved by homeomorphisms, compactness is an invariant, and it is often the quickest one: [0,1]≇(0,1)[0,1]\not\cong(0,1) and S1≇RS^1\not\cong\mathbb{R} both follow immediately.

  • Sequentially compact - every sequence has a convergent subsequence. Equivalent to compact in metric spaces, not in general.
  • Limit point compact - every infinite subset has a limit point. Weaker in general.
  • Locally compact - every point has a compact neighbourhood. Rn\mathbb{R}^n qualifies; infinite-dimensional spaces generally do not.
  • σ\sigma-compact - a countable union of compact sets, as R\mathbb{R} is.

The equivalences in metric spaces are the subject of the next lesson.

Open covers are not an obvious thing to axiomatize, and it is fair to ask why this is the right notion. Two answers.

It is the topological version of finiteness. A finite space is compact trivially, and compactness lets you run arguments that need “finitely many cases” on infinite spaces. Every proof above is really the finite case plus a cover argument.

It is exactly what makes the theorems true. Boundedness is not topological, since (0,1)R(0,1)\cong\mathbb{R}. Compactness is, and it is the hypothesis that the extreme value theorem, uniform continuity, and the closed-map results actually need.

Example 1: Show (0,1)(0,1) is not compact.

Solution. Take the cover {(1n,1):n2}\left\{\left(\frac1n,1\right) : n\ge2\right\}, which covers (0,1)(0,1) since every x>0x>0 exceeds some 1n\frac1n.

Any finite subfamily has a largest index NN, so its union is (1N,1)\left(\frac1N,1\right), missing everything in (0,1N]\left(0,\frac1N\right].

Answer: no finite subcover, so not compact. ∎

Example 2: Show R\mathbb{R} is not compact.

Solution. The cover {(n,n):nN}\{(-n,n) : n\in\mathbb{N}\} has union R\mathbb{R}. Any finite subfamily is contained in the largest (N,N)(-N,N), which misses NN.

Answer: not compact. ∎

Example 3: Show a closed subset of a compact space is compact.

Solution. Let CXC\subseteq X be closed with XX compact, and let {Ui}\{U_i\} be a cover of CC by open sets of XX.

Adding XCX\setminus C, which is open, gives an open cover of XX. Compactness yields a finite subcover, and discarding XCX\setminus C from it leaves finitely many UiU_i still covering CC.

C is compactC \text{ is compact}

Example 4: Prove the extreme value theorem.

Solution. Let f:KRf:K\to\mathbb{R} be continuous with KK compact and nonempty.

f(K)f(K) is compact, hence closed and bounded in R\mathbb{R}. Being bounded, it has a supremum MM; being closed, it contains MM. So M=f(x0)M=f(x_0) for some x0Kx_0\in K, and similarly for the infimum. ∎

Example 5: Show compact subsets of a Hausdorff space are closed, and that Hausdorff is needed.

Solution. In a Hausdorff space XX with KK compact, take yKy\notin K. For each xKx\in K choose disjoint open UxxU_x\ni x and VxyV_x\ni y. The UxU_x cover KK, so finitely many do, and intersecting the corresponding VxV_x gives an open set around yy missing KK. Hence XKX\setminus K is open.

For the failure, take X={a,b}X=\{a,b\} with the trivial topology. The subset {a}\{a\} is compact, being finite, but it is not closed: its complement {b}\{b\} is not open. ∎

Example 6: Show a finite space is always compact.

Solution. Any open cover of a finite space has, for each point, at least one member containing it. Choosing one such member per point gives a subcover with at most X|X| elements.

Answer: compact. ∎

This is the sense in which compactness generalizes finiteness, and it is worth keeping as the guiding intuition.

Example 7: Show closed and bounded does not imply compact in general metric spaces.

Solution. In the space of square-summable sequences 2\ell^2, take the standard basis vectors ene_n, each with a single 1 in position nn. The set {en}\{e_n\} is bounded, since every element has norm 1, and closed, since the points are all at distance 2\sqrt2 from each other and so the set has no limit points.

The open balls B(en,12)B(e_n,\frac12) cover it, each containing exactly one point, so no finite subfamily covers an infinite set.

Answer: closed, bounded, not compact. ∎

Heine–Borel is special to Rn\mathbb{R}^n, and this is the standard reminder. The failure is what makes infinite-dimensional analysis genuinely different.

Optimization. Existence of a solution is guaranteed on a compact feasible set and can fail otherwise. Minimizing 1/x1/x on (0,1](0,1] has no solution, which is exactly the non-compactness in the figure showing up as an engineering problem.

Numerical error bounds. On a compact domain a continuous error function attains a worst case, so a maximum error can be quoted. On a non-compact domain the supremum may not be attained and may not even be finite.

Economics. Existence of equilibria is proved with fixed-point theorems whose hypotheses include compactness of the strategy or price set. Compactifying the space is a standard modelling step.

Control theory. Reachable sets are often shown to be compact so that optimal controls exist. Without it, an optimal control may be approached but never achieved.

Machine learning. Bounding a parameter space to make it compact is what lets uniform convergence and generalization arguments go through, and it is why weight constraints appear in theoretical guarantees.

Logic and computation. The compactness theorem of first-order logic - that a set of sentences with all finite subsets satisfiable is satisfiable - is literally topological compactness of a space of models, which is where the name came from.

What does it mean for X to be compact?
Which cover shows (0, 1) is not compact?
What does the Heine–Borel theorem say, and where does it apply?
What happens to compactness under a continuous map?
How does compactness give the extreme value theorem?
Which subspaces of a compact space are guaranteed compact?
Why are compact subsets of a Hausdorff space closed, and why is Hausdorff needed?
In what sense does compactness generalize finiteness?