Definition map_fmap (A B:Type) (f:A->B) : map A -> map B :=
  fix map_fmap (m:map A) : map B :=
  match m with
  | Leaf => Leaf _
  | Node m1 o m2 =>
       let x := match o with
                | None => None
                | Some x => Some (f x)
                end in
       Node _ (map_fmap m1) x (map_fmap m2)
  end.

Lemma fmap_update : forall A B (m:map A) (f:A->B) x a, (map_fmap A B f (m#x <- a)) = (map_fmap A B f m)#x <- (f a).