From 5794a55f9e8b39b8e562e70593ab794abf463a86 Mon Sep 17 00:00:00 2001 From: letouzey Date: Thu, 7 Jan 2010 15:32:52 +0000 Subject: Nicer names: DecidableType2* --> Equalities*, OrderedType2* --> Orders* Old stuff DecidableType.v and OrderedType.v stay there and keep their names for the moment, for compatibility. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@12641 85f007b7-540e-0410-9357-904b9bb8a0f7 --- theories/Arith/MinMax.v | 2 +- theories/Arith/NatOrderedType.v | 2 +- theories/FSets/FSetAVL.v | 4 +- theories/FSets/FSetCompat.v | 4 +- theories/FSets/FSetList.v | 4 +- theories/FSets/FSetWeakList.v | 4 +- theories/MSets/MSetInterface.v | 2 +- theories/MSets/MSetList.v | 2 +- theories/MSets/MSetProperties.v | 2 +- theories/MSets/MSetToFiniteSet.v | 2 +- theories/MSets/MSets.v | 9 +- theories/NArith/NOrderedType.v | 2 +- theories/NArith/Nminmax.v | 2 +- theories/NArith/POrderedType.v | 2 +- theories/NArith/Pminmax.v | 2 +- theories/Numbers/NatInt/NZAxioms.v | 2 +- theories/Numbers/NatInt/NZOrder.v | 2 +- theories/QArith/QOrderedType.v | 2 +- theories/QArith/Qminmax.v | 2 +- theories/Reals/ROrderedType.v | 2 +- theories/Reals/Rminmax.v | 2 +- theories/Structures/DecidableType.v | 8 +- theories/Structures/DecidableType2.v | 214 -------------------- theories/Structures/DecidableType2Ex.v | 53 ----- theories/Structures/DecidableType2Facts.v | 148 -------------- theories/Structures/DecidableTypeEx.v | 27 +-- theories/Structures/Equalities.v | 216 ++++++++++++++++++++ theories/Structures/EqualitiesFacts.v | 185 +++++++++++++++++ theories/Structures/GenericMinMax.v | 2 +- theories/Structures/OrderTac.v | 323 ------------------------------ theories/Structures/OrderedType.v | 7 +- theories/Structures/OrderedType2.v | 160 --------------- theories/Structures/OrderedType2Alt.v | 243 ---------------------- theories/Structures/OrderedType2Ex.v | 88 -------- theories/Structures/OrderedType2Facts.v | 234 ---------------------- theories/Structures/OrderedType2Lists.v | 256 ----------------------- theories/Structures/Orders.v | 160 +++++++++++++++ theories/Structures/OrdersAlt.v | 243 ++++++++++++++++++++++ theories/Structures/OrdersEx.v | 88 ++++++++ theories/Structures/OrdersFacts.v | 234 ++++++++++++++++++++++ theories/Structures/OrdersLists.v | 256 +++++++++++++++++++++++ theories/Structures/OrdersTac.v | 323 ++++++++++++++++++++++++++++++ theories/Structures/vo.itarget | 23 +-- theories/ZArith/ZOrderedType.v | 2 +- theories/ZArith/Zminmax.v | 2 +- 45 files changed, 1764 insertions(+), 1788 deletions(-) delete mode 100644 theories/Structures/DecidableType2.v delete mode 100644 theories/Structures/DecidableType2Ex.v delete mode 100644 theories/Structures/DecidableType2Facts.v create mode 100644 theories/Structures/Equalities.v create mode 100644 theories/Structures/EqualitiesFacts.v delete mode 100644 theories/Structures/OrderTac.v delete mode 100644 theories/Structures/OrderedType2.v delete mode 100644 theories/Structures/OrderedType2Alt.v delete mode 100644 theories/Structures/OrderedType2Ex.v delete mode 100644 theories/Structures/OrderedType2Facts.v delete mode 100644 theories/Structures/OrderedType2Lists.v create mode 100644 theories/Structures/Orders.v create mode 100644 theories/Structures/OrdersAlt.v create mode 100644 theories/Structures/OrdersEx.v create mode 100644 theories/Structures/OrdersFacts.v create mode 100644 theories/Structures/OrdersLists.v create mode 100644 theories/Structures/OrdersTac.v diff --git a/theories/Arith/MinMax.v b/theories/Arith/MinMax.v index 32afba489c..6e86a88c59 100644 --- a/theories/Arith/MinMax.v +++ b/theories/Arith/MinMax.v @@ -6,7 +6,7 @@ (* * GNU Lesser General Public License Version 2.1 *) (************************************************************************) -Require Import OrderedType2 NatOrderedType GenericMinMax. +Require Import Orders NatOrderedType GenericMinMax. (** * Maximum and Minimum of two natural numbers *) diff --git a/theories/Arith/NatOrderedType.v b/theories/Arith/NatOrderedType.v index d9b2b30f04..fa4b7172ad 100644 --- a/theories/Arith/NatOrderedType.v +++ b/theories/Arith/NatOrderedType.v @@ -7,7 +7,7 @@ (************************************************************************) Require Import Lt Peano_dec Compare_dec EqNat - DecidableType2 OrderedType2 OrderTac. + Equalities Orders OrdersTac. (** * DecidableType structure for Peano numbers *) diff --git a/theories/FSets/FSetAVL.v b/theories/FSets/FSetAVL.v index e2953f3334..bc6c731f62 100644 --- a/theories/FSets/FSetAVL.v +++ b/theories/FSets/FSetAVL.v @@ -41,10 +41,10 @@ Unset Strict Implicit. (** This is just a compatibility layer, the real implementation is now in [MSetAVL] *) -Require FSetCompat MSetAVL OrderedType2 OrderedType2Alt. +Require FSetCompat MSetAVL Orders OrdersAlt. Module IntMake (I:Int)(X: OrderedType) <: S with Module E := X. - Module X' := OrderedType2Alt.Update_OT X. + Module X' := OrdersAlt.Update_OT X. Module MSet := MSetAVL.IntMake I X'. Include FSetCompat.Backport_Sets X MSet. End IntMake. diff --git a/theories/FSets/FSetCompat.v b/theories/FSets/FSetCompat.v index 4a341328ea..971daa2152 100644 --- a/theories/FSets/FSetCompat.v +++ b/theories/FSets/FSetCompat.v @@ -221,7 +221,7 @@ End Backport_Sets. (** * From old Weak Sets to new ones. *) Module Update_WSets - (E:DecidableType2.DecidableType) + (E:Equalities.DecidableType) (M:FSetInterface.WS with Definition E.t := E.t with Definition E.eq := E.eq) <: MSetInterface.WSetsOn E. @@ -342,7 +342,7 @@ End Update_WSets. (** * From old Sets to new ones. *) Module Update_Sets - (E:OrderedType2.OrderedType) + (E:Orders.OrderedType) (M:FSetInterface.S with Definition E.t := E.t with Definition E.eq := E.eq with Definition E.lt := E.lt) diff --git a/theories/FSets/FSetList.v b/theories/FSets/FSetList.v index 950f48a903..f83259c447 100644 --- a/theories/FSets/FSetList.v +++ b/theories/FSets/FSetList.v @@ -20,10 +20,10 @@ Unset Strict Implicit. (** This is just a compatibility layer, the real implementation is now in [MSetList] *) -Require FSetCompat MSetList OrderedType2 OrderedType2Alt. +Require FSetCompat MSetList Orders OrdersAlt. Module Make (X: OrderedType) <: S with Module E := X. - Module X' := OrderedType2Alt.Update_OT X. + Module X' := OrdersAlt.Update_OT X. Module MSet := MSetList.Make X'. Include FSetCompat.Backport_Sets X MSet. End Make. diff --git a/theories/FSets/FSetWeakList.v b/theories/FSets/FSetWeakList.v index 6bf4ae989e..711cbd9a68 100644 --- a/theories/FSets/FSetWeakList.v +++ b/theories/FSets/FSetWeakList.v @@ -20,11 +20,11 @@ Unset Strict Implicit. (** This is just a compatibility layer, the real implementation is now in [MSetWeakList] *) -Require DecidableType2 FSetCompat MSetWeakList. +Require Equalities FSetCompat MSetWeakList. Module Make (X: DecidableType) <: WS with Module E := X. Module E := X. - Module X' := DecidableType2.Update_DT X. + Module X' := Equalities.Update_DT X. Module MSet := MSetWeakList.Make X'. Include FSetCompat.Backport_WSets X MSet. End Make. diff --git a/theories/MSets/MSetInterface.v b/theories/MSets/MSetInterface.v index cb18785e6c..0de28d5e88 100644 --- a/theories/MSets/MSetInterface.v +++ b/theories/MSets/MSetInterface.v @@ -30,7 +30,7 @@ *) Require Export Bool SetoidList RelationClasses Morphisms - RelationPairs DecidableType2 OrderedType2 OrderedType2Facts. + RelationPairs Equalities Orders OrdersFacts. Set Implicit Arguments. Unset Strict Implicit. diff --git a/theories/MSets/MSetList.v b/theories/MSets/MSetList.v index 4292eb9386..b0caf6692f 100644 --- a/theories/MSets/MSetList.v +++ b/theories/MSets/MSetList.v @@ -13,7 +13,7 @@ (** This file proposes an implementation of the non-dependant interface [MSetInterface.S] using strictly ordered list. *) -Require Export MSetInterface OrderedType2Facts OrderedType2Lists. +Require Export MSetInterface OrdersFacts OrdersLists. Set Implicit Arguments. Unset Strict Implicit. diff --git a/theories/MSets/MSetProperties.v b/theories/MSets/MSetProperties.v index dc82a14502..a9ba0a823b 100644 --- a/theories/MSets/MSetProperties.v +++ b/theories/MSets/MSetProperties.v @@ -17,7 +17,7 @@ [Equal s s'] instead of [equal s s'=true], etc. *) Require Export MSetInterface. -Require Import DecidableTypeEx OrderedType2Lists MSetFacts MSetDecide. +Require Import DecidableTypeEx OrdersLists MSetFacts MSetDecide. Set Implicit Arguments. Unset Strict Implicit. diff --git a/theories/MSets/MSetToFiniteSet.v b/theories/MSets/MSetToFiniteSet.v index f805a3c965..f0b964cf2d 100644 --- a/theories/MSets/MSetToFiniteSet.v +++ b/theories/MSets/MSetToFiniteSet.v @@ -11,7 +11,7 @@ (** * Finite sets library : conversion to old [Finite_sets] *) Require Import Ensembles Finite_sets. -Require Import MSetInterface MSetProperties OrderedType2Ex DecidableType2Ex. +Require Import MSetInterface MSetProperties OrdersEx. (** * Going from [MSets] with usual Leibniz equality to the good old [Ensembles] and [Finite_sets] theory. *) diff --git a/theories/MSets/MSets.v b/theories/MSets/MSets.v index 42966c7fc2..558b09562d 100644 --- a/theories/MSets/MSets.v +++ b/theories/MSets/MSets.v @@ -8,11 +8,10 @@ (* $Id$ *) -Require Export OrderedType2. -Require Export OrderedType2Ex. -Require Export OrderedType2Alt. -Require Export DecidableType2. -Require Export DecidableType2Ex. +Require Export Orders. +Require Export OrdersEx. +Require Export OrdersAlt. +Require Export Equalities. Require Export MSetInterface. Require Export MSetFacts. Require Export MSetDecide. diff --git a/theories/NArith/NOrderedType.v b/theories/NArith/NOrderedType.v index 06db5fa1ce..c5dd395bb2 100644 --- a/theories/NArith/NOrderedType.v +++ b/theories/NArith/NOrderedType.v @@ -6,7 +6,7 @@ (* * GNU Lesser General Public License Version 2.1 *) (************************************************************************) -Require Import BinNat DecidableType2 OrderedType2 OrderTac. +Require Import BinNat Equalities Orders OrdersTac. Local Open Scope N_scope. diff --git a/theories/NArith/Nminmax.v b/theories/NArith/Nminmax.v index 625fcce237..475b4dfb82 100644 --- a/theories/NArith/Nminmax.v +++ b/theories/NArith/Nminmax.v @@ -6,7 +6,7 @@ (* * GNU Lesser General Public License Version 2.1 *) (************************************************************************) -Require Import OrderedType2 BinNat Nnat NOrderedType GenericMinMax. +Require Import Orders BinNat Nnat NOrderedType GenericMinMax. (** * Maximum and Minimum of two [N] numbers *) diff --git a/theories/NArith/POrderedType.v b/theories/NArith/POrderedType.v index 041a3a01be..9c0f826185 100644 --- a/theories/NArith/POrderedType.v +++ b/theories/NArith/POrderedType.v @@ -6,7 +6,7 @@ (* * GNU Lesser General Public License Version 2.1 *) (************************************************************************) -Require Import BinPos DecidableType2 OrderedType2 OrderTac. +Require Import BinPos Equalities Orders OrdersTac. Local Open Scope positive_scope. diff --git a/theories/NArith/Pminmax.v b/theories/NArith/Pminmax.v index 3b3c58841b..4cc48af66e 100644 --- a/theories/NArith/Pminmax.v +++ b/theories/NArith/Pminmax.v @@ -6,7 +6,7 @@ (* * GNU Lesser General Public License Version 2.1 *) (************************************************************************) -Require Import OrderedType2 BinPos Pnat POrderedType GenericMinMax. +Require Import Orders BinPos Pnat POrderedType GenericMinMax. (** * Maximum and Minimum of two positive numbers *) diff --git a/theories/Numbers/NatInt/NZAxioms.v b/theories/Numbers/NatInt/NZAxioms.v index 5b4e16cafe..480314f96f 100644 --- a/theories/Numbers/NatInt/NZAxioms.v +++ b/theories/Numbers/NatInt/NZAxioms.v @@ -10,7 +10,7 @@ (*i $Id$ i*) -Require Export DecidableType2 OrderedType2 NumPrelude GenericMinMax. +Require Export Equalities Orders NumPrelude GenericMinMax. (** Axiomatization of a domain with zero, successor, predecessor, and a bi-directional induction principle. We require [P (S n) = n] diff --git a/theories/Numbers/NatInt/NZOrder.v b/theories/Numbers/NatInt/NZOrder.v index 6a086f3bd6..9764d15576 100644 --- a/theories/Numbers/NatInt/NZOrder.v +++ b/theories/Numbers/NatInt/NZOrder.v @@ -10,7 +10,7 @@ (*i $Id$ i*) -Require Import NZAxioms NZBase Decidable OrderTac. +Require Import NZAxioms NZBase Decidable OrdersTac. Module Type NZOrderPropSig (Import NZ : NZOrdSig')(Import NZBase : NZBasePropSig NZ). diff --git a/theories/QArith/QOrderedType.v b/theories/QArith/QOrderedType.v index 74770d6e11..f3229d7236 100644 --- a/theories/QArith/QOrderedType.v +++ b/theories/QArith/QOrderedType.v @@ -6,7 +6,7 @@ (* * GNU Lesser General Public License Version 2.1 *) (************************************************************************) -Require Import QArith_base DecidableType2 OrderedType2 OrderTac. +Require Import QArith_base Equalities Orders OrdersTac. Local Open Scope Q_scope. diff --git a/theories/QArith/Qminmax.v b/theories/QArith/Qminmax.v index ae9cc46052..d20396c86a 100644 --- a/theories/QArith/Qminmax.v +++ b/theories/QArith/Qminmax.v @@ -6,7 +6,7 @@ (* * GNU Lesser General Public License Version 2.1 *) (************************************************************************) -Require Import QArith_base OrderedType2 QOrderedType GenericMinMax. +Require Import QArith_base Orders QOrderedType GenericMinMax. (** * Maximum and Minimum of two rational numbers *) diff --git a/theories/Reals/ROrderedType.v b/theories/Reals/ROrderedType.v index ea20db99fb..2b302386ed 100644 --- a/theories/Reals/ROrderedType.v +++ b/theories/Reals/ROrderedType.v @@ -6,7 +6,7 @@ (* * GNU Lesser General Public License Version 2.1 *) (************************************************************************) -Require Import Rbase DecidableType2 OrderedType2 OrderTac. +Require Import Rbase Equalities Orders OrdersTac. Local Open Scope R_scope. diff --git a/theories/Reals/Rminmax.v b/theories/Reals/Rminmax.v index 79343ee45c..373f30ddee 100644 --- a/theories/Reals/Rminmax.v +++ b/theories/Reals/Rminmax.v @@ -6,7 +6,7 @@ (* * GNU Lesser General Public License Version 2.1 *) (************************************************************************) -Require Import OrderedType2 Rbase Rbasic_fun ROrderedType GenericMinMax. +Require Import Orders Rbase Rbasic_fun ROrderedType GenericMinMax. (** * Maximum and Minimum of two real numbers *) diff --git a/theories/Structures/DecidableType.v b/theories/Structures/DecidableType.v index de7a20d4c5..2c72e30b16 100644 --- a/theories/Structures/DecidableType.v +++ b/theories/Structures/DecidableType.v @@ -9,19 +9,21 @@ (* $Id$ *) Require Export SetoidList. -Require DecidableType2. (* No Import here, this is on purpose. *) +Require Equalities. Set Implicit Arguments. Unset Strict Implicit. +(** NB: This file is here only for compatibility with earlier version of + [FSets] and [FMap]. Please use [Structures/Equalities.v] directly now. *) (** * Types with Equalities, and nothing more (for subtyping purpose) *) -Module Type EqualityType := DecidableType2.EqualityTypeOrig. +Module Type EqualityType := Equalities.EqualityTypeOrig. (** * Types with decidable Equalities (but no ordering) *) -Module Type DecidableType := DecidableType2.DecidableTypeOrig. +Module Type DecidableType := Equalities.DecidableTypeOrig. (** * Additional notions about keys and datas used in FMap *) diff --git a/theories/Structures/DecidableType2.v b/theories/Structures/DecidableType2.v deleted file mode 100644 index 2679d25b01..0000000000 --- a/theories/Structures/DecidableType2.v +++ /dev/null @@ -1,214 +0,0 @@ -(***********************************************************************) -(* v * The Coq Proof Assistant / The Coq Development Team *) -(* t -> Prop. -End HasEq. - -Module Type Eq := Typ <+ HasEq. - -Module Type EqNotation (Import E:Eq). - Infix "==" := eq (at level 70, no associativity). - Notation "x ~= y" := (~eq x y) (at level 70, no associativity). -End EqNotation. - -Module Type Eq' := Eq <+ EqNotation. - -(** * Specification of the equality via the [Equivalence] type class *) - -Module Type IsEq (Import E:Eq). - Declare Instance eq_equiv : Equivalence eq. -End IsEq. - -(** * Earlier specification of equality by three separate lemmas. *) - -Module Type IsEqOrig (Import E:Eq'). - Axiom eq_refl : forall x : t, x==x. - Axiom eq_sym : forall x y : t, x==y -> y==x. - Axiom eq_trans : forall x y z : t, x==y -> y==z -> x==z. - Hint Immediate eq_sym. - Hint Resolve eq_refl eq_trans. -End IsEqOrig. - -(** * Types with decidable equality *) - -Module Type HasEqDec (Import E:Eq'). - Parameter eq_dec : forall x y : t, { x==y } + { ~ x==y }. -End HasEqDec. - -(** * Boolean Equality *) - -(** Having [eq_dec] is the same as having a boolean equality plus - a correctness proof. *) - -Module Type HasEqBool (Import E:Eq'). - Parameter Inline eqb : t -> t -> bool. - Parameter eqb_eq : forall x y, eqb x y = true <-> x==y. -End HasEqBool. - -(** From these basic blocks, we can build many combinations - of static standalone module types. *) - -Module Type EqualityType := Eq <+ IsEq. - -Module Type EqualityTypeOrig := Eq <+ IsEqOrig. - -Module Type EqualityTypeBoth <: EqualityType <: EqualityTypeOrig - := Eq <+ IsEq <+ IsEqOrig. - -Module Type DecidableType <: EqualityType - := Eq <+ IsEq <+ HasEqDec. - -Module Type DecidableTypeOrig <: EqualityTypeOrig - := Eq <+ IsEqOrig <+ HasEqDec. - -Module Type DecidableTypeBoth <: DecidableType <: DecidableTypeOrig - := EqualityTypeBoth <+ HasEqDec. - -Module Type BooleanEqualityType <: EqualityType - := Eq <+ IsEq <+ HasEqBool. - -Module Type BooleanDecidableType <: DecidableType <: BooleanEqualityType - := Eq <+ IsEq <+ HasEqDec <+ HasEqBool. - -Module Type DecidableTypeFull <: DecidableTypeBoth <: BooleanDecidableType - := Eq <+ IsEq <+ IsEqOrig <+ HasEqDec <+ HasEqBool. - -(** Same, with notation for [eq] *) - -Module Type EqualityType' := EqualityType <+ EqNotation. -Module Type EqualityTypeOrig' := EqualityTypeOrig <+ EqNotation. -Module Type EqualityTypeBoth' := EqualityTypeBoth <+ EqNotation. -Module Type DecidableType' := DecidableType <+ EqNotation. -Module Type DecidableTypeOrig' := DecidableTypeOrig <+ EqNotation. -Module Type DecidableTypeBoth' := DecidableTypeBoth <+ EqNotation. -Module Type BooleanEqualityType' := BooleanEqualityType <+ EqNotation. -Module Type BooleanDecidableType' := BooleanDecidableType <+ EqNotation. -Module Type DecidableTypeFull' := DecidableTypeFull <+ EqNotation. - -(** * Compatibility wrapper from/to the old version of - [EqualityType] and [DecidableType] *) - -Module BackportEq (E:Eq)(F:IsEq E) <: IsEqOrig E. - Definition eq_refl := @Equivalence_Reflexive _ _ F.eq_equiv. - Definition eq_sym := @Equivalence_Symmetric _ _ F.eq_equiv. - Definition eq_trans := @Equivalence_Transitive _ _ F.eq_equiv. -End BackportEq. - -Module UpdateEq (E:Eq)(F:IsEqOrig E) <: IsEq E. - Instance eq_equiv : Equivalence E.eq. - Proof. exact (Build_Equivalence _ _ F.eq_refl F.eq_sym F.eq_trans). Qed. -End UpdateEq. - -Module Backport_ET (E:EqualityType) <: EqualityTypeBoth - := E <+ BackportEq. - -Module Update_ET (E:EqualityTypeOrig) <: EqualityTypeBoth - := E <+ UpdateEq. - -Module Backport_DT (E:DecidableType) <: DecidableTypeBoth - := E <+ BackportEq. - -Module Update_DT (E:DecidableTypeOrig) <: DecidableTypeBoth - := E <+ UpdateEq. - - -(** * Having [eq_dec] is equivalent to having [eqb] and its spec. *) - -Module HasEqDec2Bool (E:Eq)(F:HasEqDec E) <: HasEqBool E. - Definition eqb x y := if F.eq_dec x y then true else false. - Lemma eqb_eq : forall x y, eqb x y = true <-> E.eq x y. - Proof. - intros x y. unfold eqb. destruct F.eq_dec as [EQ|NEQ]. - auto with *. - split. discriminate. intro EQ; elim NEQ; auto. - Qed. -End HasEqDec2Bool. - -Module HasEqBool2Dec (E:Eq)(F:HasEqBool E) <: HasEqDec E. - Lemma eq_dec : forall x y, {E.eq x y}+{~E.eq x y}. - Proof. - intros x y. assert (H:=F.eqb_eq x y). - destruct (F.eqb x y); [left|right]. - apply -> H; auto. - intro EQ. apply H in EQ. discriminate. - Defined. -End HasEqBool2Dec. - -Module Dec2Bool (E:DecidableType) <: BooleanDecidableType - := E <+ HasEqDec2Bool. - -Module Bool2Dec (E:BooleanEqualityType) <: BooleanDecidableType - := E <+ HasEqBool2Dec. - - - -(** * UsualDecidableType - - A particular case of [DecidableType] where the equality is - the usual one of Coq. *) - -Module Type UsualEq <: Eq. - Parameter Inline t : Type. - Definition eq := @eq t. -End UsualEq. - -Module UsualIsEq (E:UsualEq) <: IsEq E. - Program Instance eq_equiv : Equivalence E.eq. -End UsualIsEq. - -Module UsualIsEqOrig (E:UsualEq) <: IsEqOrig E. - Definition eq_refl := @eq_refl E.t. - Definition eq_sym := @eq_sym E.t. - Definition eq_trans := @eq_trans E.t. -End UsualIsEqOrig. - -Module Type UsualEqualityType <: EqualityType - := UsualEq <+ IsEq. - -Module Type UsualDecidableType <: DecidableType - := UsualEq <+ IsEq <+ HasEqDec. - -Module Type UsualDecidableTypeBoth <: DecidableTypeBoth - := UsualEq <+ IsEq <+ IsEqOrig <+ HasEqDec. - -Module Type UsualBoolEq := UsualEq <+ HasEqBool. - -Module Type UsualDecidableTypeFull <: DecidableTypeFull - := UsualEq <+ IsEq <+ IsEqOrig <+ HasEqDec <+ HasEqBool. - - -(** Some shortcuts for easily building a [UsualDecidableType] *) - -Module Type MiniDecidableType. - Parameter t : Type. - Parameter eq_dec : forall x y : t, {x=y}+{~x=y}. -End MiniDecidableType. - -Module Make_UDT (M:MiniDecidableType) <: UsualDecidableTypeBoth. - Definition eq := @Logic.eq M.t. - Include M <+ UsualIsEq <+ UsualIsEqOrig. -End Make_UDT. - -Module Make_UDTF (M:UsualBoolEq) <: UsualDecidableTypeFull - := M <+ UsualIsEq <+ UsualIsEqOrig <+ HasEqBool2Dec. diff --git a/theories/Structures/DecidableType2Ex.v b/theories/Structures/DecidableType2Ex.v deleted file mode 100644 index 2ce2b56623..0000000000 --- a/theories/Structures/DecidableType2Ex.v +++ /dev/null @@ -1,53 +0,0 @@ -(***********************************************************************) -(* v * The Coq Proof Assistant / The Coq Development Team *) -(* E.eq ==> Logic.eq) eqb. -Proof. -intros x x' Exx' y y' Eyy'. -apply eq_true_iff_eq. -rewrite 2 eqb_eq, Exx', Eyy'; auto with *. -Qed. - -End BoolEqualityFacts. - - -(** * Keys and datas used in FMap *) -Module KeyDecidableType(Import D:DecidableType). - - Section Elt. - Variable elt : Type. - Notation key:=t. - - Local Open Scope signature_scope. - - Definition eqk : relation (key*elt) := eq @@1. - Definition eqke : relation (key*elt) := eq * Logic.eq. - Hint Unfold eqk eqke. - - (* eqke is stricter than eqk *) - - Global Instance eqke_eqk : subrelation eqke eqk. - Proof. firstorder. Qed. - - (* eqk, eqke are equalities, ltk is a strict order *) - - Global Instance eqk_equiv : Equivalence eqk. - - Global Instance eqke_equiv : Equivalence eqke. - - (* Additionnal facts *) - - Lemma InA_eqke_eqk : - forall x m, InA eqke x m -> InA eqk x m. - Proof. - unfold eqke, RelProd; induction 1; firstorder. - Qed. - Hint Resolve InA_eqke_eqk. - - Lemma InA_eqk : forall p q m, eqk p q -> InA eqk p m -> InA eqk q m. - Proof. - intros. rewrite <- H; auto. - Qed. - - Definition MapsTo (k:key)(e:elt):= InA eqke (k,e). - Definition In k m := exists e:elt, MapsTo k e m. - - Hint Unfold MapsTo In. - - (* An alternative formulation for [In k l] is [exists e, InA eqk (k,e) l] *) - - Lemma In_alt : forall k l, In k l <-> exists e, InA eqk (k,e) l. - Proof. - firstorder. - exists x; auto. - induction H. - destruct y; compute in H. - exists e; left; auto. - destruct IHInA as [e H0]. - exists e; auto. - Qed. - - Lemma In_alt2 : forall k l, In k l <-> Exists (fun p => eq k (fst p)) l. - Proof. - unfold In, MapsTo. - setoid_rewrite Exists_exists; setoid_rewrite InA_alt. - firstorder. - exists (snd x), x; auto. - Qed. - - Lemma In_nil : forall k, In k nil <-> False. - Proof. - intros; rewrite In_alt2; apply Exists_nil. - Qed. - - Lemma In_cons : forall k p l, - In k (p::l) <-> eq k (fst p) \/ In k l. - Proof. - intros; rewrite !In_alt2, Exists_cons; intuition. - Qed. - - Global Instance MapsTo_compat : - Proper (eq==>Logic.eq==>equivlistA eqke==>iff) MapsTo. - Proof. - intros x x' Hx e e' He l l' Hl. unfold MapsTo. - rewrite Hx, He, Hl; intuition. - Qed. - - Global Instance In_compat : Proper (eq==>equivlistA eqk==>iff) In. - Proof. - intros x x' Hx l l' Hl. rewrite !In_alt. - setoid_rewrite Hl. setoid_rewrite Hx. intuition. - Qed. - - Lemma MapsTo_eq : forall l x y e, eq x y -> MapsTo x e l -> MapsTo y e l. - Proof. intros l x y e EQ. rewrite <- EQ; auto. Qed. - - Lemma In_eq : forall l x y, eq x y -> In x l -> In y l. - Proof. intros l x y EQ. rewrite <- EQ; auto. Qed. - - Lemma In_inv : forall k k' e l, In k ((k',e) :: l) -> eq k k' \/ In k l. - Proof. - intros; invlist In; invlist MapsTo. compute in * |- ; intuition. - right; exists x; auto. - Qed. - - Lemma In_inv_2 : forall k k' e e' l, - InA eqk (k, e) ((k', e') :: l) -> ~ eq k k' -> InA eqk (k, e) l. - Proof. - intros; invlist InA; intuition. - Qed. - - Lemma In_inv_3 : forall x x' l, - InA eqke x (x' :: l) -> ~ eqk x x' -> InA eqke x l. - Proof. - intros; invlist InA; compute in * |- ; intuition. - Qed. - - End Elt. - - Hint Unfold eqk eqke. - Hint Extern 2 (eqke ?a ?b) => split. - Hint Resolve InA_eqke_eqk. - Hint Unfold MapsTo In. - Hint Resolve In_inv_2 In_inv_3. - -End KeyDecidableType. - - - diff --git a/theories/Structures/DecidableTypeEx.v b/theories/Structures/DecidableTypeEx.v index 022102f70d..4407ead416 100644 --- a/theories/Structures/DecidableTypeEx.v +++ b/theories/Structures/DecidableTypeEx.v @@ -12,19 +12,15 @@ Require Import DecidableType OrderedType OrderedTypeEx. Set Implicit Arguments. Unset Strict Implicit. +(** NB: This file is here only for compatibility with earlier version of + [FSets] and [FMap]. Please use [Structures/Equalities.v] directly now. *) + (** * Examples of Decidable Type structures. *) (** A particular case of [DecidableType] where the equality is the usual one of Coq. *) -Module Type UsualDecidableType. - Parameter Inline t : Type. - Definition eq := @eq t. - Definition eq_refl := @refl_equal t. - Definition eq_sym := @sym_eq t. - Definition eq_trans := @trans_eq t. - Parameter eq_dec : forall x y, { eq x y }+{~eq x y }. -End UsualDecidableType. +Module Type UsualDecidableType := Equalities.UsualDecidableTypeOrig. (** a [UsualDecidableType] is in particular an [DecidableType]. *) @@ -32,19 +28,10 @@ Module UDT_to_DT (U:UsualDecidableType) <: DecidableType := U. (** an shortcut for easily building a UsualDecidableType *) -Module Type MiniDecidableType. - Parameter Inline t : Type. - Parameter eq_dec : forall x y:t, { x=y }+{ x<>y }. -End MiniDecidableType. +Module Type MiniDecidableType := Equalities.MiniDecidableType. -Module Make_UDT (M:MiniDecidableType) <: UsualDecidableType. - Definition t:=M.t. - Definition eq := @eq t. - Definition eq_refl := @refl_equal t. - Definition eq_sym := @sym_eq t. - Definition eq_trans := @trans_eq t. - Definition eq_dec := M.eq_dec. -End Make_UDT. +Module Make_UDT (M:MiniDecidableType) <: UsualDecidableType + := Equalities.Make_UDT M. (** An OrderedType can now directly be seen as a DecidableType *) diff --git a/theories/Structures/Equalities.v b/theories/Structures/Equalities.v new file mode 100644 index 0000000000..76f539764a --- /dev/null +++ b/theories/Structures/Equalities.v @@ -0,0 +1,216 @@ +(***********************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* t -> Prop. +End HasEq. + +Module Type Eq := Typ <+ HasEq. + +Module Type EqNotation (Import E:Eq). + Infix "==" := eq (at level 70, no associativity). + Notation "x ~= y" := (~eq x y) (at level 70, no associativity). +End EqNotation. + +Module Type Eq' := Eq <+ EqNotation. + +(** * Specification of the equality via the [Equivalence] type class *) + +Module Type IsEq (Import E:Eq). + Declare Instance eq_equiv : Equivalence eq. +End IsEq. + +(** * Earlier specification of equality by three separate lemmas. *) + +Module Type IsEqOrig (Import E:Eq'). + Axiom eq_refl : forall x : t, x==x. + Axiom eq_sym : forall x y : t, x==y -> y==x. + Axiom eq_trans : forall x y z : t, x==y -> y==z -> x==z. + Hint Immediate eq_sym. + Hint Resolve eq_refl eq_trans. +End IsEqOrig. + +(** * Types with decidable equality *) + +Module Type HasEqDec (Import E:Eq'). + Parameter eq_dec : forall x y : t, { x==y } + { ~ x==y }. +End HasEqDec. + +(** * Boolean Equality *) + +(** Having [eq_dec] is the same as having a boolean equality plus + a correctness proof. *) + +Module Type HasEqBool (Import E:Eq'). + Parameter Inline eqb : t -> t -> bool. + Parameter eqb_eq : forall x y, eqb x y = true <-> x==y. +End HasEqBool. + +(** From these basic blocks, we can build many combinations + of static standalone module types. *) + +Module Type EqualityType := Eq <+ IsEq. + +Module Type EqualityTypeOrig := Eq <+ IsEqOrig. + +Module Type EqualityTypeBoth <: EqualityType <: EqualityTypeOrig + := Eq <+ IsEq <+ IsEqOrig. + +Module Type DecidableType <: EqualityType + := Eq <+ IsEq <+ HasEqDec. + +Module Type DecidableTypeOrig <: EqualityTypeOrig + := Eq <+ IsEqOrig <+ HasEqDec. + +Module Type DecidableTypeBoth <: DecidableType <: DecidableTypeOrig + := EqualityTypeBoth <+ HasEqDec. + +Module Type BooleanEqualityType <: EqualityType + := Eq <+ IsEq <+ HasEqBool. + +Module Type BooleanDecidableType <: DecidableType <: BooleanEqualityType + := Eq <+ IsEq <+ HasEqDec <+ HasEqBool. + +Module Type DecidableTypeFull <: DecidableTypeBoth <: BooleanDecidableType + := Eq <+ IsEq <+ IsEqOrig <+ HasEqDec <+ HasEqBool. + +(** Same, with notation for [eq] *) + +Module Type EqualityType' := EqualityType <+ EqNotation. +Module Type EqualityTypeOrig' := EqualityTypeOrig <+ EqNotation. +Module Type EqualityTypeBoth' := EqualityTypeBoth <+ EqNotation. +Module Type DecidableType' := DecidableType <+ EqNotation. +Module Type DecidableTypeOrig' := DecidableTypeOrig <+ EqNotation. +Module Type DecidableTypeBoth' := DecidableTypeBoth <+ EqNotation. +Module Type BooleanEqualityType' := BooleanEqualityType <+ EqNotation. +Module Type BooleanDecidableType' := BooleanDecidableType <+ EqNotation. +Module Type DecidableTypeFull' := DecidableTypeFull <+ EqNotation. + +(** * Compatibility wrapper from/to the old version of + [EqualityType] and [DecidableType] *) + +Module BackportEq (E:Eq)(F:IsEq E) <: IsEqOrig E. + Definition eq_refl := @Equivalence_Reflexive _ _ F.eq_equiv. + Definition eq_sym := @Equivalence_Symmetric _ _ F.eq_equiv. + Definition eq_trans := @Equivalence_Transitive _ _ F.eq_equiv. +End BackportEq. + +Module UpdateEq (E:Eq)(F:IsEqOrig E) <: IsEq E. + Instance eq_equiv : Equivalence E.eq. + Proof. exact (Build_Equivalence _ _ F.eq_refl F.eq_sym F.eq_trans). Qed. +End UpdateEq. + +Module Backport_ET (E:EqualityType) <: EqualityTypeBoth + := E <+ BackportEq. + +Module Update_ET (E:EqualityTypeOrig) <: EqualityTypeBoth + := E <+ UpdateEq. + +Module Backport_DT (E:DecidableType) <: DecidableTypeBoth + := E <+ BackportEq. + +Module Update_DT (E:DecidableTypeOrig) <: DecidableTypeBoth + := E <+ UpdateEq. + + +(** * Having [eq_dec] is equivalent to having [eqb] and its spec. *) + +Module HasEqDec2Bool (E:Eq)(F:HasEqDec E) <: HasEqBool E. + Definition eqb x y := if F.eq_dec x y then true else false. + Lemma eqb_eq : forall x y, eqb x y = true <-> E.eq x y. + Proof. + intros x y. unfold eqb. destruct F.eq_dec as [EQ|NEQ]. + auto with *. + split. discriminate. intro EQ; elim NEQ; auto. + Qed. +End HasEqDec2Bool. + +Module HasEqBool2Dec (E:Eq)(F:HasEqBool E) <: HasEqDec E. + Lemma eq_dec : forall x y, {E.eq x y}+{~E.eq x y}. + Proof. + intros x y. assert (H:=F.eqb_eq x y). + destruct (F.eqb x y); [left|right]. + apply -> H; auto. + intro EQ. apply H in EQ. discriminate. + Defined. +End HasEqBool2Dec. + +Module Dec2Bool (E:DecidableType) <: BooleanDecidableType + := E <+ HasEqDec2Bool. + +Module Bool2Dec (E:BooleanEqualityType) <: BooleanDecidableType + := E <+ HasEqBool2Dec. + + + +(** * UsualDecidableType + + A particular case of [DecidableType] where the equality is + the usual one of Coq. *) + +Module Type HasUsualEq (Import T:Typ) <: HasEq T. + Definition eq := @Logic.eq t. +End HasUsualEq. + +Module Type UsualEq <: Eq := Typ <+ HasUsualEq. + +Module Type UsualIsEq (E:UsualEq) <: IsEq E. + Program Instance eq_equiv : Equivalence E.eq. +End UsualIsEq. + +Module Type UsualIsEqOrig (E:UsualEq) <: IsEqOrig E. + Definition eq_refl := @Logic.eq_refl E.t. + Definition eq_sym := @Logic.eq_sym E.t. + Definition eq_trans := @Logic.eq_trans E.t. +End UsualIsEqOrig. + +Module Type UsualEqualityType <: EqualityType + := UsualEq <+ UsualIsEq. + +Module Type UsualDecidableType <: DecidableType + := UsualEq <+ UsualIsEq <+ HasEqDec. + +Module Type UsualDecidableTypeOrig <: DecidableTypeOrig + := UsualEq <+ UsualIsEqOrig <+ HasEqDec. + +Module Type UsualDecidableTypeBoth <: DecidableTypeBoth + := UsualEq <+ UsualIsEq <+ UsualIsEqOrig <+ HasEqDec. + +Module Type UsualBoolEq := UsualEq <+ HasEqBool. + +Module Type UsualDecidableTypeFull <: DecidableTypeFull + := UsualEq <+ UsualIsEq <+ UsualIsEqOrig <+ HasEqDec <+ HasEqBool. + + +(** Some shortcuts for easily building a [UsualDecidableType] *) + +Module Type MiniDecidableType. + Include Typ. + Parameter eq_dec : forall x y : t, {x=y}+{~x=y}. +End MiniDecidableType. + +Module Make_UDT (M:MiniDecidableType) <: UsualDecidableTypeBoth + := M <+ HasUsualEq <+ UsualIsEq <+ UsualIsEqOrig. + +Module Make_UDTF (M:UsualBoolEq) <: UsualDecidableTypeFull + := M <+ UsualIsEq <+ UsualIsEqOrig <+ HasEqBool2Dec. diff --git a/theories/Structures/EqualitiesFacts.v b/theories/Structures/EqualitiesFacts.v new file mode 100644 index 0000000000..d9b1d76fdf --- /dev/null +++ b/theories/Structures/EqualitiesFacts.v @@ -0,0 +1,185 @@ +(***********************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* E.eq ==> Logic.eq) eqb. +Proof. +intros x x' Exx' y y' Eyy'. +apply eq_true_iff_eq. +rewrite 2 eqb_eq, Exx', Eyy'; auto with *. +Qed. + +End BoolEqualityFacts. + + +(** * Keys and datas used in FMap *) +Module KeyDecidableType(Import D:DecidableType). + + Section Elt. + Variable elt : Type. + Notation key:=t. + + Local Open Scope signature_scope. + + Definition eqk : relation (key*elt) := eq @@1. + Definition eqke : relation (key*elt) := eq * Logic.eq. + Hint Unfold eqk eqke. + + (* eqke is stricter than eqk *) + + Global Instance eqke_eqk : subrelation eqke eqk. + Proof. firstorder. Qed. + + (* eqk, eqke are equalities, ltk is a strict order *) + + Global Instance eqk_equiv : Equivalence eqk. + + Global Instance eqke_equiv : Equivalence eqke. + + (* Additionnal facts *) + + Lemma InA_eqke_eqk : + forall x m, InA eqke x m -> InA eqk x m. + Proof. + unfold eqke, RelProd; induction 1; firstorder. + Qed. + Hint Resolve InA_eqke_eqk. + + Lemma InA_eqk : forall p q m, eqk p q -> InA eqk p m -> InA eqk q m. + Proof. + intros. rewrite <- H; auto. + Qed. + + Definition MapsTo (k:key)(e:elt):= InA eqke (k,e). + Definition In k m := exists e:elt, MapsTo k e m. + + Hint Unfold MapsTo In. + + (* An alternative formulation for [In k l] is [exists e, InA eqk (k,e) l] *) + + Lemma In_alt : forall k l, In k l <-> exists e, InA eqk (k,e) l. + Proof. + firstorder. + exists x; auto. + induction H. + destruct y; compute in H. + exists e; left; auto. + destruct IHInA as [e H0]. + exists e; auto. + Qed. + + Lemma In_alt2 : forall k l, In k l <-> Exists (fun p => eq k (fst p)) l. + Proof. + unfold In, MapsTo. + setoid_rewrite Exists_exists; setoid_rewrite InA_alt. + firstorder. + exists (snd x), x; auto. + Qed. + + Lemma In_nil : forall k, In k nil <-> False. + Proof. + intros; rewrite In_alt2; apply Exists_nil. + Qed. + + Lemma In_cons : forall k p l, + In k (p::l) <-> eq k (fst p) \/ In k l. + Proof. + intros; rewrite !In_alt2, Exists_cons; intuition. + Qed. + + Global Instance MapsTo_compat : + Proper (eq==>Logic.eq==>equivlistA eqke==>iff) MapsTo. + Proof. + intros x x' Hx e e' He l l' Hl. unfold MapsTo. + rewrite Hx, He, Hl; intuition. + Qed. + + Global Instance In_compat : Proper (eq==>equivlistA eqk==>iff) In. + Proof. + intros x x' Hx l l' Hl. rewrite !In_alt. + setoid_rewrite Hl. setoid_rewrite Hx. intuition. + Qed. + + Lemma MapsTo_eq : forall l x y e, eq x y -> MapsTo x e l -> MapsTo y e l. + Proof. intros l x y e EQ. rewrite <- EQ; auto. Qed. + + Lemma In_eq : forall l x y, eq x y -> In x l -> In y l. + Proof. intros l x y EQ. rewrite <- EQ; auto. Qed. + + Lemma In_inv : forall k k' e l, In k ((k',e) :: l) -> eq k k' \/ In k l. + Proof. + intros; invlist In; invlist MapsTo. compute in * |- ; intuition. + right; exists x; auto. + Qed. + + Lemma In_inv_2 : forall k k' e e' l, + InA eqk (k, e) ((k', e') :: l) -> ~ eq k k' -> InA eqk (k, e) l. + Proof. + intros; invlist InA; intuition. + Qed. + + Lemma In_inv_3 : forall x x' l, + InA eqke x (x' :: l) -> ~ eqk x x' -> InA eqke x l. + Proof. + intros; invlist InA; compute in * |- ; intuition. + Qed. + + End Elt. + + Hint Unfold eqk eqke. + Hint Extern 2 (eqke ?a ?b) => split. + Hint Resolve InA_eqke_eqk. + Hint Unfold MapsTo In. + Hint Resolve In_inv_2 In_inv_3. + +End KeyDecidableType. + + +(** * PairDecidableType + + From two decidable types, we can build a new DecidableType + over their cartesian product. *) + +Module PairDecidableType(D1 D2:DecidableType) <: DecidableType. + + Definition t := (D1.t * D2.t)%type. + + Definition eq := (D1.eq * D2.eq)%signature. + + Instance eq_equiv : Equivalence eq. + + Definition eq_dec : forall x y, { eq x y }+{ ~eq x y }. + Proof. + intros (x1,x2) (y1,y2); unfold eq; simpl. + destruct (D1.eq_dec x1 y1); destruct (D2.eq_dec x2 y2); + compute; intuition. + Defined. + +End PairDecidableType. + +(** Similarly for pairs of UsualDecidableType *) + +Module PairUsualDecidableType(D1 D2:UsualDecidableType) <: UsualDecidableType. + Definition t := (D1.t * D2.t)%type. + Definition eq := @eq t. + Program Instance eq_equiv : Equivalence eq. + Definition eq_dec : forall x y, { eq x y }+{ ~eq x y }. + Proof. + intros (x1,x2) (y1,y2); + destruct (D1.eq_dec x1 y1); destruct (D2.eq_dec x2 y2); + unfold eq, D1.eq, D2.eq in *; simpl; + (left; f_equal; auto; fail) || + (right; intro H; injection H; auto). + Defined. + +End PairUsualDecidableType. diff --git a/theories/Structures/GenericMinMax.v b/theories/Structures/GenericMinMax.v index f45e43b445..232989fad0 100644 --- a/theories/Structures/GenericMinMax.v +++ b/theories/Structures/GenericMinMax.v @@ -6,7 +6,7 @@ (* * GNU Lesser General Public License Version 2.1 *) (***********************************************************************) -Require Import OrderTac OrderedType2 OrderedType2Facts Setoid Morphisms Basics. +Require Import Orders OrdersTac OrdersFacts Setoid Morphisms Basics. (** * A Generic construction of min and max *) diff --git a/theories/Structures/OrderTac.v b/theories/Structures/OrderTac.v deleted file mode 100644 index 2465dc539e..0000000000 --- a/theories/Structures/OrderTac.v +++ /dev/null @@ -1,323 +0,0 @@ -(***********************************************************************) -(* v * The Coq Proof Assistant / The Coq Development Team *) -(* le y z -> le x z]. -*) - -Inductive ord := OEQ | OLT | OLE. -Definition trans_ord o o' := - match o, o' with - | OEQ, _ => o' - | _, OEQ => o - | OLE, OLE => OLE - | _, _ => OLT - end. -Local Infix "+" := trans_ord. - - -(** ** The requirements of the tactic : [TotalOrder]. - - [TotalOrder] contains an equivalence [eq], - a strict order [lt] total and compatible with [eq], and - a larger order [le] synonym for [lt\/eq]. - - NB: we create here a clone of TotalOrder, but without the [Inline] Pragma. - This is important for having later the exact shape in Ltac matching. -*) - -Module Type TotalOrder_NoInline <: TotalOrder. - Parameter Inline t : Type. - Parameters eq lt le : t -> t -> Prop. - Include IsEq <+ IsStrOrder <+ LeIsLtEq <+ LtIsTotal. -End TotalOrder_NoInline. - -Module Type TotalOrder_NoInline' := TotalOrder_NoInline <+ EqLtLeNotation. - -(** We make explicit aliases to help ltac matching *) - -Module CloneOrder (O:TotalOrder_NoInline) <: TotalOrder. -Definition t := O.t. -Definition eq := O.eq. -Definition lt := O.lt. -Definition le := O.le. -Definition eq_equiv := O.eq_equiv. -Definition lt_compat := O.lt_compat. -Definition lt_strorder := O.lt_strorder. -Definition le_lteq := O.le_lteq. -Definition lt_total := O.lt_total. -End CloneOrder. - - - -(** ** Properties that will be used by the [order] tactic *) - -Module OrderFacts(Import O:TotalOrder_NoInline'). - -(** Reflexivity rules *) - -Lemma eq_refl : forall x, x==x. -Proof. reflexivity. Qed. - -Lemma le_refl : forall x, x<=x. -Proof. intros; rewrite le_lteq; right; reflexivity. Qed. - -Lemma lt_irrefl : forall x, ~ x y==x. -Proof. auto with *. Qed. - -Lemma le_antisym : forall x y, x<=y -> y<=x -> x==y. -Proof. - intros x y; rewrite 2 le_lteq. intuition. - elim (StrictOrder_Irreflexive x); transitivity y; auto. -Qed. - -Lemma neq_sym : forall x y, ~x==y -> ~y==x. -Proof. auto using eq_sym. Qed. - -(** Transitivity rules : first, a generic formulation, then instances*) - -Ltac subst_eqns := - match goal with - | H : _==_ |- _ => (rewrite H || rewrite <- H); clear H; subst_eqns - | _ => idtac - end. - -Definition interp_ord o := - match o with OEQ => O.eq | OLT => O.lt | OLE => O.le end. -Local Notation "#" := interp_ord. - -Lemma trans : forall o o' x y z, #o x y -> #o' y z -> #(o+o') x z. -Proof. -destruct o, o'; simpl; intros x y z; rewrite ?le_lteq; intuition; - subst_eqns; eauto using (StrictOrder_Transitive x y z) with *. -Qed. - -Definition eq_trans x y z : x==y -> y==z -> x==z := @trans OEQ OEQ x y z. -Definition le_trans x y z : x<=y -> y<=z -> x<=z := @trans OLE OLE x y z. -Definition lt_trans x y z : x y x y x y<=z -> x y x y==z -> x y<=z -> x<=z := @trans OEQ OLE x y z. -Definition le_eq x y z : x<=y -> y==z -> x<=z := @trans OLE OEQ x y z. - -Lemma eq_neq : forall x y z, x==y -> ~y==z -> ~x==z. -Proof. eauto using eq_trans, eq_sym. Qed. - -Lemma neq_eq : forall x y z, ~x==y -> y==z -> ~x==z. -Proof. eauto using eq_trans, eq_sym. Qed. - -(** (double) negation rules *) - -Lemma not_neq_eq : forall x y, ~~x==y -> x==y. -Proof. -intros x y H. destruct (lt_total x y) as [H'|[H'|H']]; auto; - destruct H; intro H; rewrite H in H'; eapply lt_irrefl; eauto. -Qed. - -Lemma not_ge_lt : forall x y, ~y<=x -> x x<=y. -Proof. -intros x y H. rewrite le_lteq. generalize (lt_total x y); intuition. -Qed. - -Lemma le_neq_lt : forall x y, x<=y -> ~x==y -> x