Positive integral everywhere implies positive function a.e I would like to get feedback on my demonstration of this simple statement :
Let $f$ be an integrable function on the measure space $(X,S,\mu)$.
\begin{align}
\text{If }\int_E f \, d\mu \geq 0\text{ for all }E\in S\text{ then }f \geq 0\text{ a.e.}
\end{align}
I came up with this and I'm not sure about the reasoning ...
Let $D = \{x: f(x)<0\}$ be the set where $f$ is negative. Since $f$ is integrable we have :
$$\int_Df < \int_D 0 = 0$$
But for all $E\in S$ we have $\int_E f\geq 0$. So by taking $E=D$ we have :
$$0 \leq \int_Df < 0. $$ Which is impossible. So the set $D$ must not be measurable.
I would think that I have to find a way to show that $\mu(D) = 0$ to conclude that $f \geq 0$ a.e
Thanks for any help !
 A: I think it much more convincing to note that $\{f < 0\} = \cup_{n=1}^\infty \{f \leq -n^{-1}\}$. Suppose that $\alpha_n = \mu(\{f \leq -n^{-1}\}) > 0$ for some $n \geq 1$; then $$\int_{\{f \leq -n^{-1}\}} f d\mu \leq -n^{-1}\alpha_n < 0,$$
a contradiction to the hypothesis since $f^{-1}(-\infty,-n^{-1})$ is the pre-image of a Borel set, hence measurable. Thus $\alpha_n = 0$ for all $n \geq 1$, and $$\mu(\{f < 0\}) \leq \sum_{n=1}^\infty \alpha_n = 0.$$
A: $D$ is certainly measurable. Just replace your strict inequality with $\leq$, and you are good to go.
A: Hint:
$$
D = \{ x \mid f(x) < 0 \} = f^{-1}([-\infty,0))
$$
Thus what can we say about $D$?
From here consider your hypothesis you should get that either $\mu(D) = 0$ or $f = 0$ a.e., and so the conclusion follows.
Note: If we have $f = 0$ a.e. then we have $\mu(\{x \in D \mid f(x) \neq 0 \}) = 0$ so we must have $\mu(D) = 0$ thus leading to the hypothesis again. Note that $\{x \in D \mid f(x) \neq 0 \} = D$ since $D = \{ x \mid f(x) < 0 \}$.
