Prove that $E(Y)-E(X)= \int_\Bbb{R}\Bbb{P}(X<t\leq Y)-\Bbb{P}(Y<t\leq X)\, dt$

Problem. Let $\left(\Omega, \mathcal A, \Bbb{P} \right)$ be a probability space and $X,Y$ be real-valued random variables with finite expected value. Then $$E(Y)-E(X)= \int_\Bbb{R}\Bbb{P}(X<t\leq Y)-\Bbb{P}(Y<t\leq X)\, dt.$$

My attempt. This isn't much of an attempt, but I've written $$\int_\Bbb{R}\Bbb{P}(X<t\leq Y)-\Bbb{P}(Y<t\leq X)\, dt = \int_\Bbb{R} E\left(\mathbf 1\{X<t\leq Y\}-\mathbf 1\{Y<t\leq X\} \right) dt$$ Can we interchange integration and $E$? How could we proceed?

Yes, we interchange integration with expectation using Fubini-Tonelli. (This uses the finite expected value condition.) $$\int_{\mathbb R}E({\bf 1}\{X<t\leq Y\}-{\bf 1}\{Y<t\leq X\})=E\left(\int_{\mathbb R}{\bf 1}\{X<t\leq Y\}-{\bf 1}\{Y<t\leq X\}\right)=E(Y-X).$$ The last step follows from the the deterministic identity $$Y-X=\int_{\mathbb R}{\bf 1}\{X<t\leq Y\}-{\bf 1}\{Y<t\leq X\}$$ for any real numbers $X,Y\in \mathbb R$ (just consider each of the two cases $X\leq Y$ and $X\geq Y$ separately).
• Well, the standard way is to split $f$ into positive and negative parts and to apply Tonelli to each separately. – pre-kidney Sep 9 '15 at 8:28