# A very intuitive question about iterated expectations

I am struggling to prove a very intuitive property about iterated expectations.

We know that $$\mathbb E[X] = \mathbb E[\mathbb E[X\vert Y]].$$

I want to argue the following:

\begin{align*} \mathbb E[XY \vert Z ] = \mathbb E[X \mathbb E[Y \vert X,Z] \vert Z] \end{align*}

But I am having a hard time establishing this using the definition of conditional expectations.

To prove this would entail proving,

\begin{align*} \int_S XY d\mathbb P = \int_S X \mathbb E[Y \vert X,Z] d\mathbb P \end{align*} for all $$S \in \sigma(Z)$$.

This would be true if, for example, $$Y = \mathbb E[Y \vert X,Z]$$ which seems way demanding and is, most likely, not true.

In its more general version, the tower property of conditional expectation tells you that if $$\mathcal G,\mathcal H$$ are two sub-sigma algebras of $$\mathcal F$$ with $$\mathcal H \subseteq \mathcal G$$, then for any random variable $$\tilde X$$ on $$(\Omega,\mathcal F,\mathbb P)$$, we have $$\mathbb E[\tilde X\mid\mathcal H] =\mathbb E \big[\mathbb E[\tilde X\mid\mathcal G]\mid\mathcal H\big]$$

Applying the above with $$\tilde X := XY$$, $$\mathcal G :=\sigma(X,Z)$$ and $$\mathcal H := \sigma(Z)$$ we immediately get $$\mathbb E[XY \mid Z ] = \mathbb E[ \mathbb E\big[XY \mid X,Z] \mid Z\big]$$ Which is almost the desired result. All that is left is to notice that since $$X$$ is $$\sigma(X,Z)$$-measurable, we have $$\mathbb E\big[XY \mid X,Z]=X\mathbb E\big[Y \mid X,Z]$$ and the desired result follows.

I will explain the general idea and let you fill in the small details.

For the conditional expectation, you have the property $$\mathbb{E}[XY] =\mathbb{E}[X\cdot\mathbb{E}[Y|X]]$$, also called the tower property.

The discrete case gives you a really good intuition about why it is true: if $$X,Y$$ are discrete random variables, then $$\mathbb{E}[XY]= \sum_{k,n\in \mathbb{N}} x_ky_n\Pr[X=x_k,Y=y_n]$$.By using conditional probability, we get $$\mathbb{E}[XY]=\sum_{k\in \mathbb{N}} x_k\Pr[X=x_k]\sum_{n\in \mathbb{N}}y_n\Pr[Y=y_n|X=x_k]$$. We write $$\mathbb{E}[Y|X=x_k] = \sum_{n\in \mathbb{N}}y_n\Pr[Y=y_n|X=x_k]$$. We can define $$\mathbb{E}[Y|X]$$ as the random variable that gets the value $$\mathbb{E}[Y|X=x_k]$$ whenever $$X=x_k$$. Hence, since $$\mathbb{E}[XY] = \sum_{k\in \mathbb{N}} x_k \mathbb{E}[Y|X=x_k] \Pr[X=x_k]$$, we can deduce $$\mathbb{E}[XY] = \mathbb{E}[X \cdot \mathbb{E}[Y|X]]$$.

The identity $$\mathbb{E}[XY|Z] = \mathbb{E}[X\cdot \mathbb{E}[Y|X,Z] |Z]$$ is really just the tower property in disguise - only now we work with the conditional expectation of $$Z$$ instead of an actual expectation.

We can apply $$\mathbb{E}[XY] =\mathbb{E}[X\cdot\mathbb{E}[Y|X]]$$ on the conditional expectation of $$Z$$, by writing $$\mathbb{E}[XY|Z] = \mathbb{E}[X\cdot \mathbb{E}[\mathbb{E}[Y|Z]|X]|Z]$$. Since $$\mathbb{E}[\mathbb{E}[Y|Z]|X]] = \mathbb{E}[Y|X,Z]$$, we are done.