# If $\{x:f(x)<a\}$ and $\{x:f(x)>a\}$ are open then $f$ is continuous

Show that if the sets $\{x:f(x)<a\}$ and the set $\{x:f(x)>a\}$ are open for every $a\in \Bbb Q$ where $(M,d)$ is a metric space and $f:M\to\Bbb R$ ,then $f$ is continuous.

Take a basic open set $(a,b)\in \Bbb R$. To show that $f$ is continuous we need to show that $f^{-1}(a,b)$ is open.

Let $c_n(\in \Bbb Q)\to a$ and $d_n(\in \Bbb Q)\to b$

$f^{-1}(a,b)= \{x:f(x)>a\}\cap \{x:f(x)<b\}$

But how can I write $\{x:f(x)>a\},\{x:f(x)<b\}$ in terms of $c_n,d_n$??

Let $a\in \mathbb R.$ Then there exists a sequence of rationals $c_1>c_2 > \cdots$ such that $c_n\to a.$ It follows that $(a,\infty) = \cup_{n=1}^\infty (c_n,\infty).$ Thus, since inverse images respect unions, we have

$$\tag 1 \{x: f(x)>a\} = f^{-1}((a,\infty))= f^{-1}(\cup_{n=1}^\infty (c_n,\infty))= \cup_{n=1}^\infty f^{-1}((c_n,\infty)).$$

We are given that each $f^{-1}((c_n,\infty))$ is open. Since any union of open sets is open, the right side of $(1)$ is open.

We have shown $\{x: f(x)>a\}$ is open for every real $a.$ A similar argument shows $\{x: f(x)<b\}$ is open for every real $b.$

• I got your argument. But there is something wrong in your last line. Because we have to prove $f$ is continuous whether it is given that both sets $\{x:f(x)<a\}$ and $\{x:f(x)>a\}$ are open. – Empty Jun 27 '17 at 16:04
• The question was "But how can I write $\{x:f(x)>a\},\{x:f(x)<b\}$ in terms of $c_n,d_n$??" I answered that and more. Rather than saying my last line is wrong, which is false, you could have asked a question. – zhw. Jun 27 '17 at 16:16
Can you write $\{x:f(x)<a\}$ as a countable union of open sets, where $a\in\mathbb{R}$ $($not just $\mathbb{Q})$?