Module Import Private_NZDiv := Nop <+ NZDivProp A D B.
(** Another formulation of the main equation *)
Ltac pos_or_neg a :=
let LT := fresh "LT" in
let LE := fresh "LE" in
destruct (le_gt_cases 0 a) as [LE|LT]; [|rewrite <- opp_pos_neg in LT].
(** Uniqueness theorems *)
(** Sign rules *)
(** A division by itself returns 1 *)
(** A division of a small number by a bigger one yields zero. *)
(** * Order results about mod and div *)
(** A modulo cannot grow beyond its starting point. *)
(** As soon as the divisor is strictly greater than 1, the division is strictly decreasing. *)
(** In this convention, [div] performs Rounding-Toward-Bottom when divisor is positive, and Rounding-Toward-Top otherwise.  Since we cannot speak of rational values here, we express this fact by multiplying back by [b], and this leads to a nice unique statement. *)
(** Giving a reversed bound is slightly more complex *)
(** NB: The three previous properties could be used as specifications for [div]. *)
(** Inequality [mul_div_le] is exact iff the modulo is zero. *)
(** Some additional inequalities about div. *)
(** A division respects opposite monotonicity for the divisor *)
(** Cancellations. *)
(** With the current convention, the following isn't always true when [c<0]: [-3*-1 / -2*-1 = 3/2 = 1] while [-3/-2 = 2] *)
(** Operations modulo. *)
(** With the current convention, the following result isn't always true with a negative intermediate divisor. For instance [ 3/(-2)/(-2) = 1 <> 0 = 3 / (-2*-2) ] and [ 3/(-2)/2 = -1 <> 0 = 3 / (-2*2) ]. *)
(** Similarly, the following result doesn't always hold when [b<0]. For instance [3 mod (-2*-2)) = 3] while [3 mod (-2) + (-2)*((3/-2) mod -2) = -1]. *)

Lemma mod_mul_r : forall a b c, 0<b -> c~=0 ->
a mod (b*c) == a mod b + b*((a/b) mod c).