*Note: All sets and functions defined below are assumed measurable. $\mu$ denotes the Lebesgue measure.*


Let $D$ be a dense subset of $[0, 1]$, and $f: D \to \mathbb R$ a function. Given $\varepsilon > 0$, say that $g: [0, 1] \to \mathbb R$ is an $\varepsilon$-almost extension of $f$ if


$$\mu(\overline{\{x \in D \, | \, g(x) \neq f(x)\}}) \leq \varepsilon.$$


**Question:** Suppose $f: D \to \mathbb R$ is continuous. Does there exist for every $\varepsilon > 0$, a continuous $\varepsilon$-almost extension of $f$?



Can a function that is continuous on a dense set be almost extended to a continuous function?
Let $A,B$ be disjoint countable dense subsets of $[0,1]$. Let $p:B\rightarrow(0,\infty)$ be a function where $\sum\_{b\in B}p(b)\leq 1$. Define a function $f:A\rightarrow[0,1]$ by letting $f(a)=\sum\_{b\in B,b<a}p(b)$. Then $f$ is a continuous function. Suppose now that $g:[0,1]\rightarrow\mathbb{R}$ is a continuous function. I claim that
$\{a\in A:f(a)\neq g(a)\}$ is dense in $A$ (and hence dense in [0,1]). Suppose to the contrary that $\{a\in A:f(a)\neq g(a)\}$ is not dense in $A$. Then there is an open subset $U\subseteq(0,1)$ where if $a\in A\cap U$, then $f(a)=g(a)$. Now, suppose that
$b\in B\cap U$. Then $g(b)=\lim\_{a\in A,a\rightarrow b}g(a)=\lim\_{a\in A,a\rightarrow b}f(a)$. But this limit does not exist since $\lim\_{a\in A,a\rightarrow b^-}f(a)<\lim\_{a\in A,a\rightarrow b^+}f(a)$ which is our contradiction. Therefore, $\{a\in A:f(a)\neq g(a)\}$ is dense in $A$.


We can get everything to work using Lusin's theorem if we slightly changed the problem by weakening the amount that $f,g$ have to agree with each other by just requiring that $\mu(\{x\in D:f(x)\neq g(x)\})\leq\epsilon$. If $D$ is a subset of $[0,1]$, then whenever $f:D\rightarrow[0,1]$ is continuous, we can extend $f$ to an upper semicontinuous $f\_1:[0,1]\rightarrow[0,1]$, and by Lusin's theorem, for each $\epsilon>0$ there will be a continuous $g:[0,1]\rightarrow[0,1]$ and a compact $E\subseteq[0,1]$ with $\mu([0,1]\setminus E)<\epsilon$ and $g(x)=f\_1(x)$ for $x\in E$; in particular, $g(x)=f(x)$ for $x\in E\cap D$.


