(************************************************************************)
(*         *      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)         *)
(************************************************************************)
Attributes deprecated(since="8.20", note="Use ZDivTrunc or ZDivFloor instead.").
From Stdlib.Numbers.Integer.Abstract Require Import ZAxioms ZMulOrder ZSgnAbs.
From Stdlib.Numbers.NatInt Require Import NZDiv.
(** * Euclidean Division for integers, Euclid convention  We use here the "usual" formulation of the Euclid Theorem [forall a b, b<>0 -> exists r q, a = b*q+r /\ 0 <= r < |b| ]  The outcome of the modulo function is hence always positive. This corresponds to convention "E" 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 [ZDivTrunc] and [ZDivFloor] for others conventions.  We simply extend NZDiv with a bound for modulo that holds regardless of the sign of a and b. This new specification subsume mod_bound_pos, which nonetheless stays there for subtyping. Note also that ZAxiomSig now already contain a div and a modulo (that follow the Floor convention). We just ignore them here. *)
Module Type EuclidSpec (Import A : ZAxiomsSig')(Import B : DivMod A).

Axiom mod_always_pos : forall a b, b ~= 0 -> 0 <= B.modulo a b < abs b.
End EuclidSpec.