(**************************************************  Solve_mod_modulus  **************************************************)
Definition int_modm x := x mod Int.modulus.

(* Specifications: *)
Lemma int_modm_mod_eq: forall x y, Int.eqmod Int.modulus x y -> x mod Int.modulus = int_modm y.
Lemma int_modm_mod_elim: forall x y, Int.eqmod Int.modulus x y -> Int.eqmod Int.modulus (x mod Int.modulus) y.
Definition int_reprm := Int.repr.
Lemma int_modm_repr_eq: forall x y, Int.eqmod Int.modulus x y -> Int.repr x = int_reprm y.
Ltac int_simpl_mod A H :=
let H0 := fresh "H" in
let H1 := fresh "H" in
match A with
| (?B + ?C)%Z =>
int_simpl_mod B H0; int_simpl_mod C H1;
pose proof Int.eqmod_add Int.modulus _ _ _ _ H0 H1 as H;
clear H1 H0
| (?B - ?C)%Z =>
int_simpl_mod B H0; int_simpl_mod C H1;
pose proof Int.eqmod_sub Int.modulus _ _ _ _ H0 H1 as H;
clear H1 H0
| (?B * ?C)%Z =>
int_simpl_mod B H0; int_simpl_mod C H1;
pose proof Int.eqmod_mult Int.modulus _ _ _ _ H0 H1 as H;
clear H1 H0
| (- ?B)%Z =>
int_simpl_mod B H0;
pose proof Int.eqmod_neg Int.modulus _ _ H0 as H;
clear H0
| ?B mod Int.modulus =>
int_simpl_mod B H0;
pose proof int_modm_mod_elim B _ H0 as H;
clear H0
| int_modm ?B =>
int_simpl_mod B H0;
pose proof int_modm_mod_elim B _ H0 as H;
clear H0
| _ =>
pose proof Int.eqmod_refl Int.modulus A as H
end.