# Uniformly continuous only on compact space

Heine–Cantor theorem state that if $M$ is compact then the continuous function $f:M\to N$ is uniformly continuous.

Is there a continuous function $f:A\to\Bbb R^n$ such that $f$ is uniformly continuous on $B\subset A$ implies $B$ is compact, i.e. $f$ is uniformly continuous only on compact space?

I thought about using some function $f:\Bbb R\to \Bbb R$, like $x\mapsto x^2$ but I don't know how to approach to this if $B$ is between 2 finites numbers (like $B=(0,1]$)

• Since $\mathbb R$ and $(0,1]$ are not compact, any function works and is vacuously true. You should look at examples like $[0,1]$. – Stella Biderman Dec 22 '17 at 13:50
• Such a function won't exists… if $f$ is uniformly continuous on $B \subset A$ then it is also on each open (and hence non compact) set $C \subset B$. – Gono Dec 22 '17 at 13:51

This is only possible, if all subsets of $A$ are compact, but then the statement is trivial. (Such sets $A$ do exists, take for example a finite set $A$.)
Let $A \subset \mathbb R^m$, $f: A \to \mathbb R^n$ continuous and $B \subset A$ not compact. For some $R \gt 0$ the set $$B' := B_R(0) \cap B$$ is not empty. $B'$ is not compact (else $B$ would be compact).
However, $\overline{ B'}$ is compact, hence for all $\varepsilon \gt 0$ there exists $\delta \gt 0$ such that $\|f(x) - f(y)\| \lt \varepsilon$ for $\|x - y\| \lt \delta$ and $x, y \in \overline{B'}$. This is obviously also true for $x, y \in B'$, as $B' \subset \overline{B'}$.
• I understand the general idea behind this, but What does $B_r(0)$ mean? – ℋolo Dec 22 '17 at 14:03
• $B_R(0) := \{x \in \mathbb R^m: \|x-0\| \le R\}$. – Keba Dec 22 '17 at 14:05
If $f :\mathbb R \to \mathbb R$ is uniformly continuous on compact sets, you can say that $f$ is uniformly continuous on $[0, 1]$, which means that for all $\epsilon > 0$ there exists $\eta >0$ such that for all $x, y \in [0,1]$ such that $|x-y| \leq \eta$, $|f(x)-f(y)| \leq \epsilon$.
Which means that $f$ is uniformly continuous on $(0,1)$ which is open and therefore not compact.