Section MAIN.
intros.
rewrite <- H0.
auto.
Qed.
(** %\label{castfin}% *)
Definition cast_fin : forall n n' : Nat, fin n -> n =' n' in _ -> fin n'.
intros.
destruct X.
exact (Build_finiteT (lt_comp in_range_prf H)).
Defined.
intros until H'.
unfold cast_fin in |- *.
case i; case i'.
simpl in |- *.
auto.
Qed.
Hint Resolve cast_fin_comp: algebra.
Variable A : Setoid.
Definition cast_seq : forall n n' : Nat, seq n A -> n =' n' in _ -> seq n' A.
intros.
destruct X.
set (Ap' := fun i : fin n' => Ap (cast_fin i (sym_eq H))) in *.
assert (Mcp' : fun_compatible Ap').
red in |- *; red in Map_compatible_prf.
unfold Ap' in |- *.
intros.
apply Map_compatible_prf; auto with algebra.
exact (Build_Map Mcp').
Defined.
unfold cast_seq in |- *.
intros until H'.
case v; case v'.
simpl in |- *.
red in |- *.
simpl in |- *.
intros.
red in H0.
simpl in H0.
apply Trans with (Ap0 (cast_fin x (sym_eq H'))); auto with algebra.
Qed.
Hint Resolve cast_seq_comp: algebra.
Variable n n' : Nat.
Variable v : seq n A.
intros.
unfold cast_seq, cast_fin in |- *.
destruct v.
simpl in |- *.
destruct i.
apply Map_compatible_prf; auto with algebra.
Qed.

Lemma cast_seq_cast_fin' :
forall (i : fin n') (H : n =' n' in _) (H' : n' =' n in _),
cast_seq v H i =' v (cast_fin i H') in _.