Heine-Cantor Theorem

Theorem
Let $M_1$ and $M_2$ be metric spaces.

Let $f: M_1 \to M_2$ be a continuous mapping.

If $M_1$ is compact, then $f$ is uniformly continuous on $M_1$.

Proof
Let $M_1 = \left({A_1, d_1}\right)$ and $M_2 = \left({A_2, d_2}\right)$ be metric spaces such that $M_1$ is compact.

Let $f: M_1 \to M_2$ be continuous.

Let $\epsilon > 0$.

Then by definition:
 * $\forall x \in M_1: \exists \delta \left({x}\right) > 0: \forall y \in M_1: d_1 \left({x, y}\right) < 2 \delta \left({x}\right) \implies d_2 \left({f \left({x}\right), f \left({y}\right)}\right) < \dfrac \epsilon 2$

The set $\left\{{N_{\delta \left({x}\right)} \left({x}\right): x \in M_1}\right\}$ is an open cover for $M_1$.

As $M_1$ is compact, there is a finite subcover $\left\{{N_{\delta \left({x_1}\right)} \left({x_1}\right), N_{\delta \left({x_2}\right)} \left({x_2}\right), \ldots, N_{\delta \left({x_r}\right)} \left({x_r}\right)}\right\}$.

Now let $\delta = \min \left\{{\delta \left({x_1}\right), \delta \left({x_2}\right), \ldots, \delta \left({x_r}\right)}\right\}$.

Consider any $x, y \in M_1$ which satisfy $d_1 \left({x, y}\right) < \delta$.

There is some $i \in \left\{{1, 2, \ldots, r}\right\}$ such that $d_1 \left({x, x_i}\right) < \delta \left({x_i}\right)$.

Thus:
 * From $d_1 \left({x, x_i}\right) < \delta \left({x_i}\right)$ we have:
 * $d_2 \left({f \left({x}\right), f \left({x_1}\right)}\right) \le \dfrac \epsilon 2$


 * From $d_1 \left({y, x_i}\right) \le 2 \delta\left({x_i}\right)$ we have:
 * $d_2 \left({f \left({y}\right), f \left({x_1}\right)}\right) \le \dfrac \epsilon 2$

So:

Alternative proof
By Sequence of Implications of Metric Space Compactness Properties, we can assume that $M_1$ is sequentially compact.

Suppose $f:A_1 \to A_2$ is continuous but not uniformly continuous.

Then for some $\epsilon > 0$ and each number $\dfrac 1 n$, we can select points $x_n, y_n \in A_1$ such that $ d_1(x_n, y_n) < \dfrac 1 n$ but $d_2(f(x_n), f(y_n)) \geq \epsilon$.

Since $A_1$ is sequentially compact, some subsequence $x_{\phi(n)}$ of $x_n$ converges to a point $x$.

Since $d_1(y_{\phi(n)}, x) \leq d_1 (y_{\phi(n)}, x_{\phi(n)}) + d_1 (x_{\phi(n)}, x) \to 0$, we see that $y_{\phi(n)}$ converges to x as well.

Since continuous functions send convergent sequences to convergent sequences (see: Limit of Image of Sequence), both $f(x_{\phi(n)})$ and $f(y_{\phi(n)})$ both converge to $f(x)$, hence they must grow arbitrarily close to each other.

But this contradicts the fact that we chose $x_n$ and $y_n$ to always be at least $\epsilon$ apart.

Note
If a mapping is uniformly continuous it is not necessarily compact.

For example, the identity mapping is (trivially) uniformly continuous on a mapping from any metric space, whether compact or not.