(** [filter] *)
Fixpoint filter (l:list A) : list A :=
match l with
| [] => []
| x :: l => if f x then x::(filter l) else filter l
end.

(* Specifications: *)
Lemma filter_In : forall x l, In x (filter l) <-> In x l /\ f x = true.
Lemma filter_app (l l':list A) :
filter (l ++ l') = filter l ++ filter l'.
Lemma concat_filter_map : forall (l : list (list A)),
concat (map filter l) = filter (concat l).
Lemma forallb_filter l: forallb (filter l) = true.
Lemma forallb_filter_id l: forallb l = true -> filter l = l.
Fixpoint find (l:list A) : option A :=
match l with
| [] => None
| x :: tl => if f x then Some x else find tl
end.