Section First.
Variable A : Type.
(* 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.
Proof using.
intros n; elim n; simpl in |- *; auto.
intros l1; case l1; simpl in |- *; auto.
intros b l l2 H; Contradict H; auto with arith.
intros n0 H l1; case l1; simpl in |- *; auto with arith.
intros b l l2 H0; rewrite H; auto with arith.
Qed.

Theorem first_n_app2 :
forall (n : nat) (l1 l2 : list A),
n <= length l1 -> first_n (l1 ++ l2) n = first_n l1 n.