Measurable Functions as a Limit of Continuous Functions UPDATE: I added an answer based off the hints provided by Robert Israel.  It may, however, need some adjustment.
I'm trying to solve #18 (pg. 42) from Stein and Sharkarchi's analysis text.
(Before reading, I added the if part (<=) to the question since it didn't seem like much extra work to prove the statements were equivalent).
Problem Statement -- A function is measurable if and only if it is the a.e. limit of continuous functions.
My proof: Assume $\{f_{n}\}\to f\;a.e.\;x$ is a sequence of continuos functions.  Then by property 2, each $f_{n}$ is measurable, and by property 4, their $a.e.$ limit is measurable.  Thus, $f$ is measurable.  Now suppose $f$ is measurable, and further assume $f$ is defined on a set $A\subset\mathbb{R}^{d}$ of finite measure and is infinite only on a set of measure zero.  Let $B\subset A$ be the set where $f$ is finite so that $m(A-B)\leq\epsilon\;\forall\epsilon>0$.  Then Lusin's Theorem guarantees the existence of a compact set $C\subset B$ where $m(B-C)\leq\epsilon\;\forall\epsilon>0$ and $f_{C}$ uniformly continuous.  An application of the Tietze Extension Theorem allows us to construct a new function $F$ such that $F = f_{C}$ on $C$ and is continuous on all of $B$.  Define a sequence of functions on $B$ by $f_{n} = F\;\forall\;n=1,2\ldots$  Then $\{f_{n}\}$ is (trivially) a sequence of continuous functions which uniformly converges to $F$ on $B$ (to obtain a non-trivial sequence of continuous functions, one could apply the generalized Stone-Weirstrass Approximation Theorem to $F$).  As consequence, $f_{n}\to f\;a.e.\; x\in B$, since $m(B-C)\leq\epsilon$.  But the union of two sets of measure zero is again a set of measure zero, so in fact $f_{n}\to\; f\; a.e.\; x\in A$
I'm concerned that my proof strategy is off the mark, particularly since I construct a rather trivial sequence of continuous functions.  Secondly, how can I strengthen the theorem by getting rid of the hypotheses of $A$ having finite measure and $f$ being finite? (I managed to make $f$ finite a.e., but I don't think that's strong enough?).
Thanks!
 A: Here is a tentative solution.  Thank you Robert.
Problem Statement: A function is measurable if and only if it is the a.e. limit of continuous functions.
Proof: The reverse direction is trivial (see original post).
To prove the converse, we begin with proving a sequence of weaker statements which lead to the conclusion (since we want to apply certain theorems which require stronger hypotheses on $f$, and also because it significantly simplifies the notational mess that would occur if we had to deal with all exceptional cases at once).  First, suppose $f$ is measurable, $f$ is defined on a set $A\subset\mathbb{R}^{d}$ of finite measure, and $f$ is finite on $A$.  Then Lusin's Theorem guarantees us the existence of a compact $B\subset A$ where $m(A-B)\leq\epsilon$ for all $\epsilon>0$ and $f_{B}$ is uniformly continuous ($f_{B}$ is the "restriction" of $f$ to $B$; it is not defined on $A$!).  An application of the Tietze Extension Theorem allows us to construct a new function $F$ such that $F$ is continuous on all of $A$ and $F=f_{B}$ on $B\subset A$ ($F$ is the continuous extension of $f_{B}$ from the subset $B$ to $A$).  There are now many ways to construct a sequence of continuous functions.  One trivial example is $\{f_{n}\}_{n=1}^{\infty}$ where $f_{n}=F\;\forall\;n=1,2,3\ldots$.  A less trivial one comes from an application of the Stone-Weierstrass Approximation Theorem which guarantees the existence of a sequence of continuous polynomials which converge uniformly to $F$ on any compact set (take the closure of $A$ if necessary).  In any case, we have a sequence of continuous functions $\{f_{n}\}_{n=1}^{\infty}$ where $f_{n}\to F$ on $A$.  And since $F=f_{B}$ on $B$ is equivalent to $F=f$ on $B$, we have that $f_{n}\to f\;a.e.\;x\in A$ since $m(A-B)\leq\epsilon$.
Now weaken the hypotheses slightly by allowing $f$ to be infinite on a set of measure zero.  Then we can let $B\subset A$ be the set on which $f$ is finite, where $m(A-B)=0$.  Then from the above proof, we see there is a sequence of continuous functions $\{f_{n}\}_{n=1}^{\infty}$ which converges to $f\;a.e.$ on $B$.  Let $C\subset B$ be the subset on which the convergence occurs.  Then $f_{n}\to f$ on $(A-D)$ where $D=(B-C)\cup(A-B)$ is the union of two sets of measure zero.  Hence, $f_{n}\to f\;a.e.\;x\in A$ since $D$ being the union of two sets of measure zero is again a set of measure zero.
Weakening the hypotheses further, we now allow the possibility of $E$ having non-finite measure, in particular, $E$ can be unbounded.  Then $A=\bigcup_{n=1}^{\infty}A_{n}$ where $A_{n}=A\cap B_{n}$ and $B_{n}$ is a ball of radius $n$ about the origin.  Since $\{B_{n}\}_{n=1}^{\infty}\nearrow\mathbb{R}^{d}$, for any subset of $A$ you desire $a.e.$ convergence, there exists an $N$ such that an application of the above proofs yield the desired result on $A_{N}$, and letting $N\to\infty$ gives the required conclusion on all of $A$.
Finally, we weaken the hypotheses to the original statement.  In particular, we now allow $f$ to be infinite on a set of positive measure.  To prove the same result holds, consider "cutoff" functions $g_{n} = f$ on the set where $f$ is finite, and $g_{n}=n$ on the set where $f$ is infinite.  Then each $g_{n}$ is measurable, and so the above proofs apply to $g_{n}$ for all $n=1,2,\ldots$  Evidently $g_{n}\to f$ as $n\to\infty$, and so the sequences of continuous functions converging $a.e.$ to each $g_{n}$, also converge to $f$ at points where $f$ is finite, and as $n\to\infty$, to arbitrarily large values at points where $f$ is infinite.  We therefore conclude the theorem holds when $f$ is infinite on sets of positive measure, thus completing the proof. (Note, in the final two cases, the index $n$ has nothing to do with the index on sequences of functions; it in fact indexes a collection of sequences of functions).  QED
NOTE: I'm a little unsure about the final two cases; I was trying to apply Robert's hints, but I think I'm not being technical enough to offer a rigorous proof.  Modifications are welcomed.
A: I'm not sure if this solution works, but if it does, it seems much simpler than the other one given here:) Maybe we can attack this problem by considering the following two cases.
Let $f$ be a measurable function defined over a measurable set $E$.
i)$f:E\to\mathbb{R}$ measurable.
For each $n\in\mathbb{N}^+$, define $B_n$ to be the closed ball centered at the origin with radius $n$.
$E\cap B_n$ is measurable and of finite measure.
By Lusin's theorem, there exists $F_n$ closed with $F_n\subset E\cap B_n$, $m(E\cap B_n-F_n)<2^{-n}$ and $f$ continuous when restricted to $F_n$.
By Tietze extension theorem, there exists continuous $f_n:E\to\mathbb{R}$ with $f_n = f$ when restricted to $F_n$.
If sequence $f_n$ does not converge to $f$ at $x\in E$, then $x\in E-F_n$ for infinitely many $n$.
$E-F_n \subset (E\cap B_n-F_n)\cup B_n^c$.
But $x\in B_n^c$ for only finitely many $n$.
Thus, $x\in E\cap B_n-F_n$ for infinitely many $n$.
By Borel-Cantelli theorem, since $\sum_{n=1}^{\infty}m(E\cap B_n-F_n)<\infty$, $m(\limsup_{n\to\infty}E\cap B_n-F_n) = 0$.
Thus, $m(x\in E:f_n\text{ does not converges to }f\text{ at }x) = 0$ and $f_n\to f$ almost everywhere.
Indeed, when applying Tietze extension theorem above, we can take $f_n$ such that $\sup\{|f_n(x)|:x\in E\} = \sup\{|f(x)|:x\in F_n\}\leq\sup\{|f(x)|:x\in E\}$ for all $n$.
Denote by $\overline{\mathbb{R}}$ the extended real line with the standard topology.
ii)$f:E\to\overline{\mathbb{R}}$ measurable.
Denote a homeomorphism from $[-1,1]$ to $\overline{\mathbb{R}}$ by $h$(for example, $h(x) = \tan(x\pi/2)$).
Easy to see $(h^{-1}\circ f):E\to[-1,1]$ is measurable.
From the first case, there exists sequence $g_n:E\to\mathbb{R}$ continuous with $g_n\to (h^{-1}\circ f)$ a.e. and $\sup\{|g_n(x)|:x\in E\}\leq\sup\{|(h^{-1}\circ f)(x)|:x\in E\}\leq 1$.
We conclude that $h\circ g_n$ is a sequence of continuous functions from $E$ to $\overline{\mathbb{R}}$ and $(h\circ g_n)\to f$ a.e..
