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.
Proof with auto with real.
induction l...
simpl @length.
intros.
simpl Rsum.
apply Rle_trans with (a + INR (length l) * r).
apply Rplus_le_compat_l.
apply IHl.
intros.
apply H.
right...
apply Rle_trans with (r + INR (length l) * r).
apply Rplus_le_compat_r.
firstorder.
simpl @length.
rewrite S_INR.
rewrite Rmult_plus_distr_r.
rewrite Rmult_1_l...
Qed.

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