Is $f$ non-negative a.e. if its primitive is non-decreasing? Let $f:[a,b]\to\mathbb{R}$ be Lebesgue integrable.
Clearly, if $f$ is non-negative then
$$
g:[a,b]\ni x\mapsto\int_a^x f(t)\,\mathrm{d}t\in\mathbb{R}
$$
is non-decreasing since for $x<y$ it holds
$$
g(y)-g(x)
=\int_a^y f(t)\,\mathrm{d}t-\int_a^x f(t)\,\mathrm{d}t
=\int_x^y f(t)\,\mathrm{d}t\ge 0\text{.}
$$
How can I show that $f$ is non-negative almost everywhere if $g$ is non-decreasing?
I would suppose that $f$ is negative on a set $A\subseteq[a,b]$ of positive measure. Then there exists a compact set $B\subseteq A$ of positive measure and it holds
$$
\int_B f(t)\,\mathrm{d}x<0\text{.}
$$
Does $B$ contain a non-empty interval?
 A: I would use the monotone class theorem.  Assume without loss of generality that $f$ is Borel measurable (since there is a Borel measurable function $\tilde{f}$ with $f = \tilde{f}$ a.e.).
Let $\mathcal{M}$ be the collection of all Borel subsets $E \subset [a,b]$ for which $\int_E f \ge 0$.  Then $\mathcal{M}$ is a monotone class (use the dominated convergence theorem).  Let $\mathcal{A}$ be the collection of all finite unions of half-open intervals $[c,d)$.  Then $\mathcal{A}$ is an algebra, $\mathcal{A} \subset \mathcal{M}$, and $\mathcal{A}$ generates the Borel $\sigma$-algebra.  By the monotone class theorem, $\mathcal{M}$ equals the Borel $\sigma$-algebra.  In particular, $\{f < 0\} \in \mathcal{M}$, from which it follows that $f \ge 0$ a.e.
See also this related question.
A: Inspired by Jonas' answer to my related question


*

*Is $f$ non-decreasing a.e. if its primitive is convex?
I did some research and can now come up with an alternative solution.
In the book The Integrals of Lebesgue, Denjoy, Perron, and Henstock by Russell A. Gordon, it is stated that:

A non-decreasing function $g:[a,b]\to\mathbb{R}$ is differentiable almost everywhere and $g'$ is non-negative where it exists.

Since $f=g'$ almost everywhere, $f$ is non-negative almost everywhere.
