Totally Bounded Metric Space is Separable

Theorem
A totally bounded metric space is separable and second-countable.

Proof
Consider a totally bounded metric space $$(X,\vartheta)$$.

Let us first show that $$(X,\vartheta)$$ is separable, that is, that we can find a countable dense set in $$X$$.

As we can cover $$X$$ by a finite number of balls of any given size, let us define a set of points as follows:
 * $$X$$ can be covered by a certain finite number of balls of radius $$1$$; call their centers $$x_{1,1},x_{1,2},\ldots,x_{1,n_1}$$, for some natural number $$n_1$$.
 * $$X$$ can be covered by a certain finite number of balls of radius $$1/2$$; call their centers $$x_{2,1},x_{2,2},\ldots,x_{2,n_2}$$, for some natural number $$n_2$$.
 * In general, for an integer $$k \geq 1$$, $$X$$ can be covered by a certain finite number of balls of radius $$1/k$$; call their centers $$x_{k,1},x_{k,2},\ldots,x_{k,n_k}$$, for some natural number $$n_k$$.

Consider the set of all of these centers:
 * $$S := \{x_{k,n} \mid k,n \in \N, \, 1 \leq k \leq n_k \}$$.

This set fulfills the requirements: it is countable, as it is a countable union of finite sets. It also dense in $$X$$, as we will prove now:

Take any point $$x \in X$$, and any $$\epsilon > 0$$, and let us prove that $$B(x,\epsilon) \cap S \neq \emptyset$$.

Take some natural $$k$$ such that $$1/k < \epsilon$$.

As the balls of centers $$x_{k,1}, x_{k,2},\ldots,x_{k,n_k}$$ and radius $$1/k$$ cover $$X$$, there exists a ball, say $$B(x_{k,n}, 1/k)$$, which contains $$x$$, the center of our initial ball.

But then:
 * $$d(x_{k,n}, x) < 1/k < \epsilon,$$

which implies that $$x_{k,n} \in B(x,\epsilon)$$.

The point $$x_{k,n}$$ is also in $$S$$, so we have proved that $$S$$ is dense in $$X$$.

In order to use it below, note that we have actually proved that $$B(x_{k,n}, 1/k) \subseteq B(x,\epsilon)$$.

Let us show that $$(X,\vartheta)$$ is second-countable, that is, that its topology has a countable base.

Instead of taking all of the centers of the open balls we constructed at the beginning, now take the familiy of all the open balls which we used to cover the space:
 * $$\Sigma := \{ B(x_{k,n},1/k) \mid k,n \in \N, \, 1 \leq k \leq n_k \}$$.

Then, $$\Sigma$$ is a countable set (it contains the same number of balls as points are in $$S$$).

It is also a base of the topology of $$X$$: given any open ball $$B(x,\epsilon)$$ in $$X$$, we proved before that there exists a ball $$B \in \Sigma$$ such that $$x \in B \subseteq B(x,\epsilon)$$.

Hence, $$\Sigma$$ is a countable base, which is to say that $$X$$ is second-countable.