# Uniformly continuous function and compactness

If every continuous function $f:X\to\mathbb{R}$ (where $X$ is a subset of a compact metric space), is uniformly continuous, then am I right to assume that $X$ is compact as well?

I think it should but I'm not sure if I am correct. Like if $X$ is a subset of a compact metric space then shouldn't $X$ itself the domain be compact as well if $f$ is uniformly continuous?

Let $K$ be a compact metric space such that $X \subseteq K$. Suppose $X$ is not compact, then $X$ is not closed in $K$, hence there is a point $k \in \bar X \setminus X$. Consider the function $$f \colon X \to \mathbb R, \quad x \mapsto \frac 1{d(x,k)}$$ ($d$ denoting the metric of $K$). Then $f$ is continuous, but not uniformly continuous, as in the letter case, $f$ would have a continuous extension to $\bar X$, which is impossible.
• @user97994 He's shown "$X$ not compact $\implies$ there exists a continuous, not uniformly continuous $f$". This is equivalent to what you wanted. – Arthur Oct 1 '13 at 11:35