Solution (source code)

= Solution
{c}

We prove the <Doob-Dynkin lemma> here by <simple function> approximation. Choose $C<\infty$ such that $|Z|\leq C$ everywhere, and let
$$
Z_m=2^{-m}\lfloor2^mZ\rfloor.
$$
Each $Z_m$ is a finite-valued $\sigma(X)$-<measurable function> and $Z_m\to Z$ pointwise. Write its level <sets> as $A_{m,j}$, with associated values $z_{m,j}$. By part (i), choose <Borel sets> $D_{m,j}$ with $A_{m,j}=X^{-1}(D_{m,j})$. Define the <Borel measurable functions>
$$
g_m(x)=\sum_jz_{m,j}\mathbf1_{D_{m,j}}(x).
$$
Although the chosen $D_{m,j}$ need not partition all of $\mathbb R$, their <inverse images> do partition $\Omega$, so $g_m(X)=Z_m$ exactly.

Apply <scalar clipping> to each $g_m$ with bounds $[-C-1,C+1]$, preserving this equality, and define $g(x)=\limsup_mg_m(x)$. A bounded <limit superior> of <Borel measurable functions> is a finite <Borel measurable function>. At every $\omega\in\Omega$ the <limit of a sequence> exists and gives
$$
\boxed{g(X(\omega))=\lim_mZ_m(\omega)=Z(\omega).}
$$
Thus the factorization is exact for a bounded, exactly $\sigma(X)$-<measurable function>. If hypotheses are instead given only up to <null sets>, the corresponding conclusion is a factorization holding <almost surely> after choosing a representative.