Proof using.
intros l1 l2 H; elim H; auto.
simpl in |- *; auto; intros; ring.
simpl in |- *; auto; intros; ring.
intros l0 l3 l4 H0 H1 H2 H3; apply trans_equal with (1 := H1); auto.
Qed.
End WeightTree.
Arguments sum_leaves [A].
Arguments sum_order [A].
Arguments le_sum [A].
Arguments weight_tree [A].
Arguments weight_tree_list [A].

(* sum_leaves are the same for ordered list that are permutations one from the other *)
Theorem ordered_sum_leaves_eq :
forall (A : Type) (f : A -> nat) (l1 l2 : list (btree A)),
permutation l1 l2 ->
ordered (sum_order f) l1 ->
ordered (sum_order f) l2 -> map (sum_leaves f) l1 = map (sum_leaves f) l2.