(* 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 2.1   *)
(* 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 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, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)
(** %\subsection*{ support :  modify\_seq.v }%*)
(** - if $v=\langle v_0...v_i...v_{n-1}\rangle$ then (modify v i a) = $\langle v_0...a...v_{n-1}\rangle$ *)
Set Implicit Arguments.
Unset Strict Implicit.
Require Export conshdtl.
(** %\label{modifyseq}% *)
Definition modify_seq :
forall (A : Setoid) (n : Nat), seq n A -> fin n -> A -> seq n A.
induction n.
intros.
auto.
intros.
destruct X0.
destruct index as [| n0].
exact (X1;; Seqtl X).
exact (head X;; IHn (Seqtl X) (Build_finiteT (lt_S_n _ _ in_range_prf)) X1).
Defined.
induction n.
intros.
apply False_ind; auto with algebra.
intros.
destruct i.
destruct i'.
destruct index as [| n0].
destruct index0 as [| n0].
apply split_hd_tl_equality; auto with algebra.
intro.
destruct x.
simpl in |- *.
apply Ap_comp; auto with algebra.
inversion H1.
destruct index0 as [| n1].
inversion H1.
unfold modify_seq in |- *.
unfold nat_rect in |- *.
apply cons_comp; auto with algebra.
unfold modify_seq in IHn.
apply IHn; auto with algebra.
change (Seqtl v =' Seqtl v' in _) in |- *.
apply Seqtl_comp; auto with algebra.
Qed.
Hint Resolve modify_comp: algebra.
intros.
simpl in |- *.
auto with algebra.
Qed.
Hint Resolve modify_hd_hd: algebra.
intros.
unfold modify_seq, nat_rect in |- *.
auto with algebra.
Qed.
Hint Resolve modify_hd_tl: algebra.
intros.
simpl in |- *; auto with algebra.
Qed.
Hint Resolve modify_tl_hd: algebra.
intros; intro.
unfold Seqtl in |- *.
simpl in |- *.
case x.
intros.
apply Ap_comp; auto with algebra.
Qed.
Hint Resolve modify_tl_tl: algebra.
intros; intro.
simpl in |- *.
auto with algebra.
Qed.
Hint Resolve Seqtl_modify_seq.

Lemma modify_seq_defprop :
forall (A : Setoid) (n : Nat) (v : seq n A) (i : fin n) (a : A),
modify_seq v i a i =' a in _.