Chapter 7 · Metric and Normed Spaces

7.2 Compactness in Metric Spaces

Finite up to $\varepsilon$: open covers, sequential compactness and total boundedness — why they agree in every metric space, why closed and bounded suffices in $\mathbb{R}^n$ but not in $\ell^2$ or $C[0,1]$, and what compactness does for continuous functions.

In §3.1 we met compactness on the real line: a set $K\subseteq\mathbb{R}$ is compact when every open cover has a finite subcover, and the Heine–Borel theorem identifies these sets as the closed bounded ones. Compactness is what turns local information into global information — "near every point $f$ is bounded" becomes "$f$ is bounded", "near every point one $\delta$ works" becomes "one $\delta$ works everywhere". The extreme value theorem, uniform continuity on $[a,b]$ and Dini's theorem are all instances.

In a general metric space three different ideas compete for the name "compact": every open cover has a finite subcover; every sequence has a convergent subsequence; and the space is complete and can be covered, for every $\varepsilon$, by finitely many $\varepsilon$-balls. The main theorem of this section is that in a metric space these are all the same. The other main point is a warning: "closed and bounded" is not on the list. It works in $\mathbb{R}^n$, but the closed unit ball of $\ell^2$, of $C[0,1]$ and of any infinite discrete space is closed, bounded and not compact — a fact that CSIR Part C tests in almost every paper, together with the Hilbert cube, which is compact although it is infinite-dimensional.

Compact Sets in a Metric Space

📘 Definition 7.11 — Open covers and compactness

Let $(X,d)$ be a metric space and $K\subseteq X$. An open cover of $K$ is a family $\mathcal U=\{U_\alpha\}_{\alpha\in I}$ of open subsets of $X$ with $K\subseteq\bigcup_\alpha U_\alpha$; a subcover is a subfamily that still covers $K$. $K$ is compact if every open cover of $K$ has a finite subcover. The space $X$ is compact if $K=X$ is.

Compactness is intrinsic. If $K\subseteq Y\subseteq X$, then $K$ is compact as a subset of $Y$ (covers by sets open in $Y$) iff it is compact as a subset of $X$: a set open in $Y$ has the form $V\cap Y$ with $V$ open in $X$, so covers translate in both directions. Hence we may always regard a compact set as a compact metric space in its own right. Closedness, by contrast, is relative: $(0,1]$ is closed in $(0,1]$ but not in $\mathbb{R}$, and it is not compact.

📐 Theorem 7.12 — First properties of compact sets

Let $(X,d)$ be a metric space.

  1. A compact subset of $X$ is closed and bounded.
  2. A closed subset of a compact set is compact.
  3. A finite union of compact sets is compact; an arbitrary (nonempty) intersection of compact sets is compact.
  4. Every finite set is compact; a convergent sequence together with its limit is compact.

Proof. (1) Bounded: fix $a\in X$; the balls $B(a,n)$, $n\in\mathbb{N}$, cover $X\supseteq K$, and they increase, so one of them contains $K$. Closed: let $p\in X\setminus K$. The open sets $U_n=\{x:d(x,p)\gt\tfrac1n\}$ cover $X\setminus\{p\}\supseteq K$ and increase, so $K\subseteq U_N$ for some $N$; then $B(p,\tfrac1N)$ misses $K$. Thus $X\setminus K$ is open.

(2) Let $F\subseteq K$ be closed in $X$ and $\mathcal U$ an open cover of $F$. Then $\mathcal U\cup\{X\setminus F\}$ is an open cover of $K$; take a finite subcover and discard $X\setminus F$, which contains no point of $F$.

(3) For $K_1\cup\dots\cup K_m$, combine finite subcovers of each $K_i$. An intersection $\bigcap K_\alpha$ is closed by (1) and lies in one compact $K_{\alpha_0}$, so it is compact by (2).

(4) Finite sets: one member per point. If $x_n\to x$ and $\mathcal U$ covers $K=\{x\}\cup\{x_n\}$, some $U_0\in\mathcal U$ contains $x$, hence a ball $B(x,r)$, hence all $x_n$ with $n\ge N$; finitely many further members cover $x_1,\dots,x_{N-1}$. ∎

The converse of (1) is false in general (Theorem 7.17 below); it is true in $\mathbb{R}^n$ (Theorem 7.16). Note also that (1) uses the metric: compact subsets of a metric space are closed because two distinct points can be separated by balls.

📘 Definition 7.12 — Finite intersection property
A family $\{F_\alpha\}$ of sets has the finite intersection property (FIP) if every finite subfamily has nonempty intersection: $F_{\alpha_1}\cap\dots\cap F_{\alpha_m}\ne\varnothing$.
📐 Theorem 7.13 — Compactness through closed sets
A metric space $X$ is compact if and only if every family of closed subsets of $X$ with the finite intersection property has nonempty intersection. In particular, if $K_1\supseteq K_2\supseteq\cdots$ are nonempty compact sets, then $\bigcap_nK_n\ne\varnothing$.

Proof. Closed sets $F_\alpha$ have empty intersection iff their complements $U_\alpha=X\setminus F_\alpha$ cover $X$ (De Morgan). "Some finite subfamily of the $F_\alpha$ has empty intersection" says "some finite subfamily of the $U_\alpha$ covers $X$". So "every open cover has a finite subcover" is, word for word, "every family of closed sets with empty intersection fails the FIP" — the contrapositive of the stated condition. For the nested sequence, apply this inside the compact space $K_1$: the closed subsets $K_n$ of $K_1$ have the FIP because $K_{n_1}\cap\dots\cap K_{n_m}=K_{\max n_i}\ne\varnothing$. ∎

Compactness cannot be dropped: in $\mathbb{R}$ the closed sets $[n,\infty)$ are nested and nonempty with empty intersection. Compare Cantor's intersection theorem (Theorem 7.8), which trades compactness for completeness plus $\operatorname{diam}F_n\to0$.

✏️ Example 1 — Closed and bounded, yet not compact
Prove from the definition that the following closed bounded sets are not compact: (a) an infinite set $X$ with the discrete metric; (b) $\mathbb{R}$ with the metric $\min(1,|x-y|)$; (c) the closed unit ball $\overline B=\{x\in\ell^2:\|x\|_2\le1\}$; (d) the set $(0,1]$ regarded as a metric space in its own right.
(a) $X$ is closed in itself and bounded ($X=B(a,2)$). The singletons $\{x\}=B(x,\tfrac12)$ are open and form a cover of $X$ in which every member is needed; since $X$ is infinite there is no finite subcover.
(b) Bounded: every distance is $\le1$. The open sets $(-n,n)$ (open for this metric, which has the same open sets as $|x-y|$, Theorem 7.5) cover $\mathbb{R}$ and increase, and no single one is all of $\mathbb{R}$. Compactness, unlike boundedness, is a topological property — so changing to a topologically equivalent bounded metric cannot make $\mathbb{R}$ compact.
(c) The unit vectors $e_n$ (with $1$ in place $n$) lie in $\overline B$ and $\|e_n-e_m\|_2=\sqrt2$ for $n\ne m$. The open balls $B(x,\tfrac{\sqrt2}2)$, $x\in\overline B$, cover $\overline B$; a ball of radius $\tfrac{\sqrt2}2$ contains at most one $e_n$ (two would be at distance $\lt\sqrt2$). So finitely many of these balls contain only finitely many $e_n$ and cannot cover $\overline B$.
(d) $(0,1]$ is closed and bounded as a space, but $U_n=(\tfrac1n,1]$ is an increasing open cover with no finite subcover. This is why "closed" must always be read in a complete ambient space before one can hope for Heine–Borel.

Sequential Compactness and Total Boundedness

📘 Definition 7.13 — Sequential compactness and the Bolzano–Weierstrass property
A metric space $X$ is sequentially compact if every sequence in $X$ has a subsequence converging to a point of $X$. It has the Bolzano–Weierstrass property if every infinite subset of $X$ has a limit point in $X$.
📘 Definition 7.14 — $\varepsilon$-nets and total boundedness
Let $\varepsilon\gt0$. A finite set $\{a_1,\dots,a_N\}\subseteq X$ is an $\varepsilon$-net for $X$ if $X=\bigcup_{i=1}^NB(a_i,\varepsilon)$, i.e. every point is within $\varepsilon$ of some $a_i$. $X$ is totally bounded (precompact) if it has an $\varepsilon$-net for every $\varepsilon\gt0$. A subset is totally bounded if it is so with the subspace metric.

Totally bounded sets are bounded (if $\{a_1,\dots,a_N\}$ is a $1$-net, $\operatorname{diam}X\le2+\max_{i,j}d(a_i,a_j)$), and a subset of a totally bounded set is totally bounded (Exercise II.1). In $\mathbb{R}^n$ the converse holds: a bounded set lies in a cube, and a cube of side $L$ is covered by $m^n$ subcubes of side $L/m$, each inside a ball of radius $\sqrt n\,L/m$. In infinite dimensions bounded sets need not be totally bounded — Example 1(c) shows that the unit ball of $\ell^2$ has no $\tfrac{\sqrt2}2$-net. A good way to see total boundedness is to build nets: go through the points and keep a point as a new centre whenever it is at distance at least $\varepsilon$ from all the centres chosen so far. The centres end up pairwise $\ge\varepsilon$ apart, and every point is within $\varepsilon$ of one of them. Interactive 1 does exactly this.

Interactive 1 — Building $\varepsilon$-Nets: How Many Balls Does a Set Need?

Left: a greedy $\varepsilon$-net for the chosen set (the lab works with a fine sample of its points). Each red centre carries its ball of radius $\varepsilon$; together they cover the set, and the centres are pairwise at least $\varepsilon$ apart. Right: $\log N(\varepsilon)$ against $\log(1/\varepsilon)$ for a ladder of radii; the slope is the set's dimension. Press Play to shrink $\varepsilon$. A totally bounded set needs finitely many balls for every $\varepsilon$; the unit vectors of $\ell^2$ need infinitely many as soon as $\varepsilon\le1$.

—
radius ε—
balls N(ε)—
log N / log(1/ε)—
fitted slope—
📘 Definition 7.15 — Lebesgue number of a cover
Let $\mathcal U$ be an open cover of a metric space $X$. A number $\lambda\gt0$ is a Lebesgue number of $\mathcal U$ if for every $x\in X$ the ball $B(x,\lambda)$ is contained in some member of $\mathcal U$. (Then every subset of diameter less than $\lambda$ lies in one member: it sits inside $B(a,\lambda)$ for any of its points $a$.)
📐 Theorem 7.14 — Lebesgue number lemma
Every open cover of a sequentially compact metric space has a Lebesgue number.

Proof. Suppose the open cover $\mathcal U$ has no Lebesgue number. Then for each $n$ the number $\tfrac1n$ fails: there is $x_n$ such that $B(x_n,\tfrac1n)$ lies in no member of $\mathcal U$. By sequential compactness a subsequence $x_{n_k}\to x\in X$. Some $U\in\mathcal U$ contains $x$, hence a ball $B(x,r)$. Choose $k$ so large that $d(x_{n_k},x)\lt\tfrac r2$ and $\tfrac1{n_k}\lt\tfrac r2$. Then for $y\in B(x_{n_k},\tfrac1{n_k})$, $d(y,x)\lt\tfrac r2+\tfrac r2=r$, so $B(x_{n_k},\tfrac1{n_k})\subseteq B(x,r)\subseteq U$ — a contradiction. ∎

A second, more geometric proof for compact $X$: the function $\rho$, where $\rho(x)$ is the supremum of the $r\le1$ such that $B(x,r)$ lies in some member of $\mathcal U$, is positive, and it is $1$-Lipschitz (if $B(x,r)\subseteq U$ then $B(y,r-d(x,y))\subseteq U$); a positive continuous function on a compact space has a positive minimum (Theorem 7.18), and any $\lambda$ below that minimum works. Interactive 2 plots this function $\rho$.

Interactive 2 — The Lebesgue Number of a Cover

Top: the members of an open cover (bars) of the green set $K$. A point $x$ moves along $K$; its amber ball $B(x,\rho(x))$ is the largest ball around $x$ that fits inside a single member (that member is highlighted). Bottom: the graph of $\rho(x)$. A Lebesgue number exists exactly when $\rho$ stays above a positive level; the dashed line marks $\inf\rho$. For the compact $[0,1]$ the infimum is a positive minimum; for $(0,1]$ with the cover $\left(\tfrac1{n+2},\tfrac1n\right)$ it is $0$.

x—
ρ(x)—
member used—
inf ρ (Lebesgue number)—
📐 Theorem 7.15 — Characterisation of compact metric spaces

For a metric space $X$ the following are equivalent:

  1. $X$ is compact (every open cover has a finite subcover);
  2. $X$ has the Bolzano–Weierstrass property (every infinite subset has a limit point in $X$);
  3. $X$ is sequentially compact;
  4. $X$ is complete and totally bounded.

Proof. (1)⇒(2). Let $E\subseteq X$ have no limit point in $X$. Then every $x\in X$ has a ball $B(x,r_x)$ containing no point of $E$ other than (possibly) $x$ itself. These balls cover $X$; finitely many of them cover $X$, and together they contain at most finitely many points of $E$. So $E$ is finite.

(2)⇒(3). Let $(x_n)$ be a sequence. If its range $E=\{x_n\}$ is finite, some value is taken infinitely often, giving a constant subsequence. Otherwise $E$ is infinite and has a limit point $p$. Every ball $B(p,r)$ then contains infinitely many points of $E$ (Exercise II.9 of §7.1), hence $x_n$ for infinitely many indices $n$. Choose $n_1$ with $d(x_{n_1},p)\lt1$ and, inductively, $n_{k+1}\gt n_k$ with $d(x_{n_{k+1}},p)\lt\tfrac1{k+1}$: then $x_{n_k}\to p$.

(3)⇒(4). A Cauchy sequence with a convergent subsequence converges (§7.1), so $X$ is complete. If $X$ were not totally bounded, some $\varepsilon\gt0$ would admit no finite $\varepsilon$-net. Pick any $x_1$; since $\{x_1\}$ is not an $\varepsilon$-net, there is $x_2$ with $d(x_2,x_1)\ge\varepsilon$; since $\{x_1,x_2\}$ is not, there is $x_3$ at distance $\ge\varepsilon$ from both; and so on. The sequence $(x_n)$ has $d(x_m,x_n)\ge\varepsilon$ for all $m\ne n$, so no subsequence is Cauchy, let alone convergent.

(4)⇒(3). Let $(x_n)$ be a sequence. Cover $X$ by finitely many balls of radius $1$; one of them, $B_1$, contains $x_n$ for infinitely many $n$. Cover $X$ by finitely many balls of radius $\tfrac12$; one of them, $B_2$, contains infinitely many of the terms lying in $B_1$. Continuing, we get balls $B_k$ of radius $\tfrac1k$ such that $B_1\cap\dots\cap B_k$ contains $x_n$ for infinitely many $n$. Choose $n_1\lt n_2\lt\cdots$ with $x_{n_k}\in B_1\cap\dots\cap B_k$. For $j,k\ge m$ both $x_{n_j}$ and $x_{n_k}$ lie in $B_m$, so $d(x_{n_j},x_{n_k})\lt\tfrac2m$: the subsequence is Cauchy, and it converges because $X$ is complete. (This is the Bolzano–Weierstrass bisection argument of §2.2 with "halve the interval" replaced by "use a finer net".)

(3)⇒(1). Let $\mathcal U$ be an open cover. By Theorem 7.14 it has a Lebesgue number $\lambda$, and by (3)⇒(4) $X$ is totally bounded, so it has a $\lambda$-net $\{a_1,\dots,a_N\}$. Each $B(a_i,\lambda)$ lies in some $U_i\in\mathcal U$, and then $U_1,\dots,U_N$ cover $X$. ∎

📐 Theorem 7.16 — Heine–Borel theorem in $\mathbb{R}^n$
A subset $K$ of $\mathbb{R}^n$ (with any of the metrics $d_p$, $1\le p\le\infty$) is compact if and only if it is closed and bounded. Equivalently, every bounded sequence in $\mathbb{R}^n$ has a convergent subsequence (Bolzano–Weierstrass in $\mathbb{R}^n$).

Proof. The metrics $d_p$ are strongly equivalent (Theorem 7.5), so they have the same open sets, bounded sets and compact sets; use $d_2$. Compact ⇒ closed and bounded is Theorem 7.12(1). Conversely, let $K$ be closed and bounded. As a closed subset of the complete space $\mathbb{R}^n$, $K$ is complete (Theorem 7.7). As a bounded set it lies in a cube $[-M,M]^n$, which for any $\varepsilon\gt0$ is covered by finitely many closed cubes of diameter $\varepsilon/2$. In each cube that meets $K$ choose a point of $K$; these finitely many points form an $\varepsilon$-net of $K$, because every point of $K$ shares a cube with one of them. So $K$ is totally bounded. By Theorem 7.15, $K$ is compact. For the sequence form, a bounded sequence lies in a closed ball, which is compact. ∎

A second route avoids Theorem 7.15: by the one-dimensional Bolzano–Weierstrass theorem, extract a subsequence whose first coordinates converge, then a further subsequence whose second coordinates converge, and so on through the $n$ coordinates. Either way, the proof uses exactly two facts about $\mathbb{R}^n$ — completeness and the fact that a bounded set can be chopped into finitely many small pieces — and the second fails in every infinite-dimensional space.

✏️ Example 2 — Computing a Lebesgue number
In $X=[0,1]$ with the usual metric consider the cover by the sets $U_1=[0,\tfrac12)$, $U_2=(\tfrac14,\tfrac34)$, $U_3=(\tfrac12,1]$, which are open in $X$. (a) Find the largest Lebesgue number in the sense of Definition 7.15. (b) Find the supremum of the $\delta$ such that every subset of diameter less than $\delta$ lies in one member. (c) Show that the open cover of $(0,1]$ by $V_0=(\tfrac12,2)$ and $V_n=(\tfrac1{n+2},\tfrac1n)$, $n\ge1$, has no Lebesgue number.
The function ρ For $x\in X$ let $\rho(x)$ be the largest $r$ with $B_X(x,r)$ inside one member. For $x\in[0,\tfrac14]$ only $U_1$ contains $x$, and $B_X(x,r)=[0,x+r)\cap\dots$ fits iff $x+r\le\tfrac12$: $\rho(x)=\tfrac12-x\ge\tfrac14$. For $x\in(\tfrac14,\tfrac12)$, $x\in U_1\cap U_2$ and $\rho(x)=\max\left(\tfrac12-x,\ x-\tfrac14\right)$, which is smallest at $x=\tfrac38$, where it equals $\tfrac18$. At $x=\tfrac12$ only $U_2$ works: $\rho=\tfrac14$. The right half is symmetric.
(a) $\min\rho=\tfrac18$ (attained at $\tfrac38$ and $\tfrac58$). Since the balls are open, $\lambda=\tfrac18$ itself works: $B(\tfrac38,\tfrac18)=(\tfrac14,\tfrac12)\subseteq U_1$. No $\lambda\gt\tfrac18$ works. So the largest Lebesgue number is $\tfrac18$.
(b) A set $A$ with $\operatorname{diam}A\lt\tfrac14$ lies in $[a,a+\tfrac14)$ with $a=\inf A$; checking the cases $a\lt\tfrac14$ (inside $U_1$), $a=\tfrac14$ (inside $[\tfrac14,\tfrac12)\subseteq U_1$), $\tfrac14\lt a\lt\tfrac12$ (inside $U_2$), $a=\tfrac12$ (inside $U_2$) and $a\gt\tfrac12$ (inside $U_3$) shows it lies in one member. But $[\tfrac14,\tfrac12]$ has diameter exactly $\tfrac14$ and lies in no member. So the supremum is $\tfrac14=2\cdot\tfrac18$: the diameter version and the ball version of the Lebesgue number differ by a factor of up to $2$, and exam questions must say which is meant.
(c) The $V_n$ are open and cover $(0,1]$ ($1\in V_0$, and $\tfrac1m\in V_{m-1}$ for $m\ge2$; any other $x\in(0,1)$ lies between some $\tfrac1{m+1}$ and $\tfrac1m$, inside $V_m$). A ball $B(x,r)$ around a small $x$ inside one $V_n$ needs $x\in V_n$, so $\tfrac1{n+2}\lt x$, and $r\le x-\tfrac1{n+2}\lt x$. Hence $\rho(x)\lt x\to0$: no positive $\lambda$ works. This is mode 2 of Interactive 2. (Mode 3 shows that a Lebesgue number may exist on a non-compact space; the lemma has no converse.)

Compactness Beyond $\mathbb{R}^n$

Theorem 7.15 says that compactness = completeness + total boundedness. In the classical infinite-dimensional spaces completeness is free (Theorem 7.6), so the question is always whether a set is totally bounded — whether it is "essentially finite-dimensional up to $\varepsilon$".

📐 Theorem 7.17 — Closed balls in infinite dimensions; the Hilbert cube
  1. The closed unit balls of $\ell^p$ ($1\le p\le\infty$), $c_0$ and $(C[a,b],d_\infty)$ are closed and bounded but not compact. So is every infinite set with the discrete metric.
  2. Let $(c_n)$ be a sequence of non-negative numbers with $\sum c_n^2\lt\infty$. Then the "box" $H=\{x\in\ell^2:\ |x_n|\le c_n\text{ for all }n\}$ is compact. For $c_n=\tfrac1n$ this is the Hilbert cube.
  3. More generally, a closed set $S\subseteq\ell^p$ ($1\le p\lt\infty$) is compact if and only if it is bounded and has uniformly small tails: for every $\varepsilon\gt0$ there is $N$ with $\sum_{n\gt N}|x_n|^p\lt\varepsilon^p$ for all $x\in S$.

Proof. (1) In $\ell^p$ ($p\lt\infty$) the unit vectors satisfy $\|e_n-e_m\|_p=2^{1/p}$; in $\ell^\infty$ and $c_0$, $\|e_n-e_m\|_\infty=1$. In $C[a,b]$ take "tents" $f_n$ of height $1$ supported on disjoint subintervals $\left[a+\tfrac{(b-a)}{n+1},a+\tfrac{(b-a)}{n}\right]$; then $d_\infty(f_n,f_m)=1$ for $n\ne m$. In a discrete space distinct points are at distance $1$. In each case there is a sequence in the ball with all mutual distances at least some $c\gt0$, which has no Cauchy subsequence; by Theorem 7.15 the ball is not compact.

(3) Let $S$ be closed, bounded with uniformly small tails. $S$ is complete (closed in the complete $\ell^p$). Given $\varepsilon$, choose $N$ for the tails. The set $P=\{(x_1,\dots,x_N):x\in S\}$ is bounded in $\mathbb{R}^N$ (or $\mathbb{C}^N$), so it has a finite $\varepsilon$-net $\{y^{(1)},\dots,y^{(m)}\}$ (regard $y^{(i)}$ as sequences ending in zeros). For $x\in S$ pick $i$ with $\left(\sum_{n\le N}|x_n-y^{(i)}_n|^p\right)^{1/p}\lt\varepsilon$; then $\|x-y^{(i)}\|_p^p\lt\varepsilon^p+\varepsilon^p$. So $S$ has a finite $2^{1/p}\varepsilon$-net — it is totally bounded, hence compact. Conversely, if $S$ is compact, take a finite $\varepsilon$-net $\{a^{(1)},\dots,a^{(m)}\}$ of $S$ and $N$ with all tails of the $a^{(i)}$ below $\varepsilon^p$; Minkowski's inequality on the tail coordinates gives tails of every $x\in S$ below $(2\varepsilon)^p$.

(2) $H$ is closed (coordinatewise limits preserve $|x_n|\le c_n$) and bounded ($\|x\|_2^2\le\sum c_n^2$), and $\sum_{n\gt N}|x_n|^2\le\sum_{n\gt N}c_n^2\to0$ uniformly in $x\in H$. Apply (3). ∎

The contrast between (1) and (2) is exactly the content of many exam questions: the unit ball of $\ell^2$ is not compact, but the Hilbert cube — infinite-dimensional, closed, bounded, sitting inside that ball — is. The difference is uniform control of the tails. For $C[a,b]$ the analogous criterion is the Arzelà–Ascoli theorem (§7.4): a closed set of functions is compact iff it is bounded and equicontinuous. And Riesz's lemma (§7.4) shows that the failure in (1) is universal: the closed unit ball of a normed space is compact iff the space is finite-dimensional.

✏️ Example 3 — Compact or not, in $\mathbb{R}^2$ and among matrices
Decide which sets are compact. (a) $\{(x,y):x^4+y^4\le1\}$; (b) $\{(x,y):xy=1\}$; (c) $\{(t,\sin\tfrac1t):0\lt t\le1\}$; (d) the same set together with $\{0\}\times[-1,1]$; (e) the orthogonal group $O(2)$ in $M_2(\mathbb{R})\cong\mathbb{R}^4$; (f) $SL(2,\mathbb{R})=\{A:\det A=1\}$; (g) the set of $2\times2$ real symmetric matrices with trace $0$ and determinant $\ge-1$; (h) the set of $2\times2$ real idempotent matrices ($A^2=A$).
(a) Compact Closed (preimage of $(-\infty,1]$ under a continuous map) and bounded ($|x|,|y|\le1$). Heine–Borel.
(b) No Closed but unbounded: $(n,\tfrac1n)$.
(c) No Bounded but not closed: $\left(\tfrac1{n\pi},0\right)$ lies in the set and converges to $(0,0)\notin$ set.
(d) Compact This is the closure of (c) (the "topologist's sine curve", §7.3): every limit point of the graph with $t\to0$ has the form $(0,c)$, $|c|\le1$, and these were added. Closed and bounded.
(e) Compact $O(2)=\{A:A^{T}A=I\}$ is closed (the entries of $A^{T}A$ are polynomials in the entries of $A$) and bounded (each column is a unit vector, so every entry has absolute value $\le1$).
(f) No Closed ($\det$ is continuous) but unbounded: $\operatorname{diag}(n,\tfrac1n)$.
(g) Compact Such a matrix is $\begin{pmatrix}a&b\\b&-a\end{pmatrix}$ with $\det=-a^2-b^2\ge-1$, i.e. $a^2+b^2\le1$: a closed disc in a $2$-dimensional subspace.
(h) No Closed ($A^2-A=0$ is polynomial) but unbounded: $\begin{pmatrix}1&t\\0&0\end{pmatrix}^2=\begin{pmatrix}1&t\\0&0\end{pmatrix}$ for every $t$.
✏️ Example 4 — Compact sets of sequences and of functions
Decide which sets are compact. (a) $S_1=\{x\in\ell^2:\ \sum_nn^2x_n^2\le1\}$; (b) $S_2=\{x\in\ell^2:\ \|x\|_2=1\}$; (c) $S_3=\{e_n/n:n\in\mathbb{N}\}\cup\{0\}$ in $\ell^2$; (d) in $(C[0,1],d_\infty)$: $F_1=\{x^n:n\in\mathbb{N}\}$; (e) $F_2=\{\tfrac{x^n}n:n\in\mathbb{N}\}\cup\{0\}$; (f) $F_3=\{c\sin x+d\cos x:\ c^2+d^2\le1\}$.
(a) Compact Closed (if $x^{(k)}\to x$ in $\ell^2$, each partial sum $\sum_{n\le N}n^2(x^{(k)}_n)^2\le1$ passes to the limit). Bounded ($\|x\|_2\le1$). Tails: $\sum_{n\gt N}x_n^2\le\tfrac1{N^2}\sum_{n\gt N}n^2x_n^2\le\tfrac1{N^2}$ uniformly. Theorem 7.17(3). (It is a Hilbert-cube-like "ellipsoid".)
(b) No The unit sphere contains all $e_n$, pairwise $\sqrt2$ apart.
(c) Compact $\|e_n/n\|_2=\tfrac1n\to0$: a convergent sequence with its limit (Theorem 7.12(4)).
(d) No A subsequence of $(x^n)$ converging in $d_\infty$ would converge uniformly, hence pointwise, to the discontinuous function equal to $0$ on $[0,1)$ and $1$ at $1$ — impossible in $C[0,1]$. So $F_1$ is not sequentially compact. (Equivalently: $d_\infty(x^n,x^{2n})=\tfrac14$ for all $n$.)
(e) Compact $d_\infty(x^n/n,0)=\tfrac1n\to0$: a convergent sequence with its limit.
(f) Compact It is the image of the compact disc $\{c^2+d^2\le1\}\subseteq\mathbb{R}^2$ under the map $(c,d)\mapsto c\sin x+d\cos x$, which is Lipschitz into $(C[0,1],d_\infty)$ (with constant $\sqrt2$, as $|c\sin x+d\cos x|\le|c|+|d|$). Continuous images of compact sets are compact (Theorem 7.18). A bounded set lying in a finite-dimensional subspace and closed is always compact.

Continuous Functions on Compact Metric Spaces

📐 Theorem 7.18 — Continuous images of compact sets; extreme values; distances

Let $f:X\to Y$ be continuous and $K\subseteq X$ compact.

  1. $f(K)$ is compact. In particular, if $Y=\mathbb{R}$, then $f$ is bounded on $K$ and attains its maximum and minimum there (extreme value theorem).
  2. For each $x\in X$ there is $k_0\in K$ with $d(x,k_0)=d(x,K)$ (if $K\ne\varnothing$).
  3. If $K\ne\varnothing$ is compact, $F$ is closed and $K\cap F=\varnothing$, then $d(K,F)\gt0$.
  4. If $K$ is compact and $F$ is closed in $\mathbb{R}^n$, then $K+F=\{k+f:k\in K,\ f\in F\}$ is closed; if both are compact, $K+F$ is compact.

Proof. (1) If $\{V_\alpha\}$ is an open cover of $f(K)$, the sets $f^{-1}(V_\alpha)$ are open (Theorem 7.4) and cover $K$; finitely many cover $K$, and the corresponding $V_\alpha$ cover $f(K)$. A compact subset of $\mathbb{R}$ is closed and bounded, so it contains its supremum and infimum.

(2) For fixed $x$, the function $k\mapsto d(x,k)$ is continuous on $K$ (Theorem 7.4), so by (1) it attains its minimum, which is $d(x,K)$.

(3) The function $k\mapsto d(k,F)$ is continuous and positive on $K$ (positive because $F$ is closed and $k\notin F$, Theorem 7.3(3)); by (1) its minimum $d(K,F)$ is attained, hence positive.

(4) Let $k_j+f_j\to z$ with $k_j\in K$, $f_j\in F$. By sequential compactness a subsequence $k_{j_i}\to k\in K$; then $f_{j_i}=(k_{j_i}+f_{j_i})-k_{j_i}\to z-k$, and $z-k\in F$ because $F$ is closed. So $z=k+(z-k)\in K+F$. If both are compact, $K+F$ is the image of the compact set $K\times F\subseteq\mathbb{R}^{2n}$ under the continuous map $(k,f)\mapsto k+f$. ∎

Each conclusion fails without compactness: the closed sets $F_1=\{(x,0)\}$ and $F_2=\{(x,\tfrac1x):x\gt0\}$ in $\mathbb{R}^2$ are disjoint with $d(F_1,F_2)=0$, and $F_1+F_2=\{(s,y):y\gt0\}$ is not closed; the projection of the closed set $F_2$ onto the $x$-axis is $(0,\infty)$, not closed; and $f(x)=x$ on $(0,1)$ attains neither its supremum nor its infimum.

📐 Theorem 7.19 — Uniform continuity and continuous inverses on compact spaces

Let $X$ be a compact metric space and $f:X\to Y$ continuous, $Y$ a metric space.

  1. Heine–Cantor: $f$ is uniformly continuous.
  2. If $f$ is a bijection onto $Y$, then $f^{-1}$ is continuous: $f$ is a homeomorphism. More generally, $f$ maps closed sets to closed sets.

Proof. (1) Suppose not. Then there is $\varepsilon\gt0$ and, for each $n$, points $x_n,y_n$ with $d(x_n,y_n)\lt\tfrac1n$ but $\rho(f(x_n),f(y_n))\ge\varepsilon$. By sequential compactness $x_{n_k}\to x$, and then $y_{n_k}\to x$ too. Continuity at $x$ gives $f(x_{n_k})\to f(x)$ and $f(y_{n_k})\to f(x)$, so $\rho(f(x_{n_k}),f(y_{n_k}))\to0$ — contradiction. (Alternatively: for each $x$ choose $\delta_x$ for $\tfrac\varepsilon2$; a Lebesgue number of the cover $\{B(x,\delta_x)\}$ is a uniform $\delta$.)

(2) A closed $F\subseteq X$ is compact (Theorem 7.12(2)), so $f(F)$ is compact (Theorem 7.18), hence closed in $Y$ (Theorem 7.12(1)). For a bijection, $(f^{-1})^{-1}(F)=f(F)$, so preimages of closed sets under $f^{-1}$ are closed and $f^{-1}$ is continuous by Theorem 7.4. ∎

Compactness of the domain is essential in (2): $t\mapsto(\cos t,\sin t)$ is a continuous bijection of $[0,2\pi)$ onto the circle whose inverse is discontinuous at $(1,0)$ (points just below $(1,0)$ on the circle come from $t$ near $2\pi$, points just above from $t$ near $0$). And in (1): $x^2$ on $\mathbb{R}$ and $\sin\tfrac1x$ on $(0,1]$ are continuous but not uniformly continuous (§3.2).

📐 Theorem 7.20 — Edelstein's fixed point theorem
Let $X$ be a nonempty compact metric space and $T:X\to X$ contractive: $d(Tx,Ty)\lt d(x,y)$ for all $x\ne y$. Then $T$ has exactly one fixed point $x^*$, and for every $x_0$ the iterates $x_{n+1}=Tx_n$ converge to $x^*$.

Proof. The function $g(x)=d(x,Tx)$ is continuous ($T$ is $1$-Lipschitz, so $|g(x)-g(y)|\le2d(x,y)$). By Theorem 7.18 it attains its minimum at some $x^*$. If $Tx^*\ne x^*$, then $g(Tx^*)=d(Tx^*,T^2x^*)$ is less than $d(x^*,Tx^*)=g(x^*)$, contradicting minimality. So $Tx^*=x^*$; two fixed points $x\ne y$ would give $d(x,y)=d(Tx,Ty)\lt d(x,y)$. For convergence, $a_n=d(x_n,x^*)$ is non-increasing ($a_{n+1}=d(Tx_n,Tx^*)\le a_n$), so $a_n\downarrow a\ge0$. A subsequence $x_{n_k}\to z$; then $d(z,x^*)=a$ and $d(Tz,x^*)=\lim d(x_{n_k+1},x^*)=a$. If $a\gt0$ then $z\ne x^*$ and $d(Tz,x^*)=d(Tz,Tx^*)\lt d(z,x^*)=a$ — contradiction. So $a=0$. ∎

Compare Banach's theorem (§7.1): there completeness and a uniform $k\lt1$; here compactness and the weaker strict inequality. The map $x+\tfrac1x$ on $[1,\infty)$ shows that compactness cannot be replaced by completeness, and $\sin x$ on $[0,1]$ (fixed point $0$, but $\sup_{x\ne y}\tfrac{|\sin x-\sin y|}{|x-y|}=1$) is a contractive map that is not a contraction. Its iterates converge very slowly: $\sin^{(n)}(1)\approx\sqrt{3/n}$, about $0.0546$ after $1000$ steps.

✏️ Example 5 — Nearest points and separated sets
(a) Find the point of the ellipse $E=\{(x,y):\tfrac{x^2}4+y^2=1\}$ nearest to $p=(3,0)$ and the distance $d(p,E)$. Why must a nearest point exist? (b) Let $A=\mathbb{N}$ and $B=\{n+\tfrac1n:n\ge2\}$ in $\mathbb{R}$. Show that $A$, $B$ are closed and disjoint with $d(A,B)=0$, and that $A-B$ is not closed. (c) Give a closed set in $\mathbb{R}^2$ whose projection onto the $x$-axis is not closed, and explain why the projection of a compact set is always compact.
(a) Existence $E$ is closed and bounded in $\mathbb{R}^2$, hence compact, and $q\mapsto d(p,q)$ is continuous: Theorem 7.18(2).
(a) Computation On $E$, $y^2=1-\tfrac{x^2}4$ with $x\in[-2,2]$, so $d^2=(x-3)^2+1-\tfrac{x^2}4=\tfrac34x^2-6x+10=:h(x)$. The vertex of this parabola is at $x=4\notin[-2,2]$, so $h$ decreases on $[-2,2]$ and its minimum is $h(2)=3-12+10=1$. The nearest point is $(2,0)$ and $d(p,E)=1$.
(b) Both sets have no limit points in $\mathbb{R}$ (consecutive points are at least $\tfrac12$ apart), so they are closed; they are disjoint since $n+\tfrac1n\notin\mathbb{N}$ for $n\ge2$. $d(n,\,n+\tfrac1n)=\tfrac1n\to0$, so $d(A,B)=0$. The set $A-B=\{m-n-\tfrac1n\}$ contains $-\tfrac1n$ (take $m=n$) for every $n\ge2$, so $0$ is a limit point; but $m-n-\tfrac1n=0$ would need $\tfrac1n\in\mathbb{Z}$. So $A-B$ is not closed. Neither set is compact, so Theorem 7.18(3)–(4) does not apply.
(c) $\{(x,y):xy=1\}$ is closed, but its projection is $\mathbb{R}\setminus\{0\}$. The projection $\pi(x,y)=x$ is continuous, so it maps compact sets to compact sets (Theorem 7.18(1)).
✏️ Example 6 — Prove or disprove
Let $(X,d)$ be a metric space. Prove or disprove: (a) if $X$ is compact, every continuous $f:X\to(0,\infty)$ satisfies $f\ge c$ for some constant $c\gt0$; (b) if $X$ is complete and bounded, then $X$ is compact; (c) if every closed ball in $X$ is compact, then $X$ is complete; (d) if $X$ is compact and $f:X\to X$ is an isometry, then $f$ is surjective; (e) if every sequence in $X$ has a Cauchy subsequence, then $X$ is compact.
(a) True $f$ attains its minimum $c=f(x_0)\gt0$ (Theorem 7.18). On $(0,1)$, $f(x)=x$ shows compactness is needed.
(b) False An infinite discrete space is complete and bounded (diameter $1$) but not compact; so is the closed unit ball of $\ell^2$.
(c) True A Cauchy sequence is bounded, so it lies in some closed ball $\overline B(a,R)$, which is compact; a subsequence converges, so the whole Cauchy sequence converges.
(d) True Suppose $y\notin f(X)$. $f(X)$ is compact, hence closed, so $\varepsilon=d(y,f(X))\gt0$. Let $y_n=f^n(y)$. For $m\lt n$, $d(y_n,y_m)=d(f^{n-m}(y),y)\ge\varepsilon$ (apply the isometry $f^m$ backwards, and note $f^{n-m}(y)\in f(X)$). So $(y_n)$ has no Cauchy subsequence — contradicting compactness. (On the non-compact $[0,\infty)$, $x\mapsto x+1$ is a non-surjective isometry; on $\ell^2$ so is the right shift.)
(e) False "Every sequence has a Cauchy subsequence" characterises total boundedness (Exercise II.8). $(0,1)$ is totally bounded but not compact; compactness also needs completeness.
🧭 Problem-solving strategy — is this set compact?
  1. In $\mathbb{R}^n$ (or $M_n(\mathbb{R})\cong\mathbb{R}^{n^2}$): check closed (preimage of a closed set under continuous maps; or exhibit a sequence escaping to a missing limit) and bounded (or exhibit an unbounded sequence). That is all (Theorem 7.16).
  2. Image of a compact set? If the set is $f(K)$ with $K$ compact and $f$ continuous, it is compact — the fastest route for parametrised curves, matrix groups given by $\theta\mapsto$ rotations, and sets like $\{c\sin x:c\in[0,1]\}$.
  3. In an infinite-dimensional space: first look for a sequence with all mutual distances $\ge c\gt0$ (unit vectors, disjoint tents, $x^n$-type functions). If you find one, the set is not compact. Otherwise prove total boundedness — uniformly small tails in $\ell^p$, equicontinuity in $C[a,b]$ — plus closedness.
  4. Discrete-type spaces: a set all of whose points are isolated is compact iff finite.
  5. Watch the ambient space. "Closed" means closed in a complete space before Heine–Borel thinking applies; $[0,1]\cap\mathbb{Q}$ is closed in $\mathbb{Q}$ but not compact.
⚠️ Counterexamples and pitfalls
  1. Closed + bounded $\not\Rightarrow$ compact. Infinite discrete spaces; $\mathbb{R}$ with $\min(1,|x-y|)$; the closed unit balls of $\ell^p$, $c_0$, $C[0,1]$; the unit sphere of $\ell^2$.
  2. Bounded $\not\Rightarrow$ totally bounded. $\{e_n\}$ in $\ell^2$ is bounded with no finite $1$-net. In $\mathbb{R}^n$ the two notions coincide.
  3. Totally bounded $\not\Rightarrow$ compact. $(0,1)$, $\mathbb{Q}\cap[0,1]$: completeness is missing.
  4. Infinite-dimensional need not mean non-compact. The Hilbert cube $\{|x_n|\le\tfrac1n\}\subseteq\ell^2$ and $\{\sum n^2x_n^2\le1\}$ are compact; what they have is uniformly small tails.
  5. Continuous images, not preimages. $f(K)$ is compact for compact $K$, but a constant map $\mathbb{R}\to\mathbb{R}$ has non-compact preimage $\mathbb{R}$ of the compact set $\{0\}$; and images of closed sets need not be closed (projection of $xy=1$).
  6. Disjoint closed sets can be at distance $0$. $\mathbb{N}$ and $\{n+\tfrac1n\}$; the $x$-axis and the hyperbola $y=1/x$. One of the two must be compact for $d(K,F)\gt0$.
  7. Continuous bijection $\not\Rightarrow$ homeomorphism unless the domain is compact: $[0,2\pi)\to S^1$.
  8. Infinite unions. $\bigcup_n[-n,n]=\mathbb{R}$ is a countable union of compact sets that is not compact; intersections of compact sets are always compact.
  9. Contractive is not enough without compactness. $x+\tfrac1x$ on $[1,\infty)$; with compactness it is (Edelstein), even though $\sin x$ on $[0,1]$ is not a contraction.
  10. Lebesgue numbers: ball version vs diameter version. For $[0,\tfrac12),(\tfrac14,\tfrac34),(\tfrac12,1]$ the best ball radius is $\tfrac18$ but the best diameter bound is $\tfrac14$. A non-compact space can still have a Lebesgue number for a particular cover.
  11. Compact subsets are closed only in the ambient metric space. $[0,1]$ is compact and closed in $\mathbb{R}$; a compact set is never "open and compact" in $\mathbb{R}^n$ unless empty — but in a discrete space every finite set is open and compact.

Exercises

I
Compact sets.
  • 1 Prove from the definition that $\{\tfrac1n:n\in\mathbb{N}\}$ is not compact, and that $\{0\}\cup\{\tfrac1n\}$ is.
  • 2 Which subsets of $\mathbb{R}^2$ are compact? (a) $\{x^2+y^2=1\}$; (b) $\{x^2-y^2=1\}$; (c) $\{(x,y):|x|+|y|\le1,\ x\in\mathbb{Q}\}$; (d) $\{(x,y):0\le x\le1,\ 0\le y\le x^2\}$; (e) $\{(x,y):x^2+y^2\le1,\ y\gt0\}$.
  • 3 Which are compact in $M_2(\mathbb{R})\cong\mathbb{R}^4$? (a) $SO(2)$; (b) the nilpotent matrices; (c) the matrices with $\det A=0$ and all entries in $[0,1]$; (d) $\{A: A^{T}=A,\ A^2=I\}$.
  • 4 Show that a subset of a discrete metric space is compact iff it is finite.
  • 5 Use Theorem 7.13 to show that a decreasing sequence of nonempty compact sets has nonempty intersection, and give decreasing nonempty closed sets in $\mathbb{R}$ with empty intersection.
  • 6 Let $K\subseteq\mathbb{R}$ be compact and nonempty. Prove that $\sup K\in K$, and that $K$ has a smallest element.
  • 7 Prove that the union of a compact set $K\subseteq\mathbb{R}^n$ and finitely many convergent sequences (with their limits) is compact.
  • 8 Let $X=\mathbb{Q}$ with the usual metric. Show that $[0,1]\cap\mathbb{Q}$ is closed and bounded in $X$ but not compact, and that every compact subset of $\mathbb{Q}$ has empty interior in $\mathbb{Q}$.
1 For $\{\tfrac1n\}$: the sets $U_n=\left(\tfrac1n-\tfrac1{2n^2},\tfrac1n+\tfrac1{2n^2}\right)$ are open, each contains exactly one point of the set (since $\tfrac1n-\tfrac1{n+1}=\tfrac1{n(n+1)}\ge\tfrac1{2n^2}$), and together they cover it; no finite subfamily does. For $\{0\}\cup\{\tfrac1n\}$: Theorem 7.12(4), or §3.1, Example 4(c).
2 (a) Yes. (b) No (unbounded). (c) No: not closed — $(\tfrac{\sqrt2}{4},0)$ is a limit of points with rational first coordinate. (d) Yes (closed: defined by non-strict inequalities between continuous functions; bounded). (e) No: $(\tfrac12,\tfrac1n)\to(\tfrac12,0)\notin$ set.
3 (a) Yes: closed ($A^{T}A=I$, $\det A=1$) and bounded. (b) No: $\begin{pmatrix}0&t\\0&0\end{pmatrix}$, $t\in\mathbb{R}$. (c) Yes: closed (intersection of the closed cube $[0,1]^4$ with $\det^{-1}(0)$) and bounded. (d) Yes: a symmetric $A$ with $A^2=I$ has eigenvalues $\pm1$ and an orthonormal eigenbasis, so $A$ is orthogonal; the set is closed (polynomial equations) and lies in the bounded $O(2)$. Explicitly it is $\{\pm I\}$ together with the reflections $\begin{pmatrix}\cos\theta&\sin\theta\\\sin\theta&-\cos\theta\end{pmatrix}$.
4 Finite sets are always compact. If $A$ is infinite, the open singletons $\{a\}$, $a\in A$, cover $A$ with no finite subcover.
5 The sets $K_n$ are closed subsets of the compact $K_1$ with the FIP (any finite subfamily intersects in its smallest member), so $\bigcap K_n\ne\varnothing$. In $\mathbb{R}$: $F_n=[n,\infty)$.
6 $K$ is bounded, so $s=\sup K$ exists; for each $n$ there is $k_n\in K$ with $s-\tfrac1n\lt k_n\le s$, so $k_n\to s$ and $s\in K$ since $K$ is closed. Similarly $\inf K\in K$ is the smallest element.
7 Each convergent sequence with its limit is compact (Theorem 7.12(4)); a finite union of compact sets is compact (Theorem 7.12(3)).
8 $[0,1]\cap\mathbb{Q}=\mathbb{Q}\cap[0,1]$ is the intersection of $X$ with a closed set, so closed in $X$; it is bounded. Not compact: a sequence of rationals in $[0,1]$ converging to $\tfrac{\sqrt2}2$ has no subsequence converging in $\mathbb{Q}$. If a compact $K\subseteq\mathbb{Q}$ contained a ball $B_{\mathbb{Q}}(q,r)=\mathbb{Q}\cap(q-r,q+r)$, then the closed subset $\mathbb{Q}\cap[q-\tfrac r2,q+\tfrac r2]$ of $K$ would be compact — but it is not, by the same irrational-limit argument.
II
Sequential compactness, total boundedness, Lebesgue numbers.
  • 1 Prove that a subset of a totally bounded space is totally bounded, and that a totally bounded set is bounded. Show that $\mathbb{N}$ with the discrete metric is bounded but not totally bounded.
  • 2 Let $N(\varepsilon)$ be the least number of closed $d_\infty$-balls of radius $\varepsilon$ needed to cover $[0,1]^2$. Show that $N(\varepsilon)=\lceil\tfrac1{2\varepsilon}\rceil^2$ for $0\lt\varepsilon\le\tfrac12$, and evaluate $N(0.1)$ and $N(0.15)$.
  • 3 Compute $\|e_n-e_m\|_p$ in $\ell^p$ ($n\ne m$) for $1\le p\lt\infty$ and in $\ell^\infty$, and deduce that no closed ball of positive radius in these spaces is compact.
  • 4 Prove that the Hilbert cube $H=\{x\in\ell^2:|x_n|\le\tfrac1n\}$ is compact by extracting, for a given sequence in $H$, a convergent subsequence with a diagonal argument.
  • 5 Is $\{x\in\ell^\infty:|x_n|\le\tfrac1n\}$ compact in $\ell^\infty$? Is $\{x\in\ell^\infty:|x_n|\le1\}$?
  • 6 Find the largest Lebesgue number (ball version) of the cover $(-1,\tfrac13)$, $(\tfrac15,\tfrac45)$, $(\tfrac23,2)$ of $[0,1]$.
  • 7 Show that the cover $\{(\tfrac1n,1):n\ge2\}$ of $(0,1)$ has no Lebesgue number, while the cover $\{(0,\tfrac23),(\tfrac13,1)\}$ of $(0,1)$ has one.
  • 8 Prove that $X$ is totally bounded iff every sequence in $X$ has a Cauchy subsequence.
1 Let $Y\subseteq X$ and $\varepsilon\gt0$. Take an $\tfrac\varepsilon2$-net $\{a_i\}$ of $X$; for each $i$ with $B(a_i,\tfrac\varepsilon2)\cap Y\ne\varnothing$ pick $y_i$ in it. Then the $y_i$ form an $\varepsilon$-net of $Y$ (triangle inequality). Boundedness: shown after Definition 7.14. $\mathbb{N}$ discrete: diameter $1$, but a ball of radius $\tfrac12$ is a single point, so no finite $\tfrac12$-net exists.
2 A closed $d_\infty$-ball of radius $\varepsilon$ is a square of side $2\varepsilon$. With $m=\lceil\tfrac1{2\varepsilon}\rceil$, $m^2$ such squares on a grid cover $[0,1]^2$. Lower bound: if $\tfrac1{2\varepsilon}$ is an integer $m$, area gives $N\ge\tfrac1{4\varepsilon^2}=m^2$; otherwise $m-1\lt\tfrac1{2\varepsilon}$, the $m^2$ grid points $(\tfrac i{m-1},\tfrac j{m-1})$, $0\le i,j\le m-1$, are pairwise more than $2\varepsilon$ apart in $d_\infty$, and one ball of diameter $2\varepsilon$ contains at most one of them. (For $m=1$ one ball suffices.) $N(0.1)=5^2=25$; $N(0.15)=\lceil3.33\rceil^2=16$.
3 $\|e_n-e_m\|_p=(1+1)^{1/p}=2^{1/p}$; in $\ell^\infty$ it is $1$. The ball $\overline B(a,r)$ contains $a+re_n$ for all $n$, pairwise at distance $r\,2^{1/p}$ (or $r$), so it has no Cauchy subsequence and is not compact (Theorem 7.15).
4 Let $(x^{(k)})$ lie in $H$. The first coordinates lie in $[-1,1]$: choose a subsequence along which they converge; from it a further subsequence along which the second coordinates converge; and so on. The diagonal subsequence $y^{(j)}$ ($j$-th term of the $j$-th subsequence) converges in every coordinate, to some $x$ with $|x_n|\le\tfrac1n$. Given $\varepsilon$, choose $N$ with $\sum_{n\gt N}\tfrac4{n^2}\lt\tfrac{\varepsilon^2}2$; then $\|y^{(j)}-x\|_2^2\le\sum_{n\le N}|y^{(j)}_n-x_n|^2+\tfrac{\varepsilon^2}2\lt\varepsilon^2$ for large $j$.
5 Yes: it is closed, and the tails are uniformly small in sup: $\sup_{n\gt N}|x_n|\le\tfrac1N$, so the same finite-net argument as in Theorem 7.17(3) works (approximate the first $N$ coordinates by a finite net of $[-1,1]^N$). The cube $\{|x_n|\le1\}$ is the closed unit ball of $\ell^\infty$: not compact.
6 Overlaps: $(\tfrac15,\tfrac13)$ (width $\tfrac2{15}$) and $(\tfrac23,\tfrac45)$ (width $\tfrac2{15}$). On an overlap $(a,b)$, $\rho(x)=\max(b-x,x-a)$ with minimum $\tfrac{b-a}2=\tfrac1{15}$ at the midpoint. Elsewhere: on $[0,\tfrac15]$, $\rho=\tfrac13-x\ge\tfrac2{15}$; on $[\tfrac13,\tfrac23]$, $\rho=\min(x-\tfrac15,\tfrac45-x)\ge\tfrac2{15}$; on $[\tfrac45,1]$, $\rho=x-\tfrac23\ge\tfrac2{15}$. Largest Lebesgue number: $\tfrac1{15}$.
7 A ball $B(x,r)\cap(0,1)$ lies inside some $(\tfrac1n,1)$ only if $x-r\ge\tfrac1n\gt0$, so $\rho(x)\lt x$; letting $x\to0$, no uniform $\lambda$ exists. For the two-set cover, points of $(0,\tfrac13]$ have $\rho\ge\tfrac13$ (balls are cut off at $0$ by the space itself), points of $[\tfrac23,1)$ similarly, and on $(\tfrac13,\tfrac23)$, $\rho(x)=\max(\tfrac23-x,x-\tfrac13)\ge\tfrac16$. So $\lambda=\tfrac16$ works.
8 ⇒: the proof of (4)⇒(3) in Theorem 7.15 produced a Cauchy subsequence using only total boundedness. ⇐: if $X$ is not totally bounded, the proof of (3)⇒(4) produced a sequence with $d(x_m,x_n)\ge\varepsilon$ for $m\ne n$, which has no Cauchy subsequence.
III
Continuous maps on compact spaces.
  • 1 Find $d(p,C)$ for $p=(0,2)$ and $C$ the parabola $y=x^2$, and explain why the minimum is attained although $C$ is not compact.
  • 2 Give a bounded continuous function on $(0,1)$ that attains neither its supremum nor its infimum, and an unbounded continuous function on the bounded set $(0,1)$.
  • 3 Show that $t\mapsto(\cos t,\sin t)$ from $[0,2\pi)$ onto the unit circle is a continuous bijection whose inverse is not continuous. Which hypothesis of Theorem 7.19(2) fails?
  • 4 Let $K\subseteq\mathbb{R}^n$ be compact and $U\supseteq K$ open. Prove that there is $\varepsilon\gt0$ with $\{x:d(x,K)\lt\varepsilon\}\subseteq U$.
  • 5 Show that the sum of the $x$-axis and the branch $\{(x,\tfrac1x):x\gt0\}$ of a hyperbola is not closed in $\mathbb{R}^2$.
  • 6 Let $f:[0,1]\to[0,1]$ satisfy $|f(x)-f(y)|\lt|x-y|$ for $x\ne y$. Prove that $f$ has a unique fixed point and that $x_{n+1}=f(x_n)$ converges to it. Apply this to $f(x)=\sin x$.
  • 7 Prove that a continuous $f:X\to Y$ from a compact metric space is proper: preimages of compact sets are compact. Show that $f(x)=x^2$ on $\mathbb{R}$ is also proper, but $f(x)=\sin x$ is not.
  • 8 Let $K\subseteq\mathbb{R}^2$ be compact and $f:K\to\mathbb{R}$ continuous. Show that the graph $\{(x,f(x)):x\in K\}$ is compact in $\mathbb{R}^3$. Conversely, show that if $f:[0,1]\to\mathbb{R}$ has a compact graph, then $f$ is continuous.
1 $d^2=x^2+(x^2-2)^2=x^4-3x^2+4$; with $u=x^2\ge0$ the minimum of $u^2-3u+4$ is at $u=\tfrac32$: $d^2=\tfrac94-\tfrac92+4=\tfrac74$, so $d(p,C)=\tfrac{\sqrt7}2$ at $(\pm\sqrt{3/2},\tfrac32)$. Existence: points of $C$ with $d\le2$ (note $d((0,0),p)=2$) form a closed bounded, hence compact, piece of $C$, and the minimum over it is the global minimum.
2 $f(x)=x$ (sup $1$, inf $0$, neither attained). $g(x)=\tfrac1x$ is continuous and unbounded on $(0,1)$.
3 Continuity is clear and each point of the circle has exactly one argument in $[0,2\pi)$. The points $(\cos t,\sin t)$ with $t=2\pi-\tfrac1n$ converge to $(1,0)$, but their preimages $2\pi-\tfrac1n$ do not converge to $0=$ the preimage of $(1,0)$. The domain $[0,2\pi)$ is not compact.
4 If $U=\mathbb{R}^n$ any $\varepsilon$ works. Otherwise $F=\mathbb{R}^n\setminus U$ is closed and disjoint from $K$, so $\varepsilon=d(K,F)\gt0$ (Theorem 7.18(3)); if $d(x,K)\lt\varepsilon$, then $x\notin F$.
5 The sum is $\{(s+x,\tfrac1x)\}=\{(u,v):v\gt0\}$, the open upper half-plane: every $(u,v)$ with $v\gt0$ is $(u-\tfrac1v,0)+(\tfrac1v,v)$. It is not closed ($(0,\tfrac1n)\to(0,0)$).
6 Theorem 7.20 with $X=[0,1]$. For $\sin$: $f$ maps $[0,1]$ into $[0,\sin1]\subseteq[0,1]$, and $|\sin x-\sin y|=|\cos c||x-y|\lt|x-y|$ for $x\ne y$ in $[0,1]$ (as $c\in(0,1]$, $\cos c\lt1$). The fixed point is $0$, and $\sin^{(n)}(x_0)\to0$ for every $x_0\in[0,1]$.
7 If $C\subseteq Y$ is compact, it is closed, so $f^{-1}(C)$ is a closed subset of the compact $X$, hence compact. For $x^2$: the preimage of a compact $C$ is closed and lies in $[-\sqrt M,\sqrt M]$ if $C\subseteq[-M,M]$, so it is compact. For $\sin$: $\sin^{-1}(\{0\})=\pi\mathbb{Z}$ is unbounded.
8 The graph is the image of $K$ under the continuous map $x\mapsto(x,f(x))$. Conversely, suppose the graph $\Gamma$ of $f:[0,1]\to\mathbb{R}$ is compact and $x_n\to x$. Any subsequence of $(x_n,f(x_n))$ has a further subsequence converging in $\Gamma$, necessarily to a point $(x,y)\in\Gamma$, so $y=f(x)$. Thus every subsequence of $f(x_n)$ has a further subsequence converging to $f(x)$, which forces $f(x_n)\to f(x)$.
IV
Proofs and challenges.
  • 1 Prove that every compact metric space is separable.
  • 2 Let $X$ be compact and $f:X\to X$ continuous with $f(x)\ne x$ for all $x$. Prove that there is $c\gt0$ with $d(x,f(x))\ge c$ for all $x$.
  • 3 Prove that a metric space $X$ is compact if and only if every continuous function $f:X\to\mathbb{R}$ is bounded.
  • 4 Let $(K_n)$ be a decreasing sequence of nonempty compact sets and $U$ an open set containing $\bigcap_nK_n$. Prove that $K_n\subseteq U$ for some $n$.
  • 5 Prove that if $X$ is compact and $f:X\to X$ satisfies $d(f(x),f(y))\ge d(x,y)$ for all $x,y$, then $f$ is an isometry onto $X$. (Hint: consider $(f^n(x),f^n(y))$ in $X\times X$.)
  • 6 Let $\mathcal L$ be the set of $f\in C[0,1]$ with $f(0)=0$ and $|f(x)-f(y)|\le|x-y|$ for all $x,y$. Show that $\mathcal L$ is compact in $(C[0,1],d_\infty)$. (Use Theorem 7.15: show it is complete and totally bounded, approximating by piecewise linear functions.)
1 For each $k$ choose a finite $\tfrac1k$-net $A_k$. $D=\bigcup_kA_k$ is countable, and every ball $B(x,r)$ contains a point of $A_k$ for $\tfrac1k\lt r$. So $D$ is dense.
2 $g(x)=d(x,f(x))$ is continuous and positive on the compact $X$, so its minimum $c$ is positive (Theorem 7.18).
3 ⇒ is the extreme value theorem. ⇐: if $X$ is not compact, there is a sequence $(x_n)$ with no convergent subsequence; dropping repetitions we may take the $x_n$ distinct, and each $x_n$ is then not a limit point of $E=\{x_k\}$, so $s_n=\inf_{k\ne n}d(x_n,x_k)\gt0$. Put $r_n=\min(\tfrac1n,\tfrac{s_n}3)$; the balls $B(x_n,r_n)$ are pairwise disjoint. Let $\varphi_n(x)=n\max\left(0,1-\tfrac{d(x,x_n)}{r_n}\right)$ and $f=\sum_n\varphi_n$. Each point $x$ has a neighbourhood meeting only finitely many balls $B(x_n,r_n)$: otherwise points $y_j\to x$ lie in balls with distinct indices $n_j$, and $d(x_{n_j},x)\le r_{n_j}+d(y_j,x)\to0$ (as $r_{n_j}\le\tfrac1{n_j}\to0$) — a convergent subsequence of $(x_n)$. So near each point $f$ is a finite sum of continuous functions, hence continuous; and $f(x_n)=n$ is unbounded.
4 The sets $K_n\setminus U=K_n\cap(X\setminus U)$ are compact (closed in $K_1$) and decreasing, with intersection $\bigcap K_n\setminus U=\varnothing$. By Theorem 7.13 one of them is empty.
5 Fix $x,y$. The sequence $(f^n(x),f^n(y))$ in the compact $X\times X$ has a convergent subsequence, so for every $\varepsilon$ there are $m\lt n$ with $f^m(x),f^n(x)$ within $\varepsilon$ and $f^m(y),f^n(y)$ within $\varepsilon$; with $k=n-m\ge1$, expansiveness gives $d(x,f^k(x))\le d(f^m(x),f^n(x))\lt\varepsilon$ and likewise for $y$. Hence $d(f(x),f(y))\le d(f^k(x),f^k(y))\lt d(x,y)+2\varepsilon$ (using $d(f(x),f(y))\le d(f^k x,f^k y)$ by expansiveness of $f^{k-1}$). So $d(f(x),f(y))\le d(x,y)$, and with the hypothesis, $f$ is an isometry. Surjectivity: the points $x$ are limits of $f^k(x)\in f(X)$, and $f(X)$ is closed; so $X=f(X)$ (Example 6(d)).
6 The set $\mathcal L$ is closed in $C[0,1]$ (both conditions survive uniform, even pointwise, limits), hence complete, and bounded by $|f(x)|\le x\le1$. Total boundedness: given $\varepsilon$, choose $m$ with $\tfrac1m\lt\varepsilon$. A function in $\mathcal L$ is within $\varepsilon$ of the piecewise linear function $g$ interpolating it at $\tfrac jm$, and then within $\varepsilon$ of a piecewise linear $h$ whose nodal values are multiples of $\tfrac1m$ with consecutive differences in $\{-\tfrac1m,0,\tfrac1m\}$ (round the nodal values successively). There are at most $3^m$ such $h$: a finite $3\varepsilon$-net. By Theorem 7.15 $\mathcal L$ is compact (the Arzelà–Ascoli idea of §7.4).
🎯 Exam corner CSIR Part BCSIR Part CGATE MA

E1. CSIR Part B GATE MA Which of the following subsets of $\mathbb{R}^2$ is compact? (A) $\{(x,y):xy=1\}$; (B) $\{(x,y):x^2+y^4\le1\}$; (C) $\{(x,y):x^2+y^2\lt1\}$; (D) $\{(x,\sin\tfrac1x):0\lt x\le1\}$.

Idea Heine–Borel in $\mathbb{R}^2$: closed and bounded.
Options (A) closed, unbounded. (B) closed (preimage of $(-\infty,1]$) and bounded ($|x|\le1$, $|y|\le1$). (C) bounded, not closed. (D) bounded, not closed ($(\tfrac1{n\pi},0)\to(0,0)$).
Answer (B).

E2. CSIR Part B Let $S=\{x\in\ell^2:\ \sum_{n\ge1}n^2x_n^2\le1\}$ and $B=\{x\in\ell^2:\|x\|_2\le1\}$. Then (A) both $S$ and $B$ are compact; (B) $S$ is compact and $B$ is not; (C) $B$ is compact and $S$ is not; (D) neither is compact.

$S$ Closed, bounded, uniformly small tails ($\sum_{n\gt N}x_n^2\le N^{-2}$): compact (Example 4(a)).
$B$ Contains the $e_n$, pairwise $\sqrt2$ apart: not compact.
Answer (B).

E3. CSIR Part B Let $X$ be a compact metric space. Which statement is necessarily true? (A) Every closed subset of $X$ is countable. (B) Every continuous $f:X\to\mathbb{R}$ is uniformly continuous. (C) Every bounded subset of $X$ is compact. (D) Every Cauchy sequence in $X$ is eventually constant.

Test with $X=[0,1]$ (A) $[0,1]$ itself is closed and uncountable. (C) $(0,1)$ is bounded, not compact. (D) $\tfrac1n$ is Cauchy, not eventually constant.
(B) Heine–Cantor (Theorem 7.19(1)).
Answer (B).

E4. CSIR Part C In $C[0,1]$ with the sup metric, which of the following sets are compact? (One or more options may be correct.) (A) $\{f:\ \max|f|\le1\}$; (B) $\{x^n:n\in\mathbb{N}\}$; (C) $\{\tfrac{x^n}n:n\in\mathbb{N}\}\cup\{0\}$; (D) $\{c\,e^x:\ c\in[-1,1]\}$.

(A) No The closed unit ball contains disjoint tents at mutual distance $1$ (Theorem 7.17(1)).
(B) No No subsequence of $x^n$ converges uniformly (the pointwise limit is discontinuous); $d_\infty(x^n,x^{2n})=\tfrac14$.
(C) Yes $\|x^n/n\|_\infty=\tfrac1n\to0$: a convergent sequence with its limit.
(D) Yes The image of $[-1,1]$ under the continuous (Lipschitz, constant $e$) map $c\mapsto ce^x$.
Answer (C) and (D).

E5. CSIR Part C Let $(X,d)$ be a metric space. Which of the following are true? (A) If $X$ is complete and totally bounded, every continuous $f:X\to\mathbb{R}$ attains its maximum. (B) If every closed and bounded subset of $X$ is compact, then $X$ is complete. (C) If $X$ is complete and bounded, then $X$ is compact. (D) If every sequence in $X$ has a Cauchy subsequence, then $X$ is compact.

(A) True Complete + totally bounded = compact (Theorem 7.15); then EVT.
(B) True A Cauchy sequence $(x_n)$ is bounded, and the closure of $\{x_n\}$ is closed and bounded, hence compact; a subsequence converges, so the Cauchy sequence converges.
(C) False An infinite discrete space.
(D) False This says $X$ is totally bounded (Exercise II.8); $(0,1)$ is a counterexample.
Answer (A) and (B).

E6. CSIR Part C Let $K\subseteq\mathbb{R}^2$ be nonempty and compact, $F\subseteq\mathbb{R}^2$ nonempty and closed, with $K\cap F=\varnothing$, and let $\pi(x,y)=x$. Which of the following are necessarily true? (A) $d(K,F)\gt0$. (B) $K+F$ is closed. (C) $\pi(F)$ is closed. (D) $\pi(K)$ is compact.

(A) True Theorem 7.18(3).
(B) True Theorem 7.18(4): a sequence $k_j+f_j\to z$ has $k_{j_i}\to k$, so $f_{j_i}\to z-k\in F$.
(C) False $F=\{(x,y):xy=1\}$ (and $K=\{(0,0)\}$): $\pi(F)=\mathbb{R}\setminus\{0\}$.
(D) True Continuous image of a compact set.
Answer (A), (B) and (D).
🧑‍🏫 For the teacher

Suggested plan — 3 lectures × 60 min.

  1. Compactness by covers. Recall §3.1. Definition 7.11, intrinsic nature, Theorem 7.12 with full proofs, FIP (Theorem 7.13). Example 1 — make the class find the cover that fails in each case. Ten minutes on "closedness is relative, compactness is not".
  2. The equivalence theorem. Definitions 7.13–7.15; project Interactive 1 (square, then circle, then the Cantor set; ask for the slope before revealing it; finish with $e_n$). Lebesgue lemma and Interactive 2 (mode 1, then 2, then 3). Theorem 7.15 in full — the four implications fit on two boards. Heine–Borel in $\mathbb{R}^n$ as a corollary.
  3. Infinite dimensions and continuous maps. Theorem 7.17 (unit balls versus the Hilbert cube), Examples 3–4 as a quiz; Theorems 7.18–7.20 with Example 5 and Example 6; close with Exam-corner E2 and E6.

Discussion questions. (1) Which of the four conditions in Theorem 7.15 is easiest to check, and which is easiest to use? Give an example of each use. (2) The Hilbert cube is infinite-dimensional yet compact. In what precise sense is it "almost finite-dimensional"? (3) Why does the proof that compact sets are closed fail for a "distance" that does not separate points?

Misconceptions to watch for. "Closed and bounded means compact" in every space; "bounded means totally bounded"; believing that preimages of compact sets are compact; forgetting that the definition of compactness quantifies over every open cover (exhibiting one cover with a finite subcover proves nothing); mixing up the ball and diameter versions of the Lebesgue number; assuming a contractive map on a complete space has a fixed point.

Suggested homework. I(1, 2, 3, 6, 8), II(1, 2, 4, 6, 8), III(1, 3, 4, 6, 7), IV(1, 3); Exam corner E2, E4, E5.

🔬 Research–Teaching NexusResearch-tutored · optional, about 60 minutes

Research question. How fast does the number $N(\varepsilon)$ of $\varepsilon$-balls needed to cover a compact set grow as $\varepsilon\to0$, and can that growth rate measure the "dimension" of a coastline, a fractal or a data set?

Why it matters. Total boundedness is not only a yes/no property: the covering numbers $N(\varepsilon)$ quantify how compact a set is. Lewis Fry Richardson's measurements of the coastline of Britain and of the border between Spain and Portugal (1950s–60s) showed that the measured length grows as the ruler shrinks, leading to Mandelbrot's fractal dimension; today covering numbers control the sample complexity of machine-learning models, the resolution needed in medical imaging, and the "intrinsic dimension" of high-dimensional data.

What to do.

  1. For $[0,1]^2$ prove $c_1\varepsilon^{-2}\le N(\varepsilon)\le c_2\varepsilon^{-2}$, and for the middle-thirds Cantor set prove $N(3^{-k})$ is between $2^{k-1}$ and $2^{k+1}$. Deduce $\lim\frac{\log N(\varepsilon)}{\log(1/\varepsilon)}$ in both cases.
  2. Write a short program that builds greedy $\varepsilon$-nets (as in Interactive 1) for: the Sierpiński triangle (from the chaos game, $20\,000$ points), the Koch curve, and a random walk of $10\,000$ steps in the plane. Fit the slope of $\log N$ against $\log(1/\varepsilon)$.
  3. Download (or digitise from a map) the coordinates of a stretch of coastline — Norway, Kerala or the west coast of Ireland work well — and estimate its covering dimension.
  4. Compare with the "dimension" of the unit ball of $\ell^2$: show that it needs infinitely many balls of radius $\tfrac12$, and that its compact subset $\{\sum n^2x_n^2\le1\}$ has $\log N(\varepsilon)$ growing faster than any multiple of $\log(1/\varepsilon)$ — an infinite-dimensional compact set. Estimate the actual growth rate.

Tools: Python (NumPy, Matplotlib) or any spreadsheet; a free map service for coastline coordinates.

Hand in: A two-page report with the three log–log plots, your fitted slopes with an honest error estimate, and the proof of step 1.

Going further. Read about Kolmogorov's $\varepsilon$-entropy $\log_2N(\varepsilon)$ of function classes (how many bits are needed to describe a Lipschitz function to accuracy $\varepsilon$ — compare Exercise IV.6) and about the box-counting versus Hausdorff dimension.

Instructor note: expected slopes are $\log3/\log2\approx1.585$ for the Sierpiński triangle, $\log4/\log3\approx1.262$ for the Koch curve, close to $2$ for a long planar random walk (its trace is "space-filling" at large scales), and between about $1.0$ and $1.5$ for real coastlines depending on the region (rugged fjord coasts at the top of that range). Greedy nets on finite samples bias the fitted slope downwards at the smallest radii (the sample runs out of points) — encourage students to discard radii below a few sample spacings, as Interactive 1 does. For step 4: about $1/\varepsilon$ of the semi-axes $\tfrac1n$ exceed $\varepsilon$, and each contributes roughly $\log\frac{1/n}{\varepsilon}$ to $\log N(\varepsilon)$, so $\log N(\varepsilon)$ is of order $\tfrac1\varepsilon$; accept any well-argued two-sided bound of that order.

🧪 Self-check quiz

0/5 correct

Q1. In a general metric space, a compact set is always

Q2. A metric space is compact if and only if it is

Q3. Which subset of $\ell^2$ is compact?

Q4. The continuous bijection $t\mapsto(\cos t,\sin t)$ from $[0,2\pi)$ onto the circle is not a homeomorphism because

Q5. For two disjoint nonempty closed sets $A,B\subseteq\mathbb{R}^2$, $d(A,B)\gt0$ is guaranteed when