Definition tsplit (t1 t2 : tuple) :=
Eval lazy beta delta [tsplit3] in
  let (i1,i2,i3) := t1 in
  let (j1,j2,j3) := t2 in
  match tvcompare i1 j1 with
  | Gt => (* tsplit3 j1 j2 j3 i1 i2 i3 *) SProd S1 t2 t1 :: nil 
  | _  => tsplit3 i1 i2 i3 j1 j2 j3
  end.(* Lexicographic comparison *)
Fixpoint list_compare (T : Type) (cmp : T -> T -> comparison) 
                                 (l1 l2 : list T) :=
match l1, l2 with
|   nil,   nil => Eq
|   nil,   _   => Lt
|     _,   nil => Gt
| a::l1, b::l2 => match cmp a b with
                  |  Eq => list_compare T cmp l1 l2
                  | res => res
                  end
end.

Lemma list_compare_eq T cmp l1 l2 : (forall c1 c2, match cmp c1 c2 with Eq => c1 = c2 | _ => True end) -> match list_compare T cmp l1 l2 with Eq => l1 = l2 | _ => True end.