aboutsummaryrefslogtreecommitdiff
path: root/theories/Arith
diff options
context:
space:
mode:
Diffstat (limited to 'theories/Arith')
-rw-r--r--theories/Arith/Compare_dec.v12
-rw-r--r--theories/Arith/Lt.v7
-rw-r--r--theories/Arith/NatOrderedType.v19
3 files changed, 23 insertions, 15 deletions
diff --git a/theories/Arith/Compare_dec.v b/theories/Arith/Compare_dec.v
index a684d5a10d..1dc74af736 100644
--- a/theories/Arith/Compare_dec.v
+++ b/theories/Arith/Compare_dec.v
@@ -171,7 +171,17 @@ Proof.
apply -> nat_compare_lt; auto.
Qed.
-(** Some projections of the above equivalences, used in OrderedTypeEx. *)
+Lemma nat_compare_spec : forall x y, CompSpec eq lt x y (nat_compare x y).
+Proof.
+ intros.
+ destruct (nat_compare x y) as [ ]_eqn; constructor.
+ apply nat_compare_eq; auto.
+ apply <- nat_compare_lt; auto.
+ apply <- nat_compare_gt; auto.
+Qed.
+
+
+(** Some projections of the above equivalences. *)
Lemma nat_compare_Lt_lt : forall n m, nat_compare n m = Lt -> n<m.
Proof.
diff --git a/theories/Arith/Lt.v b/theories/Arith/Lt.v
index 1fb5b3e558..bdd7ce0921 100644
--- a/theories/Arith/Lt.v
+++ b/theories/Arith/Lt.v
@@ -144,6 +144,13 @@ Proof.
induction 1; auto with arith.
Qed.
+Theorem le_lt_or_eq_iff : forall n m, n <= m <-> n < m \/ n = m.
+Proof.
+ split.
+ intros; apply le_lt_or_eq; auto.
+ destruct 1; subst; auto with arith.
+Qed.
+
Theorem lt_le_weak : forall n m, n < m -> n <= m.
Proof.
auto with arith.
diff --git a/theories/Arith/NatOrderedType.v b/theories/Arith/NatOrderedType.v
index c4e71632cf..dda2fca6ca 100644
--- a/theories/Arith/NatOrderedType.v
+++ b/theories/Arith/NatOrderedType.v
@@ -6,7 +6,7 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-Require Import Peano_dec Compare_dec
+Require Import Lt Peano_dec Compare_dec
DecidableType2 OrderedType2 OrderedType2Facts.
@@ -33,26 +33,17 @@ Module Nat_as_OT <: OrderedTypeFull.
Definition compare := nat_compare.
Instance lt_strorder : StrictOrder lt.
- Proof. split; [ exact Lt.lt_irrefl | exact Lt.lt_trans ]. Qed.
+ Proof. split; [ exact lt_irrefl | exact lt_trans ]. Qed.
Instance lt_compat : Proper (Logic.eq==>Logic.eq==>iff) lt.
Proof. repeat red; intros; subst; auto. Qed.
- Lemma le_lteq : forall x y, x <= y <-> x < y \/ x=y.
- Proof. intuition; subst; auto using Lt.le_lt_or_eq. Qed.
-
- Lemma compare_spec : forall x y, Cmp eq lt x y (compare x y).
- Proof.
- intros; unfold compare.
- destruct (nat_compare x y) as [ ]_eqn; constructor.
- apply nat_compare_eq; auto.
- apply nat_compare_Lt_lt; auto.
- apply nat_compare_Gt_gt; auto.
- Qed.
+ Definition le_lteq := le_lt_or_eq_iff.
+ Definition compare_spec := nat_compare_spec.
End Nat_as_OT.
-(* Note that [Nat_as_OT] can also be seen as a [UsualOrderedType]
+(** Note that [Nat_as_OT] can also be seen as a [UsualOrderedType]
and a [OrderedType] (and also as a [DecidableType]). *)