Lebesgue measurable function is a limit of continuous functions almost everywhere Show that for a Lebesgue measurable function $f\colon R^n\rightarrow R$, there is a sequence of continuous function $\{f_i\}$ that $f=\lim_{i\rightarrow\infty}f_i$ almost everywhere.
What about also prove the other side? i.e. if $f=\lim_{i\rightarrow\infty}f_i$ almost everywhere then $f$ is Lebesgue measurable.
A similar question can be found here. But it doesn't show how actually is this question proved. Is every Lebesgue measurable function on $\mathbb{R}$ the pointwise limit of continuous functions?
 A: In fact the similar question you posted answers your question.
The only thing you need is that  Luzin's Theorem is true for the whole space,not only for sets if finite measure.
Lets prove this.

We have that $\Bbb{R}^n=A_1 \cup \bigcup_{n=1}^{\infty}A_n$ where $A_0=\{x:|x|<1\}$ and $A_n=\{x:n \leq |x|<n+1\}$
Let $\epsilon>0$. Then exists a closed $F_n \subseteq A_n$ and $g_n$ continuous on $F_n$ such that $m(A_n \setminus F_n)<\frac{\epsilon}{2^{n+1}}$ and $g_n=f$ on $F_n$
Define $F=\bigcup_{n=0}^{\infty}F_n$ and $g=\sum_{n=0}^{\infty}g_n1_{F_n}$
$g$ is continuous on $F$(exercise)
$F$ is closed (exercise)
Since $F$ is closed we can extend $g$ to a continuous $G$ on the whole space by Tietze's theorem and $G=f$ on $F$ and $m(\{G \neq f\}) \leq m(\Bbb{R}\setminus F)<\epsilon$

Now $\forall n \in \Bbb{N}$ exists $G_n$ continuous on $\Bbb{R}^n$ such that $m(\{G_n \neq f\})< \frac{1}{2^n}$
By Borel-Cantelli we have that $m(\bigcap_{n=1}^{\infty}\bigcup_{k=n}^{\infty}\{G_k \neq f\})=0$
Thus for almost every $x$ we have that exists $m \in \Bbb{N}$ such that $G_n(x)=f(x),\forall n \geq m$
So you have the conclusion.
For the other part,note that every continuous function is measurable.
Thus $\limsup_nf_n$ is measurable so $f=\limsup_n f_n$ is measurable.
A: I'll try to give a solution based on the relevant exercises in Tao's "An Introduction to Measure Theory".
Exercise $1.3.24$: Show that a function $f: \mathbb{R^d} \to \mathbb{C}$ is measurable if and only if it is the pointwise almost everywhere limit of continuous functions $f_n: \mathbb{R^d} \to \mathbb{C}$.
proof: If $f: \mathbb{R^d} \to \mathbb{C}$ is measurable. Let $\epsilon > 0$.By exercise $1.3.25$, $\forall n \geq 1$, there is a measurable set $E_n \subset \mathbb{R^d}$ of measure at most $\frac{1}{2^{n+1}}$ s.t the function $f \cdot 1_{B(0,n)}$ is locally bounded outside of $E_n$. In particular, this implies that $\exists M_n < \infty$ s.t $|f(x) \cdot 1_B(0,n)(x)| \leq M_n$ on $B(0,n)\setminus E_n$. Then since $\int_\mathbb{R^d} |f \cdot 1_{B(0,n) \setminus E_n}| \leq  \int_\mathbb{R^d} M_n \cdot 1_{B(0,n) \setminus E_n} < \infty$, the function $f \cdot 1_{B(0,n) \setminus E_n}: \mathbb{R^d} \to \mathbb{C}$ is absolutely integrable. By Theorem $1.3.20$, there exists a continuous, compactly supported function $f_n$ s.t $||f \cdot 1_{B(0,n) \setminus E_n} - f_n||_L{^{1}}(\mathbb{R^d}) \leq \frac{1}{n \cdot 2^{n+1}}.$ WLOG, we assume that $f_n$ is supported on $B(0,n) \setminus E_n$. By Markov's inequality and sub-additivity of the lebesgue measure, we have that: $m(\{x \in B(0,n): |f(x) - f_n(x)| \geq 1/n\}) = m(\{x \in \mathbb{R^d}: |f(x) \cdot 1_{B(0,n)}(x) - f_n(x)| \geq 1/n \}) = m(\{x \in \mathbb{R^d}: |f(x) \cdot 1_{B(0,n) \setminus E_n}(x) - f_n(x)| \geq 1/n \} \cup \{x \in \mathbb{R^d}: |f(x) \cdot 1_{E_n \cap B(0,n)}(x)| \geq 1/n \}) \leq \frac{n}{n \cdot 2^{n+1}} + \frac{1}{2^{n+1}} = 1/2^n.$
Now, we have shown that for every $n \geq 1$, there exists a continuous function $f_n: \mathbb{R^d} \to \mathbb{C}$ for which the set $\{x \in B(0,n): |f(x) - f_n(x)| \geq 1/n\}$ has measure at most $1/2^n$. Let $A$ be the set on which $f_n \not\to f$ pointwise. Then $A = \cup_{m=1}^{\infty}\cap_{n=1}^{\infty}E_{n,m}$, where $E_{n,m} = \{x \in \mathbb{R^d}: |f(x) - f_n(x)| \geq 1/m \}$. Note that for any $m \geq 1$,   $\cap_{n=1}^{\infty}E_{n,m} \subset \{x \in B(0,n): |f(x) - f_n(x)| \geq 1/n \}$ for sufficiently large n and all $n' \geq n$, and thus $m(\cap_{n=1}^{\infty}E_{n,m}) \leq 1/2^n$ can be made arbitrarily small by sending $n \to \infty$, and we have $m(A) = 0$ as desired.
Conversely, if $f$ is the pointwise almost everywhere limit of continuous functions $f_n: \mathbb{R^d} \to \mathbb{C}$. Then $f$ is measurable by (i) and (iv) of exercise $1.3.8$.
