# What functions are equal to a measurable function except on a set of measure epsilon?

Lusin's theorem states that if $$f:[a,b]\rightarrow\mathbb{R}$$ is a Lebesgue measurable function, then for any $$\epsilon>0$$ there exists a compact subset $$E$$ of $$[a,b]$$ whose complement is of Lebesgue measure $$\epsilon$$ and a function $$g$$ continuous relative to $$E$$ such that $$f=g$$ on $$E$$.

My question is, what if something weaker is true? What if $$f:[a,b]\rightarrow\mathbb{R}$$ is a function such that for any $$\epsilon>0$$ there exists a compact subset $$E$$ of $$[a,b]$$ whose complement is of Lebesgue measure $$\epsilon$$ and a function $$g$$ Lebesgue measurable on $$E$$ such that $$f=g$$ on $$E$$? Then what properties does $$f$$ have to satisfy?

Does $$f$$ have to be Lebesgue measurable, or what?

Yes, $$f$$ does have to be Lebesgue measurable. Specifically, let $$E_n, g_n$$ be the corresponding compact set and measurable function for $$\epsilon={1\over n}$$, and let $$F=[a,b]\setminus \bigcup_{n\in\mathbb{N}} E_n$$ (note that $$F$$ is null). Now fix $$c\in\mathbb{R}$$; we want to show that $$f^{-1}((-\infty,c))$$ is measurable. Let $$A_n=E_n\cap g_n^{-1}((-\infty,c)).$$ Each $$A_n$$ is measurable, and we have $$\bigcup_{n\in\mathbb{N}} A_n\subseteq f^{-1}((-\infty,c))\subseteq F\cup\bigcup_{n\in\mathbb{N}} A_n.$$ This traps $$f^{-1}((-\infty,c))$$ between two measurable sets whose difference is null, and so $$f^{-1}((-\infty,c))$$ is measurable. So $$f$$ is a measurable function.
Suppose we have a function $$f:D\rightarrow \mathbb{R}$$, a sequence of sets $$E_n\subseteq D$$, a sequence of functions $$g_n:D\rightarrow\mathbb{R}$$, and a family of sets of reals $$\mathcal{A}\subseteq\mathcal{P}(\mathbb{R})$$ such that: $$(i)$$ each $$E_n$$ is measurable, $$(ii)$$ $$m(D\setminus E_n)\rightarrow 0$$ as $$n\rightarrow\infty$$, $$(iii)$$ $$f=g_n$$ on $$E_n$$, and $$(iv)$$ $$g_n^{-1}(A)$$ is measurable for each $$A\in\mathcal{A}$$. Then $$f^{-1}(A)$$ is measurable for each $$A\in\mathcal{A}$$.
(Note that $$(i)$$ and $$(ii)$$ imply that $$D$$ is measurable.) In fact we can really go more general, but this seems like a good stopping point.