Section contents.
Variable (e: E) (ol: list e).
(* todo: use:  Inductive UnordNatPair: Set := unord_nat_pair (x y: nat): x <= y -> UnordNatPair.  Definition mk_unord_nat_pair (x y: nat): UnordNatPair := match le_lt_dec x y with | left p => unord_nat_pair p | right p => unord_nat_pair (lt_le_weak _ _ p) end.  *)
Definition monoid := ListMonoid.M (nat * nat).
Definition M: Monad := MonoidMonadTrans.M monoid ne_tree_monad.ext.
Proof MonoidMonadTrans.Mext monoid ne_tree_monad.ext.
Definition unordered_nat_pair (x y: nat): nat * nat :=
if le_lt_dec x y then (x, y) else (y, x).
Definition cmp (x y: Index e ol): M comparison
:= ret (unordered_nat_pair x y :: nil, Ecmp e (subscript x) (subscript y)).
Definition homo: monoidHomo monoid NatAddMonoid (fun x => length x).
Proof with auto. apply Build_monoidHomo... simpl. intros. rewrite app_length... Qed.
Definition pick := monoid_tree_monad.pick monoid.
Proof with auto. (* todo: rename *)
induction l...
simpl.
rewrite (@mon_assoc (ne_tree_monad.M)).
rewrite IHl.
simpl.
rewrite app_nil_r...
Qed.

Lemma simplePartition_component (ee: E) i cr l:
proj1_sig (simplerPartition ee i l) cr =
filter (fun f => unsum_bool (cmp_cmp (Ecmp ee f i) cr)) l.