Definition ptrofs_modm x := x mod Ptrofs.modulus.

Lemma ptrofs_modm_repr_eq: forall x y, Ptrofs.eqmod Ptrofs.modulus x y -> Ptrofs.repr x = ptrofs_reprm y.
Ltac ptrofs_simpl_mod A H :=
let H0 := fresh "H" in
let H1 := fresh "H" in
match A with
| (?B + ?C)%Z =>
ptrofs_simpl_mod B H0; ptrofs_simpl_mod C H1;
pose proof Ptrofs.eqmod_add Ptrofs.modulus _ _ _ _ H0 H1 as H;
clear H1 H0
| (?B - ?C)%Z =>
ptrofs_simpl_mod B H0; ptrofs_simpl_mod C H1;
pose proof Ptrofs.eqmod_sub Ptrofs.modulus _ _ _ _ H0 H1 as H;
clear H1 H0
| (?B * ?C)%Z =>
ptrofs_simpl_mod B H0; ptrofs_simpl_mod C H1;
pose proof Ptrofs.eqmod_mult Ptrofs.modulus _ _ _ _ H0 H1 as H;
clear H1 H0
| (- ?B)%Z =>
ptrofs_simpl_mod B H0;
pose proof Ptrofs.eqmod_neg Ptrofs.modulus _ _ H0 as H;
clear H0
| ?B mod Ptrofs.modulus =>
ptrofs_simpl_mod B H0;
pose proof ptrofs_modm_mod_elim B _ H0 as H;
clear H0
| ptrofs_modm ?B =>
ptrofs_simpl_mod B H0;
pose proof ptrofs_modm_mod_elim B _ H0 as H;
clear H0
| _ =>
pose proof Ptrofs.eqmod_refl Ptrofs.modulus A as H
end.