End AbelianGroup1.
(** Sum *)
Section Sums.
Context {G : AbelianGroup}.
Definition sum_n_m (a : nat -> G) n m :=
iter_nat plus zero a n m.
Definition sum_n (a : nat -> G) n :=
sum_n_m a O n.

(* Specifications: *)
Lemma sum_n_m_Chasles (a : nat -> G) (n m k : nat) :
(n <= S m)%nat -> (m <= k)%nat
-> sum_n_m a n k = plus (sum_n_m a n m) (sum_n_m a (S m) k).
Lemma sum_n_n (a : nat -> G) (n : nat) :
sum_n_m a n n = a n.
Lemma sum_O (a : nat -> G) : sum_n a 0 = a O.
Lemma sum_n_Sm (a : nat -> G) (n m : nat) :
(n <= S m)%nat -> sum_n_m a n (S m) = plus (sum_n_m a n m) (a (S m)).
Lemma sum_Sn_m (a : nat -> G) (n m : nat) :
(n <= m)%nat -> sum_n_m a n m = plus (a n) (sum_n_m a (S n) m).
Lemma sum_n_m_S (a : nat -> G) (n m : nat) :
sum_n_m (fun n => a (S n)) n m = sum_n_m a (S n) (S m).
Lemma sum_Sn (a : nat -> G) (n : nat) :
sum_n a (S n) = plus (sum_n a n) (a (S n)).
Lemma sum_n_m_zero (a : nat -> G) (n m : nat) :
(m < n)%nat -> sum_n_m a n m = zero.
Lemma sum_n_m_const_zero (n m : nat) :
sum_n_m (fun _ => zero) n m = zero.
Lemma sum_n_m_ext_loc (a b : nat -> G) (n m : nat) :
(forall k, (n <= k <= m)%nat -> a k = b k) ->
sum_n_m a n m = sum_n_m b n m.
Lemma sum_n_m_ext (a b : nat -> G) n m :
(forall n, a n = b n) ->
sum_n_m a n m = sum_n_m b n m.
Lemma sum_n_ext_loc :
forall (a b : nat -> G) N,
(forall n, (n <= N)%nat -> a n = b n) ->
sum_n a N = sum_n b N.
Lemma sum_n_ext :
forall (a b : nat -> G) N,
(forall n, a n = b n) ->
sum_n a N = sum_n b N.
Lemma sum_n_m_plus :
forall (u v : nat -> G) (n m : nat),
sum_n_m (fun k => plus (u k) (v k)) n m = plus (sum_n_m u n m) (sum_n_m v n m).
Lemma sum_n_plus :
forall (u v : nat -> G) (n : nat),
sum_n (fun k => plus (u k) (v k)) n = plus (sum_n u n) (sum_n v n).
Lemma sum_n_switch :
forall (u : nat -> nat -> G) (m n : nat),
sum_n (fun i => sum_n (u i) n) m = sum_n (fun j => sum_n (fun i => u i j) m) n.
Lemma sum_n_m_sum_n (a:nat -> G) (n m : nat) :
(n <= m)%nat -> sum_n_m a (S n) m = minus (sum_n a m) (sum_n a n).