MATH-447 · Lesson 7 of 12 · 26 min

Compactness and the Heine–Borel theorem

Compactness is the topological version of finiteness. A finite set has many pleasant properties: every function on it attains a maximum, every sequence in it has a constant subsequence, and anything that holds near each of its points holds uniformly. Compact spaces keep these properties while being infinite. MATH-341 met compactness in metric spaces, defined through sequences and through open covers, and proved that the two definitions agree there. In general topology the open cover definition is the right one, and this lesson develops its theory from scratch, proves the Heine–Borel theorem for Euclidean space, and derives the theorem promised in lessons 3 and 4: a continuous bijection from a compact space to a Hausdorff space is a homeomorphism.

Open covers

Definition. An open cover of a space \(X\) is a family \(\mathcal{U}\) of open sets whose union is \(X\). A subcover is a subfamily that still covers \(X\). The space \(X\) is compact if every open cover has a finite subcover. A subset of a space is compact if it is compact in the subspace topology, which is equivalent to saying that every cover of it by open sets of the ambient space has a finite subcover.

Some examples. Every finite space is compact, and so is every space with finitely many open sets. The real line is not compact, since the cover by the intervals \((-n, n)\) has no finite subcover: finitely many of them have union \((-N, N)\) for the largest \(N\) used. The open interval \((0, 1)\) is not compact, by the cover \(\{(1/n, 1) : n \ge 2\}\). An infinite discrete space is not compact, by the cover by its points. Any set with the cofinite topology is compact: given a cover, one member \(U\) misses only finitely many points, and finitely many more members cover those.

Two number lines. The upper line shows the open interval from 0 to 1 covered by nested intervals from 1 over n to 1, which crowd towards 0 without any finite number of them covering the interval. The lower line shows the closed interval from 0 to 1 covered by a family of overlapping open intervals, with five of them highlighted as a finite subcover.
The open interval has an open cover with no finite subcover; every open cover of the closed interval has one

A useful reformulation uses closed sets. A family of sets has the finite intersection property if every finite subfamily has nonempty intersection. Taking complements, \(X\) is compact if and only if every family of closed sets with the finite intersection property has nonempty intersection. For example, the closed sets \([n, \infty)\) in the real line have the finite intersection property and empty intersection, another proof that the line is not compact. The reformulation is the form in which compactness is used in Tychonoff's theorem in lesson 8.

The closed interval is compact

Theorem. The interval \([a, b]\) is compact.

Proof. Let \(\mathcal{U}\) be an open cover of \([a, b]\) by open sets of the real line. Let \(C\) be the set of \(x \in [a, b]\) such that \([a, x]\) is covered by finitely many members of \(\mathcal{U}\). Then \(a \in C\), since \(a\) lies in some member. Let \(s = \sup C\), which exists by the completeness of the reals, and \(a \le s \le b\). The point \(s\) lies in some \(U \in \mathcal{U}\), and \(U\) contains \((s - \varepsilon, s + \varepsilon)\) for some \(\varepsilon > 0\). Since \(s\) is the least upper bound of \(C\), some \(x \in C\) satisfies \(x > s - \varepsilon\). Then \([a, x]\) is covered by finitely many members, and adding \(U\) covers \([a, y]\) for every \(y < s + \varepsilon\) with \(y \le b\). Taking \(y = s\) shows that \(s \in C\). If \(s < b\), then any \(y\) with \(s < y < \min(s + \varepsilon, b)\) would also lie in \(C\), contradicting \(s = \sup C\). So \(s = b \in C\). So \([a, b]\) is covered by finitely many members.

As in lesson 6, the proof relies on the least upper bound property. The theorem is false over the rationals: \([0, 2] \cap \mathbb{Q}\) is not compact, because the open sets \(\{q : |q^2 - 2| > 1/n\}\) cover it, each missing a small gap around \(\sqrt{2}\), but finitely many of them miss a whole interval of rationals near \(\sqrt{2}\).

Basic properties

Theorem. (a) A closed subset of a compact space is compact. (b) A compact subset of a Hausdorff space is closed. (c) The continuous image of a compact space is compact.

Proof. (a) Let \(C\) be closed in compact \(X\), and \(\mathcal{U}\) a cover of \(C\) by open sets of \(X\). Adding the open set \(X \setminus C\) gives an open cover of \(X\), which has a finite subcover; dropping \(X \setminus C\) leaves a finite subfamily of \(\mathcal{U}\) covering \(C\). (b) Let \(K\) be compact in Hausdorff \(X\), and \(x \notin K\). For each \(k \in K\) choose disjoint open sets \(U_k \ni k\) and \(V_k \ni x\). The \(U_k\) cover \(K\), so finitely many, \(U_{k_1}, \ldots, U_{k_n}\), do. Then \(V = V_{k_1} \cap \cdots \cap V_{k_n}\) is an open set containing \(x\) that misses \(U_{k_1} \cup \cdots \cup U_{k_n} \supseteq K\). So the complement of \(K\) is open. (c) If \(f : X \to Y\) is continuous and \(\mathcal{V}\) is an open cover of \(f(X)\), the sets \(f^{-1}(V)\) cover \(X\); finitely many suffice, and the corresponding \(V\) cover \(f(X)\).

The proof of (b) shows more: in a Hausdorff space, a compact set and a point outside it have disjoint neighbourhoods. Running the same argument again with a second compact set in place of the point shows that disjoint compact sets in a Hausdorff space have disjoint neighbourhoods. Since closed subsets of a compact space are compact, this gives the following theorem.

Theorem. A compact Hausdorff space is normal.

Part (b) fails without the Hausdorff condition. In the cofinite topology on the real line every subset is compact, by the same argument as for the whole space, but only finite sets and the whole line are closed. In the line with two origins, each copy of \([-1, 1]\) containing one of the origins is compact, but neither is closed, since the other origin lies in its closure.

Compact to Hausdorff

Theorem. Let \(f : X \to Y\) be a continuous map from a compact space to a Hausdorff space. Then \(f\) is a closed map. If \(f\) is a bijection, it is a homeomorphism. If \(f\) is a surjection, it is a quotient map.

Proof. If \(C\) is closed in \(X\), it is compact by (a), so \(f(C)\) is compact by (c), and closed in \(Y\) by (b). A closed continuous bijection has continuous inverse, since \((f^{-1})^{-1}(C) = f(C)\) is closed for each closed \(C\). A closed continuous surjection is a quotient map: if \(f^{-1}(V)\) is open then its complement \(f^{-1}(Y \setminus V)\) is closed, so \(f(f^{-1}(Y \setminus V)) = Y \setminus V\) is closed and \(V\) is open.

This single theorem settles every gluing question deferred in lesson 4. The quotient of \([0, 1]\) by \(0 \sim 1\) is compact, being a continuous image of a compact space, and maps continuously and bijectively onto the Hausdorff circle; so it is homeomorphic to the circle. The same argument identifies the glued square with \(S^1 \times S^1\), the disc with its boundary collapsed with \(S^2\), and the hemisphere with antipodal boundary points identified with \(\mathbb{RP}^2\). The wrapping map \([0, 2\pi) \to S^1\) of lesson 3 escapes the theorem only because \([0, 2\pi)\) is not compact.

Products and the Heine–Borel theorem

Lemma (the tube lemma). Let \(Y\) be compact, \(x_0 \in X\), and \(N\) an open set of \(X \times Y\) containing the slice \(\{x_0\} \times Y\). Then \(N\) contains a tube \(W \times Y\) for some open \(W \ni x_0\).

Proof. Each point \((x_0, y)\) of the slice has a basic neighbourhood \(U_y \times V_y \subseteq N\). The \(V_y\) cover the compact space \(Y\), so finitely many, \(V_{y_1}, \ldots, V_{y_n}\), cover it. Put \(W = U_{y_1} \cap \cdots \cap U_{y_n}\), an open set containing \(x_0\). For any \((x, y) \in W \times Y\), the point \(y\) lies in some \(V_{y_i}\), and \(x \in U_{y_i}\), so \((x, y) \in U_{y_i} \times V_{y_i} \subseteq N\).

Theorem. The product of two compact spaces is compact. Hence every finite product of compact spaces is compact.

Proof. Let \(\mathcal{A}\) be an open cover of \(X \times Y\), with \(X\) and \(Y\) compact. For each \(x \in X\), the slice \(\{x\} \times Y\) is homeomorphic to \(Y\), hence compact, so finitely many members of \(\mathcal{A}\) cover it. Their union is an open set containing the slice, so by the tube lemma it contains a tube \(W_x \times Y\). The \(W_x\) cover \(X\), so finitely many, \(W_{x_1}, \ldots, W_{x_m}\), do. The tubes \(W_{x_i} \times Y\) cover the product, and each is covered by finitely many members of \(\mathcal{A}\); altogether finitely many members cover \(X \times Y\).

The tube lemma fails without compactness: the open set \(\{(x, y) : |xy| < 1\}\) in \(\mathbb{R}^2\) contains the slice \(\{0\} \times \mathbb{R}\) but no tube around it, since any tube \((-\varepsilon, \varepsilon) \times \mathbb{R}\) contains points with \(y > 1/\varepsilon\).

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

Proof. A compact subset \(K\) of the Hausdorff space \(\mathbb{R}^n\) is closed by (b). It is bounded because the open balls \(B(0, m)\) cover it and finitely many must suffice, so \(K \subseteq B(0, M)\) for the largest \(M\) used. Conversely, if \(K\) is closed and bounded, it lies in some cube \([-M, M]^n\). That cube is a finite product of compact intervals, hence compact, and \(K\) is a closed subset of it, hence compact by (a).

The theorem is named after Eduard Heine, who used the covering argument in 1872 in proving uniform continuity, and Émile Borel, who stated the covering property for countable covers of a closed interval in 1895; Henri Lebesgue and others extended it to arbitrary covers. In a general metric space closed and bounded is not enough: the closed unit ball of an infinite-dimensional normed space is never compact, as MATH-341 showed for sequence spaces. The correct metric characterization, also proved in MATH-341, is complete and totally bounded.

Consequences for functions

Theorem (extreme value theorem). A continuous real function on a nonempty compact space attains its maximum and minimum.

Proof. The image is a compact subset of \(\mathbb{R}\), so it is closed and bounded by Heine–Borel. A closed bounded nonempty set of reals contains its supremum and infimum.

Lemma (Lebesgue number). If \(X\) is a compact metric space and \(\mathcal{U}\) an open cover, there is \(\delta > 0\) such that every subset of diameter less than \(\delta\) lies inside a single member of \(\mathcal{U}\).

Proof. If \(X\) itself belongs to \(\mathcal{U}\), any \(\delta\) works. Otherwise choose a finite subcover \(U_1, \ldots, U_n\), let \(C_i = X \setminus U_i\), which is nonempty, and define \(f(x) = \frac{1}{n}\sum_i d(x, C_i)\). The function \(f\) is continuous, and positive everywhere: each \(x\) lies in some \(U_i\), and the open set \(U_i\) contains a ball around \(x\), so \(d(x, C_i) > 0\). By the extreme value theorem \(f\) has a positive minimum \(\delta\). For any \(x\), choose \(i\) with \(d(x, C_i)\) as large as possible; then \(d(x, C_i) \ge f(x) \ge \delta\), so the ball \(B(x, \delta)\) lies in \(U_i\). A set of diameter less than \(\delta\) containing \(x\) lies in that ball.

The Lebesgue number lemma reproves the uniform continuity of continuous functions on compact metric spaces, the result Heine proved, and it is the key technical tool in lesson 10: when a path in the circle is cut into pieces shorter than a Lebesgue number, each piece lies in an arc over which the path can be lifted to the real line.

Compactness and sequences

A space is sequentially compact if every sequence has a convergent subsequence. MATH-341 proved that a metric space is compact exactly when it is sequentially compact. In general neither property implies the other. The product \([0, 1]^{[0, 1]}\) of continuum many intervals is compact by Tychonoff's theorem in lesson 8, but it is not sequentially compact: one can build a sequence of points in it, using the binary digits of the index, with no convergent subsequence. Conversely, the space of countable ordinals with the order topology is sequentially compact but not compact. For this reason general topology uses open covers, and sequences only in first countable or metric settings.

Finite subcovers by computer

For a cover of \([0, 1]\) by open intervals, a finite subcover can be extracted greedily, following the proof that \([0, 1]\) is compact: start at 0, repeatedly choose the interval containing the current point that reaches farthest to the right, and jump to its right end. The program does this for a random cover, computes a Lebesgue number for the subcover, and shows that the cover \((1/n, 1)\) of the open interval has no finite subcover.

A greedy finite subcover of a random cover of [0, 1], its Lebesgue number, and a cover of (0, 1) with no finite subcover
import random

def greedy_subcover(intervals, a=0.0, b=1.0):
    """intervals: list of open intervals (lo, hi). Return a finite subcover of [a, b] or None."""
    chosen = []
    x = a
    while True:
        containing = [iv for iv in intervals if iv[0] < x < iv[1]]
        if not containing:
            return None
        best = max(containing, key=lambda iv: iv[1])
        chosen.append(best)
        if best[1] > b:
            return chosen
        x = best[1]                      # the right end is not covered yet; it lies in some other interval

random.seed(447)
cover = []
for k in range(400):
    c = random.uniform(-0.05, 1.05)
    r = random.uniform(0.01, 0.06)
    cover.append((c - r, c + r))
assert all(any(lo < t / 1000 < hi for lo, hi in cover) for t in range(1001))
sub = greedy_subcover(cover)
print("random cover of [0, 1]:", len(cover), "intervals; greedy subcover uses", len(sub))
for lo, hi in sub[:5]:
    print(f"  ({lo:+.4f}, {hi:.4f})")
print("  ...")

def lebesgue_number(sub, a=0.0, b=1.0, steps=20000):
    best = float('inf')
    for k in range(steps + 1):
        x = a + (b - a) * k / steps
        reach = max(min(x - lo, hi - x) for lo, hi in sub if lo < x < hi)
        best = min(best, reach)
    return best
print(f"Lebesgue number of the subcover (radius form): about {lebesgue_number(sub):.4f}")

for N in [10, 100, 1000]:
    family = [(1 / n, 1.0) for n in range(2, N + 1)]
    left = min(lo for lo, hi in family)
    print(f"the first {N - 1} sets (1/n, 1) cover only (1/{N}, 1), missing (0, {left:.4f}]")
Output
random cover of [0, 1]: 400 intervals; greedy subcover uses 10
  (-0.0082, 0.1004)
  (+0.0967, 0.2165)
  (+0.2154, 0.3250)
  (+0.3207, 0.4192)
  (+0.3999, 0.5146)
  ...
Lebesgue number of the subcover (radius form): about 0.0006
the first 9 sets (1/n, 1) cover only (1/10, 1), missing (0, 0.1000]
the first 99 sets (1/n, 1) cover only (1/100, 1), missing (0, 0.0100]
the first 999 sets (1/n, 1) cover only (1/1000, 1), missing (0, 0.0010]

The greedy procedure is exactly the supremum argument run forward: each step pushes the covered stretch \([0, x]\) as far right as one interval can, and compactness guarantees the process stops after finitely many steps. The Lebesgue number is positive, so every subinterval shorter than twice the printed radius lies inside one interval of the subcover. For the open interval, by contrast, every finite family of sets \((1/n, 1)\) leaves a gap next to 0, which is why \((0, 1)\) is not compact even though it is bounded.

Worked problem

Using compactness to prove a closed map

Show that the projection \(\pi_1 : X \times Y \to X\) is a closed map when \(Y\) is compact.

Show solution
  1. Let \(C\) be closed in \(X \times Y\) and \(x_0 \notin \pi_1(C)\). Then the slice \(\{x_0\} \times Y\) misses \(C\).
  2. So the slice lies in the open set \(N = (X \times Y) \setminus C\).
  3. By the tube lemma there is an open \(W \ni x_0\) with \(W \times Y \subseteq N\).
  4. Then no point of \(W\) is the first coordinate of a point of \(C\), so \(W \cap \pi_1(C) = \varnothing\).
  5. Hence the complement of \(\pi_1(C)\) is open, and \(\pi_1(C)\) is closed.

Answer: Projection along a compact factor is closed; the hyperbola \(xy = 1\) shows this fails for the noncompact factor \(\mathbb{R}\).

Common mistakes

  • MistakeDefining compactness by the existence of some finite cover.

    InsteadEvery space has the finite cover by itself; compactness requires that every open cover have a finite subcover.

  • MistakeUsing Heine–Borel outside Euclidean space.

    InsteadIn infinite-dimensional normed spaces closed bounded sets need not be compact; use complete and totally bounded in metric spaces.

  • MistakeConcluding that compact sets are closed in any space.

    InsteadThis needs the Hausdorff property; in the cofinite topology every set is compact.

  • MistakeForgetting compactness when inverting a continuous bijection.

    InsteadThe wrapping map from \([0, 2\pi)\) to the circle is a continuous bijection, not a homeomorphism, because its domain is not compact.

  • MistakeAssuming compact and sequentially compact always agree.

    InsteadThey agree for metric spaces; in general neither implies the other.

Summary and key terms

  • A space is compact when every open cover has a finite subcover; equivalently, closed families with the finite intersection property have nonempty intersection.
  • The interval [a, b] is compact, by a supremum argument that uses completeness.
  • Closed subsets of compact spaces and continuous images of compact spaces are compact; compact subsets of Hausdorff spaces are closed.
  • A continuous bijection from a compact space to a Hausdorff space is a homeomorphism, which identifies the gluings of lesson 4.
  • The tube lemma gives compactness of finite products, and with it the Heine–Borel theorem: in Euclidean space compact means closed and bounded.
  • Continuous functions on compact spaces attain their extremes; compact metric spaces have Lebesgue numbers for open covers.
open cover
A family of open sets whose union is the space.
compact
Every open cover has a finite subcover.
finite intersection property
Every finite subfamily has nonempty intersection.
tube lemma
An open set containing a slice through a compact factor contains a tube around it.
Heine–Borel theorem
A subset of Euclidean space is compact if and only if it is closed and bounded.
Lebesgue number
A positive number such that every set of smaller diameter lies in one member of a given cover.
sequentially compact
Every sequence has a convergent subsequence.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. Is \(\{1/n : n \ge 1\}\) compact? What about \(\{0\} \cup \{1/n\}\)?

    Show answer

    The first is not: it is not closed in \(\mathbb{R}\), since 0 is a limit point, or directly, the singletons are open in it and infinitely many are needed. The second is closed and bounded, hence compact.

  2. Show that the unit sphere \(S^{n-1}\) in \(\mathbb{R}^n\) is compact.

    Show answer

    It is closed, as the preimage of 1 under the continuous norm, and bounded, so Heine–Borel applies.

  3. Prove that a continuous \(f : X \to \mathbb{R}\) on a compact space is bounded without using Heine–Borel.

    Show answer

    The open sets \(f^{-1}((-n, n))\) cover \(X\); finitely many suffice, so \(|f| < N\) for the largest \(N\) used.

  4. Show that \(\mathbb{RP}^2\), defined as the quotient of \(S^2\) by \(x \sim -x\), is compact.

    Show answer

    It is the continuous image of the compact sphere under the quotient map.

  5. Give an open cover of the closed unit ball in the space of square-summable sequences with no finite subcover.

    Show answer

    Take the open balls of radius \(1/\sqrt{2}\) about every point of the ball. The unit vectors \(e_k\) are at distance \(\sqrt{2}\) apart, so each ball of radius \(1/\sqrt{2}\) contains at most one of them, and infinitely many balls are needed.

  6. Use the finite intersection property to show that a decreasing sequence of nonempty compact sets in a Hausdorff space has nonempty intersection.

    Show answer

    All the sets are closed subsets of the first, which is compact, and any finitely many have intersection equal to the smallest, which is nonempty.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz