# If $E[X|Y]=Y$ almost surely and $E[Y|X]=X$ almost surely then $X=Y$ almost surely

Assume that $X$ and $Y$ are two random variables such that $Y=E[X|Y]$ almost surely and $X= E[Y|X]$ almost surely. Prove that $X=Y$ almost surely.

The hint I was given is to evaluate: $$E[X-Y;X>a,Y\leq a] + E[X-Y;X\leq a,Y\leq a]$$

which I can write as: $$\int_A(X-Y)dP +\int_B(X-Y)dP$$ where $A=\{X>a, Y\leq a\}$ and $B=\{X\leq a,Y\leq a\}$.

But I need some more hints.

-

Simply follow the hint... First note that, since $E(X\mid Y)=Y$ almost surely, for every $c$, $$E(X-Y;Y\leqslant c)=E(E(X\mid Y)-Y;Y\leqslant c)=0,$$ and that, decomposing the event $[Y\leqslant c]$ into the disjoint union of the events $[X>c,Y\leqslant c]$ and $[X\leqslant c,Y\leqslant c]$, one has $$E(X-Y;Y\leqslant c)=U_c+E(X-Y;X\leqslant c,Y\leqslant c),$$ with $$U_c=E(X-Y;X>c,Y\leqslant c).$$ Since $U_c\geqslant0$, this shows that $$E(X-Y;X\leqslant c,Y\leqslant c)\leqslant 0.$$ Exchanging $X$ and $Y$ and following the same steps, using the hypothesis that $E(Y\mid X)=X$ almost surely instead of $E(X\mid Y)=Y$ almost surely, one gets $$E(Y-X;X\leqslant c,Y\leqslant c)\leqslant0,$$ that is $$E(Y-X;X\leqslant c,Y\leqslant c)=0,$$ which, coming back to the first decomposition of an expectation above, yields $U_c=0$, that is, $$E(X-Y;X>c\geqslant Y)=0.$$ This is the expectation of a nonnegative random variable hence $(X-Y)\mathbf 1_{X>c\geqslant Y}=0$ almost surely, which can only happen if the event $[X>c\geqslant Y]$ has probability zero. Now, $$[X>Y]=\bigcup_{c\in\mathbb Q}[X>c\geqslant Y],$$ hence all this proves that $P(X>Y)=0$. By symmetry, $P(Y>X)=0$ and we are done.

-
If one assumes furthermore that $X$ and $Y$ are square integrable, the $L^2$ proof in the other answer (already on several other pages of the site) is simpler. – Did Nov 9 '15 at 7:58
is this question a duplicate, then? We should mark it as such. – Nate Eldredge Nov 9 '15 at 14:09
@NateEldredge If the question was assuming square integrability, it would be a duplicate. The general version (assuming only integrability) might also be a duplicate but I am not sure (and I said nothing about that). – Did Nov 9 '15 at 14:10
Can you give a link to the previous instance(s) of the $L^2$ case? – Nate Eldredge Nov 9 '15 at 14:14
@NateEldredge Not at the moment but I remember having seen solutions based on the square integrability you explained (and I remember them because, at the moment, I was already aware of the "only integrable" proof above). – Did Nov 9 '15 at 14:16

If $X,Y$ are square-integrable we can give a quick proof.

Consider the random variable $(X-Y)^2 = X^2 - 2XY + Y^2$. Let's compute its expectation by conditioning on $X$. We have \begin{align*} E[(X-Y)^2] &= E[E[(X-Y)^2 \mid X]] \\ &= E[E[X^2 - 2XY + Y^2 \mid X]] \\ &= E[X^2 - 2 X E[Y \mid X] + E[Y^2 \mid X]] \\ &= E[X^2 - 2 X^2 + E[Y^2 \mid X]] \\ &= E[-X^2 + Y^2]\end{align*} If we condition on $Y$ instead we get $E[(X-Y)^2] = E[X^2 - Y^2]$. Comparing these, we see that we have $E[(X-Y)^2] = -E[(X-Y)^2]$, i.e. $E[(X-Y)^2]=0$. This means $X=Y$ almost surely.

Unfortunately I don't quite see a way to handle the case where $X,Y$ are merely integrable, since in that case some of the expectations used above may be undefined.

Acknowledgement of priority. After writing this I found (thanks to Did) that essentially the same proof was given by Michael Hardy in Conditional expectation and almost sure equality.

-