Metric Space Compact iff Complete and Totally Bounded

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

Proof
First suppose that $$(S,d)$$ is a sequentially compact metric space.

We first show that any Cauchy sequence $$(a_k)$$ in $$(S,d)$$ has a limit.

Indeed, by (sequential) compactness the sequence has a subsequence converging to some point $$a\in S$$; but since the sequence is Cauchy, this implies that the entire sequence has limit $a$. So $$(S,d)$$ is complete.

To show that a compact space is totally bounded, let $$\varepsilon>0$$.

Then the family of open $$\varepsilon$$-balls $$\{N_{\varepsilon}(x):x\in S\}$$ forms an open cover of $$S$$.

By compactness, there exists a finite subcover.

That is, there are points $$x_0,\dots,x_n$$ such that:
 * $$S = \bigcup_{0\leq i\leq n} N_{\varepsilon}(x),$$

as required.

Now assume that $$(S,d)$$ is complete and totally bounded; we will show that $$(S,d)$$ is sequentially compact.

This will prove that $$(S,d)$$ is in fact compact, as a sequentially compact metric space is also compact.

We first claim that total boundedness implies the following:


 * If $$(a_k)$$ is any sequence in $$S$$ and $$\varepsilon>0$$, then there is some $$x\in S$$ such that $$d(a_k,x)\leq \varepsilon$$ for infinitely many $$k$$.

Indeed, let $$x_0,\dots,x_n$$ be as in the definition of total boundedness.

Then for every $$k$$, there is some $$j_k\in\{0,\dots,n\}$$ such that $$d(a_k,x_{j_k})\leq\varepsilon$$.

For some $$j$$, we must have $$j_k=j$$ for infinitely many $$k$$, and the claim follows by setting $$x:=x_{j_k}$$.

Now let $$(a_k)$$ be an arbitrary sequence in $$S$$.

By the claim, there is some $$x_1\in S$$ such that $$d(a_k,x_1)\leq 1/2$$ for infinitely many $$k$$.

Now we can apply the claim to the subsequence of $$(a_k)$$ consisting of those elements for which $$d(a_k,x_1)\leq 1/2$$, to find $$x_2\in S$$ such that infinitely many $$k$$ satisfy both $$d(a_k,x_2)\leq 1/4$$ and $$d(a_k,x_2)\leq 1/2$$.

Now we proceed inductively, to obtain a sequence $$(x_m)$$ with the property that there exist infinitely many $$k$$ such that, for $$1\leq j\leq m$$:
 * $$(1) \qquad d(a_k,x_j)\leq 2^{-j}$$

Now define a subsequence $$(a_{k_m})$$ inductively by letting $$k_0$$ be arbitrary, and choosing $$k_{m+1}$$ minimal such that $$k_{m+1}>k_m$$ and such that $$(1)$$ holds for $$k=k_m$$ and all $$1\leq j\leq m$$.

We claim that this subsequence is a Cauchy sequence.

Indeed, let $$\varepsilon>0$$, and choose $$n$$ sufficiently large that $$1/2^{n-1}<\varepsilon$$.

Then:
 * $$d(a_{k_j},a_{k_{j'}}) \leq d(a_{k_j},x_n) + d(a_{k_{j'}},x_n)) \leq 2\cdot 2^{-n} < \varepsilon$$

whenever $$j,j'\geq n$$.

Because $$(S,d)$$ is complete by assumption, we see that $$(a_k)$$ has a convergent subsequence, as required.