Quantum mechanical sum rules, gauge invariance: a study of the HF molecule