TITLE: Conditional expectation and almost sure equality
QUESTION [6 upvotes]: Let $X$, $Y$ be r.v. with finite second moments. Suppose $\mathbb{E}(X\mid\sigma (Y))=Y$, and $\mathbb{E}(Y\mid\sigma(X))=X$, show that $\Pr(X=Y)=1$.
So what I have done is this, I first consider $\mathbb{E}((X-Y)^2)$ by conditioning on $X$ and $Y$
$\mathbb{E}((X-Y)^2\mid X)=\mathbb{E}(X^2\mid X)-2\mathbb{E}[XY\mid X]+\mathbb{E}[Y^2\mid X]=X^2-2X^2+\mathbb{E}(Y^2\mid X)=-X^2+\mathbb{E}[Y^2\mid X]$, and similarly for conditioning on $Y$, but I am not sure how to subtract them properly to make use of them. Thanks
In the end I have $\mathbb{E}((X-Y)^2\mid X)=-X^2+\mathbb{E}[Y^2\mid X]$;
 $\mathbb{E}((X-Y)^2\mid Y)=-Y^2+\mathbb{E}[X^2\mid Y]$

REPLY [4 votes]: \begin{align}
\operatorname{cov}(X,Y) & = \operatorname{E}(XY) - (\operatorname{E}X)(\operatorname{E}Y) = \operatorname{E}(\operatorname{E}(XY \mid X)) - (\operatorname{E}X)(\operatorname{E}Y) \\[10pt]
& = \operatorname{E}(X\operatorname{E}(Y\mid X)) - (\operatorname{E}X)(\operatorname{E}Y) = \operatorname{E}(X^2) - (\operatorname{E}X)(\operatorname{E}Y).
\end{align}
Now use the fact that the expectations of $X$ and $Y$ are equal:
$\operatorname{E}(X)= \operatorname{E}(\operatorname{E}(X\mid Y)) = \operatorname{E}(Y)$.
We get $\operatorname{cov}(X,Y) = \operatorname{E}(X^2) - (\operatorname{E}X)^2 = \operatorname{var}(X)$.  By the same argument, we get $\operatorname{cov}(X,Y) = \operatorname{var}(Y)$.  Hence $\operatorname{cov}(X,Y) = \operatorname{var}(X)=\operatorname{var}(Y)$.
Hence the correlation between $X$ and $Y$ is $1$ (provided neither of them has variance $0$, but proving the result you want when that happens is trivial).