Proof of $\int_Ef\,dm=\int_Eg\,dm\implies f,\,g$ equal almost everywhere. Consider the following problem, in particular, the second implication:
"Prove that $f$ and $g$ are equal almost everywhere if and only if $\int_Ef\,dm=\int_Eg\,dm$ for every measurable set $E$."
My problem: I've looked at the solution I've been given to the second implication, but I don't see how it actually shows what I'm trying to prove, and I would like help being convinced of it.
Here is an outline of the procedure employed in the solutions.


*

*Start by assuming that $f\neq g$ on a set of positive measure, say $F\subset \mathbb R$. Then, $F=\{x:f(x)\neq g(x)\}$. As far as I can see, this is tantamount to assuming that $f$ is not equal to $g$ almost everywhere.

*Then you consider $F$ as $F=\{x:f(x)\gt g(x)\}\cup\{x:f(x)\lt g(x)\}$, and label each as $F_1$ and $F_2$ respectively. It then follows, since we have assumed $F$ to have positive measure, that either $F_1$ or $F_2$ has positive measure. Without loss of generality, we take $F_1$ to have positive measure.

*This means that $\forall x\in F_1,\,f(x)-g(x)\gt0$. We move then to compute $\int_{F_1}(f-g)dm$. To determine this integral, we use the fact that for a measurable subset $E\subset\mathbb R$ of positive measure and $f\in\mathcal L(\mathbb R^n,m),$ where $f$ is strictly positive on $E$,then $\int_Ef\,dm>0$. We apply this here to see that $\int_{F_1}(f-g)dm>0$, and then, using the properties of the Lebesgue integral, are able to draw that $\int_{F_1}f\,dm\neq\int_{F_1}g\,dm$.
Now I understand all the little facets used throughout the proof, but I just don't see how it shows the second implication of the problem, namely, that if $\int_Ef\,dm=\int_Eg\,dm$ for every measurable set $E$ then $f$ and $g$ are equal almost everywhere, is true? How is this reasoning sufficient to deduce this? Are there any final details that I have missed that might better tie this all together?
 A: Consider that for a statement $a\Rightarrow b$ the contraposition $\neg b\Rightarrow \neg a$ is equivalent. 
In your case 
$$
\int_E f~dm=\int_Eg~dm\Rightarrow f=g~\text{a.e.}
$$
is your statement and the proof shows that the equivalent contrapostion
$$
\text{not} (f=g~\text{a.e.}) \Rightarrow \int_E f~dm\neq \int_Eg~dm
$$
holds.
A: 
Now I understand all the little facets used throughout the proof, but I just don't see how it shows the second implication of the problem, namely, that if ∫Efdm=∫Egdm for every measurable set E then f and g are equal almost everywhere, is true?

The statement you proved is just the contraposition of the statement you originally wanted to prove.
Now I think the proof you are mentioning is quite complicated and fails to really highlight the main phenomenon here, which is that the Lebesgue integral of a strictly positive function on a measurable set of strictly positive measure has to be positive. (Which is mentioned but buried under a heap of details.)
I would prefer to mimic the proof of this last property, which even yields a shorter proof!
Set $P_n = \{ x \mid f(x) \ge g(x) + 1/n \}$ for positive integer $n$. Then at the same time, we have that
$$\int_{P_n} (f -g) = 0 \mbox{ and }\int_{P_n} (f - g)\ge \lambda(P_n)/n $$
which forces $\lambda(P_n)$ to be $0$. We therefore can present the set where $f > g$ as a countable union of measurables sets of measure $0$ and its measure has to be$0$. By a similar argument the set where $f < g$ has also measure $0$. Therefore $f = g$ almost everywhere.
A: Let $(X,\mathscr A,\mu)$ be a $\sigma$- finite measure space, and let $f$ and $g$ be nonnegative measurable functions on $X$ such that $\int_E fd\mu=\int_Egd\mu$ for all measurable subsets $E$ of $X$. Then $f=g$ a.e. $[\mu]$ on $X$.
First assume that $\mu$ is a finite measure. For $n \in \mathbb N\bigcup \{0\}$, let $A_n=\{x\in X:n\leq f(x)<n+1\}$ and $A_\infty=\{x\in X:f(x)=\infty\}$. Then the sets $A_n$ and $A_\infty$ are pairwise disjoint, measurable and $\bigcup_{n=0}^\infty A_n \bigcup A_\infty=X$. Also, note that each $A_n$ as well as $A_\infty$ have finite measure.

Fix $n \in \mathbb N \bigcup\{0\}$. Since $f$ is bounded on $A_n$ and $\mu(A_n)$, $f$ is integrable on $A_n$ and hence $g$ is integrable on $A_n$ as $\int_{A_n} gd\mu=\int_{A_n}fd\mu$. If $E$ is a measurable subset of $A_n$, then $\int_E(f-g)d\mu=\int_Efd\mu-\int_Egd\mu=0$. Therefore $f=g$ a.e. $[\mu]$ on $A_n$. Therefore there is a measurable subset $B_n$ of $A_n$ with $\mu(B_n)=0$ such that $f=g$ on $A_n-B_n$.

Suppose that $f\neq g$ a.e. $[\mu]$ on $A_\infty$. Then there is a measurable subset $B$ of $A_\infty$ with $\mu(B)>0$ such that $f(x)\neq g(x)$ for all $x \in B$. Since $\mu(B)>0$, there is $n\in \mathbb N\bigcup\{0\}$ such that the set $C=\{x\in B:n\leq g(x)<n+1\}$ has positive measure. But then $\int_C gd\mu \leq (n+1)\mu(C)$ whereas $\int_C fd\mu=\infty$. This is not possible. Therefore $f=g$ a.e. $[\mu]$ on $A_\infty$ and hence there is a measurable subset $B_\infty$ of $A_\infty$ such that $\mu(B_\infty)=0$ and $f=g$ on $A_\infty - B_\infty$. Take $B=\bigcup_{n=0}^\infty B_n \bigcup B_\infty$. Then $\mu(B)=0$ and $f=g$ on $X-B$. Thus $f=g$ a.e. $[\mu]$ on $X$.

Now suppose that $\mu$ is $\sigma$- finite. Then there is a sequence $\{X_n\}$ of pairwise disjoint measurable subsets of $X$ such that $\bigcup_n X_n=X$ and $\mu(X_n)<\infty$ for all $n$. It follows from above paragraph that $f=g$ a.e. $[\mu]$ on $X_n$. Therefore there is a measurable subset $Y_n$ of $X_n$ such that $\mu(X_n)=0$ and $f=g$ on $X_n-Y_n$. But then $f=g$ on $X-Y$ and $\mu(Y)=0$, where $Y=\bigcup_nY_n$. Thus $f=g$ a.e. $[\mu]$ on $X$.
A: The proof actually proves that $f$, $g$ are not a.e. equal implies that there exists measurable $E$ s.t. $\int_E f\,dm\neq\int_E g\,dm$.

Then you have to remember some details that can be summarized as "once all input is measurable, everything is measurable". Namely:


*

*In (1), the assumption "$f(x)\neq g(x)$ on a set of positive measure" is the negation of "$f$ and $g$ are equal almost everywhere".

*In (2), both $F_1$ and $F_2$ are measurable (so you can assume things about them, there's nothing missing).

*In (3), we again use that $F_1$ is measurable.


These might be the little pieces you were missing.
A: The proof shows that if it is not true that $f=g,$ $m$-almost everywhere, then the is a particular set $E$ such that $\int_E f\,dm \ne \int_E g\, dm,$ namely either $E=F_1$ or $E=F_2.$
I.e.
\begin{align}
\text{If } & \text{not }\Big( f=g\quad m\text{-almost everywhere} \Big) \\[5pt] \text{then } & \Big( \text{there exists a set } E \text{ such that } m(E)>0 \text{ and } \int_E f\,dm\ne \int_E g\,dm \Big).
\end{align}
The contrapositive of this is:
\begin{align}
\text{If } & \text{not } \Big( \text{there exists a set } E \text{ such that } m(E)>0 \text{ and } \int_E f\,dm\ne \int_E g\,dm \Big) \\[5pt]
\text{then } & \Big( f= g \quad m\text{-almost everywhere} \Big).
\end{align}
Now observe that the following are equivalent:
\begin{align}
& \text{Not }\Big( \text{there exists a set } E \text{ such that } m(E)>0 \text{ and } \int_E f\,dm\ne\int_E g\,dm\Big). \\[5pt]
& \text{For every set } E \text{ for which } m(E)>0, \text{ we have } \int_E f\,dm = \int_E g\, dm.
\end{align}
Thus we have:
\begin{align}
& \text{If for every set } E \text{ for which } m(E)>0, \text{ we have } \int_E f\,dm = \int_E g\, dm, \\[5pt]
& \text{then } f=g\quad m\text{-almost everywhere}.
\end{align}
