From 345c0ee557465d7d2f22ac34898388dfbb57cd0f Mon Sep 17 00:00:00 2001 From: letouzey Date: Thu, 7 Jan 2010 15:32:22 +0000 Subject: OrderTac: use TotalOrder, no more "change" before calling "order" (stuff with Inline) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@12636 85f007b7-540e-0410-9357-904b9bb8a0f7 --- theories/Structures/OrderTac.v | 174 ++++++++++++++++++++++---------- theories/Structures/OrderedType.v | 12 +-- theories/Structures/OrderedType2Facts.v | 64 +++--------- 3 files changed, 137 insertions(+), 113 deletions(-) (limited to 'theories/Structures') diff --git a/theories/Structures/OrderTac.v b/theories/Structures/OrderTac.v index f75e1ae913..43df377c08 100644 --- a/theories/Structures/OrderTac.v +++ b/theories/Structures/OrderTac.v @@ -6,7 +6,7 @@ (* * GNU Lesser General Public License Version 2.1 *) (***********************************************************************) -Require Import Setoid Morphisms. +Require Import Setoid Morphisms Basics DecidableType2 OrderedType2. Set Implicit Arguments. (** * The order tactic *) @@ -23,25 +23,6 @@ Set Implicit Arguments. The tactic will fail if it doesn't solve the goal. *) -(** ** The requirements of the tactic : an equivalence [eq], - a strict order [lt] total and compatible with [eq], and - a larger order [le] synonym of [lt\/eq]. *) - -Module Type OrderSig. - -Parameter Inline t : Type. -Parameters eq lt le : t -> t -> Prop. -Declare Instance eq_equiv : Equivalence eq. -Declare Instance lt_strorder : StrictOrder lt. -Declare Instance lt_compat : Proper (eq==>eq==>iff) lt. -Parameter lt_total : forall x y, lt x y \/ eq x y \/ lt y x. -Parameter le_lteq : forall x y, le x y <-> lt x y \/ eq x y. - -End OrderSig. - -(** NB : we should _not_ use "Inline" for these predicates, - otherwise the ltac matching will not work properly later. *) - (** An abstract vision of the predicates. This allows a one-line statement for interesting transitivity properties: for instance [trans_ord OLE OLE = OLE] will imply later @@ -56,19 +37,46 @@ Definition trans_ord o o' := | OLE, OLE => OLE | _, _ => OLT end. -Infix "+" := trans_ord : order. +Local Infix "+" := trans_ord. -(** ** [MakeOrderTac] : The functor providing the order tactic. *) -Module MakeOrderTac(Import O:OrderSig). +(** ** The requirements of the tactic : [TotalOrder]. -Local Open Scope order. + [TotalOrder] contains an equivalence [eq], + a strict order [lt] total and compatible with [eq], and + a larger order [le] synonym for [lt\/eq]. -Infix "==" := eq (at level 70, no associativity) : order. -Infix "<" := lt : order. -Infix "<=" := le : order. + 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. +*) -(** ** Properties that will be used by the tactic *) +Module Type TotalOrder_NoInline <: TotalOrder. + Parameter Inline t : Type. + Parameters eq lt le : t -> t -> Prop. + Include Type 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 *) @@ -104,8 +112,8 @@ Ltac subst_eqns := end. Definition interp_ord o := - match o with OEQ => eq | OLT => lt | OLE => le end. -Notation "#" := interp_ord : order. + 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. @@ -113,15 +121,15 @@ 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. +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. @@ -151,8 +159,15 @@ Qed. Lemma le_neq_lt : forall x y, x<=y -> ~x==y -> x