Kosniowski's exercise I'm having troubles solving the following exercise, proposed in Kosniowski's "A first course in Algebraic Topology", and any help would be appreciated!
Consider the topological space $X:=(\mathbb{R}, \mathcal{T})$, where $\mathcal{T}=\{\emptyset\}\cup \{\mathbb{R}\} \cup \{(-\infty, t):t \in \mathbb{R}\}$. Prove that a function $f: X \to X$ is continuous if and only if it is non-decreasing (that is, if $x > x'$, then $f(x)\ge f(x')$) and continuous on the right (that is, $\forall x \in \mathbb{R}$ and all $\epsilon > 0$ there exists $\delta > 0$ such that if $x' \in [x, x + \delta)$, then $|f(x) - f(x')| < \epsilon$).
 A: HINTS: Let $f:X\to X$ be a function. You have to prove three things:


*

*If $f$ is continuous, then $f$ is non-decreasing.  

*If $f$ is continuous, then $f$ is continuous on the right.  

*If $f$ is non-decreasing and continuous on the right, then $f$ is continuous.


(2) is trivial, so it really comes down to proving (1) and (3).
(1) is the sort of statement that almost begs to be proved either by contradiction or by proving the contrapositive, so suppose that $f$ is not non-decreasing. Then there are $x,y\in\Bbb R$ such that $x<y$ and $f(x)>f(y)$, and we’d like to use $x$ and $y$ somehow to show that $f$ is not continuous. Let $u\in\big(f(y),f(x)\big)$, and let $U=(\leftarrow,u)$. $U$ is an open nbhd of $f(y)$; is $f^{-1}[U]$ open?
For (3) a direct proof looks feasible, so suppose that $f$ is non-decreasing and continuous on the right. Let $U$ be any open subset of $X$; we need to show that $f^{-1}[U]$ is open. This is trivial if $U=\varnothing$ or $U=\Bbb R$, so we might as well assume that $U=(\leftarrow,u)$ for some $u\in\Bbb R$. 


*

*Show that if $f(x)\in U$, then $(\leftarrow,x]\subseteq f^{-1}[U]$; this uses the fact that $f$ is non-decreasing.  

*Conclude that either $f^{-1}[U]=X$, or $f^{-1}[U]$ is bounded above. In the latter case let $v=\sup f^{-1}[U]$. Clearly $f^{-1}[U]$ must then be equal either to the open ray $(\leftarrow,v)$ or to the closed ray $(\leftarrow,v]$. Use the right-continuity of $f$ to show that $f^{-1}[U]=(\leftarrow,v)$.

