say we're in a probability space $(\Omega, \Sigma, \mathbb{P})$ and $X : (\Omega, \Sigma) \to (\mathbb{R}, \mathscr{B}_{\mathbb{R}})$ is random variable
I resulted in the right result but I feel like the math is bad, please check it :
$$\begin{align} & \int_{0}^{\infty}\mathbb{P}(X \geq t) dt = \int_0^{\infty}\int_{X \geq t}d\mathbb{P}\,dt \,\,\,\,\\ = & \int_{X \geq 0}\int_{0}^{X}dt\,d\mathbb{P} \,\,(\star) = \int_{X \geq 0}X\,d\mathbb{P} \\ = & \int_{\Omega}X\,d\mathbb{P} \,\,\,\, \text{due to non-negativity} = \mathbb{E}[X] \end{align}$$
where I'm not sure I'm doing legal stuff is $(\star)$, I used Fubini-Tonelli theorem to change order of integration, but when I changed bounds of integration I reasoned the following way :
we have : $t\geq 0$ and $X\geq t$ meaning on the one hand we have $X \geq 0$ and $ 0 \leq t \leq X $
am I doing this right ?
The integral before $(\star)$ can be written as $\int_\Omega\int_{\mathbb R}f(t,\omega)\mathrm dt\mathrm dP(\omega)$, where $f(t,\omega)=1$ if $X(\omega)\geqslant t$ and $0$ otherwise. Then Fubini's theorem can be used in this setting.