How can I use Fubini's Theorem here? Exercise:

If $F$ is a continuous distribution function on $(\mathbb R, \mathscr B, \mu_{\mathcal L})$ with distribution $\mu_F$, use Fubini's theorem to show that

*

*$\int_{\mathbb R} F(x) \, d\mu_F(x) = \frac{1}{2}$


*if $X_1, X_2$ are i.i.d random variables with common distribution $F$, then $P(\{X_1 \leq X_2 \}) = 1/2$ and $\text E(F(X_1)) = 1/2$.

My Attempt:
I don't really understand bs_math's answer so I have been trying to write my own. I just deleted an attempt here that was (I think) completely nonsensical. I am working on another attempt.
For example, I don't understand what's going on in line 4 of bs_math's answer.
 A: The distribution function is generally defined as
$$ F: x \mapsto \mu_F((-\infty, x]), $$
see Wikpedia. The OP relies on another definition stating that
$$ \tilde{F}(x) = \begin{cases}
\mu_F((0, x], & x > 0, \\
0, &x = 0, \\
- \mu_F((-x, 0], &x < 0.
\end{cases}
$$
Then we have $\tilde{F} = F + c$ for the constant summand $c = - \mu_F((-\infty, 0])$. I have never seen this as a definition of the distribution function. The fact that one can show the claim
$$ \int_\mathbb{R} F(x) \, d\mu_F(x) = \frac{1}{2} \tag{1} $$
for $F$ shows that $(1)$ is actually false as soon as $c \neq 0$. So I assume there is a misunderstanding regarding the intended definition of $F$.
Now, in order to show $(1)$ use that by the very definition of the Lebesgue integral it is
$$ F(x) = \mu((-\infty, x]) = \int_\mathbb{R} 1_{(-\infty, x]}(y) \, d\mu_F(y).$$
Then, consider the following transformations:
\begin{align}
\int_\mathbb{R} F(x) d\mu_F(x) 
&= \int_{\mathbb{R}} \int_\mathbb{R} 1_{(-\infty, x]}(y) \, d\mu_F(y)  \, d\mu_F(x) \\
&= \int_\mathbb{R} \int_\mathbb{R} 1_{(-\infty, x]}(y) \, d\mu_F(x) \, d\mu_F(y) \\
&= \int_\mathbb{R} \int_{\mathbb{R}} 1_{[y, \infty)}(x) \, d \mu_F(x) \, d\mu_F(y) \\
&= \int_\mathbb{R} 1 - F(y) \, d\mu_F(y) \\
&= 1 - \int_\mathbb{R} F(x) \, d \mu_F(x), \tag{2}
\end{align}
where we use Fubinis's theorem in the second line. To get from the second to the third line we observe for every $x, y \in \mathbb{R}$
$$ 1_{(-\infty, x]}(y) = 1 \Leftrightarrow y \leq x \Leftrightarrow 1_{[y, \infty)}(x) = 1. $$
In the fourth line we use that for fixed $y$ one has
\begin{align*}
\int_\mathbb{R} 1_{[y, \infty)}(x) \, d \mu_F(x)
&= \int_\mathbb{R} 1 - 1_{(-\infty, y)}(x) \, d\mu_F(x) \\
&= 1 - \int_\mathbb{R} 1_{(-\infty, y)}(x) \, d\mu_F(x) \\
&= 1 - \lim_{h \searrow 0} \int_\mathbb{R} 1_{(-\infty, y - h]}(x) \, d\mu_F(x) \\
&= 1 - \lim_{h \searrow 0} F(y-h) \\
&= 1 - F(y),
\end{align*}
where we use Beppo-Levi's theorem in the third line.
The claim $(1)$ follows immediately from $(2)$ by rearranging terms.
Here all intgrals are to be understood as Lebesgue integrals.
