Show that there is no continuous function $f:\mathbb R\to\mathbb R$ such that $f=1_{[0,1]}$ a.e. How can I show that there is no continuous function $f:\mathbb R\to\mathbb R$ such that $f=1_{[0,1]}$ a.e. It seems obvious, but I can't prove it. I tried by contradiction, but I can't conclude.
 A: Assume $f(0) \neq 0$. By continuity we find an $h > 0$ such that $f(x) \neq 0$ on the interval $(-h,0)$. The measure of the set, where $f$ and $1_{[0,1]}$ do not coincide is then at least $h$.
If $f(0)=0$, we have $f(0) \neq 1$ and then we can do the same for an interval $(0,h)$, on which $f(x) \neq 1$.
A: We need $f$ to be continuous, right?  And we also need $f$ to equal $\Bbb 1_{[0,1]}$ a.e. (presumably with respect to Lebesgue measure).
Suppose that such an $f$ exists.  What should $f$ equal at the point $x = 0$?  Well, let's show that for any value $f$ takes at $0$, it contradicts our assumption.
First, if $f(0) > 1$, then consider an $\epsilon > 0$ small enough such that $(f(0) - \epsilon, f(0) + \epsilon)$ doesn't contain $1$.  By the continuity of $f$, there is some $\delta > 0$ such that $(-\delta, \delta)$ is mapped into $(f(0) - \epsilon, f(0) + \epsilon)$, and since this second interval doesn't contain $0$ or $1$, then $f$ doesn't equal $\Bbb 1_{[0,1]}$ on the set $(-\delta, \delta)$ which is a set of positive measure.  This contradicts that $f$ equals $\Bbb 1_{[0,1]}$ almost everywhere.
A similar argument works if $f(0) < 0$ and if $0 < f(0) < 1$.
So, we have to worry about if $f(0) = 0$ or $f(0) = 1$ only.
Suppose $f(0) = 1$.  Again, by the continuity of $f$, there is some $\delta > 0$ such that $(-\delta, \delta)$ is mapped into $(1 - \frac{1}{4}, 1 + \frac{1}{4})$.  But then on $(-\delta,0)$, $f$ doesn't equal $\Bbb 1_{[0,1]}$, so they aren't equal on a set of positive measure, which contradicts that they should be equal almost everywhere.
A similar argument works for $f(0) = 0$.
Thus, no continuous function can equal $\Bbb 1_{[0,1]}$ almost everywhere.
A: Suppose that there is a continuous function $f:\mathbb R\longrightarrow \mathbb R$ such that  $f=\boldsymbol  1_{[0,1]}$ a.e.. Then, for
$$U=f^{-1}\Big((-\infty ,0)\cup(0,1)\cup (1,+\infty )\Big)\Big),$$
we have $m(U)=0$, where $m$ is Lebesgue measure.
 Since $f$ is continuous, $U$ is open and thus $U=\emptyset.$ Contradiction !
