Implicit Types A B : list X.Definition inclp (X : Type) (A : list X) (p : X -> Prop) : Prop :=
  forall x, x el A -> p x.Instance incl_preorder X : PreOrder (@incl X).Instance equi_Equivalence X : Equivalence (@equi X).(* * Filter *)

Definition filter (X : Type) (p : X -> Prop) (p_dec : forall x, dec (p x)) : list X -> list X :=
  fix f A := match A with
              | nil => nil
              | x::A' => if decision (p x) then x :: f A' else f A'
            end.

(* Specifications: *)
Lemma in_filter_iff x A : x el filter p A <-> x el A /\ p x.
Lemma filter_fst x A : p x -> filter p (x::A) = x::filter p A.
Lemma filter_app A B : filter p (A ++ B) = filter p A ++ filter p B.
Lemma filter_fst' x A : ~ p x -> filter p (x::A) = filter p A.