Writing $\{x; (fg)(x)>a\}$ as a countable union of measurable sets for measurable functions $f,g$ I was trying to prove that the product of two measurable functions on the extended real line is measurable and I came across this statement:
\begin{equation*}
\{x : (fg)(x) > a\} = \left(\bigcup_{r \in \mathbb{Q}^+}(\{x : f(x) > r\} \cap \{x : rg(x) > a\})\right)\bigcup\left(\bigcup_{r \in \mathbb{Q}^-}(\{x : f(x) < r\} \cap \{x : rg(x) > a\})\right)
\end{equation*}
I can see that this would prove the result I want, but I really don't see why this set equality holds in the first place. Can anyone shed some light on this, possibly with as much detail as possible. Thanks!
 A: As @user180040 pointed out, the equality does not hold if $f(x)$ or $g(x)$ is zero for some $x$. Therefore, I'll assume in the first part of my answer that $f(x), g(x) \neq 0$ for all $x$. For brevity of notation, set
$$\begin{align*} A &:= \{fg>a\} \\ B &:= \left(\bigcup_{r \in \mathbb{Q}^+}(\{f>r\} \cap \{rg>a\})\right)\cup\left(\bigcup_{r \in \mathbb{Q}^-}(\{f<r\} \cap \{rg>a\})\right). \tag{1} \end{align*}$$
To show $A=B$, we prove $A \subseteq B$ and $B \subseteq A$.


*

*$B \subseteq A$: Let $r \in \mathbb{Q}^+$ and $x \in \{f>r\} \cap \{rg> a\}$. Then it follows that $$a<g(x) r <  g(x) f(x),$$ i.e. $x \in \{fg>a\}$. A similar argumentation applies for $r \in \mathbb{Q}^-$ and $x \in \{f<r\} \cap \{rg>a\}$. Hence, $B \subseteq A$.

*$A \subseteq B$: Let $x$ such that $(fg)(x)>a$ and $f(x) > 0$. Recall that the mapping $$y \mapsto y \cdot g(x)$$ is continuous, and therefore it follows that we can choose $\varepsilon>0$ such that $$y \cdot g(x)>a$$ for all $y \in B(f(x),\varepsilon)$. In particular, since $\mathbb{Q}$ is dense, we can pick $r \in \mathbb{Q}^+$, $0<r<f(x)$. By  the virtue of our choice, $r>f(x)$ and $r g(x)>a$. Consequently, $x \in \{f>r\} \cap \{rg>a\}$. Again, a very similar argumentation applies for $f(x)<0$. This proves $A \subseteq B$.


Finally, let us consider the general case, i.e. if $f(x)$ or $g(x)$ might be zero for some $x$. For $a<0$, we then note that
$$\{x; (fg)(x) >a\} = \{f=0\} \cup \{g=0\} \cup B.$$
In contrast, for $a \geq 0$, we still have
$$\{x; (fg)(x)>a\} = B.$$
Obviously, these equalities show that $f \cdot g$ is measurable if $f$ and $g$ are mesurable.
