Built with Alectryon, running Coq+SerAPI v8.10.0+0.7.0. Coq sources are in this panel; goals and messages will appear in the other. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑ Ctrl+↓ to navigate, Ctrl+🖱️ to focus.
(************************************************************************)
(*         *   The Coq Proof Assistant / The Coq Development Team       *)
(*  v      *   INRIA, CNRS and contributors - Copyright 1999-2018       *)
(* <O___,, *       (see CREDITS file for the list of authors)           *)
(*   \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)         *)
(************************************************************************)

Require Import ZAxioms ZMulOrder ZSgnAbs NZDiv.

Euclidean Division for integers (Trunc convention)

We use here the convention known as Trunc, or Round-Toward-Zero, where a/b is the integer with the largest absolute value to be between zero and the exact fraction. It can be summarized by:
a = bq+r 0 |r| < |b| Sign(r) = Sign(a)
This is the convention of Ocaml and many other systems (C, ASM, ...). This convention is named "T" in the following paper:
R. Boute, "The Euclidean definition of the functions div and mod", ACM Transactions on Programming Languages and Systems, Vol. 14, No.2, pp. 127-144, April 1992.
See files ZDivFloor and ZDivEucl for others conventions.
Module Type ZQuotProp
 (Import A : ZAxiomsSig')
 (Import B : ZMulOrderProp A)
 (Import C : ZSgnAbsProp A B).
We benefit from what already exists for NZ
 Module Import Private_Div.
 Module Quot2Div <: NZDiv A.
  Definition div := quot.
  Definition modulo := A.rem.
  Definition div_wd := quot_wd.
  Definition mod_wd := rem_wd.
  Definition div_mod := quot_rem.
  Definition mod_bound_pos := rem_bound_pos.
 End Quot2Div.
 Module NZQuot := Nop <+ NZDivProp A Quot2Div B.
 End Private_Div.

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].
Another formulation of the main equation

forall a b : t, b ~= 0 -> a rem b == a - b * (a ÷ b)

forall a b : t, b ~= 0 -> a rem b == a - b * (a ÷ b)
a, b:t
H:b ~= 0

a rem b == a - b * (a ÷ b)
a, b:t
H:b ~= 0

b * (a ÷ b) + a rem b == a
a, b:t
H:b ~= 0

a == b * (a ÷ b) + a rem b
now apply quot_rem. Qed.
A few sign rules (simple ones)

forall a b : t, b ~= 0 -> - a rem - b == - (a rem b)

forall a b : t, b ~= 0 -> - a rem - b == - (a rem b)
a, b:t
H:b ~= 0

- a rem - b == - (a rem b)
now rewrite rem_opp_r, rem_opp_l. Qed.

forall a b : t, b ~= 0 -> - a ÷ b == - (a ÷ b)

forall a b : t, b ~= 0 -> - a ÷ b == - (a ÷ b)
a, b:t
H:b ~= 0

- a ÷ b == - (a ÷ b)
a, b:t
H:b ~= 0

b * (- a ÷ b) == b * - (a ÷ b)
a, b:t
H:b ~= 0

b * (- a ÷ b) + - a rem b == b * - (a ÷ b) + - a rem b
now rewrite <- quot_rem, rem_opp_l, mul_opp_r, <- opp_add_distr, <- quot_rem. Qed.

forall a b : t, b ~= 0 -> a ÷ - b == - (a ÷ b)

forall a b : t, b ~= 0 -> a ÷ - b == - (a ÷ b)
a, b:t
H:b ~= 0

a ÷ - b == - (a ÷ b)
a, b:t
H:b ~= 0
H0:- b ~= 0

a ÷ - b == - (a ÷ b)
a, b:t
H:b ~= 0
H0:- b ~= 0

- b * (a ÷ - b) == - b * - (a ÷ b)
a, b:t
H:b ~= 0
H0:- b ~= 0

- b * (a ÷ - b) + a rem - b == - b * - (a ÷ b) + a rem - b
now rewrite <- quot_rem, rem_opp_r, mul_opp_opp, <- quot_rem. Qed.

forall a b : t, b ~= 0 -> - a ÷ - b == a ÷ b

forall a b : t, b ~= 0 -> - a ÷ - b == a ÷ b
a, b:t
H:b ~= 0

- a ÷ - b == a ÷ b
now rewrite quot_opp_r, quot_opp_l, opp_involutive. Qed.
Uniqueness theorems

forall b q1 q2 r1 r2 : t, 0 <= r1 < b \/ b < r1 <= 0 -> 0 <= r2 < b \/ b < r2 <= 0 -> b * q1 + r1 == b * q2 + r2 -> q1 == q2 /\ r1 == r2

forall b q1 q2 r1 r2 : t, 0 <= r1 < b \/ b < r1 <= 0 -> 0 <= r2 < b \/ b < r2 <= 0 -> b * q1 + r1 == b * q2 + r2 -> q1 == q2 /\ r1 == r2
b, q1, q2, r1, r2:t
Hr1:0 <= r1 < b \/ b < r1 <= 0
Hr2:0 <= r2 < b \/ b < r2 <= 0
EQ:b * q1 + r1 == b * q2 + r2

q1 == q2 /\ r1 == r2
b, q1, q2, r1, r2:t
H:0 <= r1 < b
H0:0 <= r2 < b
EQ:b * q1 + r1 == b * q2 + r2

q1 == q2 /\ r1 == r2
b, q1, q2, r1, r2:t
H:b < r1 <= 0
H0:b < r2 <= 0
EQ:b * q1 + r1 == b * q2 + r2
q1 == q2 /\ r1 == r2
b, q1, q2, r1, r2:t
H:b < r1 <= 0
H0:b < r2 <= 0
EQ:b * q1 + r1 == b * q2 + r2

q1 == q2 /\ r1 == r2
b, q1, q2, r1, r2:t
H:b < r1 <= 0
H0:b < r2 <= 0
EQ:b * q1 + r1 == b * q2 + r2

q1 == q2 /\ - r1 == - r2
b, q1, q2, r1, r2:t
H:b < r1 <= 0
H0:b < r2 <= 0
EQ:b * q1 + r1 == b * q2 + r2

0 <= - r1 < - b
b, q1, q2, r1, r2:t
H:b < r1 <= 0
H0:b < r2 <= 0
EQ:b * q1 + r1 == b * q2 + r2
0 <= - r2 < - b
b, q1, q2, r1, r2:t
H:b < r1 <= 0
H0:b < r2 <= 0
EQ:b * q1 + r1 == b * q2 + r2
- b * q1 + - r1 == - b * q2 + - r2
b, q1, q2, r1, r2:t
H:b < r1 <= 0
H0:b < r2 <= 0
EQ:b * q1 + r1 == b * q2 + r2

0 <= - r2 < - b
b, q1, q2, r1, r2:t
H:b < r1 <= 0
H0:b < r2 <= 0
EQ:b * q1 + r1 == b * q2 + r2
- b * q1 + - r1 == - b * q2 + - r2
b, q1, q2, r1, r2:t
H:b < r1 <= 0
H0:b < r2 <= 0
EQ:b * q1 + r1 == b * q2 + r2

- b * q1 + - r1 == - b * q2 + - r2
now rewrite 2 mul_opp_l, <- 2 opp_add_distr, opp_inj_wd. Qed.

forall a b q r : t, 0 <= a -> 0 <= r < b -> a == b * q + r -> q == a ÷ b

forall a b q r : t, 0 <= a -> 0 <= r < b -> a == b * q + r -> q == a ÷ b
intros; now apply NZQuot.div_unique with r. Qed.

forall a b q r : t, 0 <= a -> 0 <= r < b -> a == b * q + r -> r == a rem b

forall a b q r : t, 0 <= a -> 0 <= r < b -> a == b * q + r -> r == a rem b
intros; now apply NZQuot.mod_unique with q. Qed.
A division by itself returns 1

forall a : t, a ~= 0 -> a ÷ a == 1

forall a : t, a ~= 0 -> a ÷ a == 1
a:t
H:a ~= 0

a ÷ a == 1
a:t
H:a ~= 0
LE:0 <= a

a ÷ a == 1
a:t
H:a ~= 0
LT:0 < - a
a ÷ a == 1
a:t
H:a ~= 0
LT:0 < - a

a ÷ a == 1
a:t
H:a ~= 0
LT:0 < - a

- a ÷ - a == 1
now apply NZQuot.div_same. Qed.

forall a : t, a ~= 0 -> a rem a == 0

forall a : t, a ~= 0 -> a rem a == 0
a:t
H:a ~= 0

a rem a == 0
a:t
H:a ~= 0

a - a * 1 == 0
a:t
H:a ~= 0

a - a == 0
apply sub_diag. Qed.
A division of a small number by a bigger one yields zero.

forall a b : t, 0 <= a < b -> a ÷ b == 0

forall a b : t, 0 <= a < b -> a ÷ b == 0
exact NZQuot.div_small. Qed.
Same situation, in term of remulo:

forall a b : t, 0 <= a < b -> a rem b == a

forall a b : t, 0 <= a < b -> a rem b == a
exact NZQuot.mod_small. Qed.

Basic values of divisions and modulo.


forall a : t, a ~= 0 -> 0 ÷ a == 0

forall a : t, a ~= 0 -> 0 ÷ a == 0
a:t
H:a ~= 0

0 ÷ a == 0
a:t
H:a ~= 0
LE:0 <= a

0 ÷ a == 0
a:t
H:a ~= 0
LT:0 < - a
0 ÷ a == 0
a:t
H:a ~= 0
LT:0 < - a

0 ÷ a == 0
a:t
H:a ~= 0
LT:0 < - a

0 ÷ - a == 0
now apply NZQuot.div_0_l. Qed.

forall a : t, a ~= 0 -> 0 rem a == 0

forall a : t, a ~= 0 -> 0 rem a == 0
intros; rewrite rem_eq, quot_0_l; now nzsimpl. Qed.

forall a : t, a ÷ 1 == a

forall a : t, a ÷ 1 == a
a:t

a ÷ 1 == a
a:t
LE:0 <= a

a ÷ 1 == a
a:t
LT:0 < - a
a ÷ 1 == a
a:t
LT:0 < - a

a ÷ 1 == a
a:t
LT:0 < - a

- (a ÷ 1) == - a
a:t
LT:0 < - a

- a ÷ 1 == - a
a:t
LT:0 < - a
1 ~= 0
a:t
LT:0 < - a

1 ~= 0
intro EQ; symmetry in EQ; revert EQ; apply lt_neq, lt_0_1. Qed.

forall a : t, a rem 1 == 0

forall a : t, a rem 1 == 0
a:t

a rem 1 == 0
a:t

1 ~= 0
intro EQ; symmetry in EQ; revert EQ; apply lt_neq; apply lt_0_1. Qed.

forall a : t, 1 < a -> 1 ÷ a == 0

forall a : t, 1 < a -> 1 ÷ a == 0
exact NZQuot.div_1_l. Qed.

forall a : t, 1 < a -> 1 rem a == 1

forall a : t, 1 < a -> 1 rem a == 1
exact NZQuot.mod_1_l. Qed.

forall a b : t, b ~= 0 -> a * b ÷ b == a

forall a b : t, b ~= 0 -> a * b ÷ b == a
a, b:t
H:b ~= 0

a * b ÷ b == a
a, b:t
H:b ~= 0
LE:0 <= a
LE0:0 <= b

a * b ÷ b == a
a, b:t
H:b ~= 0
LE:0 <= a
LT:0 < - b
a * b ÷ b == a
a, b:t
H:b ~= 0
LT:0 < - a
LE:0 <= b
a * b ÷ b == a
a, b:t
H:b ~= 0
LT:0 < - a
LT0:0 < - b
a * b ÷ b == a
a, b:t
H:b ~= 0
LE:0 <= a
LT:0 < - b

a * b ÷ b == a
a, b:t
H:b ~= 0
LT:0 < - a
LE:0 <= b
a * b ÷ b == a
a, b:t
H:b ~= 0
LT:0 < - a
LT0:0 < - b
a * b ÷ b == a
a, b:t
H:b ~= 0
LE:0 <= a
LT:0 < - b

a * - b ÷ - b == a
a, b:t
H:b ~= 0
LT:0 < - a
LE:0 <= b
a * b ÷ b == a
a, b:t
H:b ~= 0
LT:0 < - a
LT0:0 < - b
a * b ÷ b == a
a, b:t
H:b ~= 0
LT:0 < - a
LE:0 <= b

a * b ÷ b == a
a, b:t
H:b ~= 0
LT:0 < - a
LT0:0 < - b
a * b ÷ b == a
a, b:t
H:b ~= 0
LT:0 < - a
LE:0 <= b

- a * b ÷ b == - a
a, b:t
H:b ~= 0
LT:0 < - a
LT0:0 < - b
a * b ÷ b == a
a, b:t
H:b ~= 0
LT:0 < - a
LT0:0 < - b

a * b ÷ b == a
a, b:t
H:b ~= 0
LT:0 < - a
LT0:0 < - b

- a * - b ÷ - b == - a
apply NZQuot.div_mul; order. Qed.

forall a b : t, b ~= 0 -> (a * b) rem b == 0

forall a b : t, b ~= 0 -> (a * b) rem b == 0
a, b:t
H:b ~= 0

(a * b) rem b == 0
a, b:t
H:b ~= 0

a * b - b * a == 0
rewrite mul_comm; apply sub_diag. Qed.
a, b, q:t

b ~= 0 -> a == b * q -> q == a ÷ b
a, b, q:t

b ~= 0 -> a == b * q -> q == a ÷ b
a, b, q:t
Hb:b ~= 0
H:a == b * q

q == a ÷ b
a, b, q:t
Hb:b ~= 0
H:a == b * q

q == q * b ÷ b
a, b, q:t
Hb:b ~= 0
H:a == b * q

q * b ÷ b == q
now apply quot_mul. Qed.
The sign of a rem b is the one of a (when it's not null)

forall a b : t, b ~= 0 -> 0 <= a -> 0 <= a rem b

forall a b : t, b ~= 0 -> 0 <= a -> 0 <= a rem b
a, b:t
H:b ~= 0
H0:0 <= a

0 <= a rem b
a, b:t
H:b ~= 0
H0:0 <= a
LE:0 <= b

0 <= a rem b
a, b:t
H:b ~= 0
H0:0 <= a
LT:0 < - b
0 <= a rem b
a, b:t
H:b ~= 0
H0:0 <= a
LT:0 < - b

0 <= a rem b
a, b:t
H:b ~= 0
H0:0 <= a
LT:0 < - b

0 <= a rem - b
destruct (rem_bound_pos a (-b)); trivial. Qed.

forall a b : t, b ~= 0 -> a <= 0 -> a rem b <= 0

forall a b : t, b ~= 0 -> a <= 0 -> a rem b <= 0
a, b:t
Hb:b ~= 0
Ha:a <= 0

a rem b <= 0
a, b:t
Hb:b ~= 0
Ha:a <= 0

0 <= - (a rem b)
a, b:t
Hb:b ~= 0
Ha:0 <= - a

0 <= - (a rem b)
a, b:t
Hb:b ~= 0
Ha:0 <= - a

0 <= - a rem b
now apply rem_nonneg. Qed.

forall a b : t, b ~= 0 -> 0 <= a rem b * a

forall a b : t, b ~= 0 -> 0 <= a rem b * a
a, b:t
Hb:b ~= 0

0 <= a rem b * a
a, b:t
Hb:b ~= 0
H:0 <= a

0 <= a rem b * a
a, b:t
Hb:b ~= 0
H:a <= 0
0 <= a rem b * a
a, b:t
Hb:b ~= 0
H:0 <= a

0 <= a rem b
a, b:t
Hb:b ~= 0
H:a <= 0
0 <= a rem b * a
a, b:t
Hb:b ~= 0
H:a <= 0

0 <= a rem b * a
a, b:t
Hb:b ~= 0
H:a <= 0

a rem b <= 0
now apply rem_nonpos. Qed.

forall a b : t, b ~= 0 -> a rem b ~= 0 -> sgn (a rem b) == sgn a

forall a b : t, b ~= 0 -> a rem b ~= 0 -> sgn (a rem b) == sgn a
a, b:t
Hb:b ~= 0
H:a rem b ~= 0

sgn (a rem b) == sgn a
a, b:t
Hb:b ~= 0
H:a rem b ~= 0
LT:0 < a

sgn (a rem b) == sgn a
a, b:t
Hb:b ~= 0
H:a rem b ~= 0
EQ:0 == a
sgn (a rem b) == sgn a
a, b:t
Hb:b ~= 0
H:a rem b ~= 0
LT:a < 0
sgn (a rem b) == sgn a
a, b:t
Hb:b ~= 0
H:a rem b ~= 0
LT:0 < a

0 < a rem b
a, b:t
Hb:b ~= 0
H:a rem b ~= 0
EQ:0 == a
sgn (a rem b) == sgn a
a, b:t
Hb:b ~= 0
H:a rem b ~= 0
LT:a < 0
sgn (a rem b) == sgn a
a, b:t
Hb:b ~= 0
H:a rem b ~= 0
LT:0 < a

0 <= a rem b -> 0 < a rem b
a, b:t
Hb:b ~= 0
H:a rem b ~= 0
EQ:0 == a
sgn (a rem b) == sgn a
a, b:t
Hb:b ~= 0
H:a rem b ~= 0
LT:a < 0
sgn (a rem b) == sgn a
a, b:t
Hb:b ~= 0
H:a rem b ~= 0
EQ:0 == a

sgn (a rem b) == sgn a
a, b:t
Hb:b ~= 0
H:a rem b ~= 0
LT:a < 0
sgn (a rem b) == sgn a
a, b:t
Hb:b ~= 0
H:a rem b ~= 0
LT:a < 0

sgn (a rem b) == sgn a
a, b:t
Hb:b ~= 0
H:a rem b ~= 0
LT:a < 0

a rem b < 0
a, b:t
Hb:b ~= 0
H:a rem b ~= 0
LT:a < 0

a rem b <= 0 -> a rem b < 0
order. Qed.

forall a b : t, a ~= 0 -> b ~= 0 -> sgn (a rem b) ~= - sgn a

forall a b : t, a ~= 0 -> b ~= 0 -> sgn (a rem b) ~= - sgn a
a, b:t
Ha:a ~= 0
Hb:b ~= 0
H:sgn (a rem b) == - sgn a

False
a, b:t
Ha:a ~= 0
Hb:b ~= 0
H:sgn (a rem b) == - sgn a
EQ:a rem b == 0

False
a, b:t
Ha:a ~= 0
Hb:b ~= 0
H:sgn (a rem b) == - sgn a
NEQ:a rem b ~= 0
False
a, b:t
Ha:a ~= 0
Hb:b ~= 0
H:sgn (a rem b) == - sgn a
EQ:a rem b == 0

- sgn a == - 0
a, b:t
Ha:a ~= 0
Hb:b ~= 0
H:sgn (a rem b) == - sgn a
NEQ:a rem b ~= 0
False
a, b:t
Ha:a ~= 0
Hb:b ~= 0
H:sgn (a rem b) == - sgn a
NEQ:a rem b ~= 0

False
a, b:t
Ha:a ~= 0
Hb:b ~= 0
H:sgn (a rem b) == - sgn a
NEQ:a rem b ~= 0

sgn a == 0
a, b:t
Ha:a ~= 0
Hb:b ~= 0
H:sgn (a rem b) == - sgn a
NEQ:a rem b ~= 0

sgn a * 2 == 0
a, b:t
Ha:a ~= 0
Hb:b ~= 0
H:sgn (a rem b) == - sgn a
NEQ:a rem b ~= 0

sgn a + sgn a == 0
a, b:t
Ha:a ~= 0
Hb:b ~= 0
H:sgn (a rem b) == - sgn a
NEQ:a rem b ~= 0

sgn a == - sgn a
a, b:t
Ha:a ~= 0
Hb:b ~= 0
H:sgn (a rem b) == - sgn a
NEQ:a rem b ~= 0

sgn a == sgn (a rem b)
a, b:t
Ha:a ~= 0
Hb:b ~= 0
H:sgn (a rem b) == - sgn a
NEQ:a rem b ~= 0

sgn (a rem b) == sgn a
now apply rem_sign_nz. Qed.
Operations and absolute value

forall a b : t, b ~= 0 -> abs a rem b == abs (a rem b)

forall a b : t, b ~= 0 -> abs a rem b == abs (a rem b)
a, b:t
Hb:b ~= 0

abs a rem b == abs (a rem b)
a, b:t
Hb:b ~= 0
LE:0 <= a

abs a rem b == abs (a rem b)
a, b:t
Hb:b ~= 0
LE:a <= 0
abs a rem b == abs (a rem b)
a, b:t
Hb:b ~= 0
LE:0 <= a

0 <= a rem b
a, b:t
Hb:b ~= 0
LE:a <= 0
abs a rem b == abs (a rem b)
a, b:t
Hb:b ~= 0
LE:a <= 0

abs a rem b == abs (a rem b)
a, b:t
Hb:b ~= 0
LE:a <= 0

a rem b <= 0
now apply rem_nonpos. Qed.

forall a b : t, b ~= 0 -> a rem abs b == a rem b

forall a b : t, b ~= 0 -> a rem abs b == a rem b
a, b:t
Hb:b ~= 0

a rem abs b == a rem b
a, b:t
Hb:b ~= 0
H:0 <= b

a rem abs b == a rem b
a, b:t
Hb:b ~= 0
H:b <= 0
a rem abs b == a rem b
a, b:t
Hb:b ~= 0
H:b <= 0

a rem abs b == a rem b
now rewrite abs_neq, ?rem_opp_r. Qed.

forall a b : t, b ~= 0 -> abs a rem abs b == abs (a rem b)

forall a b : t, b ~= 0 -> abs a rem abs b == abs (a rem b)
a, b:t
H:b ~= 0

abs a rem abs b == abs (a rem b)
now rewrite rem_abs_r, rem_abs_l. Qed.

forall a b : t, b ~= 0 -> abs a ÷ b == sgn a * (a ÷ b)

forall a b : t, b ~= 0 -> abs a ÷ b == sgn a * (a ÷ b)
a, b:t
Hb:b ~= 0

abs a ÷ b == sgn a * (a ÷ b)
a, b:t
Hb:b ~= 0
LT:0 < a

abs a ÷ b == sgn a * (a ÷ b)
a, b:t
Hb:b ~= 0
EQ:0 == a
abs a ÷ b == sgn a * (a ÷ b)
a, b:t
Hb:b ~= 0
LT:a < 0
abs a ÷ b == sgn a * (a ÷ b)
a, b:t
Hb:b ~= 0
LT:0 < a

a ÷ b == 1 * (a ÷ b)
a, b:t
Hb:b ~= 0
EQ:0 == a
abs a ÷ b == sgn a * (a ÷ b)
a, b:t
Hb:b ~= 0
LT:a < 0
abs a ÷ b == sgn a * (a ÷ b)
a, b:t
Hb:b ~= 0
EQ:0 == a

abs a ÷ b == sgn a * (a ÷ b)
a, b:t
Hb:b ~= 0
LT:a < 0
abs a ÷ b == sgn a * (a ÷ b)
a, b:t
Hb:b ~= 0
EQ:0 == a

0 == sgn 0 * 0
a, b:t
Hb:b ~= 0
LT:a < 0
abs a ÷ b == sgn a * (a ÷ b)
a, b:t
Hb:b ~= 0
LT:a < 0

abs a ÷ b == sgn a * (a ÷ b)
a, b:t
Hb:b ~= 0
LT:a < 0

- (a ÷ b) == -1 * (a ÷ b)
a, b:t
Hb:b ~= 0
LT:a < 0

- (a ÷ b) == - (1 * (a ÷ b))
now nzsimpl. Qed.

forall a b : t, b ~= 0 -> a ÷ abs b == sgn b * (a ÷ b)

forall a b : t, b ~= 0 -> a ÷ abs b == sgn b * (a ÷ b)
a, b:t
Hb:b ~= 0

a ÷ abs b == sgn b * (a ÷ b)
a, b:t
Hb:b ~= 0
LT:0 < b

a ÷ abs b == sgn b * (a ÷ b)
a, b:t
Hb:b ~= 0
EQ:0 == b
a ÷ abs b == sgn b * (a ÷ b)
a, b:t
Hb:b ~= 0
LT:b < 0
a ÷ abs b == sgn b * (a ÷ b)
a, b:t
Hb:b ~= 0
LT:0 < b

a ÷ b == 1 * (a ÷ b)
a, b:t
Hb:b ~= 0
EQ:0 == b
a ÷ abs b == sgn b * (a ÷ b)
a, b:t
Hb:b ~= 0
LT:b < 0
a ÷ abs b == sgn b * (a ÷ b)
a, b:t
Hb:b ~= 0
EQ:0 == b

a ÷ abs b == sgn b * (a ÷ b)
a, b:t
Hb:b ~= 0
LT:b < 0
a ÷ abs b == sgn b * (a ÷ b)
a, b:t
Hb:b ~= 0
LT:b < 0

a ÷ abs b == sgn b * (a ÷ b)
a, b:t
Hb:b ~= 0
LT:b < 0

- (a ÷ b) == -1 * (a ÷ b)
a, b:t
Hb:b ~= 0
LT:b < 0

- (a ÷ b) == - (1 * (a ÷ b))
now nzsimpl. Qed.

forall a b : t, b ~= 0 -> abs a ÷ abs b == abs (a ÷ b)

forall a b : t, b ~= 0 -> abs a ÷ abs b == abs (a ÷ b)
a, b:t
Hb:b ~= 0

abs a ÷ abs b == abs (a ÷ b)
a, b:t
Hb:b ~= 0
LE:0 <= a

a ÷ abs b == abs (a ÷ b)
a, b:t
Hb:b ~= 0
LT:0 < - a
- a ÷ abs b == abs (a ÷ b)
a, b:t
Hb:b ~= 0
LE:0 <= a
LE0:0 <= b

a ÷ b == abs (a ÷ b)
a, b:t
Hb:b ~= 0
LE:0 <= a
LT:0 < - b
a ÷ - b == abs (a ÷ b)
a, b:t
Hb:b ~= 0
LT:0 < - a
- a ÷ abs b == abs (a ÷ b)
a, b:t
Hb:b ~= 0
LE:0 <= a
LE0:0 <= b

0 <= a ÷ b
a, b:t
Hb:b ~= 0
LE:0 <= a
LT:0 < - b
a ÷ - b == abs (a ÷ b)
a, b:t
Hb:b ~= 0
LT:0 < - a
- a ÷ abs b == abs (a ÷ b)
a, b:t
Hb:b ~= 0
LE:0 <= a
LT:0 < - b

a ÷ - b == abs (a ÷ b)
a, b:t
Hb:b ~= 0
LT:0 < - a
- a ÷ abs b == abs (a ÷ b)
a, b:t
Hb:b ~= 0
LE:0 <= a
LT:0 < - b

0 <= a ÷ - b
a, b:t
Hb:b ~= 0
LT:0 < - a
- a ÷ abs b == abs (a ÷ b)
a, b:t
Hb:b ~= 0
LT:0 < - a

- a ÷ abs b == abs (a ÷ b)
a, b:t
Hb:b ~= 0
LT:0 < - a
LE:0 <= b

- a ÷ b == abs (a ÷ b)
a, b:t
Hb:b ~= 0
LT:0 < - a
LT0:0 < - b
- a ÷ - b == abs (a ÷ b)
a, b:t
Hb:b ~= 0
LT:0 < - a
LE:0 <= b

0 <= - a ÷ b
a, b:t
Hb:b ~= 0
LT:0 < - a
LT0:0 < - b
- a ÷ - b == abs (a ÷ b)
a, b:t
Hb:b ~= 0
LT:0 < - a
LT0:0 < - b

- a ÷ - b == abs (a ÷ b)
a, b:t
Hb:b ~= 0
LT:0 < - a
LT0:0 < - b

0 <= - a ÷ - b
apply NZQuot.div_pos; order. Qed.
We have a general bound for absolute values

forall a b : t, b ~= 0 -> abs (a rem b) < abs b

forall a b : t, b ~= 0 -> abs (a rem b) < abs b
a, b:t
H:b ~= 0

abs (a rem b) < abs b
a, b:t
H:b ~= 0

abs a rem abs b < abs b
a, b:t
H:b ~= 0

0 <= abs a
a, b:t
H:b ~= 0
0 < abs b
a, b:t
H:b ~= 0

0 < abs b
now apply abs_pos. Qed.

Order results about rem and quot

A modulo cannot grow beyond its starting point.

forall a b : t, 0 <= a -> 0 < b -> a rem b <= a

forall a b : t, 0 <= a -> 0 < b -> a rem b <= a
exact NZQuot.mod_le. Qed.

forall a b : t, 0 <= a -> 0 < b -> 0 <= a ÷ b

forall a b : t, 0 <= a -> 0 < b -> 0 <= a ÷ b
exact NZQuot.div_pos. Qed.

forall a b : t, 0 < b <= a -> 0 < a ÷ b

forall a b : t, 0 < b <= a -> 0 < a ÷ b
exact NZQuot.div_str_pos. Qed.

forall a b : t, b ~= 0 -> a ÷ b == 0 <-> abs a < abs b

forall a b : t, b ~= 0 -> a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0

a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LE:0 <= a
LE0:0 <= b

a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LE:0 <= a
LT:0 < - b
a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LT:0 < - a
LE:0 <= b
a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LT:0 < - a
LT0:0 < - b
a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LE:0 <= a
LE0:0 <= b

a < b <-> abs a < abs b
a, b:t
H:b ~= 0
LE:0 <= a
LT:0 < - b
a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LT:0 < - a
LE:0 <= b
a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LT:0 < - a
LT0:0 < - b
a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LE:0 <= a
LT:0 < - b

a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LT:0 < - a
LE:0 <= b
a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LT:0 < - a
LT0:0 < - b
a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LE:0 <= a
LT:0 < - b

a < - b <-> abs a < abs b
a, b:t
H:b ~= 0
LT:0 < - a
LE:0 <= b
a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LT:0 < - a
LT0:0 < - b
a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LT:0 < - a
LE:0 <= b

a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LT:0 < - a
LT0:0 < - b
a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LT:0 < - a
LE:0 <= b

- a < b <-> abs a < abs b
a, b:t
H:b ~= 0
LT:0 < - a
LT0:0 < - b
a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LT:0 < - a
LT0:0 < - b

a ÷ b == 0 <-> abs a < abs b
a, b:t
H:b ~= 0
LT:0 < - a
LT0:0 < - b

- a < - b <-> abs a < abs b
rewrite (abs_neq' a), (abs_neq' b); intuition; order. Qed.

forall a b : t, b ~= 0 -> a rem b == a <-> abs a < abs b

forall a b : t, b ~= 0 -> a rem b == a <-> abs a < abs b
a, b:t
H:b ~= 0

a rem b == a <-> abs a < abs b
a, b:t
H:b ~= 0

a - b * (a ÷ b) == a <-> a ÷ b == 0
a, b:t
H:b ~= 0

a + 0 == a + b * (a ÷ b) <-> a ÷ b == 0
a, b:t
H:b ~= 0

0 == b * (a ÷ b) <-> a ÷ b == 0
a, b:t
H:b ~= 0

b == 0 \/ a ÷ b == 0 <-> a ÷ b == 0
tauto. Qed.
As soon as the divisor is strictly greater than 1, the division is strictly decreasing.

forall a b : t, 0 < a -> 1 < b -> a ÷ b < a

forall a b : t, 0 < a -> 1 < b -> a ÷ b < a
exact NZQuot.div_lt. Qed.
le is compatible with a positive division.

forall a b c : t, 0 < c -> a <= b -> a ÷ c <= b ÷ c

forall a b c : t, 0 < c -> a <= b -> a ÷ c <= b ÷ c
a, b, c:t
H:0 < c
H0:a <= b

a ÷ c <= b ÷ c
a, b, c:t
H:0 < c
H0:a <= b
LE:0 <= a

a ÷ c <= b ÷ c
a, b, c:t
H:0 < c
H0:a <= b
LT:0 < - a
a ÷ c <= b ÷ c
a, b, c:t
H:0 < c
H0:a <= b
LT:0 < - a

a ÷ c <= b ÷ c
a, b, c:t
H:0 < c
H0:a <= b
LT:0 < - a
LE:0 <= b

a ÷ c <= b ÷ c
a, b, c:t
H:0 < c
H0:a <= b
LT:0 < - a
LT0:0 < - b
a ÷ c <= b ÷ c
a, b, c:t
H:0 < c
H0:a <= b
LT:0 < - a
LE:0 <= b

a ÷ c <= 0
a, b, c:t
H:0 < c
H0:a <= b
LT:0 < - a
LE:0 <= b
0 <= b ÷ c
a, b, c:t
H:0 < c
H0:a <= b
LT:0 < - a
LT0:0 < - b
a ÷ c <= b ÷ c
a, b, c:t
H:0 < c
H0:a <= b
LT:0 < - a
LE:0 <= b

0 <= - a ÷ c
a, b, c:t
H:0 < c
H0:a <= b
LT:0 < - a
LE:0 <= b
0 <= b ÷ c
a, b, c:t
H:0 < c
H0:a <= b
LT:0 < - a
LT0:0 < - b
a ÷ c <= b ÷ c
a, b, c:t
H:0 < c
H0:a <= b
LT:0 < - a
LE:0 <= b

0 <= b ÷ c
a, b, c:t
H:0 < c
H0:a <= b
LT:0 < - a
LT0:0 < - b
a ÷ c <= b ÷ c
a, b, c:t
H:0 < c
H0:a <= b
LT:0 < - a
LT0:0 < - b

a ÷ c <= b ÷ c
a, b, c:t
H:0 < c
H0:- b <= - a
LT:0 < - a
LT0:0 < - b

- (b ÷ c) <= - (a ÷ c)
a, b, c:t
H:0 < c
H0:- b <= - a
LT:0 < - a
LT0:0 < - b

- b ÷ c <= - a ÷ c
apply NZQuot.div_le_mono; intuition; order. Qed.
With this choice of division, rounding of quot is always done toward zero:

forall a b : t, 0 <= a -> b ~= 0 -> 0 <= b * (a ÷ b) <= a

forall a b : t, 0 <= a -> b ~= 0 -> 0 <= b * (a ÷ b) <= a
a, b:t
H:0 <= a
H0:b ~= 0

0 <= b * (a ÷ b) <= a
a, b:t
H:0 <= a
H0:b ~= 0
LE:0 <= b

0 <= b * (a ÷ b) <= a
a, b:t
H:0 <= a
H0:b ~= 0
LT:0 < - b
0 <= b * (a ÷ b) <= a
a, b:t
H:0 <= a
H0:b ~= 0
LE:0 <= b

0 <= b * (a ÷ b)
a, b:t
H:0 <= a
H0:b ~= 0
LE:0 <= b
b * (a ÷ b) <= a
a, b:t
H:0 <= a
H0:b ~= 0
LT:0 < - b
0 <= b * (a ÷ b) <= a
a, b:t
H:0 <= a
H0:b ~= 0
LE:0 <= b

b * (a ÷ b) <= a
a, b:t
H:0 <= a
H0:b ~= 0
LT:0 < - b
0 <= b * (a ÷ b) <= a
a, b:t
H:0 <= a
H0:b ~= 0
LT:0 < - b

0 <= b * (a ÷ b) <= a
a, b:t
H:0 <= a
H0:b ~= 0
LT:0 < - b

0 <= - b * (a ÷ - b) <= a
a, b:t
H:0 <= a
H0:b ~= 0
LT:0 < - b

0 <= - b * (a ÷ - b)
a, b:t
H:0 <= a
H0:b ~= 0
LT:0 < - b
- b * (a ÷ - b) <= a
a, b:t
H:0 <= a
H0:b ~= 0
LT:0 < - b

- b * (a ÷ - b) <= a
apply NZQuot.mul_div_le; order. Qed.

forall a b : t, a <= 0 -> b ~= 0 -> a <= b * (a ÷ b) <= 0

forall a b : t, a <= 0 -> b ~= 0 -> a <= b * (a ÷ b) <= 0
a, b:t
H:a <= 0
H0:b ~= 0

a <= b * (a ÷ b) <= 0
a, b:t
H:a <= 0
H0:b ~= 0

b * (- a ÷ b) <= - a /\ 0 <= b * (- a ÷ b)
a, b:t
H:0 <= - a
H0:b ~= 0

b * (- a ÷ b) <= - a /\ 0 <= b * (- a ÷ b)
destruct (mul_quot_le (-a) b); tauto. Qed.
For positive numbers, considering S (a÷b) leads to an upper bound for a

forall a b : t, 0 <= a -> 0 < b -> a < b * S (a ÷ b)

forall a b : t, 0 <= a -> 0 < b -> a < b * S (a ÷ b)
exact NZQuot.mul_succ_div_gt. Qed.
Similar results with negative numbers

forall a b : t, a <= 0 -> 0 < b -> b * P (a ÷ b) < a

forall a b : t, a <= 0 -> 0 < b -> b * P (a ÷ b) < a
a, b:t
H:a <= 0
H0:0 < b

b * P (a ÷ b) < a
a, b:t
H:a <= 0
H0:0 < b

- a < b * S (- a ÷ b)
a, b:t
H:0 <= - a
H0:0 < b

- a < b * S (- a ÷ b)
now apply mul_succ_quot_gt. Qed.

forall a b : t, 0 <= a -> b < 0 -> a < b * P (a ÷ b)

forall a b : t, 0 <= a -> b < 0 -> a < b * P (a ÷ b)
a, b:t
H:0 <= a
H0:b < 0

a < b * P (a ÷ b)
a, b:t
H:0 <= a
H0:b < 0

a < - b * S (a ÷ - b)
a, b:t
H:0 <= a
H0:0 < - b

a < - b * S (a ÷ - b)
now apply mul_succ_quot_gt. Qed.

forall a b : t, a <= 0 -> b < 0 -> b * S (a ÷ b) < a

forall a b : t, a <= 0 -> b < 0 -> b * S (a ÷ b) < a
a, b:t
H:a <= 0
H0:b < 0

b * S (a ÷ b) < a
a, b:t
H:a <= 0
H0:b < 0

- a < - b * S (- a ÷ - b)
a, b:t
H:0 <= - a
H0:0 < - b

- a < - b * S (- a ÷ - b)
now apply mul_succ_quot_gt. Qed.
Inequality mul_quot_le is exact iff the modulo is zero.

forall a b : t, b ~= 0 -> a == b * (a ÷ b) <-> a rem b == 0

forall a b : t, b ~= 0 -> a == b * (a ÷ b) <-> a rem b == 0
a, b:t
H:b ~= 0

a == b * (a ÷ b) <-> a rem b == 0
a, b:t
H:b ~= 0

a == b * (a ÷ b) <-> a - b * (a ÷ b) == 0
rewrite sub_move_r; nzsimpl; tauto. Qed.
Some additional inequalities about quot.

forall a b q : t, 0 <= a -> 0 < b -> a < b * q -> a ÷ b < q

forall a b q : t, 0 <= a -> 0 < b -> a < b * q -> a ÷ b < q
exact NZQuot.div_lt_upper_bound. Qed.

forall a b q : t, 0 < b -> a <= b * q -> a ÷ b <= q

forall a b q : t, 0 < b -> a <= b * q -> a ÷ b <= q
a, b, q:t
H:0 < b
H0:a <= b * q

a ÷ b <= q
a, b, q:t
H:0 < b
H0:a <= b * q

a ÷ b <= q * b ÷ b
a, b, q:t
H:0 < b
H0:a <= b * q

a <= q * b
now rewrite mul_comm. Qed.

forall a b q : t, 0 < b -> b * q <= a -> q <= a ÷ b

forall a b q : t, 0 < b -> b * q <= a -> q <= a ÷ b
a, b, q:t
H:0 < b
H0:b * q <= a

q <= a ÷ b
a, b, q:t
H:0 < b
H0:b * q <= a

q * b ÷ b <= a ÷ b
a, b, q:t
H:0 < b
H0:b * q <= a

q * b <= a
now rewrite mul_comm. Qed.
A division respects opposite monotonicity for the divisor

forall p q r : t, 0 <= p -> 0 < q <= r -> p ÷ r <= p ÷ q

forall p q r : t, 0 <= p -> 0 < q <= r -> p ÷ r <= p ÷ q
exact NZQuot.div_le_compat_l. Qed.

Relations between usual operations and rem and quot

Unlike with other division conventions, some results here aren't always valid, and need to be restricted. For instance (a+b×c) rem c a rem c for a=9,b=-5,c=2

forall a b c : t, c ~= 0 -> 0 <= (a + b * c) * a -> (a + b * c) rem c == a rem c

forall a b c : t, c ~= 0 -> 0 <= (a + b * c) * a -> (a + b * c) rem c == a rem c

forall a b c : t, c ~= 0 -> 0 <= a -> 0 <= a + b * c -> (a + b * c) rem c == a rem c
H:forall a b c : t, c ~= 0 -> 0 <= a -> 0 <= a + b * c -> (a + b * c) rem c == a rem c
forall a b c : t, c ~= 0 -> 0 <= (a + b * c) * a -> (a + b * c) rem c == a rem c
a, b, c:t
H:c ~= 0
H0:0 <= a
H1:0 <= a + b * c

(a + b * c) rem c == a rem c
H:forall a b c : t, c ~= 0 -> 0 <= a -> 0 <= a + b * c -> (a + b * c) rem c == a rem c
forall a b c : t, c ~= 0 -> 0 <= (a + b * c) * a -> (a + b * c) rem c == a rem c
a, b, c:t
H:c ~= 0
H0:0 <= a
H1:0 <= a + b * c
LE:0 <= c

(a + b * c) rem c == a rem c
a, b, c:t
H:c ~= 0
H0:0 <= a
H1:0 <= a + b * c
LT:0 < - c
(a + b * c) rem c == a rem c
H:forall a b c : t, c ~= 0 -> 0 <= a -> 0 <= a + b * c -> (a + b * c) rem c == a rem c
forall a b c : t, c ~= 0 -> 0 <= (a + b * c) * a -> (a + b * c) rem c == a rem c
a, b, c:t
H:c ~= 0
H0:0 <= a
H1:0 <= a + b * c
LT:0 < - c

(a + b * c) rem c == a rem c
H:forall a b c : t, c ~= 0 -> 0 <= a -> 0 <= a + b * c -> (a + b * c) rem c == a rem c
forall a b c : t, c ~= 0 -> 0 <= (a + b * c) * a -> (a + b * c) rem c == a rem c
a, b, c:t
H:c ~= 0
H0:0 <= a
H1:0 <= a + b * c
LT:0 < - c

(a + b * c) rem - c == a rem - c
H:forall a b c : t, c ~= 0 -> 0 <= a -> 0 <= a + b * c -> (a + b * c) rem c == a rem c
forall a b c : t, c ~= 0 -> 0 <= (a + b * c) * a -> (a + b * c) rem c == a rem c
a, b, c:t
H:c ~= 0
H0:0 <= a
H1:0 <= a + - b * - c
LT:0 < - c

(a + - b * - c) rem - c == a rem - c
H:forall a b c : t, c ~= 0 -> 0 <= a -> 0 <= a + b * c -> (a + b * c) rem c == a rem c
forall a b c : t, c ~= 0 -> 0 <= (a + b * c) * a -> (a + b * c) rem c == a rem c
H:forall a b c : t, c ~= 0 -> 0 <= a -> 0 <= a + b * c -> (a + b * c) rem c == a rem c

forall a b c : t, c ~= 0 -> 0 <= (a + b * c) * a -> (a + b * c) rem c == a rem c
H:forall a0 b0 c0 : t, c0 ~= 0 -> 0 <= a0 -> 0 <= a0 + b0 * c0 -> (a0 + b0 * c0) rem c0 == a0 rem c0
a, b, c:t
Hc:c ~= 0
Habc:0 <= (a + b * c) * a

(a + b * c) rem c == a rem c
H:forall a0 b0 c0 : t, c0 ~= 0 -> 0 <= a0 -> 0 <= a0 + b0 * c0 -> (a0 + b0 * c0) rem c0 == a0 rem c0
a, b, c:t
Hc:c ~= 0
Habc:0 <= (a + b * c) * a
Habc':0 <= a + b * c
Ha:0 <= a

(a + b * c) rem c == a rem c
H:forall a0 b0 c0 : t, c0 ~= 0 -> 0 <= a0 -> 0 <= a0 + b0 * c0 -> (a0 + b0 * c0) rem c0 == a0 rem c0
a, b, c:t
Hc:c ~= 0
Habc:0 <= (a + b * c) * a
Habc':a + b * c <= 0
Ha:a <= 0
(a + b * c) rem c == a rem c
H:forall a0 b0 c0 : t, c0 ~= 0 -> 0 <= a0 -> 0 <= a0 + b0 * c0 -> (a0 + b0 * c0) rem c0 == a0 rem c0
a, b, c:t
Hc:c ~= 0
Habc:0 <= (a + b * c) * a
Habc':a + b * c <= 0
Ha:a <= 0

(a + b * c) rem c == a rem c
H:forall a0 b0 c0 : t, c0 ~= 0 -> 0 <= a0 -> 0 <= a0 + b0 * c0 -> (a0 + b0 * c0) rem c0 == a0 rem c0
a, b, c:t
Hc:c ~= 0
Habc:0 <= (a + b * c) * a
Habc':a + b * c <= 0
Ha:a <= 0

- ((a + b * c) rem c) == - (a rem c)
H:forall a0 b0 c0 : t, c0 ~= 0 -> 0 <= a0 -> 0 <= a0 + b0 * c0 -> (a0 + b0 * c0) rem c0 == a0 rem c0
a, b, c:t
Hc:c ~= 0
Habc:0 <= (a + b * c) * a

a <= 0 -> a + b * c <= 0 -> - ((a + b * c) rem c) == - (a rem c)
H:forall a0 b0 c0 : t, c0 ~= 0 -> 0 <= a0 -> 0 <= a0 + b0 * c0 -> (a0 + b0 * c0) rem c0 == a0 rem c0
a, b, c:t
Hc:c ~= 0
Habc:0 <= (a + b * c) * a

0 <= - a -> 0 <= - (a + b * c) -> - ((a + b * c) rem c) == - (a rem c)
H:forall a0 b0 c0 : t, c0 ~= 0 -> 0 <= a0 -> 0 <= a0 + b0 * c0 -> (a0 + b0 * c0) rem c0 == a0 rem c0
a, b, c:t
Hc:c ~= 0
Habc:0 <= (a + b * c) * a

0 <= - a -> 0 <= - a + - b * c -> (- a + - b * c) rem c == - a rem c
auto. Qed.

forall a b c : t, c ~= 0 -> 0 <= (a + b * c) * a -> (a + b * c) ÷ c == a ÷ c + b

forall a b c : t, c ~= 0 -> 0 <= (a + b * c) * a -> (a + b * c) ÷ c == a ÷ c + b
a, b, c:t
H:c ~= 0
H0:0 <= (a + b * c) * a

(a + b * c) ÷ c == a ÷ c + b
a, b, c:t
H:c ~= 0
H0:0 <= (a + b * c) * a

c * ((a + b * c) ÷ c) == c * (a ÷ c + b)
a, b, c:t
H:c ~= 0
H0:0 <= (a + b * c) * a

c * ((a + b * c) ÷ c) + (a + b * c) rem c == c * (a ÷ c + b) + (a + b * c) rem c
a, b, c:t
H:c ~= 0
H0:0 <= (a + b * c) * a

a + b * c == c * (a ÷ c + b) + a rem c
now rewrite mul_add_distr_l, add_shuffle0, <-quot_rem, mul_comm. Qed.

forall a b c : t, b ~= 0 -> 0 <= (a * b + c) * c -> (a * b + c) ÷ b == a + c ÷ b

forall a b c : t, b ~= 0 -> 0 <= (a * b + c) * c -> (a * b + c) ÷ b == a + c ÷ b
a, b, c:t

b ~= 0 -> 0 <= (a * b + c) * c -> (a * b + c) ÷ b == a + c ÷ b
a, b, c:t

b ~= 0 -> 0 <= (c + a * b) * c -> (c + a * b) ÷ b == c ÷ b + a
now apply quot_add. Qed.
Cancellations.

forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b

forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b

forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
a, b, c:t
H:0 <= a
H0:0 < b
H1:c ~= 0

a * c ÷ (b * c) == a ÷ b
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
a, b, c:t
H:0 <= a
H0:0 < b
H1:c ~= 0
LE:0 <= c

a * c ÷ (b * c) == a ÷ b
a, b, c:t
H:0 <= a
H0:0 < b
H1:c ~= 0
LT:0 < - c
a * c ÷ (b * c) == a ÷ b
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
a, b, c:t
H:0 <= a
H0:0 < b
H1:c ~= 0
LT:0 < - c

a * c ÷ (b * c) == a ÷ b
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
a, b, c:t
H:0 <= a
H0:0 < b
H1:c ~= 0
LT:0 < - c

a * - c ÷ (b * - c) == a ÷ b
a, b, c:t
H:0 <= a
H0:0 < b
H1:c ~= 0
LT:0 < - c
b * c ~= 0
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
a, b, c:t
H:0 <= a
H0:0 < b
H1:c ~= 0
LT:0 < - c

b * c ~= 0
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b

forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b

forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux2:forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
a, b, c:t
H:0 <= a
H0:b ~= 0
H1:c ~= 0

a * c ÷ (b * c) == a ÷ b
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux2:forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
a, b, c:t
H:0 <= a
H0:b ~= 0
H1:c ~= 0
LE:0 <= b

a * c ÷ (b * c) == a ÷ b
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
a, b, c:t
H:0 <= a
H0:b ~= 0
H1:c ~= 0
LT:0 < - b
a * c ÷ (b * c) == a ÷ b
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux2:forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
a, b, c:t
H:0 <= a
H0:b ~= 0
H1:c ~= 0
LT:0 < - b

a * c ÷ (b * c) == a ÷ b
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux2:forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
a, b, c:t
H:0 <= a
H0:b ~= 0
H1:c ~= 0
LT:0 < - b

- (a * c ÷ (b * c)) == - (a ÷ b)
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux2:forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
a, b, c:t
H:0 <= a
H0:b ~= 0
H1:c ~= 0
LT:0 < - b

a * c ÷ (- b * c) == a ÷ - b
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
a, b, c:t
H:0 <= a
H0:b ~= 0
H1:c ~= 0
LT:0 < - b
b * c ~= 0
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux2:forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
a, b, c:t
H:0 <= a
H0:b ~= 0
H1:c ~= 0
LT:0 < - b

b * c ~= 0
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux2:forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux2:forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b

forall a b c : t, b ~= 0 -> c ~= 0 -> a * c ÷ (b * c) == a ÷ b
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
a, b, c:t
H:b ~= 0
H0:c ~= 0

a * c ÷ (b * c) == a ÷ b
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
a, b, c:t
H:b ~= 0
H0:c ~= 0
LE:0 <= a

a * c ÷ (b * c) == a ÷ b
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
a, b, c:t
H:b ~= 0
H0:c ~= 0
LT:0 < - a
a * c ÷ (b * c) == a ÷ b
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
a, b, c:t
H:b ~= 0
H0:c ~= 0
LT:0 < - a

a * c ÷ (b * c) == a ÷ b
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
a, b, c:t
H:b ~= 0
H0:c ~= 0
LT:0 < - a

- (a * c ÷ (b * c)) == - (a ÷ b)
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
a, b, c:t
H:b ~= 0
H0:c ~= 0
LT:0 < - a

- a * c ÷ (b * c) == - a ÷ b
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
a, b, c:t
H:b ~= 0
H0:c ~= 0
LT:0 < - a
b * c ~= 0
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 * c0 ÷ (b0 * c0) == a0 ÷ b0
a, b, c:t
H:b ~= 0
H0:c ~= 0
LT:0 < - a

b * c ~= 0
rewrite <- neq_mul_0; intuition order. Qed.

forall a b c : t, b ~= 0 -> c ~= 0 -> c * a ÷ (c * b) == a ÷ b

forall a b c : t, b ~= 0 -> c ~= 0 -> c * a ÷ (c * b) == a ÷ b
a, b, c:t
H:b ~= 0
H0:c ~= 0

c * a ÷ (c * b) == a ÷ b
rewrite !(mul_comm c); now apply quot_mul_cancel_r. Qed.

forall a b c : t, b ~= 0 -> c ~= 0 -> (a * c) rem (b * c) == a rem b * c

forall a b c : t, b ~= 0 -> c ~= 0 -> (a * c) rem (b * c) == a rem b * c
a, b, c:t
H:b ~= 0
H0:c ~= 0

(a * c) rem (b * c) == a rem b * c
a, b, c:t
H:b ~= 0
H0:c ~= 0
H1:b * c ~= 0

(a * c) rem (b * c) == a rem b * c
a, b, c:t
H:b ~= 0
H0:c ~= 0
H1:b * c ~= 0

a * c - b * c * (a * c ÷ (b * c)) == (a - b * (a ÷ b)) * c
a, b, c:t
H:b ~= 0
H0:c ~= 0
H1:b * c ~= 0

a * c - b * c * (a ÷ b) == (a - b * (a ÷ b)) * c
now rewrite mul_sub_distr_r, <- !mul_assoc, (mul_comm (a÷b) c). Qed.

forall a b c : t, b ~= 0 -> c ~= 0 -> (c * a) rem (c * b) == c * (a rem b)

forall a b c : t, b ~= 0 -> c ~= 0 -> (c * a) rem (c * b) == c * (a rem b)
intros; rewrite !(mul_comm c); now apply mul_rem_distr_r. Qed.
Operations modulo.

forall a n : t, n ~= 0 -> (a rem n) rem n == a rem n

forall a n : t, n ~= 0 -> (a rem n) rem n == a rem n
a, n:t
H:n ~= 0

(a rem n) rem n == a rem n
a, n:t
H:n ~= 0
LE:0 <= a
LE0:0 <= n

(a rem n) rem n == a rem n
a, n:t
H:n ~= 0
LE:0 <= a
LT:0 < - n
(a rem n) rem n == a rem n
a, n:t
H:n ~= 0
LT:0 < - a
LE:0 <= n
(a rem n) rem n == a rem n
a, n:t
H:n ~= 0
LT:0 < - a
LT0:0 < - n
(a rem n) rem n == a rem n
a, n:t
H:n ~= 0
LE:0 <= a
LT:0 < - n

(a rem n) rem n == a rem n
a, n:t
H:n ~= 0
LT:0 < - a
LE:0 <= n
(a rem n) rem n == a rem n
a, n:t
H:n ~= 0
LT:0 < - a
LT0:0 < - n
(a rem n) rem n == a rem n
a, n:t
H:n ~= 0
LE:0 <= a
LT:0 < - n

(a rem - n) rem - n == a rem - n
a, n:t
H:n ~= 0
LT:0 < - a
LE:0 <= n
(a rem n) rem n == a rem n
a, n:t
H:n ~= 0
LT:0 < - a
LT0:0 < - n
(a rem n) rem n == a rem n
a, n:t
H:n ~= 0
LT:0 < - a
LE:0 <= n

(a rem n) rem n == a rem n
a, n:t
H:n ~= 0
LT:0 < - a
LT0:0 < - n
(a rem n) rem n == a rem n
a, n:t
H:n ~= 0
LT:0 < - a
LE:0 <= n

- ((a rem n) rem n) == - (a rem n)
a, n:t
H:n ~= 0
LT:0 < - a
LT0:0 < - n
(a rem n) rem n == a rem n
a, n:t
H:n ~= 0
LT:0 < - a
LE:0 <= n

(- a rem n) rem n == - a rem n
a, n:t
H:n ~= 0
LT:0 < - a
LT0:0 < - n
(a rem n) rem n == a rem n
a, n:t
H:n ~= 0
LT:0 < - a
LT0:0 < - n

(a rem n) rem n == a rem n
a, n:t
H:n ~= 0
LT:0 < - a
LT0:0 < - n

- ((a rem n) rem n) == - (a rem n)
a, n:t
H:n ~= 0
LT:0 < - a
LT0:0 < - n

(- a rem - n) rem - n == - a rem - n
apply NZQuot.mod_mod; order. Qed.

forall a b n : t, n ~= 0 -> (a rem n * b) rem n == (a * b) rem n

forall a b n : t, n ~= 0 -> (a rem n * b) rem n == (a * b) rem n

forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux1:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
forall a b n : t, n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
a, b, n:t
H:0 <= a
H0:0 <= b
H1:n ~= 0

(a rem n * b) rem n == (a * b) rem n
Aux1:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
forall a b n : t, n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
a, b, n:t
H:0 <= a
H0:0 <= b
H1:n ~= 0
LE:0 <= n

(a rem n * b) rem n == (a * b) rem n
a, b, n:t
H:0 <= a
H0:0 <= b
H1:n ~= 0
LT:0 < - n
(a rem n * b) rem n == (a * b) rem n
Aux1:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
forall a b n : t, n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
a, b, n:t
H:0 <= a
H0:0 <= b
H1:n ~= 0
LT:0 < - n

(a rem n * b) rem n == (a * b) rem n
Aux1:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
forall a b n : t, n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
a, b, n:t
H:0 <= a
H0:0 <= b
H1:n ~= 0
LT:0 < - n

(a rem - n * b) rem - n == (a * b) rem - n
Aux1:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
forall a b n : t, n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux1:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n

forall a b n : t, n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux1:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n

forall a b n : t, 0 <= a -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux1:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux2:forall a b n : t, 0 <= a -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
forall a b n : t, n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux1:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
a, b, n:t
H:0 <= a
H0:n ~= 0

(a rem n * b) rem n == (a * b) rem n
Aux1:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux2:forall a b n : t, 0 <= a -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
forall a b n : t, n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux1:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
a, b, n:t
H:0 <= a
H0:n ~= 0
LE:0 <= b

(a rem n * b) rem n == (a * b) rem n
Aux1:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
a, b, n:t
H:0 <= a
H0:n ~= 0
LT:0 < - b
(a rem n * b) rem n == (a * b) rem n
Aux1:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux2:forall a b n : t, 0 <= a -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
forall a b n : t, n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux1:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
a, b, n:t
H:0 <= a
H0:n ~= 0
LT:0 < - b

(a rem n * b) rem n == (a * b) rem n
Aux1:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux2:forall a b n : t, 0 <= a -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
forall a b n : t, n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux1:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
a, b, n:t
H:0 <= a
H0:n ~= 0
LT:0 < - b

- ((a rem n * b) rem n) == - ((a * b) rem n)
Aux1:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux2:forall a b n : t, 0 <= a -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
forall a b n : t, n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux1:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
a, b, n:t
H:0 <= a
H0:n ~= 0
LT:0 < - b

(a rem n * - b) rem n == (a * - b) rem n
Aux1:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux2:forall a b n : t, 0 <= a -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
forall a b n : t, n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux1:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux2:forall a b n : t, 0 <= a -> n ~= 0 -> (a rem n * b) rem n == (a * b) rem n

forall a b n : t, n ~= 0 -> (a rem n * b) rem n == (a * b) rem n
Aux1:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
Aux2:forall a0 b0 n0 : t, 0 <= a0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
a, b, n:t
Hn:n ~= 0

(a rem n * b) rem n == (a * b) rem n
Aux1:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
Aux2:forall a0 b0 n0 : t, 0 <= a0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
a, b, n:t
Hn:n ~= 0
LE:0 <= a

(a rem n * b) rem n == (a * b) rem n
Aux1:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
Aux2:forall a0 b0 n0 : t, 0 <= a0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
a, b, n:t
Hn:n ~= 0
LT:0 < - a
(a rem n * b) rem n == (a * b) rem n
Aux1:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
Aux2:forall a0 b0 n0 : t, 0 <= a0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
a, b, n:t
Hn:n ~= 0
LT:0 < - a

(a rem n * b) rem n == (a * b) rem n
Aux1:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
Aux2:forall a0 b0 n0 : t, 0 <= a0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
a, b, n:t
Hn:n ~= 0
LT:0 < - a

- ((a rem n * b) rem n) == - ((a * b) rem n)
Aux1:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
Aux2:forall a0 b0 n0 : t, 0 <= a0 -> n0 ~= 0 -> (a0 rem n0 * b0) rem n0 == (a0 * b0) rem n0
a, b, n:t
Hn:n ~= 0
LT:0 < - a

(- a rem n * b) rem n == (- a * b) rem n
apply Aux2; order. Qed.

forall a b n : t, n ~= 0 -> (a * (b rem n)) rem n == (a * b) rem n

forall a b n : t, n ~= 0 -> (a * (b rem n)) rem n == (a * b) rem n
a, b, n:t
H:n ~= 0

(a * (b rem n)) rem n == (a * b) rem n
a, b, n:t
H:n ~= 0

(b rem n * a) rem n == (b * a) rem n
now apply mul_rem_idemp_l. Qed.

forall a b n : t, n ~= 0 -> (a * b) rem n == (a rem n * (b rem n)) rem n

forall a b n : t, n ~= 0 -> (a * b) rem n == (a rem n * (b rem n)) rem n
a, b, n:t
H:n ~= 0

(a * b) rem n == (a rem n * (b rem n)) rem n
now rewrite mul_rem_idemp_l, mul_rem_idemp_r. Qed.
addition and modulo
Generally speaking, unlike with other conventions, we don't have (a+b) rem n = (a rem n + b rem n) rem n for any a and b. For instance, take (8 + (-10)) rem 3 = -2 whereas (8 rem 3 + (-10 rem 3)) rem 3 = 1.

forall a b n : t, n ~= 0 -> 0 <= a * b -> (a rem n + b) rem n == (a + b) rem n

forall a b n : t, n ~= 0 -> 0 <= a * b -> (a rem n + b) rem n == (a + b) rem n

forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n + b) rem n == (a + b) rem n
Aux:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n + b) rem n == (a + b) rem n
forall a b n : t, n ~= 0 -> 0 <= a * b -> (a rem n + b) rem n == (a + b) rem n
a, b, n:t
H:0 <= a
H0:0 <= b
H1:n ~= 0

(a rem n + b) rem n == (a + b) rem n
Aux:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n + b) rem n == (a + b) rem n
forall a b n : t, n ~= 0 -> 0 <= a * b -> (a rem n + b) rem n == (a + b) rem n
a, b, n:t
H:0 <= a
H0:0 <= b
H1:n ~= 0
LE:0 <= n

(a rem n + b) rem n == (a + b) rem n
a, b, n:t
H:0 <= a
H0:0 <= b
H1:n ~= 0
LT:0 < - n
(a rem n + b) rem n == (a + b) rem n
Aux:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n + b) rem n == (a + b) rem n
forall a b n : t, n ~= 0 -> 0 <= a * b -> (a rem n + b) rem n == (a + b) rem n
a, b, n:t
H:0 <= a
H0:0 <= b
H1:n ~= 0
LT:0 < - n

(a rem n + b) rem n == (a + b) rem n
Aux:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n + b) rem n == (a + b) rem n
forall a b n : t, n ~= 0 -> 0 <= a * b -> (a rem n + b) rem n == (a + b) rem n
a, b, n:t
H:0 <= a
H0:0 <= b
H1:n ~= 0
LT:0 < - n

(a rem - n + b) rem - n == (a + b) rem - n
Aux:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n + b) rem n == (a + b) rem n
forall a b n : t, n ~= 0 -> 0 <= a * b -> (a rem n + b) rem n == (a + b) rem n
Aux:forall a b n : t, 0 <= a -> 0 <= b -> n ~= 0 -> (a rem n + b) rem n == (a + b) rem n

forall a b n : t, n ~= 0 -> 0 <= a * b -> (a rem n + b) rem n == (a + b) rem n
Aux:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 + b0) rem n0 == (a0 + b0) rem n0
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b

(a rem n + b) rem n == (a + b) rem n
Aux:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 + b0) rem n0 == (a0 + b0) rem n0
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b
Ha:0 <= a
Hb:0 <= b

(a rem n + b) rem n == (a + b) rem n
Aux:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 + b0) rem n0 == (a0 + b0) rem n0
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b
Ha:a <= 0
Hb:b <= 0
(a rem n + b) rem n == (a + b) rem n
Aux:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 + b0) rem n0 == (a0 + b0) rem n0
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b
Ha:a <= 0
Hb:b <= 0

(a rem n + b) rem n == (a + b) rem n
Aux:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 + b0) rem n0 == (a0 + b0) rem n0
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b
Ha:a <= 0
Hb:b <= 0

- ((a rem n + b) rem n) == - ((a + b) rem n)
Aux:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 + b0) rem n0 == (a0 + b0) rem n0
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b
Ha:a <= 0
Hb:b <= 0

(- a rem n + - b) rem n == (- a + - b) rem n
Aux:forall a0 b0 n0 : t, 0 <= a0 -> 0 <= b0 -> n0 ~= 0 -> (a0 rem n0 + b0) rem n0 == (a0 + b0) rem n0
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b
Ha:0 <= - a
Hb:0 <= - b

(- a rem n + - b) rem n == (- a + - b) rem n
now apply Aux. Qed.

forall a b n : t, n ~= 0 -> 0 <= a * b -> (a + b rem n) rem n == (a + b) rem n

forall a b n : t, n ~= 0 -> 0 <= a * b -> (a + b rem n) rem n == (a + b) rem n
a, b, n:t
H:n ~= 0
H0:0 <= a * b

(a + b rem n) rem n == (a + b) rem n
a, b, n:t
H:n ~= 0
H0:0 <= a * b

(b rem n + a) rem n == (b + a) rem n
a, b, n:t
H:n ~= 0
H0:0 <= a * b

0 <= b * a
now rewrite mul_comm. Qed.

forall a b n : t, n ~= 0 -> 0 <= a * b -> (a + b) rem n == (a rem n + b rem n) rem n

forall a b n : t, n ~= 0 -> 0 <= a * b -> (a + b) rem n == (a rem n + b rem n) rem n
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b

(a + b) rem n == (a rem n + b rem n) rem n
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b

(a + b) rem n == (a + b) rem n
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b
0 <= a * (b rem n)
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b

0 <= a * (b rem n)
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b
Ha:0 <= a
Hb:0 <= b
Hb':b rem n <= 0
Hm:b <= 0

0 <= a * (b rem n)
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b
Ha:a <= 0
Hb:b <= 0
Hb':0 <= b rem n
Hm:0 <= b
0 <= a * (b rem n)
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b
Ha:0 <= a
Hb:0 <= b
Hb':b rem n <= 0
Hm:b <= 0

0 <= a * (0 rem n)
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b
Ha:a <= 0
Hb:b <= 0
Hb':0 <= b rem n
Hm:0 <= b
0 <= a * (b rem n)
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b
Ha:0 <= a
Hb:0 <= b
Hb':b rem n <= 0
Hm:b <= 0

0 <= a * 0
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b
Ha:a <= 0
Hb:b <= 0
Hb':0 <= b rem n
Hm:0 <= b
0 <= a * (b rem n)
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b
Ha:a <= 0
Hb:b <= 0
Hb':0 <= b rem n
Hm:0 <= b

0 <= a * (b rem n)
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b
Ha:a <= 0
Hb:b <= 0
Hb':0 <= b rem n
Hm:0 <= b

0 <= a * (0 rem n)
a, b, n:t
Hn:n ~= 0
Hab:0 <= a * b
Ha:a <= 0
Hb:b <= 0
Hb':0 <= b rem n
Hm:0 <= b

0 <= a * 0
nzsimpl; order. Qed.
Conversely, the following results need less restrictions here.

forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)

forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)

forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
a, b, c:t
H:0 <= a
H0:0 < b
H1:c ~= 0

a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
a, b, c:t
H:0 <= a
H0:0 < b
H1:c ~= 0
LE:0 <= c

a ÷ b ÷ c == a ÷ (b * c)
a, b, c:t
H:0 <= a
H0:0 < b
H1:c ~= 0
LT:0 < - c
a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
a, b, c:t
H:0 <= a
H0:0 < b
H1:c ~= 0
LT:0 < - c

a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
a, b, c:t
H:0 <= a
H0:0 < b
H1:c ~= 0
LT:0 < - c

- (a ÷ b ÷ c) == - (a ÷ (b * c))
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
a, b, c:t
H:0 <= a
H0:0 < b
H1:c ~= 0
LT:0 < - c

a ÷ b ÷ - c == a ÷ (b * - c)
a, b, c:t
H:0 <= a
H0:0 < b
H1:c ~= 0
LT:0 < - c
b * c ~= 0
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
a, b, c:t
H:0 <= a
H0:0 < b
H1:c ~= 0
LT:0 < - c

b * c ~= 0
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)

forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)

forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux2:forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:0 <= a
H0:b ~= 0
H1:c ~= 0

a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux2:forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:0 <= a
H0:b ~= 0
H1:c ~= 0
LE:0 <= b

a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:0 <= a
H0:b ~= 0
H1:c ~= 0
LT:0 < - b
a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux2:forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:0 <= a
H0:b ~= 0
H1:c ~= 0
LT:0 < - b

a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux2:forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:0 <= a
H0:b ~= 0
H1:c ~= 0
LT:0 < - b

- (a ÷ b ÷ c) == - (a ÷ (b * c))
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux2:forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:0 <= a
H0:b ~= 0
H1:c ~= 0
LT:0 < - b

a ÷ - b ÷ c == a ÷ (- b * c)
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:0 <= a
H0:b ~= 0
H1:c ~= 0
LT:0 < - b
b * c ~= 0
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux2:forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:0 <= a
H0:b ~= 0
H1:c ~= 0
LT:0 < - b

b * c ~= 0
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux2:forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a b c : t, 0 <= a -> 0 < b -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux2:forall a b c : t, 0 <= a -> b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)

forall a b c : t, b ~= 0 -> c ~= 0 -> a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:b ~= 0
H0:c ~= 0

a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:b ~= 0
H0:c ~= 0
LE:0 <= a

a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:b ~= 0
H0:c ~= 0
LT:0 < - a
a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:b ~= 0
H0:c ~= 0
LT:0 < - a

a ÷ b ÷ c == a ÷ (b * c)
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:b ~= 0
H0:c ~= 0
LT:0 < - a

- (a ÷ b ÷ c) == - (a ÷ (b * c))
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:b ~= 0
H0:c ~= 0
LT:0 < - a

- a ÷ b ÷ c == - a ÷ (b * c)
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:b ~= 0
H0:c ~= 0
LT:0 < - a
b * c ~= 0
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:b ~= 0
H0:c ~= 0
LT:0 < - a

b * c ~= 0
Aux1:forall a0 b0 c0 : t, 0 <= a0 -> 0 < b0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
Aux2:forall a0 b0 c0 : t, 0 <= a0 -> b0 ~= 0 -> c0 ~= 0 -> a0 ÷ b0 ÷ c0 == a0 ÷ (b0 * c0)
a, b, c:t
H:b ~= 0
H0:c ~= 0
LT:0 < - a

b ~= 0 /\ c ~= 0
tauto. Qed.

forall a b c : t, b ~= 0 -> c ~= 0 -> a rem (b * c) == a rem b + b * ((a ÷ b) rem c)

forall a b c : t, b ~= 0 -> c ~= 0 -> a rem (b * c) == a rem b + b * ((a ÷ b) rem c)
a, b, c:t
Hb:b ~= 0
Hc:c ~= 0

a rem (b * c) == a rem b + b * ((a ÷ b) rem c)
a, b, c:t
Hb:b ~= 0
Hc:c ~= 0

b * c * (a ÷ (b * c)) + a rem (b * c) == b * c * (a ÷ (b * c)) + (a rem b + b * ((a ÷ b) rem c))
a, b, c:t
Hb:b ~= 0
Hc:c ~= 0

a == b * c * (a ÷ (b * c)) + (a rem b + b * ((a ÷ b) rem c))
a, b, c:t
Hb:b ~= 0
Hc:c ~= 0

a == b * c * (a ÷ b ÷ c) + (a rem b + b * ((a ÷ b) rem c))
a, b, c:t
Hb:b ~= 0
Hc:c ~= 0

a == b * (c * (a ÷ b ÷ c) + (a ÷ b) rem c) + a rem b
a, b, c:t
Hb:b ~= 0
Hc:c ~= 0

a == b * (a ÷ b) + a rem b
apply quot_rem; order. Qed.

forall a b : t, b ~= 0 -> a rem b ÷ b == 0

forall a b : t, b ~= 0 -> a rem b ÷ b == 0
a, b:t
Hb:b ~= 0

a rem b ÷ b == 0
a, b:t
Hb:b ~= 0

abs (a rem b) < abs b
auto using rem_bound_abs. Qed.
A last inequality:

forall a b c : t, 0 <= a -> 0 < b -> 0 <= c -> c * (a ÷ b) <= c * a ÷ b

forall a b c : t, 0 <= a -> 0 < b -> 0 <= c -> c * (a ÷ b) <= c * a ÷ b
exact NZQuot.div_mul_le. Qed. End ZQuotProp.