aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorletouzey2010-01-05 15:24:29 +0000
committerletouzey2010-01-05 15:24:29 +0000
commit9332ed8f53f544c0dccac637a88d09a252c3c653 (patch)
treefe59e48dd8bbce65a19b3e806c70e52db1ed0858
parentb63cd131e8b4a5600973c860d2ccc6e3e5c8ce91 (diff)
Division in Numbers: factorisation of signatures
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@12624 85f007b7-540e-0410-9357-904b9bb8a0f7
-rw-r--r--theories/Numbers/Integer/Abstract/ZDivEucl.v14
-rw-r--r--theories/Numbers/Integer/Abstract/ZDivFloor.v13
-rw-r--r--theories/Numbers/Integer/Abstract/ZDivTrunc.v13
-rw-r--r--theories/Numbers/NatInt/NZDiv.v18
-rw-r--r--theories/Numbers/Natural/Abstract/NDiv.v13
5 files changed, 17 insertions, 54 deletions
diff --git a/theories/Numbers/Integer/Abstract/ZDivEucl.v b/theories/Numbers/Integer/Abstract/ZDivEucl.v
index 2ec1cc9b04..e6af6f16f7 100644
--- a/theories/Numbers/Integer/Abstract/ZDivEucl.v
+++ b/theories/Numbers/Integer/Abstract/ZDivEucl.v
@@ -26,21 +26,9 @@ Require Import ZAxioms ZProperties NZDiv.
Open Scope NumScope.
Module Type ZDiv (Import Z : ZAxiomsSig).
-
- Parameter Inline div : t -> t -> t.
- Parameter Inline modulo : t -> t -> t.
-
- Infix "/" := div : NumScope.
- Infix "mod" := modulo (at level 40, no associativity) : NumScope.
-
- Declare Instance div_wd : Proper (eq==>eq==>eq) div.
- Declare Instance mod_wd : Proper (eq==>eq==>eq) modulo.
-
+ Include Type NZDivCommon Z. (** div, mod, compat with eq, equation a=bq+r *)
Definition abs z := max z (-z).
-
- Axiom div_mod : forall a b, b ~= 0 -> a == b*(a/b) + (a mod b).
Axiom mod_always_pos : forall a b, 0 <= a mod b < abs b.
-
End ZDiv.
Module Type ZDivSig := ZAxiomsSig <+ ZDiv.
diff --git a/theories/Numbers/Integer/Abstract/ZDivFloor.v b/theories/Numbers/Integer/Abstract/ZDivFloor.v
index 4736312939..c152fa83ea 100644
--- a/theories/Numbers/Integer/Abstract/ZDivFloor.v
+++ b/theories/Numbers/Integer/Abstract/ZDivFloor.v
@@ -29,20 +29,9 @@ Require Import ZAxioms ZProperties NZDiv.
Open Scope NumScope.
Module Type ZDiv (Import Z : ZAxiomsSig).
-
- Parameter Inline div : t -> t -> t.
- Parameter Inline modulo : t -> t -> t.
-
- Infix "/" := div : NumScope.
- Infix "mod" := modulo (at level 40, no associativity) : NumScope.
-
- Declare Instance div_wd : Proper (eq==>eq==>eq) div.
- Declare Instance mod_wd : Proper (eq==>eq==>eq) modulo.
-
- Axiom div_mod : forall a b, b ~= 0 -> a == b*(a/b) + (a mod b).
+ Include Type NZDivCommon Z. (** div, mod, compat with eq, equation a=bq+r *)
Axiom mod_pos_bound : forall a b, 0 < b -> 0 <= a mod b < b.
Axiom mod_neg_bound : forall a b, b < 0 -> b < a mod b <= 0.
-
End ZDiv.
Module Type ZDivSig := ZAxiomsSig <+ ZDiv.
diff --git a/theories/Numbers/Integer/Abstract/ZDivTrunc.v b/theories/Numbers/Integer/Abstract/ZDivTrunc.v
index 2522f70c12..eca1e2ba17 100644
--- a/theories/Numbers/Integer/Abstract/ZDivTrunc.v
+++ b/theories/Numbers/Integer/Abstract/ZDivTrunc.v
@@ -29,21 +29,10 @@ Require Import ZAxioms ZProperties NZDiv.
Open Scope NumScope.
Module Type ZDiv (Import Z : ZAxiomsSig).
-
- Parameter Inline div : t -> t -> t.
- Parameter Inline modulo : t -> t -> t.
-
- Infix "/" := div : NumScope.
- Infix "mod" := modulo (at level 40, no associativity) : NumScope.
-
- Declare Instance div_wd : Proper (eq==>eq==>eq) div.
- Declare Instance mod_wd : Proper (eq==>eq==>eq) modulo.
-
- Axiom div_mod : forall a b, b ~= 0 -> a == b*(a/b) + (a mod b).
+ Include Type NZDivCommon Z. (** div, mod, compat with eq, equation a=bq+r *)
Axiom mod_bound : forall a b, 0<=a -> 0<b -> 0 <= a mod b < b.
Axiom mod_opp_l : forall a b, b ~= 0 -> (-a) mod b == - (a mod b).
Axiom mod_opp_r : forall a b, b ~= 0 -> a mod (-b) == a mod b.
-
End ZDiv.
Module Type ZDivSig := ZAxiomsSig <+ ZDiv.
diff --git a/theories/Numbers/NatInt/NZDiv.v b/theories/Numbers/NatInt/NZDiv.v
index 1be2f85087..bb63b420b3 100644
--- a/theories/Numbers/NatInt/NZDiv.v
+++ b/theories/Numbers/NatInt/NZDiv.v
@@ -12,20 +12,28 @@ Require Import NZAxioms NZMulOrder.
Open Scope NumScope.
-Module Type NZDiv (Import NZ : NZOrdAxiomsSig).
+(** This first signature will be common to all divisions over NZ, N and Z *)
+Module Type NZDivCommon (Import NZ : NZAxiomsSig).
Parameter Inline div : t -> t -> t.
Parameter Inline modulo : t -> t -> t.
-
Infix "/" := div : NumScope.
Infix "mod" := modulo (at level 40, no associativity) : NumScope.
-
Declare Instance div_wd : Proper (eq==>eq==>eq) div.
Declare Instance mod_wd : Proper (eq==>eq==>eq) modulo.
-
Axiom div_mod : forall a b, b ~= 0 -> a == b*(a/b) + (a mod b).
- Axiom mod_bound : forall a b, 0<=a -> 0<b -> 0 <= a mod b < b.
+End NZDivCommon.
+(** The different divisions will only differ in the conditions
+ they impose on [modulo]. For NZ, we only describe behavior
+ on positive numbers.
+
+ NB: This axiom would also be true for N and Z, but redundant.
+*)
+
+Module Type NZDiv (Import NZ : NZOrdAxiomsSig).
+ Include Type NZDivCommon NZ.
+ Axiom mod_bound : forall a b, 0<=a -> 0<b -> 0 <= a mod b < b.
End NZDiv.
Module Type NZDivSig := NZOrdAxiomsSig <+ NZDiv.
diff --git a/theories/Numbers/Natural/Abstract/NDiv.v b/theories/Numbers/Natural/Abstract/NDiv.v
index 1aa10958f0..6c417868a8 100644
--- a/theories/Numbers/Natural/Abstract/NDiv.v
+++ b/theories/Numbers/Natural/Abstract/NDiv.v
@@ -13,19 +13,8 @@ Require Import NAxioms NProperties NZDiv.
Open Scope NumScope.
Module Type NDiv (Import N : NAxiomsSig).
-
- Parameter Inline div : t -> t -> t.
- Parameter Inline modulo : t -> t -> t.
-
- Infix "/" := div : NumScope.
- Infix "mod" := modulo (at level 40, no associativity) : NumScope.
-
- Declare Instance div_wd : Proper (eq==>eq==>eq) div.
- Declare Instance mod_wd : Proper (eq==>eq==>eq) modulo.
-
- Axiom div_mod : forall a b, b ~= 0 -> a == b*(a/b) + (a mod b).
+ Include Type NZDivCommon N. (** div, mod, compat with eq, equation a=bq+r *)
Axiom mod_upper_bound : forall a b, b ~= 0 -> a mod b < b.
-
End NDiv.
Module Type NDivSig := NAxiomsSig <+ NDiv.