Totally bounded set. Let \((X,\rho)\) be a metric space, \(E \subseteq X\) is called totally bounded if for every \(\varepsilon>0\), the set \(E\) can be covered by finitely many balls of radius \(\varepsilon\).
It means that there is \(N_{\varepsilon} \in \mathbb{N}\) so that \[E \subseteq \bigcup_{j=1}^{N_{\varepsilon}}B(x_j,\varepsilon)\quad \text{ for some }\quad x_1,x_2,\ldots,x_{N_{\varepsilon}} \in X.\]
Remark 1. If \(E\) is totally bounded so is \({\rm cl\;}(E)\). Indeed, \[E \subseteq \bigcup_{j=1}^{N_{\varepsilon}}B(x_j,\varepsilon) \Longrightarrow {\rm cl\;}(E) \subseteq \bigcup_{j=1}^{N_{\varepsilon}}B(x_j,2\varepsilon).\]
Remark 2. Every totally bounded set \(E\) is bounded. If \[x,y \in E \subseteq \bigcup_{j=1}^{N_{\varepsilon}}B(x_j,\varepsilon),\] then say \(x \in B(x_1,\varepsilon)\), \(y \in B(x_2,\varepsilon)\) and \[\begin{aligned} \rho(x,y) &\leq \rho(x,x_1)+\rho(x_1,x_2)+\rho(x_2,y) \\&\leq \varepsilon +\max\{\rho(x_i,x_j)\;:\;1 \leq i,j \leq N_{\varepsilon}\}+\varepsilon. \end{aligned}\]
The converse is false in general.
Theorem. If \(E\) is a subset of a metric space \((X,\rho)\) the following are equivalent.
\(E\) is complete and totally bounded.
(The Bolzano–Weierstrass property) Every sequence in \(E\) has a subsequence that converges to a point of \(E\).
(The Heine–Borel property) If \((V_{\alpha})_{\alpha \in A}\) is an open cover of \(E\) then there is finite \(F \subseteq A\) such that \((V_{\alpha})_{\alpha \in F}\) covers \(E\).
Remark. This theorem can be thought of as a characterization of compactness in metric spaces.
Suppose that (a) holds and \((x_n)_{n \in \mathbb{N}}\subseteq E\). We find \((x_{n_k})_{k \in \mathbb{N}}\) such that \(\rho(x_{n_k},x_0) \ _{\overrightarrow{k \to \infty}}\ 0\) for some \(x_0 \in E\).
\(E\) can be covered by finitely many balls of radius \(1 / 2\). At least one of them must contain \(x_n\) for infinitely many \(n \in \mathbb{N}\):
say \(x_n \in B_1\) for \(n \in \mathbb{N}_1 \subseteq \mathbb{N}\) and \({\rm card\;}(\mathbb{N}_1)={\rm card\;}(\mathbb{N})\).
Now \(E \cap B_1\) can be covered by finitely many balls of radius \(1 / 4\). At least one of them must contain \(x_n\) for infinitely many \(n \in \mathbb{N}\):
say \(x_n \in B_2\) for \(n \in \mathbb{N}_2 \subseteq \mathbb{N}_1\) and \({\rm card\;}(\mathbb{N}_2)={\rm card\;}(\mathbb{N})\).
Continuing inductively we obtain a sequence of balls \(B_j\) of radius \(2^{-j}\) and decreasing sequence of subsets \(\mathbb{N}_j\) of \(\mathbb{N}\) such that
\(x_n \in B_j\) for \(n \in \mathbb{N}_j\), \(\mathbb{N}_{j+1} \subseteq \mathbb{N}_j \subseteq \mathbb{N}\), \({\rm card\;}(\mathbb{N}_j)={\rm card\;}(\mathbb{N})\).
Pick \(n_1 \in \mathbb{N}_1\), \(n_2 \in \mathbb{N}_2, \ldots\) such that \[n_1<n_2<n_3<\ldots.\]
Then \((x_{n_j})_{j \in \mathbb{N}}\) is a Cauchy sequence for \[\rho(x_{n_j},x_{n_k})<2^{1-j} \quad \text{ if } \quad k \geq j,\] since \(x_{n_j},x_{n_k} \in B_j\) and \[{\rm diam\;}(B_j) \leq 2^{1-j}.\]
Since \(E\) is complete the sequence \((x_{n_k})_{k \in \mathbb{N}}\) has a limit in \(E\) and the implication (a) \(\Rightarrow\) (b) is proved.$$\tag*{$\blacksquare$}$$
We show that of either condition in (a) fails then so does (b).
If \(E\) is not complete there is a Cauchy sequence \((x_n)_{n \in \mathbb{N}}\subseteq E\), with no limit in \(E\). No subsequence of \((x_n)_{n \in \mathbb{N}}\) can converge in \(E\), for otherwise the whole sequence would converge to the same limit.
On the other hand if \(E\) is not totally bounded, let \(\varepsilon>0\) be such that \(E\) cannot be covered by finitely many balls of radius \(\varepsilon>0\). Choose \(x_n \in E\) inductively as follows. Let \(x_1 \in E\), and having chosen \(x_1,\ldots,x_n\) pick \[x_{n+1} \in E \setminus \bigcup_{j=1}^nB(x_j,\varepsilon),\] then \(\rho(x_n,x_m) \geq \varepsilon\) for all \(n \neq m\), so \((x_n)_{n \in \mathbb{N}}\) has no convergent subsequence. Thus (b) \(\Rightarrow\) (a). $$\tag*{$\blacksquare$}$$
It suffices to show that if (b) holds and \((V_{\alpha})_{\alpha \in A}\) is an open cover of \(E\) then the following claim holds:
Claim. There exists \(\varepsilon>0\) such that every ball of radius \(\varepsilon>0\) that intersects \(E\) is contained in some \(V_{\alpha}\).
Then \(E\) can be covered by finitely many such balls by (a) this allows us to find a finite subcover of \((V_{\alpha})_{\alpha \in A}\).
Suppose for a contradiction that the claim is not true.
For each \(n \in \mathbb{N}\) there is a ball \(B_n\) of radius \(2^{-n}\) such that \(B_n \cap E \neq \varnothing\) and \(B_n\) is contained in no \(V_{\alpha}\).
Pick \(x_n \in B_n \cap E\). Using (b), (by passing to a subsequence if necessary) we may assume \(\lim_{n \to \infty}\rho(x_n,x)=0\) for some \(x \in E\).
We have \(x \in V_{\alpha}\) for some \(\alpha \in A\) and since \(V_{\alpha}\) is open there is \(\varepsilon>0\) so that \(B(x,\varepsilon) \subseteq V_{\alpha}\).
If \(n\) is large enough so that \(\rho(x_n,x)<\frac{\varepsilon}{3}\) and \(2^{-n}<\frac{\varepsilon}{3}\), then \(B_n \subseteq B(x,\varepsilon) \subseteq V_{\alpha}\), which is contradiction.
Indeed, pick \(y \in B_n\), then \[\rho(y,x) \leq \rho(x_n,y)+\rho(x_n,x)<2^{1-n}+\frac{\varepsilon}{3} \leq \varepsilon.\]
This completes the proof of the implication (a) and (b) \(\Rightarrow\) (c). $$\tag*{$\blacksquare$}$$
If \((x_n)_{n \in \mathbb{N}}\subseteq E\), with no convergent sequence, for each \(x \in E\) there is a ball \(B_x\) centered at \(x\) that contains \(x_n\) for only finitely many \(n\).
Otherwise, some sequence would converge to \(x\). Then \[{\color{blue}(B_{x})_{x \in E}}\] is a cover of \(E\) by open sets with no finite subcover.$$\tag*{$\blacksquare$}$$
Theorem. Every closed and bounded set of \(\mathbb{R}\) is compact.
Proof. We deduce compactness by showing completeness and total boundedness.
Since every closed subset of \(\mathbb{R}\) is complete it suffices to show that bounded subsets of \(\mathbb{R}\) are totally bounded.
Since every bounded set is contained in some interval \([-R,R]\) it is enough to show that \([-R,R]\) is totally bounded.
Given \(\varepsilon>0\) pick an integer \(k>\frac{R}{\varepsilon}\) and express \([-R,R]\) as the union of \(k\) intervals of equal length. $$\tag*{$\blacksquare$}$$
Theorem. Every closed and bounded set of \(\mathbb{R}^n\) is complete.
Proof. We deduce compactness by showing completeness and total boundedness.
Since every closed subset of \(\mathbb{R}^n\) is complete is suffices to show that bounded subsets of \(\mathbb{R}^n\) are totally bounded.
Since every bounded set is contained in some cube \(Q=[-R,R]^n\) it is enough to show that \(Q\) is totally bounded.
Given \(\varepsilon>0\) pick the integer \(k>\frac{R\sqrt{n}}{\varepsilon}\) and express \(Q\) as the union of \(n^n\) congruent subcubes by dividing the interval \([-R,R]\) into \(k\) equal pieces.
The side length of these subcubes is \(\frac{2R}{k}\) and hence the diameter is \(\sqrt{n}\left(\frac{2R}{k}\right)<2\varepsilon\), so they are contained in the balls of radius \(\varepsilon\) about their centers. $$\tag*{$\blacksquare$}$$

Example. Determine if the set \[X=\{(x,y) \in \mathbb{R}^2\;:\;(x-1)^2+(y-1)^2 < 1\}\] is compact or not in \(\mathbb{R}^2\) with Euclidean metric.

Solution. Note that \((2,0)\) is an accumulation point of \(X\), but \((2,0) \not\in X\). Therefore, \(X\) is not closed, so it is not compact.$$\tag*{$\blacksquare$}$$
Example. Determine if the set is compact or not in \(\mathbb{R}^2\) with Euclidean metric: \[X=\{(x,y) \in \mathbb{R}^2\;:\;(x-1)^2+(y-1)^2 {\color{red}\leq} 1\}.\]

Solution. \(X\) contains all of its accumulation points so it is closed. It is contained in the ball \(B(0,10)\), so it is bounded. Therefore, by the previous theorem, it is compact.$$\tag*{$\blacksquare$}$$
Example. Determine if the set \[X=\{(x,y) \in \mathbb{R}^2\;: 1<y<2\}\] is compact or not in \(\mathbb{R}^2\) with Euclidean metric.

Solution. Note that \((0,2)\) is an accumulation point of \(X\), but \((0,2) \not\in X\). Therefore, \(X\) is not closed, so it is not compact.$$\tag*{$\blacksquare$}$$
Example. Determine if the set \[X=\{(x,y) \in \mathbb{R}^2\;: 1 {\color{red}\leq} y {\color{red}\leq} 2\}\] is compact or not in \(\mathbb{R}^2\) with Euclidean metric.

Solution. In can be checked that \(X\) is closed, although it is not contained in any ball, so it is not bounded, so it is not compact.$$\tag*{$\blacksquare$}$$
Example. Determine if the set \(\mathbb{Q}\) is compact in \(\mathbb{R}\).
Solution. \(\mathbb{Q}\) is not contained in any interval, so it is not compact.$$\tag*{$\blacksquare$}$$
Example. Determine if the set \(\mathbb{Q} \cap [0,1]\) is compact in \(\mathbb{R}\).
Solution. \(\mathbb{Q}\) is contained in \((-1,2)\), but \({\rm cl\;}\mathbb{Q} \cap [0,1] =[0,1] \neq \mathbb{Q} \cap [0,1]\), so it is not closed, so it is not compact.$$\tag*{$\blacksquare$}$$
Separated sets. Two subsets \(A\) and \(B\) of a metric space \((X,\rho)\) are said to be separated if both \[A \cap {\rm cl\;}(B)=\varnothing \quad \text{ and }\quad {\rm cl\;}(A) \cap B=\varnothing.\]
In other words, no points of \(A\) lies in the closure of \(B\) and vice versa.
Connected set. A set \(E \subseteq X\) is said to be connected if \(E\) is not a union of two nonempty separated sets.
Example.
\([0,1]\) and \((1,2)\) are not separated since \(1\) is a limit point of \((1,2)\).
However, \((0,1)\) and \((1,2)\) are separated.
Theorem. \(E \subseteq \mathbb{R}\) is connected iff for all \(x,y \in E\) if \(x<z<y\), then \(z \in E\).
Proof (\(\Longrightarrow\)). If there exist \(x,y \in E\) and \(z \in (x,y)\) such that \(z \not\in E\), then \[E={\color{red}A_z} \cup {\color{blue}B_z}, \quad \text{ where }\quad {\color{red}A_z=E \cap (-\infty,z)} \quad \text{ and } \quad {\color{blue}B_z=E \cap (z,\infty)}.\] Since \(x \in A_z\) and \(y \in B_z\), then \(A_z \neq \varnothing\), \(B_z \neq \varnothing\) and also \(A_z \subseteq (-\infty,z)\), \(B_z \subseteq (z,\infty)\), so they are separated. Hence \(E\) is not connected.
Proof (\(\Longleftarrow\)). Conversely, suppose that \(E\) is not connected.
Then there are non-empty separated sets \(A,B\) such that \(A \cup B=E\).
Pick \(x \in A\) and \(y \in B\) and without loss of generality assume \(x<y\). Define \[z=\sup \left(A \cap [x,y]\right).\] hence \(z \in {\rm cl\;}(A)\) and \(z \not\in B\). In particular, \(x \leq z<y\).
If \(z \not\in A\) it follows \(x<z<y\) and \(z \not \in E\).
If \(z \in A\) then \(z \not \in {\rm cl\;}(B)\) hence there is \(z_1\) such that \(z<z_1<y\) and \(z_1 \not\in B\). Then \(x<z_1<y\) and \(z_1 \not\in E\).$$\tag*{$\blacksquare$}$$
Example. Prove that \(X=\mathbb{R} \setminus \{0\}\) is not connected.
Solution. We have \(-1,1 \in X\), but \(-1<0<1\) and \(0 \not\in X\), so \(X\) is not connected.$$\tag*{$\blacksquare$}$$
Let \(C_0=[0,1]\). Given \(C_n\) that consist of \(2^n\) disjoint closed intervals each of length \(3^{-n}\) take each of these intervals and delete the open middle third to produce two closed intervals each of length \(3^{-n-1}\).

Take \(C_{n+1}\) to be the union of \(2^{n+1}\) closed intervals so formed and continue.
Cantor set. The set \[\mathcal{C}=\bigcap_{n=0}^{\infty}C_n\] is called the Cantor set or ternary Cantor set.
Each \(C_0 \supseteq C_1 \supseteq C_2 \supseteq \ldots\) is closed and bounded thus compact, and the family \((C_n)_{n \in \mathbb{N}}\) has finite intersection property thus the Cantor set is compact and \(\mathcal{C} \neq \varnothing\) .
Property (*). By the construction for each \(k,m \in \mathbb{N}\) we see that no segment of the form \[\left(\frac{3k+1}{3^m},\frac{3k+2}{3^m}\right) \quad \text{ has a point in common with $\mathcal{C}$. }\]
Since every segment \((\alpha,\beta)\) contains a segment of the form (*) if \(m\) is sufficiently large, since the set \[\left\{\frac{\ell}{3^m}\;:\; m \in \mathbb{N} \text{ and }0 \leq \ell \leq 3^{m}-1\right\}\] is dense in \([0,1]\). Thus \(\mathcal{C}\) contains no segment \((\alpha,\beta)\). This also shows \({\rm int\;}\mathcal C=\varnothing\).
To prove that \(\mathcal{C}\) is perfect it is enough to show that \(\mathcal{C}\) contains no isolated point. Let \(x \in \mathcal{C}\) and let \(I_n\) be the unique interval from \(C_n\) which contains \(x \in I_n\). Let \(x_n\) be the endpoint of \(I_n\) such that \(x \neq x_n\). It follows from the construction of \(\mathcal{C}\) that \(x_n \in \mathcal{C}\). Hence \(x\) is a limit point of \(\mathcal{C}\) thus \(\mathcal{C}\) is perfect.
Each component of \(C_n\) can be described as the set
\[C_n=\left\{\sum_{n=1}^\infty \frac{\varepsilon_j}{3^j}\;:\; \varepsilon_j \in \{0,1,2\} \text{ and }\varepsilon_j \neq 1 \text{ for }1 \leq j \leq n\right\}.\].
Consequently,
\[{\color{teal}\mathcal{C}=\left\{\sum_{n=1}^\infty \frac{\varepsilon_j}{3^j}\;:\; \varepsilon_j \in \{0,2\} \right\}.}\].
Fact. Any number \(\sum_{j=1}^\infty \frac{\varepsilon_j}{3^j}\) is uniquely determined by its sequence \(\varepsilon=(\varepsilon_j)_{j \in \mathbb{N}}\) with \(\varepsilon_j \in \{0,2\}\).
Proof. Take \(\varepsilon=(\varepsilon_j)_{j \in \mathbb{N}}\), \(\delta=(\delta_j)_{j \in \mathbb{N}}\) with \(\varepsilon_j,\delta_j \in \{0,2\}\) such that \(\varepsilon \neq \delta\). Let \(N=\min\{j \in \mathbb{N}\;:\; \varepsilon_j \neq \delta_j\}\) and assume \(0=\varepsilon_N<\delta_N=2\). Then \[\begin{aligned} \sum_{j=1}^{\infty}\frac{\varepsilon_j}{3^j}&= \sum_{j=1}^{N-1}\frac{\varepsilon_j}{3^j}+\sum_{j=N+1}^{\infty}\frac{\varepsilon_j}{3^j} \leq \sum_{j=1}^{N-1}\frac{\delta_j}{3^j}+\frac{2}{3^{N+1}}\sum_{j=0}^{\infty}\frac{1}{3^j} \\&\leq \sum_{j=1}^{N-1}\frac{\delta_j}{3^j}+\frac{2}{3^{N+1}}\underbrace{\frac{1}{1-\frac{1}{3}}}_{{\color{red}\frac{3}{2}}} =\sum_{j=1}^{N-1}\frac{\delta_j}{3^j}+\frac{1}{3^N}<\sum_{j=1}^{N-1}\frac{\delta_j}{3^j}+\frac{2}{3^N}\le \sum_{j=1}^{\infty}\frac{\delta_j}{3^j}. \end{aligned}\] This completes the proof. $$\tag*{$\blacksquare$}$$
Remark. We have two different representations \[\begin{aligned} \frac{1}{3}&=\sum_{j=1}^\infty \frac{\varepsilon_j}{3^j}=A, \quad \varepsilon_1=1, \quad \varepsilon_j=0 \quad\text{ for } \quad j \geq 2.\\ \frac{1}{3}&=\sum_{j=1}^\infty \frac{\varepsilon_j}{3^j}=B, \quad \varepsilon_1=0, \quad \varepsilon_j=2 \quad \text{ for } \quad j \geq 2. \end{aligned}\]
There is a bijection \(\phi:\{0,1\}^{\mathbb{N}} \to \mathcal{C}\) defined by \[\phi(z)=\frac{2}{3}\sum_{j=0}^{\infty}\frac{z_j}{3^j} \quad \text{ for } \quad z=(z_j)_{j \in \mathbb{N}}, \quad z_j \in \{0,1\},\] and consequently \({\rm card\;}(\mathcal{C})={\rm card\;}(\{0,1\}^{\mathbb{N}})={\rm card\;}(\mathbb{R})=\mathfrak{c}.\)

\({\color{red}\varepsilon=(0,1,1,0,\varepsilon_4,\varepsilon_5,\ldots)}\)