Integral vanishes on all intervals implies the function is a.e. zero I am having trouble with the following problem: 

$f:\mathbb{R}\to \mathbb{R}$ is a measurable function such that for all $a$:
  $$\int_{[0,a]}f\,dm=0.$$
  Prove that $f=0$ for $m$ almost every $x$ (here $m$ is the Lebesgue measure). 

I have no problem proving this for $f$ non-negative, or under the assumption that $f$ is integrable. But the question only assumes that $f$ is measurable and no more.
My idea was the usual thing; we look at the set of points where $f$ is positive and negative and assume one of these has measure greater than zero. Then I wanted to estimate one of these by an open set, look at the integral on the open set and show that it had to be greater than zero, a contradiction. But a key part of this attack is the assumption of the absolute continuity of the integral, which only holds in the case where $f$ is integrable.
Alternatively, if it were integrable one could simply estimate $f$ by a continuous function, where the result is quite obvious.
Ultimately we are going to show that $f$ is integrable, but it is not clear to me how to show this before showing it is zero a.e. So there must be a simpler way. Does anyone have suggestions?
 A: Dynkin's $\pi-\lambda$ System theorem, as a strategic approach, works perfectly to conclude that the problem is true for all measurable sets !
Let $\mathcal{A}=$"set of intervals" which is a $\pi$-system and $\mathcal{L}=\{A\in\mathcal{F};\;\int_A f=0\}$ which is a $\lambda$-system. Hence,
$$\mathcal{B}=\sigma(\mathcal{A})\subseteq\mathcal{L}$$
It means for each Borel-set $B$ : $\displaystyle \int_B f = 0$
Now use this fact that any measurable set differs from a Borel-measurable set by a Zero-set.

To finish the proof, see : Showing that $f = 0 $ a.e. if for any measurable set $E$, $\int_E f = 0$
A: The function $f$ must be integrable (one of $\int f^+$ or $\int f^-$ is finite) in order for the symbol $\int f$ to be defined. So, I'll assume this is the case. In fact, then, since $\int_0^a f$ exists and is finite for any $a$, it follows that $\int_c^d |f|<\infty$ for any numbers $c$, $d$.
We show $f$ is almost everywhere
 $0$ on any interval $[c,d]$; this will imply the desired result.  
Suppose $f>0$ on the set of positive measure $E\subset[c,d]$. Choose a closed subset $F$ of $E$ with positive measure. We then have $\int_F f>0$. Now let $U=[c,d]\setminus F$. As $U$ is open, we may write $U$ as a disjoint union of open intervals: $U=\bigcup_{k=1}^\infty (a_k,b_k)$. 
Now, since $\int_c^d |f|<\infty$
$$
0=\int_{[c,d]}f=\sum_{k=1}^\infty\int_{a_k}^{b_k}f+\int_F f.
$$
Since $\int_F f>0$, it follows that $\sum\limits_{k=1}^\infty\int_{a_k}^{b_k}f$ is negative. But then $\int_{a_n}^{b_n} f$ must be negative for some $n$.  However, this proves untenable upon observing that
$$
\int_{a_n}^{b_n} f =\int_0^{b_n} f - \int_0^{a_n} f =0.
$$
Similarly, one can show $f$ cannot be negative on a set of positive measure.
A: Any measurable function is uniformly approximated by continuous function on $(a, b)$. given statement is true for any continuous function and hence it is true for uniform limit of continuous functions, that is for measurable function
