I am unsure about my (supposed) solution to exrecise 9.2 from the book "Probability with martingales" by David Williams.
The problem is as follows:
Suppose that $X,Y\in \mathcal{L}^1(\Omega,\mathcal{F},P)$ and that $$ E[X|Y]=Y\text{ a.s, }E[Y|X]=X\text{ a.s}$$ Prove that $P(X=Y)=1$.
He also provides a hint that I didn't try to use directly:
Hint. Consider $E[X-Y;X>c,Y\leq c]+E[X-Y;X\leq c,Y\leq c]$.
I am worried about my solution seeing as the hint doesn't seem trivial, and I didn't use it at all. My solution is as follows:
By definition of the conditional expectation we get that for all $A\in \sigma(X)\cup\sigma(Y)$ $$\intop_AXdP=\intop_AYdP\Rightarrow\intop_A(X-Y)dP=0$$
Now, assume by contradiction that $P(X=Y)<1\Rightarrow P(X-Y\neq0)>0$. wlog, this means that there exists some $c>0$ such that $P(F)>0,F=\{X-Y>c\}\in\sigma(X)\cup\sigma(Y)$.
Now, using what we have seen earlier we get $$0=\intop_F(X-Y)dP>\intop_FcdP=cP(F)>0$$ and that's what we wanted to show.
I would very much appriciate a feedback on this solution, and a explenation about where I went wrong in the likely case this is incorrect (A hint about how I should continue would also be much appriciated, although I'll try my best not to use it).
As mentioned in the comments, the flaw in your approach is that the event $\{X-Y>c\}$ is not a member of $\sigma(X)\cup\sigma(Y)$.
To use the hint, write $$ r:=E[X-Y; Y\le c]=E[X-Y;X>c,Y\le c]+E[X-Y; X\le c, Y\le c]=:s+t. $$ You've already shown that $r=0$. But notice that $s\ge 0$. It follows that $E[X-Y;X\le c, Y\le c]\le 0$. Swapping $X$ and $Y$, the same argument shows that $E[Y-X; Y\le c, X\le c]\le 0$.
Next hint:
Additional hint: