Fixpoint filterMap {A B} (f : A -> option B) (l : list A) : list B :=
  match l with
    | [] => []
    | x :: xs => match f x with
                   | None => filterMap f xs
                   | Some y => y :: filterMap f xs
                 end
  end.

Lemma filterMap_defn : forall (f : A -> option B) x xs, filterMap f (x :: xs) = match f x with | Some y => y :: filterMap f xs | None => filterMap f xs end.