Section Prod2List.
Variable A : Type.
Variable f : A -> nat.
(* In the product the sum of the leaves is multiplied by the integer and added to the weight of the tree *)
Definition prod2list l1 l2 :=
fold_left plus
(map2 (fun a b => a * sum_leaves f b + weight_tree f b) l1 l2) 0.

(* The product of the appended list is the sum of the product *)
Theorem prod2list_app :
forall l1 l2 l3 l4,
length l1 = length l2 ->
prod2list (l1 ++ l3) (l2 ++ l4) = prod2list l1 l2 + prod2list l3 l4.