Module WP := WProperties_fun E M.  (* More useful stuff about maps *)
Print Module WF.
Print Module WP.
Check E.lt. (*   : positive -> positive -> Prop *)
(** [E.lt] is a comparison predicate on [positive] numbers.  It is _not_ the usual less-than operator; it is a different ordering that is more compatible with the order that a Positive Trie arranges its keys.  In the application of certain lemmas about maps and sets, we will need the facts that [E.lt] is a [StrictOrder] (irreflexive and transitive) and respects a congruence over equality (is [Proper] for [eq ==> eq ==> iff]).   As shown here, we just have to dig up these facts from a submodule of a submodule of a submodule of [M]. *)
(* ================================================================= *)
(** ** SortA_equivlistA_eqlistA  Suppose two lists [al,bl] are "equivalent:" they contain the same set of elements (modulo an equivalence relation [eqA] on elements, perhaps in different orders, and perhaps with different numbers of repetitions).  That is, suppose [equivlistA eqA al bl].  And suppose list [al] is sorted, in some strict total order (respecting the same equivalence relation [eqA]).  And suppose list [bl] is sorted.  Then the lists must be _equal_ (modulo [eqA]).  Just to make this easier to think about, suppose [eqA] is just ordinary equality. Then if [al] and [bl] contain the same set of elements (perhaps reordered), and each list is sorted (by _less-than_, not by _less-or-equal_), then they must be equal.  Obviously.  That's what the theorem [SortA_equivlistA_eqlistA] says, in the Coq library: *)
Check SortA_equivlistA_eqlistA.    (*
: forall (A : Type) (eqA : A -> A -> Prop),
Equivalence eqA ->
forall ltA : A -> A -> Prop,
StrictOrder ltA ->
Proper (eqA ==> eqA ==> iff) ltA ->
forall l l' : list A,
Sorted ltA l ->
Sorted ltA l' -> equivlistA eqA l l' -> eqlistA eqA l l'  *)
(** That is, suppose [eqA] is an equivalence relation on type [A], that is, [eqA] is reflexive, symmetric, and transitive.  And suppose [ltA] is a strict order, that is, irreflexive and transitive.   And suppose [ltA] respects the equivalence relation, that is, if [eqA x x'] and [eqA y y'], then [ltA x y <-> ltA x' y']. THEN, if [l] is sorted (using the comparison [ltA]), and l' is sorted, and [l,l'] contain equivalent sets of elements, then [l,l'] must be equal lists, modulo the equivalence relation.  To make this easier to think about, let's use ordinary equality for eqA. We will be making sets and maps over the "node" type, [E.t], but that's just type [positive].  Therefore, the equivalence [E.eq: E.t -> E.t -> Prop] is just the same as [eq]. *)
Goal E.t = positive.  Proof. reflexivity. Qed.
Goal E.eq = @eq positive.  Proof. reflexivity. Qed.
(** And therefore, [eqlistA E.eq al bl] means the same as [al=bl]. *)
(** So now, the theorem:  if [al] and [bl] are sorted, and contain "the same" elements, then they are equal: *)

Lemma SortE_equivlistE_eqlistE:
forall al bl, Sorted E.lt al ->
Sorted E.lt bl ->
equivlistA E.eq al bl -> eqlistA E.eq al bl.