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

(* Specifications: *)
Theorem all_cover_aux_cover : forall (n : nat) l t, n = length l -> In t (all_cover_aux l n) -> cover l t.
Theorem all_cover_cover : forall l t, In t (all_cover l) -> cover l t.
Theorem cover_all_cover_aux : forall (n : nat) l t, n = length l -> cover l t -> In t (all_cover_aux l n).
Theorem cover_all_cover : forall l t, cover l t -> In t (all_cover l).