Theory of variational quantum simulation