# Part of Fubini's Theorem with almost everywhere

Here is the statement: ($\bf{Tonelli}$) If $f\in L^+(X,Y)$, then $\displaystyle g:x\mapsto\int_Yf_xd\nu$ is $\mathcal{M}$-measurable,\ $\displaystyle h:y\mapsto \int_Xf^yd\mu$ is $\mathcal{N}$-measurable (so $g\in L^+(X)$ and $h\in L^+(Y)$). And $$\displaystyle \int_{X\times Y}fd\mu \times\nu=\int_Xgd\mu=\int_Yhd\nu.$$ That is, $$\displaystyle \int_{X\times Y}fd\mu \times\nu=\int_X\left(\int_Yf_xd\nu\right)d\mu(x)=\int_Y\left(\int_Xf^yd\mu\right)d\nu(y)$$

($\bf{Fubini}$) If $f\in L^1(X\times Y)$, then $f_x\in L^1(Y,\nu)$ for a.e. $x\in X$ and $f^y\in L^1(X,\mu)$ for a.e. $y\in Y$. The a.e. defined functions $g$ and $h$ above are $\mathcal{M}$-measurable and $\mathcal{N}$-measurable respectively and the conclusion from above holds.

($\bf{Fubini}$) Since $f\in L^1(X\times Y)$, then $|f|\in L^+$. That is $(\int_{X\times Y})|f|<\infty$. Then $\Rightarrow$ $\displaystyle\int_{X\times Y}|f|d\mu \times\nu=\int_Y\left(\int_X|f^y|d\mu\right)d\nu=\int_X\left(\int_Y|f_x|d\nu\right)d\mu$ $\Rightarrow \displaystyle \int_X|f^y|d\mu<\infty$ a.e. $y$ and $\displaystyle \int_Y|f_x|d\nu<\infty$ a.e. $x$. $\Rightarrow f^y\in L^1(\mu)$ a.e. $y$ and $f_x\in L^1(\nu)$ a.e. $x$. Let $f=f^+-f^-$, then $f_x=(f_x)^+-(f_x)^-=(f^+)_x-(f^-)_x$. So \begin{eqnarray*} \int_{X\times Y}f&=&\int_{X\times Y}f^+-\int_{X\times Y}f^-\\ &=&\int_X\left[\int_Y(f^+)_x\right]-\int_X\left[\int_Y(f^-)_x\right]\\ &=&\int_X\left[\int_Y(f^+)_x-(f_x)^-\right]\\ &=&\int_X\int_Yf_x. \end{eqnarray*} Similar for $f^y$.

My question is about the a.e. part of this proof. I'm not sure exactly why line 2 implies the a.e. conclusion. Should we not show this rigorously or is there a way of looking at these types of a.e. statements and seeing it automatically? Thank you!

Here is where the a.e. is coming from. Suppose we have a measurable function $g$, and we know that $$\int |g|\ d\mu<\infty.$$ Then it is intuitively clear that $|g|<\infty$, because integrating $\infty$s would give you $\infty$. However, we have to hedge our statement because integration w.r.t. a measure "forgets" about null sets. Therefore all we can say with certainty is that $|g|<\infty$ $\mu$-almost everywhere.
It's trivial to come up with counterexamples, for example: $$g(x)=\begin{cases} \infty & x=0\\ 0 & x\not=0 \end{cases}$$ Then $\int_{\mathbb{R}} g(x)\ dx=0$ (where $dx$ denotes Lebesgue measure), however $g$ takes on the value $\infty$.
In line 2 of your proof, the idea I've described happens twice, with different $g$ functions. First it happens with $g(y)=\int_X |f^y|\ d\mu$, then immediately afterwards we fix $x$ and apply the argument to $g(y)=f_x(y)$.
I think that follows from $\int_{X×Y}|f|<\infty$.