I'm working on the problem linked here: Measure Theory - Folland - Problem 2.7 For completeness, I restate it here:
Suppose that for each $\alpha \in \mathbb{R}$ we are given a set $E_{\alpha} \in \mathcal{M}$ such that $E_{\alpha} \subset E_{\beta}$ whenever $\alpha < \beta$, $\bigcup_{\alpha \in \mathbb{R}}E_{\alpha}=X$, and $\bigcap_{\alpha \in \mathbb{R}}E_{\alpha}=\emptyset$. Then there is a measurable function $f: X \rightarrow \mathbb{R}$ such that $f(x) \leq \alpha$ on $E_{\alpha}$ and $f(x) \geq \alpha$ on $E_{\alpha}^C$ for all $\alpha$.
A poster suggests trying: $f(x) = \inf\{q \in \mathbb{Q} | x \in E_q\}$. I'm failing to see how this satisfies $f(x) \leq \alpha$ on $E_{\alpha}$. In fact, I'm having trouble interpreting what $\inf\{q \in \mathbb{Q} | x \in E_q\}$ is. Is this function taking "the interior rational level sets" and finding a minimum of $f(x)$?
Suppose $x \in E_\alpha$. Then $x \in E_\beta$ for all $\beta \in \mathbb{Q}, \beta > \alpha$. Therefore, $f(x) \le \beta$ for all $\beta \in \mathbb{Q}, \beta > \alpha$. Hence, $f(x) \le \alpha$. Now take $x \in E_\alpha^C$. Then $x \in E_\beta$ for all $\beta \in \mathbb{Q}, \beta < \alpha$. So, $f(x) \ge \beta$ for all $\beta \in \mathbb{Q}, \beta < \alpha$ and hence, $f(x) \ge \alpha$. We've shown $f^{-1}([\alpha,\infty)) = E_\alpha^C$ for all $\alpha \in \mathbb{R}$. This shows $f$ is measurable.