A question concerning measurable functions I came across this lovely problem in my self-study:
For $(X, \mathcal{M})$ a measurable space, if $f: X \rightarrow \overline{\mathbb{R}}$ and $f^{-1}((r, \infty]) \in \mathcal{M}$ for all $r \in \mathbb{Q}$, then $f$ is measurable.  
I want to tackle this problem by using the following related result:
For $(X, \mathcal{M})$ a measurable space, if $f: X \rightarrow \overline{\mathbb{R}}$ and $f^{-1}(\mathbb{R}) = Y$ then $f$ is measurable $\iff$ $f^{-1}(-\infty) \in \mathcal{M}$, $f^{-1}(\infty) \in \mathcal{M}$, and $f$ is measurable on $Y$.
Using countable intersections and complements, confirming that $f^{-1}(-\infty) \in \mathcal{M}$, $f^{-1}(\infty) \in \mathcal{M}$ is pretty easy. I am not as sure how to verify the last item! However, I think the fact that $\mathbb{Q}$ is dense in $\mathbb{R}$ will be important.
I am interested to see if anyone has any ideas on how to prove this last part, or alternative strategies for proof of the exercise. 
 A: Ok, let's prove that $\forall \ r \in \mathbb{Q}, \ f^{-1}((r, \infty]) \in \mathcal{M}$ is equivalent to any of the following: 


*

*$\forall \ r \in \mathbb{Q}, \ f^{-1}([r, \infty]) \in \mathcal{M}$ 

*$\forall \ r \in \mathbb{Q}, \ f^{-1}([-\infty, r)) \in \mathcal{M}$

*$\forall \ r \in \mathbb{Q}, \ f^{-1}([-\infty, r]) \in \mathcal{M}$


This isn't hard to do: for example let's prove 1. : $$f^{-1}([r, \infty]) = f^{-1} \left(\bigcap_{n \in \mathbb{N}} \left(r- \frac{1}{n}, +\infty \right] \right) = \bigcap_{n \in \mathbb{N}} f^{-1} \left( \left(r- \frac{1}{n}, +\infty \right] \right) $$
which is a countable intersection of measurable sets, and thus is measurable. The other implications can be proven in a similar way, or, for example, by observing that $f^{-1}([-\infty, r]) =  X \setminus f^{-1}((r, \infty])$. 
Now, it can be proved that all open sets of $\mathbb{R}$ can be expressed as countable unions of intervals of three types: $(a,b), (a, +\infty], [- \infty, b)$, with $a, b \in \mathbb{Q}$ - this is where the density of $\mathbb{Q}$ in $\mathbb{R}$ is important. So let $A \subseteq \mathbb{R}$ be an open set, with $A = \bigcup_{n \in \mathbb{N}} I_n$, where the $I_n$'s are intervals of the types described above. Then we have: $$f^{-1}(A) = f^{-1} \left( \bigcup_{n \in \mathbb{N}} I_n \right) = \bigcup_{n \in \mathbb{N}}f^{-1} (I_n)$$
which is a countable union of measurable sets by the above, (in the case $I_n = (a, b)$ write $(a, b) = (a, +\infty) \cap (-\infty, b)$), and we are done.  
As noted in the comments, if you know that $f^{-1}((r, \infty]) \in \mathcal{M}$ for all $r \in \mathbb{R} \Rightarrow \ f$ is measurable , it might be easier to prove the assertion. Not knowing whether you were familiar with this theorem or not, I wrote down a proof which doesn't use it (it is basically a modified version of it). I hope this helps.
