(* A local function to compute all covers of a certain length *)
Fixpoint all_cover_aux (l : list (btree A)) (n : nat) {struct n} : list (btree A) :=
  match n with
  | O => nil
  | S n1 =>
      flat_map
        (fun l1 =>
         match l1 with
         | nil => nil
         | a :: nil => a :: nil
         | a :: b :: l2 => all_cover_aux (node a b :: l2) n1
         end) (all_permutations l)
  end.(* A function to compute all covers *)
Definition all_cover l := all_cover_aux l (length l).

Theorem all_cover_aux_cover : forall (n : nat) l t, n = length l -> In t (all_cover_aux l n) -> cover l t.