Every measurable function is the limit a.e of a sequence of continuous functions 
Problem. Prove that every measurable function is the limit a.e of a sequence of continuous functions



*

*"a.e" mean almost everywhere

*Here, $m$ is the Lebesgue measure
Idea. Let $\psi = \sum_{1}^{n}a_{j}\chi_{R_{j}}$ be a step function where $R_{j}$ are closed rectangles. Each $R_{j} \subset \mathbb{R}^{d}$ is of the form $R_{j} = \prod_{1}^{d}[a_{i},b_{i}]$. For $\chi_{[a_{i},b_{i}]}$ consider
$$g_{[a_{i},b_{i}]}(x) = \begin{cases} 
                         1,& x \in [a_{i},b_{i}]\\
                         0,& x \geq b_{i} + \epsilon\;\mathrm{ou}\;x\leq a_{i} - \epsilon\\
                         \frac{1}{\epsilon}(x - a_{i} + \epsilon), & x \in (a_{i}-\epsilon,a_{i})\\
                         1 - \frac{1}{\epsilon}(x - b_{i}),& x \in (b_{i},b_{i} + \epsilon)
\end{cases}$$
that is continuous and igual to $\chi_{[a_{i},b_{i}]}$ a.e. Thus, for $R_{j}$, $\chi_{R_{j}} = g_{R_{j}}$ a.e. Since $\psi$ is finite linear combination of $n$ characteristics functions defined in rectangles, then $\psi = \sum_{1}^{n}a_{j}g_{R_{j}}$ a.e.
Now, let $f$ be a measurable function. Then there is a sequence of step functions tht converges pointwise to $f$ a.e. Let $g_{k}$ be a continuous function with $\psi_{k} = g_{k}$ a.e. Let $Y$ be a null set such that the sequence of step function doesn't converges to $f$ and $X_{k}$ a set of measure at most $2^{-k}$ such that $\psi_{k} \neq g_{k}$. Thus, if
$$x \in \bigcup_{n=1}^{\infty}\bigcap_{k=n}^{\infty}(X_{k}^{c}\setminus Y)$$
then there is $n$ such that for $k>n$ we have $\psi_{k}(x) = g_{k}(x)$. Therefore, for this $x$, define
$$f(x) = \lim_{k \to \infty}\psi_{k}(x) = \lim_{k \to \infty}g_{k}(x).$$
Now, define
$$Z = \left(\bigcup_{n=1}^{\infty}\bigcap_{k=n}^{\infty}(X_{k}^{c}\setminus Y)\right)^{c} = Y \cup \left(\bigcup_{n=1}^{\infty}\bigcap_{k=n}^{\infty}X_{k}\right)$$
and so,
\begin{eqnarray*}
m(Z) & \leq & m(Y) + m\left(\bigcup_{n=1}^{\infty}\bigcap_{k=n}^{\infty}X_{k}\right)\\
     & \leq & m\left(\bigcup_{n=1}^{\infty}\bigcap_{k=n}^{\infty}X_{k}\right)\\
     & \leq & m\left(\bigcup_{n=k}^{\infty}X_{k}\right)\\
     & \leq & \sum_{k=n}^{\infty}m(X_{k})\\
     & \leq & \sum_{k=n}^{\infty}2^{-k} = 2^{1-n}
\end{eqnarray*}
and when $n \to \infty$, $m(Z) = 0$. For $x \not\in Z$, $g_{n} \to f$ pointwise.

This is the idea that I know to prove it, but I'm trying to get a different proof, a little more intuitive maybe. Somebody knows?
 A: As in the other answer, the $f_n$ can be constructed. Here is a different approach.
Since $\mathbb R^d$ is $\sigma-$ finite and since there is a sequence of simple functions (not necessarily continuous) converging to $f$, it suffices to prove this for $f=\chi_E$, the indicator function of a measurable set $E$ with $\ \lambda (E)<\infty.$ 
Using regularity of the Lebesgue measure, we find compact sets $K_n\subset E$ and open sets $U_n\supseteq E$ such that $\lambda(U_n-E)<1/n$ and $\lambda(E-K_n)<1/n.$ 
Now, $U^c_n$ and $K_n$ are closed and disjoint, so we may apply Urysohn's Lemma, to produce a sequence $(f_n)$ of continuous functions that satisfy $0\le f_n\le 1,\ f_n(K_n)=1$ and $f_n(U_n)=0.$ Then, $|\chi-f_n|=0$ except on $U_n- E$ and $E-K_n$ each of which is aset of maeasure less than $1/n,$ which implies that $f_n\to \chi_E$ except on $\bigcap_n (U_n-E)\cup(\bigcup_n E-K_n)$, which has Lebesgue measure zero. 
A: Actually we can find a sequence of $C^{\infty}$ functions with compact support converging a.e. to $f$. Since $(\tan ^{-1} f) I_{(-n,n)}$ is an inegrable function there exists a  $C^{\infty}$ function $g_n$  with compact support such that $\int |(\tan ^{-1} f) I_{(-n,n)}-g_n|\, dx <\frac 1 n$. [ See Theorem 3.14 in Rudin's RCA].This implies that a subseqeunce of $\{(\tan ^{-1} f) I_{(-n,n)}-g_n\}$ converges almost everywhere. From this the result follows immediately. [Just consider $\tan g_n$ along the subsequence]. 
A: Well, let $f$ be a measurable function, without loss of generality you can consider $f\geq 0$, now you can approximate $f$ by simple functions. Now, between them, in the possible discontinuities, cut an $\epsilon=2^{-k-1}$ (where k is the number of the addens in the simple aproximation) and glue by a line making them continuous. Now, you have to play with the epsilon and you are ready.
