Section map_fold_index.
Variables A B:Type.
Variable f:positive -> A -> B.
Variable c:B -> B -> B.
Variable u:B.
Hypothesis Hassoc : forall x y z:B,
c x (c y z) = c (c x y) z.
Hypothesis Hunit_left : forall x, c u x = x.
intro m; induction m; simpl; intros.
rewrite Hunit_left; auto.
destruct o; simpl.
symmetry.
rewrite IHm1.
rewrite <- Hassoc.
rewrite <- Hassoc.
symmetry.
rewrite IHm1.
rewrite IHm2.
auto.
symmetry.
rewrite IHm1.
rewrite <- Hassoc.
symmetry.
rewrite IHm1.
rewrite IHm2.
auto.
Qed.

Lemma map_fold_index_lookup' : forall
(m:map A) (g:positive -> positive) (z:B) v x,
m#v = Some x -> exists l, exists r,
map_fold_index' A B f c z g m =
c l (c (f (g v) x) r).