I'm asked to show that if $X, Y$ are random variables (discrete or continuous) and $E(X|Y) = Y$, $E(Y|X) = X$, then $X = Y$ almost surely.
I'd like to argue as follows: Suppose not. Then
$$\{X\neq Y\} = \bigcup _{r\in\mathbb{Q}} \left(\{X<r\} \cap \{r<Y\}\right) \cup \bigcup _{r\in\mathbb{Q}}\left(\{X>r\} \cap \{r>Y\}\right)$$
has positive measure, and hence without loss of generality there's some $r\in \mathbb{Q}$ such that $\{X<r<Y\}$ has positive measure. Let's call this set $C$. Then we get:
$$\int_CX<\mu(C)\cdot r<\int_CY=\int_CE(Y|X)=\int_CX$$
where the second-last equality comes from the definition of conditional expectation, and the last equality comes from one of the given equations. But the above is a contradiction, so that does it.
The problem here is that I've only used one of the given assumptions, so have I implicitly used the other one somewhere? Is there some measurability-related concern I'm overlooking?