Let $f: \Bbb R \to \Bbb R$ be such that $f^{-1} (a, \infty)$ and $f^{-1} (- \infty, b)$ are open for any $a,b \in \Bbb R$. Let $f: \Bbb R \to \Bbb R$ be such that $f^{-1} (a, \infty)$ and $f^{-1} (- \infty, b)$ are open for any $a,b \in \Bbb R$. Show that $f$ is continuous.
My Try: We first take an arbitary open subset $(a,b)$ of  $\Bbb R$. We note that $(a,b) = (- \infty, b) \bigcap (a, \infty)$ for any $a<b$. Thus $f^{-1} (a, b)$ is open since, both $f^{-1} (a, \infty)$ and $f^{-1} (- \infty, b)$ are open. Any we know that $f$ is continuous if $f^{-1} (G)$ is open in $\Bbb R$ for all open subsets $G \in \Bbb R$.
Is proof correct??
Thank You.
 A: *

*Sets of the form $(a,\infty)$ and $(-\infty,b)$ form a subbase for the topology on $\Bbb R$.

*It suffices to check continuity of a function on the subbase for a topology, i.e. if $\cal B$ is a subbase for $Y$ then $f:X\to Y$ is continuous iff $f^{-1}(B)\in{\cal O}_X$ for each $B\in\cal B$.


To see (2), let $\cal F$ be the set of finite intersections of $\cal B$ - this is a basis for ${\cal O}_Y$. If $F\in\cal F$ then $F=B_1\cap B_2\cap\dots\cap B_k$ where each $B_i$ is in $\cal B$. Then $f^{-1}(F)=f^{-1}(B_1\cap\dots\cap B_k)=f^{-1}(B_1)\cap\dots\cap f^{-1}(B_k)$ which is a finite intersection of open sets and hence open. Now if $U\in{\cal O}_Y$, then $U=\bigcup_i F_i$ for some family $F_i\in\cal F$, and then $f^{-1}(U)=f^{-1}(\bigcup_i F_i)=\bigcup_i f^{-1}(F_i)$, which is a union of open sets and hence open.
A: You can also do a direct proof. 
Consider $x\in\mathbb{R}$, $y=f(x)$ and $\epsilon>0$. Let $U=(-\infty,y+\epsilon)$ and $V=(y-\epsilon,+\infty)$. Then $x\in f^{-1}(U)\cap f^{-1}(V)$. By assumption, $f^{-1}(U)$ is open so there is $\delta_1>0$ such that $B(x,\delta_1)\subset f^{-1}(U)$. Similarly, there is $\delta_2>0$ such that $B(x,\delta_2)\subset f^{-1}(V)$. So if $\delta=\min\{\delta_1,\delta_2\}$, then we have
$$
B(x,\delta)\subset f^{-1}(U)\cap f^{-1}(V)\implies f(B(x,\delta))\subset U\cap V=B(y,\epsilon)
$$
which proves continuity at $x$. As $x$ is arbitrary, the claim follows.
