Definition eqST (cp1 cp2 : tST) :=
eqList (PosSort.sort (CPToList cp1)) (PosSort.sort (CPToList cp2)).

(* Specifications: *)
Lemma eqListSortOCP : forall (cp : tST), eqList (CPToList (OCP cp)) (PosSort.sort (CPToList cp)).
Fixpoint eqbList (l1 l2 : list positive) :=
match l1, l2 with
| nil         , nil          => true
| (hd1 :: tl1), (hd2 :: tl2) => (Pos.eqb hd1 hd2) && (eqbList tl1 tl2)
| _           , _            => false
end.
Lemma eqbListEqList : forall l1 l2, eqbList l1 l2 = true <-> eqList l1 l2.
Definition eqbST (cp1 cp2 : tST) :=
eqbList (PosSort.sort (CPToList cp1)) (PosSort.sort (CPToList cp2)).
Lemma eqbST_eqST : forall cp1 cp2, eqbST cp1 cp2 = true <-> eqST cp1 cp2.
Lemma lengthAtLeastOne : forall (l : list positive) n,
length l = (S n) -> exists a0 l0, l = a0 :: l0.
Lemma ltListTrans : forall m x y z,
length x = (S m) ->
length y = (S m) ->
length z = (S m) ->
ltList x y -> ltList y z -> ltList x z.
Lemma sortOK : forall m l, length l = m -> length (sort l) = m.
Definition ltST (cp1 cp2 : tST) :=
ltList (PosSort.sort (CPToList cp1)) (PosSort.sort (CPToList cp2)).
Lemma ltTrans : Transitive ltST.
Lemma ltListIrrefl : forall l, ltList l l -> False.
Lemma eqListOK : forall l1 l2, eqList l1 l2 -> l1 = l2.
Fixpoint compareList (l1 l2 : list positive) :=
match l1, l2 with
| nil, nil => Eq
| (hd1 :: tl1), (hd2 :: tl2) => match Pos.compare hd1 hd2 with
| Lt => Lt
| Eq => compareList tl1 tl2
| Gt => Gt
end
| nil, _ => Lt
| _, nil => Gt
end.
Lemma compareListSpec : forall l1 l2,
CompSpec eqList ltList l1 l2 (compareList l1 l2).