$\mathbb{E}(XY) = \mathbb{E}(X) \mathbb{E}(Y)$: where do we use independence property? Suppose both r.v. $X$ and $Y$ are defined on $\left(\Omega, \mathcal{F}, \mathbb{P}\right)$. Furthermore, $X$ and $Y$ are independent, in the sense that $\mathbb{P}\left(X\in B_1 \cap Y\in B_2\right)= \mathbb{P}\left(X\in B_1\right) \mathbb{P}\left(Y \in B_2\right)$. How do we show that $\mathbb{E}\left(XY\right) = \mathbb{E}(X) \mathbb{E}(Y)$?
Ideally I would like to use Fubini and product measure, but I have some confusions. Now, if we consider the product space $\left(\Omega^2, \mathcal{F}^2, \mathbb{P}^2\right)$, and we define a random variable $Z$ on it as $Z\left(\omega_1,\omega_2\right)=X\left(\omega_1\right) Y\left(\omega_2\right)$, we do have
$$\int_{\Omega^2} Z \,d\mathbb{P}^2 = \int_\Omega X \,d\mathbb{P} \int_\Omega Y \,d\mathbb{P}$$
by Tonelli-Fubini (assuming necessary technical assumptions are satisfied). The r.v. $Z$ we just defined is just $XY$.
However here is my confusion: Where did we use the fact that $X$ and $Y$ are independent?
Update: Here is the proof in the book.

 A: Your computation has nothing to do with the formula $\mathbb{E}[XY] = \mathbb{E}X \mathbb{E}Y$. You have to show that
$$ \int_{\Omega} X(\omega)Y(\omega) \, \mathbb{P}(d\omega) = \left( \int_{\Omega} X(\omega) \, \mathbb{P}(d\omega) \right)\left( \int_{\Omega} Y(\omega) \, \mathbb{P}(d\omega) \right), $$
and you will desperately need the independence of $X$ and $Y$. As a proof, you may first consider the case where $X$ and $Y$ are simple, i.e.,
$$ X = \sum_{i=1}^{m} x_i \mathbf{1}_{A_1}, \qquad Y = \sum_{j=1}^{n} y_j \mathbf{1}_{B_j} $$
for some constants $x_i, y_j \in \mathbb{R}$ and events $A_i \in \sigma(X)$ and $B_j \in \sigma(Y)$.

Here is a detail of the proof in the photo. Recall the following basic theorems.
1. Change of variables formula. 

Theorem 1. Suppose that
  
  
*
  
*$(\Omega, \mathcal{F}, \mathbb{P})$ is a probability space, 
  
*$(S, \mathcal{S})$ is a measurable space,
  
*$X : \Omega \to S$ is measurable.
  
  
  Denote by $\mu(E) = \mathbb{P}(\{\omega:X(\omega)\in E\})$ the law of $X$. Then for any measurable map $f : S \to \mathbb{R}$ such that $f\circ X$ is either non-negative or integrable, we have
$$ \mathbb{E}[f(X)] = \int_{\Omega} f(X(\omega)) \, \mathbb{P}(d\omega) = \int_{S} f(x) \, \mu(dx). $$

2. Independence as factoring of the joint law.

Theorem 2. Let $X, Y$ be $\mathbb{R}$-valued random variables. Denote the law of $(X,Y)$, $X$ and $Y$ by
\begin{align*}
\mu_{X,Y}(E) &= \mathbb{P}(\{\omega : (X(\omega),Y(\omega))\in E\}), \\
\mu_X(E) &= \mathbb{P}(\{\omega : X(\omega)\in E\}), \\
\mu_Y(E) &= \mathbb{P}(\{\omega : Y(\omega)\in E\})
\end{align*}
Then the followings are equivalent:
  
  
*
  
*$X$ and $Y$ are independent.
  
*$\mu_{X,Y} = \mu_X \otimes \mu_Y$.
  

Now the proof goes as follows: Assume that $X$ and $Y$ are independent and $XY$ is integrable. Then writing $XY$ as the composition of $f(x, y) = xy$ and $(X, Y)$, we have
\begin{align*}
\mathbb{E}[XY]
&= \int_{\mathbb{R}^2} xy \, \mu_{X,Y}(dxdy) \tag{$\because$ Theorem 1} \\
&= \int_{\mathbb{R}^2} xy \, \mu_X(dx)\mu_Y(dy)\tag{$\because$ Theorem 2} \\
&= \left(\int_{\mathbb{R}} x \, \mu_X(dx) \right)\left( \int_{\mathbb{R}} y \, \mu_Y(dy) \right) \tag{$\because$ Fubini} \\
&= (\mathbb{E} X)(\mathbb{E} Y) \tag{$\because$ Theorem 1}
\end{align*}
A: Your proof is incorrect, because $XY$ denotes the random variable $\omega\mapsto X(\omega)Y(\omega)$ on $\Omega$, which is different from your random variable $Z(\omega_1,\omega_2)$ on $\Omega^2$.
The step where independence is used in the book's proof is when it uses "(3)" to say $$\int_{\mathbb{R}^2}xy\mu^2(dx,dy)=\int_{\mathbb{R}^1}\int_{\mathbb{R}^1} xy \mu_1(dx)\mu_2(dy).$$  What is being used in this step is the fact that the measure $\mu^2$ is the same as the product measure $\mu_1\times\mu_2$, which is exactly the definition of independence.  Indeed, $\mu^2$ is by definition the measure that sends a rectangle $B_1\times B_2\subseteq\mathbb{R}^2$ to $\mathbb{P}(X\in B_1\text{ and }Y\in B_2)$, whereas $\mu_1\times\mu_2$ is by definition the measure that sends $B_1\times B_2$ to $\mathbb{P}(X\in B_1)\mathbb{P}(Y\in B_2)$.
