Section EqualityModulo.
Variable N:Z.
Definition eqm a b := (a mod N = b mod N).
Infix "==" := eqm (at level 70).
Instance Zplus_eqm : Proper (eqm ==> eqm ==> eqm) Z.add.
Instance Zminus_eqm : Proper (eqm ==> eqm ==> eqm) Z.sub.
Instance Zmult_eqm : Proper (eqm ==> eqm ==> eqm) Z.mul.
Instance Zopp_eqm : Proper (eqm ==> eqm) Z.opp.
(* NB: Z.modulo and Z.div are not morphisms with respect to eqm. For instance, let (==) be (eqm 2). Then we have (3 == 1) but: ~ (3 mod 3 == 1 mod 3) ~ (1 mod 3 == 1 mod 1) ~ (3/3 == 1/3) ~ (1/3 == 1/1) *)
End EqualityModulo.
(** Unfortunately, the previous result isn't always true on negative numbers. For instance: 3/(-2)/(-2) = 1 <> 0 = 3 / (-2*-2) *)
(** A last inequality: *)
(** Particular case : dividing by 2 is related with parity *)
Proof Z.div2_div.
(** * Compatibility *)
(** Weaker results kept only for compatibility *)

Lemma Z_div_exact_1 : forall a b:Z, b > 0 -> a = b*(a/b) -> a mod b = 0.