# Proving $P(X=Y)=1$ given that $E(Y|X)=X$ and $E(X|Y)=Y$

It's a Prove/Disprove question.

Given $\mathrm{E}(Y|X)=X$ and $\mathrm{E}(X|Y)=Y$ and both $\mathrm{E}(X^2)$ and $\mathrm{E}(Y^2)$ are finite, then $$P(X=Y)=1$$

If we somehow get $\mathrm{Var}(X-Y)=0$, the above statement could be true.

So, $\mathrm{Var}(X-Y)=\mathrm{Var}(X)+\mathrm{Var}(Y)-2\mathrm{Cov}(X,Y)$

$\qquad\qquad\qquad\quad=\mathrm{E}(X^2)-[\mathrm{E}(X)]^2+\mathrm{E}(Y^2)-[\mathrm{E}(Y)]^2-2\mathrm{E}(XY)+2\mathrm{E}(X)\mathrm{E}(Y)$

Now, $-[\mathrm{E}(X)]^2-[\mathrm{E}(Y)]^2+2\mathrm{E}(X)\mathrm{E}(Y)=0$, since $\mathrm{E}(X)=\mathrm{E}(Y)$.

So, $\mathrm{Var}(X-Y)=\mathrm{E}(X^2)+\mathrm{E}(Y^2)-2\mathrm{E}(XY)$ $-(*)$

The solution given directly says the statement $(*)$ equals zero and hence the result, but \begin{align} \mathrm{E}(X^2) &= \mathrm{E}(X\cdot X) = \mathrm{E}(X\mathrm{E}(Y|X)) \\ \mathrm{E}(Y^2) &= \mathrm{E}(Y\cdot Y)\, = \mathrm{E}(Y\mathrm{E}(X|Y)) \\ \mathrm{E}(X\cdot Y) &= \mathrm{E}(\mathrm{E}(Y|X)\mathrm{E}(X|Y)) \end{align} How are they canceling each other?

Just note that

$\mathbf{E}(X^2)=\mathbf{E}(X\,\mathbf{E}(Y\mid X))=\mathbf{E}(\mathbf{E}(XY\mid X))=\mathbf{E}(XY)$

$\qquad\qquad=\mathbf{E}(\mathbf{E}(XY|Y))=\mathbf{E}(Y\,\mathbf{E}(X\mid Y))=\mathbf{E}(Y^2)$.

Hint: you have not used the hypothesis about $\mathbb{E}[X|Y]$ and $\mathbb{E}[Y|X]$ in your calculations...