destruct n.
auto with algebra.
induction  n as [| n Hrecn].
intros.
simpl in |- *.
generalize H.
unfold head in |- *.
elim i.
intro x; case x.
intros.
apply Trans with (v (Build_finiteT (lt_O_Sn 0))); auto with algebra.
apply Trans with (v (Build_finiteT in_range_prf)); auto with algebra.
intros.
inversion in_range_prf.
inversion H2.
intros.
generalize H; clear H.
case i.
intro x; case x.
intros.
apply Trans with (sum (hdtl v)); auto with algebra.
unfold hdtl in |- *.
unfold head in |- *.
apply Trans with ((zero M) +' sum (Seqtl v)); auto with algebra.
apply Trans with (v (Build_finiteT (lt_O_Sn (S n))) +' sum (Seqtl v));
auto with algebra.
apply SGROUP_comp; auto with algebra.
apply Trans with (v (Build_finiteT in_range_prf)); auto with algebra.
intros.
apply Trans with (sum (hdtl v)); auto with algebra.
apply
Trans
with
(sum (head v;; omit (Seqtl v) (Build_finiteT (lt_S_n _ _ in_range_prf))));
auto with algebra.
unfold hdtl in |- *.
apply Trans with (head v +' sum (Seqtl v)); auto with algebra.
apply
Trans
with
(head v +' sum (omit (Seqtl v) (Build_finiteT (lt_S_n _ _ in_range_prf))));
auto with algebra.
apply SGROUP_comp; auto with algebra.
apply Hrecn; auto with algebra.
apply Trans with (v (Build_finiteT in_range_prf)); auto with algebra.
generalize Seqtl_to_seq.
intro.
apply (H0 M (S n) v n0 (lt_S_n n0 (S n) in_range_prf) in_range_prf).
Qed.

Lemma sum_modify :
forall (AG : abelian_group) (n : Nat) (v : seq n AG) (i : fin n) (a : AG),
sum (modify_seq v i a) =' sum v +' (min v i) +' a in _.