Local Open Scope positive_scope.
(* union of maps (left-heavy) *)
Definition Munion {A} (f g : M.t A) := M.fold (fun k v => M.add k v) f g.
(* Two maps are disjoint if their keys have no intersection. *)
(* Mkeys is just Mdomain *)
Definition Mdisjoint {A} (f g : M.t A) := S.Equal (S.inter (Mdomain f) (Mdomain g)) S.empty.
(* Test case for disjointness *)
Example Mdisjoint_test1 :
Mdisjoint (fold_right (fun p m => M.add (fst p) (snd p) m) (@M.empty _) [(1,1);(2,2)])
(fold_right (fun p m => M.add (fst p) (snd p) m) (@M.empty _) [(3,1);(4,2)]).

Lemma Munion_in {A} : forall i (m1 m2 : M.t A),
M.In i (Munion m1 m2) <-> M.In i m1 \/ M.In i m2.