(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)
Module Type NDivPropPrivate (N : NAxiomsSig') (NP : NSubProp N).
Declare Module Private_NDivProp : NDivProp N NP.
End NDivPropPrivate.
(** Properties of Euclidean Division with a / 0 == 0 and a mod 0 == a *)
Module Type NDivProp0
(Import N : NAxiomsSig')
(Import NP : NSubProp N)
(Import D0 : NZDivSpec0 N N N)
(Import P : NDivPropPrivate N NP).
(** Let's now state again theorems, but without useless hypothesis. *)
Module Div0.

(* Specifications: *)
Lemma div_0_l : forall a, 0/a == 0.
Lemma mod_0_l : forall a, 0 mod a == 0.
#[local] Hint Rewrite div_0_l mod_0_l div_0_r mod_0_r : nz.
Lemma div_mod : forall a b, a == b*(a/b) + (a mod b).
Lemma mod_eq : forall a b, a mod b == a - b*(a/b).
Lemma mod_same : forall a, a mod a == 0.
Lemma mod_mul : forall a b, (a*b) mod b == 0.
Lemma mod_le : forall a b, a mod b <= a.
Lemma div_le_mono : forall a b c, a<=b -> a/c <= b/c.
Lemma mul_div_le : forall a b, b*(a/b) <= a.
Lemma div_exact : forall a b, (a == b*(a/b) <-> a mod b == 0).
Lemma div_lt_upper_bound : forall a b q, a < b*q -> a/b < q.
Lemma div_le_upper_bound : forall a b q, a <= b*q -> a/b <= q.
Lemma mod_add : forall a b c, (a + b * c) mod c == a mod c.
Lemma div_mul_cancel_r : forall a b c, c~=0 -> (a*c)/(b*c) == a/b.
Lemma div_mul_cancel_l : forall a b c, c~=0 -> (c*a)/(c*b) == a/b.
Lemma mul_mod_distr_r : forall a b c, (a*c) mod (b*c) == (a mod b) * c.
Lemma mul_mod_distr_l : forall a b c, (c*a) mod (c*b) == c * (a mod b).
Lemma mod_mod : forall a n, (a mod n) mod n == a mod n.
Lemma mul_mod_idemp_l : forall a b n, ((a mod n)*b) mod n == (a*b) mod n.
Lemma mul_mod_idemp_r : forall a b n, (a*(b mod n)) mod n == (a*b) mod n.
Lemma mul_mod : forall a b n, (a * b) mod n == ((a mod n) * (b mod n)) mod n.
Lemma add_mod_idemp_l : forall a b n, ((a mod n)+b) mod n == (a+b) mod n.
Lemma add_mod_idemp_r : forall a b n, (a+(b mod n)) mod n == (a+b) mod n.
Lemma add_mod : forall a b n, (a+b) mod n == (a mod n + b mod n) mod n.
Lemma div_div : forall a b c, (a/b)/c == a/(b*c).
Lemma mod_mul_r : forall a b c, a mod (b*c) == a mod b + b*((a/b) mod c).
Lemma add_mul_mod_distr_l : forall a b c d, d<c -> (c*a+d) mod (c*b) == c*(a mod b)+d.
Lemma add_mul_mod_distr_r : forall a b c d, d<c -> (a*c+d) mod (b*c) == (a mod b)*c+d.
Lemma div_mul_le : forall a b c, c*(a/b) <= (c*a)/b.
Lemma mod_divides : forall a b, (a mod b == 0 <-> exists c, a == b*c).
End Div0.