Section OneStep.
Variable A : Type.
Variable f : A -> nat.
(* A step is valid if the two smallest elements of the initial list have been merged *)
Definition one_step (l1 l2 : list (btree A)) : Prop :=
exists l3 : list (btree A),
(exists t1 : btree A,
(exists t2 : btree A,
ordered (sum_order f) (t1 :: t2 :: l3) /\
permutation l1 (t1 :: t2 :: l3) /\
permutation l2 (node t1 t2 :: l3))).

(* Choosing one step or another does not change the weight *)
Theorem one_step_weight_tree_list :
forall l1 l2 l3 : list (btree A),
one_step l1 l2 ->
one_step l1 l3 -> weight_tree_list f l2 = weight_tree_list f l3.