Theory of filters on sets #
Main definitions #
Filter
: filters on a set;Filter.principal
: filter of all sets containing a given set;Filter.map
,Filter.comap
: operations on filters;Filter.Tendsto
: limit with respect to filters;Filter.Eventually
:f.eventually p
means{x | p x} ∈ f
;Filter.Frequently
:f.frequently p
means{x | ¬p x} ∉ f
;filter_upwards [h₁, ..., hₙ]
: a tactic that takes a list of proofshᵢ : sᵢ ∈ f
, and replaces a goals ∈ f
with∀ x, x ∈ s₁ → ... → x ∈ sₙ → x ∈ s
;Filter.NeBot f
: a utility class stating thatf
is a non-trivial filter.
Filters on a type X
are sets of sets of X
satisfying three conditions. They are mostly used to
abstract two related kinds of ideas:
- limits, including finite or infinite limits of sequences, finite or infinite limits of functions at a point or at infinity, etc...
- things happening eventually, including things happening for large enough
n : ℕ
, or near enough a pointx
, or for close enough pairs of points, or things happening almost everywhere in the sense of measure theory. Dually, filters can also express the idea of things happening often: for arbitrarily largen
, or at a point in any neighborhood of given a point etc...
In this file, we define the type Filter X
of filters on X
, and endow it with a complete lattice
structure. This structure is lifted from the lattice structure on Set (Set X)
using the Galois
insertion which maps a filter to its elements in one direction, and an arbitrary set of sets to
the smallest filter containing it in the other direction.
We also prove Filter
is a monadic functor, with a push-forward operation
Filter.map
and a pull-back operation Filter.comap
that form a Galois connections for the
order on filters.
The examples of filters appearing in the description of the two motivating ideas are:
(Filter.atTop : Filter ℕ)
: made of sets ofℕ
containing{n | n ≥ N}
for someN
𝓝 x
: made of neighborhoods ofx
in a topological space (defined in topology.basic)𝓤 X
: made of entourages of a uniform space (those space are generalizations of metric spaces defined inMathlib/Topology/UniformSpace/Basic.lean
)MeasureTheory.ae
: made of sets whose complement has zero measure with respect toμ
(defined inMathlib/MeasureTheory/OuterMeasure/AE
)
The general notion of limit of a map with respect to filters on the source and target types
is Filter.Tendsto
. It is defined in terms of the order and the push-forward operation.
The predicate "happening eventually" is Filter.Eventually
, and "happening often" is
Filter.Frequently
, whose definitions are immediate after Filter
is defined (but they come
rather late in this file in order to immediately relate them to the lattice structure).
For instance, anticipating on Topology.Basic, the statement: "if a sequence u
converges to
some x
and u n
belongs to a set M
for n
large enough then x
is in the closure of
M
" is formalized as: Tendsto u atTop (𝓝 x) → (∀ᶠ n in atTop, u n ∈ M) → x ∈ closure M
,
which is a special case of mem_closure_of_tendsto
from Topology.Basic.
Notations #
∀ᶠ x in f, p x
:f.Eventually p
;∃ᶠ x in f, p x
:f.Frequently p
;f =ᶠ[l] g
:∀ᶠ x in l, f x = g x
;f ≤ᶠ[l] g
:∀ᶠ x in l, f x ≤ g x
;𝓟 s
:Filter.Principal s
, localized inFilter
.
References #
- [N. Bourbaki, General Topology][bourbaki1966]
Important note: Bourbaki requires that a filter on X
cannot contain all sets of X
, which
we do not require. This gives Filter X
better formal properties, in particular a bottom element
⊥
for its lattice structure, at the cost of including the assumption
[NeBot f]
in a number of lemmas and definitions.
A filter F
on a type α
is a collection of sets of α
which contains the whole α
,
is upwards-closed, and is stable under intersection. We do not forbid this collection to be
all sets of α
.
The set of sets that belong to the filter.
- univ_sets : Set.univ ∈ self.sets
The set
Set.univ
belongs to any filter. If a set belongs to a filter, then its superset belongs to the filter as well.
If two sets belong to a filter, then their intersection belongs to the filter as well.
Instances For
If F
is a filter on α
, and U
a subset of α
then we can write U ∈ F
as on paper.
filter_upwards [h₁, ⋯, hₙ]
replaces a goal of the form s ∈ f
and terms
h₁ : t₁ ∈ f, ⋯, hₙ : tₙ ∈ f
with ∀ x, x ∈ t₁ → ⋯ → x ∈ tₙ → x ∈ s
.
The list is an optional parameter, []
being its default value.
filter_upwards [h₁, ⋯, hₙ] with a₁ a₂ ⋯ aₖ
is a short form for
{ filter_upwards [h₁, ⋯, hₙ], intros a₁ a₂ ⋯ aₖ }
.
filter_upwards [h₁, ⋯, hₙ] using e
is a short form for
{ filter_upwards [h1, ⋯, hn], exact e }
.
Combining both shortcuts is done by writing filter_upwards [h₁, ⋯, hₙ] with a₁ a₂ ⋯ aₖ using e
.
Note that in this case, the aᵢ
terms can be used in e
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The principal filter of s
is the collection of all supersets of s
.
Equations
- Filter.principal s = { sets := {t : Set α | s ⊆ t}, univ_sets := ⋯, sets_of_superset := ⋯, inter_sets := ⋯ }
Instances For
The principal filter of s
is the collection of all supersets of s
.
Equations
- Filter.term𝓟 = Lean.ParserDescr.node `Filter.term𝓟 1024 (Lean.ParserDescr.symbol "𝓟")
Instances For
Equations
- Filter.instPartialOrder = PartialOrder.mk ⋯
GenerateSets g s
: s
is in the filter closure of g
.
- basic: ∀ {α : Type u} {g : Set (Set α)} {s : Set α}, s ∈ g → Filter.GenerateSets g s
- univ: ∀ {α : Type u} {g : Set (Set α)}, Filter.GenerateSets g Set.univ
- superset: ∀ {α : Type u} {g : Set (Set α)} {s t : Set α}, Filter.GenerateSets g s → s ⊆ t → Filter.GenerateSets g t
- inter: ∀ {α : Type u} {g : Set (Set α)} {s t : Set α}, Filter.GenerateSets g s → Filter.GenerateSets g t → Filter.GenerateSets g (s ∩ t)
Instances For
generate g
is the largest filter containing the sets g
.
Equations
- Filter.generate g = { sets := {s : Set α | Filter.GenerateSets g s}, univ_sets := ⋯, sets_of_superset := ⋯, inter_sets := ⋯ }
Instances For
mkOfClosure s hs
constructs a filter on α
whose elements set is exactly
s : Set (Set α)
, provided one gives the assumption hs : (generate s).sets = s
.
Equations
- Filter.mkOfClosure s hs = { sets := s, univ_sets := ⋯, sets_of_superset := ⋯, inter_sets := ⋯ }
Instances For
Galois insertion from sets of sets into filters.
Equations
- Filter.giGenerate α = { choice := fun (s : Set (Set α)) (hs : (Filter.generate s).sets ≤ s) => Filter.mkOfClosure s ⋯, gc := ⋯, le_l_u := ⋯, choice_eq := ⋯ }
Instances For
The infimum of filters is the filter generated by intersections of elements of the two filters.
Equations
- Filter.instCompleteLatticeFilter = let __src := OrderDual.instCompleteLattice; CompleteLattice.mk ⋯ ⋯ ⋯ ⋯ ⋯ ⋯
A filter is NeBot
if it is not equal to ⊥
, or equivalently the empty set does not belong to
the filter. Bourbaki include this assumption in the definition of a filter but we prefer to have a
CompleteLattice
structure on Filter _
, so we use a typeclass argument in lemmas instead.
The filter is nontrivial:
f ≠ ⊥
or equivalently,∅ ∉ f
.
Instances
Either f = ⊥
or Filter.NeBot f
. This is a version of eq_or_ne
that uses Filter.NeBot
as the second alternative, to be used as an instance.
Alias of the reverse direction of Filter.principal_mono
.
Lattice equations #
There are only two filters on a Subsingleton
: ⊥
and ⊤
. If the type is empty, then they are
equal.
Equations
- ⋯ = ⋯
Equations
- Filter.instDistribLattice = let __src := Filter.instCompleteLatticeFilter; DistribLattice.mk ⋯
Equations
- Filter.instCoframe = let __src := Filter.instCompleteLatticeFilter; Order.Coframe.mk ⋯
If f : ι → Filter α
is directed, ι
is not empty, and ∀ i, f i ≠ ⊥
, then iInf f ≠ ⊥
.
See also iInf_neBot_of_directed
for a version assuming Nonempty α
instead of Nonempty ι
.
If f : ι → Filter α
is directed, α
is not empty, and ∀ i, f i ≠ ⊥
, then iInf f ≠ ⊥
.
See also iInf_neBot_of_directed'
for a version assuming Nonempty ι
instead of Nonempty α
.
Alias of the reverse direction of Filter.principal_neBot_iff
.
A special case of iInf_principal
that is safe to mark simp
.
Eventually #
f.Eventually p
or ∀ᶠ x in f, p x
mean that {x | p x} ∈ f
. E.g., ∀ᶠ x in atTop, p x
means that p
holds true for sufficiently large x
.
Equations
- Filter.Eventually p f = ({x : α | p x} ∈ f)
Instances For
Pretty printer defined by notation3
command.
Equations
- One or more equations did not get rendered due to their size.
Instances For
f.Eventually p
or ∀ᶠ x in f, p x
mean that {x | p x} ∈ f
. E.g., ∀ᶠ x in atTop, p x
means that p
holds true for sufficiently large x
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Alias of Filter.eventually_all_finite
.
Alias of Filter.eventually_all_finset
.
Frequently #
f.Frequently p
or ∃ᶠ x in f, p x
mean that {x | ¬p x} ∉ f
. E.g., ∃ᶠ x in atTop, p x
means that there exist arbitrarily large x
for which p
holds true.
Equations
- Filter.Frequently p f = ¬∀ᶠ (x : α) in f, ¬p x
Instances For
f.Frequently p
or ∃ᶠ x in f, p x
mean that {x | ¬p x} ∉ f
. E.g., ∃ᶠ x in atTop, p x
means that there exist arbitrarily large x
for which p
holds true.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Pretty printer defined by notation3
command.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Alias of the reverse direction of Filter.frequently_inf_principal
.
Alias of the forward direction of Filter.frequently_inf_principal
.
Relation “eventually equal” #
Two functions f
and g
are eventually equal along a filter l
if the set of x
such that
f x = g x
belongs to l
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A function f
is eventually less than or equal to a function g
at a filter l
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Push-forwards, pull-backs, and the monad structure #
The forward map of a filter
Equations
- Filter.map m f = { sets := Set.preimage m ⁻¹' f.sets, univ_sets := ⋯, sets_of_superset := ⋯, inter_sets := ⋯ }
Instances For
If functions m₁
and m₂
are eventually equal at a filter f
, then
they map this filter to the same filter.
The inverse map of a filter. A set s
belongs to Filter.comap m f
if either of the following
equivalent conditions hold.
- There exists a set
t ∈ f
such thatm ⁻¹' t ⊆ s
. This is used as a definition. - The set
kernImage m s = {y | ∀ x, m x = y → x ∈ s}
belongs tof
, seeFilter.mem_comap'
. - The set
(m '' sᶜ)ᶜ
belongs tof
, seeFilter.mem_comap_iff_compl
andFilter.compl_mem_comap
.
Equations
- Filter.comap m f = { sets := {s : Set α | ∃ t ∈ f, m ⁻¹' t ⊆ s}, univ_sets := ⋯, sets_of_superset := ⋯, inter_sets := ⋯ }
Instances For
The analog of kernImage
for filters. A set s
belongs to Filter.kernMap m f
if either of
the following equivalent conditions hold.
- There exists a set
t ∈ f
such thats = kernImage m t
. This is used as a definition. - There exists a set
t
such thattᶜ ∈ f
andsᶜ = m '' t
, seeFilter.mem_kernMap_iff_compl
andFilter.compl_mem_kernMap
.
This definition because it gives a right adjoint to Filter.comap
, and because it has a nice
interpretation when working with co-
filters (Filter.cocompact
, Filter.cofinite
, ...).
For example, kernMap m (cocompact α)
is the filter generated by the complements of the sets
m '' K
where K
is a compact subset of α
.
Equations
- Filter.kernMap m f = { sets := Set.kernImage m '' f.sets, univ_sets := ⋯, sets_of_superset := ⋯, inter_sets := ⋯ }
Instances For
The monadic bind operation on filter is defined the usual way in terms of map
and join
.
Unfortunately, this bind
does not result in the expected applicative. See Filter.seq
for the
applicative instance.
Equations
- f.bind m = (Filter.map m f).join
Instances For
The applicative sequentiation operation. This is not induced by the bind operation.
Equations
Instances For
pure x
is the set of sets that contain x
. It is equal to 𝓟 {x}
but
with this definition we have s ∈ pure a
defeq a ∈ s
.
Equations
- Filter.instFunctor = { map := @Filter.map, mapConst := fun {α β : Type u_2} => Filter.map ∘ Function.const β }
Filter
as a Monad
#
In this section we define Filter.monad
, a Monad
structure on Filter
s. This definition is not
an instance because its Seq
projection is not equal to the Filter.seq
function we use in the
Applicative
instance on Filter
.
The variables in the following lemmas are used as in this diagram:
φ
α → β
θ ↓ ↓ ψ
γ → δ
ρ
Temporary lemma that we can tag with gcongr
Temporary lemma that we can tag with gcongr
Equations
- ⋯ = ⋯
A useful lemma when dealing with uniformities.
Equations
Equations
Limits #
Filter.Tendsto
is the generic "limit of a function" predicate.
Tendsto f l₁ l₂
asserts that for every l₂
neighborhood a
,
the f
-preimage of a
is an l₁
neighborhood.
Equations
- Filter.Tendsto f l₁ l₂ = (Filter.map f l₁ ≤ l₂)
Instances For
Alias of the forward direction of Filter.tendsto_iff_comap
.
Alias of the reverse direction of Filter.tendsto_map'_iff
.
If two filters are disjoint, then a function cannot tend to both of them along a non-trivial filter.
Alias of the reverse direction of Filter.map_mapsTo_Iic_iff_tendsto
.
Alias of the reverse direction of Filter.map_mapsTo_Iic_iff_mapsTo
.
Alias of the reverse direction of Filter.map_surjOn_Iic_iff_surjOn
.
Alias of the reverse direction of Filter.filter_injOn_Iic_iff_injOn
.
Construct a filter from a property that is stable under finite unions.
A set s
belongs to Filter.comk p _ _ _
iff its complement satisfies the predicate p
.
This constructor is useful to define filters like Filter.cofinite
.
Equations
- Filter.comk p he hmono hunion = { sets := {t : Set α | p tᶜ}, univ_sets := ⋯, sets_of_superset := ⋯, inter_sets := ⋯ }