Inverse of Heine–Cantor theorem
We have by Heine–Cantor theorem that:
If $M$ and $N$ are metric spaces and $M$ is compact then every continuous function $f : M \to N$, is uniformly continuous.
Is the inverse of this theorem is satisfied?
Solution 1:
Let $(M,d)$ be a metric space that is not compact and has no isolated points. Then there exists a countable discrete subspace $Z$. For this, there exists an enumeration $Z=\{z_n\mid n\in\mathbb N\}$ and radii $ r_n>0$ such that $Z\cap B(z_n,r_n)=\{z_n\}$. Then the $B(z_n,\frac12r_n)$ are pairwise disjoint. We may assume wlog. that $r_n\to 0$. Then for any $x\in M$, there exists $r>0$ such that $B(x,r)$ intersects only finitely many $B(z_n,\frac12r_n)$. Therefore if for each $n$ we have a continuous function $f_n\colon M\to\mathbb R$ with $f_n(x)=0$ for all $x$ with $d(x,z_n)\ge \frac12r_n$, then the sum $$\tag1f(x):=\sum_{n\in\mathbb N} f_n(x)$$ is in fact locally finite (that is each point has a neighbourhood where all but finitely many summands are identically $0$), hence continuous. Since the $z_n$ are not isolated, we find $y_n$ with $0<d(y_n,z_n)<r_n$ and can define $$f_n(x)=\max\left\{0, 1-\frac{d(x,z_n)}{d(y_n,z_n)}\right\}.$$ With this choice of $f_n$, the function $f$ is not uniformly continuous: No matter how small we choose $\delta>0$, we will find $n$ with $r_n<\delta$ and hence $d(y_n,z_n)<\delta$. But $f(y_n)=f_n(y_n)=0$ and $f(z_n)=f_n(z_n)=1$.
We also note that pointwise at most one summand in $(5)$ is nonzero, hence $0\le f(x)\le 1$ with our choice of $f_n$.
Conclusion: If $(M,d)$ is a metric space without isolated points and every continuous function $f\colon M\to\mathbb [0,1]$ is uniformly continuous, then $M$ is compact.
Solution 2:
If $M$ is path-connected and any continuous $f:\mathbb M\to \mathbb R$ is uniformly continuous, then $M$ is compact. (I think it is true if $M$ is connected, but I'm not sure.)
First prove that $M$ is bounded. If $M$ is not bounded, pick $x_0\in M$ and define $f(x)=d_M(x_0,x)^2$. Show that this is not uniformly continuous. So $$|f(x)-f(y)|=|d(x_0,x)-d(x_0,y)|(d(x_0,x)+d(x_0,y))\geq d(x,y)d(x_0,x)$$
So, given an $\epsilon>0$ and a $\delta>0$, pick $x$ so that $d(x_0,x)>2\epsilon/\delta$. Pick $y$ so that $d(x,y)=\delta/2$ (which is possible by connectedness.) Then $$|f(x)-f(y)| > \frac{\delta}{2} d(x_0,x) =\epsilon$$ So $f$ is not uniformly continuous.
Then we prove that $M$ is complete.
Assume $x_1,x_2,\dots,x_n,\dots$ is a Cauchy sequence which does not converge. For each $x\in M$, the sequence of real numbers $d(x,x_1),d(x,x_2),\dots$ is Cauchy in $\mathbb R$. Define$$g(x)=\lim_{n\to\infty} d(x,x_n)$$ Show that this is a continuous map from $M\to\mathbb R^+$. Then define $f(x)=\frac{1}{g(x)}$, which is again continuous. Finally, show that this $f$ cannot be uniformly continuous I'll leave these last steps to you.