Module KeyDecidableType(D:DecidableType).
Local Open Scope signature_scope.
Local Notation key := D.t.
Definition eqk {elt} : relation (key*elt) := D.eq @@1.
Definition eqke {elt} : relation (key*elt) := D.eq * Logic.eq.
Hint Unfold eqk eqke : core.
(** eqk, eqke are equalities *)
Instance eqk_equiv {elt} : Equivalence (@eqk elt) := _.
Instance eqke_equiv {elt} : Equivalence (@eqke elt) := _.
(** eqke is stricter than eqk *)
Instance eqke_eqk {elt} : subrelation (@eqke elt) (@eqk elt).
Hint Resolve InA_eqke_eqk : core.
Definition MapsTo {elt} (k:key)(e:elt):= InA eqke (k,e).
Definition In {elt} k m := exists e:elt, MapsTo k e m.
Hint Unfold MapsTo In : core.
(* Alternative formulations for [In k l] *)
Instance MapsTo_compat {elt} :
Proper (D.eq==>Logic.eq==>equivlistA eqke==>iff) (@MapsTo elt).
Instance In_compat {elt} : Proper (D.eq==>equivlistA eqk==>iff) (@In elt).

Lemma In_inv_2 {elt} k k' e e' (l:list (key*elt)) :
InA eqk (k, e) ((k', e') :: l) -> ~ D.eq k k' -> InA eqk (k, e) l.