Built with Alectryon, running Coq+SerAPI v8.10.0+0.7.0. Coq sources are in this panel; goals and messages will appear in the other. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑ Ctrl+↓ to navigate, Ctrl+🖱️ to focus.
(************************************************************************) (* * The Coq Proof Assistant / The Coq Development Team *) (* v * INRIA, CNRS and contributors - Copyright 1999-2018 *) (* <O___,, * (see CREDITS file for the list of authors) *) (* \VV/ **************************************************************) (* // * This file is distributed under the terms of the *) (* * GNU Lesser General Public License Version 2.1 *) (* * (see LICENSE file for the text of the license) *) (************************************************************************) Require Export RelationPairs SetoidList Orders EqualitiesFacts. Set Implicit Arguments. Unset Strict Implicit.
Module OrderedTypeLists (O:OrderedType). Notation In:=(InA O.eq). Notation Inf:=(lelistA O.lt). Notation Sort:=(sort O.lt). Notation NoDup:=(NoDupA O.eq).forall (l : list O.t) (x y : O.t), x = y -> In x l -> In y lforall (l : list O.t) (x y : O.t), x = y -> In x l -> In y lrewrite <- H; auto. Qed.l:list O.tx, y:O.tH:x = yH0:In x lIn y lforall (l : list O.t) (x : O.t), List.In x l -> In x lexact (In_InA O.eq_equiv). Qed.forall (l : list O.t) (x : O.t), List.In x l -> In x lforall (l : list O.t) (x y : O.t), O.lt x y -> Inf y l -> Inf x lexact (InfA_ltA O.lt_strorder). Qed.forall (l : list O.t) (x y : O.t), O.lt x y -> Inf y l -> Inf x lforall (l : list O.t) (x y : O.t), O.eq x y -> Inf y l -> Inf x lexact (InfA_eqA O.eq_equiv O.lt_compat). Qed.forall (l : list O.t) (x y : O.t), O.eq x y -> Inf y l -> Inf x lforall (l : list O.t) (x a : O.t), Sort l -> Inf a l -> In x l -> O.lt a xexact (SortA_InfA_InA O.eq_equiv O.lt_strorder O.lt_compat). Qed.forall (l : list O.t) (x a : O.t), Sort l -> Inf a l -> In x l -> O.lt a xforall (l : list O.t) (x : O.t), (forall y : O.t, List.In y l -> O.lt x y) -> Inf x lexact (@In_InfA O.t O.lt). Qed.forall (l : list O.t) (x : O.t), (forall y : O.t, List.In y l -> O.lt x y) -> Inf x lforall (l : list O.t) (x : O.t), (forall y : O.t, In y l -> O.lt x y) -> Inf x lexact (InA_InfA O.eq_equiv (ltA:=O.lt)). Qed.forall (l : list O.t) (x : O.t), (forall y : O.t, In y l -> O.lt x y) -> Inf x lforall (l : list O.t) (x : O.t), Sort l -> Inf x l <-> (forall y : O.t, In y l -> O.lt x y)exact (InfA_alt O.eq_equiv O.lt_strorder O.lt_compat). Qed.forall (l : list O.t) (x : O.t), Sort l -> Inf x l <-> (forall y : O.t, In y l -> O.lt x y)forall l : list O.t, Sort l -> NoDup lexact (SortA_NoDupA O.eq_equiv O.lt_strorder O.lt_compat) . Qed. Hint Resolve ListIn_In Sort_NoDup Inf_lt : core. Hint Immediate In_eq Inf_lt : core. End OrderedTypeLists.forall l : list O.t, Sort l -> NoDup l
Module KeyOrderedType(O:OrderedType). Include KeyDecidableType(O). (* provides eqk, eqke *) Notation key:=O.t. Local Open Scope signature_scope. Definition ltk {elt} : relation (key*elt) := O.lt @@1. Hint Unfold ltk : core. (* ltk is a strict order *) Instance ltk_strorder {elt} : StrictOrder (@ltk elt) := _.elt:TypeProper (eqk ==> eqk ==> iff) ltkunfold eqk, ltk; auto with *. Qed.elt:TypeProper (eqk ==> eqk ==> iff) ltkelt:TypeProper (eqke ==> eqke ==> iff) ltkeapply subrelation_proper; eauto with *. Qed. (* Additional facts *)elt:TypeProper (eqke ==> eqke ==> iff) ltkelt:TypeProper (O.eq ==> eq ==> eqke) pairapply pair_compat. Qed. Section Elt. Variable elt : Type. Implicit Type p q : key*elt. Implicit Type l m : list (key*elt).elt:TypeProper (O.eq ==> eq ==> eqke) pairelt:Typep, q:(key * elt)%typeltk p q -> ~ eqk p qelt:Typep, q:(key * elt)%typeltk p q -> ~ eqk p qelim (StrictOrder_Irreflexive _ LT). Qed.elt:Typep, q:(key * elt)%typeLT:ltk q qEQ:eqk p qFalseelt:Typep, q:(key * elt)%typeltk p q -> ~ eqke p qelt:Typep, q:(key * elt)%typeltk p q -> ~ eqke p qelim (StrictOrder_Irreflexive _ LT). Qed. Notation Sort := (sort ltk). Notation Inf := (lelistA ltk).elt:Typep, q:(key * elt)%typeLT:ltk q qEQ:eqke p qFalseelt:Typel:list (key * elt)x, x':(key * elt)%typeeqk x x' -> Inf x' l -> Inf x lnow intros <-. Qed.elt:Typel:list (key * elt)x, x':(key * elt)%typeeqk x x' -> Inf x' l -> Inf x lelt:Typel:list (key * elt)x, x':(key * elt)%typeltk x x' -> Inf x' l -> Inf x lapply InfA_ltA; auto with *. Qed. Hint Immediate Inf_eq : core. Hint Resolve Inf_lt : core.elt:Typel:list (key * elt)x, x':(key * elt)%typeltk x x' -> Inf x' l -> Inf x lelt:Typel:list (key * elt)p, q:(key * elt)%typeSort l -> Inf q l -> InA eqk p l -> ltk q papply SortA_InfA_InA; auto with *. Qed.elt:Typel:list (key * elt)p, q:(key * elt)%typeSort l -> Inf q l -> InA eqk p l -> ltk q pelt:Typel:list (key * elt)k:keye:eltSort l -> Inf (k, e) l -> ~ In k lelt:Typel:list (key * elt)k:keye:eltSort l -> Inf (k, e) l -> ~ In k lelt:Typel:list (key * elt)k:keye:eltH:Sort lH0:Inf (k, e) lH1:In k lFalseelt:Typel:list (key * elt)k:keye:eltH:Sort lH0:Inf (k, e) le':eltH2:MapsTo k e' lFalseelt:Typel:list (key * elt)k:keye:eltH:Sort lH0:Inf (k, e) le':eltH2:MapsTo k e' lltk (k, e) (k, e')elt:Typel:list (key * elt)k:keye:eltH:Sort lH0:Inf (k, e) le':eltH2:MapsTo k e' leqk (k, e) (k, e')repeat red; reflexivity. Qed.elt:Typel:list (key * elt)k:keye:eltH:Sort lH0:Inf (k, e) le':eltH2:MapsTo k e' leqk (k, e) (k, e')elt:Typel:list (key * elt)Sort l -> NoDupA eqk lapply SortA_NoDupA; auto with *. Qed.elt:Typel:list (key * elt)Sort l -> NoDupA eqk lelt:Typel:list (key * elt)p, q:(key * elt)%typeSort (p :: l) -> InA eqk q l -> ltk p qintros; invlist sort; eapply Sort_Inf_In; eauto. Qed.elt:Typel:list (key * elt)p, q:(key * elt)%typeSort (p :: l) -> InA eqk q l -> ltk p qelt:Typel:list (key * elt)p, q:(key * elt)%typeSort (p :: l) -> InA eqk q (p :: l) -> ltk p q \/ eqk p qelt:Typel:list (key * elt)p, q:(key * elt)%typeSort (p :: l) -> InA eqk q (p :: l) -> ltk p q \/ eqk p qleft; apply Sort_In_cons_1 with l; auto with relations. Qed.elt:Typel:list (key * elt)p, q:(key * elt)%typeH:Sort (p :: l)H1:InA eqk q lltk p q \/ eqk p qelt:Typex:keyl:list (key * elt)k:keye:eltSort ((k, e) :: l) -> In x l -> ~ O.eq x kelt:Typex:keyl:list (key * elt)k:keye:eltSort ((k, e) :: l) -> In x l -> ~ O.eq x keapply Sort_Inf_NotIn; eauto using In_eq. Qed. End Elt. Hint Resolve ltk_not_eqk ltk_not_eqke : core. Hint Immediate Inf_eq : core. Hint Resolve Inf_lt : core. Hint Resolve Sort_Inf_NotIn : core. End KeyOrderedType.elt:Typex:keyl:list (key * elt)k:keye:eltH0:In x lH1:Sort lH2:Inf (k, e) lH:O.eq x kFalse