Section Elt.
Variable elt:Type.
Implicit Types m r : t elt.
(** * Basic results about [MapsTo], [In], [lt_tree], [gt_tree], [height] *)
(** Facts about [MapsTo] and [In]. *)
Hint Resolve MapsTo_In : core.
Hint Immediate MapsTo_1 : core.
(** Results about [lt_tree] and [gt_tree] *)
Hint Resolve lt_leaf gt_leaf lt_tree_node gt_tree_node : core.
Hint Resolve lt_left lt_right gt_left gt_right : core.
Hint Resolve lt_tree_not_in lt_tree_trans gt_tree_not_in gt_tree_trans : core.
(** * Empty map *)
Definition Empty m := forall (a:key)(e:elt) , ~ MapsTo a e m.
(** * Emptyness test *)
(** * Membership *)
(** * Helper functions *)
Hint Resolve create_bst : core.
Hint Resolve bal_bst : core.
(** * Insertion *)
Hint Resolve add_bst : core.
(** * Extraction of minimum binding *)
Hint Resolve remove_min_bst : core.
Hint Resolve remove_min_gt_tree : core.
(** * Merging two trees *)
(** * Deletion *)
(** * join *)
Hint Resolve join_bst : core.
(** * split *)
(** * Concatenation *)
Hint Resolve concat_bst : core.
(** * Elements *)
Notation eqk := (PX.eqk (elt:= elt)).
Notation eqke := (PX.eqke (elt:= elt)).
Notation ltk := (PX.ltk (elt:= elt)).
Hint Resolve elements_sort : core.
(** * Fold *)
Definition fold' (A : Type) (f : key -> elt -> A -> A)(s : t elt) :=
L.fold f (elements s).
(** * Comparison *)
(** [flatten_e e] returns the list of elements of the enumeration [e] i.e. the list of elements actually compared *)
Fixpoint flatten_e (e : enumeration elt) : list (key*elt) := match e with
| End _ => nil
| More x e t r => (x,e) :: elements t ++ flatten_e r
end.
(** Proof of correction for the comparison *)
Variable cmp : elt->elt->bool.
Definition IfEq b l1 l2 := L.equal cmp l1 l2 = b.
Definition Equivb m m' :=
(forall k, In k m <-> In k m') /\
(forall k e e', MapsTo k e m -> MapsTo k e' m' -> cmp e e' = true).

Lemma equal_Equivb : forall (s s': t elt), bst s -> bst s' ->
(equal cmp s s' = true <-> Equivb s s').