Theory of filters on sets #
Main definitions #
Filter
: filters on a set;Filter.Principal
: specific filters;map
,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ₙ]
: 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
)μ.ae
: made of sets whose complement has zero measure with respect toμ
(defined inMeasureTheory.MeasureSpace
)
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.
The set of sets that belong to the filter.
- univ_sets : Set.univ ∈ s.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.
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 α
.
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
- 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.term𝓟 = Lean.ParserDescr.node `Filter.term𝓟 1024 (Lean.ParserDescr.symbol "𝓟")
Instances For
- 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)
generate_sets g s
: s
is in the filter closure of g
.
Instances For
Galois insertion from sets of sets into filters.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The infimum of filters is the filter generated by intersections of elements of the two filters.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
The filter is nontrivial:
f ≠ ⊥
or equivalently,∅ ∉ f
.
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.
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.
Lattice equations #
There are only two filters on a subsingleton
: ⊥
and ⊤
. If the type is empty, then they are
equal.
Equations
- One or more equations did not get rendered due to their size.
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
.
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
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
.
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
Equations
- One or more equations did not get rendered due to their size.
Instances For
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 #
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
- One or more equations did not get rendered due to their size.
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
- One or more equations did not get rendered due to their size.
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
- Filter.bind f m = Filter.join (Filter.map m f)
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
- One or more equations did not get rendered due to their size.
Equations
- Filter.instBindFilter = { bind := @Filter.bind }
Equations
- Filter.instFunctorFilter = { map := @Filter.map, mapConst := fun {α β} => 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
.
Equations
- Filter.instAlternativeFilter = Alternative.mk (fun {α} => ⊥) fun {α} x y => x ⊔ y ()
The variables in the following lemmas are used as in this diagram:
φ
α → β
θ ↓ ↓ ψ
γ → δ
ρ
Equations
Equations
- (_ : Filter.NeBot (Filter.map m f)) = (_ : Filter.NeBot (Filter.map m f))
A useful lemma when dealing with uniformities.
The kernel of a filter is the intersection of all its sets.
Equations
- Filter.ker f = ⋂₀ f.sets
Instances For
Filter.principal
forms a Galois coinsertion with Filter.ker
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
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.