Definition sumF {X} `{Finite X} (f : X -> nat) : nat :=
  list_sum (map f enum).Definition sumFQ {X} `{Finite X} (f : X -> Q) : Q :=
  Qsum(map f enum).

(* Specifications: *)
Lemma sumFQ_ext {X} `{Finite X} (f g : X -> Q) : (forall x, f x == g x) -> sumFQ f == sumFQ g.
Lemma sumFQ_scalar {X} `{Finite X} (f : X -> Q) (c : Q) : sumFQ (fun x => c * f x) == c * sumFQ f.
Lemma count_sumF_lst {X} (l : list X) (p : X -> bool): length (filter p l) = list_sum (map (fun x : X => indicate_nat (p x)) l).
Lemma map_const_repeat {X Y} (y : Y) (l : list X) : map (fun _ => y) l = repeat y (length l).
Lemma list_sum_repeat (x n : nat) : list_sum (repeat x n) = (x * n)%nat.
Lemma count_sumF {X} `{Finite X} (p : X -> bool) : count p = sumF (fun x => indicate_nat (p x)).
Lemma Q_of_nat_plus (x y : nat) : Q_of_nat (x + y)%nat = Q_of_nat x + Q_of_nat y.
Lemma sumF_sumFQ {X} `{Finite X} (E : X -> bool) : sumFQ (fun x => indicate (E x)) == Q_of_nat (sumF (fun x => indicate_nat (E x))).
Lemma eval_monad_map {X Y} (m : dist X) (E : Y -> bool) (f : X -> Y) : eval_dist (monad_map f m) E == eval_dist m (fun x => E (f x)).
Lemma sumFQ_ext {X} `{Finite X} (f g : X -> Q) : (forall x, f x == g x) -> sumFQ f == sumFQ g.
Lemma sumFQ_scalar {X} `{Finite X} (f : X -> Q) (c : Q) : sumFQ (fun x => c * f x) == c * sumFQ f.
Lemma count_sumF_lst {X} (l : list X) (p : X -> bool): length (filter p l) = list_sum (map (fun x : X => indicate_nat (p x)) l).
Lemma map_const_repeat {X Y} (y : Y) (l : list X) : map (fun _ => y) l = repeat y (length l).
Lemma list_sum_repeat (x n : nat) : list_sum (repeat x n) = (x * n)%nat.
Lemma count_sumF {X} `{Finite X} (p : X -> bool) : count p = sumF (fun x => indicate_nat (p x)).
Lemma Q_of_nat_plus (x y : nat) : Q_of_nat (x + y)%nat = Q_of_nat x + Q_of_nat y.
Lemma sumF_sumFQ {X} `{Finite X} (E : X -> bool) : sumFQ (fun x => indicate (E x)) == Q_of_nat (sumF (fun x => indicate_nat (E x))).
Lemma eval_monad_map {X Y} (m : dist X) (E : Y -> bool) (f : X -> Y) : eval_dist (monad_map f m) E == eval_dist m (fun x => E (f x)).