End Equi.
(* * 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.
Arguments filter {X} p {p_dec} A.
Section FilterLemmas.
Variable X : Type.
Variable p : X -> Prop.
Context {p_dec : forall x, dec (p x)}.

(* Specifications: *)
Lemma in_filter_iff x A :
x el filter p A <-> x el A /\ p x.
Lemma filter_incl A :
filter p A <<= A.
Lemma filter_mono A B :
A <<= B -> filter p A <<= filter p B.
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.