Showing that $f = 0 $ a.e. if for any measurable set $E$, $\int_E f = 0$

Solution 1:

Arguing by contradiction definitely works, here's the idea.

Let $\mu(\{ x : f(x) \neq 0 \}) > 0$.

Then we have $\{x : f(x) \neq 0\} = \{x : f(x) > 0\} \cup \{x : f(x) < 0\}$, so we must have one of these two sets have positive measure.

Let's say its the first one (the argument for the second is analogous).

Then $\{x : f(x) > 0\} = \bigcup \{ x : f(x) \geq \frac{1}{n}\} = \bigcup E_n$ so again one of these must have positive measure.

So say $E_k$ has positive measure, then $f$ dominates $\frac{1}{k}$ on $E_k$ so $$\int_{E_k} f \geq \int_{E_k} \frac{1}{k} = \mu(E_k)\frac{1}{k} > 0.$$ So we have a contradiction.

EDIT: also, to comment on your proof: as you see here we don't need to deal with whether or not $A$ is measurable, it definitely is. And also, for step $4$ of your proof $\mu(A) > 0$ does not imply that $\int_A f \neq 0$ for example if $f = 1_{(0,1)} - 1_{(-1,0)}$

Solution 2:

The set $\{x:f(x)\neq 0\}$ is the same as $f^{-1}\big((-\infty,0)\big)\cup f^{-1}\big((0,\infty)\big)$ and therefore measurable. So the issue in 5. never occurs.

And I think you should be more explicit in step 4.