Let $X$ be a metric space. Prove that if every continuous function $f: X \rightarrow \mathbb{R}$ is bounded, then $X$ is compact.

This has been asked before, but all the answers I have seen prove the contrapositive. Realistically, this may be the way to go, but is there way to exhibit an unbounded continuous function (under the assumption $X$ is not compact) without appealing to results beyond introductory real analysis (e.g., the solution I’ve seen involves the Tietze Extension theorem)?

Because we’re working with metric spaces, it’s clear that the assumption that $X$ is noncompact (towards proving contrapositive) will lead us to extract a sequence of points in the space with no convergent subsequences. But how can we infer the existence of an unbounded continuous on the space knowing only about some sequence of points in this space (without using anything too advanced)?

**Answer**

But how can we infer the existence of an unbounded continuous on the space knowing only about some sequence of points in this space

By using the sequence to construct an unbounded continuous function.

Since the sequence – call it $(x_n)_{n\in\mathbb{N}}$ – has no convergent subsequence, every point occurs only finitely many times in the sequence. Passing to a subsequence, we may assume all the $x_n$ are distinct.

For every $m\in\mathbb{N}$, the distance of $x_m$ to the rest of the sequence is positive,

$$\delta_m := \inf \left\{ d(x_m,x_k) : k \in \mathbb{N}\setminus \{m\}\right\} > 0,$$

for if $\delta_m = 0$, then $(x_n)$ would have a subsequence converging to $x_m$.

Now consider the functions

$$f_m(x) = \left(1 – \frac{3}{\delta_m}d(x_m,x)\right)^+,$$

where $u^+$ is the positive part of $u$, $u^+ = \max \{u,0\}$. These functions are continuous since the maximum of two continuous functions is continuous. The function

$$f(x) = \sum_{m=0}^\infty m\cdot f_m(x)$$

is, if well-defined, unbounded, since $f(x_m) \geqslant m$.

It remains to see that $f$ is well-defined and continuous. That follows if we can show that every point $x\in X$ has a neighbourhood on which at most one of the $f_m$ attains values $\neq 0$.

If $x = x_m$ for some $m\in\mathbb{N}$, then $f_k\lvert B_{\delta_m/3}(x_m) \equiv 0$ for all $k\neq m$: Suppose we had $f_k(y)\neq 0$ for some $y\in B_{\delta_m/3}(x_m)$ and some $k\neq m$. Then

$$\max \{\delta_k,\delta_m\} \leqslant d(x_m,x_k) \leqslant d(x_m,y) + d(y,x_k) \leqslant \frac{\delta_m}{3} + \frac{\delta_k}{3} \leqslant 2\frac{\max \{\delta_m,\delta_k\}}{3} < \max \{\delta_k,\delta_m\},$$

so that is impossible.

If $x \neq x_m$ for all $m$, the argument is similar. Let $\delta = \inf \{ d(x,x_n) : n\in\mathbb{N}\}$. Then $\delta > 0$ for otherwise the sequence would have a subsequence converging to $x$. Then on $B_{\delta/4}(x)$ at most one $f_m$ can attain a nonzero value. Suppose again it weren’t so, and also $f_k$ attained a nonzero value there. Then we have $y,z \in B_{\delta/4}(x)$ with $f_m(y) \neq 0$ and $f_k(z) \neq 0$. That implies $\frac{3}{4}\delta < \frac{1}{3}\min \{ \delta_m,\delta_k\}$ since $d(y,x_m) \geqslant d(x,x_m) – d(x,y) \geqslant \frac{3}{4}\delta$ and similarly for $x_k$. But then we would have

$$0 < \max \{ \delta_m,\delta_k\} \leqslant d(x_m,x_k) \leqslant d(x_m,y) + d(y,z) + d(z,x_k) \leqslant \frac{\delta_m}{3} + \frac{1}{2}\delta + \frac{\delta_k}{3} < \max \{\delta_m,\delta_k\}.$$

Since every point has a neighbourhood on which at most one $f_k$ does not identically vanish, $f$ is well-defined and continuous.

**Attribution***Source : Link , Question Author : combinator , Answer Author : Daniel Fischer*