Section contents.
Variables (m: Monoid) (ms: m -> nat).
About MonoidMonadTrans.M .
Definition monoid_expec {A: Set}:
MonoidMonadTrans.M m ne_tree_monad.ext A -> R
:= expec (ms ∘ (fst (B:=_:Set))).
Hypothesis mh: monoidHomo m NatAddMonoid ms.
Definition monoid_expec_sum (T U: Set)
(g: T -> MonoidMonadTrans.M m ne_tree_monad.ext U): list T -> R
:= Rsum ∘ map (monoid_expec ∘ g).
Proof with auto.
unfold monoid_expec_sum.
intros.
intro.
unfold compose.
f_equal.
apply map_ext.
intro.
f_equal.
apply H.
Qed.
Proof with auto.
unfold monoid_expec, monoid_expec_sum.
intros.
rewrite expec_Node.
rewrite ne_list.map_map.
unfold Ravg.
rewrite ne_list.map_length.
unfold monoid_expec.
rewrite ne_list.plain_map...
Qed.
Proof with auto.
intros.
simpl.
unfold monoid_expec.
unfold expec, compose.
simpl.
rewrite (monoidHomo_zero mh)...
Qed.

Lemma monoid_expec_bind_leaf_plus (X Y: Set) (f: X -> MonoidMonadTrans.M m ne_tree_monad.ext Y)
(n: prod m X):
monoid_expec (@bind (MonoidMonadTrans.M m ne_tree_monad.ext) _ _ (ne_tree.Leaf n) f) =
INR (ms (fst n)) + monoid_expec (f (snd n)).