Let $X$ and $Y$ be r.v. such that $E[X^2] < \infty$, $E[Y^2] < \infty$. Suppose that $E[X|Y] = Y$ and $E[Y|X] = X$. Prove that $Y=X$ with probability 1.
My professor gave us a hint: Compute $E[X-Y]^2$ using conditioning on X and Y.
My attempt:
$E[X-Y]^2 = E[X^2 - 2XY +Y^2] = E[X^2] - 2E[XY] + E[Y^2]$ $= E[E[Y|X]^2] - 2E[E[X|Y] E[Y|X]] + E[E[X|Y]^2]$
I am stuck here. I don't understand why computation of $E[X-Y]^2$ will help me prove that $X=Y$. I am looking for a hint here.