The invariance group for Hamiltonian systems of partial differential equations