diff options
author | Stephane Glondu <steph@glondu.net> | 2010-07-21 09:46:51 +0200 |
---|---|---|
committer | Stephane Glondu <steph@glondu.net> | 2010-07-21 09:46:51 +0200 |
commit | 5b7eafd0f00a16d78f99a27f5c7d5a0de77dc7e6 (patch) | |
tree | 631ad791a7685edafeb1fb2e8faeedc8379318ae /theories/Arith/NatOrderedType.v | |
parent | da178a880e3ace820b41d38b191d3785b82991f5 (diff) |
Imported Upstream snapshot 8.3~beta0+13298
Diffstat (limited to 'theories/Arith/NatOrderedType.v')
-rw-r--r-- | theories/Arith/NatOrderedType.v | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/theories/Arith/NatOrderedType.v b/theories/Arith/NatOrderedType.v new file mode 100644 index 00000000..df5b37e0 --- /dev/null +++ b/theories/Arith/NatOrderedType.v @@ -0,0 +1,64 @@ +(************************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *) +(* \VV/ **************************************************************) +(* // * This file is distributed under the terms of the *) +(* * GNU Lesser General Public License Version 2.1 *) +(************************************************************************) + +Require Import Lt Peano_dec Compare_dec EqNat + Equalities Orders OrdersTac. + + +(** * DecidableType structure for Peano numbers *) + +Module Nat_as_UBE <: UsualBoolEq. + Definition t := nat. + Definition eq := @eq nat. + Definition eqb := beq_nat. + Definition eqb_eq := beq_nat_true_iff. +End Nat_as_UBE. + +Module Nat_as_DT <: UsualDecidableTypeFull := Make_UDTF Nat_as_UBE. + +(** Note that the last module fulfills by subtyping many other + interfaces, such as [DecidableType] or [EqualityType]. *) + + + +(** * OrderedType structure for Peano numbers *) + +Module Nat_as_OT <: OrderedTypeFull. + Include Nat_as_DT. + Definition lt := lt. + Definition le := le. + Definition compare := nat_compare. + + Instance lt_strorder : StrictOrder lt. + 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. + + 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] + and a [OrderedType] (and also as a [DecidableType]). *) + + + +(** * An [order] tactic for Peano numbers *) + +Module NatOrder := OTF_to_OrderTac Nat_as_OT. +Ltac nat_order := NatOrder.order. + +(** Note that [nat_order] is domain-agnostic: it will not prove + [1<=2] or [x<=x+x], but rather things like [x<=y -> y<=x -> x=y]. *) + +Section Test. +Let test : forall x y : nat, x<=y -> y<=x -> x=y. +Proof. nat_order. Qed. +End Test. |