intros.
red in H, H0.
red in |- *; intro.
generalize (H i) (H0 i); clear H H0; intros.
inversion_clear H; inversion_clear H0.
left.
inversion_clear H1; inversion_clear H.
exists x.
inversion_clear H0; inversion_clear H1.
exists x2.
apply Trans with (w (Build_finiteT x1)); auto with algebra.
apply Trans with (w (Build_finiteT x0)); auto with algebra.
inversion_clear H1; inversion_clear H.
inversion_clear H0.
apply False_ind; auto with algebra.
generalize (lt_not_le i m); intro p; red in p.
auto.
inversion_clear H1; inversion_clear H.
apply False_ind; auto with algebra.
generalize (lt_not_le i m); intro p; red in p.
auto.
right.
inversion_clear H; inversion_clear H1; split; auto.
Qed.
Hint Resolve seq_equal_trans: algebra.

(* Finally, the interplay with casting functions: *)
Lemma cast_seq_preserves_seq_equal :
forall (A : Setoid) (n m : Nat) (v : seq n A) (H : n =' m in _),
seq_equal v (cast_seq v H).