intros.
induction n.
intro j.
generalize (le_or_lt (pred (0 + m)) j).
intro p; inversion_clear p.
right; split; auto.
left.
exists H0.
exists (lt_comp H0 (sym_eq H)).
simpl in Hi', H, H0.
simpl in |- *.
apply Ap_comp; auto with algebra.
intro j.
generalize (le_or_lt (pred (S n + m)) j).
intro p; inversion_clear p.
right; split; auto.
rewrite H.
auto.
left.
exists H0.
exists (lt_comp H0 (sym_eq H)).
apply Trans with (omit (hdtl v ++ w) (Build_finiteT Hi') (Build_finiteT H0));
auto with algebra.
apply
Trans
with
((hdtl v ++ omit w (Build_finiteT Hi))
(Build_finiteT (lt_comp H0 (sym_eq H)))); auto with algebra.
unfold hdtl in |- *.
apply
Trans
with (omit (head v;; Seqtl v ++ w) (Build_finiteT Hi') (Build_finiteT H0));
auto with algebra.
apply
Trans
with
((head v;; Seqtl v ++ omit w (Build_finiteT Hi))
(Build_finiteT (lt_comp H0 (sym_eq H)))).
2: apply Ap_comp; auto with algebra.
2: apply toSeq; auto with algebra.
2: apply (cons_concat_special (head v) (Seqtl v) (omit w (Build_finiteT Hi))).
assert (n + m = S (pred (n + m))).
clear H0 j IHn w v A.
transitivity (S n + pred m); auto with arith.
transitivity (pred (S n + m)); auto with arith.
simpl in |- *.
apply S_pred with (n + i).
auto with arith.
apply
Trans
with
(cast_seq (head v;; omit (Seqtl v ++ w) (Build_finiteT (lt_S_n _ _ Hi')))
(sym_eq H1) (Build_finiteT H0)); fold (n + i) (n + m) in |- *.
apply Ap_comp; auto with algebra.
apply toSeq.
apply
Trans
with
(cast_seq
(head (head v;; Seqtl v ++ w);;
omit (Seqtl (head v;; Seqtl v ++ w))
(Build_finiteT (lt_S_n (n + i) (n + m) Hi')))
(sym_eq H1)).
apply (omit_tlelt' (head v;; Seqtl v ++ w) Hi' (lt_S_n _ _ Hi') (sym_eq H1));
auto with algebra.
apply cast_seq_comp; auto with algebra.
apply cons_comp; auto with algebra.
apply omit_comp; auto with algebra.
apply (Seqtl_cons_inv (head v) (Seqtl v ++ w)).
apply seq_equal_equal_elements; auto with algebra.
apply
seq_equal_trans
with
(w := head v;;
omit (Seqtl v ++ w) (Build_finiteT (lt_S_n (n + i) (n + m) Hi'))).
apply seq_equal_symm.
apply cast_seq_preserves_seq_equal.
apply seq_equal_cons; auto with algebra.
generalize (IHn (Seqtl v) (lt_S_n (n + i) (n + m) Hi')).
clear IHn; intro.
apply H2.
clear H2.
simpl in H.
transitivity (pred (S (n + pred m))); auto with arith.
Qed.

(* Specifications: *)
Lemma omit_concat_second_part :
forall (n m : Nat) (A : Setoid) (v : seq n A) (w : seq m A)
(i : Nat) (Hi : i < m) (Hi' : n + i < n + m)
(H : n + pred m = pred (n + m)),
omit (v ++ w) (Build_finiteT Hi') ='
cast_seq (v ++ omit w (Build_finiteT Hi)) H in _.