Fixpoint getNats s n :=
  match n with 
    | O => nil
    | S n' => (s + n')%nat :: (getNats s n')
  end.

(* Specifications: *)
Lemma series_le : forall n (f1 f2 : nat -> Rat -> Prop) r1 r2, (forall i v1 v2, f1 i v1 -> f2 i v2 -> v2 <= v1) -> sumList_rel f1 (getNats O n) r1 -> sumList_rel f2 (getNats O n) r2 -> r2 <= r1.
Lemma sumList_rel_le : forall (A : Set)(ls : list A)(f1 f2 : A -> Rat -> Prop) r1 r2, sumList_rel f1 ls r1 -> sumList_rel f2 ls r2 -> (forall a v1 v2, In a ls -> f1 a v1 -> f2 a v2 -> v1 <= v2) -> r1 <= r2.
Lemma sumList_filter_le : forall (A : Set)(ls : list A)(f : A -> Rat)(P : A -> bool), sumList (filter P ls) f <= sumList ls f.
Lemma firstn_nil : forall (A : Set) n, firstn n nil = (@nil A).
Lemma firstn_ge_all : forall n (A : Set) (ls : list A), n >= length ls -> firstn n ls = ls.
Lemma firstn_app : forall n (A : Set) (ls1 ls2 : list A), (n <= length ls1)%nat -> firstn n (ls1 ++ ls2) = firstn n ls1.
Lemma sumList_le : forall (A : Set)(ls : list A)(f1 f2 : A -> Rat), (forall a, In a ls -> f1 a <= f2 a) -> sumList ls f1 <= sumList ls f2.
Theorem filter_app : forall (A : Set)(ls1 ls2 : list A)(f : A -> bool), filter f (ls1 ++ ls2) = filter f ls1 ++ filter f ls2.
Theorem filter_true : forall (A : Set)(ls : list A)(f : A -> bool), (forall a, In a ls -> (f a) = true) -> filter f ls = ls.
Theorem sumList_subset_le : forall (A : Set){eqd: EqDec A}(ls1 ls2 : list A)(f : A -> Rat), NoDup ls1 -> NoDup ls2 -> (forall a, In a ls1 -> In a ls2) -> sumList ls1 f <= sumList ls2 f.