Set Implicit Arguments.
Plus List Permutation Arith Relations RelationClasses Morphisms
arith_lems util list_utils nat_seqs Omega.
(* sum *)
Fixpoint sum (l: list nat): nat :=
match l with
| nil => 0
| h :: t => h + sum t
end.
Open Scope R_scope.
(* Rsum *)
Definition Rsum: list R -> R := fold_right Rplus 0.
Proof with auto.
induction l...
simpl.
intros.
rewrite plus_INR.
rewrite H...
rewrite IHl...
Qed.
Instance Rsum_Permutation: Proper (Permutation ==> eq) Rsum.
Proof with auto.
intros x y p.
induction p...
simpl.
rewrite IHp...
simpl.
do 2 rewrite <- Rplus_assoc.
rewrite (Rplus_comm y)...
rewrite IHp1...
Qed.
Proof with auto with real.
induction x...
simpl.
intros.
rewrite IHx...
Qed.
Proof with auto.
induction l; intros.
simpl.
field.
simpl Rsum.
simpl @length.
rewrite IHl.
rewrite (H a).
rewrite S_INR.
field.
left...
intros.
apply H.
right...
Qed.

Lemma Rsum_le l r: (forall x, In x l -> x <= r) -> Rsum l <= INR (length l) * r.