Rigorous proof that $\int_{\Omega}X\;dP=\int_{-\infty}^{\infty}xf(x)\;dx$
Solution 1:
If $X\geqslant0$ almost surely, Fubini yields $$ E[X]=\int_\Omega X\mathrm dP=\int_\Omega\int_0^\infty\mathbf 1_{t\leqslant X}\mathrm dt\mathrm dP=\int_0^\infty\int_\Omega\mathbf 1_{t\leqslant X}\mathrm dP\mathrm dt=\int_0^\infty P[X\geqslant t]\mathrm dt. $$ Now, for each $t$, $$ P[X\geqslant t]=\int_0^\infty \mathbf 1_{x\geqslant t}f(x)\mathrm dx, $$ hence Fubini again yields $$ E[X]=\int_0^\infty\int_0^\infty \mathbf 1_{x\geqslant t}f(x)\mathrm dx\mathrm dt=\int_0^\infty\int_0^\infty \mathbf 1_{x\geqslant t}\mathrm dtf(x)\mathrm dx=\int_0^\infty xf(x)\mathrm dx. $$ If $X$ is real valued with $P[X\gt0]\cdot P[X\lt0]\ne0$, use the identity $E[X]=aE[Y]-bE[Z]$ where $a=P[X\gt0]$, $b=P[X\lt0]$, $Y$ has the distribution of $X$ conditioned on $X\gt0$ and $Z$ has the distribution of $-X$ conditioned on $X\lt0$, that is, $a=1-F(0)$, $b=F(0)$, $$ f_Y(y)=\frac{f(y)}{a}\mathbf 1_{y\gt0},\qquad f_Z(z)=\frac{f(-z)}{b}\mathbf 1_{z\gt0}. $$ This yields $$ E[X]=a\int_0^\infty y\frac{f(y)}{a}\mathrm dy-b\int_0^\infty z\frac{f(-z)}{b}\mathrm dz=\int_{-\infty}^{+\infty}xf(x)\mathrm dx. $$
Solution 2:
I'll try to provide a little more general result. Let $(\Omega,\ \mathcal{E},\ P)$ be a probability space and let $X\colon \Omega\longrightarrow \mathbb{R}$ be a random variable, i.e for each $I\in \mathcal{B}$, $X^{-1}(I)\in\mathcal{E}$, where $\mathcal{B}$ is the usual Borel $\sigma-$algebra on $\mathbb{R}$. Let us write $\mu:=\mu_{X}$ for the probability distribution of $X$, i.e for the measure defined on $\mathcal{B}$ by $\mu(I):=P(X^{-1}(I))$ for each $I\in\mathcal{B}$. Then the following holds.
Theorem (Abstract-Concrete Formula): Let $\phi\colon\mathbb{R}\longrightarrow \mathbb{R}$ be a borelian function, i.e $\phi^{-1}(I)\in\mathcal{B}$ for every $I\in\mathcal{B}$, and write $\phi(X)$ for the composition $\phi\circ X$. Suppose at least one between the integrals $$\int_{\Omega} \phi(X)\ dP\quad\text{and}\quad \int_{\mathbb{R}}\phi (x) \ d\mu $$ exists (resp. exists and it is finite). Then also the other one exists (resp. exists and it is finite) and it holds that $$\int_{\Omega} \phi(X)\ dP=\int_{\mathbb{R}}\phi (x) \ d\mu\ .$$ In particular, $\phi(X)$ is summable with respect to $P$ if and only if $\phi$ is summable with respect to $\mu$.
(When I say that a Lebesgue integral for a measurable function exists, I allow that it is not finite). The proof of this fact is quite straightforward but it requires some measure theory results such as the approximation theorem with simple functions and the Lebesgue's monotone convergence theorem. Indeed, suppose first that $\phi$ is a (finitely) simple and positive function. Then also $\phi(X)$ is simple (and positive) and (therefore) both mentioned integrals always exist. Writing $\phi=\sum_{i=1}^{n} c_{i}1_{E_{i}}$, where $n=\vert \phi(\mathbb{R})\vert$, $\phi (\mathbb{R})=\{c_{1},\cdots,c_{n}\}$ and $E_{i}:=\phi^{-1}(\{c_{i}\})$, we get $$\int_{\mathbb{R}}\phi (x) \ d\mu=\sum_{i=1}^{n}c_{i}\mu (E_{i})=\sum_{i} c_{i}P(X^{-1}(E_{i}))=\sum_{i} c_{i}P(X^{-1}(\phi^{-1}(\{c_{i}\})))=\int_{\Omega} \phi(X)\ dP.$$ Assume now $\phi$ is a non-negative borelian function. Then there exists a non-decreasing sequence $(\phi_{n})_{n\in \mathbb{N}}$ of simple, positive functions such that $\lim\limits_{n\to \infty}\phi_{n}(x)=\phi (x)$ for every $x\in\mathbb{R}$. By monotone convergence theorem we get immediately that $$\int_{\mathbb{R}}\phi (x) \ d\mu=\int_{\mathbb{R}}(\lim_{n\to\infty}\phi_{n} (x)) \ d\mu =\lim_{n\to\infty} \int_{\mathbb{R}}\phi_{n} (x) \ d\mu=\lim_{n\to\infty} \int_{\Omega}\phi_{n} (X) \ dP=\int_{\Omega} \phi(X)\ dP.$$ Finally, suppose only $\phi\colon \mathbb{R}\longrightarrow\mathbb{R}$ is a borelian function, with no further restrictions. Then one can write $\phi=\phi^{+}-\phi^{-}$ (here for notation). Suppose $\int_{\mathbb{R}}\phi (x) \ d\mu$ exists: then at least one between $\int_{\mathbb{R}}\phi^{+} (x) \ d\mu$ and $\int_{\mathbb{R}}\phi^{-}(x) \ d\mu$ (say, the first one) must be finite and hence also $\int_{\Omega}(\phi(X))^{+} \ dP$ is finite, i.e $\int_{\Omega}\phi(X)\ dP$ exists. It is now clear that we can conclude with our thesis.
Corollary: In the previous situation, if $E[X]<+\infty$, then $$E[X]:=\int_{\Omega} X\ dP=\int_{\mathbb{R}} x\ d\mu.$$ In particular, if $\mu$ is absolutely continuous with respect to Lebesgue's Measure (on $\mathbb{R}$) and has density $f$, then we get $E[X]=\int_{\mathbb{R}} xf(x)\ dx$ (by (a straightforward consequence of) Radon-Nikodym theorem).