intros.
generalize (seq_equal_length_equal H).
generalize (seq_equal_length_equal H0).
intros.
red in |- *.
intro.
generalize (le_or_lt (n + p) i).
intro.
case H3.
right.
split; try tauto.
rewrite <- H1.
rewrite <- H2.
tauto.
intro.
left.
exists H4.
assert (i < m + q).
rewrite <- H1.
rewrite <- H2.
tauto.
exists H5.
generalize (le_or_lt n i).
intro.
case H6; clear H6; intro.
2: assert (i < m).
2: rewrite <- H2.
2: auto.
2: apply Trans with (v (Build_finiteT H6)); auto with algebra.
2: apply Trans with (w (Build_finiteT H7)); auto with algebra.
assert (exists k : Nat, i =' n + k in _).
exists (i - n).
simpl in |- *; symmetry  in |- *.
auto with arith.
inversion_clear H7.
assert (n + x < n + p).
rewrite <- H8.
auto.
assert (m + x < m + q).
rewrite <- H2.
rewrite <- H1.
auto.
apply Trans with ((v ++ a) (Build_finiteT H7)); auto with algebra.
apply Trans with ((w ++ b) (Build_finiteT H9)).
2: apply Ap_comp; auto with algebra.
2: simpl in |- *.
2: symmetry  in |- *.
2: rewrite <- H2.
2: auto.
assert (x < p).
apply plus_lt_reg_l with n; auto with algebra.
apply Trans with (a (Build_finiteT H10)); auto with algebra.
assert (x < q).
rewrite <- H1.
auto.
apply Trans with (b (Build_finiteT H11)); auto with algebra.
Qed.
Hint Resolve seq_equal_concat: algebra.

Lemma seq_equal_seq_set :
forall (A : Setoid) (n m : Nat) (v : seq n A) (w : seq m A),
seq_equal v w -> seq_set v =' seq_set w in _.