# True Or not: Compact iff every continuous function is bounded [duplicate]

Let $X$ be a topological space. My question is:

If $f:X\to \mathbb{R}$ is bounded for all such continuous $f$, then is $X$ compact. Is is really?

If $X$ is the subset of $\mathbb{R}^d$, then it is clear, beacause with Heine-Borel we get what we want (closed and bounded (with the help of the norm)), but is it true in general? I really hope there exists a non-compact space with the property above.

-

## marked as duplicate by Chris Eagle, Cameron Buie, Julian Kuelshammer, Danny Cheuk, Chris GodsilJul 22 '13 at 11:53

martini gave a counter-example. The result is however true if we assume $X$ to be a metric space. If it's not compact, there are disjoint ball $B(x_n,r_n)$ with $r_n\downarrow 0$. Then take $f=\sum_n n\cdot f_n$, where $f_n:=\max\{0,r_n-d(x,x_n)\}$. – Davide Giraudo Jul 22 '13 at 10:49

Let $X = [0,\omega_1)$. Then $X$ is non-compact as the $[0,\alpha)$, $\alpha < \omega_1$ form an open cover without even a countable subcover.

On the other hand, let $f \colon X \to \mathbb R$ continuous. Suppose $f%$ were unbounded. Then there is a sequence $\alpha_n < \omega_1$ such that $f(\alpha_n) \ge n$. As $[0,\alpha]$ is compact for $\alpha < \omega_1$ and $f$ is continuous, $f([0,\alpha])$ is bounded. So we may arrange that $\alpha_{n+1} > \alpha_n$ for $n < \omega$. Let $\alpha^* = \sup_n \alpha_n$. By continuity $f(\alpha^*) = \lim_n f(\alpha_n)$. But $f(\alpha_n) \ge n$ for each $n$. Contradiction, hence $f$ is bounded.

-
And (as you know but the OP may not) even more is true: every continuous function from $X$ to $\Bbb R$ is eventually constant. Dan Ma’s Topology Blog has a proof. – Brian M. Scott Jul 22 '13 at 10:48
I have to check it first, but thanks for this fast answer. – Evarist Jul 22 '13 at 10:53

To complement Martini's answer, one may add that if the space $X$ is $metrizable$, then the answer is "yes".

Indeed, assume that $X$ is metrizable and not compact. Then one can find a sequence $(x_n)_{n\in\mathbb N}\subset X$ with $x_n\neq x_m$ if $n\neq m$, such that the set $C=\{ x_n;\; n\in\mathbb N\}$ is discrete in the topology induced by $X$. Then the function $f_0=C\to\mathbb R$ defined by $f_0(x_n)=n$ is continuous and unbounded. Moreover, $C$ is closed in $X$, so by Tietze's extension theorem $f_0$ can be extended to a continuous (and unbounded!) function $f:X\to\mathbb R$.

Apologies: I did not notice that Davide Giraudo gave the same answer in a comment above.

-