Section ImplSpec.
Variable s s' : t.
Variable x y : elt.
Variable f : elt->bool.
End BoolSpec.
(** * Declarations of morphisms with respects to [E.eq] and [Equal] *)
Instance In_m : Proper (E.eq==>Equal==>iff) In.
Instance Empty_m : Proper (Equal==>iff) Empty.
Instance is_empty_m : Proper (Equal==>Logic.eq) is_empty.
Instance mem_m : Proper (E.eq==>Equal==>Logic.eq) mem.
Instance singleton_m : Proper (E.eq==>Equal) singleton.
Instance add_m : Proper (E.eq==>Equal==>Equal) add.
Instance remove_m : Proper (E.eq==>Equal==>Equal) remove.
Instance union_m : Proper (Equal==>Equal==>Equal) union.
Instance inter_m : Proper (Equal==>Equal==>Equal) inter.
Instance diff_m : Proper (Equal==>Equal==>Equal) diff.
Instance Subset_m : Proper (Equal==>Equal==>iff) Subset.
Instance subset_m : Proper (Equal==>Equal==>Logic.eq) subset.
Instance equal_m : Proper (Equal==>Equal==>Logic.eq) equal.
Instance SubsetSetoid : PreOrder Subset. (* reflexive + transitive *)
Instance Empty_s_m : Proper (Subset-->impl) Empty.
Instance remove_s_m : Proper (E.eq==>Subset++>Subset) remove.
Instance union_s_m : Proper (Subset++>Subset++>Subset) union.
Instance inter_s_m : Proper (Subset++>Subset++>Subset) inter.
Instance diff_s_m : Proper (Subset++>Subset-->Subset) diff.
(* [fold], [filter], [for_all], [exists_] and [partition] requires some knowledge on [f] in order to be known as morphisms. *)
Generalizable Variables f.
Instance filter_equal : forall `(Proper _ (E.eq==>Logic.eq) f),
Proper (Equal==>Equal) (filter f).
Instance filter_subset : forall `(Proper _ (E.eq==>Logic.eq) f),
Proper (Subset==>Subset) (filter f).

Lemma filter_ext : forall f f', Proper (E.eq==>Logic.eq) f -> (forall x, f x = f' x) ->
forall s s', s[=]s' -> filter f s [=] filter f' s'.