If $\int_{A}f \ \text{d}\mu=\int_{A}g \ \text{d}\mu$ for every measurable subset $A\subset X$, then $f=g$ almost everywhere? Let $(X,\mu)$ be a measure space. Suppose that $f,g\in L^{1}(X,\mu)$ satisfy $$\int_{A}f \ \text{d}\mu=\int_{A}g \ \text{d}\mu\qquad(*)$$ for every measurable subset $A\subset X$. Can we conclude that $f=g$ almost everywhere? If it is true, how do I prove it? If it is not true, is there an easy counterexample?
Here is what I know:


*

*I know that the conclusion is not true if $(*)$ only holds for $A:=X$, for example,
$\int_{0}^{1}\frac{1}{2} \ \text{d}t=\int_{0}^{1}t \ \text{d}t$.

*My intuition says that is is true. If $f-g\geq0$ and $\int_{X} f \ \text{d}\mu=\int_{X} g \ \text{d}\mu$, then $f=g$ almost everywhere. So I was thinking that we could use the set $A:=\{x\in X:f(x)\geq g(x)\}$. Then $f-g\geq0$ on $A$. But I don't know if $A$ is measurable and if this will even work.


Any suggestions are greatly appreciated!
 A: Yes, your approach is correct. To elaborate, let $h=f-g$. Without loss of generality we can assume that $h$ takes value in $\mathbb{R}\cup\{\infty\}$. Consider the sets $A_n=h^{-1}\Big(\big[\frac{1}{n},\infty\big]\Big)$ and $B_n=h^{-1}\Big(\big[-\infty,-\frac{1}{n}\big]\Big)$ for $n\in\mathbb{N}$. These sets are inverse image of measurable sets, and hence measurable. Now $0=\int_{A_n}h\,d\mu\geq\frac{1}{n}\mu(A_n)$, and hence $\mu(A_n)=0$. Similarly we can show $\mu(B_n)=0$. Hence $\mu(\bigcup_n (A_n \cup B_n))=0$. But $\bigcup_n A_n\cup B_n=h^{-1}\big(\{0\}^c\big)$. Therefore $\mu\Big((h^{-1}\big(\{0\}^c\big)\Big)=0$ and $h$ is zero almost everywhere.
A: Let $h=f-g$, so it is enough to show that $h=0$ almost everywhere.
Suppose not, so there is a small open set $U$ on which $h\neq 0$. Shrink $U$ or replace $h$ with $-h$ to ensure $h>0$ on $U$. Let $M=sup_{x\in U}h(x)$. So
$$V:=\{x\in U:h(x)>\frac{M}2\}=h^{-1}(\frac{M}2,M)$$
is an open set in $X$. So
$$\int_V h(x)dx>\int_V \frac{M}2dx=\frac{M}2\mu (V)>0.$$
But
$$\int_V h(x)dx=\int_V f(x)dx-\int_V g(x)dx=0,$$
which is a contradiction.
A: The measure $\nu$ given by $\nu(A)=\int_Af\,d\mu-\int_Ag\,d\mu$ is absolutely continuous with respect to $\mu$. By the Radon-Nikodym theorem its RN derivative $h$ is unique $\mu$-ae.  On the one hand, $h=f-g$.  And on the other, $\nu$ is just another name for the zero measure, whose RN density wrt $\mu$ is $0$. So $f=g$ $\mu$-ae.
