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.

Theorem firstn_map : forall (A B : Set)(f : A -> B)(ls : list A) n, firstn n (map f ls) = map f (firstn n ls).