Definition f_OK (A B : Set) (f : ad -> A -> Map B) :=
  forall (a a1 a2 : ad) (y1 y2 : A),
  in_dom _ a (f a1 y1) = true -> in_dom _ a (f a2 y2) = true -> a1 = a2.Definition no_dup_alist (A : Set) (l : alist A) :=
  forall (a : ad) (y1 y2 : A), In (a, y1) l -> In (a, y2) l -> y1 = y2.

(* Specifications: *)
Lemma no_dup_alist_of_Map : forall (A : Set) (m : Map A), no_dup_alist _ (alist_of_Map _ m).
Lemma my_fold_right_lemma : forall (A B : Set) (f : ad -> A -> Map B) (l : alist A), f_OK _ _ f -> no_dup_alist _ l -> forall (a : ad) (y : B), MapGet _ (fold_right (fun (r : ad * A) (m0 : Map B) => let (a0, y0) := r in MapMerge B (f a0 y0) m0) (M0 B) l) a = Some y <-> (exists a1 : ad, (exists y1 : A, In (a1, y1) l /\ MapGet _ (f a1 y1) a = Some y)).
Lemma myMapFold_lemma : forall (A B : Set) (f : ad -> A -> Map B) (m : Map A), f_OK _ _ f -> forall (a : ad) (y : B), MapGet _ (MapFold _ _ (M0 _) (MapMerge _) f m) a = Some y <-> (exists a1 : ad, (exists y1 : A, MapGet _ m a1 = Some y1 /\ MapGet _ (f a1 y1) a = Some y)).