Theoretical foundations of the finite element method