This is an oxidation-reduction (redox) reaction:
2 HI + 2 e- → 2 H0 (reduction)
2 Mg0 - 4 e- → 2 MgII (oxidation)
2 O-II + 2 e- → 2 O-III (reduction)
H2O is an oxidizing agent, Mg is a reducing agent, H2O is an oxidizing agent.
Reactants:
Products: