path
stringlengths 11
71
| content
stringlengths 75
124k
|
---|---|
Topology\UniformSpace\AbsoluteValue.lean
|
/-
Copyright (c) 2019 Patrick Massot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot
-/
import Mathlib.Algebra.Order.AbsoluteValue
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Topology.UniformSpace.Basic
/-!
# Uniform structure induced by an absolute value
We build a uniform space structure on a commutative ring `R` equipped with an absolute value into
a linear ordered field `š`. Of course in the case `R` is `ā`, `ā` or `ā` and
`š = ā`, we get the same thing as the metric space construction, and the general construction
follows exactly the same path.
## References
* [N. Bourbaki, *Topologie gƩnƩrale*][bourbaki1966]
## Tags
absolute value, uniform spaces
-/
open Set Function Filter Uniformity
namespace AbsoluteValue
variable {š : Type*} [LinearOrderedField š]
variable {R : Type*} [CommRing R] (abv : AbsoluteValue R š)
/-- The uniform structure coming from an absolute value. -/
def uniformSpace : UniformSpace R :=
.ofFun (fun x y => abv (y - x)) (by simp) (fun x y => abv.map_sub y x)
(fun x y z => (abv.sub_le _ _ _).trans_eq (add_comm _ _))
fun ε ε0 => āØĪµ / 2, half_pos ε0, fun _ hā _ hā => (add_lt_add hā hā).trans_eq (add_halves ε)ā©
theorem hasBasis_uniformity :
š¤[abv.uniformSpace].HasBasis ((0 : š) < Ā·) fun ε => { p : R Ć R | abv (p.2 - p.1) < ε } :=
UniformSpace.hasBasis_ofFun (exists_gt _) _ _ _ _ _
end AbsoluteValue
|
Topology\UniformSpace\AbstractCompletion.lean
|
/-
Copyright (c) 2019 Patrick Massot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot
-/
import Mathlib.Topology.UniformSpace.UniformEmbedding
import Mathlib.Topology.UniformSpace.Equiv
/-!
# Abstract theory of Hausdorff completions of uniform spaces
This file characterizes Hausdorff completions of a uniform space α as complete Hausdorff spaces
equipped with a map from α which has dense image and induce the original uniform structure on α.
Assuming these properties we "extend" uniformly continuous maps from α to complete Hausdorff spaces
to the completions of α. This is the universal property expected from a completion.
It is then used to extend uniformly continuous maps from α to α' to maps between
completions of α and α'.
This file does not construct any such completion, it only study consequences of their existence.
The first advantage is that formal properties are clearly highlighted without interference from
construction details. The second advantage is that this framework can then be used to compare
different completion constructions. See `Topology/UniformSpace/CompareReals` for an example.
Of course the comparison comes from the universal property as usual.
A general explicit construction of completions is done in `UniformSpace/Completion`, leading
to a functor from uniform spaces to complete Hausdorff uniform spaces that is left adjoint to the
inclusion, see `UniformSpace/UniformSpaceCat` for the category packaging.
## Implementation notes
A tiny technical advantage of using a characteristic predicate such as the properties listed in
`AbstractCompletion` instead of stating the universal property is that the universal property
derived from the predicate is more universe polymorphic.
## References
We don't know any traditional text discussing this. Real world mathematics simply silently
identify the results of any two constructions that lead to something one could reasonably
call a completion.
## Tags
uniform spaces, completion, universal property
-/
noncomputable section
attribute [local instance] Classical.propDecidable
open Filter Set Function
universe u
/-- A completion of `α` is the data of a complete separated uniform space (from the same universe)
and a map from `α` with dense range and inducing the original uniform structure on `α`. -/
structure AbstractCompletion (α : Type u) [UniformSpace α] where
/-- The underlying space of the completion. -/
space : Type u
/-- A map from a space to its completion. -/
coe : α ā space
/-- The completion carries a uniform structure. -/
uniformStruct : UniformSpace space
/-- The completion is complete. -/
complete : CompleteSpace space
/-- The completion is a Tā space. -/
separation : T0Space space
/-- The map into the completion is uniform-inducing. -/
uniformInducing : UniformInducing coe
/-- The map into the completion has dense range. -/
dense : DenseRange coe
attribute [local instance]
AbstractCompletion.uniformStruct AbstractCompletion.complete AbstractCompletion.separation
namespace AbstractCompletion
variable {α : Type*} [UniformSpace α] (pkg : AbstractCompletion α)
local notation "hatα" => pkg.space
local notation "ι" => pkg.coe
/-- If `α` is complete, then it is an abstract completion of itself. -/
def ofComplete [T0Space α] [CompleteSpace α] : AbstractCompletion α :=
mk α id inferInstance inferInstance inferInstance uniformInducing_id denseRange_id
theorem closure_range : closure (range ι) = univ :=
pkg.dense.closure_range
theorem denseInducing : DenseInducing ι :=
āØpkg.uniformInducing.inducing, pkg.denseā©
theorem uniformContinuous_coe : UniformContinuous ι :=
UniformInducing.uniformContinuous pkg.uniformInducing
theorem continuous_coe : Continuous ι :=
pkg.uniformContinuous_coe.continuous
@[elab_as_elim]
theorem induction_on {p : hatα ā Prop} (a : hatα) (hp : IsClosed { a | p a }) (ih : ā a, p (ι a)) :
p a :=
isClosed_property pkg.dense hp ih a
variable {β : Type*}
protected theorem funext [TopologicalSpace β] [T2Space β] {f g : hatα ā β} (hf : Continuous f)
(hg : Continuous g) (h : ā a, f (ι a) = g (ι a)) : f = g :=
funext fun a => pkg.induction_on a (isClosed_eq hf hg) h
variable [UniformSpace β]
section Extend
/-- Extension of maps to completions -/
protected def extend (f : α ā β) : hatα ā β :=
if UniformContinuous f then pkg.denseInducing.extend f else fun x => f (pkg.dense.some x)
variable {f : α ā β}
theorem extend_def (hf : UniformContinuous f) : pkg.extend f = pkg.denseInducing.extend f :=
if_pos hf
theorem extend_coe [T2Space β] (hf : UniformContinuous f) (a : α) : (pkg.extend f) (ι a) = f a := by
rw [pkg.extend_def hf]
exact pkg.denseInducing.extend_eq hf.continuous a
variable [CompleteSpace β]
theorem uniformContinuous_extend : UniformContinuous (pkg.extend f) := by
by_cases hf : UniformContinuous f
Ā· rw [pkg.extend_def hf]
exact uniformContinuous_uniformly_extend pkg.uniformInducing pkg.dense hf
Ā· change UniformContinuous (ite _ _ _)
rw [if_neg hf]
exact uniformContinuous_of_const fun a b => by congr 1
theorem continuous_extend : Continuous (pkg.extend f) :=
pkg.uniformContinuous_extend.continuous
variable [T0Space β]
theorem extend_unique (hf : UniformContinuous f) {g : hatα ā β} (hg : UniformContinuous g)
(h : ā a : α, f a = g (ι a)) : pkg.extend f = g := by
apply pkg.funext pkg.continuous_extend hg.continuous
simpa only [pkg.extend_coe hf] using h
@[simp]
theorem extend_comp_coe {f : hatα ā β} (hf : UniformContinuous f) : pkg.extend (f ā ι) = f :=
funext fun x =>
pkg.induction_on x (isClosed_eq pkg.continuous_extend hf.continuous) fun y =>
pkg.extend_coe (hf.comp <| pkg.uniformContinuous_coe) y
end Extend
section MapSec
variable (pkg' : AbstractCompletion β)
local notation "hatβ" => pkg'.space
local notation "ι'" => pkg'.coe
/-- Lifting maps to completions -/
protected def map (f : α ā β) : hatα ā hatβ :=
pkg.extend (ι' ā f)
local notation "map" => pkg.map pkg'
variable (f : α ā β)
theorem uniformContinuous_map : UniformContinuous (map f) :=
pkg.uniformContinuous_extend
@[continuity]
theorem continuous_map : Continuous (map f) :=
pkg.continuous_extend
variable {f}
@[simp]
theorem map_coe (hf : UniformContinuous f) (a : α) : map f (ι a) = ι' (f a) :=
pkg.extend_coe (pkg'.uniformContinuous_coe.comp hf) a
theorem map_unique {f : α ā β} {g : hatα ā hatβ} (hg : UniformContinuous g)
(h : ā a, ι' (f a) = g (ι a)) : map f = g :=
pkg.funext (pkg.continuous_map _ _) hg.continuous <| by
intro a
change pkg.extend (ι' ā f) _ = _
simp_rw [(Ā· ā Ā·), h, ā comp_apply (f := g)]
rw [pkg.extend_coe (hg.comp pkg.uniformContinuous_coe)]
@[simp]
theorem map_id : pkg.map pkg id = id :=
pkg.map_unique pkg uniformContinuous_id fun _ => rfl
variable {γ : Type*} [UniformSpace γ]
theorem extend_map [CompleteSpace γ] [T0Space γ] {f : β ā γ} {g : α ā β}
(hf : UniformContinuous f) (hg : UniformContinuous g) :
pkg'.extend f ā map g = pkg.extend (f ā g) :=
pkg.funext (pkg'.continuous_extend.comp (pkg.continuous_map pkg' _)) pkg.continuous_extend
fun a => by
rw [pkg.extend_coe (hf.comp hg), comp_apply, pkg.map_coe pkg' hg, pkg'.extend_coe hf]
rfl
variable (pkg'' : AbstractCompletion γ)
theorem map_comp {g : β ā γ} {f : α ā β} (hg : UniformContinuous g) (hf : UniformContinuous f) :
pkg'.map pkg'' g ā pkg.map pkg' f = pkg.map pkg'' (g ā f) :=
pkg.extend_map pkg' (pkg''.uniformContinuous_coe.comp hg) hf
end MapSec
section Compare
-- We can now compare two completion packages for the same uniform space
variable (pkg' : AbstractCompletion α)
/-- The comparison map between two completions of the same uniform space. -/
def compare : pkg.space ā pkg'.space :=
pkg.extend pkg'.coe
theorem uniformContinuous_compare : UniformContinuous (pkg.compare pkg') :=
pkg.uniformContinuous_extend
theorem compare_coe (a : α) : pkg.compare pkg' (pkg.coe a) = pkg'.coe a :=
pkg.extend_coe pkg'.uniformContinuous_coe a
theorem inverse_compare : pkg.compare pkg' ā pkg'.compare pkg = id := by
have uc := pkg.uniformContinuous_compare pkg'
have uc' := pkg'.uniformContinuous_compare pkg
apply pkg'.funext (uc.comp uc').continuous continuous_id
intro a
rw [comp_apply, pkg'.compare_coe pkg, pkg.compare_coe pkg']
rfl
/-- The uniform bijection between two completions of the same uniform space. -/
def compareEquiv : pkg.space āᵤ pkg'.space where
toFun := pkg.compare pkg'
invFun := pkg'.compare pkg
left_inv := congr_fun (pkg'.inverse_compare pkg)
right_inv := congr_fun (pkg.inverse_compare pkg')
uniformContinuous_toFun := uniformContinuous_compare _ _
uniformContinuous_invFun := uniformContinuous_compare _ _
theorem uniformContinuous_compareEquiv : UniformContinuous (pkg.compareEquiv pkg') :=
pkg.uniformContinuous_compare pkg'
theorem uniformContinuous_compareEquiv_symm : UniformContinuous (pkg.compareEquiv pkg').symm :=
pkg'.uniformContinuous_compare pkg
open scoped Topology
/-Let `f : α ā γ` be a continuous function between a uniform space `α` and a regular topological
space `γ`, and let `pkg, pkg'` be two abstract completions of `α`. Then
if for every point `a : pkg` the filter `f.map (coeā»Ā¹ (š a))` obtained by pushing forward with `f`
the preimage in `α` of `š a` tends to `š (f.extend a : β)`, then the comparison map
between `pkg` and `pkg'` composed with the extension of `f` to `pkg`` coincides with the
extension of `f` to `pkg'`. The situation is described in the following diagram, where the
two diagonal arrows are the extensions of `f` to the two different completions `pkg` and `pkg'`;
the statement of `compare_comp_eq_compare` is the commutativity of the right triangle.
```
`α^`=`pkg` ā
`α^'`=`pkg'` *here `ā
` is `compare`*
ā§ \ /
| \ /
| \ /
| V āØ
α ---f---> γ
```
-/
theorem compare_comp_eq_compare (γ : Type*) [TopologicalSpace γ]
[T3Space γ] {f : α ā γ} (cont_f : Continuous f) :
letI := pkg.uniformStruct.toTopologicalSpace
letI := pkg'.uniformStruct.toTopologicalSpace
(ā a : pkg.space,
Filter.Tendsto f (Filter.comap pkg.coe (š a)) (š ((pkg.denseInducing.extend f) a))) ā
pkg.denseInducing.extend f ā pkg'.compare pkg = pkg'.denseInducing.extend f := by
let _ := pkg'.uniformStruct
let _ := pkg.uniformStruct
intro h
have (x : α) : (pkg.denseInducing.extend f ā pkg'.compare pkg) (pkg'.coe x) = f x := by
simp only [Function.comp_apply, compare_coe, DenseInducing.extend_eq _ cont_f, implies_true]
apply (DenseInducing.extend_unique (AbstractCompletion.denseInducing _) this
(Continuous.comp _ (uniformContinuous_compare pkg' pkg).continuous )).symm
apply DenseInducing.continuous_extend
exact fun a ⦠āØ(pkg.denseInducing.extend f) a, h aā©
end Compare
section Prod
variable (pkg' : AbstractCompletion β)
local notation "hatβ" => pkg'.space
local notation "ι'" => pkg'.coe
/-- Products of completions -/
protected def prod : AbstractCompletion (α à β) where
space := hatα à hatβ
coe p := āØĪ¹ p.1, ι' p.2ā©
uniformStruct := inferInstance
complete := inferInstance
separation := inferInstance
uniformInducing := UniformInducing.prod pkg.uniformInducing pkg'.uniformInducing
dense := DenseRange.prod_map pkg.dense pkg'.dense
end Prod
section Extensionā
variable (pkg' : AbstractCompletion β)
local notation "hatβ" => pkg'.space
local notation "ι'" => pkg'.coe
variable {γ : Type*} [UniformSpace γ]
open Function
/-- Extend two variable map to completions. -/
protected def extendā (f : α ā β ā γ) : hatα ā hatβ ā γ :=
curry <| (pkg.prod pkg').extend (uncurry f)
section T0Space
variable [T0Space γ] {f : α ā β ā γ}
theorem extensionā_coe_coe (hf : UniformContinuous <| uncurry f) (a : α) (b : β) :
pkg.extendā pkg' f (ι a) (ι' b) = f a b :=
show (pkg.prod pkg').extend (uncurry f) ((pkg.prod pkg').coe (a, b)) = uncurry f (a, b) from
(pkg.prod pkg').extend_coe hf _
end T0Space
variable {f : α ā β ā γ}
variable [CompleteSpace γ] (f)
theorem uniformContinuous_extensionā : UniformContinuousā (pkg.extendā pkg' f) := by
rw [uniformContinuousā_def, AbstractCompletion.extendā, uncurry_curry]
apply uniformContinuous_extend
end Extensionā
section Mapā
variable (pkg' : AbstractCompletion β)
local notation "hatβ" => pkg'.space
local notation "ι'" => pkg'.coe
variable {γ : Type*} [UniformSpace γ] (pkg'' : AbstractCompletion γ)
local notation "hatγ" => pkg''.space
local notation "ι''" => pkg''.coe
local notation f " āā " g => bicompr f g
/-- Lift two variable maps to completions. -/
protected def mapā (f : α ā β ā γ) : hatα ā hatβ ā hatγ :=
pkg.extendā pkg' (pkg''.coe āā f)
theorem uniformContinuous_mapā (f : α ā β ā γ) : UniformContinuousā (pkg.mapā pkg' pkg'' f) :=
AbstractCompletion.uniformContinuous_extensionā pkg pkg' _
theorem continuous_mapā {Ī“} [TopologicalSpace Ī“] {f : α ā β ā γ} {a : Ī“ ā hatα} {b : Ī“ ā hatβ}
(ha : Continuous a) (hb : Continuous b) :
Continuous fun d : Ī“ => pkg.mapā pkg' pkg'' f (a d) (b d) :=
((pkg.uniformContinuous_mapā pkg' pkg'' f).continuous.comp (Continuous.prod_mk ha hb) : _)
theorem mapā_coe_coe (a : α) (b : β) (f : α ā β ā γ) (hf : UniformContinuousā f) :
pkg.mapā pkg' pkg'' f (ι a) (ι' b) = ι'' (f a b) :=
pkg.extensionā_coe_coe (f := pkg''.coe āā f) pkg' (pkg''.uniformContinuous_coe.comp hf) a b
end Mapā
end AbstractCompletion
|
Topology\UniformSpace\Ascoli.lean
|
/-
Copyright (c) 2022 Anatole Dedecker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anatole Dedecker
-/
import Mathlib.Topology.UniformSpace.CompactConvergence
import Mathlib.Topology.UniformSpace.Equicontinuity
import Mathlib.Topology.UniformSpace.Equiv
/-!
# Ascoli Theorem
In this file, we prove the general **Arzela-Ascoli theorem**, and various related statements about
the topology of equicontinuous subsetes of `X āᵤ[š] α`, where `X` is a topological space, `š` is
a family of compact subsets of `X`, and `α` is a uniform space.
## Main statements
* If `X` is a compact space, then the uniform structures of uniform convergence and pointwise
convergence coincide on equicontinuous subsets. This is the key fact that makes equicontinuity
important in functional analysis. We state various versions of it:
- as an equality of `UniformSpace`s: `Equicontinuous.comap_uniformFun_eq`
- in terms of `UniformInducing`: `Equicontinuous.uniformInducing_uniformFun_iff_pi`
- in terms of `Inducing`: `Equicontinuous.inducing_uniformFun_iff_pi`
- in terms of convergence along a filter: `Equicontinuous.tendsto_uniformFun_iff_pi`
* As a consequence, if `š` is a family of compact subsets of `X`, then the uniform structures of
uniform convergence on `š` and pointwise convergence on `āā š` coincide on equicontinuous
subsets. Again, we prove multiple variations:
- as an equality of `UniformSpace`s: `EquicontinuousOn.comap_uniformOnFun_eq`
- in terms of `UniformInducing`: `EquicontinuousOn.uniformInducing_uniformOnFun_iff_pi'`
- in terms of `Inducing`: `EquicontinuousOn.inducing_uniformOnFun_iff_pi'`
- in terms of convergence along a filter: `EquicontinuousOn.tendsto_uniformOnFun_iff_pi'`
* The **Arzela-Ascoli theorem** follows from the previous fact and Tykhonov's theorem.
All of its variations can be found under the `ArzelaAscoli` namespace.
## Implementation details
* The statements in this file may be a bit daunting because we prove everything for families and
embeddings instead of subspaces with the subspace topology. This is done because, in practice,
one would rarely work with `X āᵤ[š] α` directly, so we need to provide API for bringing back the
statements to various other types, such as `C(X, Y)` or `E āL[š] F`. To counteract this, all
statements (as well as most proofs!) are documented quite thouroughly.
* A lot of statements assume `ā K ā š, EquicontinuousOn F K` instead of the more natural
`EquicontinuousOn F (āā š)`. This is in order to keep the most generality, as the first statement
is strictly weaker.
* In Bourbaki, the usual Arzela-Ascoli compactness theorem follows from a similar total boundedness
result. Here we go directly for the compactness result, which is the most useful in practice, but
this will be an easy addition/refactor if we ever need it.
## TODO
* Prove that, on an equicontinuous family, pointwise convergence and pointwise convergence on a
dense subset coincide, and deduce metrizability criterions for equicontinuous subsets.
* Prove the total boundedness version of the theorem
* Prove the converse statement: if a subset of `X āᵤ[š] α` is compact, then it is equicontinuous
on each `K ā š`.
## References
* [N. Bourbaki, *General Topology, Chapter X*][bourbaki1966]
## Tags
equicontinuity, uniform convergence, ascoli
-/
open Set Filter Uniformity Topology Function UniformConvergence
variable {ι X Y α β : Type*} [TopologicalSpace X] [UniformSpace α] [UniformSpace β]
variable {F : ι ā X ā α} {G : ι ā β ā α}
/-- Let `X` be a compact topological space, `α` a uniform space, and `F : ι ā (X ā α)` an
equicontinuous family. Then, the uniform structures of uniform convergence and pointwise
convergence induce the same uniform structure on `ι`.
In other words, pointwise convergence and uniform convergence coincide on an equicontinuous
subset of `X ā α`.
Consider using `Equicontinuous.uniformInducing_uniformFun_iff_pi` and
`Equicontinuous.inducing_uniformFun_iff_pi` instead, to avoid rewriting instances. -/
theorem Equicontinuous.comap_uniformFun_eq [CompactSpace X] (F_eqcont : Equicontinuous F) :
(UniformFun.uniformSpace X α).comap F =
(Pi.uniformSpace _).comap F := by
-- The `ā¤` inequality is trivial
refine le_antisymm (UniformSpace.comap_mono UniformFun.uniformContinuous_toFun) ?_
-- A bit of rewriting to get a nice intermediate statement.
change comap _ _ ⤠comap _ _
simp_rw [Pi.uniformity, Filter.comap_iInf, comap_comap, Function.comp]
refine ((UniformFun.hasBasis_uniformity X α).comap (Prod.map F F)).ge_iff.mpr ?_
-- Core of the proof: we need to show that, for any entourage `U` in `α`,
-- the set `š(U) := {(i,j) : ι à ι | ā x : X, (F i x, F j x) ā U}` belongs to the filter
-- `āØ
x, comap ((i,j) ⦠(F i x, F j x)) (š¤ α)`.
-- In other words, we have to show that it contains a finite intersection of
-- sets of the form `š(V, x) := {(i,j) : ι à ι | (F i x, F j x) ā V}` for some
-- `x : X` and `V ā š¤ α`.
intro U hU
-- We will do an `ε/3` argument, so we start by choosing a symmetric entourage `V ā š¤ α`
-- such that `V ā V ā V ā U`.
rcases comp_comp_symm_mem_uniformity_sets hU with āØV, hV, Vsymm, hVUā©
-- Set `Ī© x := {y | ā i, (F i x, F i y) ā V}`. The equicontinuity of `F` guarantees that
-- each `Ī© x` is a neighborhood of `x`.
let Ī© x : Set X := {y | ā i, (F i x, F i y) ā V}
-- Hence, by compactness of `X`, we can find some `A ā X` finite such that the `Ī© a`s for `a ā A`
-- still cover `X`.
rcases CompactSpace.elim_nhds_subcover Ī© (fun x ⦠F_eqcont x V hV) with āØA, Acoverā©
-- We now claim that `ā a ā A, š(V, a) ā š(U)`.
have : (ā a ā A, {ij : ι à ι | (F ij.1 a, F ij.2 a) ā V}) ā
(Prod.map F F) ā»Ā¹' UniformFun.gen X α U := by
-- Given `(i, j) ā ā a ā A, š(V, a)` and `x : X`, we have to prove that `(F i x, F j x) ā U`.
rintro āØi, jā© hij x
rw [mem_iInterā] at hij
-- We know that `x ā Ī© a` for some `a ā A`, so that both `(F i x, F i a)` and `(F j a, F j x)`
-- are in `V`.
rcases mem_iUnionā.mp (Acover.symm.subset <| mem_univ x) with āØa, ha, haxā©
-- Since `(i, j) ā š(V, a)` we also have `(F i a, F j a) ā V`, and finally we get
-- `(F i x, F j x) ā V ā V ā V ā U`.
exact hVU (prod_mk_mem_compRel (prod_mk_mem_compRel
(Vsymm.mk_mem_comm.mp (hax i)) (hij a ha)) (hax j))
-- This completes the proof.
exact mem_of_superset
(A.iInter_mem_sets.mpr fun x _ ⦠mem_iInf_of_mem x <| preimage_mem_comap hV) this
/-- Let `X` be a compact topological space, `α` a uniform space, and `F : ι ā (X ā α)` an
equicontinuous family. Then, the uniform structures of uniform convergence and pointwise
convergence induce the same uniform structure on `ι`.
In other words, pointwise convergence and uniform convergence coincide on an equicontinuous
subset of `X ā α`.
This is a version of `Equicontinuous.comap_uniformFun_eq` stated in terms of `UniformInducing`
for convenuence. -/
lemma Equicontinuous.uniformInducing_uniformFun_iff_pi [UniformSpace ι] [CompactSpace X]
(F_eqcont : Equicontinuous F) :
UniformInducing (UniformFun.ofFun ā F) ā UniformInducing F := by
rw [uniformInducing_iff_uniformSpace, uniformInducing_iff_uniformSpace,
ā F_eqcont.comap_uniformFun_eq]
rfl
/-- Let `X` be a compact topological space, `α` a uniform space, and `F : ι ā (X ā α)` an
equicontinuous family. Then, the topologies of uniform convergence and pointwise convergence induce
the same topology on `ι`.
In other words, pointwise convergence and uniform convergence coincide on an equicontinuous
subset of `X ā α`.
This is a consequence of `Equicontinuous.comap_uniformFun_eq`, stated in terms of `Inducing`
for convenuence. -/
lemma Equicontinuous.inducing_uniformFun_iff_pi [TopologicalSpace ι] [CompactSpace X]
(F_eqcont : Equicontinuous F) :
Inducing (UniformFun.ofFun ā F) ā Inducing F := by
rw [inducing_iff, inducing_iff]
change (_ = (UniformFun.uniformSpace X α |>.comap F |>.toTopologicalSpace)) ā
(_ = (Pi.uniformSpace _ |>.comap F |>.toTopologicalSpace))
rw [F_eqcont.comap_uniformFun_eq]
/-- Let `X` be a compact topological space, `α` a uniform space, `F : ι ā (X ā α)` an
equicontinuous family, and `ā±` a filter on `ι`. Then, `F` tends *uniformly* to `f : X ā α` along
`ā±` iff it tends to `f` *pointwise* along `ā±`. -/
theorem Equicontinuous.tendsto_uniformFun_iff_pi [CompactSpace X]
(F_eqcont : Equicontinuous F) (ā± : Filter ι) (f : X ā α) :
Tendsto (UniformFun.ofFun ā F) ā± (š <| UniformFun.ofFun f) ā
Tendsto F ā± (š f) := by
-- Assume `ā±` is non trivial.
rcases ā±.eq_or_neBot with rfl | ā±_ne
Ā· simp
constructor <;> intro H
-- The forward direction is always true, the interesting part is the converse.
Ā· exact UniformFun.uniformContinuous_toFun.continuous.tendsto _|>.comp H
-- To prove it, assume that `F` tends to `f` *pointwise* along `ā±`.
Ā· set S : Set (X ā α) := closure (range F)
set š¢ : Filter S := comap (ā) (map F ā±)
-- We would like to use `Equicontinuous.comap_uniformFun_eq`, but applying it to `F` is not
-- enough since `f` has no reason to be in the range of `F`.
-- Instead, we will apply it to the inclusion `(ā) : S ā (X ā α)` where `S` is the closure of
-- the range of `F` *for the product topology*.
-- We know that `S` is still equicontinuous...
have hS : S.Equicontinuous := closure' (by rwa [equicontinuous_iff_range] at F_eqcont)
continuous_id
-- ... hence, as announced, the product topology and uniform convergence topology
-- coincide on `S`.
have ind : Inducing (UniformFun.ofFun ā (ā) : S ā X āᵤ α) :=
hS.inducing_uniformFun_iff_pi.mpr āØrflā©
-- By construction, `f` is in `S`.
have f_mem : f ā S := mem_closure_of_tendsto H range_mem_map
-- To conclude, we just have to translate our hypothesis and goal as statements about
-- `S`, on which we know the two topologies at play coincide.
-- For this, we define a filter on `S` by `š¢ := comap (ā) (map F ā±)`, and note that
-- it satisfies `map (ā) š¢ = map F ā±`. Thus, both our hypothesis and our goal
-- can be rewritten as `š¢ ⤠š f`, where the neighborhood filter in the RHS corresponds
-- to one of the two topologies at play on `S`. Since they coincide, we are done.
have hš¢ā± : map (ā) š¢ = map F ā± := Filter.map_comap_of_mem
(Subtype.range_coe āø mem_of_superset range_mem_map subset_closure)
have H' : Tendsto id š¢ (š āØf, f_memā©) := by
rwa [tendsto_id', nhds_induced, ā map_le_iff_le_comap, hš¢ā±]
rwa [ind.tendsto_nhds_iff, comp_id, ā tendsto_map'_iff, hš¢ā±] at H'
/-- Let `X` be a topological space, `š` a family of compact subsets of `X`, `α` a uniform space,
and `F : ι ā (X ā α)` a family which is equicontinuous on each `K ā š`. Then, the uniform
structures of uniform convergence on `š` and pointwise convergence on `āā š` induce the same
uniform structure on `ι`.
In particular, pointwise convergence and compact convergence coincide on an equicontinuous
subset of `X ā α`.
Consider using `EquicontinuousOn.uniformInducing_uniformOnFun_iff_pi'` and
`EquicontinuousOn.inducing_uniformOnFun_iff_pi'` instead to avoid rewriting instances,
as well as their unprimed versions in case `š` covers `X`. -/
theorem EquicontinuousOn.comap_uniformOnFun_eq {š : Set (Set X)} (š_compact : ā K ā š, IsCompact K)
(F_eqcont : ā K ā š, EquicontinuousOn F K) :
(UniformOnFun.uniformSpace X α š).comap F =
(Pi.uniformSpace _).comap ((āā š).restrict ā F) := by
-- Recall that the uniform structure on `X āᵤ[š] α` is the one induced by all the maps
-- `K.restrict : (X āᵤ[š] α) ā (K āᵤ α)` for `K ā š`. Its pullback along `F`, which is
-- the LHS of our goal, is thus the uniform structure induced by the maps
-- `K.restrict ā F : ι ā (K āᵤ α)` for `K ā š`.
have H1 : (UniformOnFun.uniformSpace X α š).comap F =
āØ
(K ā š), (UniformFun.uniformSpace _ _).comap (K.restrict ā F) := by
simp_rw [UniformOnFun.uniformSpace, UniformSpace.comap_iInf, ā UniformSpace.comap_comap,
UniformFun.ofFun, Equiv.coe_fn_mk, UniformOnFun.toFun, UniformOnFun.ofFun, Function.comp,
UniformFun, Equiv.coe_fn_symm_mk]
-- Now, note that a similar fact is true for the uniform structure on `X ā α` induced by
-- the map `(āā š).restrict : (X ā α) ā ((āā š) ā α)`: it is equal to the one induced by
-- all maps `K.restrict : (X ā α) ā (K ā α)` for `K ā š`, which means that the RHS of our
-- goal is the uniform structure induced by the maps `K.restrict ā F : ι ā (K ā α)` for `K ā š`.
have H2 : (Pi.uniformSpace _).comap ((āā š).restrict ā F) =
āØ
(K ā š), (Pi.uniformSpace _).comap (K.restrict ā F) := by
simp_rw [UniformSpace.comap_comap, Pi.uniformSpace_comap_restrict_sUnion (fun _ ⦠α) š,
UniformSpace.comap_iInf]
-- But, for `K ā š` fixed, we know that the uniform structures of `K āᵤ α` and `K ā α`
-- induce, via the equicontinuous family `K.restrict ā F`, the same uniform structure on `ι`.
have H3 : ā K ā š, (UniformFun.uniformSpace K α).comap (K.restrict ā F) =
(Pi.uniformSpace _).comap (K.restrict ā F) := fun K hK ⦠by
have : CompactSpace K := isCompact_iff_compactSpace.mp (š_compact K hK)
exact (equicontinuous_restrict_iff _ |>.mpr <| F_eqcont K hK).comap_uniformFun_eq
-- Combining these three facts completes the proof.
simp_rw [H1, H2, iInf_congr fun K ⦠iInf_congr fun hK ⦠H3 K hK]
/-- Let `X` be a topological space, `š` a family of compact subsets of `X`, `α` a uniform space,
and `F : ι ā (X ā α)` a family which is equicontinuous on each `K ā š`. Then, the uniform
structures of uniform convergence on `š` and pointwise convergence on `āā š` induce the same
uniform structure on `ι`.
In particular, pointwise convergence and compact convergence coincide on an equicontinuous
subset of `X ā α`.
This is a version of `EquicontinuousOn.comap_uniformOnFun_eq` stated in terms of `UniformInducing`
for convenuence. -/
lemma EquicontinuousOn.uniformInducing_uniformOnFun_iff_pi' [UniformSpace ι]
{š : Set (Set X)} (š_compact : ā K ā š, IsCompact K)
(F_eqcont : ā K ā š, EquicontinuousOn F K) :
UniformInducing (UniformOnFun.ofFun š ā F) ā
UniformInducing ((āā š).restrict ā F) := by
rw [uniformInducing_iff_uniformSpace, uniformInducing_iff_uniformSpace,
ā EquicontinuousOn.comap_uniformOnFun_eq š_compact F_eqcont]
rfl
/-- Let `X` be a topological space, `š` a covering of `X` by compact subsets, `α` a uniform space,
and `F : ι ā (X ā α)` a family which is equicontinuous on each `K ā š`. Then, the uniform
structures of uniform convergence on `š` and pointwise convergence induce the same
uniform structure on `ι`.
This is a specialization of `EquicontinuousOn.uniformInducing_uniformOnFun_iff_pi'` to
the case where `š` covers `X`. -/
lemma EquicontinuousOn.uniformInducing_uniformOnFun_iff_pi [UniformSpace ι]
{š : Set (Set X)} (š_covers : āā š = univ) (š_compact : ā K ā š, IsCompact K)
(F_eqcont : ā K ā š, EquicontinuousOn F K) :
UniformInducing (UniformOnFun.ofFun š ā F) ā
UniformInducing F := by
rw [eq_univ_iff_forall] at š_covers
-- This obviously follows from the previous lemma, we formalize it by going through the
-- isomorphism of uniform spaces between `(āā š) ā α` and `X ā α`.
let Ļ : ((āā š) ā α) āᵤ (X ā α) := UniformEquiv.piCongrLeft (β := fun _ ⦠α)
(Equiv.subtypeUnivEquiv š_covers)
rw [EquicontinuousOn.uniformInducing_uniformOnFun_iff_pi' š_compact F_eqcont,
show restrict (āā š) ā F = Ļ.symm ā F by rfl]
exact āØfun H ⦠Ļ.uniformInducing.comp H, fun H ⦠Ļ.symm.uniformInducing.comp Hā©
/-- Let `X` be a topological space, `š` a family of compact subsets of `X`, `α` a uniform space,
and `F : ι ā (X ā α)` a family which is equicontinuous on each `K ā š`. Then, the topologies
of uniform convergence on `š` and pointwise convergence on `āā š` induce the same topology on `ι`.
In particular, pointwise convergence and compact convergence coincide on an equicontinuous
subset of `X ā α`.
This is a consequence of `EquicontinuousOn.comap_uniformOnFun_eq` stated in terms of `Inducing`
for convenuence. -/
lemma EquicontinuousOn.inducing_uniformOnFun_iff_pi' [TopologicalSpace ι]
{š : Set (Set X)} (š_compact : ā K ā š, IsCompact K)
(F_eqcont : ā K ā š, EquicontinuousOn F K) :
Inducing (UniformOnFun.ofFun š ā F) ā
Inducing ((āā š).restrict ā F) := by
rw [inducing_iff, inducing_iff]
change (_ = ((UniformOnFun.uniformSpace X α š).comap F).toTopologicalSpace) ā
(_ = ((Pi.uniformSpace _).comap ((āā š).restrict ā F)).toTopologicalSpace)
rw [ā EquicontinuousOn.comap_uniformOnFun_eq š_compact F_eqcont]
/-- Let `X` be a topological space, `š` a covering of `X` by compact subsets, `α` a uniform space,
and `F : ι ā (X ā α)` a family which is equicontinuous on each `K ā š`. Then, the topologies
of uniform convergence on `š` and pointwise convergence induce the same topology on `ι`.
This is a specialization of `EquicontinuousOn.inducing_uniformOnFun_iff_pi'` to
the case where `š` covers `X`. -/
lemma EquicontinuousOn.inducing_uniformOnFun_iff_pi [TopologicalSpace ι]
{š : Set (Set X)} (š_covers : āā š = univ) (š_compact : ā K ā š, IsCompact K)
(F_eqcont : ā K ā š, EquicontinuousOn F K) :
Inducing (UniformOnFun.ofFun š ā F) ā
Inducing F := by
rw [eq_univ_iff_forall] at š_covers
-- This obviously follows from the previous lemma, we formalize it by going through the
-- homeomorphism between `(āā š) ā α` and `X ā α`.
let Ļ : ((āā š) ā α) āā (X ā α) := Homeomorph.piCongrLeft (Y := fun _ ⦠α)
(Equiv.subtypeUnivEquiv š_covers)
rw [EquicontinuousOn.inducing_uniformOnFun_iff_pi' š_compact F_eqcont,
show restrict (āā š) ā F = Ļ.symm ā F by rfl]
exact āØfun H ⦠Ļ.inducing.comp H, fun H ⦠Ļ.symm.inducing.comp Hā©
-- TODO: find a way to factor common elements of this proof and the proof of
-- `EquicontinuousOn.comap_uniformOnFun_eq`
/-- Let `X` be a topological space, `š` a family of compact subsets of `X`,
`α` a uniform space, `F : ι ā (X ā α)` a family equicontinuous on each `K ā š`, and `ā±` a filter
on `ι`. Then, `F` tends to `f : X ā α` along `ā±` *uniformly on each `K ā š`* iff it tends to `f`
*pointwise on `āā š`* along `ā±`. -/
theorem EquicontinuousOn.tendsto_uniformOnFun_iff_pi'
{š : Set (Set X)} (š_compact : ā K ā š, IsCompact K)
(F_eqcont : ā K ā š, EquicontinuousOn F K) (ā± : Filter ι) (f : X ā α) :
Tendsto (UniformOnFun.ofFun š ā F) ā± (š <| UniformOnFun.ofFun š f) ā
Tendsto ((āā š).restrict ā F) ā± (š <| (āā š).restrict f) := by
-- Recall that the uniform structure on `X āᵤ[š] α` is the one induced by all the maps
-- `K.restrict : (X āᵤ[š] α) ā (K āᵤ α)` for `K ā š`.
-- Similarly, the uniform structure on `X ā α` induced by the map
-- `(āā š).restrict : (X ā α) ā ((āā š) ā α)` is equal to the one induced by
-- all maps `K.restrict : (X ā α) ā (K ā α)` for `K ā š`
-- Thus, we just have to compare the two sides of our goal when restricted to some
-- `K ā š`, where we can apply `Equicontinuous.tendsto_uniformFun_iff_pi`.
rw [ā Filter.tendsto_comap_iff (g := (āā š).restrict), ā nhds_induced]
simp_rw [UniformOnFun.topologicalSpace_eq, Pi.induced_restrict_sUnion š (Ļ := fun _ ⦠α),
_root_.nhds_iInf, nhds_induced, tendsto_iInf, tendsto_comap_iff]
congrm ā K (hK : K ā š), ?_
have : CompactSpace K := isCompact_iff_compactSpace.mp (š_compact K hK)
rw [ā (equicontinuous_restrict_iff _ |>.mpr <| F_eqcont K hK).tendsto_uniformFun_iff_pi]
rfl
/-- Let `X` be a topological space, `š` a covering of `X` by compact subsets,
`α` a uniform space, `F : ι ā (X ā α)` a family equicontinuous on each `K ā š`, and `ā±` a filter
on `ι`. Then, `F` tends to `f : X ā α` along `ā±` *uniformly on each `K ā š`* iff it tends to `f`
*pointwise* along `ā±`.
This is a specialization of `EquicontinuousOn.tendsto_uniformOnFun_iff_pi'` to the case
where `š` covers `X`. -/
theorem EquicontinuousOn.tendsto_uniformOnFun_iff_pi
{š : Set (Set X)} (š_compact : ā K ā š, IsCompact K) (š_covers : āā š = univ)
(F_eqcont : ā K ā š, EquicontinuousOn F K) (ā± : Filter ι) (f : X ā α) :
Tendsto (UniformOnFun.ofFun š ā F) ā± (š <| UniformOnFun.ofFun š f) ā
Tendsto F ā± (š f) := by
rw [eq_univ_iff_forall] at š_covers
let Ļ : ((āā š) ā α) āā (X ā α) := Homeomorph.piCongrLeft (Y := fun _ ⦠α)
(Equiv.subtypeUnivEquiv š_covers)
rw [EquicontinuousOn.tendsto_uniformOnFun_iff_pi' š_compact F_eqcont,
show restrict (āā š) ā F = Ļ.symm ā F by rfl, show restrict (āā š) f = Ļ.symm f by rfl,
Ļ.symm.inducing.tendsto_nhds_iff]
/-- Let `X` be a topological space, `š` a family of compact subsets of `X` and
`α` a uniform space. An equicontinuous subset of `X ā α` is closed in the topology of uniform
convergence on all `K ā š` iff it is closed in the topology of pointwise convergence on `āā š`. -/
theorem EquicontinuousOn.isClosed_range_pi_of_uniformOnFun'
{š : Set (Set X)} (š_compact : ā K ā š, IsCompact K)
(F_eqcont : ā K ā š, EquicontinuousOn F K)
(H : IsClosed (range <| UniformOnFun.ofFun š ā F)) :
IsClosed (range <| (āā š).restrict ā F) := by
-- Do we have no equivalent of `nontriviality`?
rcases isEmpty_or_nonempty α with _ | _
Ā· simp [isClosed_discrete]
-- This follows from the previous lemmas and the characterization of the closure using filters.
simp_rw [isClosed_iff_clusterPt, ā Filter.map_top, ā mapClusterPt_def,
mapClusterPt_iff_ultrafilter, range_comp, Subtype.coe_injective.surjective_comp_right.forall,
ā restrict_eq, ā EquicontinuousOn.tendsto_uniformOnFun_iff_pi' š_compact F_eqcont]
exact fun f āØu, _, hu⩠⦠mem_image_of_mem _ <| H.mem_of_tendsto hu <|
eventually_of_forall mem_range_self
/-- Let `X` be a topological space, `š` a covering of `X` by compact subsets, and
`α` a uniform space. An equicontinuous subset of `X ā α` is closed in the topology of uniform
convergence on all `K ā š` iff it is closed in the topology of pointwise convergence.
This is a specialization of `EquicontinuousOn.isClosed_range_pi_of_uniformOnFun'` to the case where
`š` covers `X`. -/
theorem EquicontinuousOn.isClosed_range_uniformOnFun_iff_pi
{š : Set (Set X)} (š_compact : ā K ā š, IsCompact K) (š_covers : āā š = univ)
(F_eqcont : ā K ā š, EquicontinuousOn F K) :
IsClosed (range <| UniformOnFun.ofFun š ā F) ā
IsClosed (range F) := by
-- This follows from the previous lemmas and the characterization of the closure using filters.
simp_rw [isClosed_iff_clusterPt, ā Filter.map_top, ā mapClusterPt_def,
mapClusterPt_iff_ultrafilter, range_comp, (UniformOnFun.ofFun š).surjective.forall,
ā EquicontinuousOn.tendsto_uniformOnFun_iff_pi š_compact š_covers F_eqcont,
(UniformOnFun.ofFun š).injective.mem_set_image]
alias āØEquicontinuousOn.isClosed_range_pi_of_uniformOnFun, _ā© :=
EquicontinuousOn.isClosed_range_uniformOnFun_iff_pi
/-- A version of the **Arzela-Ascoli theorem**.
Let `X` be a topological space, `š` a family of compact subsets of `X`, `α` a uniform space,
and `F : ι ā (X ā α)`. Assume that:
* `F`, viewed as a function `ι ā (X āᵤ[š] α)`, is closed and inducing
* `F` is equicontinuous on each `K ā š`
* For all `x ā āā š`, the range of `i ⦠F i x` is contained in some fixed compact subset.
Then `ι` is compact. -/
theorem ArzelaAscoli.compactSpace_of_closed_inducing' [TopologicalSpace ι] {š : Set (Set X)}
(š_compact : ā K ā š, IsCompact K) (F_ind : Inducing (UniformOnFun.ofFun š ā F))
(F_cl : IsClosed <| range <| UniformOnFun.ofFun š ā F)
(F_eqcont : ā K ā š, EquicontinuousOn F K)
(F_pointwiseCompact : ā K ā š, ā x ā K, ā Q, IsCompact Q ā§ ā i, F i x ā Q) :
CompactSpace ι := by
-- By equicontinuity, we know that the topology on `ι` is also the one induced by
-- `restrict (āā š) ā F`.
have : Inducing (restrict (āā š) ā F) := by
rwa [EquicontinuousOn.inducing_uniformOnFun_iff_pi' š_compact F_eqcont] at F_ind
-- Thus, we just have to check that the range of this map is compact.
rw [ā isCompact_univ_iff, this.isCompact_iff, image_univ]
-- But then we are working in a product space, where compactness can easily be proven using
-- Tykhonov's theorem! More precisely, for each `x ā āā š`, choose a compact set `Q x`
-- containing all `F i x`s.
rw [ā forall_sUnion] at F_pointwiseCompact
choose! Q Q_compact F_in_Q using F_pointwiseCompact
-- Notice that, since the range of `F` is closed in `X āᵤ[š] α`, equicontinuity ensures that
-- the range of `(āā š).restrict ā F` is still closed in the product topology.
-- But it's contained in the product of the `Q x`s, which is compact by Tykhonov, hence
-- it is compact as well.
refine IsCompact.of_isClosed_subset (isCompact_univ_pi fun x ⦠Q_compact x x.2)
(EquicontinuousOn.isClosed_range_pi_of_uniformOnFun' š_compact F_eqcont F_cl)
(range_subset_iff.mpr fun i x _ ⦠F_in_Q x x.2 i)
/-- A version of the **Arzela-Ascoli theorem**.
Let `X, ι` be topological spaces, `š` a covering of `X` by compact subsets, `α` a uniform space,
and `F : ι ā (X ā α)`. Assume that:
* `F`, viewed as a function `ι ā (X āᵤ[š] α)`, is a closed embedding (in other words, `ι`
identifies to a closed subset of `X āᵤ[š] α` through `F`)
* `F` is equicontinuous on each `K ā š`
* For all `x`, the range of `i ⦠F i x` is contained in some fixed compact subset.
Then `ι` is compact. -/
theorem ArzelaAscoli.compactSpace_of_closedEmbedding [TopologicalSpace ι] {š : Set (Set X)}
(š_compact : ā K ā š, IsCompact K) (F_clemb : ClosedEmbedding (UniformOnFun.ofFun š ā F))
(F_eqcont : ā K ā š, EquicontinuousOn F K)
(F_pointwiseCompact : ā K ā š, ā x ā K, ā Q, IsCompact Q ā§ ā i, F i x ā Q) :
CompactSpace ι :=
compactSpace_of_closed_inducing' š_compact F_clemb.toInducing F_clemb.isClosed_range
F_eqcont F_pointwiseCompact
/-- A version of the **Arzela-Ascoli theorem**.
Let `X, ι` be topological spaces, `š` a covering of `X` by compact subsets, `α` a T2 uniform space,
`F : ι ā (X ā α)`, and `s` a subset of `ι`. Assume that:
* `F`, viewed as a function `ι ā (X āᵤ[š] α)`, is a closed embedding (in other words, `ι`
identifies to a closed subset of `X āᵤ[š] α` through `F`)
* `F '' s` is equicontinuous on each `K ā š`
* For all `x ā āā š`, the image of `s` under `i ⦠F i x` is contained in some fixed compact subset.
Then `s` has compact closure in `ι`. -/
theorem ArzelaAscoli.isCompact_closure_of_closedEmbedding [TopologicalSpace ι] [T2Space α]
{š : Set (Set X)} (š_compact : ā K ā š, IsCompact K)
(F_clemb : ClosedEmbedding (UniformOnFun.ofFun š ā F))
{s : Set ι} (s_eqcont : ā K ā š, EquicontinuousOn (F ā ((ā) : s ā ι)) K)
(s_pointwiseCompact : ā K ā š, ā x ā K, ā Q, IsCompact Q ā§ ā i ā s, F i x ā Q) :
IsCompact (closure s) := by
-- We apply `ArzelaAscoli.compactSpace_of_closedEmbedding` to the map
-- `F ā (ā) : closure s ā (X ā α)`, for which all the hypotheses are easily verified.
rw [isCompact_iff_compactSpace]
have : ā K ā š, ā x ā K, Continuous (eval x ā F) := fun K hK x hx ā¦
UniformOnFun.uniformContinuous_eval_of_mem _ _ hx hK |>.continuous.comp F_clemb.continuous
have cls_eqcont : ā K ā š, EquicontinuousOn (F ā ((ā) : closure s ā ι)) K :=
fun K hK ⦠(s_eqcont K hK).closure' <| show Continuous (K.restrict ā F) from
continuous_pi fun āØx, hx⩠⦠this K hK x hx
have cls_pointwiseCompact : ā K ā š, ā x ā K, ā Q, IsCompact Q ā§ ā i ā closure s, F i x ā Q :=
fun K hK x hx ⦠(s_pointwiseCompact K hK x hx).imp fun Q hQ ⦠āØhQ.1, closure_minimal hQ.2 <|
hQ.1.isClosed.preimage (this K hK x hx)ā©
exact ArzelaAscoli.compactSpace_of_closedEmbedding š_compact
(F_clemb.comp isClosed_closure.closedEmbedding_subtype_val) cls_eqcont
fun K hK x hx ⦠(cls_pointwiseCompact K hK x hx).imp fun Q hQ ⦠āØhQ.1, by simpa using hQ.2ā©
/-- A version of the **Arzela-Ascoli theorem**.
If an equicontinuous family of continuous functions is compact in the pointwise topology, then it
is compact in the compact open topology. -/
theorem ArzelaAscoli.isCompact_of_equicontinuous
(S : Set C(X, α)) (hS1 : IsCompact (ContinuousMap.toFun '' S))
(hS2 : Equicontinuous ((ā) : S ā X ā α)) : IsCompact S := by
suffices h : Inducing (Equiv.Set.image (ā) S DFunLike.coe_injective) by
rw [isCompact_iff_compactSpace] at hS1 ā¢
exact (Equiv.toHomeomorphOfInducing _ h).symm.compactSpace
rw [ā inducing_subtype_val.of_comp_iff, ā EquicontinuousOn.inducing_uniformOnFun_iff_pi _ _ _]
Ā· exact ContinuousMap.uniformEmbedding_toUniformOnFunIsCompact.inducing.comp inducing_subtype_val
· exact eq_univ_iff_forall.mpr (fun x ⦠mem_sUnion_of_mem (mem_singleton x) isCompact_singleton)
· exact fun _ ⦠id
· exact fun K _ ⦠hS2.equicontinuousOn K
|
Topology\UniformSpace\Basic.lean
|
/-
Copyright (c) 2017 Johannes Hƶlzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hƶlzl, Mario Carneiro, Patrick Massot
-/
import Mathlib.Order.Filter.SmallSets
import Mathlib.Tactic.Monotonicity
import Mathlib.Topology.Compactness.Compact
import Mathlib.Topology.NhdsSet
import Mathlib.Algebra.Group.Defs
/-!
# Uniform spaces
Uniform spaces are a generalization of metric spaces and topological groups. Many concepts directly
generalize to uniform spaces, e.g.
* uniform continuity (in this file)
* completeness (in `Cauchy.lean`)
* extension of uniform continuous functions to complete spaces (in `UniformEmbedding.lean`)
* totally bounded sets (in `Cauchy.lean`)
* totally bounded complete sets are compact (in `Cauchy.lean`)
A uniform structure on a type `X` is a filter `š¤ X` on `X Ć X` satisfying some conditions
which makes it reasonable to say that `āį¶ (p : X Ć X) in š¤ X, ...` means
"for all p.1 and p.2 in X close enough, ...". Elements of this filter are called entourages
of `X`. The two main examples are:
* If `X` is a metric space, `V ā š¤ X ā ā ε > 0, { p | dist p.1 p.2 < ε } ā V`
* If `G` is an additive topological group, `V ā š¤ G ā ā U ā š (0 : G), {p | p.2 - p.1 ā U} ā V`
Those examples are generalizations in two different directions of the elementary example where
`X = ā` and `V ā š¤ ā ā ā ε > 0, { p | |p.2 - p.1| < ε } ā V` which features both the topological
group structure on `ā` and its metric space structure.
Each uniform structure on `X` induces a topology on `X` characterized by
> `nhds_eq_comap_uniformity : ā {x : X}, š x = comap (Prod.mk x) (š¤ X)`
where `Prod.mk x : X ā X Ć X := (fun y ⦠(x, y))` is the partial evaluation of the product
constructor.
The dictionary with metric spaces includes:
* an upper bound for `dist x y` translates into `(x, y) ā V` for some `V ā š¤ X`
* a ball `ball x r` roughly corresponds to `UniformSpace.ball x V := {y | (x, y) ā V}`
for some `V ā š¤ X`, but the later is more general (it includes in
particular both open and closed balls for suitable `V`).
In particular we have:
`isOpen_iff_ball_subset {s : Set X} : IsOpen s ā ā x ā s, ā V ā š¤ X, ball x V ā s`
The triangle inequality is abstracted to a statement involving the composition of relations in `X`.
First note that the triangle inequality in a metric space is equivalent to
`ā (x y z : X) (r r' : ā), dist x y ⤠r ā dist y z ⤠r' ā dist x z ⤠r + r'`.
Then, for any `V` and `W` with type `Set (X Ć X)`, the composition `V ā W : Set (X Ć X)` is
defined as `{ p : X Ć X | ā z, (p.1, z) ā V ā§ (z, p.2) ā W }`.
In the metric space case, if `V = { p | dist p.1 p.2 ⤠r }` and `W = { p | dist p.1 p.2 ⤠r' }`
then the triangle inequality, as reformulated above, says `V ā W` is contained in
`{p | dist p.1 p.2 ⤠r + r'}` which is the entourage associated to the radius `r + r'`.
In general we have `mem_ball_comp (h : y ā ball x V) (h' : z ā ball y W) : z ā ball x (V ā W)`.
Note that this discussion does not depend on any axiom imposed on the uniformity filter,
it is simply captured by the definition of composition.
The uniform space axioms ask the filter `š¤ X` to satisfy the following:
* every `V ā š¤ X` contains the diagonal `idRel = { p | p.1 = p.2 }`. This abstracts the fact
that `dist x x ⤠r` for every non-negative radius `r` in the metric space case and also that
`x - x` belongs to every neighborhood of zero in the topological group case.
* `V ā š¤ X ā Prod.swap '' V ā š¤ X`. This is tightly related the fact that `dist x y = dist y x`
in a metric space, and to continuity of negation in the topological group case.
* `ā V ā š¤ X, ā W ā š¤ X, W ā W ā V`. In the metric space case, it corresponds
to cutting the radius of a ball in half and applying the triangle inequality.
In the topological group case, it comes from continuity of addition at `(0, 0)`.
These three axioms are stated more abstractly in the definition below, in terms of
operations on filters, without directly manipulating entourages.
## Main definitions
* `UniformSpace X` is a uniform space structure on a type `X`
* `UniformContinuous f` is a predicate saying a function `f : α ā β` between uniform spaces
is uniformly continuous : `ā r ā š¤ β, āį¶ (x : α à α) in š¤ α, (f x.1, f x.2) ā r`
In this file we also define a complete lattice structure on the type `UniformSpace X`
of uniform structures on `X`, as well as the pullback (`UniformSpace.comap`) of uniform structures
coming from the pullback of filters.
Like distance functions, uniform structures cannot be pushed forward in general.
## Notations
Localized in `Uniformity`, we have the notation `š¤ X` for the uniformity on a uniform space `X`,
and `ā` for composition of relations, seen as terms with type `Set (X Ć X)`.
## Implementation notes
There is already a theory of relations in `Data/Rel.lean` where the main definition is
`def Rel (α β : Type*) := α ā β ā Prop`.
The relations used in the current file involve only one type, but this is not the reason why
we don't reuse `Data/Rel.lean`. We use `Set (α à α)`
instead of `Rel α α` because we really need sets to use the filter library, and elements
of filters on `α à α` have type `Set (α à α)`.
The structure `UniformSpace X` bundles a uniform structure on `X`, a topology on `X` and
an assumption saying those are compatible. This may not seem mathematically reasonable at first,
but is in fact an instance of the forgetful inheritance pattern. See Note [forgetful inheritance]
below.
## References
The formalization uses the books:
* [N. Bourbaki, *General Topology*][bourbaki1966]
* [I. M. James, *Topologies and Uniformities*][james1999]
But it makes a more systematic use of the filter library.
-/
open Set Filter Topology
universe u v ua ub uc ud
/-!
### Relations, seen as `Set (α à α)`
-/
variable {α : Type ua} {β : Type ub} {γ : Type uc} {Γ : Type ud} {ι : Sort*}
/-- The identity relation, or the graph of the identity function -/
def idRel {α : Type*} :=
{ p : α à α | p.1 = p.2 }
@[simp]
theorem mem_idRel {a b : α} : (a, b) ā @idRel α ā a = b :=
Iff.rfl
@[simp]
theorem idRel_subset {s : Set (α à α)} : idRel ā s ā ā a, (a, a) ā s := by
simp [subset_def]
/-- The composition of relations -/
def compRel (rā rā : Set (α à α)) :=
{ p : α à α | ā z : α, (p.1, z) ā rā ā§ (z, p.2) ā rā }
@[inherit_doc]
scoped[Uniformity] infixl:62 " ā " => compRel
open Uniformity
@[simp]
theorem mem_compRel {α : Type u} {rā rā : Set (α à α)} {x y : α} :
(x, y) ā rā ā rā ā ā z, (x, z) ā rā ā§ (z, y) ā rā :=
Iff.rfl
@[simp]
theorem swap_idRel : Prod.swap '' idRel = @idRel α :=
Set.ext fun āØa, bā© => by simpa [image_swap_eq_preimage_swap] using eq_comm
theorem Monotone.compRel [Preorder β] {f g : β ā Set (α à α)} (hf : Monotone f) (hg : Monotone g) :
Monotone fun x => f x ā g x := fun _ _ h _ āØz, hā, hāā© => āØz, hf h hā, hg h hāā©
@[mono, gcongr]
theorem compRel_mono {f g h k : Set (α à α)} (hā : f ā h) (hā : g ā k) : f ā g ā h ā k :=
fun _ āØz, h, h'ā© => āØz, hā h, hā h'ā©
theorem prod_mk_mem_compRel {a b c : α} {s t : Set (α à α)} (hā : (a, c) ā s) (hā : (c, b) ā t) :
(a, b) ā s ā t :=
āØc, hā, hāā©
@[simp]
theorem id_compRel {r : Set (α à α)} : idRel ā r = r :=
Set.ext fun āØa, bā© => by simp
theorem compRel_assoc {r s t : Set (α à α)} : r ā s ā t = r ā (s ā t) := by
ext āØa, bā©; simp only [mem_compRel]; tauto
theorem left_subset_compRel {s t : Set (α à α)} (h : idRel ā t) : s ā s ā t := fun āØ_x, yā© xy_in =>
āØy, xy_in, h <| rflā©
theorem right_subset_compRel {s t : Set (α à α)} (h : idRel ā s) : t ā s ā t := fun āØx, _yā© xy_in =>
āØx, h <| rfl, xy_inā©
theorem subset_comp_self {s : Set (α à α)} (h : idRel ā s) : s ā s ā s :=
left_subset_compRel h
theorem subset_iterate_compRel {s t : Set (α à α)} (h : idRel ā s) (n : ā) :
t ā (s ā Ā·)^[n] t := by
induction' n with n ihn generalizing t
exacts [Subset.rfl, (right_subset_compRel h).trans ihn]
/-- The relation is invariant under swapping factors. -/
def SymmetricRel (V : Set (α à α)) : Prop :=
Prod.swap ā»Ā¹' V = V
/-- The maximal symmetric relation contained in a given relation. -/
def symmetrizeRel (V : Set (α à α)) : Set (α à α) :=
V ā© Prod.swap ā»Ā¹' V
theorem symmetric_symmetrizeRel (V : Set (α à α)) : SymmetricRel (symmetrizeRel V) := by
simp [SymmetricRel, symmetrizeRel, preimage_inter, inter_comm, ā preimage_comp]
theorem symmetrizeRel_subset_self (V : Set (α à α)) : symmetrizeRel V ā V :=
sep_subset _ _
@[mono]
theorem symmetrize_mono {V W : Set (α à α)} (h : V ā W) : symmetrizeRel V ā symmetrizeRel W :=
inter_subset_inter h <| preimage_mono h
theorem SymmetricRel.mk_mem_comm {V : Set (α à α)} (hV : SymmetricRel V) {x y : α} :
(x, y) ā V ā (y, x) ā V :=
Set.ext_iff.1 hV (y, x)
theorem SymmetricRel.eq {U : Set (α à α)} (hU : SymmetricRel U) : Prod.swap ā»Ā¹' U = U :=
hU
theorem SymmetricRel.inter {U V : Set (α à α)} (hU : SymmetricRel U) (hV : SymmetricRel V) :
SymmetricRel (U ā© V) := by rw [SymmetricRel, preimage_inter, hU.eq, hV.eq]
/-- This core description of a uniform space is outside of the type class hierarchy. It is useful
for constructions of uniform spaces, when the topology is derived from the uniform space. -/
structure UniformSpace.Core (α : Type u) where
/-- The uniformity filter. Once `UniformSpace` is defined, `š¤ α` (`_root_.uniformity`) becomes the
normal form. -/
uniformity : Filter (α à α)
/-- Every set in the uniformity filter includes the diagonal. -/
refl : š idRel ⤠uniformity
/-- If `s ā uniformity`, then `Prod.swap ā»Ā¹' s ā uniformity`. -/
symm : Tendsto Prod.swap uniformity uniformity
/-- For every set `u ā uniformity`, there exists `v ā uniformity` such that `v ā v ā u`. -/
comp : (uniformity.lift' fun s => s ā s) ⤠uniformity
protected theorem UniformSpace.Core.comp_mem_uniformity_sets {c : Core α} {s : Set (α à α)}
(hs : s ā c.uniformity) : ā t ā c.uniformity, t ā t ā s :=
(mem_lift'_sets <| monotone_id.compRel monotone_id).mp <| c.comp hs
/-- An alternative constructor for `UniformSpace.Core`. This version unfolds various
`Filter`-related definitions. -/
def UniformSpace.Core.mk' {α : Type u} (U : Filter (α à α)) (refl : ā r ā U, ā (x), (x, x) ā r)
(symm : ā r ā U, Prod.swap ā»Ā¹' r ā U) (comp : ā r ā U, ā t ā U, t ā t ā r) :
UniformSpace.Core α :=
āØU, fun _r ru => idRel_subset.2 (refl _ ru), symm, fun _r ru =>
let āØ_s, hs, hsrā© := comp _ ru
mem_of_superset (mem_lift' hs) hsrā©
/-- Defining a `UniformSpace.Core` from a filter basis satisfying some uniformity-like axioms. -/
def UniformSpace.Core.mkOfBasis {α : Type u} (B : FilterBasis (α à α))
(refl : ā r ā B, ā (x), (x, x) ā r) (symm : ā r ā B, ā t ā B, t ā Prod.swap ā»Ā¹' r)
(comp : ā r ā B, ā t ā B, t ā t ā r) : UniformSpace.Core α where
uniformity := B.filter
refl := B.hasBasis.ge_iff.mpr fun _r ru => idRel_subset.2 <| refl _ ru
symm := (B.hasBasis.tendsto_iff B.hasBasis).mpr symm
comp := (HasBasis.le_basis_iff (B.hasBasis.lift' (monotone_id.compRel monotone_id))
B.hasBasis).2 comp
/-- A uniform space generates a topological space -/
def UniformSpace.Core.toTopologicalSpace {α : Type u} (u : UniformSpace.Core α) :
TopologicalSpace α :=
.mkOfNhds fun x ⦠.comap (Prod.mk x) u.uniformity
theorem UniformSpace.Core.ext :
ā {uā uā : UniformSpace.Core α}, uā.uniformity = uā.uniformity ā uā = uā
| āØ_, _, _, _ā©, āØ_, _, _, _ā©, rfl => rfl
theorem UniformSpace.Core.nhds_toTopologicalSpace {α : Type u} (u : Core α) (x : α) :
@nhds α u.toTopologicalSpace x = comap (Prod.mk x) u.uniformity := by
apply TopologicalSpace.nhds_mkOfNhds_of_hasBasis (fun _ ⦠(basis_sets _).comap _)
· exact fun a U hU ⦠u.refl hU rfl
Ā· intro a U hU
rcases u.comp_mem_uniformity_sets hU with āØV, hV, hVUā©
filter_upwards [preimage_mem_comap hV] with b hb
filter_upwards [preimage_mem_comap hV] with c hc
exact hVU āØb, hb, hcā©
-- the topological structure is embedded in the uniform structure
-- to avoid instance diamond issues. See Note [forgetful inheritance].
/-- A uniform space is a generalization of the "uniform" topological aspects of a
metric space. It consists of a filter on `α à α` called the "uniformity", which
satisfies properties analogous to the reflexivity, symmetry, and triangle properties
of a metric.
A metric space has a natural uniformity, and a uniform space has a natural topology.
A topological group also has a natural uniformity, even when it is not metrizable. -/
class UniformSpace (α : Type u) extends TopologicalSpace α where
/-- The uniformity filter. -/
protected uniformity : Filter (α à α)
/-- If `s ā uniformity`, then `Prod.swap ā»Ā¹' s ā uniformity`. -/
protected symm : Tendsto Prod.swap uniformity uniformity
/-- For every set `u ā uniformity`, there exists `v ā uniformity` such that `v ā v ā u`. -/
protected comp : (uniformity.lift' fun s => s ā s) ⤠uniformity
/-- The uniformity agrees with the topology: the neighborhoods filter of each point `x`
is equal to `Filter.comap (Prod.mk x) (š¤ α)`. -/
protected nhds_eq_comap_uniformity (x : α) : š x = comap (Prod.mk x) uniformity
/-- The uniformity is a filter on α à α (inferred from an ambient uniform space
structure on α). -/
def uniformity (α : Type u) [UniformSpace α] : Filter (α à α) :=
@UniformSpace.uniformity α _
/-- Notation for the uniformity filter with respect to a non-standard `UniformSpace` instance. -/
scoped[Uniformity] notation "š¤[" u "]" => @uniformity _ u
@[inherit_doc] -- Porting note (#11215): TODO: should we drop the `uniformity` def?
scoped[Uniformity] notation "š¤" => uniformity
/-- Construct a `UniformSpace` from a `u : UniformSpace.Core` and a `TopologicalSpace` structure
that is equal to `u.toTopologicalSpace`. -/
abbrev UniformSpace.ofCoreEq {α : Type u} (u : UniformSpace.Core α) (t : TopologicalSpace α)
(h : t = u.toTopologicalSpace) : UniformSpace α where
__ := u
toTopologicalSpace := t
nhds_eq_comap_uniformity x := by rw [h, u.nhds_toTopologicalSpace]
/-- Construct a `UniformSpace` from a `UniformSpace.Core`. -/
abbrev UniformSpace.ofCore {α : Type u} (u : UniformSpace.Core α) : UniformSpace α :=
.ofCoreEq u _ rfl
/-- Construct a `UniformSpace.Core` from a `UniformSpace`. -/
abbrev UniformSpace.toCore (u : UniformSpace α) : UniformSpace.Core α where
__ := u
refl := by
rintro U hU āØx, yā© (rfl : x = y)
have : Prod.mk x ā»Ā¹' U ā š x := by
rw [UniformSpace.nhds_eq_comap_uniformity]
exact preimage_mem_comap hU
convert mem_of_mem_nhds this
theorem UniformSpace.toCore_toTopologicalSpace (u : UniformSpace α) :
u.toCore.toTopologicalSpace = u.toTopologicalSpace :=
TopologicalSpace.ext_nhds fun a ⦠by
rw [u.nhds_eq_comap_uniformity, u.toCore.nhds_toTopologicalSpace]
/-- Build a `UniformSpace` from a `UniformSpace.Core` and a compatible topology.
Use `UniformSpace.mk` instead to avoid proving
the unnecessary assumption `UniformSpace.Core.refl`.
The main constructor used to use a different compatibility assumption.
This definition was created as a step towards porting to a new definition.
Now the main definition is ported,
so this constructor will be removed in a few months. -/
@[deprecated UniformSpace.mk (since := "2024-03-20")]
def UniformSpace.ofNhdsEqComap (u : UniformSpace.Core α) (_t : TopologicalSpace α)
(h : ā x, š x = u.uniformity.comap (Prod.mk x)) : UniformSpace α where
__ := u
nhds_eq_comap_uniformity := h
@[ext (iff := false)]
protected theorem UniformSpace.ext {uā uā : UniformSpace α} (h : š¤[uā] = š¤[uā]) : uā = uā := by
have : uā.toTopologicalSpace = uā.toTopologicalSpace := TopologicalSpace.ext_nhds fun x ⦠by
rw [uā.nhds_eq_comap_uniformity, uā.nhds_eq_comap_uniformity]
exact congr_arg (comap _) h
cases uā; cases uā; congr
protected theorem UniformSpace.ext_iff {uā uā : UniformSpace α} :
uā = uā ā ā s, s ā š¤[uā] ā s ā š¤[uā] :=
āØfun h _ => h āø Iff.rfl, fun h => by ext; exact h _ā©
theorem UniformSpace.ofCoreEq_toCore (u : UniformSpace α) (t : TopologicalSpace α)
(h : t = u.toCore.toTopologicalSpace) : .ofCoreEq u.toCore t h = u :=
UniformSpace.ext rfl
/-- Replace topology in a `UniformSpace` instance with a propositionally (but possibly not
definitionally) equal one. -/
abbrev UniformSpace.replaceTopology {α : Type*} [i : TopologicalSpace α] (u : UniformSpace α)
(h : i = u.toTopologicalSpace) : UniformSpace α where
__ := u
toTopologicalSpace := i
nhds_eq_comap_uniformity x := by rw [h, u.nhds_eq_comap_uniformity]
theorem UniformSpace.replaceTopology_eq {α : Type*} [i : TopologicalSpace α] (u : UniformSpace α)
(h : i = u.toTopologicalSpace) : u.replaceTopology h = u :=
UniformSpace.ext rfl
-- Porting note: rfc: use `UniformSpace.Core.mkOfBasis`? This will change defeq here and there
/-- Define a `UniformSpace` using a "distance" function. The function can be, e.g., the
distance in a (usual or extended) metric space or an absolute value on a ring. -/
def UniformSpace.ofFun {α : Type u} {β : Type v} [OrderedAddCommMonoid β]
(d : α ā α ā β) (refl : ā x, d x x = 0) (symm : ā x y, d x y = d y x)
(triangle : ā x y z, d x z ⤠d x y + d y z)
(half : ā ε > (0 : β), ā Ī“ > (0 : β), ā x < Ī“, ā y < Ī“, x + y < ε) :
UniformSpace α :=
.ofCore
{ uniformity := āØ
r > 0, š { x | d x.1 x.2 < r }
refl := le_iInfā fun r hr => principal_mono.2 <| idRel_subset.2 fun x => by simpa [refl]
symm := tendsto_iInf_iInf fun r => tendsto_iInf_iInf fun _ => tendsto_principal_principal.2
fun x hx => by rwa [mem_setOf, symm]
comp := le_iInfā fun r hr => let āØĪ“, h0, hĪ“rā© := half r hr; le_principal_iff.2 <|
mem_of_superset
(mem_lift' <| mem_iInf_of_mem Ī“ <| mem_iInf_of_mem h0 <| mem_principal_self _)
fun (x, z) āØy, hā, hāā© => (triangle _ _ _).trans_lt (hĪ“r _ hā _ hā) }
theorem UniformSpace.hasBasis_ofFun {α : Type u} {β : Type v} [LinearOrderedAddCommMonoid β]
(hā : ā x : β, 0 < x) (d : α ā α ā β) (refl : ā x, d x x = 0) (symm : ā x y, d x y = d y x)
(triangle : ā x y z, d x z ⤠d x y + d y z)
(half : ā ε > (0 : β), ā Ī“ > (0 : β), ā x < Ī“, ā y < Ī“, x + y < ε) :
š¤[.ofFun d refl symm triangle half].HasBasis ((0 : β) < Ā·) (fun ε => { x | d x.1 x.2 < ε }) :=
hasBasis_biInf_principal'
(fun εā hā εā hā => āØmin εā εā, lt_min hā hā, fun _x hx => lt_of_lt_of_le hx (min_le_left _ _),
fun _x hx => lt_of_lt_of_le hx (min_le_right _ _)ā©) hā
section UniformSpace
variable [UniformSpace α]
theorem nhds_eq_comap_uniformity {x : α} : š x = (š¤ α).comap (Prod.mk x) :=
UniformSpace.nhds_eq_comap_uniformity x
theorem isOpen_uniformity {s : Set α} :
IsOpen s ā ā x ā s, { p : α à α | p.1 = x ā p.2 ā s } ā š¤ α := by
simp only [isOpen_iff_mem_nhds, nhds_eq_comap_uniformity, mem_comap_prod_mk]
theorem refl_le_uniformity : š idRel ⤠š¤ α :=
(@UniformSpace.toCore α _).refl
instance uniformity.neBot [Nonempty α] : NeBot (š¤ α) :=
diagonal_nonempty.principal_neBot.mono refl_le_uniformity
theorem refl_mem_uniformity {x : α} {s : Set (α à α)} (h : s ā š¤ α) : (x, x) ā s :=
refl_le_uniformity h rfl
theorem mem_uniformity_of_eq {x y : α} {s : Set (α à α)} (h : s ā š¤ α) (hx : x = y) : (x, y) ā s :=
refl_le_uniformity h hx
theorem symm_le_uniformity : map (@Prod.swap α α) (š¤ _) ⤠š¤ _ :=
UniformSpace.symm
theorem comp_le_uniformity : ((š¤ α).lift' fun s : Set (α à α) => s ā s) ⤠š¤ α :=
UniformSpace.comp
theorem lift'_comp_uniformity : ((š¤ α).lift' fun s : Set (α à α) => s ā s) = š¤ α :=
comp_le_uniformity.antisymm <| le_lift'.2 fun _s hs ⦠mem_of_superset hs <|
subset_comp_self <| idRel_subset.2 fun _ ⦠refl_mem_uniformity hs
theorem tendsto_swap_uniformity : Tendsto (@Prod.swap α α) (š¤ α) (š¤ α) :=
symm_le_uniformity
theorem comp_mem_uniformity_sets {s : Set (α à α)} (hs : s ā š¤ α) : ā t ā š¤ α, t ā t ā s :=
(mem_lift'_sets <| monotone_id.compRel monotone_id).mp <| comp_le_uniformity hs
/-- If `s ā š¤ α`, then for any natural `n`, for a subset `t` of a sufficiently small set in `š¤ α`,
we have `t ā t ā ... ā t ā s` (`n` compositions). -/
theorem eventually_uniformity_iterate_comp_subset {s : Set (α à α)} (hs : s ā š¤ α) (n : ā) :
āį¶ t in (š¤ α).smallSets, (t ā Ā·)^[n] t ā s := by
suffices āį¶ t in (š¤ α).smallSets, t ā s ā§ (t ā Ā·)^[n] t ā s from (eventually_and.1 this).2
induction' n with n ihn generalizing s
Ā· simpa
rcases comp_mem_uniformity_sets hs with āØt, htU, htsā©
refine (ihn htU).mono fun U hU => ?_
rw [Function.iterate_succ_apply']
exact
āØhU.1.trans <| (subset_comp_self <| refl_le_uniformity htU).trans hts,
(compRel_mono hU.1 hU.2).trans htsā©
/-- If `s ā š¤ α`, then for a subset `t` of a sufficiently small set in `š¤ α`,
we have `t ā t ā s`. -/
theorem eventually_uniformity_comp_subset {s : Set (α à α)} (hs : s ā š¤ α) :
āį¶ t in (š¤ α).smallSets, t ā t ā s :=
eventually_uniformity_iterate_comp_subset hs 1
/-- Relation `fun f g ⦠Tendsto (fun x ⦠(f x, g x)) l (š¤ α)` is transitive. -/
theorem Filter.Tendsto.uniformity_trans {l : Filter β} {fā fā fā : β ā α}
(hāā : Tendsto (fun x => (fā x, fā x)) l (š¤ α))
(hāā : Tendsto (fun x => (fā x, fā x)) l (š¤ α)) : Tendsto (fun x => (fā x, fā x)) l (š¤ α) := by
refine le_trans (le_lift'.2 fun s hs => mem_map.2 ?_) comp_le_uniformity
filter_upwards [mem_map.1 (hāā hs), mem_map.1 (hāā hs)] with x hxāā hxāā using āØ_, hxāā, hxāāā©
/-- Relation `fun f g ⦠Tendsto (fun x ⦠(f x, g x)) l (š¤ α)` is symmetric. -/
theorem Filter.Tendsto.uniformity_symm {l : Filter β} {f : β ā α à α} (h : Tendsto f l (š¤ α)) :
Tendsto (fun x => ((f x).2, (f x).1)) l (š¤ α) :=
tendsto_swap_uniformity.comp h
/-- Relation `fun f g ⦠Tendsto (fun x ⦠(f x, g x)) l (š¤ α)` is reflexive. -/
theorem tendsto_diag_uniformity (f : β ā α) (l : Filter β) :
Tendsto (fun x => (f x, f x)) l (š¤ α) := fun _s hs =>
mem_map.2 <| univ_mem' fun _ => refl_mem_uniformity hs
theorem tendsto_const_uniformity {a : α} {f : Filter β} : Tendsto (fun _ => (a, a)) f (š¤ α) :=
tendsto_diag_uniformity (fun _ => a) f
theorem symm_of_uniformity {s : Set (α à α)} (hs : s ā š¤ α) :
ā t ā š¤ α, (ā a b, (a, b) ā t ā (b, a) ā t) ā§ t ā s :=
have : preimage Prod.swap s ā š¤ α := symm_le_uniformity hs
āØs ā© preimage Prod.swap s, inter_mem hs this, fun _ _ āØhā, hāā© => āØhā, hāā©, inter_subset_leftā©
theorem comp_symm_of_uniformity {s : Set (α à α)} (hs : s ā š¤ α) :
ā t ā š¤ α, (ā {a b}, (a, b) ā t ā (b, a) ā t) ā§ t ā t ā s :=
let āØ_t, htā, htāā© := comp_mem_uniformity_sets hs
let āØt', ht', ht'ā, ht'āā© := symm_of_uniformity htā
āØt', ht', ht'ā _ _, Subset.trans (monotone_id.compRel monotone_id ht'ā) htāā©
theorem uniformity_le_symm : š¤ α ⤠@Prod.swap α α <$> š¤ α := by
rw [map_swap_eq_comap_swap]; exact tendsto_swap_uniformity.le_comap
theorem uniformity_eq_symm : š¤ α = @Prod.swap α α <$> š¤ α :=
le_antisymm uniformity_le_symm symm_le_uniformity
@[simp]
theorem comap_swap_uniformity : comap (@Prod.swap α α) (š¤ α) = š¤ α :=
(congr_arg _ uniformity_eq_symm).trans <| comap_map Prod.swap_injective
theorem symmetrize_mem_uniformity {V : Set (α à α)} (h : V ā š¤ α) : symmetrizeRel V ā š¤ α := by
apply (š¤ α).inter_sets h
rw [ā image_swap_eq_preimage_swap, uniformity_eq_symm]
exact image_mem_map h
/-- Symmetric entourages form a basis of `š¤ α` -/
theorem UniformSpace.hasBasis_symmetric :
(š¤ α).HasBasis (fun s : Set (α à α) => s ā š¤ α ā§ SymmetricRel s) id :=
hasBasis_self.2 fun t t_in =>
āØsymmetrizeRel t, symmetrize_mem_uniformity t_in, symmetric_symmetrizeRel t,
symmetrizeRel_subset_self tā©
theorem uniformity_lift_le_swap {g : Set (α à α) ā Filter β} {f : Filter β} (hg : Monotone g)
(h : ((š¤ α).lift fun s => g (preimage Prod.swap s)) ⤠f) : (š¤ α).lift g ⤠f :=
calc
(š¤ α).lift g ⤠(Filter.map (@Prod.swap α α) <| š¤ α).lift g :=
lift_mono uniformity_le_symm le_rfl
_ ⤠_ := by rw [map_lift_eq2 hg, image_swap_eq_preimage_swap]; exact h
theorem uniformity_lift_le_comp {f : Set (α à α) ā Filter β} (h : Monotone f) :
((š¤ α).lift fun s => f (s ā s)) ⤠(š¤ α).lift f :=
calc
((š¤ α).lift fun s => f (s ā s)) = ((š¤ α).lift' fun s : Set (α à α) => s ā s).lift f := by
rw [lift_lift'_assoc]
Ā· exact monotone_id.compRel monotone_id
Ā· exact h
_ ⤠(š¤ α).lift f := lift_mono comp_le_uniformity le_rfl
theorem comp3_mem_uniformity {s : Set (α à α)} (hs : s ā š¤ α) : ā t ā š¤ α, t ā (t ā t) ā s :=
let āØ_t', ht', ht'sā© := comp_mem_uniformity_sets hs
let āØt, ht, htt'ā© := comp_mem_uniformity_sets ht'
āØt, ht, (compRel_mono ((subset_comp_self (refl_le_uniformity ht)).trans htt') htt').trans ht'sā©
/-- See also `comp3_mem_uniformity`. -/
theorem comp_le_uniformity3 : ((š¤ α).lift' fun s : Set (α à α) => s ā (s ā s)) ⤠š¤ α := fun _ h =>
let āØ_t, htU, htā© := comp3_mem_uniformity h
mem_of_superset (mem_lift' htU) ht
/-- See also `comp_open_symm_mem_uniformity_sets`. -/
theorem comp_symm_mem_uniformity_sets {s : Set (α à α)} (hs : s ā š¤ α) :
ā t ā š¤ α, SymmetricRel t ā§ t ā t ā s := by
obtain āØw, w_in, w_subā© : ā w ā š¤ α, w ā w ā s := comp_mem_uniformity_sets hs
use symmetrizeRel w, symmetrize_mem_uniformity w_in, symmetric_symmetrizeRel w
have : symmetrizeRel w ā w := symmetrizeRel_subset_self w
calc symmetrizeRel w ā symmetrizeRel w
_ ā w ā w := by gcongr
_ ā s := w_sub
theorem subset_comp_self_of_mem_uniformity {s : Set (α à α)} (h : s ā š¤ α) : s ā s ā s :=
subset_comp_self (refl_le_uniformity h)
theorem comp_comp_symm_mem_uniformity_sets {s : Set (α à α)} (hs : s ā š¤ α) :
ā t ā š¤ α, SymmetricRel t ā§ t ā t ā t ā s := by
rcases comp_symm_mem_uniformity_sets hs with āØw, w_in, _, w_subā©
rcases comp_symm_mem_uniformity_sets w_in with āØt, t_in, t_symm, t_subā©
use t, t_in, t_symm
have : t ā t ā t := subset_comp_self_of_mem_uniformity t_in
-- Porting note: Needed the following `have`s to make `mono` work
have ht := Subset.refl t
have hw := Subset.refl w
calc
t ā t ā t ā w ā t := by mono
_ ā w ā (t ā t) := by mono
_ ā w ā w := by mono
_ ā s := w_sub
/-!
### Balls in uniform spaces
-/
/-- The ball around `(x : β)` with respect to `(V : Set (β à β))`. Intended to be
used for `V ā š¤ β`, but this is not needed for the definition. Recovers the
notions of metric space ball when `V = {p | dist p.1 p.2 < r }`. -/
def UniformSpace.ball (x : β) (V : Set (β à β)) : Set β :=
Prod.mk x ā»Ā¹' V
open UniformSpace (ball)
theorem UniformSpace.mem_ball_self (x : α) {V : Set (α à α)} (hV : V ā š¤ α) : x ā ball x V :=
refl_mem_uniformity hV
/-- The triangle inequality for `UniformSpace.ball` -/
theorem mem_ball_comp {V W : Set (β à β)} {x y z} (h : y ā ball x V) (h' : z ā ball y W) :
z ā ball x (V ā W) :=
prod_mk_mem_compRel h h'
theorem ball_subset_of_comp_subset {V W : Set (β à β)} {x y} (h : x ā ball y W) (h' : W ā W ā V) :
ball x W ā ball y V := fun _z z_in => h' (mem_ball_comp h z_in)
theorem ball_mono {V W : Set (β à β)} (h : V ā W) (x : β) : ball x V ā ball x W :=
preimage_mono h
theorem ball_inter (x : β) (V W : Set (β à β)) : ball x (V ⩠W) = ball x V ⩠ball x W :=
preimage_inter
theorem ball_inter_left (x : β) (V W : Set (β à β)) : ball x (V ā© W) ā ball x V :=
ball_mono inter_subset_left x
theorem ball_inter_right (x : β) (V W : Set (β à β)) : ball x (V ā© W) ā ball x W :=
ball_mono inter_subset_right x
theorem mem_ball_symmetry {V : Set (β à β)} (hV : SymmetricRel V) {x y} :
x ā ball y V ā y ā ball x V :=
show (x, y) ā Prod.swap ā»Ā¹' V ā (x, y) ā V by
unfold SymmetricRel at hV
rw [hV]
theorem ball_eq_of_symmetry {V : Set (β à β)} (hV : SymmetricRel V) {x} :
ball x V = { y | (y, x) ā V } := by
ext y
rw [mem_ball_symmetry hV]
exact Iff.rfl
theorem mem_comp_of_mem_ball {V W : Set (β à β)} {x y z : β} (hV : SymmetricRel V)
(hx : x ā ball z V) (hy : y ā ball z W) : (x, y) ā V ā W := by
rw [mem_ball_symmetry hV] at hx
exact āØz, hx, hyā©
theorem UniformSpace.isOpen_ball (x : α) {V : Set (α à α)} (hV : IsOpen V) : IsOpen (ball x V) :=
hV.preimage <| continuous_const.prod_mk continuous_id
theorem UniformSpace.isClosed_ball (x : α) {V : Set (α à α)} (hV : IsClosed V) :
IsClosed (ball x V) :=
hV.preimage <| continuous_const.prod_mk continuous_id
theorem mem_comp_comp {V W M : Set (β à β)} (hW' : SymmetricRel W) {p : β à β} :
p ā V ā M ā W ā (ball p.1 V ĆĖ¢ ball p.2 W ā© M).Nonempty := by
cases' p with x y
constructor
Ā· rintro āØz, āØw, hpw, hwzā©, hzyā©
exact āØ(w, z), āØhpw, by rwa [mem_ball_symmetry hW']ā©, hwzā©
Ā· rintro āØāØw, zā©, āØw_in, z_inā©, hwzā©
rw [mem_ball_symmetry hW'] at z_in
exact āØz, āØw, w_in, hwzā©, z_inā©
/-!
### Neighborhoods in uniform spaces
-/
theorem mem_nhds_uniformity_iff_right {x : α} {s : Set α} :
s ā š x ā { p : α à α | p.1 = x ā p.2 ā s } ā š¤ α := by
simp only [nhds_eq_comap_uniformity, mem_comap_prod_mk]
theorem mem_nhds_uniformity_iff_left {x : α} {s : Set α} :
s ā š x ā { p : α à α | p.2 = x ā p.1 ā s } ā š¤ α := by
rw [uniformity_eq_symm, mem_nhds_uniformity_iff_right]
simp only [map_def, mem_map, preimage_setOf_eq, Prod.snd_swap, Prod.fst_swap]
theorem nhdsWithin_eq_comap_uniformity_of_mem {x : α} {T : Set α} (hx : x ā T) (S : Set α) :
š[S] x = (š¤ α ā š (T ĆĖ¢ S)).comap (Prod.mk x) := by
simp [nhdsWithin, nhds_eq_comap_uniformity, hx]
theorem nhdsWithin_eq_comap_uniformity {x : α} (S : Set α) :
š[S] x = (š¤ α ā š (univ ĆĖ¢ S)).comap (Prod.mk x) :=
nhdsWithin_eq_comap_uniformity_of_mem (mem_univ _) S
/-- See also `isOpen_iff_open_ball_subset`. -/
theorem isOpen_iff_ball_subset {s : Set α} : IsOpen s ā ā x ā s, ā V ā š¤ α, ball x V ā s := by
simp_rw [isOpen_iff_mem_nhds, nhds_eq_comap_uniformity, mem_comap, ball]
theorem nhds_basis_uniformity' {p : ι ā Prop} {s : ι ā Set (α à α)} (h : (š¤ α).HasBasis p s)
{x : α} : (š x).HasBasis p fun i => ball x (s i) := by
rw [nhds_eq_comap_uniformity]
exact h.comap (Prod.mk x)
theorem nhds_basis_uniformity {p : ι ā Prop} {s : ι ā Set (α à α)} (h : (š¤ α).HasBasis p s)
{x : α} : (š x).HasBasis p fun i => { y | (y, x) ā s i } := by
replace h := h.comap Prod.swap
rw [comap_swap_uniformity] at h
exact nhds_basis_uniformity' h
theorem nhds_eq_comap_uniformity' {x : α} : š x = (š¤ α).comap fun y => (y, x) :=
(nhds_basis_uniformity (š¤ α).basis_sets).eq_of_same_basis <| (š¤ α).basis_sets.comap _
theorem UniformSpace.mem_nhds_iff {x : α} {s : Set α} : s ā š x ā ā V ā š¤ α, ball x V ā s := by
rw [nhds_eq_comap_uniformity, mem_comap]
simp_rw [ball]
theorem UniformSpace.ball_mem_nhds (x : α) ā¦V : Set (α à α)⦠(V_in : V ā š¤ α) : ball x V ā š x := by
rw [UniformSpace.mem_nhds_iff]
exact āØV, V_in, Subset.rflā©
theorem UniformSpace.ball_mem_nhdsWithin {x : α} {S : Set α} ā¦V : Set (α à α)⦠(x_in : x ā S)
(V_in : V ā š¤ α ā š (S ĆĖ¢ S)) : ball x V ā š[S] x := by
rw [nhdsWithin_eq_comap_uniformity_of_mem x_in, mem_comap]
exact āØV, V_in, Subset.rflā©
theorem UniformSpace.mem_nhds_iff_symm {x : α} {s : Set α} :
s ā š x ā ā V ā š¤ α, SymmetricRel V ā§ ball x V ā s := by
rw [UniformSpace.mem_nhds_iff]
constructor
Ā· rintro āØV, V_in, V_subā©
use symmetrizeRel V, symmetrize_mem_uniformity V_in, symmetric_symmetrizeRel V
exact Subset.trans (ball_mono (symmetrizeRel_subset_self V) x) V_sub
Ā· rintro āØV, V_in, _, V_subā©
exact āØV, V_in, V_subā©
theorem UniformSpace.hasBasis_nhds (x : α) :
HasBasis (š x) (fun s : Set (α à α) => s ā š¤ α ā§ SymmetricRel s) fun s => ball x s :=
āØfun t => by simp [UniformSpace.mem_nhds_iff_symm, and_assoc]ā©
open UniformSpace
theorem UniformSpace.mem_closure_iff_symm_ball {s : Set α} {x} :
x ā closure s ā ā {V}, V ā š¤ α ā SymmetricRel V ā (s ā© ball x V).Nonempty := by
simp [mem_closure_iff_nhds_basis (hasBasis_nhds x), Set.Nonempty]
theorem UniformSpace.mem_closure_iff_ball {s : Set α} {x} :
x ā closure s ā ā {V}, V ā š¤ α ā (ball x V ā© s).Nonempty := by
simp [mem_closure_iff_nhds_basis' (nhds_basis_uniformity' (š¤ α).basis_sets)]
theorem UniformSpace.hasBasis_nhds_prod (x y : α) :
HasBasis (š (x, y)) (fun s => s ā š¤ α ā§ SymmetricRel s) fun s => ball x s ĆĖ¢ ball y s := by
rw [nhds_prod_eq]
apply (hasBasis_nhds x).prod_same_index (hasBasis_nhds y)
rintro U V āØU_in, U_symmā© āØV_in, V_symmā©
exact
āØU ā© V, āØ(š¤ α).inter_sets U_in V_in, U_symm.inter V_symmā©, ball_inter_left x U V,
ball_inter_right y U Vā©
theorem nhds_eq_uniformity {x : α} : š x = (š¤ α).lift' (ball x) :=
(nhds_basis_uniformity' (š¤ α).basis_sets).eq_biInf
theorem nhds_eq_uniformity' {x : α} : š x = (š¤ α).lift' fun s => { y | (y, x) ā s } :=
(nhds_basis_uniformity (š¤ α).basis_sets).eq_biInf
theorem mem_nhds_left (x : α) {s : Set (α à α)} (h : s ā š¤ α) : { y : α | (x, y) ā s } ā š x :=
ball_mem_nhds x h
theorem mem_nhds_right (y : α) {s : Set (α à α)} (h : s ā š¤ α) : { x : α | (x, y) ā s } ā š y :=
mem_nhds_left _ (symm_le_uniformity h)
theorem exists_mem_nhds_ball_subset_of_mem_nhds {a : α} {U : Set α} (h : U ā š a) :
ā V ā š a, ā t ā š¤ α, ā a' ā V, UniformSpace.ball a' t ā U :=
let āØt, ht, htUā© := comp_mem_uniformity_sets (mem_nhds_uniformity_iff_right.1 h)
āØ_, mem_nhds_left a ht, t, ht, fun aā hā aā hā => @htU (a, aā) āØaā, hā, hāā© rflā©
theorem tendsto_right_nhds_uniformity {a : α} : Tendsto (fun a' => (a', a)) (š a) (š¤ α) := fun _ =>
mem_nhds_right a
theorem tendsto_left_nhds_uniformity {a : α} : Tendsto (fun a' => (a, a')) (š a) (š¤ α) := fun _ =>
mem_nhds_left a
theorem lift_nhds_left {x : α} {g : Set α ā Filter β} (hg : Monotone g) :
(š x).lift g = (š¤ α).lift fun s : Set (α à α) => g (ball x s) := by
rw [nhds_eq_comap_uniformity, comap_lift_eq2 hg]
simp_rw [ball, Function.comp]
theorem lift_nhds_right {x : α} {g : Set α ā Filter β} (hg : Monotone g) :
(š x).lift g = (š¤ α).lift fun s : Set (α à α) => g { y | (y, x) ā s } := by
rw [nhds_eq_comap_uniformity', comap_lift_eq2 hg]
simp_rw [Function.comp, preimage]
theorem nhds_nhds_eq_uniformity_uniformity_prod {a b : α} :
š a ĆĖ¢ š b = (š¤ α).lift fun s : Set (α à α) =>
(š¤ α).lift' fun t => { y : α | (y, a) ā s } ĆĖ¢ { y : α | (b, y) ā t } := by
rw [nhds_eq_uniformity', nhds_eq_uniformity, prod_lift'_lift']
exacts [rfl, monotone_preimage, monotone_preimage]
theorem nhds_eq_uniformity_prod {a b : α} :
š (a, b) =
(š¤ α).lift' fun s : Set (α à α) => { y : α | (y, a) ā s } ĆĖ¢ { y : α | (b, y) ā s } := by
rw [nhds_prod_eq, nhds_nhds_eq_uniformity_uniformity_prod, lift_lift'_same_eq_lift']
Ā· exact fun s => monotone_const.set_prod monotone_preimage
Ā· refine fun t => Monotone.set_prod ?_ monotone_const
exact monotone_preimage (f := fun y => (y, a))
theorem nhdset_of_mem_uniformity {d : Set (α à α)} (s : Set (α à α)) (hd : d ā š¤ α) :
ā t : Set (α à α), IsOpen t ā§ s ā t ā§
t ā { p | ā x y, (p.1, x) ā d ā§ (x, y) ā s ā§ (y, p.2) ā d } := by
let cl_d := { p : α à α | ā x y, (p.1, x) ā d ā§ (x, y) ā s ā§ (y, p.2) ā d }
have : ā p ā s, ā t, t ā cl_d ā§ IsOpen t ā§ p ā t := fun āØx, yā© hp =>
mem_nhds_iff.mp <|
show cl_d ā š (x, y) by
rw [nhds_eq_uniformity_prod, mem_lift'_sets]
Ā· exact āØd, hd, fun āØa, bā© āØha, hbā© => āØx, y, ha, hp, hbā©ā©
Ā· exact fun _ _ h _ h' => āØh h'.1, h h'.2ā©
choose t ht using this
exact āØ(ā p : α à α, ā h : p ā s, t p h : Set (α à α)),
isOpen_iUnion fun p : α à α => isOpen_iUnion fun hp => (ht p hp).right.left,
fun āØa, bā© hp => by
simp only [mem_iUnion, Prod.exists]; exact āØa, b, hp, (ht (a, b) hp).right.rightā©,
iUnion_subset fun p => iUnion_subset fun hp => (ht p hp).leftā©
/-- Entourages are neighborhoods of the diagonal. -/
theorem nhds_le_uniformity (x : α) : š (x, x) ⤠š¤ α := by
intro V V_in
rcases comp_symm_mem_uniformity_sets V_in with āØw, w_in, w_symm, w_subā©
have : ball x w ĆĖ¢ ball x w ā š (x, x) := by
rw [nhds_prod_eq]
exact prod_mem_prod (ball_mem_nhds x w_in) (ball_mem_nhds x w_in)
apply mem_of_superset this
rintro āØu, vā© āØu_in, v_inā©
exact w_sub (mem_comp_of_mem_ball w_symm u_in v_in)
/-- Entourages are neighborhoods of the diagonal. -/
theorem iSup_nhds_le_uniformity : ⨠x : α, š (x, x) ⤠š¤ α :=
iSup_le nhds_le_uniformity
/-- Entourages are neighborhoods of the diagonal. -/
theorem nhdsSet_diagonal_le_uniformity : šĖ¢ (diagonal α) ⤠š¤ α :=
(nhdsSet_diagonal α).trans_le iSup_nhds_le_uniformity
/-!
### Closure and interior in uniform spaces
-/
theorem closure_eq_uniformity (s : Set <| α à α) :
closure s = ā V ā { V | V ā š¤ α ā§ SymmetricRel V }, V ā s ā V := by
ext āØx, yā©
simp (config := { contextual := true }) only
[mem_closure_iff_nhds_basis (UniformSpace.hasBasis_nhds_prod x y), mem_iInter, mem_setOf_eq,
and_imp, mem_comp_comp, exists_prop, ā mem_inter_iff, inter_comm, Set.Nonempty]
theorem uniformity_hasBasis_closed :
HasBasis (š¤ α) (fun V : Set (α à α) => V ā š¤ α ā§ IsClosed V) id := by
refine Filter.hasBasis_self.2 fun t h => ?_
rcases comp_comp_symm_mem_uniformity_sets h with āØw, w_in, w_symm, rā©
refine āØclosure w, mem_of_superset w_in subset_closure, isClosed_closure, ?_ā©
refine Subset.trans ?_ r
rw [closure_eq_uniformity]
apply iInter_subset_of_subset
apply iInter_subset
exact āØw_in, w_symmā©
theorem uniformity_eq_uniformity_closure : š¤ α = (š¤ α).lift' closure :=
Eq.symm <| uniformity_hasBasis_closed.lift'_closure_eq_self fun _ => And.right
theorem Filter.HasBasis.uniformity_closure {p : ι ā Prop} {U : ι ā Set (α à α)}
(h : (š¤ α).HasBasis p U) : (š¤ α).HasBasis p fun i => closure (U i) :=
(@uniformity_eq_uniformity_closure α _).symm ⸠h.lift'_closure
/-- Closed entourages form a basis of the uniformity filter. -/
theorem uniformity_hasBasis_closure : HasBasis (š¤ α) (fun V : Set (α à α) => V ā š¤ α) closure :=
(š¤ α).basis_sets.uniformity_closure
theorem closure_eq_inter_uniformity {t : Set (α à α)} : closure t = ā d ā š¤ α, d ā (t ā d) :=
calc
closure t = ā (V) (_ : V ā š¤ α ā§ SymmetricRel V), V ā t ā V := closure_eq_uniformity t
_ = ā V ā š¤ α, V ā t ā V :=
Eq.symm <|
UniformSpace.hasBasis_symmetric.biInter_mem fun Vā Vā hV =>
compRel_mono (compRel_mono hV Subset.rfl) hV
_ = ā V ā š¤ α, V ā (t ā V) := by simp only [compRel_assoc]
theorem uniformity_eq_uniformity_interior : š¤ α = (š¤ α).lift' interior :=
le_antisymm
(le_iInfā fun d hd => by
let āØs, hs, hs_compā© := comp3_mem_uniformity hd
let āØt, ht, hst, ht_compā© := nhdset_of_mem_uniformity s hs
have : s ā interior d :=
calc
s ā t := hst
_ ā interior d :=
ht.subset_interior_iff.mpr fun x (hx : x ā t) =>
let āØx, y, hā, hā, hāā© := ht_comp hx
hs_comp āØx, hā, y, hā, hāā©
have : interior d ā š¤ α := by filter_upwards [hs] using this
simp [this])
fun s hs => ((š¤ α).lift' interior).sets_of_superset (mem_lift' hs) interior_subset
theorem interior_mem_uniformity {s : Set (α à α)} (hs : s ā š¤ α) : interior s ā š¤ α := by
rw [uniformity_eq_uniformity_interior]; exact mem_lift' hs
theorem mem_uniformity_isClosed {s : Set (α à α)} (h : s ā š¤ α) : ā t ā š¤ α, IsClosed t ā§ t ā s :=
let āØt, āØht_mem, htcā©, htsā© := uniformity_hasBasis_closed.mem_iff.1 h
āØt, ht_mem, htc, htsā©
theorem isOpen_iff_open_ball_subset {s : Set α} :
IsOpen s ā ā x ā s, ā V ā š¤ α, IsOpen V ā§ ball x V ā s := by
rw [isOpen_iff_ball_subset]
constructor <;> intro h x hx
Ā· obtain āØV, hV, hV'ā© := h x hx
exact
āØinterior V, interior_mem_uniformity hV, isOpen_interior,
(ball_mono interior_subset x).trans hV'ā©
Ā· obtain āØV, hV, -, hV'ā© := h x hx
exact āØV, hV, hV'ā©
/-- The uniform neighborhoods of all points of a dense set cover the whole space. -/
theorem Dense.biUnion_uniformity_ball {s : Set α} {U : Set (α à α)} (hs : Dense s) (hU : U ā š¤ α) :
ā x ā s, ball x U = univ := by
refine iUnionā_eq_univ_iff.2 fun y => ?_
rcases hs.inter_nhds_nonempty (mem_nhds_right y hU) with āØx, hxs, hxy : (x, y) ā Uā©
exact āØx, hxs, hxyā©
/-- The uniform neighborhoods of all points of a dense indexed collection cover the whole space. -/
lemma DenseRange.iUnion_uniformity_ball {ι : Type*} {xs : ι ā α}
(xs_dense : DenseRange xs) {U : Set (α à α)} (hU : U ā uniformity α) :
ā i, UniformSpace.ball (xs i) U = univ := by
rw [ā biUnion_range (f := xs) (g := fun x ⦠UniformSpace.ball x U)]
exact Dense.biUnion_uniformity_ball xs_dense hU
/-!
### Uniformity bases
-/
/-- Open elements of `š¤ α` form a basis of `š¤ α`. -/
theorem uniformity_hasBasis_open : HasBasis (š¤ α) (fun V : Set (α à α) => V ā š¤ α ā§ IsOpen V) id :=
hasBasis_self.2 fun s hs =>
āØinterior s, interior_mem_uniformity hs, isOpen_interior, interior_subsetā©
theorem Filter.HasBasis.mem_uniformity_iff {p : β ā Prop} {s : β ā Set (α à α)}
(h : (š¤ α).HasBasis p s) {t : Set (α à α)} :
t ā š¤ α ā ā i, p i ā§ ā a b, (a, b) ā s i ā (a, b) ā t :=
h.mem_iff.trans <| by simp only [Prod.forall, subset_def]
/-- Open elements `s : Set (α à α)` of `š¤ α` such that `(x, y) ā s ā (y, x) ā s` form a basis
of `š¤ α`. -/
theorem uniformity_hasBasis_open_symmetric :
HasBasis (š¤ α) (fun V : Set (α à α) => V ā š¤ α ā§ IsOpen V ā§ SymmetricRel V) id := by
simp only [ā and_assoc]
refine uniformity_hasBasis_open.restrict fun s hs => āØsymmetrizeRel s, ?_ā©
exact
āØāØsymmetrize_mem_uniformity hs.1, IsOpen.inter hs.2 (hs.2.preimage continuous_swap)ā©,
symmetric_symmetrizeRel s, symmetrizeRel_subset_self sā©
theorem comp_open_symm_mem_uniformity_sets {s : Set (α à α)} (hs : s ā š¤ α) :
ā t ā š¤ α, IsOpen t ā§ SymmetricRel t ā§ t ā t ā s := by
obtain āØt, htā, htāā© := comp_mem_uniformity_sets hs
obtain āØu, āØhuā, huā, huāā©, huā : u ā tā© := uniformity_hasBasis_open_symmetric.mem_iff.mp htā
exact āØu, huā, huā, huā, (compRel_mono huā huā).trans htāā©
section
variable (α)
theorem UniformSpace.has_seq_basis [IsCountablyGenerated <| š¤ α] :
ā V : ā ā Set (α à α), HasAntitoneBasis (š¤ α) V ā§ ā n, SymmetricRel (V n) :=
let āØU, hsym, hbasisā© := (@UniformSpace.hasBasis_symmetric α _).exists_antitone_subbasis
āØU, hbasis, fun n => (hsym n).2ā©
end
theorem Filter.HasBasis.biInter_biUnion_ball {p : ι ā Prop} {U : ι ā Set (α à α)}
(h : HasBasis (š¤ α) p U) (s : Set α) :
(ā (i) (_ : p i), ā x ā s, ball x (U i)) = closure s := by
ext x
simp [mem_closure_iff_nhds_basis (nhds_basis_uniformity h), ball]
/-! ### Uniform continuity -/
/-- A function `f : α ā β` is *uniformly continuous* if `(f x, f y)` tends to the diagonal
as `(x, y)` tends to the diagonal. In other words, if `x` is sufficiently close to `y`, then
`f x` is close to `f y` no matter where `x` and `y` are located in `α`. -/
def UniformContinuous [UniformSpace β] (f : α ā β) :=
Tendsto (fun x : α à α => (f x.1, f x.2)) (š¤ α) (š¤ β)
/-- Notation for uniform continuity with respect to non-standard `UniformSpace` instances. -/
scoped[Uniformity] notation "UniformContinuous[" uā ", " uā "]" => @UniformContinuous _ _ uā uā
/-- A function `f : α ā β` is *uniformly continuous* on `s : Set α` if `(f x, f y)` tends to
the diagonal as `(x, y)` tends to the diagonal while remaining in `s ĆĖ¢ s`.
In other words, if `x` is sufficiently close to `y`, then `f x` is close to
`f y` no matter where `x` and `y` are located in `s`. -/
def UniformContinuousOn [UniformSpace β] (f : α ā β) (s : Set α) : Prop :=
Tendsto (fun x : α à α => (f x.1, f x.2)) (š¤ α ā š (s ĆĖ¢ s)) (š¤ β)
theorem uniformContinuous_def [UniformSpace β] {f : α ā β} :
UniformContinuous f ā ā r ā š¤ β, { x : α à α | (f x.1, f x.2) ā r } ā š¤ α :=
Iff.rfl
theorem uniformContinuous_iff_eventually [UniformSpace β] {f : α ā β} :
UniformContinuous f ā ā r ā š¤ β, āį¶ x : α à α in š¤ α, (f x.1, f x.2) ā r :=
Iff.rfl
theorem uniformContinuousOn_univ [UniformSpace β] {f : α ā β} :
UniformContinuousOn f univ ā UniformContinuous f := by
rw [UniformContinuousOn, UniformContinuous, univ_prod_univ, principal_univ, inf_top_eq]
theorem uniformContinuous_of_const [UniformSpace β] {c : α ā β} (h : ā a b, c a = c b) :
UniformContinuous c :=
have : (fun x : α à α => (c x.fst, c x.snd)) ā»Ā¹' idRel = univ :=
eq_univ_iff_forall.2 fun āØa, bā© => h a b
le_trans (map_le_iff_le_comap.2 <| by simp [comap_principal, this, univ_mem]) refl_le_uniformity
theorem uniformContinuous_id : UniformContinuous (@id α) := tendsto_id
theorem uniformContinuous_const [UniformSpace β] {b : β} : UniformContinuous fun _ : α => b :=
uniformContinuous_of_const fun _ _ => rfl
nonrec theorem UniformContinuous.comp [UniformSpace β] [UniformSpace γ] {g : β ā γ} {f : α ā β}
(hg : UniformContinuous g) (hf : UniformContinuous f) : UniformContinuous (g ā f) :=
hg.comp hf
/--If a function `T` is uniformly continuous in a uniform space `β`,
then its `n`-th iterate `T^[n]` is also uniformly continuous.-/
theorem UniformContinuous.iterate [UniformSpace β] (T : β ā β) (n : ā) (h : UniformContinuous T) :
UniformContinuous T^[n] := by
induction n with
| zero => exact uniformContinuous_id
| succ n hn => exact Function.iterate_succ _ _ āø UniformContinuous.comp hn h
theorem Filter.HasBasis.uniformContinuous_iff {ι'} [UniformSpace β] {p : ι ā Prop}
{s : ι ā Set (α à α)} (ha : (š¤ α).HasBasis p s) {q : ι' ā Prop} {t : ι' ā Set (β à β)}
(hb : (š¤ β).HasBasis q t) {f : α ā β} :
UniformContinuous f ā ā i, q i ā ā j, p j ā§ ā x y, (x, y) ā s j ā (f x, f y) ā t i :=
(ha.tendsto_iff hb).trans <| by simp only [Prod.forall]
theorem Filter.HasBasis.uniformContinuousOn_iff {ι'} [UniformSpace β] {p : ι ā Prop}
{s : ι ā Set (α à α)} (ha : (š¤ α).HasBasis p s) {q : ι' ā Prop} {t : ι' ā Set (β à β)}
(hb : (š¤ β).HasBasis q t) {f : α ā β} {S : Set α} :
UniformContinuousOn f S ā
ā i, q i ā ā j, p j ā§ ā x, x ā S ā ā y, y ā S ā (x, y) ā s j ā (f x, f y) ā t i :=
((ha.inf_principal (S ĆĖ¢ S)).tendsto_iff hb).trans <| by
simp_rw [Prod.forall, Set.inter_comm (s _), forall_mem_comm, mem_inter_iff, mem_prod, and_imp]
end UniformSpace
open uniformity
section Constructions
instance : PartialOrder (UniformSpace α) :=
PartialOrder.lift (fun u => š¤[u]) fun _ _ => UniformSpace.ext
protected theorem UniformSpace.le_def {uā uā : UniformSpace α} : uā ⤠uā ā š¤[uā] ⤠š¤[uā] := Iff.rfl
instance : InfSet (UniformSpace α) :=
āØfun s =>
UniformSpace.ofCore
{ uniformity := āØ
u ā s, š¤[u]
refl := le_iInf fun u => le_iInf fun _ => u.toCore.refl
symm := le_iInfā fun u hu =>
le_trans (map_mono <| iInf_le_of_le _ <| iInf_le _ hu) u.symm
comp := le_iInfā fun u hu =>
le_trans (lift'_mono (iInf_le_of_le _ <| iInf_le _ hu) <| le_rfl) u.comp }ā©
protected theorem UniformSpace.sInf_le {tt : Set (UniformSpace α)} {t : UniformSpace α}
(h : t ā tt) : sInf tt ⤠t :=
show āØ
u ā tt, š¤[u] ⤠š¤[t] from iInfā_le t h
protected theorem UniformSpace.le_sInf {tt : Set (UniformSpace α)} {t : UniformSpace α}
(h : ā t' ā tt, t ⤠t') : t ⤠sInf tt :=
show š¤[t] ⤠āØ
u ā tt, š¤[u] from le_iInfā h
instance : Top (UniformSpace α) :=
āØ@UniformSpace.mk α ⤠⤠le_top le_top fun x ⦠by simp only [nhds_top, comap_top]ā©
instance : Bot (UniformSpace α) :=
āØ{ toTopologicalSpace := ā„
uniformity := š idRel
symm := by simp [Tendsto]
comp := lift'_le (mem_principal_self _) <| principal_mono.2 id_compRel.subset
nhds_eq_comap_uniformity := fun s => by
let _ : TopologicalSpace α := ā„; have := discreteTopology_bot α
simp [idRel] }ā©
instance : Inf (UniformSpace α) :=
āØfun uā uā =>
{ uniformity := š¤[uā] ā š¤[uā]
symm := uā.symm.inf uā.symm
comp := (lift'_inf_le _ _ _).trans <| inf_le_inf uā.comp uā.comp
toTopologicalSpace := uā.toTopologicalSpace ā uā.toTopologicalSpace
nhds_eq_comap_uniformity := fun _ ⦠by
rw [@nhds_inf _ uā.toTopologicalSpace _, @nhds_eq_comap_uniformity _ uā,
@nhds_eq_comap_uniformity _ uā, comap_inf] }ā©
instance : CompleteLattice (UniformSpace α) :=
{ inferInstanceAs (PartialOrder (UniformSpace α)) with
sup := fun a b => sInf { x | a ⤠x ⧠b ⤠x }
le_sup_left := fun _ _ => UniformSpace.le_sInf fun _ āØh, _ā© => h
le_sup_right := fun _ _ => UniformSpace.le_sInf fun _ āØ_, hā© => h
sup_le := fun _ _ _ hā hā => UniformSpace.sInf_le āØhā, hāā©
inf := (Ā· ā Ā·)
le_inf := fun a _ _ hā hā => show a.uniformity ⤠_ from le_inf hā hā
inf_le_left := fun a _ => show _ ⤠a.uniformity from inf_le_left
inf_le_right := fun _ b => show _ ⤠b.uniformity from inf_le_right
top := ā¤
le_top := fun a => show a.uniformity ⤠⤠from le_top
bot := ā„
bot_le := fun u => u.toCore.refl
sSup := fun tt => sInf { t | ā t' ā tt, t' ⤠t }
le_sSup := fun _ _ h => UniformSpace.le_sInf fun _ h' => h' _ h
sSup_le := fun _ _ h => UniformSpace.sInf_le h
sInf := sInf
le_sInf := fun _ _ hs => UniformSpace.le_sInf hs
sInf_le := fun _ _ ha => UniformSpace.sInf_le ha }
theorem iInf_uniformity {ι : Sort*} {u : ι ā UniformSpace α} : š¤[iInf u] = āØ
i, š¤[u i] :=
iInf_range
theorem inf_uniformity {u v : UniformSpace α} : š¤[u ā v] = š¤[u] ā š¤[v] := rfl
lemma bot_uniformity : š¤[(ā„ : UniformSpace α)] = š idRel := rfl
lemma top_uniformity : š¤[(⤠: UniformSpace α)] = ⤠:= rfl
instance inhabitedUniformSpace : Inhabited (UniformSpace α) :=
āØā„ā©
instance inhabitedUniformSpaceCore : Inhabited (UniformSpace.Core α) :=
āØ@UniformSpace.toCore _ defaultā©
instance [Subsingleton α] : Unique (UniformSpace α) where
uniq u := bot_unique <| le_principal_iff.2 <| by
rw [idRel, ā diagonal, diagonal_eq_univ]; exact univ_mem
/-- Given `f : α ā β` and a uniformity `u` on `β`, the inverse image of `u` under `f`
is the inverse image in the filter sense of the induced function `α à α ā β à β`.
See note [reducible non-instances]. -/
abbrev UniformSpace.comap (f : α ā β) (u : UniformSpace β) : UniformSpace α where
uniformity := š¤[u].comap fun p : α à α => (f p.1, f p.2)
symm := by
simp only [tendsto_comap_iff, Prod.swap, (Ā· ā Ā·)]
exact tendsto_swap_uniformity.comp tendsto_comap
comp := le_trans
(by
rw [comap_lift'_eq, comap_lift'_eq2]
Ā· exact lift'_mono' fun s _ āØaā, aāā© āØx, hā, hāā© => āØf x, hā, hāā©
Ā· exact monotone_id.compRel monotone_id)
(comap_mono u.comp)
toTopologicalSpace := u.toTopologicalSpace.induced f
nhds_eq_comap_uniformity x := by
simp only [nhds_induced, nhds_eq_comap_uniformity, comap_comap, Function.comp]
theorem uniformity_comap {_ : UniformSpace β} (f : α ā β) :
š¤[UniformSpace.comap f ā¹_āŗ] = comap (Prod.map f f) (š¤ β) :=
rfl
@[simp]
theorem uniformSpace_comap_id {α : Type*} : UniformSpace.comap (id : α ā α) = id := by
ext : 2
rw [uniformity_comap, Prod.map_id, comap_id]
theorem UniformSpace.comap_comap {α β γ} {uγ : UniformSpace γ} {f : α ā β} {g : β ā γ} :
UniformSpace.comap (g ā f) uγ = UniformSpace.comap f (UniformSpace.comap g uγ) := by
ext1
simp only [uniformity_comap, Filter.comap_comap, Prod.map_comp_map]
theorem UniformSpace.comap_inf {α γ} {uā uā : UniformSpace γ} {f : α ā γ} :
(uā ā uā).comap f = uā.comap f ā uā.comap f :=
UniformSpace.ext Filter.comap_inf
theorem UniformSpace.comap_iInf {ι α γ} {u : ι ā UniformSpace γ} {f : α ā γ} :
(āØ
i, u i).comap f = āØ
i, (u i).comap f := by
ext : 1
simp [uniformity_comap, iInf_uniformity]
theorem UniformSpace.comap_mono {α γ} {f : α ā γ} :
Monotone fun u : UniformSpace γ => u.comap f := fun _ _ hu =>
Filter.comap_mono hu
theorem uniformContinuous_iff {α β} {uα : UniformSpace α} {uβ : UniformSpace β} {f : α ā β} :
UniformContinuous f ā uα ⤠uβ.comap f :=
Filter.map_le_iff_le_comap
theorem le_iff_uniformContinuous_id {u v : UniformSpace α} :
u ⤠v ā @UniformContinuous _ _ u v id := by
rw [uniformContinuous_iff, uniformSpace_comap_id, id]
theorem uniformContinuous_comap {f : α ā β} [u : UniformSpace β] :
@UniformContinuous α β (UniformSpace.comap f u) u f :=
tendsto_comap
theorem uniformContinuous_comap' {f : γ ā β} {g : α ā γ} [v : UniformSpace β] [u : UniformSpace α]
(h : UniformContinuous (f ā g)) : @UniformContinuous α γ u (UniformSpace.comap f v) g :=
tendsto_comap_iff.2 h
namespace UniformSpace
theorem to_nhds_mono {uā uā : UniformSpace α} (h : uā ⤠uā) (a : α) :
@nhds _ (@UniformSpace.toTopologicalSpace _ uā) a ā¤
@nhds _ (@UniformSpace.toTopologicalSpace _ uā) a := by
rw [@nhds_eq_uniformity α uā a, @nhds_eq_uniformity α uā a]; exact lift'_mono h le_rfl
theorem toTopologicalSpace_mono {uā uā : UniformSpace α} (h : uā ⤠uā) :
@UniformSpace.toTopologicalSpace _ uā ⤠@UniformSpace.toTopologicalSpace _ uā :=
le_of_nhds_le_nhds <| to_nhds_mono h
theorem toTopologicalSpace_comap {f : α ā β} {u : UniformSpace β} :
@UniformSpace.toTopologicalSpace _ (UniformSpace.comap f u) =
TopologicalSpace.induced f (@UniformSpace.toTopologicalSpace β u) :=
rfl
lemma uniformSpace_eq_bot {u : UniformSpace α} : u = ā„ ā idRel ā š¤[u] :=
le_bot_iff.symm.trans le_principal_iff
protected lemma _root_.Filter.HasBasis.uniformSpace_eq_bot {ι p} {s : ι ā Set (α à α)}
{u : UniformSpace α} (h : š¤[u].HasBasis p s) :
u = ā„ ā ā i, p i ā§ Pairwise fun x y : α ⦠(x, y) ā s i := by
simp [uniformSpace_eq_bot, h.mem_iff, subset_def, Pairwise, not_imp_not]
theorem toTopologicalSpace_bot : @UniformSpace.toTopologicalSpace α ℠= ℠:= rfl
theorem toTopologicalSpace_top : @UniformSpace.toTopologicalSpace α ⤠= ⤠:= rfl
theorem toTopologicalSpace_iInf {ι : Sort*} {u : ι ā UniformSpace α} :
(iInf u).toTopologicalSpace = āØ
i, (u i).toTopologicalSpace :=
TopologicalSpace.ext_nhds fun a ⦠by simp only [@nhds_eq_comap_uniformity _ (iInf u), nhds_iInf,
iInf_uniformity, @nhds_eq_comap_uniformity _ (u _), Filter.comap_iInf]
theorem toTopologicalSpace_sInf {s : Set (UniformSpace α)} :
(sInf s).toTopologicalSpace = āØ
i ā s, @UniformSpace.toTopologicalSpace α i := by
rw [sInf_eq_iInf]
simp only [ā toTopologicalSpace_iInf]
theorem toTopologicalSpace_inf {u v : UniformSpace α} :
(u ā v).toTopologicalSpace = u.toTopologicalSpace ā v.toTopologicalSpace :=
rfl
end UniformSpace
theorem UniformContinuous.continuous [UniformSpace α] [UniformSpace β] {f : α ā β}
(hf : UniformContinuous f) : Continuous f :=
continuous_iff_le_induced.mpr <| UniformSpace.toTopologicalSpace_mono <|
uniformContinuous_iff.1 hf
/-- Uniform space structure on `ULift α`. -/
instance ULift.uniformSpace [UniformSpace α] : UniformSpace (ULift α) :=
UniformSpace.comap ULift.down ā¹_āŗ
section UniformContinuousInfi
-- Porting note: renamed for dot notation; add an `iff` lemma?
theorem UniformContinuous.inf_rng {f : α ā β} {uā : UniformSpace α} {uā uā : UniformSpace β}
(hā : UniformContinuous[uā, uā] f) (hā : UniformContinuous[uā, uā] f) :
UniformContinuous[uā, uā ā uā] f :=
tendsto_inf.mpr āØhā, hāā©
-- Porting note: renamed for dot notation
theorem UniformContinuous.inf_dom_left {f : α ā β} {uā uā : UniformSpace α} {uā : UniformSpace β}
(hf : UniformContinuous[uā, uā] f) : UniformContinuous[uā ā uā, uā] f :=
tendsto_inf_left hf
-- Porting note: renamed for dot notation
theorem UniformContinuous.inf_dom_right {f : α ā β} {uā uā : UniformSpace α} {uā : UniformSpace β}
(hf : UniformContinuous[uā, uā] f) : UniformContinuous[uā ā uā, uā] f :=
tendsto_inf_right hf
theorem uniformContinuous_sInf_dom {f : α ā β} {uā : Set (UniformSpace α)} {uā : UniformSpace β}
{u : UniformSpace α} (hā : u ā uā) (hf : UniformContinuous[u, uā] f) :
UniformContinuous[sInf uā, uā] f := by
delta UniformContinuous
rw [sInf_eq_iInf', iInf_uniformity]
exact tendsto_iInf' āØu, hāā© hf
theorem uniformContinuous_sInf_rng {f : α ā β} {uā : UniformSpace α} {uā : Set (UniformSpace β)} :
UniformContinuous[uā, sInf uā] f ā ā u ā uā, UniformContinuous[uā, u] f := by
delta UniformContinuous
rw [sInf_eq_iInf', iInf_uniformity, tendsto_iInf, SetCoe.forall]
theorem uniformContinuous_iInf_dom {f : α ā β} {uā : ι ā UniformSpace α} {uā : UniformSpace β}
{i : ι} (hf : UniformContinuous[uā i, uā] f) : UniformContinuous[iInf uā, uā] f := by
delta UniformContinuous
rw [iInf_uniformity]
exact tendsto_iInf' i hf
theorem uniformContinuous_iInf_rng {f : α ā β} {uā : UniformSpace α} {uā : ι ā UniformSpace β} :
UniformContinuous[uā, iInf uā] f ā ā i, UniformContinuous[uā, uā i] f := by
delta UniformContinuous
rw [iInf_uniformity, tendsto_iInf]
end UniformContinuousInfi
/-- A uniform space with the discrete uniformity has the discrete topology. -/
theorem discreteTopology_of_discrete_uniformity [hα : UniformSpace α] (h : uniformity α = š idRel) :
DiscreteTopology α :=
āØ(UniformSpace.ext h.symm : ā„ = hα) āø rflā©
instance : UniformSpace Empty := ā„
instance : UniformSpace PUnit := ā„
instance : UniformSpace Bool := ā„
instance : UniformSpace ā := ā„
instance : UniformSpace ⤠:= ā„
section
variable [UniformSpace α]
open Additive Multiplicative
instance : UniformSpace (Additive α) := ā¹UniformSpace αāŗ
instance : UniformSpace (Multiplicative α) := ā¹UniformSpace αāŗ
theorem uniformContinuous_ofMul : UniformContinuous (ofMul : α ā Additive α) :=
uniformContinuous_id
theorem uniformContinuous_toMul : UniformContinuous (toMul : Additive α ā α) :=
uniformContinuous_id
theorem uniformContinuous_ofAdd : UniformContinuous (ofAdd : α ā Multiplicative α) :=
uniformContinuous_id
theorem uniformContinuous_toAdd : UniformContinuous (toAdd : Multiplicative α ā α) :=
uniformContinuous_id
theorem uniformity_additive : š¤ (Additive α) = (š¤ α).map (Prod.map ofMul ofMul) := rfl
theorem uniformity_multiplicative : š¤ (Multiplicative α) = (š¤ α).map (Prod.map ofAdd ofAdd) := rfl
end
instance instUniformSpaceSubtype {p : α ā Prop} [t : UniformSpace α] : UniformSpace (Subtype p) :=
UniformSpace.comap Subtype.val t
theorem uniformity_subtype {p : α ā Prop} [UniformSpace α] :
š¤ (Subtype p) = comap (fun q : Subtype p Ć Subtype p => (q.1.1, q.2.1)) (š¤ α) :=
rfl
theorem uniformity_setCoe {s : Set α} [UniformSpace α] :
š¤ s = comap (Prod.map ((ā) : s ā α) ((ā) : s ā α)) (š¤ α) :=
rfl
theorem map_uniformity_set_coe {s : Set α} [UniformSpace α] :
map (Prod.map (ā) (ā)) (š¤ s) = š¤ α ā š (s ĆĖ¢ s) := by
rw [uniformity_setCoe, map_comap, range_prod_map, Subtype.range_val]
theorem uniformContinuous_subtype_val {p : α ā Prop} [UniformSpace α] :
UniformContinuous (Subtype.val : { a : α // p a } ā α) :=
uniformContinuous_comap
theorem UniformContinuous.subtype_mk {p : α ā Prop} [UniformSpace α] [UniformSpace β] {f : β ā α}
(hf : UniformContinuous f) (h : ā x, p (f x)) :
UniformContinuous (fun x => āØf x, h xā© : β ā Subtype p) :=
uniformContinuous_comap' hf
theorem uniformContinuousOn_iff_restrict [UniformSpace α] [UniformSpace β] {f : α ā β} {s : Set α} :
UniformContinuousOn f s ā UniformContinuous (s.restrict f) := by
delta UniformContinuousOn UniformContinuous
rw [ā map_uniformity_set_coe, tendsto_map'_iff]; rfl
theorem tendsto_of_uniformContinuous_subtype [UniformSpace α] [UniformSpace β] {f : α ā β}
{s : Set α} {a : α} (hf : UniformContinuous fun x : s => f x.val) (ha : s ā š a) :
Tendsto f (š a) (š (f a)) := by
rw [(@map_nhds_subtype_coe_eq_nhds α _ s a (mem_of_mem_nhds ha) ha).symm]
exact tendsto_map' hf.continuous.continuousAt
theorem UniformContinuousOn.continuousOn [UniformSpace α] [UniformSpace β] {f : α ā β} {s : Set α}
(h : UniformContinuousOn f s) : ContinuousOn f s := by
rw [uniformContinuousOn_iff_restrict] at h
rw [continuousOn_iff_continuous_restrict]
exact h.continuous
@[to_additive]
instance [UniformSpace α] : UniformSpace αįµįµįµ :=
UniformSpace.comap MulOpposite.unop ā¹_āŗ
@[to_additive]
theorem uniformity_mulOpposite [UniformSpace α] :
š¤ αįµįµįµ = comap (fun q : αįµįµįµ à αįµįµįµ => (q.1.unop, q.2.unop)) (š¤ α) :=
rfl
@[to_additive (attr := simp)]
theorem comap_uniformity_mulOpposite [UniformSpace α] :
comap (fun p : α à α => (MulOpposite.op p.1, MulOpposite.op p.2)) (š¤ αįµįµįµ) = š¤ α := by
simpa [uniformity_mulOpposite, comap_comap, (Ā· ā Ā·)] using comap_id
namespace MulOpposite
@[to_additive]
theorem uniformContinuous_unop [UniformSpace α] : UniformContinuous (unop : αįµįµįµ ā α) :=
uniformContinuous_comap
@[to_additive]
theorem uniformContinuous_op [UniformSpace α] : UniformContinuous (op : α ā αįµįµįµ) :=
uniformContinuous_comap' uniformContinuous_id
end MulOpposite
section Prod
/- a similar product space is possible on the function space (uniformity of pointwise convergence),
but we want to have the uniformity of uniform convergence on function spaces -/
instance instUniformSpaceProd [uā : UniformSpace α] [uā : UniformSpace β] : UniformSpace (α à β) :=
uā.comap Prod.fst ā uā.comap Prod.snd
-- check the above produces no diamond for `simp` and typeclass search
example [UniformSpace α] [UniformSpace β] :
(instTopologicalSpaceProd : TopologicalSpace (α à β)) = UniformSpace.toTopologicalSpace := by
with_reducible_and_instances rfl
theorem uniformity_prod [UniformSpace α] [UniformSpace β] :
š¤ (α à β) =
((š¤ α).comap fun p : (α à β) à α à β => (p.1.1, p.2.1)) ā
(š¤ β).comap fun p : (α à β) à α à β => (p.1.2, p.2.2) :=
rfl
instance [UniformSpace α] [IsCountablyGenerated (š¤ α)]
[UniformSpace β] [IsCountablyGenerated (š¤ β)] : IsCountablyGenerated (š¤ (α à β)) := by
rw [uniformity_prod]
infer_instance
theorem uniformity_prod_eq_comap_prod [UniformSpace α] [UniformSpace β] :
š¤ (α à β) =
comap (fun p : (α à β) à α à β => ((p.1.1, p.2.1), (p.1.2, p.2.2))) (š¤ α ĆĖ¢ š¤ β) := by
dsimp [SProd.sprod]
rw [uniformity_prod, Filter.prod, comap_inf, comap_comap, comap_comap]; rfl
theorem uniformity_prod_eq_prod [UniformSpace α] [UniformSpace β] :
š¤ (α à β) = map (fun p : (α à α) à β à β => ((p.1.1, p.2.1), (p.1.2, p.2.2))) (š¤ α ĆĖ¢ š¤ β) := by
rw [map_swap4_eq_comap, uniformity_prod_eq_comap_prod]
theorem mem_uniformity_of_uniformContinuous_invariant [UniformSpace α] [UniformSpace β]
{s : Set (β à β)} {f : α ā α ā β} (hf : UniformContinuous fun p : α à α => f p.1 p.2)
(hs : s ā š¤ β) : ā u ā š¤ α, ā a b c, (a, b) ā u ā (f a c, f b c) ā s := by
rw [UniformContinuous, uniformity_prod_eq_prod, tendsto_map'_iff] at hf
rcases mem_prod_iff.1 (mem_map.1 <| hf hs) with āØu, hu, v, hv, huvtā©
exact āØu, hu, fun a b c hab => @huvt ((_, _), (_, _)) āØhab, refl_mem_uniformity hvā©ā©
theorem mem_uniform_prod [tā : UniformSpace α] [tā : UniformSpace β] {a : Set (α à α)}
{b : Set (β à β)} (ha : a ā š¤ α) (hb : b ā š¤ β) :
{ p : (α à β) à α à β | (p.1.1, p.2.1) ā a ā§ (p.1.2, p.2.2) ā b } ā š¤ (α à β) := by
rw [uniformity_prod]; exact inter_mem_inf (preimage_mem_comap ha) (preimage_mem_comap hb)
theorem tendsto_prod_uniformity_fst [UniformSpace α] [UniformSpace β] :
Tendsto (fun p : (α à β) à α à β => (p.1.1, p.2.1)) (š¤ (α à β)) (š¤ α) :=
le_trans (map_mono inf_le_left) map_comap_le
theorem tendsto_prod_uniformity_snd [UniformSpace α] [UniformSpace β] :
Tendsto (fun p : (α à β) à α à β => (p.1.2, p.2.2)) (š¤ (α à β)) (š¤ β) :=
le_trans (map_mono inf_le_right) map_comap_le
theorem uniformContinuous_fst [UniformSpace α] [UniformSpace β] :
UniformContinuous fun p : α à β => p.1 :=
tendsto_prod_uniformity_fst
theorem uniformContinuous_snd [UniformSpace α] [UniformSpace β] :
UniformContinuous fun p : α à β => p.2 :=
tendsto_prod_uniformity_snd
variable [UniformSpace α] [UniformSpace β] [UniformSpace γ]
theorem UniformContinuous.prod_mk {fā : α ā β} {fā : α ā γ} (hā : UniformContinuous fā)
(hā : UniformContinuous fā) : UniformContinuous fun a => (fā a, fā a) := by
rw [UniformContinuous, uniformity_prod]
exact tendsto_inf.2 āØtendsto_comap_iff.2 hā, tendsto_comap_iff.2 hāā©
theorem UniformContinuous.prod_mk_left {f : α à β ā γ} (h : UniformContinuous f) (b) :
UniformContinuous fun a => f (a, b) :=
h.comp (uniformContinuous_id.prod_mk uniformContinuous_const)
theorem UniformContinuous.prod_mk_right {f : α à β ā γ} (h : UniformContinuous f) (a) :
UniformContinuous fun b => f (a, b) :=
h.comp (uniformContinuous_const.prod_mk uniformContinuous_id)
theorem UniformContinuous.prod_map [UniformSpace Ī“] {f : α ā γ} {g : β ā Ī“}
(hf : UniformContinuous f) (hg : UniformContinuous g) : UniformContinuous (Prod.map f g) :=
(hf.comp uniformContinuous_fst).prod_mk (hg.comp uniformContinuous_snd)
theorem toTopologicalSpace_prod {α} {β} [u : UniformSpace α] [v : UniformSpace β] :
@UniformSpace.toTopologicalSpace (α à β) instUniformSpaceProd =
@instTopologicalSpaceProd α β u.toTopologicalSpace v.toTopologicalSpace :=
rfl
/-- A version of `UniformContinuous.inf_dom_left` for binary functions -/
theorem uniformContinuous_inf_dom_leftā {α β γ} {f : α ā β ā γ} {ua1 ua2 : UniformSpace α}
{ub1 ub2 : UniformSpace β} {uc1 : UniformSpace γ}
(h : by haveI := ua1; haveI := ub1; exact UniformContinuous fun p : α à β => f p.1 p.2) : by
haveI := ua1 ā ua2; haveI := ub1 ā ub2
exact UniformContinuous fun p : α à β => f p.1 p.2 := by
-- proof essentially copied from `continuous_inf_dom_leftā`
have ha := @UniformContinuous.inf_dom_left _ _ id ua1 ua2 ua1 (@uniformContinuous_id _ (id _))
have hb := @UniformContinuous.inf_dom_left _ _ id ub1 ub2 ub1 (@uniformContinuous_id _ (id _))
have h_unif_cont_id :=
@UniformContinuous.prod_map _ _ _ _ (ua1 ā ua2) (ub1 ā ub2) ua1 ub1 _ _ ha hb
exact @UniformContinuous.comp _ _ _ (id _) (id _) _ _ _ h h_unif_cont_id
/-- A version of `UniformContinuous.inf_dom_right` for binary functions -/
theorem uniformContinuous_inf_dom_rightā {α β γ} {f : α ā β ā γ} {ua1 ua2 : UniformSpace α}
{ub1 ub2 : UniformSpace β} {uc1 : UniformSpace γ}
(h : by haveI := ua2; haveI := ub2; exact UniformContinuous fun p : α à β => f p.1 p.2) : by
haveI := ua1 ā ua2; haveI := ub1 ā ub2
exact UniformContinuous fun p : α à β => f p.1 p.2 := by
-- proof essentially copied from `continuous_inf_dom_rightā`
have ha := @UniformContinuous.inf_dom_right _ _ id ua1 ua2 ua2 (@uniformContinuous_id _ (id _))
have hb := @UniformContinuous.inf_dom_right _ _ id ub1 ub2 ub2 (@uniformContinuous_id _ (id _))
have h_unif_cont_id :=
@UniformContinuous.prod_map _ _ _ _ (ua1 ā ua2) (ub1 ā ub2) ua2 ub2 _ _ ha hb
exact @UniformContinuous.comp _ _ _ (id _) (id _) _ _ _ h h_unif_cont_id
/-- A version of `uniformContinuous_sInf_dom` for binary functions -/
theorem uniformContinuous_sInf_domā {α β γ} {f : α ā β ā γ} {uas : Set (UniformSpace α)}
{ubs : Set (UniformSpace β)} {ua : UniformSpace α} {ub : UniformSpace β} {uc : UniformSpace γ}
(ha : ua ā uas) (hb : ub ā ubs) (hf : UniformContinuous fun p : α à β => f p.1 p.2) : by
haveI := sInf uas; haveI := sInf ubs
exact @UniformContinuous _ _ _ uc fun p : α à β => f p.1 p.2 := by
-- proof essentially copied from `continuous_sInf_dom`
let _ : UniformSpace (α à β) := instUniformSpaceProd
have ha := uniformContinuous_sInf_dom ha uniformContinuous_id
have hb := uniformContinuous_sInf_dom hb uniformContinuous_id
have h_unif_cont_id := @UniformContinuous.prod_map _ _ _ _ (sInf uas) (sInf ubs) ua ub _ _ ha hb
exact @UniformContinuous.comp _ _ _ (id _) (id _) _ _ _ hf h_unif_cont_id
end Prod
section
open UniformSpace Function
variable {Γ' : Type*} [UniformSpace α] [UniformSpace β] [UniformSpace γ] [UniformSpace Γ]
[UniformSpace Ī“']
local notation f " āā " g => Function.bicompr f g
/-- Uniform continuity for functions of two variables. -/
def UniformContinuousā (f : α ā β ā γ) :=
UniformContinuous (uncurry f)
theorem uniformContinuousā_def (f : α ā β ā γ) :
UniformContinuousā f ā UniformContinuous (uncurry f) :=
Iff.rfl
theorem UniformContinuousā.uniformContinuous {f : α ā β ā γ} (h : UniformContinuousā f) :
UniformContinuous (uncurry f) :=
h
theorem uniformContinuousā_curry (f : α à β ā γ) :
UniformContinuousā (Function.curry f) ā UniformContinuous f := by
rw [UniformContinuousā, uncurry_curry]
theorem UniformContinuousā.comp {f : α ā β ā γ} {g : γ ā Ī“} (hg : UniformContinuous g)
(hf : UniformContinuousā f) : UniformContinuousā (g āā f) :=
hg.comp hf
theorem UniformContinuousā.bicompl {f : α ā β ā γ} {ga : Ī“ ā α} {gb : Ī“' ā β}
(hf : UniformContinuousā f) (hga : UniformContinuous ga) (hgb : UniformContinuous gb) :
UniformContinuousā (bicompl f ga gb) :=
hf.uniformContinuous.comp (hga.prod_map hgb)
end
theorem toTopologicalSpace_subtype [u : UniformSpace α] {p : α ā Prop} :
@UniformSpace.toTopologicalSpace (Subtype p) instUniformSpaceSubtype =
@instTopologicalSpaceSubtype α p u.toTopologicalSpace :=
rfl
section Sum
variable [UniformSpace α] [UniformSpace β]
open Sum
-- Obsolete auxiliary definitions and lemmas
/-- Uniformity on a disjoint union. Entourages of the diagonal in the union are obtained
by taking independently an entourage of the diagonal in the first part, and an entourage of
the diagonal in the second part. -/
instance Sum.instUniformSpace : UniformSpace (α ā β) where
uniformity := map (fun p : α à α => (inl p.1, inl p.2)) (š¤ α) ā
map (fun p : β à β => (inr p.1, inr p.2)) (š¤ β)
symm := fun s hs ⦠āØsymm_le_uniformity hs.1, symm_le_uniformity hs.2ā©
comp := fun s hs ⦠by
rcases comp_mem_uniformity_sets hs.1 with āØtα, htα, Htαā©
rcases comp_mem_uniformity_sets hs.2 with āØtβ, htβ, Htβā©
filter_upwards [mem_lift' (union_mem_sup (image_mem_map htα) (image_mem_map htβ))]
rintro āØ_, _ā© āØz, āØāØa, bā©, hab, āØā©ā© | āØāØa, bā©, hab, āØā©ā©, āØāØ_, cā©, hbc, āØā©ā© | āØāØ_, cā©, hbc, āØā©ā©ā©
exacts [@Htα (_, _) āØb, hab, hbcā©, @Htβ (_, _) āØb, hab, hbcā©]
nhds_eq_comap_uniformity x := by
ext
cases x <;> simp [mem_comap', -mem_comap, nhds_inl, nhds_inr, nhds_eq_comap_uniformity,
Prod.ext_iff]
@[reducible, deprecated (since := "2024-02-15")] alias Sum.uniformSpace := Sum.instUniformSpace
/-- The union of an entourage of the diagonal in each set of a disjoint union is again an entourage
of the diagonal. -/
theorem union_mem_uniformity_sum {a : Set (α à α)} (ha : a ā š¤ α) {b : Set (β à β)} (hb : b ā š¤ β) :
Prod.map inl inl '' a āŖ Prod.map inr inr '' b ā š¤ (α ā β) :=
union_mem_sup (image_mem_map ha) (image_mem_map hb)
theorem Sum.uniformity : š¤ (α ā β) = map (Prod.map inl inl) (š¤ α) ā map (Prod.map inr inr) (š¤ β) :=
rfl
lemma uniformContinuous_inl : UniformContinuous (Sum.inl : α ā α ā β) := le_sup_left
lemma uniformContinuous_inr : UniformContinuous (Sum.inr : β ā α ā β) := le_sup_right
instance [IsCountablyGenerated (š¤ α)] [IsCountablyGenerated (š¤ β)] :
IsCountablyGenerated (š¤ (α ā β)) := by
rw [Sum.uniformity]
infer_instance
end Sum
end Constructions
/-!
### Compact sets in uniform spaces
-/
section Compact
open UniformSpace
variable [UniformSpace α] {K : Set α}
/-- Let `c : ι ā Set α` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ā s` its `n`-neighborhood is contained in some `c i`. -/
theorem lebesgue_number_lemma {ι : Sort*} {U : ι ā Set α} (hK : IsCompact K)
(hopen : ā i, IsOpen (U i)) (hcover : K ā ā i, U i) :
ā V ā š¤ α, ā x ā K, ā i, ball x V ā U i := by
have : ā x ā K, ā i, ā V ā š¤ α, ball x (V ā V) ā U i := fun x hx ⦠by
obtain āØi, hiā© := mem_iUnion.1 (hcover hx)
rw [ā (hopen i).mem_nhds_iff, nhds_eq_comap_uniformity, ā lift'_comp_uniformity] at hi
exact āØi, (((basis_sets _).lift' <| monotone_id.compRel monotone_id).comap _).mem_iff.1 hiā©
choose ind W hW hWU using this
rcases hK.elim_nhds_subcover' (fun x hx ⦠ball x (W x hx)) (fun x hx ⦠ball_mem_nhds _ (hW x hx))
with āØt, htā©
refine āØā x ā t, W x x.2, (biInter_finset_mem _).2 fun x _ ⦠hW x x.2, fun x hx ⦠?_ā©
rcases mem_iUnionā.1 (ht hx) with āØy, hyt, hxyā©
exact āØind y y.2, fun z hz ⦠hWU _ _ āØx, hxy, mem_iInterā.1 hz _ hytā©ā©
/-- Let `U : ι ā Set α` be an open cover of a compact set `K`.
Then there exists an entourage `V`
such that for each `x ā K` its `V`-neighborhood is included in some `U i`.
Moreover, one can choose an entourage from a given basis. -/
protected theorem Filter.HasBasis.lebesgue_number_lemma {ι' ι : Sort*} {p : ι' ā Prop}
{V : ι' ā Set (α à α)} {U : ι ā Set α} (hbasis : (š¤ α).HasBasis p V) (hK : IsCompact K)
(hopen : ā j, IsOpen (U j)) (hcover : K ā ā j, U j) :
ā i, p i ā§ ā x ā K, ā j, ball x (V i) ā U j := by
refine (hbasis.exists_iff ?_).1 (lebesgue_number_lemma hK hopen hcover)
exact fun s t hst ht x hx ⦠(ht x hx).imp fun i hi ⦠Subset.trans (ball_mono hst _) hi
/-- Let `c : Set (Set α)` be an open cover of a compact set `s`. Then there exists an entourage
`n` such that for each `x ā s` its `n`-neighborhood is contained in some `t ā c`. -/
theorem lebesgue_number_lemma_sUnion {S : Set (Set α)}
(hK : IsCompact K) (hopen : ā s ā S, IsOpen s) (hcover : K ā āā S) :
ā V ā š¤ α, ā x ā K, ā s ā S, ball x V ā s := by
rw [sUnion_eq_iUnion] at hcover
simpa using lebesgue_number_lemma hK (by simpa) hcover
/-- If `K` is a compact set in a uniform space and `{V i | p i}` is a basis of entourages,
then `{ā x ā K, UniformSpace.ball x (V i) | p i}` is a basis of `šĖ¢ K`.
Here "`{s i | p i}` is a basis of a filter `l`" means `Filter.HasBasis l p s`. -/
theorem IsCompact.nhdsSet_basis_uniformity {p : ι ā Prop} {V : ι ā Set (α à α)}
(hbasis : (š¤ α).HasBasis p V) (hK : IsCompact K) :
(šĖ¢ K).HasBasis p fun i => ā x ā K, ball x (V i) where
mem_iff' U := by
constructor
Ā· intro H
have HKU : K ā ā _ : Unit, interior U := by
simpa only [iUnion_const, subset_interior_iff_mem_nhdsSet] using H
obtain āØi, hpi, hiā© : ā i, p i ā§ ā x ā K, ball x (V i) ā interior U := by
simpa using hbasis.lebesgue_number_lemma hK (fun _ ⦠isOpen_interior) HKU
exact āØi, hpi, hi.trans interior_subsetā©
Ā· rintro āØi, hpi, hiā©
refine mem_of_superset (bUnion_mem_nhdsSet fun x _ ⦠?_) hi
exact ball_mem_nhds _ <| hbasis.mem_of_mem hpi
-- TODO: move to a separate file, golf using the regularity of a uniform space.
theorem Disjoint.exists_uniform_thickening {A B : Set α} (hA : IsCompact A) (hB : IsClosed B)
(h : Disjoint A B) : ā V ā š¤ α, Disjoint (ā x ā A, ball x V) (ā x ā B, ball x V) := by
have : Bį¶ ā šĖ¢ A := hB.isOpen_compl.mem_nhdsSet.mpr h.le_compl_right
rw [(hA.nhdsSet_basis_uniformity (Filter.basis_sets _)).mem_iff] at this
rcases this with āØU, hU, hUABā©
rcases comp_symm_mem_uniformity_sets hU with āØV, hV, hVsymm, hVUā©
refine āØV, hV, Set.disjoint_left.mpr fun x => ?_ā©
simp only [mem_iUnionā]
rintro āØa, ha, hxaā© āØb, hb, hxbā©
rw [mem_ball_symmetry hVsymm] at hxa hxb
exact hUAB (mem_iUnionā_of_mem ha <| hVU <| mem_comp_of_mem_ball hVsymm hxa hxb) hb
theorem Disjoint.exists_uniform_thickening_of_basis {p : ι ā Prop} {s : ι ā Set (α à α)}
(hU : (š¤ α).HasBasis p s) {A B : Set α} (hA : IsCompact A) (hB : IsClosed B)
(h : Disjoint A B) : ā i, p i ā§ Disjoint (ā x ā A, ball x (s i)) (ā x ā B, ball x (s i)) := by
rcases h.exists_uniform_thickening hA hB with āØV, hV, hVABā©
rcases hU.mem_iff.1 hV with āØi, hi, hiVā©
exact āØi, hi, hVAB.mono (iUnionā_mono fun a _ => ball_mono hiV a)
(iUnionā_mono fun b _ => ball_mono hiV b)ā©
/-- A useful consequence of the Lebesgue number lemma: given any compact set `K` contained in an
open set `U`, we can find an (open) entourage `V` such that the ball of size `V` about any point of
`K` is contained in `U`. -/
theorem lebesgue_number_of_compact_open {K U : Set α} (hK : IsCompact K)
(hU : IsOpen U) (hKU : K ā U) : ā V ā š¤ α, IsOpen V ā§ ā x ā K, UniformSpace.ball x V ā U :=
let āØV, āØhV, hVoā©, hVUā© :=
(hK.nhdsSet_basis_uniformity uniformity_hasBasis_open).mem_iff.1 (hU.mem_nhdsSet.2 hKU)
āØV, hV, hVo, iUnionā_subset_iff.1 hVUā©
end Compact
/-!
### Expressing continuity properties in uniform spaces
We reformulate the various continuity properties of functions taking values in a uniform space
in terms of the uniformity in the target. Since the same lemmas (essentially with the same names)
also exist for metric spaces and emetric spaces (reformulating things in terms of the distance or
the edistance in the target), we put them in a namespace `Uniform` here.
In the metric and emetric space setting, there are also similar lemmas where one assumes that
both the source and the target are metric spaces, reformulating things in terms of the distance
on both sides. These lemmas are generally written without primes, and the versions where only
the target is a metric space is primed. We follow the same convention here, thus giving lemmas
with primes.
-/
namespace Uniform
variable [UniformSpace α]
theorem tendsto_nhds_right {f : Filter β} {u : β ā α} {a : α} :
Tendsto u f (š a) ā Tendsto (fun x => (a, u x)) f (š¤ α) := by
rw [nhds_eq_comap_uniformity, tendsto_comap_iff]; rfl
theorem tendsto_nhds_left {f : Filter β} {u : β ā α} {a : α} :
Tendsto u f (š a) ā Tendsto (fun x => (u x, a)) f (š¤ α) := by
rw [nhds_eq_comap_uniformity', tendsto_comap_iff]; rfl
theorem continuousAt_iff'_right [TopologicalSpace β] {f : β ā α} {b : β} :
ContinuousAt f b ā Tendsto (fun x => (f b, f x)) (š b) (š¤ α) := by
rw [ContinuousAt, tendsto_nhds_right]
theorem continuousAt_iff'_left [TopologicalSpace β] {f : β ā α} {b : β} :
ContinuousAt f b ā Tendsto (fun x => (f x, f b)) (š b) (š¤ α) := by
rw [ContinuousAt, tendsto_nhds_left]
theorem continuousAt_iff_prod [TopologicalSpace β] {f : β ā α} {b : β} :
ContinuousAt f b ā Tendsto (fun x : β à β => (f x.1, f x.2)) (š (b, b)) (š¤ α) :=
āØfun H => le_trans (H.prod_map' H) (nhds_le_uniformity _), fun H =>
continuousAt_iff'_left.2 <| H.comp <| tendsto_id.prod_mk_nhds tendsto_const_nhdsā©
theorem continuousWithinAt_iff'_right [TopologicalSpace β] {f : β ā α} {b : β} {s : Set β} :
ContinuousWithinAt f s b ā Tendsto (fun x => (f b, f x)) (š[s] b) (š¤ α) := by
rw [ContinuousWithinAt, tendsto_nhds_right]
theorem continuousWithinAt_iff'_left [TopologicalSpace β] {f : β ā α} {b : β} {s : Set β} :
ContinuousWithinAt f s b ā Tendsto (fun x => (f x, f b)) (š[s] b) (š¤ α) := by
rw [ContinuousWithinAt, tendsto_nhds_left]
theorem continuousOn_iff'_right [TopologicalSpace β] {f : β ā α} {s : Set β} :
ContinuousOn f s ā ā b ā s, Tendsto (fun x => (f b, f x)) (š[s] b) (š¤ α) := by
simp [ContinuousOn, continuousWithinAt_iff'_right]
theorem continuousOn_iff'_left [TopologicalSpace β] {f : β ā α} {s : Set β} :
ContinuousOn f s ā ā b ā s, Tendsto (fun x => (f x, f b)) (š[s] b) (š¤ α) := by
simp [ContinuousOn, continuousWithinAt_iff'_left]
theorem continuous_iff'_right [TopologicalSpace β] {f : β ā α} :
Continuous f ā ā b, Tendsto (fun x => (f b, f x)) (š b) (š¤ α) :=
continuous_iff_continuousAt.trans <| forall_congr' fun _ => tendsto_nhds_right
theorem continuous_iff'_left [TopologicalSpace β] {f : β ā α} :
Continuous f ā ā b, Tendsto (fun x => (f x, f b)) (š b) (š¤ α) :=
continuous_iff_continuousAt.trans <| forall_congr' fun _ => tendsto_nhds_left
/-- Consider two functions `f` and `g` which coincide on a set `s` and are continuous there.
Then there is an open neighborhood of `s` on which `f` and `g` are uniformly close. -/
lemma exists_is_open_mem_uniformity_of_forall_mem_eq
[TopologicalSpace β] {r : Set (α à α)} {s : Set β}
{f g : β ā α} (hf : ā x ā s, ContinuousAt f x) (hg : ā x ā s, ContinuousAt g x)
(hfg : s.EqOn f g) (hr : r ā š¤ α) :
ā t, IsOpen t ā§ s ā t ā§ ā x ā t, (f x, g x) ā r := by
have A : ā x ā s, ā t, IsOpen t ā§ x ā t ā§ ā z ā t, (f z, g z) ā r := by
intro x hx
obtain āØt, ht, htsymm, htrā© := comp_symm_mem_uniformity_sets hr
have A : {z | (f x, f z) ā t} ā š x := (hf x hx).preimage_mem_nhds (mem_nhds_left (f x) ht)
have B : {z | (g x, g z) ā t} ā š x := (hg x hx).preimage_mem_nhds (mem_nhds_left (g x) ht)
rcases _root_.mem_nhds_iff.1 (inter_mem A B) with āØu, hu, u_open, xuā©
refine āØu, u_open, xu, fun y hy ⦠?_ā©
have I1 : (f y, f x) ā t := (htsymm.mk_mem_comm).2 (hu hy).1
have I2 : (g x, g y) ā t := (hu hy).2
rw [hfg hx] at I1
exact htr (prod_mk_mem_compRel I1 I2)
choose! t t_open xt ht using A
refine āØā x ā s, t x, isOpen_biUnion t_open, fun x hx ⦠mem_biUnion hx (xt x hx), ?_ā©
rintro x hx
simp only [mem_iUnion, exists_prop] at hx
rcases hx with āØy, ys, hyā©
exact ht y ys x hy
end Uniform
theorem Filter.Tendsto.congr_uniformity {α β} [UniformSpace β] {f g : α ā β} {l : Filter α} {b : β}
(hf : Tendsto f l (š b)) (hg : Tendsto (fun x => (f x, g x)) l (š¤ β)) : Tendsto g l (š b) :=
Uniform.tendsto_nhds_right.2 <| (Uniform.tendsto_nhds_right.1 hf).uniformity_trans hg
theorem Uniform.tendsto_congr {α β} [UniformSpace β] {f g : α ā β} {l : Filter α} {b : β}
(hfg : Tendsto (fun x => (f x, g x)) l (š¤ β)) : Tendsto f l (š b) ā Tendsto g l (š b) :=
āØfun h => h.congr_uniformity hfg, fun h => h.congr_uniformity hfg.uniformity_symmā©
|
Topology\UniformSpace\Cauchy.lean
|
/-
Copyright (c) 2017 Johannes Hƶlzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hƶlzl, Mario Carneiro
-/
import Mathlib.Topology.Algebra.Constructions
import Mathlib.Topology.Bases
import Mathlib.Topology.UniformSpace.Basic
/-!
# Theory of Cauchy filters in uniform spaces. Complete uniform spaces. Totally bounded subsets.
-/
universe u v
open Filter Function TopologicalSpace Topology Set UniformSpace Uniformity
variable {α : Type u} {β : Type v} [uniformSpace : UniformSpace α]
/-- A filter `f` is Cauchy if for every entourage `r`, there exists an
`s ā f` such that `s Ć s ā r`. This is a generalization of Cauchy
sequences, because if `a : ā ā α` then the filter of sets containing
cofinitely many of the `a n` is Cauchy iff `a` is a Cauchy sequence. -/
def Cauchy (f : Filter α) :=
NeBot f ā§ f ĆĖ¢ f ⤠š¤ α
/-- A set `s` is called *complete*, if any Cauchy filter `f` such that `s ā f`
has a limit in `s` (formally, it satisfies `f ⤠š x` for some `x ā s`). -/
def IsComplete (s : Set α) :=
ā f, Cauchy f ā f ⤠š s ā ā x ā s, f ⤠š x
theorem Filter.HasBasis.cauchy_iff {ι} {p : ι ā Prop} {s : ι ā Set (α à α)} (h : (š¤ α).HasBasis p s)
{f : Filter α} :
Cauchy f ā NeBot f ā§ ā i, p i ā ā t ā f, ā x ā t, ā y ā t, (x, y) ā s i :=
and_congr Iff.rfl <|
(f.basis_sets.prod_self.le_basis_iff h).trans <| by
simp only [subset_def, Prod.forall, mem_prod_eq, and_imp, id, forall_mem_comm]
theorem cauchy_iff' {f : Filter α} :
Cauchy f ā NeBot f ā§ ā s ā š¤ α, ā t ā f, ā x ā t, ā y ā t, (x, y) ā s :=
(š¤ α).basis_sets.cauchy_iff
theorem cauchy_iff {f : Filter α} : Cauchy f ā NeBot f ā§ ā s ā š¤ α, ā t ā f, t ĆĖ¢ t ā s :=
cauchy_iff'.trans <| by
simp only [subset_def, Prod.forall, mem_prod_eq, and_imp, id, forall_mem_comm]
lemma cauchy_iff_le {l : Filter α} [hl : l.NeBot] :
Cauchy l ā l ĆĖ¢ l ⤠š¤ α := by
simp only [Cauchy, hl, true_and]
theorem Cauchy.ultrafilter_of {l : Filter α} (h : Cauchy l) :
Cauchy (@Ultrafilter.of _ l h.1 : Filter α) := by
haveI := h.1
have := Ultrafilter.of_le l
exact āØUltrafilter.neBot _, (Filter.prod_mono this this).trans h.2ā©
theorem cauchy_map_iff {l : Filter β} {f : β ā α} :
Cauchy (l.map f) ā NeBot l ā§ Tendsto (fun p : β à β => (f p.1, f p.2)) (l ĆĖ¢ l) (š¤ α) := by
rw [Cauchy, map_neBot_iff, prod_map_map_eq, Tendsto]
theorem cauchy_map_iff' {l : Filter β} [hl : NeBot l] {f : β ā α} :
Cauchy (l.map f) ā Tendsto (fun p : β à β => (f p.1, f p.2)) (l ĆĖ¢ l) (š¤ α) :=
cauchy_map_iff.trans <| and_iff_right hl
theorem Cauchy.mono {f g : Filter α} [hg : NeBot g] (h_c : Cauchy f) (h_le : g ⤠f) : Cauchy g :=
āØhg, le_trans (Filter.prod_mono h_le h_le) h_c.rightā©
theorem Cauchy.mono' {f g : Filter α} (h_c : Cauchy f) (_ : NeBot g) (h_le : g ⤠f) : Cauchy g :=
h_c.mono h_le
theorem cauchy_nhds {a : α} : Cauchy (š a) :=
āØnhds_neBot, nhds_prod_eq.symm.trans_le (nhds_le_uniformity a)ā©
theorem cauchy_pure {a : α} : Cauchy (pure a) :=
cauchy_nhds.mono (pure_le_nhds a)
theorem Filter.Tendsto.cauchy_map {l : Filter β} [NeBot l] {f : β ā α} {a : α}
(h : Tendsto f l (š a)) : Cauchy (map f l) :=
cauchy_nhds.mono h
lemma Cauchy.mono_uniformSpace {u v : UniformSpace β} {F : Filter β} (huv : u ⤠v)
(hF : Cauchy (uniformSpace := u) F) : Cauchy (uniformSpace := v) F :=
āØhF.1, hF.2.trans huvā©
lemma cauchy_inf_uniformSpace {u v : UniformSpace β} {F : Filter β} :
Cauchy (uniformSpace := u ā v) F ā
Cauchy (uniformSpace := u) F ā§ Cauchy (uniformSpace := v) F := by
unfold Cauchy
rw [inf_uniformity (u := u), le_inf_iff, and_and_left]
lemma cauchy_iInf_uniformSpace {ι : Sort*} [Nonempty ι] {u : ι ā UniformSpace β}
{l : Filter β} :
Cauchy (uniformSpace := āØ
i, u i) l ā ā i, Cauchy (uniformSpace := u i) l := by
unfold Cauchy
rw [iInf_uniformity, le_iInf_iff, forall_and, forall_const]
lemma cauchy_iInf_uniformSpace' {ι : Sort*} {u : ι ā UniformSpace β}
{l : Filter β} [l.NeBot] :
Cauchy (uniformSpace := āØ
i, u i) l ā ā i, Cauchy (uniformSpace := u i) l := by
simp_rw [cauchy_iff_le (uniformSpace := _), iInf_uniformity, le_iInf_iff]
lemma cauchy_comap_uniformSpace {u : UniformSpace β} {α} {f : α ā β} {l : Filter α} :
Cauchy (uniformSpace := comap f u) l ā Cauchy (map f l) := by
simp only [Cauchy, map_neBot_iff, prod_map_map_eq, map_le_iff_le_comap]
rfl
lemma cauchy_prod_iff [UniformSpace β] {F : Filter (α à β)} :
Cauchy F ā Cauchy (map Prod.fst F) ā§ Cauchy (map Prod.snd F) := by
simp_rw [instUniformSpaceProd, ā cauchy_comap_uniformSpace, ā cauchy_inf_uniformSpace]
theorem Cauchy.prod [UniformSpace β] {f : Filter α} {g : Filter β} (hf : Cauchy f) (hg : Cauchy g) :
Cauchy (f ĆĖ¢ g) := by
have := hf.1; have := hg.1
simpa [cauchy_prod_iff, hf.1] using āØhf, hgā©
/-- The common part of the proofs of `le_nhds_of_cauchy_adhp` and
`SequentiallyComplete.le_nhds_of_seq_tendsto_nhds`: if for any entourage `s`
one can choose a set `t ā f` of diameter `s` such that it contains a point `y`
with `(x, y) ā s`, then `f` converges to `x`. -/
theorem le_nhds_of_cauchy_adhp_aux {f : Filter α} {x : α}
(adhs : ā s ā š¤ α, ā t ā f, t ĆĖ¢ t ā s ā§ ā y, (x, y) ā s ā§ y ā t) : f ⤠š x := by
-- Consider a neighborhood `s` of `x`
intro s hs
-- Take an entourage twice smaller than `s`
rcases comp_mem_uniformity_sets (mem_nhds_uniformity_iff_right.1 hs) with āØU, U_mem, hUā©
-- Take a set `t ā f`, `t Ć t ā U`, and a point `y ā t` such that `(x, y) ā U`
rcases adhs U U_mem with āØt, t_mem, ht, y, hxy, hyā©
apply mem_of_superset t_mem
-- Given a point `z ā t`, we have `(x, y) ā U` and `(y, z) ā t Ć t ā U`, hence `z ā s`
exact fun z hz => hU (prod_mk_mem_compRel hxy (ht <| mk_mem_prod hy hz)) rfl
/-- If `x` is an adherent (cluster) point for a Cauchy filter `f`, then it is a limit point
for `f`. -/
theorem le_nhds_of_cauchy_adhp {f : Filter α} {x : α} (hf : Cauchy f) (adhs : ClusterPt x f) :
f ⤠š x :=
le_nhds_of_cauchy_adhp_aux
(fun s hs => by
obtain āØt, t_mem, htā© : ā t ā f, t ĆĖ¢ t ā s := (cauchy_iff.1 hf).2 s hs
use t, t_mem, ht
exact forall_mem_nonempty_iff_neBot.2 adhs _ (inter_mem_inf (mem_nhds_left x hs) t_mem))
theorem le_nhds_iff_adhp_of_cauchy {f : Filter α} {x : α} (hf : Cauchy f) :
f ⤠š x ā ClusterPt x f :=
āØfun h => ClusterPt.of_le_nhds' h hf.1, le_nhds_of_cauchy_adhp hfā©
nonrec theorem Cauchy.map [UniformSpace β] {f : Filter α} {m : α ā β} (hf : Cauchy f)
(hm : UniformContinuous m) : Cauchy (map m f) :=
āØhf.1.map _,
calc
map m f ĆĖ¢ map m f = map (Prod.map m m) (f ĆĖ¢ f) := Filter.prod_map_map_eq
_ ⤠Filter.map (Prod.map m m) (š¤ α) := map_mono hf.right
_ ⤠š¤ β := hmā©
nonrec theorem Cauchy.comap [UniformSpace β] {f : Filter β} {m : α ā β} (hf : Cauchy f)
(hm : comap (fun p : α à α => (m p.1, m p.2)) (š¤ β) ⤠š¤ α) [NeBot (comap m f)] :
Cauchy (comap m f) :=
āØā¹_āŗ,
calc
comap m f ĆĖ¢ comap m f = comap (Prod.map m m) (f ĆĖ¢ f) := prod_comap_comap_eq
_ ⤠comap (Prod.map m m) (š¤ β) := comap_mono hf.right
_ ⤠š¤ α := hmā©
theorem Cauchy.comap' [UniformSpace β] {f : Filter β} {m : α ā β} (hf : Cauchy f)
(hm : Filter.comap (fun p : α à α => (m p.1, m p.2)) (š¤ β) ⤠š¤ α)
(_ : NeBot (Filter.comap m f)) : Cauchy (Filter.comap m f) :=
hf.comap hm
/-- Cauchy sequences. Usually defined on ā, but often it is also useful to say that a function
defined on ā is Cauchy at +ā to deduce convergence. Therefore, we define it in a type class that
is general enough to cover both ā and ā, which are the main motivating examples. -/
def CauchySeq [Preorder β] (u : β ā α) :=
Cauchy (atTop.map u)
theorem CauchySeq.tendsto_uniformity [Preorder β] {u : β ā α} (h : CauchySeq u) :
Tendsto (Prod.map u u) atTop (š¤ α) := by
simpa only [Tendsto, prod_map_map_eq', prod_atTop_atTop_eq] using h.right
theorem CauchySeq.nonempty [Preorder β] {u : β ā α} (hu : CauchySeq u) : Nonempty β :=
@nonempty_of_neBot _ _ <| (map_neBot_iff _).1 hu.1
theorem CauchySeq.mem_entourage {β : Type*} [SemilatticeSup β] {u : β ā α} (h : CauchySeq u)
{V : Set (α à α)} (hV : V ā š¤ α) : ā kā, ā i j, kā ⤠i ā kā ⤠j ā (u i, u j) ā V := by
haveI := h.nonempty
have := h.tendsto_uniformity; rw [ā prod_atTop_atTop_eq] at this
simpa [MapsTo] using atTop_basis.prod_self.tendsto_left_iff.1 this V hV
theorem Filter.Tendsto.cauchySeq [SemilatticeSup β] [Nonempty β] {f : β ā α} {x}
(hx : Tendsto f atTop (š x)) : CauchySeq f :=
hx.cauchy_map
theorem cauchySeq_const [SemilatticeSup β] [Nonempty β] (x : α) : CauchySeq fun _ : β => x :=
tendsto_const_nhds.cauchySeq
theorem cauchySeq_iff_tendsto [Nonempty β] [SemilatticeSup β] {u : β ā α} :
CauchySeq u ā Tendsto (Prod.map u u) atTop (š¤ α) :=
cauchy_map_iff'.trans <| by simp only [prod_atTop_atTop_eq, Prod.map_def]
theorem CauchySeq.comp_tendsto {γ} [Preorder β] [SemilatticeSup γ] [Nonempty γ] {f : β ā α}
(hf : CauchySeq f) {g : γ ā β} (hg : Tendsto g atTop atTop) : CauchySeq (f ā g) :=
āØinferInstance, le_trans (prod_le_prod.mpr āØTendsto.comp le_rfl hg, Tendsto.comp le_rfl hgā©) hf.2ā©
theorem CauchySeq.comp_injective [SemilatticeSup β] [NoMaxOrder β] [Nonempty β] {u : ā ā α}
(hu : CauchySeq u) {f : β ā ā} (hf : Injective f) : CauchySeq (u ā f) :=
hu.comp_tendsto <| Nat.cofinite_eq_atTop āø hf.tendsto_cofinite.mono_left atTop_le_cofinite
theorem Function.Bijective.cauchySeq_comp_iff {f : ā ā ā} (hf : Bijective f) (u : ā ā α) :
CauchySeq (u ā f) ā CauchySeq u := by
refine āØfun H => ?_, fun H => H.comp_injective hf.injectiveā©
lift f to ā ā ā using hf
simpa only [(Ā· ā Ā·), f.apply_symm_apply] using H.comp_injective f.symm.injective
theorem CauchySeq.subseq_subseq_mem {V : ā ā Set (α à α)} (hV : ā n, V n ā š¤ α) {u : ā ā α}
(hu : CauchySeq u) {f g : ā ā ā} (hf : Tendsto f atTop atTop) (hg : Tendsto g atTop atTop) :
ā Ļ : ā ā ā, StrictMono Ļ ā§ ā n, ((u ā f ā Ļ) n, (u ā g ā Ļ) n) ā V n := by
rw [cauchySeq_iff_tendsto] at hu
exact ((hu.comp <| hf.prod_atTop hg).comp tendsto_atTop_diagonal).subseq_mem hV
-- todo: generalize this and other lemmas to a nonempty semilattice
theorem cauchySeq_iff' {u : ā ā α} :
CauchySeq u ā ā V ā š¤ α, āį¶ k in atTop, k ā Prod.map u u ā»Ā¹' V :=
cauchySeq_iff_tendsto
theorem cauchySeq_iff {u : ā ā α} :
CauchySeq u ā ā V ā š¤ α, ā N, ā k ā„ N, ā l ā„ N, (u k, u l) ā V := by
simp only [cauchySeq_iff', Filter.eventually_atTop_prod_self', mem_preimage, Prod.map_apply]
theorem CauchySeq.prod_map {γ Ī“} [UniformSpace β] [Preorder γ] [Preorder Ī“] {u : γ ā α}
{v : Ī“ ā β} (hu : CauchySeq u) (hv : CauchySeq v) : CauchySeq (Prod.map u v) := by
simpa only [CauchySeq, prod_map_map_eq', prod_atTop_atTop_eq] using hu.prod hv
theorem CauchySeq.prod {γ} [UniformSpace β] [Preorder γ] {u : γ ā α} {v : γ ā β}
(hu : CauchySeq u) (hv : CauchySeq v) : CauchySeq fun x => (u x, v x) :=
haveI := hu.1.of_map
(Cauchy.prod hu hv).mono (Tendsto.prod_mk le_rfl le_rfl)
theorem CauchySeq.eventually_eventually [SemilatticeSup β] {u : β ā α} (hu : CauchySeq u)
{V : Set (α à α)} (hV : V ā š¤ α) : āį¶ k in atTop, āį¶ l in atTop, (u k, u l) ā V :=
eventually_atTop_curry <| hu.tendsto_uniformity hV
theorem UniformContinuous.comp_cauchySeq {γ} [UniformSpace β] [Preorder γ] {f : α ā β}
(hf : UniformContinuous f) {u : γ ā α} (hu : CauchySeq u) : CauchySeq (f ā u) :=
hu.map hf
theorem CauchySeq.subseq_mem {V : ā ā Set (α à α)} (hV : ā n, V n ā š¤ α) {u : ā ā α}
(hu : CauchySeq u) : ā Ļ : ā ā ā, StrictMono Ļ ā§ ā n, (u <| Ļ (n + 1), u <| Ļ n) ā V n := by
have : ā n, ā N, ā k ā„ N, ā l ā„ k, (u l, u k) ā V n := fun n => by
rw [cauchySeq_iff] at hu
rcases hu _ (hV n) with āØN, Hā©
exact āØN, fun k hk l hl => H _ (le_trans hk hl) _ hkā©
obtain āØĻ : ā ā ā, Ļ_extr : StrictMono Ļ, hĻ : ā n, ā l ā„ Ļ n, (u l, u <| Ļ n) ā V nā© :=
extraction_forall_of_eventually' this
exact āØĻ, Ļ_extr, fun n => hĻ _ _ (Ļ_extr <| lt_add_one n).leā©
theorem Filter.Tendsto.subseq_mem_entourage {V : ā ā Set (α à α)} (hV : ā n, V n ā š¤ α) {u : ā ā α}
{a : α} (hu : Tendsto u atTop (š a)) : ā Ļ : ā ā ā, StrictMono Ļ ā§ (u (Ļ 0), a) ā V 0 ā§
ā n, (u <| Ļ (n + 1), u <| Ļ n) ā V (n + 1) := by
rcases mem_atTop_sets.1 (hu (ball_mem_nhds a (symm_le_uniformity <| hV 0))) with āØn, hnā©
rcases (hu.comp (tendsto_add_atTop_nat n)).cauchySeq.subseq_mem fun n => hV (n + 1) with
āØĻ, Ļ_mono, hĻVā©
exact āØfun k => Ļ k + n, Ļ_mono.add_const _, hn _ le_add_self, hĻVā©
/-- If a Cauchy sequence has a convergent subsequence, then it converges. -/
theorem tendsto_nhds_of_cauchySeq_of_subseq [Preorder β] {u : β ā α} (hu : CauchySeq u)
{ι : Type*} {f : ι ā β} {p : Filter ι} [NeBot p] (hf : Tendsto f p atTop) {a : α}
(ha : Tendsto (u ā f) p (š a)) : Tendsto u atTop (š a) :=
le_nhds_of_cauchy_adhp hu (mapClusterPt_of_comp hf ha)
/-- Any shift of a Cauchy sequence is also a Cauchy sequence. -/
theorem cauchySeq_shift {u : ā ā α} (k : ā) : CauchySeq (fun n ⦠u (n + k)) ā CauchySeq u := by
constructor <;> intro h
Ā· rw [cauchySeq_iff] at h ā¢
intro V mV
obtain āØN, hā© := h V mV
use N + k
intro a ha b hb
convert h (a - k) (Nat.le_sub_of_add_le ha) (b - k) (Nat.le_sub_of_add_le hb) <;> omega
Ā· exact h.comp_tendsto (tendsto_add_atTop_nat k)
theorem Filter.HasBasis.cauchySeq_iff {γ} [Nonempty β] [SemilatticeSup β] {u : β ā α} {p : γ ā Prop}
{s : γ ā Set (α à α)} (h : (š¤ α).HasBasis p s) :
CauchySeq u ā ā i, p i ā ā N, ā m, N ⤠m ā ā n, N ⤠n ā (u m, u n) ā s i := by
rw [cauchySeq_iff_tendsto, ā prod_atTop_atTop_eq]
refine (atTop_basis.prod_self.tendsto_iff h).trans ?_
simp only [exists_prop, true_and_iff, MapsTo, preimage, subset_def, Prod.forall, mem_prod_eq,
mem_setOf_eq, mem_Ici, and_imp, Prod.map, @forall_swap (_ ⤠_) β]
theorem Filter.HasBasis.cauchySeq_iff' {γ} [Nonempty β] [SemilatticeSup β] {u : β ā α}
{p : γ ā Prop} {s : γ ā Set (α à α)} (H : (š¤ α).HasBasis p s) :
CauchySeq u ā ā i, p i ā ā N, ā n ā„ N, (u n, u N) ā s i := by
refine H.cauchySeq_iff.trans āØfun h i hi => ?_, fun h i hi => ?_ā©
Ā· exact (h i hi).imp fun N hN n hn => hN n hn N le_rfl
Ā· rcases comp_symm_of_uniformity (H.mem_of_mem hi) with āØt, ht, ht', htsā©
rcases H.mem_iff.1 ht with āØj, hj, hjtā©
refine (h j hj).imp fun N hN m hm n hn => hts āØu N, hjt ?_, ht' <| hjt ?_ā©
exacts [hN m hm, hN n hn]
theorem cauchySeq_of_controlled [SemilatticeSup β] [Nonempty β] (U : β ā Set (α à α))
(hU : ā s ā š¤ α, ā n, U n ā s) {f : β ā α}
(hf : ā ā¦N m n : βā¦, N ⤠m ā N ⤠n ā (f m, f n) ā U N) : CauchySeq f :=
-- Porting note: changed to semi-implicit arguments
cauchySeq_iff_tendsto.2
(by
intro s hs
rw [mem_map, mem_atTop_sets]
cases' hU s hs with N hN
refine āØ(N, N), fun mn hmn => ?_ā©
cases' mn with m n
exact hN (hf hmn.1 hmn.2))
theorem isComplete_iff_clusterPt {s : Set α} :
IsComplete s ā ā l, Cauchy l ā l ⤠š s ā ā x ā s, ClusterPt x l :=
forallā_congr fun _ hl _ => exists_congr fun _ => and_congr_right fun _ =>
le_nhds_iff_adhp_of_cauchy hl
theorem isComplete_iff_ultrafilter {s : Set α} :
IsComplete s ā ā l : Ultrafilter α, Cauchy (l : Filter α) ā āl ⤠š s ā ā x ā s, āl ⤠š x := by
refine āØfun h l => h l, fun H => isComplete_iff_clusterPt.2 fun l hl hls => ?_ā©
haveI := hl.1
rcases H (Ultrafilter.of l) hl.ultrafilter_of ((Ultrafilter.of_le l).trans hls) with āØx, hxs, hxlā©
exact āØx, hxs, (ClusterPt.of_le_nhds hxl).mono (Ultrafilter.of_le l)ā©
theorem isComplete_iff_ultrafilter' {s : Set α} :
IsComplete s ā ā l : Ultrafilter α, Cauchy (l : Filter α) ā s ā l ā ā x ā s, āl ⤠š x :=
isComplete_iff_ultrafilter.trans <| by simp only [le_principal_iff, Ultrafilter.mem_coe]
protected theorem IsComplete.union {s t : Set α} (hs : IsComplete s) (ht : IsComplete t) :
IsComplete (s āŖ t) := by
simp only [isComplete_iff_ultrafilter', Ultrafilter.union_mem_iff, or_imp] at *
exact fun l hl =>
āØfun hsl => (hs l hl hsl).imp fun x hx => āØOr.inl hx.1, hx.2ā©, fun htl =>
(ht l hl htl).imp fun x hx => āØOr.inr hx.1, hx.2ā©ā©
theorem isComplete_iUnion_separated {ι : Sort*} {s : ι ā Set α} (hs : ā i, IsComplete (s i))
{U : Set (α à α)} (hU : U ā š¤ α) (hd : ā (i j : ι), ā x ā s i, ā y ā s j, (x, y) ā U ā i = j) :
IsComplete (ā i, s i) := by
set S := ā i, s i
intro l hl hls
rw [le_principal_iff] at hls
cases' cauchy_iff.1 hl with hl_ne hl'
obtain āØt, htS, htl, htUā© : ā t, t ā S ā§ t ā l ā§ t ĆĖ¢ t ā U := by
rcases hl' U hU with āØt, htl, htUā©
refine āØt ā© S, inter_subset_right, inter_mem htl hls, Subset.trans ?_ htUā©
gcongr <;> apply inter_subset_left
obtain āØi, hiā© : ā i, t ā s i := by
rcases Filter.nonempty_of_mem htl with āØx, hxā©
rcases mem_iUnion.1 (htS hx) with āØi, hiā©
refine āØi, fun y hy => ?_ā©
rcases mem_iUnion.1 (htS hy) with āØj, hjā©
rwa [hd i j x hi y hj (htU <| mk_mem_prod hx hy)]
rcases hs i l hl (le_principal_iff.2 <| mem_of_superset htl hi) with āØx, hxs, hlxā©
exact āØx, mem_iUnion.2 āØi, hxsā©, hlxā©
/-- A complete space is defined here using uniformities. A uniform space
is complete if every Cauchy filter converges. -/
class CompleteSpace (α : Type u) [UniformSpace α] : Prop where
/-- In a complete uniform space, every Cauchy filter converges. -/
complete : ā {f : Filter α}, Cauchy f ā ā x, f ⤠š x
theorem complete_univ {α : Type u} [UniformSpace α] [CompleteSpace α] :
IsComplete (univ : Set α) := fun f hf _ => by
rcases CompleteSpace.complete hf with āØx, hxā©
exact āØx, mem_univ x, hxā©
instance CompleteSpace.prod [UniformSpace β] [CompleteSpace α] [CompleteSpace β] :
CompleteSpace (α à β) where
complete hf :=
let āØx1, hx1ā© := CompleteSpace.complete <| hf.map uniformContinuous_fst
let āØx2, hx2ā© := CompleteSpace.complete <| hf.map uniformContinuous_snd
āØ(x1, x2), by rw [nhds_prod_eq, le_prod]; constructor <;> assumptionā©
lemma CompleteSpace.fst_of_prod [UniformSpace β] [CompleteSpace (α à β)] [h : Nonempty β] :
CompleteSpace α where
complete hf :=
let āØyā© := h
let āØ(a, b), habā© := CompleteSpace.complete <| hf.prod <| cauchy_pure (a := y)
āØa, by simpa only [map_fst_prod, nhds_prod_eq] using map_mono (m := Prod.fst) habā©
lemma CompleteSpace.snd_of_prod [UniformSpace β] [CompleteSpace (α à β)] [h : Nonempty α] :
CompleteSpace β where
complete hf :=
let āØxā© := h
let āØ(a, b), habā© := CompleteSpace.complete <| (cauchy_pure (a := x)).prod hf
āØb, by simpa only [map_snd_prod, nhds_prod_eq] using map_mono (m := Prod.snd) habā©
lemma completeSpace_prod_of_nonempty [UniformSpace β] [Nonempty α] [Nonempty β] :
CompleteSpace (α à β) ā CompleteSpace α ā§ CompleteSpace β :=
āØfun _ ⦠āØ.fst_of_prod (β := β), .snd_of_prod (α := α)ā©, fun āØ_, _⩠⦠.prodā©
@[to_additive]
instance CompleteSpace.mulOpposite [CompleteSpace α] : CompleteSpace αįµįµįµ where
complete hf :=
MulOpposite.op_surjective.exists.mpr <|
let āØx, hxā© := CompleteSpace.complete (hf.map MulOpposite.uniformContinuous_unop)
āØx, (map_le_iff_le_comap.mp hx).trans_eq <| MulOpposite.comap_unop_nhds _ā©
/-- If `univ` is complete, the space is a complete space -/
theorem completeSpace_of_isComplete_univ (h : IsComplete (univ : Set α)) : CompleteSpace α :=
āØfun hf => let āØx, _, hxā© := h _ hf ((@principal_univ α).symm āø le_top); āØx, hxā©ā©
theorem completeSpace_iff_isComplete_univ : CompleteSpace α ā IsComplete (univ : Set α) :=
āØ@complete_univ α _, completeSpace_of_isComplete_univā©
theorem completeSpace_iff_ultrafilter :
CompleteSpace α ā ā l : Ultrafilter α, Cauchy (l : Filter α) ā ā x : α, āl ⤠š x := by
simp [completeSpace_iff_isComplete_univ, isComplete_iff_ultrafilter]
theorem cauchy_iff_exists_le_nhds [CompleteSpace α] {l : Filter α} [NeBot l] :
Cauchy l ā ā x, l ⤠š x :=
āØCompleteSpace.complete, fun āØ_, hxā© => cauchy_nhds.mono hxā©
theorem cauchy_map_iff_exists_tendsto [CompleteSpace α] {l : Filter β} {f : β ā α} [NeBot l] :
Cauchy (l.map f) ā ā x, Tendsto f l (š x) :=
cauchy_iff_exists_le_nhds
/-- A Cauchy sequence in a complete space converges -/
theorem cauchySeq_tendsto_of_complete [Preorder β] [CompleteSpace α] {u : β ā α}
(H : CauchySeq u) : ā x, Tendsto u atTop (š x) :=
CompleteSpace.complete H
/-- If `K` is a complete subset, then any cauchy sequence in `K` converges to a point in `K` -/
theorem cauchySeq_tendsto_of_isComplete [Preorder β] {K : Set α} (hā : IsComplete K)
{u : β ā α} (hā : ā n, u n ā K) (hā : CauchySeq u) : ā v ā K, Tendsto u atTop (š v) :=
hā _ hā <| le_principal_iff.2 <| mem_map_iff_exists_image.2
āØuniv, univ_mem, by rwa [image_univ, range_subset_iff]ā©
theorem Cauchy.le_nhds_lim [CompleteSpace α] {f : Filter α} (hf : Cauchy f) :
haveI := hf.1.nonempty; f ⤠š (lim f) :=
_root_.le_nhds_lim (CompleteSpace.complete hf)
theorem CauchySeq.tendsto_limUnder [Preorder β] [CompleteSpace α] {u : β ā α} (h : CauchySeq u) :
haveI := h.1.nonempty; Tendsto u atTop (š <| limUnder atTop u) :=
h.le_nhds_lim
theorem IsClosed.isComplete [CompleteSpace α] {s : Set α} (h : IsClosed s) : IsComplete s :=
fun _ cf fs =>
let āØx, hxā© := CompleteSpace.complete cf
āØx, isClosed_iff_clusterPt.mp h x (cf.left.mono (le_inf hx fs)), hxā©
/-- A set `s` is totally bounded if for every entourage `d` there is a finite
set of points `t` such that every element of `s` is `d`-near to some element of `t`. -/
def TotallyBounded (s : Set α) : Prop :=
ā d ā š¤ α, ā t : Set α, t.Finite ā§ s ā ā y ā t, { x | (x, y) ā d }
theorem TotallyBounded.exists_subset {s : Set α} (hs : TotallyBounded s) {U : Set (α à α)}
(hU : U ā š¤ α) : ā t, t ā s ā§ Set.Finite t ā§ s ā ā y ā t, { x | (x, y) ā U } := by
rcases comp_symm_of_uniformity hU with āØr, hr, rs, rUā©
rcases hs r hr with āØk, fk, ksā©
let u := k ā© { y | ā x ā s, (x, y) ā r }
choose f hfs hfr using fun x : u => x.coe_prop.2
refine āØrange f, ?_, ?_, ?_ā©
Ā· exact range_subset_iff.2 hfs
Ā· haveI : Fintype u := (fk.inter_of_left _).fintype
exact finite_range f
Ā· intro x xs
obtain āØy, hy, xyā© := mem_iUnionā.1 (ks xs)
rw [biUnion_range, mem_iUnion]
set z : ā„u := āØy, hy, āØx, xs, xyā©ā©
exact āØz, rU <| mem_compRel.2 āØy, xy, rs (hfr z)ā©ā©
theorem totallyBounded_iff_subset {s : Set α} :
TotallyBounded s ā
ā d ā š¤ α, ā t, t ā s ā§ Set.Finite t ā§ s ā ā y ā t, { x | (x, y) ā d } :=
āØfun H _ hd ⦠H.exists_subset hd, fun H d hd ⦠let āØt, _, htā© := H d hd; āØt, htā©ā©
theorem Filter.HasBasis.totallyBounded_iff {ι} {p : ι ā Prop} {U : ι ā Set (α à α)}
(H : (š¤ α).HasBasis p U) {s : Set α} :
TotallyBounded s ā ā i, p i ā ā t : Set α, Set.Finite t ā§ s ā ā y ā t, { x | (x, y) ā U i } :=
H.forall_iff fun _ _ hUV h =>
h.imp fun _ ht => āØht.1, ht.2.trans <| iUnionā_mono fun _ _ _ hy => hUV hyā©
theorem totallyBounded_of_forall_symm {s : Set α}
(h : ā V ā š¤ α, SymmetricRel V ā ā t : Set α, Set.Finite t ā§ s ā ā y ā t, ball y V) :
TotallyBounded s :=
UniformSpace.hasBasis_symmetric.totallyBounded_iff.2 fun V hV => by
simpa only [ball_eq_of_symmetry hV.2] using h V hV.1 hV.2
theorem TotallyBounded.subset {sā sā : Set α} (hs : sā ā sā) (h : TotallyBounded sā) :
TotallyBounded sā := fun d hd =>
let āØt, htā, htāā© := h d hd
āØt, htā, Subset.trans hs htāā©
@[deprecated (since := "2024-06-01")]
alias totallyBounded_subset := TotallyBounded.subset
/-- The closure of a totally bounded set is totally bounded. -/
theorem TotallyBounded.closure {s : Set α} (h : TotallyBounded s) : TotallyBounded (closure s) :=
uniformity_hasBasis_closed.totallyBounded_iff.2 fun V hV =>
let āØt, htf, hstā© := h V hV.1
āØt, htf,
closure_minimal hst <|
htf.isClosed_biUnion fun _ _ => hV.2.preimage (continuous_id.prod_mk continuous_const)ā©
@[simp]
lemma totallyBounded_closure {s : Set α} : TotallyBounded (closure s) ā TotallyBounded s :=
āØfun h ⦠h.subset subset_closure, TotallyBounded.closureā©
/-- A finite indexed union is totally bounded
if and only if each set of the family is totally bounded. -/
@[simp]
lemma totallyBounded_iUnion {ι : Sort*} [Finite ι] {s : ι ā Set α} :
TotallyBounded (ā i, s i) ā ā i, TotallyBounded (s i) := by
refine āØfun h i ⦠h.subset (subset_iUnion _ _), fun h U hU ⦠?_ā©
choose t htf ht using (h Ā· U hU)
refine āØā i, t i, finite_iUnion htf, ?_ā©
rw [biUnion_iUnion]
gcongr; apply ht
/-- A union indexed by a finite set is totally bounded
if and only if each set of the family is totally bounded. -/
lemma totallyBounded_biUnion {ι : Type*} {I : Set ι} (hI : I.Finite) {s : ι ā Set α} :
TotallyBounded (ā i ā I, s i) ā ā i ā I, TotallyBounded (s i) := by
have := hI.to_subtype
rw [biUnion_eq_iUnion, totallyBounded_iUnion, Subtype.forall]
/-- A union of a finite family of sets is totally bounded
if and only if each set of the family is totally bounded. -/
lemma totallyBounded_sUnion {S : Set (Set α)} (hS : S.Finite) :
TotallyBounded (āā S) ā ā s ā S, TotallyBounded s := by
rw [sUnion_eq_biUnion, totallyBounded_biUnion hS]
/-- A finite set is totally bounded. -/
lemma Set.Finite.totallyBounded {s : Set α} (hs : s.Finite) : TotallyBounded s := fun _U hU ā¦
āØs, hs, fun _x hx ⦠mem_biUnion hx <| refl_mem_uniformity hUā©
/-- A subsingleton is totally bounded. -/
lemma Set.Subsingleton.totallyBounded {s : Set α} (hs : s.Subsingleton) :
TotallyBounded s :=
hs.finite.totallyBounded
@[simp]
lemma totallyBounded_singleton (a : α) : TotallyBounded {a} := (finite_singleton a).totallyBounded
@[simp]
theorem totallyBounded_empty : TotallyBounded (ā
: Set α) := finite_empty.totallyBounded
/-- The union of two sets is totally bounded
if and only if each of the two sets is totally bounded.-/
@[simp]
lemma totallyBounded_union {s t : Set α} :
TotallyBounded (s āŖ t) ā TotallyBounded s ā§ TotallyBounded t := by
rw [union_eq_iUnion, totallyBounded_iUnion]
simp [and_comm]
/-- The union of two totally bounded sets is totally bounded. -/
protected lemma TotallyBounded.union {s t : Set α} (hs : TotallyBounded s) (ht : TotallyBounded t) :
TotallyBounded (s āŖ t) :=
totallyBounded_union.2 āØhs, htā©
@[simp]
lemma totallyBounded_insert (a : α) {s : Set α} :
TotallyBounded (insert a s) ā TotallyBounded s := by
simp_rw [ā singleton_union, totallyBounded_union, totallyBounded_singleton, true_and]
protected alias āØ_, TotallyBounded.insertā© := totallyBounded_insert
/-- The image of a totally bounded set under a uniformly continuous map is totally bounded. -/
theorem TotallyBounded.image [UniformSpace β] {f : α ā β} {s : Set α} (hs : TotallyBounded s)
(hf : UniformContinuous f) : TotallyBounded (f '' s) := fun t ht =>
have : { p : α à α | (f p.1, f p.2) ā t } ā š¤ α := hf ht
let āØc, hfc, hctā© := hs _ this
āØf '' c, hfc.image f, by
simp only [mem_image, iUnion_exists, biUnion_and', iUnion_iUnion_eq_right, image_subset_iff,
preimage_iUnion, preimage_setOf_eq]
simp? [subset_def] at hct says
simp only [mem_setOf_eq, subset_def, mem_iUnion, exists_prop] at hct
intro x hx; simp
exact hct x hxā©
theorem Ultrafilter.cauchy_of_totallyBounded {s : Set α} (f : Ultrafilter α) (hs : TotallyBounded s)
(h : āf ⤠š s) : Cauchy (f : Filter α) :=
āØf.neBot', fun _ ht =>
let āØt', ht'ā, ht'_symm, ht'_tā© := comp_symm_of_uniformity ht
let āØi, hi, hs_unionā© := hs t' ht'ā
have : (ā y ā i, { x | (x, y) ā t' }) ā f := mem_of_superset (le_principal_iff.mp h) hs_union
have : ā y ā i, { x | (x, y) ā t' } ā f := (Ultrafilter.finite_biUnion_mem_iff hi).1 this
let āØy, _, hifā© := this
have : { x | (x, y) ā t' } ĆĖ¢ { x | (x, y) ā t' } ā compRel t' t' :=
fun āØ_, _ā© āØ(hā : (_, y) ā t'), (hā : (_, y) ā t')ā© => āØy, hā, ht'_symm hāā©
mem_of_superset (prod_mem_prod hif hif) (Subset.trans this ht'_t)ā©
theorem totallyBounded_iff_filter {s : Set α} :
TotallyBounded s ā ā f, NeBot f ā f ⤠š s ā ā c ⤠f, Cauchy c := by
constructor
Ā· exact fun H f hf hfs => āØUltrafilter.of f, Ultrafilter.of_le f,
(Ultrafilter.of f).cauchy_of_totallyBounded H ((Ultrafilter.of_le f).trans hfs)ā©
Ā· intro H d hd
contrapose! H with hd_cover
set f := āØ
t : Finset α, š (s \ ā y ā t, { x | (x, y) ā d })
have hb : HasAntitoneBasis f fun t : Finset α ⦠s \ ā y ā t, { x | (x, y) ā d } :=
.iInf_principal fun _ _ ⦠diff_subset_diff_right ā biUnion_subset_biUnion_left
have : Filter.NeBot f := hb.1.neBot_iff.2 fun _ ā¦
nonempty_diff.2 <| hd_cover _ (Finset.finite_toSet _)
have : f ⤠š s := iInf_le_of_le ā
(by simp)
refine āØf, ā¹_āŗ, ā¹_āŗ, fun c hcf hc => ?_ā©
rcases mem_prod_same_iff.1 (hc.2 hd) with āØm, hm, hmdā©
rcases hc.1.nonempty_of_mem hm with āØy, hymā©
have : s \ {x | (x, y) ā d} ā c := by simpa using hcf (hb.mem {y})
rcases hc.1.nonempty_of_mem (inter_mem hm this) with āØz, hzm, -, hyzā©
exact hyz (hmd āØhzm, hymā©)
theorem totallyBounded_iff_ultrafilter {s : Set α} :
TotallyBounded s ā ā f : Ultrafilter α, āf ⤠š s ā Cauchy (f : Filter α) := by
refine āØfun hs f => f.cauchy_of_totallyBounded hs, fun H => totallyBounded_iff_filter.2 ?_ā©
intro f hf hfs
exact āØUltrafilter.of f, Ultrafilter.of_le f, H _ ((Ultrafilter.of_le f).trans hfs)ā©
theorem isCompact_iff_totallyBounded_isComplete {s : Set α} :
IsCompact s ā TotallyBounded s ā§ IsComplete s :=
āØfun hs =>
āØtotallyBounded_iff_ultrafilter.2 fun f hf =>
let āØ_, _, fxā© := isCompact_iff_ultrafilter_le_nhds.1 hs f hf
cauchy_nhds.mono fx,
fun f fc fs =>
let āØa, as, faā© := @hs f fc.1 fs
āØa, as, le_nhds_of_cauchy_adhp fc faā©ā©,
fun āØht, hcā© =>
isCompact_iff_ultrafilter_le_nhds.2 fun f hf =>
hc _ (totallyBounded_iff_ultrafilter.1 ht f hf) hfā©
protected theorem IsCompact.totallyBounded {s : Set α} (h : IsCompact s) : TotallyBounded s :=
(isCompact_iff_totallyBounded_isComplete.1 h).1
protected theorem IsCompact.isComplete {s : Set α} (h : IsCompact s) : IsComplete s :=
(isCompact_iff_totallyBounded_isComplete.1 h).2
-- see Note [lower instance priority]
instance (priority := 100) complete_of_compact {α : Type u} [UniformSpace α] [CompactSpace α] :
CompleteSpace α :=
āØfun hf => by simpa using (isCompact_iff_totallyBounded_isComplete.1 isCompact_univ).2 _ hfā©
theorem isCompact_of_totallyBounded_isClosed [CompleteSpace α] {s : Set α} (ht : TotallyBounded s)
(hc : IsClosed s) : IsCompact s :=
(@isCompact_iff_totallyBounded_isComplete α _ s).2 āØht, hc.isCompleteā©
/-- Every Cauchy sequence over `ā` is totally bounded. -/
theorem CauchySeq.totallyBounded_range {s : ā ā α} (hs : CauchySeq s) :
TotallyBounded (range s) := by
intro a ha
cases' cauchySeq_iff.1 hs a ha with n hn
refine āØs '' { k | k ⤠n }, (finite_le_nat _).image _, ?_ā©
rw [range_subset_iff, biUnion_image]
intro m
rw [mem_iUnionā]
rcases le_total m n with hm | hm
exacts [āØm, hm, refl_mem_uniformity haā©, āØn, le_refl n, hn m hm n le_rflā©]
/-!
### Sequentially complete space
In this section we prove that a uniform space is complete provided that it is sequentially complete
(i.e., any Cauchy sequence converges) and its uniformity filter admits a countable generating set.
In particular, this applies to (e)metric spaces, see the files `Topology/MetricSpace/EmetricSpace`
and `Topology/MetricSpace/Basic`.
More precisely, we assume that there is a sequence of entourages `U_n` such that any other
entourage includes one of `U_n`. Then any Cauchy filter `f` generates a decreasing sequence of
sets `s_n ā f` such that `s_n Ć s_n ā U_n`. Choose a sequence `x_nās_n`. It is easy to show
that this is a Cauchy sequence. If this sequence converges to some `a`, then `f ⤠š a`. -/
namespace SequentiallyComplete
variable {f : Filter α} (hf : Cauchy f) {U : ā ā Set (α à α)} (U_mem : ā n, U n ā š¤ α)
open Set Finset
noncomputable section
/-- An auxiliary sequence of sets approximating a Cauchy filter. -/
def setSeqAux (n : ā) : { s : Set α // s ā f ā§ s ĆĖ¢ s ā U n } :=
-- Porting note: changed `ā _ : s ā f, ..` to `s ā f ā§ ..`
Classical.indefiniteDescription _ <| (cauchy_iff.1 hf).2 (U n) (U_mem n)
/-- Given a Cauchy filter `f` and a sequence `U` of entourages, `set_seq` provides
an antitone sequence of sets `s n ā f` such that `s n ĆĖ¢ s n ā U`. -/
def setSeq (n : ā) : Set α :=
ā m ā Set.Iic n, (setSeqAux hf U_mem m).val
theorem setSeq_mem (n : ā) : setSeq hf U_mem n ā f :=
(biInter_mem (finite_le_nat n)).2 fun m _ => (setSeqAux hf U_mem m).2.1
theorem setSeq_mono ā¦m n : ā⦠(h : m ⤠n) : setSeq hf U_mem n ā setSeq hf U_mem m :=
biInter_subset_biInter_left <| Iic_subset_Iic.2 h
theorem setSeq_sub_aux (n : ā) : setSeq hf U_mem n ā setSeqAux hf U_mem n :=
biInter_subset_of_mem right_mem_Iic
theorem setSeq_prod_subset {N m n} (hm : N ⤠m) (hn : N ⤠n) :
setSeq hf U_mem m ĆĖ¢ setSeq hf U_mem n ā U N := fun p hp => by
refine (setSeqAux hf U_mem N).2.2 �_, ?_⩠<;> apply setSeq_sub_aux
Ā· exact setSeq_mono hf U_mem hm hp.1
Ā· exact setSeq_mono hf U_mem hn hp.2
/-- A sequence of points such that `seq n ā setSeq n`. Here `setSeq` is an antitone
sequence of sets `setSeq n ā f` with diameters controlled by a given sequence
of entourages. -/
def seq (n : ā) : α :=
(hf.1.nonempty_of_mem (setSeq_mem hf U_mem n)).choose
theorem seq_mem (n : ā) : seq hf U_mem n ā setSeq hf U_mem n :=
(hf.1.nonempty_of_mem (setSeq_mem hf U_mem n)).choose_spec
theorem seq_pair_mem ā¦N m n : ā⦠(hm : N ⤠m) (hn : N ⤠n) :
(seq hf U_mem m, seq hf U_mem n) ā U N :=
setSeq_prod_subset hf U_mem hm hn āØseq_mem hf U_mem m, seq_mem hf U_mem nā©
theorem seq_is_cauchySeq (U_le : ā s ā š¤ α, ā n, U n ā s) : CauchySeq <| seq hf U_mem :=
cauchySeq_of_controlled U U_le <| seq_pair_mem hf U_mem
/-- If the sequence `SequentiallyComplete.seq` converges to `a`, then `f ⤠š a`. -/
theorem le_nhds_of_seq_tendsto_nhds (U_le : ā s ā š¤ α, ā n, U n ā s)
ā¦a : α⦠(ha : Tendsto (seq hf U_mem) atTop (š a)) : f ⤠š a :=
le_nhds_of_cauchy_adhp_aux
(fun s hs => by
rcases U_le s hs with āØm, hmā©
rcases tendsto_atTop'.1 ha _ (mem_nhds_left a (U_mem m)) with āØn, hnā©
refine
āØsetSeq hf U_mem (max m n), setSeq_mem hf U_mem _, ?_, seq hf U_mem (max m n), ?_,
seq_mem hf U_mem _ā©
Ā· have := le_max_left m n
exact Set.Subset.trans (setSeq_prod_subset hf U_mem this this) hm
Ā· exact hm (hn _ <| le_max_right m n))
end
end SequentiallyComplete
namespace UniformSpace
open SequentiallyComplete
variable [IsCountablyGenerated (š¤ α)]
/-- A uniform space is complete provided that (a) its uniformity filter has a countable basis;
(b) any sequence satisfying a "controlled" version of the Cauchy condition converges. -/
theorem complete_of_convergent_controlled_sequences (U : ā ā Set (α à α)) (U_mem : ā n, U n ā š¤ α)
(HU : ā u : ā ā α, (ā N m n, N ⤠m ā N ⤠n ā (u m, u n) ā U N) ā ā a, Tendsto u atTop (š a)) :
CompleteSpace α := by
obtain āØU', -, hU'ā© := (š¤ α).exists_antitone_seq
have Hmem : ā n, U n ā© U' n ā š¤ α := fun n => inter_mem (U_mem n) (hU'.2 āØn, Subset.refl _ā©)
refine āØfun hf => (HU (seq hf Hmem) fun N m n hm hn => ?_).imp <|
le_nhds_of_seq_tendsto_nhds _ _ fun s hs => ?_ā©
Ā· exact inter_subset_left (seq_pair_mem hf Hmem hm hn)
Ā· rcases hU'.1 hs with āØN, hNā©
exact āØN, Subset.trans inter_subset_right hNā©
/-- A sequentially complete uniform space with a countable basis of the uniformity filter is
complete. -/
theorem complete_of_cauchySeq_tendsto (H' : ā u : ā ā α, CauchySeq u ā ā a, Tendsto u atTop (š a)) :
CompleteSpace α :=
let āØU', _, hU'ā© := (š¤ α).exists_antitone_seq
complete_of_convergent_controlled_sequences U' (fun n => hU'.2 āØn, Subset.refl _ā©) fun u hu =>
H' u <| cauchySeq_of_controlled U' (fun _ hs => hU'.1 hs) hu
variable (α)
-- Porting note (#11215): TODO: move to `Topology.UniformSpace.Basic`
instance (priority := 100) firstCountableTopology : FirstCountableTopology α :=
āØfun a => by rw [nhds_eq_comap_uniformity]; infer_instanceā©
/-- A separable uniform space with countably generated uniformity filter is second countable:
one obtains a countable basis by taking the balls centered at points in a dense subset,
and with rational "radii" from a countable open symmetric antitone basis of `š¤ α`. We do not
register this as an instance, as there is already an instance going in the other direction
from second countable spaces to separable spaces, and we want to avoid loops. -/
theorem secondCountable_of_separable [SeparableSpace α] : SecondCountableTopology α := by
rcases exists_countable_dense α with āØs, hsc, hsdā©
obtain
āØt : ā ā Set (α à α), hto : ā i : ā, t i ā (š¤ α).sets ā§ IsOpen (t i) ā§ SymmetricRel (t i),
h_basis : (š¤ α).HasAntitoneBasis tā© :=
(@uniformity_hasBasis_open_symmetric α _).exists_antitone_subbasis
choose ht_mem hto hts using hto
refine āØāØā x ā s, range fun k => ball x (t k), hsc.biUnion fun x _ => countable_range _, ?_ā©ā©
refine (isTopologicalBasis_of_isOpen_of_nhds ?_ ?_).eq_generateFrom
Ā· simp only [mem_iUnionā, mem_range]
rintro _ āØx, _, k, rflā©
exact isOpen_ball x (hto k)
Ā· intro x V hxV hVo
simp only [mem_iUnionā, mem_range, exists_prop]
rcases UniformSpace.mem_nhds_iff.1 (IsOpen.mem_nhds hVo hxV) with āØU, hU, hUVā©
rcases comp_symm_of_uniformity hU with āØU', hU', _, hUU'ā©
rcases h_basis.toHasBasis.mem_iff.1 hU' with āØk, -, hkā©
rcases hsd.inter_open_nonempty (ball x <| t k) (isOpen_ball x (hto k))
āØx, UniformSpace.mem_ball_self _ (ht_mem k)ā© with
āØy, hxy, hysā©
refine āØ_, āØy, hys, k, rflā©, (hts k).subset hxy, fun z hz => ?_ā©
exact hUV (ball_subset_of_comp_subset (hk hxy) hUU' (hk hz))
end UniformSpace
|
Topology\UniformSpace\Compact.lean
|
/-
Copyright (c) 2020 Patrick Massot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot, Yury Kudryashov
-/
import Mathlib.Topology.UniformSpace.UniformConvergence
import Mathlib.Topology.UniformSpace.Equicontinuity
import Mathlib.Topology.Separation
import Mathlib.Topology.Support
/-!
# Compact separated uniform spaces
## Main statements
* `compactSpace_uniformity`: On a compact uniform space, the topology determines the
uniform structure, entourages are exactly the neighborhoods of the diagonal.
* `uniformSpace_of_compact_t2`: every compact T2 topological structure is induced by a uniform
structure. This uniform structure is described in the previous item.
* **Heine-Cantor** theorem: continuous functions on compact uniform spaces with values in uniform
spaces are automatically uniformly continuous. There are several variations, the main one is
`CompactSpace.uniformContinuous_of_continuous`.
## Implementation notes
The construction `uniformSpace_of_compact_t2` is not declared as an instance, as it would badly
loop.
## Tags
uniform space, uniform continuity, compact space
-/
open scoped Classical
open Uniformity Topology Filter UniformSpace Set
variable {α β γ : Type*} [UniformSpace α] [UniformSpace β]
/-!
### Uniformity on compact spaces
-/
/-- On a compact uniform space, the topology determines the uniform structure, entourages are
exactly the neighborhoods of the diagonal. -/
theorem nhdsSet_diagonal_eq_uniformity [CompactSpace α] : šĖ¢ (diagonal α) = š¤ α := by
refine nhdsSet_diagonal_le_uniformity.antisymm ?_
have :
(š¤ (α à α)).HasBasis (fun U => U ā š¤ α) fun U =>
(fun p : (α à α) à α à α => ((p.1.1, p.2.1), p.1.2, p.2.2)) ā»Ā¹' U ĆĖ¢ U := by
rw [uniformity_prod_eq_comap_prod]
exact (š¤ α).basis_sets.prod_self.comap _
refine (isCompact_diagonal.nhdsSet_basis_uniformity this).ge_iff.2 fun U hU => ?_
exact mem_of_superset hU fun āØx, yā© hxy => mem_iUnionā.2
āØ(x, x), rfl, refl_mem_uniformity hU, hxyā©
/-- On a compact uniform space, the topology determines the uniform structure, entourages are
exactly the neighborhoods of the diagonal. -/
theorem compactSpace_uniformity [CompactSpace α] : š¤ α = ⨠x, š (x, x) :=
nhdsSet_diagonal_eq_uniformity.symm.trans (nhdsSet_diagonal _)
theorem unique_uniformity_of_compact [t : TopologicalSpace γ] [CompactSpace γ]
{u u' : UniformSpace γ} (h : u.toTopologicalSpace = t) (h' : u'.toTopologicalSpace = t) :
u = u' := by
refine UniformSpace.ext ?_
have : @CompactSpace γ u.toTopologicalSpace := by rwa [h]
have : @CompactSpace γ u'.toTopologicalSpace := by rwa [h']
rw [@compactSpace_uniformity _ u, compactSpace_uniformity, h, h']
/-- The unique uniform structure inducing a given compact topological structure. -/
def uniformSpaceOfCompactT2 [TopologicalSpace γ] [CompactSpace γ] [T2Space γ] : UniformSpace γ where
uniformity := šĖ¢ (diagonal γ)
symm := continuous_swap.tendsto_nhdsSet fun x => Eq.symm
comp := by
/- This is the difficult part of the proof. We need to prove that, for each neighborhood `W`
of the diagonal `Ī`, there exists a smaller neighborhood `V` such that `V ā V ā W`.
-/
set šĪ := šĖ¢ (diagonal γ)
-- The filter of neighborhoods of Ī
set F := šĪ.lift' fun s : Set (γ à γ) => s ā s
-- Compositions of neighborhoods of Ī
-- If this weren't true, then there would be V ā šĪ such that F ā š Vį¶ ā ā„
rw [le_iff_forall_inf_principal_compl]
intro V V_in
by_contra H
haveI : NeBot (F ā š Vį¶) := āØHā©
-- Hence compactness would give us a cluster point (x, y) for F ā š Vį¶
obtain āØāØx, yā©, hxyā© : ā p : γ à γ, ClusterPt p (F ā š Vį¶) := exists_clusterPt_of_compactSpace _
-- In particular (x, y) is a cluster point of š Vį¶, hence is not in the interior of V,
-- and a fortiori not in Ī, so x ā y
have clV : ClusterPt (x, y) (š <| Vį¶) := hxy.of_inf_right
have : (x, y) ā interior V := by
have : (x, y) ā closure Vį¶ := by rwa [mem_closure_iff_clusterPt]
rwa [closure_compl] at this
have diag_subset : diagonal γ ā interior V := subset_interior_iff_mem_nhdsSet.2 V_in
have x_ne_y : x ā y := mt (@diag_subset (x, y)) this
-- Since γ is compact and Hausdorff, it is Tā, hence Tā.
-- So there are closed neighborhoods Vā and Vā of x and y contained in
-- disjoint open neighborhoods Uā and Uā.
obtain
āØUā, _, Vā, Vā_in, Uā, _, Vā, Vā_in, Vā_cl, Vā_cl, Uā_op, Uā_op, VUā, VUā, hUāāā© :=
disjoint_nested_nhds x_ne_y
-- We set Uā := (Vā āŖ Vā)į¶ so that W := Uā ĆĖ¢ Uā āŖ Uā ĆĖ¢ Uā āŖ Uā ĆĖ¢ Uā is an open
-- neighborhood of Ī.
let Uā := (Vā āŖ Vā)į¶
have Uā_op : IsOpen Uā := (Vā_cl.union Vā_cl).isOpen_compl
let W := Uā ĆĖ¢ Uā āŖ Uā ĆĖ¢ Uā āŖ Uā ĆĖ¢ Uā
have W_in : W ā šĪ := by
rw [mem_nhdsSet_iff_forall]
rintro āØz, z'ā© (rfl : z = z')
refine IsOpen.mem_nhds ?_ ?_
Ā· apply_rules [IsOpen.union, IsOpen.prod]
Ā· simp only [W, mem_union, mem_prod, and_self_iff]
exact (_root_.em _).imp_left fun h => union_subset_union VUā VUā h
-- So W ā W ā F by definition of F
have : W ā W ā F := @mem_lift' _ _ _ (fun s => s ā s) _ W_in
-- Porting note: was `by simpa only using mem_lift' W_in`
-- And Vā ĆĖ¢ Vā ā š (x, y)
have hVāā : Vā ĆĖ¢ Vā ā š (x, y) := prod_mem_nhds Vā_in Vā_in
-- But (x, y) is also a cluster point of F so (Vā ĆĖ¢ Vā) ā© (W ā W) ā ā
-- However the construction of W implies (Vā ĆĖ¢ Vā) ā© (W ā W) = ā
.
-- Indeed assume for contradiction there is some (u, v) in the intersection.
obtain āØāØu, vā©, āØu_in, v_inā©, w, huw, hwvā© := clusterPt_iff.mp hxy.of_inf_left hVāā this
-- So u ā Vā, v ā Vā, and there exists some w such that (u, w) ā W and (w ,v) ā W.
-- Because u is in Vā which is disjoint from Uā and Uā, (u, w) ā W forces (u, w) ā Uā ĆĖ¢ Uā.
have uw_in : (u, w) ā Uā ĆĖ¢ Uā :=
(huw.resolve_right fun h => h.1 <| Or.inl u_in).resolve_right fun h =>
hUāā.le_bot āØVUā u_in, h.1ā©
-- Similarly, because v ā Vā, (w ,v) ā W forces (w, v) ā Uā ĆĖ¢ Uā.
have wv_in : (w, v) ā Uā ĆĖ¢ Uā :=
(hwv.resolve_right fun h => h.2 <| Or.inr v_in).resolve_left fun h =>
hUāā.le_bot āØh.2, VUā v_inā©
-- Hence w ā Uā ā© Uā which is empty.
-- So we have a contradiction
exact hUāā.le_bot āØuw_in.2, wv_in.1ā©
nhds_eq_comap_uniformity x := by
simp_rw [nhdsSet_diagonal, comap_iSup, nhds_prod_eq, comap_prod, (Ā· ā Ā·), comap_id']
rw [iSup_split_single _ x, comap_const_of_mem fun V => mem_of_mem_nhds]
suffices ā y ā x, comap (fun _ : γ ⦠x) (š y) ā š y ⤠š x by simpa
intro y hxy
simp [comap_const_of_not_mem (compl_singleton_mem_nhds hxy) (not_not_intro rfl)]
/-!
###Ā Heine-Cantor theorem
-/
/-- Heine-Cantor: a continuous function on a compact uniform space is uniformly
continuous. -/
theorem CompactSpace.uniformContinuous_of_continuous [CompactSpace α] {f : α ā β}
(h : Continuous f) : UniformContinuous f :=
calc map (Prod.map f f) (š¤ α)
= map (Prod.map f f) (šĖ¢ (diagonal α)) := by rw [nhdsSet_diagonal_eq_uniformity]
_ ⤠šĖ¢ (diagonal β) := (h.prod_map h).tendsto_nhdsSet mapsTo_prod_map_diagonal
_ ⤠š¤ β := nhdsSet_diagonal_le_uniformity
/-- Heine-Cantor: a continuous function on a compact set of a uniform space is uniformly
continuous. -/
theorem IsCompact.uniformContinuousOn_of_continuous {s : Set α} {f : α ā β} (hs : IsCompact s)
(hf : ContinuousOn f s) : UniformContinuousOn f s := by
rw [uniformContinuousOn_iff_restrict]
rw [isCompact_iff_compactSpace] at hs
rw [continuousOn_iff_continuous_restrict] at hf
exact CompactSpace.uniformContinuous_of_continuous hf
/-- If `s` is compact and `f` is continuous at all points of `s`, then `f` is
"uniformly continuous at the set `s`", i.e. `f x` is close to `f y` whenever `x ā s` and `y` is
close to `x` (even if `y` is not itself in `s`, so this is a stronger assertion than
`UniformContinuousOn s`). -/
theorem IsCompact.uniformContinuousAt_of_continuousAt {r : Set (β à β)} {s : Set α}
(hs : IsCompact s) (f : α ā β) (hf : ā a ā s, ContinuousAt f a) (hr : r ā š¤ β) :
{ x : α à α | x.1 ā s ā (f x.1, f x.2) ā r } ā š¤ α := by
obtain āØt, ht, htsymm, htrā© := comp_symm_mem_uniformity_sets hr
choose U hU T hT hb using fun a ha =>
exists_mem_nhds_ball_subset_of_mem_nhds ((hf a ha).preimage_mem_nhds <| mem_nhds_left _ ht)
obtain āØfs, hsUā© := hs.elim_nhds_subcover' U hU
apply mem_of_superset ((biInter_finset_mem fs).2 fun a _ => hT a a.2)
rintro āØaā, aāā© h hā
obtain āØa, ha, haUā© := Set.mem_iUnionā.1 (hsU hā)
apply htr
refine āØf a, htsymm.mk_mem_comm.1 (hb _ _ _ haU ?_), hb _ _ _ haU ?_ā©
exacts [mem_ball_self _ (hT a a.2), mem_iInterā.1 h a ha]
theorem Continuous.uniformContinuous_of_tendsto_cocompact {f : α ā β} {x : β}
(h_cont : Continuous f) (hx : Tendsto f (cocompact α) (š x)) : UniformContinuous f :=
uniformContinuous_def.2 fun r hr => by
obtain āØt, ht, htsymm, htrā© := comp_symm_mem_uniformity_sets hr
obtain āØs, hs, hstā© := mem_cocompact.1 (hx <| mem_nhds_left _ ht)
apply
mem_of_superset
(symmetrize_mem_uniformity <|
(hs.uniformContinuousAt_of_continuousAt f fun _ _ => h_cont.continuousAt) <|
symmetrize_mem_uniformity hr)
rintro āØbā, bāā© h
by_cases hā : bā ā s; Ā· exact (h.1 hā).1
by_cases hā : bā ā s; Ā· exact (h.2 hā).2
apply htr
exact āØx, htsymm.mk_mem_comm.1 (hst hā), hst hāā©
@[to_additive]
theorem HasCompactMulSupport.uniformContinuous_of_continuous {f : α ā β} [One β]
(h1 : HasCompactMulSupport f) (h2 : Continuous f) : UniformContinuous f :=
h2.uniformContinuous_of_tendsto_cocompact h1.is_one_at_infty
/-- A family of functions `α ā β ā γ` tends uniformly to its value at `x` if `α` is locally compact,
`β` is compact and `f` is continuous on `U à (univ : Set β)` for some neighborhood `U` of `x`. -/
theorem ContinuousOn.tendstoUniformly [LocallyCompactSpace α] [CompactSpace β] [UniformSpace γ]
{f : α ā β ā γ} {x : α} {U : Set α} (hxU : U ā š x) (h : ContinuousOn (āæf) (U ĆĖ¢ univ)) :
TendstoUniformly f (f x) (š x) := by
rcases LocallyCompactSpace.local_compact_nhds _ _ hxU with āØK, hxK, hKU, hKā©
have : UniformContinuousOn (āæf) (K ĆĖ¢ univ) :=
IsCompact.uniformContinuousOn_of_continuous (hK.prod isCompact_univ)
(h.mono <| prod_mono hKU Subset.rfl)
exact this.tendstoUniformly hxK
/-- A continuous family of functions `α ā β ā γ` tends uniformly to its value at `x`
if `α` is weakly locally compact and `β` is compact. -/
theorem Continuous.tendstoUniformly [WeaklyLocallyCompactSpace α] [CompactSpace β] [UniformSpace γ]
(f : α ā β ā γ) (h : Continuous āæf) (x : α) : TendstoUniformly f (f x) (š x) :=
let āØK, hK, hxKā© := exists_compact_mem_nhds x
have : UniformContinuousOn (āæf) (K ĆĖ¢ univ) :=
IsCompact.uniformContinuousOn_of_continuous (hK.prod isCompact_univ) h.continuousOn
this.tendstoUniformly hxK
/-- In a product space `α à β`, assume that a function `f` is continuous on `s à k` where `k` is
compact. Then, along the fiber above any `q ā s`, `f` is transversely uniformly continuous, i.e.,
if `p ā s` is close enough to `q`, then `f p x` is uniformly close to `f q x` for all `x ā k`. -/
lemma IsCompact.mem_uniformity_of_prod
{α β E : Type*} [TopologicalSpace α] [TopologicalSpace β] [UniformSpace E]
{f : α ā β ā E} {s : Set α} {k : Set β} {q : α} {u : Set (E Ć E)}
(hk : IsCompact k) (hf : ContinuousOn f.uncurry (s ĆĖ¢ k)) (hq : q ā s) (hu : u ā š¤ E) :
ā v ā š[s] q, ā p ā v, ā x ā k, (f p x, f q x) ā u := by
apply hk.induction_on (p := fun t ⦠ā v ā š[s] q, ā p ā v, ā x ā t, (f p x, f q x) ā u)
Ā· exact āØuniv, univ_mem, by simpā©
Ā· intro t' t ht't āØv, v_mem, hvā©
exact āØv, v_mem, fun p hp x hx ⦠hv p hp x (ht't hx)ā©
Ā· intro t t' āØv, v_mem, hvā© āØv', v'_mem, hv'ā©
refine āØv ā© v', inter_mem v_mem v'_mem, fun p hp x hx ⦠?_ā©
rcases hx with h'x|h'x
Ā· exact hv p hp.1 x h'x
Ā· exact hv' p hp.2 x h'x
Ā· rcases comp_symm_of_uniformity hu with āØu', u'_mem, u'_symm, hu'ā©
intro x hx
obtain āØv, hv, w, hw, hvwā© :
ā v ā š[s] q, ā w ā š[k] x, v ĆĖ¢ w ā f.uncurry ā»Ā¹' {z | (f q x, z) ā u'} :=
mem_nhdsWithin_prod_iff.1 (hf (q, x) āØhq, hxā© (mem_nhds_left (f q x) u'_mem))
refine āØw, hw, v, hv, fun p hp y hy ⦠?_ā©
have A : (f q x, f p y) ā u' := hvw (āØhp, hyā© : (p, y) ā v ĆĖ¢ w)
have B : (f q x, f q y) ā u' := hvw (āØmem_of_mem_nhdsWithin hq hv, hyā© : (q, y) ā v ĆĖ¢ w)
exact hu' (prod_mk_mem_compRel (u'_symm A) B)
section UniformConvergence
/-- An equicontinuous family of functions defined on a compact uniform space is automatically
uniformly equicontinuous. -/
theorem CompactSpace.uniformEquicontinuous_of_equicontinuous {ι : Type*} {F : ι ā β ā α}
[CompactSpace β] (h : Equicontinuous F) : UniformEquicontinuous F := by
rw [equicontinuous_iff_continuous] at h
rw [uniformEquicontinuous_iff_uniformContinuous]
exact CompactSpace.uniformContinuous_of_continuous h
end UniformConvergence
|
Topology\UniformSpace\CompactConvergence.lean
|
/-
Copyright (c) 2021 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash, Yury Kudryashov
-/
import Mathlib.Topology.CompactOpen
import Mathlib.Topology.LocallyFinite
import Mathlib.Topology.Maps.Proper.Basic
import Mathlib.Topology.UniformSpace.UniformConvergenceTopology
/-!
# Compact convergence (uniform convergence on compact sets)
Given a topological space `α` and a uniform space `β` (e.g., a metric space or a topological group),
the space of continuous maps `C(α, β)` carries a natural uniform space structure.
We define this uniform space structure in this file
and also prove its basic properties.
## Main definitions
- `ContinuousMap.toUniformOnFunIsCompact`:
natural embedding of `C(α, β)`
into the space `α āᵤ[{K | IsCompact K}] β` of all maps `α ā β`
with the uniform space structure of uniform convergence on compacts.
- `ContinuousMap.compactConvergenceUniformSpace`:
the `UniformSpace` structure on `C(α, β)` induced by the map above.
## Main results
* `ContinuousMap.mem_compactConvergence_entourage_iff`:
a characterisation of the entourages of `C(α, β)`.
The entourages are generated by the following sets.
Given `K : Set α` and `V : Set (β à β)`,
let `E(K, V) : Set (C(α, β) Ć C(α, β))` be the set of pairs of continuous functions `α ā β`
which are `V`-close on `K`:
$$
E(K, V) = \{ (f, g) | ā (x ā K), (f x, g x) ā V \}.
$$
Then the sets `E(K, V)` for all compact sets `K` and all entourages `V`
form a basis of entourages of `C(α, β)`.
As usual, this basis of entourages provides a basis of neighbourhoods
by fixing `f`, see `nhds_basis_uniformity'`.
* `Filter.HasBasis.compactConvergenceUniformity`:
a similar statement that uses a basis of entourages of `β` instead of all entourages.
It is useful, e.g., if `β` is a metric space.
* `ContinuousMap.tendsto_iff_forall_compact_tendstoUniformlyOn`:
a sequence of functions `Fā` in `C(α, β)` converges in the compact-open topology to some `f`
iff `Fā` converges to `f` uniformly on each compact subset `K` of `α`.
* Topology induced by the uniformity described above agrees with the compact-open topology.
This is essentially the same as `ContinuousMap.tendsto_iff_forall_compact_tendstoUniformlyOn`.
This fact is not available as a separate theorem.
Instead, we override the projection of `ContinuousMap.compactConvergenceUniformity`
to `TopologicalSpace` to be `ContinuousMap.compactOpen` and prove that they agree,
see Note [forgetful inheritance] and implementation notes below.
* `ContinuousMap.tendsto_iff_tendstoLocallyUniformly`:
on a weakly locally compact space,
a sequence of functions `Fā` in `C(α, β)` converges to some `f`
iff `Fā` converges to `f` locally uniformly.
* `ContinuousMap.tendsto_iff_tendstoUniformly`:
on a compact space, a sequence of functions `Fā` in `C(α, β)` converges to some `f`
iff `Fā` converges to `f` uniformly.
## Implementation details
For technical reasons (see Note [forgetful inheritance]),
instead of defining a `UniformSpace C(α, β)` structure
and proving in a theorem that it agrees with the compact-open topology,
we override the projection right in the definition,
so that the resulting instance uses the compact-open topology.
## TODO
* Results about uniformly continuous functions `γ ā C(α, β)`
and uniform limits of sequences `ι ā γ ā C(α, β)`.
-/
universe uā uā uā
open scoped Uniformity Topology UniformConvergence
open UniformSpace Set Filter
variable {α : Type uā} {β : Type uā} [TopologicalSpace α] [UniformSpace β]
variable (K : Set α) (V : Set (β à β)) (f : C(α, β))
namespace ContinuousMap
/-- Compact-open topology on `C(α, β)` agrees with the topology of uniform convergence on compacts:
a family of continuous functions `F i` tends to `f` in the compact-open topology
if and only if the `F i` tends to `f` uniformly on all compact sets. -/
theorem tendsto_iff_forall_compact_tendstoUniformlyOn
{ι : Type uā} {p : Filter ι} {F : ι ā C(α, β)} {f} :
Tendsto F p (š f) ā ā K, IsCompact K ā TendstoUniformlyOn (fun i a => F i a) f p K := by
rw [tendsto_nhds_compactOpen]
constructor
Ā· -- Let us prove that convergence in the compact-open topology
-- implies uniform convergence on compacts.
-- Consider a compact set `K`
intro h K hK
-- Since `K` is compact, it suffices to prove locally uniform convergence
rw [ā tendstoLocallyUniformlyOn_iff_tendstoUniformlyOn_of_compact hK]
-- Now choose an entourage `U` in the codomain and a point `x ā K`.
intro U hU x _
-- Choose an open symmetric entourage `V` such that `V ā V ā U`.
rcases comp_open_symm_mem_uniformity_sets hU with āØV, hV, hVo, hVsymm, hVUā©
-- Then choose a closed entourage `W ā V`
rcases mem_uniformity_isClosed hV with āØW, hW, hWc, hWUā©
-- Consider `s = {y ā K | (f x, f y) ā W}`
set s := K ā© f ā»Ā¹' ball (f x) W
-- This is a neighbourhood of `x` within `K`, because `W` is an entourage.
have hnhds : s ā š[K] x := inter_mem_nhdsWithin _ <| f.continuousAt _ (ball_mem_nhds _ hW)
-- This set is compact because it is an intersection of `K`
-- with a closed set `{y | (f x, f y) ā W} = f ā»Ā¹' UniformSpace.ball (f x) W`
have hcomp : IsCompact s := hK.inter_right <| (isClosed_ball _ hWc).preimage f.continuous
-- `f` maps `s` to the open set `ball (f x) V = {z | (f x, z) ā V}`
have hmaps : MapsTo f s (ball (f x) V) := fun x hx ⦠hWU hx.2
use s, hnhds
-- Continuous maps `F i` in a neighbourhood of `f` map `s` to `ball (f x) V` as well.
refine (h s hcomp _ (isOpen_ball _ hVo) hmaps).mono fun g hg y hy ⦠?_
-- Then for `y ā s` we have `(f y, f x) ā V` and `(f x, F i y) ā V`, thus `(f y, F i y) ā U`
exact hVU āØf x, hVsymm.mk_mem_comm.2 <| hmaps hy, hg hyā©
Ā· -- Now we prove that uniform convergence on compacts
-- implies convergence in the compact-open topology
-- Consider a compact set `K`, an open set `U`, and a continuous map `f` that maps `K` to `U`
intro h K hK U hU hf
-- Due to Lebesgue number lemma, there exists an entourage `V`
-- such that `U` includes the `V`-thickening of `f '' K`.
rcases lebesgue_number_of_compact_open (hK.image (map_continuous f)) hU hf.image_subset
with āØV, hV, -, hVfā©
-- Then any continuous map that is uniformly `V`-close to `f` on `K`
-- maps `K` to `U` as well
filter_upwards [h K hK V hV] with g hg x hx using hVf _ (mem_image_of_mem f hx) (hg x hx)
/-- Interpret a bundled continuous map as an element of `α āᵤ[{K | IsCompact K}] β`.
We use this map to induce the `UniformSpace` structure on `C(α, β)`. -/
def toUniformOnFunIsCompact (f : C(α, β)) : α āᵤ[{K | IsCompact K}] β :=
UniformOnFun.ofFun {K | IsCompact K} f
@[simp]
theorem toUniformOnFun_toFun (f : C(α, β)) :
UniformOnFun.toFun _ f.toUniformOnFunIsCompact = f := rfl
open UniformSpace in
/-- Uniform space structure on `C(α, β)`.
The uniformity comes from `α āᵤ[{K | IsCompact K}] β` (i.e., `UniformOnFun α β {K | IsCompact K}`)
which defines topology of uniform convergence on compact sets.
We use `ContinuousMap.tendsto_iff_forall_compact_tendstoUniformlyOn`
to show that the induced topology agrees with the compact-open topology
and replace the topology with `compactOpen` to avoid non-defeq diamonds,
see Note [forgetful inheritance]. -/
instance compactConvergenceUniformSpace : UniformSpace C(α, β) :=
.replaceTopology (.comap toUniformOnFunIsCompact inferInstance) <| by
refine TopologicalSpace.ext_nhds fun f ⦠eq_of_forall_le_iff fun l ⦠?_
simp_rw [ā tendsto_id', tendsto_iff_forall_compact_tendstoUniformlyOn,
nhds_induced, tendsto_comap_iff, UniformOnFun.tendsto_iff_tendstoUniformlyOn]
rfl
theorem uniformEmbedding_toUniformOnFunIsCompact :
UniformEmbedding (toUniformOnFunIsCompact : C(α, β) ā α āᵤ[{K | IsCompact K}] β) where
comap_uniformity := rfl
inj := DFunLike.coe_injective
-- The following definitions and theorems
-- used to be a part of the construction of the `UniformSpace C(α, β)` structure
-- before it was migrated to `UniformOnFun`
theorem _root_.Filter.HasBasis.compactConvergenceUniformity {ι : Type*} {pi : ι ā Prop}
{s : ι ā Set (β à β)} (h : (š¤ β).HasBasis pi s) :
HasBasis (š¤ C(α, β)) (fun p : Set α à ι => IsCompact p.1 ā§ pi p.2) fun p =>
{ fg : C(α, β) Ć C(α, β) | ā x ā p.1, (fg.1 x, fg.2 x) ā s p.2 } := by
rw [ā uniformEmbedding_toUniformOnFunIsCompact.comap_uniformity]
exact .comap _ <| UniformOnFun.hasBasis_uniformity_of_basis _ _ {K | IsCompact K}
āØā
, isCompact_empty⩠(directedOn_of_sup_mem fun _ _ ⦠IsCompact.union) h
theorem hasBasis_compactConvergenceUniformity :
HasBasis (š¤ C(α, β)) (fun p : Set α Ć Set (β à β) => IsCompact p.1 ā§ p.2 ā š¤ β) fun p =>
{ fg : C(α, β) Ć C(α, β) | ā x ā p.1, (fg.1 x, fg.2 x) ā p.2 } :=
(basis_sets _).compactConvergenceUniformity
theorem mem_compactConvergence_entourage_iff (X : Set (C(α, β) à C(α, β))) :
X ā š¤ C(α, β) ā
ā (K : Set α) (V : Set (β à β)), IsCompact K ā§ V ā š¤ β ā§
{ fg : C(α, β) Ć C(α, β) | ā x ā K, (fg.1 x, fg.2 x) ā V } ā X := by
simp [hasBasis_compactConvergenceUniformity.mem_iff, and_assoc]
/-- If `K` is a compact exhaustion of `α`
and `V i` bounded by `p i` is a basis of entourages of `β`,
then `fun (n, i) ⦠{(f, g) | ā x ā K n, (f x, g x) ā V i}` bounded by `p i`
is a basis of entourages of `C(α, β)`. -/
theorem _root_.CompactExhaustion.hasBasis_compactConvergenceUniformity {ι : Type*}
{p : ι ā Prop} {V : ι ā Set (β à β)} (K : CompactExhaustion α) (hb : (š¤ β).HasBasis p V) :
HasBasis (š¤ C(α, β)) (fun i : ā à ι ⦠p i.2) fun i ā¦
{fg | ā x ā K i.1, (fg.1 x, fg.2 x) ā V i.2} :=
(UniformOnFun.hasBasis_uniformity_of_covering_of_basis {K | IsCompact K} K.isCompact
(Monotone.directed_le K.subset) (fun _ ⦠K.exists_superset_of_isCompact) hb).comap _
theorem _root_.CompactExhaustion.hasAntitoneBasis_compactConvergenceUniformity
{V : ā ā Set (β à β)} (K : CompactExhaustion α) (hb : (š¤ β).HasAntitoneBasis V) :
HasAntitoneBasis (š¤ C(α, β)) fun n ⦠{fg | ā x ā K n, (fg.1 x, fg.2 x) ā V n} :=
(UniformOnFun.hasAntitoneBasis_uniformity {K | IsCompact K} K.isCompact
K.subset (fun _ ⦠K.exists_superset_of_isCompact) hb).comap _
/-- If `α` is a weakly locally compact Ļ-compact space
(e.g., a proper pseudometric space or a compact spaces)
and the uniformity on `β` is pseudometrizable,
then the uniformity on `C(α, β)` is pseudometrizable too.
-/
instance [WeaklyLocallyCompactSpace α] [SigmaCompactSpace α] [IsCountablyGenerated (š¤ β)] :
IsCountablyGenerated (š¤ (C(α, β))) :=
let āØ_V, hVā© := exists_antitone_basis (š¤ β)
((CompactExhaustion.choice α).hasAntitoneBasis_compactConvergenceUniformity
hV).isCountablyGenerated
variable {ι : Type uā} {p : Filter ι} {F : ι ā C(α, β)} {f}
/-- Locally uniform convergence implies convergence in the compact-open topology. -/
theorem tendsto_of_tendstoLocallyUniformly (h : TendstoLocallyUniformly (fun i a => F i a) f p) :
Tendsto F p (š f) := by
rw [tendsto_iff_forall_compact_tendstoUniformlyOn]
intro K hK
rw [ā tendstoLocallyUniformlyOn_iff_tendstoUniformlyOn_of_compact hK]
exact h.tendstoLocallyUniformlyOn
/-- In a weakly locally compact space,
convergence in the compact-open topology is the same as locally uniform convergence.
The right-to-left implication holds in any topological space,
see `ContinuousMap.tendsto_of_tendstoLocallyUniformly`. -/
theorem tendsto_iff_tendstoLocallyUniformly [WeaklyLocallyCompactSpace α] :
Tendsto F p (š f) ā TendstoLocallyUniformly (fun i a => F i a) f p := by
refine āØfun h V hV x ⦠?_, tendsto_of_tendstoLocallyUniformlyā©
rw [tendsto_iff_forall_compact_tendstoUniformlyOn] at h
obtain āØn, hnā, hnāā© := exists_compact_mem_nhds x
exact āØn, hnā, h n hnā V hVā©
@[deprecated tendsto_iff_tendstoLocallyUniformly (since := "2023-09-03")]
theorem tendstoLocallyUniformly_of_tendsto [WeaklyLocallyCompactSpace α] (h : Tendsto F p (š f)) :
TendstoLocallyUniformly (fun i a => F i a) f p :=
tendsto_iff_tendstoLocallyUniformly.1 h
section Functorial
variable {γ Γ : Type*} [TopologicalSpace γ] [UniformSpace Γ]
theorem uniformContinuous_comp (g : C(β, Γ)) (hg : UniformContinuous g) :
UniformContinuous (ContinuousMap.comp g : C(α, β) ā C(α, Ī“)) :=
uniformEmbedding_toUniformOnFunIsCompact.uniformContinuous_iff.mpr <|
UniformOnFun.postcomp_uniformContinuous hg |>.comp
uniformEmbedding_toUniformOnFunIsCompact.uniformContinuous
theorem uniformInducing_comp (g : C(β, Γ)) (hg : UniformInducing g) :
UniformInducing (ContinuousMap.comp g : C(α, β) ā C(α, Ī“)) :=
uniformEmbedding_toUniformOnFunIsCompact.toUniformInducing.of_comp_iff.mp <|
UniformOnFun.postcomp_uniformInducing hg |>.comp
uniformEmbedding_toUniformOnFunIsCompact.toUniformInducing
theorem uniformEmbedding_comp (g : C(β, Γ)) (hg : UniformEmbedding g) :
UniformEmbedding (ContinuousMap.comp g : C(α, β) ā C(α, Ī“)) :=
uniformEmbedding_toUniformOnFunIsCompact.of_comp_iff.mp <|
UniformOnFun.postcomp_uniformEmbedding hg |>.comp
uniformEmbedding_toUniformOnFunIsCompact
theorem uniformContinuous_comp_left (g : C(α, γ)) :
UniformContinuous (fun f ⦠f.comp g : C(γ, β) ā C(α, β)) :=
uniformEmbedding_toUniformOnFunIsCompact.uniformContinuous_iff.mpr <|
UniformOnFun.precomp_uniformContinuous (fun _ hK ⦠hK.image g.continuous) |>.comp
uniformEmbedding_toUniformOnFunIsCompact.uniformContinuous
/-- Any pair of a homeomorphism `X āā Z` and an isomorphism `Y āᵤ T` of uniform spaces gives rise
to an isomorphism `C(X, Y) āᵤ C(Z, T)`. -/
protected def _root_.UniformEquiv.arrowCongr (Ļ : α āā γ) (Ļ : β āᵤ Ī“) :
C(α, β) āᵤ C(γ, Ī“) where
toFun f := .comp Ļ.toHomeomorph <| f.comp Ļ.symm
invFun f := .comp Ļ.symm.toHomeomorph <| f.comp Ļ
left_inv f := ext fun _ ⦠Ļ.left_inv (f _) |>.trans <| congrArg f <| Ļ.left_inv _
right_inv f := ext fun _ ⦠Ļ.right_inv (f _) |>.trans <| congrArg f <| Ļ.right_inv _
uniformContinuous_toFun := uniformContinuous_comp _ Ļ.uniformContinuous |>.comp <|
uniformContinuous_comp_left _
uniformContinuous_invFun := uniformContinuous_comp _ Ļ.symm.uniformContinuous |>.comp <|
uniformContinuous_comp_left _
end Functorial
section CompactDomain
variable [CompactSpace α]
theorem hasBasis_compactConvergenceUniformity_of_compact :
HasBasis (š¤ C(α, β)) (fun V : Set (β à β) => V ā š¤ β) fun V =>
{ fg : C(α, β) Ć C(α, β) | ā x, (fg.1 x, fg.2 x) ā V } :=
hasBasis_compactConvergenceUniformity.to_hasBasis
(fun p hp => āØp.2, hp.2, fun _fg hfg x _hx => hfg xā©) fun V hV =>
āØāØuniv, Vā©, āØisCompact_univ, hVā©, fun _fg hfg x => hfg x (mem_univ x)ā©
/-- Convergence in the compact-open topology is the same as uniform convergence for sequences of
continuous functions on a compact space. -/
theorem tendsto_iff_tendstoUniformly :
Tendsto F p (š f) ā TendstoUniformly (fun i a => F i a) f p := by
rw [tendsto_iff_forall_compact_tendstoUniformlyOn, ā tendstoUniformlyOn_univ]
exact āØfun h => h univ isCompact_univ, fun h K _hK => h.mono (subset_univ K)ā©
end CompactDomain
theorem uniformSpace_eq_inf_precomp_of_cover {Ī“ā Ī“ā : Type*} [TopologicalSpace Ī“ā]
[TopologicalSpace Ī“ā] (Ļā : C(Ī“ā, α)) (Ļā : C(Ī“ā, α)) (h_properā : IsProperMap Ļā)
(h_properā : IsProperMap Ļā) (h_cover : range Ļā āŖ range Ļā = univ) :
(inferInstanceAs <| UniformSpace C(α, β)) =
.comap (comp Ā· Ļā) inferInstance ā
.comap (comp Ā· Ļā) inferInstance := by
-- We check the analogous result for `UniformOnFun` using
-- `UniformOnFun.uniformSpace_eq_inf_precomp_of_cover`...
set š : Set (Set α) := {K | IsCompact K}
set šā : Set (Set Ī“ā) := {K | IsCompact K}
set šā : Set (Set Ī“ā) := {K | IsCompact K}
have h_imageā : MapsTo (Ļā '' Ā·) šā š := fun K hK ⦠hK.image Ļā.continuous
have h_imageā : MapsTo (Ļā '' Ā·) šā š := fun K hK ⦠hK.image Ļā.continuous
have h_preimageā : MapsTo (Ļā ā»Ā¹' Ā·) š šā := fun K ⦠h_properā.isCompact_preimage
have h_preimageā : MapsTo (Ļā ā»Ā¹' Ā·) š šā := fun K ⦠h_properā.isCompact_preimage
have h_cover' : ā S ā š, S ā range Ļā āŖ range Ļā := fun S _ ⦠h_cover āø subset_univ _
-- ... and we just pull it back.
simp_rw [compactConvergenceUniformSpace, replaceTopology_eq, inferInstanceAs, inferInstance,
UniformOnFun.uniformSpace_eq_inf_precomp_of_cover _ _ _ _ _
h_imageā h_imageā h_preimageā h_preimageā h_cover',
UniformSpace.comap_inf, ā UniformSpace.comap_comap]
rfl
theorem uniformSpace_eq_iInf_precomp_of_cover {Ī“ : ι ā Type*} [ā i, TopologicalSpace (Ī“ i)]
(Ļ : Ī i, C(Ī“ i, α)) (h_proper : ā i, IsProperMap (Ļ i))
(h_lf : LocallyFinite fun i ⦠range (Ļ i)) (h_cover : ā i, range (Ļ i) = univ) :
(inferInstanceAs <| UniformSpace C(α, β)) = āØ
i, .comap (comp Ā· (Ļ i)) inferInstance := by
-- We check the analogous result for `UniformOnFun` using
-- `UniformOnFun.uniformSpace_eq_iInf_precomp_of_cover`...
set š : Set (Set α) := {K | IsCompact K}
set š : Ī i, Set (Set (Ī“ i)) := fun i ⦠{K | IsCompact K}
have h_image : ā i, MapsTo (Ļ i '' Ā·) (š i) š := fun i K hK ⦠hK.image (Ļ i).continuous
have h_preimage : ā i, MapsTo (Ļ i ā»Ā¹' Ā·) š (š i) := fun i K ⦠(h_proper i).isCompact_preimage
have h_cover' : ā S ā š, ā I : Set ι, I.Finite ā§ S ā ā i ā I, range (Ļ i) := fun S hS ⦠by
refine āØ{i | (range (Ļ i) ā© S).Nonempty}, h_lf.finite_nonempty_inter_compact hS,
inter_eq_right.mp ?_ā©
simp_rw [iUnionā_inter, mem_setOf, iUnion_nonempty_self, ā iUnion_inter, h_cover, univ_inter]
-- ... and we just pull it back.
simp_rw [compactConvergenceUniformSpace, replaceTopology_eq, inferInstanceAs, inferInstance,
UniformOnFun.uniformSpace_eq_iInf_precomp_of_cover _ _ _ h_image h_preimage h_cover',
UniformSpace.comap_iInf, ā UniformSpace.comap_comap]
rfl
end ContinuousMap
|
Topology\UniformSpace\CompareReals.lean
|
/-
Copyright (c) 2019 Patrick Massot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot
-/
import Mathlib.Topology.UniformSpace.AbsoluteValue
import Mathlib.Topology.Instances.Real
import Mathlib.Topology.Instances.Rat
import Mathlib.Topology.UniformSpace.Completion
/-!
# Comparison of Cauchy reals and Bourbaki reals
In `Data.Real.Basic` real numbers are defined using the so called Cauchy construction (although
it is due to Georg Cantor). More precisely, this construction applies to commutative rings equipped
with an absolute value with values in a linear ordered field.
On the other hand, in the `UniformSpace` folder, we construct completions of general uniform
spaces, which allows to construct the Bourbaki real numbers. In this file we build uniformly
continuous bijections from Cauchy reals to Bourbaki reals and back. This is a cross sanity check of
both constructions. Of course those two constructions are variations on the completion idea, simply
with different level of generality. Comparing with Dedekind cuts or quasi-morphisms would be of a
completely different nature.
Note that `MetricSpace/cau_seq_filter` also relates the notions of Cauchy sequences in metric
spaces and Cauchy filters in general uniform spaces, and `MetricSpace/Completion` makes sure
the completion (as a uniform space) of a metric space is a metric space.
Historical note: mathlib used to define real numbers in an intermediate way, using completion
of uniform spaces but extending multiplication in an ad-hoc way.
TODO:
* Upgrade this isomorphism to a topological ring isomorphism.
* Do the same comparison for p-adic numbers
## Implementation notes
The heavy work is done in `Topology/UniformSpace/AbstractCompletion` which provides an abstract
characterization of completions of uniform spaces, and isomorphisms between them. The only work left
here is to prove the uniform space structure coming from the absolute value on ā (with values in ā,
not referring to ā) coincides with the one coming from the metric space structure (which of course
does use ā).
## References
* [N. Bourbaki, *Topologie gƩnƩrale*][bourbaki1966]
## Tags
real numbers, completion, uniform spaces
-/
open Set Function Filter CauSeq UniformSpace
/-- The metric space uniform structure on ā (which presupposes the existence
of real numbers) agrees with the one coming directly from (abs : ā ā ā). -/
theorem Rat.uniformSpace_eq :
(AbsoluteValue.abs : AbsoluteValue ā ā).uniformSpace = PseudoMetricSpace.toUniformSpace := by
ext s
rw [(AbsoluteValue.hasBasis_uniformity _).mem_iff, Metric.uniformity_basis_dist_rat.mem_iff]
simp only [Rat.dist_eq, AbsoluteValue.abs_apply, ā Rat.cast_sub, ā Rat.cast_abs, Rat.cast_lt,
abs_sub_comm]
/-- Cauchy reals packaged as a completion of ā using the absolute value route. -/
def rationalCauSeqPkg : @AbstractCompletion ā <| (@AbsoluteValue.abs ā _).uniformSpace :=
@AbstractCompletion.mk
(space := ā)
(coe := ((ā) : ā ā ā))
(uniformStruct := by infer_instance)
(complete := by infer_instance)
(separation := by infer_instance)
(uniformInducing := by
rw [Rat.uniformSpace_eq]
exact Rat.uniformEmbedding_coe_real.toUniformInducing)
(dense := Rat.denseEmbedding_coe_real.dense)
namespace CompareReals
/-- Type wrapper around ā to make sure the absolute value uniform space instance is picked up
instead of the metric space one. We proved in `Rat.uniformSpace_eq` that they are equal,
but they are not definitionaly equal, so it would confuse the type class system (and probably
also human readers). -/
def Q :=
ā deriving CommRing, Inhabited
instance uniformSpace : UniformSpace Q :=
(@AbsoluteValue.abs ā _).uniformSpace
/-- Real numbers constructed as in Bourbaki. -/
def Bourbakiā : Type :=
Completion Q deriving Inhabited
instance Bourbaki.uniformSpace : UniformSpace Bourbakiā :=
Completion.uniformSpace Q
/-- Bourbaki reals packaged as a completion of Q using the general theory. -/
def bourbakiPkg : AbstractCompletion Q :=
Completion.cPkg
/-- The uniform bijection between Bourbaki and Cauchy reals. -/
noncomputable def compareEquiv : Bourbakiā āᵤ ā :=
bourbakiPkg.compareEquiv rationalCauSeqPkg
theorem compare_uc : UniformContinuous compareEquiv :=
bourbakiPkg.uniformContinuous_compareEquiv rationalCauSeqPkg
theorem compare_uc_symm : UniformContinuous compareEquiv.symm :=
bourbakiPkg.uniformContinuous_compareEquiv_symm rationalCauSeqPkg
end CompareReals
|
Topology\UniformSpace\CompleteSeparated.lean
|
/-
Copyright (c) 2019 SƩbastien Gouƫzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: SƩbastien Gouƫzel
-/
import Mathlib.Topology.UniformSpace.UniformEmbedding
/-!
# Theory of complete separated uniform spaces.
This file is for elementary lemmas that depend on both Cauchy filters and separation.
-/
open Filter
open Topology Filter
variable {α β : Type*}
/-- In a separated space, a complete set is closed. -/
theorem IsComplete.isClosed [UniformSpace α] [T0Space α] {s : Set α} (h : IsComplete s) :
IsClosed s :=
isClosed_iff_clusterPt.2 fun a ha => by
let f := š[s] a
have : Cauchy f := cauchy_nhds.mono' ha inf_le_left
rcases h f this inf_le_right with āØy, ys, fyā©
rwa [(tendsto_nhds_unique' ha inf_le_left fy : a = y)]
theorem UniformEmbedding.toClosedEmbedding [UniformSpace α] [UniformSpace β] [CompleteSpace α]
[T0Space β] {f : α ā β} (hf : UniformEmbedding f) :
ClosedEmbedding f :=
āØhf.embedding, hf.toUniformInducing.isComplete_range.isClosedā©
namespace DenseInducing
open Filter
variable [TopologicalSpace α] {β : Type*} [TopologicalSpace β]
variable {γ : Type*} [UniformSpace γ] [CompleteSpace γ] [T0Space γ]
theorem continuous_extend_of_cauchy {e : α ā β} {f : α ā γ} (de : DenseInducing e)
(h : ā b : β, Cauchy (map f (comap e <| š b))) : Continuous (de.extend f) :=
de.continuous_extend fun b => CompleteSpace.complete (h b)
end DenseInducing
|
Topology\UniformSpace\Completion.lean
|
/-
Copyright (c) 2018 Patrick Massot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot, Johannes Hƶlzl
-/
import Mathlib.Topology.UniformSpace.AbstractCompletion
/-!
# Hausdorff completions of uniform spaces
The goal is to construct a left-adjoint to the inclusion of complete Hausdorff uniform spaces
into all uniform spaces. Any uniform space `α` gets a completion `Completion α` and a morphism
(ie. uniformly continuous map) `(ā) : α ā Completion α` which solves the universal
mapping problem of factorizing morphisms from `α` to any complete Hausdorff uniform space `β`.
It means any uniformly continuous `f : α ā β` gives rise to a unique morphism
`Completion.extension f : Completion α ā β` such that `f = Completion.extension f ā (ā)`.
Actually `Completion.extension f` is defined for all maps from `α` to `β` but it has the desired
properties only if `f` is uniformly continuous.
Beware that `(ā)` is not injective if `α` is not Hausdorff. But its image is always
dense. The adjoint functor acting on morphisms is then constructed by the usual abstract nonsense.
For every uniform spaces `α` and `β`, it turns `f : α ā β` into a morphism
`Completion.map f : Completion α ā Completion β`
such that
`(ā) ā f = (Completion.map f) ā (ā)`
provided `f` is uniformly continuous. This construction is compatible with composition.
In this file we introduce the following concepts:
* `CauchyFilter α` the uniform completion of the uniform space `α` (using Cauchy filters).
These are not minimal filters.
* `Completion α := Quotient (separationSetoid (CauchyFilter α))` the Hausdorff completion.
## References
This formalization is mostly based on
N. Bourbaki: General Topology
I. M. James: Topologies and Uniformities
From a slightly different perspective in order to reuse material in `Topology.UniformSpace.Basic`.
-/
noncomputable section
open Filter Set
universe u v w x
open scoped Classical
open Uniformity Topology Filter
/-- Space of Cauchy filters
This is essentially the completion of a uniform space. The embeddings are the neighbourhood filters.
This space is not minimal, the separated uniform space (i.e. quotiented on the intersection of all
entourages) is necessary for this.
-/
def CauchyFilter (α : Type u) [UniformSpace α] : Type u :=
{ f : Filter α // Cauchy f }
namespace CauchyFilter
section
variable {α : Type u} [UniformSpace α]
variable {β : Type v} {γ : Type w}
variable [UniformSpace β] [UniformSpace γ]
instance (f : CauchyFilter α) : NeBot f.1 := f.2.1
/-- The pairs of Cauchy filters generated by a set. -/
def gen (s : Set (α à α)) : Set (CauchyFilter α à CauchyFilter α) :=
{ p | s ā p.1.val ĆĖ¢ p.2.val }
theorem monotone_gen : Monotone (gen : Set (α à α) ā _) :=
monotone_setOf fun p => @Filter.monotone_mem _ (p.1.val ĆĖ¢ p.2.val)
-- Porting note: this was a calc proof, but I could not make it work
private theorem symm_gen : map Prod.swap ((š¤ α).lift' gen) ⤠(š¤ α).lift' gen := by
let f := fun s : Set (α à α) =>
{ p : CauchyFilter α Ć CauchyFilter α | s ā (p.2.val ĆĖ¢ p.1.val : Filter (α à α)) }
have hā : map Prod.swap ((š¤ α).lift' gen) = (š¤ α).lift' f := by
delta gen
simp [map_lift'_eq, monotone_setOf, Filter.monotone_mem, Function.comp,
image_swap_eq_preimage_swap]
have hā : (š¤ α).lift' f ⤠(š¤ α).lift' gen :=
uniformity_lift_le_swap
(monotone_principal.comp
(monotone_setOf fun p => @Filter.monotone_mem _ (p.2.val ĆĖ¢ p.1.val)))
(by
have h := fun p : CauchyFilter α à CauchyFilter α => @Filter.prod_comm _ _ p.2.val p.1.val
simp only [Function.comp, h, mem_map, f]
exact le_rfl)
exact hā.trans_le hā
private theorem compRel_gen_gen_subset_gen_compRel {s t : Set (α à α)} :
compRel (gen s) (gen t) ā (gen (compRel s t) : Set (CauchyFilter α Ć CauchyFilter α)) :=
fun āØf, gā© āØh, hā, hāā© =>
let āØtā, (htā : tā ā f.val), tā, (htā : tā ā h.val), (hā : tā ĆĖ¢ tā ā s)ā© := mem_prod_iff.mp hā
let āØtā, (htā : tā ā h.val), tā, (htā : tā ā g.val), (hā : tā ĆĖ¢ tā ā t)ā© := mem_prod_iff.mp hā
have : tā ā© tā ā h.val := inter_mem htā htā
let āØx, xtā, xtāā© := h.property.left.nonempty_of_mem this
(f.val ĆĖ¢ g.val).sets_of_superset (prod_mem_prod htā htā)
fun āØa, bā© āØ(ha : a ā tā), (hb : b ā tā)ā© =>
āØx, hā (show (a, x) ā tā ĆĖ¢ tā from āØha, xtāā©), hā (show (x, b) ā tā ĆĖ¢ tā from āØxtā, hbā©)ā©
private theorem comp_gen : (((š¤ α).lift' gen).lift' fun s => compRel s s) ⤠(š¤ α).lift' gen :=
calc
(((š¤ α).lift' gen).lift' fun s => compRel s s) =
(š¤ α).lift' fun s => compRel (gen s) (gen s) := by
rw [lift'_lift'_assoc]
Ā· exact monotone_gen
Ā· exact monotone_id.compRel monotone_id
_ ⤠(š¤ α).lift' fun s => gen <| compRel s s :=
lift'_mono' fun s _hs => compRel_gen_gen_subset_gen_compRel
_ = ((š¤ α).lift' fun s : Set (α à α) => compRel s s).lift' gen := by
rw [lift'_lift'_assoc]
Ā· exact monotone_id.compRel monotone_id
Ā· exact monotone_gen
_ ⤠(š¤ α).lift' gen := lift'_mono comp_le_uniformity le_rfl
instance : UniformSpace (CauchyFilter α) :=
UniformSpace.ofCore
{ uniformity := (š¤ α).lift' gen
refl := principal_le_lift'.2 fun _s hs āØa, bā© =>
fun (a_eq_b : a = b) => a_eq_b āø a.property.right hs
symm := symm_gen
comp := comp_gen }
theorem mem_uniformity {s : Set (CauchyFilter α à CauchyFilter α)} :
s ā š¤ (CauchyFilter α) ā ā t ā š¤ α, gen t ā s :=
mem_lift'_sets monotone_gen
theorem basis_uniformity {ι : Sort*} {p : ι ā Prop} {s : ι ā Set (α à α)} (h : (š¤ α).HasBasis p s) :
(š¤ (CauchyFilter α)).HasBasis p (gen ā s) :=
h.lift' monotone_gen
theorem mem_uniformity' {s : Set (CauchyFilter α à CauchyFilter α)} :
s ā š¤ (CauchyFilter α) ā ā t ā š¤ α, ā f g : CauchyFilter α, t ā f.1 ĆĖ¢ g.1 ā (f, g) ā s := by
refine mem_uniformity.trans (exists_congr (fun t => and_congr_right_iff.mpr (fun _h => ?_)))
exact āØfun h _f _g ht => h ht, fun h _p hp => h _ _ hpā©
/-- Embedding of `α` into its completion `CauchyFilter α` -/
def pureCauchy (a : α) : CauchyFilter α :=
āØpure a, cauchy_pureā©
theorem uniformInducing_pureCauchy : UniformInducing (pureCauchy : α ā CauchyFilter α) :=
āØhave : (preimage fun x : α à α => (pureCauchy x.fst, pureCauchy x.snd)) ā gen = id :=
funext fun s =>
Set.ext fun āØaā, aāā© => by simp [preimage, gen, pureCauchy, prod_principal_principal]
calc
comap (fun x : α à α => (pureCauchy x.fst, pureCauchy x.snd)) ((š¤ α).lift' gen) =
(š¤ α).lift' ((preimage fun x : α à α => (pureCauchy x.fst, pureCauchy x.snd)) ā gen) :=
comap_lift'_eq
_ = š¤ α := by simp [this]
ā©
theorem uniformEmbedding_pureCauchy : UniformEmbedding (pureCauchy : α ā CauchyFilter α) :=
{ uniformInducing_pureCauchy with
inj := fun _aā _aā h => pure_injective <| Subtype.ext_iff_val.1 h }
theorem denseRange_pureCauchy : DenseRange (pureCauchy : α ā CauchyFilter α) := fun f => by
have h_ex : ā s ā š¤ (CauchyFilter α), ā y : α, (f, pureCauchy y) ā s := fun s hs =>
let āØt'', ht''ā, (ht''ā : gen t'' ā s)ā© := (mem_lift'_sets monotone_gen).mp hs
let āØt', ht'ā, ht'āā© := comp_mem_uniformity_sets ht''ā
have : t' ā f.val ĆĖ¢ f.val := f.property.right ht'ā
let āØt, ht, (h : t ĆĖ¢ t ā t')ā© := mem_prod_same_iff.mp this
let āØx, (hx : x ā t)ā© := f.property.left.nonempty_of_mem ht
have : t'' ā f.val ĆĖ¢ pure x :=
mem_prod_iff.mpr
āØt, ht, { y : α | (x, y) ā t' }, h <| mk_mem_prod hx hx,
fun āØa, bā© āØ(hā : a ā t), (hā : (x, b) ā t')ā© =>
ht'ā <| prod_mk_mem_compRel (@h (a, x) āØhā, hxā©) hāā©
āØx, ht''ā <| by dsimp [gen]; exact thisā©
simp only [closure_eq_cluster_pts, ClusterPt, nhds_eq_uniformity, lift'_inf_principal_eq,
Set.inter_comm _ (range pureCauchy), mem_setOf_eq]
refine (lift'_neBot_iff ?_).mpr (fun s hs => ?_)
Ā· exact monotone_const.inter monotone_preimage
Ā· let āØy, hyā© := h_ex s hs
have : pureCauchy y ā range pureCauchy ā© { y : CauchyFilter α | (f, y) ā s } :=
āØmem_range_self y, hyā©
exact āØ_, thisā©
theorem denseInducing_pureCauchy : DenseInducing (pureCauchy : α ā CauchyFilter α) :=
uniformInducing_pureCauchy.denseInducing denseRange_pureCauchy
theorem denseEmbedding_pureCauchy : DenseEmbedding (pureCauchy : α ā CauchyFilter α) :=
uniformEmbedding_pureCauchy.denseEmbedding denseRange_pureCauchy
theorem nonempty_cauchyFilter_iff : Nonempty (CauchyFilter α) ā Nonempty α := by
constructor <;> rintro āØcā©
Ā· have := eq_univ_iff_forall.1 denseEmbedding_pureCauchy.toDenseInducing.closure_range c
obtain āØ_, āØ_, a, _ā©ā© := mem_closure_iff.1 this _ isOpen_univ trivial
exact āØaā©
Ā· exact āØpureCauchy cā©
section
-- Porting note: I commented this
-- set_option eqn_compiler.zeta true
instance : CompleteSpace (CauchyFilter α) :=
completeSpace_extension uniformInducing_pureCauchy denseRange_pureCauchy fun f hf =>
let f' : CauchyFilter α := āØf, hfā©
have : map pureCauchy f ⤠(š¤ <| CauchyFilter α).lift' (preimage (Prod.mk f')) :=
le_lift'.2 fun s hs =>
let āØt, htā, (htā : gen t ā s)ā© := (mem_lift'_sets monotone_gen).mp hs
let āØt', ht', (h : t' ĆĖ¢ t' ā t)ā© := mem_prod_same_iff.mp (hf.right htā)
have : t' ā { y : α | (f', pureCauchy y) ā gen t } := fun x hx =>
(f ĆĖ¢ pure x).sets_of_superset (prod_mem_prod ht' hx) h
f.sets_of_superset ht' <| Subset.trans this (preimage_mono htā)
āØf', by simpa [nhds_eq_uniformity]ā©
end
instance [Inhabited α] : Inhabited (CauchyFilter α) :=
āØpureCauchy defaultā©
instance [h : Nonempty α] : Nonempty (CauchyFilter α) :=
h.recOn fun a => Nonempty.intro <| CauchyFilter.pureCauchy a
section Extend
/-- Extend a uniformly continuous function `α ā β` to a function `CauchyFilter α ā β`.
Outputs junk when `f` is not uniformly continuous. -/
def extend (f : α ā β) : CauchyFilter α ā β :=
if UniformContinuous f then denseInducing_pureCauchy.extend f
else fun x => f (nonempty_cauchyFilter_iff.1 āØxā©).some
section T0Space
variable [T0Space β]
theorem extend_pureCauchy {f : α ā β} (hf : UniformContinuous f) (a : α) :
extend f (pureCauchy a) = f a := by
rw [extend, if_pos hf]
exact uniformly_extend_of_ind uniformInducing_pureCauchy denseRange_pureCauchy hf _
end T0Space
variable [CompleteSpace β]
theorem uniformContinuous_extend {f : α ā β} : UniformContinuous (extend f) := by
by_cases hf : UniformContinuous f
Ā· rw [extend, if_pos hf]
exact uniformContinuous_uniformly_extend uniformInducing_pureCauchy denseRange_pureCauchy hf
Ā· rw [extend, if_neg hf]
exact uniformContinuous_of_const fun a _b => by congr
end Extend
theorem inseparable_iff {f g : CauchyFilter α} : Inseparable f g ā f.1 ĆĖ¢ g.1 ⤠š¤ α :=
(basis_uniformity (basis_sets _)).inseparable_iff_uniformity
theorem inseparable_iff_of_le_nhds {f g : CauchyFilter α} {a b : α}
(ha : f.1 ⤠š a) (hb : g.1 ⤠š b) : Inseparable a b ā Inseparable f g := by
rw [ā tendsto_id'] at ha hb
rw [inseparable_iff, (ha.comp tendsto_fst).inseparable_iff_uniformity (hb.comp tendsto_snd)]
simp only [Function.comp_apply, id_eq, Prod.mk.eta, ā Function.id_def, tendsto_id']
theorem inseparable_lim_iff [CompleteSpace α] {f g : CauchyFilter α} :
haveI := f.2.1.nonempty; Inseparable (lim f.1) (lim g.1) ā Inseparable f g :=
inseparable_iff_of_le_nhds f.2.le_nhds_lim g.2.le_nhds_lim
end
theorem cauchyFilter_eq {α : Type*} [UniformSpace α] [CompleteSpace α] [T0Space α]
{f g : CauchyFilter α} :
haveI := f.2.1.nonempty; lim f.1 = lim g.1 ā Inseparable f g := by
rw [ā inseparable_iff_eq, inseparable_lim_iff]
section
theorem separated_pureCauchy_injective {α : Type*} [UniformSpace α] [T0Space α] :
Function.Injective fun a : α => SeparationQuotient.mk (pureCauchy a) := fun a b h ā¦
Inseparable.eq <| (inseparable_iff_of_le_nhds (pure_le_nhds a) (pure_le_nhds b)).2 <|
SeparationQuotient.mk_eq_mk.1 h
end
end CauchyFilter
open CauchyFilter Set
namespace UniformSpace
variable (α : Type*) [UniformSpace α]
variable {β : Type*} [UniformSpace β]
variable {γ : Type*} [UniformSpace γ]
/-- Hausdorff completion of `α` -/
def Completion := SeparationQuotient (CauchyFilter α)
namespace Completion
instance inhabited [Inhabited α] : Inhabited (Completion α) :=
inferInstanceAs <| Inhabited (Quotient _)
instance uniformSpace : UniformSpace (Completion α) :=
SeparationQuotient.instUniformSpace
instance completeSpace : CompleteSpace (Completion α) :=
SeparationQuotient.instCompleteSpace
instance t0Space : T0Space (Completion α) := SeparationQuotient.instT0Space
/-- The map from a uniform space to its completion.
porting note: this was added to create a target for the `@[coe]` attribute. -/
@[coe] def coe' : α ā Completion α := SeparationQuotient.mk ā pureCauchy
/-- Automatic coercion from `α` to its completion. Not always injective. -/
instance : Coe α (Completion α) :=
āØcoe' αā©
-- note [use has_coe_t]
protected theorem coe_eq : ((ā) : α ā Completion α) = SeparationQuotient.mk ā pureCauchy := rfl
theorem uniformInducing_coe : UniformInducing ((ā) : α ā Completion α) :=
SeparationQuotient.uniformInducing_mk.comp uniformInducing_pureCauchy
theorem comap_coe_eq_uniformity :
((š¤ _).comap fun p : α à α => ((p.1 : Completion α), (p.2 : Completion α))) = š¤ α :=
(uniformInducing_coe _).1
variable {α}
theorem denseRange_coe : DenseRange ((ā) : α ā Completion α) :=
SeparationQuotient.surjective_mk.denseRange.comp denseRange_pureCauchy
SeparationQuotient.continuous_mk
variable (α)
/-- The Haudorff completion as an abstract completion. -/
def cPkg {α : Type*} [UniformSpace α] : AbstractCompletion α where
space := Completion α
coe := (ā)
uniformStruct := by infer_instance
complete := by infer_instance
separation := by infer_instance
uniformInducing := Completion.uniformInducing_coe α
dense := Completion.denseRange_coe
instance AbstractCompletion.inhabited : Inhabited (AbstractCompletion α) :=
āØcPkgā©
attribute [local instance]
AbstractCompletion.uniformStruct AbstractCompletion.complete AbstractCompletion.separation
theorem nonempty_completion_iff : Nonempty (Completion α) ā Nonempty α :=
cPkg.dense.nonempty_iff.symm
theorem uniformContinuous_coe : UniformContinuous ((ā) : α ā Completion α) :=
cPkg.uniformContinuous_coe
theorem continuous_coe : Continuous ((ā) : α ā Completion α) :=
cPkg.continuous_coe
theorem uniformEmbedding_coe [T0Space α] : UniformEmbedding ((ā) : α ā Completion α) :=
{ comap_uniformity := comap_coe_eq_uniformity α
inj := separated_pureCauchy_injective }
theorem coe_injective [T0Space α] : Function.Injective ((ā) : α ā Completion α) :=
UniformEmbedding.inj (uniformEmbedding_coe _)
variable {α}
theorem denseInducing_coe : DenseInducing ((ā) : α ā Completion α) :=
{ (uniformInducing_coe α).inducing with dense := denseRange_coe }
/-- The uniform bijection between a complete space and its uniform completion. -/
def UniformCompletion.completeEquivSelf [CompleteSpace α] [T0Space α] : Completion α āᵤ α :=
AbstractCompletion.compareEquiv Completion.cPkg AbstractCompletion.ofComplete
open TopologicalSpace
instance separableSpace_completion [SeparableSpace α] : SeparableSpace (Completion α) :=
Completion.denseInducing_coe.separableSpace
theorem denseEmbedding_coe [T0Space α] : DenseEmbedding ((ā) : α ā Completion α) :=
{ denseInducing_coe with inj := separated_pureCauchy_injective }
theorem denseRange_coeā :
DenseRange fun x : α à β => ((x.1 : Completion α), (x.2 : Completion β)) :=
denseRange_coe.prod_map denseRange_coe
theorem denseRange_coeā :
DenseRange fun x : α à β à γ =>
((x.1 : Completion α), ((x.2.1 : Completion β), (x.2.2 : Completion γ))) :=
denseRange_coe.prod_map denseRange_coeā
@[elab_as_elim]
theorem induction_on {p : Completion α ā Prop} (a : Completion α) (hp : IsClosed { a | p a })
(ih : ā a : α, p a) : p a :=
isClosed_property denseRange_coe hp ih a
@[elab_as_elim]
theorem induction_onā {p : Completion α ā Completion β ā Prop} (a : Completion α) (b : Completion β)
(hp : IsClosed { x : Completion α à Completion β | p x.1 x.2 })
(ih : ā (a : α) (b : β), p a b) : p a b :=
have : ā x : Completion α Ć Completion β, p x.1 x.2 :=
isClosed_property denseRange_coeā hp fun āØa, bā© => ih a b
this (a, b)
@[elab_as_elim]
theorem induction_onā {p : Completion α ā Completion β ā Completion γ ā Prop} (a : Completion α)
(b : Completion β) (c : Completion γ)
(hp : IsClosed { x : Completion α à Completion β à Completion γ | p x.1 x.2.1 x.2.2 })
(ih : ā (a : α) (b : β) (c : γ), p a b c) : p a b c :=
have : ā x : Completion α Ć Completion β Ć Completion γ, p x.1 x.2.1 x.2.2 :=
isClosed_property denseRange_coeā hp fun āØa, b, cā© => ih a b c
this (a, b, c)
theorem ext {Y : Type*} [TopologicalSpace Y] [T2Space Y] {f g : Completion α ā Y}
(hf : Continuous f) (hg : Continuous g) (h : ā a : α, f a = g a) : f = g :=
cPkg.funext hf hg h
theorem ext' {Y : Type*} [TopologicalSpace Y] [T2Space Y] {f g : Completion α ā Y}
(hf : Continuous f) (hg : Continuous g) (h : ā a : α, f a = g a) (a : Completion α) :
f a = g a :=
congr_fun (ext hf hg h) a
section Extension
variable {f : α ā β}
/-- "Extension" to the completion. It is defined for any map `f` but
returns an arbitrary constant value if `f` is not uniformly continuous -/
protected def extension (f : α ā β) : Completion α ā β :=
cPkg.extend f
section CompleteSpace
variable [CompleteSpace β]
theorem uniformContinuous_extension : UniformContinuous (Completion.extension f) :=
cPkg.uniformContinuous_extend
@[continuity, fun_prop]
theorem continuous_extension : Continuous (Completion.extension f) :=
cPkg.continuous_extend
end CompleteSpace
/- porting note: removed `@[simp]` because this lemma doesn't even trigger on itself in Lean 3 or
Lean 4 unless the user manually supplies the `hf` argument, so it is useless as a `simp` lemma. -/
theorem extension_coe [T0Space β] (hf : UniformContinuous f) (a : α) :
(Completion.extension f) a = f a :=
cPkg.extend_coe hf a
variable [T0Space β] [CompleteSpace β]
theorem extension_unique (hf : UniformContinuous f) {g : Completion α ā β}
(hg : UniformContinuous g) (h : ā a : α, f a = g (a : Completion α)) :
Completion.extension f = g :=
cPkg.extend_unique hf hg h
@[simp]
theorem extension_comp_coe {f : Completion α ā β} (hf : UniformContinuous f) :
Completion.extension (f ā (ā)) = f :=
cPkg.extend_comp_coe hf
end Extension
section Map
variable {f : α ā β}
/-- Completion functor acting on morphisms -/
protected def map (f : α ā β) : Completion α ā Completion β :=
cPkg.map cPkg f
theorem uniformContinuous_map : UniformContinuous (Completion.map f) :=
cPkg.uniformContinuous_map cPkg f
@[continuity]
theorem continuous_map : Continuous (Completion.map f) :=
cPkg.continuous_map cPkg f
/- porting note: removed `@[simp]` because this lemma doesn't even trigger on itself in Lean 3 or
Lean 4 unless the user manually supplies the `hf` argument, so it is useless as a `simp` lemma. -/
theorem map_coe (hf : UniformContinuous f) (a : α) : (Completion.map f) a = f a :=
cPkg.map_coe cPkg hf a
theorem map_unique {f : α ā β} {g : Completion α ā Completion β} (hg : UniformContinuous g)
(h : ā a : α, ā(f a) = g a) : Completion.map f = g :=
cPkg.map_unique cPkg hg h
@[simp]
theorem map_id : Completion.map (@id α) = id :=
cPkg.map_id
theorem extension_map [CompleteSpace γ] [T0Space γ] {f : β ā γ} {g : α ā β}
(hf : UniformContinuous f) (hg : UniformContinuous g) :
Completion.extension f ā Completion.map g = Completion.extension (f ā g) :=
Completion.ext (continuous_extension.comp continuous_map) continuous_extension <| by
intro a
-- Porting note: this is not provable by simp [hf, hg, hf.comp hg, map_coe, extension_coe],
-- but should be?
rw [extension_coe (hf.comp hg), Function.comp_apply, map_coe hg, extension_coe hf,
Function.comp_apply]
theorem map_comp {g : β ā γ} {f : α ā β} (hg : UniformContinuous g) (hf : UniformContinuous f) :
Completion.map g ā Completion.map f = Completion.map (g ā f) :=
extension_map ((uniformContinuous_coe _).comp hg) hf
end Map
/- In this section we construct isomorphisms between the completion of a uniform space and the
completion of its separation quotient -/
section SeparationQuotientCompletion
open SeparationQuotient in
/-- The isomorphism between the completion of a uniform space and the completion of its separation
quotient. -/
def completionSeparationQuotientEquiv (α : Type u) [UniformSpace α] :
Completion (SeparationQuotient α) ā Completion α := by
refine āØCompletion.extension (lift' ((ā) : α ā Completion α)),
Completion.map SeparationQuotient.mk, fun a ⦠?_, fun a ⦠?_ā©
Ā· refine induction_on a (isClosed_eq (continuous_map.comp continuous_extension) continuous_id) ?_
refine SeparationQuotient.surjective_mk.forall.2 fun a ⦠?_
rw [extension_coe (uniformContinuous_lift' _), lift'_mk (uniformContinuous_coe α),
map_coe uniformContinuous_mk]
Ā· refine induction_on a
(isClosed_eq (continuous_extension.comp continuous_map) continuous_id) fun a ⦠?_
rw [map_coe uniformContinuous_mk, extension_coe (uniformContinuous_lift' _),
lift'_mk (uniformContinuous_coe _)]
theorem uniformContinuous_completionSeparationQuotientEquiv :
UniformContinuous (completionSeparationQuotientEquiv α) :=
uniformContinuous_extension
theorem uniformContinuous_completionSeparationQuotientEquiv_symm :
UniformContinuous (completionSeparationQuotientEquiv α).symm :=
uniformContinuous_map
end SeparationQuotientCompletion
section Extensionā
variable (f : α ā β ā γ)
open Function
/-- Extend a two variable map to the Hausdorff completions. -/
protected def extensionā (f : α ā β ā γ) : Completion α ā Completion β ā γ :=
cPkg.extendā cPkg f
section T0Space
variable [T0Space γ] {f}
/- porting note: removed `@[simp]` because this lemma doesn't even trigger on itself in Lean 3 or
Lean 4 unless the user manually supplies the `hf` argument, so it is useless as a `simp` lemma. -/
theorem extensionā_coe_coe (hf : UniformContinuousā f) (a : α) (b : β) :
Completion.extensionā f a b = f a b :=
cPkg.extensionā_coe_coe cPkg hf a b
end T0Space
variable [CompleteSpace γ]
theorem uniformContinuous_extensionā : UniformContinuousā (Completion.extensionā f) :=
cPkg.uniformContinuous_extensionā cPkg f
end Extensionā
section Mapā
open Function
/-- Lift a two variable map to the Hausdorff completions. -/
protected def mapā (f : α ā β ā γ) : Completion α ā Completion β ā Completion γ :=
cPkg.mapā cPkg cPkg f
theorem uniformContinuous_mapā (f : α ā β ā γ) : UniformContinuousā (Completion.mapā f) :=
cPkg.uniformContinuous_mapā cPkg cPkg f
theorem continuous_mapā {Ī“} [TopologicalSpace Ī“] {f : α ā β ā γ} {a : Ī“ ā Completion α}
{b : Ī“ ā Completion β} (ha : Continuous a) (hb : Continuous b) :
Continuous fun d : Ī“ => Completion.mapā f (a d) (b d) :=
cPkg.continuous_mapā cPkg cPkg ha hb
theorem mapā_coe_coe (a : α) (b : β) (f : α ā β ā γ) (hf : UniformContinuousā f) :
Completion.mapā f (a : Completion α) (b : Completion β) = f a b :=
cPkg.mapā_coe_coe cPkg cPkg a b f hf
end Mapā
end Completion
end UniformSpace
|
Topology\UniformSpace\Equicontinuity.lean
|
/-
Copyright (c) 2022 Anatole Dedecker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anatole Dedecker
-/
import Mathlib.Topology.UniformSpace.UniformConvergenceTopology
/-!
# Equicontinuity of a family of functions
Let `X` be a topological space and `α` a `UniformSpace`. A family of functions `F : ι ā X ā α`
is said to be *equicontinuous at a point `xā : X`* when, for any entourage `U` in `α`, there is a
neighborhood `V` of `xā` such that, for all `x ā V`, and *for all `i`*, `F i x` is `U`-close to
`F i xā`. In other words, one has `ā U ā š¤ α, āį¶ x in š xā, ā i, (F i xā, F i x) ā U`.
For maps between metric spaces, this corresponds to
`ā ε > 0, ā Ī“ > 0, ā x, ā i, dist xā x < Ī“ ā dist (F i xā) (F i x) < ε`.
`F` is said to be *equicontinuous* if it is equicontinuous at each point.
A closely related concept is that of ***uniform*** *equicontinuity* of a family of functions
`F : ι ā β ā α` between uniform spaces, which means that, for any entourage `U` in `α`, there is an
entourage `V` in `β` such that, if `x` and `y` are `V`-close, then *for all `i`*, `F i x` and
`F i y` are `U`-close. In other words, one has
`ā U ā š¤ α, āį¶ xy in š¤ β, ā i, (F i xy.1, F i xy.2) ā U`.
For maps between metric spaces, this corresponds to
`ā ε > 0, ā Ī“ > 0, ā x y, ā i, dist x y < Ī“ ā dist (F i xā) (F i x) < ε`.
## Main definitions
* `EquicontinuousAt`: equicontinuity of a family of functions at a point
* `Equicontinuous`: equicontinuity of a family of functions on the whole domain
* `UniformEquicontinuous`: uniform equicontinuity of a family of functions on the whole domain
We also introduce relative versions, namely `EquicontinuousWithinAt`, `EquicontinuousOn` and
`UniformEquicontinuousOn`, akin to `ContinuousWithinAt`, `ContinuousOn` and `UniformContinuousOn`
respectively.
## Main statements
* `equicontinuous_iff_continuous`: equicontinuity can be expressed as a simple continuity
condition between well-chosen function spaces. This is really useful for building up the theory.
* `Equicontinuous.closure`: if a set of functions is equicontinuous, its closure
*for the topology of pointwise convergence* is also equicontinuous.
## Notations
Throughout this file, we use :
- `ι`, `κ` for indexing types
- `X`, `Y`, `Z` for topological spaces
- `α`, `β`, `γ` for uniform spaces
## Implementation details
We choose to express equicontinuity as a properties of indexed families of functions rather
than sets of functions for the following reasons:
- it is really easy to express equicontinuity of `H : Set (X ā α)` using our setup: it is just
equicontinuity of the family `(ā) : ā„H ā (X ā α)`. On the other hand, going the other way around
would require working with the range of the family, which is always annoying because it
introduces useless existentials.
- in most applications, one doesn't work with bare functions but with a more specific hom type
`hom`. Equicontinuity of a set `H : Set hom` would then have to be expressed as equicontinuity
of `coe_fn '' H`, which is super annoying to work with. This is much simpler with families,
because equicontinuity of a family `š : ι ā hom` would simply be expressed as equicontinuity
of `coe_fn ā š`, which doesn't introduce any nasty existentials.
To simplify statements, we do provide abbreviations `Set.EquicontinuousAt`, `Set.Equicontinuous`
and `Set.UniformEquicontinuous` asserting the corresponding fact about the family
`(ā) : ā„H ā (X ā α)` where `H : Set (X ā α)`. Note however that these won't work for sets of hom
types, and in that case one should go back to the family definition rather than using `Set.image`.
## References
* [N. Bourbaki, *General Topology, Chapter X*][bourbaki1966]
## Tags
equicontinuity, uniform convergence, ascoli
-/
section
open UniformSpace Filter Set Uniformity Topology UniformConvergence Function
variable {ι Īŗ X X' Y Z α α' β β' γ š : Type*} [tX : TopologicalSpace X] [tY : TopologicalSpace Y]
[tZ : TopologicalSpace Z] [uα : UniformSpace α] [uβ : UniformSpace β] [uγ : UniformSpace γ]
/-- A family `F : ι ā X ā α` of functions from a topological space to a uniform space is
*equicontinuous at `xā : X`* if, for all entourages `U ā š¤ α`, there is a neighborhood `V` of `xā`
such that, for all `x ā V` and for all `i : ι`, `F i x` is `U`-close to `F i xā`. -/
def EquicontinuousAt (F : ι ā X ā α) (xā : X) : Prop :=
ā U ā š¤ α, āį¶ x in š xā, ā i, (F i xā, F i x) ā U
/-- We say that a set `H : Set (X ā α)` of functions is equicontinuous at a point if the family
`(ā) : ā„H ā (X ā α)` is equicontinuous at that point. -/
protected abbrev Set.EquicontinuousAt (H : Set <| X ā α) (xā : X) : Prop :=
EquicontinuousAt ((ā) : H ā X ā α) xā
/-- A family `F : ι ā X ā α` of functions from a topological space to a uniform space is
*equicontinuous at `xā : X` within `S : Set X`* if, for all entourages `U ā š¤ α`, there is a
neighborhood `V` of `xā` within `S` such that, for all `x ā V` and for all `i : ι`, `F i x` is
`U`-close to `F i xā`. -/
def EquicontinuousWithinAt (F : ι ā X ā α) (S : Set X) (xā : X) : Prop :=
ā U ā š¤ α, āį¶ x in š[S] xā, ā i, (F i xā, F i x) ā U
/-- We say that a set `H : Set (X ā α)` of functions is equicontinuous at a point within a subset
if the family `(ā) : ā„H ā (X ā α)` is equicontinuous at that point within that same subset. -/
protected abbrev Set.EquicontinuousWithinAt (H : Set <| X ā α) (S : Set X) (xā : X) : Prop :=
EquicontinuousWithinAt ((ā) : H ā X ā α) S xā
/-- A family `F : ι ā X ā α` of functions from a topological space to a uniform space is
*equicontinuous* on all of `X` if it is equicontinuous at each point of `X`. -/
def Equicontinuous (F : ι ā X ā α) : Prop :=
ā xā, EquicontinuousAt F xā
/-- We say that a set `H : Set (X ā α)` of functions is equicontinuous if the family
`(ā) : ā„H ā (X ā α)` is equicontinuous. -/
protected abbrev Set.Equicontinuous (H : Set <| X ā α) : Prop :=
Equicontinuous ((ā) : H ā X ā α)
/-- A family `F : ι ā X ā α` of functions from a topological space to a uniform space is
*equicontinuous on `S : Set X`* if it is equicontinuous *within `S`* at each point of `S`. -/
def EquicontinuousOn (F : ι ā X ā α) (S : Set X) : Prop :=
ā xā ā S, EquicontinuousWithinAt F S xā
/-- We say that a set `H : Set (X ā α)` of functions is equicontinuous on a subset if the family
`(ā) : ā„H ā (X ā α)` is equicontinuous on that subset. -/
protected abbrev Set.EquicontinuousOn (H : Set <| X ā α) (S : Set X) : Prop :=
EquicontinuousOn ((ā) : H ā X ā α) S
/-- A family `F : ι ā β ā α` of functions between uniform spaces is *uniformly equicontinuous* if,
for all entourages `U ā š¤ α`, there is an entourage `V ā š¤ β` such that, whenever `x` and `y` are
`V`-close, we have that, *for all `i : ι`*, `F i x` is `U`-close to `F i y`. -/
def UniformEquicontinuous (F : ι ā β ā α) : Prop :=
ā U ā š¤ α, āį¶ xy : β à β in š¤ β, ā i, (F i xy.1, F i xy.2) ā U
/-- We say that a set `H : Set (X ā α)` of functions is uniformly equicontinuous if the family
`(ā) : ā„H ā (X ā α)` is uniformly equicontinuous. -/
protected abbrev Set.UniformEquicontinuous (H : Set <| β ā α) : Prop :=
UniformEquicontinuous ((ā) : H ā β ā α)
/-- A family `F : ι ā β ā α` of functions between uniform spaces is
*uniformly equicontinuous on `S : Set β`* if, for all entourages `U ā š¤ α`, there is a relative
entourage `V ā š¤ β ā š (S ĆĖ¢ S)` such that, whenever `x` and `y` are `V`-close, we have that,
*for all `i : ι`*, `F i x` is `U`-close to `F i y`. -/
def UniformEquicontinuousOn (F : ι ā β ā α) (S : Set β) : Prop :=
ā U ā š¤ α, āį¶ xy : β à β in š¤ β ā š (S ĆĖ¢ S), ā i, (F i xy.1, F i xy.2) ā U
/-- We say that a set `H : Set (X ā α)` of functions is uniformly equicontinuous on a subset if the
family `(ā) : ā„H ā (X ā α)` is uniformly equicontinuous on that subset. -/
protected abbrev Set.UniformEquicontinuousOn (H : Set <| β ā α) (S : Set β) : Prop :=
UniformEquicontinuousOn ((ā) : H ā β ā α) S
lemma EquicontinuousAt.equicontinuousWithinAt {F : ι ā X ā α} {xā : X} (H : EquicontinuousAt F xā)
(S : Set X) : EquicontinuousWithinAt F S xā :=
fun U hU ⦠(H U hU).filter_mono inf_le_left
lemma EquicontinuousWithinAt.mono {F : ι ā X ā α} {xā : X} {S T : Set X}
(H : EquicontinuousWithinAt F T xā) (hST : S ā T) : EquicontinuousWithinAt F S xā :=
fun U hU ⦠(H U hU).filter_mono <| nhdsWithin_mono xā hST
@[simp] lemma equicontinuousWithinAt_univ (F : ι ā X ā α) (xā : X) :
EquicontinuousWithinAt F univ xā ā EquicontinuousAt F xā := by
rw [EquicontinuousWithinAt, EquicontinuousAt, nhdsWithin_univ]
lemma equicontinuousAt_restrict_iff (F : ι ā X ā α) {S : Set X} (xā : S) :
EquicontinuousAt (S.restrict ā F) xā ā EquicontinuousWithinAt F S xā := by
simp [EquicontinuousWithinAt, EquicontinuousAt,
ā eventually_nhds_subtype_iff]
lemma Equicontinuous.equicontinuousOn {F : ι ā X ā α} (H : Equicontinuous F)
(S : Set X) : EquicontinuousOn F S :=
fun x _ ⦠(H x).equicontinuousWithinAt S
lemma EquicontinuousOn.mono {F : ι ā X ā α} {S T : Set X}
(H : EquicontinuousOn F T) (hST : S ā T) : EquicontinuousOn F S :=
fun x hx ⦠(H x (hST hx)).mono hST
lemma equicontinuousOn_univ (F : ι ā X ā α) :
EquicontinuousOn F univ ā Equicontinuous F := by
simp [EquicontinuousOn, Equicontinuous]
lemma equicontinuous_restrict_iff (F : ι ā X ā α) {S : Set X} :
Equicontinuous (S.restrict ā F) ā EquicontinuousOn F S := by
simp [Equicontinuous, EquicontinuousOn, equicontinuousAt_restrict_iff]
lemma UniformEquicontinuous.uniformEquicontinuousOn {F : ι ā β ā α} (H : UniformEquicontinuous F)
(S : Set β) : UniformEquicontinuousOn F S :=
fun U hU ⦠(H U hU).filter_mono inf_le_left
lemma UniformEquicontinuousOn.mono {F : ι ā β ā α} {S T : Set β}
(H : UniformEquicontinuousOn F T) (hST : S ā T) : UniformEquicontinuousOn F S :=
fun U hU ⦠(H U hU).filter_mono <| by gcongr
lemma uniformEquicontinuousOn_univ (F : ι ā β ā α) :
UniformEquicontinuousOn F univ ā UniformEquicontinuous F := by
simp [UniformEquicontinuousOn, UniformEquicontinuous]
lemma uniformEquicontinuous_restrict_iff (F : ι ā β ā α) {S : Set β} :
UniformEquicontinuous (S.restrict ā F) ā UniformEquicontinuousOn F S := by
rw [UniformEquicontinuous, UniformEquicontinuousOn]
conv in _ ā _ => rw [ā Subtype.range_val (s := S), ā range_prod_map, ā map_comap]
rfl
/-!
### Empty index type
-/
@[simp]
lemma equicontinuousAt_empty [h : IsEmpty ι] (F : ι ā X ā α) (xā : X) :
EquicontinuousAt F xā :=
fun _ _ ⦠eventually_of_forall (fun _ ⦠h.elim)
@[simp]
lemma equicontinuousWithinAt_empty [h : IsEmpty ι] (F : ι ā X ā α) (S : Set X) (xā : X) :
EquicontinuousWithinAt F S xā :=
fun _ _ ⦠eventually_of_forall (fun _ ⦠h.elim)
@[simp]
lemma equicontinuous_empty [IsEmpty ι] (F : ι ā X ā α) :
Equicontinuous F :=
equicontinuousAt_empty F
@[simp]
lemma equicontinuousOn_empty [IsEmpty ι] (F : ι ā X ā α) (S : Set X) :
EquicontinuousOn F S :=
fun xā _ ⦠equicontinuousWithinAt_empty F S xā
@[simp]
lemma uniformEquicontinuous_empty [h : IsEmpty ι] (F : ι ā β ā α) :
UniformEquicontinuous F :=
fun _ _ ⦠eventually_of_forall (fun _ ⦠h.elim)
@[simp]
lemma uniformEquicontinuousOn_empty [h : IsEmpty ι] (F : ι ā β ā α) (S : Set β) :
UniformEquicontinuousOn F S :=
fun _ _ ⦠eventually_of_forall (fun _ ⦠h.elim)
/-!
### Finite index type
-/
theorem equicontinuousAt_finite [Finite ι] {F : ι ā X ā α} {xā : X} :
EquicontinuousAt F xā ā ā i, ContinuousAt (F i) xā := by
simp [EquicontinuousAt, ContinuousAt, (nhds_basis_uniformity' (š¤ α).basis_sets).tendsto_right_iff,
UniformSpace.ball, @forall_swap _ ι]
theorem equicontinuousWithinAt_finite [Finite ι] {F : ι ā X ā α} {S : Set X} {xā : X} :
EquicontinuousWithinAt F S xā ā ā i, ContinuousWithinAt (F i) S xā := by
simp [EquicontinuousWithinAt, ContinuousWithinAt,
(nhds_basis_uniformity' (š¤ α).basis_sets).tendsto_right_iff, UniformSpace.ball,
@forall_swap _ ι]
theorem equicontinuous_finite [Finite ι] {F : ι ā X ā α} :
Equicontinuous F ā ā i, Continuous (F i) := by
simp only [Equicontinuous, equicontinuousAt_finite, continuous_iff_continuousAt, @forall_swap ι]
theorem equicontinuousOn_finite [Finite ι] {F : ι ā X ā α} {S : Set X} :
EquicontinuousOn F S ā ā i, ContinuousOn (F i) S := by
simp only [EquicontinuousOn, equicontinuousWithinAt_finite, ContinuousOn, @forall_swap ι]
theorem uniformEquicontinuous_finite [Finite ι] {F : ι ā β ā α} :
UniformEquicontinuous F ā ā i, UniformContinuous (F i) := by
simp only [UniformEquicontinuous, eventually_all, @forall_swap _ ι]; rfl
theorem uniformEquicontinuousOn_finite [Finite ι] {F : ι ā β ā α} {S : Set β} :
UniformEquicontinuousOn F S ā ā i, UniformContinuousOn (F i) S := by
simp only [UniformEquicontinuousOn, eventually_all, @forall_swap _ ι]; rfl
/-!
### Index type with a unique element
-/
theorem equicontinuousAt_unique [Unique ι] {F : ι ā X ā α} {x : X} :
EquicontinuousAt F x ā ContinuousAt (F default) x :=
equicontinuousAt_finite.trans Unique.forall_iff
theorem equicontinuousWithinAt_unique [Unique ι] {F : ι ā X ā α} {S : Set X} {x : X} :
EquicontinuousWithinAt F S x ā ContinuousWithinAt (F default) S x :=
equicontinuousWithinAt_finite.trans Unique.forall_iff
theorem equicontinuous_unique [Unique ι] {F : ι ā X ā α} :
Equicontinuous F ā Continuous (F default) :=
equicontinuous_finite.trans Unique.forall_iff
theorem equicontinuousOn_unique [Unique ι] {F : ι ā X ā α} {S : Set X} :
EquicontinuousOn F S ā ContinuousOn (F default) S :=
equicontinuousOn_finite.trans Unique.forall_iff
theorem uniformEquicontinuous_unique [Unique ι] {F : ι ā β ā α} :
UniformEquicontinuous F ā UniformContinuous (F default) :=
uniformEquicontinuous_finite.trans Unique.forall_iff
theorem uniformEquicontinuousOn_unique [Unique ι] {F : ι ā β ā α} {S : Set β} :
UniformEquicontinuousOn F S ā UniformContinuousOn (F default) S :=
uniformEquicontinuousOn_finite.trans Unique.forall_iff
/-- Reformulation of equicontinuity at `xā` within a set `S`, comparing two variables near `xā`
instead of comparing only one with `xā`. -/
theorem equicontinuousWithinAt_iff_pair {F : ι ā X ā α} {S : Set X} {xā : X} (hxā : xā ā S) :
EquicontinuousWithinAt F S xā ā
ā U ā š¤ α, ā V ā š[S] xā, ā x ā V, ā y ā V, ā i, (F i x, F i y) ā U := by
constructor <;> intro H U hU
Ā· rcases comp_symm_mem_uniformity_sets hU with āØV, hV, hVsymm, hVUā©
refine āØ_, H V hV, fun x hx y hy i => hVU (prod_mk_mem_compRel ?_ (hy i))ā©
exact hVsymm.mk_mem_comm.mp (hx i)
Ā· rcases H U hU with āØV, hV, hVUā©
filter_upwards [hV] using fun x hx i => hVU xā (mem_of_mem_nhdsWithin hxā hV) x hx i
/-- Reformulation of equicontinuity at `xā` comparing two variables near `xā` instead of comparing
only one with `xā`. -/
theorem equicontinuousAt_iff_pair {F : ι ā X ā α} {xā : X} :
EquicontinuousAt F xā ā
ā U ā š¤ α, ā V ā š xā, ā x ā V, ā y ā V, ā i, (F i x, F i y) ā U := by
simp_rw [ā equicontinuousWithinAt_univ, equicontinuousWithinAt_iff_pair (mem_univ xā),
nhdsWithin_univ]
/-- Uniform equicontinuity implies equicontinuity. -/
theorem UniformEquicontinuous.equicontinuous {F : ι ā β ā α} (h : UniformEquicontinuous F) :
Equicontinuous F := fun xā U hU ā¦
mem_of_superset (ball_mem_nhds xā (h U hU)) fun _ hx i ⦠hx i
/-- Uniform equicontinuity on a subset implies equicontinuity on that subset. -/
theorem UniformEquicontinuousOn.equicontinuousOn {F : ι ā β ā α} {S : Set β}
(h : UniformEquicontinuousOn F S) :
EquicontinuousOn F S := fun _ hxā U hU ā¦
mem_of_superset (ball_mem_nhdsWithin hxā (h U hU)) fun _ hx i ⦠hx i
/-- Each function of a family equicontinuous at `xā` is continuous at `xā`. -/
theorem EquicontinuousAt.continuousAt {F : ι ā X ā α} {xā : X} (h : EquicontinuousAt F xā) (i : ι) :
ContinuousAt (F i) xā :=
(UniformSpace.hasBasis_nhds _).tendsto_right_iff.2 fun U āØhU, _⩠⦠(h U hU).mono fun _x hx ⦠hx i
/-- Each function of a family equicontinuous at `xā` within `S` is continuous at `xā` within `S`. -/
theorem EquicontinuousWithinAt.continuousWithinAt {F : ι ā X ā α} {S : Set X} {xā : X}
(h : EquicontinuousWithinAt F S xā) (i : ι) :
ContinuousWithinAt (F i) S xā :=
(UniformSpace.hasBasis_nhds _).tendsto_right_iff.2 fun U āØhU, _⩠⦠(h U hU).mono fun _x hx ⦠hx i
protected theorem Set.EquicontinuousAt.continuousAt_of_mem {H : Set <| X ā α} {xā : X}
(h : H.EquicontinuousAt xā) {f : X ā α} (hf : f ā H) : ContinuousAt f xā :=
h.continuousAt āØf, hfā©
protected theorem Set.EquicontinuousWithinAt.continuousWithinAt_of_mem {H : Set <| X ā α}
{S : Set X} {xā : X} (h : H.EquicontinuousWithinAt S xā) {f : X ā α} (hf : f ā H) :
ContinuousWithinAt f S xā :=
h.continuousWithinAt āØf, hfā©
/-- Each function of an equicontinuous family is continuous. -/
theorem Equicontinuous.continuous {F : ι ā X ā α} (h : Equicontinuous F) (i : ι) :
Continuous (F i) :=
continuous_iff_continuousAt.mpr fun x => (h x).continuousAt i
/-- Each function of a family equicontinuous on `S` is continuous on `S`. -/
theorem EquicontinuousOn.continuousOn {F : ι ā X ā α} {S : Set X} (h : EquicontinuousOn F S)
(i : ι) : ContinuousOn (F i) S :=
fun x hx ⦠(h x hx).continuousWithinAt i
protected theorem Set.Equicontinuous.continuous_of_mem {H : Set <| X ā α} (h : H.Equicontinuous)
{f : X ā α} (hf : f ā H) : Continuous f :=
h.continuous āØf, hfā©
protected theorem Set.EquicontinuousOn.continuousOn_of_mem {H : Set <| X ā α} {S : Set X}
(h : H.EquicontinuousOn S) {f : X ā α} (hf : f ā H) : ContinuousOn f S :=
h.continuousOn āØf, hfā©
/-- Each function of a uniformly equicontinuous family is uniformly continuous. -/
theorem UniformEquicontinuous.uniformContinuous {F : ι ā β ā α} (h : UniformEquicontinuous F)
(i : ι) : UniformContinuous (F i) := fun U hU =>
mem_map.mpr (mem_of_superset (h U hU) fun _ hxy => hxy i)
/-- Each function of a family uniformly equicontinuous on `S` is uniformly continuous on `S`. -/
theorem UniformEquicontinuousOn.uniformContinuousOn {F : ι ā β ā α} {S : Set β}
(h : UniformEquicontinuousOn F S) (i : ι) :
UniformContinuousOn (F i) S := fun U hU =>
mem_map.mpr (mem_of_superset (h U hU) fun _ hxy => hxy i)
protected theorem Set.UniformEquicontinuous.uniformContinuous_of_mem {H : Set <| β ā α}
(h : H.UniformEquicontinuous) {f : β ā α} (hf : f ā H) : UniformContinuous f :=
h.uniformContinuous āØf, hfā©
protected theorem Set.UniformEquicontinuousOn.uniformContinuousOn_of_mem {H : Set <| β ā α}
{S : Set β} (h : H.UniformEquicontinuousOn S) {f : β ā α} (hf : f ā H) :
UniformContinuousOn f S :=
h.uniformContinuousOn āØf, hfā©
/-- Taking sub-families preserves equicontinuity at a point. -/
theorem EquicontinuousAt.comp {F : ι ā X ā α} {xā : X} (h : EquicontinuousAt F xā) (u : Īŗ ā ι) :
EquicontinuousAt (F ā u) xā := fun U hU => (h U hU).mono fun _ H k => H (u k)
/-- Taking sub-families preserves equicontinuity at a point within a subset. -/
theorem EquicontinuousWithinAt.comp {F : ι ā X ā α} {S : Set X} {xā : X}
(h : EquicontinuousWithinAt F S xā) (u : Īŗ ā ι) :
EquicontinuousWithinAt (F ā u) S xā :=
fun U hU ⦠(h U hU).mono fun _ H k => H (u k)
protected theorem Set.EquicontinuousAt.mono {H H' : Set <| X ā α} {xā : X}
(h : H.EquicontinuousAt xā) (hH : H' ā H) : H'.EquicontinuousAt xā :=
h.comp (inclusion hH)
protected theorem Set.EquicontinuousWithinAt.mono {H H' : Set <| X ā α} {S : Set X} {xā : X}
(h : H.EquicontinuousWithinAt S xā) (hH : H' ā H) : H'.EquicontinuousWithinAt S xā :=
h.comp (inclusion hH)
/-- Taking sub-families preserves equicontinuity. -/
theorem Equicontinuous.comp {F : ι ā X ā α} (h : Equicontinuous F) (u : Īŗ ā ι) :
Equicontinuous (F ā u) := fun x => (h x).comp u
/-- Taking sub-families preserves equicontinuity on a subset. -/
theorem EquicontinuousOn.comp {F : ι ā X ā α} {S : Set X} (h : EquicontinuousOn F S) (u : Īŗ ā ι) :
EquicontinuousOn (F ā u) S := fun x hx ⦠(h x hx).comp u
protected theorem Set.Equicontinuous.mono {H H' : Set <| X ā α} (h : H.Equicontinuous)
(hH : H' ā H) : H'.Equicontinuous :=
h.comp (inclusion hH)
protected theorem Set.EquicontinuousOn.mono {H H' : Set <| X ā α} {S : Set X}
(h : H.EquicontinuousOn S) (hH : H' ā H) : H'.EquicontinuousOn S :=
h.comp (inclusion hH)
/-- Taking sub-families preserves uniform equicontinuity. -/
theorem UniformEquicontinuous.comp {F : ι ā β ā α} (h : UniformEquicontinuous F) (u : Īŗ ā ι) :
UniformEquicontinuous (F ā u) := fun U hU => (h U hU).mono fun _ H k => H (u k)
/-- Taking sub-families preserves uniform equicontinuity on a subset. -/
theorem UniformEquicontinuousOn.comp {F : ι ā β ā α} {S : Set β} (h : UniformEquicontinuousOn F S)
(u : Īŗ ā ι) : UniformEquicontinuousOn (F ā u) S :=
fun U hU ⦠(h U hU).mono fun _ H k => H (u k)
protected theorem Set.UniformEquicontinuous.mono {H H' : Set <| β ā α} (h : H.UniformEquicontinuous)
(hH : H' ā H) : H'.UniformEquicontinuous :=
h.comp (inclusion hH)
protected theorem Set.UniformEquicontinuousOn.mono {H H' : Set <| β ā α} {S : Set β}
(h : H.UniformEquicontinuousOn S) (hH : H' ā H) : H'.UniformEquicontinuousOn S :=
h.comp (inclusion hH)
/-- A family `š : ι ā X ā α` is equicontinuous at `xā` iff `range š` is equicontinuous at `xā`,
i.e the family `(ā) : range F ā X ā α` is equicontinuous at `xā`. -/
theorem equicontinuousAt_iff_range {F : ι ā X ā α} {xā : X} :
EquicontinuousAt F xā ā EquicontinuousAt ((ā) : range F ā X ā α) xā := by
simp only [EquicontinuousAt, forall_subtype_range_iff]
/-- A family `š : ι ā X ā α` is equicontinuous at `xā` within `S` iff `range š` is equicontinuous
at `xā` within `S`, i.e the family `(ā) : range F ā X ā α` is equicontinuous at `xā` within `S`. -/
theorem equicontinuousWithinAt_iff_range {F : ι ā X ā α} {S : Set X} {xā : X} :
EquicontinuousWithinAt F S xā ā EquicontinuousWithinAt ((ā) : range F ā X ā α) S xā := by
simp only [EquicontinuousWithinAt, forall_subtype_range_iff]
/-- A family `š : ι ā X ā α` is equicontinuous iff `range š` is equicontinuous,
i.e the family `(ā) : range F ā X ā α` is equicontinuous. -/
theorem equicontinuous_iff_range {F : ι ā X ā α} :
Equicontinuous F ā Equicontinuous ((ā) : range F ā X ā α) :=
forall_congr' fun _ => equicontinuousAt_iff_range
/-- A family `š : ι ā X ā α` is equicontinuous on `S` iff `range š` is equicontinuous on `S`,
i.e the family `(ā) : range F ā X ā α` is equicontinuous on `S`. -/
theorem equicontinuousOn_iff_range {F : ι ā X ā α} {S : Set X} :
EquicontinuousOn F S ā EquicontinuousOn ((ā) : range F ā X ā α) S :=
forall_congr' fun _ ⦠forall_congr' fun _ ⦠equicontinuousWithinAt_iff_range
/-- A family `š : ι ā β ā α` is uniformly equicontinuous iff `range š` is uniformly equicontinuous,
i.e the family `(ā) : range F ā β ā α` is uniformly equicontinuous. -/
theorem uniformEquicontinuous_iff_range {F : ι ā β ā α} :
UniformEquicontinuous F ā UniformEquicontinuous ((ā) : range F ā β ā α) :=
āØfun h => by rw [ā comp_rangeSplitting F]; exact h.comp _, fun h =>
h.comp (rangeFactorization F)ā©
/-- A family `š : ι ā β ā α` is uniformly equicontinuous on `S` iff `range š` is uniformly
equicontinuous on `S`, i.e the family `(ā) : range F ā β ā α` is uniformly equicontinuous on `S`. -/
theorem uniformEquicontinuousOn_iff_range {F : ι ā β ā α} {S : Set β} :
UniformEquicontinuousOn F S ā UniformEquicontinuousOn ((ā) : range F ā β ā α) S :=
āØfun h => by rw [ā comp_rangeSplitting F]; exact h.comp _, fun h =>
h.comp (rangeFactorization F)ā©
section
open UniformFun
/-- A family `š : ι ā X ā α` is equicontinuous at `xā` iff the function `swap š : X ā ι ā α` is
continuous at `xā` *when `ι ā α` is equipped with the topology of uniform convergence*. This is
very useful for developping the equicontinuity API, but it should not be used directly for other
purposes. -/
theorem equicontinuousAt_iff_continuousAt {F : ι ā X ā α} {xā : X} :
EquicontinuousAt F xā ā ContinuousAt (ofFun ā Function.swap F : X ā ι āᵤ α) xā := by
rw [ContinuousAt, (UniformFun.hasBasis_nhds ι α _).tendsto_right_iff]
rfl
/-- A family `š : ι ā X ā α` is equicontinuous at `xā` within `S` iff the function
`swap š : X ā ι ā α` is continuous at `xā` within `S`
*when `ι ā α` is equipped with the topology of uniform convergence*. This is very useful for
developping the equicontinuity API, but it should not be used directly for other purposes. -/
theorem equicontinuousWithinAt_iff_continuousWithinAt {F : ι ā X ā α} {S : Set X} {xā : X} :
EquicontinuousWithinAt F S xā ā
ContinuousWithinAt (ofFun ā Function.swap F : X ā ι āᵤ α) S xā := by
rw [ContinuousWithinAt, (UniformFun.hasBasis_nhds ι α _).tendsto_right_iff]
rfl
/-- A family `š : ι ā X ā α` is equicontinuous iff the function `swap š : X ā ι ā α` is
continuous *when `ι ā α` is equipped with the topology of uniform convergence*. This is
very useful for developping the equicontinuity API, but it should not be used directly for other
purposes. -/
theorem equicontinuous_iff_continuous {F : ι ā X ā α} :
Equicontinuous F ā Continuous (ofFun ā Function.swap F : X ā ι āᵤ α) := by
simp_rw [Equicontinuous, continuous_iff_continuousAt, equicontinuousAt_iff_continuousAt]
/-- A family `š : ι ā X ā α` is equicontinuous on `S` iff the function `swap š : X ā ι ā α` is
continuous on `S` *when `ι ā α` is equipped with the topology of uniform convergence*. This is
very useful for developping the equicontinuity API, but it should not be used directly for other
purposes. -/
theorem equicontinuousOn_iff_continuousOn {F : ι ā X ā α} {S : Set X} :
EquicontinuousOn F S ā ContinuousOn (ofFun ā Function.swap F : X ā ι āᵤ α) S := by
simp_rw [EquicontinuousOn, ContinuousOn, equicontinuousWithinAt_iff_continuousWithinAt]
/-- A family `š : ι ā β ā α` is uniformly equicontinuous iff the function `swap š : β ā ι ā α` is
uniformly continuous *when `ι ā α` is equipped with the uniform structure of uniform convergence*.
This is very useful for developping the equicontinuity API, but it should not be used directly
for other purposes. -/
theorem uniformEquicontinuous_iff_uniformContinuous {F : ι ā β ā α} :
UniformEquicontinuous F ā UniformContinuous (ofFun ā Function.swap F : β ā ι āᵤ α) := by
rw [UniformContinuous, (UniformFun.hasBasis_uniformity ι α).tendsto_right_iff]
rfl
/-- A family `š : ι ā β ā α` is uniformly equicontinuous on `S` iff the function
`swap š : β ā ι ā α` is uniformly continuous on `S`
*when `ι ā α` is equipped with the uniform structure of uniform convergence*. This is very useful
for developping the equicontinuity API, but it should not be used directly for other purposes. -/
theorem uniformEquicontinuousOn_iff_uniformContinuousOn {F : ι ā β ā α} {S : Set β} :
UniformEquicontinuousOn F S ā UniformContinuousOn (ofFun ā Function.swap F : β ā ι āᵤ α) S := by
rw [UniformContinuousOn, (UniformFun.hasBasis_uniformity ι α).tendsto_right_iff]
rfl
theorem equicontinuousWithinAt_iInf_rng {u : Īŗ ā UniformSpace α'} {F : ι ā X ā α'}
{S : Set X} {xā : X} : EquicontinuousWithinAt (uα := āØ
k, u k) F S xā ā
ā k, EquicontinuousWithinAt (uα := u k) F S xā := by
simp only [equicontinuousWithinAt_iff_continuousWithinAt (uα := _), topologicalSpace]
unfold ContinuousWithinAt
rw [UniformFun.iInf_eq, toTopologicalSpace_iInf, nhds_iInf, tendsto_iInf]
theorem equicontinuousAt_iInf_rng {u : Īŗ ā UniformSpace α'} {F : ι ā X ā α'}
{xā : X} :
EquicontinuousAt (uα := āØ
k, u k) F xā ā ā k, EquicontinuousAt (uα := u k) F xā := by
simp only [ā equicontinuousWithinAt_univ (uα := _), equicontinuousWithinAt_iInf_rng]
theorem equicontinuous_iInf_rng {u : Īŗ ā UniformSpace α'} {F : ι ā X ā α'} :
Equicontinuous (uα := āØ
k, u k) F ā ā k, Equicontinuous (uα := u k) F := by
simp_rw [equicontinuous_iff_continuous (uα := _), UniformFun.topologicalSpace]
rw [UniformFun.iInf_eq, toTopologicalSpace_iInf, continuous_iInf_rng]
theorem equicontinuousOn_iInf_rng {u : Īŗ ā UniformSpace α'} {F : ι ā X ā α'}
{S : Set X} :
EquicontinuousOn (uα := āØ
k, u k) F S ā ā k, EquicontinuousOn (uα := u k) F S := by
simp_rw [EquicontinuousOn, equicontinuousWithinAt_iInf_rng, @forall_swap _ Īŗ]
theorem uniformEquicontinuous_iInf_rng {u : Īŗ ā UniformSpace α'} {F : ι ā β ā α'} :
UniformEquicontinuous (uα := āØ
k, u k) F ā ā k, UniformEquicontinuous (uα := u k) F := by
simp_rw [uniformEquicontinuous_iff_uniformContinuous (uα := _)]
rw [UniformFun.iInf_eq, uniformContinuous_iInf_rng]
theorem uniformEquicontinuousOn_iInf_rng {u : Īŗ ā UniformSpace α'} {F : ι ā β ā α'}
{S : Set β} : UniformEquicontinuousOn (uα := āØ
k, u k) F S ā
ā k, UniformEquicontinuousOn (uα := u k) F S := by
simp_rw [uniformEquicontinuousOn_iff_uniformContinuousOn (uα := _)]
unfold UniformContinuousOn
rw [UniformFun.iInf_eq, iInf_uniformity, tendsto_iInf]
theorem equicontinuousWithinAt_iInf_dom {t : Īŗ ā TopologicalSpace X'} {F : ι ā X' ā α}
{S : Set X'} {xā : X'} {k : Īŗ} (hk : EquicontinuousWithinAt (tX := t k) F S xā) :
EquicontinuousWithinAt (tX := āØ
k, t k) F S xā := by
simp [equicontinuousWithinAt_iff_continuousWithinAt (tX := _)] at hk ā¢
unfold ContinuousWithinAt nhdsWithin at hk ā¢
rw [nhds_iInf]
exact hk.mono_left <| inf_le_inf_right _ <| iInf_le _ k
theorem equicontinuousAt_iInf_dom {t : Īŗ ā TopologicalSpace X'} {F : ι ā X' ā α}
{xā : X'} {k : Īŗ} (hk : EquicontinuousAt (tX := t k) F xā) :
EquicontinuousAt (tX := āØ
k, t k) F xā := by
rw [ā equicontinuousWithinAt_univ (tX := _)] at hk ā¢
exact equicontinuousWithinAt_iInf_dom hk
theorem equicontinuous_iInf_dom {t : Īŗ ā TopologicalSpace X'} {F : ι ā X' ā α}
{k : Īŗ} (hk : Equicontinuous (tX := t k) F) :
Equicontinuous (tX := āØ
k, t k) F :=
fun x ⦠equicontinuousAt_iInf_dom (hk x)
theorem equicontinuousOn_iInf_dom {t : Īŗ ā TopologicalSpace X'} {F : ι ā X' ā α}
{S : Set X'} {k : Īŗ} (hk : EquicontinuousOn (tX := t k) F S) :
EquicontinuousOn (tX := āØ
k, t k) F S :=
fun x hx ⦠equicontinuousWithinAt_iInf_dom (hk x hx)
theorem uniformEquicontinuous_iInf_dom {u : Īŗ ā UniformSpace β'} {F : ι ā β' ā α}
{k : κ} (hk : UniformEquicontinuous (uβ := u k) F) :
UniformEquicontinuous (uβ := āØ
k, u k) F := by
simp_rw [uniformEquicontinuous_iff_uniformContinuous (uβ := _)] at hk ā¢
exact uniformContinuous_iInf_dom hk
theorem uniformEquicontinuousOn_iInf_dom {u : Īŗ ā UniformSpace β'} {F : ι ā β' ā α}
{S : Set β'} {k : κ} (hk : UniformEquicontinuousOn (uβ := u k) F S) :
UniformEquicontinuousOn (uβ := āØ
k, u k) F S := by
simp_rw [uniformEquicontinuousOn_iff_uniformContinuousOn (uβ := _)] at hk ā¢
unfold UniformContinuousOn
rw [iInf_uniformity]
exact hk.mono_left <| inf_le_inf_right _ <| iInf_le _ k
theorem Filter.HasBasis.equicontinuousAt_iff_left {p : Īŗ ā Prop} {s : Īŗ ā Set X}
{F : ι ā X ā α} {xā : X} (hX : (š xā).HasBasis p s) :
EquicontinuousAt F xā ā ā U ā š¤ α, ā k, p k ā§ ā x ā s k, ā i, (F i xā, F i x) ā U := by
rw [equicontinuousAt_iff_continuousAt, ContinuousAt,
hX.tendsto_iff (UniformFun.hasBasis_nhds ι α _)]
rfl
theorem Filter.HasBasis.equicontinuousWithinAt_iff_left {p : Īŗ ā Prop} {s : Īŗ ā Set X}
{F : ι ā X ā α} {S : Set X} {xā : X} (hX : (š[S] xā).HasBasis p s) :
EquicontinuousWithinAt F S xā ā ā U ā š¤ α, ā k, p k ā§ ā x ā s k, ā i, (F i xā, F i x) ā U := by
rw [equicontinuousWithinAt_iff_continuousWithinAt, ContinuousWithinAt,
hX.tendsto_iff (UniformFun.hasBasis_nhds ι α _)]
rfl
theorem Filter.HasBasis.equicontinuousAt_iff_right {p : Īŗ ā Prop} {s : Īŗ ā Set (α à α)}
{F : ι ā X ā α} {xā : X} (hα : (š¤ α).HasBasis p s) :
EquicontinuousAt F xā ā ā k, p k ā āį¶ x in š xā, ā i, (F i xā, F i x) ā s k := by
rw [equicontinuousAt_iff_continuousAt, ContinuousAt,
(UniformFun.hasBasis_nhds_of_basis ι α _ hα).tendsto_right_iff]
rfl
theorem Filter.HasBasis.equicontinuousWithinAt_iff_right {p : Īŗ ā Prop}
{s : Īŗ ā Set (α à α)} {F : ι ā X ā α} {S : Set X} {xā : X} (hα : (š¤ α).HasBasis p s) :
EquicontinuousWithinAt F S xā ā ā k, p k ā āį¶ x in š[S] xā, ā i, (F i xā, F i x) ā s k := by
rw [equicontinuousWithinAt_iff_continuousWithinAt, ContinuousWithinAt,
(UniformFun.hasBasis_nhds_of_basis ι α _ hα).tendsto_right_iff]
rfl
theorem Filter.HasBasis.equicontinuousAt_iff {Īŗā Īŗā : Type*} {pā : Īŗā ā Prop} {sā : Īŗā ā Set X}
{pā : Īŗā ā Prop} {sā : Īŗā ā Set (α à α)} {F : ι ā X ā α} {xā : X} (hX : (š xā).HasBasis pā sā)
(hα : (š¤ α).HasBasis pā sā) :
EquicontinuousAt F xā ā
ā kā, pā kā ā ā kā, pā kā ā§ ā x ā sā kā, ā i, (F i xā, F i x) ā sā kā := by
rw [equicontinuousAt_iff_continuousAt, ContinuousAt,
hX.tendsto_iff (UniformFun.hasBasis_nhds_of_basis ι α _ hα)]
rfl
theorem Filter.HasBasis.equicontinuousWithinAt_iff {Īŗā Īŗā : Type*} {pā : Īŗā ā Prop}
{sā : Īŗā ā Set X} {pā : Īŗā ā Prop} {sā : Īŗā ā Set (α à α)} {F : ι ā X ā α} {S : Set X} {xā : X}
(hX : (š[S] xā).HasBasis pā sā) (hα : (š¤ α).HasBasis pā sā) :
EquicontinuousWithinAt F S xā ā
ā kā, pā kā ā ā kā, pā kā ā§ ā x ā sā kā, ā i, (F i xā, F i x) ā sā kā := by
rw [equicontinuousWithinAt_iff_continuousWithinAt, ContinuousWithinAt,
hX.tendsto_iff (UniformFun.hasBasis_nhds_of_basis ι α _ hα)]
rfl
theorem Filter.HasBasis.uniformEquicontinuous_iff_left {p : Īŗ ā Prop}
{s : Īŗ ā Set (β à β)} {F : ι ā β ā α} (hβ : (š¤ β).HasBasis p s) :
UniformEquicontinuous F ā
ā U ā š¤ α, ā k, p k ā§ ā x y, (x, y) ā s k ā ā i, (F i x, F i y) ā U := by
rw [uniformEquicontinuous_iff_uniformContinuous, UniformContinuous,
hβ.tendsto_iff (UniformFun.hasBasis_uniformity ι α)]
simp only [Prod.forall]
rfl
theorem Filter.HasBasis.uniformEquicontinuousOn_iff_left {p : Īŗ ā Prop}
{s : Īŗ ā Set (β à β)} {F : ι ā β ā α} {S : Set β} (hβ : (š¤ β ā š (S ĆĖ¢ S)).HasBasis p s) :
UniformEquicontinuousOn F S ā
ā U ā š¤ α, ā k, p k ā§ ā x y, (x, y) ā s k ā ā i, (F i x, F i y) ā U := by
rw [uniformEquicontinuousOn_iff_uniformContinuousOn, UniformContinuousOn,
hβ.tendsto_iff (UniformFun.hasBasis_uniformity ι α)]
simp only [Prod.forall]
rfl
theorem Filter.HasBasis.uniformEquicontinuous_iff_right {p : Īŗ ā Prop}
{s : Īŗ ā Set (α à α)} {F : ι ā β ā α} (hα : (š¤ α).HasBasis p s) :
UniformEquicontinuous F ā ā k, p k ā āį¶ xy : β à β in š¤ β, ā i, (F i xy.1, F i xy.2) ā s k := by
rw [uniformEquicontinuous_iff_uniformContinuous, UniformContinuous,
(UniformFun.hasBasis_uniformity_of_basis ι α hα).tendsto_right_iff]
rfl
theorem Filter.HasBasis.uniformEquicontinuousOn_iff_right {p : Īŗ ā Prop}
{s : Īŗ ā Set (α à α)} {F : ι ā β ā α} {S : Set β} (hα : (š¤ α).HasBasis p s) :
UniformEquicontinuousOn F S ā
ā k, p k ā āį¶ xy : β à β in š¤ β ā š (S ĆĖ¢ S), ā i, (F i xy.1, F i xy.2) ā s k := by
rw [uniformEquicontinuousOn_iff_uniformContinuousOn, UniformContinuousOn,
(UniformFun.hasBasis_uniformity_of_basis ι α hα).tendsto_right_iff]
rfl
theorem Filter.HasBasis.uniformEquicontinuous_iff {Īŗā Īŗā : Type*} {pā : Īŗā ā Prop}
{sā : Īŗā ā Set (β à β)} {pā : Īŗā ā Prop} {sā : Īŗā ā Set (α à α)} {F : ι ā β ā α}
(hβ : (š¤ β).HasBasis pā sā) (hα : (š¤ α).HasBasis pā sā) :
UniformEquicontinuous F ā
ā kā, pā kā ā ā kā, pā kā ā§ ā x y, (x, y) ā sā kā ā ā i, (F i x, F i y) ā sā kā := by
rw [uniformEquicontinuous_iff_uniformContinuous, UniformContinuous,
hβ.tendsto_iff (UniformFun.hasBasis_uniformity_of_basis ι α hα)]
simp only [Prod.forall]
rfl
theorem Filter.HasBasis.uniformEquicontinuousOn_iff {Īŗā Īŗā : Type*} {pā : Īŗā ā Prop}
{sā : Īŗā ā Set (β à β)} {pā : Īŗā ā Prop} {sā : Īŗā ā Set (α à α)} {F : ι ā β ā α}
{S : Set β} (hβ : (š¤ β ā š (S ĆĖ¢ S)).HasBasis pā sā) (hα : (š¤ α).HasBasis pā sā) :
UniformEquicontinuousOn F S ā
ā kā, pā kā ā ā kā, pā kā ā§ ā x y, (x, y) ā sā kā ā ā i, (F i x, F i y) ā sā kā := by
rw [uniformEquicontinuousOn_iff_uniformContinuousOn, UniformContinuousOn,
hβ.tendsto_iff (UniformFun.hasBasis_uniformity_of_basis ι α hα)]
simp only [Prod.forall]
rfl
/-- Given `u : α ā β` a uniform inducing map, a family `š : ι ā X ā α` is equicontinuous at a point
`xā : X` iff the family `š'`, obtained by composing each function of `š` by `u`, is
equicontinuous at `xā`. -/
theorem UniformInducing.equicontinuousAt_iff {F : ι ā X ā α} {xā : X} {u : α ā β}
(hu : UniformInducing u) : EquicontinuousAt F xā ā EquicontinuousAt ((u ā Ā·) ā F) xā := by
have := (UniformFun.postcomp_uniformInducing (α := ι) hu).inducing
rw [equicontinuousAt_iff_continuousAt, equicontinuousAt_iff_continuousAt, this.continuousAt_iff]
rfl
/-- Given `u : α ā β` a uniform inducing map, a family `š : ι ā X ā α` is equicontinuous at a point
`xā : X` within a subset `S : Set X` iff the family `š'`, obtained by composing each function
of `š` by `u`, is equicontinuous at `xā` within `S`. -/
theorem UniformInducing.equicontinuousWithinAt_iff {F : ι ā X ā α} {S : Set X} {xā : X} {u : α ā β}
(hu : UniformInducing u) : EquicontinuousWithinAt F S xā ā
EquicontinuousWithinAt ((u ā Ā·) ā F) S xā := by
have := (UniformFun.postcomp_uniformInducing (α := ι) hu).inducing
simp only [equicontinuousWithinAt_iff_continuousWithinAt, this.continuousWithinAt_iff]
rfl
/-- Given `u : α ā β` a uniform inducing map, a family `š : ι ā X ā α` is equicontinuous iff the
family `š'`, obtained by composing each function of `š` by `u`, is equicontinuous. -/
theorem UniformInducing.equicontinuous_iff {F : ι ā X ā α} {u : α ā β} (hu : UniformInducing u) :
Equicontinuous F ā Equicontinuous ((u ā Ā·) ā F) := by
congrm ā x, ?_
rw [hu.equicontinuousAt_iff]
/-- Given `u : α ā β` a uniform inducing map, a family `š : ι ā X ā α` is equicontinuous on a
subset `S : Set X` iff the family `š'`, obtained by composing each function of `š` by `u`, is
equicontinuous on `S`. -/
theorem UniformInducing.equicontinuousOn_iff {F : ι ā X ā α} {S : Set X} {u : α ā β}
(hu : UniformInducing u) : EquicontinuousOn F S ā EquicontinuousOn ((u ā Ā·) ā F) S := by
congrm ā x ā S, ?_
rw [hu.equicontinuousWithinAt_iff]
/-- Given `u : α ā γ` a uniform inducing map, a family `š : ι ā β ā α` is uniformly equicontinuous
iff the family `š'`, obtained by composing each function of `š` by `u`, is uniformly
equicontinuous. -/
theorem UniformInducing.uniformEquicontinuous_iff {F : ι ā β ā α} {u : α ā γ}
(hu : UniformInducing u) : UniformEquicontinuous F ā UniformEquicontinuous ((u ā Ā·) ā F) := by
have := UniformFun.postcomp_uniformInducing (α := ι) hu
simp only [uniformEquicontinuous_iff_uniformContinuous, this.uniformContinuous_iff]
rfl
/-- Given `u : α ā γ` a uniform inducing map, a family `š : ι ā β ā α` is uniformly equicontinuous
on a subset `S : Set β` iff the family `š'`, obtained by composing each function of `š` by `u`,
is uniformly equicontinuous on `S`. -/
theorem UniformInducing.uniformEquicontinuousOn_iff {F : ι ā β ā α} {S : Set β} {u : α ā γ}
(hu : UniformInducing u) :
UniformEquicontinuousOn F S ā UniformEquicontinuousOn ((u ā Ā·) ā F) S := by
have := UniformFun.postcomp_uniformInducing (α := ι) hu
simp only [uniformEquicontinuousOn_iff_uniformContinuousOn, this.uniformContinuousOn_iff]
rfl
/-- If a set of functions is equicontinuous at some `xā` within a set `S`, the same is true for its
closure in *any* topology for which evaluation at any `x ā S āŖ {xā}` is continuous. Since
this will be applied to `DFunLike` types, we state it for any topological space whith a map
to `X ā α` satisfying the right continuity conditions. See also `Set.EquicontinuousWithinAt.closure`
for a more familiar (but weaker) statement.
Note: This could *technically* be called `EquicontinuousWithinAt.closure` without name clashes
with `Set.EquicontinuousWithinAt.closure`, but we don't do it because, even with a `protected`
marker, it would introduce ambiguities while working in namespace `Set` (e.g, in the proof of
any theorem called `Set.something`). -/
theorem EquicontinuousWithinAt.closure' {A : Set Y} {u : Y ā X ā α} {S : Set X} {xā : X}
(hA : EquicontinuousWithinAt (u ā (ā) : A ā X ā α) S xā) (huā : Continuous (S.restrict ā u))
(huā : Continuous (eval xā ā u)) :
EquicontinuousWithinAt (u ā (ā) : closure A ā X ā α) S xā := by
intro U hU
rcases mem_uniformity_isClosed hU with āØV, hV, hVclosed, hVUā©
filter_upwards [hA V hV, eventually_mem_nhdsWithin] with x hx hxS
rw [SetCoe.forall] at *
change A ā (fun f => (u f xā, u f x)) ā»Ā¹' V at hx
refine (closure_minimal hx <| hVclosed.preimage <| huā.prod_mk ?_).trans (preimage_mono hVU)
exact (continuous_apply āØx, hxSā©).comp huā
/-- If a set of functions is equicontinuous at some `xā`, the same is true for its closure in *any*
topology for which evaluation at any point is continuous. Since this will be applied to
`DFunLike` types, we state it for any topological space whith a map to `X ā α` satisfying the right
continuity conditions. See also `Set.EquicontinuousAt.closure` for a more familiar statement. -/
theorem EquicontinuousAt.closure' {A : Set Y} {u : Y ā X ā α} {xā : X}
(hA : EquicontinuousAt (u ā (ā) : A ā X ā α) xā) (hu : Continuous u) :
EquicontinuousAt (u ā (ā) : closure A ā X ā α) xā := by
rw [ā equicontinuousWithinAt_univ] at hA ā¢
exact hA.closure' (Pi.continuous_restrict _ |>.comp hu) (continuous_apply xā |>.comp hu)
/-- If a set of functions is equicontinuous at some `xā`, its closure for the product topology is
also equicontinuous at `xā`. -/
protected theorem Set.EquicontinuousAt.closure {A : Set (X ā α)} {xā : X}
(hA : A.EquicontinuousAt xā) : (closure A).EquicontinuousAt xā :=
hA.closure' (u := id) continuous_id
/-- If a set of functions is equicontinuous at some `xā` within a set `S`, its closure for the
product topology is also equicontinuous at `xā` within `S`. This would also be true for the coarser
topology of pointwise convergence on `S āŖ {xā}`, see `Set.EquicontinuousWithinAt.closure'`. -/
protected theorem Set.EquicontinuousWithinAt.closure {A : Set (X ā α)} {S : Set X} {xā : X}
(hA : A.EquicontinuousWithinAt S xā) :
(closure A).EquicontinuousWithinAt S xā :=
hA.closure' (u := id) (Pi.continuous_restrict _) (continuous_apply _)
/-- If a set of functions is equicontinuous, the same is true for its closure in *any*
topology for which evaluation at any point is continuous. Since this will be applied to
`DFunLike` types, we state it for any topological space whith a map to `X ā α` satisfying the right
continuity conditions. See also `Set.Equicontinuous.closure` for a more familiar statement. -/
theorem Equicontinuous.closure' {A : Set Y} {u : Y ā X ā α}
(hA : Equicontinuous (u ā (ā) : A ā X ā α)) (hu : Continuous u) :
Equicontinuous (u ā (ā) : closure A ā X ā α) := fun x ⦠(hA x).closure' hu
/-- If a set of functions is equicontinuous on a set `S`, the same is true for its closure in *any*
topology for which evaluation at any `x ā S` is continuous. Since this will be applied to
`DFunLike` types, we state it for any topological space whith a map to `X ā α` satisfying the right
continuity conditions. See also `Set.EquicontinuousOn.closure` for a more familiar
(but weaker) statement. -/
theorem EquicontinuousOn.closure' {A : Set Y} {u : Y ā X ā α} {S : Set X}
(hA : EquicontinuousOn (u ā (ā) : A ā X ā α) S) (hu : Continuous (S.restrict ā u)) :
EquicontinuousOn (u ā (ā) : closure A ā X ā α) S :=
fun x hx ⦠(hA x hx).closure' hu <| by exact continuous_apply āØx, hxā© |>.comp hu
/-- If a set of functions is equicontinuous, its closure for the product topology is also
equicontinuous. -/
protected theorem Set.Equicontinuous.closure {A : Set <| X ā α} (hA : A.Equicontinuous) :
(closure A).Equicontinuous := fun x ⦠Set.EquicontinuousAt.closure (hA x)
/-- If a set of functions is equicontinuous, its closure for the product topology is also
equicontinuous. This would also be true for the coarser topology of pointwise convergence on `S`,
see `EquicontinuousOn.closure'`. -/
protected theorem Set.EquicontinuousOn.closure {A : Set <| X ā α} {S : Set X}
(hA : A.EquicontinuousOn S) : (closure A).EquicontinuousOn S :=
fun x hx ⦠Set.EquicontinuousWithinAt.closure (hA x hx)
/-- If a set of functions is uniformly equicontinuous on a set `S`, the same is true for its
closure in *any* topology for which evaluation at any `x ā S` i continuous. Since this will be
applied to `DFunLike` types, we state it for any topological space whith a map to `β ā α` satisfying
the right continuity conditions. See also `Set.UniformEquicontinuousOn.closure` for a more familiar
(but weaker) statement. -/
theorem UniformEquicontinuousOn.closure' {A : Set Y} {u : Y ā β ā α} {S : Set β}
(hA : UniformEquicontinuousOn (u ā (ā) : A ā β ā α) S) (hu : Continuous (S.restrict ā u)) :
UniformEquicontinuousOn (u ā (ā) : closure A ā β ā α) S := by
intro U hU
rcases mem_uniformity_isClosed hU with āØV, hV, hVclosed, hVUā©
filter_upwards [hA V hV, mem_inf_of_right (mem_principal_self _)]
rintro āØx, yā© hxy āØhxS, hySā©
rw [SetCoe.forall] at *
change A ā (fun f => (u f x, u f y)) ā»Ā¹' V at hxy
refine (closure_minimal hxy <| hVclosed.preimage <| .prod_mk ?_ ?_).trans (preimage_mono hVU)
Ā· exact (continuous_apply āØx, hxSā©).comp hu
Ā· exact (continuous_apply āØy, hySā©).comp hu
/-- If a set of functions is uniformly equicontinuous, the same is true for its closure in *any*
topology for which evaluation at any point is continuous. Since this will be applied to
`DFunLike` types, we state it for any topological space whith a map to `β ā α` satisfying the right
continuity conditions. See also `Set.UniformEquicontinuous.closure` for a more familiar statement.
-/
theorem UniformEquicontinuous.closure' {A : Set Y} {u : Y ā β ā α}
(hA : UniformEquicontinuous (u ā (ā) : A ā β ā α)) (hu : Continuous u) :
UniformEquicontinuous (u ā (ā) : closure A ā β ā α) := by
rw [ā uniformEquicontinuousOn_univ] at hA ā¢
exact hA.closure' (Pi.continuous_restrict _ |>.comp hu)
/-- If a set of functions is uniformly equicontinuous, its closure for the product topology is also
uniformly equicontinuous. -/
protected theorem Set.UniformEquicontinuous.closure {A : Set <| β ā α}
(hA : A.UniformEquicontinuous) : (closure A).UniformEquicontinuous :=
UniformEquicontinuous.closure' (u := id) hA continuous_id
/-- If a set of functions is uniformly equicontinuous on a set `S`, its closure for the product
topology is also uniformly equicontinuous. This would also be true for the coarser topology of
pointwise convergence on `S`, see `UniformEquicontinuousOn.closure'`. -/
protected theorem Set.UniformEquicontinuousOn.closure {A : Set <| β ā α} {S : Set β}
(hA : A.UniformEquicontinuousOn S) : (closure A).UniformEquicontinuousOn S :=
UniformEquicontinuousOn.closure' (u := id) hA (Pi.continuous_restrict _)
/-
Implementation note: The following lemma (as well as all the following variations) could
theoretically be deduced from the "closure" statements above. For example, we could do:
```lean
theorem Filter.Tendsto.continuousAt_of_equicontinuousAt {l : Filter ι} [l.NeBot] {F : ι ā X ā α}
{f : X ā α} {xā : X} (hā : Tendsto F l (š f)) (hā : EquicontinuousAt F xā) :
ContinuousAt f xā :=
(equicontinuousAt_iff_range.mp hā).closure.continuousAt
āØf, mem_closure_of_tendsto hā <| eventually_of_forall mem_range_selfā©
theorem Filter.Tendsto.uniformContinuous_of_uniformEquicontinuous {l : Filter ι} [l.NeBot]
{F : ι ā β ā α} {f : β ā α} (hā : Tendsto F l (š f)) (hā : UniformEquicontinuous F) :
UniformContinuous f :=
(uniformEquicontinuous_iff_range.mp hā).closure.uniformContinuous
āØf, mem_closure_of_tendsto hā <| eventually_of_forall mem_range_selfā©
```
Unfortunately, the proofs get painful when dealing with the relative case as one needs to change
the ambient topology. So it turns out to be easier to re-do the proof by hand.
-/
/-- If `š : ι ā X ā α` tends to `f : X ā α` *pointwise on `S āŖ {xā} : Set X`* along some nontrivial
filter, and if the family `š` is equicontinuous at `xā : X` within `S`, then the limit is
continuous at `xā` within `S`. -/
theorem Filter.Tendsto.continuousWithinAt_of_equicontinuousWithinAt {l : Filter ι} [l.NeBot]
{F : ι ā X ā α} {f : X ā α} {S : Set X} {xā : X} (hā : ā x ā S, Tendsto (F Ā· x) l (š (f x)))
(hā : Tendsto (F Ā· xā) l (š (f xā))) (hā : EquicontinuousWithinAt F S xā) :
ContinuousWithinAt f S xā := by
intro U hU; rw [mem_map]
rcases UniformSpace.mem_nhds_iff.mp hU with āØV, hV, hVUā©
rcases mem_uniformity_isClosed hV with āØW, hW, hWclosed, hWVā©
filter_upwards [hā W hW, eventually_mem_nhdsWithin] with x hx hxS using
hVU <| ball_mono hWV (f xā) <| hWclosed.mem_of_tendsto (hā.prod_mk_nhds (hā x hxS)) <|
eventually_of_forall hx
/-- If `š : ι ā X ā α` tends to `f : X ā α` *pointwise* along some nontrivial filter, and if the
family `š` is equicontinuous at some `xā : X`, then the limit is continuous at `xā`. -/
theorem Filter.Tendsto.continuousAt_of_equicontinuousAt {l : Filter ι} [l.NeBot] {F : ι ā X ā α}
{f : X ā α} {xā : X} (hā : Tendsto F l (š f)) (hā : EquicontinuousAt F xā) :
ContinuousAt f xā := by
rw [ā continuousWithinAt_univ, ā equicontinuousWithinAt_univ, tendsto_pi_nhds] at *
exact continuousWithinAt_of_equicontinuousWithinAt (fun x _ ⦠hā x) (hā xā) hā
/-- If `š : ι ā X ā α` tends to `f : X ā α` *pointwise* along some nontrivial filter, and if the
family `š` is equicontinuous, then the limit is continuous. -/
theorem Filter.Tendsto.continuous_of_equicontinuous {l : Filter ι} [l.NeBot] {F : ι ā X ā α}
{f : X ā α} (hā : Tendsto F l (š f)) (hā : Equicontinuous F) : Continuous f :=
continuous_iff_continuousAt.mpr fun x => hā.continuousAt_of_equicontinuousAt (hā x)
/-- If `š : ι ā X ā α` tends to `f : X ā α` *pointwise on `S : Set X`* along some nontrivial
filter, and if the family `š` is equicontinuous, then the limit is continuous on `S`. -/
theorem Filter.Tendsto.continuousOn_of_equicontinuousOn {l : Filter ι} [l.NeBot] {F : ι ā X ā α}
{f : X ā α} {S : Set X} (hā : ā x ā S, Tendsto (F Ā· x) l (š (f x)))
(hā : EquicontinuousOn F S) : ContinuousOn f S :=
fun x hx ⦠Filter.Tendsto.continuousWithinAt_of_equicontinuousWithinAt hā (hā x hx) (hā x hx)
/-- If `š : ι ā β ā α` tends to `f : β ā α` *pointwise on `S : Set β`* along some nontrivial
filter, and if the family `š` is uniformly equicontinuous on `S`, then the limit is uniformly
continuous on `S`. -/
theorem Filter.Tendsto.uniformContinuousOn_of_uniformEquicontinuousOn {l : Filter ι} [l.NeBot]
{F : ι ā β ā α} {f : β ā α} {S : Set β} (hā : ā x ā S, Tendsto (F Ā· x) l (š (f x)))
(hā : UniformEquicontinuousOn F S) :
UniformContinuousOn f S := by
intro U hU; rw [mem_map]
rcases mem_uniformity_isClosed hU with āØV, hV, hVclosed, hVUā©
filter_upwards [hā V hV, mem_inf_of_right (mem_principal_self _)]
rintro āØx, yā© hxy āØhxS, hySā©
exact hVU <| hVclosed.mem_of_tendsto ((hā x hxS).prod_mk_nhds (hā y hyS)) <|
eventually_of_forall hxy
/-- If `š : ι ā β ā α` tends to `f : β ā α` *pointwise* along some nontrivial filter, and if the
family `š` is uniformly equicontinuous, then the limit is uniformly continuous. -/
theorem Filter.Tendsto.uniformContinuous_of_uniformEquicontinuous {l : Filter ι} [l.NeBot]
{F : ι ā β ā α} {f : β ā α} (hā : Tendsto F l (š f)) (hā : UniformEquicontinuous F) :
UniformContinuous f := by
rw [ā uniformContinuousOn_univ, ā uniformEquicontinuousOn_univ, tendsto_pi_nhds] at *
exact uniformContinuousOn_of_uniformEquicontinuousOn (fun x _ ⦠hā x) hā
/-- If `F : ι ā X ā α` is a family of functions equicontinuous at `x`,
it tends to `f y` along a filter `l` for any `y ā s`,
the limit function `f` tends to `z` along `š[s] x`, and `x ā closure s`,
then `(F Ā· x)` tends to `z` along `l`.
In some sense, this is a converse of `EquicontinuousAt.closure`. -/
theorem EquicontinuousAt.tendsto_of_mem_closure {l : Filter ι} {F : ι ā X ā α} {f : X ā α}
{s : Set X} {x : X} {z : α} (hF : EquicontinuousAt F x) (hf : Tendsto f (š[s] x) (š z))
(hs : ā y ā s, Tendsto (F Ā· y) l (š (f y))) (hx : x ā closure s) :
Tendsto (F Ā· x) l (š z) := by
rw [(nhds_basis_uniformity (š¤ α).basis_sets).tendsto_right_iff] at hf ā¢
intro U hU
rcases comp_comp_symm_mem_uniformity_sets hU with āØV, hV, hVs, hVUā©
rw [mem_closure_iff_nhdsWithin_neBot] at hx
have : āį¶ y in š[s] x, y ā s ā§ (ā i, (F i x, F i y) ā V) ā§ (f y, z) ā V :=
eventually_mem_nhdsWithin.and <| ((hF V hV).filter_mono nhdsWithin_le_nhds).and (hf V hV)
rcases this.exists with āØy, hys, hFy, hfyā©
filter_upwards [hs y hys (ball_mem_nhds _ hV)] with i hi
exact hVU āØ_, āØ_, hFy i, (mem_ball_symmetry hVs).2 hiā©, hfyā©
/-- If `F : ι ā X ā α` is an equicontinuous family of functions,
`f : X ā α` is a continuous function, and `l` is a filter on `ι`,
then `{x | Filter.Tendsto (F Ā· x) l (š (f x))}` is a closed set. -/
theorem Equicontinuous.isClosed_setOf_tendsto {l : Filter ι} {F : ι ā X ā α} {f : X ā α}
(hF : Equicontinuous F) (hf : Continuous f) :
IsClosed {x | Tendsto (F Ā· x) l (š (f x))} :=
closure_subset_iff_isClosed.mp fun x hx ā¦
(hF x).tendsto_of_mem_closure (hf.continuousAt.mono_left inf_le_left) (fun _ ⦠id) hx
end
end
|
Topology\UniformSpace\Equiv.lean
|
/-
Copyright (c) 2022 Anatole Dedecker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hƶlzl, Patrick Massot, SƩbastien Gouƫzel, Zhouhang Zhou, Reid Barton,
Anatole Dedecker
-/
import Mathlib.Topology.Homeomorph
import Mathlib.Topology.UniformSpace.UniformEmbedding
import Mathlib.Topology.UniformSpace.Pi
/-!
# Uniform isomorphisms
This file defines uniform isomorphisms between two uniform spaces. They are bijections with both
directions uniformly continuous. We denote uniform isomorphisms with the notation `āᵤ`.
# Main definitions
* `UniformEquiv α β`: The type of uniform isomorphisms from `α` to `β`.
This type can be denoted using the following notation: `α āᵤ β`.
-/
open Set Filter
universe u v
variable {α : Type u} {β : Type*} {γ : Type*} {Γ : Type*}
-- not all spaces are homeomorphic to each other
/-- Uniform isomorphism between `α` and `β` -/
--@[nolint has_nonempty_instance] -- Porting note(#5171): linter not yet ported
structure UniformEquiv (α : Type*) (β : Type*) [UniformSpace α] [UniformSpace β] extends
α ā β where
/-- Uniform continuity of the function -/
uniformContinuous_toFun : UniformContinuous toFun
/-- Uniform continuity of the inverse -/
uniformContinuous_invFun : UniformContinuous invFun
/-- Uniform isomorphism between `α` and `β` -/
infixl:25 " āᵤ " => UniformEquiv
namespace UniformEquiv
variable [UniformSpace α] [UniformSpace β] [UniformSpace γ] [UniformSpace Γ]
theorem toEquiv_injective : Function.Injective (toEquiv : α āᵤ β ā α ā β)
| āØe, hā, hāā©, āØe', hā', hā'ā©, h => by simpa only [mk.injEq]
instance : EquivLike (α āᵤ β) α β where
coe := fun h => h.toEquiv
inv := fun h => h.toEquiv.symm
left_inv := fun h => h.left_inv
right_inv := fun h => h.right_inv
coe_injective' := fun _ _ H _ => toEquiv_injective <| DFunLike.ext' H
@[simp]
theorem uniformEquiv_mk_coe (a : Equiv α β) (b c) : (UniformEquiv.mk a b c : α ā β) = a :=
rfl
/-- Inverse of a uniform isomorphism. -/
protected def symm (h : α āᵤ β) : β āᵤ α where
uniformContinuous_toFun := h.uniformContinuous_invFun
uniformContinuous_invFun := h.uniformContinuous_toFun
toEquiv := h.toEquiv.symm
/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,
because it is a composition of multiple projections. -/
def Simps.apply (h : α āᵤ β) : α ā β :=
h
/-- See Note [custom simps projection] -/
def Simps.symm_apply (h : α āᵤ β) : β ā α :=
h.symm
initialize_simps_projections UniformEquiv (toFun ā apply, invFun ā symm_apply)
@[simp]
theorem coe_toEquiv (h : α āᵤ β) : āh.toEquiv = h :=
rfl
@[simp]
theorem coe_symm_toEquiv (h : α āᵤ β) : āh.toEquiv.symm = h.symm :=
rfl
@[ext]
theorem ext {h h' : α āᵤ β} (H : ā x, h x = h' x) : h = h' :=
toEquiv_injective <| Equiv.ext H
/-- Identity map as a uniform isomorphism. -/
@[simps! (config := .asFn) apply]
protected def refl (α : Type*) [UniformSpace α] : α āᵤ α where
uniformContinuous_toFun := uniformContinuous_id
uniformContinuous_invFun := uniformContinuous_id
toEquiv := Equiv.refl α
/-- Composition of two uniform isomorphisms. -/
protected def trans (hā : α āᵤ β) (hā : β āᵤ γ) : α āᵤ γ where
uniformContinuous_toFun := hā.uniformContinuous_toFun.comp hā.uniformContinuous_toFun
uniformContinuous_invFun := hā.uniformContinuous_invFun.comp hā.uniformContinuous_invFun
toEquiv := Equiv.trans hā.toEquiv hā.toEquiv
@[simp]
theorem trans_apply (hā : α āᵤ β) (hā : β āᵤ γ) (a : α) : hā.trans hā a = hā (hā a) :=
rfl
@[simp]
theorem uniformEquiv_mk_coe_symm (a : Equiv α β) (b c) :
((UniformEquiv.mk a b c).symm : β ā α) = a.symm :=
rfl
@[simp]
theorem refl_symm : (UniformEquiv.refl α).symm = UniformEquiv.refl α :=
rfl
protected theorem uniformContinuous (h : α āᵤ β) : UniformContinuous h :=
h.uniformContinuous_toFun
@[continuity]
protected theorem continuous (h : α āᵤ β) : Continuous h :=
h.uniformContinuous.continuous
protected theorem uniformContinuous_symm (h : α āᵤ β) : UniformContinuous h.symm :=
h.uniformContinuous_invFun
-- otherwise `by continuity` can't prove continuity of `h.to_equiv.symm`
@[continuity]
protected theorem continuous_symm (h : α āᵤ β) : Continuous h.symm :=
h.uniformContinuous_symm.continuous
/-- A uniform isomorphism as a homeomorphism. -/
-- @[simps] -- Porting note: removed, `simps?` produced no `simp` lemmas
protected def toHomeomorph (e : α āᵤ β) : α āā β :=
{ e.toEquiv with
continuous_toFun := e.continuous
continuous_invFun := e.continuous_symm }
lemma toHomeomorph_apply (e : α āᵤ β) : (e.toHomeomorph : α ā β) = e := rfl
lemma toHomeomorph_symm_apply (e : α āᵤ β) : (e.toHomeomorph.symm : β ā α) = e.symm := rfl
@[simp]
theorem apply_symm_apply (h : α āᵤ β) (x : β) : h (h.symm x) = x :=
h.toEquiv.apply_symm_apply x
@[simp]
theorem symm_apply_apply (h : α āᵤ β) (x : α) : h.symm (h x) = x :=
h.toEquiv.symm_apply_apply x
protected theorem bijective (h : α āᵤ β) : Function.Bijective h :=
h.toEquiv.bijective
protected theorem injective (h : α āᵤ β) : Function.Injective h :=
h.toEquiv.injective
protected theorem surjective (h : α āᵤ β) : Function.Surjective h :=
h.toEquiv.surjective
/-- Change the uniform equiv `f` to make the inverse function definitionally equal to `g`. -/
def changeInv (f : α āᵤ β) (g : β ā α) (hg : Function.RightInverse g f) : α āᵤ β :=
have : g = f.symm :=
funext fun x => calc
g x = f.symm (f (g x)) := (f.left_inv (g x)).symm
_ = f.symm x := by rw [hg x]
{ toFun := f
invFun := g
left_inv := by convert f.left_inv
right_inv := by convert f.right_inv using 1
uniformContinuous_toFun := f.uniformContinuous
uniformContinuous_invFun := by convert f.symm.uniformContinuous }
@[simp]
theorem symm_comp_self (h : α āᵤ β) : (h.symm : β ā α) ā h = id :=
funext h.symm_apply_apply
@[simp]
theorem self_comp_symm (h : α āᵤ β) : (h : α ā β) ā h.symm = id :=
funext h.apply_symm_apply
-- @[simp] -- Porting note (#10618): `simp` can prove this `simp only [Equiv.range_eq_univ]`
theorem range_coe (h : α āᵤ β) : range h = univ :=
h.surjective.range_eq
theorem image_symm (h : α āᵤ β) : image h.symm = preimage h :=
funext h.symm.toEquiv.image_eq_preimage
theorem preimage_symm (h : α āᵤ β) : preimage h.symm = image h :=
(funext h.toEquiv.image_eq_preimage).symm
-- @[simp] -- Porting note (#10618): `simp` can prove this `simp only [Equiv.image_preimage]`
theorem image_preimage (h : α āᵤ β) (s : Set β) : h '' (h ā»Ā¹' s) = s :=
h.toEquiv.image_preimage s
--@[simp] -- Porting note (#10618): `simp` can prove this `simp only [Equiv.preimage_image]`
theorem preimage_image (h : α āᵤ β) (s : Set α) : h ā»Ā¹' (h '' s) = s :=
h.toEquiv.preimage_image s
protected theorem uniformInducing (h : α āᵤ β) : UniformInducing h :=
uniformInducing_of_compose h.uniformContinuous h.symm.uniformContinuous <| by
simp only [symm_comp_self, uniformInducing_id]
theorem comap_eq (h : α āᵤ β) : UniformSpace.comap h ā¹_āŗ = ā¹_āŗ :=
h.uniformInducing.comap_uniformSpace
protected theorem uniformEmbedding (h : α āᵤ β) : UniformEmbedding h :=
āØh.uniformInducing, h.injectiveā©
theorem completeSpace_iff (h : α āᵤ β) : CompleteSpace α ā CompleteSpace β :=
completeSpace_congr h.uniformEmbedding
/-- Uniform equiv given a uniform embedding. -/
noncomputable def ofUniformEmbedding (f : α ā β) (hf : UniformEmbedding f) : α āᵤ Set.range f where
uniformContinuous_toFun := hf.toUniformInducing.uniformContinuous.subtype_mk _
uniformContinuous_invFun := by
rw [hf.toUniformInducing.uniformContinuous_iff, Equiv.invFun_as_coe,
Equiv.self_comp_ofInjective_symm]
exact uniformContinuous_subtype_val
toEquiv := Equiv.ofInjective f hf.inj
/-- If two sets are equal, then they are uniformly equivalent. -/
def setCongr {s t : Set α} (h : s = t) : s āᵤ t where
uniformContinuous_toFun := uniformContinuous_subtype_val.subtype_mk _
uniformContinuous_invFun := uniformContinuous_subtype_val.subtype_mk _
toEquiv := Equiv.setCongr h
/-- Product of two uniform isomorphisms. -/
def prodCongr (hā : α āᵤ β) (hā : γ āᵤ Ī“) : α à γ āᵤ β Ć Ī“ where
uniformContinuous_toFun :=
(hā.uniformContinuous.comp uniformContinuous_fst).prod_mk
(hā.uniformContinuous.comp uniformContinuous_snd)
uniformContinuous_invFun :=
(hā.symm.uniformContinuous.comp uniformContinuous_fst).prod_mk
(hā.symm.uniformContinuous.comp uniformContinuous_snd)
toEquiv := hā.toEquiv.prodCongr hā.toEquiv
@[simp]
theorem prodCongr_symm (hā : α āᵤ β) (hā : γ āᵤ Ī“) :
(hā.prodCongr hā).symm = hā.symm.prodCongr hā.symm :=
rfl
@[simp]
theorem coe_prodCongr (hā : α āᵤ β) (hā : γ āᵤ Ī“) : ā(hā.prodCongr hā) = Prod.map hā hā :=
rfl
section
variable (α β γ)
/-- `α à β` is uniformly isomorphic to `β à α`. -/
def prodComm : α à β āᵤ β à α where
uniformContinuous_toFun := uniformContinuous_snd.prod_mk uniformContinuous_fst
uniformContinuous_invFun := uniformContinuous_snd.prod_mk uniformContinuous_fst
toEquiv := Equiv.prodComm α β
@[simp]
theorem prodComm_symm : (prodComm α β).symm = prodComm β α :=
rfl
@[simp]
theorem coe_prodComm : ā(prodComm α β) = Prod.swap :=
rfl
/-- `(α à β) à γ` is uniformly isomorphic to `α à (β à γ)`. -/
def prodAssoc : (α à β) à γ āᵤ α à β à γ where
uniformContinuous_toFun :=
(uniformContinuous_fst.comp uniformContinuous_fst).prod_mk
((uniformContinuous_snd.comp uniformContinuous_fst).prod_mk uniformContinuous_snd)
uniformContinuous_invFun := by -- Porting note: the `rw` was not necessary in Lean 3
rw [Equiv.invFun, Equiv.prodAssoc]
exact (uniformContinuous_fst.prod_mk (uniformContinuous_fst.comp
uniformContinuous_snd)).prod_mk (uniformContinuous_snd.comp uniformContinuous_snd)
toEquiv := Equiv.prodAssoc α β γ
/-- `α à {*}` is uniformly isomorphic to `α`. -/
@[simps! (config := .asFn) apply]
def prodPunit : α Ć PUnit āᵤ α where
toEquiv := Equiv.prodPUnit α
uniformContinuous_toFun := uniformContinuous_fst
uniformContinuous_invFun := uniformContinuous_id.prod_mk uniformContinuous_const
/-- `{*} à α` is uniformly isomorphic to `α`. -/
def punitProd : PUnit à α āᵤ α :=
(prodComm _ _).trans (prodPunit _)
@[simp]
theorem coe_punitProd : ā(punitProd α) = Prod.snd :=
rfl
/-- `Equiv.piCongrLeft` as a uniform isomorphism: this is the natural isomorphism
`Ī i, β (e i) āᵤ Ī j, β j` obtained from a bijection `ι ā ι'`. -/
@[simps! apply toEquiv]
def piCongrLeft {ι ι' : Type*} {β : ι' ā Type*} [ā j, UniformSpace (β j)]
(e : ι ā ι') : (ā i, β (e i)) āᵤ ā j, β j where
uniformContinuous_toFun := uniformContinuous_pi.mpr <| e.forall_congr_right.mp fun i ⦠by
simpa only [Equiv.toFun_as_coe, Equiv.piCongrLeft_apply_apply] using
Pi.uniformContinuous_proj _ i
uniformContinuous_invFun := Pi.uniformContinuous_precomp' _ e
toEquiv := Equiv.piCongrLeft _ e
/-- `Equiv.piCongrRight` as a uniform isomorphism: this is the natural isomorphism
`Ī i, βā i āᵤ Ī j, βā i` obtained from uniform isomorphisms `βā i āᵤ βā i` for each `i`. -/
@[simps! apply toEquiv]
def piCongrRight {ι : Type*} {βā βā : ι ā Type*} [ā i, UniformSpace (βā i)]
[ā i, UniformSpace (βā i)] (F : ā i, βā i āᵤ βā i) : (ā i, βā i) āᵤ ā i, βā i where
uniformContinuous_toFun := Pi.uniformContinuous_postcomp' _ fun i ⦠(F i).uniformContinuous
uniformContinuous_invFun := Pi.uniformContinuous_postcomp' _ fun i ⦠(F i).symm.uniformContinuous
toEquiv := Equiv.piCongrRight fun i => (F i).toEquiv
@[simp]
theorem piCongrRight_symm {ι : Type*} {βā βā : ι ā Type*} [ā i, UniformSpace (βā i)]
[ā i, UniformSpace (βā i)] (F : ā i, βā i āᵤ βā i) :
(piCongrRight F).symm = piCongrRight fun i => (F i).symm :=
rfl
/-- `Equiv.piCongr` as a uniform isomorphism: this is the natural isomorphism
`Ī iā, βā i āᵤ Ī iā, βā iā` obtained from a bijection `ιā ā ιā` and isomorphisms
`βā iā āᵤ βā (e iā)` for each `iā : ιā`. -/
@[simps! apply toEquiv]
def piCongr {ιā ιā : Type*} {βā : ιā ā Type*} {βā : ιā ā Type*}
[ā iā, UniformSpace (βā iā)] [ā iā, UniformSpace (βā iā)]
(e : ιā ā ιā) (F : ā iā, βā iā āᵤ βā (e iā)) : (ā iā, βā iā) āᵤ ā iā, βā iā :=
(UniformEquiv.piCongrRight F).trans (UniformEquiv.piCongrLeft e)
/-- Uniform equivalence between `ULift α` and `α`. -/
def ulift : ULift.{v, u} α āᵤ α :=
{ Equiv.ulift with
uniformContinuous_toFun := uniformContinuous_comap
uniformContinuous_invFun := by
have hf : UniformInducing (@Equiv.ulift.{v, u} α).toFun := āØrflā©
simp_rw [hf.uniformContinuous_iff]
exact uniformContinuous_id }
end
/-- If `ι` has a unique element, then `ι ā α` is uniformly isomorphic to `α`. -/
@[simps! (config := .asFn)]
def funUnique (ι α : Type*) [Unique ι] [UniformSpace α] : (ι ā α) āᵤ α where
toEquiv := Equiv.funUnique ι α
uniformContinuous_toFun := Pi.uniformContinuous_proj _ _
uniformContinuous_invFun := uniformContinuous_pi.mpr fun _ => uniformContinuous_id
/-- Uniform isomorphism between dependent functions `Πi : Fin 2, α i` and `α 0 à α 1`. -/
@[simps! (config := .asFn)]
def piFinTwo (α : Fin 2 ā Type u) [ā i, UniformSpace (α i)] : (ā i, α i) āᵤ α 0 à α 1 where
toEquiv := piFinTwoEquiv α
uniformContinuous_toFun := (Pi.uniformContinuous_proj _ 0).prod_mk (Pi.uniformContinuous_proj _ 1)
uniformContinuous_invFun :=
uniformContinuous_pi.mpr <| Fin.forall_fin_two.2 āØuniformContinuous_fst, uniformContinuous_sndā©
/-- Uniform isomorphism between `α² = Fin 2 ā α` and `α à α`. -/
-- Porting note: made `α` explicit
@[simps! (config := .asFn)]
def finTwoArrow (α : Type*) [UniformSpace α] : (Fin 2 ā α) āᵤ α à α :=
{ piFinTwo fun _ => α with toEquiv := finTwoArrowEquiv α }
/-- A subset of a uniform space is uniformly isomorphic to its image under a uniform isomorphism.
-/
def image (e : α āᵤ β) (s : Set α) : s āᵤ e '' s where
uniformContinuous_toFun := (e.uniformContinuous.comp uniformContinuous_subtype_val).subtype_mk _
uniformContinuous_invFun :=
(e.symm.uniformContinuous.comp uniformContinuous_subtype_val).subtype_mk _
toEquiv := e.toEquiv.image s
end UniformEquiv
/-- A uniform inducing equiv between uniform spaces is a uniform isomorphism. -/
-- @[simps] -- Porting note: removed, `simps?` produced no `simp` lemmas
def Equiv.toUniformEquivOfUniformInducing [UniformSpace α] [UniformSpace β] (f : α ā β)
(hf : UniformInducing f) : α āᵤ β :=
{ f with
uniformContinuous_toFun := hf.uniformContinuous
uniformContinuous_invFun := hf.uniformContinuous_iff.2 <| by simpa using uniformContinuous_id }
|
Topology\UniformSpace\Matrix.lean
|
/-
Copyright (c) 2022 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser, Heather Macbeth
-/
import Mathlib.Topology.Algebra.UniformGroup
import Mathlib.Topology.UniformSpace.Pi
import Mathlib.Data.Matrix.Basic
/-!
# Uniform space structure on matrices
-/
open Uniformity Topology
variable (m n š : Type*) [UniformSpace š]
namespace Matrix
instance instUniformSpace : UniformSpace (Matrix m n š) :=
(by infer_instance : UniformSpace (m ā n ā š))
instance instUniformAddGroup [AddGroup š] [UniformAddGroup š] :
UniformAddGroup (Matrix m n š) :=
inferInstanceAs <| UniformAddGroup (m ā n ā š)
theorem uniformity :
š¤ (Matrix m n š) = āØ
(i : m) (j : n), (š¤ š).comap fun a => (a.1 i j, a.2 i j) := by
erw [Pi.uniformity]
simp_rw [Pi.uniformity, Filter.comap_iInf, Filter.comap_comap]
rfl
theorem uniformContinuous {β : Type*} [UniformSpace β] {f : β ā Matrix m n š} :
UniformContinuous f ā ā i j, UniformContinuous fun x => f x i j := by
simp only [UniformContinuous, Matrix.uniformity, Filter.tendsto_iInf, Filter.tendsto_comap_iff]
apply Iff.intro <;> intro a <;> apply a
instance [CompleteSpace š] : CompleteSpace (Matrix m n š) :=
(by infer_instance : CompleteSpace (m ā n ā š))
instance [T0Space š] : T0Space (Matrix m n š) :=
inferInstanceAs (T0Space (m ā n ā š))
end Matrix
|
Topology\UniformSpace\Pi.lean
|
/-
Copyright (c) 2019 Patrick Massot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot
-/
import Mathlib.Topology.UniformSpace.UniformEmbedding
/-!
# Indexed product of uniform spaces
-/
noncomputable section
open scoped Uniformity Topology
open Filter UniformSpace Function Set
universe u
variable {ι ι' β : Type*} (α : ι ā Type u) [U : ā i, UniformSpace (α i)] [UniformSpace β]
instance Pi.uniformSpace : UniformSpace (ā i, α i) :=
UniformSpace.ofCoreEq (āØ
i, UniformSpace.comap (eval i) (U i)).toCore
Pi.topologicalSpace <|
Eq.symm toTopologicalSpace_iInf
lemma Pi.uniformSpace_eq :
Pi.uniformSpace α = āØ
i, UniformSpace.comap (eval i) (U i) := by
ext : 1; rfl
theorem Pi.uniformity :
š¤ (ā i, α i) = āØ
i : ι, (Filter.comap fun a => (a.1 i, a.2 i)) (š¤ (α i)) :=
iInf_uniformity
variable {α}
instance [Countable ι] [ā i, IsCountablyGenerated (š¤ (α i))] :
IsCountablyGenerated (š¤ (ā i, α i)) := by
rw [Pi.uniformity]
infer_instance
theorem uniformContinuous_pi {β : Type*} [UniformSpace β] {f : β ā ā i, α i} :
UniformContinuous f ā ā i, UniformContinuous fun x => f x i := by
-- Porting note: required `Function.comp` to close
simp only [UniformContinuous, Pi.uniformity, tendsto_iInf, tendsto_comap_iff, Function.comp]
variable (α)
theorem Pi.uniformContinuous_proj (i : ι) : UniformContinuous fun a : ā i : ι, α i => a i :=
uniformContinuous_pi.1 uniformContinuous_id i
theorem Pi.uniformContinuous_precomp' (Ļ : ι' ā ι) :
UniformContinuous (fun (f : (ā i, α i)) (j : ι') ⦠f (Ļ j)) :=
uniformContinuous_pi.mpr fun j ⦠uniformContinuous_proj α (Ļ j)
theorem Pi.uniformContinuous_precomp (Ļ : ι' ā ι) :
UniformContinuous (Ā· ā Ļ : (ι ā β) ā (ι' ā β)) :=
Pi.uniformContinuous_precomp' _ Ļ
theorem Pi.uniformContinuous_postcomp' {β : ι ā Type*} [ā i, UniformSpace (β i)]
{g : ā i, α i ā β i} (hg : ā i, UniformContinuous (g i)) :
UniformContinuous (fun (f : (ā i, α i)) (i : ι) ⦠g i (f i)) :=
uniformContinuous_pi.mpr fun i ⦠(hg i).comp <| uniformContinuous_proj α i
theorem Pi.uniformContinuous_postcomp {α : Type*} [UniformSpace α] {g : α ā β}
(hg : UniformContinuous g) : UniformContinuous (g ā Ā· : (ι ā α) ā (ι ā β)) :=
Pi.uniformContinuous_postcomp' _ fun _ ⦠hg
lemma Pi.uniformSpace_comap_precomp' (Ļ : ι' ā ι) :
UniformSpace.comap (fun g i' ⦠g (Ļ i')) (Pi.uniformSpace (fun i' ⦠α (Ļ i'))) =
āØ
i', UniformSpace.comap (eval (Ļ i')) (U (Ļ i')) := by
simp [Pi.uniformSpace_eq, UniformSpace.comap_iInf, ā UniformSpace.comap_comap, comp]
lemma Pi.uniformSpace_comap_precomp (Ļ : ι' ā ι) :
UniformSpace.comap (Ā· ā Ļ) (Pi.uniformSpace (fun _ ⦠β)) =
āØ
i', UniformSpace.comap (eval (Ļ i')) ā¹UniformSpace β⺠:=
uniformSpace_comap_precomp' (fun _ ⦠β) Ļ
lemma Pi.uniformContinuous_restrict (S : Set ι) :
UniformContinuous (S.restrict : (ā i : ι, α i) ā (ā i : S, α i)) :=
Pi.uniformContinuous_precomp' _ ((ā) : S ā ι)
lemma Pi.uniformSpace_comap_restrict (S : Set ι) :
UniformSpace.comap (S.restrict) (Pi.uniformSpace (fun i : S ⦠α i)) =
āØ
i ā S, UniformSpace.comap (eval i) (U i) := by
simp (config := { unfoldPartialApp := true })
[ā iInf_subtype'', ā uniformSpace_comap_precomp' _ ((ā) : S ā ι), Set.restrict]
lemma cauchy_pi_iff [Nonempty ι] {l : Filter (ā i, α i)} :
Cauchy l ā ā i, Cauchy (map (eval i) l) := by
simp_rw [Pi.uniformSpace_eq, cauchy_iInf_uniformSpace, cauchy_comap_uniformSpace]
lemma cauchy_pi_iff' {l : Filter (ā i, α i)} [l.NeBot] :
Cauchy l ā ā i, Cauchy (map (eval i) l) := by
simp_rw [Pi.uniformSpace_eq, cauchy_iInf_uniformSpace', cauchy_comap_uniformSpace]
lemma Cauchy.pi [Nonempty ι] {l : ā i, Filter (α i)} (hl : ā i, Cauchy (l i)) :
Cauchy (Filter.pi l) := by
have := fun i ⦠(hl i).1
simpa [cauchy_pi_iff]
instance Pi.complete [ā i, CompleteSpace (α i)] : CompleteSpace (ā i, α i) where
complete {f} hf := by
have := hf.1
simp_rw [cauchy_pi_iff', cauchy_iff_exists_le_nhds] at hf
choose x hx using hf
use x
rwa [nhds_pi, le_pi]
lemma Pi.uniformSpace_comap_restrict_sUnion (š : Set (Set ι)) :
UniformSpace.comap (āā š).restrict (Pi.uniformSpace (fun i : (āā š) ⦠α i)) =
āØ
S ā š, UniformSpace.comap S.restrict (Pi.uniformSpace (fun i : S ⦠α i)) := by
simp_rw [Pi.uniformSpace_comap_restrict α, iInf_sUnion]
/- An infimum of complete uniformities is complete,
as long as the whole family is bounded by some common T2 topology. -/
protected theorem CompleteSpace.iInf {ι X : Type*} {u : ι ā UniformSpace X}
(hu : ā i, @CompleteSpace X (u i))
(ht : ā t, @T2Space X t ā§ ā i, (u i).toTopologicalSpace ⤠t) :
@CompleteSpace X (āØ
i, u i) := by
-- We can assume `X` is nonempty.
nontriviality X
rcases ht with āØt, ht, hutā©
-- The diagonal map `(X, āØ
i, u i) ā ā i, (X, u i)` is a uniform embedding.
have : @UniformInducing X (ι ā X) (āØ
i, u i) (Pi.uniformSpace (U := u)) (const ι) := by
simp_rw [uniformInducing_iff, iInf_uniformity, Pi.uniformity, Filter.comap_iInf,
Filter.comap_comap, (Ā· ā Ā·), const, Prod.eta, comap_id']
-- Hence, it suffices to show that its range, the diagonal, is closed in `Ī i, (X, u i)`.
simp_rw [@completeSpace_iff_isComplete_range _ _ (_) (_) _ this, range_const_eq_diagonal,
setOf_forall]
-- The separation of `t` ensures that this is the case in `Ī i, (X, t)`, hence the result
-- since the topology associated to each `u i` is finer than `t`.
have : Pi.topologicalSpace (tā := fun i ⦠(u i).toTopologicalSpace) ā¤
Pi.topologicalSpace (tā := fun _ ⦠t) :=
iInf_mono fun i ⦠induced_mono <| hut i
refine IsClosed.isComplete <| .mono ?_ this
exact isClosed_iInter fun i ⦠isClosed_iInter fun j ā¦
isClosed_eq (continuous_apply _) (continuous_apply _)
|
Topology\UniformSpace\Separation.lean
|
/-
Copyright (c) 2017 Johannes Hƶlzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hƶlzl, Patrick Massot, Yury Kudryashov
-/
import Mathlib.Tactic.ApplyFun
import Mathlib.Topology.UniformSpace.Basic
import Mathlib.Topology.Separation
/-!
# Hausdorff properties of uniform spaces. Separation quotient.
Two points of a topological space are called `Inseparable`,
if their neighborhoods filter are equal.
Equivalently, `Inseparable x y` means that any open set that contains `x` must contain `y`
and vice versa.
In a uniform space, points `x` and `y` are inseparable
if and only if `(x, y)` belongs to all entourages,
see `inseparable_iff_ker_uniformity`.
A uniform space is a regular topological space,
hence separation axioms `T0Space`, `T1Space`, `T2Space`, and `T3Space`
are equivalent for uniform spaces,
and Lean typeclass search can automatically convert from one assumption to another.
We say that a uniform space is *separated*, if it satisfies these axioms.
If you need an `Iff` statement (e.g., to rewrite),
then see `R1Space.t0Space_iff_t2Space` and `RegularSpace.t0Space_iff_t3Space`.
In this file we prove several facts
that relate `Inseparable` and `Specializes` to the uniformity filter.
Most of them are simple corollaries of `Filter.HasBasis.inseparable_iff_uniformity`
for different filter bases of `š¤ α`.
Then we study the Kolmogorov quotient `SeparationQuotient X` of a uniform space.
For a general topological space,
this quotient is defined as the quotient by `Inseparable` equivalence relation.
It is the maximal Tā quotient of a topological space.
In case of a uniform space, we equip this quotient with a `UniformSpace` structure
that agrees with the quotient topology.
We also prove that the quotient map induces uniformity on the original space.
Finally, we turn `SeparationQuotient` into a functor
(not in terms of `CategoryTheory.Functor` to avoid extra imports)
by defining `SeparationQuotient.lift'` and `SeparationQuotient.map` operations.
## Main definitions
* `SeparationQuotient.instUniformSpace`: uniform space structure on `SeparationQuotient α`,
where `α` is a uniform space;
* `SeparationQuotient.lift'`: given a map `f : α ā β`
from a uniform space to a separated uniform space,
lift it to a map `SeparationQuotient α ā β`;
if the original map is not uniformly continuous, then returns a constant map.
* `SeparationQuotient.map`: given a map `f : α ā β` between uniform spaces,
returns a map `SeparationQuotient α ā SeparationQuotient β`.
If the original map is not uniformly continuous, then returns a constant map.
Otherwise, `SeparationQuotient.map f (SeparationQuotient.mk x) = SeparationQuotient.mk (f x)`.
## Main results
* `SeparationQuotient.uniformity_eq`: the uniformity filter on `SeparationQuotient α`
is the push forward of the uniformity filter on `α`.
* `SeparationQuotient.comap_mk_uniformity`: the quotient map `α ā SeparationQuotient α`
induces uniform space structure on the original space.
* `SeparationQuotient.uniformContinuous_lift'`: factoring a uniformly continuous map through the
separation quotient gives a uniformly continuous map.
* `SeparationQuotient.uniformContinuous_map`: maps induced between separation quotients are
uniformly continuous.
## Implementation notes
This files used to contain definitions of `separationRel α` and `UniformSpace.SeparationQuotient α`.
These definitions were equal (but not definitionally equal)
to `{x : α à α | Inseparable x.1 x.2}` and `SeparationQuotient α`, respectively,
and were added to the library before their geneeralizations to topological spaces.
In #10644, we migrated from these definitions
to more general `Inseparable` and `SeparationQuotient`.
## TODO
Definitions `SeparationQuotient.lift'` and `SeparationQuotient.map`
rely on `UniformSpace` structures in the domain and in the codomain.
We should generalize them to topological spaces.
This generalization will drop `UniformContinuous` assumptions in some lemmas,
and add these assumptions in other lemmas,
so it was not done in #10644 to keep it reasonably sized.
## Keywords
uniform space, separated space, Hausdorff space, separation quotient
-/
open Filter Set Function Topology Uniformity UniformSpace
open scoped Classical
noncomputable section
universe u v w
variable {α : Type u} {β : Type v} {γ : Type w}
variable [UniformSpace α] [UniformSpace β] [UniformSpace γ]
/-!
### Separated uniform spaces
-/
instance (priority := 100) UniformSpace.to_regularSpace : RegularSpace α :=
.of_hasBasis
(fun _ ⦠nhds_basis_uniformity' uniformity_hasBasis_closed)
fun a _V hV ⦠isClosed_ball a hV.2
theorem Filter.HasBasis.specializes_iff_uniformity {ι : Sort*} {p : ι ā Prop} {s : ι ā Set (α à α)}
(h : (š¤ α).HasBasis p s) {x y : α} : x ⤳ y ā ā i, p i ā (x, y) ā s i :=
(nhds_basis_uniformity h).specializes_iff
theorem Filter.HasBasis.inseparable_iff_uniformity {ι : Sort*} {p : ι ā Prop} {s : ι ā Set (α à α)}
(h : (š¤ α).HasBasis p s) {x y : α} : Inseparable x y ā ā i, p i ā (x, y) ā s i :=
specializes_iff_inseparable.symm.trans h.specializes_iff_uniformity
theorem inseparable_iff_ker_uniformity {x y : α} : Inseparable x y ā (x, y) ā (š¤ α).ker :=
(š¤ α).basis_sets.inseparable_iff_uniformity
protected theorem Inseparable.nhds_le_uniformity {x y : α} (h : Inseparable x y) :
š (x, y) ⤠š¤ α := by
rw [h.prod rfl]
apply nhds_le_uniformity
theorem inseparable_iff_clusterPt_uniformity {x y : α} :
Inseparable x y ā ClusterPt (x, y) (š¤ α) := by
refine āØfun h ⦠.of_nhds_le h.nhds_le_uniformity, fun h ⦠?_ā©
simp_rw [uniformity_hasBasis_closed.inseparable_iff_uniformity, isClosed_iff_clusterPt]
exact fun U āØhU, hUc⩠⦠hUc _ <| h.mono <| le_principal_iff.2 hU
theorem t0Space_iff_uniformity :
T0Space α ā ā x y, (ā r ā š¤ α, (x, y) ā r) ā x = y := by
simp only [t0Space_iff_inseparable, inseparable_iff_ker_uniformity, mem_ker, id]
theorem t0Space_iff_uniformity' :
T0Space α ā Pairwise fun x y ⦠ā r ā š¤ α, (x, y) ā r := by
simp [t0Space_iff_not_inseparable, inseparable_iff_ker_uniformity]
theorem t0Space_iff_ker_uniformity : T0Space α ā (š¤ α).ker = diagonal α := by
simp_rw [t0Space_iff_uniformity, subset_antisymm_iff, diagonal_subset_iff, subset_def,
Prod.forall, Filter.mem_ker, mem_diagonal_iff, iff_self_and]
exact fun _ x s hs ⦠refl_mem_uniformity hs
theorem eq_of_uniformity {α : Type*} [UniformSpace α] [T0Space α] {x y : α}
(h : ā {V}, V ā š¤ α ā (x, y) ā V) : x = y :=
t0Space_iff_uniformity.mp ā¹T0Space α⺠x y @h
theorem eq_of_uniformity_basis {α : Type*} [UniformSpace α] [T0Space α] {ι : Sort*}
{p : ι ā Prop} {s : ι ā Set (α à α)} (hs : (š¤ α).HasBasis p s) {x y : α}
(h : ā {i}, p i ā (x, y) ā s i) : x = y :=
(hs.inseparable_iff_uniformity.2 @h).eq
theorem eq_of_forall_symmetric {α : Type*} [UniformSpace α] [T0Space α] {x y : α}
(h : ā {V}, V ā š¤ α ā SymmetricRel V ā (x, y) ā V) : x = y :=
eq_of_uniformity_basis hasBasis_symmetric (by simpa)
theorem eq_of_clusterPt_uniformity [T0Space α] {x y : α} (h : ClusterPt (x, y) (š¤ α)) : x = y :=
(inseparable_iff_clusterPt_uniformity.2 h).eq
theorem Filter.Tendsto.inseparable_iff_uniformity {β} {l : Filter β} [NeBot l] {f g : β ā α}
{a b : α} (ha : Tendsto f l (š a)) (hb : Tendsto g l (š b)) :
Inseparable a b ā Tendsto (fun x ⦠(f x, g x)) l (š¤ α) := by
refine āØfun h ⦠(ha.prod_mk_nhds hb).mono_right h.nhds_le_uniformity, fun h ⦠?_ā©
rw [inseparable_iff_clusterPt_uniformity]
exact (ClusterPt.of_le_nhds (ha.prod_mk_nhds hb)).mono h
theorem isClosed_of_spaced_out [T0Space α] {Vā : Set (α à α)} (Vā_in : Vā ā š¤ α) {s : Set α}
(hs : s.Pairwise fun x y => (x, y) ā Vā) : IsClosed s := by
rcases comp_symm_mem_uniformity_sets Vā_in with āØVā, Vā_in, Vā_symm, h_compā©
apply isClosed_of_closure_subset
intro x hx
rw [mem_closure_iff_ball] at hx
rcases hx Vā_in with āØy, hy, hy'ā©
suffices x = y by rwa [this]
apply eq_of_forall_symmetric
intro V V_in _
rcases hx (inter_mem Vā_in V_in) with āØz, hz, hz'ā©
obtain rfl : z = y := by
by_contra hzy
exact hs hz' hy' hzy (h_comp <| mem_comp_of_mem_ball Vā_symm (ball_inter_left x _ _ hz) hy)
exact ball_inter_right x _ _ hz
theorem isClosed_range_of_spaced_out {ι} [T0Space α] {Vā : Set (α à α)} (Vā_in : Vā ā š¤ α)
{f : ι ā α} (hf : Pairwise fun x y => (f x, f y) ā Vā) : IsClosed (range f) :=
isClosed_of_spaced_out Vā_in <| by
rintro _ āØx, rflā© _ āØy, rflā© h
exact hf (ne_of_apply_ne f h)
/-!
### Separation quotient
-/
namespace SeparationQuotient
theorem comap_map_mk_uniformity : comap (Prod.map mk mk) (map (Prod.map mk mk) (š¤ α)) = š¤ α := by
refine le_antisymm ?_ le_comap_map
refine ((((š¤ α).basis_sets.map _).comap _).le_basis_iff uniformity_hasBasis_open).2 fun U hU ⦠?_
refine āØU, hU.1, fun (xā, xā) āØ(yā, yā), hyU, hxy⩠⦠?_ā©
simp only [Prod.map, Prod.ext_iff, mk_eq_mk] at hxy
exact ((hxy.1.prod hxy.2).mem_open_iff hU.2).1 hyU
instance instUniformSpace : UniformSpace (SeparationQuotient α) where
uniformity := map (Prod.map mk mk) (š¤ α)
symm := tendsto_map' <| tendsto_map.comp tendsto_swap_uniformity
comp := fun t ht ⦠by
rcases comp_open_symm_mem_uniformity_sets ht with āØU, hU, hUo, -, hUtā©
refine mem_of_superset (mem_lift' <| image_mem_map hU) ?_
simp only [subset_def, Prod.forall, mem_compRel, mem_image, Prod.ext_iff]
rintro _ _ āØ_, āØāØx, yā©, hxyU, rfl, rflā©, āØāØy', zā©, hyzU, hy, rflā©ā©
have : y' ⤳ y := (mk_eq_mk.1 hy).specializes
exact @hUt (x, z) āØy', this.mem_open (UniformSpace.isOpen_ball _ hUo) hxyU, hyzUā©
nhds_eq_comap_uniformity := surjective_mk.forall.2 fun x ⦠comap_injective surjective_mk <| by
conv_lhs => rw [comap_mk_nhds_mk, nhds_eq_comap_uniformity, ā comap_map_mk_uniformity]
simp only [Filter.comap_comap, Function.comp, Prod.map_apply]
theorem uniformity_eq : š¤ (SeparationQuotient α) = (š¤ α).map (Prod.map mk mk) := rfl
theorem uniformContinuous_mk : UniformContinuous (mk : α ā SeparationQuotient α) :=
le_rfl
theorem uniformContinuous_dom {f : SeparationQuotient α ā β} :
UniformContinuous f ā UniformContinuous (f ā mk) :=
.rfl
theorem uniformContinuous_domā {f : SeparationQuotient α Ć SeparationQuotient β ā γ} :
UniformContinuous f ā UniformContinuous fun p : α à β ⦠f (mk p.1, mk p.2) := by
simp only [UniformContinuous, uniformity_prod_eq_prod, uniformity_eq, prod_map_map_eq,
tendsto_map'_iff]
rfl
theorem uniformContinuous_lift {f : α ā β} (h : ā a b, Inseparable a b ā f a = f b) :
UniformContinuous (lift f h) ā UniformContinuous f :=
.rfl
theorem uniformContinuous_uncurry_liftā {f : α ā β ā γ}
(h : ā a c b d, Inseparable a b ā Inseparable c d ā f a c = f b d) :
UniformContinuous (uncurry <| liftā f h) ā UniformContinuous (uncurry f) :=
uniformContinuous_domā
theorem comap_mk_uniformity : (š¤ (SeparationQuotient α)).comap (Prod.map mk mk) = š¤ α :=
comap_map_mk_uniformity
/-- Factoring functions to a separated space through the separation quotient.
TODO: unify with `SeparationQuotient.lift`. -/
def lift' [T0Space β] (f : α ā β) : SeparationQuotient α ā β :=
if hc : UniformContinuous f then lift f fun _ _ h => (h.map hc.continuous).eq
else fun x => f (Nonempty.some āØx.out'ā©)
theorem lift'_mk [T0Space β] {f : α ā β} (h : UniformContinuous f) (a : α) :
lift' f (mk a) = f a := by rw [lift', dif_pos h, lift_mk]
theorem uniformContinuous_lift' [T0Space β] (f : α ā β) : UniformContinuous (lift' f) := by
by_cases hf : UniformContinuous f
Ā· rwa [lift', dif_pos hf, uniformContinuous_lift]
Ā· rw [lift', dif_neg hf]
exact uniformContinuous_of_const fun a _ => rfl
/-- The separation quotient functor acting on functions. -/
def map (f : α ā β) : SeparationQuotient α ā SeparationQuotient β := lift' (mk ā f)
theorem map_mk {f : α ā β} (h : UniformContinuous f) (a : α) : map f (mk a) = mk (f a) := by
rw [map, lift'_mk (uniformContinuous_mk.comp h)]; rfl
theorem uniformContinuous_map (f : α ā β) : UniformContinuous (map f) :=
uniformContinuous_lift' _
theorem map_unique {f : α ā β} (hf : UniformContinuous f)
{g : SeparationQuotient α ā SeparationQuotient β} (comm : mk ā f = g ā mk) : map f = g := by
ext āØaā©
calc
map f ā¦aā§ = ā¦f aā§ := map_mk hf a
_ = g ā¦aā§ := congr_fun comm a
@[simp]
theorem map_id : map (@id α) = id := map_unique uniformContinuous_id rfl
theorem map_comp {f : α ā β} {g : β ā γ} (hf : UniformContinuous f) (hg : UniformContinuous g) :
map g ā map f = map (g ā f) :=
(map_unique (hg.comp hf) <| by simp only [Function.comp, map_mk, hf, hg]).symm
end SeparationQuotient
|
Topology\UniformSpace\UniformConvergence.lean
|
/-
Copyright (c) 2020 SƩbastien Gouƫzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: SƩbastien Gouƫzel
-/
import Mathlib.Topology.Separation
import Mathlib.Topology.UniformSpace.Basic
import Mathlib.Topology.UniformSpace.Cauchy
/-!
# Uniform convergence
A sequence of functions `Fā` (with values in a metric space) converges uniformly on a set `s` to a
function `f` if, for all `ε > 0`, for all large enough `n`, one has for all `y ā s` the inequality
`dist (f y, Fā y) < ε`. Under uniform convergence, many properties of the `Fā` pass to the limit,
most notably continuity. We prove this in the file, defining the notion of uniform convergence
in the more general setting of uniform spaces, and with respect to an arbitrary indexing set
endowed with a filter (instead of just `ā` with `atTop`).
## Main results
Let `α` be a topological space, `β` a uniform space, `Fā` and `f` be functions from `α` to `β`
(where the index `n` belongs to an indexing type `ι` endowed with a filter `p`).
* `TendstoUniformlyOn F f p s`: the fact that `Fā` converges uniformly to `f` on `s`. This means
that, for any entourage `u` of the diagonal, for large enough `n` (with respect to `p`), one has
`(f y, Fā y) ā u` for all `y ā s`.
* `TendstoUniformly F f p`: same notion with `s = univ`.
* `TendstoUniformlyOn.continuousOn`: a uniform limit on a set of functions which are continuous
on this set is itself continuous on this set.
* `TendstoUniformly.continuous`: a uniform limit of continuous functions is continuous.
* `TendstoUniformlyOn.tendsto_comp`: If `Fā` tends uniformly to `f` on a set `s`, and `gā` tends
to `x` within `s`, then `Fā gā` tends to `f x` if `f` is continuous at `x` within `s`.
* `TendstoUniformly.tendsto_comp`: If `Fā` tends uniformly to `f`, and `gā` tends to `x`, then
`Fā gā` tends to `f x`.
We also define notions where the convergence is locally uniform, called
`TendstoLocallyUniformlyOn F f p s` and `TendstoLocallyUniformly F f p`. The previous theorems
all have corresponding versions under locally uniform convergence.
Finally, we introduce the notion of a uniform Cauchy sequence, which is to uniform
convergence what a Cauchy sequence is to the usual notion of convergence.
## Implementation notes
We derive most of our initial results from an auxiliary definition `TendstoUniformlyOnFilter`.
This definition in and of itself can sometimes be useful, e.g., when studying the local behavior
of the `Fā` near a point, which would typically look like `TendstoUniformlyOnFilter F f p (š x)`.
Still, while this may be the "correct" definition (see
`tendstoUniformlyOn_iff_tendstoUniformlyOnFilter`), it is somewhat unwieldy to work with in
practice. Thus, we provide the more traditional definition in `TendstoUniformlyOn`.
Most results hold under weaker assumptions of locally uniform approximation. In a first section,
we prove the results under these weaker assumptions. Then, we derive the results on uniform
convergence from them.
## Tags
Uniform limit, uniform convergence, tends uniformly to
-/
noncomputable section
open Topology Uniformity Filter Set
universe u v w x
variable {α : Type u} {β : Type v} {γ : Type w} {ι : Type x} [UniformSpace β]
variable {F : ι ā α ā β} {f : α ā β} {s s' : Set α} {x : α} {p : Filter ι} {p' : Filter α}
{g : ι ā α}
/-!
### Different notions of uniform convergence
We define uniform convergence and locally uniform convergence, on a set or in the whole space.
-/
/-- A sequence of functions `Fā` converges uniformly on a filter `p'` to a limiting function `f`
with respect to the filter `p` if, for any entourage of the diagonal `u`, one has
`p ĆĖ¢ p'`-eventually `(f x, Fā x) ā u`. -/
def TendstoUniformlyOnFilter (F : ι ā α ā β) (f : α ā β) (p : Filter ι) (p' : Filter α) :=
ā u ā š¤ β, āį¶ n : ι à α in p ĆĖ¢ p', (f n.snd, F n.fst n.snd) ā u
/--
A sequence of functions `Fā` converges uniformly on a filter `p'` to a limiting function `f` w.r.t.
filter `p` iff the function `(n, x) ⦠(f x, Fā x)` converges along `p ĆĖ¢ p'` to the uniformity.
In other words: one knows nothing about the behavior of `x` in this limit besides it being in `p'`.
-/
theorem tendstoUniformlyOnFilter_iff_tendsto :
TendstoUniformlyOnFilter F f p p' ā
Tendsto (fun q : ι à α => (f q.2, F q.1 q.2)) (p ĆĖ¢ p') (š¤ β) :=
Iff.rfl
/-- A sequence of functions `Fā` converges uniformly on a set `s` to a limiting function `f` with
respect to the filter `p` if, for any entourage of the diagonal `u`, one has `p`-eventually
`(f x, Fā x) ā u` for all `x ā s`. -/
def TendstoUniformlyOn (F : ι ā α ā β) (f : α ā β) (p : Filter ι) (s : Set α) :=
ā u ā š¤ β, āį¶ n in p, ā x : α, x ā s ā (f x, F n x) ā u
theorem tendstoUniformlyOn_iff_tendstoUniformlyOnFilter :
TendstoUniformlyOn F f p s ā TendstoUniformlyOnFilter F f p (š s) := by
simp only [TendstoUniformlyOn, TendstoUniformlyOnFilter]
apply forallā_congr
simp_rw [eventually_prod_principal_iff]
simp
alias āØTendstoUniformlyOn.tendstoUniformlyOnFilter, TendstoUniformlyOnFilter.tendstoUniformlyOnā© :=
tendstoUniformlyOn_iff_tendstoUniformlyOnFilter
/-- A sequence of functions `Fā` converges uniformly on a set `s` to a limiting function `f` w.r.t.
filter `p` iff the function `(n, x) ⦠(f x, Fā x)` converges along `p ĆĖ¢ š s` to the uniformity.
In other words: one knows nothing about the behavior of `x` in this limit besides it being in `s`.
-/
theorem tendstoUniformlyOn_iff_tendsto {F : ι ā α ā β} {f : α ā β} {p : Filter ι} {s : Set α} :
TendstoUniformlyOn F f p s ā
Tendsto (fun q : ι à α => (f q.2, F q.1 q.2)) (p ĆĖ¢ š s) (š¤ β) := by
simp [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter, tendstoUniformlyOnFilter_iff_tendsto]
/-- A sequence of functions `Fā` converges uniformly to a limiting function `f` with respect to a
filter `p` if, for any entourage of the diagonal `u`, one has `p`-eventually
`(f x, Fā x) ā u` for all `x`. -/
def TendstoUniformly (F : ι ā α ā β) (f : α ā β) (p : Filter ι) :=
ā u ā š¤ β, āį¶ n in p, ā x : α, (f x, F n x) ā u
-- Porting note: moved from below
theorem tendstoUniformlyOn_univ : TendstoUniformlyOn F f p univ ā TendstoUniformly F f p := by
simp [TendstoUniformlyOn, TendstoUniformly]
theorem tendstoUniformly_iff_tendstoUniformlyOnFilter :
TendstoUniformly F f p ā TendstoUniformlyOnFilter F f p ⤠:= by
rw [ā tendstoUniformlyOn_univ, tendstoUniformlyOn_iff_tendstoUniformlyOnFilter, principal_univ]
theorem TendstoUniformly.tendstoUniformlyOnFilter (h : TendstoUniformly F f p) :
TendstoUniformlyOnFilter F f p ⤠:= by rwa [ā tendstoUniformly_iff_tendstoUniformlyOnFilter]
theorem tendstoUniformlyOn_iff_tendstoUniformly_comp_coe :
TendstoUniformlyOn F f p s ā TendstoUniformly (fun i (x : s) => F i x) (f ā (ā)) p :=
forallā_congr fun u _ => by simp
/-- A sequence of functions `Fā` converges uniformly to a limiting function `f` w.r.t.
filter `p` iff the function `(n, x) ⦠(f x, Fā x)` converges along `p ĆĖ¢ ā¤` to the uniformity.
In other words: one knows nothing about the behavior of `x` in this limit.
-/
theorem tendstoUniformly_iff_tendsto {F : ι ā α ā β} {f : α ā β} {p : Filter ι} :
TendstoUniformly F f p ā Tendsto (fun q : ι à α => (f q.2, F q.1 q.2)) (p ĆĖ¢ ā¤) (š¤ β) := by
simp [tendstoUniformly_iff_tendstoUniformlyOnFilter, tendstoUniformlyOnFilter_iff_tendsto]
/-- Uniform converence implies pointwise convergence. -/
theorem TendstoUniformlyOnFilter.tendsto_at (h : TendstoUniformlyOnFilter F f p p')
(hx : š {x} ⤠p') : Tendsto (fun n => F n x) p <| š (f x) := by
refine Uniform.tendsto_nhds_right.mpr fun u hu => mem_map.mpr ?_
filter_upwards [(h u hu).curry]
intro i h
simpa using h.filter_mono hx
/-- Uniform converence implies pointwise convergence. -/
theorem TendstoUniformlyOn.tendsto_at (h : TendstoUniformlyOn F f p s) {x : α} (hx : x ā s) :
Tendsto (fun n => F n x) p <| š (f x) :=
h.tendstoUniformlyOnFilter.tendsto_at
(le_principal_iff.mpr <| mem_principal.mpr <| singleton_subset_iff.mpr <| hx)
/-- Uniform converence implies pointwise convergence. -/
theorem TendstoUniformly.tendsto_at (h : TendstoUniformly F f p) (x : α) :
Tendsto (fun n => F n x) p <| š (f x) :=
h.tendstoUniformlyOnFilter.tendsto_at le_top
-- Porting note: tendstoUniformlyOn_univ moved up
theorem TendstoUniformlyOnFilter.mono_left {p'' : Filter ι} (h : TendstoUniformlyOnFilter F f p p')
(hp : p'' ⤠p) : TendstoUniformlyOnFilter F f p'' p' := fun u hu =>
(h u hu).filter_mono (p'.prod_mono_left hp)
theorem TendstoUniformlyOnFilter.mono_right {p'' : Filter α} (h : TendstoUniformlyOnFilter F f p p')
(hp : p'' ⤠p') : TendstoUniformlyOnFilter F f p p'' := fun u hu =>
(h u hu).filter_mono (p.prod_mono_right hp)
theorem TendstoUniformlyOn.mono {s' : Set α} (h : TendstoUniformlyOn F f p s) (h' : s' ā s) :
TendstoUniformlyOn F f p s' :=
tendstoUniformlyOn_iff_tendstoUniformlyOnFilter.mpr
(h.tendstoUniformlyOnFilter.mono_right (le_principal_iff.mpr <| mem_principal.mpr h'))
theorem TendstoUniformlyOnFilter.congr {F' : ι ā α ā β} (hf : TendstoUniformlyOnFilter F f p p')
(hff' : āį¶ n : ι à α in p ĆĖ¢ p', F n.fst n.snd = F' n.fst n.snd) :
TendstoUniformlyOnFilter F' f p p' := by
refine fun u hu => ((hf u hu).and hff').mono fun n h => ?_
rw [ā h.right]
exact h.left
theorem TendstoUniformlyOn.congr {F' : ι ā α ā β} (hf : TendstoUniformlyOn F f p s)
(hff' : āį¶ n in p, Set.EqOn (F n) (F' n) s) : TendstoUniformlyOn F' f p s := by
rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter] at hf ā¢
refine hf.congr ?_
rw [eventually_iff] at hff' ā¢
simp only [Set.EqOn] at hff'
simp only [mem_prod_principal, hff', mem_setOf_eq]
theorem TendstoUniformlyOn.congr_right {g : α ā β} (hf : TendstoUniformlyOn F f p s)
(hfg : EqOn f g s) : TendstoUniformlyOn F g p s := fun u hu => by
filter_upwards [hf u hu] with i hi a ha using hfg ha āø hi a ha
protected theorem TendstoUniformly.tendstoUniformlyOn (h : TendstoUniformly F f p) :
TendstoUniformlyOn F f p s :=
(tendstoUniformlyOn_univ.2 h).mono (subset_univ s)
/-- Composing on the right by a function preserves uniform convergence on a filter -/
theorem TendstoUniformlyOnFilter.comp (h : TendstoUniformlyOnFilter F f p p') (g : γ ā α) :
TendstoUniformlyOnFilter (fun n => F n ā g) (f ā g) p (p'.comap g) := by
rw [tendstoUniformlyOnFilter_iff_tendsto] at h ā¢
exact h.comp (tendsto_id.prod_map tendsto_comap)
/-- Composing on the right by a function preserves uniform convergence on a set -/
theorem TendstoUniformlyOn.comp (h : TendstoUniformlyOn F f p s) (g : γ ā α) :
TendstoUniformlyOn (fun n => F n ā g) (f ā g) p (g ā»Ā¹' s) := by
rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter] at h ā¢
simpa [TendstoUniformlyOn, comap_principal] using TendstoUniformlyOnFilter.comp h g
/-- Composing on the right by a function preserves uniform convergence -/
theorem TendstoUniformly.comp (h : TendstoUniformly F f p) (g : γ ā α) :
TendstoUniformly (fun n => F n ā g) (f ā g) p := by
rw [tendstoUniformly_iff_tendstoUniformlyOnFilter] at h ā¢
simpa [principal_univ, comap_principal] using h.comp g
/-- Composing on the left by a uniformly continuous function preserves
uniform convergence on a filter -/
theorem UniformContinuous.comp_tendstoUniformlyOnFilter [UniformSpace γ] {g : β ā γ}
(hg : UniformContinuous g) (h : TendstoUniformlyOnFilter F f p p') :
TendstoUniformlyOnFilter (fun i => g ā F i) (g ā f) p p' := fun _u hu => h _ (hg hu)
/-- Composing on the left by a uniformly continuous function preserves
uniform convergence on a set -/
theorem UniformContinuous.comp_tendstoUniformlyOn [UniformSpace γ] {g : β ā γ}
(hg : UniformContinuous g) (h : TendstoUniformlyOn F f p s) :
TendstoUniformlyOn (fun i => g ā F i) (g ā f) p s := fun _u hu => h _ (hg hu)
/-- Composing on the left by a uniformly continuous function preserves uniform convergence -/
theorem UniformContinuous.comp_tendstoUniformly [UniformSpace γ] {g : β ā γ}
(hg : UniformContinuous g) (h : TendstoUniformly F f p) :
TendstoUniformly (fun i => g ā F i) (g ā f) p := fun _u hu => h _ (hg hu)
theorem TendstoUniformlyOnFilter.prod_map {ι' α' β' : Type*} [UniformSpace β'] {F' : ι' ā α' ā β'}
{f' : α' ā β'} {q : Filter ι'} {q' : Filter α'} (h : TendstoUniformlyOnFilter F f p p')
(h' : TendstoUniformlyOnFilter F' f' q q') :
TendstoUniformlyOnFilter (fun i : ι à ι' => Prod.map (F i.1) (F' i.2)) (Prod.map f f')
(p ĆĖ¢ q) (p' ĆĖ¢ q') := by
rw [tendstoUniformlyOnFilter_iff_tendsto] at h h' ā¢
rw [uniformity_prod_eq_comap_prod, tendsto_comap_iff, ā map_swap4_prod, tendsto_map'_iff]
convert h.prod_map h' -- seems to be faster than `exact` here
theorem TendstoUniformlyOn.prod_map {ι' α' β' : Type*} [UniformSpace β'] {F' : ι' ā α' ā β'}
{f' : α' ā β'} {p' : Filter ι'} {s' : Set α'} (h : TendstoUniformlyOn F f p s)
(h' : TendstoUniformlyOn F' f' p' s') :
TendstoUniformlyOn (fun i : ι à ι' => Prod.map (F i.1) (F' i.2)) (Prod.map f f') (p ĆĖ¢ p')
(s ĆĖ¢ s') := by
rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter] at h h' ā¢
simpa only [prod_principal_principal] using h.prod_map h'
theorem TendstoUniformly.prod_map {ι' α' β' : Type*} [UniformSpace β'] {F' : ι' ā α' ā β'}
{f' : α' ā β'} {p' : Filter ι'} (h : TendstoUniformly F f p) (h' : TendstoUniformly F' f' p') :
TendstoUniformly (fun i : ι à ι' => Prod.map (F i.1) (F' i.2)) (Prod.map f f') (p ĆĖ¢ p') := by
rw [ā tendstoUniformlyOn_univ, ā univ_prod_univ] at *
exact h.prod_map h'
theorem TendstoUniformlyOnFilter.prod {ι' β' : Type*} [UniformSpace β'] {F' : ι' ā α ā β'}
{f' : α ā β'} {q : Filter ι'} (h : TendstoUniformlyOnFilter F f p p')
(h' : TendstoUniformlyOnFilter F' f' q p') :
TendstoUniformlyOnFilter (fun (i : ι à ι') a => (F i.1 a, F' i.2 a)) (fun a => (f a, f' a))
(p ĆĖ¢ q) p' :=
fun u hu => ((h.prod_map h') u hu).diag_of_prod_right
theorem TendstoUniformlyOn.prod {ι' β' : Type*} [UniformSpace β'] {F' : ι' ā α ā β'} {f' : α ā β'}
{p' : Filter ι'} (h : TendstoUniformlyOn F f p s) (h' : TendstoUniformlyOn F' f' p' s) :
TendstoUniformlyOn (fun (i : ι à ι') a => (F i.1 a, F' i.2 a)) (fun a => (f a, f' a))
(p.prod p') s :=
(congr_arg _ s.inter_self).mp ((h.prod_map h').comp fun a => (a, a))
theorem TendstoUniformly.prod {ι' β' : Type*} [UniformSpace β'] {F' : ι' ā α ā β'} {f' : α ā β'}
{p' : Filter ι'} (h : TendstoUniformly F f p) (h' : TendstoUniformly F' f' p') :
TendstoUniformly (fun (i : ι à ι') a => (F i.1 a, F' i.2 a)) (fun a => (f a, f' a))
(p ĆĖ¢ p') :=
(h.prod_map h').comp fun a => (a, a)
/-- Uniform convergence on a filter `p'` to a constant function is equivalent to convergence in
`p ĆĖ¢ p'`. -/
theorem tendsto_prod_filter_iff {c : β} :
Tendsto (āæF) (p ĆĖ¢ p') (š c) ā TendstoUniformlyOnFilter F (fun _ => c) p p' := by
simp_rw [nhds_eq_comap_uniformity, tendsto_comap_iff]
rfl
/-- Uniform convergence on a set `s` to a constant function is equivalent to convergence in
`p ĆĖ¢ š s`. -/
theorem tendsto_prod_principal_iff {c : β} :
Tendsto (āæF) (p ĆĖ¢ š s) (š c) ā TendstoUniformlyOn F (fun _ => c) p s := by
rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter]
exact tendsto_prod_filter_iff
/-- Uniform convergence to a constant function is equivalent to convergence in `p ĆĖ¢ ā¤`. -/
theorem tendsto_prod_top_iff {c : β} :
Tendsto (āæF) (p ĆĖ¢ ā¤) (š c) ā TendstoUniformly F (fun _ => c) p := by
rw [tendstoUniformly_iff_tendstoUniformlyOnFilter]
exact tendsto_prod_filter_iff
/-- Uniform convergence on the empty set is vacuously true -/
theorem tendstoUniformlyOn_empty : TendstoUniformlyOn F f p ā
:= fun u _ => by simp
/-- Uniform convergence on a singleton is equivalent to regular convergence -/
theorem tendstoUniformlyOn_singleton_iff_tendsto :
TendstoUniformlyOn F f p {x} ā Tendsto (fun n : ι => F n x) p (š (f x)) := by
simp_rw [tendstoUniformlyOn_iff_tendsto, Uniform.tendsto_nhds_right, tendsto_def]
exact forallā_congr fun u _ => by simp [mem_prod_principal, preimage]
/-- If a sequence `g` converges to some `b`, then the sequence of constant functions
`fun n ⦠fun a ⦠g n` converges to the constant function `fun a ⦠b` on any set `s` -/
theorem Filter.Tendsto.tendstoUniformlyOnFilter_const {g : ι ā β} {b : β} (hg : Tendsto g p (š b))
(p' : Filter α) :
TendstoUniformlyOnFilter (fun n : ι => fun _ : α => g n) (fun _ : α => b) p p' := by
simpa only [nhds_eq_comap_uniformity, tendsto_comap_iff] using hg.comp (tendsto_fst (g := p'))
/-- If a sequence `g` converges to some `b`, then the sequence of constant functions
`fun n ⦠fun a ⦠g n` converges to the constant function `fun a ⦠b` on any set `s` -/
theorem Filter.Tendsto.tendstoUniformlyOn_const {g : ι ā β} {b : β} (hg : Tendsto g p (š b))
(s : Set α) : TendstoUniformlyOn (fun n : ι => fun _ : α => g n) (fun _ : α => b) p s :=
tendstoUniformlyOn_iff_tendstoUniformlyOnFilter.mpr (hg.tendstoUniformlyOnFilter_const (š s))
theorem UniformContinuousOn.tendstoUniformlyOn [UniformSpace α] [UniformSpace γ] {x : α} {U : Set α}
{V : Set β} {F : α ā β ā γ} (hF : UniformContinuousOn (āæF) (U ĆĖ¢ V)) (hU : x ā U) :
TendstoUniformlyOn F (F x) (š[U] x) V := by
set Ļ := fun q : α à β => ((x, q.2), q)
rw [tendstoUniformlyOn_iff_tendsto]
change Tendsto (Prod.map (āæF) āæF ā Ļ) (š[U] x ĆĖ¢ š V) (š¤ γ)
simp only [nhdsWithin, SProd.sprod, Filter.prod, comap_inf, inf_assoc, comap_principal,
inf_principal]
refine hF.comp (Tendsto.inf ?_ <| tendsto_principal_principal.2 fun x hx => āØāØhU, hx.2ā©, hxā©)
simp only [uniformity_prod_eq_comap_prod, tendsto_comap_iff, (Ā· ā Ā·),
nhds_eq_comap_uniformity, comap_comap]
exact tendsto_comap.prod_mk (tendsto_diag_uniformity _ _)
theorem UniformContinuousOn.tendstoUniformly [UniformSpace α] [UniformSpace γ] {x : α} {U : Set α}
(hU : U ā š x) {F : α ā β ā γ} (hF : UniformContinuousOn (āæF) (U ĆĖ¢ (univ : Set β))) :
TendstoUniformly F (F x) (š x) := by
simpa only [tendstoUniformlyOn_univ, nhdsWithin_eq_nhds.2 hU]
using hF.tendstoUniformlyOn (mem_of_mem_nhds hU)
theorem UniformContinuousā.tendstoUniformly [UniformSpace α] [UniformSpace γ] {f : α ā β ā γ}
(h : UniformContinuousā f) {x : α} : TendstoUniformly f (f x) (š x) :=
UniformContinuousOn.tendstoUniformly univ_mem <| by rwa [univ_prod_univ, uniformContinuousOn_univ]
/-- A sequence is uniformly Cauchy if eventually all of its pairwise differences are
uniformly bounded -/
def UniformCauchySeqOnFilter (F : ι ā α ā β) (p : Filter ι) (p' : Filter α) : Prop :=
ā u ā š¤ β, āį¶ m : (ι à ι) à α in (p ĆĖ¢ p) ĆĖ¢ p', (F m.fst.fst m.snd, F m.fst.snd m.snd) ā u
/-- A sequence is uniformly Cauchy if eventually all of its pairwise differences are
uniformly bounded -/
def UniformCauchySeqOn (F : ι ā α ā β) (p : Filter ι) (s : Set α) : Prop :=
ā u ā š¤ β, āį¶ m : ι à ι in p ĆĖ¢ p, ā x : α, x ā s ā (F m.fst x, F m.snd x) ā u
theorem uniformCauchySeqOn_iff_uniformCauchySeqOnFilter :
UniformCauchySeqOn F p s ā UniformCauchySeqOnFilter F p (š s) := by
simp only [UniformCauchySeqOn, UniformCauchySeqOnFilter]
refine forallā_congr fun u hu => ?_
rw [eventually_prod_principal_iff]
theorem UniformCauchySeqOn.uniformCauchySeqOnFilter (hF : UniformCauchySeqOn F p s) :
UniformCauchySeqOnFilter F p (š s) := by rwa [ā uniformCauchySeqOn_iff_uniformCauchySeqOnFilter]
/-- A sequence that converges uniformly is also uniformly Cauchy -/
theorem TendstoUniformlyOnFilter.uniformCauchySeqOnFilter (hF : TendstoUniformlyOnFilter F f p p') :
UniformCauchySeqOnFilter F p p' := by
intro u hu
rcases comp_symm_of_uniformity hu with āØt, ht, htsymm, htmemā©
have := tendsto_swap4_prod.eventually ((hF t ht).prod_mk (hF t ht))
apply this.diag_of_prod_right.mono
simp only [and_imp, Prod.forall]
intro n1 n2 x hl hr
exact Set.mem_of_mem_of_subset (prod_mk_mem_compRel (htsymm hl) hr) htmem
/-- A sequence that converges uniformly is also uniformly Cauchy -/
theorem TendstoUniformlyOn.uniformCauchySeqOn (hF : TendstoUniformlyOn F f p s) :
UniformCauchySeqOn F p s :=
uniformCauchySeqOn_iff_uniformCauchySeqOnFilter.mpr
hF.tendstoUniformlyOnFilter.uniformCauchySeqOnFilter
/-- A uniformly Cauchy sequence converges uniformly to its limit -/
theorem UniformCauchySeqOnFilter.tendstoUniformlyOnFilter_of_tendsto [NeBot p]
(hF : UniformCauchySeqOnFilter F p p')
(hF' : āį¶ x : α in p', Tendsto (fun n => F n x) p (š (f x))) :
TendstoUniformlyOnFilter F f p p' := by
-- Proof idea: |f_n(x) - f(x)| ⤠|f_n(x) - f_m(x)| + |f_m(x) - f(x)|. We choose `n`
-- so that |f_n(x) - f_m(x)| is uniformly small across `s` whenever `m ā„ n`. Then for
-- a fixed `x`, we choose `m` sufficiently large such that |f_m(x) - f(x)| is small.
intro u hu
rcases comp_symm_of_uniformity hu with āØt, ht, htsymm, htmemā©
-- We will choose n, x, and m simultaneously. n and x come from hF. m comes from hF'
-- But we need to promote hF' to the full product filter to use it
have hmc : āį¶ x in (p ĆĖ¢ p) ĆĖ¢ p', Tendsto (fun n : ι => F n x.snd) p (š (f x.snd)) := by
rw [eventually_prod_iff]
exact āØfun _ => True, by simp, _, hF', by simpā©
-- To apply filter operations we'll need to do some order manipulation
rw [Filter.eventually_swap_iff]
have := tendsto_prodAssoc.eventually (tendsto_prod_swap.eventually ((hF t ht).and hmc))
apply this.curry.mono
simp only [Equiv.prodAssoc_apply, eventually_and, eventually_const, Prod.snd_swap, Prod.fst_swap,
and_imp, Prod.forall]
-- Complete the proof
intro x n hx hm'
refine Set.mem_of_mem_of_subset (mem_compRel.mpr ?_) htmem
rw [Uniform.tendsto_nhds_right] at hm'
have := hx.and (hm' ht)
obtain āØm, hmā© := this.exists
exact āØF m x, āØhm.2, htsymm hm.1ā©ā©
/-- A uniformly Cauchy sequence converges uniformly to its limit -/
theorem UniformCauchySeqOn.tendstoUniformlyOn_of_tendsto [NeBot p] (hF : UniformCauchySeqOn F p s)
(hF' : ā x : α, x ā s ā Tendsto (fun n => F n x) p (š (f x))) : TendstoUniformlyOn F f p s :=
tendstoUniformlyOn_iff_tendstoUniformlyOnFilter.mpr
(hF.uniformCauchySeqOnFilter.tendstoUniformlyOnFilter_of_tendsto hF')
theorem UniformCauchySeqOnFilter.mono_left {p'' : Filter ι} (hf : UniformCauchySeqOnFilter F p p')
(hp : p'' ⤠p) : UniformCauchySeqOnFilter F p'' p' := by
intro u hu
have := (hf u hu).filter_mono (p'.prod_mono_left (Filter.prod_mono hp hp))
exact this.mono (by simp)
theorem UniformCauchySeqOnFilter.mono_right {p'' : Filter α} (hf : UniformCauchySeqOnFilter F p p')
(hp : p'' ⤠p') : UniformCauchySeqOnFilter F p p'' := fun u hu =>
have := (hf u hu).filter_mono ((p ĆĖ¢ p).prod_mono_right hp)
this.mono (by simp)
theorem UniformCauchySeqOn.mono {s' : Set α} (hf : UniformCauchySeqOn F p s) (hss' : s' ā s) :
UniformCauchySeqOn F p s' := by
rw [uniformCauchySeqOn_iff_uniformCauchySeqOnFilter] at hf ā¢
exact hf.mono_right (le_principal_iff.mpr <| mem_principal.mpr hss')
/-- Composing on the right by a function preserves uniform Cauchy sequences -/
theorem UniformCauchySeqOnFilter.comp {γ : Type*} (hf : UniformCauchySeqOnFilter F p p')
(g : γ ā α) : UniformCauchySeqOnFilter (fun n => F n ā g) p (p'.comap g) := fun u hu => by
obtain āØpa, hpa, pb, hpb, hpapbā© := eventually_prod_iff.mp (hf u hu)
rw [eventually_prod_iff]
refine āØpa, hpa, pb ā g, ?_, fun hx _ hy => hpapb hx hyā©
exact eventually_comap.mpr (hpb.mono fun x hx y hy => by simp only [hx, hy, Function.comp_apply])
/-- Composing on the right by a function preserves uniform Cauchy sequences -/
theorem UniformCauchySeqOn.comp {γ : Type*} (hf : UniformCauchySeqOn F p s) (g : γ ā α) :
UniformCauchySeqOn (fun n => F n ā g) p (g ā»Ā¹' s) := by
rw [uniformCauchySeqOn_iff_uniformCauchySeqOnFilter] at hf ā¢
simpa only [UniformCauchySeqOn, comap_principal] using hf.comp g
/-- Composing on the left by a uniformly continuous function preserves
uniform Cauchy sequences -/
theorem UniformContinuous.comp_uniformCauchySeqOn [UniformSpace γ] {g : β ā γ}
(hg : UniformContinuous g) (hf : UniformCauchySeqOn F p s) :
UniformCauchySeqOn (fun n => g ā F n) p s := fun _u hu => hf _ (hg hu)
theorem UniformCauchySeqOn.prod_map {ι' α' β' : Type*} [UniformSpace β'] {F' : ι' ā α' ā β'}
{p' : Filter ι'} {s' : Set α'} (h : UniformCauchySeqOn F p s)
(h' : UniformCauchySeqOn F' p' s') :
UniformCauchySeqOn (fun i : ι à ι' => Prod.map (F i.1) (F' i.2)) (p ĆĖ¢ p') (s ĆĖ¢ s') := by
intro u hu
rw [uniformity_prod_eq_prod, mem_map, mem_prod_iff] at hu
obtain āØv, hv, w, hw, hvwā© := hu
simp_rw [mem_prod, and_imp, Prod.forall, Prod.map_apply]
rw [ā Set.image_subset_iff] at hvw
apply (tendsto_swap4_prod.eventually ((h v hv).prod_mk (h' w hw))).mono
intro x hx a b ha hb
exact hvw āØ_, mk_mem_prod (hx.1 a ha) (hx.2 b hb), rflā©
theorem UniformCauchySeqOn.prod {ι' β' : Type*} [UniformSpace β'] {F' : ι' ā α ā β'}
{p' : Filter ι'} (h : UniformCauchySeqOn F p s) (h' : UniformCauchySeqOn F' p' s) :
UniformCauchySeqOn (fun (i : ι à ι') a => (F i.fst a, F' i.snd a)) (p ĆĖ¢ p') s :=
(congr_arg _ s.inter_self).mp ((h.prod_map h').comp fun a => (a, a))
theorem UniformCauchySeqOn.prod' {β' : Type*} [UniformSpace β'] {F' : ι ā α ā β'}
(h : UniformCauchySeqOn F p s) (h' : UniformCauchySeqOn F' p s) :
UniformCauchySeqOn (fun (i : ι) a => (F i a, F' i a)) p s := fun u hu =>
have hh : Tendsto (fun x : ι => (x, x)) p (p ĆĖ¢ p) := tendsto_diag
(hh.prod_map hh).eventually ((h.prod h') u hu)
/-- If a sequence of functions is uniformly Cauchy on a set, then the values at each point form
a Cauchy sequence. -/
theorem UniformCauchySeqOn.cauchy_map [hp : NeBot p] (hf : UniformCauchySeqOn F p s) (hx : x ā s) :
Cauchy (map (fun i => F i x) p) := by
simp only [cauchy_map_iff, hp, true_and_iff]
intro u hu
rw [mem_map]
filter_upwards [hf u hu] with p hp using hp x hx
/-- If a sequence of functions is uniformly Cauchy on a set, then the values at each point form
a Cauchy sequence. See `UniformCauchSeqOn.cauchy_map` for the non-`atTop` case. -/
theorem UniformCauchySeqOn.cauchySeq [Nonempty ι] [SemilatticeSup ι]
(hf : UniformCauchySeqOn F atTop s) (hx : x ā s) :
CauchySeq fun i ⦠F i x :=
hf.cauchy_map (hp := atTop_neBot) hx
section SeqTendsto
theorem tendstoUniformlyOn_of_seq_tendstoUniformlyOn {l : Filter ι} [l.IsCountablyGenerated]
(h : ā u : ā ā ι, Tendsto u atTop l ā TendstoUniformlyOn (fun n => F (u n)) f atTop s) :
TendstoUniformlyOn F f l s := by
rw [tendstoUniformlyOn_iff_tendsto, tendsto_iff_seq_tendsto]
intro u hu
rw [tendsto_prod_iff'] at hu
specialize h (fun n => (u n).fst) hu.1
rw [tendstoUniformlyOn_iff_tendsto] at h
exact h.comp (tendsto_id.prod_mk hu.2)
theorem TendstoUniformlyOn.seq_tendstoUniformlyOn {l : Filter ι} (h : TendstoUniformlyOn F f l s)
(u : ā ā ι) (hu : Tendsto u atTop l) : TendstoUniformlyOn (fun n => F (u n)) f atTop s := by
rw [tendstoUniformlyOn_iff_tendsto] at h ā¢
exact h.comp ((hu.comp tendsto_fst).prod_mk tendsto_snd)
theorem tendstoUniformlyOn_iff_seq_tendstoUniformlyOn {l : Filter ι} [l.IsCountablyGenerated] :
TendstoUniformlyOn F f l s ā
ā u : ā ā ι, Tendsto u atTop l ā TendstoUniformlyOn (fun n => F (u n)) f atTop s :=
āØTendstoUniformlyOn.seq_tendstoUniformlyOn, tendstoUniformlyOn_of_seq_tendstoUniformlyOnā©
theorem tendstoUniformly_iff_seq_tendstoUniformly {l : Filter ι} [l.IsCountablyGenerated] :
TendstoUniformly F f l ā
ā u : ā ā ι, Tendsto u atTop l ā TendstoUniformly (fun n => F (u n)) f atTop := by
simp_rw [ā tendstoUniformlyOn_univ]
exact tendstoUniformlyOn_iff_seq_tendstoUniformlyOn
end SeqTendsto
variable [TopologicalSpace α]
/-- A sequence of functions `Fā` converges locally uniformly on a set `s` to a limiting function
`f` with respect to a filter `p` if, for any entourage of the diagonal `u`, for any `x ā s`, one
has `p`-eventually `(f y, Fā y) ā u` for all `y` in a neighborhood of `x` in `s`. -/
def TendstoLocallyUniformlyOn (F : ι ā α ā β) (f : α ā β) (p : Filter ι) (s : Set α) :=
ā u ā š¤ β, ā x ā s, ā t ā š[s] x, āį¶ n in p, ā y ā t, (f y, F n y) ā u
/-- A sequence of functions `Fā` converges locally uniformly to a limiting function `f` with respect
to a filter `p` if, for any entourage of the diagonal `u`, for any `x`, one has `p`-eventually
`(f y, Fā y) ā u` for all `y` in a neighborhood of `x`. -/
def TendstoLocallyUniformly (F : ι ā α ā β) (f : α ā β) (p : Filter ι) :=
ā u ā š¤ β, ā x : α, ā t ā š x, āį¶ n in p, ā y ā t, (f y, F n y) ā u
theorem tendstoLocallyUniformlyOn_univ :
TendstoLocallyUniformlyOn F f p univ ā TendstoLocallyUniformly F f p := by
simp [TendstoLocallyUniformlyOn, TendstoLocallyUniformly, nhdsWithin_univ]
theorem tendstoLocallyUniformlyOn_iff_forall_tendsto :
TendstoLocallyUniformlyOn F f p s ā
ā x ā s, Tendsto (fun y : ι à α => (f y.2, F y.1 y.2)) (p ĆĖ¢ š[s] x) (š¤ β) :=
forallā_swap.trans <| forallā_congr fun _ _ _ _ => by
rw [mem_map, mem_prod_iff_right]; rfl
nonrec theorem IsOpen.tendstoLocallyUniformlyOn_iff_forall_tendsto (hs : IsOpen s) :
TendstoLocallyUniformlyOn F f p s ā
ā x ā s, Tendsto (fun y : ι à α => (f y.2, F y.1 y.2)) (p ĆĖ¢ š x) (š¤ β) :=
tendstoLocallyUniformlyOn_iff_forall_tendsto.trans <| forallā_congr fun x hx => by
rw [hs.nhdsWithin_eq hx]
theorem tendstoLocallyUniformly_iff_forall_tendsto :
TendstoLocallyUniformly F f p ā
ā x, Tendsto (fun y : ι à α => (f y.2, F y.1 y.2)) (p ĆĖ¢ š x) (š¤ β) := by
simp [ā tendstoLocallyUniformlyOn_univ, isOpen_univ.tendstoLocallyUniformlyOn_iff_forall_tendsto]
theorem tendstoLocallyUniformlyOn_iff_tendstoLocallyUniformly_comp_coe :
TendstoLocallyUniformlyOn F f p s ā
TendstoLocallyUniformly (fun i (x : s) => F i x) (f ā (ā)) p := by
simp only [tendstoLocallyUniformly_iff_forall_tendsto, Subtype.forall', tendsto_map'_iff,
tendstoLocallyUniformlyOn_iff_forall_tendsto, ā map_nhds_subtype_val, prod_map_right]; rfl
protected theorem TendstoUniformlyOn.tendstoLocallyUniformlyOn (h : TendstoUniformlyOn F f p s) :
TendstoLocallyUniformlyOn F f p s := fun u hu x _ =>
āØs, self_mem_nhdsWithin, by simpa using h u huā©
protected theorem TendstoUniformly.tendstoLocallyUniformly (h : TendstoUniformly F f p) :
TendstoLocallyUniformly F f p := fun u hu x => āØuniv, univ_mem, by simpa using h u huā©
theorem TendstoLocallyUniformlyOn.mono (h : TendstoLocallyUniformlyOn F f p s) (h' : s' ā s) :
TendstoLocallyUniformlyOn F f p s' := by
intro u hu x hx
rcases h u hu x (h' hx) with āØt, ht, Hā©
exact āØt, nhdsWithin_mono x h' ht, H.mono fun n => idā©
-- Porting note: generalized from `Type` to `Sort`
theorem tendstoLocallyUniformlyOn_iUnion {ι' : Sort*} {S : ι' ā Set α} (hS : ā i, IsOpen (S i))
(h : ā i, TendstoLocallyUniformlyOn F f p (S i)) :
TendstoLocallyUniformlyOn F f p (ā i, S i) :=
(isOpen_iUnion hS).tendstoLocallyUniformlyOn_iff_forall_tendsto.2 fun _x hx =>
let āØi, hiā© := mem_iUnion.1 hx
(hS i).tendstoLocallyUniformlyOn_iff_forall_tendsto.1 (h i) _ hi
theorem tendstoLocallyUniformlyOn_biUnion {s : Set γ} {S : γ ā Set α} (hS : ā i ā s, IsOpen (S i))
(h : ā i ā s, TendstoLocallyUniformlyOn F f p (S i)) :
TendstoLocallyUniformlyOn F f p (ā i ā s, S i) :=
tendstoLocallyUniformlyOn_iUnion (fun i => isOpen_iUnion (hS i)) fun i =>
tendstoLocallyUniformlyOn_iUnion (hS i) (h i)
theorem tendstoLocallyUniformlyOn_sUnion (S : Set (Set α)) (hS : ā s ā S, IsOpen s)
(h : ā s ā S, TendstoLocallyUniformlyOn F f p s) : TendstoLocallyUniformlyOn F f p (āā S) := by
rw [sUnion_eq_biUnion]
exact tendstoLocallyUniformlyOn_biUnion hS h
theorem TendstoLocallyUniformlyOn.union {sā sā : Set α} (hsā : IsOpen sā) (hsā : IsOpen sā)
(hā : TendstoLocallyUniformlyOn F f p sā) (hā : TendstoLocallyUniformlyOn F f p sā) :
TendstoLocallyUniformlyOn F f p (sā āŖ sā) := by
rw [ā sUnion_pair]
refine tendstoLocallyUniformlyOn_sUnion _ ?_ ?_ <;> simp [*]
-- Porting note: tendstoLocallyUniformlyOn_univ moved up
protected theorem TendstoLocallyUniformly.tendstoLocallyUniformlyOn
(h : TendstoLocallyUniformly F f p) : TendstoLocallyUniformlyOn F f p s :=
(tendstoLocallyUniformlyOn_univ.mpr h).mono (subset_univ _)
/-- On a compact space, locally uniform convergence is just uniform convergence. -/
theorem tendstoLocallyUniformly_iff_tendstoUniformly_of_compactSpace [CompactSpace α] :
TendstoLocallyUniformly F f p ā TendstoUniformly F f p := by
refine āØfun h V hV => ?_, TendstoUniformly.tendstoLocallyUniformlyā©
choose U hU using h V hV
obtain āØt, htā© := isCompact_univ.elim_nhds_subcover' (fun k _ => U k) fun k _ => (hU k).1
replace hU := fun x : t => (hU x).2
rw [ā eventually_all] at hU
refine hU.mono fun i hi x => ?_
specialize ht (mem_univ x)
simp only [exists_prop, mem_iUnion, SetCoe.exists, exists_and_right, Subtype.coe_mk] at ht
obtain āØy, āØhyā, hyāā©, hyāā© := ht
exact hi āØāØy, hyāā©, hyāā© x hyā
/-- For a compact set `s`, locally uniform convergence on `s` is just uniform convergence on `s`. -/
theorem tendstoLocallyUniformlyOn_iff_tendstoUniformlyOn_of_compact (hs : IsCompact s) :
TendstoLocallyUniformlyOn F f p s ā TendstoUniformlyOn F f p s := by
haveI : CompactSpace s := isCompact_iff_compactSpace.mp hs
refine āØfun h => ?_, TendstoUniformlyOn.tendstoLocallyUniformlyOnā©
rwa [tendstoLocallyUniformlyOn_iff_tendstoLocallyUniformly_comp_coe,
tendstoLocallyUniformly_iff_tendstoUniformly_of_compactSpace, ā
tendstoUniformlyOn_iff_tendstoUniformly_comp_coe] at h
theorem TendstoLocallyUniformlyOn.comp [TopologicalSpace γ] {t : Set γ}
(h : TendstoLocallyUniformlyOn F f p s) (g : γ ā α) (hg : MapsTo g t s)
(cg : ContinuousOn g t) : TendstoLocallyUniformlyOn (fun n => F n ā g) (f ā g) p t := by
intro u hu x hx
rcases h u hu (g x) (hg hx) with āØa, ha, Hā©
have : g ā»Ā¹' a ā š[t] x :=
(cg x hx).preimage_mem_nhdsWithin' (nhdsWithin_mono (g x) hg.image_subset ha)
exact āØg ā»Ā¹' a, this, H.mono fun n hn y hy => hn _ hyā©
theorem TendstoLocallyUniformly.comp [TopologicalSpace γ] (h : TendstoLocallyUniformly F f p)
(g : γ ā α) (cg : Continuous g) : TendstoLocallyUniformly (fun n => F n ā g) (f ā g) p := by
rw [ā tendstoLocallyUniformlyOn_univ] at h ā¢
rw [continuous_iff_continuousOn_univ] at cg
exact h.comp _ (mapsTo_univ _ _) cg
theorem tendstoLocallyUniformlyOn_TFAE [LocallyCompactSpace α] (G : ι ā α ā β) (g : α ā β)
(p : Filter ι) (hs : IsOpen s) :
List.TFAE [
TendstoLocallyUniformlyOn G g p s,
ā K, K ā s ā IsCompact K ā TendstoUniformlyOn G g p K,
ā x ā s, ā v ā š[s] x, TendstoUniformlyOn G g p v] := by
tfae_have 1 ā 2
Ā· rintro h K hK1 hK2
exact (tendstoLocallyUniformlyOn_iff_tendstoUniformlyOn_of_compact hK2).mp (h.mono hK1)
tfae_have 2 ā 3
Ā· rintro h x hx
obtain āØK, āØhK1, hK2ā©, hK3ā© := (compact_basis_nhds x).mem_iff.mp (hs.mem_nhds hx)
exact āØK, nhdsWithin_le_nhds hK1, h K hK3 hK2ā©
tfae_have 3 ā 1
Ā· rintro h u hu x hx
obtain āØv, hv1, hv2ā© := h x hx
exact āØv, hv1, hv2 u huā©
tfae_finish
theorem tendstoLocallyUniformlyOn_iff_forall_isCompact [LocallyCompactSpace α] (hs : IsOpen s) :
TendstoLocallyUniformlyOn F f p s ā ā K, K ā s ā IsCompact K ā TendstoUniformlyOn F f p K :=
(tendstoLocallyUniformlyOn_TFAE F f p hs).out 0 1
lemma tendstoLocallyUniformly_iff_forall_isCompact [LocallyCompactSpace α] :
TendstoLocallyUniformly F f p ā ā K : Set α, IsCompact K ā TendstoUniformlyOn F f p K := by
simp only [ā tendstoLocallyUniformlyOn_univ,
tendstoLocallyUniformlyOn_iff_forall_isCompact isOpen_univ, Set.subset_univ, forall_true_left]
theorem tendstoLocallyUniformlyOn_iff_filter :
TendstoLocallyUniformlyOn F f p s ā ā x ā s, TendstoUniformlyOnFilter F f p (š[s] x) := by
simp only [TendstoUniformlyOnFilter, eventually_prod_iff]
constructor
Ā· rintro h x hx u hu
obtain āØs, hs1, hs2ā© := h u hu x hx
exact āØ_, hs2, _, eventually_of_mem hs1 fun x => id, fun hi y hy => hi y hyā©
Ā· rintro h u hu x hx
obtain āØpa, hpa, pb, hpb, hā© := h x hx u hu
exact āØpb, hpb, eventually_of_mem hpa fun i hi y hy => h hi hyā©
theorem tendstoLocallyUniformly_iff_filter :
TendstoLocallyUniformly F f p ā ā x, TendstoUniformlyOnFilter F f p (š x) := by
simpa [ā tendstoLocallyUniformlyOn_univ, ā nhdsWithin_univ] using
@tendstoLocallyUniformlyOn_iff_filter _ _ _ _ F f univ p _
theorem TendstoLocallyUniformlyOn.tendsto_at (hf : TendstoLocallyUniformlyOn F f p s) {a : α}
(ha : a ā s) : Tendsto (fun i => F i a) p (š (f a)) := by
refine ((tendstoLocallyUniformlyOn_iff_filter.mp hf) a ha).tendsto_at ?_
simpa only [Filter.principal_singleton] using pure_le_nhdsWithin ha
theorem TendstoLocallyUniformlyOn.unique [p.NeBot] [T2Space β] {g : α ā β}
(hf : TendstoLocallyUniformlyOn F f p s) (hg : TendstoLocallyUniformlyOn F g p s) :
s.EqOn f g := fun _a ha => tendsto_nhds_unique (hf.tendsto_at ha) (hg.tendsto_at ha)
theorem TendstoLocallyUniformlyOn.congr {G : ι ā α ā β} (hf : TendstoLocallyUniformlyOn F f p s)
(hg : ā n, s.EqOn (F n) (G n)) : TendstoLocallyUniformlyOn G f p s := by
rintro u hu x hx
obtain āØt, ht, hā© := hf u hu x hx
refine āØs ā© t, inter_mem self_mem_nhdsWithin ht, ?_ā©
filter_upwards [h] with i hi y hy using hg i hy.1 āø hi y hy.2
theorem TendstoLocallyUniformlyOn.congr_right {g : α ā β} (hf : TendstoLocallyUniformlyOn F f p s)
(hg : s.EqOn f g) : TendstoLocallyUniformlyOn F g p s := by
rintro u hu x hx
obtain āØt, ht, hā© := hf u hu x hx
refine āØs ā© t, inter_mem self_mem_nhdsWithin ht, ?_ā©
filter_upwards [h] with i hi y hy using hg hy.1 āø hi y hy.2
/-!
### Uniform approximation
In this section, we give lemmas ensuring that a function is continuous if it can be approximated
uniformly by continuous functions. We give various versions, within a set or the whole space, at
a single point or at all points, with locally uniform approximation or uniform approximation. All
the statements are derived from a statement about locally uniform approximation within a set at
a point, called `continuousWithinAt_of_locally_uniform_approx_of_continuousWithinAt`. -/
/-- A function which can be locally uniformly approximated by functions which are continuous
within a set at a point is continuous within this set at this point. -/
theorem continuousWithinAt_of_locally_uniform_approx_of_continuousWithinAt (hx : x ā s)
(L : ā u ā š¤ β, ā t ā š[s] x, ā F : α ā β, ContinuousWithinAt F s x ā§ ā y ā t, (f y, F y) ā u) :
ContinuousWithinAt f s x := by
refine Uniform.continuousWithinAt_iff'_left.2 fun uā huā => ?_
obtain āØuā, hā, uāāā© : ā u ā š¤ β, u ā u ā uā := comp_mem_uniformity_sets huā
obtain āØuā, hā, hsymm, uāāā© : ā u ā š¤ β, (ā {a b}, (a, b) ā u ā (b, a) ā u) ā§ u ā u ā uā :=
comp_symm_of_uniformity hā
rcases L uā hā with āØt, tx, F, hFc, hFā©
have A : āį¶ y in š[s] x, (f y, F y) ā uā := Eventually.mono tx hF
have B : āį¶ y in š[s] x, (F y, F x) ā uā := Uniform.continuousWithinAt_iff'_left.1 hFc hā
have C : āį¶ y in š[s] x, (f y, F x) ā uā :=
(A.and B).mono fun y hy => uāā (prod_mk_mem_compRel hy.1 hy.2)
have : (F x, f x) ā uā :=
uāā (prod_mk_mem_compRel (refl_mem_uniformity hā) (hsymm (A.self_of_nhdsWithin hx)))
exact C.mono fun y hy => uāā (prod_mk_mem_compRel hy this)
/-- A function which can be locally uniformly approximated by functions which are continuous at
a point is continuous at this point. -/
theorem continuousAt_of_locally_uniform_approx_of_continuousAt
(L : ā u ā š¤ β, ā t ā š x, ā F, ContinuousAt F x ā§ ā y ā t, (f y, F y) ā u) :
ContinuousAt f x := by
rw [ā continuousWithinAt_univ]
apply continuousWithinAt_of_locally_uniform_approx_of_continuousWithinAt (mem_univ _) _
simpa only [exists_prop, nhdsWithin_univ, continuousWithinAt_univ] using L
/-- A function which can be locally uniformly approximated by functions which are continuous
on a set is continuous on this set. -/
theorem continuousOn_of_locally_uniform_approx_of_continuousWithinAt
(L : ā x ā s, ā u ā š¤ β, ā t ā š[s] x, ā F,
ContinuousWithinAt F s x ā§ ā y ā t, (f y, F y) ā u) :
ContinuousOn f s := fun x hx =>
continuousWithinAt_of_locally_uniform_approx_of_continuousWithinAt hx (L x hx)
/-- A function which can be uniformly approximated by functions which are continuous on a set
is continuous on this set. -/
theorem continuousOn_of_uniform_approx_of_continuousOn
(L : ā u ā š¤ β, ā F, ContinuousOn F s ā§ ā y ā s, (f y, F y) ā u) : ContinuousOn f s :=
continuousOn_of_locally_uniform_approx_of_continuousWithinAt fun _x hx u hu =>
āØs, self_mem_nhdsWithin, (L u hu).imp fun _F hF => āØhF.1.continuousWithinAt hx, hF.2ā©ā©
/-- A function which can be locally uniformly approximated by continuous functions is continuous. -/
theorem continuous_of_locally_uniform_approx_of_continuousAt
(L : ā x : α, ā u ā š¤ β, ā t ā š x, ā F, ContinuousAt F x ā§ ā y ā t, (f y, F y) ā u) :
Continuous f :=
continuous_iff_continuousAt.2 fun x =>
continuousAt_of_locally_uniform_approx_of_continuousAt (L x)
/-- A function which can be uniformly approximated by continuous functions is continuous. -/
theorem continuous_of_uniform_approx_of_continuous
(L : ā u ā š¤ β, ā F, Continuous F ā§ ā y, (f y, F y) ā u) : Continuous f :=
continuous_iff_continuousOn_univ.mpr <|
continuousOn_of_uniform_approx_of_continuousOn <| by
simpa [continuous_iff_continuousOn_univ] using L
/-!
### Uniform limits
From the previous statements on uniform approximation, we deduce continuity results for uniform
limits.
-/
/-- A locally uniform limit on a set of functions which are continuous on this set is itself
continuous on this set. -/
protected theorem TendstoLocallyUniformlyOn.continuousOn (h : TendstoLocallyUniformlyOn F f p s)
(hc : āį¶ n in p, ContinuousOn (F n) s) [NeBot p] : ContinuousOn f s := by
refine continuousOn_of_locally_uniform_approx_of_continuousWithinAt fun x hx u hu => ?_
rcases h u hu x hx with āØt, ht, Hā©
rcases (hc.and H).exists with āØn, hFc, hFā©
exact āØt, ht, āØF n, hFc.continuousWithinAt hx, hFā©ā©
/-- A uniform limit on a set of functions which are continuous on this set is itself continuous
on this set. -/
protected theorem TendstoUniformlyOn.continuousOn (h : TendstoUniformlyOn F f p s)
(hc : āį¶ n in p, ContinuousOn (F n) s) [NeBot p] : ContinuousOn f s :=
h.tendstoLocallyUniformlyOn.continuousOn hc
/-- A locally uniform limit of continuous functions is continuous. -/
protected theorem TendstoLocallyUniformly.continuous (h : TendstoLocallyUniformly F f p)
(hc : āį¶ n in p, Continuous (F n)) [NeBot p] : Continuous f :=
continuous_iff_continuousOn_univ.mpr <|
h.tendstoLocallyUniformlyOn.continuousOn <| hc.mono fun _n hn => hn.continuousOn
/-- A uniform limit of continuous functions is continuous. -/
protected theorem TendstoUniformly.continuous (h : TendstoUniformly F f p)
(hc : āį¶ n in p, Continuous (F n)) [NeBot p] : Continuous f :=
h.tendstoLocallyUniformly.continuous hc
/-!
### Composing limits under uniform convergence
In general, if `Fā` converges pointwise to a function `f`, and `gā` tends to `x`, it is not true
that `Fā gā` tends to `f x`. It is true however if the convergence of `Fā` to `f` is uniform. In
this paragraph, we prove variations around this statement.
-/
/-- If `Fā` converges locally uniformly on a neighborhood of `x` within a set `s` to a function `f`
which is continuous at `x` within `s`, and `gā` tends to `x` within `s`, then `Fā (gā)` tends
to `f x`. -/
theorem tendsto_comp_of_locally_uniform_limit_within (h : ContinuousWithinAt f s x)
(hg : Tendsto g p (š[s] x))
(hunif : ā u ā š¤ β, ā t ā š[s] x, āį¶ n in p, ā y ā t, (f y, F n y) ā u) :
Tendsto (fun n => F n (g n)) p (š (f x)) := by
refine Uniform.tendsto_nhds_right.2 fun uā huā => ?_
obtain āØuā, hā, uāāā© : ā u ā š¤ β, u ā u ā uā := comp_mem_uniformity_sets huā
rcases hunif uā hā with āØs, sx, hsā©
have A : āį¶ n in p, g n ā s := hg sx
have B : āį¶ n in p, (f x, f (g n)) ā uā := hg (Uniform.continuousWithinAt_iff'_right.1 h hā)
exact B.mp <| A.mp <| hs.mono fun y H1 H2 H3 => uāā (prod_mk_mem_compRel H3 (H1 _ H2))
/-- If `Fā` converges locally uniformly on a neighborhood of `x` to a function `f` which is
continuous at `x`, and `gā` tends to `x`, then `Fā (gā)` tends to `f x`. -/
theorem tendsto_comp_of_locally_uniform_limit (h : ContinuousAt f x) (hg : Tendsto g p (š x))
(hunif : ā u ā š¤ β, ā t ā š x, āį¶ n in p, ā y ā t, (f y, F n y) ā u) :
Tendsto (fun n => F n (g n)) p (š (f x)) := by
rw [ā continuousWithinAt_univ] at h
rw [ā nhdsWithin_univ] at hunif hg
exact tendsto_comp_of_locally_uniform_limit_within h hg hunif
/-- If `Fā` tends locally uniformly to `f` on a set `s`, and `gā` tends to `x` within `s`, then
`Fā gā` tends to `f x` if `f` is continuous at `x` within `s` and `x ā s`. -/
theorem TendstoLocallyUniformlyOn.tendsto_comp (h : TendstoLocallyUniformlyOn F f p s)
(hf : ContinuousWithinAt f s x) (hx : x ā s) (hg : Tendsto g p (š[s] x)) :
Tendsto (fun n => F n (g n)) p (š (f x)) :=
tendsto_comp_of_locally_uniform_limit_within hf hg fun u hu => h u hu x hx
/-- If `Fā` tends uniformly to `f` on a set `s`, and `gā` tends to `x` within `s`, then `Fā gā`
tends to `f x` if `f` is continuous at `x` within `s`. -/
theorem TendstoUniformlyOn.tendsto_comp (h : TendstoUniformlyOn F f p s)
(hf : ContinuousWithinAt f s x) (hg : Tendsto g p (š[s] x)) :
Tendsto (fun n => F n (g n)) p (š (f x)) :=
tendsto_comp_of_locally_uniform_limit_within hf hg fun u hu => āØs, self_mem_nhdsWithin, h u huā©
/-- If `Fā` tends locally uniformly to `f`, and `gā` tends to `x`, then `Fā gā` tends to `f x`. -/
theorem TendstoLocallyUniformly.tendsto_comp (h : TendstoLocallyUniformly F f p)
(hf : ContinuousAt f x) (hg : Tendsto g p (š x)) : Tendsto (fun n => F n (g n)) p (š (f x)) :=
tendsto_comp_of_locally_uniform_limit hf hg fun u hu => h u hu x
/-- If `Fā` tends uniformly to `f`, and `gā` tends to `x`, then `Fā gā` tends to `f x`. -/
theorem TendstoUniformly.tendsto_comp (h : TendstoUniformly F f p) (hf : ContinuousAt f x)
(hg : Tendsto g p (š x)) : Tendsto (fun n => F n (g n)) p (š (f x)) :=
h.tendstoLocallyUniformly.tendsto_comp hf hg
|
Topology\UniformSpace\UniformConvergenceTopology.lean
|
/-
Copyright (c) 2022 Anatole Dedecker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anatole Dedecker
-/
import Mathlib.Topology.UniformSpace.UniformConvergence
import Mathlib.Topology.UniformSpace.Pi
import Mathlib.Topology.UniformSpace.Equiv
import Mathlib.Topology.RestrictGenTopology
/-!
# Topology and uniform structure of uniform convergence
This files endows `α ā β` with the topologies / uniform structures of
- uniform convergence on `α`
- uniform convergence on a specified family `š` of sets of `α`, also called `š`-convergence
Since `α ā β` is already endowed with the topologies and uniform structures of pointwise
convergence, we introduce type aliases `UniformFun α β` (denoted `α āᵤ β`) and
`UniformOnFun α β š` (denoted `α āᵤ[š] β`) and we actually endow *these* with the structures
of uniform and `š`-convergence respectively.
Usual examples of the second construction include :
- the topology of compact convergence, when `š` is the set of compacts of `α`
- the strong topology on the dual of a topological vector space (TVS) `E`, when `š` is the set of
Von Neumann bounded subsets of `E`
- the weak-* topology on the dual of a TVS `E`, when `š` is the set of singletons of `E`.
This file contains a lot of technical facts, so it is heavily commented, proofs included!
## Main definitions
* `UniformFun.gen`: basis sets for the uniformity of uniform convergence. These are sets
of the form `S(V) := {(f, g) | ā x : α, (f x, g x) ā V}` for some `V : Set (β à β)`
* `UniformFun.uniformSpace`: uniform structure of uniform convergence. This is the
`UniformSpace` on `α āᵤ β` whose uniformity is generated by the sets `S(V)` for `V ā š¤ β`.
We will denote this uniform space as `š°(α, β, uβ)`, both in the comments and as a local notation
in the Lean code, where `uβ` is the uniform space structure on `β`.
This is declared as an instance on `α āᵤ β`.
* `UniformOnFun.uniformSpace`: uniform structure of `š`-convergence, where
`š : Set (Set α)`. This is the infimum, for `S ā š`, of the pullback of `š° S β` by the map of
restriction to `S`. We will denote it `š±(α, β, š, uβ)`, where `uβ` is the uniform space structure
on `β`.
This is declared as an instance on `α āᵤ[š] β`.
## Main statements
### Basic properties
* `UniformFun.uniformContinuous_eval`: evaluation is uniformly continuous on `α āᵤ β`.
* `UniformFun.t2Space`: the topology of uniform convergence on `α āᵤ β` is Tā if
`β` is Tā.
* `UniformFun.tendsto_iff_tendstoUniformly`: `š°(α, β, uβ)` is
indeed the uniform structure of uniform convergence
* `UniformOnFun.uniformContinuous_eval_of_mem`: evaluation at a point contained in a
set of `š` is uniformly continuous on `α āᵤ[š] β`
* `UniformOnFun.t2Space_of_covering`: the topology of `š`-convergence on `α āᵤ[š] β` is Tā if
`β` is Tā and `š` covers `α`
* `UniformOnFun.tendsto_iff_tendstoUniformlyOn`:
`š±(α, β, š uβ)` is indeed the uniform structure of `š`-convergence
### Functoriality and compatibility with product of uniform spaces
In order to avoid the need for filter bases as much as possible when using these definitions,
we develop an extensive API for manipulating these structures abstractly. As usual in the topology
section of mathlib, we first state results about the complete lattices of `UniformSpace`s on
fixed types, and then we use these to deduce categorical-like results about maps between two
uniform spaces.
We only describe these in the harder case of `š`-convergence, as the names of the corresponding
results for uniform convergence can easily be guessed.
#### Order statements
* `UniformOnFun.mono`: let `uā`, `uā` be two uniform structures on `γ` and
`šā šā : Set (Set α)`. If `uā ⤠uā` and `šā ā šā` then `š±(α, γ, šā, uā) ⤠š±(α, γ, šā, uā)`.
* `UniformOnFun.iInf_eq`: if `u` is a family of uniform structures on `γ`, then
`š±(α, γ, š, (āØ
i, u i)) = āØ
i, š±(α, γ, š, u i)`.
* `UniformOnFun.comap_eq`: if `u` is a uniform structures on `β` and `f : γ ā β`, then
`š±(α, γ, š, comap f u) = comap (fun g ⦠f ā g) š±(α, γ, š, uā)`.
An interesting note about these statements is that they are proved without ever unfolding the basis
definition of the uniform structure of uniform convergence! Instead, we build a
(not very interesting) Galois connection `UniformFun.gc` and then rely on the Galois
connection API to do most of the work.
#### Morphism statements (unbundled)
* `UniformOnFun.postcomp_uniformContinuous`: if `f : γ ā β` is uniformly
continuous, then `(fun g ⦠f ā g) : (α āᵤ[š] γ) ā (α āᵤ[š] β)` is uniformly continuous.
* `UniformOnFun.postcomp_uniformInducing`: if `f : γ ā β` is a uniform
inducing, then `(fun g ⦠f ā g) : (α āᵤ[š] γ) ā (α āᵤ[š] β)` is a uniform inducing.
* `UniformOnFun.precomp_uniformContinuous`: let `f : γ ā α`, `š : Set (Set α)`,
`š : Set (Set γ)`, and assume that `ā T ā š, f '' T ā š`. Then, the function
`(fun g ⦠g ā f) : (α āᵤ[š] β) ā (γ āᵤ[š] β)` is uniformly continuous.
#### Isomorphism statements (bundled)
* `UniformOnFun.congrRight`: turn a uniform isomorphism `γ āᵤ β` into a uniform isomorphism
`(α āᵤ[š] γ) āᵤ (α āᵤ[š] β)` by post-composing.
* `UniformOnFun.congrLeft`: turn a bijection `e : γ ā α` such that we have both
`ā T ā š, e '' T ā š` and `ā S ā š, e ā»Ā¹' S ā š` into a uniform isomorphism
`(γ āᵤ[š] β) āᵤ (α āᵤ[š] β)` by pre-composing.
* `UniformOnFun.uniformEquivPiComm`: the natural bijection between `α ā Ī i, Ī“ i`
and `Ī i, α ā Ī“ i`, upgraded to a uniform isomorphism between `α āᵤ[š] (Ī i, Ī“ i)` and
`Ī i, α āᵤ[š] Ī“ i`.
#### Important use cases
* If `G` is a uniform group, then `α āᵤ[š] G` is a uniform group: since `(/) : G Ć G ā G` is
uniformly continuous, `UniformOnFun.postcomp_uniformContinuous` tells us that
`((/) ā ā) : (α āᵤ[š] G Ć G) ā (α āᵤ[š] G)` is uniformly continuous. By precomposing with
`UniformOnFun.uniformEquivProdArrow`, this gives that
`(/) : (α āᵤ[š] G) Ć (α āᵤ[š] G) ā (α āᵤ[š] G)` is also uniformly continuous
* The transpose of a continuous linear map is continuous for the strong topologies: since
continuous linear maps are uniformly continuous and map bounded sets to bounded sets,
this is just a special case of `UniformOnFun.precomp_uniformContinuous`.
## TODO
* Show that the uniform structure of `š`-convergence is exactly the structure of `š'`-convergence,
where `š'` is the ***noncovering*** bornology (i.e ***not*** what `Bornology` currently refers
to in mathlib) generated by `š`.
## References
* [N. Bourbaki, *General Topology, Chapter X*][bourbaki1966]
## Tags
uniform convergence
-/
noncomputable section
open scoped Topology Uniformity
open Set Filter
section TypeAlias
/-- The type of functions from `α` to `β` equipped with the uniform structure and topology of
uniform convergence. We denote it `α āᵤ β`. -/
def UniformFun (α β : Type*) :=
α ā β
/-- The type of functions from `α` to `β` equipped with the uniform structure and topology of
uniform convergence on some family `š` of subsets of `α`. We denote it `α āᵤ[š] β`. -/
@[nolint unusedArguments]
def UniformOnFun (α β : Type*) (_ : Set (Set α)) :=
α ā β
@[inherit_doc] scoped[UniformConvergence] notation:25 α " āᵤ " β:0 => UniformFun α β
@[inherit_doc] scoped[UniformConvergence] notation:25 α " āᵤ[" š "] " β:0 => UniformOnFun α β š
open UniformConvergence
variable {α β : Type*} {š : Set (Set α)}
instance [Nonempty β] : Nonempty (α āᵤ β) := Pi.instNonempty
instance [Nonempty β] : Nonempty (α āᵤ[š] β) := Pi.instNonempty
instance [Subsingleton β] : Subsingleton (α āᵤ β) :=
inferInstanceAs <| Subsingleton <| α ā β
instance [Subsingleton β] : Subsingleton (α āᵤ[š] β) :=
inferInstanceAs <| Subsingleton <| α ā β
/-- Reinterpret `f : α ā β` as an element of `α āᵤ β`. -/
def UniformFun.ofFun : (α ā β) ā (α āᵤ β) :=
āØfun x => x, fun x => x, fun _ => rfl, fun _ => rflā©
/-- Reinterpret `f : α ā β` as an element of `α āᵤ[š] β`. -/
def UniformOnFun.ofFun (š) : (α ā β) ā (α āᵤ[š] β) :=
āØfun x => x, fun x => x, fun _ => rfl, fun _ => rflā©
/-- Reinterpret `f : α āᵤ β` as an element of `α ā β`. -/
def UniformFun.toFun : (α āᵤ β) ā (α ā β) :=
UniformFun.ofFun.symm
/-- Reinterpret `f : α āᵤ[š] β` as an element of `α ā β`. -/
def UniformOnFun.toFun (š) : (α āᵤ[š] β) ā (α ā β) :=
(UniformOnFun.ofFun š).symm
@[simp] lemma UniformFun.toFun_ofFun (f : α ā β) : toFun (ofFun f) = f := rfl
@[simp] lemma UniformFun.ofFun_toFun (f : α āᵤ β) : ofFun (toFun f) = f := rfl
@[simp] lemma UniformOnFun.toFun_ofFun (f : α ā β) : toFun š (ofFun š f) = f := rfl
@[simp] lemma UniformOnFun.ofFun_toFun (f : α āᵤ[š] β) : ofFun š (toFun š f) = f := rfl
-- Note: we don't declare a `CoeFun` instance because Lean wouldn't insert it when writing
-- `f x` (because of definitional equality with `α ā β`).
end TypeAlias
open UniformConvergence
namespace UniformFun
variable (α β : Type*) {γ ι : Type*}
variable {s s' : Set α} {x : α} {p : Filter ι} {g : ι ā α}
/-- Basis sets for the uniformity of uniform convergence: `gen α β V` is the set of pairs `(f, g)`
of functions `α āᵤ β` such that `ā x, (f x, g x) ā V`. -/
protected def gen (V : Set (β à β)) : Set ((α āᵤ β) Ć (α āᵤ β)) :=
{ uv : (α āᵤ β) Ć (α āᵤ β) | ā x, (toFun uv.1 x, toFun uv.2 x) ā V }
/-- If `š` is a filter on `β à β`, then the set of all `UniformFun.gen α β V` for
`V ā š` is a filter basis on `(α āᵤ β) Ć (α āᵤ β)`. This will only be applied to `š = š¤ β` when
`β` is equipped with a `UniformSpace` structure, but it is useful to define it for any filter in
order to be able to state that it has a lower adjoint (see `UniformFun.gc`). -/
protected theorem isBasis_gen (š : Filter <| β à β) :
IsBasis (fun V : Set (β à β) => V ā š) (UniformFun.gen α β) :=
āØāØuniv, univ_memā©, @fun U V hU hV =>
āØU ā© V, inter_mem hU hV, fun _ huv => āØfun x => (huv x).left, fun x => (huv x).rightā©ā©ā©
/-- For `š : Filter (β à β)`, this is the set of all `UniformFun.gen α β V` for
`V ā š` as a bundled `FilterBasis` over `(α āᵤ β) Ć (α āᵤ β)`. This will only be applied to
`š = š¤ β` when `β` is equipped with a `UniformSpace` structure, but it is useful to define it for
any filter in order to be able to state that it has a lower adjoint
(see `UniformFun.gc`). -/
protected def basis (š : Filter <| β à β) : FilterBasis ((α āᵤ β) Ć (α āᵤ β)) :=
(UniformFun.isBasis_gen α β š).filterBasis
/-- For `š : Filter (β à β)`, this is the filter generated by the filter basis
`UniformFun.basis α β š`. For `š = š¤ β`, this will be the uniformity of uniform
convergence on `α`. -/
protected def filter (š : Filter <| β à β) : Filter ((α āᵤ β) Ć (α āᵤ β)) :=
(UniformFun.basis α β š).filter
--local notation "Φ" => fun (α β : Type*) (uvx : ((α āᵤ β) Ć (α āᵤ β)) à α) =>
--(uvx.fst.fst uvx.2, uvx.1.2 uvx.2)
protected def phi (α β : Type*) (uvx : ((α āᵤ β) Ć (α āᵤ β)) à α) : β à β :=
(uvx.fst.fst uvx.2, uvx.1.2 uvx.2)
set_option quotPrecheck false -- Porting note: error message suggested to do this
/- This is a lower adjoint to `UniformFun.filter` (see `UniformFun.gc`).
The exact definition of the lower adjoint `l` is not interesting; we will only use that it exists
(in `UniformFun.mono` and `UniformFun.iInf_eq`) and that
`l (Filter.map (Prod.map f f) š) = Filter.map (Prod.map ((ā) f) ((ā) f)) (l š)` for each
`š : Filter (γ à γ)` and `f : γ ā α` (in `UniformFun.comap_eq`). -/
local notation "lowerAdjoint" => fun š => map (UniformFun.phi α β) (š ĆĖ¢ ā¤)
/-- The function `UniformFun.filter α β : Filter (β à β) ā Filter ((α āᵤ β) Ć (α āᵤ β))`
has a lower adjoint `l` (in the sense of `GaloisConnection`). The exact definition of `l` is not
interesting; we will only use that it exists (in `UniformFun.mono` and
`UniformFun.iInf_eq`) and that
`l (Filter.map (Prod.map f f) š) = Filter.map (Prod.map ((ā) f) ((ā) f)) (l š)` for each
`š : Filter (γ à γ)` and `f : γ ā α` (in `UniformFun.comap_eq`). -/
protected theorem gc : GaloisConnection lowerAdjoint fun š => UniformFun.filter α β š := by
intro š š
symm
calc
š ⤠UniformFun.filter α β š ā (UniformFun.basis α β š).sets ā š.sets := by
rw [UniformFun.filter, ā FilterBasis.generate, le_generate_iff]
_ ā ā U ā š, UniformFun.gen α β U ā š := image_subset_iff
_ ā ā U ā š,
{ uv | ā x, (uv, x) ā { t : ((α āᵤ β) Ć (α āᵤ β)) à α | (t.1.1 t.2, t.1.2 t.2) ā U } } ā
š :=
Iff.rfl
_ ā ā U ā š,
{ uvx : ((α āᵤ β) Ć (α āᵤ β)) à α | (uvx.1.1 uvx.2, uvx.1.2 uvx.2) ā U } ā
š ĆĖ¢ (⤠: Filter α) :=
forallā_congr fun U _hU => mem_prod_top.symm
_ ā lowerAdjoint š ⤠š := Iff.rfl
variable [UniformSpace β]
/-- Core of the uniform structure of uniform convergence. -/
protected def uniformCore : UniformSpace.Core (α āᵤ β) :=
UniformSpace.Core.mkOfBasis (UniformFun.basis α β (š¤ β))
(fun _ āØ_, hV, hVUā© _ => hVU āø fun _ => refl_mem_uniformity hV)
(fun _ āØV, hV, hVUā© =>
hVU āø
āØUniformFun.gen α β (Prod.swap ā»Ā¹' V), āØProd.swap ā»Ā¹' V, tendsto_swap_uniformity hV, rflā©,
fun _ huv x => huv xā©)
fun _ āØ_, hV, hVUā© =>
hVU āø
let āØW, hW, hWVā© := comp_mem_uniformity_sets hV
āØUniformFun.gen α β W, āØW, hW, rflā©, fun _ āØw, huw, hwvā© x => hWV āØw x, āØhuw x, hwv xā©ā©ā©
/-- Uniform structure of uniform convergence, declared as an instance on `α āᵤ β`.
We will denote it `š°(α, β, uβ)` in the rest of this file. -/
instance uniformSpace : UniformSpace (α āᵤ β) :=
UniformSpace.ofCore (UniformFun.uniformCore α β)
/-- Topology of uniform convergence, declared as an instance on `α āᵤ β`. -/
instance topologicalSpace : TopologicalSpace (α āᵤ β) :=
inferInstance
local notation "š°(" α ", " β ", " u ")" => @UniformFun.uniformSpace α β u
/-- By definition, the uniformity of `α āᵤ β` admits the family `{(f, g) | ā x, (f x, g x) ā V}`
for `V ā š¤ β` as a filter basis. -/
protected theorem hasBasis_uniformity :
(š¤ (α āᵤ β)).HasBasis (Ā· ā š¤ β) (UniformFun.gen α β) :=
(UniformFun.isBasis_gen α β (š¤ β)).hasBasis
/-- The uniformity of `α āᵤ β` admits the family `{(f, g) | ā x, (f x, g x) ā V}` for `V ā š` as
a filter basis, for any basis `š` of `š¤ β` (in the case `š = (š¤ β).as_basis` this is true by
definition). -/
protected theorem hasBasis_uniformity_of_basis {ι : Sort*} {p : ι ā Prop} {s : ι ā Set (β à β)}
(h : (š¤ β).HasBasis p s) : (š¤ (α āᵤ β)).HasBasis p (UniformFun.gen α β ā s) :=
(UniformFun.hasBasis_uniformity α β).to_hasBasis
(fun _ hU =>
let āØi, hi, hiUā© := h.mem_iff.mp hU
āØi, hi, fun _ huv x => hiU (huv x)ā©)
fun i hi => āØs i, h.mem_of_mem hi, subset_refl _ā©
/-- For `f : α āᵤ β`, `š f` admits the family `{g | ā x, (f x, g x) ā V}` for `V ā š` as a filter
basis, for any basis `š` of `š¤ β`. -/
protected theorem hasBasis_nhds_of_basis (f) {p : ι ā Prop} {s : ι ā Set (β à β)}
(h : HasBasis (š¤ β) p s) :
(š f).HasBasis p fun i => { g | (f, g) ā UniformFun.gen α β (s i) } :=
nhds_basis_uniformity' (UniformFun.hasBasis_uniformity_of_basis α β h)
/-- For `f : α āᵤ β`, `š f` admits the family `{g | ā x, (f x, g x) ā V}` for `V ā š¤ β` as a
filter basis. -/
protected theorem hasBasis_nhds (f) :
(š f).HasBasis (fun V => V ā š¤ β) fun V => { g | (f, g) ā UniformFun.gen α β V } :=
UniformFun.hasBasis_nhds_of_basis α β f (Filter.basis_sets _)
variable {α}
/-- Evaluation at a fixed point is uniformly continuous on `α āᵤ β`. -/
theorem uniformContinuous_eval (x : α) :
UniformContinuous (Function.eval x ā toFun : (α āᵤ β) ā β) := by
change _ ⤠_
rw [map_le_iff_le_comap,
(UniformFun.hasBasis_uniformity α β).le_basis_iff ((š¤ _).basis_sets.comap _)]
exact fun U hU => āØU, hU, fun uv huv => huv xā©
variable {β}
@[simp]
protected lemma mem_gen {β} {f g : α āᵤ β} {V : Set (β à β)} :
(f, g) ā UniformFun.gen α β V ā ā x, (toFun f x, toFun g x) ā V :=
.rfl
/-- If `uā` and `uā` are two uniform structures on `γ` and `uā ⤠uā`, then
`š°(α, γ, uā) ⤠š°(α, γ, uā)`. -/
protected theorem mono : Monotone (@UniformFun.uniformSpace α γ) := fun _ _ hu =>
(UniformFun.gc α γ).monotone_u hu
/-- If `u` is a family of uniform structures on `γ`, then
`š°(α, γ, (āØ
i, u i)) = āØ
i, š°(α, γ, u i)`. -/
protected theorem iInf_eq {u : ι ā UniformSpace γ} : š°(α, γ, (āØ
i, u i)) = āØ
i, š°(α, γ, u i) := by
-- This follows directly from the fact that the upper adjoint in a Galois connection maps
-- infimas to infimas.
ext : 1
change UniformFun.filter α γ š¤[āØ
i, u i] = š¤[āØ
i, š°(α, γ, u i)]
rw [iInf_uniformity, iInf_uniformity]
exact (UniformFun.gc α γ).u_iInf
/-- If `uā` and `uā` are two uniform structures on `γ`, then
`š°(α, γ, uā ā uā) = š°(α, γ, uā) ā š°(α, γ, uā)`. -/
protected theorem inf_eq {uā uā : UniformSpace γ} :
š°(α, γ, uā ā uā) = š°(α, γ, uā) ā š°(α, γ, uā) := by
-- This follows directly from the fact that the upper adjoint in a Galois connection maps
-- infimas to infimas.
rw [inf_eq_iInf, inf_eq_iInf, UniformFun.iInf_eq]
refine iInf_congr fun i => ?_
cases i <;> rfl
/-- Post-composition by a uniform inducing function is
a uniform inducing function for the uniform structures of uniform convergence.
More precisely, if `f : γ ā β` is uniform inducing,
then `(f ā Ā·) : (α āᵤ γ) ā (α āᵤ β)` is uniform inducing. -/
protected theorem postcomp_uniformInducing [UniformSpace γ] {f : γ ā β} (hf : UniformInducing f) :
UniformInducing (ofFun ā (f ā Ā·) ā toFun : (α āᵤ γ) ā α āᵤ β) :=
āØ((UniformFun.hasBasis_uniformity _ _).comap _).eq_of_same_basis <|
UniformFun.hasBasis_uniformity_of_basis _ _ (hf.basis_uniformity (š¤ β).basis_sets)ā©
/-- Post-composition by a uniform embedding is
a uniform embedding for the uniform structures of uniform convergence.
More precisely, if `f : γ ā β` is a uniform embedding,
then `(f ā Ā·) : (α āᵤ γ) ā (α āᵤ β)` is a uniform embedding. -/
protected theorem postcomp_uniformEmbedding [UniformSpace γ] {f : γ ā β} (hf : UniformEmbedding f) :
UniformEmbedding (ofFun ā (f ā Ā·) ā toFun : (α āᵤ γ) ā α āᵤ β) where
toUniformInducing := UniformFun.postcomp_uniformInducing hf.toUniformInducing
inj _ _ H := funext fun _ ⦠hf.inj (congrFun H _)
-- Porting note: had to add a type annotation at `((f ā Ā·) : ((α ā γ) ā (α ā β)))`
/-- If `u` is a uniform structures on `β` and `f : γ ā β`, then
`š°(α, γ, comap f u) = comap (fun g ⦠f ā g) š°(α, γ, uā)`. -/
protected theorem comap_eq {f : γ ā β} :
š°(α, γ, ā¹UniformSpace βāŗ.comap f) = š°(α, β, _).comap (f ā Ā·) := by
letI : UniformSpace γ := .comap f ā¹_āŗ
exact (UniformFun.postcomp_uniformInducing (f := f) āØrflā©).comap_uniformSpace.symm
/-- Post-composition by a uniformly continuous function is uniformly continuous on `α āᵤ β`.
More precisely, if `f : γ ā β` is uniformly continuous, then `(fun g ⦠f ā g) : (α āᵤ γ) ā (α āᵤ β)`
is uniformly continuous. -/
protected theorem postcomp_uniformContinuous [UniformSpace γ] {f : γ ā β}
(hf : UniformContinuous f) :
UniformContinuous (ofFun ā (f ā Ā·) ā toFun : (α āᵤ γ) ā α āᵤ β) := by
-- This is a direct consequence of `UniformFun.comap_eq`
refine uniformContinuous_iff.mpr ?_
exact (UniformFun.mono (uniformContinuous_iff.mp hf)).trans_eq UniformFun.comap_eq
-- Porting note: the original calc proof below gives a deterministic timeout
--calc
-- š°(α, γ, _) ⤠š°(α, γ, ā¹UniformSpace βāŗ.comap f) :=
-- UniformFun.mono (uniformContinuous_iff.mp hf)
-- _ = š°(α, β, _).comap (f ā Ā·) := @UniformFun.comap_eq α β γ _ f
/-- Turn a uniform isomorphism `γ āᵤ β` into a uniform isomorphism `(α āᵤ γ) āᵤ (α āᵤ β)` by
post-composing. -/
protected def congrRight [UniformSpace γ] (e : γ āᵤ β) : (α āᵤ γ) āᵤ (α āᵤ β) :=
{ Equiv.piCongrRight fun _ => e.toEquiv with
uniformContinuous_toFun := UniformFun.postcomp_uniformContinuous e.uniformContinuous
uniformContinuous_invFun := UniformFun.postcomp_uniformContinuous e.symm.uniformContinuous }
/-- Pre-composition by any function is uniformly continuous for the uniform structures of
uniform convergence.
More precisely, for any `f : γ ā α`, the function `(Ā· ā f) : (α āᵤ β) ā (γ āᵤ β)` is uniformly
continuous. -/
protected theorem precomp_uniformContinuous {f : γ ā α} :
UniformContinuous fun g : α āᵤ β => ofFun (toFun g ā f) := by
-- Here we simply go back to filter bases.
rw [UniformContinuous,
(UniformFun.hasBasis_uniformity α β).tendsto_iff (UniformFun.hasBasis_uniformity γ β)]
exact fun U hU => āØU, hU, fun uv huv x => huv (f x)ā©
/-- Turn a bijection `γ ā α` into a uniform isomorphism
`(γ āᵤ β) āᵤ (α āᵤ β)` by pre-composing. -/
protected def congrLeft (e : γ ā α) : (γ āᵤ β) āᵤ (α āᵤ β) where
toEquiv := e.arrowCongr (.refl _)
uniformContinuous_toFun := UniformFun.precomp_uniformContinuous
uniformContinuous_invFun := UniformFun.precomp_uniformContinuous
/-- The natural map `UniformFun.toFun` from `α āᵤ β` to `α ā β` is uniformly continuous.
In other words, the uniform structure of uniform convergence is finer than that of pointwise
convergence, aka the product uniform structure. -/
protected theorem uniformContinuous_toFun : UniformContinuous (toFun : (α āᵤ β) ā α ā β) := by
-- By definition of the product uniform structure, this is just `uniform_continuous_eval`.
rw [uniformContinuous_pi]
intro x
exact uniformContinuous_eval β x
/-- The topology of uniform convergence is Tā. -/
instance [T2Space β] : T2Space (α āᵤ β) :=
.of_injective_continuous toFun.injective UniformFun.uniformContinuous_toFun.continuous
/-- The topology of uniform convergence indeed gives the same notion of convergence as
`TendstoUniformly`. -/
protected theorem tendsto_iff_tendstoUniformly {F : ι ā α āᵤ β} {f : α āᵤ β} :
Tendsto F p (š f) ā TendstoUniformly (toFun ā F) (toFun f) p := by
rw [(UniformFun.hasBasis_nhds α β f).tendsto_right_iff, TendstoUniformly]
simp only [mem_setOf, UniformFun.gen, Function.comp_def]
/-- The natural bijection between `α ā β à γ` and `(α ā β) Ć (α ā γ)`, upgraded to a uniform
isomorphism between `α āᵤ β à γ` and `(α āᵤ β) Ć (α āᵤ γ)`. -/
protected def uniformEquivProdArrow [UniformSpace γ] : (α āᵤ β à γ) āᵤ (α āᵤ β) Ć (α āᵤ γ) :=
-- Denote `Ļ` this bijection. We want to show that
-- `comap Ļ (š°(α, β, uβ) Ć š°(α, γ, uγ)) = š°(α, β à γ, uβ Ć uγ)`.
-- But `uβ Ć uγ` is defined as `comap fst uβ ā comap snd uγ`, so we just have to apply
-- `UniformFun.inf_eq` and `UniformFun.comap_eq`, which leaves us to check
-- that some square commutes.
Equiv.toUniformEquivOfUniformInducing (Equiv.arrowProdEquivProdArrow _ _ _) <| by
constructor
change
comap (Prod.map (Equiv.arrowProdEquivProdArrow _ _ _) (Equiv.arrowProdEquivProdArrow _ _ _))
_ = _
simp_rw [UniformFun]
rw [ā uniformity_comap]
congr
unfold instUniformSpaceProd
rw [UniformSpace.comap_inf, ā UniformSpace.comap_comap, ā UniformSpace.comap_comap]
have := (@UniformFun.inf_eq α (β à γ)
(UniformSpace.comap Prod.fst ā¹_āŗ) (UniformSpace.comap Prod.snd ā¹_āŗ)).symm
rwa [UniformFun.comap_eq, UniformFun.comap_eq] at this
-- the relevant diagram commutes by definition
variable (α) (Ī“ : ι ā Type*) [ā i, UniformSpace (Ī“ i)]
/-- The natural bijection between `α ā Ī i, Ī“ i` and `Ī i, α ā Ī“ i`, upgraded to a uniform
isomorphism between `α āᵤ (Ī i, Ī“ i)` and `Ī i, α āᵤ Ī“ i`. -/
protected def uniformEquivPiComm : UniformEquiv (α āᵤ ā i, Ī“ i) (ā i, α āᵤ Ī“ i) :=
-- Denote `Ļ` this bijection. We want to show that
-- `comap Ļ (Ī i, š°(α, Ī“ i, uĪ“ i)) = š°(α, (Ī i, Ī“ i), (Ī i, uĪ“ i))`.
-- But `Ī i, uĪ“ i` is defined as `āØ
i, comap (eval i) (uΓ i)`, so we just have to apply
-- `UniformFun.iInf_eq` and `UniformFun.comap_eq`, which leaves us to check
-- that some square commutes.
@Equiv.toUniformEquivOfUniformInducing
_ _ š°(α, ā i, Ī“ i, Pi.uniformSpace Ī“)
(@Pi.uniformSpace ι (fun i => α ā Ī“ i) fun i => š°(α, Ī“ i, _)) (Equiv.piComm _) <| by
refine @UniformInducing.mk ?_ ?_ ?_ ?_ ?_ ?_
change comap (Prod.map Function.swap Function.swap) _ = _
rw [ā uniformity_comap]
congr
unfold Pi.uniformSpace
rw [UniformSpace.ofCoreEq_toCore, UniformSpace.ofCoreEq_toCore,
UniformSpace.comap_iInf, UniformFun.iInf_eq]
refine iInf_congr fun i => ?_
rw [ā UniformSpace.comap_comap, UniformFun.comap_eq]
rfl
-- Like in the previous lemma, the diagram actually commutes by definition
/-- The set of continuous functions is closed in the uniform convergence topology.
This is a simple wrapper over `TendstoUniformly.continuous`. -/
theorem isClosed_setOf_continuous [TopologicalSpace α] :
IsClosed {f : α āᵤ β | Continuous (toFun f)} := by
refine isClosed_iff_forall_filter.2 fun f u _ hu huf ⦠?_
rw [ā tendsto_id', UniformFun.tendsto_iff_tendstoUniformly] at huf
exact huf.continuous (le_principal_iff.mp hu)
variable {α} (β) in
theorem uniformSpace_eq_inf_precomp_of_cover {Ī“ā Ī“ā : Type*} (Ļā : Ī“ā ā α) (Ļā : Ī“ā ā α)
(h_cover : range Ļā āŖ range Ļā = univ) :
š°(α, β, _) =
.comap (ofFun ā (Ā· ā Ļā) ā toFun) š°(Ī“ā, β, _) ā
.comap (ofFun ā (Ā· ā Ļā) ā toFun) š°(Ī“ā, β, _) := by
ext : 1
refine le_antisymm (le_inf ?_ ?_) ?_
Ā· exact tendsto_iff_comap.mp UniformFun.precomp_uniformContinuous
Ā· exact tendsto_iff_comap.mp UniformFun.precomp_uniformContinuous
Ā· refine
(UniformFun.hasBasis_uniformity Ī“ā β |>.comap _).inf
(UniformFun.hasBasis_uniformity Ī“ā β |>.comap _)
|>.le_basis_iff (UniformFun.hasBasis_uniformity α β) |>.mpr fun U hU ā¦
āØāØU, Uā©, āØhU, hUā©, fun āØf, gā© hfg x ⦠?_ā©
rcases h_cover.ge <| mem_univ x with (āØy, rflā©|āØy, rflā©)
Ā· exact hfg.1 y
Ā· exact hfg.2 y
variable {α} (β) in
theorem uniformSpace_eq_iInf_precomp_of_cover {Ī“ : ι ā Type*} (Ļ : Ī i, Ī“ i ā α)
(h_cover : ā I : Set ι, I.Finite ā§ ā i ā I, range (Ļ i) = univ) :
š°(α, β, _) = āØ
i, .comap (ofFun ā (Ā· ā Ļ i) ā toFun) š°(Ī“ i, β, _) := by
ext : 1
simp_rw [iInf_uniformity, uniformity_comap]
refine le_antisymm (le_iInf fun i ⦠tendsto_iff_comap.mp UniformFun.precomp_uniformContinuous) ?_
rcases h_cover with āØI, I_finite, I_coverā©
refine Filter.hasBasis_iInf (fun i : ι ⦠UniformFun.hasBasis_uniformity (Γ i) β |>.comap _)
|>.le_basis_iff (UniformFun.hasBasis_uniformity α β) |>.mpr fun U hU ā¦
āØāØI, fun _ ⦠Uā©, āØI_finite, fun _ ⦠hUā©, fun āØf, gā© hfg x ⦠?_ā©
rcases mem_iUnionā.mp <| I_cover.ge <| mem_univ x with āØi, hi, y, rflā©
exact mem_iInter.mp hfg āØi, hiā© y
end UniformFun
namespace UniformOnFun
variable {α β : Type*} {γ ι : Type*}
variable {s s' : Set α} {x : α} {p : Filter ι} {g : ι ā α}
local notation "š°(" α ", " β ", " u ")" => @UniformFun.uniformSpace α β u
/-- Basis sets for the uniformity of `š`-convergence: for `S : Set α` and `V : Set (β à β)`,
`gen š S V` is the set of pairs `(f, g)` of functions `α āᵤ[š] β` such that
`ā x ā S, (f x, g x) ā V`. Note that the family `š : Set (Set α)` is only used to specify which
type alias of `α ā β` to use here. -/
protected def gen (š) (S : Set α) (V : Set (β à β)) : Set ((α āᵤ[š] β) Ć (α āᵤ[š] β)) :=
{ uv : (α āᵤ[š] β) Ć (α āᵤ[š] β) | ā x ā S, (toFun š uv.1 x, toFun š uv.2 x) ā V }
/-- For `S : Set α` and `V : Set (β à β)`, we have
`UniformOnFun.gen š S V = (S.restrict Ć S.restrict) ā»Ā¹' (UniformFun.gen S β V)`.
This is the crucial fact for proving that the family `UniformOnFun.gen S V` for `S ā š` and
`V ā š¤ β` is indeed a basis for the uniformity `α āᵤ[š] β` endowed with `š±(α, β, š, uβ)`
the uniform structure of `š`-convergence, as defined in `UniformOnFun.uniformSpace`. -/
protected theorem gen_eq_preimage_restrict {š} (S : Set α) (V : Set (β à β)) :
UniformOnFun.gen š S V =
Prod.map (S.restrict ā UniformFun.toFun) (S.restrict ā UniformFun.toFun) ā»Ā¹'
UniformFun.gen S β V := by
ext uv
exact āØfun h āØx, hxā© => h x hx, fun h x hx => h āØx, hxā©ā©
/-- `UniformOnFun.gen` is antitone in the first argument and monotone in the second. -/
protected theorem gen_mono {š} {S S' : Set α} {V V' : Set (β à β)} (hS : S' ā S) (hV : V ā V') :
UniformOnFun.gen š S V ā UniformOnFun.gen š S' V' := fun _uv h x hx => hV (h x <| hS hx)
/-- If `š : Set (Set α)` is nonempty and directed and `š` is a filter basis on `β à β`, then the
family `UniformOnFun.gen š S V` for `S ā š` and `V ā š` is a filter basis on
`(α āᵤ[š] β) Ć (α āᵤ[š] β)`.
We will show in `has_basis_uniformity_of_basis` that, if `š` is a basis for `š¤ β`, then the
corresponding filter is the uniformity of `α āᵤ[š] β`. -/
protected theorem isBasis_gen (š : Set (Set α)) (h : š.Nonempty) (h' : DirectedOn (Ā· ā Ā·) š)
(š : FilterBasis <| β à β) :
IsBasis (fun SV : Set α Ć Set (β à β) => SV.1 ā š ā§ SV.2 ā š) fun SV =>
UniformOnFun.gen š SV.1 SV.2 :=
āØh.prod š.nonempty, fun {UāVā UāVā} hā hā =>
let āØUā, hUā, hUāā, hUāāā© := h' UāVā.1 hā.1 UāVā.1 hā.1
let āØVā, hVā, hVāāāā© := š.inter_sets hā.2 hā.2
āØāØUā, Vāā©,
āØāØhUā, hVāā©, fun _ H =>
āØfun x hx => (hVāāā <| H x <| hUāā hx).1, fun x hx => (hVāāā <| H x <| hUāā hx).2ā©ā©ā©ā©
variable (α β) [UniformSpace β] (š : Set (Set α))
/-- Uniform structure of `š`-convergence, i.e uniform convergence on the elements of `š`,
declared as an instance on `α āᵤ[š] β`. It is defined as the infimum, for `S ā š`, of the pullback
by `S.restrict`, the map of restriction to `S`, of the uniform structure `š°(s, β, uβ)` on
`ā„S āᵤ β`. We will denote it `š±(α, β, š, uβ)`, where `uβ` is the uniform structure on `β`. -/
instance uniformSpace : UniformSpace (α āᵤ[š] β) :=
āØ
(s : Set α) (_ : s ā š),
.comap (UniformFun.ofFun ā s.restrict ā UniformOnFun.toFun š) š°(s, β, _)
local notation "š±(" α ", " β ", " š ", " u ")" => @UniformOnFun.uniformSpace α β u š
/-- Topology of `š`-convergence, i.e uniform convergence on the elements of `š`, declared as an
instance on `α āᵤ[š] β`. -/
instance topologicalSpace : TopologicalSpace (α āᵤ[š] β) :=
š±(α, β, š, _).toTopologicalSpace
/-- The topology of `š`-convergence is the infimum, for `S ā š`, of topology induced by the map
of `S.restrict : (α āᵤ[š] β) ā (ā„S āᵤ β)` of restriction to `S`, where `ā„S āᵤ β` is endowed with
the topology of uniform convergence. -/
protected theorem topologicalSpace_eq :
UniformOnFun.topologicalSpace α β š =
āØ
(s : Set α) (_ : s ā š), TopologicalSpace.induced
(UniformFun.ofFun ā s.restrict ā toFun š) (UniformFun.topologicalSpace s β) := by
simp only [UniformOnFun.topologicalSpace, UniformSpace.toTopologicalSpace_iInf]
rfl
protected theorem hasBasis_uniformity_of_basis_auxā {p : ι ā Prop} {s : ι ā Set (β à β)}
(hb : HasBasis (š¤ β) p s) (S : Set α) :
(@uniformity (α āᵤ[š] β) ((UniformFun.uniformSpace S β).comap S.restrict)).HasBasis p fun i =>
UniformOnFun.gen š S (s i) := by
simp_rw [UniformOnFun.gen_eq_preimage_restrict, uniformity_comap]
exact (UniformFun.hasBasis_uniformity_of_basis S β hb).comap _
protected theorem hasBasis_uniformity_of_basis_auxā (h : DirectedOn (Ā· ā Ā·) š) {p : ι ā Prop}
{s : ι ā Set (β à β)} (hb : HasBasis (š¤ β) p s) :
DirectedOn
((fun s : Set α => (UniformFun.uniformSpace s β).comap (s.restrict : (α āᵤ β) ā s āᵤ β)) ā»Ā¹'o
GE.ge)
š :=
h.mono fun _ _ hst =>
((UniformOnFun.hasBasis_uniformity_of_basis_auxā α β š hb _).le_basis_iff
(UniformOnFun.hasBasis_uniformity_of_basis_auxā α β š hb _)).mpr
fun V hV => āØV, hV, UniformOnFun.gen_mono hst subset_rflā©
/-- If `š : Set (Set α)` is nonempty and directed and `š` is a filter basis of `š¤ β`, then the
uniformity of `α āᵤ[š] β` admits the family `{(f, g) | ā x ā S, (f x, g x) ā V}` for `S ā š` and
`V ā š` as a filter basis. -/
protected theorem hasBasis_uniformity_of_basis (h : š.Nonempty) (h' : DirectedOn (Ā· ā Ā·) š)
{p : ι ā Prop} {s : ι ā Set (β à β)} (hb : HasBasis (š¤ β) p s) :
(š¤ (α āᵤ[š] β)).HasBasis (fun Si : Set α à ι => Si.1 ā š ā§ p Si.2) fun Si =>
UniformOnFun.gen š Si.1 (s Si.2) := by
simp only [iInf_uniformity]
exact
hasBasis_biInf_of_directed h (fun S => UniformOnFun.gen š S ā s) _
(fun S _hS => UniformOnFun.hasBasis_uniformity_of_basis_auxā α β š hb S)
(UniformOnFun.hasBasis_uniformity_of_basis_auxā α β š h' hb)
/-- If `š : Set (Set α)` is nonempty and directed, then the uniformity of `α āᵤ[š] β` admits the
family `{(f, g) | ā x ā S, (f x, g x) ā V}` for `S ā š` and `V ā š¤ β` as a filter basis. -/
protected theorem hasBasis_uniformity (h : š.Nonempty) (h' : DirectedOn (Ā· ā Ā·) š) :
(š¤ (α āᵤ[š] β)).HasBasis (fun SV : Set α Ć Set (β à β) => SV.1 ā š ā§ SV.2 ā š¤ β) fun SV =>
UniformOnFun.gen š SV.1 SV.2 :=
UniformOnFun.hasBasis_uniformity_of_basis α β š h h' (š¤ β).basis_sets
variable {α β}
/-- Let `t i` be a nonempty directed subfamily of `š`
such that every `s ā š` is included in some `t i`.
Let `V` bounded by `p` be a basis of entourages of `β`.
Then `UniformOnFun.gen š (t i) (V j)` bounded by `p j` is a basis of entourages of `α āᵤ[š] β`. -/
protected theorem hasBasis_uniformity_of_covering_of_basis {ι ι' : Type*} [Nonempty ι]
{t : ι ā Set α} {p : ι' ā Prop} {V : ι' ā Set (β à β)} (ht : ā i, t i ā š)
(hdir : Directed (Ā· ā Ā·) t) (hex : ā s ā š, ā i, s ā t i) (hb : HasBasis (š¤ β) p V) :
(š¤ (α āᵤ[š] β)).HasBasis (fun i : ι à ι' ⦠p i.2) fun i ā¦
UniformOnFun.gen š (t i.1) (V i.2) := by
have hne : š.Nonempty := (range_nonempty t).mono (range_subset_iff.2 ht)
have hd : DirectedOn (Ā· ā Ā·) š := fun sā hsā sā hsā ⦠by
rcases hex sā hsā, hex sā hsā with āØāØiā, hisāā©, iā, hisāā©
rcases hdir iā iā with āØi, hiā, hiāā©
exact āØt i, ht _, hisā.trans hiā, hisā.trans hiāā©
refine (UniformOnFun.hasBasis_uniformity_of_basis α β š hne hd hb).to_hasBasis
(fun āØs, i'ā© āØhs, hi'⩠⦠?_) fun āØi, i'ā© hi' ⦠āØ(t i, i'), āØht i, hi'ā©, Subset.rflā©
rcases hex s hs with āØi, hiā©
exact āØ(i, i'), hi', UniformOnFun.gen_mono hi Subset.rflā©
/-- If `t n` is a monotone sequence of sets in `š`
such that each `s ā š` is included in some `t n`
and `V n` is an antitone basis of entourages of `β`,
then `UniformOnFun.gen š (t n) (V n)` is an antitone basis of entourages of `α āᵤ[š] β`. -/
protected theorem hasAntitoneBasis_uniformity {ι : Type*} [Preorder ι] [IsDirected ι (· ⤠·)]
{t : ι ā Set α} {V : ι ā Set (β à β)}
(ht : ā n, t n ā š) (hmono : Monotone t) (hex : ā s ā š, ā n, s ā t n)
(hb : HasAntitoneBasis (š¤ β) V) :
(š¤ (α āᵤ[š] β)).HasAntitoneBasis fun n ⦠UniformOnFun.gen š (t n) (V n) := by
have := hb.nonempty
refine āØ(UniformOnFun.hasBasis_uniformity_of_covering_of_basis š
ht hmono.directed_le hex hb.1).to_hasBasis ?_ fun i _ ⦠āØ(i, i), trivial, Subset.rflā©, ?_ā©
Ā· rintro āØk, lā© -
rcases directed_of (Ā· ⤠·) k l with āØn, hkn, hlnā©
exact āØn, trivial, UniformOnFun.gen_mono (hmono hkn) (hb.2 <| hln)ā©
· exact fun k l h ⦠UniformOnFun.gen_mono (hmono h) (hb.2 h)
protected theorem isCountablyGenerated_uniformity [IsCountablyGenerated (š¤ β)] {t : ā ā Set α}
(ht : ā n, t n ā š) (hmono : Monotone t) (hex : ā s ā š, ā n, s ā t n) :
IsCountablyGenerated (š¤ (α āᵤ[š] β)) :=
let āØ_V, hVā© := exists_antitone_basis (š¤ β)
(UniformOnFun.hasAntitoneBasis_uniformity š ht hmono hex hV).isCountablyGenerated
variable (α β)
/-- For `f : α āᵤ[š] β`, where `š : Set (Set α)` is nonempty and directed, `š f` admits the
family `{g | ā x ā S, (f x, g x) ā V}` for `S ā š` and `V ā š` as a filter basis, for any basis
`š` of `š¤ β`. -/
protected theorem hasBasis_nhds_of_basis (f : α āᵤ[š] β) (h : š.Nonempty)
(h' : DirectedOn (Ā· ā Ā·) š) {p : ι ā Prop} {s : ι ā Set (β à β)} (hb : HasBasis (š¤ β) p s) :
(š f).HasBasis (fun Si : Set α à ι => Si.1 ā š ā§ p Si.2) fun Si =>
{ g | (g, f) ā UniformOnFun.gen š Si.1 (s Si.2) } :=
letI : UniformSpace (α ā β) := UniformOnFun.uniformSpace α β š
nhds_basis_uniformity (UniformOnFun.hasBasis_uniformity_of_basis α β š h h' hb)
/-- For `f : α āᵤ[š] β`, where `š : Set (Set α)` is nonempty and directed, `š f` admits the
family `{g | ā x ā S, (f x, g x) ā V}` for `S ā š` and `V ā š¤ β` as a filter basis. -/
protected theorem hasBasis_nhds (f : α āᵤ[š] β) (h : š.Nonempty) (h' : DirectedOn (Ā· ā Ā·) š) :
(š f).HasBasis (fun SV : Set α Ć Set (β à β) => SV.1 ā š ā§ SV.2 ā š¤ β) fun SV =>
{ g | (g, f) ā UniformOnFun.gen š SV.1 SV.2 } :=
UniformOnFun.hasBasis_nhds_of_basis α β š f h h' (Filter.basis_sets _)
/-- If `S ā š`, then the restriction to `S` is a uniformly continuous map from `α āᵤ[š] β` to
`ā„S āᵤ β`. -/
protected theorem uniformContinuous_restrict (h : s ā š) :
UniformContinuous (UniformFun.ofFun ā (s.restrict : (α ā β) ā s ā β) ā toFun š) := by
change _ ⤠_
simp only [UniformOnFun.uniformSpace, map_le_iff_le_comap, iInf_uniformity]
exact iInfā_le s h
variable {α}
/-- A version of `UniformOnFun.hasBasis_uniformity_of_basis`
with weaker conclusion and weaker assumptions.
We make no assumptions about the set `š`
but conclude only that the uniformity is equal to some indexed infimum. -/
protected theorem uniformity_eq_of_basis {ι : Sort*} {p : ι ā Prop} {V : ι ā Set (β à β)}
(h : (š¤ β).HasBasis p V) :
š¤ (α āᵤ[š] β) = āØ
s ā š, āØ
(i) (_ : p i), š (UniformOnFun.gen š s (V i)) := by
simp_rw [iInf_uniformity, uniformity_comap,
(UniformFun.hasBasis_uniformity_of_basis _ _ h).eq_biInf, comap_iInf, comap_principal,
Function.comp_apply, UniformFun.gen, Subtype.forall, UniformOnFun.gen, preimage_setOf_eq,
Prod.map_fst, Prod.map_snd, Function.comp_apply, UniformFun.toFun_ofFun, restrict_apply]
protected theorem uniformity_eq : š¤ (α āᵤ[š] β) = āØ
s ā š, āØ
V ā š¤ β, š (UniformOnFun.gen š s V) :=
UniformOnFun.uniformity_eq_of_basis _ _ (š¤ β).basis_sets
protected theorem gen_mem_uniformity (hs : s ā š) {V : Set (β à β)} (hV : V ā š¤ β) :
UniformOnFun.gen š s V ā š¤ (α āᵤ[š] β) := by
rw [UniformOnFun.uniformity_eq]
apply_rules [mem_iInf_of_mem, mem_principal_self]
/-- A version of `UniformOnFun.hasBasis_nhds_of_basis`
with weaker conclusion and weaker assumptions.
We make no assumptions about the set `š`
but conclude only that the neighbourhoods filter is equal to some indexed infimum. -/
protected theorem nhds_eq_of_basis {ι : Sort*} {p : ι ā Prop} {V : ι ā Set (β à β)}
(h : (š¤ β).HasBasis p V) (f : α āᵤ[š] β) :
š f = āØ
s ā š, āØ
(i) (_ : p i), š {g | ā x ā s, (toFun š f x, toFun š g x) ā V i} := by
simp_rw [nhds_eq_comap_uniformity, UniformOnFun.uniformity_eq_of_basis _ _ h, comap_iInf,
comap_principal, UniformOnFun.gen, preimage_setOf_eq]
protected theorem nhds_eq (f : α āᵤ[š] β) :
š f = āØ
s ā š, āØ
V ā š¤ β, š {g | ā x ā s, (toFun š f x, toFun š g x) ā V} :=
UniformOnFun.nhds_eq_of_basis _ _ (š¤ β).basis_sets f
protected theorem gen_mem_nhds (f : α āᵤ[š] β) (hs : s ā š) {V : Set (β à β)} (hV : V ā š¤ β) :
{g | ā x ā s, (toFun š f x, toFun š g x) ā V} ā š f := by
rw [UniformOnFun.nhds_eq]
apply_rules [mem_iInf_of_mem, mem_principal_self]
theorem uniformContinuous_ofUniformFun :
UniformContinuous fun f : α āᵤ β ⦠ofFun š (UniformFun.toFun f) := by
simp only [UniformContinuous, UniformOnFun.uniformity_eq, tendsto_iInf, tendsto_principal,
(UniformFun.hasBasis_uniformity _ _).eventually_iff]
exact fun _ _ U hU ⦠āØU, hU, fun f hf x _ ⦠hf xā©
/-- The uniformity on `α āᵤ[š] β` is the same as the uniformity on `α āᵤ β`,
provided that `Set.univ ā š`.
Here we formulate it as a `UniformEquiv`. -/
def uniformEquivUniformFun (h : univ ā š) : (α āᵤ[š] β) āᵤ (α āᵤ β) where
toFun f := UniformFun.ofFun <| toFun _ f
invFun f := ofFun _ <| UniformFun.toFun f
left_inv _ := rfl
right_inv _ := rfl
uniformContinuous_toFun := by
simp only [UniformContinuous, (UniformFun.hasBasis_uniformity _ _).tendsto_right_iff]
intro U hU
filter_upwards [UniformOnFun.gen_mem_uniformity _ _ h hU] with f hf x using hf x (mem_univ _)
uniformContinuous_invFun := uniformContinuous_ofUniformFun _ _
/-- Let `uā`, `uā` be two uniform structures on `γ` and `šā šā : Set (Set α)`. If `uā ⤠uā` and
`šā ā šā` then `š±(α, γ, šā, uā) ⤠š±(α, γ, šā, uā)`. -/
protected theorem mono ā¦uā uā : UniformSpace γ⦠(hu : uā ⤠uā) ā¦šā šā : Set (Set α)ā¦
(hš : šā ā šā) : š±(α, γ, šā, uā) ⤠š±(α, γ, šā, uā) :=
calc
š±(α, γ, šā, uā) ⤠š±(α, γ, šā, uā) := iInf_le_iInf_of_subset hš
_ ⤠š±(α, γ, šā, uā) := iInfā_mono fun _i _hi => UniformSpace.comap_mono <| UniformFun.mono hu
/-- If `x : α` is in some `S ā š`, then evaluation at `x` is uniformly continuous on
`α āᵤ[š] β`. -/
theorem uniformContinuous_eval_of_mem {x : α} (hxs : x ā s) (hs : s ā š) :
UniformContinuous ((Function.eval x : (α ā β) ā β) ā toFun š) :=
(UniformFun.uniformContinuous_eval β (āØx, hxsā© : s)).comp
(UniformOnFun.uniformContinuous_restrict α β š hs)
theorem uniformContinuous_eval_of_mem_sUnion {x : α} (hx : x ā āā š) :
UniformContinuous ((Function.eval x : (α ā β) ā β) ā toFun š) :=
let āØ_s, hs, hxsā© := hx
uniformContinuous_eval_of_mem _ _ hxs hs
variable {β} {š}
theorem uniformContinuous_eval (h : āā š = univ) (x : α) :
UniformContinuous ((Function.eval x : (α ā β) ā β) ā toFun š) :=
uniformContinuous_eval_of_mem_sUnion _ _ <| h.symm āø mem_univ _
/-- If `u` is a family of uniform structures on `γ`, then
`š±(α, γ, š, (āØ
i, u i)) = āØ
i, š±(α, γ, š, u i)`. -/
protected theorem iInf_eq {u : ι ā UniformSpace γ} :
š±(α, γ, š, āØ
i, u i) = āØ
i, š±(α, γ, š, u i) := by
simp_rw [UniformOnFun.uniformSpace, UniformFun.iInf_eq, UniformSpace.comap_iInf]
rw [iInf_comm]
exact iInf_congr fun s => iInf_comm
/-- If `uā` and `uā` are two uniform structures on `γ`, then
`š±(α, γ, š, uā ā uā) = š±(α, γ, š, uā) ā š±(α, γ, š, uā)`. -/
protected theorem inf_eq {uā uā : UniformSpace γ} :
š±(α, γ, š, uā ā uā) = š±(α, γ, š, uā) ā š±(α, γ, š, uā) := by
rw [inf_eq_iInf, inf_eq_iInf, UniformOnFun.iInf_eq]
refine iInf_congr fun i => ?_
cases i <;> rfl
/-- If `u` is a uniform structure on `β` and `f : γ ā β`, then
`š±(α, γ, š, comap f u) = comap (fun g ⦠f ā g) š±(α, γ, š, uā)`. -/
protected theorem comap_eq {f : γ ā β} :
š±(α, γ, š, ā¹UniformSpace βāŗ.comap f) = š±(α, β, š, _).comap (f ā Ā·) := by
-- We reduce this to `UniformFun.comap_eq` using the fact that `comap` distributes
-- on `iInf`.
simp_rw [UniformOnFun.uniformSpace, UniformSpace.comap_iInf, UniformFun.comap_eq, ā
UniformSpace.comap_comap]
-- By definition, `ā S ā š, (f ā ā) ā S.restrict = S.restrict ā (f ā ā)`.
rfl
/-- Post-composition by a uniformly continuous function is uniformly continuous for the
uniform structures of `š`-convergence.
More precisely, if `f : γ ā β` is uniformly continuous, then
`(fun g ⦠f ā g) : (α āᵤ[š] γ) ā (α āᵤ[š] β)` is uniformly continuous. -/
protected theorem postcomp_uniformContinuous [UniformSpace γ] {f : γ ā β}
(hf : UniformContinuous f) : UniformContinuous (ofFun š ā (f ā Ā·) ā toFun š) := by
-- This is a direct consequence of `UniformOnFun.comap_eq`
rw [uniformContinuous_iff]
exact (UniformOnFun.mono (uniformContinuous_iff.mp hf) subset_rfl).trans_eq UniformOnFun.comap_eq
/-- Post-composition by a uniform inducing is a uniform inducing for the
uniform structures of `š`-convergence.
More precisely, if `f : γ ā β` is a uniform inducing, then
`(fun g ⦠f ā g) : (α āᵤ[š] γ) ā (α āᵤ[š] β)` is a uniform inducing. -/
protected theorem postcomp_uniformInducing [UniformSpace γ] {f : γ ā β} (hf : UniformInducing f) :
UniformInducing (ofFun š ā (f ā Ā·) ā toFun š) := by
-- This is a direct consequence of `UniformOnFun.comap_eq`
constructor
replace hf : (š¤ β).comap (Prod.map f f) = _ := hf.comap_uniformity
change comap (Prod.map (ofFun š ā (f ā Ā·) ā toFun š) (ofFun š ā (f ā Ā·) ā toFun š)) _ = _
rw [ā uniformity_comap] at hf ā¢
congr
rw [ā UniformSpace.ext hf, UniformOnFun.comap_eq]
rfl
/-- Post-composition by a uniform embedding is a uniform embedding for the
uniform structures of `š`-convergence.
More precisely, if `f : γ ā β` is a uniform embedding, then
`(fun g ⦠f ā g) : (α āᵤ[š] γ) ā (α āᵤ[š] β)` is a uniform embedding. -/
protected theorem postcomp_uniformEmbedding [UniformSpace γ] {f : γ ā β} (hf : UniformEmbedding f) :
UniformEmbedding (ofFun š ā (f ā Ā·) ā toFun š) where
toUniformInducing := UniformOnFun.postcomp_uniformInducing hf.toUniformInducing
inj _ _ H := funext fun _ ⦠hf.inj (congrFun H _)
/-- Turn a uniform isomorphism `γ āᵤ β` into a uniform isomorphism `(α āᵤ[š] γ) āᵤ (α āᵤ[š] β)`
by post-composing. -/
protected def congrRight [UniformSpace γ] (e : γ āᵤ β) : (α āᵤ[š] γ) āᵤ (α āᵤ[š] β) :=
{ Equiv.piCongrRight fun _a => e.toEquiv with
uniformContinuous_toFun := UniformOnFun.postcomp_uniformContinuous e.uniformContinuous
uniformContinuous_invFun := UniformOnFun.postcomp_uniformContinuous e.symm.uniformContinuous }
/-- Let `f : γ ā α`, `š : Set (Set α)`, `š : Set (Set γ)`, and assume that `ā T ā š, f '' T ā š`.
Then, the function `(fun g ⦠g ā f) : (α āᵤ[š] β) ā (γ āᵤ[š] β)` is uniformly continuous.
Note that one can easily see that assuming `ā T ā š, ā S ā š, f '' T ā S` would work too, but
we will get this for free when we prove that `š±(α, β, š, uβ) = š±(α, β, š', uβ)` where `š'` is the
***noncovering*** bornology generated by `š`. -/
protected theorem precomp_uniformContinuous {š : Set (Set γ)} {f : γ ā α}
(hf : MapsTo (f '' Ā·) š š) :
UniformContinuous fun g : α āᵤ[š] β => ofFun š (toFun š g ā f) := by
-- This follows from the fact that `(Ā· ā f) Ć (Ā· ā f)` maps `gen (f '' t) V` to `gen t V`.
simp_rw [UniformContinuous, UniformOnFun.uniformity_eq, tendsto_iInf]
refine fun t ht V hV ⦠tendsto_iInf' (f '' t) <| tendsto_iInf' (hf ht) <|
tendsto_iInf' V <| tendsto_iInf' hV ?_
simpa only [tendsto_principal_principal, UniformOnFun.gen] using fun _ ⦠forall_mem_image.1
/-- Turn a bijection `e : γ ā α` such that we have both `ā T ā š, e '' T ā š` and
`ā S ā š, e ā»Ā¹' S ā š` into a uniform isomorphism `(γ āᵤ[š] β) āᵤ (α āᵤ[š] β)` by pre-composing. -/
protected def congrLeft {š : Set (Set γ)} (e : γ ā α) (he : š ā image e ā»Ā¹' š)
(he' : š ā preimage e ā»Ā¹' š) : (γ āᵤ[š] β) āᵤ (α āᵤ[š] β) :=
{ Equiv.arrowCongr e (Equiv.refl _) with
uniformContinuous_toFun := UniformOnFun.precomp_uniformContinuous fun s hs ⦠by
change e.symm '' s ā š
rw [ā preimage_equiv_eq_image_symm]
exact he' hs
uniformContinuous_invFun := UniformOnFun.precomp_uniformContinuous he }
/-- If `š` covers `α`, then the topology of `š`-convergence is Tā. -/
theorem t2Space_of_covering [T2Space β] (h : āā š = univ) : T2Space (α āᵤ[š] β) where
t2 f g hfg := by
obtain āØx, hxā© := not_forall.mp (mt funext hfg)
obtain āØs, hs, hxsā© : ā s ā š, x ā s := mem_sUnion.mp (h.symm āø True.intro)
exact separated_by_continuous (uniformContinuous_eval_of_mem β š hxs hs).continuous hx
/-- The restriction map from `α āᵤ[š] β` to `āā š ā β` is uniformly continuous. -/
theorem uniformContinuous_restrict_toFun :
UniformContinuous ((āā š).restrict ā toFun š : (α āᵤ[š] β) ā āā š ā β) := by
rw [uniformContinuous_pi]
intro āØx, hxā©
obtain āØs : Set α, hs : s ā š, hxs : x ā sā© := mem_sUnion.mpr hx
exact uniformContinuous_eval_of_mem β š hxs hs
/-- If `š` covers `α`, the natural map `UniformOnFun.toFun` from `α āᵤ[š] β` to `α ā β` is
uniformly continuous.
In other words, if `š` covers `α`, then the uniform structure of `š`-convergence is finer than
that of pointwise convergence. -/
protected theorem uniformContinuous_toFun (h : āā š = univ) :
UniformContinuous (toFun š : (α āᵤ[š] β) ā α ā β) := by
rw [uniformContinuous_pi]
exact uniformContinuous_eval h
/-- If `f : α āᵤ[š] β` is continuous at `x` and `x` admits a neighbourhood `V ā š`,
then evaluation of `g : α āᵤ[š] β` at `y : α` is continuous in `(g, y)` at `(f, x)`. -/
protected theorem continuousAt_evalā [TopologicalSpace α] {f : α āᵤ[š] β} {x : α}
(hš : ā V ā š, V ā š x) (hc : ContinuousAt (toFun š f) x) :
ContinuousAt (fun fx : (α āᵤ[š] β) à α ⦠toFun š fx.1 fx.2) (f, x) := by
rw [ContinuousAt, nhds_eq_comap_uniformity, tendsto_comap_iff, ā lift'_comp_uniformity,
tendsto_lift']
intro U hU
rcases hš with āØV, hV, hVxā©
filter_upwards [prod_mem_nhds (UniformOnFun.gen_mem_nhds _ _ _ hV hU)
(inter_mem hVx <| hc <| UniformSpace.ball_mem_nhds _ hU)]
with āØg, yā© āØhg, hyV, hyā© using āØtoFun š f y, hy, hg y hyVā©
/-- If each point of `α` admits a neighbourhood `V ā š`,
then the evaluation of `f : α āᵤ[š] β` at `x : α` is continuous in `(f, x)`
on the set of `(f, x)` such that `f` is continuous at `x`. -/
protected theorem continuousOn_evalā [TopologicalSpace α] (hš : ā x, ā V ā š, V ā š x) :
ContinuousOn (fun fx : (α āᵤ[š] β) à α ⦠toFun š fx.1 fx.2)
{fx | ContinuousAt (toFun š fx.1) fx.2} := fun (_f, x) hc ā¦
(UniformOnFun.continuousAt_evalā (hš x) hc).continuousWithinAt
/-- Convergence in the topology of `š`-convergence means uniform convergence on `S` (in the sense
of `TendstoUniformlyOn`) for all `S ā š`. -/
protected theorem tendsto_iff_tendstoUniformlyOn {F : ι ā α āᵤ[š] β} {f : α āᵤ[š] β} :
Tendsto F p (š f) ā ā s ā š, TendstoUniformlyOn (toFun š ā F) (toFun š f) p s := by
simp only [UniformOnFun.nhds_eq, tendsto_iInf, tendsto_principal, TendstoUniformlyOn,
Function.comp_apply, mem_setOf]
protected lemma continuous_rng_iff {X : Type*} [TopologicalSpace X] {f : X ā (α āᵤ[š] β)} :
Continuous f ā ā s ā š,
Continuous (UniformFun.ofFun ā s.restrict ā UniformOnFun.toFun š ā f) := by
simp only [continuous_iff_continuousAt, ContinuousAt,
UniformOnFun.tendsto_iff_tendstoUniformlyOn, UniformFun.tendsto_iff_tendstoUniformly,
tendstoUniformlyOn_iff_tendstoUniformly_comp_coe, @forall_swap X, Function.comp_apply,
Function.comp_def, restrict_eq, UniformFun.toFun_ofFun]
instance [CompleteSpace β] : CompleteSpace (α āᵤ[š] β) := by
rcases isEmpty_or_nonempty β
Ā· infer_instance
Ā· refine āØfun {F} hF ⦠?_ā©
have := hF.1
have : ā x ā āā š, ā y : β, Tendsto (toFun š Ā· x) F (š y) := fun x hx ā¦
CompleteSpace.complete (hF.map (uniformContinuous_eval_of_mem_sUnion _ _ hx))
choose! g hg using this
use ofFun š g
simp_rw [UniformOnFun.nhds_eq_of_basis _ _ uniformity_hasBasis_closed, le_iInfā_iff,
le_principal_iff]
intro s hs U āØhU, hUcā©
rcases cauchy_iff.mp hF |>.2 _ <| UniformOnFun.gen_mem_uniformity _ _ hs hU
with āØV, hV, hVUā©
filter_upwards [hV] with f hf x hx
refine hUc.mem_of_tendsto ((hg x āØs, hs, hxā©).prod_mk_nhds tendsto_const_nhds) ?_
filter_upwards [hV] with g' hg' using hVU (mk_mem_prod hg' hf) _ hx
/-- The natural bijection between `α ā β à γ` and `(α ā β) Ć (α ā γ)`, upgraded to a uniform
isomorphism between `α āᵤ[š] β à γ` and `(α āᵤ[š] β) Ć (α āᵤ[š] γ)`. -/
protected def uniformEquivProdArrow [UniformSpace γ] :
(α āᵤ[š] β à γ) āᵤ (α āᵤ[š] β) Ć (α āᵤ[š] γ) :=
-- Denote `Ļ` this bijection. We want to show that
-- `comap Ļ (š±(α, β, š, uβ) Ć š±(α, γ, š, uγ)) = š±(α, β à γ, š, uβ Ć uγ)`.
-- But `uβ Ć uγ` is defined as `comap fst uβ ā comap snd uγ`, so we just have to apply
-- `UniformOnFun.inf_eq` and `UniformOnFun.comap_eq`,
-- which leaves us to check that some square commutes.
-- We could also deduce this from `UniformFun.uniformEquivProdArrow`,
-- but it turns out to be more annoying.
((UniformOnFun.ofFun š).symm.trans <|
(Equiv.arrowProdEquivProdArrow _ _ _).trans <|
(UniformOnFun.ofFun š).prodCongr (UniformOnFun.ofFun š)).toUniformEquivOfUniformInducing <| by
constructor
rw [uniformity_prod, comap_inf, comap_comap, comap_comap]
have H := @UniformOnFun.inf_eq α (β à γ) š
(UniformSpace.comap Prod.fst ā¹_āŗ) (UniformSpace.comap Prod.snd ā¹_āŗ)
apply_fun (fun u ⦠@uniformity (α āᵤ[š] β à γ) u) at H
convert H.symm using 1
rw [UniformOnFun.comap_eq, UniformOnFun.comap_eq]
erw [inf_uniformity]
rw [uniformity_comap, uniformity_comap]
rfl
-- the relevant diagram commutes by definition
variable (š) (Ī“ : ι ā Type*) [ā i, UniformSpace (Ī“ i)] in
/-- The natural bijection between `α ā Ī i, Ī“ i` and `Ī i, α ā Ī“ i`, upgraded to a uniform
isomorphism between `α āᵤ[š] (Ī i, Ī“ i)` and `Ī i, α āᵤ[š] Ī“ i`. -/
protected def uniformEquivPiComm : (α āᵤ[š] ((i : ι) ā Ī“ i)) āᵤ ((i : ι) ā α āᵤ[š] Ī“ i) :=
-- Denote `Ļ` this bijection. We want to show that
-- `comap Ļ (Ī i, š±(α, Ī“ i, š, uĪ“ i)) = š±(α, (Ī i, Ī“ i), š, (Ī i, uĪ“ i))`.
-- But `Ī i, uĪ“ i` is defined as `āØ
i, comap (eval i) (uΓ i)`, so we just have to apply
-- `UniformOnFun.iInf_eq` and `UniformOnFun.comap_eq`,
-- which leaves us to check that some square commutes.
-- We could also deduce this from `UniformFun.uniformEquivPiComm`, but it turns out
-- to be more annoying.
@Equiv.toUniformEquivOfUniformInducing (α āᵤ[š] ((i : ι) ā Ī“ i)) ((i : ι) ā α āᵤ[š] Ī“ i)
_ _ (Equiv.piComm _) <| by
constructor
change comap (Prod.map Function.swap Function.swap) _ = _
erw [ā uniformity_comap]
congr
rw [Pi.uniformSpace, UniformSpace.ofCoreEq_toCore, Pi.uniformSpace,
UniformSpace.ofCoreEq_toCore, UniformSpace.comap_iInf, UniformOnFun.iInf_eq]
refine iInf_congr fun i => ?_
rw [ā UniformSpace.comap_comap, UniformOnFun.comap_eq]
rfl
-- Like in the previous lemma, the diagram actually commutes by definition
/-- Suppose that the topology on `α` is defined by its restrictions to the sets of `š`.
Then the set of continuous functions is closed
in the topology of uniform convergence on the sets of `š`. -/
theorem isClosed_setOf_continuous [TopologicalSpace α] (h : RestrictGenTopology š) :
IsClosed {f : α āᵤ[š] β | Continuous (toFun š f)} := by
refine isClosed_iff_forall_filter.2 fun f u _ hu huf ⦠h.continuous_iff.2 fun s hs ⦠?_
rw [ā tendsto_id', UniformOnFun.tendsto_iff_tendstoUniformlyOn] at huf
exact (huf s hs).continuousOn <| hu fun _ ⦠Continuous.continuousOn
/-- Suppose that the topology on `α` is defined by its restrictions to the sets of `š`.
Then the set of continuous functions is closed
in the topology of uniform convergence on the sets of `š`. -/
@[deprecated isClosed_setOf_continuous (since := "2024-06-29")]
theorem isClosed_setOf_continuous_of_le [t : TopologicalSpace α]
(h : t ⤠⨠s ā š, .coinduced (Subtype.val : s ā α) inferInstance) :
IsClosed {f : α āᵤ[š] β | Continuous (toFun š f)} :=
isClosed_setOf_continuous āØfun u hu ⦠h _ <| by simpa only [isOpen_iSup_iff, isOpen_coinduced]ā©
variable (š) in
theorem uniformSpace_eq_inf_precomp_of_cover {Ī“ā Ī“ā : Type*} (Ļā : Ī“ā ā α) (Ļā : Ī“ā ā α)
(šā : Set (Set Ī“ā)) (šā : Set (Set Ī“ā))
(h_imageā : MapsTo (Ļā '' Ā·) šā š) (h_imageā : MapsTo (Ļā '' Ā·) šā š)
(h_preimageā : MapsTo (Ļā ā»Ā¹' Ā·) š šā) (h_preimageā : MapsTo (Ļā ā»Ā¹' Ā·) š šā)
(h_cover : ā S ā š, S ā range Ļā āŖ range Ļā) :
š±(α, β, š, _) =
.comap (ofFun šā ā (Ā· ā Ļā) ā toFun š) š±(Ī“ā, β, šā, _) ā
.comap (ofFun šā ā (Ā· ā Ļā) ā toFun š) š±(Ī“ā, β, šā, _) := by
set Ļā : Ī S : Set α, Ļā ā»Ā¹' S ā S := fun S ⦠S.restrictPreimage Ļā
set Ļā : Ī S : Set α, Ļā ā»Ā¹' S ā S := fun S ⦠S.restrictPreimage Ļā
have : ā S ā š, š°(S, β, _) = .comap (Ā· ā Ļā S) š°(_, β, _) ā .comap (Ā· ā Ļā S) š°(_, β, _) := by
refine fun S hS ⦠UniformFun.uniformSpace_eq_inf_precomp_of_cover β _ _ ?_
simpa only [ā univ_subset_iff, Ļā, Ļā, range_restrictPreimage, ā preimage_union,
ā image_subset_iff, image_univ, Subtype.range_val] using h_cover S hS
refine le_antisymm (le_inf ?_ ?_) (le_iInfā fun S hS ⦠?_)
Ā· rw [ā uniformContinuous_iff]
exact UniformOnFun.precomp_uniformContinuous h_imageā
Ā· rw [ā uniformContinuous_iff]
exact UniformOnFun.precomp_uniformContinuous h_imageā
Ā· simp_rw [this S hS, UniformSpace.comap_iInf, UniformSpace.comap_inf, ā UniformSpace.comap_comap]
exact inf_le_inf
(iInfā_le_of_le _ (h_preimageā hS) le_rfl)
(iInfā_le_of_le _ (h_preimageā hS) le_rfl)
variable (š) in
theorem uniformSpace_eq_iInf_precomp_of_cover {Ī“ : ι ā Type*} (Ļ : Ī i, Ī“ i ā α)
(š : ā i, Set (Set (Ī“ i))) (h_image : ā i, MapsTo (Ļ i '' Ā·) (š i) š)
(h_preimage : ā i, MapsTo (Ļ i ā»Ā¹' Ā·) š (š i))
(h_cover : ā S ā š, ā I : Set ι, I.Finite ā§ S ā ā i ā I, range (Ļ i)) :
š±(α, β, š, _) = āØ
i, .comap (ofFun (š i) ā (Ā· ā Ļ i) ā toFun š) š±(Ī“ i, β, š i, _) := by
set Ļ : Ī S : Set α, Ī i : ι, (Ļ i) ā»Ā¹' S ā S := fun S i ⦠S.restrictPreimage (Ļ i)
have : ā S ā š, š°(S, β, _) = āØ
i, .comap (Ā· ā Ļ S i) š°(_, β, _) := fun S hS ⦠by
rcases h_cover S hS with āØI, I_finite, I_coverā©
refine UniformFun.uniformSpace_eq_iInf_precomp_of_cover β _ āØI, I_finite, ?_ā©
simpa only [ā univ_subset_iff, Ļ, range_restrictPreimage, ā preimage_iUnionā,
ā image_subset_iff, image_univ, Subtype.range_val] using I_cover
-- With a better theory of ideals we may be able to simplify the following by replacing `š i`
-- by `(Ļ i ā»Ā¹' Ā·) '' š`.
refine le_antisymm (le_iInf fun i ⦠?_) (le_iInfā fun S hS ⦠?_)
Ā· rw [ā uniformContinuous_iff]
exact UniformOnFun.precomp_uniformContinuous (h_image i)
Ā· simp_rw [this S hS, UniformSpace.comap_iInf, ā UniformSpace.comap_comap]
exact iInf_mono fun i ⦠iInfā_le_of_le _ (h_preimage i hS) le_rfl
end UniformOnFun
namespace UniformFun
instance {α β : Type*} [UniformSpace β] [CompleteSpace β] : CompleteSpace (α āᵤ β) :=
(UniformOnFun.uniformEquivUniformFun β {univ} (mem_singleton _)).completeSpace_iff.1 inferInstance
end UniformFun
|
Topology\UniformSpace\UniformEmbedding.lean
|
/-
Copyright (c) 2017 Johannes Hƶlzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hƶlzl, SƩbastien Gouƫzel, Patrick Massot
-/
import Mathlib.Topology.UniformSpace.Cauchy
import Mathlib.Topology.UniformSpace.Separation
import Mathlib.Topology.DenseEmbedding
/-!
# Uniform embeddings of uniform spaces.
Extension of uniform continuous functions.
-/
open Filter Function Set Uniformity Topology
section
universe u v w
variable {α : Type u} {β : Type v} {γ : Type w} [UniformSpace α] [UniformSpace β] [UniformSpace γ]
/-!
### Uniform inducing maps
-/
/-- A map `f : α ā β` between uniform spaces is called *uniform inducing* if the uniformity filter
on `α` is the pullback of the uniformity filter on `β` under `Prod.map f f`. If `α` is a separated
space, then this implies that `f` is injective, hence it is a `UniformEmbedding`. -/
@[mk_iff]
structure UniformInducing (f : α ā β) : Prop where
/-- The uniformity filter on the domain is the pullback of the uniformity filter on the codomain
under `Prod.map f f`. -/
comap_uniformity : comap (fun x : α à α => (f x.1, f x.2)) (š¤ β) = š¤ α
lemma uniformInducing_iff_uniformSpace {f : α ā β} :
UniformInducing f ā ā¹UniformSpace βāŗ.comap f = ā¹UniformSpace α⺠:= by
rw [uniformInducing_iff, UniformSpace.ext_iff, Filter.ext_iff]
rfl
protected alias āØUniformInducing.comap_uniformSpace, _ā© := uniformInducing_iff_uniformSpace
lemma uniformInducing_iff' {f : α ā β} :
UniformInducing f ā UniformContinuous f ā§ comap (Prod.map f f) (š¤ β) ⤠š¤ α := by
rw [uniformInducing_iff, UniformContinuous, tendsto_iff_comap, le_antisymm_iff, and_comm]; rfl
protected lemma Filter.HasBasis.uniformInducing_iff {ι ι'} {p : ι ā Prop} {p' : ι' ā Prop} {s s'}
(h : (š¤ α).HasBasis p s) (h' : (š¤ β).HasBasis p' s') {f : α ā β} :
UniformInducing f ā
(ā i, p' i ā ā j, p j ā§ ā x y, (x, y) ā s j ā (f x, f y) ā s' i) ā§
(ā j, p j ā ā i, p' i ā§ ā x y, (f x, f y) ā s' i ā (x, y) ā s j) := by
simp [uniformInducing_iff', h.uniformContinuous_iff h', (h'.comap _).le_basis_iff h, subset_def]
theorem UniformInducing.mk' {f : α ā β}
(h : ā s, s ā š¤ α ā ā t ā š¤ β, ā x y : α, (f x, f y) ā t ā (x, y) ā s) : UniformInducing f :=
āØby simp [eq_comm, Filter.ext_iff, subset_def, h]ā©
theorem uniformInducing_id : UniformInducing (@id α) :=
āØby rw [ā Prod.map_def, Prod.map_id, comap_id]ā©
theorem UniformInducing.comp {g : β ā γ} (hg : UniformInducing g) {f : α ā β}
(hf : UniformInducing f) : UniformInducing (g ā f) :=
āØby rw [ā hf.1, ā hg.1, comap_comap]; rflā©
theorem UniformInducing.of_comp_iff {g : β ā γ} (hg : UniformInducing g) {f : α ā β} :
UniformInducing (g ā f) ā UniformInducing f := by
refine āØfun h ⦠?_, hg.compā©
rw [uniformInducing_iff, ā hg.comap_uniformity, comap_comap, ā h.comap_uniformity,
Function.comp, Function.comp]
theorem UniformInducing.basis_uniformity {f : α ā β} (hf : UniformInducing f) {ι : Sort*}
{p : ι ā Prop} {s : ι ā Set (β à β)} (H : (š¤ β).HasBasis p s) :
(š¤ α).HasBasis p fun i => Prod.map f f ā»Ā¹' s i :=
hf.1 āø H.comap _
theorem UniformInducing.cauchy_map_iff {f : α ā β} (hf : UniformInducing f) {F : Filter α} :
Cauchy (map f F) ā Cauchy F := by
simp only [Cauchy, map_neBot_iff, prod_map_map_eq, map_le_iff_le_comap, ā hf.comap_uniformity]
theorem uniformInducing_of_compose {f : α ā β} {g : β ā γ} (hf : UniformContinuous f)
(hg : UniformContinuous g) (hgf : UniformInducing (g ā f)) : UniformInducing f := by
refine āØle_antisymm ?_ hf.le_comapā©
rw [ā hgf.1, ā Prod.map_def, ā Prod.map_def, ā Prod.map_comp_map f f g g, ā comap_comap]
exact comap_mono hg.le_comap
theorem UniformInducing.uniformContinuous {f : α ā β} (hf : UniformInducing f) :
UniformContinuous f := (uniformInducing_iff'.1 hf).1
theorem UniformInducing.uniformContinuous_iff {f : α ā β} {g : β ā γ} (hg : UniformInducing g) :
UniformContinuous f ā UniformContinuous (g ā f) := by
dsimp only [UniformContinuous, Tendsto]
simp only [ā hg.comap_uniformity, ā map_le_iff_le_comap, Filter.map_map, Function.comp_def]
protected theorem UniformInducing.uniformInducing_comp_iff {f : α ā β} {g : β ā γ}
(hg : UniformInducing g) : UniformInducing (g ā f) ā UniformInducing f := by
simp only [uniformInducing_iff, ā hg.comap_uniformity, comap_comap, Function.comp_def]
theorem UniformInducing.uniformContinuousOn_iff {f : α ā β} {g : β ā γ} {S : Set α}
(hg : UniformInducing g) :
UniformContinuousOn f S ā UniformContinuousOn (g ā f) S := by
dsimp only [UniformContinuousOn, Tendsto]
rw [ā hg.comap_uniformity, ā map_le_iff_le_comap, Filter.map_map, comp_def, comp_def]
theorem UniformInducing.inducing {f : α ā β} (h : UniformInducing f) : Inducing f := by
obtain rfl := h.comap_uniformSpace
exact inducing_induced f
theorem UniformInducing.prod {α' : Type*} {β' : Type*} [UniformSpace α'] [UniformSpace β']
{eā : α ā α'} {eā : β ā β'} (hā : UniformInducing eā) (hā : UniformInducing eā) :
UniformInducing fun p : α à β => (eā p.1, eā p.2) :=
āØby simp [(Ā· ā Ā·), uniformity_prod, ā hā.1, ā hā.1, comap_inf, comap_comap]ā©
theorem UniformInducing.denseInducing {f : α ā β} (h : UniformInducing f) (hd : DenseRange f) :
DenseInducing f :=
{ dense := hd
induced := h.inducing.induced }
theorem SeparationQuotient.uniformInducing_mk : UniformInducing (mk : α ā SeparationQuotient α) :=
āØcomap_mk_uniformityā©
protected theorem UniformInducing.injective [T0Space α] {f : α ā β} (h : UniformInducing f) :
Injective f :=
h.inducing.injective
/-!
### Uniform embeddings
-/
/-- A map `f : α ā β` between uniform spaces is a *uniform embedding* if it is uniform inducing and
injective. If `α` is a separated space, then the latter assumption follows from the former. -/
@[mk_iff]
structure UniformEmbedding (f : α ā β) extends UniformInducing f : Prop where
/-- A uniform embedding is injective. -/
inj : Function.Injective f
theorem uniformEmbedding_iff' {f : α ā β} :
UniformEmbedding f ā Injective f ā§ UniformContinuous f ā§ comap (Prod.map f f) (š¤ β) ⤠š¤ α := by
rw [uniformEmbedding_iff, and_comm, uniformInducing_iff']
theorem Filter.HasBasis.uniformEmbedding_iff' {ι ι'} {p : ι ā Prop} {p' : ι' ā Prop} {s s'}
(h : (š¤ α).HasBasis p s) (h' : (š¤ β).HasBasis p' s') {f : α ā β} :
UniformEmbedding f ā Injective f ā§
(ā i, p' i ā ā j, p j ā§ ā x y, (x, y) ā s j ā (f x, f y) ā s' i) ā§
(ā j, p j ā ā i, p' i ā§ ā x y, (f x, f y) ā s' i ā (x, y) ā s j) := by
rw [uniformEmbedding_iff, and_comm, h.uniformInducing_iff h']
theorem Filter.HasBasis.uniformEmbedding_iff {ι ι'} {p : ι ā Prop} {p' : ι' ā Prop} {s s'}
(h : (š¤ α).HasBasis p s) (h' : (š¤ β).HasBasis p' s') {f : α ā β} :
UniformEmbedding f ā Injective f ā§ UniformContinuous f ā§
(ā j, p j ā ā i, p' i ā§ ā x y, (f x, f y) ā s' i ā (x, y) ā s j) := by
simp only [h.uniformEmbedding_iff' h', h.uniformContinuous_iff h']
theorem uniformEmbedding_subtype_val {p : α ā Prop} :
UniformEmbedding (Subtype.val : Subtype p ā α) :=
{ comap_uniformity := rfl
inj := Subtype.val_injective }
theorem uniformEmbedding_set_inclusion {s t : Set α} (hst : s ā t) :
UniformEmbedding (inclusion hst) where
comap_uniformity := by rw [uniformity_subtype, uniformity_subtype, comap_comap]; rfl
inj := inclusion_injective hst
theorem UniformEmbedding.comp {g : β ā γ} (hg : UniformEmbedding g) {f : α ā β}
(hf : UniformEmbedding f) : UniformEmbedding (g ā f) :=
{ hg.toUniformInducing.comp hf.toUniformInducing with inj := hg.inj.comp hf.inj }
theorem UniformEmbedding.of_comp_iff {g : β ā γ} (hg : UniformEmbedding g) {f : α ā β} :
UniformEmbedding (g ā f) ā UniformEmbedding f := by
simp_rw [uniformEmbedding_iff, hg.toUniformInducing.of_comp_iff, hg.inj.of_comp_iff f]
theorem Equiv.uniformEmbedding {α β : Type*} [UniformSpace α] [UniformSpace β] (f : α ā β)
(hā : UniformContinuous f) (hā : UniformContinuous f.symm) : UniformEmbedding f :=
uniformEmbedding_iff'.2 āØf.injective, hā, by rwa [ā Equiv.prodCongr_apply, ā map_equiv_symm]ā©
theorem uniformEmbedding_inl : UniformEmbedding (Sum.inl : α ā α ā β) :=
uniformEmbedding_iff'.2 āØSum.inl_injective, uniformContinuous_inl, fun s hs =>
āØProd.map Sum.inl Sum.inl '' s āŖ range (Prod.map Sum.inr Sum.inr),
union_mem_sup (image_mem_map hs) range_mem_map,
fun x h => by simpa [Prod.map_apply'] using hā©ā©
theorem uniformEmbedding_inr : UniformEmbedding (Sum.inr : β ā α ā β) :=
uniformEmbedding_iff'.2 āØSum.inr_injective, uniformContinuous_inr, fun s hs =>
āØrange (Prod.map Sum.inl Sum.inl) āŖ Prod.map Sum.inr Sum.inr '' s,
union_mem_sup range_mem_map (image_mem_map hs),
fun x h => by simpa [Prod.map_apply'] using hā©ā©
/-- If the domain of a `UniformInducing` map `f` is a Tā space, then `f` is injective,
hence it is a `UniformEmbedding`. -/
protected theorem UniformInducing.uniformEmbedding [T0Space α] {f : α ā β}
(hf : UniformInducing f) : UniformEmbedding f :=
āØhf, hf.inducing.injectiveā©
theorem uniformEmbedding_iff_uniformInducing [T0Space α] {f : α ā β} :
UniformEmbedding f ā UniformInducing f :=
āØUniformEmbedding.toUniformInducing, UniformInducing.uniformEmbeddingā©
/-- If a map `f : α ā β` sends any two distinct points to point that are **not** related by a fixed
`s ā š¤ β`, then `f` is uniform inducing with respect to the discrete uniformity on `α`:
the preimage of `š¤ β` under `Prod.map f f` is the principal filter generated by the diagonal in
`α à α`. -/
theorem comap_uniformity_of_spaced_out {α} {f : α ā β} {s : Set (β à β)} (hs : s ā š¤ β)
(hf : Pairwise fun x y => (f x, f y) ā s) : comap (Prod.map f f) (š¤ β) = š idRel := by
refine le_antisymm ?_ (@refl_le_uniformity α (UniformSpace.comap f _))
calc
comap (Prod.map f f) (š¤ β) ⤠comap (Prod.map f f) (š s) := comap_mono (le_principal_iff.2 hs)
_ = š (Prod.map f f ā»Ā¹' s) := comap_principal
_ ⤠š idRel := principal_mono.2 ?_
rintro āØx, yā©; simpa [not_imp_not] using @hf x y
/-- If a map `f : α ā β` sends any two distinct points to point that are **not** related by a fixed
`s ā š¤ β`, then `f` is a uniform embedding with respect to the discrete uniformity on `α`. -/
theorem uniformEmbedding_of_spaced_out {α} {f : α ā β} {s : Set (β à β)} (hs : s ā š¤ β)
(hf : Pairwise fun x y => (f x, f y) ā s) : @UniformEmbedding α β ā„ ā¹_āŗ f := by
let _ : UniformSpace α := ā„; have := discreteTopology_bot α
exact UniformInducing.uniformEmbedding āØcomap_uniformity_of_spaced_out hs hfā©
protected theorem UniformEmbedding.embedding {f : α ā β} (h : UniformEmbedding f) : Embedding f :=
{ toInducing := h.toUniformInducing.inducing
inj := h.inj }
theorem UniformEmbedding.denseEmbedding {f : α ā β} (h : UniformEmbedding f) (hd : DenseRange f) :
DenseEmbedding f :=
{ h.embedding with dense := hd }
theorem closedEmbedding_of_spaced_out {α} [TopologicalSpace α] [DiscreteTopology α]
[T0Space β] {f : α ā β} {s : Set (β à β)} (hs : s ā š¤ β)
(hf : Pairwise fun x y => (f x, f y) ā s) : ClosedEmbedding f := by
rcases @DiscreteTopology.eq_bot α _ _ with rfl; let _ : UniformSpace α := ā„
exact
{ (uniformEmbedding_of_spaced_out hs hf).embedding with
isClosed_range := isClosed_range_of_spaced_out hs hf }
theorem closure_image_mem_nhds_of_uniformInducing {s : Set (α à α)} {e : α ā β} (b : β)
(heā : UniformInducing e) (heā : DenseInducing e) (hs : s ā š¤ α) :
ā a, closure (e '' { a' | (a, a') ā s }) ā š b := by
obtain āØU, āØhU, hUo, hsymmā©, hsā© :
ā U, (U ā š¤ β ā§ IsOpen U ā§ SymmetricRel U) ā§ Prod.map e e ā»Ā¹' U ā s := by
rwa [ā heā.comap_uniformity, (uniformity_hasBasis_open_symmetric.comap _).mem_iff] at hs
rcases heā.dense.mem_nhds (UniformSpace.ball_mem_nhds b hU) with āØa, haā©
refine āØa, mem_of_superset ?_ (closure_mono <| image_subset _ <| ball_mono hs a)ā©
have ho : IsOpen (UniformSpace.ball (e a) U) := UniformSpace.isOpen_ball (e a) hUo
refine mem_of_superset (ho.mem_nhds <| (mem_ball_symmetry hsymm).2 ha) fun y hy => ?_
refine mem_closure_iff_nhds.2 fun V hV => ?_
rcases heā.dense.mem_nhds (inter_mem hV (ho.mem_nhds hy)) with āØx, hxV, hxUā©
exact āØe x, hxV, mem_image_of_mem e hxUā©
theorem uniformEmbedding_subtypeEmb (p : α ā Prop) {e : α ā β} (ue : UniformEmbedding e)
(de : DenseEmbedding e) : UniformEmbedding (DenseEmbedding.subtypeEmb p e) :=
{ comap_uniformity := by
simp [comap_comap, (Ā· ā Ā·), DenseEmbedding.subtypeEmb, uniformity_subtype,
ue.comap_uniformity.symm]
inj := (de.subtype p).inj }
theorem UniformEmbedding.prod {α' : Type*} {β' : Type*} [UniformSpace α'] [UniformSpace β']
{eā : α ā α'} {eā : β ā β'} (hā : UniformEmbedding eā) (hā : UniformEmbedding eā) :
UniformEmbedding fun p : α à β => (eā p.1, eā p.2) :=
{ hā.toUniformInducing.prod hā.toUniformInducing with inj := hā.inj.prodMap hā.inj }
/-- A set is complete iff its image under a uniform inducing map is complete. -/
theorem isComplete_image_iff {m : α ā β} {s : Set α} (hm : UniformInducing m) :
IsComplete (m '' s) ā IsComplete s := by
have fact1 : SurjOn (map m) (Iic <| š s) (Iic <| š <| m '' s) := surjOn_image .. |>.filter_map_Iic
have fact2 : MapsTo (map m) (Iic <| š s) (Iic <| š <| m '' s) := mapsTo_image .. |>.filter_map_Iic
simp_rw [IsComplete, imp.swap (a := Cauchy _), ā mem_Iic (b := š _), fact1.forall fact2,
hm.cauchy_map_iff, exists_mem_image, map_le_iff_le_comap, hm.inducing.nhds_eq_comap]
alias āØisComplete_of_complete_image, _ā© := isComplete_image_iff
theorem completeSpace_iff_isComplete_range {f : α ā β} (hf : UniformInducing f) :
CompleteSpace α ā IsComplete (range f) := by
rw [completeSpace_iff_isComplete_univ, ā isComplete_image_iff hf, image_univ]
theorem UniformInducing.isComplete_range [CompleteSpace α] {f : α ā β} (hf : UniformInducing f) :
IsComplete (range f) :=
(completeSpace_iff_isComplete_range hf).1 ā¹_āŗ
theorem SeparationQuotient.completeSpace_iff :
CompleteSpace (SeparationQuotient α) ā CompleteSpace α := by
rw [completeSpace_iff_isComplete_univ, ā range_mk,
ā completeSpace_iff_isComplete_range uniformInducing_mk]
instance SeparationQuotient.instCompleteSpace [CompleteSpace α] :
CompleteSpace (SeparationQuotient α) :=
completeSpace_iff.2 ā¹_āŗ
theorem completeSpace_congr {e : α ā β} (he : UniformEmbedding e) :
CompleteSpace α ā CompleteSpace β := by
rw [completeSpace_iff_isComplete_range he.toUniformInducing, e.range_eq_univ,
completeSpace_iff_isComplete_univ]
theorem completeSpace_coe_iff_isComplete {s : Set α} : CompleteSpace s ā IsComplete s :=
(completeSpace_iff_isComplete_range uniformEmbedding_subtype_val.toUniformInducing).trans <| by
rw [Subtype.range_coe]
alias āØ_, IsComplete.completeSpace_coeā© := completeSpace_coe_iff_isComplete
theorem IsClosed.completeSpace_coe [CompleteSpace α] {s : Set α} (hs : IsClosed s) :
CompleteSpace s :=
hs.isComplete.completeSpace_coe
/-- The lift of a complete space to another universe is still complete. -/
instance ULift.completeSpace [h : CompleteSpace α] : CompleteSpace (ULift α) :=
haveI : UniformEmbedding (@Equiv.ulift α) := āØāØrflā©, ULift.down_injectiveā©
(completeSpace_congr this).2 h
theorem completeSpace_extension {m : β ā α} (hm : UniformInducing m) (dense : DenseRange m)
(h : ā f : Filter β, Cauchy f ā ā x : α, map m f ⤠š x) : CompleteSpace α :=
āØfun {f : Filter α} (hf : Cauchy f) =>
let p : Set (α à α) ā Set α ā Set α := fun s t => { y : α | ā x : α, x ā t ā§ (x, y) ā s }
let g := (š¤ α).lift fun s => f.lift' (p s)
have mpā : Monotone p := fun a b h t s āØx, xs, xaā© => āØx, xs, h xaā©
have mpā : ā {s}, Monotone (p s) := fun h x āØy, ya, yxsā© => āØy, h ya, yxsā©
have : f ⤠g := le_iInfā fun s hs => le_iInfā fun t ht =>
le_principal_iff.mpr <| mem_of_superset ht fun x hx => āØx, hx, refl_mem_uniformity hsā©
have : NeBot g := hf.left.mono this
have : NeBot (comap m g) :=
comap_neBot fun t ht =>
let āØt', ht', ht_memā© := (mem_lift_sets <| monotone_lift' monotone_const mpā).mp ht
let āØt'', ht'', ht'_subā© := (mem_lift'_sets mpā).mp ht_mem
let āØx, (hx : x ā t'')ā© := hf.left.nonempty_of_mem ht''
have hā : NeBot (š[range m] x) := dense.nhdsWithin_neBot x
have hā : { y | (x, y) ā t' } ā š[range m] x :=
@mem_inf_of_left α (š x) (š (range m)) _ <| mem_nhds_left x ht'
have hā : range m ā š[range m] x :=
@mem_inf_of_right α (š x) (š (range m)) _ <| Subset.refl _
have : { y | (x, y) ā t' } ā© range m ā š[range m] x := @inter_mem α (š[range m] x) _ _ hā hā
let āØy, xyt', b, b_eqā© := hā.nonempty_of_mem this
āØb, b_eq.symm āø ht'_sub āØx, hx, xyt'ā©ā©
have : Cauchy g :=
āØā¹NeBot gāŗ, fun s hs =>
let āØsā, hsā, (comp_sā : compRel sā sā ā s)ā© := comp_mem_uniformity_sets hs
let āØsā, hsā, (comp_sā : compRel sā sā ā sā)ā© := comp_mem_uniformity_sets hsā
let āØt, ht, (prod_t : t ĆĖ¢ t ā sā)ā© := mem_prod_same_iff.mp (hf.right hsā)
have hgā : p (preimage Prod.swap sā) t ā g :=
mem_lift (symm_le_uniformity hsā) <| @mem_lift' α α f _ t ht
have hgā : p sā t ā g := mem_lift hsā <| @mem_lift' α α f _ t ht
have hg : p (Prod.swap ā»Ā¹' sā) t ĆĖ¢ p sā t ā g ĆĖ¢ g := @prod_mem_prod α α _ _ g g hgā hgā
(g ĆĖ¢ g).sets_of_superset hg fun āØa, bā© āØāØcā, cāt, hcāā©, āØcā, cāt, hcāā©ā© =>
have : (cā, cā) ā t ĆĖ¢ t := āØcāt, cātā©
comp_sā <| prod_mk_mem_compRel hcā <| comp_sā <| prod_mk_mem_compRel (prod_t this) hcāā©
have : Cauchy (Filter.comap m g) := ā¹Cauchy gāŗ.comap' (le_of_eq hm.comap_uniformity) ā¹_āŗ
let āØx, (hx : map m (Filter.comap m g) ⤠š x)ā© := h _ this
have : ClusterPt x (map m (Filter.comap m g)) :=
(le_nhds_iff_adhp_of_cauchy (this.map hm.uniformContinuous)).mp hx
have : ClusterPt x g := this.mono map_comap_le
āØx,
calc
f ⤠g := by assumption
_ ⤠š x := le_nhds_of_cauchy_adhp ā¹Cauchy gāŗ this
ā©ā©
lemma totallyBounded_image_iff {f : α ā β} {s : Set α} (hf : UniformInducing f) :
TotallyBounded (f '' s) ā TotallyBounded s := by
refine āØfun hs ⦠?_, fun h ⦠h.image hf.uniformContinuousā©
simp_rw [(hf.basis_uniformity (basis_sets _)).totallyBounded_iff]
intro t ht
rcases exists_subset_image_finite_and.1 (hs.exists_subset ht) with āØu, -, hfin, hā©
use u, hfin
rwa [biUnion_image, image_subset_iff, preimage_iUnionā] at h
theorem totallyBounded_preimage {f : α ā β} {s : Set β} (hf : UniformInducing f)
(hs : TotallyBounded s) : TotallyBounded (f ā»Ā¹' s) :=
(totallyBounded_image_iff hf).1 <| hs.subset <| image_preimage_subset ..
instance CompleteSpace.sum [CompleteSpace α] [CompleteSpace β] : CompleteSpace (α ā β) := by
rw [completeSpace_iff_isComplete_univ, ā range_inl_union_range_inr]
exact uniformEmbedding_inl.toUniformInducing.isComplete_range.union
uniformEmbedding_inr.toUniformInducing.isComplete_range
end
theorem uniformEmbedding_comap {α : Type*} {β : Type*} {f : α ā β} [u : UniformSpace β]
(hf : Function.Injective f) : @UniformEmbedding α β (UniformSpace.comap f u) u f :=
@UniformEmbedding.mk _ _ (UniformSpace.comap f u) _ _
(@UniformInducing.mk _ _ (UniformSpace.comap f u) _ _ rfl) hf
/-- Pull back a uniform space structure by an embedding, adjusting the new uniform structure to
make sure that its topology is defeq to the original one. -/
def Embedding.comapUniformSpace {α β} [TopologicalSpace α] [u : UniformSpace β] (f : α ā β)
(h : Embedding f) : UniformSpace α :=
(u.comap f).replaceTopology h.induced
theorem Embedding.to_uniformEmbedding {α β} [TopologicalSpace α] [u : UniformSpace β] (f : α ā β)
(h : Embedding f) : @UniformEmbedding α β (h.comapUniformSpace f) u f :=
let _ := h.comapUniformSpace f
{ comap_uniformity := rfl
inj := h.inj }
section UniformExtension
variable {α : Type*} {β : Type*} {γ : Type*} [UniformSpace α] [UniformSpace β] [UniformSpace γ]
{e : β ā α} (h_e : UniformInducing e) (h_dense : DenseRange e) {f : β ā γ}
(h_f : UniformContinuous f)
local notation "Ļ" => DenseInducing.extend (UniformInducing.denseInducing h_e h_dense) f
theorem uniformly_extend_exists [CompleteSpace γ] (a : α) : ā c, Tendsto f (comap e (š a)) (š c) :=
let de := h_e.denseInducing h_dense
have : Cauchy (š a) := cauchy_nhds
have : Cauchy (comap e (š a)) :=
this.comap' (le_of_eq h_e.comap_uniformity) (de.comap_nhds_neBot _)
have : Cauchy (map f (comap e (š a))) := this.map h_f
CompleteSpace.complete this
theorem uniform_extend_subtype [CompleteSpace γ] {p : α ā Prop} {e : α ā β} {f : α ā γ} {b : β}
{s : Set α} (hf : UniformContinuous fun x : Subtype p => f x.val) (he : UniformEmbedding e)
(hd : ā x : β, x ā closure (range e)) (hb : closure (e '' s) ā š b) (hs : IsClosed s)
(hp : ā x ā s, p x) : ā c, Tendsto f (comap e (š b)) (š c) := by
have de : DenseEmbedding e := he.denseEmbedding hd
have de' : DenseEmbedding (DenseEmbedding.subtypeEmb p e) := de.subtype p
have ue' : UniformEmbedding (DenseEmbedding.subtypeEmb p e) := uniformEmbedding_subtypeEmb _ he de
have : b ā closure (e '' { x | p x }) :=
(closure_mono <| monotone_image <| hp) (mem_of_mem_nhds hb)
let āØc, hcā© := uniformly_extend_exists ue'.toUniformInducing de'.dense hf āØb, thisā©
replace hc : Tendsto (f ā Subtype.val (p := p)) (((š b).comap e).comap Subtype.val) (š c) := by
simpa only [nhds_subtype_eq_comap, comap_comap, DenseEmbedding.subtypeEmb_coe] using hc
refine āØc, (tendsto_comap'_iff ?_).1 hcā©
rw [Subtype.range_coe_subtype]
exact āØ_, hb, by rwa [ā de.toInducing.closure_eq_preimage_closure_image, hs.closure_eq]ā©
theorem uniformly_extend_spec [CompleteSpace γ] (a : α) : Tendsto f (comap e (š a)) (š (Ļ a)) := by
simpa only [DenseInducing.extend] using
tendsto_nhds_limUnder (uniformly_extend_exists h_e ā¹_āŗ h_f _)
theorem uniformContinuous_uniformly_extend [CompleteSpace γ] : UniformContinuous Ļ := fun d hd =>
let āØs, hs, hs_compā© := comp3_mem_uniformity hd
have h_pnt : ā {a m}, m ā š a ā ā c ā f '' (e ā»Ā¹' m), (c, Ļ a) ā s ā§ (Ļ a, c) ā s :=
fun {a m} hm =>
have nb : NeBot (map f (comap e (š a))) :=
((h_e.denseInducing h_dense).comap_nhds_neBot _).map _
have :
f '' (e ā»Ā¹' m) ā© ({ c | (c, Ļ a) ā s } ā© { c | (Ļ a, c) ā s }) ā map f (comap e (š a)) :=
inter_mem (image_mem_map <| preimage_mem_comap <| hm)
(uniformly_extend_spec h_e h_dense h_f _
(inter_mem (mem_nhds_right _ hs) (mem_nhds_left _ hs)))
nb.nonempty_of_mem this
have : (Prod.map f f) ā»Ā¹' s ā š¤ β := h_f hs
have : (Prod.map f f) ā»Ā¹' s ā comap (Prod.map e e) (š¤ α) := by
rwa [ā h_e.comap_uniformity] at this
let āØt, ht, tsā© := this
show (Prod.map Ļ Ļ) ā»Ā¹' d ā š¤ α from
mem_of_superset (interior_mem_uniformity ht) fun āØxā, xāā© hx_t => by
have : interior t ā š (xā, xā) := isOpen_interior.mem_nhds hx_t
let āØmā, hmā, mā, hmā, (hm : mā ĆĖ¢ mā ā interior t)ā© := mem_nhds_prod_iff.mp this
obtain āØ_, āØa, haā, rflā©, _, haāā© := h_pnt hmā
obtain āØ_, āØb, hbā, rflā©, hbā, _ā© := h_pnt hmā
have : Prod.map f f (a, b) ā s :=
ts <| mem_preimage.2 <| interior_subset (@hm (e a, e b) āØhaā, hbāā©)
exact hs_comp āØf a, haā, āØf b, this, hbāā©ā©
variable [T0Space γ]
theorem uniformly_extend_of_ind (b : β) : Ļ (e b) = f b :=
DenseInducing.extend_eq_at _ h_f.continuous.continuousAt
theorem uniformly_extend_unique {g : α ā γ} (hg : ā b, g (e b) = f b) (hc : Continuous g) : Ļ = g :=
DenseInducing.extend_unique _ hg hc
end UniformExtension
|
Topology\VectorBundle\Basic.lean
|
/-
Copyright (c) 2020 Nicolò Cavalleri. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Nicolò Cavalleri, Sebastien Gouezel, Heather Macbeth, Patrick Massot, Floris van Doorn
-/
import Mathlib.Analysis.Normed.Operator.BoundedLinearMaps
import Mathlib.Topology.FiberBundle.Basic
/-!
# Vector bundles
In this file we define (topological) vector bundles.
Let `B` be the base space, let `F` be a normed space over a normed field `R`, and let
`E : B ā Type*` be a `FiberBundle` with fiber `F`, in which, for each `x`, the fiber `E x` is a
topological vector space over `R`.
To have a vector bundle structure on `Bundle.TotalSpace F E`, one should additionally have the
following properties:
* The bundle trivializations in the trivialization atlas should be continuous linear equivs in the
fibers;
* For any two trivializations `e`, `e'` in the atlas the transition function considered as a map
from `B` into `F āL[R] F` is continuous on `e.baseSet ā© e'.baseSet` with respect to the operator
norm topology on `F āL[R] F`.
If these conditions are satisfied, we register the typeclass `VectorBundle R F E`.
We define constructions on vector bundles like pullbacks and direct sums in other files.
## Main Definitions
* `Trivialization.IsLinear`: a class stating that a trivialization is fiberwise linear on its base
set.
* `Trivialization.linearEquivAt` and `Trivialization.continuousLinearMapAt` are the
(continuous) linear fiberwise equivalences a trivialization induces.
* They have forward maps `Trivialization.linearMapAt` / `Trivialization.continuousLinearMapAt`
and inverses `Trivialization.symmā` / `Trivialization.symmL`. Note that these are all defined
everywhere, since they are extended using the zero function.
* `Trivialization.coordChangeL` is the coordinate change induced by two trivializations. It only
makes sense on the intersection of their base sets, but is extended outside it using the identity.
* Given a continuous (semi)linear map between `E x` and `E' y` where `E` and `E'` are bundles over
possibly different base sets, `ContinuousLinearMap.inCoordinates` turns this into a continuous
(semi)linear map between the chosen fibers of those bundles.
## Implementation notes
The implementation choices in the vector bundle definition are discussed in the "Implementation
notes" section of `Mathlib.Topology.FiberBundle.Basic`.
## Tags
Vector bundle
-/
noncomputable section
open scoped Classical
open Bundle Set
open scoped Topology
variable (R : Type*) {B : Type*} (F : Type*) (E : B ā Type*)
section TopologicalVectorSpace
variable {F E}
variable [Semiring R] [TopologicalSpace F] [TopologicalSpace B]
/-- A mixin class for `Pretrivialization`, stating that a pretrivialization is fiberwise linear with
respect to given module structures on its fibers and the model fiber. -/
protected class Pretrivialization.IsLinear [AddCommMonoid F] [Module R F] [ā x, AddCommMonoid (E x)]
[ā x, Module R (E x)] (e : Pretrivialization F (Ļ F E)) : Prop where
linear : ā b ā e.baseSet, IsLinearMap R fun x : E b => (e āØb, xā©).2
namespace Pretrivialization
variable (e : Pretrivialization F (Ļ F E)) {x : TotalSpace F E} {b : B} {y : E b}
theorem linear [AddCommMonoid F] [Module R F] [ā x, AddCommMonoid (E x)] [ā x, Module R (E x)]
[e.IsLinear R] {b : B} (hb : b ā e.baseSet) :
IsLinearMap R fun x : E b => (e āØb, xā©).2 :=
Pretrivialization.IsLinear.linear b hb
variable [AddCommMonoid F] [Module R F] [ā x, AddCommMonoid (E x)] [ā x, Module R (E x)]
/-- A fiberwise linear inverse to `e`. -/
@[simps!]
protected def symmā (e : Pretrivialization F (Ļ F E)) [e.IsLinear R] (b : B) : F āā[R] E b := by
refine IsLinearMap.mk' (e.symm b) ?_
by_cases hb : b ā e.baseSet
Ā· exact (((e.linear R hb).mk' _).inverse (e.symm b) (e.symm_apply_apply_mk hb) fun v ā¦
congr_arg Prod.snd <| e.apply_mk_symm hb v).isLinear
Ā· rw [e.coe_symm_of_not_mem hb]
exact (0 : F āā[R] E b).isLinear
/-- A pretrivialization for a vector bundle defines linear equivalences between the
fibers and the model space. -/
@[simps (config := .asFn)]
def linearEquivAt (e : Pretrivialization F (Ļ F E)) [e.IsLinear R] (b : B) (hb : b ā e.baseSet) :
E b āā[R] F where
toFun y := (e āØb, yā©).2
invFun := e.symm b
left_inv := e.symm_apply_apply_mk hb
right_inv v := by simp_rw [e.apply_mk_symm hb v]
map_add' v w := (e.linear R hb).map_add v w
map_smul' c v := (e.linear R hb).map_smul c v
/-- A fiberwise linear map equal to `e` on `e.baseSet`. -/
protected def linearMapAt (e : Pretrivialization F (Ļ F E)) [e.IsLinear R] (b : B) : E b āā[R] F :=
if hb : b ā e.baseSet then e.linearEquivAt R b hb else 0
variable {R}
theorem coe_linearMapAt (e : Pretrivialization F (Ļ F E)) [e.IsLinear R] (b : B) :
ā(e.linearMapAt R b) = fun y => if b ā e.baseSet then (e āØb, yā©).2 else 0 := by
rw [Pretrivialization.linearMapAt]
split_ifs <;> rfl
theorem coe_linearMapAt_of_mem (e : Pretrivialization F (Ļ F E)) [e.IsLinear R] {b : B}
(hb : b ā e.baseSet) : ā(e.linearMapAt R b) = fun y => (e āØb, yā©).2 := by
simp_rw [coe_linearMapAt, if_pos hb]
theorem linearMapAt_apply (e : Pretrivialization F (Ļ F E)) [e.IsLinear R] {b : B} (y : E b) :
e.linearMapAt R b y = if b ā e.baseSet then (e āØb, yā©).2 else 0 := by
rw [coe_linearMapAt]
theorem linearMapAt_def_of_mem (e : Pretrivialization F (Ļ F E)) [e.IsLinear R] {b : B}
(hb : b ā e.baseSet) : e.linearMapAt R b = e.linearEquivAt R b hb :=
dif_pos hb
theorem linearMapAt_def_of_not_mem (e : Pretrivialization F (Ļ F E)) [e.IsLinear R] {b : B}
(hb : b ā e.baseSet) : e.linearMapAt R b = 0 :=
dif_neg hb
theorem linearMapAt_eq_zero (e : Pretrivialization F (Ļ F E)) [e.IsLinear R] {b : B}
(hb : b ā e.baseSet) : e.linearMapAt R b = 0 :=
dif_neg hb
theorem symmā_linearMapAt (e : Pretrivialization F (Ļ F E)) [e.IsLinear R] {b : B}
(hb : b ā e.baseSet) (y : E b) : e.symmā R b (e.linearMapAt R b y) = y := by
rw [e.linearMapAt_def_of_mem hb]
exact (e.linearEquivAt R b hb).left_inv y
theorem linearMapAt_symmā (e : Pretrivialization F (Ļ F E)) [e.IsLinear R] {b : B}
(hb : b ā e.baseSet) (y : F) : e.linearMapAt R b (e.symmā R b y) = y := by
rw [e.linearMapAt_def_of_mem hb]
exact (e.linearEquivAt R b hb).right_inv y
end Pretrivialization
variable [TopologicalSpace (TotalSpace F E)]
/-- A mixin class for `Trivialization`, stating that a trivialization is fiberwise linear with
respect to given module structures on its fibers and the model fiber. -/
protected class Trivialization.IsLinear [AddCommMonoid F] [Module R F] [ā x, AddCommMonoid (E x)]
[ā x, Module R (E x)] (e : Trivialization F (Ļ F E)) : Prop where
linear : ā b ā e.baseSet, IsLinearMap R fun x : E b => (e āØb, xā©).2
namespace Trivialization
variable (e : Trivialization F (Ļ F E)) {x : TotalSpace F E} {b : B} {y : E b}
protected theorem linear [AddCommMonoid F] [Module R F] [ā x, AddCommMonoid (E x)]
[ā x, Module R (E x)] [e.IsLinear R] {b : B} (hb : b ā e.baseSet) :
IsLinearMap R fun y : E b => (e āØb, yā©).2 :=
Trivialization.IsLinear.linear b hb
instance toPretrivialization.isLinear [AddCommMonoid F] [Module R F] [ā x, AddCommMonoid (E x)]
[ā x, Module R (E x)] [e.IsLinear R] : e.toPretrivialization.IsLinear R :=
{ (ā¹_āŗ : e.IsLinear R) with }
variable [AddCommMonoid F] [Module R F] [ā x, AddCommMonoid (E x)] [ā x, Module R (E x)]
/-- A trivialization for a vector bundle defines linear equivalences between the
fibers and the model space. -/
def linearEquivAt (e : Trivialization F (Ļ F E)) [e.IsLinear R] (b : B) (hb : b ā e.baseSet) :
E b āā[R] F :=
e.toPretrivialization.linearEquivAt R b hb
variable {R}
@[simp]
theorem linearEquivAt_apply (e : Trivialization F (Ļ F E)) [e.IsLinear R] (b : B)
(hb : b ā e.baseSet) (v : E b) : e.linearEquivAt R b hb v = (e āØb, vā©).2 :=
rfl
@[simp]
theorem linearEquivAt_symm_apply (e : Trivialization F (Ļ F E)) [e.IsLinear R] (b : B)
(hb : b ā e.baseSet) (v : F) : (e.linearEquivAt R b hb).symm v = e.symm b v :=
rfl
variable (R)
/-- A fiberwise linear inverse to `e`. -/
protected def symmā (e : Trivialization F (Ļ F E)) [e.IsLinear R] (b : B) : F āā[R] E b :=
e.toPretrivialization.symmā R b
variable {R}
theorem coe_symmā (e : Trivialization F (Ļ F E)) [e.IsLinear R] (b : B) :
ā(e.symmā R b) = e.symm b :=
rfl
variable (R)
/-- A fiberwise linear map equal to `e` on `e.baseSet`. -/
protected def linearMapAt (e : Trivialization F (Ļ F E)) [e.IsLinear R] (b : B) : E b āā[R] F :=
e.toPretrivialization.linearMapAt R b
variable {R}
theorem coe_linearMapAt (e : Trivialization F (Ļ F E)) [e.IsLinear R] (b : B) :
ā(e.linearMapAt R b) = fun y => if b ā e.baseSet then (e āØb, yā©).2 else 0 :=
e.toPretrivialization.coe_linearMapAt b
theorem coe_linearMapAt_of_mem (e : Trivialization F (Ļ F E)) [e.IsLinear R] {b : B}
(hb : b ā e.baseSet) : ā(e.linearMapAt R b) = fun y => (e āØb, yā©).2 := by
simp_rw [coe_linearMapAt, if_pos hb]
theorem linearMapAt_apply (e : Trivialization F (Ļ F E)) [e.IsLinear R] {b : B} (y : E b) :
e.linearMapAt R b y = if b ā e.baseSet then (e āØb, yā©).2 else 0 := by
rw [coe_linearMapAt]
theorem linearMapAt_def_of_mem (e : Trivialization F (Ļ F E)) [e.IsLinear R] {b : B}
(hb : b ā e.baseSet) : e.linearMapAt R b = e.linearEquivAt R b hb :=
dif_pos hb
theorem linearMapAt_def_of_not_mem (e : Trivialization F (Ļ F E)) [e.IsLinear R] {b : B}
(hb : b ā e.baseSet) : e.linearMapAt R b = 0 :=
dif_neg hb
theorem symmā_linearMapAt (e : Trivialization F (Ļ F E)) [e.IsLinear R] {b : B} (hb : b ā e.baseSet)
(y : E b) : e.symmā R b (e.linearMapAt R b y) = y :=
e.toPretrivialization.symmā_linearMapAt hb y
theorem linearMapAt_symmā (e : Trivialization F (Ļ F E)) [e.IsLinear R] {b : B} (hb : b ā e.baseSet)
(y : F) : e.linearMapAt R b (e.symmā R b y) = y :=
e.toPretrivialization.linearMapAt_symmā hb y
variable (R)
/-- A coordinate change function between two trivializations, as a continuous linear equivalence.
Defined to be the identity when `b` does not lie in the base set of both trivializations. -/
def coordChangeL (e e' : Trivialization F (Ļ F E)) [e.IsLinear R] [e'.IsLinear R] (b : B) :
F āL[R] F :=
{ toLinearEquiv := if hb : b ā e.baseSet ā© e'.baseSet
then (e.linearEquivAt R b (hb.1 : _)).symm.trans (e'.linearEquivAt R b hb.2)
else LinearEquiv.refl R F
continuous_toFun := by
by_cases hb : b ā e.baseSet ā© e'.baseSet
Ā· rw [dif_pos hb]
refine (e'.continuousOn.comp_continuous ?_ ?_).snd
Ā· exact e.continuousOn_symm.comp_continuous (Continuous.Prod.mk b) fun y =>
mk_mem_prod hb.1 (mem_univ y)
Ā· exact fun y => e'.mem_source.mpr hb.2
Ā· rw [dif_neg hb]
exact continuous_id
continuous_invFun := by
by_cases hb : b ā e.baseSet ā© e'.baseSet
Ā· rw [dif_pos hb]
refine (e.continuousOn.comp_continuous ?_ ?_).snd
Ā· exact e'.continuousOn_symm.comp_continuous (Continuous.Prod.mk b) fun y =>
mk_mem_prod hb.2 (mem_univ y)
exact fun y => e.mem_source.mpr hb.1
Ā· rw [dif_neg hb]
exact continuous_id }
variable {R}
theorem coe_coordChangeL (e e' : Trivialization F (Ļ F E)) [e.IsLinear R] [e'.IsLinear R] {b : B}
(hb : b ā e.baseSet ā© e'.baseSet) :
ā(coordChangeL R e e' b) = (e.linearEquivAt R b hb.1).symm.trans (e'.linearEquivAt R b hb.2) :=
congr_arg (fun f : F āā[R] F ⦠āf) (dif_pos hb)
theorem coe_coordChangeL' (e e' : Trivialization F (Ļ F E)) [e.IsLinear R] [e'.IsLinear R] {b : B}
(hb : b ā e.baseSet ā© e'.baseSet) :
(coordChangeL R e e' b).toLinearEquiv =
(e.linearEquivAt R b hb.1).symm.trans (e'.linearEquivAt R b hb.2) :=
LinearEquiv.coe_injective (coe_coordChangeL _ _ hb)
theorem symm_coordChangeL (e e' : Trivialization F (Ļ F E)) [e.IsLinear R] [e'.IsLinear R] {b : B}
(hb : b ā e'.baseSet ā© e.baseSet) : (e.coordChangeL R e' b).symm = e'.coordChangeL R e b := by
apply ContinuousLinearEquiv.toLinearEquiv_injective
rw [coe_coordChangeL' e' e hb, (coordChangeL R e e' b).symm_toLinearEquiv,
coe_coordChangeL' e e' hb.symm, LinearEquiv.trans_symm, LinearEquiv.symm_symm]
theorem coordChangeL_apply (e e' : Trivialization F (Ļ F E)) [e.IsLinear R] [e'.IsLinear R] {b : B}
(hb : b ā e.baseSet ā© e'.baseSet) (y : F) :
coordChangeL R e e' b y = (e' āØb, e.symm b yā©).2 :=
congr_fun (coe_coordChangeL e e' hb) y
theorem mk_coordChangeL (e e' : Trivialization F (Ļ F E)) [e.IsLinear R] [e'.IsLinear R] {b : B}
(hb : b ā e.baseSet ā© e'.baseSet) (y : F) :
(b, coordChangeL R e e' b y) = e' āØb, e.symm b yā© := by
ext
Ā· rw [e.mk_symm hb.1 y, e'.coe_fst', e.proj_symm_apply' hb.1]
rw [e.proj_symm_apply' hb.1]
exact hb.2
Ā· exact e.coordChangeL_apply e' hb y
theorem apply_symm_apply_eq_coordChangeL (e e' : Trivialization F (Ļ F E)) [e.IsLinear R]
[e'.IsLinear R] {b : B} (hb : b ā e.baseSet ā© e'.baseSet) (v : F) :
e' (e.toPartialHomeomorph.symm (b, v)) = (b, e.coordChangeL R e' b v) := by
rw [e.mk_coordChangeL e' hb, e.mk_symm hb.1]
/-- A version of `Trivialization.coordChangeL_apply` that fully unfolds `coordChange`. The
right-hand side is ugly, but has good definitional properties for specifically defined
trivializations. -/
theorem coordChangeL_apply' (e e' : Trivialization F (Ļ F E)) [e.IsLinear R] [e'.IsLinear R] {b : B}
(hb : b ā e.baseSet ā© e'.baseSet) (y : F) :
coordChangeL R e e' b y = (e' (e.toPartialHomeomorph.symm (b, y))).2 := by
rw [e.coordChangeL_apply e' hb, e.mk_symm hb.1]
theorem coordChangeL_symm_apply (e e' : Trivialization F (Ļ F E)) [e.IsLinear R] [e'.IsLinear R]
{b : B} (hb : b ā e.baseSet ā© e'.baseSet) :
ā(coordChangeL R e e' b).symm =
(e'.linearEquivAt R b hb.2).symm.trans (e.linearEquivAt R b hb.1) :=
congr_arg LinearEquiv.invFun (dif_pos hb)
end Trivialization
end TopologicalVectorSpace
section
namespace Bundle
/-- The zero section of a vector bundle -/
def zeroSection [ā x, Zero (E x)] : B ā TotalSpace F E := (āØĀ·, 0ā©)
@[simp, mfld_simps]
theorem zeroSection_proj [ā x, Zero (E x)] (x : B) : (zeroSection F E x).proj = x :=
rfl
@[simp, mfld_simps]
theorem zeroSection_snd [ā x, Zero (E x)] (x : B) : (zeroSection F E x).2 = 0 :=
rfl
end Bundle
open Bundle
variable [NontriviallyNormedField R] [ā x, AddCommMonoid (E x)] [ā x, Module R (E x)]
[NormedAddCommGroup F] [NormedSpace R F] [TopologicalSpace B] [TopologicalSpace (TotalSpace F E)]
[ā x, TopologicalSpace (E x)] [FiberBundle F E]
/-- The space `Bundle.TotalSpace F E` (for `E : B ā Type*` such that each `E x` is a topological
vector space) has a topological vector space structure with fiber `F` (denoted with
`VectorBundle R F E`) if around every point there is a fiber bundle trivialization which is linear
in the fibers. -/
class VectorBundle : Prop where
trivialization_linear' : ā (e : Trivialization F (Ļ F E)) [MemTrivializationAtlas e], e.IsLinear R
continuousOn_coordChange' :
ā (e e' : Trivialization F (Ļ F E)) [MemTrivializationAtlas e] [MemTrivializationAtlas e'],
ContinuousOn (fun b => Trivialization.coordChangeL R e e' b : B ā F āL[R] F)
(e.baseSet ā© e'.baseSet)
variable {F E}
instance (priority := 100) trivialization_linear [VectorBundle R F E] (e : Trivialization F (Ļ F E))
[MemTrivializationAtlas e] : e.IsLinear R :=
VectorBundle.trivialization_linear' e
theorem continuousOn_coordChange [VectorBundle R F E] (e e' : Trivialization F (Ļ F E))
[MemTrivializationAtlas e] [MemTrivializationAtlas e'] :
ContinuousOn (fun b => Trivialization.coordChangeL R e e' b : B ā F āL[R] F)
(e.baseSet ā© e'.baseSet) :=
VectorBundle.continuousOn_coordChange' e e'
namespace Trivialization
/-- Forward map of `Trivialization.continuousLinearEquivAt` (only propositionally equal),
defined everywhere (`0` outside domain). -/
@[simps (config := .asFn) apply]
def continuousLinearMapAt (e : Trivialization F (Ļ F E)) [e.IsLinear R] (b : B) : E b āL[R] F :=
{ e.linearMapAt R b with
toFun := e.linearMapAt R b -- given explicitly to help `simps`
cont := by
dsimp
rw [e.coe_linearMapAt b]
refine continuous_if_const _ (fun hb => ?_) fun _ => continuous_zero
exact (e.continuousOn.comp_continuous (FiberBundle.totalSpaceMk_inducing F E b).continuous
fun x => e.mem_source.mpr hb).snd }
/-- Backwards map of `Trivialization.continuousLinearEquivAt`, defined everywhere. -/
@[simps (config := .asFn) apply]
def symmL (e : Trivialization F (Ļ F E)) [e.IsLinear R] (b : B) : F āL[R] E b :=
{ e.symmā R b with
toFun := e.symm b -- given explicitly to help `simps`
cont := by
by_cases hb : b ā e.baseSet
Ā· rw [(FiberBundle.totalSpaceMk_inducing F E b).continuous_iff]
exact e.continuousOn_symm.comp_continuous (continuous_const.prod_mk continuous_id) fun x ā¦
mk_mem_prod hb (mem_univ x)
Ā· refine continuous_zero.congr fun x => (e.symm_apply_of_not_mem hb x).symm }
variable {R}
theorem symmL_continuousLinearMapAt (e : Trivialization F (Ļ F E)) [e.IsLinear R] {b : B}
(hb : b ā e.baseSet) (y : E b) : e.symmL R b (e.continuousLinearMapAt R b y) = y :=
e.symmā_linearMapAt hb y
theorem continuousLinearMapAt_symmL (e : Trivialization F (Ļ F E)) [e.IsLinear R] {b : B}
(hb : b ā e.baseSet) (y : F) : e.continuousLinearMapAt R b (e.symmL R b y) = y :=
e.linearMapAt_symmā hb y
variable (R)
/-- In a vector bundle, a trivialization in the fiber (which is a priori only linear)
is in fact a continuous linear equiv between the fibers and the model fiber. -/
@[simps (config := .asFn) apply symm_apply]
def continuousLinearEquivAt (e : Trivialization F (Ļ F E)) [e.IsLinear R] (b : B)
(hb : b ā e.baseSet) : E b āL[R] F :=
{ e.toPretrivialization.linearEquivAt R b hb with
toFun := fun y => (e āØb, yā©).2 -- given explicitly to help `simps`
invFun := e.symm b -- given explicitly to help `simps`
continuous_toFun := (e.continuousOn.comp_continuous
(FiberBundle.totalSpaceMk_inducing F E b).continuous fun _ => e.mem_source.mpr hb).snd
continuous_invFun := (e.symmL R b).continuous }
variable {R}
theorem coe_continuousLinearEquivAt_eq (e : Trivialization F (Ļ F E)) [e.IsLinear R] {b : B}
(hb : b ā e.baseSet) :
(e.continuousLinearEquivAt R b hb : E b ā F) = e.continuousLinearMapAt R b :=
(e.coe_linearMapAt_of_mem hb).symm
theorem symm_continuousLinearEquivAt_eq (e : Trivialization F (Ļ F E)) [e.IsLinear R] {b : B}
(hb : b ā e.baseSet) : ((e.continuousLinearEquivAt R b hb).symm : F ā E b) = e.symmL R b :=
rfl
@[simp]
theorem continuousLinearEquivAt_apply' (e : Trivialization F (Ļ F E)) [e.IsLinear R]
(x : TotalSpace F E) (hx : x ā e.source) :
e.continuousLinearEquivAt R x.proj (e.mem_source.1 hx) x.2 = (e x).2 := rfl
variable (R)
theorem apply_eq_prod_continuousLinearEquivAt (e : Trivialization F (Ļ F E)) [e.IsLinear R] (b : B)
(hb : b ā e.baseSet) (z : E b) : e āØb, zā© = (b, e.continuousLinearEquivAt R b hb z) := by
ext
Ā· refine e.coe_fst ?_
rw [e.source_eq]
exact hb
Ā· simp only [coe_coe, continuousLinearEquivAt_apply]
protected theorem zeroSection (e : Trivialization F (Ļ F E)) [e.IsLinear R] {x : B}
(hx : x ā e.baseSet) : e (zeroSection F E x) = (x, 0) := by
simp_rw [zeroSection, e.apply_eq_prod_continuousLinearEquivAt R x hx 0, map_zero]
variable {R}
theorem symm_apply_eq_mk_continuousLinearEquivAt_symm (e : Trivialization F (Ļ F E)) [e.IsLinear R]
(b : B) (hb : b ā e.baseSet) (z : F) :
e.toPartialHomeomorph.symm āØb, zā© = āØb, (e.continuousLinearEquivAt R b hb).symm zā© := by
have h : (b, z) ā e.target := by
rw [e.target_eq]
exact āØhb, mem_univ _ā©
apply e.injOn (e.map_target h)
Ā· simpa only [e.source_eq, mem_preimage]
Ā· simp_rw [e.right_inv h, coe_coe, e.apply_eq_prod_continuousLinearEquivAt R b hb,
ContinuousLinearEquiv.apply_symm_apply]
theorem comp_continuousLinearEquivAt_eq_coord_change (e e' : Trivialization F (Ļ F E))
[e.IsLinear R] [e'.IsLinear R] {b : B} (hb : b ā e.baseSet ā© e'.baseSet) :
(e.continuousLinearEquivAt R b hb.1).symm.trans (e'.continuousLinearEquivAt R b hb.2) =
coordChangeL R e e' b := by
ext v
rw [coordChangeL_apply e e' hb]
rfl
end Trivialization
/-! ### Constructing vector bundles -/
variable (B F)
/-- Analogous construction of `FiberBundleCore` for vector bundles. This
construction gives a way to construct vector bundles from a structure registering how
trivialization changes act on fibers. -/
structure VectorBundleCore (ι : Type*) where
baseSet : ι ā Set B
isOpen_baseSet : ā i, IsOpen (baseSet i)
indexAt : B ā ι
mem_baseSet_at : ā x, x ā baseSet (indexAt x)
coordChange : ι ā ι ā B ā F āL[R] F
coordChange_self : ā i, ā x ā baseSet i, ā v, coordChange i i x v = v
continuousOn_coordChange : ā i j, ContinuousOn (coordChange i j) (baseSet i ā© baseSet j)
coordChange_comp : ā i j k, ā x ā baseSet i ā© baseSet j ā© baseSet k, ā v,
(coordChange j k x) (coordChange i j x v) = coordChange i k x v
/-- The trivial vector bundle core, in which all the changes of coordinates are the
identity. -/
def trivialVectorBundleCore (ι : Type*) [Inhabited ι] : VectorBundleCore R B F ι where
baseSet _ := univ
isOpen_baseSet _ := isOpen_univ
indexAt := default
mem_baseSet_at x := mem_univ x
coordChange _ _ _ := ContinuousLinearMap.id R F
coordChange_self _ _ _ _ := rfl
coordChange_comp _ _ _ _ _ _ := rfl
continuousOn_coordChange _ _ := continuousOn_const
instance (ι : Type*) [Inhabited ι] : Inhabited (VectorBundleCore R B F ι) :=
āØtrivialVectorBundleCore R B F ιā©
namespace VectorBundleCore
variable {R B F} {ι : Type*}
variable (Z : VectorBundleCore R B F ι)
/-- Natural identification to a `FiberBundleCore`. -/
@[simps (config := mfld_cfg)]
def toFiberBundleCore : FiberBundleCore ι B F :=
{ Z with
coordChange := fun i j b => Z.coordChange i j b
continuousOn_coordChange := fun i j =>
isBoundedBilinearMap_apply.continuous.comp_continuousOn
((Z.continuousOn_coordChange i j).prod_map continuousOn_id) }
-- Porting note (#11215): TODO: restore coercion
-- instance toFiberBundleCoreCoe : Coe (VectorBundleCore R B F ι) (FiberBundleCore ι B F) :=
-- āØtoFiberBundleCoreā©
theorem coordChange_linear_comp (i j k : ι) :
ā x ā Z.baseSet i ā© Z.baseSet j ā© Z.baseSet k,
(Z.coordChange j k x).comp (Z.coordChange i j x) = Z.coordChange i k x :=
fun x hx => by
ext v
exact Z.coordChange_comp i j k x hx v
/-- The index set of a vector bundle core, as a convenience function for dot notation -/
@[nolint unusedArguments] -- Porting note(#5171): was `nolint has_nonempty_instance`
def Index := ι
/-- The base space of a vector bundle core, as a convenience function for dot notation-/
@[nolint unusedArguments, reducible]
def Base := B
/-- The fiber of a vector bundle core, as a convenience function for dot notation and
typeclass inference -/
@[nolint unusedArguments] -- Porting note(#5171): was `nolint has_nonempty_instance`
def Fiber : B ā Type _ :=
Z.toFiberBundleCore.Fiber
instance topologicalSpaceFiber (x : B) : TopologicalSpace (Z.Fiber x) :=
Z.toFiberBundleCore.topologicalSpaceFiber x
-- Porting note: fixed: used to assume both `[NormedAddCommGroup F]` and `[AddCommGrp F]`
instance addCommGroupFiber (x : B) : AddCommGroup (Z.Fiber x) :=
inferInstanceAs (AddCommGroup F)
instance moduleFiber (x : B) : Module R (Z.Fiber x) :=
inferInstanceAs (Module R F)
/-- The projection from the total space of a fiber bundle core, on its base. -/
@[reducible, simp, mfld_simps]
protected def proj : TotalSpace F Z.Fiber ā B :=
TotalSpace.proj
/-- The total space of the vector bundle, as a convenience function for dot notation.
It is by definition equal to `Bundle.TotalSpace F Z.Fiber`. -/
@[nolint unusedArguments, reducible]
protected def TotalSpace :=
Bundle.TotalSpace F Z.Fiber
/-- Local homeomorphism version of the trivialization change. -/
def trivChange (i j : ι) : PartialHomeomorph (B à F) (B à F) :=
Z.toFiberBundleCore.trivChange i j
@[simp, mfld_simps]
theorem mem_trivChange_source (i j : ι) (p : B à F) :
p ā (Z.trivChange i j).source ā p.1 ā Z.baseSet i ā© Z.baseSet j :=
Z.toFiberBundleCore.mem_trivChange_source i j p
/-- Topological structure on the total space of a vector bundle created from core, designed so
that all the local trivialization are continuous. -/
instance toTopologicalSpace : TopologicalSpace Z.TotalSpace :=
Z.toFiberBundleCore.toTopologicalSpace
variable (b : B) (a : F)
@[simp, mfld_simps]
theorem coe_coordChange (i j : ι) : Z.toFiberBundleCore.coordChange i j b = Z.coordChange i j b :=
rfl
/-- One of the standard local trivializations of a vector bundle constructed from core, taken by
considering this in particular as a fiber bundle constructed from core. -/
def localTriv (i : ι) : Trivialization F (Ļ F Z.Fiber) :=
Z.toFiberBundleCore.localTriv i
-- Porting note: moved from below to fix the next instance
@[simp, mfld_simps]
theorem localTriv_apply {i : ι} (p : Z.TotalSpace) :
(Z.localTriv i) p = āØp.1, Z.coordChange (Z.indexAt p.1) i p.1 p.2ā© :=
rfl
/-- The standard local trivializations of a vector bundle constructed from core are linear. -/
instance localTriv.isLinear (i : ι) : (Z.localTriv i).IsLinear R where
linear x _ :=
{ map_add := fun _ _ => by simp only [map_add, localTriv_apply, mfld_simps]
map_smul := fun _ _ => by simp only [map_smul, localTriv_apply, mfld_simps] }
variable (i j : ι)
@[simp, mfld_simps]
theorem mem_localTriv_source (p : Z.TotalSpace) : p ā (Z.localTriv i).source ā p.1 ā Z.baseSet i :=
Iff.rfl
@[simp, mfld_simps]
theorem baseSet_at : Z.baseSet i = (Z.localTriv i).baseSet :=
rfl
@[simp, mfld_simps]
theorem mem_localTriv_target (p : B Ć F) :
p ā (Z.localTriv i).target ā p.1 ā (Z.localTriv i).baseSet :=
Z.toFiberBundleCore.mem_localTriv_target i p
@[simp, mfld_simps]
theorem localTriv_symm_fst (p : B Ć F) :
(Z.localTriv i).toPartialHomeomorph.symm p = āØp.1, Z.coordChange i (Z.indexAt p.1) p.1 p.2ā© :=
rfl
@[simp, mfld_simps]
theorem localTriv_symm_apply {b : B} (hb : b ā Z.baseSet i) (v : F) :
(Z.localTriv i).symm b v = Z.coordChange i (Z.indexAt b) b v := by
apply (Z.localTriv i).symm_apply hb v
@[simp, mfld_simps]
theorem localTriv_coordChange_eq {b : B} (hb : b ā Z.baseSet i ā© Z.baseSet j) (v : F) :
(Z.localTriv i).coordChangeL R (Z.localTriv j) b v = Z.coordChange i j b v := by
rw [Trivialization.coordChangeL_apply', localTriv_symm_fst, localTriv_apply, coordChange_comp]
exacts [āØāØhb.1, Z.mem_baseSet_at bā©, hb.2ā©, hb]
/-- Preferred local trivialization of a vector bundle constructed from core, at a given point, as
a bundle trivialization -/
def localTrivAt (b : B) : Trivialization F (Ļ F Z.Fiber) :=
Z.localTriv (Z.indexAt b)
@[simp, mfld_simps]
theorem localTrivAt_def : Z.localTriv (Z.indexAt b) = Z.localTrivAt b :=
rfl
@[simp, mfld_simps]
theorem mem_source_at : (āØb, aā© : Z.TotalSpace) ā (Z.localTrivAt b).source := by
rw [localTrivAt, mem_localTriv_source]
exact Z.mem_baseSet_at b
@[simp, mfld_simps]
theorem localTrivAt_apply (p : Z.TotalSpace) : Z.localTrivAt p.1 p = āØp.1, p.2ā© :=
Z.toFiberBundleCore.localTrivAt_apply p
@[simp, mfld_simps]
theorem localTrivAt_apply_mk (b : B) (a : F) : Z.localTrivAt b āØb, aā© = āØb, aā© :=
Z.localTrivAt_apply _
@[simp, mfld_simps]
theorem mem_localTrivAt_baseSet : b ā (Z.localTrivAt b).baseSet :=
Z.toFiberBundleCore.mem_localTrivAt_baseSet b
instance fiberBundle : FiberBundle F Z.Fiber :=
Z.toFiberBundleCore.fiberBundle
instance vectorBundle : VectorBundle R F Z.Fiber where
trivialization_linear' := by
rintro _ āØi, rflā©
apply localTriv.isLinear
continuousOn_coordChange' := by
rintro _ _ āØi, rflā© āØi', rflā©
refine (Z.continuousOn_coordChange i i').congr fun b hb => ?_
ext v
exact Z.localTriv_coordChange_eq i i' hb v
/-- The projection on the base of a vector bundle created from core is continuous -/
@[continuity]
theorem continuous_proj : Continuous Z.proj :=
Z.toFiberBundleCore.continuous_proj
/-- The projection on the base of a vector bundle created from core is an open map -/
theorem isOpenMap_proj : IsOpenMap Z.proj :=
Z.toFiberBundleCore.isOpenMap_proj
variable {i j}
@[simp, mfld_simps]
theorem localTriv_continuousLinearMapAt {b : B} (hb : b ā Z.baseSet i) :
(Z.localTriv i).continuousLinearMapAt R b = Z.coordChange (Z.indexAt b) i b := by
ext1 v
rw [(Z.localTriv i).continuousLinearMapAt_apply R, (Z.localTriv i).coe_linearMapAt_of_mem]
exacts [rfl, hb]
@[simp, mfld_simps]
theorem trivializationAt_continuousLinearMapAt {bā b : B}
(hb : b ā (trivializationAt F Z.Fiber bā).baseSet) :
(trivializationAt F Z.Fiber bā).continuousLinearMapAt R b =
Z.coordChange (Z.indexAt b) (Z.indexAt bā) b :=
Z.localTriv_continuousLinearMapAt hb
@[simp, mfld_simps]
theorem localTriv_symmL {b : B} (hb : b ā Z.baseSet i) :
(Z.localTriv i).symmL R b = Z.coordChange i (Z.indexAt b) b := by
ext1 v
rw [(Z.localTriv i).symmL_apply R, (Z.localTriv i).symm_apply]
exacts [rfl, hb]
@[simp, mfld_simps]
theorem trivializationAt_symmL {bā b : B} (hb : b ā (trivializationAt F Z.Fiber bā).baseSet) :
(trivializationAt F Z.Fiber bā).symmL R b = Z.coordChange (Z.indexAt bā) (Z.indexAt b) b :=
Z.localTriv_symmL hb
@[simp, mfld_simps]
theorem trivializationAt_coordChange_eq {bā bā b : B}
(hb : b ā (trivializationAt F Z.Fiber bā).baseSet ā© (trivializationAt F Z.Fiber bā).baseSet)
(v : F) :
(trivializationAt F Z.Fiber bā).coordChangeL R (trivializationAt F Z.Fiber bā) b v =
Z.coordChange (Z.indexAt bā) (Z.indexAt bā) b v :=
Z.localTriv_coordChange_eq _ _ hb v
end VectorBundleCore
end
/-! ### Vector prebundle -/
section
variable [NontriviallyNormedField R] [ā x, AddCommMonoid (E x)] [ā x, Module R (E x)]
[NormedAddCommGroup F] [NormedSpace R F] [TopologicalSpace B] [ā x, TopologicalSpace (E x)]
open TopologicalSpace
open VectorBundle
/-- This structure permits to define a vector bundle when trivializations are given as local
equivalences but there is not yet a topology on the total space or the fibers.
The total space is hence given a topology in such a way that there is a fiber bundle structure for
which the partial equivalences are also partial homeomorphisms and hence vector bundle
trivializations. The topology on the fibers is induced from the one on the total space.
The field `exists_coordChange` is stated as an existential statement (instead of 3 separate
fields), since it depends on propositional information (namely `e e' ā pretrivializationAtlas`).
This makes it inconvenient to explicitly define a `coordChange` function when constructing a
`VectorPrebundle`. -/
-- Porting note(#5171): was @[nolint has_nonempty_instance]
structure VectorPrebundle where
pretrivializationAtlas : Set (Pretrivialization F (Ļ F E))
pretrivialization_linear' : ā e, e ā pretrivializationAtlas ā e.IsLinear R
pretrivializationAt : B ā Pretrivialization F (Ļ F E)
mem_base_pretrivializationAt : ā x : B, x ā (pretrivializationAt x).baseSet
pretrivialization_mem_atlas : ā x : B, pretrivializationAt x ā pretrivializationAtlas
exists_coordChange : āįµ (e ā pretrivializationAtlas) (e' ā pretrivializationAtlas),
ā f : B ā F āL[R] F, ContinuousOn f (e.baseSet ā© e'.baseSet) ā§
āįµ (b ā e.baseSet ā© e'.baseSet) (v : F), f b v = (e' āØb, e.symm b vā©).2
totalSpaceMk_inducing : ā b : B, Inducing (pretrivializationAt b ā .mk b)
namespace VectorPrebundle
variable {R E F}
/-- A randomly chosen coordinate change on a `VectorPrebundle`, given by
the field `exists_coordChange`. -/
def coordChange (a : VectorPrebundle R F E) {e e' : Pretrivialization F (Ļ F E)}
(he : e ā a.pretrivializationAtlas) (he' : e' ā a.pretrivializationAtlas) (b : B) : F āL[R] F :=
Classical.choose (a.exists_coordChange e he e' he') b
theorem continuousOn_coordChange (a : VectorPrebundle R F E) {e e' : Pretrivialization F (Ļ F E)}
(he : e ā a.pretrivializationAtlas) (he' : e' ā a.pretrivializationAtlas) :
ContinuousOn (a.coordChange he he') (e.baseSet ā© e'.baseSet) :=
(Classical.choose_spec (a.exists_coordChange e he e' he')).1
theorem coordChange_apply (a : VectorPrebundle R F E) {e e' : Pretrivialization F (Ļ F E)}
(he : e ā a.pretrivializationAtlas) (he' : e' ā a.pretrivializationAtlas) {b : B}
(hb : b ā e.baseSet ā© e'.baseSet) (v : F) :
a.coordChange he he' b v = (e' āØb, e.symm b vā©).2 :=
(Classical.choose_spec (a.exists_coordChange e he e' he')).2 b hb v
theorem mk_coordChange (a : VectorPrebundle R F E) {e e' : Pretrivialization F (Ļ F E)}
(he : e ā a.pretrivializationAtlas) (he' : e' ā a.pretrivializationAtlas) {b : B}
(hb : b ā e.baseSet ā© e'.baseSet) (v : F) :
(b, a.coordChange he he' b v) = e' āØb, e.symm b vā© := by
ext
Ā· rw [e.mk_symm hb.1 v, e'.coe_fst', e.proj_symm_apply' hb.1]
rw [e.proj_symm_apply' hb.1]
exact hb.2
Ā· exact a.coordChange_apply he he' hb v
/-- Natural identification of `VectorPrebundle` as a `FiberPrebundle`. -/
def toFiberPrebundle (a : VectorPrebundle R F E) : FiberPrebundle F E :=
{ a with
continuous_trivChange := fun e he e' he' ⦠by
have : ContinuousOn (fun x : B à F ⦠a.coordChange he' he x.1 x.2)
((e'.baseSet ā© e.baseSet) ĆĖ¢ univ) :=
isBoundedBilinearMap_apply.continuous.comp_continuousOn
((a.continuousOn_coordChange he' he).prod_map continuousOn_id)
rw [e.target_inter_preimage_symm_source_eq e', inter_comm]
refine (continuousOn_fst.prod this).congr ?_
rintro āØb, fā© āØhb, -ā©
dsimp only [Function.comp_def, Prod.map]
rw [a.mk_coordChange _ _ hb, e'.mk_symm hb.1] }
/-- Topology on the total space that will make the prebundle into a bundle. -/
def totalSpaceTopology (a : VectorPrebundle R F E) : TopologicalSpace (TotalSpace F E) :=
a.toFiberPrebundle.totalSpaceTopology
/-- Promotion from a `Pretrivialization` in the `pretrivializationAtlas` of a
`VectorPrebundle` to a `Trivialization`. -/
def trivializationOfMemPretrivializationAtlas (a : VectorPrebundle R F E)
{e : Pretrivialization F (Ļ F E)} (he : e ā a.pretrivializationAtlas) :
@Trivialization B F _ _ _ a.totalSpaceTopology (Ļ F E) :=
a.toFiberPrebundle.trivializationOfMemPretrivializationAtlas he
theorem linear_trivializationOfMemPretrivializationAtlas (a : VectorPrebundle R F E)
{e : Pretrivialization F (Ļ F E)} (he : e ā a.pretrivializationAtlas) :
letI := a.totalSpaceTopology
Trivialization.IsLinear R (trivializationOfMemPretrivializationAtlas a he) :=
letI := a.totalSpaceTopology
{ linear := (a.pretrivialization_linear' e he).linear }
variable (a : VectorPrebundle R F E)
theorem mem_trivialization_at_source (b : B) (x : E b) :
āØb, xā© ā (a.pretrivializationAt b).source :=
a.toFiberPrebundle.mem_pretrivializationAt_source b x
@[simp]
theorem totalSpaceMk_preimage_source (b : B) :
.mk b ā»Ā¹' (a.pretrivializationAt b).source = univ :=
a.toFiberPrebundle.totalSpaceMk_preimage_source b
@[continuity]
theorem continuous_totalSpaceMk (b : B) :
Continuous[_, a.totalSpaceTopology] (.mk b) :=
a.toFiberPrebundle.continuous_totalSpaceMk b
/-- Make a `FiberBundle` from a `VectorPrebundle`; auxiliary construction for
`VectorPrebundle.toVectorBundle`. -/
def toFiberBundle : @FiberBundle B F _ _ _ a.totalSpaceTopology _ :=
a.toFiberPrebundle.toFiberBundle
/-- Make a `VectorBundle` from a `VectorPrebundle`. Concretely this means
that, given a `VectorPrebundle` structure for a sigma-type `E` -- which consists of a
number of "pretrivializations" identifying parts of `E` with product spaces `U Ć F` -- one
establishes that for the topology constructed on the sigma-type using
`VectorPrebundle.totalSpaceTopology`, these "pretrivializations" are actually
"trivializations" (i.e., homeomorphisms with respect to the constructed topology). -/
theorem toVectorBundle : @VectorBundle R _ F E _ _ _ _ _ _ a.totalSpaceTopology _ a.toFiberBundle :=
letI := a.totalSpaceTopology; letI := a.toFiberBundle
{ trivialization_linear' := by
rintro _ āØe, he, rflā©
apply linear_trivializationOfMemPretrivializationAtlas
continuousOn_coordChange' := by
rintro _ _ āØe, he, rflā© āØe', he', rflā©
refine (a.continuousOn_coordChange he he').congr fun b hb ⦠?_
ext v
-- Porting note: help `rw` find instances
haveI hā := a.linear_trivializationOfMemPretrivializationAtlas he
haveI hā := a.linear_trivializationOfMemPretrivializationAtlas he'
rw [trivializationOfMemPretrivializationAtlas] at hā hā
rw [a.coordChange_apply he he' hb v, ContinuousLinearEquiv.coe_coe,
Trivialization.coordChangeL_apply]
exacts [rfl, hb] }
end VectorPrebundle
namespace ContinuousLinearMap
variable {šā šā : Type*} [NontriviallyNormedField šā] [NontriviallyNormedField šā]
variable {Ļ : šā ā+* šā}
variable {B' : Type*} [TopologicalSpace B']
variable [NormedSpace šā F] [ā x, Module šā (E x)] [TopologicalSpace (TotalSpace F E)]
variable {F' : Type*} [NormedAddCommGroup F'] [NormedSpace šā F'] {E' : B' ā Type*}
[ā x, AddCommMonoid (E' x)] [ā x, Module šā (E' x)] [TopologicalSpace (TotalSpace F' E')]
variable [FiberBundle F E] [VectorBundle šā F E]
variable [ā x, TopologicalSpace (E' x)] [FiberBundle F' E'] [VectorBundle šā F' E']
variable (F' E')
/-- When `Ļ` is a continuous (semi)linear map between the fibers `E x` and `E' y` of two vector
bundles `E` and `E'`, `ContinuousLinearMap.inCoordinates F E F' E' xā x yā y Ļ` is a coordinate
change of this continuous linear map w.r.t. the chart around `xā` and the chart around `yā`.
It is defined by composing `Ļ` with appropriate coordinate changes given by the vector bundles
`E` and `E'`.
We use the operations `Trivialization.continuousLinearMapAt` and `Trivialization.symmL` in the
definition, instead of `Trivialization.continuousLinearEquivAt`, so that
`ContinuousLinearMap.inCoordinates` is defined everywhere (but see
`ContinuousLinearMap.inCoordinates_eq`).
This is the (second component of the) underlying function of a trivialization of the hom-bundle
(see `hom_trivializationAt_apply`). However, note that `ContinuousLinearMap.inCoordinates` is
defined even when `x` and `y` live in different base sets.
Therefore, it is also convenient when working with the hom-bundle between pulled back bundles.
-/
def inCoordinates (xā x : B) (yā y : B') (Ļ : E x āSL[Ļ] E' y) : F āSL[Ļ] F' :=
((trivializationAt F' E' yā).continuousLinearMapAt šā y).comp <|
Ļ.comp <| (trivializationAt F E xā).symmL šā x
variable {F F'}
/-- Rewrite `ContinuousLinearMap.inCoordinates` using continuous linear equivalences. -/
theorem inCoordinates_eq (xā x : B) (yā y : B') (Ļ : E x āSL[Ļ] E' y)
(hx : x ā (trivializationAt F E xā).baseSet) (hy : y ā (trivializationAt F' E' yā).baseSet) :
inCoordinates F E F' E' xā x yā y Ļ =
((trivializationAt F' E' yā).continuousLinearEquivAt šā y hy : E' y āL[šā] F').comp
(Ļ.comp <|
(((trivializationAt F E xā).continuousLinearEquivAt šā x hx).symm : F āL[šā] E x)) := by
ext
simp_rw [inCoordinates, ContinuousLinearMap.coe_comp', ContinuousLinearEquiv.coe_coe,
Trivialization.coe_continuousLinearEquivAt_eq, Trivialization.symm_continuousLinearEquivAt_eq]
/-- Rewrite `ContinuousLinearMap.inCoordinates` in a `VectorBundleCore`. -/
protected theorem _root_.VectorBundleCore.inCoordinates_eq {ι ι'} (Z : VectorBundleCore šā B F ι)
(Z' : VectorBundleCore šā B' F' ι') {xā x : B} {yā y : B'} (Ļ : F āSL[Ļ] F')
(hx : x ā Z.baseSet (Z.indexAt xā)) (hy : y ā Z'.baseSet (Z'.indexAt yā)) :
inCoordinates F Z.Fiber F' Z'.Fiber xā x yā y Ļ =
(Z'.coordChange (Z'.indexAt y) (Z'.indexAt yā) y).comp
(Ļ.comp <| Z.coordChange (Z.indexAt xā) (Z.indexAt x) x) := by
simp_rw [inCoordinates, Z'.trivializationAt_continuousLinearMapAt hy,
Z.trivializationAt_symmL hx]
end ContinuousLinearMap
end
|
Topology\VectorBundle\Constructions.lean
|
/-
Copyright (c) 2022 Nicolò Cavalleri. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Nicolò Cavalleri, Sébastien Gouëzel, Heather Macbeth, Floris van Doorn
-/
import Mathlib.Topology.FiberBundle.Constructions
import Mathlib.Topology.VectorBundle.Basic
import Mathlib.Analysis.NormedSpace.OperatorNorm.Prod
/-!
# Standard constructions on vector bundles
This file contains several standard constructions on vector bundles:
* `Bundle.Trivial.vectorBundle š B F`: the trivial vector bundle with scalar field `š` and model
fiber `F` over the base `B`
* `VectorBundle.prod`: for vector bundles `Eā` and `Eā` with scalar field `š` over a common base,
a vector bundle structure on their direct sum `Eā Ćįµ Eā` (the notation stands for
`fun x ⦠Eā x Ć Eā x`).
* `VectorBundle.pullback`: for a vector bundle `E` over `B`, a vector bundle structure on its
pullback `f *įµ E` by a map `f : B' ā B` (the notation is a type synonym for `E ā f`).
## Tags
Vector bundle, direct sum, pullback
-/
noncomputable section
open scoped Classical
open Bundle Set FiberBundle
/-! ### The trivial vector bundle -/
namespace Bundle.Trivial
variable (š : Type*) (B : Type*) (F : Type*) [NontriviallyNormedField š] [NormedAddCommGroup F]
[NormedSpace š F] [TopologicalSpace B]
instance trivialization.isLinear : (trivialization B F).IsLinear š where
linear _ _ := āØfun _ _ => rfl, fun _ _ => rflā©
variable {š}
theorem trivialization.coordChangeL (b : B) :
(trivialization B F).coordChangeL š (trivialization B F) b =
ContinuousLinearEquiv.refl š F := by
ext v
rw [Trivialization.coordChangeL_apply']
exacts [rfl, āØmem_univ _, mem_univ _ā©]
variable (š)
instance vectorBundle : VectorBundle š F (Bundle.Trivial B F) where
trivialization_linear' e he := by
rw [eq_trivialization B F e]
infer_instance
continuousOn_coordChange' e e' he he' := by
obtain rfl := eq_trivialization B F e
obtain rfl := eq_trivialization B F e'
simp only [trivialization.coordChangeL]
exact continuous_const.continuousOn
end Bundle.Trivial
/-! ### Direct sum of two vector bundles -/
section
variable (š : Type*) {B : Type*} [NontriviallyNormedField š] [TopologicalSpace B] (Fā : Type*)
[NormedAddCommGroup Fā] [NormedSpace š Fā] (Eā : B ā Type*) [TopologicalSpace (TotalSpace Fā Eā)]
(Fā : Type*) [NormedAddCommGroup Fā] [NormedSpace š Fā] (Eā : B ā Type*)
[TopologicalSpace (TotalSpace Fā Eā)]
namespace Trivialization
variable {Fā Eā Fā Eā}
variable [ā x, AddCommMonoid (Eā x)] [ā x, Module š (Eā x)]
[ā x, AddCommMonoid (Eā x)] [ā x, Module š (Eā x)] (eā eā' : Trivialization Fā (Ļ Fā Eā))
(eā eā' : Trivialization Fā (Ļ Fā Eā))
instance prod.isLinear [eā.IsLinear š] [eā.IsLinear š] : (eā.prod eā).IsLinear š where
linear := fun _ āØhā, hāā© =>
(((eā.linear š hā).mk' _).prodMap ((eā.linear š hā).mk' _)).isLinear
@[simp]
theorem coordChangeL_prod [eā.IsLinear š] [eā'.IsLinear š] [eā.IsLinear š] [eā'.IsLinear š] ā¦bā¦
(hb : b ā (eā.prod eā).baseSet ā© (eā'.prod eā').baseSet) :
((eā.prod eā).coordChangeL š (eā'.prod eā') b : Fā Ć Fā āL[š] Fā Ć Fā) =
(eā.coordChangeL š eā' b : Fā āL[š] Fā).prodMap (eā.coordChangeL š eā' b) := by
rw [ContinuousLinearMap.ext_iff, ContinuousLinearMap.coe_prodMap']
rintro āØvā, vāā©
show
(eā.prod eā).coordChangeL š (eā'.prod eā') b (vā, vā) =
(eā.coordChangeL š eā' b vā, eā.coordChangeL š eā' b vā)
rw [eā.coordChangeL_apply eā', eā.coordChangeL_apply eā', (eā.prod eā).coordChangeL_apply']
exacts [rfl, hb, āØhb.1.2, hb.2.2ā©, āØhb.1.1, hb.2.1ā©]
variable {eā eā} [ā x : B, TopologicalSpace (Eā x)] [ā x : B, TopologicalSpace (Eā x)]
[FiberBundle Fā Eā] [FiberBundle Fā Eā]
theorem prod_apply [eā.IsLinear š] [eā.IsLinear š] {x : B} (hxā : x ā eā.baseSet)
(hxā : x ā eā.baseSet) (vā : Eā x) (vā : Eā x) :
prod eā eā āØx, (vā, vā)ā© =
āØx, eā.continuousLinearEquivAt š x hxā vā, eā.continuousLinearEquivAt š x hxā vāā© :=
rfl
end Trivialization
open Trivialization
variable [ā x, AddCommMonoid (Eā x)] [ā x, Module š (Eā x)] [ā x, AddCommMonoid (Eā x)]
[ā x, Module š (Eā x)] [ā x : B, TopologicalSpace (Eā x)] [ā x : B, TopologicalSpace (Eā x)]
[FiberBundle Fā Eā] [FiberBundle Fā Eā]
/-- The product of two vector bundles is a vector bundle. -/
instance VectorBundle.prod [VectorBundle š Fā Eā] [VectorBundle š Fā Eā] :
VectorBundle š (Fā Ć Fā) (Eā Ćįµ Eā) where
trivialization_linear' := by
rintro _ āØeā, eā, heā, heā, rflā©
infer_instance
continuousOn_coordChange' := by
rintro _ _ āØeā, eā, heā, heā, rflā© āØeā', eā', heā', heā', rflā©
refine (((continuousOn_coordChange š eā eā').mono ?_).prod_mapL š
((continuousOn_coordChange š eā eā').mono ?_)).congr ?_ <;>
dsimp only [baseSet_prod, mfld_simps]
Ā· mfld_set_tac
Ā· mfld_set_tac
Ā· rintro b hb
rw [ContinuousLinearMap.ext_iff]
rintro āØvā, vāā©
show (eā.prod eā).coordChangeL š (eā'.prod eā') b (vā, vā) =
(eā.coordChangeL š eā' b vā, eā.coordChangeL š eā' b vā)
rw [eā.coordChangeL_apply eā', eā.coordChangeL_apply eā', (eā.prod eā).coordChangeL_apply']
exacts [rfl, hb, āØhb.1.2, hb.2.2ā©, āØhb.1.1, hb.2.1ā©]
variable {š Fā Eā Fā Eā}
@[simp] -- Porting note: changed arguments to make `simpNF` happy: merged `hxā` and `hxā` into `hx`
theorem Trivialization.continuousLinearEquivAt_prod {eā : Trivialization Fā (Ļ Fā Eā)}
{eā : Trivialization Fā (Ļ Fā Eā)} [eā.IsLinear š] [eā.IsLinear š] {x : B}
(hx : x ā (eā.prod eā).baseSet) :
(eā.prod eā).continuousLinearEquivAt š x hx =
(eā.continuousLinearEquivAt š x hx.1).prod (eā.continuousLinearEquivAt š x hx.2) := by
ext v : 2
obtain āØvā, vāā© := v
rw [(eā.prod eā).continuousLinearEquivAt_apply š, Trivialization.prod]
exact (congr_arg Prod.snd (prod_apply š hx.1 hx.2 vā vā) : _)
end
/-! ### Pullbacks of vector bundles -/
section
variable (R š : Type*) {B : Type*} (F : Type*) (E : B ā Type*) {B' : Type*} (f : B' ā B)
instance [i : ā x : B, AddCommMonoid (E x)] (x : B') : AddCommMonoid ((f *įµ E) x) := i _
instance [Semiring R] [ā x : B, AddCommMonoid (E x)] [i : ā x, Module R (E x)] (x : B') :
Module R ((f *įµ E) x) := i _
variable {E F} [TopologicalSpace B'] [TopologicalSpace (TotalSpace F E)] [NontriviallyNormedField š]
[NormedAddCommGroup F] [NormedSpace š F] [TopologicalSpace B] [ā x, AddCommMonoid (E x)]
[ā x, Module š (E x)] {K : Type*} [FunLike K B' B] [ContinuousMapClass K B' B]
instance Trivialization.pullback_linear (e : Trivialization F (Ļ F E)) [e.IsLinear š] (f : K) :
(Trivialization.pullback (B' := B') e f).IsLinear š where
linear _ h := e.linear š h
instance VectorBundle.pullback [ā x, TopologicalSpace (E x)] [FiberBundle F E] [VectorBundle š F E]
(f : K) : VectorBundle š F ((f : B' ā B) *įµ E) where
trivialization_linear' := by
rintro _ āØe, he, rflā©
infer_instance
continuousOn_coordChange' := by
rintro _ _ āØe, he, rflā© āØe', he', rflā©
refine ((continuousOn_coordChange š e e').comp
(map_continuous f).continuousOn fun b hb => hb).congr ?_
rintro b (hb : f b ā e.baseSet ā© e'.baseSet); ext v
show ((e.pullback f).coordChangeL š (e'.pullback f) b) v = (e.coordChangeL š e' (f b)) v
rw [e.coordChangeL_apply e' hb, (e.pullback f).coordChangeL_apply' _]
exacts [rfl, hb]
end
|
Topology\VectorBundle\Hom.lean
|
/-
Copyright (c) 2022 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth, Floris van Doorn
-/
import Mathlib.Topology.VectorBundle.Basic
/-!
# The vector bundle of continuous (semi)linear maps
We define the (topological) vector bundle of continuous (semi)linear maps between two vector bundles
over the same base.
Given bundles `Eā Eā : B ā Type*`, normed spaces `Fā` and `Fā`, and a ring-homomorphism `Ļ` between
their respective scalar fields, we define `Bundle.ContinuousLinearMap Ļ Fā Eā Fā Eā x` to be a
type synonym for `fun x ⦠Eā x āSL[Ļ] Eā x`. If the `Eā` and `Eā` are vector bundles with model
fibers `Fā` and `Fā`, then this will be a vector bundle with fiber `Fā āSL[Ļ] Fā`.
The topology on the total space is constructed from the trivializations for `Eā` and `Eā` and the
norm-topology on the model fiber `Fā āSL[š] Fā` using the `VectorPrebundle` construction. This is
a bit awkward because it introduces a dependence on the normed space structure of the model fibers,
rather than just their topological vector space structure; it is not clear whether this is
necessary.
Similar constructions should be possible (but are yet to be formalized) for tensor products of
topological vector bundles, exterior algebras, and so on, where again the topology can be defined
using a norm on the fiber model if this helps.
## Main Definitions
* `Bundle.ContinuousLinearMap.vectorBundle`: continuous semilinear maps between
vector bundles form a vector bundle.
-/
noncomputable section
open scoped Bundle
open Bundle Set ContinuousLinearMap
variable {šā : Type*} [NontriviallyNormedField šā] {šā : Type*} [NontriviallyNormedField šā]
(Ļ : šā ā+* šā) [iĻ : RingHomIsometric Ļ]
variable {B : Type*}
variable {Fā : Type*} [NormedAddCommGroup Fā] [NormedSpace šā Fā] (Eā : B ā Type*)
[ā x, AddCommGroup (Eā x)] [ā x, Module šā (Eā x)] [TopologicalSpace (TotalSpace Fā Eā)]
variable {Fā : Type*} [NormedAddCommGroup Fā] [NormedSpace šā Fā] (Eā : B ā Type*)
[ā x, AddCommGroup (Eā x)] [ā x, Module šā (Eā x)] [TopologicalSpace (TotalSpace Fā Eā)]
/-- A reducible type synonym for the bundle of continuous (semi)linear maps. For some reason, it
helps with instance search.
Porting note: after the port is done, we may want to remove this definition.
-/
protected abbrev Bundle.ContinuousLinearMap [ā x, TopologicalSpace (Eā x)]
[ā x, TopologicalSpace (Eā x)] : B ā Type _ := fun x => Eā x āSL[Ļ] Eā x
-- Porting note: possibly remove after the port
instance Bundle.ContinuousLinearMap.module [ā x, TopologicalSpace (Eā x)]
[ā x, TopologicalSpace (Eā x)] [ā x, TopologicalAddGroup (Eā x)]
[ā x, ContinuousConstSMul šā (Eā x)] : ā x, Module šā (Bundle.ContinuousLinearMap Ļ Eā Eā x) :=
fun _ => inferInstance
variable {Eā Eā}
variable [TopologicalSpace B] (eā eā' : Trivialization Fā (Ļ Fā Eā))
(eā eā' : Trivialization Fā (Ļ Fā Eā))
namespace Pretrivialization
/-- Assume `eįµ¢` and `eįµ¢'` are trivializations of the bundles `Eįµ¢` over base `B` with fiber `Fįµ¢`
(`i ā {1,2}`), then `Pretrivialization.continuousLinearMapCoordChange Ļ eā eā' eā eā'` is the
coordinate change function between the two induced (pre)trivializations
`Pretrivialization.continuousLinearMap Ļ eā eā` and
`Pretrivialization.continuousLinearMap Ļ eā' eā'` of `Bundle.ContinuousLinearMap`. -/
def continuousLinearMapCoordChange [eā.IsLinear šā] [eā'.IsLinear šā] [eā.IsLinear šā]
[eā'.IsLinear šā] (b : B) : (Fā āSL[Ļ] Fā) āL[šā] Fā āSL[Ļ] Fā :=
((eā'.coordChangeL šā eā b).symm.arrowCongrSL (eā.coordChangeL šā eā' b) :
(Fā āSL[Ļ] Fā) āL[šā] Fā āSL[Ļ] Fā)
variable {Ļ eā eā' eā eā'}
variable [ā x, TopologicalSpace (Eā x)] [FiberBundle Fā Eā]
variable [ā x, TopologicalSpace (Eā x)] [ita : ā x, TopologicalAddGroup (Eā x)] [FiberBundle Fā Eā]
theorem continuousOn_continuousLinearMapCoordChange [VectorBundle šā Fā Eā] [VectorBundle šā Fā Eā]
[MemTrivializationAtlas eā] [MemTrivializationAtlas eā'] [MemTrivializationAtlas eā]
[MemTrivializationAtlas eā'] :
ContinuousOn (continuousLinearMapCoordChange Ļ eā eā' eā eā')
(eā.baseSet ā© eā.baseSet ā© (eā'.baseSet ā© eā'.baseSet)) := by
have hā := (compSL Fā Fā Fā Ļ (RingHom.id šā)).continuous
have hā := (ContinuousLinearMap.flip (compSL Fā Fā Fā (RingHom.id šā) Ļ)).continuous
have hā := continuousOn_coordChange šā eā' eā
have hā := continuousOn_coordChange šā eā eā'
refine ((hā.comp_continuousOn (hā.mono ?_)).clm_comp (hā.comp_continuousOn (hā.mono ?_))).congr ?_
Ā· mfld_set_tac
Ā· mfld_set_tac
Ā· intro b _; ext L v
-- Porting note: was
-- simp only [continuousLinearMapCoordChange, ContinuousLinearEquiv.coe_coe,
-- ContinuousLinearEquiv.arrowCongrāā_apply, LinearEquiv.toFun_eq_coe, coe_comp',
-- ContinuousLinearEquiv.arrowCongrSL_apply, comp_apply, Function.comp, compSL_apply,
-- flip_apply, ContinuousLinearEquiv.symm_symm]
-- Now `simp` fails to use `ContinuousLinearMap.comp_apply` in this case
dsimp [continuousLinearMapCoordChange]
rw [ContinuousLinearEquiv.symm_symm]
variable (Ļ eā eā' eā eā')
variable [eā.IsLinear šā] [eā'.IsLinear šā] [eā.IsLinear šā] [eā'.IsLinear šā]
/-- Given trivializations `eā`, `eā` for vector bundles `Eā`, `Eā` over a base `B`,
`Pretrivialization.continuousLinearMap Ļ eā eā` is the induced pretrivialization for the
continuous `Ļ`-semilinear maps from `Eā` to `Eā`. That is, the map which will later become a
trivialization, after the bundle of continuous semilinear maps is equipped with the right
topological vector bundle structure. -/
def continuousLinearMap :
Pretrivialization (Fā āSL[Ļ] Fā) (Ļ (Fā āSL[Ļ] Fā) (Bundle.ContinuousLinearMap Ļ Eā Eā)) where
toFun p := āØp.1, .comp (eā.continuousLinearMapAt šā p.1) (p.2.comp (eā.symmL šā p.1))ā©
invFun p := āØp.1, .comp (eā.symmL šā p.1) (p.2.comp (eā.continuousLinearMapAt šā p.1))ā©
source := Bundle.TotalSpace.proj ā»Ā¹' (eā.baseSet ā© eā.baseSet)
target := (eā.baseSet ā© eā.baseSet) ĆĖ¢ Set.univ
map_source' := fun āØx, Lā© h => āØh, Set.mem_univ _ā©
map_target' := fun āØx, fā© h => h.1
left_inv' := fun āØx, Lā© āØhā, hāā© => by
simp only [TotalSpace.mk_inj]
ext (v : Eā x)
dsimp only [comp_apply]
rw [Trivialization.symmL_continuousLinearMapAt, Trivialization.symmL_continuousLinearMapAt]
exacts [hā, hā]
right_inv' := fun āØx, fā© āØāØhā, hāā©, _ā© => by
simp only [Prod.mk_inj_left]
ext v
dsimp only [comp_apply]
rw [Trivialization.continuousLinearMapAt_symmL, Trivialization.continuousLinearMapAt_symmL]
exacts [hā, hā]
open_target := (eā.open_baseSet.inter eā.open_baseSet).prod isOpen_univ
baseSet := eā.baseSet ā© eā.baseSet
open_baseSet := eā.open_baseSet.inter eā.open_baseSet
source_eq := rfl
target_eq := rfl
proj_toFun _ _ := rfl
-- Porting note (#11215): TODO: see if Lean 4 can generate this instance without a hint
instance continuousLinearMap.isLinear [ā x, ContinuousAdd (Eā x)] [ā x, ContinuousSMul šā (Eā x)] :
(Pretrivialization.continuousLinearMap Ļ eā eā).IsLinear šā where
linear x _ :=
{ map_add := fun L L' =>
show (eā.continuousLinearMapAt šā x).comp ((L + L').comp (eā.symmL šā x)) = _ by
simp_rw [add_comp, comp_add]
rfl
map_smul := fun c L =>
show (eā.continuousLinearMapAt šā x).comp ((c ⢠L).comp (eā.symmL šā x)) = _ by
simp_rw [smul_comp, comp_smulāā, RingHom.id_apply]
rfl }
theorem continuousLinearMap_apply (p : TotalSpace (Fā āSL[Ļ] Fā) fun x => Eā x āSL[Ļ] Eā x) :
(continuousLinearMap Ļ eā eā) p =
āØp.1, .comp (eā.continuousLinearMapAt šā p.1) (p.2.comp (eā.symmL šā p.1))ā© :=
rfl
theorem continuousLinearMap_symm_apply (p : B Ć (Fā āSL[Ļ] Fā)) :
(continuousLinearMap Ļ eā eā).toPartialEquiv.symm p =
āØp.1, .comp (eā.symmL šā p.1) (p.2.comp (eā.continuousLinearMapAt šā p.1))ā© :=
rfl
theorem continuousLinearMap_symm_apply' {b : B} (hb : b ā eā.baseSet ā© eā.baseSet)
(L : Fā āSL[Ļ] Fā) :
(continuousLinearMap Ļ eā eā).symm b L =
(eā.symmL šā b).comp (L.comp <| eā.continuousLinearMapAt šā b) := by
rw [symm_apply]
Ā· rfl
Ā· exact hb
theorem continuousLinearMapCoordChange_apply (b : B)
(hb : b ā eā.baseSet ā© eā.baseSet ā© (eā'.baseSet ā© eā'.baseSet)) (L : Fā āSL[Ļ] Fā) :
continuousLinearMapCoordChange Ļ eā eā' eā eā' b L =
(continuousLinearMap Ļ eā' eā' āØb, (continuousLinearMap Ļ eā eā).symm b Lā©).2 := by
ext v
simp_rw [continuousLinearMapCoordChange, ContinuousLinearEquiv.coe_coe,
ContinuousLinearEquiv.arrowCongrSL_apply, continuousLinearMap_apply,
continuousLinearMap_symm_apply' Ļ eā eā hb.1, comp_apply, ContinuousLinearEquiv.coe_coe,
ContinuousLinearEquiv.symm_symm, Trivialization.continuousLinearMapAt_apply,
Trivialization.symmL_apply]
rw [eā.coordChangeL_apply eā', eā'.coordChangeL_apply eā, eā.coe_linearMapAt_of_mem hb.1.1,
eā'.coe_linearMapAt_of_mem hb.2.2]
exacts [āØhb.2.1, hb.1.1ā©, āØhb.1.2, hb.2.2ā©]
end Pretrivialization
open Pretrivialization
variable (Fā Eā Fā Eā)
variable [ā x : B, TopologicalSpace (Eā x)] [FiberBundle Fā Eā] [VectorBundle šā Fā Eā]
variable [ā x : B, TopologicalSpace (Eā x)] [FiberBundle Fā Eā] [VectorBundle šā Fā Eā]
variable [ā x, TopologicalAddGroup (Eā x)] [ā x, ContinuousSMul šā (Eā x)]
/-- The continuous `Ļ`-semilinear maps between two topological vector bundles form a
`VectorPrebundle` (this is an auxiliary construction for the
`VectorBundle` instance, in which the pretrivializations are collated but no topology
on the total space is yet provided). -/
def Bundle.ContinuousLinearMap.vectorPrebundle :
VectorPrebundle šā (Fā āSL[Ļ] Fā) (Bundle.ContinuousLinearMap Ļ Eā Eā) where
pretrivializationAtlas :=
{e | ā (eā : Trivialization Fā (Ļ Fā Eā)) (eā : Trivialization Fā (Ļ Fā Eā))
(_ : MemTrivializationAtlas eā) (_ : MemTrivializationAtlas eā),
e = Pretrivialization.continuousLinearMap Ļ eā eā}
pretrivialization_linear' := by
rintro _ āØeā, heā, eā, heā, rflā©
infer_instance
pretrivializationAt x :=
Pretrivialization.continuousLinearMap Ļ (trivializationAt Fā Eā x) (trivializationAt Fā Eā x)
mem_base_pretrivializationAt x :=
āØmem_baseSet_trivializationAt Fā Eā x, mem_baseSet_trivializationAt Fā Eā xā©
pretrivialization_mem_atlas x :=
āØtrivializationAt Fā Eā x, trivializationAt Fā Eā x, inferInstance, inferInstance, rflā©
exists_coordChange := by
rintro _ āØeā, eā, heā, heā, rflā© _ āØeā', eā', heā', heā', rflā©
exact āØcontinuousLinearMapCoordChange Ļ eā eā' eā eā',
continuousOn_continuousLinearMapCoordChange,
continuousLinearMapCoordChange_apply Ļ eā eā' eā eā'ā©
totalSpaceMk_inducing := by
intro b
let Lā : Eā b āL[šā] Fā :=
(trivializationAt Fā Eā b).continuousLinearEquivAt šā b
(mem_baseSet_trivializationAt _ _ _)
let Lā : Eā b āL[šā] Fā :=
(trivializationAt Fā Eā b).continuousLinearEquivAt šā b
(mem_baseSet_trivializationAt _ _ _)
let Ļ : (Eā b āSL[Ļ] Eā b) āL[šā] Fā āSL[Ļ] Fā := Lā.arrowCongrSL Lā
have : Inducing fun x => (b, Ļ x) := inducing_const_prod.mpr Ļ.toHomeomorph.inducing
convert this
ext f
dsimp [Pretrivialization.continuousLinearMap_apply]
rw [Trivialization.linearMapAt_def_of_mem _ (mem_baseSet_trivializationAt _ _ _)]
rfl
/-- Topology on the total space of the continuous `Ļ`-semilinear maps between two "normable" vector
bundles over the same base. -/
instance Bundle.ContinuousLinearMap.topologicalSpaceTotalSpace :
TopologicalSpace (TotalSpace (Fā āSL[Ļ] Fā) (Bundle.ContinuousLinearMap Ļ Eā Eā)) :=
(Bundle.ContinuousLinearMap.vectorPrebundle Ļ Fā Eā Fā Eā).totalSpaceTopology
/-- The continuous `Ļ`-semilinear maps between two vector bundles form a fiber bundle. -/
instance Bundle.ContinuousLinearMap.fiberBundle :
FiberBundle (Fā āSL[Ļ] Fā) fun x => Eā x āSL[Ļ] Eā x :=
(Bundle.ContinuousLinearMap.vectorPrebundle Ļ Fā Eā Fā Eā).toFiberBundle
/-- The continuous `Ļ`-semilinear maps between two vector bundles form a vector bundle. -/
instance Bundle.ContinuousLinearMap.vectorBundle :
VectorBundle šā (Fā āSL[Ļ] Fā) (Bundle.ContinuousLinearMap Ļ Eā Eā) :=
(Bundle.ContinuousLinearMap.vectorPrebundle Ļ Fā Eā Fā Eā).toVectorBundle
variable [heā : MemTrivializationAtlas eā] [heā : MemTrivializationAtlas eā] {Fā Eā Fā Eā}
/-- Given trivializations `eā`, `eā` in the atlas for vector bundles `Eā`, `Eā` over a base `B`,
the induced trivialization for the continuous `Ļ`-semilinear maps from `Eā` to `Eā`,
whose base set is `eā.baseSet ā© eā.baseSet`. -/
def Trivialization.continuousLinearMap :
Trivialization (Fā āSL[Ļ] Fā) (Ļ (Fā āSL[Ļ] Fā) (Bundle.ContinuousLinearMap Ļ Eā Eā)) :=
VectorPrebundle.trivializationOfMemPretrivializationAtlas _ āØeā, eā, heā, heā, rflā©
instance Bundle.ContinuousLinearMap.memTrivializationAtlas :
MemTrivializationAtlas
(eā.continuousLinearMap Ļ eā :
Trivialization (Fā āSL[Ļ] Fā) (Ļ (Fā āSL[Ļ] Fā) (Bundle.ContinuousLinearMap Ļ Eā Eā))) where
out := āØ_, āØeā, eā, by infer_instance, by infer_instance, rflā©, rflā©
variable {eā eā}
@[simp]
theorem Trivialization.baseSet_continuousLinearMap :
(eā.continuousLinearMap Ļ eā).baseSet = eā.baseSet ā© eā.baseSet :=
rfl
theorem Trivialization.continuousLinearMap_apply
(p : TotalSpace (Fā āSL[Ļ] Fā) (Bundle.ContinuousLinearMap Ļ Eā Eā)) :
eā.continuousLinearMap Ļ eā p =
āØp.1, (eā.continuousLinearMapAt šā p.1 : _ āL[šā] _).comp
(p.2.comp (eā.symmL šā p.1 : Fā āL[šā] Eā p.1) : Fā āSL[Ļ] Eā p.1)ā© :=
rfl
theorem hom_trivializationAt_apply (xā : B)
(x : TotalSpace (Fā āSL[Ļ] Fā) (Bundle.ContinuousLinearMap Ļ Eā Eā)) :
trivializationAt (Fā āSL[Ļ] Fā) (fun x => Eā x āSL[Ļ] Eā x) xā x =
āØx.1, inCoordinates Fā Eā Fā Eā xā x.1 xā x.1 x.2ā© :=
rfl
@[simp, mfld_simps]
theorem hom_trivializationAt_source (xā : B) :
(trivializationAt (Fā āSL[Ļ] Fā) (Bundle.ContinuousLinearMap Ļ Eā Eā) xā).source =
Ļ (Fā āSL[Ļ] Fā) (Bundle.ContinuousLinearMap Ļ Eā Eā) ā»Ā¹'
((trivializationAt Fā Eā xā).baseSet ā© (trivializationAt Fā Eā xā).baseSet) :=
rfl
@[simp, mfld_simps]
theorem hom_trivializationAt_target (xā : B) :
(trivializationAt (Fā āSL[Ļ] Fā) (fun x => Eā x āSL[Ļ] Eā x) xā).target =
((trivializationAt Fā Eā xā).baseSet ā© (trivializationAt Fā Eā xā).baseSet) ĆĖ¢ Set.univ :=
rfl
|
Util\AddRelatedDecl.lean
|
/-
Copyright (c) 2023 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Floris van Doorn
-/
import Lean.Elab.DeclarationRange
import Lean.Elab.Term
/-!
# `addRelatedDecl`
-/
open Lean Meta Elab
namespace Mathlib.Tactic
/-- A helper function for constructing a related declaration from an existing one.
This is currently used by the attributes `reassoc` and `elementwise`,
and has been factored out to avoid code duplication.
Feel free to add features as needed for other applications.
This helper:
* calls `addDeclarationRanges`, so jump-to-definition works,
* copies the `protected` status of the existing declaration, and
* supports copying attributes.
Arguments:
* `src : Name` is the existing declaration that we are modifying.
* `suffix : String` will be appended to `src` to form the name of the new declaration.
* `ref : Syntax` is the syntax where the user requested the related declaration.
* `construct type value levels : MetaM (Expr Ć List Name)`
given the type, value, and universe variables of the original declaration,
should construct the value of the new declaration,
along with the names of its universe variables.
* `attrs` is the attributes that should be applied to both the new and the original declaration,
e.g. in the usage `@[reassoc (attr := simp)]`.
We apply it to both declarations, to have the same behavior as `to_additive`, and to shorten some
attribute commands. Note that `@[elementwise (attr := simp), reassoc (attr := simp)]` will try
to apply `simp` twice to the current declaration, but that causes no issues.
-/
def addRelatedDecl (src : Name) (suffix : String) (ref : Syntax)
(attrs? : Option (Syntax.TSepArray `Lean.Parser.Term.attrInstance ","))
(construct : Expr ā Expr ā List Name ā MetaM (Expr Ć List Name)) :
MetaM Unit := do
let tgt := match src with
| Name.str n s => Name.mkStr n <| s ++ suffix
| x => x
addDeclarationRanges tgt {
range := ā getDeclarationRange (ā getRef)
selectionRange := ā getDeclarationRange ref }
let info ā getConstInfo src
let (newValue, newLevels) ā construct info.type info.value! info.levelParams
let newValue ā instantiateMVars newValue
let newType ā instantiateMVars (ā inferType newValue)
match info with
| ConstantInfo.thmInfo info =>
addAndCompile <| .thmDecl
{ info with levelParams := newLevels, type := newType, name := tgt, value := newValue }
| ConstantInfo.defnInfo info =>
-- Structure fields are created using `def`, even when they are propositional,
-- so we don't rely on this to decided whether we should be constructing a `theorem` or a `def`.
addAndCompile <| if ā isProp newType then .thmDecl
{ info with levelParams := newLevels, type := newType, name := tgt, value := newValue }
else .defnDecl
{ info with levelParams := newLevels, type := newType, name := tgt, value := newValue }
| _ => throwError "Constant {src} is not a theorem or definition."
if isProtected (ā getEnv) src then
setEnv <| addProtected (ā getEnv) tgt
let attrs := match attrs? with | some attrs => attrs | none => #[]
_ ā Term.TermElabM.run' <| do
let attrs ā elabAttrs attrs
Term.applyAttributes src attrs
Term.applyAttributes tgt attrs
|
Util\AssertExists.lean
|
/-
Copyright (c) 2022 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot, Scott Morrison
-/
import Lean.Elab.Command
/-!
# User commands for assert the (non-)existence of declaration or instances.
These commands are used to enforce the independence of different parts of mathlib.
## TODO
Potentially after the port reimplement the mathlib 3 linters to check that declarations asserted
about do eventually exist.
Implement `assert_instance` and `assert_no_instance`
-/
section
open Lean Elab Meta Command
/--
`assert_exists n` is a user command that asserts that a declaration named `n` exists
in the current import scope.
Be careful to use names (e.g. `Rat`) rather than notations (e.g. `ā`).
-/
elab "assert_exists " n:ident : command => do
-- this throws an error if the user types something ambiguous or
-- something that doesn't exist, otherwise succeeds
let _ ā liftCoreM <| realizeGlobalConstNoOverloadWithInfo n
/--
`assert_not_exists n` is a user command that asserts that a declaration named `n` *does not exist*
in the current import scope.
Be careful to use names (e.g. `Rat`) rather than notations (e.g. `ā`).
It may be used (sparingly!) in mathlib to enforce plans that certain files
are independent of each other.
If you encounter an error on an `assert_not_exists` command while developing mathlib,
it is probably because you have introduced new import dependencies to a file.
In this case, you should refactor your work
(for example by creating new files rather than adding imports to existing files).
You should *not* delete the `assert_not_exists` statement without careful discussion ahead of time.
-/
elab "assert_not_exists " n:ident : command => do
let decl ā try liftCoreM <| realizeGlobalConstNoOverloadWithInfo n catch _ => return
let env ā getEnv
let c ā mkConstWithLevelParams decl
let msg ā (do
let mut some idx := env.getModuleIdxFor? decl
| pure m!"Declaration {c} is defined in this file."
let mut msg := m!"Declaration {c} is not allowed to be imported by this file.\n\
It is defined in {env.header.moduleNames[idx.toNat]!},"
for i in [idx.toNat+1:env.header.moduleData.size] do
if env.header.moduleData[i]!.imports.any (Ā·.module == env.header.moduleNames[idx.toNat]!) then
idx := i
msg := msg ++ m!"\n which is imported by {env.header.moduleNames[i]!},"
pure <| msg ++ m!"\n which is imported by this file.")
throw <| .error n m!"{msg}\n\n\
These invariants are maintained by `assert_not_exists` statements, \
and exist in order to ensure that \"complicated\" parts of the library \
are not accidentally introduced as dependencies of \"simple\" parts of the library."
|
Util\AssertNoSorry.lean
|
/-
Copyright (c) 2023 David Renshaw. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Renshaw
-/
import Lean.Util.CollectAxioms
import Lean.Elab.Command
/-!
# Defines the `assert_no_sorry` command.
Throws an error if the given identifier uses sorryAx.
-/
open Lean Meta Elab Command
/-- Throws an error if the given identifier uses sorryAx. -/
elab "assert_no_sorry " n:ident : command => do
let name ā liftCoreM <| Lean.Elab.realizeGlobalConstNoOverloadWithInfo n
let axioms ā Lean.collectAxioms name
if axioms.contains ``sorryAx
then throwError "{n} contains sorry"
|
Util\AtomM.lean
|
/-
Copyright (c) 2023 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Lean.Meta.Tactic.Simp.Types
/-!
# A monad for tracking and deduplicating atoms
This monad is used by tactics like `ring` and `abel` to keep uninterpreted atoms in a consistent
order, and also to allow unifying atoms up to a specified transparency mode.
-/
namespace Mathlib.Tactic
open Lean Meta
/-- The context (read-only state) of the `AtomM` monad. -/
structure AtomM.Context :=
/-- The reducibility setting for definitional equality of atoms -/
red : TransparencyMode
/-- A simplification to apply to atomic expressions when they are encountered,
before interning them in the atom list. -/
evalAtom : Expr ā MetaM Simp.Result := fun e ⦠pure { expr := e }
deriving Inhabited
/-- The mutable state of the `AtomM` monad. -/
structure AtomM.State :=
/-- The list of atoms-up-to-defeq encountered thus far, used for atom sorting. -/
atoms : Array Expr := #[]
/-- The monad that `ring` works in. This is only used for collecting atoms. -/
abbrev AtomM := ReaderT AtomM.Context <| StateRefT AtomM.State MetaM
/-- Run a computation in the `AtomM` monad. -/
def AtomM.run {α : Type} (red : TransparencyMode) (m : AtomM α)
(evalAtom : Expr ā MetaM Simp.Result := fun e ⦠pure { expr := e }) :
MetaM α :=
(m { red, evalAtom }).run' {}
/-- Get the index corresponding to an atomic expression, if it has already been encountered, or
put it in the list of atoms and return the new index, otherwise. -/
def AtomM.addAtom (e : Expr) : AtomM Nat := do
let c ā get
for h : i in [:c.atoms.size] do
if ā withTransparency (ā read).red <| isDefEq e c.atoms[i] then
return i
modifyGet fun c ⦠(c.atoms.size, { c with atoms := c.atoms.push e })
|
Util\CompileInductive.lean
|
/-
Copyright (c) 2023 Parth Shastri. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Parth Shastri, Gabriel Ebner, Mario Carneiro
-/
import Lean.Elab.Command
import Lean.Compiler.CSimpAttr
import Lean.Util.FoldConsts
/-!
# Define the `compile_inductive%` command.
The command `compile_inductive% Foo` adds compiled code for the recursor `Foo.rec`,
working around a bug in the core Lean compiler which does not support recursors.
For technical reasons, the recursor code generated by `compile_inductive%`
unfortunately evaluates the base cases eagerly. That is,
`List.rec (unreachable!) (fun _ _ _ => 42) [42]` will panic.
Similarly, `compile_def% Foo.foo` adds compiled code for definitions when missing.
This can be the case for type class projections, or definitions like `List._sizeOf_1`.
-/
namespace Mathlib.Util
open Lean Meta
private def replaceConst (repl : AssocList Name Name) (e : Expr) : Expr :=
e.replace fun | .const n us => repl.find? n |>.map (.const Ā· us) | _ => none
/-- Returns the names of the recursors for a nested or mutual inductive,
using the `all` and `numMotives` arguments from `RecursorVal`. -/
def mkRecNames (all : List Name) (numMotives : Nat) : List Name :=
if numMotives ⤠all.length then
all.map mkRecName
else
let main := all[0]!
all.map mkRecName ++
(List.range (numMotives - all.length)).map (fun i => main.str s!"rec_{i+1}")
private def addAndCompile' (decl : Declaration) : CoreM Unit := do
try addAndCompile decl
catch e =>
match decl with
| .defnDecl val => throwError "while compiling {val.name}: {e.toMessageData}"
| .mutualDefnDecl val => throwError "while compiling {val.map (Ā·.name)}: {e.toMessageData}"
| _ => unreachable!
/--
Compile the definition `dv` by adding a second definition `dvā` with the same body,
and registering a `csimp`-lemma `dv = dvā`.
-/
def compileDefn (dv : DefinitionVal) : MetaM Unit := do
if ((ā getEnv).getModuleIdxFor? dv.name).isNone then
-- If it's in the same module then we can safely just call `compileDecl`
-- on the original definition
return ā compileDecl <| .defnDecl dv
let name ā mkFreshUserName dv.name
addAndCompile' <| .defnDecl { dv with name }
let levels := dv.levelParams.map .param
let old := .const dv.name levels
let new := .const name levels
let name ā mkFreshUserName <| dv.name.str "eq"
addDecl <| .thmDecl {
name
levelParams := dv.levelParams
type := ā mkEq old new
value := ā mkEqRefl old
}
Compiler.CSimp.add name .global
open Elab
/-- Returns true if the given declaration has already been compiled, either directly or via a
`@[csimp]` lemma. -/
def isCompiled (env : Environment) (n : Name) : Bool :=
env.contains (n.str "_cstage2") || (Compiler.CSimp.ext.getState env).map.contains n
/--
`compile_def% Foo.foo` adds compiled code for the definition `Foo.foo`.
This can be used for type class projections or definitions like `List._sizeOf_1`,
for which Lean does not generate compiled code by default
(since it is not used 99% of the time).
-/
elab tk:"compile_def% " i:ident : command => Command.liftTermElabM do
let n ā realizeGlobalConstNoOverloadWithInfo i
if isCompiled (ā getEnv) n then
logWarningAt tk m!"already compiled {n}"
return
let dv ā withRef i <| getConstInfoDefn n
withRef tk <| compileDefn dv
private def compileStructOnly (iv : InductiveVal) (rv : RecursorVal) : MetaM Unit := do
let value ā forallTelescope rv.type fun xs _ =>
let val := xs[rv.getFirstMinorIdx]!
let val := mkAppN val āØ.map (xs[rv.getMajorIdx]!.proj iv.name) <| .range rv.rules[0]!.nfieldsā©
mkLambdaFVars xs val
go value
where
go value := do
let name ā mkFreshUserName rv.name
addAndCompile' <| .defnDecl { rv with
name
value
hints := .abbrev
safety := .safe
}
let levels := rv.levelParams.map .param
let old := .const rv.name levels
let new := .const name levels
let name ā mkFreshUserName <| rv.name.str "eq"
addDecl <| .mutualDefnDecl [{
name
levelParams := rv.levelParams
type := ā mkEq old new
value := .const name levels
hints := .opaque
safety := .partial
}]
Compiler.CSimp.add name .global
compileDefn <| ā getConstInfoDefn <| mkRecOnName iv.name
/--
Generate compiled code for the recursor for `iv`, excluding the `sizeOf` function.
-/
def compileInductiveOnly (iv : InductiveVal) (warn := true) : MetaM Unit := do
let rv ā getConstInfoRec <| mkRecName iv.name
if ā isProp rv.type then
if warn then logWarning m!"not compiling {rv.name}"
return
if isCompiled (ā getEnv) rv.name then
if warn then logWarning m!"already compiled {rv.name}"
return
if !iv.isRec && rv.numMotives == 1 && iv.numCtors == 1 && iv.numIndices == 0 then
compileStructOnly iv rv
return
let levels := rv.levelParams.map .param
let rvs ā
if rv.numMotives == 1 then pure [rv]
else mkRecNames iv.all rv.numMotives |>.mapM getConstInfoRec
let rvs ā rvs.mapM fun rv => return (rv, ā mkFreshUserName rv.name)
let repl := rvs.foldl (fun l (rv, name) => .cons rv.name name l) .nil
addAndCompile' <| .mutualDefnDecl <|ā rvs.mapM fun (rv, name) => do
pure { rv with
name
value := ā forallTelescope rv.type fun xs body => do
let major := xs[rv.getMajorIdx]!
(ā whnfD <| ā inferType major).withApp fun head args => do
let .const iv levels' := head | throwError "not an inductive"
let iv ā getConstInfoInduct iv
let rv' ā getConstInfoRec <| mkRecName iv.name
if !iv.isRec && rv'.numMotives == 1 && iv.numCtors == 1 && iv.numIndices == 0 then
let rule := rv.rules[0]!
let val := .beta (replaceConst repl rule.rhs) xs[:rv.getFirstIndexIdx]
let val := .beta val āØ.map (major.proj iv.name) <| .range rule.nfieldsā©
mkLambdaFVars xs val
else
let val := .const (mkCasesOnName iv.name) (.param rv.levelParams.head! :: levels')
let val := mkAppN val args[:rv'.numParams]
let val := .app val <| ā mkLambdaFVars xs[rv.getFirstIndexIdx:] body
let val := mkAppN val xs[rv.getFirstIndexIdx:]
let val := mkAppN val <| rv.rules.toArray.map fun rule =>
.beta (replaceConst repl rule.rhs) xs[:rv.getFirstIndexIdx]
mkLambdaFVars xs val
hints := .opaque
safety := .partial
}
for (rv, name) in rvs do
let old := .const rv.name levels
let new := .const name levels
let name ā mkFreshUserName <| rv.name.str "eq"
addDecl <| .mutualDefnDecl [{
name
levelParams := rv.levelParams
type := ā mkEq old new
value := .const name levels
hints := .opaque
safety := .partial
}]
Compiler.CSimp.add name .global
for name in iv.all do
for aux in [mkRecOnName name, mkBRecOnName name] do
if let some (.defnInfo dv) := (ā getEnv).find? aux then
compileDefn dv
mutual
/--
Generate compiled code for the recursor for `iv`.
-/
partial def compileInductive (iv : InductiveVal) (warn := true) : MetaM Unit := do
compileInductiveOnly iv warn
compileSizeOf iv
/--
Compiles the `sizeOf` auxiliary functions. It also recursively compiles any inductives required to
compile the `sizeOf` definition (because `sizeOf` definitions depend on `T.rec`).
-/
partial def compileSizeOf (iv : InductiveVal) : MetaM Unit := do
let go aux := do
if let some (.defnInfo dv) := (ā getEnv).find? aux then
if !isCompiled (ā getEnv) aux then
let deps : NameSet := dv.value.foldConsts ā
fun c arr =>
if let .str name "_sizeOf_inst" := c then arr.insert name else arr
for i in deps do
if let some (.inductInfo iv) := (ā getEnv).find? i then
compileInductive iv (warn := false)
compileDefn dv
let rv ā getConstInfoRec <| mkRecName iv.name
for name in iv.all do
for i in [:rv.numMotives] do
go <| name.str s!"_sizeOf_{i+1}"
go <| name.str "_sizeOf_inst"
end
/--
`compile_inductive% Foo` creates compiled code for the recursor `Foo.rec`,
so that `Foo.rec` can be used in a definition
without having to mark the definition as `noncomputable`.
-/
elab tk:"compile_inductive% " i:ident : command => Command.liftTermElabM do
let n ā realizeGlobalConstNoOverloadWithInfo i
let iv ā withRef i <| getConstInfoInduct n
withRef tk <| compileInductive iv
end Mathlib.Util
-- `Nat.rec` already has a `@[csimp]` lemma in Lean.
compile_def% Nat.recOn
compile_def% Nat.brecOn
compile_inductive% Prod
compile_inductive% List
compile_inductive% PUnit
compile_inductive% PEmpty
compile_inductive% Sum
compile_inductive% PSum
compile_inductive% And
compile_inductive% False
compile_inductive% Empty
compile_inductive% Bool
compile_inductive% Sigma
-- In addition to the manual implementation below, we also have to override the `Float.val` and
-- `Float.mk` functions because these also have no implementation in core lean.
-- Because `floatSpec.float` is an opaque type, the identity function is as good an implementation
-- as any.
private unsafe def Float.valUnsafe : Float ā floatSpec.float := unsafeCast
private unsafe def Float.mkUnsafe : floatSpec.float ā Float := unsafeCast
@[implemented_by Float.valUnsafe] private def Float.valImpl (x : Float) : floatSpec.float := x.1
@[implemented_by Float.mkUnsafe] private def Float.mkImpl (x : floatSpec.float) : Float := āØxā©
@[csimp] private theorem Float.val_eq : @Float.val = Float.valImpl := rfl
@[csimp] private theorem Float.mk_eq : @Float.mk = Float.mkImpl := rfl
-- These types need manual implementations because the default implementation in `compileStruct`
-- uses `Expr.proj` which has an invalid IR type.
open Lean Meta Elab Mathlib.Util in
run_cmd Command.liftTermElabM do
for n in [``UInt8, ``UInt16, ``UInt32, ``UInt64, ``USize, ``Float] do
let iv ā getConstInfoInduct n
let rv ā getConstInfoRec <| mkRecName n
let value ā Elab.Term.elabTerm (ā `(fun H t => H t.1))
(ā inferType (.const rv.name (rv.levelParams.map .param)))
compileStructOnly.go iv rv value
compileSizeOf iv
-- These need special handling because `Lean.Name.sizeOf` and `Lean.instSizeOfName`
-- were manually implemented as `noncomputable`
compile_inductive% String
compile_inductive% Lean.Name
compile_def% Lean.Name.sizeOf
compile_def% Lean.instSizeOfName
|
Util\CountHeartbeats.lean
|
/-
Copyright (c) 2023 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Lean.Util.Heartbeats
import Lean.Meta.Tactic.TryThis
/-!
Defines a command wrapper that prints the number of heartbeats used in the enclosed command.
For example
```
count_heartbeats in
theorem foo : 42 = 6 * 7 := rfl
```
will produce an info message containing a number around 51.
If this number is above the current `maxHeartbeats`, we also print a `Try this:` suggestion.
-/
open Lean Elab Command Meta
namespace Mathlib.CountHeartbeats
open Tactic
/--
Run a tactic, optionally restoring the original state, and report just the number of heartbeats.
-/
def runTacForHeartbeats (tac : TSyntax `Lean.Parser.Tactic.tacticSeq) (revert : Bool := true) :
TacticM Nat := do
let start ā IO.getNumHeartbeats
let s ā saveState
evalTactic tac
if revert then restoreState s
return (ā IO.getNumHeartbeats) - start
/--
Given a `List Nat`, return the minimum, maximum, and standard deviation.
-/
def variation (counts : List Nat) : List Nat :=
let min := counts.minimum?.getD 0
let max := counts.maximum?.getD 0
let toFloat (n : Nat) := n.toUInt64.toFloat
let toNat (f : Float) := f.toUInt64.toNat
let counts' := counts.map toFloat
let μ : Float := counts'.foldl (· + ·) 0 / toFloat counts.length
let stddev : Float := Float.sqrt <|
((counts'.map fun i => (i - μ)^2).foldl (· + ·) 0) / toFloat counts.length
[min, max, toNat stddev]
/--
Given a `List Nat`, log an info message with the minimum, maximum, and standard deviation.
-/
def logVariation {m} [Monad m] [MonadLog m] [AddMessageContext m] [MonadOptions m]
(counts : List Nat) : m Unit := do
if let [min, max, stddev] := variation counts then
-- convert `[min, max, stddev]` to user-facing heartbeats
logInfo s!"Min: {min / 1000} Max: {max / 1000} StdDev: {stddev / 10}%"
/-- Count the heartbeats used by a tactic, e.g.: `count_heartbeats simp`. -/
elab "count_heartbeats " tac:tacticSeq : tactic => do
logInfo s!"{ā runTacForHeartbeats tac (revert := false)}"
/--
`count_heartbeats! in tac` runs a tactic 10 times, counting the heartbeats used, and logs the range
and standard deviation. The tactic `count_heartbeats! n in tac` runs it `n` times instead.
-/
elab "count_heartbeats! " n:(num)? "in" ppLine tac:tacticSeq : tactic => do
let n := match n with
| some j => j.getNat
| none => 10
-- First run the tactic `n-1` times, reverting the state.
let counts ā (List.range (n - 1)).mapM fun _ => runTacForHeartbeats tac
-- Then run once more, keeping the state.
let counts := (ā runTacForHeartbeats tac (revert := false)) :: counts
logVariation counts
/--
Count the heartbeats used in the enclosed command.
This is most useful for setting sufficient but reasonable limits via `set_option maxHeartbeats`
for long running declarations.
If you do so, please resist the temptation to set the limit as low as possible.
As the `simp` set and other features of the library evolve,
other contributors will find that their (likely unrelated) changes
have pushed the declaration over the limit.
`count_heartbearts in` will automatically suggest a `set_option maxHeartbeats` via "Try this:"
using the least number of the form `2^k * 200000` that suffices.
Note that that internal heartbeat counter accessible via `IO.getNumHeartbeats`
has granularity 1000 times finer that the limits set by `set_option maxHeartbeats`.
As this is intended as a user command, we divide by 1000.
-/
elab "count_heartbeats " "in" ppLine cmd:command : command => do
let start ā IO.getNumHeartbeats
try
elabCommand (ā `(command| set_option maxHeartbeats 0 in $cmd))
finally
let finish ā IO.getNumHeartbeats
let elapsed := (finish - start) / 1000
let max := (ā Command.liftCoreM getMaxHeartbeats) / 1000
if elapsed < max then
logInfo m!"Used {elapsed} heartbeats, which is less than the current maximum of {max}."
else
let mut max' := max
while max' < elapsed do
max' := 2 * max'
logInfo m!"Used {elapsed} heartbeats, which is greater than the current maximum of {max}."
let m : TSyntax `num := quote max'
Command.liftCoreM <| MetaM.run' do
Lean.Meta.Tactic.TryThis.addSuggestion (ā getRef)
(ā set_option hygiene false in `(command| set_option maxHeartbeats $m in $cmd))
/--
Run a command, optionally restoring the original state, and report just the number of heartbeats.
-/
def elabForHeartbeats (cmd : TSyntax `command) (revert : Bool := true) : CommandElabM Nat := do
let start ā IO.getNumHeartbeats
let s ā get
elabCommand (ā `(command| set_option maxHeartbeats 0 in $cmd))
if revert then set s
return (ā IO.getNumHeartbeats) - start
/--
`count_heartbeats! in cmd` runs a command `10` times, reporting the range in heartbeats, and the
standard deviation. The command `count_heartbeats! n in cmd` runs it `n` times instead.
Example usage:
```
count_heartbeats! in
def f := 37
```
displays the info message `Min: 7 Max: 8 StdDev: 14%`.
-/
elab "count_heartbeats! " n:(num)? "in" ppLine cmd:command : command => do
let n := match n with
| some j => j.getNat
| none => 10
-- First run the command `n-1` times, reverting the state.
let counts ā (List.range (n - 1)).mapM fun _ => elabForHeartbeats cmd
-- Then run once more, keeping the state.
let counts := (ā elabForHeartbeats cmd (revert := false)) :: counts
logVariation counts
|
Util\Delaborators.lean
|
/-
Copyright (c) 2023 Kyle Miller. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kyle Miller
-/
import Lean.PrettyPrinter.Delaborator.Builtins
/-! # Pi type notation
Provides the `Πx : α, β x` notation as an alternative to Lean 4's built-in
`(x : α) ā β x` notation. To get all non-`ā` pi types to pretty print this way
then do `open scoped PiNotation`.
The notation also accepts extended binders, like `Ī x ā s, β x` for `Ī x, x ā s ā β x`.
-/
namespace PiNotation
open Lean.Parser Term
open Lean.PrettyPrinter.Delaborator
/-- Dependent function type (a "pi type"). The notation `Πx : α, β x` can
also be written as `(x : α) ā β x`. -/
-- A direct copy of forall notation but with `Ī `/`Pi` instead of `ā`/`Forall`.
@[term_parser]
def piNotation := leading_parser:leadPrec
unicodeSymbol "Ī " "PiType" >>
many1 (ppSpace >> (binderIdent <|> bracketedBinder)) >>
optType >> ", " >> termParser
/-- Dependent function type (a "pi type"). The notation `Ī x ā s, β x` is
short for `Ī x, x ā s ā β x`. -/
-- A copy of forall notation from `Batteries.Util.ExtendedBinder` for pi notation
syntax "Ī " binderIdent binderPred ", " term : term
macro_rules
| `(Ī $x:ident $pred:binderPred, $p) => `(Ī $x:ident, satisfies_binder_pred% $x $pred ā $p)
| `(Ī _ $pred:binderPred, $p) => `(Ī x, satisfies_binder_pred% x $pred ā $p)
/-- Since pi notation and forall notation are interchangeable, we can
parse it by simply using the pre-existing forall parser. -/
@[macro PiNotation.piNotation] def replacePiNotation : Lean.Macro
| .node info _ args => return .node info ``Lean.Parser.Term.forall args
| _ => Lean.Macro.throwUnsupported
/-- Override the Lean 4 pi notation delaborator with one that prints cute binders
such as `ā ε > 0`. -/
@[delab forallE]
def delabPi : Delab := whenPPOption Lean.getPPNotation do
let stx ā delabForall
match stx with
| `(ā ($i:ident : $_), $j:ident ā $s ā $body) =>
if i == j then `(ā $i:ident ā $s, $body) else pure stx
| `(ā ($x:ident : $_), $y:ident > $z ā $body) =>
if x == y then `(ā $x:ident > $z, $body) else pure stx
| `(ā ($x:ident : $_), $y:ident < $z ā $body) =>
if x == y then `(ā $x:ident < $z, $body) else pure stx
| `(ā ($x:ident : $_), $y:ident ā„ $z ā $body) =>
if x == y then `(ā $x:ident ā„ $z, $body) else pure stx
| `(ā ($x:ident : $_), $y:ident ⤠$z ā $body) =>
if x == y then `(ā $x:ident ⤠$z, $body) else pure stx
| `(Ī ($i:ident : $_), $j:ident ā $s ā $body) =>
if i == j then `(Ī $i:ident ā $s, $body) else pure stx
| `(ā ($i:ident : $_), $j:ident ā $s ā $body) =>
if i == j then `(ā $i:ident ā $s, $body) else pure stx
| `(ā ($i:ident : $_), $j:ident ā $s ā $body) =>
if i == j then `(ā $i:ident ā $s, $body) else pure stx
| `(ā ($i:ident : $_), $j:ident ā $s ā $body) =>
if i == j then `(ā $i:ident ā $s, $body) else pure stx
| `(ā ($i:ident : $_), $j:ident ā $s ā $body) =>
if i == j then `(ā $i:ident ā $s, $body) else pure stx
| `(ā ($i:ident : $_), $j:ident ā $s ā $body) =>
if i == j then `(ā $i:ident ā $s, $body) else pure stx
| _ => pure stx
/-- Override the Lean 4 pi notation delaborator with one that uses `Ī ` and prints
cute binders such as `ā ε > 0`.
Note that this takes advantage of the fact that `(x : α) ā p x` notation is
never used for propositions, so we can match on this result and rewrite it. -/
@[scoped delab forallE]
def delabPi' : Delab := whenPPOption Lean.getPPNotation do
let stx ā delabPi
-- Replacements
let stx : Term ā
match stx with
| `($group:bracketedBinder ā $body) => `(Ī $group:bracketedBinder, $body)
| _ => pure stx
-- Merging
match stx with
| `(Ī $group, Ī $groups*, $body) => `(Ī $group $groups*, $body)
| _ => pure stx
end PiNotation
section existential
open Lean Parser Term PrettyPrinter Delaborator
/-- Delaborator for existential quantifier, including extended binders. -/
-- TODO: reduce the duplication in this code
@[delab app.Exists]
def exists_delab : Delab := whenPPOption Lean.getPPNotation do
let #[ι, f] := (ā SubExpr.getExpr).getAppArgs | failure
unless f.isLambda do failure
let prop ā Meta.isProp ι
let dep := f.bindingBody!.hasLooseBVar 0
let ppTypes ā getPPOption getPPFunBinderTypes
let stx ā SubExpr.withAppArg do
let dom ā SubExpr.withBindingDomain delab
withBindingBodyUnusedName fun x => do
let x : TSyntax `ident := .mk x
let body ā delab
if prop && !dep then
`(ā (_ : $dom), $body)
else if prop || ppTypes then
`(ā ($x:ident : $dom), $body)
else
`(ā $x:ident, $body)
-- Cute binders
let stx : Term ā
match stx with
| `(ā $i:ident, $j:ident ā $s ā§ $body)
| `(ā ($i:ident : $_), $j:ident ā $s ā§ $body) =>
if i == j then `(ā $i:ident ā $s, $body) else pure stx
| `(ā $x:ident, $y:ident > $z ā§ $body)
| `(ā ($x:ident : $_), $y:ident > $z ā§ $body) =>
if x == y then `(ā $x:ident > $z, $body) else pure stx
| `(ā $x:ident, $y:ident < $z ā§ $body)
| `(ā ($x:ident : $_), $y:ident < $z ā§ $body) =>
if x == y then `(ā $x:ident < $z, $body) else pure stx
| `(ā $x:ident, $y:ident ā„ $z ā§ $body)
| `(ā ($x:ident : $_), $y:ident ā„ $z ā§ $body) =>
if x == y then `(ā $x:ident ā„ $z, $body) else pure stx
| `(ā $x:ident, $y:ident ⤠$z ā§ $body)
| `(ā ($x:ident : $_), $y:ident ⤠$z ā§ $body) =>
if x == y then `(ā $x:ident ⤠$z, $body) else pure stx
| `(ā $x:ident, $y:ident ā $z ā§ $body)
| `(ā ($x:ident : $_), $y:ident ā $z ā§ $body) => do
if x == y then `(ā $x:ident ā $z, $body) else pure stx
| `(ā $x:ident, $y:ident ā $z ā§ $body)
| `(ā ($x:ident : $_), $y:ident ā $z ā§ $body) =>
if x == y then `(ā $x:ident ā $z, $body) else pure stx
| `(ā $x:ident, $y:ident ā $z ā§ $body)
| `(ā ($x:ident : $_), $y:ident ā $z ā§ $body) =>
if x == y then `(ā $x:ident ā $z, $body) else pure stx
| `(ā $x:ident, $y:ident ā $z ā§ $body)
| `(ā ($x:ident : $_), $y:ident ā $z ā§ $body) =>
if x == y then `(ā $x:ident ā $z, $body) else pure stx
| `(ā $x:ident, $y:ident ā $z ā§ $body)
| `(ā ($x:ident : $_), $y:ident ā $z ā§ $body) =>
if x == y then `(ā $x:ident ā $z, $body) else pure stx
| _ => pure stx
match stx with
| `(ā $group:bracketedExplicitBinders, ā $[$groups:bracketedExplicitBinders]*, $body) =>
`(ā $group $groups*, $body)
| `(ā $b:binderIdent, ā $[$bs:binderIdent]*, $body) => `(ā $b:binderIdent $[$bs]*, $body)
| _ => pure stx
end existential
open Lean Lean.PrettyPrinter.Delaborator
/-- Delaborator for `ā`. -/
@[delab app.Not] def delab_not_in := whenPPOption Lean.getPPNotation do
let #[f] := (ā SubExpr.getExpr).getAppArgs | failure
guard <| f.isAppOfArity ``Membership.mem 5
let stxā ā SubExpr.withAppArg <| SubExpr.withNaryArg 3 delab
let stxā ā SubExpr.withAppArg <| SubExpr.withNaryArg 4 delab
return ā `($stxā ā $stxā)
|
Util\DischargerAsTactic.lean
|
/-
Copyright (c) 2023 Alex J. Best. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alex J. Best
-/
import Lean.Elab.Tactic.Basic
import Lean.Meta.Tactic.Simp.Rewrite
import Batteries.Tactic.Exact
/-!
## Dischargers for `simp` to tactics
This file defines a wrapper for `Simp.Discharger`s as regular tactics, that allows them to be
used via the tactic frontend of `simp` via `simp (discharger := wrapSimpDischarger my_discharger)`.
-/
open Lean Meta Elab Tactic
/-- Wrap an simp discharger (a function `Expr ā SimpM (Option Expr)`) as a tactic,
so that it can be passed as an argument to `simp (discharger := foo)`.
This is inverse to `mkDischargeWrapper`. -/
def wrapSimpDischarger (dis : Simp.Discharge) : TacticM Unit := do
let eS : Lean.Meta.Simp.State := {}
let eC : Lean.Meta.Simp.Context := {}
let eM : Lean.Meta.Simp.Methods := {}
let (some a, _) ā liftM <| StateRefT'.run (ReaderT.run (ReaderT.run (dis <| ā getMainTarget)
eM.toMethodsRef) eC) eS | failure
(ā getMainGoal).assignIfDefeq a
|
Util\Export.lean
|
/-
Copyright (c) 2021 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Lean.CoreM
import Lean.Util.FoldConsts
/-!
A rudimentary export format, adapted from
<https://github.com/leanprover-community/lean/blob/master/doc/export_format.md>
with support for lean 4 kernel primitives.
-/
open Lean (HashMap HashSet)
namespace Lean
namespace Export
/- References -/
private opaque MethodsRefPointed : NonemptyType.{0}
private def MethodsRef : Type := MethodsRefPointed.type
inductive Entry
| name (n : Name)
| level (n : Level)
| expr (n : Expr)
| defn (n : Name)
deriving Inhabited
instance : Coe Name Entry := āØEntry.nameā©
instance : Coe Level Entry := āØEntry.levelā©
instance : Coe Expr Entry := āØEntry.exprā©
structure Alloc (α) [BEq α] [Hashable α] where
map : HashMap α Nat
next : Nat
deriving Inhabited
structure State where
names : Alloc Name := āØHashMap.empty.insert Name.anonymous 0, 1ā©
levels : Alloc Level := āØHashMap.empty.insert levelZero 0, 1ā©
exprs : Alloc Expr
defs : HashSet Name
stk : Array (Bool Ć Entry)
deriving Inhabited
class OfState (α : Type) [BEq α] [Hashable α] where
get : State ā Alloc α
modify : (Alloc α ā Alloc α) ā State ā State
instance : OfState Name where
get s := s.names
modify f s := { s with names := f s.names }
instance : OfState Level where
get s := s.levels
modify f s := { s with levels := f s.levels }
instance : OfState Expr where
get s := s.exprs
modify f s := { s with exprs := f s.exprs }
end Export
abbrev ExportM := StateT Export.State CoreM
namespace Export
def alloc {α} [BEq α] [Hashable α] [OfState α] (a : α) : ExportM Nat := do
let n := (OfState.get (α := α) (ā get)).next
modify <| OfState.modify (α := α) fun s ⦠{map := s.map.insert a n, next := n+1}
pure n
def exportName (n : Name) : ExportM Nat := do
match (ā get).names.map.find? n with
| some i => pure i
| none => match n with
| .anonymous => pure 0
| .num p a => let i ā alloc n; IO.println s!"{i} #NI {ā exportName p} {a}"; pure i
| .str p s => let i ā alloc n; IO.println s!"{i} #NS {ā exportName p} {s}"; pure i
def exportLevel (L : Level) : ExportM Nat := do
match (ā get).levels.map.find? L with
| some i => pure i
| none => match L with
| .zero => pure 0
| .succ l =>
let i ā alloc L; IO.println s!"{i} #US {ā exportLevel l}"; pure i
| .max lā lā =>
let i ā alloc L; IO.println s!"{i} #UM {ā exportLevel lā} {ā exportLevel lā}"; pure i
| .imax lā lā =>
let i ā alloc L; IO.println s!"{i} #UIM {ā exportLevel lā} {ā exportLevel lā}"; pure i
| .param n =>
let i ā alloc L; IO.println s!"{i} #UP {ā exportName n}"; pure i
| .mvar _ => unreachable!
def biStr : BinderInfo ā String
| BinderInfo.default => "#BD"
| BinderInfo.implicit => "#BI"
| BinderInfo.strictImplicit => "#BS"
| BinderInfo.instImplicit => "#BC"
open ConstantInfo in
mutual
partial def exportExpr (E : Expr) : ExportM Nat := do
match (ā get).exprs.map.find? E with
| some i => pure i
| none => match E with
| .bvar n => let i ā alloc E; IO.println s!"{i} #EV {n}"; pure i
| .fvar _ => unreachable!
| .mvar _ => unreachable!
| .sort l => let i ā alloc E; IO.println s!"{i} #ES {ā exportLevel l}"; pure i
| .const n ls =>
exportDef n
let i ā alloc E
let mut s := s!"{i} #EC {ā exportName n}"
for l in ls do s := s ++ s!" {ā exportLevel l}"
IO.println s; pure i
| .app eā eā =>
let i ā alloc E; IO.println s!"{i} #EA {ā exportExpr eā} {ā exportExpr eā}"; pure i
| .lam _ eā eā d =>
let i ā alloc E
IO.println s!"{i} #EL {biStr d} {ā exportExpr eā} {ā exportExpr eā}"; pure i
| .forallE _ eā eā d =>
let i ā alloc E
IO.println s!"{i} #EP {biStr d} {ā exportExpr eā} {ā exportExpr eā}"; pure i
| .letE _ eā eā eā _ =>
let i ā alloc E
IO.println s!"{i} #EP {ā exportExpr eā} {ā exportExpr eā} {ā exportExpr eā}"; pure i
| .lit (.natVal n) => let i ā alloc E; IO.println s!"{i} #EN {n}"; pure i
| .lit (.strVal s) => let i ā alloc E; IO.println s!"{i} #ET {s}"; pure i
| .mdata _ _ => unreachable!
| .proj n k e =>
let i ā alloc E; IO.println s!"{i} #EJ {ā exportName n} {k} {ā exportExpr e}"; pure i
partial def exportDef (n : Name) : ExportM Unit := do
if (ā get).defs.contains n then return
let ci ā getConstInfo n
for c in ci.value!.getUsedConstants do
unless (ā get).defs.contains c do
exportDef c
match ci with
| axiomInfo val => axdef "#AX" val.name val.type val.levelParams
| defnInfo val => defn "#DEF" val.name val.type val.value val.levelParams
| thmInfo val => defn "#THM" val.name val.type val.value val.levelParams
| opaqueInfo val => defn "#CN" val.name val.type val.value val.levelParams
| quotInfo _ =>
IO.println "#QUOT"
for n in [``Quot, ``Quot.mk, ``Quot.lift, ``Quot.ind] do
insert n
| inductInfo val => ind val.all
| ctorInfo val => ind (ā getConstInfoInduct val.induct).all
| recInfo val => ind val.all
where
insert (n : Name) : ExportM Unit :=
modify fun s ⦠{ s with defs := s.defs.insert n }
defn (ty : String) (n : Name) (t e : Expr) (ls : List Name) : ExportM Unit := do
let mut s := s!"{ty} {ā exportName n} {ā exportExpr t} {ā exportExpr e}"
for l in ls do s := s ++ s!" {ā exportName l}"
IO.println s
insert n
axdef (ty : String) (n : Name) (t : Expr) (ls : List Name) : ExportM Unit := do
let mut s := s!"{ty} {ā exportName n} {ā exportExpr t}"
for l in ls do s := s ++ s!" {ā exportName l}"
IO.println s
insert n
ind : List Name ā ExportM Unit
| [] => unreachable!
| is@(i::_) => do
let val ā getConstInfoInduct i
let mut s := match is.length with
| 1 => s!"#IND {val.numParams}"
| n => s!"#MUT {val.numParams} {n}"
for j in is do insert j; insert (mkRecName j)
for j in is do
let val ā getConstInfoInduct j
s := s ++ s!" {ā exportName val.name} {ā exportExpr val.type} {val.ctors.length}"
for c in val.ctors do
insert c
s := s ++ s!" {ā exportName c} {ā exportExpr (ā getConstInfoCtor c).type}"
for j in is do s ā indbody j s
for l in val.levelParams do s := s ++ s!" {ā exportName l}"
IO.println s
indbody (ind : Name) (s : String) : ExportM String := do
let val ā getConstInfoInduct ind
let mut s := s ++ s!" {ā exportName ind} {ā exportExpr val.type} {val.ctors.length}"
for c in val.ctors do
s := s ++ s!" {ā exportName c} {ā exportExpr (ā getConstInfoCtor c).type}"
pure s
end
def runExportM {α : Type} (m : ExportM α) : CoreM α := m.run' default
-- #eval runExportM (exportDef `Lean.Expr)
end Export
end Lean
|
Util\FormatTable.lean
|
/-
Copyright (c) 2024 Bolton Bailey. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bolton Bailey
-/
import Mathlib.Data.String.Defs
/-!
# Format Table
This file provides a simple function for formatting a two-dimensional array of `String`s
into a markdown-compliant table.
-/
/-- Possible alignment modes for each table item: left-aligned, right-aligned and centered. -/
inductive Alignment where
| left
| right
| center
deriving Inhabited, BEq
/-- Align a `String` `s` to the left, right, or center within a field of width `width`. -/
def String.justify (s : String) (a : Alignment) (width : Nat) : String :=
match a with
| Alignment.left => s.rightpad width
| Alignment.right => s.leftpad width
| Alignment.center =>
let pad := (width - s.length) / 2
String.replicate pad ' ' ++ s ++ String.replicate (width - s.length - pad) ' '
/--
Render a two-dimensional array of `String`s` into a markdown-compliant table.
`headers` is a list of column headers,
`table` is a 2D array of cell contents,
`alignments` describes how to align each table column (default: left-aligned) -/
def formatTable (headers : Array String) (table : Array (Array String))
(alignments : Option (Array Alignment) := none) :
String := Id.run do
-- If no alignments are provided, default to left alignment for all columns.
let alignments := alignments.getD (Array.mkArray headers.size Alignment.left)
-- Compute the maximum width of each column.
let mut widths := headers.map (Ā·.length)
for row in table do
for i in [0:widths.size] do
widths := widths.set! i (max widths[i]! ((row[i]?.map (Ā·.length)).getD 0))
-- Pad each cell with spaces to match the column width.
let paddedHeaders := headers.mapIdx fun i h => h.rightpad widths[i]!
let paddedTable := table.map fun row => row.mapIdx fun i cell =>
cell.justify alignments[i]! widths[i]!
-- Construct the lines of the table
let headerLine := "| " ++ String.intercalate " | " (paddedHeaders.toList) ++ " |"
-- Construct the separator line, with colons to indicate alignment
let separatorLine :=
"| "
++ String.intercalate " | "
(((widths.zip alignments).map fun āØw, aā© =>
match a with
| Alignment.left => ":" ++ String.replicate (w-1) '-'
| Alignment.right => String.replicate (w-1) '-' ++ ":"
| Alignment.center => ":" ++ String.replicate (w-2) '-' ++ ":"
).toList)
++ " |"
let rowLines := paddedTable.map (fun row => "| " ++ String.intercalate " | " (row.toList) ++ " |")
-- Return the table
return String.intercalate "\n" (headerLine :: separatorLine :: rowLines.toList)
|
Util\GetAllModules.lean
|
/-
Copyright (c) 2024 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Kim Morrison, Damiano Testa
-/
import Lean.Util.Path
/-!
# Utility functions for finding all `.lean` files or modules in a project.
TODO:
`getLeanLibs` contains a hard-coded choice of which dependencies should be built and which ones
should not. Could this be made more structural and robust, possibly with extra `Lake` support?
-/
open Lean System.FilePath
/-- `getAllFiles git ml` takes all `.lean` files in the directory `ml`
(recursing into sub-directories) and returns the `Array` of `String`s
```
#[fileā, ..., fileā]
```
of all their file names. These are not sorted in general.
The input `git` is a `Bool`ean flag:
* `true` means that the command uses `git ls-files` to find the relevant files;
* `false` means that the command recursively scans all dirs searching for `.lean` files.
-/
def getAllFiles (git : Bool) (ml : String) : IO (Array System.FilePath) := do
let ml.lean := addExtension āØmlā© "lean" -- for example, `Mathlib.lean`
let allModules : Array System.FilePath ā (do
if git then
let mlDir := ml.push pathSeparator -- for example, `Mathlib/`
let allLean ā IO.Process.run { cmd := "git", args := #["ls-files", mlDir ++ "*.lean"] }
return (((allLean.dropRightWhile (Ā· == '\n')).splitOn "\n").map (āØĀ·ā©)).toArray
else do
let all ā walkDir ml
return all.filter (Ā·.extension == some "lean"))
-- Filter out all files which do not exist.
-- This check is helpful in case the `git` option is on and a local file has been removed.
return ā (allModules.erase ml.lean).filterMapM (fun f ⦠do
if ā pathExists f then pure (some f) else pure none
)
/-- Like `getAllFiles`, but return an array of *module* names instead,
i.e. names of the form `Mathlib.Algebra.Algebra.Basic`.
In addition, these names are sorted in a platform-independent order. -/
def getAllModulesSorted (git : Bool) (ml : String) : IO (Array String) := do
let files ā getAllFiles git ml
let names := ā files.mapM fun f => do
return (ā moduleNameOfFileName f none).toString
return names.qsort (Ā· < Ā·)
|
Util\IncludeStr.lean
|
/-
Copyright (c) 2021 Henrik Bƶving. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Henrik Bƶving, Xubai Wang
-/
import Lean
/-!
# Defines the `include_str` macro.
-/
namespace Mathlib.Util
/-- A term macro that includes the content of a file, as a string. -/
elab (name := includeStr) "include_str " str:str : term => do
let some str := str.1.isStrLit? | Lean.Elab.throwUnsupportedSyntax
let srcPath := System.FilePath.mk (ā Lean.MonadLog.getFileName)
let some srcDir := srcPath.parent | throwError "{srcPath} not in a valid directory"
let path := srcDir / str
Lean.mkStrLit <$> IO.FS.readFile path
|
Util\LongNames.lean
|
/-
Copyright (c) 2023 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Lean.Name
import Mathlib.Lean.Expr.Basic
/-!
# Commands `#long_names` and `#long_instances`
For finding declarations with excessively long names.
-/
open Lean Meta Elab
/-- Helper function for `#long_names` and `#long_instances`. -/
def printNameHashMap (h : Std.HashMap Name (Array Name)) : IO Unit :=
for (m, names) in h.toList do
IO.println "----"
IO.println <| m.toString ++ ":"
for n in names do
IO.println n
/--
Lists all declarations with a long name, gathered according to the module they are defined in.
Use as `#long_names` or `#long_names 100` to specify the length.
-/
elab "#long_names " N:(num)? : command =>
Command.runTermElabM fun _ => do
let N := N.map TSyntax.getNat |>.getD 50
let namesByModule ā allNamesByModule (fun n => n.toString.length > N)
let namesByModule := namesByModule.filter fun m _ => m.getRoot.toString = "Mathlib"
printNameHashMap namesByModule
/--
Lists all instances with a long name beginning with `inst`,
gathered according to the module they are defined in.
This is useful for finding automatically named instances with absurd names.
Use as `#long_names` or `#long_names 100` to specify the length.
-/
elab "#long_instances " N:(num)?: command =>
Command.runTermElabM fun _ => do
let N := N.map TSyntax.getNat |>.getD 50
let namesByModule ā allNamesByModule
(fun n => n.lastComponentAsString.startsWith "inst" && n.lastComponentAsString.length > N)
let namesByModule := namesByModule.filter fun m _ => m.getRoot.toString = "Mathlib"
printNameHashMap namesByModule
|
Util\MemoFix.lean
|
/-
Copyright (c) 2022 Gabriel Ebner. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Gabriel Ebner, E.W.Ayers
-/
import Lean.Data.HashMap
/-!
# Fixpoint function with memoisation
-/
universe u v
open ShareCommon
private unsafe abbrev ObjectMap := @Lean.HashMap Object Object āØObject.ptrEqā© āØObject.hashā©
private unsafe def memoFixImplObj (f : (Object ā Object) ā (Object ā Object)) (a : Object) :
Object := unsafeBaseIO do
let cache : IO.Ref ObjectMap ā ST.mkRef ā
let rec fix (a) := unsafeBaseIO do
if let some b := (ā cache.get).find? a then
return b
let b := f fix a
cache.modify (Ā·.insert a b)
pure b
pure <| fix a
private unsafe def memoFixImpl {α : Type u} {β : Type v} [Nonempty β] :
(f : (α ā β) ā (α ā β)) ā (a : α) ā β :=
unsafeCast memoFixImplObj
/-- Takes the fixpoint of `f` with caching of values that have been seen before.
Hashing makes use of a pointer hash.
This is useful for implementing tree traversal functions where
subtrees may be referenced in multiple places.
-/
@[implemented_by memoFixImpl]
opaque memoFix {α : Type u} {β : Type v} [Nonempty β] (f : (α ā β) ā (α ā β)) : α ā β
|
Util\Qq.lean
|
/-
Copyright (c) 2023 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Alex J. Best
-/
import Qq
/-!
# Extra `Qq` helpers
This file contains some additional functions for using the quote4 library more conveniently.
-/
open Lean Elab Tactic Meta
namespace Qq
/-- Variant of `inferTypeQ` that yields a type in `Type u` rather than `Sort u`.
Throws an error if the type is a `Prop` or if it's otherwise not possible to represent
the universe as `Type u` (for example due to universe level metavariables). -/
-- See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Using.20.60QQ.60.20when.20you.20only.20have.20an.20.60Expr.60/near/303349037
def inferTypeQ' (e : Expr) : MetaM ((u : Level) à (α : Q(Type $u)) à Q($α)) := do
let α ā inferType e
let .sort u ā whnf (ā inferType α) | throwError "not a type{indentExpr α}"
let some v := (ā instantiateLevelMVars u).dec | throwError "not a Type{indentExpr e}"
pure āØv, α, eā©
theorem QuotedDefEq.rfl {u : Level} {α : Q(Sort u)} {a : Q($α)} : @QuotedDefEq u α a a := āØā©
end Qq
|
Util\SleepHeartbeats.lean
|
/-
Copyright (c) 2023 Alex J. Best. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alex J. Best
-/
import Lean.Elab.Tactic.Basic
/-!
# Defines `sleep_heartbeats` tactic.
This is useful for testing / debugging long running commands or elaboration in a somewhat precise
manner.
-/
open Lean Elab
/-- A low level command to sleep for at least a given number of heartbeats by running in a loop
until the desired number of heartbeats is hit.
Warning: this function relies on interpreter / compiler
behaviour that is not guaranteed to function in the way that is relied upon here.
As such this function is not to be considered reliable, especially after future updates to Lean.
This should be used with caution and basically only for demo / testing purposes
and not in compiled code without further testing. -/
def sleepAtLeastHeartbeats (n : Nat) : IO Unit := do
let i ā IO.getNumHeartbeats
while (ā IO.getNumHeartbeats) < i + n do
continue
/-- do nothing for at least n heartbeats -/
elab "sleep_heartbeats " n:num : tactic => do
match Syntax.isNatLit? n with
| none => throwIllFormedSyntax
/- as this is a user facing command we multiply the user input by 1000 to match the maxHeartbeats
option -/
| some m => sleepAtLeastHeartbeats (m * 1000)
example : 1 = 1 := by
sleep_heartbeats 1000
rfl
|
Util\Superscript.lean
|
/-
Copyright (c) 2023 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Batteries.Tactic.Lint
/-!
# A parser for superscripts and subscripts
This is intended for use in local notations. Basic usage is:
```
local syntax:arg term:max superscript(term) : term
local macro_rules | `($a:term $b:superscript) => `($a ^ $b)
```
where `superscript(term)` indicates that it will parse a superscript, and the `$b:superscript`
antiquotation binds the `term` argument of the superscript. Given a notation like this,
the expression `2ā¶ā“` parses and expands to `2 ^ 64`.
The superscript body is considered to be the longest contiguous sequence of superscript tokens and
whitespace, so no additional bracketing is required (unless you want to separate two superscripts).
However, note that Unicode has a rather restricted character set for superscripts and subscripts
(see `Mapping.superscript` and `Mapping.subscript` in this file), so you should not use this
parser for complex expressions.
-/
universe u
namespace Mathlib.Tactic
open Lean Parser PrettyPrinter
namespace Superscript
instance : Hashable Char := āØfun c => hash c.1ā©
/-- A bidirectional character mapping. -/
structure Mapping where
/-- Map from "special" (e.g. superscript) characters to "normal" characters. -/
toNormal : HashMap Char Char := {}
/-- Map from "normal" text to "special" (e.g. superscript) characters. -/
toSpecial : HashMap Char Char := {}
deriving Inhabited
/-- Constructs a mapping (intended for compile time use). Panics on violated invariants. -/
def mkMapping (sā sā : String) : Mapping := Id.run do
let mut toNormal := {}
let mut toSpecial := {}
assert! sā.length == sā.length
for sp in sā.toSubstring, nm in sā do
assert! !toNormal.contains sp
assert! !toSpecial.contains nm
toNormal := toNormal.insert sp nm
toSpecial := toSpecial.insert nm sp
pure { toNormal, toSpecial }
/-- A mapping from superscripts to and from regular text. -/
def Mapping.superscript := mkMapping
"ā°Ā¹Ā²Ā³ā“āµā¶ā·āøā¹įµįµį¶įµįµį¶ įµŹ°ā±Ź²įµĖ”įµāæįµįµš„ʳˢįµįµįµŹ·Ė£Źøį¶»į“¬į“®į“°į“±į“³į““ᓵᓶᓷᓸᓹᓺᓼᓾź“ᓿįµįµā±½įµįµįµįµįµį¶æį¶„ᶹᵠᵔāŗā»ā¼ā½ā¾"
"0123456789abcdefghijklmnopqrstuvwxyzABDEGHIJKLMNOPQRTUVWβγΓεθιĻ
ĻĻ+-=()"
/-- A mapping from subscripts to and from regular text. -/
def Mapping.subscript := mkMapping
"āāāāāā
āāāāāāāᵢⱼāāāāāāįµ£āāᵤᵄāį“Źį“į“
į“ź°É¢ŹÉŖį“į“Źį“É“į“į“źÆŹź±į“į“į“ į“”Źį“¢įµ¦įµ§įµØįµ©įµŖāāāāā"
"0123456789aehijklmnoprstuvxABCDEFGHIJKLMNOPQRSTUVWYZβγĻĻĻ+-=()"
/-- Collects runs of text satisfying `p` followed by whitespace. Fails if the first character does
not satisfy `p`. If `many` is true, it will parse 1 or more many whitespace-separated runs,
otherwise it will parse only 1. If successful, it passes the result to `k` as an array `(a, b, c)`
where `a..b` is a token and `b..c` is whitespace.
-/
partial def satisfyTokensFn (p : Char ā Bool) (errorMsg : String) (many := true)
(k : Array (String.Pos Ć String.Pos Ć String.Pos) ā ParserState ā ParserState) :
ParserFn := fun c s =>
let start := s.pos
let s := takeWhile1Fn p errorMsg c s
if s.hasError then s else
let stop := s.pos
let s := whitespace c s
let toks := #[(start, stop, s.pos)]
if many then
let rec /-- Loop body of `satisfyTokensFn` -/
loop (toks) (s : ParserState) : ParserState :=
let start := s.pos
let s := takeWhileFn p c s
if s.pos == start then k toks s else
let stop := s.pos
let s := whitespace c s
let toks := toks.push (start, stop, s.pos)
loop toks s
loop toks s
else k toks s
variable {α : Type u} [Inhabited α] (as : Array α) (leftOfPartition : α ā Bool) in
/-- Given a predicate `leftOfPartition` which is true for indexes `< i` and false for `ā„ i`,
returns `i`, by binary search. -/
@[specialize] partial def partitionPoint (lo := 0) (hi := as.size) : Nat :=
if lo < hi then
let m := (lo + hi)/2
let a := as.get! m
if leftOfPartition a then
partitionPoint (m+1) hi
else
partitionPoint lo m
else lo
/-- The core function for super/subscript parsing. It consists of three stages:
1. Parse a run of superscripted characters, skipping whitespace and stopping when we hit a
non-superscript character.
2. Un-superscript the text and pass the body to the inner parser (usually `term`).
3. Take the resulting `Syntax` object and align all the positions to fit back into the original
text (which as a side effect also rewrites all the substrings to be in subscript text).
If `many` is false, then whitespace (and comments) are not allowed inside the superscript.
-/
partial def scriptFnNoAntiquot (m : Mapping) (errorMsg : String) (p : ParserFn)
(many := true) : ParserFn := fun c s =>
let start := s.pos
satisfyTokensFn m.toNormal.contains errorMsg many c s (k := fun toks s => Id.run do
let input := c.input
let mut newStr := ""
-- This consists of a sorted array of `(from, to)` pairs, where indexes `from+i` in `newStr`
-- such that `from+i < from'` for the next element of the array, are mapped to `to+i`.
let mut aligns := #[((0 : String.Pos), start)]
for (start, stopTk, stopWs) in toks do
let mut pos := start
while pos < stopTk do
let c := input.get pos
let c' := m.toNormal.find! c
newStr := newStr.push c'
pos := pos + c
if c.utf8Size != c'.utf8Size then
aligns := aligns.push (newStr.endPos, pos)
newStr := newStr.push ' '
if stopWs.1 - stopTk.1 != 1 then
aligns := aligns.push (newStr.endPos, stopWs)
let ictx := mkInputContext newStr "<superscript>"
let s' := p.run ictx c.toParserModuleContext c.tokens (mkParserState newStr)
let rec /-- Applies the alignment mapping to a position. -/
align (pos : String.Pos) :=
let i := partitionPoint aligns (·.1 ⤠pos)
let (a, b) := aligns[i - 1]!
pos - a + b
let s := { s with pos := align s'.pos, errorMsg := s'.errorMsg }
if s.hasError then return s
let rec
/-- Applies the alignment mapping to a `Substring`. -/
alignSubstr : Substring ā Substring
| āØ_newStr, start, stopā© => āØinput, align start, align stopā©,
/-- Applies the alignment mapping to a `SourceInfo`. -/
alignInfo : SourceInfo ā SourceInfo
| .original leading pos trailing endPos =>
-- Marking these as original breaks semantic highlighting,
-- marking them as canonical breaks the unused variables linter. :(
.original (alignSubstr leading) (align pos) (alignSubstr trailing) (align endPos)
| .synthetic pos endPos canonical =>
.synthetic (align pos) (align endPos) canonical
| .none => .none,
/-- Applies the alignment mapping to a `Syntax`. -/
alignSyntax : Syntax ā Syntax
| .missing => .missing
| .node info kind args => .node (alignInfo info) kind (args.map alignSyntax)
| .atom info val =>
-- We have to preserve the unsubscripted `val` even though it breaks `Syntax.reprint`
-- because basic parsers like `num` read the `val` directly
.atom (alignInfo info) val
| .ident info rawVal val preresolved =>
.ident (alignInfo info) (alignSubstr rawVal) val preresolved
s.pushSyntax (alignSyntax s'.stxStack.back)
)
/-- The super/subscript parser.
* `m`: the character mapping
* `antiquotName`: the name to use for antiquotation bindings `$a:antiquotName`.
Note that the actual syntax kind bound will be the body kind (parsed by `p`), not `kind`.
* `errorMsg`: shown when the parser does not match
* `p`: the inner parser (usually `term`), to be called on the body of the superscript
* `many`: if false, whitespace is not allowed inside the superscript
* `kind`: the term will be wrapped in a node with this kind
-/
def scriptParser (m : Mapping) (antiquotName errorMsg : String) (p : Parser)
(many := true) (kind : SyntaxNodeKind := by exact decl_name%) : Parser :=
let tokens := "$" :: (m.toNormal.toArray.map (Ā·.1.toString) |>.qsort (Ā·<Ā·)).toList
let antiquotP := mkAntiquot antiquotName `term (isPseudoKind := true)
let p := Superscript.scriptFnNoAntiquot m errorMsg p.fn many
node kind {
info.firstTokens := .tokens tokens
info.collectTokens := (tokens ++ Ā·)
fn := withAntiquotFn antiquotP.fn p (isCatAntiquot := true)
}
/-- Parenthesizer for the script parser. -/
def scriptParser.parenthesizer (k : SyntaxNodeKind) (p : Parenthesizer) : Parenthesizer :=
Parenthesizer.node.parenthesizer k p
/-- Map over the strings in a `Format`. -/
def _root_.Std.Format.mapStringsM {m} [Monad m] (f : Format) (f' : String ā m String) : m Format :=
match f with
| .group f b => (.group Ā· b) <$> Std.Format.mapStringsM f f'
| .tag t g => .tag t <$> Std.Format.mapStringsM g f'
| .append f g => .append <$> Std.Format.mapStringsM f f' <*> Std.Format.mapStringsM g f'
| .nest n f => .nest n <$> Std.Format.mapStringsM f f'
| .text s => .text <$> f' s
| .align _ | .line | .nil => pure f
/-- Formatter for the script parser. -/
def scriptParser.formatter (name : String) (m : Mapping) (k : SyntaxNodeKind) (p : Formatter) :
Formatter := do
let stack ā modifyGet fun s => (s.stack, {s with stack := #[]})
Formatter.node.formatter k p
let st ā get
let transformed : Except String _ := st.stack.mapM (Ā·.mapStringsM fun s => do
let .some s := s.toList.mapM (m.toSpecial.insert ' ' ' ').find? | .error s
.ok āØsā©)
match transformed with
| .error err =>
-- TODO: this only appears if the caller explicitly calls the pretty-printer
Lean.logErrorAt (ā get).stxTrav.cur s!"Not a {name}: '{err}'"
set { st with stack := stack ++ st.stack }
| .ok newStack =>
set { st with stack := stack ++ newStack }
end Superscript
/--
The parser `superscript(term)` parses a superscript. Basic usage is:
```
local syntax:arg term:max superscript(term) : term
local macro_rules | `($a:term $b:superscript) => `($a ^ $b)
```
Given a notation like this, the expression `2ā¶ā“` parses and expands to `2 ^ 64`.
Note that because of Unicode limitations, not many characters can actually be typed inside the
superscript, so this should not be used for complex expressions. Legal superscript characters:
```
ā°Ā¹Ā²Ā³ā“āµā¶ā·āøā¹įµįµį¶įµįµį¶ įµŹ°ā±Ź²įµĖ”įµāæįµįµš„ʳˢįµįµįµŹ·Ė£Źøį¶»į“¬į“®į“°į“±į“³į““ᓵᓶᓷᓸᓹᓺᓼᓾź“ᓿįµįµā±½įµįµįµįµįµį¶æį¶„ᶹᵠᵔāŗā»ā¼ā½ā¾
```
-/
def superscript (p : Parser) : Parser :=
Superscript.scriptParser .superscript "superscript" "expected superscript character" p
/-- Formatter for the superscript parser. -/
@[combinator_parenthesizer superscript]
def superscript.parenthesizer := Superscript.scriptParser.parenthesizer ``superscript
/-- Formatter for the superscript parser. -/
@[combinator_formatter superscript]
def superscript.formatter :=
Superscript.scriptParser.formatter "superscript" .superscript ``superscript
/--
The parser `subscript(term)` parses a subscript. Basic usage is:
```
local syntax:arg term:max subscript(term) : term
local macro_rules | `($a:term $i:subscript) => `($a $i)
```
Given a notation like this, the expression `(a)įµ¢` parses and expands to `a i`. (Either parentheses
or a whitespace as in `a įµ¢` is required, because `aįµ¢` is considered as an identifier.)
Note that because of Unicode limitations, not many characters can actually be typed inside the
subscript, so this should not be used for complex expressions. Legal subscript characters:
```
āāāāāā
āāāāāāāᵢⱼāāāāāāįµ£āāᵤᵄāį“Źį“į“
į“ź°É¢ŹÉŖį“į“Źį“É“į“į“źÆŹź±į“į“į“ į“”Źį“¢įµ¦įµ§įµØįµ©įµŖāāāāā
```
-/
def subscript (p : Parser) : Parser :=
Superscript.scriptParser .subscript "subscript" "expected subscript character" p
/-- Formatter for the subscript parser. -/
@[combinator_parenthesizer subscript]
def subscript.parenthesizer := Superscript.scriptParser.parenthesizer ``subscript
/-- Formatter for the subscript parser. -/
@[combinator_formatter subscript]
def subscript.formatter := Superscript.scriptParser.formatter "subscript" .subscript ``subscript
initialize
registerAlias `superscript ``superscript superscript
registerAliasCore Formatter.formatterAliasesRef `superscript superscript.formatter
registerAliasCore Parenthesizer.parenthesizerAliasesRef `superscript superscript.parenthesizer
registerAlias `subscript ``subscript subscript
registerAliasCore Formatter.formatterAliasesRef `subscript subscript.formatter
registerAliasCore Parenthesizer.parenthesizerAliasesRef `subscript subscript.parenthesizer
|
Util\SynthesizeUsing.lean
|
/-
Copyright (c) 2022 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Lean.Elab.Tactic.Basic
import Qq
/-!
# `SynthesizeUsing`
This is a slight simplification of the `solve_aux` tactic in Lean3.
-/
open Lean Elab Tactic Meta Qq
/--
`synthesizeUsing type tac` synthesizes an element of type `type` using tactic `tac`.
The tactic `tac` is allowed to leave goals open, and these remain as metavariables in the
returned expression.
-/
-- In Lean3 this was called `solve_aux`,
-- and took a `TacticM α` and captured the produced value in `α`.
-- As this was barely used, we've simplified here.
def synthesizeUsing {u : Level} (type : Q(Sort u)) (tac : TacticM Unit) :
MetaM (List MVarId Ć Q($type)) := do
let m ā mkFreshExprMVar type
let goals ā (Term.withoutErrToSorry <| run m.mvarId! tac).run'
return (goals, ā instantiateMVars m)
/--
`synthesizeUsing type tac` synthesizes an element of type `type` using tactic `tac`.
The tactic must solve for all goals, in contrast to `synthesizeUsing`.
-/
def synthesizeUsing' {u : Level} (type : Q(Sort u)) (tac : TacticM Unit) : MetaM Q($type) := do
let (goals, e) ā synthesizeUsing type tac
-- Note: doesn't use `tac *> Tactic.done` since that just adds a message
-- rather than raising an error.
unless goals.isEmpty do
throwError m!"synthesizeUsing': unsolved goals\n{goalsToMessageData goals}"
return e
/--
`synthesizeUsing type tacticSyntax` synthesizes an element of type `type` by evaluating the
given tactic syntax.
Example:
```lean
let (gs, e) ā synthesizeUsingTactic ty (ā `(tactic| congr!))
```
The tactic `tac` is allowed to leave goals open, and these remain as metavariables in the
returned expression.
-/
def synthesizeUsingTactic {u : Level} (type : Q(Sort u)) (tac : Syntax) :
MetaM (List MVarId Ć Q($type)) := do
synthesizeUsing type (do evalTactic tac)
/--
`synthesizeUsing' type tacticSyntax` synthesizes an element of type `type` by evaluating the
given tactic syntax.
Example:
```lean
let e ā synthesizeUsingTactic' ty (ā `(tactic| norm_num))
```
The tactic must solve for all goals, in contrast to `synthesizeUsingTactic`.
If you need to insert expressions into a tactic proof, then you might use `synthesizeUsing'`
directly, since the `TacticM` monad has access to the `TermElabM` monad. For example, here
is a term elaborator that wraps the `simp at ...` tactic:
```
def simpTerm (e : Expr) : MetaM Expr := do
let mvar ā Meta.mkFreshTypeMVar
let e' ā synthesizeUsing' mvar
(do evalTactic (ā `(tactic| have h := $(ā Term.exprToSyntax e); simp at h; exact h)))
-- Note: `simp` does not always insert type hints, so to ensure that we get a term
-- with the simplified type (as opposed to one that is merely defeq), we should add
-- a type hint ourselves.
Meta.mkExpectedTypeHint e' mvar
elab "simpTerm% " t:term : term => do simpTerm (ā Term.elabTerm t none)
```
-/
def synthesizeUsingTactic' {u : Level} (type : Q(Sort u)) (tac : Syntax) : MetaM Q($type) := do
synthesizeUsing' type (do evalTactic tac)
|
Util\Tactic.lean
|
/-
Copyright (c) 2022 Arthur Paulino. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Arthur Paulino, Jannis Limperg
-/
import Lean.MetavarContext
/-!
# Miscellaneous helper functions for tactics.
[TODO] Ideally we would find good homes for everything in this file, eventually removing it.
-/
namespace Mathlib.Tactic
open Lean Meta Tactic
variable {m : Type ā Type} [Monad m]
/--
`modifyMetavarDecl mvarId f` updates the `MetavarDecl` for `mvarId` with `f`.
Conditions on `f`:
- The target of `f mdecl` is defeq to the target of `mdecl`.
- The local context of `f mdecl` must contain the same fvars as the local
context of `mdecl`. For each fvar in the local context of `f mdecl`, the type
(and value, if any) of the fvar must be defeq to the corresponding fvar in
the local context of `mdecl`.
If `mvarId` does not refer to a declared metavariable, nothing happens.
-/
def modifyMetavarDecl [MonadMCtx m] (mvarId : MVarId)
(f : MetavarDecl ā MetavarDecl) : m Unit := do
modifyMCtx fun mctx ā¦
match mctx.decls.find? mvarId with
| none => mctx
| some mdecl => { mctx with decls := mctx.decls.insert mvarId (f mdecl) }
/--
`modifyTarget mvarId f` updates the target of the metavariable `mvarId` with
`f`. For any `e`, `f e` must be defeq to `e`. If `mvarId` does not refer to
a declared metavariable, nothing happens.
-/
def modifyTarget [MonadMCtx m] (mvarId : MVarId) (f : Expr ā Expr) : m Unit :=
modifyMetavarDecl mvarId fun mdecl ā¦
{ mdecl with type := f mdecl.type }
/--
`modifyLocalContext mvarId f` updates the local context of the metavariable
`mvarId` with `f`. The new local context must contain the same fvars as the old
local context and the types (and values, if any) of the fvars in the new local
context must be defeq to their equivalents in the old local context.
If `mvarId` does not refer to a declared metavariable, nothing happens.
-/
def modifyLocalContext [MonadMCtx m] (mvarId : MVarId)
(f : LocalContext ā LocalContext) : m Unit :=
modifyMetavarDecl mvarId fun mdecl ā¦
{ mdecl with lctx := f mdecl.lctx }
/--
`modifyLocalDecl mvarId fvarId f` updates the local decl `fvarId` in the local
context of `mvarId` with `f`. `f` must leave the `fvarId` and `index` of the
`LocalDecl` unchanged. The type of the new `LocalDecl` must be defeq to the type
of the old `LocalDecl` (and the same applies to the value of the `LocalDecl`, if
any).
If `mvarId` does not refer to a declared metavariable or if `fvarId` does not
exist in the local context of `mvarId`, nothing happens.
-/
def modifyLocalDecl [MonadMCtx m] (mvarId : MVarId) (fvarId : FVarId)
(f : LocalDecl ā LocalDecl) : m Unit :=
modifyLocalContext mvarId fun lctx ⦠lctx.modifyLocalDecl fvarId f
|
Util\TermBeta.lean
|
/-
Copyright (c) 2023 Kyle Miller. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kyle Miller
-/
import Lean.Elab.Term
/-! `beta%` term elaborator
The `beta% f x1 ... xn` term elaborator elaborates the expression
`f x1 ... xn` and then does one level of beta reduction.
That is, if `f` is a lambda then it will substitute its arguments.
The purpose of this is to support substitutions in notations such as
`ā i, beta% p i` so that `p i` gets beta reduced when `p` is a lambda.
-/
namespace Mathlib.Util.TermBeta
open Lean Elab Term
/-- `beta% t` elaborates `t` and then if the result is in the form
`f x1 ... xn` where `f` is a (nested) lambda expression,
it will substitute all of its arguments by beta reduction.
This does not recursively do beta reduction, nor will it do
beta reduction of subexpressions.
In particular, `t` is elaborated, its metavariables are instantiated,
and then `Lean.Expr.headBeta` is applied. -/
syntax (name := betaStx) "beta% " term : term
@[term_elab betaStx, inherit_doc betaStx]
def elabBeta : TermElab := fun stx expectedType? =>
match stx with
| `(beta% $t) => do
let e ā elabTerm t expectedType?
return (ā instantiateMVars e).headBeta
| _ => throwUnsupportedSyntax
|
Util\Time.lean
|
/-
Copyright (c) 2021 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Lean
/-!
# Defines `#time` command.
Time the elaboration of a command, and print the result (in milliseconds).
-/
section
open Lean Elab Command
syntax (name := timeCmd) "#time " command : command
/--
Time the elaboration of a command, and print the result (in milliseconds).
Example usage:
```
set_option maxRecDepth 100000 in
#time example : (List.range 500).length = 500 := rfl
```
-/
@[command_elab timeCmd] def timeCmdElab : CommandElab
| `(#time%$tk $stx:command) => do
let start ā IO.monoMsNow
elabCommand stx
logInfoAt tk m!"time: {(ā IO.monoMsNow) - start}ms"
| _ => throwUnsupportedSyntax
end
|
Util\WhatsNew.lean
|
/-
Copyright (c) 2021 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Gabriel Ebner
-/
import Lean
/-!
Defines a command wrapper that prints the changes the command makes to the
environment.
```
whatsnew in
theorem foo : 42 = 6 * 7 := rfl
```
-/
open Lean Elab Command
namespace Mathlib.WhatsNew
private def throwUnknownId (id : Name) : CommandElabM Unit :=
throwError "unknown identifier '{mkConst id}'"
private def levelParamsToMessageData (levelParams : List Name) : MessageData :=
match levelParams with
| [] => ""
| u::us => Id.run <| do
let mut m := m!".\{{u}"
for u in us do
m := m ++ ", " ++ toMessageData u
return m ++ "}"
private def mkHeader (kind : String) (id : Name) (levelParams : List Name) (type : Expr)
(safety : DefinitionSafety) : CoreM MessageData := do
let m : MessageData :=
match safety with
| DefinitionSafety.unsafe => "unsafe "
| DefinitionSafety.partial => "partial "
| DefinitionSafety.safe => ""
let m := if isProtected (ā getEnv) id then m ++ "protected " else m
let (m, id) := match privateToUserName? id with
| some id => (m ++ "private ", id)
| none => (m, id)
let m := m ++ kind ++ " " ++ id ++ levelParamsToMessageData levelParams ++ " : " ++ type
pure m
private def mkHeader' (kind : String) (id : Name) (levelParams : List Name) (type : Expr)
(isUnsafe : Bool) : CoreM MessageData :=
mkHeader kind id levelParams type
(if isUnsafe then DefinitionSafety.unsafe else DefinitionSafety.safe)
private def printDefLike (kind : String) (id : Name) (levelParams : List Name) (type : Expr)
(value : Expr) (safety := DefinitionSafety.safe) : CoreM MessageData :=
return (ā mkHeader kind id levelParams type safety) ++ " :=" ++ Format.line ++ value
private def printInduct (id : Name) (levelParams : List Name) (_numParams : Nat) (_numIndices : Nat)
(type : Expr) (ctors : List Name) (isUnsafe : Bool) : CoreM MessageData := do
let mut m ā mkHeader' "inductive" id levelParams type isUnsafe
m := m ++ Format.line ++ "constructors:"
for ctor in ctors do
let cinfo ā getConstInfo ctor
m := m ++ Format.line ++ ctor ++ " : " ++ cinfo.type
pure m
private def printIdCore (id : Name) : ConstantInfo ā CoreM MessageData
| ConstantInfo.axiomInfo { levelParams := us, type := t, isUnsafe := u, .. } =>
mkHeader' "axiom" id us t u
| ConstantInfo.defnInfo { levelParams := us, type := t, value := v, safety := s, .. } =>
printDefLike "def" id us t v s
| ConstantInfo.thmInfo { levelParams := us, type := t, value := v, .. } =>
printDefLike "theorem" id us t v
| ConstantInfo.opaqueInfo { levelParams := us, type := t, isUnsafe := u, .. } =>
mkHeader' "constant" id us t u
| ConstantInfo.quotInfo { levelParams := us, type := t, .. } =>
mkHeader' "Quotient primitive" id us t false
| ConstantInfo.ctorInfo { levelParams := us, type := t, isUnsafe := u, .. } =>
mkHeader' "constructor" id us t u
| ConstantInfo.recInfo { levelParams := us, type := t, isUnsafe := u, .. } =>
mkHeader' "recursor" id us t u
| ConstantInfo.inductInfo
{ levelParams := us, numParams, numIndices, type := t, ctors, isUnsafe := u, .. } =>
printInduct id us numParams numIndices t ctors u
def diffExtension (old new : Environment)
(ext : PersistentEnvExtension EnvExtensionEntry EnvExtensionEntry EnvExtensionState) :
CoreM (Option MessageData) := unsafe do
let oldSt := ext.toEnvExtension.getState old
let newSt := ext.toEnvExtension.getState new
if ptrAddrUnsafe oldSt == ptrAddrUnsafe newSt then return none
let oldEntries := ext.exportEntriesFn oldSt.state
let newEntries := ext.exportEntriesFn newSt.state
pure m!"-- {ext.name} extension: {(newEntries.size - oldEntries.size : Int)} new entries"
def whatsNew (old new : Environment) : CoreM MessageData := do
let mut diffs := #[]
for (c, i) in new.constants.mapā.toList do
unless old.constants.mapā.contains c do
diffs := diffs.push (ā printIdCore c i)
for ext in ā persistentEnvExtensionsRef.get do
if let some diff := ā diffExtension old new ext then
diffs := diffs.push diff
if diffs.isEmpty then return "no new constants"
pure <| MessageData.joinSep diffs.toList "\n\n"
/-- `whatsnew in $command` executes the command and then prints the
declarations that were added to the environment. -/
elab "whatsnew " "in" ppLine cmd:command : command => do
let oldEnv ā getEnv
try
elabCommand cmd
finally
let newEnv ā getEnv
logInfo (ā liftCoreM <| whatsNew oldEnv newEnv)
|
Util\WithWeakNamespace.lean
|
/-
Copyright (c) 2021 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Daniel Selsam, Gabriel Ebner
-/
import Lean
/-!
# Defines `with_weak_namespace` command.
Changes the current namespace without causing scoped things to go out of scope.
-/
namespace Lean.Elab.Command
/-- Adds the name to the namespace, `_root_`-aware.
```
resolveNamespace `A `B.b == `A.B.b
resolveNamespace `A `_root_.B.c == `B.c
```
-/
def resolveNamespace (ns : Name) : Name ā Name
| `_root_ => Name.anonymous
| Name.str n s .. => Name.mkStr (resolveNamespace ns n) s
| Name.num n i .. => Name.mkNum (resolveNamespace ns n) i
| Name.anonymous => ns
/-- Changes the current namespace without causing scoped things to go out of scope -/
def withWeakNamespace {α : Type} (ns : Name) (m : CommandElabM α) : CommandElabM α := do
let old ā getCurrNamespace
let ns := resolveNamespace old ns
modify fun s ⦠{ s with env := s.env.registerNamespace ns }
modifyScope ({ Ā· with currNamespace := ns })
try m finally modifyScope ({ Ā· with currNamespace := old })
/-- Changes the current namespace without causing scoped things to go out of scope -/
elab "with_weak_namespace " ns:ident cmd:command : command =>
withWeakNamespace ns.getId (elabCommand cmd)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.