Section MAIN.
Variable A : Setoid.
Variable n m : Nat.
Variable v : seq n A.
Variable w : seq m A.
(** - More facts about concatenation *)
induction n.
intros.
inversion Hi.
intro.
case i.
unfold concat in |- *.
unfold nat_rect in |- *.
simpl in |- *.
intros.
apply Ap_comp; auto with algebra.
intros.
apply Trans with (hdtl v (Build_finiteT Hi)).
apply Trans with ((hdtl v ++ w) (Build_finiteT Hi')).
apply concat_comp; auto with algebra.
2: apply Ap_comp; auto with algebra.
unfold hdtl in |- *.
apply Trans with ((head v;; Seqtl v ++ w) (Build_finiteT Hi'));
auto with algebra.
apply Trans with (Seqtl v (Build_finiteT (lt_S_n _ _ Hi))); auto with algebra.
apply Trans with ((Seqtl v ++ w) (Build_finiteT (lt_S_n _ _ Hi')));
auto with algebra.
Qed.
Hint Resolve concat_first_part: algebra.
induction n.
intros.
unfold concat in |- *.
unfold nat_rect in |- *.
apply Ap_comp; auto with algebra.
intros.
apply Trans with ((hdtl v ++ w) (Build_finiteT Hi')); auto with algebra.
unfold hdtl in |- *.
apply Trans with ((head v;; Seqtl v ++ w) (Build_finiteT Hi'));
auto with algebra.
cut (S (c + i) < S (c + m)).
intro.
apply Trans with ((Seqtl v ++ w) (Build_finiteT (lt_S_n _ _ H)));
auto with algebra.
apply Trans with ((head v;; Seqtl v ++ w) (Build_finiteT H));
auto with algebra.
replace (S (c + i)) with (S c + i).
assumption.
auto.
Qed.
Hint Resolve concat_second_part: algebra.
induction n.
intros.
unfold concat in |- *; unfold nat_rect in |- *.
apply H0.
intros.
generalize Hk; clear Hk; case k; [ intro Hk | intros k0 Hk0 ].
generalize (lt_O_Sn c); intro Hk'.
apply (Pred_compatible_prf (p:=P)) with (v (Build_finiteT Hk'));
auto with algebra.
simpl in |- *.
apply Ap_comp; auto with algebra.
generalize (lt_S_n _ _ Hk0); intro Hk0'.
fold (c + m) in Hk0'.
apply (Pred_compatible_prf (p:=P)) with ((Seqtl v ++ w) (Build_finiteT Hk0')).
apply IHc; auto with algebra.
clear Hk0' Hk0 k0 k.
intros.
apply (Pred_compatible_prf (p:=P)) with (v (Build_finiteT (lt_n_S _ _ Hi)));
auto with algebra.
apply Trans with (Seqtl (v ++ w) (Build_finiteT Hk0')).
apply Sym.
generalize Seqtl_to_seq.
intros.
apply (H1 _ _ (v ++ w) _ Hk0' Hk0).
generalize Seqtl_concat.
intro p.
apply Ap_comp; auto with algebra.
Qed.
intros.
apply concat_prop_per_part.
intros.
generalize (H i Hi); intro.
apply
(Pred_compatible_prf (p:=P))
with ((v ++ w) (Build_finiteT (lt_plus_trans _ _ m Hi))).
apply H1.
apply Sym.
apply concat_first_part.
intros.
cut (n + j < n + m).
intro Hj'.
apply (Pred_compatible_prf (p:=P)) with ((v ++ w) (Build_finiteT Hj'));
auto with algebra.
auto with arith.
Qed.

Lemma split_to_concat :
forall vw : seq (n + m) A, sigT (fun a => sigT (fun b => vw =' a ++ b in _)).