# Compactness implies Continuity?

I am stuck on this question (probably there are many counterexamples, but I can't find any).

"Suppose $f:\mathbb{R}\mapsto\mathbb{R}$ that preserves compactness (i.e, for every $K \subseteq R$, then $f(K)$ is compact). Is $f$ continuous?"

thanks!

-
Just wanted to point out that the inverse direction is indeed true: the image of a compact set $K\subset\mathbb{R}$ under a continuous function $f$ is compact (iow $f(K)\subset\mathbb{R}$ is compact). $\ddot\smile$ –  b00n heT Jan 31 at 22:19

## 2 Answers

$f(x) = 1$ if $x$ is rational, otherwise $f(x)=0.$ So $f(K)$ is either one or two points.

-
@Dror: There are plenty. This function, while not continuous, is the pointwise limit of continuous functions. One can find functions which are not even Borel measurable. That means that they are far far less continuous than this one. –  Asaf Karagila Jan 31 at 22:25
Will, of course. It's when you're drunk you start flirting with the idea that every function is Borel measurable. –  Asaf Karagila Jan 31 at 22:26
As long as it's not light beer... –  Asaf Karagila Jan 31 at 22:30
Hey @WillJagy, I got it. thank you all for the comments! –  user125303 Jan 31 at 22:35
@Dror: I am talking about functions $\Bbb{R\to R}$. There are only $2^{\aleph_0}$ functions which are Borel (which turn out the be the smallest class of functions containing all the continuous functions and closed under pointwise limits), so most of the functions are even "less continuous" than that. If you want to be slightly more "specific", pick any non-measurable subset, e.g. a Bernstein set or a Vitali set, and consider its indicator function. –  Asaf Karagila Jan 31 at 22:36

Floor function should be another example. The image of each compact (bounded) set is a finite discrete set and therefore compact.

-