diff options
author | letouzey <letouzey@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2011-05-05 15:12:15 +0000 |
---|---|---|
committer | letouzey <letouzey@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2011-05-05 15:12:15 +0000 |
commit | c0a3544d6351e19c695951796bcee838671d1098 (patch) | |
tree | d87f69afd73340492ac694b2aa837024a90e8692 /theories/NArith/Ndiv_def.v | |
parent | f61a557fbbdb89a4c24a8050a67252c3ecda6ea7 (diff) |
Modularization of BinPos + fixes in Stdlib
BinPos now contain a sub-module Pos, in which are placed functions
like add (ex-Pplus), mul (ex-Pmult), ... and properties like
add_comm, add_assoc, ...
In addition to the name changes, the organisation is changed quite
a lot, to try to take advantage more of the orders < and <= instead
of speaking only of the comparison function.
The main source of incompatibilities in scripts concerns this compare:
Pos.compare is now a binary operation, expressed in terms of the
ex-Pcompare which is ternary (expecting an initial comparision as 3rd arg),
this ternary version being called now Pos.compare_cont. As for everything
else, compatibility notations (only parsing) are provided. But notations
"_ ?= _" on positive will have to be edited, since they now point to
Pos.compare.
We also make the sub-module Pos to be directly an OrderedType,
and include results about min and max.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@14098 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'theories/NArith/Ndiv_def.v')
-rw-r--r-- | theories/NArith/Ndiv_def.v | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/theories/NArith/Ndiv_def.v b/theories/NArith/Ndiv_def.v index 2a3fd152a..0850a631e 100644 --- a/theories/NArith/Ndiv_def.v +++ b/theories/NArith/Ndiv_def.v @@ -14,7 +14,7 @@ Local Open Scope N_scope. Definition NPgeb (a:N)(b:positive) := match a with | 0 => false - | Npos na => match Pcompare na b Eq with Lt => false | _ => true end + | Npos na => match Pos.compare na b with Lt => false | _ => true end end. Local Notation "a >=? b" := (NPgeb a b) (at level 70). @@ -54,24 +54,22 @@ Lemma NPgeb_ge : forall a b, NPgeb a b = true -> a >= Npos b. Proof. destruct a; simpl; intros. discriminate. - unfold Nge, Ncompare. now destruct Pcompare. + unfold Nge, Ncompare. now destruct Pos.compare. Qed. Lemma NPgeb_lt : forall a b, NPgeb a b = false -> a < Npos b. Proof. destruct a; simpl; intros. red; auto. - unfold Nlt, Ncompare. now destruct Pcompare. + unfold Nlt, Ncompare. now destruct Pos.compare. Qed. Theorem NPgeb_correct: forall (a:N)(b:positive), if NPgeb a b then a = a - Npos b + Npos b else True. Proof. destruct a as [|a]; simpl; intros b; auto. - generalize (Pcompare_Eq_eq a b). - case_eq (Pcompare a b Eq); intros; auto. - rewrite H0; auto. + case Pos.compare_spec; intros; subst; auto. now rewrite Pminus_mask_diag. - destruct (Pminus_mask_Gt a b H) as [d [H2 [H3 _]]]. + destruct (Pminus_mask_Gt a b (Pos.lt_gt _ _ H)) as [d [H2 [H3 _]]]. rewrite H2. rewrite <- H3. simpl; f_equal; apply Pplus_comm. Qed. @@ -96,7 +94,7 @@ rewrite Nplus_comm. generalize (NPgeb_correct (2*a+1) p). rewrite GE. intros <-. rewrite <- (Nmult_1_l (Npos p)). rewrite <- Nmult_plus_distr_r. destruct a; auto. -red; simpl. apply Pcompare_eq_Lt; auto. +red; simpl. apply Pcompare_Gt_Lt; auto. Qed. (* Proofs of specifications for these euclidean divisions. *) |