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 Zland_two_p:
forall i n, (0 <= n)%Z -> Z.land i (Z.ones n) = i mod (2 ^ n).