I am reading the proof of the Doob-Dynkin Lemma on wikipedia here:
https://en.wikipedia.org/wiki/Doob%E2%80%93Dynkin_lemma
I will first state the Lemma(with probability notation) and restrict to the case where one of the r.v. are positive. Then I will give the proof that they give. Then I will make a modification of the proof. The question is if the modification is correct.
Lemma:
Let $X$ be a real random variable on the probability space $(\Omega, \mathcal{A},P)$ and let $Y$ be a non-negative random variable on the same probablity space. Assume that $Y$ is $\sigma(X)$ measurable, and that $X(\Omega)\in \mathcal{B}(\mathbb{R})$. Then there exists a Borel-measurable function such that $Y=f(X)$.
Proof
Assume first that $Y(\omega) = \sum\limits_{i=1}^n c_i1_{A_i}(\omega)$ where the $A_is$ are disjoint. Then for each $i$, $A_i$ must be $\sigma(X)$ measurable, so there must exist a Borel set $A_i'$ such that $A_i=X^{-1}(A_i)$. Then we have
$$Y(\omega)=\sum\limits_{i=1}^n c_i1_{A_i}(\omega)=\sum\limits_{i=1}^n c_i1_{X^{-1}(A_i')}(\omega)=\sum\limits_{i=1}^n c_i1_{A_i'}(X(\omega))$$
so we can define $f=\sum\limits_{i=1}^N c_i 1_{A_i}(x)$, this is a Borel-measurable function.
Now let $Y\ge 0 $ not be a simple function. Then we know that there is a sequence of simple random variables $Y_n \uparrow Y$, for each $Y_n$ we have a corresponding simple borel function $f_n$. And we must have that:
$$Y(\omega)=\lim_{n \rightarrow \infty}Y_n(\omega) = \lim_{n \rightarrow \infty}f_n(X(\omega)).$$ This means that if $x \in X(\Omega)$ then $f_n(x)$ converges upwards to a function.
We now define $$f(x)=\lim\limits_{n \rightarrow \infty}f_n(x)1_{X(\Omega)}(x).$$
$f$ is our required function. Here we see why we needed $X(\Omega)$ to be Borel-measurable.
But from what I have read in other books, we should not require that $X(\Omega)$ is Borel-measurable. So I am wondering if I can modify the proof where I don't need that assumption.
Modified proof
Now we do not assume that $X(\Omega)\in \mathcal{B}(\mathbb{R}).$ We instead define
$$f(x) = \sup\limits_{n}\{f_n(x)\}.$$ Since each $f_n$ is Borel-measurable $f$ will be Borel-measurable, however, it may be infinity at some points. But it will be Borel-measurable in the extended sense. So we can define
$$f^*(x)=f(x)\cdot 1_{\{f(x)<\infty\}}(x),$$ this will be a finite Borel-measurable function and we have that $f(X)=Y.$
Does this modified proof hold, or is it a mistake?
$Y(\omega)=\lim Y_n(\omega)=\lim \sup Y_n(\omega)= \lim \sup f_n(X(\omega))=f(X(\omega))$ for all $\omega $ where $f(x):=\lim \sup f_n(x)$ [You can also use $\lim \inf$]. $f$ is an extended real valued measurable function. To get a real valued function $f$ you just have to modify this by taking $f(x):=\lim \sup f_n(x)$ when $\lim \sup f_n(x)$ is finite and $0$ when it is $\infty$.
EDIT: Your modified proof works fine.