Is a measureable function on a polish space an a.s. limit of continuous functions? Let $(E,\mathcal{E},\mathbb{P})$ be a probability space where $E$ is a polish space with Borel sigma algebra $\mathcal{E}$ and let $f:E \rightarrow \mathbb{R}$ be measurable. Can one find $(f_n) \in C(E,\mathbb{R})^\mathbb{N}$ s.t.
$$
f=\lim_{n \rightarrow \infty} f_n \; \text{ a.s.}
$$
holds?
I asked myself this question already many times and I don't know how to use Lusin's theorem since $E$ is not locally compact.
 A: Indeed we can find such $(f_n)$. We generalize the assumption as follows:

Assumption. $X$ is a perfectly normal space1), and $\mu$ is a finite regular measure2) on the Borel $\sigma$-algebra $\mathcal{B}(X)$.

Although this assumption might sound a bit technical, we know that:

*

*Every metrizable space is perfectly normal.


*Every Borel measure on a perfectly normal space is regular. See p. 71 in "Measure Theory" vol. 2, Springer-Verlag, Berlin 2007, by V. I. Bogachev (Corollary 7.1.9).
In particular, the assumption will be satisfied by any Borel probability measure $\mu$ on a metric space $X$. So the above assumption covers a wide range of examples, including OP's.
Now, let $L^0(X)$ be the set of all real-valued Borel-measurable functions, and let $\mathcal{H}$ be the set of all $f \in L^0(X)$ which are $\mu$-a.e. limit of sequence in $C(X,\mathbb{R})$. Then we claim that $\mathcal{H} = L^0(X)$. To this end, we make several observations:


*

*$\mathcal{H}$ is a vector space over $\mathbb{R}$.





*$\mathcal{H}$ is closed under convergence in measure.


Proof. Let $(g_n)$ be a sequence in $\mathcal{H}$ that converges to some $g \in L^0(X)$ in $\mu$-measure. By passing to a subsequence if necessary, we may assume that
$$\mu(\{|g_n - g|>2^{-n-1}\}) < 2^{-n-1}.$$
Now, since each $g_n$ is in $\mathcal{H}$, we can find $f_n \in C(X,\mathbb{R})$ such that
$$\mu(\{|f_n-g_n|>2^{-n-1}\}) < 2^{-n-1}.$$
Using the standard trick, these altogether imply that
$$\mu(\{|f_n - g|>2^{-n}\}) < 2^{-n}.$$
So by the Borel–Cantelli lemma, $\mu(\{|f_n - g|>2^{-n} \text{ i.o.}\}) = 0$ and therefore $f_n \to g$ holds $\mu$-a.s., proving $g \in \mathcal{H}$ as required.



*For any Borel-measurable set $E$, the indicator function $\mathbf{1}_E$ lies in $\mathcal{H}$.


Proof. We claim that, for each Borel-measurable $E \subseteq X$ and $\varepsilon > 0$, we can find a continuous function $f\in C(X,\mathbb{R})$ such that $\mu(\{f \neq \mathbf{1}_E\}) < \varepsilon$. We note that this claim implies $\mathbf{1}_E \in \mathcal{H}$, using a similar technique as in the proof above.
So we turn to the proof of the claim. Using the regularity of $\mu$, choose closed sets $F$ and $K$ such that
\begin{align*}
\begin{array}{cp{2em}c}
F \subseteq E, && \mu(E\setminus F) < \varepsilon/2, \\
K \subseteq X\setminus E, && \mu((X\setminus E)\setminus K) < \varepsilon/2.
\end{array}
\end{align*}
Now by noting that $X$ is perfectly normal, we can choose a continuous function $f : X \to [0, 1]$ such that $f^{-1}(\{1\}) = F$ and $f^{-1}(\{0\}) = K$. It is easy to check that this function satisfies the desired condition.



*Any $f\in L^0(X)$ is the $\mu$-a.e. limit of a sequence of simple functions.


Proof. Consider
$$g_n = \frac{\lfloor 2^n f\rfloor}{2^n} \mathbf{1}_{\{-n \leq f < n\}}.$$
Combining all these observations proves the desired claim.

1) A topological space $X$ is perfectly normal if for every disjoint closed subsets $F_0$ and $F_1$ of $X$, there exists a continuous function $f:X\to[0,1]$ that perfectly separates $F_0$ and $F_1$, in the sense that $f^{-1}(\{0\}) = F_0$ and $f^{-1}(\{1\}) = F_1$.
2) A Borel measure on a topological space $X$ is called regular if for every Borel-measurable $E\subseteq X$ and $\varepsilon > 0$, there exists a closed set $F_{\varepsilon}$ such that $F_{\varepsilon}\subseteq E$ and $\mu(E\setminus F_{\varepsilon})<\varepsilon$.
