TITLE: If $f^{-1}(c)$ is closed $\forall c\in\Bbb R$ and if for each $c\in\Bbb R$ between $f(x)$ & $f(y)$ there is $z\in[x,y]$ s.t. $f(z)=c,f$ is continuous.
QUESTION [5 upvotes]: For $x,y\in\Bbb R^n,$ define $[x,y]:=\{(1-\lambda)x+\lambda y\}.$ Let $f:\Bbb R^n\to\Bbb R.$ Prove the following statement:
If $f^{-1}(c)$ is closed $\forall c\in\Bbb R$ and if for each $c\in\Bbb R$ between $f(x)$ and $f(y)$ there is $z\in[x,y]$ such that $f(z)=c,$ then $f$ is continuous.

My thoughts:
Let's write $z_1=z\in[x,y]$ as $z_1=(1-\lambda_1)x+\lambda_1y.$ If the statement holds for any $c_1=c$ between $f(x)$ and $f(y),$ then it should also hold for any $c_2$ between $f(x)$ and $c_1$ or $c_1$ and $f(y)$. WLOG, assume it's the former, so , for that $c_2,$ there is some $z_2\in[x,z_1]$ such that   $f(z_2)=c_2$. Then, $$\begin{aligned}z_2&=(1-\lambda_2)x+\lambda_2z_1\\&=(1-\lambda_2)x+\lambda_2((1-\lambda_1)x+\lambda_1y)\\&=(1-\lambda_2+\lambda_2(1-\lambda_1))x+\lambda_1\lambda_2y\\&=(1-\lambda_1\lambda_2)x+\lambda_1\lambda_2y.\end{aligned}$$ Denote $\overline\lambda_2=\lambda_1\lambda_1\le\lambda_1.$ Then, we can repeat the procedure to approach $x$ arbitrarily close as $\lim\limits_{k\to\infty}\overline\lambda_k=0$ and obtain a somewhat recursive sequence $(z_k)_{k\in\Bbb N}, z_{k+1}\in[x,z_k]$ with $f(z_{k+1})\in\Bbb R$ between $f(x)$ and $c_k.$ We can, then, choose different lines in $\Bbb R^n$ through $x$ and $y'$s on all sides. I know that a function having the same limit at a point in all directions is insufficient and that the limit should be uniform and combine it with Heine characterization of limit of the function at a point. I guess I should use the fact $f^{-1}f((x))$ is closed here, but my attempt seems wavy and too informal. How should I proceed?

REPLY [5 votes]: We will prove that $f$ is continuous everywhere by contradiction.
Suppose $f$ is discontinuous at the point $x = p$.
There are two cases.
Case 1) There is some $\beta > 0$ so that there is a sequence $p_{1},p_{2},...\rightarrow p$ satisfying $f(p_{j}) \geq f(p)+\beta$.
In this case we can apply the interpolant property to note that there is some $\lambda_{n} \in [0,1]$ so that
$$f(\lambda_{n}p +(1-\lambda_{n})p_{n}) = f(p)+\beta$$
Note that $f^{-1}(f(p)+\beta)$ contains points $q_{n} = \lambda_{n}p +(1-\lambda_{n})p_{n} \rightarrow p$ as $n \rightarrow \infty$ and $p \notin f^{-1}(f(p)+\beta)$. But $f^{-1}(f(p)+\beta)$ is closed; thus this case is impossible.
Case 2) There is some $\beta > 0$ so that there is a sequence $p_{1},p_{2},...\rightarrow p$ satisfying $f(p_{j}) \leq f(p)-\beta$
This case is again impossible by considering methods used in Case 1.
Since both the above cases are impossible this is a contradiction.