Skip to content
Tutorials Center
My learning

Topics

Lesson 20 of 36 · Compactness

Compactness in Euclidean Space: Heine–Borel

A subset of R^n is compact exactly when it is closed and bounded. See the proof idea, the role of each condition, and test it with code.

In the previous lesson compactness was defined by open covers, which are hard to check directly. For subsets of ℝⁿ there is a far simpler test. The Heine–Borel theorem says that a subset of ℝⁿ is compact if and only if it is closed and bounded. This is why [0, 1] and closed disks are compact, while ℝ, (0, 1) and [0, ∞) are not.

The theorem is special to Euclidean space (and spaces like it). In general metric spaces "closed and bounded" is not enough, as you will see at the end. Still, it is the tool you will use most often to recognize compact sets.

The statement

Theorem (Heine–Borel). Let K ⊆ ℝⁿ with the usual topology. Then K is compact if and only if K is closed and bounded.

Bounded means there is a number M with ‖x‖ ≤ M for all x in K. Closed means K contains all its limit points, equivalently its complement is open.

Two directions are hidden in the theorem. (1) Compact implies closed and bounded, which holds in every metric space. (2) Closed and bounded implies compact, which uses a special property of ℝⁿ (completeness plus finite-dimensionality).

Why compact implies closed and bounded

Bounded. Cover K by the open balls B(0, n) for n = 1, 2, .... Finitely many of them cover K, and the largest ball contains it. So K is bounded.

Closed. Suppose p is not in K. For each n, let U_n be the set of points at distance greater than 1/n from p. These sets are open, they are nested, and their union is everything except p, so it covers K. A finite subcover gives some N with K ⊆ U_N. Then the ball of radius 1/N around p misses K. So the complement of K is open.

Why closed and bounded implies compact (idea)

The cleanest route is by bisection. Suppose [a, b] had an open cover with no finite subcover. Cut [a, b] in half. At least one half has no finite subcover. Cut that half and repeat. You get nested intervals whose lengths shrink to zero, all lacking a finite subcover. They share exactly one point p (by completeness of the reals). The point p lies in some open set U of the cover, and U contains a small interval around p. But for large k the k-th interval fits inside U, so it needs just one set. That contradicts the choice. Hence [a, b] is compact.

From there a closed bounded K ⊆ ℝⁿ sits inside a closed box [−M, M]ⁿ, which is compact (a product of compact intervals, treated in the chapter on products). A closed subset of a compact set is compact, so K is compact.

Closed subsets of compact sets

If K is compact and F ⊆ K is closed, then F is compact. Given an open cover of F, add the open set K \ F; this covers K; pick a finite subcover; drop K \ F. What remains covers F.

Testing each hypothesis

Drop either condition and compactness fails:

Set Closed? Bounded? Compact?
[0, 1] yes yes yes
(0, 1) no yes no
[0, ∞) yes no no
closed unit disk in ℝ² yes yes yes
ℚ ∩ [0, 1] no yes no
unit circle x² + y² = 1 yes yes yes

The code below looks at the failures through a sequence viewpoint. In ℝⁿ, compact sets are exactly the sets where every sequence has a subsequence converging to a point of the set. We can see a sequence escaping.

Python Sequences that escape: why unbounded or non-closed sets fail

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The third example hints at the proof of the bolzano–weierstrass property: infinitely many points of a bounded set must pile up somewhere.

Counting how many balls you need

For a compact set you can ask a quantitative question: how many open balls of radius r do we need to cover it? Finite for every r is exactly "totally bounded", which for complete spaces is equivalent to compactness.

Python How many balls of radius r cover the unit square?

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The count grows like 1/r² but is always finite. In ℝ (not bounded), no finite number of balls of a fixed radius suffices.

When closed and bounded is not enough

In an infinite-dimensional space, closed and bounded can fail to be compact. In the space ℓ² of square-summable sequences, the standard unit vectors e_1 = (1, 0, 0, ...), e_2 = (0, 1, 0, ...), ... all lie in the closed unit ball, but ‖e_i − e_j‖ = √2 for i ≠ j. No subsequence can converge. In a discrete metric space with infinitely many points (distance 1 between different points), the whole space is closed and bounded but not compact. Heine–Borel is a theorem about ℝⁿ, not a definition.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. Which subset of the plane is compact?

    The closed unit disk is closed and bounded. The open disk is not closed; the axis and the half-plane are unbounded.
  2. 2. Which infinite subset of the real numbers is compact?

    Adding the limit point 0 makes the set closed, and it is bounded. The set {1/n} alone is missing its limit point 0, so it is not closed.
  3. 3. In which space does 'closed and bounded' NOT imply compact?

    In an infinite discrete metric space the whole space is closed and bounded, yet the cover by single points has no finite subcover.
  4. 4. Why is a closed subset of a compact space compact?

    The complement of the closed subset is open, so it can join the cover. A finite subcover of the big space then yields a finite subcover of the subset.

Summary

  • Heine–Borel: in ℝⁿ, compact means closed and bounded.
  • Compact implies closed and bounded in any metric space; the other direction needs special structure.
  • Closed subsets of compact sets are compact.
  • Total boundedness (finitely many small balls) plus completeness is the general replacement for "closed and bounded".
  • In infinite-dimensional or discrete spaces, closed and bounded does not give compactness.

Next: Compact Sets and Continuous Maps