Section expec_ctors.
Variables (T: Set) (f: T -> nat).
End expec_ctors.
(* misc expec *)
Add Parametric Morphism (A: Set): (@expec A)
with signature (@ext_eq A nat) ==> (@ext_eq (ne_tree.T A) R)
as expec_ext_morph.
Proof with auto.
induction t.
repeat rewrite expec_Leaf.
apply plus_INR.
repeat rewrite expec_Node_one...
repeat rewrite expec_Node_cons.
rewrite IHt.
rewrite IHt0.
field...
Qed.
Hint Resolve expec_nonneg.
Proof with auto with real.
induction t; intros.
simpl.
repeat rewrite expec_Leaf...
repeat rewrite expec_Node_one...
repeat rewrite expec_Node_cons.
apply Rmult_le_compat_r...
apply Rplus_le_compat...
apply Rmult_le_compat_r...
apply IHt0.
intros.
apply H.
right.
inversion_clear H0...
Qed.

Lemma expec_0_inv (T: Set) (f: T -> nat) (t: ne_tree.T T):
expec f t = 0 -> forall x, ne_tree.In x t -> f x = 0%nat.