Section Mapi.
Variable f : key -> A -> B.
Fixpoint xmapi (m : t A) (i : key) : t B :=
match m with
| Leaf => @Leaf B
| Node l o r => Node (xmapi l (append i (xO xH)))
(option_map (f i) o)
(xmapi r (append i (xI xH)))
end.
Definition mapi m := xmapi m xH.
End Mapi.
Definition map (f : A -> B) m := mapi (fun _ => f) m.
End A.

Lemma map_1 : forall (elt elt':Type)(m: t elt)(x:key)(e:elt)(f:elt->elt'),
MapsTo x e m -> MapsTo x (f e) (map f m).