Ltac solve_mod_modulus :=
unfold Int.add; rewrite ?Int.unsigned_repr_eq;
unfold Ptrofs.add; rewrite ?Ptrofs.unsigned_repr_eq;
repeat
match goal with
| |- context [?A mod Int.modulus] =>
let H := fresh "H" in int_simpl_mod A H;
rewrite (int_modm_mod_eq A _ H);
clear H
| |- context [Int.repr ?A] =>
let H := fresh "H" in int_simpl_mod A H;
rewrite (int_modm_repr_eq A _ H);
clear H
| |- context [?A mod Ptrofs.modulus] =>
let H := fresh "H" in int_simpl_mod A H;
rewrite (int_modm_mod_eq A _ H);
clear H
| |- context [Int.repr ?A] =>
let H := fresh "H" in int_simpl_mod A H;
rewrite (int_modm_repr_eq A _ H);
clear H
| |- context [?A mod Ptrofs.modulus] =>
let H := fresh "H" in ptrofs_simpl_mod A H;
rewrite (ptrofs_modm_mod_eq A _ H);
clear H
| |- context [Ptrofs.repr ?A] =>
let H := fresh "H" in ptrofs_simpl_mod A H;
rewrite (ptrofs_modm_repr_eq A _ H);
clear H
| |- context [?A mod Ptrofs.modulus] =>
let H := fresh "H" in ptrofs_simpl_mod A H;
rewrite (ptrofs_modm_mod_eq A _ H);
clear H
| |- context [Ptrofs.repr ?A] =>
let H := fresh "H" in ptrofs_simpl_mod A H;
rewrite (ptrofs_modm_repr_eq A _ H);
clear H
end;
unfold int_modm, int_reprm, ptrofs_modm, ptrofs_reprm in *.
(**************************************************  List lemmas  **************************************************)

Lemma and_repr
: forall i j : Z, Int.and (Int.repr i) (Int.repr j) = Int.repr (Z.land i j).