Compact Spaces

Compactness is the topological version of "finite." A finite set can't run away and can't have holes you approach forever without reaching. Compact spaces can be infinite, but they behave as if they were finite in exactly the ways that matter: continuous real functions on them have a maximum and a minimum, and continuous functions on them are automatically uniformly continuous. The definition is strange the first time you see it. Stick with it.

Covers and Compactness

First, the language of covers.

A collection $\mathcal{A}$ of subsets of a space $X$ is said to cover $X$, or to be a covering of $X$, if the union of the elements of $\mathcal{A}$ is equal to $X$. If $Y$ is a subspace of $X$, a collection of subsets of $X$ covers $Y$ if its union contains $Y$.

We'll only care about covers made of open sets.

A covering $\mathcal{A}$ of $X$ is an open covering of $X$ if its elements are open subsets of $X$.

Now the definition itself.

A space $X$ is said to be compact if every open covering $\mathcal{A}$ of $X$ contains a finite subcollection that also covers $X$.

The word that does all the work is every. To show a space is not compact, you only need one bad cover. To show it is compact, you have to handle all covers at once.

Show that $\mathbb{R}$ and $(0, 1)$ are not compact, and that every finite space is compact.


$\mathbb{R}$: the open cover $\{(-n, n) : n \in \mathbb{N}\}$ has no finite subcover, because finitely many of these sets have union $(-N, N)$ for the largest $N$ used.

$(0, 1)$: the open cover $\{(\frac{1}{n}, 1) : n \ge 2\}$ has no finite subcover, because finitely many of them have union $(\frac{1}{N}, 1)$, which misses $(0, \frac{1}{N}]$.

A finite space $X = \{x_1, \dots, x_k\}$: given any open cover, pick one set containing each $x_i$. That's at most $k$ sets, and they cover $X$.

Try to beat these covers yourself, and notice what changes when the endpoint $0$ is in the space.

Find a Finite Subcover

For $[0, 1]$, some set in the cover has to contain $0$, and being open in $[0, 1]$, it swallows a little interval $[0, \varepsilon)$. Then only finitely many of the other sets are needed. That's the whole idea of the proof that $[0, 1]$ is compact, later on this page.

"Every open cover has a finite subcover" is the kind of definition that sounds like it was written by a lawyer. It took mathematicians decades to agree this was the right one. It is. It's just a lawyer.

Compact Subspaces

For a subspace, you can use open sets of the big space in the covers. That saves a lot of writing "$\cap Y$."

Let $Y$ be a subspace of $X$. Then $Y$ is compact if and only if every covering of $Y$ by sets open in $X$ contains a finite subcollection covering $Y$.

Show proof

Proof. Suppose $Y$ is compact and $\mathcal{A} = \{A_\alpha\}_{\alpha \in J}$ covers $Y$ by sets open in $X$. Then $\{A_\alpha \cap Y : \alpha \in J\}$ covers $Y$ by sets open in $Y$, so by compactness a finite subcollection $\{A_{\alpha_1} \cap Y, \dots, A_{\alpha_n} \cap Y\}$ covers $Y$. Then $\{A_{\alpha_1}, \dots, A_{\alpha_n}\}$ is a finite subcollection of $\mathcal{A}$ covering $Y$.

Conversely, suppose the condition holds, and let $\mathcal{B} = \{B_\alpha\}$ cover $Y$ by sets open in $Y$. For each $\alpha$, choose $\tilde{B}_\alpha$ open in $X$ with $B_\alpha = \tilde{B}_\alpha \cap Y$. The collection $\{\tilde{B}_\alpha\}$ covers $Y$ by sets open in $X$, so by assumption a finite subcollection $\{\tilde{B}_{\alpha_1}, \dots, \tilde{B}_{\alpha_k}\}$ covers $Y$. Then $\{B_{\alpha_1}, \dots, B_{\alpha_k}\}$ covers $Y$. So $Y$ is compact. $\blacksquare$

Closed pieces of compact spaces are compact.

Every closed subspace of a compact space is compact.

Proof. Let $Y$ be a closed subspace of a compact space $X$, and let $\mathcal{A}$ cover $Y$ by sets open in $X$. Then $\mathcal{B} = \mathcal{A} \cup \{X \setminus Y\}$ is an open cover of $X$ (the extra set is open because $Y$ is closed). By compactness some finite subcollection of $\mathcal{B}$ covers $X$. If it contains $X \setminus Y$, throw that set away; what's left is a finite subcollection of $\mathcal{A}$ that still covers $Y$. So $Y$ is compact. $\blacksquare$

And in Hausdorff spaces, compact pieces are closed.

Every compact subspace of a Hausdorff space is closed.

Show proof

Proof. Let $X$ be Hausdorff and $Y \subset X$ compact. We show $X \setminus Y$ is open. Let $x_0 \in X \setminus Y$. For each $y \in Y$, choose disjoint neighborhoods $U_y$ of $x_0$ and $V_y$ of $y$ (possible since $X$ is Hausdorff). The collection $\{V_y : y \in Y\}$ covers $Y$ by sets open in $X$, so finitely many of them, $V_{y_1}, \dots, V_{y_n}$, cover $Y$. Then $V = V_{y_1} \cup \dots \cup V_{y_n}$ is open and contains $Y$, and it is disjoint from the open set $U = U_{y_1} \cap \dots \cap U_{y_n}$, which contains $x_0$. So $U$ is a neighborhood of $x_0$ inside $X \setminus Y$. Since $x_0$ was arbitrary, $X \setminus Y$ is open and $Y$ is closed. $\blacksquare$

Notice the finite subcover was needed to make $U$ open: an intersection of infinitely many $U_y$'s might not be open. That's the classic pattern in compactness proofs: do something for each point, use compactness to cut down to finitely many points, then intersect.

The proof separates the point $x_0$ from each $y$ one at a time, using the Hausdorff condition over and over. Compactness then glues finitely many separations into one.

Like connectedness, compactness survives continuous maps.

The image of a compact space under a continuous map is compact.

Proof. Let $f: X \to Y$ be continuous with $X$ compact, and let $\mathcal{A}$ cover $f(X)$ by sets open in $Y$. Then $\{f^{-1}(A) : A \in \mathcal{A}\}$ covers $X$, and its sets are open by continuity. By compactness, finitely many of them, $f^{-1}(A_1), \dots, f^{-1}(A_n)$, cover $X$. Then $A_1, \dots, A_n$ cover $f(X)$, so $f(X)$ is compact. $\blacksquare$

Put the last three theorems together and you get a shortcut for proving maps are homeomorphisms.

Let $f: X \to Y$ be a bijective continuous function. If $X$ is compact and $Y$ is Hausdorff, then $f$ is a homeomorphism.

Proof. We show $f^{-1}$ is continuous, that is, that $f$ sends closed sets to closed sets. If $A$ is closed in $X$, then $A$ is compact (closed subspace of a compact space), so $f(A)$ is compact (continuous image), so $f(A)$ is closed in $Y$ (compact subspace of a Hausdorff space). Since $f$ is a bijection, $(f^{-1})^{-1}(A) = f(A)$, so preimages of closed sets under $f^{-1}$ are closed, and $f^{-1}$ is continuous. $\blacksquare$

The map $[0, 1) \to S^1$ on the Continuous Functions page was a continuous bijection that was not a homeomorphism. The theorem doesn't apply, because $[0, 1)$ isn't compact.

Products and the Tube Lemma

To show products of compact spaces are compact, we need to thicken a single slice into a whole tube.

Let $X$ and $Y$ be spaces and $x_0 \in X$. If $U$ is a neighborhood of $x_0$ in $X$, the set $U \times Y$ is called a tube about $x_0 \times Y$.

An open set around the slice $x_0 \times Y$ doesn't always contain a tube. It does when $Y$ is compact.

Consider the product space $X \times Y$, where $Y$ is compact. If $N$ is an open set of $X \times Y$ containing the slice $x_0 \times Y$, then $N$ contains some tube $W \times Y$ about $x_0 \times Y$, where $W$ is a neighborhood of $x_0$ in $X$.

Show proof

Proof. For each $y \in Y$, the point $(x_0, y)$ is in $N$, so choose a basis element $U_y \times V_y \subset N$ containing it. The sets $V_y$ cover $Y$, so by compactness finitely many of them, $V_{y_1}, \dots, V_{y_n}$, cover $Y$. Let $W = U_{y_1} \cap \dots \cap U_{y_n}$, an open set containing $x_0$. If $(x, y) \in W \times Y$, then $y \in V_{y_i}$ for some $i$, and $x \in W \subset U_{y_i}$, so $(x, y) \in U_{y_i} \times V_{y_i} \subset N$. Hence $W \times Y \subset N$. $\blacksquare$

Same pattern as before: one rectangle per point, cut down to finitely many, intersect. Now see what goes wrong without compactness.

The Tube Lemma

With the tube lemma in hand, products follow.

The product of finitely many compact spaces is compact.

Show proof

Proof. It's enough to do two spaces; induction handles the rest. Let $X$ and $Y$ be compact and $\mathcal{A}$ an open cover of $X \times Y$. Fix $x_0 \in X$. The slice $x_0 \times Y$ is homeomorphic to $Y$, hence compact, so finitely many elements $A_1, \dots, A_m$ of $\mathcal{A}$ cover it. Their union $N$ is an open set containing the slice, so by the tube lemma it contains a tube $W \times Y$ with $W$ a neighborhood of $x_0$. So the tube $W \times Y$ is covered by finitely many elements of $\mathcal{A}$.

Do this for every $x_0 \in X$, getting neighborhoods $W_{x_0}$. These cover $X$, so finitely many, $W_1, \dots, W_k$, cover $X$. The tubes $W_1 \times Y, \dots, W_k \times Y$ then cover $X \times Y$, and each is covered by finitely many elements of $\mathcal{A}$. All together that's finitely many elements of $\mathcal{A}$ covering $X \times Y$. $\blacksquare$

There's an equivalent way to say "compact" using closed sets instead of open ones. It needs this property.

A collection $\mathcal{A}$ of subsets of $X$ is said to have the finite intersection property if for every finite subcollection $\{A_1, \dots, A_n\}$ of $\mathcal{A}$, the intersection $A_1 \cap \dots \cap A_n$ is nonempty.

Taking complements turns "open cover with no finite subcover" into "closed sets with the finite intersection property and empty total intersection." So $X$ is compact exactly when every collection of closed sets with the finite intersection property has a nonempty intersection.

That reformulation appears again on the Nets page, in a list of four equivalent ways to say "compact."

Compact Sets of Real Numbers

Now, which subsets of $\mathbb{R}$ and $\mathbb{R}^n$ are compact? First, in general ordered sets.

Let $X$ be a simply ordered set having the least upper bound property. In the order topology, each closed interval in $X$ is compact.

(The proof is omitted for now. Here is the special case that matters most, with its proof.)

The unit interval $[0, 1]$ is compact.

Show proof

Proof. Let $\mathcal{A}$ be an open cover of $[0, 1]$ and define $$T = \{t \in [0, 1] : [0, t] \text{ is covered by a finite subcollection of } \mathcal{A}\}.$$ $T$ contains $0$, and if $t \in T$ and $s < t$ then $s \in T$, so $T$ is an interval starting at $0$. Let $b = \sup T$.

$b \in T$. Some $A \in \mathcal{A}$ contains $b$. Since $A$ is open in $[0, 1]$, it contains an interval $(a, b]$ for some $a < b$ (or $A \ni 0 = b$, which is immediate). Since $a < b = \sup T$, there is $t \in T$ with $t > a$, so $[0, t]$ is covered by finitely many sets. Adding $A$ covers $[0, b]$. So $b \in T$.

$b = 1$. Suppose $b < 1$. The finite subcollection covering $[0, b]$ includes some set $\tilde{A}$ containing $b$, and since $\tilde{A}$ is open, it contains $[b, b + \varepsilon)$ for some $\varepsilon > 0$. So the same finite subcollection covers $[0, b + \frac{\varepsilon}{2}]$, and $b + \frac{\varepsilon}{2} \in T$, contradicting $b = \sup T$. So $b = 1$, and $[0, 1]$ is covered by finitely many sets of $\mathcal{A}$. $\blacksquare$

And now the theorem everyone remembers from analysis.

Let $n \in \mathbb{N}$ and let $A$ be a subset of $\mathbb{R}^n$. Then $A$ is compact if and only if $A$ is closed and bounded (in the Euclidean metric).

Show proof

Proof. Suppose $A \subset \mathbb{R}^n$ is compact. Since $\mathbb{R}^n$ is Hausdorff, $A$ is closed. The balls $\{B(0, k) : k \in \mathbb{N}\}$ cover $A$, so finitely many do, so $A \subset B(0, k)$ for some $k$, and $A$ is bounded.

Conversely, suppose $A$ is closed and bounded. Then $A \subset B(0, m)$ for some $m \in \mathbb{N}$, and $$B(0, m) \subset [-m, m] \times \dots \times [-m, m] \quad (n \text{ times}).$$ Each $[-m, m]$ is homeomorphic to $[0, 1]$, hence compact, so the right side is a finite product of compact spaces, which is compact. $A$ is a closed subset of this compact set, so $A$ is compact. $\blacksquare$

Heine–Borel is a theorem about $\mathbb{R}^n$, not a definition of compactness. In other spaces "closed and bounded" is not enough: in $\mathbb{R}$ with the standard bounded metric $\overline{d}$, all of $\mathbb{R}$ is closed and bounded but not compact.

Here's the reason calculus cares about compactness.

Let $f: X \to Y$ be continuous, where $Y$ is an ordered set in the order topology. If $X$ is compact, then there exist points $p, q \in X$ such that $f(p) \le f(x) \le f(q)$ for every $x \in X$.

Proof. Since $f$ is continuous and $X$ is compact, $A = f(X)$ is compact. We show $A$ has a largest element $M$; then $M = f(q)$ for some $q$. Suppose $A$ has no largest element. Then the open rays $\{(-\infty, a) : a \in A\}$ cover $A$ (each point of $A$ is below some bigger point of $A$). By compactness, finitely many of them, $(-\infty, a_1), \dots, (-\infty, a_n)$, cover $A$. If $a_i$ is the largest of $a_1, \dots, a_n$, then $a_i$ belongs to none of these rays, a contradiction. Similarly $A$ has a smallest element $m = f(p)$. $\blacksquare$

Uniform Continuity

Back to metric spaces. Two definitions first: distance to a set, and the Lebesgue number of a cover.

Let $(X, d)$ be a metric space and $A$ a nonempty subset of $X$. For each $x \in X$, the distance from $x$ to $A$ is $$d(x, A) = \inf\{d(x, a) : a \in A\}.$$

A Lebesgue number is a size below which every set fits inside one member of the cover.

Let $(X, d)$ be a metric space and $\mathcal{A}$ an open covering of $X$. A number $\delta > 0$ such that each subset of $X$ having diameter less than $\delta$ is contained in some element of $\mathcal{A}$ is called a Lebesgue number for the covering $\mathcal{A}$.

Not every cover has one (the cover $\{(\frac{1}{n}, 1)\}$ of $(0, 1)$ doesn't: tiny sets near $0$ fit in no single $(\frac{1}{n}, 1)$). Compactness guarantees one.

If $(X, d)$ is a compact metric space, then every open covering of $X$ has a Lebesgue number.

(Proof omitted for now; it uses the function $x \mapsto d(x, X \setminus A)$ for the sets $A$ of the cover.) This is what powers the next theorem.

A function $f$ from the metric space $(X, d_X)$ to the metric space $(Y, d_Y)$ is uniformly continuous if for each $\varepsilon > 0$ there exists $\delta > 0$ such that for every pair of points $x_0, x_1 \in X$, $$d_X(x_0, x_1) < \delta \implies d_Y(f(x_0), f(x_1)) < \varepsilon.$$

Compare with plain continuity: there, $\delta$ may depend on the point. Here one $\delta$ works everywhere. On a compact space, you get that for free.

Let $f: X \to Y$ be a continuous map of the compact metric space $(X, d_X)$ to the metric space $(Y, d_Y)$. Then $f$ is uniformly continuous.

Proof. Given $\varepsilon > 0$, cover $Y$ by the balls $B(y, \frac{\varepsilon}{2})$. Let $\mathcal{A}$ be the open cover of $X$ by the preimages of these balls under $f$, and let $\delta$ be a Lebesgue number for $\mathcal{A}$. If $d_X(x_1, x_2) < \delta$, the two-point set $\{x_1, x_2\}$ has diameter less than $\delta$, so it lies in some $f^{-1}(B(y, \frac{\varepsilon}{2}))$, and $f(x_1), f(x_2) \in B(y, \frac{\varepsilon}{2})$. Hence $d_Y(f(x_1), f(x_2)) < \varepsilon$. $\blacksquare$

One last version of compactness, using sequences.

If $(x_n)$ is a sequence of points of $X$ and $n_1 < n_2 < \dots < n_i < \dots$ is an increasing sequence of natural numbers, then the sequence $(y_i)$ defined by $y_i = x_{n_i}$ is called a subsequence of $(x_n)$.

A space where every sequence has a convergent subsequence is the kind of space Bolzano and Weierstrass would recognize.

The space $X$ is said to be sequentially compact if every sequence of points of $X$ has a convergent subsequence.

In metric spaces the two notions agree.

Let $X$ be a metrizable space. Then the following are equivalent:

  1. $X$ is compact;
  2. $X$ is sequentially compact.

(Proof omitted for now.) Outside metric spaces they can differ, which is one more reason the Nets page exists.

Exercises

Compactness can tell spaces apart too.

Let $S^2 = \{(x, y, z) \in \mathbb{R}^3 : x^2 + y^2 + z^2 = 1\}$ with the subspace topology from $\mathbb{R}^3$. Prove that $S^2$ and $\mathbb{R}^2$ are not homeomorphic.

Show proof

Proof. $S^2$ is closed and bounded in $\mathbb{R}^3$, so it is compact by Heine–Borel. If $f: S^2 \to \mathbb{R}^2$ were a homeomorphism, then $\mathbb{R}^2 = f(S^2)$ would be compact, as a continuous image of a compact space. But $\mathbb{R}^2$ is not bounded, so it is not compact. Hence no such homeomorphism exists. $\blacksquare$

Compare this one with the Hausdorff and connected versions.

Let $X$ be a topological space and $A, B \subset X$ be closed subsets with $X = A \cup B$. Show that if $A$ and $B$ are compact, then $X$ is compact.

Show proof

Proof. Let $\{U_\alpha\}$ be an open cover of $X$. It also covers $A$ by sets open in $X$, so since $A$ is compact, finitely many $U_{\alpha_1}, \dots, U_{\alpha_n}$ cover $A$. Likewise finitely many $U_{\beta_1}, \dots, U_{\beta_m}$ cover $B$. Together these $n + m$ sets cover $A \cup B = X$. So $X$ is compact. $\blacksquare$

(Closedness wasn't even needed here: a union of two compact subspaces is always compact.)

You've seen the next two as theorems. Prove them again from scratch, without looking.

Suppose that $X$ is compact, $Y$ is Hausdorff, and $f: X \to Y$ is continuous. Prove that if $A \subset X$ is closed, then $f(A) \subset Y$ is closed.

Show proof

Proof. $A$ is a closed subset of a compact space, so $A$ is compact. $f$ is continuous, so $f(A)$ is compact. $f(A)$ is a compact subspace of a Hausdorff space, so $f(A)$ is closed. $\blacksquare$

And its consequence.

Suppose that $X$ is compact, $Y$ is Hausdorff, and $f: X \to Y$ is a continuous bijection. Prove that $f$ is a homeomorphism.

Show proof

Proof. We need $f^{-1}: Y \to X$ to be continuous. Let $A$ be closed in $X$. By the previous exercise, $f(A)$ is closed in $Y$. Since $f$ is a bijection, $(f^{-1})^{-1}(A) = f(A)$. So $f^{-1}$ pulls closed sets back to closed sets, and it is continuous. Hence $f$ is a homeomorphism. $\blacksquare$

Spicy Bonus

This is the sequential-compactness partner of the Spicy Bonus on the Closed Sets page, and it uses that result.

🌶️ SPICY BONUS 🌶️

Let $X$ be a topological space and let $X_1 \subset X_2 \subset X_3 \subset \dots$ be a nested sequence of subsets with $X = \bigcup_{n=1}^\infty X_n$. Suppose every $X_n$ has the subspace topology, that a subset $U \subset X$ is open in $X$ if and only if $U \cap X_n$ is open in $X_n$ for all $n$, and that every singleton of $X_n$ is closed in $X_n$, for all $n$. Suppose $A \subset X$ is sequentially compact. Prove that $A \subset X_m$ for some $m \in \mathbb{N}$.

Show proof

Proof. Suppose not: $A \not\subset X_m$ for every $m$. Then for each $n$ we can choose $p_n \in A \setminus X_n$. If $m \ge n$ then $X_n \subset X_m$, so $p_m \notin X_n$. Hence for each $n$, the set $\{p_k : k \in \mathbb{N}\} \cap X_n \subset \{p_1, \dots, p_{n-1}\}$ is finite, and the same holds for every subset of $\{p_k\}$. In particular infinitely many of the $p_k$ are distinct, and we may pass to a subsequence of distinct terms.

By sequential compactness of $A$, some subsequence $p_{n_k}$ converges to a point $p \in A$. Remove $p$ from the subsequence if it appears (it appears at most once, since the terms are distinct), and let $S = \{p_{n_k}\}$ be the remaining set. Every subset of $S$ meets each $X_n$ in a finite set, so by the Spicy Bonus on the Closed Sets page, $S$ and all of its subsets are closed in $X$. In particular $X \setminus S$ is an open set containing $p$ (since $p \notin S$). But $p_{n_k} \to p$, so this neighborhood must contain $p_{n_k}$ for all large $k$, and those points are in $S$. Contradiction. Hence $A \subset X_m$ for some $m$. $\blacksquare$

(The source version of this problem left out the hypothesis that singletons of each $X_n$ are closed. Without it the statement is false: give $X = \mathbb{N}$ and every $X_n = \{1, \dots, n\}$ the trivial topology. Every sequence in $\mathbb{N}$ converges to every point, so $A = \mathbb{N}$ is sequentially compact, yet it lies in no $X_m$.)