(* Take the first elements of a list *)
Fixpoint first_n (l : list A) (n : nat) {struct n} :
 list A :=
  match n with
  | O => nil
  | S n1 => match l with
            | nil => nil
            | a :: l1 => a :: first_n l1 n1
            end
  end.

(* Specifications: *)
Theorem first_n_app1 : forall (n : nat) (l1 l2 : list A), length l1 <= n -> first_n (l1 ++ l2) n = l1 ++ first_n l2 (n - length l1).
Theorem first_n_app2 : forall (n : nat) (l1 l2 : list A), n <= length l1 -> first_n (l1 ++ l2) n = first_n l1 n.
Theorem first_n_length : forall (n : nat) (l1 : list A), n <= length l1 -> length (first_n l1 n) = n.
Theorem first_n_id : forall l : list A, first_n l (length l) = l.