Section Iter.
Context {I T : Type}.
Context (op : T -> T -> T).
Context (x0 : T).
Context (neutral_l : forall x, op x0 x = x).
Context (neutral_r : forall x, op x x0 = x).
Context (assoc : forall x y z, op x (op y z) = op (op x y) z).
Fixpoint iter (l : list I) (f : I -> T) :=
match l with
| nil => x0
| cons h l' => op (f h) (iter l' f)
end.
Definition iter' (l : list I) (f : I -> T) :=
fold_right (fun i acc => op (f i) acc) x0 l.
End Iter.

Lemma iter_const {I} (l : list I) (a : R) :
iter Rplus 0 l (fun _ => a) = INR (length l) * a.