(************************************************************************)
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
(*   \VV/  **************************************************************)
(*    //   *      This file is distributed under the terms of the       *)
(*         *       GNU Lesser General Public License Version 2.1        *)
(************************************************************************)
(*i   	  $Id$      i*)
Section MapFoldResults.
Variable A : Type.
Variable M : Type.
Variable neutral : M.
Variable op : M -> M -> M.
Variable nleft : forall a:M, op neutral a = a.
Variable nright : forall a:M, op a neutral = a.
Variable assoc : forall a b c:M, op (op a b) c = op a (op b c).

(* Specifications: *)
Lemma MapFold_ext :
forall (f:ad -> A -> M) (m m':Map A),
eqmap A m m' -> MapFold _ _ neutral op f m = MapFold _ _ neutral op f m'.
Lemma MapFold_ext_f_1 :
forall (m:Map A) (f g:ad -> A -> M) (pf:ad -> ad),
(forall (a:ad) (y:A), MapGet _ m a = Some y -> f (pf a) y = g (pf a) y) ->
MapFold1 _ _ neutral op f pf m = MapFold1 _ _ neutral op g pf m.
Lemma MapFold_ext_f :
forall (f g:ad -> A -> M) (m:Map A),
(forall (a:ad) (y:A), MapGet _ m a = Some y -> f a y = g a y) ->
MapFold _ _ neutral op f m = MapFold _ _ neutral op g m.
Lemma MapFold1_as_Fold_1 :
forall (m:Map A) (f f':ad -> A -> M) (pf pf':ad -> ad),
(forall (a:ad) (y:A), f (pf a) y = f' (pf' a) y) ->
MapFold1 _ _ neutral op f pf m = MapFold1 _ _ neutral op f' pf' m.
Lemma MapFold1_as_Fold :
forall (f:ad -> A -> M) (pf:ad -> ad) (m:Map A),
MapFold1 _ _ neutral op f pf m =
MapFold _ _ neutral op (fun (a:ad) (y:A) => f (pf a) y) m.
Lemma MapFold1_ext :
forall (f:ad -> A -> M) (m m':Map A),
eqmap A m m' ->
forall pf:ad -> ad,
MapFold1 _ _ neutral op f pf m = MapFold1 _ _ neutral op f pf m'.