(* Rsum *)

Definition Rsum: list R -> R := fold_right Rplus 0.

(* Specifications: *)
Lemma Rsum_sum_map (T: Set) (fi: T -> nat) (fr: T -> R) (l: list T): (forall x, In x l -> fr x = INR (fi x)) -> Rsum (map fr l) = INR (sum (map fi l)).
Lemma Rsum_app (x y: list R): Rsum (x ++ y) = Rsum x + Rsum y.
Lemma Rsum_constant r l: (forall x, In x l -> x = r) -> Rsum l = INR (length l) * r.
Lemma Rsum_le l r: (forall x, In x l -> x <= r) -> Rsum l <= INR (length l) * r.
Lemma le_Rsum l r: (forall x, In x l -> r <= x) -> INR (length l) * r <= Rsum l.
Lemma Rsum_map_plus X f g (l: list X): Rsum (map (fun x => f x + g x) l) = Rsum (map f l) + Rsum (map g l).
Lemma Rsum_map_app_map X Y f g (h: X -> Y) (l: list X): Rsum (map f (map g l ++ map h l)) = Rsum (map (fun x => f (g x) + f (h x)) l).
Lemma Rsum_map_le X f g (l: list X): (forall x, In x l -> f x <= g x) -> Rsum (map f l) <= Rsum (map g l).
Lemma Rsum_map_mult c l: Rsum (map (Rmult c) l) = c * Rsum l.
Lemma Rsum_concat l: Rsum (concat l) = Rsum (map Rsum l).
Lemma Rsum_nonneg l: (forall x, In x l -> 0 <= x) -> 0 <= Rsum l.
Lemma Rsum_single x: Rsum (x :: nil) = x.