How expected value is related to density function? Let $X$ be a random variable on $(\Omega, \Sigma, P)$.  The expected value of $X$ is defined as 
$$EX = \int X \,dP.$$
But when we calculate $EX$, we often use
$$
EX = \int_{-\infty}^\infty xf(x) dx
$$
where $f(x)$ is the density function. How can we prove that these two are equivalent?
 A: You have to use two results to obtain the equality. The first being:

Suppose $(X,\mathcal{E},\mu)$ is a measure space, $(Y,\mathcal{F})$ is a measurable space and $\varphi:X\to Y$ is $\mathcal{E}$-$\mathcal{F}$-measurable. Let also $\mu_\varphi=\mu\circ\varphi^{-1}$ be the image measure of $\mu$ under $\varphi$. Then
  $$
\mathcal{L}^1(\mu_\varphi)=\{f:Y\to \mathbb{R},\,f \text{ is }\mathcal{F}\text{-}\mathcal{B}(\mathbb{R})\text{-measurable}\mid f\circ\varphi \in\mathcal{L}^1(\mu)\}
$$
  and
  $$
\int_Yf\,\mathrm{d}\mu_{\varphi}=\int_Xf\circ\varphi\,\mathrm{d}\mu,\quad f\in\mathcal{L}^1(\mu_\varphi).\quad (*)
$$
Proof:
1) For $B\in\mathcal{F}$ we have
  $$
\int_X 1_B\circ\varphi\,\mathrm{d}\mu=\int_X 1_{\varphi^{-1}(B)}\,\mathrm{d}\mu=\mu(\varphi^{-1}(B))=\mu_\varphi(B)=\int_X 1_B\,\mathrm{d}\mu_\varphi.
$$
2) If $f,g:Y\to\mathbb{R}$ are non-negative $\mathcal{F}$-measurable functions such that $(*)$ holds, then
  $$
\int_X(f+g)\circ\varphi\, \mathrm{d}\mu=\int_X (f\circ\varphi+g\circ\varphi)\,\mathrm{d}\mu=\int_X f\circ\varphi\,\mathrm{d}\mu + \int_X g\circ\varphi\,\mathrm{d}\mu\\
=\int_X f\,\mathrm{d}\mu_\varphi+\int_X g\,\mathrm{d}\mu_\varphi,
$$
  i.e. $(*)$ holds for $f+g$.
3) Let $(f_n)_{n\geq 1}$, $f_n:Y\to\mathbb{R}$, be a sequence of non-negative increasing $\mathcal{F}$-measurable functions obeying $(*)$ such that $f=\lim_{n\to\infty} f_n$ exists pointwise. Then $(f_n\circ \varphi)_{n\geq 1}$ is a sequence of non-negative increasing $\mathcal{E}$-measurable functions and by the monotone convergence theorem (twice), we have
  $$
\int_X f\circ\varphi\,\mathrm{d}\mu=\lim_{n\to\infty}\int_X f_n\circ\varphi\,\mathrm{d}\mu=\lim_{n\to\infty}\int_X f_n\,\mathrm{d}\mu_\varphi=\int_X f\,\mathrm{d}\mu_\varphi.
$$
Then a standard argument yields that $(*)$ holds for all $f\in\mathcal{L}^1(\mu_\varphi)$.

The second result:

Let $(X,\mathcal{E},\mu)$ be a measure space and let $g:X\to\mathbb{R}$ be a non-negative $\mathcal{E}$-$\mathcal{B}(\mathbb{R})$-measurable function. Let $\nu$ be the measure with density $g$ with respect to $\mu$, i.e. $\nu(A)=\int_A g\,\mathrm{d}\mu$. Then
  $$
\mathcal{L}^1(\nu)=\{f:X\to \mathbb{R},\,f \text{ is }\mathcal{E}\text{-}\mathcal{B}(\mathbb{R})\text{-measurable}\mid f\cdot g \in\mathcal{L}^1(\mu)\}
$$
  and
  $$
\int_Xf\,\mathrm{d}\nu = \int_X f\cdot g\,\mathrm{d}\mu,\quad f\in\mathcal{L}(\nu).
$$
Proof: Recreate steps 1)-3) from above to this setting.

Try to combine these results with $(X,\mathcal{E},\mu)=(\Omega,\Sigma,P)$, $(Y,\mathcal{F})=(\mathbb{R},\mathcal{B}(\mathbb{R}))$ and $\varphi=X$ in the first result, and $(X,\mathcal{E},\mu)=(\mathbb{R},\mathcal{B}(\mathbb{R}),\lambda)$, $\nu=P_X$ and $g=f$ in the second result.
