Similar questions are asked in math.SE but what I am especially interested is not asked (as far as I see).
If $\{f_j\}$ is a sequence of $\overline{\mathbb{R}}$-valued measurable functions on $(X,\mathcal{M})$, then $g_1(x) = \sup_j f_j(x)$ (and in fact $g_2(x) = \inf_j f_j(x)$) is measurable.
This is a proposition in Folland, Real Analysis and its proof as follows.
We have $$g_1^{-1}((a,\infty]) = \bigcup_1^{\infty}f_j^{-1}((a,\infty])$$ and $$g_2^{-1}([-\infty,a))=\bigcup_1^{\infty}f_j^{-1}([-\infty,a))$$
so $g_1$ and $g_2$ are measurable.
What I do not understand is, how can we convert the inverse of supremums and infimums to unions of the sets as done in above?
Thanks in advance!