Survey of Mathematics

4.3 Compactness

A set is compact when every sequence in it has a subsequence converging inside it, or equivalently when every cover by open sets can be trimmed to finitely many. In R^n that means closed and bounded (Heine–Borel), in function spaces it does not, and compactness is exactly what makes continuous functions attain extremes and have one delta for the whole set.

Beyond the courseRudin, Principles of Mathematical Analysis, ch. 2 (Thm 2.35 to 2.41) and ch. 4 (Thm 4.14 to 4.19)Abbott, Understanding Analysis, Sec. 3.3 and 4.4Munkres, Topology, Sec. 26 to 28Apostol Vol. 2, Sec. 8.2 and 9.9

In 1.3 two theorems were proved on the interval [a,b][a, b]: a continuous function attains a maximum, and it is uniformly continuous. Both proofs went through the same step, Bolzano–Weierstrass: take a sequence of points of [a,b][a, b], extract a convergent subsequence, and observe that its limit is still in [a,b][a, b]. The interval (0,1](0, 1] fails this (1n\frac1n has no limit in the set) and so do both theorems. So the interval was not the point. The property that a set must have so that sequences have a limit inside it is called compactness. This chapter defines it for any metric space, in two ways that look different (subsequences, and covers by open sets), proves they agree, proves that in Rn\mathbb R^n it means closed and bounded, shows that this fails in spaces of functions, and then proves the two theorems of 1.3 again for every compact set.

Before you start

1.2: subsequences and the Bolzano–Weierstrass theorem. 4.2: convergence in a metric space, and that a set is closed iff it contains limits of its convergent sequences. 1.3: the extreme value theorem.

Quick checkThe sequence 1,−1,1,−1,…1, -1, 1, -1, \dots is bounded. Which is true?
Quick checkIs (0,1](0, 1] a closed subset of R\mathbb R?
Quick checkDoes f(x)=xf(x) = x attain a maximum on the interval (0,1)(0, 1)?

The picture: covers and finite subcovers

A cover of a set KK is a family of open sets whose union contains KK. In the picture the sets are open intervals drawn as blue bars, and KK is the black line. Slide kk to use only the first kk intervals and watch the uncovered points (red). Three things to do:

  1. Start with (0,1](0, 1] and the intervals (1n,2)(\frac1n, 2). Every point of KK is covered if you use all of them (given x>0x > 0 pick nn with 1n<x\frac1n < x). But for every kk there is a red gap (0,1k](0, \frac1k]. No finite part of the cover works.
  2. Switch to [0,1][0, 1] with the same intervals plus one around 00. Now the point 00 is covered by the new interval, and the red gap disappears when kk reaches 1212 (the new set and U1,…,U11U_1, \dots, U_{11}). Of those twelve, two already suffice: the new one and (111,2)(\frac1{11}, 2).
  3. Try the hand-made family. It is finite, so a finite subcover is automatic. The interesting case is an infinite family, and the claim of compactness is that for [0,1][0, 1] some finite part of it always works.
Where this came from· Heine, Borel and a disputed name

Dirichlet was the first to prove that a continuous function on a closed interval is uniformly continuous. His proof, given in lectures in 1852 and published only in 1904, quietly used a finite subcover of an open cover. Heine, Weierstrass and Pincherle later used similar techniques, which is why Heine’s name is attached to the theorem even though his own result was about uniform continuity. Émile Borel stated and proved, in 1895, that any cover of a closed interval by countably many open intervals has a finite subcover. Pierre Cousin (1895), Henri Lebesgue (1898) and Arthur Schoenflies (1900) extended this to arbitrary covers, and the result is sometimes called the Borel–Lebesgue lemma. The problem they were solving was how to pass from “every point has a good neighbourhood” to “the whole set has a uniform bound”. A finite cover does that, because you can take a minimum of finitely many numbers. (The history here follows Raman-Sundström, “A Pedagogical History of Compactness”, American Mathematical Monthly, 2015.)

Where this came from· Fréchet and the two definitions

Maurice Fréchet’s 1906 thesis (the same one that began metric spaces, see 4.1) studied sets in which every sequence has a convergent subsequence, generalizing Bolzano–Weierstrass from the line to spaces of functions. The open-cover definition, which is the one topology uses, was formulated in the 1920s by Pavel Alexandroff and Pavel Urysohn (who called it “bicompact”). For metric spaces the two are equivalent, which is Theorem “Compact equals sequentially compact” below. In general topological spaces they differ, and the cover definition is the one that works.

The idea, in words

Why· Compact means: it behaves like a finite set

Finite sets are friendly. Every function on a finite set has a largest value. If every point has its own tolerance δp>0\delta_p > 0, then there is one tolerance for the whole set, the smallest δp\delta_p, and it is positive because a minimum of finitely many positive numbers is positive. Infinite sets lose both properties.

Compactness is the way an infinite set earns them back. It says the set can be handled by finitely many pieces at the scale you care about, whichever scale that is. Two statements express it:

  1. Sequences. An infinite supply of points must pile up somewhere in the set: some subsequence converges to a point of the set. (A finite set has this, since some point repeats infinitely often.)
  2. Covers. If every point of the set is given an open neighbourhood, finitely many of those neighbourhoods already cover the set. This is “take the minimum of finitely many tolerances” in disguise.

The set must be closed (no escape through an edge) and “not too spread out” (the interval [0,1][0, 1] yes, the line R\mathbb R no). In Rn\mathbb R^n that is closed and bounded. In infinite dimensions “not too spread out” needs a sharper meaning, called total boundedness.

Definitions and theorems

Sequential compactness

Definition B

Sequentially compact

Let KK be a subset of a metric space XX. KK is sequentially compact if for every sequence (xn)(x_n) with all xn∈Kx_n \in K there are indices n1<n2<⋯n_1 < n_2 < \cdots and a point x∈Kx \in K with xnk→xx_{n_k} \to x. (The limit must be in KK.)

In one lineA set KK is sequentially compact if every sequence of points of KK has a subsequence that converges to a point of KK.

Why it existsIt is the property that Bolzano–Weierstrass gives for [a,b][a, b] and that the proofs of the extreme value theorem and of uniform continuity in 1.3 used.

We use the following fact all the time: if xn→xx_n \to x then every subsequence xnk→xx_{n_k} \to x too, because nk≥kn_k \ge k, so the terms after index NN of the subsequence are terms of the original after index NN.

Worked example
Which of these subsets of R\mathbb R are sequentially compact: [0,1][0, 1], (0,1](0, 1], R\mathbb R, {1,2,3}\{1, 2, 3\}, Q∩[0,1]\mathbb Q \cap [0, 1], Z\mathbb Z?

Solution.

  1. [0,1][0, 1] is. A sequence in [0,1][0, 1] is bounded, so Bolzano–Weierstrass gives a convergent subsequence, and 0≤xnk≤10 \le x_{n_k} \le 1 passes to the limit, so the limit is in [0,1][0, 1]. Boundedness gives the subsequence, closedness keeps the limit inside.
  2. (0,1](0, 1] is not. The sequence 1n\frac1n has every subsequence converging to 00, which is outside. One sequence all of whose subsequences fail is enough to disprove the property.
  3. R\mathbb R is not. The sequence xn=nx_n = n has no convergent subsequence, since a convergent sequence is bounded and every subsequence of nn is unbounded. Bounded fails.
  4. {1,2,3}\{1, 2, 3\} is. Any sequence takes some value infinitely often; the subsequence at those positions is constant, hence convergent. Finite sets are always sequentially compact.
  5. Q∩[0,1]\mathbb Q \cap [0, 1] is not. Take rationals xn→22x_n \to \frac{\sqrt2}2 (decimal truncations). Every subsequence converges to 22\frac{\sqrt2}2, which is irrational, so outside the set. The set is bounded but not closed in R\mathbb R: it has holes.
  6. Z\mathbb Z is not. The sequence nn again. Unbounded.

Answer. Sequentially compact: [0,1][0, 1] and {1,2,3}\{1, 2, 3\}. Not: the other four. ■\blacksquare The pattern, closed and bounded, is the next theorem.

Definition B

Bounded set in a metric space

A subset KK of a metric space XX is bounded if there exist p∈Xp \in X and R>0R > 0 with d(x,p)<Rd(x, p) < R for all x∈Kx \in K. (For R\mathbb R with ∣x−y∣|x - y| this is the notion of bounded from 1.1.)

In one lineA set KK is bounded if it fits inside some ball: there are a point pp and a radius RR with K⊆B(p,R)K \subseteq B(p, R).

Why it existsIt is the replacement for 'between two numbers' in a space with no order, and it is the condition that fails for R\mathbb R and for Z\mathbb Z.

Theorem B Rudin Thm 2.34 and Thm 3.6; Abbott Sec. 3.3

Sequentially compact sets are closed and bounded

If KK is a sequentially compact subset of a metric space XX, then KK is closed and bounded.

In one lineIn any metric space, a sequentially compact set is closed and bounded.

Why it is trueA sequence escaping through a missing limit point, or running off to infinity, has no subsequence that converges inside the set.

ProofRudin 2.34
The idea: Closed: a sequence in K converging to a point outside K would force all its subsequences to converge outside K. Bounded: an unbounded set yields a sequence moving ever farther from a base point, which cannot have a convergent subsequence.
Closed. Let xn∈Kx_n \in K and xn→x∈Xx_n \to x \in X. We show x∈Kx \in K.
By the theorem in 4.2, a set is closed iff the limit of every convergent sequence of its points lies in the set. So take such a sequence.
Some subsequence xnkx_{n_k} converges to a point y∈Ky \in K.
KK is sequentially compact.
But xnk→xx_{n_k} \to x as well, so y=xy = x and x∈Kx \in K. So KK is closed.
A subsequence of a sequence converging to xx also converges to xx, and limits in a metric space are unique (4.2).
For each nn choose xn∈Kx_n \in K with d(xn,p)≥nd(x_n, p) \ge n.
Bounded: suppose not. Fix any p∈Xp \in X. Not bounded means no ball B(p,n)B(p, n) contains KK, for every nn.
Suppose a subsequence converges to y∈Ky \in K. Then d(xnk,p)d(x_{n_k}, p) is bounded.
A sequence xnk→yx_{n_k} \to y is bounded: d(xnk,p)≤d(xnk,y)+d(y,p)d(x_{n_k}, p) \le d(x_{n_k}, y) + d(y, p), and d(xnk,y)<1d(x_{n_k}, y) < 1 for large kk, so the distances stay below 1+d(y,p)1 + d(y, p) after some point.
That contradicts the choice of xnx_n. So no subsequence converges, which contradicts sequential compactness. Hence KK is bounded. ■\blacksquare
d(xnk,p)≥nk≥kd(x_{n_k}, p) \ge n_k \ge k is unbounded.

For the converse we need a statement about boxes. A box in Rn\mathbb R^n is Q=[a1,b1]×⋯×[an,bn]Q = [a_1, b_1] \times \cdots \times [a_n, b_n]. Every bounded set lies in some box.

Theorem B Rudin Thm 2.41 and Thm 3.6; Abbott Sec. 3.3

Bolzano–Weierstrass in R^n

Let K⊆RnK \subseteq \mathbb R^n be closed and bounded (for any of the 1-, 2- or max-distances). Then KK is sequentially compact.

In one lineEvery closed bounded subset of Rn\mathbb R^n is sequentially compact: each sequence in it has a subsequence converging to a point of it.

Why it is truePass to a subsequence for the first coordinate, then a further subsequence for the second, and so on; after nn rounds every coordinate converges.

ProofRudin 2.41
The idea: Bounded in R^n means each coordinate is a bounded real sequence. Apply Bolzano–Weierstrass of 1.2 one coordinate at a time, always to the subsequence already found. Then the vector converges, because convergence is coordinatewise (4.2). The limit is in K since K is closed.
Let x(m)x^{(m)} be a sequence in KK. Each coordinate sequence (xi(m))m(x^{(m)}_i)_m lies in [−R,R][-R, R].
KK is bounded, so ∥x∥2≤R\lVert x \rVert_2 \le R for some RR and all x∈Kx \in K. Each coordinate is at most the 2-norm in absolute value (the comparison theorem of 4.1).
There is a subsequence along which the first coordinate converges.
Bolzano–Weierstrass in 1.2, for the first coordinate.
Take a further subsequence along which the second coordinate also converges. Continue through coordinate nn.
A subsequence of a bounded sequence is bounded, so Bolzano–Weierstrass applies again, now to the second coordinate along the subsequence from the previous step. The first coordinate still converges along it, since subsequences of convergent sequences converge.
So some subsequence converges to a point x∈Rnx \in \mathbb R^n.
After nn steps we have one subsequence x(mk)x^{(m_k)} along which every coordinate converges. By the coordinatewise theorem of 4.2, x(mk)→xx^{(m_k)} \to x in Rn\mathbb R^n.
x∈Kx \in K. ■\blacksquare
KK is closed, so by 4.2 the limit of a convergent sequence of its points lies in KK.
Quick checkWhich of these subsets of R2\mathbb R^2 is sequentially compact?

Open covers and compactness

Definition B

Open cover

Let KK be a subset of a metric space XX. An open cover of KK is a collection {Uα}\{U_\alpha\} of open sets of XX with K⊆⋃αUαK \subseteq \bigcup_\alpha U_\alpha. A subcover is a sub-collection that still covers KK; it is a finite subcover if it has finitely many sets.

In one lineAn open cover of a set KK is a collection of open sets of the space whose union contains KK. A finite subcover is a finite part of the collection that still covers KK.

Why it existsA cover is the data 'give every point an open neighbourhood'. Compactness asks that finitely many of those neighbourhoods are enough.

Definition B

Compact set

A subset KK of a metric space XX is compact if every open cover of KK has a finite subcover.

In one lineA set KK is compact if every open cover of KK has a finite subcover.

Why it existsIt is the cover version of 'behaves like a finite set': finitely many of any given neighbourhoods already reach every point.

One remark about the definition. If we asked for covers by sets open in KK itself (as in 4.4), we would get the same notion: a set open in KK has the form K∩WK \cap W with WW open in XX (the lemma “Open sets inside a subset” in 4.4), and covers by the K∩WαK \cap W_\alpha correspond to covers by the WαW_\alpha. So being compact is a property of KK as a metric space on its own. That lets us treat KK as the whole space in proofs.

Worked example
Show that (0,1](0, 1] is not compact by giving an open cover with no finite subcover. Then show [0,1][0, 1] is not defeated by the same family.

Solution.

  1. The cover. Let Un=(1n,2)U_n = (\frac1n, 2) for n=1,2,3,…n = 1, 2, 3, \dots. Each is open. Open intervals are balls in R\mathbb R.
  2. It covers (0,1](0, 1]. Given x∈(0,1]x \in (0, 1], pick nn with 1n<x\frac1n < x (Archimedean property). Then x∈Unx \in U_n, as x≤1<2x \le 1 < 2. Every point needs a set containing it.
  3. No finite subcover. Any finitely many Un1,…,UnjU_{n_1}, \dots, U_{n_j} have union UNU_N with N=max⁡niN = \max n_i (the sets increase with nn), which is (1N,2)(\frac1N, 2). It misses the point 1N∈(0,1]\frac1N \in (0, 1]. The sets are nested, so the union of finitely many is the biggest of them, and that one has a left end.
  4. So (0,1](0, 1] is not compact. Compactness requires a finite subcover for EVERY open cover. One bad cover is enough.
  5. The same family on [0,1][0, 1]. It does not cover [0,1][0, 1] (the point 00 is in no UnU_n), so add U0=(−ε,ε)U_0 = (-\varepsilon, \varepsilon) with ε=0.05\varepsilon = 0.05. The sets U0U_0 and UNU_N cover [0,1][0, 1] once 1N<ε\frac1N < \varepsilon, that is N≥21N \ge 21. Points below ε\varepsilon are in U0U_0; points from ε\varepsilon up are above 1N\frac1N and below 22. For N=20N = 20, 120=0.05\frac1{20} = 0.05 exactly, and the point 0.050.05 is in neither set.

Answer. (0,1](0, 1] has the open cover {(1n,2)}\{(\frac1n, 2)\} with no finite subcover, so it is not compact. Adding the one set U0U_0 around the missing point makes two sets suffice for [0,1][0, 1], and compactness says that something like this always happens for [0,1][0, 1]. ■\blacksquare

Your answerCover [0,1][0, 1] by U0=(−0.05,0.05)U_0 = (-0.05, 0.05) together with Un=(1n,2)U_n = (\frac1n, 2). What is the smallest nn such that {U0,Un}\{U_0, U_n\} already covers [0,1][0, 1]?
Worked example
Prove directly from the definition that K={0}∪{1n:n≥1}K = \{0\} \cup \{\frac1n : n \ge 1\} is compact.

Solution.

  1. Start with an arbitrary open cover. Let {Uα}\{U_\alpha\} be a family of open sets of R\mathbb R whose union contains KK. The definition says every open cover has a finite subcover, so we may not choose the cover. We are handed it.
  2. Handle the troublemaker 00. Some member, call it U0U_0, contains the point 00. It is open, so it contains an interval (−r,r)(-r, r) for some r>0r > 0. Open means a ball around each of its points fits inside.
  3. See what U0U_0 covers. Choose NN with 1N<r\frac1N < r (Archimedean property). Then 1n∈(−r,r)⊆U0\frac1n \in (-r, r) \subseteq U_0 for every n≥Nn \ge N. The tail of the sequence 1n\frac1n is squeezed toward 00, so all of it is swallowed by the one set around 00. Infinitely many points are handled by a single set.
  4. Handle the finitely many points left over. The points 1,12,…,1N−11, \frac12, \dots, \frac1{N-1} number finitely many. For each, pick one member of the cover containing it. One set per point, and there are only N−1N - 1 points, so this uses at most N−1N - 1 more sets.
  5. Collect. U0U_0 together with those at most N−1N - 1 sets is a finite subfamily, and it covers KK. It contains 00, the tail, and each leftover point.

Answer. Every open cover of KK has a finite subcover, so KK is compact. This is the standard shape of a direct proof: one set handles the accumulation point and an infinite tail, finitely many sets handle the rest. Compare {1n}\{\frac1n\} without 00, where nothing handles the tail. ■\blacksquare

Two general facts, true in every metric space.

Theorem B Rudin Thm 2.34; Abbott Sec. 3.3

Compact sets are closed and bounded

If KK is a compact subset of a metric space XX, then KK is closed and bounded.

In one lineIn any metric space, every compact set is closed and bounded.

Why it is trueCover the set by balls that grow, or by the sets of points farther than 1/n1/n from a point outside the set; a finite subcover forces a gap around that outside point.

ProofRudin 2.34
The idea: Bounded: the balls B(p, n) cover everything; finitely many suffice, so the biggest contains K. Closed: for a point q outside K, the open sets {x : d(x, q) > 1/n} cover K; a finite subcover gives a ball around q that misses K.
Bounded. By compactness finitely many of these balls cover KK.
For any fixed p∈Xp \in X the open balls B(p,n)B(p, n), n=1,2,…n = 1, 2, \dots, cover all of XX, so cover KK.
So K⊆B(p,N)K \subseteq B(p, N) for some NN: KK is bounded.
The balls increase with nn, so the union of finitely many is the largest of them.
Closed. Let q∈X∖Kq \in X \setminus K and Un={x∈X:d(x,q)>1n}U_n = \{x \in X : d(x, q) > \frac1n\}.
To show KK is closed we show its complement is open: take a point q∉Kq \notin K and find a ball around qq that misses KK.
Each UnU_n is open.
If d(x,q)>1nd(x, q) > \frac1n put s=d(x,q)−1ns = d(x, q) - \frac1n. For y∈B(x,s)y \in B(x, s) the triangle inequality gives d(y,q)≥d(x,q)−d(x,y)>1nd(y, q) \ge d(x, q) - d(x, y) > \frac1n.
The sets UnU_n cover KK.
If x∈Kx \in K then x≠qx \ne q, so d(x,q)>0d(x, q) > 0 by (M1), and d(x,q)>1nd(x, q) > \frac1n for nn large.
So K⊆UNK \subseteq U_N: every point of KK is farther than 1N\frac1N from qq.
Compactness gives a finite subcover. The sets increase with nn, so one set UNU_N already contains KK.
Hence B(q,1N)⊆X∖KB(q, \frac1N) \subseteq X \setminus K, so X∖KX \setminus K is open and KK is closed. ■\blacksquare
That says no point of KK is in B(q,1N)B(q, \frac1N).
Lemma B Rudin Thm 2.35

Closed subsets of compact sets are compact

Let QQ be a compact subset of a metric space XX, and let F⊆QF \subseteq Q be closed in XX. Then FF is compact.

In one lineIf QQ is compact and F⊆QF \subseteq Q is closed, then FF is compact.

Why it is trueCover FF and also the complement of FF, which is open; the finite subcover of QQ restricts to a finite subcover of FF.

ProofRudin 2.35
The idea: Given an open cover of F, add the open set X minus F. The result covers Q, so finitely many of its sets cover Q; drop X minus F.
Let {Uα}\{U_\alpha\} be an open cover of FF.
Start with an arbitrary open cover of FF.
Then {Uα}∪{X∖F}\{U_\alpha\} \cup \{X \setminus F\} is an open cover of QQ.
FF is closed, so X∖FX \setminus F is open. Every point of QQ is in FF (so in some UαU_\alpha) or not in FF (so in X∖FX \setminus F).
A finite part of it covers QQ, hence covers FF.
QQ is compact.
Remove X∖FX \setminus F if it is among the sets. What remains is finitely many UαU_\alpha covering FF. ■\blacksquare
X∖FX \setminus F contains no point of FF, so it is not needed to cover FF.

The Heine–Borel theorem

Theorem B Rudin Thm 2.40 and 2.41; Abbott Sec. 3.3

Heine–Borel theorem

A subset K⊆RnK \subseteq \mathbb R^n (with the 1-, 2- or max-distance) is compact if and only if it is closed and bounded.

In one lineA subset of Rn\mathbb R^n is compact if and only if it is closed and bounded.

Why it is true'Compact implies closed and bounded' holds in every metric space. For the converse, keep halving a box that has no finite subcover; the nested boxes shrink to a point, and the open set covering that point also covers a small box, a contradiction.

Why· The picture behind the proof

Imagine the box QQ and an open cover of it with no finite subcover. Cut QQ into 2n2^n equal sub-boxes (in the plane, four quarters). If each quarter had a finite subcover, so would QQ. So some quarter has none. Cut that quarter into four, and again some quarter has none. The nested squares shrink to a single point xx. That point is in one set UU of the cover. Because UU is open, a small disc around xx fits in UU, and when the squares are small enough one of them fits inside this disc. That square is covered by the single set UU. It was supposed to have no finite subcover. In the cover visualizer above this is the situation near 00 for (0,1](0, 1]: the nested intervals shrink toward a point which is not in the set, so the argument has nothing to land on. Closedness is what lets the point exist.

ProofRudin 2.40 and 2.41
The idea: (⇒) is the general theorem. (⇐) First prove that every box is compact by the halving argument; then a closed bounded set is a closed subset of a box, hence compact.
(⇒\Rightarrow) A compact KK is closed and bounded.
The general theorem that compact sets are closed and bounded, in the metric space Rn\mathbb R^n.
Halve every side of Q0Q_0. This cuts Q0Q_0 into 2n2^n sub-boxes whose union is Q0Q_0.
(⇐\Leftarrow), part 1: boxes are compact. By contradiction: suppose a box Q0Q_0 has an open cover U\mathcal U with no finite subcover.
So at least one sub-box has no finite subcover. Call it Q1Q_1.
If all 2n2^n sub-boxes had a finite subcover from U\mathcal U, the union of those finitely many finite subcovers would be a finite subcover of Q0Q_0.
We get nested boxes Q0⊇Q1⊇Q2⊇⋯Q_0 \supseteq Q_1 \supseteq Q_2 \supseteq \cdots, none having a finite subcover from U\mathcal U, with diam⁡Qk=2−kdiam⁡Q0\operatorname{diam} Q_k = 2^{-k} \operatorname{diam} Q_0.
The same argument applied to Q1Q_1, then Q2Q_2, and so on (we choose one each time, an infinite repeated choice).
Pick xk∈Qkx_k \in Q_k for each kk. The sequence (xk)(x_k) is Cauchy.
For m≥km \ge k both xkx_k and xmx_m lie in QkQ_k (the boxes are nested), so d(xk,xm)≤diam⁡Qk→0d(x_k, x_m) \le \operatorname{diam} Q_k \to 0.
So xk→xx_k \to x for some x∈Rnx \in \mathbb R^n.
Rn\mathbb R^n is complete (4.2).
Hence x∈Qkx \in Q_k for every kk, in particular x∈Q0x \in Q_0.
For a fixed kk, the points xmx_m with m≥km \ge k lie in QkQ_k and converge to xx. A box is closed (its defining inequalities pass to limits coordinatewise), so x∈Qkx \in Q_k.
Some U∈UU \in \mathcal U contains xx.
U\mathcal U covers Q0Q_0.
There is r>0r > 0 with B(x,r)⊆UB(x, r) \subseteq U.
UU is open.
Then Qk⊆B(x,r)⊆UQ_k \subseteq B(x, r) \subseteq U: the single set UU is a finite subcover of QkQ_k. This contradicts the choice of QkQ_k. So every box is compact.
Choose kk with diam⁡Qk<r\operatorname{diam} Q_k < r. Every point y∈Qky \in Q_k has d(y,x)≤diam⁡Qk<rd(y, x) \le \operatorname{diam} Q_k < r since x∈Qkx \in Q_k too.
Let KK be closed and bounded. Then K⊆[−R,R]nK \subseteq [-R, R]^n, a box.
(⇐\Leftarrow), part 2: a closed bounded set sits inside a box. If ∥x∥2≤R\lVert x \rVert_2 \le R on KK then every coordinate is in [−R,R][-R, R].
KK is a closed subset of a compact box, so KK is compact. ■\blacksquare
The lemma on closed subsets of compact sets.
Proof workshopRebuild the halving argument: every box is compact

Tap the lines in the order a proof would write them. Each line can only use what is already above it.

    Worked example
    Which of these subsets of R2\mathbb R^2 or R3\mathbb R^3 are compact: the closed triangle {x,y≥0, x+y≤1}\{x, y \ge 0,\ x + y \le 1\}, the sphere {x2+y2+z2=1}\{x^2 + y^2 + z^2 = 1\}, the hyperbola {xy=1}\{xy = 1\}, the open disc {x2+y2<1}\{x^2 + y^2 < 1\}, the set {(x,y):y=sin⁡1x, 0<x≤1}\{(x, y) : y = \sin\frac1x,\ 0 < x \le 1\}?

    Solution.

    1. Closed triangle. Defined by non-strict inequalities of continuous functions, so closed. It lies in [0,1]2[0, 1]^2, so bounded. By Heine–Borel it is compact. A set defined by ≥\ge, ≤\le and == on continuous functions is closed: limits of points satisfying them still satisfy them.
    2. Sphere. Closed because xk→xx_k \to x with ∥xk∥2=1\lVert x_k \rVert_2 = 1 forces ∥x∥2=1\lVert x \rVert_2 = 1 (the norm is continuous: ∣∥xk∥−∥x∥∣≤∥xk−x∥|\lVert x_k \rVert - \lVert x \rVert| \le \lVert x_k - x \rVert, the reverse triangle inequality). Bounded since every coordinate has absolute value at most 11. Compact. This sphere is the set where continuous-function arguments will find maxima and minima; it is used again in 4.5.
    3. Hyperbola xy=1xy = 1. Closed (an equation in continuous functions) but unbounded, since (n,1n)(n, \frac1n) lies on it. Not compact. Heine–Borel needs both properties.
    4. Open disc. Bounded, not closed (the boundary circle is missing). Not compact. The sequence (1−1n,0)(1 - \frac1n, 0) approaches a point outside the set.
    5. The graph of sin⁡1x\sin\frac1x on (0,1](0, 1]. Bounded, but not closed: (1nπ,0)(\frac{1}{n\pi}, 0) lies on it and tends to (0,0)(0, 0), which is not on it. Not compact. This is the set GG of the topologist’s sine curve in 4.4; adding the missing segment makes it closed, bounded and compact.

    Answer. Compact: the triangle and the sphere. Not compact: the other three. ■\blacksquare

    Compact and sequentially compact are the same in a metric space

    In Rn\mathbb R^n we proved that closed and bounded gives sequential compactness and also gives compactness. In a general metric space the two properties still agree, which we now prove. The proof needs a measure of “how finely do I need to look”. It is called total boundedness.

    Definition B

    Totally bounded

    A metric space KK (or a subset with the inherited distance) is totally bounded if for every ε>0\varepsilon > 0 there are finitely many points p1,…,pm∈Kp_1, \dots, p_m \in K with K=B(p1,ε)∪⋯∪B(pm,ε)K = B(p_1, \varepsilon) \cup \dots \cup B(p_m, \varepsilon).

    In one lineA metric space is totally bounded if for every ε>0\varepsilon > 0 it can be covered by finitely many balls of radius ε\varepsilon.

    Why it existsBounded says one big ball is enough. Totally bounded says finitely many small balls are enough at every scale, which is the property 'not too spread out' that compactness needs.

    A totally bounded set is bounded: take ε=1\varepsilon = 1, then one big ball around p1p_1 of radius 1+max⁡id(p1,pi)1 + \max_i d(p_1, p_i) contains all the small ones. The converse fails: the closed unit ball of an infinite-dimensional space is bounded but, as we show, not totally bounded. Boundedness in Rn\mathbb R^n does imply total boundedness (cut a box into small cubes).

    Lemma B standard; Munkres Thm 45.1

    Sequentially compact implies totally bounded

    If a metric space KK is sequentially compact, then it is totally bounded.

    In one lineA sequentially compact metric space can be covered by finitely many balls of any given radius.

    Why it is trueIf it could not, you could pick points one after another, each at distance at least ε\varepsilon from all earlier ones, and that sequence has no Cauchy subsequence.

    Proofstandard
    The idea: Suppose some radius ε is not enough. Pick points greedily, each outside the balls of the earlier ones. All pairs are at least ε apart, so no subsequence is Cauchy, hence none converges.
    Pick any x1∈Kx_1 \in K.
    Contrapositive. Suppose, for some ε>0\varepsilon > 0, no finite set of balls of radius ε\varepsilon covers KK.
    Pick x2∈K∖B(x1,ε)x_2 \in K \setminus B(x_1, \varepsilon).
    B(x1,ε)B(x_1, \varepsilon) alone does not cover KK by the assumption.
    Having chosen x1,…,xjx_1, \dots, x_j, pick xj+1∈K∖(B(x1,ε)∪⋯∪B(xj,ε))x_{j+1} \in K \setminus \bigl(B(x_1, \varepsilon) \cup \dots \cup B(x_j, \varepsilon)\bigr).
    Finitely many balls never cover KK, so there is always a point outside B(x1,ε)∪⋯∪B(xj,ε)B(x_1, \varepsilon) \cup \dots \cup B(x_j, \varepsilon).
    Then d(xi,xj)≥εd(x_i, x_j) \ge \varepsilon for all i≠ji \ne j.
    Each point is outside the earlier balls, so its distance to each earlier point is at least ε\varepsilon.
    So no subsequence of (xj)(x_j) converges, contradicting sequential compactness. ■\blacksquare
    A convergent sequence is Cauchy (4.2). A subsequence with all pairwise distances at least ε\varepsilon is not Cauchy for the tolerance ε\varepsilon.

    The next lemma gives the one tolerance that works for a whole cover.

    Lemma B Munkres Lemma 27.5

    Lebesgue number lemma

    Let KK be a sequentially compact metric space and {Uα}\{U_\alpha\} a cover of KK by open sets of KK. Then there is λ>0\lambda > 0 (a Lebesgue number of the cover) such that for every x∈Kx \in K the ball B(x,λ)B(x, \lambda) is contained in some UαU_\alpha.

    In one lineIf KK is sequentially compact and {Uα}\{U_\alpha\} is an open cover of KK, there is a number λ>0\lambda > 0 such that every ball B(x,λ)B(x, \lambda) with x∈Kx \in K lies inside a single UαU_\alpha.

    Why it is trueIf no such λ\lambda existed, there would be points whose 1n\frac1n-balls escape every set; a subsequence of them converges to a point of some UαU_\alpha, and the balls around it eventually fit inside that set.

    ProofMunkres 27.5
    The idea: Contradiction: for λ = 1/n pick a bad centre x_n. A convergent subsequence tends to a point x lying in some U; a ball around x fits inside U, and for large k the bad ball around x_{n_k} fits inside it too.
    For each nn choose xn∈Kx_n \in K such that B(xn,1n)B(x_n, \frac1n) is contained in no UαU_\alpha.
    Assume the opposite: for every λ>0\lambda > 0 there is a centre whose λ\lambda-ball fits in no UαU_\alpha. Use λ=1n\lambda = \frac1n.
    A subsequence xnk→xx_{n_k} \to x for some x∈Kx \in K.
    KK is sequentially compact.
    Some UβU_\beta contains xx, and B(x,r)⊆UβB(x, r) \subseteq U_\beta for some r>0r > 0.
    {Uα}\{U_\alpha\} covers KK and each UαU_\alpha is open.
    Choose kk with d(xnk,x)<r2d(x_{n_k}, x) < \frac r2 and 1nk<r2\frac1{n_k} < \frac r2.
    Convergence xnk→xx_{n_k} \to x and 1nk→0\frac1{n_k} \to 0: both are below r2\frac r2 for large kk.
    If y∈B(xnk,1nk)y \in B(x_{n_k}, \frac1{n_k}) then y∈B(x,r)⊆Uβy \in B(x, r) \subseteq U_\beta.
    Triangle inequality: d(y,x)≤d(y,xnk)+d(xnk,x)<r2+r2=rd(y, x) \le d(y, x_{n_k}) + d(x_{n_k}, x) < \frac r2 + \frac r2 = r.
    So B(xnk,1nk)⊆UβB(x_{n_k}, \frac1{n_k}) \subseteq U_\beta, a contradiction. ■\blacksquare
    That is exactly what we assumed was impossible for the centre xnkx_{n_k}.
    Theorem B Rudin Thm 2.37 and 3.6; Munkres Thm 28.2

    Compact equals sequentially compact

    A subset KK of a metric space is compact if and only if it is sequentially compact.

    In one lineIn a metric space, a set is compact if and only if it is sequentially compact.

    Why it is trueCompact to sequential: a sequence with no convergent subsequence gives each point a ball containing only finitely many terms, and finitely many such balls cannot hold infinitely many terms. Sequential to compact: totally bounded gives finitely many balls of radius equal to a Lebesgue number, and each of those balls sits inside one set of the cover.

    ProofMunkres 28.2
    The idea: (⇒) Contrapositive with balls that catch only finitely many terms. (⇐) Take a Lebesgue number λ, cover K by finitely many λ-balls using total boundedness, and put each ball inside one set of the cover.
    Let p∈Kp \in K. If every ball B(p,1j)B(p, \frac1j) contained xnx_n for infinitely many nn, we could pick n1<n2<⋯n_1 < n_2 < \cdots with xnj∈B(p,1j)x_{n_j} \in B(p, \frac1j).
    (⇒\Rightarrow) Suppose KK is compact and (xn)(x_n) is a sequence in KK with no subsequence converging to a point of KK.
    Then xnj→px_{n_j} \to p, contrary to the assumption. So some ball B(p,rp)B(p, r_p) contains xnx_n for only finitely many indices nn.
    That subsequence has d(xnj,p)<1j→0d(x_{n_j}, p) < \frac1j \to 0.
    Say B(p1,rp1),…,B(pm,rpm)B(p_1, r_{p_1}), \dots, B(p_m, r_{p_m}) cover KK.
    The balls B(p,rp)B(p, r_p) for p∈Kp \in K are open and cover KK. By compactness finitely many of them cover KK.
    But there are infinitely many indices nn, a contradiction. So every sequence in KK has a subsequence converging in KK. KK is sequentially compact.
    Every xnx_n lies in KK, so in one of these mm balls, and each ball holds xnx_n for only finitely many nn. Finitely many balls, each with finitely many indices, give finitely many indices in total.
    By the Lebesgue number lemma there is λ>0\lambda > 0 such that every ball B(x,λ)B(x, \lambda), x∈Kx \in K, lies in some UαU_\alpha.
    (⇐\Leftarrow) Suppose KK is sequentially compact, and let {Uα}\{U_\alpha\} be an open cover of KK (by open sets of KK, equivalent to the definition, by the remark above).
    There are p1,…,pm∈Kp_1, \dots, p_m \in K with K=B(p1,λ)∪⋯∪B(pm,λ)K = B(p_1, \lambda) \cup \dots \cup B(p_m, \lambda).
    Sequentially compact implies totally bounded. Take ε=λ\varepsilon = \lambda.
    For each ii choose αi\alpha_i with B(pi,λ)⊆UαiB(p_i, \lambda) \subseteq U_{\alpha_i}.
    Each centre pip_i is a point of KK, so the Lebesgue property applies to the ball around it.
    Then K⊆Uα1∪⋯∪UαmK \subseteq U_{\alpha_1} \cup \dots \cup U_{\alpha_m}: a finite subcover. So KK is compact. ■\blacksquare
    The balls cover KK and each lies in its set.
    Proof workshopPick the reason for each line of 'sequentially compact implies compact'

    Each line of the proof is shown in order. Choose the reason that justifies it, then press Check.

    1. Let {Uα}\{U_\alpha\} be an open cover of the sequentially compact set KK.
    2. There is λ>0\lambda > 0 such that every ball B(x,λ)B(x, \lambda) lies in a single UαU_\alpha.
    3. There are p1,…,pm∈Kp_1, \dots, p_m \in K whose λ\lambda-balls cover KK.
    4. For each ii, B(pi,λ)⊆UαiB(p_i, \lambda) \subseteq U_{\alpha_i} for some αi\alpha_i.
    5. So K⊆Uα1∪⋯∪UαmK \subseteq U_{\alpha_1} \cup \dots \cup U_{\alpha_m}.

    In the picture: the Lebesgue number is the width of the narrowest “room” a point has inside the sets of the cover. For [0,1][0, 1] with the family {U0,Un}\{U_0, U_n\} of the first visualizer (where U0=(−0.1,0.1)U_0 = (-0.1, 0.1)) the room is at least 0.050.05 everywhere: a point xx with 0≤x≤0.10 \le x \le 0.1 has room 0.1−x0.1 - x inside U0U_0 and nearly xx inside some UnU_n, and the worse of the two bests, at x=0.05x = 0.05, is 0.050.05. For (0,1](0, 1] with (1n,2)(\frac1n, 2) the room of the point xx is about xx, which tends to 00 as x→0x \to 0: there is no Lebesgue number, and no finite subcover.

    Quick checkWhich of these metric spaces (with the distance ∣x−y∣|x - y|) is totally bounded?
    Worked example
    How many open intervals of length 0.10.1 are needed to cover [0,1][0, 1]?

    Solution.

    1. Eleven are enough. Take the intervals of radius 0.050.05 around the centres cj=0.04+0.095 jc_j = 0.04 + 0.095\,j for j=0,1,…,10j = 0, 1, \dots, 10. The first reaches down to c0−0.05=−0.01<0c_0 - 0.05 = -0.01 < 0, the last up to c10+0.05=1.04>1c_{10} + 0.05 = 1.04 > 1, and neighbouring centres are 0.095<0.10.095 < 0.1 apart, so neighbouring intervals overlap. Two open intervals of length 0.10.1 overlap exactly when their centres are less than 0.10.1 apart, and overlapping intervals leave no point between them uncovered.
    2. Ten are not enough. Suppose ten open intervals of length 0.10.1 cover [0,1][0, 1]. Their union UU is open and contains 00 and 11, so it contains small intervals around both, and so contains an interval (−η,1+η)(-\eta, 1 + \eta) of length 1+2η>11 + 2\eta > 1. But the total length of ten intervals of length 0.10.1 is 11, and a union of intervals cannot contain an interval longer than the sum of their lengths. Open intervals cannot touch end to end: the touching point would be missing. Overlap costs length, and there is no spare length. This is the same reason that [0,1][0, 1] cannot be split into open pieces (4.4).
    3. Conclude. The least number is 1111. This is a count of the balls in a finite cover at scale ε=0.05\varepsilon = 0.05, which is what total boundedness asks for at each scale.

    Answer. 1111. ■\blacksquare

    Your answerWhat is the least number of open intervals of length 0.10.1 that cover [0,1][0, 1]?
    Theorem B Munkres Thm 45.1

    Compact equals complete and totally bounded

    A metric space KK is compact if and only if it is complete and totally bounded.

    In one lineA metric space is compact if and only if it is complete and totally bounded.

    Why it is trueCompact means every sequence has a convergent subsequence. A Cauchy sequence with a convergent subsequence converges, so compact spaces are complete. Conversely, total boundedness lets you pick a nested sequence of small balls, which yields a Cauchy subsequence that completeness converts into a limit.

    ProofMunkres 45.1
    The idea: (⇒) Sequentially compact implies totally bounded, and a Cauchy sequence with a convergent subsequence converges. (⇐) From any sequence, use total boundedness repeatedly to pick nested infinite subsequences, each inside a ball of radius 1/k; the diagonal subsequence is Cauchy.
    (⇒\Rightarrow) KK is totally bounded.
    By the equivalence theorem, compact means sequentially compact. The lemma above gives totally bounded.
    A Cauchy sequence in KK has a convergent subsequence, hence converges to the same limit. So KK is complete.
    Let (xn)(x_n) be Cauchy with a subsequence xnk→xx_{n_k} \to x. Given ε\varepsilon, choose NN with d(xm,xn)<ε2d(x_m, x_n) < \frac\varepsilon2 for m,n>Nm, n > N and kk with nk>Nn_k > N and d(xnk,x)<ε2d(x_{n_k}, x) < \frac\varepsilon2. For n>Nn > N: d(xn,x)≤d(xn,xnk)+d(xnk,x)<εd(x_n, x) \le d(x_n, x_{n_k}) + d(x_{n_k}, x) < \varepsilon.
    One of those balls contains xnx_n for infinitely many nn. Let S1S_1 be the subsequence of those terms.
    (⇐\Leftarrow) Let KK be complete and totally bounded, and (xn)(x_n) any sequence. Finitely many balls of radius 11 cover KK.
    Let S2⊆S1S_2 \subseteq S_1 be the terms lying in one ball of radius 12\frac12. Continue: Sk⊆Sk−1S_k \subseteq S_{k-1} lies in a ball of radius 1k\frac1k.
    Finitely many balls of radius 12\frac12 cover KK, hence cover the terms of S1S_1; by the same pigeonhole one of them contains infinitely many terms of S1S_1.
    The sequence (yk)(y_k) is a subsequence of (xn)(x_n) and is Cauchy.
    The diagonal: let yky_k be the kk-th term of SkS_k, chosen with strictly increasing original indices. For m≥km \ge k both yky_k and ymy_m lie in SkS_k, inside one ball of radius 1k\frac1k, so d(yk,ym)<2kd(y_k, y_m) < \frac2k by the triangle inequality.
    So yky_k converges in KK. Every sequence has a convergent subsequence: KK is sequentially compact, hence compact. ■\blacksquare
    KK is complete.
    Worked example
    Decide whether each metric space is complete, totally bounded and compact: (a) [0,1][0, 1], (b) (0,1)(0, 1), (c) Z\mathbb Z, all with the distance ∣x−y∣|x - y|, and (d) an infinite set with the discrete metric.

    Solution.

    1. (a) [0,1][0, 1]. It is closed in the complete space R\mathbb R, so it is complete. Intervals of radius ε\varepsilon around 0,ε,2ε,…0, \varepsilon, 2\varepsilon, \dots (about 1ε\frac1\varepsilon of them) cover it, so it is totally bounded. Hence compact. The theorem: compact means complete and totally bounded.
    2. (b) (0,1)(0, 1). Totally bounded, by the same count of intervals. Not complete: 1n\frac1n is Cauchy and has no limit in (0,1)(0, 1). So not compact. One of the two properties is missing. Totally bounded alone is not enough.
    3. (c) Z\mathbb Z. Complete: a Cauchy sequence of integers is eventually constant, because after some point the terms are less than 12\frac12 apart, hence equal. Not totally bounded: balls of radius 12\frac12 are single points, and Z\mathbb Z is infinite. So not compact. Here the missing property is total boundedness.
    4. (d) A discrete infinite set. Complete for the same reason as Z\mathbb Z (a Cauchy sequence is eventually constant), and not totally bounded for the same reason (balls of radius 12\frac12 are single points). So not compact. The sets {x}\{x\} are open and cover the space, and no finite part does, which is the cover form of the same failure.

    Answer. Only [0,1][0, 1] is compact. (b) fails completeness; (c) and (d) fail total boundedness. ■\blacksquare

    This is why Rn\mathbb R^n obeys Heine–Borel. A closed subset of Rn\mathbb R^n is complete (4.2), and a bounded subset of Rn\mathbb R^n is totally bounded, so a closed bounded set is complete and totally bounded. It also explains the failure below: the closed unit ball of a function space is complete and bounded, and not totally bounded.

    Closed and bounded is not enough in function spaces

    Proposition B standard

    The unit ball of C[0,1] is closed and bounded but not compact

    Let B={f∈C[0,1]:d∞(f,0)≤1}B = \{f \in C[0, 1] : d_\infty(f, 0) \le 1\} be the closed unit ball of C[0,1]C[0, 1] with the sup metric. Then BB is closed and bounded, but not compact.

    In one lineIn C[0,1]C[0, 1] with the sup metric, the closed unit ball {f:max⁡∣f∣≤1}\{f : \max|f| \le 1\} is closed and bounded and has a sequence with no convergent subsequence, so it is not compact.

    Why it is trueTent functions with disjoint supports are all at distance exactly 1 from each other, so no subsequence is Cauchy, let alone convergent.

    Proofstandard
    The idea: Build functions f_n that are zero except on disjoint little intervals, with a peak of height 1 on each. Any two are at sup distance exactly 1, so no subsequence is Cauchy.
    BB is bounded and closed.
    The ball B(0,2)B(0, 2) contains it. Closed: it is a closed ball, and closed balls are closed (the problem at the end of 4.1; the complement is open by the triangle inequality argument).
    Let cn=12(1n+1n+1)c_n = \frac12(\frac1n + \frac1{n+1}), hn=12(1n−1n+1)h_n = \frac12(\frac1n - \frac1{n+1}) and fn(x)=max⁡(0,1−∣x−cn∣/hn)f_n(x) = \max\bigl(0, 1 - |x - c_n|/h_n\bigr).
    Tent of height 11 and half-width hnh_n, centred at the midpoint cnc_n of the interval [1n+1,1n][\frac1{n+1}, \frac1n]. For n=1n = 1 the interval is [12,1][\frac12, 1] and the centre is 34\frac34.
    For n≠mn \ne m the functions fnf_n and fmf_m are never non-zero at the same point.
    Each fnf_n is continuous with values in [0,1][0, 1], so fn∈Bf_n \in B. It is non-zero only on the open interval (1n+1,1n)(\frac1{n+1}, \frac1n), and these open intervals are pairwise disjoint.
    Hence d∞(fn,fm)=1d_\infty(f_n, f_m) = 1 for all n≠mn \ne m.
    At x=cnx = c_n: fn(cn)=1f_n(c_n) = 1 and fm(cn)=0f_m(c_n) = 0. Everywhere else at most one of them is non-zero, and values lie in [0,1][0, 1], so ∣fn−fm∣≤1|f_n - f_m| \le 1.
    No subsequence of (fn)(f_n) converges. So BB is not sequentially compact, hence not compact. ■\blacksquare
    A convergent sequence is Cauchy (4.2). A subsequence of (fn)(f_n) has all pairwise distances equal to 11, so for ε=12\varepsilon = \frac12 it is not Cauchy.

    The unit ball here is closed, bounded and even complete (4.2 shows C[0,1]C[0, 1] is complete and the ball is a closed subset). What fails is total boundedness: no finite set of functions is within 12\frac12 of all the tents. The space has infinitely many independent directions, the way Rn\mathbb R^n has nn, and a ball in each direction is needed.

    Quick checkThe closed unit ball of C[0,1]C[0, 1] with the sup metric is closed, bounded and complete. Why is it not compact?

    A computation in this space, to get used to the sup metric:

    Your answerIn C[0,1]C[0, 1] with the sup metric, what is d∞(xn,x2n)d_\infty(x^n, x^{2n}) for any n≥1n \ge 1? (Hint: the gap is xn−x2nx^n - x^{2n}; put u=xnu = x^n.)

    Compactness at work

    A few statements about continuous maps before the three theorems. A map f:X→Yf : X \to Y between metric spaces is continuous at aa if for every ε>0\varepsilon > 0 there is δ>0\delta > 0 with dY(f(x),f(a))<εd_Y(f(x), f(a)) < \varepsilon whenever dX(x,a)<δd_X(x, a) < \delta (the definition of 1.3 with two distances; 4.5 names and studies it).

    Lemma B Abbott Thm 4.3.2; Rudin Thm 4.2

    Continuous maps send convergent sequences to convergent sequences

    Let f:X→Yf : X \to Y be continuous at aa and xn→ax_n \to a in XX. Then f(xn)→f(a)f(x_n) \to f(a) in YY.

    In one lineIf ff is continuous at aa and xn→ax_n \to a, then f(xn)→f(a)f(x_n) \to f(a).

    Why it is trueContinuity turns the target tolerance into an input tolerance, and convergence of xnx_n makes the inputs fall inside it eventually.

    ProofAbbott 4.3.2
    The idea: The same two-step proof as the sequential criterion in 1.3, with distances.
    Let ε>0\varepsilon > 0.
    Arbitrary output tolerance.
    Choose δ>0\delta > 0 with dY(f(x),f(a))<εd_Y(f(x), f(a)) < \varepsilon whenever dX(x,a)<δd_X(x, a) < \delta.
    Continuity of ff at aa.
    Choose NN with dX(xn,a)<δd_X(x_n, a) < \delta for n>Nn > N.
    xn→ax_n \to a with tolerance δ\delta.
    For n>Nn > N, dY(f(xn),f(a))<εd_Y(f(x_n), f(a)) < \varepsilon. ■\blacksquare
    Combine the two choices.
    Theorem B Rudin Thm 4.14; Abbott Thm 4.4.1

    Continuous image of a compact set is compact

    If KK is a compact metric space and f:K→Yf : K \to Y is continuous, then f(K)f(K) is a compact subset of YY.

    In one lineIf KK is compact and f:K→Yf : K \to Y is continuous, then f(K)f(K) is compact.

    Why it is trueA sequence in the image comes from a sequence in KK; a convergent subsequence there is carried by continuity to a convergent subsequence of the image.

    ProofRudin 4.14
    The idea: Use sequential compactness on both ends: lift a sequence of the image to K, extract a convergent subsequence there, and push it forward.
    Let (yn)(y_n) be a sequence in f(K)f(K). Each yn=f(xn)y_n = f(x_n) for some xn∈Kx_n \in K.
    By the equivalence theorem, compact means sequentially compact, so we may check that.
    Some subsequence xnk→x∈Kx_{n_k} \to x \in K.
    KK is sequentially compact.
    ynk=f(xnk)→f(x)y_{n_k} = f(x_{n_k}) \to f(x), and f(x)∈f(K)f(x) \in f(K).
    The lemma on convergent sequences.
    So f(K)f(K) is sequentially compact, hence compact. ■\blacksquare
    Every sequence in f(K)f(K) has a subsequence converging in f(K)f(K).
    Theorem B Rudin Thm 4.16; Abbott Thm 4.4.2; Apostol Sec. 9.9

    Extreme value theorem on a compact set

    Let KK be a non-empty compact metric space and f:K→Rf : K \to \mathbb R continuous. Then there are c,d∈Kc, d \in K with f(c)≤f(x)≤f(d)f(c) \le f(x) \le f(d) for all x∈Kx \in K.

    In one lineA continuous real function on a non-empty compact set attains a maximum and a minimum.

    Why it is trueThe image is a compact subset of the line, so closed and bounded; a non-empty closed bounded set of reals contains its supremum and infimum.

    ProofRudin 4.16
    The idea: f(K) is compact in R, so bounded; its supremum M exists; M is a limit of values of f, and a closed set contains its limits, so M is a value.
    f(K)f(K) is a compact subset of R\mathbb R.
    The theorem on continuous images.
    So f(K)f(K) is closed and bounded, and non-empty.
    Compact sets are closed and bounded.
    Let M=sup⁡f(K)M = \sup f(K).
    Bounded above and non-empty, so the supremum exists (completeness axiom, 1.1).
    There are yn∈f(K)y_n \in f(K) with M−1n<yn≤MM - \frac1n < y_n \le M, so yn→My_n \to M.
    Approximation property of the supremum: for each nn there is a value within 1n\frac1n of MM.
    So M∈f(K)M \in f(K): M=f(d)M = f(d) for some d∈Kd \in K.
    A closed set contains the limit of every convergent sequence of its points (4.2).
    Hence f(d)f(d) is the maximum and a minimum f(c)f(c) exists. ■\blacksquare
    The same argument for −f-f gives the minimum.

    This is the extreme value theorem of 1.3, with the interval [a,b][a, b] replaced by any compact metric space. Its three ingredients are the three facts proved above: the image is compact, compact sets of R\mathbb R are closed and bounded, and closed sets contain their supremum.

    Worked example
    Show that f(x,y)=x+2yf(x, y) = x + 2y attains a maximum on the circle x2+y2=1x^2 + y^2 = 1, and find it.

    Solution.

    1. The circle is compact. It is closed (the sphere argument above) and bounded, so compact by Heine–Borel. Heine–Borel in R2\mathbb R^2.
    2. ff is continuous. It is a sum of coordinate functions with constant factors; ∣f(p)−f(q)∣≤∣p1−q1∣+2∣p2−q2∣≤3∥p−q∥2|f(p) - f(q)| \le |p_1 - q_1| + 2|p_2 - q_2| \le 3 \lVert p - q \rVert_2. The inequality gives δ=ε/3\delta = \varepsilon/3.
    3. So a maximum exists. By the extreme value theorem on a compact set. It does not tell where; it promises that a search for the maximum has a target.
    4. Find it. By Cauchy–Schwarz (2.9), x+2y=(x,y)⋅(1,2)≤∥(x,y)∥ ∥(1,2)∥=5x + 2y = (x, y) \cdot (1, 2) \le \lVert (x, y) \rVert\,\lVert (1, 2) \rVert = \sqrt5, with equality when (x,y)(x, y) is parallel to (1,2)(1, 2): (x,y)=15(1,2)(x, y) = \frac1{\sqrt5}(1, 2). Equality in Cauchy–Schwarz holds for parallel vectors, and this point is on the circle.

    Answer. The maximum is 5≈2.236\sqrt5 \approx 2.236, attained at (15,25)(\frac1{\sqrt5}, \frac2{\sqrt5}). ■\blacksquare

    Your answerWhat is the maximum value of x+2yx + 2y on the circle x2+y2=1x^2 + y^2 = 1?
    Theorem B Rudin Thm 4.19; Abbott Thm 4.4.7

    Continuous on a compact set implies uniformly continuous

    Let KK be a compact metric space and f:K→Yf : K \to Y continuous. Then for every ε>0\varepsilon > 0 there is δ>0\delta > 0 with dY(f(x),f(y))<εd_Y(f(x), f(y)) < \varepsilon whenever dK(x,y)<δd_K(x, y) < \delta. (This is uniform continuity as defined in 1.3, with the two distances.)

    In one lineA continuous map from a compact metric space to any metric space is uniformly continuous: one δ\delta works for the whole set.

    Why it is trueEvery point has its own tolerance; the Lebesgue number of the cover by those tolerance-balls is a single tolerance that serves everywhere.

    ProofRudin 4.19
    The idea: Give each point p the δ_p that works for ε/2 at p. The balls B(p, δ_p) cover K. A Lebesgue number λ of this cover is the δ: two points within λ of each other lie in one ball B(p, δ_p), so their images are both within ε/2 of f(p).
    Let ε>0\varepsilon > 0. For each p∈Kp \in K choose δp>0\delta_p > 0 with dY(f(x),f(p))<ε2d_Y(f(x), f(p)) < \frac\varepsilon2 whenever dK(x,p)<δpd_K(x, p) < \delta_p.
    Arbitrary tolerance. For each point we use continuity with half of it, to get two images close through a common centre.
    The balls B(p,δp)B(p, \delta_p), p∈Kp \in K, form an open cover of KK.
    Each point pp lies in its own ball.
    Let λ>0\lambda > 0 be a Lebesgue number: every ball B(x,λ)B(x, \lambda) lies in some B(p,δp)B(p, \delta_p).
    KK is compact, hence sequentially compact; the Lebesgue number lemma applies.
    So dY(f(x),f(p))<ε2d_Y(f(x), f(p)) < \frac\varepsilon2 and dY(f(y),f(p))<ε2d_Y(f(y), f(p)) < \frac\varepsilon2.
    Take δ=λ\delta = \lambda. Let dK(x,y)<λd_K(x, y) < \lambda, so y∈B(x,λ)y \in B(x, \lambda). Choose pp with B(x,λ)⊆B(p,δp)B(x, \lambda) \subseteq B(p, \delta_p). Then both xx and yy are within δp\delta_p of pp.
    dY(f(x),f(y))≤dY(f(x),f(p))+dY(f(p),f(y))<εd_Y(f(x), f(y)) \le d_Y(f(x), f(p)) + d_Y(f(p), f(y)) < \varepsilon. ■\blacksquare
    Triangle inequality in YY, through f(p)f(p).

    The proof in 1.3 used sequences instead, and found a convergent subsequence of “bad pairs”. The Lebesgue number is the same device: in the picture it is the minimum of the infinitely many local tolerances, and compactness keeps that minimum positive.

    Worked example
    For f(x)=x2f(x) = x^2 on [0,3][0, 3] and ε=0.03\varepsilon = 0.03, find a δ\delta that works at every point at once.

    Solution.

    1. The set is compact. [0,3][0, 3] is closed and bounded. Heine–Borel, so the theorem promises a uniform δ\delta exists.
    2. Find the size of the slope. For x,y∈[0,3]x, y \in [0, 3], ∣x2−y2∣=∣x−y∣ ∣x+y∣≤6 ∣x−y∣|x^2 - y^2| = |x - y|\,|x + y| \le 6\,|x - y|. ∣x+y∣≤6|x + y| \le 6 on [0,3][0, 3], the bound on how steep the graph can get.
    3. Choose δ\delta. We want 6δ≤ε=0.036\delta \le \varepsilon = 0.03, so δ=0.005=1200\delta = 0.005 = \frac1{200}. Then ∣x−y∣<δ|x - y| < \delta implies ∣x2−y2∣<6δ=0.03|x^2 - y^2| < 6\delta = 0.03 for every pair of points in the interval.

    Answer. δ=1200\delta = \frac1{200} works everywhere on [0,3][0, 3]. On R\mathbb R no such δ\delta exists (1.3). ■\blacksquare

    Your answerFor f(x)=x2f(x) = x^2 on [0,3][0, 3] the bound ∣x2−y2∣≤6∣x−y∣|x^2 - y^2| \le 6|x - y| holds. For ε=0.03\varepsilon = 0.03, what is δ=ε/6\delta = \varepsilon / 6?
    Quick checkWhich of these functions is uniformly continuous on its domain?

    Where it is used

    Used inside maths· Inside maths: why the earlier chapters worked, and what comes next

    Every proof in 1.3 that said “take a convergent subsequence” was using compactness of [a,b][a, b]. Chapter 1.5 needs uniform continuity to show that a continuous function is integrable; that is the compact-set theorem above. In 4.5 the compactness of the unit sphere of Rn\mathbb R^n proves that all norms on Rn\mathbb R^n are equivalent, the fact that 4.1 stated without proof. In Unit 5, a function of several variables on a closed bounded region has a maximum and a minimum by the theorem above; critical-point methods then find them. Later courses use the stronger statements named here without proof: the Arzelà–Ascoli theorem says which subsets of C[0,1]C[0, 1] are compact (the extra condition is that the functions do not oscillate faster and faster), and Tychonoff’s theorem says a product of compact spaces is compact (B, named only). A continuous bijection from a compact space onto another metric space is automatically a homeomorphism, shown in 4.5.

    Used in the real world· Machine learning: when does a minimizer of the loss exist?

    Training a model means minimizing a continuous loss L(w)L(w) over weights ww. The extreme value theorem says a minimizer exists on a compact set. Take logistic regression on two points: x=1x = 1 with label +1+1, and x=−1x = -1 with label −1-1, one weight ww. The loss is L(w)=2log⁡(1+e−w)L(w) = 2\log(1 + e^{-w}). It is continuous and decreasing, with infimum 00 approached as w→∞w \to \infty but never reached: on the unbounded set R\mathbb R the minimum does not exist. Gradient descent on separable data of this kind makes the weights grow without bound, like log⁡t\log t after tt steps (Soudry and co-authors, 2018). Constrain ∣w∣≤B|w| \le B, a compact interval, and the minimum exists, at w=Bw = B: with B=5B = 5 it is 2log⁡(1+e−5)≈0.01342\log(1 + e^{-5}) \approx 0.0134. Weight decay, norm clipping and constraint balls all restore compactness in finite dimensions. In infinite-dimensional function spaces the closed ball is not compact (the tent functions above), so minimizers over all functions need extra structure, such as equicontinuity in Arzelà–Ascoli.

    Your answerLogistic loss on the two points above is L(w)=2log⁡(1+e−w)L(w) = 2\log(1 + e^{-w}). What is its minimum over the compact set ∣w∣≤5|w| \le 5, as a decimal?
    Python labFind a finite subcover, and see the Lebesgue number
    import random
    random.seed(3)
    
    def make_cover():
        sets, x = [], -0.05
        while x < 1.05:
            w = random.uniform(0.05, 0.3)
            sets.append((x - random.uniform(0, 0.05), x + w))
            x += w * random.uniform(0.3, 0.9)      # change 0.9 to 2.0 to open gaps
        random.shuffle(sets)
        return sets
    
    def room(x, S):          # how far a ball around x can grow and stay inside one set
        return max(min(x - l, r - x) for l, r in S if l < x < r)
    
    sets = make_cover()
    grid = [i / 2000 for i in range(2001)]
    assert all(any(l < x < r for l, r in sets) for x in grid), "not a cover"
    lam = min(room(x, sets) for x in grid)
    print("sets in the cover:", len(sets), "  Lebesgue number about", round(lam, 4))
    
    chosen, x = [], 0.0                              # greedy finite subcover
    while x <= 1:
        options = [s for s in sets if s[0] < x < s[1]]
        best = max(options, key=lambda s: s[1])
        chosen.append(best)
        x = best[1]
    print("a finite subcover uses", len(chosen), "sets")
    
    inf_cover = [(1 / n, 2) for n in range(1, 10001)]
    for x in [0.5, 0.1, 0.01, 0.001]:
        print("(0,1] cover: x =", x, " room =", round(room(x, inf_cover), 5))

    Try this. Run it as is. The Lebesgue number is the smallest 'room' any point of [0, 1] has inside the sets of the cover, and it is positive. The last four lines show the same quantity for the cover (1/n, 2) of (0, 1]: the room at the point x is about x, which shrinks to 0, so there is no Lebesgue number and no finite subcover. Now change the 0.9 in the step to 2.0, so that neighbouring intervals can stop overlapping. The assertion fails (some grid point is uncovered): a family with gaps is not a cover.

    Traps

    Watch out· Closed and bounded is compact only in R^n

    Heine–Borel is a theorem about Rn\mathbb R^n. In C[0,1]C[0, 1], in the space of bounded sequences and in every infinite-dimensional normed space, the closed unit ball is closed and bounded and not compact. The right general statement is “complete and totally bounded”. If a problem is set in a function space, do not quote Heine–Borel.

    Watch out· Sequentially compact means the limit is INSIDE the set

    (0,1](0, 1] has plenty of convergent subsequences. 1n\frac1n converges, in R\mathbb R. What fails is that the limit is in (0,1](0, 1]. The definition says “a subsequence that converges to a point of KK”. Dropping “of KK” turns it into boundedness.

    Watch out· To show NOT compact, exhibit one cover, not 'many covers'

    Compact means EVERY open cover has a finite subcover. To prove a set is not compact you give one cover with no finite subcover (like {(1n,2)}\{(\frac1n, 2)\} for (0,1](0, 1]). To prove a set is compact you cannot check covers one at a time. You use Heine–Borel, or sequences, or a continuous image of a compact set.

    Watch out· A cover that is already finite proves nothing

    The one-set family {R}\{\mathbb R\} covers every subset of the line, and it is finite. That shows nothing about compactness. The definition quantifies over ALL open covers: you are handed a family, possibly infinite and chosen to be awkward, and must find finitely many of its members that still cover. A cover that thins out near an edge, like the sets (1n,2)(\frac1n, 2) for (0,1](0, 1], is the dangerous kind.

    Watch out· Compactness is not preserved by taking preimages

    The continuous image of a compact set is compact. The preimage of a compact set need not be. Take f(x)=0f(x) = 0 for all x∈Rx \in \mathbb R and the compact set {0}\{0\}: its preimage is all of R\mathbb R, which is not compact. Only images behave.

    Problems

    check

    Decide whether each is compact: (a) [0,1]×[2,5]⊂R2[0, 1] \times [2, 5] \subset \mathbb R^2. (b) {(x,y):x2+y2≤1}∖{(0,0)}\{(x, y) : x^2 + y^2 \le 1\} \setminus \{(0, 0)\}. (c) {1/n:n≥1}∪{0}\{1/n : n \ge 1\} \cup \{0\}. (d) {1/n:n≥1}\{1/n : n \ge 1\}.

    Solution

    (a) Closed bounded box: compact. (b) The closed disc with the centre removed is not closed ((1n,0)→(0,0)(\frac1n, 0) \to (0, 0), which is outside). Not compact. (c) Closed (it contains the limit 00 of 1n\frac1n) and bounded: compact. (d) Not closed (00 is a limit point outside): not compact.

    check

    Write an open cover of (0,∞)(0, \infty) with no finite subcover. Is the set (0,∞)(0, \infty) compact?

    Solution

    Un=(1n,n)U_n = (\frac1n, n). Each x>0x > 0 is in UnU_n for nn large. A finite subfamily has union UNU_N, which misses small and large numbers. So (0,∞)(0, \infty) is not compact.

    check

    True or false: every finite subset of a metric space is compact.

    Solution

    True. Given an open cover, choose for each of the finitely many points one set containing it. Those finitely many sets cover the set.

    check

    A continuous function ff on (0,1)(0, 1) is bounded. Does ff attain a maximum? Give an example either way.

    Solution

    Not necessarily. f(x)=xf(x) = x is bounded by 11 and takes all values below 11 but never reaches it. On the other hand f(x)=sin⁡(πx)f(x) = \sin(\pi x) attains 11 at x=12x = \frac12. The extreme value theorem needs a compact domain; bounded values are not enough.

    use

    Show that the closed ball {x∈Rn:∥x−c∥2≤r}\{x \in \mathbb R^n : \lVert x - c \rVert_2 \le r\} is compact, and that the sphere {∥x−c∥2=r}\{\lVert x - c \rVert_2 = r\} is compact.

    Solution

    Bounded: every point is within rr of cc. Closed: if xk→xx_k \to x and ∥xk−c∥≤r\lVert x_k - c \rVert \le r then ∥x−c∥≤r\lVert x - c \rVert \le r, since ∣∥xk−c∥−∥x−c∥∣≤∥xk−x∥→0|\lVert x_k - c \rVert - \lVert x - c \rVert| \le \lVert x_k - x \rVert \to 0. The same argument with equality gives the sphere. Heine–Borel applies to both.

    use

    Let K⊂R2K \subset \mathbb R^2 be the compact set {x2+y2≤4}\{x^2 + y^2 \le 4\} and f(x,y)=x2−yf(x, y) = x^2 - y. Explain why ff has a maximum and a minimum on KK, and find them.

    Solution

    KK is a closed disc, compact, ff is continuous, so extremes exist. Interior critical point: ∇f=(2x,−1)≠0\nabla f = (2x, -1) \ne 0, so none. On the boundary x=2cos⁡tx = 2\cos t, y=2sin⁡ty = 2\sin t: f=4cos⁡2t−2sin⁡t=4−4sin⁡2t−2sin⁡tf = 4\cos^2 t - 2\sin t = 4 - 4\sin^2 t - 2\sin t. Put s=sin⁡t∈[−1,1]s = \sin t \in [-1, 1]: 4−4s2−2s4 - 4s^2 - 2s, with vertex at s=−14s = -\frac14 giving 4−14+12=4.254 - \frac14 + \frac12 = 4.25. At s=1s = 1: −2-2; at s=−1s = -1: 22. Maximum 4.254.25, minimum −2-2 (at (0,2)(0, 2)).

    use

    Is f(x)=xf(x) = \sqrt x uniformly continuous on [0,1][0, 1]? What is a δ\delta for ε=0.1\varepsilon = 0.1 that works everywhere?

    Solution

    Yes: continuous on the compact [0,1][0, 1]. For explicit δ\delta use ∣x−y∣≤∣x−y∣|\sqrt x - \sqrt y| \le \sqrt{|x - y|}. So δ=ε2=0.01\delta = \varepsilon^2 = 0.01 works: ∣x−y∣<0.01|x - y| < 0.01 gives ∣x−y∣<0.1|\sqrt x - \sqrt y| < 0.1. (The derivative is unbounded near 00, so δ\delta cannot be proportional to ε\varepsilon.)

    use

    For the discrete metric on a set XX, which subsets of XX are compact?

    Solution

    Exactly the finite ones. A finite set is compact (an earlier check problem). If K⊆XK \subseteq X is infinite, the sets {x}\{x\} for x∈Kx \in K are open (the ball of radius 12\frac12 around xx is {x}\{x\}) and cover KK, and removing any one of them leaves its point uncovered, so no finite subfamily covers KK. Equivalently, KK is complete but not totally bounded, as in part (d) of the example above.

    prove

    Prove that a finite union of compact sets is compact.

    Solution

    Plan. Cover the union, then take a finite subcover for each piece.

    Let K1,…,KmK_1, \dots, K_m be compact and {Uα}\{U_\alpha\} an open cover of K1∪⋯∪KmK_1 \cup \dots \cup K_m. It also covers each KiK_i, so finitely many UαU_\alpha cover KiK_i. Collect these finite subfamilies: finitely many sets in total cover the union. ■\blacksquare

    proveRudin Thm 2.35 style; new

    Prove that if KK is compact and FF is closed then K∩FK \cap F is compact.

    Solution

    Plan. It is a closed subset of the compact set KK.

    K∩F⊆KK \cap F \subseteq K, and it is closed because an intersection of closed sets is closed (4.1). By the lemma on closed subsets of compact sets, it is compact. ■\blacksquare

    prove

    Prove: if KK is a compact subset of a metric space and pp is a point outside KK, there is a point q∈Kq \in K with d(p,q)≤d(p,x)d(p, q) \le d(p, x) for all x∈Kx \in K (a nearest point).

    Solution

    Plan. The distance to pp is a continuous function on a compact set.

    h(x)=d(p,x)h(x) = d(p, x) is continuous on KK because ∣h(x)−h(y)∣≤d(x,y)|h(x) - h(y)| \le d(x, y) (reverse triangle inequality), so δ=ε\delta = \varepsilon works. KK is compact, and non-empty (it must be, for a nearest point to exist), so by the extreme value theorem hh attains its minimum at some q∈Kq \in K. ■\blacksquare

    prove

    Prove: if K1⊇K2⊇⋯K_1 \supseteq K_2 \supseteq \cdots is a nested sequence of non-empty compact sets, then ⋂nKn≠∅\bigcap_n K_n \ne \varnothing.

    Solution

    Plan. Pick a point in each set, take a convergent subsequence, and show the limit is in every KnK_n.

    Choose xn∈Knx_n \in K_n. All xn∈K1x_n \in K_1, which is sequentially compact, so a subsequence xnk→x∈K1x_{n_k} \to x \in K_1. For a fixed mm, the terms xnkx_{n_k} with nk≥mn_k \ge m lie in KmK_m (nested), and KmK_m is closed (compact sets are closed), so the limit x∈Kmx \in K_m. This holds for every mm, so x∈⋂Kmx \in \bigcap K_m. ■\blacksquare (This is the compact version of the nested interval theorem. The halving argument in Heine–Borel used the same idea, with completeness of Rn\mathbb R^n finding the common point.)

    prove

    Prove that a continuous bijection f:K→Yf : K \to Y from a compact metric space onto a metric space has a continuous inverse. (Hint: argue with sequences and a convergent subsequence.)

    Solution

    Plan. Argue by contradiction with sequences: if the inverse is not continuous, a bad sequence in KK has a convergent subsequence, and pushing it forward with ff gives a contradiction. (4.5 proves the same fact with closed sets.)

    Let g=f−1g = f^{-1} and suppose yn→yy_n \to y in YY but g(yn)↛g(y)g(y_n) \not\to g(y). Here we use the sequence form of continuity, 4.5. Then for some ε>0\varepsilon > 0 there is a subsequence with d(g(ynk),g(y))≥εd(g(y_{n_k}), g(y)) \ge \varepsilon. The points xk=g(ynk)x_k = g(y_{n_k}) lie in the compact KK, so a further subsequence converges to some x∈Kx \in K, with d(x,g(y))≥εd(x, g(y)) \ge \varepsilon. By continuity, f(xk)→f(x)f(x_k) \to f(x), but f(xk)=ynk→yf(x_k) = y_{n_k} \to y, so f(x)=yf(x) = y by uniqueness of limits, so x=g(y)x = g(y) by injectivity, a contradiction with d(x,g(y))≥εd(x, g(y)) \ge \varepsilon. ■\blacksquare

    stretch

    Prove that the set K={f∈C[0,1]:∣f(x)−f(y)∣≤∣x−y∣ and f(0)=0}K = \{f \in C[0, 1] : |f(x) - f(y)| \le |x - y| \text{ and } f(0) = 0\} is totally bounded in the sup metric. (This is the Arzelà–Ascoli idea. KK is also closed, so it is compact.)

    Solution

    Plan. Round the function values on a grid; the Lipschitz condition forces each function to be close to a rounded step version of itself.

    Fix ε>0\varepsilon > 0 and choose NN with 1N<ε4\frac1N < \frac\varepsilon4. Grid points xj=jNx_j = \frac jN. For f∈Kf \in K, ∣f(xj)∣≤xj≤1|f(x_j)| \le x_j \le 1. Round each f(xj)f(x_j) to the nearest multiple of ε4\frac\varepsilon4: finitely many possible rounded vectors (r1,…,rN)(r_1, \dots, r_N). Two functions f,g∈Kf, g \in K with the same rounded vector satisfy ∣f(xj)−g(xj)∣≤ε4|f(x_j) - g(x_j)| \le \frac\varepsilon4 at every grid point. For any xx, pick the nearest grid point xjx_j with ∣x−xj∣≤1N<ε4|x - x_j| \le \frac1N < \frac\varepsilon4: ∣f(x)−g(x)∣≤∣f(x)−f(xj)∣+∣f(xj)−g(xj)∣+∣g(xj)−g(x)∣<ε4+ε4+ε4<ε|f(x) - g(x)| \le |f(x) - f(x_j)| + |f(x_j) - g(x_j)| + |g(x_j) - g(x)| < \frac\varepsilon4 + \frac\varepsilon4 + \frac\varepsilon4 < \varepsilon. So the functions of KK fall into finitely many classes, each of diameter below ε\varepsilon in d∞d_\infty; picking one function from each class gives finitely many balls of radius ε\varepsilon covering KK. ■\blacksquare

    stretch

    Prove that a compact metric space KK has a countable dense subset: a countable set D⊆KD \subseteq K such that every ball B(x,r)B(x, r) with x∈Kx \in K contains a point of DD.

    Solution

    Plan. Total boundedness at the scales 1n\frac1n gives finitely many centres at each scale. Collect all the centres.

    For each nn, total boundedness gives a finite set Dn⊆KD_n \subseteq K with K=⋃p∈DnB(p,1n)K = \bigcup_{p \in D_n} B(p, \frac1n). Let D=⋃nDnD = \bigcup_n D_n, a countable union of finite sets, so countable. Given x∈Kx \in K and r>0r > 0, choose nn with 1n<r\frac1n < r. Then x∈B(p,1n)x \in B(p, \frac1n) for some p∈Dnp \in D_n, so d(x,p)<1n<rd(x, p) < \frac1n < r, that is p∈B(x,r)∩Dp \in B(x, r) \cap D. ■\blacksquare

    Summary

    • A set is sequentially compact if every sequence in it has a subsequence converging to a point of the set. It is compact if every open cover has a finite subcover. In a metric space these two are the same.
    • Compact sets are closed and bounded in every metric space. In Rn\mathbb R^n the converse holds as well: this is Heine–Borel, proved by halving a box that has no finite subcover until the boxes shrink to a point covered by one open set.
    • In a function space the closed unit ball is closed and bounded and not compact (tent functions at distance 1 from each other). The general statement is: compact means complete and totally bounded.
    • The proof that sequentially compact implies compact uses a Lebesgue number: one radius such that every ball of that radius sits inside a single set of the cover.
    • A continuous map sends compact sets to compact sets. Hence a continuous real function on a compact set attains its maximum and minimum, and a continuous map on a compact set is uniformly continuous.
    • Compactness is how an infinite set earns the good properties of a finite one: finite sets have a largest value and a smallest tolerance.
    • In machine learning, a minimizer of a continuous loss exists on a compact weight set. Logistic loss on separable data has infimum 0 on the whole line and no minimizer.

    Where this sits

    Comes from
    4.1 Metric and normed spaces; open and closed sets
    4.2 Convergence, completeness and the contraction mapping theorem
    1.2 Sequences and limits, from zero
    1.3 Limits and continuity with epsilon and delta
    Leads to
    4.5 Continuity between metric spaces
    Same idea elsewhere
    MATH 375: Apostol 8.2 to 8.3 define open sets and balls but never use the word compact. The extreme value theorem for a continuous function on a closed bounded region of $\mathbb R^n$ (Apostol 9.9 to 9.12, maxima and minima) is quoted without proof. This chapter proves it.
    MATH 521: 521 spends several weeks here: Heine–Borel, sequential compactness, the equivalence in metric spaces, the extreme value theorem and uniform continuity on compact sets. Chapter 4.3 contains all of them with full proofs.
    MATH 551: Topology defines compact by open covers alone and proves that compact spaces are well behaved: closed subsets are compact, continuous images are compact. The sequential definition used here is only equivalent for metric spaces.
    CS 532 / optimization: A minimizer of a continuous loss exists when the search region is compact. Constraining weights to a norm ball is what makes that hold in finite dimensions.