Section Bool.
(** Properties of [filter] *)
Variable f:elt->bool.
Variable Comp: Proper (E.eq==>Logic.eq) f.
Let Comp' : Proper (E.eq==>Logic.eq) (fun x =>negb (f x)).

(* Specifications: *)
Lemma for_all_filter:
forall s, for_all f s=is_empty (filter (fun x => negb (f x)) s).
Lemma exists_filter :
forall s, exists_ f s=negb (is_empty (filter f s)).
Lemma partition_filter_1:
forall s, equal (fst (partition f s)) (filter f s)=true.
Lemma partition_filter_2:
forall s, equal (snd (partition f s)) (filter (fun x => negb (f x)) s)=true.
Lemma filter_add_1 : forall s x, f x = true ->
filter f (add x s) [=] add x (filter f s).
Lemma filter_add_2 : forall s x, f x = false ->
filter f (add x s) [=] filter f s.
Lemma add_filter_1 : forall s s' x,
f x=true -> (Add x s s') -> (Add x (filter f s) (filter f s')).
Lemma add_filter_2 : forall s s' x,
f x=false -> (Add x s s') -> filter f s [=] filter f s'.
Lemma union_filter: forall f g,
Proper (E.eq==>Logic.eq) f -> Proper (E.eq==>Logic.eq) g ->
forall s, union (filter f s) (filter g s) [=] filter (fun x=>orb (f x) (g x)) s.
Lemma filter_union: forall s s', filter f (union s s') [=] union (filter f s) (filter f s').
(** Properties of [for_all] *)
Lemma for_all_mem_1: forall s,
(forall x, (mem x s)=true->(f x)=true) -> (for_all f s)=true.
Lemma for_all_mem_2: forall s,
(for_all f s)=true -> forall x,(mem x s)=true -> (f x)=true.
Lemma for_all_mem_3:
forall s x,(mem x s)=true -> (f x)=false -> (for_all f s)=false.
Lemma for_all_mem_4:
forall s, for_all f s=false -> {x:elt | mem x s=true /\ f x=false}.