If $\int_a^b g(x)dx = 0$, then $g(x) = 0$ for a.e. $x$ Let $g\in L^2(\mathbb{R})$. Prove that if for $\forall a,b\in\mathbb{R}$ s.t. $a<b$, $\int_a^b g(x)dx = 0$, then $g = 0$ for a.e. $x$.
I want to prove by contradiction. Suppose $g > 0$ on a set of positive measure, say $E$, then $\exists \epsilon >0$ s.t. $g(x) > \epsilon$ for $\forall x\in E$. 
Take an open set $O \supseteq E$ s.t. $m(O) < m(E) + \delta$ for some $\delta > 0$, and $m$ is the Lebesgue measure. And $O = \cup_{n\in \mathbb{N}} (a_n,b_n)$(union of disjoint open intervals), as O is open.
Then $\int_O g(x)dx = \sum_n \int_{a_n}^{b_n} g(x)dx = 0$, but $$\int_O g(x)dx = \int_{O-E} g(x)dx + \int_E g(x)dx > \int_{O-E} g(x)dx + \epsilon m(E)$$
I want make the last term postive so that I can derive a contradiction. But I don't know how to control $g$ on $O$-$E$. Can someone help me with this? Or is there a better way to prove the statement?
 A: Pick $a<b$, then $g \in L^2[a,b] \subset L^1[a,b] $.
Then $\phi(t) = \int_{a}^t g(x) dx $, then the Lebesgue differentiation theorem tells us that $\phi'(t) = g(t)$ for ae. $x$. Since $\phi' = 0$ we see that $g = 0$ ae. $x \in [a,b]$. Since $a,b$ are arbitrary, we have $g=0$ ae.
A: $(|\int_{O-E} g(x)dx|)^{2} \leq (\int_{O-E} |g(x)|^{2}dx) (m(O-E)) < \delta ||g||_2^{2}$ by Holder's inequality.
A: Instead of doing what you did, try to use stronger mechinary: Let $M>0$ be fixed and 
$$ E = \{x : x\in [-M, M] \text{ and } g(x)>0\}.$$
There is a sequence of open sets 
$$\Omega_1 \supset \Omega_2 \supset \cdots \supset \Omega _n \cdots$$ containing $g$ so that $\cap \Omega_n = E\cup C$, where $C$ has measure zero. Now $f_n = \chi_{\Omega_n}\cdot g$ converges pointwisely a.e. to $\chi_E \cdot g$ and $|f_n|\le |g|$, which is in $L^1 ([-M,M])$. Thus the Lebesgue dominated convergence theorem states that 
$$0=\lim_{n\to\infty} \int_{-M}^M f_n dx = \int_{-M}^M  g\chi_E dx = \int_E g dx.$$
So $E$ has measure zero. Since $M$ is arbitrary, 
$$\{ x \in \mathbb R : g(x) >0\}$$
has measure zero and thus $g$ is zero a.e..
