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.
Proof with auto. induction l... simpl. intros. rewrite H... Qed.
Proof with auto with arith.
induction l...
simpl.
destruct (p a)...
Qed.
Proof with auto with arith.
induction x...
simpl.
destruct (f a).
simpl.
destruct (p a)...
destruct (p a)...
Qed.
Hint Resolve count_le.
Proof with auto with arith.
induction l; simpl; intros.
elimtype False...
inversion_clear H.
subst.
rewrite H0...
destruct (p a)...
Qed.
End count.
Hint Resolve @count_le.
Proof with auto.
induction l...
simpl.
intros.
inversion_clear H.
apply NoDup_cons...
Qed.
Proof with auto. intros. induction l... simpl. destruct (p a)... simpl... Qed.
Hint Resolve filter_preserves_incl.
Proof with eauto.
induction l; intros; inversion_clear H. subst...
destruct IHl...
Qed.
Instance Permutation_NoDup {X}: Proper (Permutation ==> iff) (@NoDup X).
Proof with firstorder auto.
pose proof NoDup_cons.
intros ? ? E.
induction E; [firstorder | | | firstorder].
split; intro A; inversion_clear A; apply NoDup_cons...
rewrite <- E...
rewrite E...
split; intro A; inversion_clear A; inversion_clear H1...
Qed.
Hint Resolve incl_tran.
Instance filter_perm X: Proper (pointwise_relation _ eq ==> Permutation ==> Permutation) (@filter X).
Proof with auto.
repeat intro.
induction H0; rewrite H in *; simpl...
destruct (y x0)...
destruct (y y0); destruct (y x0)...
eauto.
Qed.
Proof with auto.
induction l...
simpl.
unfold compose.
destruct (p a); simpl...
apply Permutation_cons_app...
Qed.
Proof with auto.
induction l.
split...
intros.
inversion H0.
destruct IHl.
split; simpl; intros.
rewrite H1...
destruct H2.
subst.
destruct (p x)...
discriminate.
apply H0...
destruct (p a)...
discriminate.
Qed.

Lemma incl_map X Y (f: X -> Y) (a b: list X): incl a b -> incl (map f a) (map f b).