Let X be a random variable whose PDF is f(x), and g a function of random variable X. How can we formally prove the formula E[g(X)] = intg(x)f(x)dx? And what is the intuition behind it?