(* 
  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))).

Theorem one_step_comp : forall l1 l2 l3 l4 : list (btree A), weight_tree_list f l1 = weight_tree_list f l2 -> same_sum_leaves f l1 l2 -> one_step l1 l3 -> one_step l2 l4 -> weight_tree_list f l3 = weight_tree_list f l4 /\ same_sum_leaves f l3 l4.