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 In_filterMap : forall (f : A -> option B) b xs, In b (filterMap f xs) -> exists a, In a xs /\ f a = Some b.