(****************************************************************************** Finite orbit-stabilizer theorem.  Based on proof from Rahbar Virk's notes from the University of Wisconsin (www.math.wisc.edu/~virk/notes/pdf/orphans/orbit-stabilizer_thm.pdf) Copyright 2008 Robert Kam  This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.  You should have received a copy of the GNU Lesser General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>. ******************************************************************************)
From Algebra Require Export Group_util.
From Algebra Require Export Fpart2.
From Algebra Require Export Parts3.
From Algebra Require Export Fmap.
From LinAlg Require Export seq_set_facts.
From LinAlg Require Export has_n_elements.
From LinAlg Require Export finite_subsets.
Require Export ClassicalDescription.
Fixpoint nsum (n:Nat) {struct n} : seq n Nat -> Nat :=
match n return (seq n Nat -> Nat) with
|O => fun x:seq 0 Nat => 0
|S m => fun x:seq (S m) Nat => (head x) + (nsum m (Seqtl x)) end.
induction n. intros. simpl. auto.
intros. unfold nsum. fold nsum.
assert (HEADHEAD:head f = head f'). unfold head. apply H.
rewrite HEADHEAD.
assert (TLTL:nsum n (Seqtl f) =' nsum n (Seqtl f')). apply IHn.
change (Seqtl f =' Seqtl f' in _). apply Seqtl_comp. exact H.
rewrite TLTL. apply Refl. Qed.
intros. rewrite H. apply Refl. Qed.

Lemma nsum_increment4:
forall (n:Nat) (v:seq n Nat) (i:fin n) (a:Nat) (H:a =' (v i) + 1),
nsum n (modify_seq v i a) =' nsum n v + 1.