Definition Subset (s s': t) := Subset' (proj1_sig s) (proj1_sig s').
Definition Empty (s: t) := Empty' (proj1_sig s).
Definition For_all (P : elt -> Prop) (s: t) := For_all' P (proj1_sig s).
Definition Exists (P : elt -> Prop) (s: t) := Exists' P  (proj1_sig s).
Definition eq : t -> t -> Prop := Equal.

(* Specifications: *)
Lemma eq_equiv: Equivalence eq.
Lemma mem_spec : forall s x, mem x s = true <-> In x s.
Lemma empty_spec : Empty empty.
Lemma is_empty_spec : forall s, is_empty s = true <-> Empty s.
Lemma add_spec : forall s x y, In y (add x s) <-> E.eq y x \/ In y s.
Definition mem_add (x: elt) (s: t) : option t :=
match mem_add' x (proj1_sig s) as b return (b = mem_add' x (proj1_sig s) -> option t)with
| None => fun _ => None
| Some s' => fun p => Some (exist valid s' (mem_add_valid x _ (proj2_sig s) s' p))
end (Logic.eq_refl _).
Lemma mem_add_spec:
forall (x: elt) (s: t), mem_add x s = if mem x s then None else Some (add x s).
Lemma remove_spec : forall s x y,
In y (remove x s) <-> In y s /\ ~E.eq y x.
Lemma singleton_spec : forall x y, In y (singleton x) <-> E.eq y x.
Lemma fold_spec : forall s (A : Type) (i : A) (f : elt -> A -> A),
fold _ f s i = List.fold_left (fun a e => f e a) (elements s) i.
Lemma elements_spec1 : forall s x,
SetoidList.InA E.eq x (elements s) <-> In x s.
Lemma add_commute:
forall x i j s, In x (add i (add j s)) <-> In x (add j (add i s)).
Lemma union_spec : forall s s' x, In x (union s s') <-> In x s \/ In x s'.
Lemma filter_spec : forall s x f,
compatb f ->
(In x (filter f s) <-> In x s /\ f x = true).
Lemma inter_spec : forall s s' x, In x (inter s s') <-> In x s /\ In x s'.
Lemma remove_commute:
forall x i j s, In x (remove i (remove j s)) <-> In x (remove j (remove i s)).
Lemma diff_spec : forall s s' x, In x (diff s s') <-> In x s /\ ~In x s'.
Lemma In_dec: forall x s, {In x s}+{~In x s}.
Lemma subset_spec : forall s s', subset s s' = true <-> Subset s s'.
Lemma equal'_spec : forall s s', valid s -> valid s' ->
(equal' s s' = true <-> Equal' s s').
Lemma equal_spec : forall s s', equal s s' = true <-> Equal s s'.
Lemma eq_dec : forall (s s':t), { eq s s' }+{ ~eq s s' }.
Lemma cardinal_spec : forall s, cardinal s = length (elements s).
Lemma for_all_spec : forall s f,
compatb f ->
(for_all f s = true <-> For_all (fun x => f x = true) s).
Lemma exists_spec : forall s f,
compatb f ->
(exists_ f s = true <-> Exists (fun x => f x = true) s).
Lemma partition_aux_filter:
forall f s n1 l1 n2 l2, partition_aux f s  (n1,l1) (n2,l2) =
(filter_aux f s n1 l1, filter_aux (compose negb f) s n2 l2).
Lemma partition_spec1 : forall s f,
compatb f -> Equal (fst (partition f s)) (filter f s).
Lemma partition_spec2 : forall s f,
compatb f ->
Equal (snd (partition f s)) (filter (fun x => negb (f x)) s).
Lemma choose_spec1 : forall s x, choose s = Some x -> In x s.
Lemma choose_spec2 : forall s, choose s = None -> Empty s.
Definition compare (s s':  t) : comparison :=
compare' (proj1_sig s) (proj1_sig s').