Module L := MSetInterface.MakeListOrdering X.
Definition eq := Equal.
Instance eq_equiv : Equivalence eq.
Definition lt (s1 s2 : tree) : Prop :=
exists s1' s2', Ok s1' /\ Ok s2' /\ eq s1 s1' /\ eq s2 s2'
/\ L.lt (elements s1') (elements s2').
Declare Equivalent Keys L.eq equivlistA.
Instance lt_strorder : StrictOrder lt.
Instance lt_compat : Proper (eq==>eq==>iff) lt.
(** Proof of the comparison algorithm *)
(** [flatten_e e] returns the list of elements of [e] i.e. the list of elements actually compared *)
Fixpoint flatten_e (e : enumeration) : list elt := match e with
| End => nil
| More x t r => x :: elements t ++ flatten_e r
end.

Lemma cons_1 : forall s e,
flatten_e (cons s e) = elements s ++ flatten_e e.