If $f^{-1}((r,\infty))$ is measurable for all $r$ in $\mathbb{Q}$, prove that $f$ is measurable

Let $f:\mathbb{R}\rightarrow \mathbb{R}$ a function, for which the sets $f^{-1}((r,\infty))$ are measurable for $\forall r \in \mathbb{Q}$. I'm asked to prove that $f$ is measurable.


This is what I've done:

Let's take any $\alpha , \beta \in \mathbb{R}$, being $\alpha < \beta$ . Then, $\exists r \in \mathbb{Q}$ where $\alpha \le r < \beta$. By hypothesis we know that $f^{-1}((r,\infty))=\{x\in \mathbb{R}:f(x)>r\}$ is a measurable set. So, $f^{-1}((\alpha,\infty))=\{x\in \mathbb{R}:f(x)> \alpha \}$ is also going to be measurable (I'm not sure if I can say this last sentence... May I prove it? I don't know how to do it).

So consecuently, as $f^{-1}((\alpha,\infty))$ is a measurable set for $\forall \alpha \in \mathbb{R}$, $f$ is a measurable function.


If $\alpha$ is any real number, you want to show that $f^{-1}(\alpha, \infty)$ is measurable. You know that $f^{-1}(r,\infty)$ is measurable whenever $r$ is rational. So let $r_1 > r_2 > r_3 > \cdots$ be a sequence of rational numbers which converges to $\alpha$. Then clearly the union of the intervals $(r_i,\infty)$ satisfies

$$\bigcup\limits_{i=1}^{\infty} (r_i, \infty) = (\alpha,\infty).$$

And therefore

$$f^{-1}(\alpha,\infty) = f^{-1} \Bigg( \bigcup\limits_{i=1}^{\infty} (r_i, \infty) \Bigg).$$

Finish the proof by using the fact that the inverse image of a union of sets is the union of the inverse images, and that a countable union of measurable sets is measurable.