Can we find a function $f:\mathbb{R}\rightarrow \mathbb{R}$ that is open, closed, but not continuous?
The question is described in the title. To clarify, I'm looking for an example where the domain of such a function is $\mathbb{R}$, so the example here will not work.
The highest upvote answer here gives an example of discontinuous open map from $\mathbb{R}$ to $\mathbb{R}$, but that map can hardly be closed (closed set does not need to contain any interval!). I have difficulty generalize the construction and know very little about any sufficient condition that leads to closed map without continuity (piecewise constant will work, but that kind of maps cannot be open!).
I'll appreciate any example, non-constructive prove/disprove, or any reference that covers this.
*In case I need to clarify this, we use std. metric topology on $\mathbb{R}$
Solution 1:
No such function exists.
Assume that $f((a,b))$ is a bounded open set. Then $f((a,b))= (c,d)$ for some $c,d\in \mathbb{R}$. Indeed, $f((a,b))$ is an open set hence of the form $\bigcup (a_n,b_n)$ however $f([a,b])$ has at most two more points than $f((a,b))$, so we conclude.
Claim: if $f((a,b))= (c,d)$ then $f$ is continuous and strictly monotonic on $(a,b)$.
Proof: Firstly, we will show that $f$ is injective. Indeed assume that $f(x_1)= f(x_2)$ for some $x_1,x_2\in (a,b)$. Then take the $f((x_1,x_2))=(c_1,d_1) $ for some $c_1,d_1$, a contradiction since $f( [x_1,x_2] )$ needs two points to be closed. Now, since $f$ has the IVT propoerty and it is injective it is strictly monotonic and continuous.
We will argue by contradiction. Assume that $f$ is not continuous at $x_0$, and set $V_n=( x_0-1/n,x_0+1/n )$. Now, the claim implies there are $z_n<w_n$ such that $f(V_n )=(-\infty ,z_n)\bigcup (w_n,\infty) $ where $z_n$ or $w_n$ can possibly take the value $\pm \infty$. Also, notice that $w_n$ is increasing and $z_n$ is decreasing.
First case, one of the $z_n,w_n$ converges (to a finite limit). WLOG assume that $w_n \rightarrow w$. Now, pick a number $\beta$ in $(w,\infty)$ that is different from $f(x_0)$. We can find a sequence $p_n\in V_{n-1}\setminus V_n$ such that $f(p_n)=\beta +1/n$. A contradiction since the closed set $\{x_0\}\bigcup \{p_n|n\in \mathbb{N}\}$ gets mapped via $f$ to $\{f(x_0)\}\bigcup \{\beta +1/n|n\in \mathbb{N}\}$ which is not closed.
In the second case, we have $z_n \rightarrow -\infty$ and $w_n \rightarrow\infty$. This is a contradiction since the previous implies $\bigcap_{n \in \mathbb{N}}f(V_n)= \emptyset$, however $\bigcap_{n \in \mathbb{N}}f(V_n)$ always contains $f(x_0)$.
Solution 2:
This proof has a flaw in the second half:
Let $f:\mathbb R\rightarrow \mathbb R$ be a closed and open function.
First we prove that $f^{-1}(x)$ is finite for every $x\in \mathbb R$
suppose not, let $a_1>a_2>a_n\dots$ be a sequence of values whose image is all $x$, and such that for every $i$ there is an element in $f^{-1}(x)$ between $a_i$ and $a_{i+1}$.
Notice that $f((a_i,a_{i+1}))=f([a_i,a_{i+1}])$. Therefore $f((a_i,a_{i+1})=\mathbb R$, since it is a clopen set).
If the $a_i$'s converge then let $l$ be their limit.
We now take $b_1,b_2,\dots$ a sequence such that $a_i<b_i<a_{i+1}$ for all $i$, and such that $f(b_i)$ is a strictly increasing converging sequence ( if the $a_i$'s converge we also ask $f(a_i)>l$).
If $l$ does not exist then $\{b_1,b_2,\dots\}$ is closed while its image is not. And if $l$ exists then $\{l,b_1,b_2,\dots\}$ is closed while its image is not.
So now let $f^{-1}(0)=\{a_1,a_2,\dots, a_n\}$. Then $f$ is injective when restricted to $(-\infty,a_1),(a_i,a_{i+1})$ and $(a_n,\infty)$.
Proof: Let $U$ be a connected set which does not contain $0$ in the image, suppose $f(x)=f(y)$ for some $x\in U$. Notice that $f((x,y))$ and $f([x,y])$ differ by exactly one point. This means that $f(x,y)$ is an open set with at most $1$ limit point. Therefore $f(x,y)=\mathbb R$ or $\mathbb R \setminus f(x)$. Either case is a contradiction, since no point in $U$ maps to $0$.
We conclude that $f$ is injective when restricted to each of those open sets. Notice that the function $f$ is an open function with respect to the induced topology, since each of those sets is open. Moreover, each of these sets is isomorphic to $\mathbb R$. The following lemma finishes the proof.
Lemma: an open injection $g:\mathbb R\rightarrow \mathbb R$ is continuous.
proof: Let $h$ be the $g$ with a changed codomain, so that the function is surjective. Notice that $h^{-1}$ is a continuous bijection from a disjoint union of open sets to $\mathbb R$. (every open set is a disjoint union of open intervals).
It suffices to show that $h^{-1}$ is open on every interval, but this is clear, since a continuous injection $(a,b)\rightarrow \mathbb R$ is increasing, and hence a homeomorphism on its domain.
This shows that $f$ is continuous for every point $x$ with $f(x)\neq 0$. Using the same argument for $1$ instead of $0$ proves continuity everywhere.