Relation between absolute continuity with respect to lebesgue measure and integral

Let $f:X \to \mathbb{R}$ be a continuous function on a compact metric space $X$. Assume that a Borel probability measure $\mu$ is absolutely continuous with respect to Lebesgue measure $\text{Leb}.$

Is it true that if $f(x)<0$ for $\text{Leb}$ a.e. $x$, then $\int f d\mu<0?$

I think it should be true as $\mu << \text{Leb}$.

Attempt: Assume that $\int fd\mu\geq 0$. Then $f\geq 0$ $\mu$ a.e. $x$. That means $\mu(\{x: f(x)>0\})>0$. That implies $\text{Leb}((\{x: f(x)>0\})>0$ which is not true.


The compactness, metrizability and other conditions are unnecessary. All that is needed is that $f$ is measurable and $\mu\ll\lambda$, where I use $\lambda$ for Lebesgue measure.

$$\lambda\{x\in X:f(x)\ge0\}=0\,\wedge\,\mu\ll\lambda\implies\mu\{x\in X:f(x)\ge0\}=0$$

And immediately we have that, as $X$ is not $\mu$-null:

$$\int_X f\,\mathrm{d}\mu\lt0$$

I'm afraid we do not quite have:

$$\int_X f\,\mathrm{d}\mu\ge0\implies f\ge0\quad\mu\text{ - a.e.}$$

Since a function that is both positive and negative can simply cancel, e.g.

$$\int_{\Bbb R}\frac{\sin x}{x}\,\mathrm{d}x$$

Famously evaluates to $\pi\gt0$, but of course $\frac{\sin(x)}{x}$ is negative on a set of infinite measure.

Otherwise, what you said is fine.