Fixpoint getSomes(A : Type)(ls : list (option A)) :=
  match ls with
    | nil => nil
    | o :: ls' =>
      match o with
        | None => getSomes ls'
        | Some x => x :: (getSomes ls')
      end
  end.

Lemma firstn_app_eq : forall (A : Set)(ls1 ls2 : list A), firstn (length ls1) (ls1 ++ ls2) = ls1.