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 Morphisms BinInt ZDivEucl.
Local Open Scope Z_scope.

Definitions of division for binary integers, Euclid convention.

In this convention, the remainder is always positive. For other conventions, see Z.div and Z.quot in file BinIntDef. To avoid collision with the other divisions, we place this one under a module.
Module ZEuclid.

 Definition modulo a b := Z.modulo a (Z.abs b).
 Definition div a b := (Z.sgn b) * (Z.div a (Z.abs b)).

 

Proper (eq ==> eq ==> eq) modulo

Proper (eq ==> eq ==> eq) modulo
congruence. Qed.

Proper (eq ==> eq ==> eq) div

Proper (eq ==> eq ==> eq) div
congruence. Qed.
a, b:Z

b <> 0 -> a = b * div a b + modulo a b
a, b:Z

b <> 0 -> a = b * div a b + modulo a b
a, b:Z
Hb:b <> 0

a = b * div a b + modulo a b
a, b:Z
Hb:b <> 0

a = b * (Z.sgn b * (a / Z.abs b)) + a mod Z.abs b
a, b:Z
Hb:b <> 0

a = b * Z.sgn b * (a / Z.abs b) + a mod Z.abs b
a, b:Z
Hb:b <> 0

a = Z.abs b * (a / Z.abs b) + a mod Z.abs b
a, b:Z
Hb:b <> 0

Z.abs b <> 0
now destruct b. Qed.
a, b:Z

b <> 0 -> 0 <= modulo a b < Z.abs b
a, b:Z

b <> 0 -> 0 <= modulo a b < Z.abs b
a, b:Z
Hb:b <> 0

0 <= modulo a b < Z.abs b
a, b:Z
Hb:b <> 0

0 <= a mod Z.abs b < Z.abs b
a, b:Z
Hb:b <> 0

0 < Z.abs b
a:Z
Hb:0 <> 0

Eq = Lt
now destruct Hb. Qed.
a, b:Z

0 <= a -> 0 < b -> 0 <= modulo a b < b
a, b:Z

0 <= a -> 0 < b -> 0 <= modulo a b < b
a, b:Z
Hb:0 < b

0 <= modulo a b < b
a, b:Z
Hb:0 < b

0 <= modulo a b < Z.abs b
a, b:Z
Hb:0 < b

b <> 0
Z.order. Qed. Include ZEuclidProp Z Z Z. End ZEuclid.