Gauge symmetries in the Heisenberg model of a magnet