Theory of density functionals