Section count.
Context {X: Type} (p: X -> bool).
Fixpoint count (l: list X): nat :=
match l with
| nil => 0
| h :: t => if p h then S (count t) else count t
end.
Proof with auto.
induction l...
simpl.
destruct (p a)...
intros.
rewrite IHl...
Qed.

Lemma count_0 l: (forall x, In x l -> p x = false) -> count l = 0.