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 SetoidList. 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.
Module Type EqualityType := Equalities.EqualityTypeOrig.
Module Type DecidableType := Equalities.DecidableTypeOrig.
Module KeyDecidableType(D:DecidableType). Import D. Section Elt. Variable elt : Type. Notation key:=t. Definition eqk (p p':key*elt) := eq (fst p) (fst p'). Definition eqke (p p':key*elt) := eq (fst p) (fst p') /\ (snd p) = (snd p'). Hint Unfold eqk eqke : core. Hint Extern 2 (eqke ?a ?b) => split : core. (* eqke is stricter than eqk *)elt:Typeforall x x' : key * elt, eqke x x' -> eqk x x'unfold eqk, eqke; intuition. Qed. (* eqk, eqke are equalities *)elt:Typeforall x x' : key * elt, eqke x x' -> eqk x x'elt:Typeforall e : key * elt, eqk e eauto. Qed.elt:Typeforall e : key * elt, eqk e eelt:Typeforall e : key * elt, eqke e eauto. Qed.elt:Typeforall e : key * elt, eqke e eelt:Typeforall e e' : key * elt, eqk e e' -> eqk e' eauto. Qed.elt:Typeforall e e' : key * elt, eqk e e' -> eqk e' eelt:Typeforall e e' : key * elt, eqke e e' -> eqke e' eunfold eqke; intuition. Qed.elt:Typeforall e e' : key * elt, eqke e e' -> eqke e' eelt:Typeforall e e' e'' : key * elt, eqk e e' -> eqk e' e'' -> eqk e e''eauto. Qed.elt:Typeforall e e' e'' : key * elt, eqk e e' -> eqk e' e'' -> eqk e e''elt:Typeforall e e' e'' : key * elt, eqke e e' -> eqke e' e'' -> eqke e e''unfold eqke; intuition; [ eauto | congruence ]. Qed. Hint Resolve eqk_trans eqke_trans eqk_refl eqke_refl : core. Hint Immediate eqk_sym eqke_sym : core.elt:Typeforall e e' e'' : key * elt, eqke e e' -> eqke e' e'' -> eqke e e''elt:TypeEquivalence eqksplit; eauto. Qed.elt:TypeEquivalence eqkelt:TypeEquivalence eqkesplit; eauto. Qed.elt:TypeEquivalence eqkeelt:Typeforall (x : key * elt) (m : list (key * elt)), InA eqke x m -> InA eqk x munfold eqke; induction 1; intuition. Qed. Hint Resolve InA_eqke_eqk : core.elt:Typeforall (x : key * elt) (m : list (key * elt)), InA eqke x m -> InA eqk x melt:Typeforall (p q : key * elt) (m : list (key * elt)), eqk p q -> InA eqk p m -> InA eqk q mintros; apply InA_eqA with p; auto using eqk_equiv. 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 : core. (* An alternative formulation for [In k l] is [exists e, InA eqk (k,e) l] *)elt:Typeforall (p q : key * elt) (m : list (key * elt)), eqk p q -> InA eqk p m -> InA eqk q melt:Typeforall (k : key) (l : list (key * elt)), In k l <-> (exists e : elt, InA eqk (k, e) l)elt:Typeforall (k : key) (l : list (key * elt)), In k l <-> (exists e : elt, InA eqk (k, e) l)elt:Typek:keyl:list (key * elt)x:eltH:MapsTo k x lexists e : elt, InA eqk (k, e) lelt:Typek:keyl:list (key * elt)x:eltH:InA eqk (k, x) lIn k lelt:Typek:keyl:list (key * elt)x:eltH:InA eqk (k, x) lIn k lelt:Typek:keyx:elty:(key * elt)%typel:list (key * elt)H:eqk (k, x) yIn k (y :: l)elt:Typek:keyx:elty:(key * elt)%typel:list (key * elt)H:InA eqk (k, x) lIHInA:In k lIn k (y :: l)elt:Typek:keyx:eltt0:keye:eltl:list (key * elt)H:eqk (k, x) (t0, e)In k ((t0, e) :: l)elt:Typek:keyx:elty:(key * elt)%typel:list (key * elt)H:InA eqk (k, x) lIHInA:In k lIn k (y :: l)elt:Typek:keyx:elty:(key * elt)%typel:list (key * elt)H:InA eqk (k, x) lIHInA:In k lIn k (y :: l)exists e; auto. Qed.elt:Typek:keyx:elty:(key * elt)%typel:list (key * elt)H:InA eqk (k, x) le:eltH0:MapsTo k e lIn k (y :: l)elt:Typeforall (l : list (key * elt)) (x y : key) (e : elt), eq x y -> MapsTo x e l -> MapsTo y e lintros; unfold MapsTo in *; apply InA_eqA with (x,e); auto using eqke_equiv. Qed.elt:Typeforall (l : list (key * elt)) (x y : key) (e : elt), eq x y -> MapsTo x e l -> MapsTo y e lelt:Typeforall (l : list (key * elt)) (x y : key), eq x y -> In x l -> In y ldestruct 2 as (e,E); exists e; eapply MapsTo_eq; eauto. Qed.elt:Typeforall (l : list (key * elt)) (x y : key), eq x y -> In x l -> In y lelt:Typeforall (k k' : key) (e : elt) (l : list (key * elt)), In k ((k', e) :: l) -> eq k k' \/ In k lelt:Typeforall (k k' : key) (e : elt) (l : list (key * elt)), In k ((k', e) :: l) -> eq k k' \/ In k lelt:Typek, k':keye:eltl:list (key * elt)H:In k ((k', e) :: l)x:eltH0:MapsTo k x ((k', e) :: l)eq k k' \/ In k ldestruct H1; simpl in *; intuition. Qed.elt:Typek, k':keye:eltl:list (key * elt)H:In k ((k', e) :: l)x:eltH1:eqke (k, x) (k', e)eq k k' \/ In k lelt:Typeforall (k k' : key) (e e' : elt) (l : list (key * elt)), InA eqk (k, e) ((k', e') :: l) -> ~ eq k k' -> InA eqk (k, e) linversion_clear 1; compute in H0; intuition. Qed.elt:Typeforall (k k' : key) (e e' : elt) (l : list (key * elt)), InA eqk (k, e) ((k', e') :: l) -> ~ eq k k' -> InA eqk (k, e) lelt:Typeforall (x x' : key * elt) (l : list (key * elt)), InA eqke x (x' :: l) -> ~ eqk x x' -> InA eqke x linversion_clear 1; compute in H0; intuition. Qed. End Elt. Hint Unfold eqk eqke : core. Hint Extern 2 (eqke ?a ?b) => split : core. Hint Resolve eqk_trans eqke_trans eqk_refl eqke_refl : core. Hint Immediate eqk_sym eqke_sym : core. Hint Resolve InA_eqke_eqk : core. Hint Unfold MapsTo In : core. Hint Resolve In_inv_2 In_inv_3 : core. End KeyDecidableType.elt:Typeforall (x x' : key * elt) (l : list (key * elt)), InA eqke x (x' :: l) -> ~ eqk x x' -> InA eqke x l