If $Y$ is measurable with respect to $\sigma (X)$ then there is a measurable function $f$ so $f(X)=Y$ - Stuck in Proof. I have $X$ an $\mathbb{R}^n$ random variable, and $Y$ is $\mathbb{R}$ valued that is measurable with respect to $\sigma (X)$.  I'm trying to follow a proof showing that there is a Borel measurable function $f$ on $\mathbb{R}^n$ such that $Y=f(X)$. 
So where I am at is a sequence of simple random variables $Y_n$ converging up to $Y$, and each $Y_n$ has the function $f_n$ for the above result, and the part I'm stuck at is actually on the convergence of the functions. 
The book States: 
Set $f(x) = \lim \sup_{n\rightarrow \infty} f_n(x)$
and then $Y$ = $\displaystyle \lim_{n\rightarrow \infty} Y_n = \lim_n f_n(X)$.
But $(\displaystyle \lim \sup_{n \rightarrow \infty} f_n)(X) = \lim \sup_n (f_n(X)$,
and since $\lim \sup_{n \rightarrow \infty} f_n(X)$ is Borel measurable, we are done.
I'm very confused by the notation at each step and what exactly is being said.  For instance, I would have began this part of the proof by defining $f(x)=\lim_{n \rightarrow \infty} f_n(x)$, and then say $Y$ = $\displaystyle \lim_{n\rightarrow \infty} Y_n = \lim_n f_n(X)=f(X)$.
Thanks.
 A: Strictly speaking, the problem here is that $X$ might not be surjective, so that convergence of
$$
f_n (X) = Y_n \to Y
$$
does not necessarily imply the convergence of $f_n(z)$ for every $z$ (only those in the range of $X$).
Hence, the lim-sup is used to ensure existence of the limit for every $z$.
But for each $z = X(\omega)$ in the range of $X$, we actually have
$$
f(X(\omega)) = f(z) = \limsup_n f_n(z) = \lim_n f_n (X(\omega)) = \lim_n Y_n (\omega) = Y(\omega),
$$
where the passage from the lim-sup to the limit uses that the limit $\lim_n f_n (X(\omega))$ is known to exist.
A: Here is an alternative proof. The results holds for arbitrary measurable functions $X$.
Suppose that $X:(\Omega,\mathscr{F})\rightarrow(R,\mathscr{R})$ is a measurable function (i.e., $X$ is an $(R,\mathscr{R})$-valued random variable) and that $Y$ is $\sigma(X)$-measurable, where $\sigma(X)$ is de $\sigma$-algebra $\{X^{-1}(B):B\in\mathscr{R}\}$.
First assume that $Y\geq0$. Being $\sigma(X)$ measurable,  the sequence
$$S_0\equiv0,\qquad S_n=2^{-n}\lfloor 2^n Y\rfloor\mathbb{1}_{[0,n)}(Y)+ n\mathbb{1}_{[n,\infty)}(Y)\quad n\geq1$$
defines a
a nondecreasing sequence of $\sigma(X)$-measurable functions such that $S_n(\omega)\xrightarrow{n\rightarrow\infty}Y(\omega)$ for all $\omega\in \Omega$. Notice that $2^n(S_n-S_n)$ is $\sigma(X)$-measurable and takes values on $\{0,1\}$. Thus, $2^n(S_n-S_{n-1})=\mathbb{1}_{B_n}(X)$ for some $B_n\in\mathscr{R}$. Hence
$$Y=\sum^\infty_{n=1}S_n-S_{n-1}=\sum_n2^{-n}\mathbb{1}_{B_n}(X)$$
In other words,
$Y=f(X)$
where $f(x)=\sum^\infty_n 2^{-n}\mathbb{1}_{B_n}(x)$. Since $Y$ is real-valued, $f$ converges in $X(\Omega)$. As a possible extended real-valued function $f$ is $\mathscr{R}/\mathscr{B}(\overline{\mathbb{R}})$-measurable and so, $f$ can be redefined on the set $\{f=\infty\}$ so that $f$ may assume to be in fact $\mathscr{R}/\mathscr{B}(\mathbb{R})$-measurable.
The conclusion follows  expressing $Y=Y_+-Y_-$.
