Doob–Dynkin lemma proof I have to prove the following lemma:
Let $X:\Omega\to E$ be a r.v., $\sigma(X)$ the $\sigma$-algebra generated from $X$. For every $Y:\Omega\to \mathbf{R}$ ($\sigma(X)$-measurable) it exists $g:E\to \mathbf{R}$ measurable such that $Y=g\circ X $.
The proof I read proves the lemma first for indicator functions, then for simple functions, then for a positive r.v $Y$ considering a sequence $(Y_n)$ of simple functions which converges increasing to $Y$. For each $n$ we could find a function $g_n$ that verifies the lemma. Unfortunately we cannot assume that the sequence $(g_n)$ is increasing but we have:
$$Y=\sup_n(Y_n)=\sup_n(g_n\circ X)=\limsup_n(g_n\circ X)=\limsup_n(g_n)\circ X.$$
At this point, my question is: why have we to pass to limsup? Is it not true that $\sup_n(g_n\circ X)=\sup_n(g_n)\circ X$ and that $\sup_n(g_n)$ is measurable?

Both assertions are true, the first because $\{g_n\}$ is increasing pointwise on the range of $X$. The measurability of $\sup_ng_n$ is a general fact of life for real-valued measurable functions. 
