(** * Conversions between maps and association lists. *)
Definition of_list :=
List.fold_right (uncurry (@add _)) (empty elt).
Definition to_list := elements.

(* Specifications: *)
Lemma of_list_1 : forall l k e,
NoDupA eqk l ->
(MapsTo k e (of_list l) <-> InA eqke (k,e) l).
Lemma of_list_1b : forall l k,
NoDupA eqk l ->
find k (of_list l) = findA (eqb k) l.
Lemma of_list_2 : forall l, NoDupA eqk l ->
equivlistA eqke l (to_list (of_list l)).
Lemma of_list_3 : forall s, Equal (of_list (to_list s)) s.
(** * Fold *)
(** Alternative specification via [fold_right] *)
Lemma fold_spec_right m (A:Type)(i:A)(f : key -> elt -> A -> A) :
fold f m i = List.fold_right (uncurry f) i (rev (elements m)).