Section WeightTree.
Variable A : Type.
Variable f : A -> nat.
Fixpoint sum_leaves (t : btree A) : nat :=
match t with
| leaf n => f n
| node t1 t2 => sum_leaves t1 + sum_leaves t2
end.
Definition sum_order x y := sum_leaves x <= sum_leaves y.
Definition le_sum x y := le_bool (sum_leaves x) (sum_leaves y).
Proof using.
intros a b1; apply (le_bool_correct3 (sum_leaves a) (sum_leaves b1)).
Qed.

Theorem le_sum_correct2 :
forall a b1 : btree A, le_sum a b1 = false -> sum_order b1 a.