path stringlengths 11 71 | content stringlengths 75 124k |
|---|---|
Topology\MetricSpace\Algebra.lean | /-
Copyright (c) 2021 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
-/
import Mathlib.Topology.Algebra.MulAction
import Mathlib.Topology.MetricSpace.Lipschitz
/-!
# Compatibility of algebraic operations with metric space structures
In this file we define mixin typeclasses `LipschitzMul`, `LipschitzAdd`,
`BoundedSMul` expressing compatibility of multiplication, addition and scalar-multiplication
operations with an underlying metric space structure. The intended use case is to abstract certain
properties shared by normed groups and by `R≥0`.
## Implementation notes
We deduce a `ContinuousMul` instance from `LipschitzMul`, etc. In principle there should
be an intermediate typeclass for uniform spaces, but the algebraic hierarchy there (see
`UniformGroup`) is structured differently.
-/
open NNReal
noncomputable section
variable (α β : Type*) [PseudoMetricSpace α] [PseudoMetricSpace β]
section LipschitzMul
/-- Class `LipschitzAdd M` says that the addition `(+) : X × X → X` is Lipschitz jointly in
the two arguments. -/
class LipschitzAdd [AddMonoid β] : Prop where
lipschitz_add : ∃ C, LipschitzWith C fun p : β × β => p.1 + p.2
/-- Class `LipschitzMul M` says that the multiplication `(*) : X × X → X` is Lipschitz jointly
in the two arguments. -/
@[to_additive]
class LipschitzMul [Monoid β] : Prop where
lipschitz_mul : ∃ C, LipschitzWith C fun p : β × β => p.1 * p.2
/-- The Lipschitz constant of an `AddMonoid` `β` satisfying `LipschitzAdd` -/
def LipschitzAdd.C [AddMonoid β] [_i : LipschitzAdd β] : ℝ≥0 := Classical.choose _i.lipschitz_add
variable [Monoid β]
/-- The Lipschitz constant of a monoid `β` satisfying `LipschitzMul` -/
@[to_additive existing] -- Porting note: had to add `LipschitzAdd.C`. to_additive silently failed
def LipschitzMul.C [_i : LipschitzMul β] : ℝ≥0 := Classical.choose _i.lipschitz_mul
variable {β}
@[to_additive]
theorem lipschitzWith_lipschitz_const_mul_edist [_i : LipschitzMul β] :
LipschitzWith (LipschitzMul.C β) fun p : β × β => p.1 * p.2 :=
Classical.choose_spec _i.lipschitz_mul
variable [LipschitzMul β]
@[to_additive]
theorem lipschitz_with_lipschitz_const_mul :
∀ p q : β × β, dist (p.1 * p.2) (q.1 * q.2) ≤ LipschitzMul.C β * dist p q := by
rw [← lipschitzWith_iff_dist_le_mul]
exact lipschitzWith_lipschitz_const_mul_edist
-- see Note [lower instance priority]
@[to_additive]
instance (priority := 100) LipschitzMul.continuousMul : ContinuousMul β :=
⟨lipschitzWith_lipschitz_const_mul_edist.continuous⟩
@[to_additive]
instance Submonoid.lipschitzMul (s : Submonoid β) : LipschitzMul s where
lipschitz_mul := ⟨LipschitzMul.C β, by
rintro ⟨x₁, x₂⟩ ⟨y₁, y₂⟩
convert lipschitzWith_lipschitz_const_mul_edist ⟨(x₁ : β), x₂⟩ ⟨y₁, y₂⟩ using 1⟩
@[to_additive]
instance MulOpposite.lipschitzMul : LipschitzMul βᵐᵒᵖ where
lipschitz_mul := ⟨LipschitzMul.C β, fun ⟨x₁, x₂⟩ ⟨y₁, y₂⟩ =>
(lipschitzWith_lipschitz_const_mul_edist ⟨x₂.unop, x₁.unop⟩ ⟨y₂.unop, y₁.unop⟩).trans_eq
(congr_arg _ <| max_comm _ _)⟩
-- this instance could be deduced from `NormedAddCommGroup.lipschitzAdd`, but we prove it
-- separately here so that it is available earlier in the hierarchy
instance Real.hasLipschitzAdd : LipschitzAdd ℝ where
lipschitz_add := ⟨2, LipschitzWith.of_dist_le_mul fun p q => by
simp only [Real.dist_eq, Prod.dist_eq, Prod.fst_sub, Prod.snd_sub, NNReal.coe_ofNat,
add_sub_add_comm, two_mul]
refine le_trans (abs_add (p.1 - q.1) (p.2 - q.2)) ?_
exact add_le_add (le_max_left _ _) (le_max_right _ _)⟩
-- this instance has the same proof as `AddSubmonoid.lipschitzAdd`, but the former can't
-- directly be applied here since `ℝ≥0` is a subtype of `ℝ`, not an additive submonoid.
instance NNReal.hasLipschitzAdd : LipschitzAdd ℝ≥0 where
lipschitz_add := ⟨LipschitzAdd.C ℝ, by
rintro ⟨x₁, x₂⟩ ⟨y₁, y₂⟩
exact lipschitzWith_lipschitz_const_add_edist ⟨(x₁ : ℝ), x₂⟩ ⟨y₁, y₂⟩⟩
end LipschitzMul
section BoundedSMul
variable [Zero α] [Zero β] [SMul α β]
/-- Mixin typeclass on a scalar action of a metric space `α` on a metric space `β` both with
distinguished points `0`, requiring compatibility of the action in the sense that
`dist (x • y₁) (x • y₂) ≤ dist x 0 * dist y₁ y₂` and
`dist (x₁ • y) (x₂ • y) ≤ dist x₁ x₂ * dist y 0`. -/
class BoundedSMul : Prop where
dist_smul_pair' : ∀ x : α, ∀ y₁ y₂ : β, dist (x • y₁) (x • y₂) ≤ dist x 0 * dist y₁ y₂
dist_pair_smul' : ∀ x₁ x₂ : α, ∀ y : β, dist (x₁ • y) (x₂ • y) ≤ dist x₁ x₂ * dist y 0
variable {α β}
variable [BoundedSMul α β]
theorem dist_smul_pair (x : α) (y₁ y₂ : β) : dist (x • y₁) (x • y₂) ≤ dist x 0 * dist y₁ y₂ :=
BoundedSMul.dist_smul_pair' x y₁ y₂
theorem dist_pair_smul (x₁ x₂ : α) (y : β) : dist (x₁ • y) (x₂ • y) ≤ dist x₁ x₂ * dist y 0 :=
BoundedSMul.dist_pair_smul' x₁ x₂ y
-- see Note [lower instance priority]
/-- The typeclass `BoundedSMul` on a metric-space scalar action implies continuity of the action. -/
instance (priority := 100) BoundedSMul.continuousSMul : ContinuousSMul α β where
continuous_smul := by
rw [Metric.continuous_iff]
rintro ⟨a, b⟩ ε ε0
obtain ⟨δ, δ0, hδε⟩ : ∃ δ > 0, δ * (δ + dist b 0) + dist a 0 * δ < ε := by
have : Continuous fun δ ↦ δ * (δ + dist b 0) + dist a 0 * δ := by fun_prop
refine ((this.tendsto' _ _ ?_).eventually (gt_mem_nhds ε0)).exists_gt
simp
refine ⟨δ, δ0, fun (a', b') hab' => ?_⟩
obtain ⟨ha, hb⟩ := max_lt_iff.1 hab'
calc dist (a' • b') (a • b)
≤ dist (a' • b') (a • b') + dist (a • b') (a • b) := dist_triangle ..
_ ≤ dist a' a * dist b' 0 + dist a 0 * dist b' b :=
add_le_add (dist_pair_smul _ _ _) (dist_smul_pair _ _ _)
_ ≤ δ * (δ + dist b 0) + dist a 0 * δ := by
have : dist b' 0 ≤ δ + dist b 0 := (dist_triangle _ _ _).trans <| add_le_add_right hb.le _
gcongr
_ < ε := hδε
-- this instance could be deduced from `NormedSpace.boundedSMul`, but we prove it separately
-- here so that it is available earlier in the hierarchy
instance Real.boundedSMul : BoundedSMul ℝ ℝ where
dist_smul_pair' x y₁ y₂ := by simpa [Real.dist_eq, mul_sub] using (abs_mul x (y₁ - y₂)).le
dist_pair_smul' x₁ x₂ y := by simpa [Real.dist_eq, sub_mul] using (abs_mul (x₁ - x₂) y).le
instance NNReal.boundedSMul : BoundedSMul ℝ≥0 ℝ≥0 where
dist_smul_pair' x y₁ y₂ := by convert dist_smul_pair (x : ℝ) (y₁ : ℝ) y₂ using 1
dist_pair_smul' x₁ x₂ y := by convert dist_pair_smul (x₁ : ℝ) x₂ (y : ℝ) using 1
/-- If a scalar is central, then its right action is bounded when its left action is. -/
instance BoundedSMul.op [SMul αᵐᵒᵖ β] [IsCentralScalar α β] : BoundedSMul αᵐᵒᵖ β where
dist_smul_pair' :=
MulOpposite.rec' fun x y₁ y₂ => by simpa only [op_smul_eq_smul] using dist_smul_pair x y₁ y₂
dist_pair_smul' :=
MulOpposite.rec' fun x₁ =>
MulOpposite.rec' fun x₂ y => by simpa only [op_smul_eq_smul] using dist_pair_smul x₁ x₂ y
end BoundedSMul
instance [Monoid α] [LipschitzMul α] : LipschitzAdd (Additive α) :=
⟨@LipschitzMul.lipschitz_mul α _ _ _⟩
instance [AddMonoid α] [LipschitzAdd α] : LipschitzMul (Multiplicative α) :=
⟨@LipschitzAdd.lipschitz_add α _ _ _⟩
@[to_additive]
instance [Monoid α] [LipschitzMul α] : LipschitzMul αᵒᵈ :=
‹LipschitzMul α›
variable {ι : Type*} [Fintype ι]
instance Pi.instBoundedSMul {α : Type*} {β : ι → Type*} [PseudoMetricSpace α]
[∀ i, PseudoMetricSpace (β i)] [Zero α] [∀ i, Zero (β i)] [∀ i, SMul α (β i)]
[∀ i, BoundedSMul α (β i)] : BoundedSMul α (∀ i, β i) where
dist_smul_pair' x y₁ y₂ :=
(dist_pi_le_iff <| by positivity).2 fun i ↦
(dist_smul_pair _ _ _).trans <| mul_le_mul_of_nonneg_left (dist_le_pi_dist _ _ _) dist_nonneg
dist_pair_smul' x₁ x₂ y :=
(dist_pi_le_iff <| by positivity).2 fun i ↦
(dist_pair_smul _ _ _).trans <| mul_le_mul_of_nonneg_left (dist_le_pi_dist _ 0 _) dist_nonneg
instance Pi.instBoundedSMul' {α β : ι → Type*} [∀ i, PseudoMetricSpace (α i)]
[∀ i, PseudoMetricSpace (β i)] [∀ i, Zero (α i)] [∀ i, Zero (β i)] [∀ i, SMul (α i) (β i)]
[∀ i, BoundedSMul (α i) (β i)] : BoundedSMul (∀ i, α i) (∀ i, β i) where
dist_smul_pair' x y₁ y₂ :=
(dist_pi_le_iff <| by positivity).2 fun i ↦
(dist_smul_pair _ _ _).trans <|
mul_le_mul (dist_le_pi_dist _ 0 _) (dist_le_pi_dist _ _ _) dist_nonneg dist_nonneg
dist_pair_smul' x₁ x₂ y :=
(dist_pi_le_iff <| by positivity).2 fun i ↦
(dist_pair_smul _ _ _).trans <|
mul_le_mul (dist_le_pi_dist _ _ _) (dist_le_pi_dist _ 0 _) dist_nonneg dist_nonneg
instance Prod.instBoundedSMul {α β γ : Type*} [PseudoMetricSpace α] [PseudoMetricSpace β]
[PseudoMetricSpace γ] [Zero α] [Zero β] [Zero γ] [SMul α β] [SMul α γ] [BoundedSMul α β]
[BoundedSMul α γ] : BoundedSMul α (β × γ) where
dist_smul_pair' _x _y₁ _y₂ :=
max_le ((dist_smul_pair _ _ _).trans <| mul_le_mul_of_nonneg_left (le_max_left _ _) dist_nonneg)
((dist_smul_pair _ _ _).trans <| mul_le_mul_of_nonneg_left (le_max_right _ _) dist_nonneg)
dist_pair_smul' _x₁ _x₂ _y :=
max_le ((dist_pair_smul _ _ _).trans <| mul_le_mul_of_nonneg_left (le_max_left _ _) dist_nonneg)
((dist_pair_smul _ _ _).trans <| mul_le_mul_of_nonneg_left (le_max_right _ _) dist_nonneg)
-- We don't have the `SMul α γ → SMul β δ → SMul (α × β) (γ × δ)` instance, but if we did, then
-- `BoundedSMul α γ → BoundedSMul β δ → BoundedSMul (α × β) (γ × δ)` would hold
|
Topology\MetricSpace\Antilipschitz.lean | /-
Copyright (c) 2020 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Topology.UniformSpace.CompleteSeparated
import Mathlib.Topology.EMetricSpace.Lipschitz
import Mathlib.Topology.MetricSpace.Basic
import Mathlib.Topology.MetricSpace.Bounded
/-!
# Antilipschitz functions
We say that a map `f : α → β` between two (extended) metric spaces is
`AntilipschitzWith K`, `K ≥ 0`, if for all `x, y` we have `edist x y ≤ K * edist (f x) (f y)`.
For a metric space, the latter inequality is equivalent to `dist x y ≤ K * dist (f x) (f y)`.
## Implementation notes
The parameter `K` has type `ℝ≥0`. This way we avoid conjunction in the definition and have
coercions both to `ℝ` and `ℝ≥0∞`. We do not require `0 < K` in the definition, mostly because
we do not have a `posreal` type.
-/
variable {α β γ : Type*}
open scoped NNReal ENNReal Uniformity Topology
open Set Filter Bornology
/-- We say that `f : α → β` is `AntilipschitzWith K` if for any two points `x`, `y` we have
`edist x y ≤ K * edist (f x) (f y)`. -/
def AntilipschitzWith [PseudoEMetricSpace α] [PseudoEMetricSpace β] (K : ℝ≥0) (f : α → β) :=
∀ x y, edist x y ≤ K * edist (f x) (f y)
theorem AntilipschitzWith.edist_lt_top [PseudoEMetricSpace α] [PseudoMetricSpace β] {K : ℝ≥0}
{f : α → β} (h : AntilipschitzWith K f) (x y : α) : edist x y < ⊤ :=
(h x y).trans_lt <| ENNReal.mul_lt_top ENNReal.coe_ne_top (edist_ne_top _ _)
theorem AntilipschitzWith.edist_ne_top [PseudoEMetricSpace α] [PseudoMetricSpace β] {K : ℝ≥0}
{f : α → β} (h : AntilipschitzWith K f) (x y : α) : edist x y ≠ ⊤ :=
(h.edist_lt_top x y).ne
section Metric
variable [PseudoMetricSpace α] [PseudoMetricSpace β] {K : ℝ≥0} {f : α → β}
theorem antilipschitzWith_iff_le_mul_nndist :
AntilipschitzWith K f ↔ ∀ x y, nndist x y ≤ K * nndist (f x) (f y) := by
simp only [AntilipschitzWith, edist_nndist]
norm_cast
alias ⟨AntilipschitzWith.le_mul_nndist, AntilipschitzWith.of_le_mul_nndist⟩ :=
antilipschitzWith_iff_le_mul_nndist
theorem antilipschitzWith_iff_le_mul_dist :
AntilipschitzWith K f ↔ ∀ x y, dist x y ≤ K * dist (f x) (f y) := by
simp only [antilipschitzWith_iff_le_mul_nndist, dist_nndist]
norm_cast
alias ⟨AntilipschitzWith.le_mul_dist, AntilipschitzWith.of_le_mul_dist⟩ :=
antilipschitzWith_iff_le_mul_dist
namespace AntilipschitzWith
theorem mul_le_nndist (hf : AntilipschitzWith K f) (x y : α) :
K⁻¹ * nndist x y ≤ nndist (f x) (f y) := by
simpa only [div_eq_inv_mul] using NNReal.div_le_of_le_mul' (hf.le_mul_nndist x y)
theorem mul_le_dist (hf : AntilipschitzWith K f) (x y : α) :
(K⁻¹ * dist x y : ℝ) ≤ dist (f x) (f y) := mod_cast hf.mul_le_nndist x y
end AntilipschitzWith
end Metric
namespace AntilipschitzWith
variable [PseudoEMetricSpace α] [PseudoEMetricSpace β] [PseudoEMetricSpace γ]
variable {K : ℝ≥0} {f : α → β}
open EMetric
-- uses neither `f` nor `hf`
/-- Extract the constant from `hf : AntilipschitzWith K f`. This is useful, e.g.,
if `K` is given by a long formula, and we want to reuse this value. -/
@[nolint unusedArguments]
protected def k (_hf : AntilipschitzWith K f) : ℝ≥0 := K
protected theorem injective {α : Type*} {β : Type*} [EMetricSpace α] [PseudoEMetricSpace β]
{K : ℝ≥0} {f : α → β} (hf : AntilipschitzWith K f) : Function.Injective f := fun x y h => by
simpa only [h, edist_self, mul_zero, edist_le_zero] using hf x y
theorem mul_le_edist (hf : AntilipschitzWith K f) (x y : α) :
(K : ℝ≥0∞)⁻¹ * edist x y ≤ edist (f x) (f y) := by
rw [mul_comm, ← div_eq_mul_inv]
exact ENNReal.div_le_of_le_mul' (hf x y)
theorem ediam_preimage_le (hf : AntilipschitzWith K f) (s : Set β) : diam (f ⁻¹' s) ≤ K * diam s :=
diam_le fun x hx y hy => (hf x y).trans <|
mul_le_mul_left' (edist_le_diam_of_mem (mem_preimage.1 hx) hy) K
theorem le_mul_ediam_image (hf : AntilipschitzWith K f) (s : Set α) : diam s ≤ K * diam (f '' s) :=
(diam_mono (subset_preimage_image _ _)).trans (hf.ediam_preimage_le (f '' s))
protected theorem id : AntilipschitzWith 1 (id : α → α) := fun x y => by
simp only [ENNReal.coe_one, one_mul, id, le_refl]
theorem comp {Kg : ℝ≥0} {g : β → γ} (hg : AntilipschitzWith Kg g) {Kf : ℝ≥0} {f : α → β}
(hf : AntilipschitzWith Kf f) : AntilipschitzWith (Kf * Kg) (g ∘ f) := fun x y =>
calc
edist x y ≤ Kf * edist (f x) (f y) := hf x y
_ ≤ Kf * (Kg * edist (g (f x)) (g (f y))) := ENNReal.mul_left_mono (hg _ _)
_ = _ := by rw [ENNReal.coe_mul, mul_assoc]; rfl
theorem restrict (hf : AntilipschitzWith K f) (s : Set α) : AntilipschitzWith K (s.restrict f) :=
fun x y => hf x y
theorem codRestrict (hf : AntilipschitzWith K f) {s : Set β} (hs : ∀ x, f x ∈ s) :
AntilipschitzWith K (s.codRestrict f hs) := fun x y => hf x y
theorem to_rightInvOn' {s : Set α} (hf : AntilipschitzWith K (s.restrict f)) {g : β → α}
{t : Set β} (g_maps : MapsTo g t s) (g_inv : RightInvOn g f t) :
LipschitzWith K (t.restrict g) := fun x y => by
simpa only [restrict_apply, g_inv x.mem, g_inv y.mem, Subtype.edist_eq, Subtype.coe_mk] using
hf ⟨g x, g_maps x.mem⟩ ⟨g y, g_maps y.mem⟩
theorem to_rightInvOn (hf : AntilipschitzWith K f) {g : β → α} {t : Set β} (h : RightInvOn g f t) :
LipschitzWith K (t.restrict g) :=
(hf.restrict univ).to_rightInvOn' (mapsTo_univ g t) h
theorem to_rightInverse (hf : AntilipschitzWith K f) {g : β → α} (hg : Function.RightInverse g f) :
LipschitzWith K g := by
intro x y
have := hf (g x) (g y)
rwa [hg x, hg y] at this
theorem comap_uniformity_le (hf : AntilipschitzWith K f) : (𝓤 β).comap (Prod.map f f) ≤ 𝓤 α := by
refine ((uniformity_basis_edist.comap _).le_basis_iff uniformity_basis_edist).2 fun ε h₀ => ?_
refine ⟨(↑K)⁻¹ * ε, ENNReal.mul_pos (ENNReal.inv_ne_zero.2 ENNReal.coe_ne_top) h₀.ne', ?_⟩
refine fun x hx => (hf x.1 x.2).trans_lt ?_
rw [mul_comm, ← div_eq_mul_inv] at hx
rw [mul_comm]
exact ENNReal.mul_lt_of_lt_div hx
protected theorem uniformInducing (hf : AntilipschitzWith K f) (hfc : UniformContinuous f) :
UniformInducing f :=
⟨le_antisymm hf.comap_uniformity_le hfc.le_comap⟩
protected theorem uniformEmbedding {α : Type*} {β : Type*} [EMetricSpace α] [PseudoEMetricSpace β]
{K : ℝ≥0} {f : α → β} (hf : AntilipschitzWith K f) (hfc : UniformContinuous f) :
UniformEmbedding f :=
⟨hf.uniformInducing hfc, hf.injective⟩
theorem isComplete_range [CompleteSpace α] (hf : AntilipschitzWith K f)
(hfc : UniformContinuous f) : IsComplete (range f) :=
(hf.uniformInducing hfc).isComplete_range
theorem isClosed_range {α β : Type*} [PseudoEMetricSpace α] [EMetricSpace β] [CompleteSpace α]
{f : α → β} {K : ℝ≥0} (hf : AntilipschitzWith K f) (hfc : UniformContinuous f) :
IsClosed (range f) :=
(hf.isComplete_range hfc).isClosed
theorem closedEmbedding {α : Type*} {β : Type*} [EMetricSpace α] [EMetricSpace β] {K : ℝ≥0}
{f : α → β} [CompleteSpace α] (hf : AntilipschitzWith K f) (hfc : UniformContinuous f) :
ClosedEmbedding f :=
{ (hf.uniformEmbedding hfc).embedding with isClosed_range := hf.isClosed_range hfc }
theorem subtype_coe (s : Set α) : AntilipschitzWith 1 ((↑) : s → α) :=
AntilipschitzWith.id.restrict s
@[nontriviality] -- Porting note: added `nontriviality`
theorem of_subsingleton [Subsingleton α] {K : ℝ≥0} : AntilipschitzWith K f := fun x y => by
simp only [Subsingleton.elim x y, edist_self, zero_le]
/-- If `f : α → β` is `0`-antilipschitz, then `α` is a `subsingleton`. -/
protected theorem subsingleton {α β} [EMetricSpace α] [PseudoEMetricSpace β] {f : α → β}
(h : AntilipschitzWith 0 f) : Subsingleton α :=
⟨fun x y => edist_le_zero.1 <| (h x y).trans_eq <| zero_mul _⟩
end AntilipschitzWith
namespace AntilipschitzWith
open Metric
variable [PseudoMetricSpace α] [PseudoMetricSpace β] [PseudoMetricSpace γ]
variable {K : ℝ≥0} {f : α → β}
theorem isBounded_preimage (hf : AntilipschitzWith K f) {s : Set β} (hs : IsBounded s) :
IsBounded (f ⁻¹' s) :=
isBounded_iff_ediam_ne_top.2 <| ne_top_of_le_ne_top
(ENNReal.mul_ne_top ENNReal.coe_ne_top hs.ediam_ne_top) (hf.ediam_preimage_le _)
theorem tendsto_cobounded (hf : AntilipschitzWith K f) : Tendsto f (cobounded α) (cobounded β) :=
compl_surjective.forall.2 fun _ ↦ hf.isBounded_preimage
/-- The image of a proper space under an expanding onto map is proper. -/
protected theorem properSpace {α : Type*} [MetricSpace α] {K : ℝ≥0} {f : α → β} [ProperSpace α]
(hK : AntilipschitzWith K f) (f_cont : Continuous f) (hf : Function.Surjective f) :
ProperSpace β := by
refine ⟨fun x₀ r => ?_⟩
let K := f ⁻¹' closedBall x₀ r
have A : IsClosed K := isClosed_ball.preimage f_cont
have B : IsBounded K := hK.isBounded_preimage isBounded_closedBall
have : IsCompact K := isCompact_iff_isClosed_bounded.2 ⟨A, B⟩
convert this.image f_cont
exact (hf.image_preimage _).symm
theorem isBounded_of_image2_left (f : α → β → γ) {K₁ : ℝ≥0}
(hf : ∀ b, AntilipschitzWith K₁ fun a => f a b) {s : Set α} {t : Set β}
(hst : IsBounded (Set.image2 f s t)) : IsBounded s ∨ IsBounded t := by
contrapose! hst
obtain ⟨b, hb⟩ : t.Nonempty := nonempty_of_not_isBounded hst.2
have : ¬IsBounded (Set.image2 f s {b}) := by
intro h
apply hst.1
rw [Set.image2_singleton_right] at h
replace h := (hf b).isBounded_preimage h
exact h.subset (subset_preimage_image _ _)
exact mt (IsBounded.subset · (image2_subset subset_rfl (singleton_subset_iff.mpr hb))) this
theorem isBounded_of_image2_right {f : α → β → γ} {K₂ : ℝ≥0} (hf : ∀ a, AntilipschitzWith K₂ (f a))
{s : Set α} {t : Set β} (hst : IsBounded (Set.image2 f s t)) : IsBounded s ∨ IsBounded t :=
Or.symm <| isBounded_of_image2_left (flip f) hf <| image2_swap f s t ▸ hst
end AntilipschitzWith
theorem LipschitzWith.to_rightInverse [PseudoEMetricSpace α] [PseudoEMetricSpace β] {K : ℝ≥0}
{f : α → β} (hf : LipschitzWith K f) {g : β → α} (hg : Function.RightInverse g f) :
AntilipschitzWith K g := fun x y => by simpa only [hg _] using hf (g x) (g y)
/-- The preimage of a proper space under a Lipschitz homeomorphism is proper. -/
protected theorem LipschitzWith.properSpace [PseudoMetricSpace α] [MetricSpace β] [ProperSpace β]
{K : ℝ≥0} {f : α ≃ₜ β} (hK : LipschitzWith K f) : ProperSpace α :=
(hK.to_rightInverse f.right_inv).properSpace f.symm.continuous f.symm.surjective
|
Topology\MetricSpace\Basic.lean | /-
Copyright (c) 2015, 2017 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Robert Y. Lewis, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel
-/
import Mathlib.Topology.MetricSpace.Pseudo.Lemmas
/-!
# Metric spaces
This file defines metric spaces and shows some of their basic properties.
Many definitions and theorems expected on metric spaces are already introduced on uniform spaces and
topological spaces. This includes open and closed sets, compactness, completeness, continuity
and uniform continuity.
TODO (anyone): Add "Main results" section.
## Implementation notes
A lot of elementary properties don't require `eq_of_dist_eq_zero`, hence are stated and proven
for `PseudoMetricSpace`s in `PseudoMetric.lean`.
## Tags
metric, pseudo_metric, dist
-/
open Set Filter Bornology
open scoped NNReal Uniformity
universe u v w
variable {α : Type u} {β : Type v} {X ι : Type*}
variable [PseudoMetricSpace α]
/-- We now define `MetricSpace`, extending `PseudoMetricSpace`. -/
class MetricSpace (α : Type u) extends PseudoMetricSpace α : Type u where
eq_of_dist_eq_zero : ∀ {x y : α}, dist x y = 0 → x = y
/-- Two metric space structures with the same distance coincide. -/
@[ext]
theorem MetricSpace.ext {α : Type*} {m m' : MetricSpace α} (h : m.toDist = m'.toDist) :
m = m' := by
cases m; cases m'; congr; ext1; assumption
/-- Construct a metric space structure whose underlying topological space structure
(definitionally) agrees which a pre-existing topology which is compatible with a given distance
function. -/
def MetricSpace.ofDistTopology {α : Type u} [TopologicalSpace α] (dist : α → α → ℝ)
(dist_self : ∀ x : α, dist x x = 0) (dist_comm : ∀ x y : α, dist x y = dist y x)
(dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z)
(H : ∀ s : Set α, IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, ∀ y, dist x y < ε → y ∈ s)
(eq_of_dist_eq_zero : ∀ x y : α, dist x y = 0 → x = y) : MetricSpace α :=
{ PseudoMetricSpace.ofDistTopology dist dist_self dist_comm dist_triangle H with
eq_of_dist_eq_zero := eq_of_dist_eq_zero _ _ }
variable {γ : Type w} [MetricSpace γ]
theorem eq_of_dist_eq_zero {x y : γ} : dist x y = 0 → x = y :=
MetricSpace.eq_of_dist_eq_zero
@[simp]
theorem dist_eq_zero {x y : γ} : dist x y = 0 ↔ x = y :=
Iff.intro eq_of_dist_eq_zero fun this => this ▸ dist_self _
@[simp]
theorem zero_eq_dist {x y : γ} : 0 = dist x y ↔ x = y := by rw [eq_comm, dist_eq_zero]
theorem dist_ne_zero {x y : γ} : dist x y ≠ 0 ↔ x ≠ y := by
simpa only [not_iff_not] using dist_eq_zero
@[simp]
theorem dist_le_zero {x y : γ} : dist x y ≤ 0 ↔ x = y := by
simpa [le_antisymm_iff, dist_nonneg] using @dist_eq_zero _ _ x y
@[simp]
theorem dist_pos {x y : γ} : 0 < dist x y ↔ x ≠ y := by
simpa only [not_le] using not_congr dist_le_zero
theorem eq_of_forall_dist_le {x y : γ} (h : ∀ ε > 0, dist x y ≤ ε) : x = y :=
eq_of_dist_eq_zero (eq_of_le_of_forall_le_of_dense dist_nonneg h)
/-- Deduce the equality of points from the vanishing of the nonnegative distance-/
theorem eq_of_nndist_eq_zero {x y : γ} : nndist x y = 0 → x = y := by
simp only [NNReal.eq_iff, ← dist_nndist, imp_self, NNReal.coe_zero, dist_eq_zero]
/-- Characterize the equality of points as the vanishing of the nonnegative distance-/
@[simp]
theorem nndist_eq_zero {x y : γ} : nndist x y = 0 ↔ x = y := by
simp only [NNReal.eq_iff, ← dist_nndist, imp_self, NNReal.coe_zero, dist_eq_zero]
@[simp]
theorem zero_eq_nndist {x y : γ} : 0 = nndist x y ↔ x = y := by
simp only [NNReal.eq_iff, ← dist_nndist, imp_self, NNReal.coe_zero, zero_eq_dist]
namespace Metric
variable {x : γ} {s : Set γ}
@[simp] theorem closedBall_zero : closedBall x 0 = {x} := Set.ext fun _ => dist_le_zero
@[simp] theorem sphere_zero : sphere x 0 = {x} := Set.ext fun _ => dist_eq_zero
theorem subsingleton_closedBall (x : γ) {r : ℝ} (hr : r ≤ 0) : (closedBall x r).Subsingleton := by
rcases hr.lt_or_eq with (hr | rfl)
· rw [closedBall_eq_empty.2 hr]
exact subsingleton_empty
· rw [closedBall_zero]
exact subsingleton_singleton
theorem subsingleton_sphere (x : γ) {r : ℝ} (hr : r ≤ 0) : (sphere x r).Subsingleton :=
(subsingleton_closedBall x hr).anti sphere_subset_closedBall
-- see Note [lower instance priority]
instance (priority := 100) _root_.MetricSpace.instT0Space : T0Space γ where
t0 _ _ h := eq_of_dist_eq_zero <| Metric.inseparable_iff.1 h
/-- A map between metric spaces is a uniform embedding if and only if the distance between `f x`
and `f y` is controlled in terms of the distance between `x` and `y` and conversely. -/
theorem uniformEmbedding_iff' [MetricSpace β] {f : γ → β} :
UniformEmbedding f ↔
(∀ ε > 0, ∃ δ > 0, ∀ {a b : γ}, dist a b < δ → dist (f a) (f b) < ε) ∧
∀ δ > 0, ∃ ε > 0, ∀ {a b : γ}, dist (f a) (f b) < ε → dist a b < δ := by
rw [uniformEmbedding_iff_uniformInducing, uniformInducing_iff, uniformContinuous_iff]
/-- If a `PseudoMetricSpace` is a T₀ space, then it is a `MetricSpace`. -/
abbrev _root_.MetricSpace.ofT0PseudoMetricSpace (α : Type*) [PseudoMetricSpace α] [T0Space α] :
MetricSpace α where
toPseudoMetricSpace := ‹_›
eq_of_dist_eq_zero hdist := (Metric.inseparable_iff.2 hdist).eq
-- see Note [lower instance priority]
/-- A metric space induces an emetric space -/
instance (priority := 100) _root_.MetricSpace.toEMetricSpace : EMetricSpace γ :=
.ofT0PseudoEMetricSpace γ
theorem isClosed_of_pairwise_le_dist {s : Set γ} {ε : ℝ} (hε : 0 < ε)
(hs : s.Pairwise fun x y => ε ≤ dist x y) : IsClosed s :=
isClosed_of_spaced_out (dist_mem_uniformity hε) <| by simpa using hs
theorem closedEmbedding_of_pairwise_le_dist {α : Type*} [TopologicalSpace α] [DiscreteTopology α]
{ε : ℝ} (hε : 0 < ε) {f : α → γ} (hf : Pairwise fun x y => ε ≤ dist (f x) (f y)) :
ClosedEmbedding f :=
closedEmbedding_of_spaced_out (dist_mem_uniformity hε) <| by simpa using hf
/-- If `f : β → α` sends any two distinct points to points at distance at least `ε > 0`, then
`f` is a uniform embedding with respect to the discrete uniformity on `β`. -/
theorem uniformEmbedding_bot_of_pairwise_le_dist {β : Type*} {ε : ℝ} (hε : 0 < ε) {f : β → α}
(hf : Pairwise fun x y => ε ≤ dist (f x) (f y)) :
@UniformEmbedding _ _ ⊥ (by infer_instance) f :=
uniformEmbedding_of_spaced_out (dist_mem_uniformity hε) <| by simpa using hf
end Metric
/-- Build a new metric space from an old one where the bundled uniform structure is provably
(but typically non-definitionaly) equal to some given uniform structure.
See Note [forgetful inheritance].
-/
def MetricSpace.replaceUniformity {γ} [U : UniformSpace γ] (m : MetricSpace γ)
(H : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace]) : MetricSpace γ where
toPseudoMetricSpace := PseudoMetricSpace.replaceUniformity m.toPseudoMetricSpace H
eq_of_dist_eq_zero := @eq_of_dist_eq_zero _ _
theorem MetricSpace.replaceUniformity_eq {γ} [U : UniformSpace γ] (m : MetricSpace γ)
(H : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace]) : m.replaceUniformity H = m := by
ext; rfl
/-- Build a new metric space from an old one where the bundled topological structure is provably
(but typically non-definitionaly) equal to some given topological structure.
See Note [forgetful inheritance].
-/
abbrev MetricSpace.replaceTopology {γ} [U : TopologicalSpace γ] (m : MetricSpace γ)
(H : U = m.toPseudoMetricSpace.toUniformSpace.toTopologicalSpace) : MetricSpace γ :=
@MetricSpace.replaceUniformity γ (m.toUniformSpace.replaceTopology H) m rfl
theorem MetricSpace.replaceTopology_eq {γ} [U : TopologicalSpace γ] (m : MetricSpace γ)
(H : U = m.toPseudoMetricSpace.toUniformSpace.toTopologicalSpace) :
m.replaceTopology H = m := by
ext; rfl
/-- One gets a metric space from an emetric space if the edistance
is everywhere finite, by pushing the edistance to reals. We set it up so that the edist and the
uniformity are defeq in the metric space and the emetric space. In this definition, the distance
is given separately, to be able to prescribe some expression which is not defeq to the push-forward
of the edistance to reals. -/
abbrev EMetricSpace.toMetricSpaceOfDist {α : Type u} [EMetricSpace α] (dist : α → α → ℝ)
(edist_ne_top : ∀ x y : α, edist x y ≠ ⊤) (h : ∀ x y, dist x y = ENNReal.toReal (edist x y)) :
MetricSpace α :=
@MetricSpace.ofT0PseudoMetricSpace _
(PseudoEMetricSpace.toPseudoMetricSpaceOfDist dist edist_ne_top h) _
/-- One gets a metric space from an emetric space if the edistance
is everywhere finite, by pushing the edistance to reals. We set it up so that the edist and the
uniformity are defeq in the metric space and the emetric space. -/
def EMetricSpace.toMetricSpace {α : Type u} [EMetricSpace α] (h : ∀ x y : α, edist x y ≠ ⊤) :
MetricSpace α :=
EMetricSpace.toMetricSpaceOfDist (fun x y => ENNReal.toReal (edist x y)) h fun _ _ => rfl
/-- Build a new metric space from an old one where the bundled bornology structure is provably
(but typically non-definitionaly) equal to some given bornology structure.
See Note [forgetful inheritance].
-/
def MetricSpace.replaceBornology {α} [B : Bornology α] (m : MetricSpace α)
(H : ∀ s, @IsBounded _ B s ↔ @IsBounded _ PseudoMetricSpace.toBornology s) : MetricSpace α :=
{ PseudoMetricSpace.replaceBornology _ H, m with toBornology := B }
theorem MetricSpace.replaceBornology_eq {α} [m : MetricSpace α] [B : Bornology α]
(H : ∀ s, @IsBounded _ B s ↔ @IsBounded _ PseudoMetricSpace.toBornology s) :
MetricSpace.replaceBornology _ H = m := by
ext
rfl
/-- Metric space structure pulled back by an injective function. Injectivity is necessary to
ensure that `dist x y = 0` only if `x = y`. -/
abbrev MetricSpace.induced {γ β} (f : γ → β) (hf : Function.Injective f) (m : MetricSpace β) :
MetricSpace γ :=
{ PseudoMetricSpace.induced f m.toPseudoMetricSpace with
eq_of_dist_eq_zero := fun h => hf (dist_eq_zero.1 h) }
/-- Pull back a metric space structure by a uniform embedding. This is a version of
`MetricSpace.induced` useful in case if the domain already has a `UniformSpace` structure. -/
abbrev UniformEmbedding.comapMetricSpace {α β} [UniformSpace α] [m : MetricSpace β] (f : α → β)
(h : UniformEmbedding f) : MetricSpace α :=
.replaceUniformity (.induced f h.inj m) h.comap_uniformity.symm
/-- Pull back a metric space structure by an embedding. This is a version of
`MetricSpace.induced` useful in case if the domain already has a `TopologicalSpace` structure. -/
abbrev Embedding.comapMetricSpace {α β} [TopologicalSpace α] [m : MetricSpace β] (f : α → β)
(h : Embedding f) : MetricSpace α :=
.replaceTopology (.induced f h.inj m) h.induced
instance Subtype.metricSpace {α : Type*} {p : α → Prop} [MetricSpace α] :
MetricSpace (Subtype p) :=
.induced Subtype.val Subtype.coe_injective ‹_›
@[to_additive]
instance {α : Type*} [MetricSpace α] : MetricSpace αᵐᵒᵖ :=
MetricSpace.induced MulOpposite.unop MulOpposite.unop_injective ‹_›
instance : MetricSpace Empty where
dist _ _ := 0
dist_self _ := rfl
dist_comm _ _ := rfl
edist _ _ := 0
eq_of_dist_eq_zero _ := Subsingleton.elim _ _
dist_triangle _ _ _ := show (0 : ℝ) ≤ 0 + 0 by rw [add_zero]
toUniformSpace := inferInstance
uniformity_dist := Subsingleton.elim _ _
instance : MetricSpace PUnit.{u + 1} where
dist _ _ := 0
dist_self _ := rfl
dist_comm _ _ := rfl
edist _ _ := 0
eq_of_dist_eq_zero _ := Subsingleton.elim _ _
dist_triangle _ _ _ := show (0 : ℝ) ≤ 0 + 0 by rw [add_zero]
toUniformSpace := inferInstance
uniformity_dist := by
simp (config := { contextual := true }) [principal_univ, eq_top_of_neBot (𝓤 PUnit)]
section Real
/-- Instantiate the reals as a metric space. -/
instance Real.metricSpace : MetricSpace ℝ := .ofT0PseudoMetricSpace ℝ
end Real
section NNReal
instance : MetricSpace ℝ≥0 :=
Subtype.metricSpace
end NNReal
instance [MetricSpace β] : MetricSpace (ULift β) :=
MetricSpace.induced ULift.down ULift.down_injective ‹_›
section Prod
instance Prod.metricSpaceMax [MetricSpace β] : MetricSpace (γ × β) := .ofT0PseudoMetricSpace _
end Prod
section Pi
open Finset
variable {π : β → Type*} [Fintype β] [∀ b, MetricSpace (π b)]
/-- A finite product of metric spaces is a metric space, with the sup distance. -/
instance metricSpacePi : MetricSpace (∀ b, π b) := .ofT0PseudoMetricSpace _
end Pi
namespace Metric
section SecondCountable
open TopologicalSpace
-- Porting note (#11215): TODO: use `Countable` instead of `Encodable`
/-- A metric space is second countable if one can reconstruct up to any `ε>0` any element of the
space from countably many data. -/
theorem secondCountable_of_countable_discretization {α : Type u} [MetricSpace α]
(H : ∀ ε > (0 : ℝ), ∃ (β : Type*) (_ : Encodable β) (F : α → β),
∀ x y, F x = F y → dist x y ≤ ε) :
SecondCountableTopology α := by
refine secondCountable_of_almost_dense_set fun ε ε0 => ?_
rcases H ε ε0 with ⟨β, fβ, F, hF⟩
let Finv := rangeSplitting F
refine ⟨range Finv, ⟨countable_range _, fun x => ?_⟩⟩
let x' := Finv ⟨F x, mem_range_self _⟩
have : F x' = F x := apply_rangeSplitting F _
exact ⟨x', mem_range_self _, hF _ _ this.symm⟩
end SecondCountable
end Metric
section EqRel
-- TODO: add `dist_congr` similar to `edist_congr`?
instance SeparationQuotient.instDist {α : Type u} [PseudoMetricSpace α] :
Dist (SeparationQuotient α) where
dist := lift₂ dist fun x y x' y' hx hy ↦ by rw [dist_edist, dist_edist, ← edist_mk x,
← edist_mk x', mk_eq_mk.2 hx, mk_eq_mk.2 hy]
theorem SeparationQuotient.dist_mk {α : Type u} [PseudoMetricSpace α] (p q : α) :
dist (mk p) (mk q) = dist p q :=
rfl
instance SeparationQuotient.instMetricSpace {α : Type u} [PseudoMetricSpace α] :
MetricSpace (SeparationQuotient α) :=
EMetricSpace.toMetricSpaceOfDist dist (surjective_mk.forall₂.2 edist_ne_top) <|
surjective_mk.forall₂.2 dist_edist
end EqRel
/-!
### `Additive`, `Multiplicative`
The distance on those type synonyms is inherited without change.
-/
open Additive Multiplicative
section
variable [Dist X]
instance : Dist (Additive X) := ‹Dist X›
instance : Dist (Multiplicative X) := ‹Dist X›
@[simp] theorem dist_ofMul (a b : X) : dist (ofMul a) (ofMul b) = dist a b := rfl
@[simp] theorem dist_ofAdd (a b : X) : dist (ofAdd a) (ofAdd b) = dist a b := rfl
@[simp] theorem dist_toMul (a b : Additive X) : dist (toMul a) (toMul b) = dist a b := rfl
@[simp] theorem dist_toAdd (a b : Multiplicative X) : dist (toAdd a) (toAdd b) = dist a b := rfl
end
section
variable [PseudoMetricSpace X]
instance : PseudoMetricSpace (Additive X) := ‹PseudoMetricSpace X›
instance : PseudoMetricSpace (Multiplicative X) := ‹PseudoMetricSpace X›
@[simp] theorem nndist_ofMul (a b : X) : nndist (ofMul a) (ofMul b) = nndist a b := rfl
@[simp] theorem nndist_ofAdd (a b : X) : nndist (ofAdd a) (ofAdd b) = nndist a b := rfl
@[simp] theorem nndist_toMul (a b : Additive X) : nndist (toMul a) (toMul b) = nndist a b := rfl
@[simp]
theorem nndist_toAdd (a b : Multiplicative X) : nndist (toAdd a) (toAdd b) = nndist a b := rfl
end
instance [MetricSpace X] : MetricSpace (Additive X) := ‹MetricSpace X›
instance [MetricSpace X] : MetricSpace (Multiplicative X) := ‹MetricSpace X›
instance MulOpposite.instMetricSpace [MetricSpace X] : MetricSpace Xᵐᵒᵖ :=
MetricSpace.induced unop unop_injective ‹_›
/-!
### Order dual
The distance on this type synonym is inherited without change.
-/
open OrderDual
section
variable [Dist X]
instance : Dist Xᵒᵈ := ‹Dist X›
@[simp] theorem dist_toDual (a b : X) : dist (toDual a) (toDual b) = dist a b := rfl
@[simp] theorem dist_ofDual (a b : Xᵒᵈ) : dist (ofDual a) (ofDual b) = dist a b := rfl
end
section
variable [PseudoMetricSpace X]
instance : PseudoMetricSpace Xᵒᵈ := ‹PseudoMetricSpace X›
@[simp] theorem nndist_toDual (a b : X) : nndist (toDual a) (toDual b) = nndist a b := rfl
@[simp] theorem nndist_ofDual (a b : Xᵒᵈ) : nndist (ofDual a) (ofDual b) = nndist a b := rfl
end
instance [MetricSpace X] : MetricSpace Xᵒᵈ := ‹MetricSpace X›
|
Topology\MetricSpace\Bounded.lean | /-
Copyright (c) 2015, 2017 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Robert Y. Lewis, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel
-/
import Mathlib.Topology.Algebra.Order.Compact
import Mathlib.Topology.MetricSpace.ProperSpace
import Mathlib.Topology.MetricSpace.Cauchy
/-!
## Boundedness in (pseudo)-metric spaces
This file contains one definition, and various results on boundedness in pseudo-metric spaces.
* `Metric.diam s` : The `iSup` of the distances of members of `s`.
Defined in terms of `EMetric.diam`, for better handling of the case when it should be infinite.
* `isBounded_iff_subset_closedBall`: a non-empty set is bounded if and only if
it is is included in some closed ball
* describing the cobounded filter, relating to the cocompact filter
* `IsCompact.isBounded`: compact sets are bounded
* `TotallyBounded.isBounded`: totally bounded sets are bounded
* `isCompact_iff_isClosed_bounded`, the **Heine–Borel theorem**:
in a proper space, a set is compact if and only if it is closed and bounded.
* `cobounded_eq_cocompact`: in a proper space, cobounded and compact sets are the same
diameter of a subset, and its relation to boundedness
## Tags
metric, pseudo_metric, bounded, diameter, Heine-Borel theorem
-/
open Set Filter Bornology
open scoped ENNReal Uniformity Topology Pointwise
universe u v w
variable {α : Type u} {β : Type v} {X ι : Type*}
variable [PseudoMetricSpace α]
namespace Metric
section Bounded
variable {x : α} {s t : Set α} {r : ℝ}
/-- Closed balls are bounded -/
theorem isBounded_closedBall : IsBounded (closedBall x r) :=
isBounded_iff.2 ⟨r + r, fun y hy z hz =>
calc dist y z ≤ dist y x + dist z x := dist_triangle_right _ _ _
_ ≤ r + r := add_le_add hy hz⟩
/-- Open balls are bounded -/
theorem isBounded_ball : IsBounded (ball x r) :=
isBounded_closedBall.subset ball_subset_closedBall
/-- Spheres are bounded -/
theorem isBounded_sphere : IsBounded (sphere x r) :=
isBounded_closedBall.subset sphere_subset_closedBall
/-- Given a point, a bounded subset is included in some ball around this point -/
theorem isBounded_iff_subset_closedBall (c : α) : IsBounded s ↔ ∃ r, s ⊆ closedBall c r :=
⟨fun h ↦ (isBounded_iff.1 (h.insert c)).imp fun _r hr _x hx ↦ hr (.inr hx) (mem_insert _ _),
fun ⟨_r, hr⟩ ↦ isBounded_closedBall.subset hr⟩
theorem _root_.Bornology.IsBounded.subset_closedBall (h : IsBounded s) (c : α) :
∃ r, s ⊆ closedBall c r :=
(isBounded_iff_subset_closedBall c).1 h
theorem _root_.Bornology.IsBounded.subset_ball_lt (h : IsBounded s) (a : ℝ) (c : α) :
∃ r, a < r ∧ s ⊆ ball c r :=
let ⟨r, hr⟩ := h.subset_closedBall c
⟨max r a + 1, (le_max_right _ _).trans_lt (lt_add_one _), hr.trans <| closedBall_subset_ball <|
(le_max_left _ _).trans_lt (lt_add_one _)⟩
theorem _root_.Bornology.IsBounded.subset_ball (h : IsBounded s) (c : α) : ∃ r, s ⊆ ball c r :=
(h.subset_ball_lt 0 c).imp fun _ ↦ And.right
theorem isBounded_iff_subset_ball (c : α) : IsBounded s ↔ ∃ r, s ⊆ ball c r :=
⟨(IsBounded.subset_ball · c), fun ⟨_r, hr⟩ ↦ isBounded_ball.subset hr⟩
theorem _root_.Bornology.IsBounded.subset_closedBall_lt (h : IsBounded s) (a : ℝ) (c : α) :
∃ r, a < r ∧ s ⊆ closedBall c r :=
let ⟨r, har, hr⟩ := h.subset_ball_lt a c
⟨r, har, hr.trans ball_subset_closedBall⟩
theorem isBounded_closure_of_isBounded (h : IsBounded s) : IsBounded (closure s) :=
let ⟨C, h⟩ := isBounded_iff.1 h
isBounded_iff.2 ⟨C, fun _a ha _b hb => isClosed_Iic.closure_subset <|
map_mem_closure₂ continuous_dist ha hb h⟩
protected theorem _root_.Bornology.IsBounded.closure (h : IsBounded s) : IsBounded (closure s) :=
isBounded_closure_of_isBounded h
@[simp]
theorem isBounded_closure_iff : IsBounded (closure s) ↔ IsBounded s :=
⟨fun h => h.subset subset_closure, fun h => h.closure⟩
theorem hasBasis_cobounded_compl_closedBall (c : α) :
(cobounded α).HasBasis (fun _ ↦ True) (fun r ↦ (closedBall c r)ᶜ) :=
⟨compl_surjective.forall.2 fun _ ↦ (isBounded_iff_subset_closedBall c).trans <| by simp⟩
theorem hasBasis_cobounded_compl_ball (c : α) :
(cobounded α).HasBasis (fun _ ↦ True) (fun r ↦ (ball c r)ᶜ) :=
⟨compl_surjective.forall.2 fun _ ↦ (isBounded_iff_subset_ball c).trans <| by simp⟩
@[simp]
theorem comap_dist_right_atTop (c : α) : comap (dist · c) atTop = cobounded α :=
(atTop_basis.comap _).eq_of_same_basis <| by
simpa only [compl_def, mem_ball, not_lt] using hasBasis_cobounded_compl_ball c
@[simp]
theorem comap_dist_left_atTop (c : α) : comap (dist c) atTop = cobounded α := by
simpa only [dist_comm _ c] using comap_dist_right_atTop c
@[simp]
theorem tendsto_dist_right_atTop_iff (c : α) {f : β → α} {l : Filter β} :
Tendsto (fun x ↦ dist (f x) c) l atTop ↔ Tendsto f l (cobounded α) := by
rw [← comap_dist_right_atTop c, tendsto_comap_iff, Function.comp_def]
@[simp]
theorem tendsto_dist_left_atTop_iff (c : α) {f : β → α} {l : Filter β} :
Tendsto (fun x ↦ dist c (f x)) l atTop ↔ Tendsto f l (cobounded α) := by
simp only [dist_comm c, tendsto_dist_right_atTop_iff]
theorem tendsto_dist_right_cobounded_atTop (c : α) : Tendsto (dist · c) (cobounded α) atTop :=
tendsto_iff_comap.2 (comap_dist_right_atTop c).ge
theorem tendsto_dist_left_cobounded_atTop (c : α) : Tendsto (dist c) (cobounded α) atTop :=
tendsto_iff_comap.2 (comap_dist_left_atTop c).ge
/-- A totally bounded set is bounded -/
theorem _root_.TotallyBounded.isBounded {s : Set α} (h : TotallyBounded s) : IsBounded s :=
-- We cover the totally bounded set by finitely many balls of radius 1,
-- and then argue that a finite union of bounded sets is bounded
let ⟨_t, fint, subs⟩ := (totallyBounded_iff.mp h) 1 zero_lt_one
((isBounded_biUnion fint).2 fun _ _ => isBounded_ball).subset subs
/-- A compact set is bounded -/
theorem _root_.IsCompact.isBounded {s : Set α} (h : IsCompact s) : IsBounded s :=
-- A compact set is totally bounded, thus bounded
h.totallyBounded.isBounded
theorem cobounded_le_cocompact : cobounded α ≤ cocompact α :=
hasBasis_cocompact.ge_iff.2 fun _s hs ↦ hs.isBounded
theorem isCobounded_iff_closedBall_compl_subset {s : Set α} (c : α) :
IsCobounded s ↔ ∃ (r : ℝ), (Metric.closedBall c r)ᶜ ⊆ s := by
rw [← isBounded_compl_iff, isBounded_iff_subset_closedBall c]
apply exists_congr
intro r
rw [compl_subset_comm]
theorem _root_.Bornology.IsCobounded.closedBall_compl_subset {s : Set α} (hs : IsCobounded s)
(c : α) : ∃ (r : ℝ), (Metric.closedBall c r)ᶜ ⊆ s :=
(isCobounded_iff_closedBall_compl_subset c).mp hs
theorem closedBall_compl_subset_of_mem_cocompact {s : Set α} (hs : s ∈ cocompact α) (c : α) :
∃ (r : ℝ), (Metric.closedBall c r)ᶜ ⊆ s :=
IsCobounded.closedBall_compl_subset (cobounded_le_cocompact hs) c
theorem mem_cocompact_of_closedBall_compl_subset [ProperSpace α] (c : α)
(h : ∃ r, (closedBall c r)ᶜ ⊆ s) : s ∈ cocompact α := by
rcases h with ⟨r, h⟩
rw [Filter.mem_cocompact]
exact ⟨closedBall c r, isCompact_closedBall c r, h⟩
theorem mem_cocompact_iff_closedBall_compl_subset [ProperSpace α] (c : α) :
s ∈ cocompact α ↔ ∃ r, (closedBall c r)ᶜ ⊆ s :=
⟨(closedBall_compl_subset_of_mem_cocompact · _), mem_cocompact_of_closedBall_compl_subset _⟩
/-- Characterization of the boundedness of the range of a function -/
theorem isBounded_range_iff {f : β → α} : IsBounded (range f) ↔ ∃ C, ∀ x y, dist (f x) (f y) ≤ C :=
isBounded_iff.trans <| by simp only [forall_mem_range]
theorem isBounded_image_iff {f : β → α} {s : Set β} :
IsBounded (f '' s) ↔ ∃ C, ∀ x ∈ s, ∀ y ∈ s, dist (f x) (f y) ≤ C :=
isBounded_iff.trans <| by simp only [forall_mem_image]
theorem isBounded_range_of_tendsto_cofinite_uniformity {f : β → α}
(hf : Tendsto (Prod.map f f) (.cofinite ×ˢ .cofinite) (𝓤 α)) : IsBounded (range f) := by
rcases (hasBasis_cofinite.prod_self.tendsto_iff uniformity_basis_dist).1 hf 1 zero_lt_one with
⟨s, hsf, hs1⟩
rw [← image_union_image_compl_eq_range]
refine (hsf.image f).isBounded.union (isBounded_image_iff.2 ⟨1, fun x hx y hy ↦ ?_⟩)
exact le_of_lt (hs1 (x, y) ⟨hx, hy⟩)
theorem isBounded_range_of_cauchy_map_cofinite {f : β → α} (hf : Cauchy (map f cofinite)) :
IsBounded (range f) :=
isBounded_range_of_tendsto_cofinite_uniformity <| (cauchy_map_iff.1 hf).2
theorem _root_.CauchySeq.isBounded_range {f : ℕ → α} (hf : CauchySeq f) : IsBounded (range f) :=
isBounded_range_of_cauchy_map_cofinite <| by rwa [Nat.cofinite_eq_atTop]
theorem isBounded_range_of_tendsto_cofinite {f : β → α} {a : α} (hf : Tendsto f cofinite (𝓝 a)) :
IsBounded (range f) :=
isBounded_range_of_tendsto_cofinite_uniformity <|
(hf.prod_map hf).mono_right <| nhds_prod_eq.symm.trans_le (nhds_le_uniformity a)
/-- In a compact space, all sets are bounded -/
theorem isBounded_of_compactSpace [CompactSpace α] : IsBounded s :=
isCompact_univ.isBounded.subset (subset_univ _)
theorem isBounded_range_of_tendsto (u : ℕ → α) {x : α} (hu : Tendsto u atTop (𝓝 x)) :
IsBounded (range u) :=
hu.cauchySeq.isBounded_range
theorem disjoint_nhds_cobounded (x : α) : Disjoint (𝓝 x) (cobounded α) :=
disjoint_of_disjoint_of_mem disjoint_compl_right (ball_mem_nhds _ one_pos) isBounded_ball
theorem disjoint_cobounded_nhds (x : α) : Disjoint (cobounded α) (𝓝 x) :=
(disjoint_nhds_cobounded x).symm
theorem disjoint_nhdsSet_cobounded {s : Set α} (hs : IsCompact s) : Disjoint (𝓝ˢ s) (cobounded α) :=
hs.disjoint_nhdsSet_left.2 fun _ _ ↦ disjoint_nhds_cobounded _
theorem disjoint_cobounded_nhdsSet {s : Set α} (hs : IsCompact s) : Disjoint (cobounded α) (𝓝ˢ s) :=
(disjoint_nhdsSet_cobounded hs).symm
theorem exists_isBounded_image_of_tendsto {α β : Type*} [PseudoMetricSpace β]
{l : Filter α} {f : α → β} {x : β} (hf : Tendsto f l (𝓝 x)) :
∃ s ∈ l, IsBounded (f '' s) :=
(l.basis_sets.map f).disjoint_iff_left.mp <| (disjoint_nhds_cobounded x).mono_left hf
/-- If a function is continuous within a set `s` at every point of a compact set `k`, then it is
bounded on some open neighborhood of `k` in `s`. -/
theorem exists_isOpen_isBounded_image_inter_of_isCompact_of_forall_continuousWithinAt
[TopologicalSpace β] {k s : Set β} {f : β → α} (hk : IsCompact k)
(hf : ∀ x ∈ k, ContinuousWithinAt f s x) :
∃ t, k ⊆ t ∧ IsOpen t ∧ IsBounded (f '' (t ∩ s)) := by
have : Disjoint (𝓝ˢ k ⊓ 𝓟 s) (comap f (cobounded α)) := by
rw [disjoint_assoc, inf_comm, hk.disjoint_nhdsSet_left]
exact fun x hx ↦ disjoint_left_comm.2 <|
tendsto_comap.disjoint (disjoint_cobounded_nhds _) (hf x hx)
rcases ((((hasBasis_nhdsSet _).inf_principal _)).disjoint_iff ((basis_sets _).comap _)).1 this
with ⟨U, ⟨hUo, hkU⟩, t, ht, hd⟩
refine ⟨U, hkU, hUo, (isBounded_compl_iff.2 ht).subset ?_⟩
rwa [image_subset_iff, preimage_compl, subset_compl_iff_disjoint_right]
/-- If a function is continuous at every point of a compact set `k`, then it is bounded on
some open neighborhood of `k`. -/
theorem exists_isOpen_isBounded_image_of_isCompact_of_forall_continuousAt [TopologicalSpace β]
{k : Set β} {f : β → α} (hk : IsCompact k) (hf : ∀ x ∈ k, ContinuousAt f x) :
∃ t, k ⊆ t ∧ IsOpen t ∧ IsBounded (f '' t) := by
simp_rw [← continuousWithinAt_univ] at hf
simpa only [inter_univ] using
exists_isOpen_isBounded_image_inter_of_isCompact_of_forall_continuousWithinAt hk hf
/-- If a function is continuous on a set `s` containing a compact set `k`, then it is bounded on
some open neighborhood of `k` in `s`. -/
theorem exists_isOpen_isBounded_image_inter_of_isCompact_of_continuousOn [TopologicalSpace β]
{k s : Set β} {f : β → α} (hk : IsCompact k) (hks : k ⊆ s) (hf : ContinuousOn f s) :
∃ t, k ⊆ t ∧ IsOpen t ∧ IsBounded (f '' (t ∩ s)) :=
exists_isOpen_isBounded_image_inter_of_isCompact_of_forall_continuousWithinAt hk fun x hx =>
hf x (hks hx)
/-- If a function is continuous on a neighborhood of a compact set `k`, then it is bounded on
some open neighborhood of `k`. -/
theorem exists_isOpen_isBounded_image_of_isCompact_of_continuousOn [TopologicalSpace β]
{k s : Set β} {f : β → α} (hk : IsCompact k) (hs : IsOpen s) (hks : k ⊆ s)
(hf : ContinuousOn f s) : ∃ t, k ⊆ t ∧ IsOpen t ∧ IsBounded (f '' t) :=
exists_isOpen_isBounded_image_of_isCompact_of_forall_continuousAt hk fun _x hx =>
hf.continuousAt (hs.mem_nhds (hks hx))
/-- The **Heine–Borel theorem**: In a proper space, a closed bounded set is compact. -/
theorem isCompact_of_isClosed_isBounded [ProperSpace α] (hc : IsClosed s) (hb : IsBounded s) :
IsCompact s := by
rcases eq_empty_or_nonempty s with (rfl | ⟨x, -⟩)
· exact isCompact_empty
· rcases hb.subset_closedBall x with ⟨r, hr⟩
exact (isCompact_closedBall x r).of_isClosed_subset hc hr
/-- The **Heine–Borel theorem**: In a proper space, the closure of a bounded set is compact. -/
theorem _root_.Bornology.IsBounded.isCompact_closure [ProperSpace α] (h : IsBounded s) :
IsCompact (closure s) :=
isCompact_of_isClosed_isBounded isClosed_closure h.closure
-- Porting note (#11215): TODO: assume `[MetricSpace α]`
-- instead of `[PseudoMetricSpace α] [T2Space α]`
/-- The **Heine–Borel theorem**:
In a proper Hausdorff space, a set is compact if and only if it is closed and bounded. -/
theorem isCompact_iff_isClosed_bounded [T2Space α] [ProperSpace α] :
IsCompact s ↔ IsClosed s ∧ IsBounded s :=
⟨fun h => ⟨h.isClosed, h.isBounded⟩, fun h => isCompact_of_isClosed_isBounded h.1 h.2⟩
theorem compactSpace_iff_isBounded_univ [ProperSpace α] :
CompactSpace α ↔ IsBounded (univ : Set α) :=
⟨@isBounded_of_compactSpace α _ _, fun hb => ⟨isCompact_of_isClosed_isBounded isClosed_univ hb⟩⟩
section CompactIccSpace
variable [Preorder α] [CompactIccSpace α]
theorem _root_.totallyBounded_Icc (a b : α) : TotallyBounded (Icc a b) :=
isCompact_Icc.totallyBounded
theorem _root_.totallyBounded_Ico (a b : α) : TotallyBounded (Ico a b) :=
(totallyBounded_Icc a b).subset Ico_subset_Icc_self
theorem _root_.totallyBounded_Ioc (a b : α) : TotallyBounded (Ioc a b) :=
(totallyBounded_Icc a b).subset Ioc_subset_Icc_self
theorem _root_.totallyBounded_Ioo (a b : α) : TotallyBounded (Ioo a b) :=
(totallyBounded_Icc a b).subset Ioo_subset_Icc_self
theorem isBounded_Icc (a b : α) : IsBounded (Icc a b) :=
(totallyBounded_Icc a b).isBounded
theorem isBounded_Ico (a b : α) : IsBounded (Ico a b) :=
(totallyBounded_Ico a b).isBounded
theorem isBounded_Ioc (a b : α) : IsBounded (Ioc a b) :=
(totallyBounded_Ioc a b).isBounded
theorem isBounded_Ioo (a b : α) : IsBounded (Ioo a b) :=
(totallyBounded_Ioo a b).isBounded
/-- In a pseudo metric space with a conditionally complete linear order such that the order and the
metric structure give the same topology, any order-bounded set is metric-bounded. -/
theorem isBounded_of_bddAbove_of_bddBelow {s : Set α} (h₁ : BddAbove s) (h₂ : BddBelow s) :
IsBounded s :=
let ⟨u, hu⟩ := h₁
let ⟨l, hl⟩ := h₂
(isBounded_Icc l u).subset (fun _x hx => mem_Icc.mpr ⟨hl hx, hu hx⟩)
end CompactIccSpace
end Bounded
section Diam
variable {s : Set α} {x y z : α}
/-- The diameter of a set in a metric space. To get controllable behavior even when the diameter
should be infinite, we express it in terms of the `EMetric.diam` -/
noncomputable def diam (s : Set α) : ℝ :=
ENNReal.toReal (EMetric.diam s)
/-- The diameter of a set is always nonnegative -/
theorem diam_nonneg : 0 ≤ diam s :=
ENNReal.toReal_nonneg
theorem diam_subsingleton (hs : s.Subsingleton) : diam s = 0 := by
simp only [diam, EMetric.diam_subsingleton hs, ENNReal.zero_toReal]
/-- The empty set has zero diameter -/
@[simp]
theorem diam_empty : diam (∅ : Set α) = 0 :=
diam_subsingleton subsingleton_empty
/-- A singleton has zero diameter -/
@[simp]
theorem diam_singleton : diam ({x} : Set α) = 0 :=
diam_subsingleton subsingleton_singleton
@[to_additive (attr := simp)]
theorem diam_one [One α] : diam (1 : Set α) = 0 :=
diam_singleton
-- Does not work as a simp-lemma, since {x, y} reduces to (insert y {x})
theorem diam_pair : diam ({x, y} : Set α) = dist x y := by
simp only [diam, EMetric.diam_pair, dist_edist]
-- Does not work as a simp-lemma, since {x, y, z} reduces to (insert z (insert y {x}))
theorem diam_triple :
Metric.diam ({x, y, z} : Set α) = max (max (dist x y) (dist x z)) (dist y z) := by
simp only [Metric.diam, EMetric.diam_triple, dist_edist]
rw [ENNReal.toReal_max, ENNReal.toReal_max] <;> apply_rules [ne_of_lt, edist_lt_top, max_lt]
/-- If the distance between any two points in a set is bounded by some constant `C`,
then `ENNReal.ofReal C` bounds the emetric diameter of this set. -/
theorem ediam_le_of_forall_dist_le {C : ℝ} (h : ∀ x ∈ s, ∀ y ∈ s, dist x y ≤ C) :
EMetric.diam s ≤ ENNReal.ofReal C :=
EMetric.diam_le fun x hx y hy => (edist_dist x y).symm ▸ ENNReal.ofReal_le_ofReal (h x hx y hy)
/-- If the distance between any two points in a set is bounded by some non-negative constant,
this constant bounds the diameter. -/
theorem diam_le_of_forall_dist_le {C : ℝ} (h₀ : 0 ≤ C) (h : ∀ x ∈ s, ∀ y ∈ s, dist x y ≤ C) :
diam s ≤ C :=
ENNReal.toReal_le_of_le_ofReal h₀ (ediam_le_of_forall_dist_le h)
/-- If the distance between any two points in a nonempty set is bounded by some constant,
this constant bounds the diameter. -/
theorem diam_le_of_forall_dist_le_of_nonempty (hs : s.Nonempty) {C : ℝ}
(h : ∀ x ∈ s, ∀ y ∈ s, dist x y ≤ C) : diam s ≤ C :=
have h₀ : 0 ≤ C :=
let ⟨x, hx⟩ := hs
le_trans dist_nonneg (h x hx x hx)
diam_le_of_forall_dist_le h₀ h
/-- The distance between two points in a set is controlled by the diameter of the set. -/
theorem dist_le_diam_of_mem' (h : EMetric.diam s ≠ ⊤) (hx : x ∈ s) (hy : y ∈ s) :
dist x y ≤ diam s := by
rw [diam, dist_edist]
rw [ENNReal.toReal_le_toReal (edist_ne_top _ _) h]
exact EMetric.edist_le_diam_of_mem hx hy
/-- Characterize the boundedness of a set in terms of the finiteness of its emetric.diameter. -/
theorem isBounded_iff_ediam_ne_top : IsBounded s ↔ EMetric.diam s ≠ ⊤ :=
isBounded_iff.trans <| Iff.intro
(fun ⟨_C, hC⟩ => ne_top_of_le_ne_top ENNReal.ofReal_ne_top <| ediam_le_of_forall_dist_le hC)
fun h => ⟨diam s, fun _x hx _y hy => dist_le_diam_of_mem' h hx hy⟩
alias ⟨_root_.Bornology.IsBounded.ediam_ne_top, _⟩ := isBounded_iff_ediam_ne_top
theorem ediam_eq_top_iff_unbounded : EMetric.diam s = ⊤ ↔ ¬IsBounded s :=
isBounded_iff_ediam_ne_top.not_left.symm
theorem ediam_univ_eq_top_iff_noncompact [ProperSpace α] :
EMetric.diam (univ : Set α) = ∞ ↔ NoncompactSpace α := by
rw [← not_compactSpace_iff, compactSpace_iff_isBounded_univ, isBounded_iff_ediam_ne_top,
Classical.not_not]
@[simp]
theorem ediam_univ_of_noncompact [ProperSpace α] [NoncompactSpace α] :
EMetric.diam (univ : Set α) = ∞ :=
ediam_univ_eq_top_iff_noncompact.mpr ‹_›
@[simp]
theorem diam_univ_of_noncompact [ProperSpace α] [NoncompactSpace α] : diam (univ : Set α) = 0 := by
simp [diam]
/-- The distance between two points in a set is controlled by the diameter of the set. -/
theorem dist_le_diam_of_mem (h : IsBounded s) (hx : x ∈ s) (hy : y ∈ s) : dist x y ≤ diam s :=
dist_le_diam_of_mem' h.ediam_ne_top hx hy
theorem ediam_of_unbounded (h : ¬IsBounded s) : EMetric.diam s = ∞ := ediam_eq_top_iff_unbounded.2 h
/-- An unbounded set has zero diameter. If you would prefer to get the value ∞, use `EMetric.diam`.
This lemma makes it possible to avoid side conditions in some situations -/
theorem diam_eq_zero_of_unbounded (h : ¬IsBounded s) : diam s = 0 := by
rw [diam, ediam_of_unbounded h, ENNReal.top_toReal]
/-- If `s ⊆ t`, then the diameter of `s` is bounded by that of `t`, provided `t` is bounded. -/
theorem diam_mono {s t : Set α} (h : s ⊆ t) (ht : IsBounded t) : diam s ≤ diam t :=
ENNReal.toReal_mono ht.ediam_ne_top <| EMetric.diam_mono h
/-- The diameter of a union is controlled by the sum of the diameters, and the distance between
any two points in each of the sets. This lemma is true without any side condition, since it is
obviously true if `s ∪ t` is unbounded. -/
theorem diam_union {t : Set α} (xs : x ∈ s) (yt : y ∈ t) :
diam (s ∪ t) ≤ diam s + dist x y + diam t := by
simp only [diam, dist_edist]
refine (ENNReal.toReal_le_add' (EMetric.diam_union xs yt) ?_ ?_).trans
(add_le_add_right ENNReal.toReal_add_le _)
· simp only [ENNReal.add_eq_top, edist_ne_top, or_false]
exact fun h ↦ top_unique <| h ▸ EMetric.diam_mono subset_union_left
· exact fun h ↦ top_unique <| h ▸ EMetric.diam_mono subset_union_right
/-- If two sets intersect, the diameter of the union is bounded by the sum of the diameters. -/
theorem diam_union' {t : Set α} (h : (s ∩ t).Nonempty) : diam (s ∪ t) ≤ diam s + diam t := by
rcases h with ⟨x, ⟨xs, xt⟩⟩
simpa using diam_union xs xt
theorem diam_le_of_subset_closedBall {r : ℝ} (hr : 0 ≤ r) (h : s ⊆ closedBall x r) :
diam s ≤ 2 * r :=
diam_le_of_forall_dist_le (mul_nonneg zero_le_two hr) fun a ha b hb =>
calc
dist a b ≤ dist a x + dist b x := dist_triangle_right _ _ _
_ ≤ r + r := add_le_add (h ha) (h hb)
_ = 2 * r := by simp [mul_two, mul_comm]
/-- The diameter of a closed ball of radius `r` is at most `2 r`. -/
theorem diam_closedBall {r : ℝ} (h : 0 ≤ r) : diam (closedBall x r) ≤ 2 * r :=
diam_le_of_subset_closedBall h Subset.rfl
/-- The diameter of a ball of radius `r` is at most `2 r`. -/
theorem diam_ball {r : ℝ} (h : 0 ≤ r) : diam (ball x r) ≤ 2 * r :=
diam_le_of_subset_closedBall h ball_subset_closedBall
/-- If a family of complete sets with diameter tending to `0` is such that each finite intersection
is nonempty, then the total intersection is also nonempty. -/
theorem _root_.IsComplete.nonempty_iInter_of_nonempty_biInter {s : ℕ → Set α}
(h0 : IsComplete (s 0)) (hs : ∀ n, IsClosed (s n)) (h's : ∀ n, IsBounded (s n))
(h : ∀ N, (⋂ n ≤ N, s n).Nonempty) (h' : Tendsto (fun n => diam (s n)) atTop (𝓝 0)) :
(⋂ n, s n).Nonempty := by
let u N := (h N).some
have I : ∀ n N, n ≤ N → u N ∈ s n := by
intro n N hn
apply mem_of_subset_of_mem _ (h N).choose_spec
intro x hx
simp only [mem_iInter] at hx
exact hx n hn
have : CauchySeq u := by
apply cauchySeq_of_le_tendsto_0 _ _ h'
intro m n N hm hn
exact dist_le_diam_of_mem (h's N) (I _ _ hm) (I _ _ hn)
obtain ⟨x, -, xlim⟩ : ∃ x ∈ s 0, Tendsto (fun n : ℕ => u n) atTop (𝓝 x) :=
cauchySeq_tendsto_of_isComplete h0 (fun n => I 0 n (zero_le _)) this
refine ⟨x, mem_iInter.2 fun n => ?_⟩
apply (hs n).mem_of_tendsto xlim
filter_upwards [Ici_mem_atTop n] with p hp
exact I n p hp
/-- In a complete space, if a family of closed sets with diameter tending to `0` is such that each
finite intersection is nonempty, then the total intersection is also nonempty. -/
theorem nonempty_iInter_of_nonempty_biInter [CompleteSpace α] {s : ℕ → Set α}
(hs : ∀ n, IsClosed (s n)) (h's : ∀ n, IsBounded (s n)) (h : ∀ N, (⋂ n ≤ N, s n).Nonempty)
(h' : Tendsto (fun n => diam (s n)) atTop (𝓝 0)) : (⋂ n, s n).Nonempty :=
(hs 0).isComplete.nonempty_iInter_of_nonempty_biInter hs h's h h'
end Diam
end Metric
namespace Mathlib.Meta.Positivity
open Lean Meta Qq Function
/-- Extension for the `positivity` tactic: the diameter of a set is always nonnegative. -/
@[positivity Metric.diam _]
def evalDiam : PositivityExt where eval {u α} _zα _pα e := do
match u, α, e with
| 0, ~q(ℝ), ~q(@Metric.diam _ $inst $s) =>
assertInstancesCommute
pure (.nonnegative q(Metric.diam_nonneg))
| _, _, _ => throwError "not ‖ · ‖"
end Mathlib.Meta.Positivity
open Metric
theorem Metric.cobounded_eq_cocompact [ProperSpace α] : cobounded α = cocompact α := by
nontriviality α; inhabit α
exact cobounded_le_cocompact.antisymm <| (hasBasis_cobounded_compl_closedBall default).ge_iff.2
fun _ _ ↦ (isCompact_closedBall _ _).compl_mem_cocompact
theorem tendsto_dist_right_cocompact_atTop [ProperSpace α] (x : α) :
Tendsto (dist · x) (cocompact α) atTop :=
(tendsto_dist_right_cobounded_atTop x).mono_left cobounded_eq_cocompact.ge
theorem tendsto_dist_left_cocompact_atTop [ProperSpace α] (x : α) :
Tendsto (dist x) (cocompact α) atTop :=
(tendsto_dist_left_cobounded_atTop x).mono_left cobounded_eq_cocompact.ge
theorem comap_dist_left_atTop_eq_cocompact [ProperSpace α] (x : α) :
comap (dist x) atTop = cocompact α := by simp [cobounded_eq_cocompact]
theorem tendsto_cocompact_of_tendsto_dist_comp_atTop {f : β → α} {l : Filter β} (x : α)
(h : Tendsto (fun y => dist (f y) x) l atTop) : Tendsto f l (cocompact α) :=
((tendsto_dist_right_atTop_iff _).1 h).mono_right cobounded_le_cocompact
theorem Metric.finite_isBounded_inter_isClosed [ProperSpace α] {K s : Set α} [DiscreteTopology s]
(hK : IsBounded K) (hs : IsClosed s) : Set.Finite (K ∩ s) := by
refine Set.Finite.subset (IsCompact.finite ?_ ?_) (Set.inter_subset_inter_left s subset_closure)
· exact hK.isCompact_closure.inter_right hs
· exact DiscreteTopology.of_subset inferInstance Set.inter_subset_right
|
Topology\MetricSpace\CantorScheme.lean | /-
Copyright (c) 2023 Felix Weilacher. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Felix Weilacher
-/
import Mathlib.Topology.MetricSpace.PiNat
/-!
# (Topological) Schemes and their induced maps
In topology, and especially descriptive set theory, one often constructs functions `(ℕ → β) → α`,
where α is some topological space and β is a discrete space, as an appropriate limit of some map
`List β → Set α`. We call the latter type of map a "`β`-scheme on `α`".
This file develops the basic, abstract theory of these schemes and the functions they induce.
## Main Definitions
* `CantorScheme.inducedMap A` : The aforementioned "limit" of a scheme `A : List β → Set α`.
This is a partial function from `ℕ → β` to `a`,
implemented here as an object of type `Σ s : Set (ℕ → β), s → α`.
That is, `(inducedMap A).1` is the domain and `(inducedMap A).2` is the function.
## Implementation Notes
We consider end-appending to be the fundamental way to build lists (say on `β`) inductively,
as this interacts better with the topology on `ℕ → β`.
As a result, functions like `List.get?` or `Stream'.take` do not have their intended meaning
in this file. See instead `PiNat.res`.
## References
* [kechris1995] (Chapters 6-7)
## Tags
scheme, cantor scheme, lusin scheme, approximation.
-/
namespace CantorScheme
open List Function Filter Set PiNat
open scoped Classical
open Topology
variable {β α : Type*} (A : List β → Set α)
/-- From a `β`-scheme on `α` `A`, we define a partial function from `(ℕ → β)` to `α`
which sends each infinite sequence `x` to an element of the intersection along the
branch corresponding to `x`, if it exists.
We call this the map induced by the scheme. -/
noncomputable def inducedMap : Σs : Set (ℕ → β), s → α :=
⟨fun x => Set.Nonempty (⋂ n : ℕ, A (res x n)), fun x => x.property.some⟩
section Topology
/-- A scheme is antitone if each set contains its children. -/
protected def Antitone : Prop :=
∀ l : List β, ∀ a : β, A (a :: l) ⊆ A l
/-- A useful strengthening of being antitone is to require that each set contains
the closure of each of its children. -/
def ClosureAntitone [TopologicalSpace α] : Prop :=
∀ l : List β, ∀ a : β, closure (A (a :: l)) ⊆ A l
/-- A scheme is disjoint if the children of each set of pairwise disjoint. -/
protected def Disjoint : Prop :=
∀ l : List β, Pairwise fun a b => Disjoint (A (a :: l)) (A (b :: l))
variable {A}
/-- If `x` is in the domain of the induced map of a scheme `A`,
its image under this map is in each set along the corresponding branch. -/
theorem map_mem (x : (inducedMap A).1) (n : ℕ) : (inducedMap A).2 x ∈ A (res x n) := by
have := x.property.some_mem
rw [mem_iInter] at this
exact this n
protected theorem ClosureAntitone.antitone [TopologicalSpace α] (hA : ClosureAntitone A) :
CantorScheme.Antitone A := fun l a => subset_closure.trans (hA l a)
protected theorem Antitone.closureAntitone [TopologicalSpace α] (hanti : CantorScheme.Antitone A)
(hclosed : ∀ l, IsClosed (A l)) : ClosureAntitone A := fun _ _ =>
(hclosed _).closure_eq.subset.trans (hanti _ _)
/-- A scheme where the children of each set are pairwise disjoint induces an injective map. -/
theorem Disjoint.map_injective (hA : CantorScheme.Disjoint A) : Injective (inducedMap A).2 := by
rintro ⟨x, hx⟩ ⟨y, hy⟩ hxy
refine Subtype.coe_injective (res_injective ?_)
dsimp
ext n : 1
induction' n with n ih; · simp
simp only [res_succ, cons.injEq]
refine ⟨?_, ih⟩
contrapose hA
simp only [CantorScheme.Disjoint, _root_.Pairwise, Ne, not_forall, exists_prop]
refine ⟨res x n, _, _, hA, ?_⟩
rw [not_disjoint_iff]
refine ⟨(inducedMap A).2 ⟨x, hx⟩, ?_, ?_⟩
· rw [← res_succ]
apply map_mem
rw [hxy, ih, ← res_succ]
apply map_mem
end Topology
section Metric
variable [PseudoMetricSpace α]
/-- A scheme on a metric space has vanishing diameter if diameter approaches 0 along each branch. -/
def VanishingDiam : Prop :=
∀ x : ℕ → β, Tendsto (fun n : ℕ => EMetric.diam (A (res x n))) atTop (𝓝 0)
variable {A}
theorem VanishingDiam.dist_lt (hA : VanishingDiam A) (ε : ℝ) (ε_pos : 0 < ε) (x : ℕ → β) :
∃ n : ℕ, ∀ (y) (_ : y ∈ A (res x n)) (z) (_ : z ∈ A (res x n)), dist y z < ε := by
specialize hA x
rw [ENNReal.tendsto_atTop_zero] at hA
cases' hA (ENNReal.ofReal (ε / 2)) (by
simp only [gt_iff_lt, ENNReal.ofReal_pos]
linarith) with n hn
use n
intro y hy z hz
rw [← ENNReal.ofReal_lt_ofReal_iff ε_pos, ← edist_dist]
apply lt_of_le_of_lt (EMetric.edist_le_diam_of_mem hy hz)
apply lt_of_le_of_lt (hn _ (le_refl _))
rw [ENNReal.ofReal_lt_ofReal_iff ε_pos]
linarith
/-- A scheme with vanishing diameter along each branch induces a continuous map. -/
theorem VanishingDiam.map_continuous [TopologicalSpace β] [DiscreteTopology β]
(hA : VanishingDiam A) : Continuous (inducedMap A).2 := by
rw [Metric.continuous_iff']
rintro ⟨x, hx⟩ ε ε_pos
cases' hA.dist_lt _ ε_pos x with n hn
rw [_root_.eventually_nhds_iff]
refine ⟨(↑)⁻¹' cylinder x n, ?_, ?_, by simp⟩
· rintro ⟨y, hy⟩ hyx
rw [mem_preimage, Subtype.coe_mk, cylinder_eq_res, mem_setOf] at hyx
apply hn
· rw [← hyx]
apply map_mem
apply map_mem
apply continuous_subtype_val.isOpen_preimage
apply isOpen_cylinder
/-- A scheme on a complete space with vanishing diameter
such that each set contains the closure of its children
induces a total map. -/
theorem ClosureAntitone.map_of_vanishingDiam [CompleteSpace α] (hdiam : VanishingDiam A)
(hanti : ClosureAntitone A) (hnonempty : ∀ l, (A l).Nonempty) : (inducedMap A).1 = univ := by
rw [eq_univ_iff_forall]
intro x
choose u hu using fun n => hnonempty (res x n)
have umem : ∀ n m : ℕ, n ≤ m → u m ∈ A (res x n) := by
have : Antitone fun n : ℕ => A (res x n) := by
refine antitone_nat_of_succ_le ?_
intro n
apply hanti.antitone
intro n m hnm
exact this hnm (hu _)
have : CauchySeq u := by
rw [Metric.cauchySeq_iff]
intro ε ε_pos
cases' hdiam.dist_lt _ ε_pos x with n hn
use n
intro m₀ hm₀ m₁ hm₁
apply hn <;> apply umem <;> assumption
cases' cauchySeq_tendsto_of_complete this with y hy
use y
rw [mem_iInter]
intro n
apply hanti _ (x n)
apply mem_closure_of_tendsto hy
rw [eventually_atTop]
exact ⟨n.succ, umem _⟩
end Metric
end CantorScheme
|
Topology\MetricSpace\Cauchy.lean | /-
Copyright (c) 2015, 2017 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Robert Y. Lewis, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel
-/
import Mathlib.Topology.MetricSpace.Pseudo.Lemmas
/-!
## Cauchy sequences in (pseudo-)metric spaces
Various results on Cauchy sequences in (pseudo-)metric spaces, including
* `Metric.complete_of_cauchySeq_tendsto` A pseudo-metric space is complete iff each Cauchy sequences
converges to some limit point.
* `cauchySeq_bdd`: a Cauchy sequence on the natural numbers is bounded
* various characterisation of Cauchy and uniformly Cauchy sequences
## Tags
metric, pseudo_metric, Cauchy sequence
-/
open Filter
open scoped Uniformity Topology
universe u v w
variable {α : Type u} {β : Type v} {X ι : Type*}
variable [PseudoMetricSpace α]
/-- A very useful criterion to show that a space is complete is to show that all sequences
which satisfy a bound of the form `dist (u n) (u m) < B N` for all `n m ≥ N` are
converging. This is often applied for `B N = 2^{-N}`, i.e., with a very fast convergence to
`0`, which makes it possible to use arguments of converging series, while this is impossible
to do in general for arbitrary Cauchy sequences. -/
theorem Metric.complete_of_convergent_controlled_sequences (B : ℕ → Real) (hB : ∀ n, 0 < B n)
(H : ∀ u : ℕ → α, (∀ N n m : ℕ, N ≤ n → N ≤ m → dist (u n) (u m) < B N) →
∃ x, Tendsto u atTop (𝓝 x)) :
CompleteSpace α :=
UniformSpace.complete_of_convergent_controlled_sequences
(fun n => { p : α × α | dist p.1 p.2 < B n }) (fun n => dist_mem_uniformity <| hB n) H
/-- A pseudo-metric space is complete iff every Cauchy sequence converges. -/
theorem Metric.complete_of_cauchySeq_tendsto :
(∀ u : ℕ → α, CauchySeq u → ∃ a, Tendsto u atTop (𝓝 a)) → CompleteSpace α :=
EMetric.complete_of_cauchySeq_tendsto
section CauchySeq
variable [Nonempty β] [SemilatticeSup β]
/-- In a pseudometric space, Cauchy sequences are characterized by the fact that, eventually,
the distance between its elements is arbitrarily small -/
-- Porting note: @[nolint ge_or_gt] doesn't exist
theorem Metric.cauchySeq_iff {u : β → α} :
CauchySeq u ↔ ∀ ε > 0, ∃ N, ∀ m ≥ N, ∀ n ≥ N, dist (u m) (u n) < ε :=
uniformity_basis_dist.cauchySeq_iff
/-- A variation around the pseudometric characterization of Cauchy sequences -/
theorem Metric.cauchySeq_iff' {u : β → α} :
CauchySeq u ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, dist (u n) (u N) < ε :=
uniformity_basis_dist.cauchySeq_iff'
-- see Note [nolint_ge]
/-- In a pseudometric space, uniform Cauchy sequences are characterized by the fact that,
eventually, the distance between all its elements is uniformly, arbitrarily small. -/
-- Porting note: no attr @[nolint ge_or_gt]
theorem Metric.uniformCauchySeqOn_iff {γ : Type*} {F : β → γ → α} {s : Set γ} :
UniformCauchySeqOn F atTop s ↔ ∀ ε > (0 : ℝ),
∃ N : β, ∀ m ≥ N, ∀ n ≥ N, ∀ x ∈ s, dist (F m x) (F n x) < ε := by
constructor
· intro h ε hε
let u := { a : α × α | dist a.fst a.snd < ε }
have hu : u ∈ 𝓤 α := Metric.mem_uniformity_dist.mpr ⟨ε, hε, by simp [u]⟩
rw [← Filter.eventually_atTop_prod_self' (p := fun m =>
∀ x ∈ s, dist (F m.fst x) (F m.snd x) < ε)]
specialize h u hu
rw [prod_atTop_atTop_eq] at h
exact h.mono fun n h x hx => h x hx
· intro h u hu
rcases Metric.mem_uniformity_dist.mp hu with ⟨ε, hε, hab⟩
rcases h ε hε with ⟨N, hN⟩
rw [prod_atTop_atTop_eq, eventually_atTop]
use (N, N)
intro b hb x hx
rcases hb with ⟨hbl, hbr⟩
exact hab (hN b.fst hbl.ge b.snd hbr.ge x hx)
/-- If the distance between `s n` and `s m`, `n ≤ m` is bounded above by `b n`
and `b` converges to zero, then `s` is a Cauchy sequence. -/
theorem cauchySeq_of_le_tendsto_0' {s : β → α} (b : β → ℝ)
(h : ∀ n m : β, n ≤ m → dist (s n) (s m) ≤ b n) (h₀ : Tendsto b atTop (𝓝 0)) : CauchySeq s :=
Metric.cauchySeq_iff'.2 fun ε ε0 => (h₀.eventually (gt_mem_nhds ε0)).exists.imp fun N hN n hn =>
calc dist (s n) (s N) = dist (s N) (s n) := dist_comm _ _
_ ≤ b N := h _ _ hn
_ < ε := hN
/-- If the distance between `s n` and `s m`, `n, m ≥ N` is bounded above by `b N`
and `b` converges to zero, then `s` is a Cauchy sequence. -/
theorem cauchySeq_of_le_tendsto_0 {s : β → α} (b : β → ℝ)
(h : ∀ n m N : β, N ≤ n → N ≤ m → dist (s n) (s m) ≤ b N) (h₀ : Tendsto b atTop (𝓝 0)) :
CauchySeq s :=
cauchySeq_of_le_tendsto_0' b (fun _n _m hnm => h _ _ _ le_rfl hnm) h₀
/-- A Cauchy sequence on the natural numbers is bounded. -/
theorem cauchySeq_bdd {u : ℕ → α} (hu : CauchySeq u) : ∃ R > 0, ∀ m n, dist (u m) (u n) < R := by
rcases Metric.cauchySeq_iff'.1 hu 1 zero_lt_one with ⟨N, hN⟩
rsuffices ⟨R, R0, H⟩ : ∃ R > 0, ∀ n, dist (u n) (u N) < R
· exact ⟨_, add_pos R0 R0, fun m n =>
lt_of_le_of_lt (dist_triangle_right _ _ _) (add_lt_add (H m) (H n))⟩
let R := Finset.sup (Finset.range N) fun n => nndist (u n) (u N)
refine ⟨↑R + 1, add_pos_of_nonneg_of_pos R.2 zero_lt_one, fun n => ?_⟩
rcases le_or_lt N n with h | h
· exact lt_of_lt_of_le (hN _ h) (le_add_of_nonneg_left R.2)
· have : _ ≤ R := Finset.le_sup (Finset.mem_range.2 h)
exact lt_of_le_of_lt this (lt_add_of_pos_right _ zero_lt_one)
/-- Yet another metric characterization of Cauchy sequences on integers. This one is often the
most efficient. -/
theorem cauchySeq_iff_le_tendsto_0 {s : ℕ → α} :
CauchySeq s ↔
∃ b : ℕ → ℝ,
(∀ n, 0 ≤ b n) ∧
(∀ n m N : ℕ, N ≤ n → N ≤ m → dist (s n) (s m) ≤ b N) ∧ Tendsto b atTop (𝓝 0) :=
⟨fun hs => by
/- `s` is a Cauchy sequence. The sequence `b` will be constructed by taking
the supremum of the distances between `s n` and `s m` for `n m ≥ N`.
First, we prove that all these distances are bounded, as otherwise the Sup
would not make sense. -/
let S N := (fun p : ℕ × ℕ => dist (s p.1) (s p.2)) '' { p | p.1 ≥ N ∧ p.2 ≥ N }
have hS : ∀ N, ∃ x, ∀ y ∈ S N, y ≤ x := by
rcases cauchySeq_bdd hs with ⟨R, -, hR⟩
refine fun N => ⟨R, ?_⟩
rintro _ ⟨⟨m, n⟩, _, rfl⟩
exact le_of_lt (hR m n)
-- Prove that it bounds the distances of points in the Cauchy sequence
have ub : ∀ m n N, N ≤ m → N ≤ n → dist (s m) (s n) ≤ sSup (S N) := fun m n N hm hn =>
le_csSup (hS N) ⟨⟨_, _⟩, ⟨hm, hn⟩, rfl⟩
have S0m : ∀ n, (0 : ℝ) ∈ S n := fun n => ⟨⟨n, n⟩, ⟨le_rfl, le_rfl⟩, dist_self _⟩
have S0 := fun n => le_csSup (hS n) (S0m n)
-- Prove that it tends to `0`, by using the Cauchy property of `s`
refine ⟨fun N => sSup (S N), S0, ub, Metric.tendsto_atTop.2 fun ε ε0 => ?_⟩
refine (Metric.cauchySeq_iff.1 hs (ε / 2) (half_pos ε0)).imp fun N hN n hn => ?_
rw [Real.dist_0_eq_abs, abs_of_nonneg (S0 n)]
refine lt_of_le_of_lt (csSup_le ⟨_, S0m _⟩ ?_) (half_lt_self ε0)
rintro _ ⟨⟨m', n'⟩, ⟨hm', hn'⟩, rfl⟩
exact le_of_lt (hN _ (le_trans hn hm') _ (le_trans hn hn')),
fun ⟨b, _, b_bound, b_lim⟩ => cauchySeq_of_le_tendsto_0 b b_bound b_lim⟩
lemma Metric.exists_subseq_bounded_of_cauchySeq (u : ℕ → α) (hu : CauchySeq u) (b : ℕ → ℝ)
(hb : ∀ n, 0 < b n) :
∃ f : ℕ → ℕ, StrictMono f ∧ ∀ n, ∀ m ≥ f n, dist (u m) (u (f n)) < b n := by
rw [cauchySeq_iff] at hu
have hu' : ∀ k, ∀ᶠ (n : ℕ) in atTop, ∀ m ≥ n, dist (u m) (u n) < b k := by
intro k
rw [eventually_atTop]
obtain ⟨N, hN⟩ := hu (b k) (hb k)
exact ⟨N, fun m hm r hr => hN r (hm.trans hr) m hm⟩
exact Filter.extraction_forall_of_eventually hu'
end CauchySeq
|
Topology\MetricSpace\CauSeqFilter.lean | /-
Copyright (c) 2018 Robert Y. Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Y. Lewis, Sébastien Gouëzel
-/
import Mathlib.Analysis.Normed.Field.Basic
/-!
# Completeness in terms of `Cauchy` filters vs `isCauSeq` sequences
In this file we apply `Metric.complete_of_cauchySeq_tendsto` to prove that a `NormedRing`
is complete in terms of `Cauchy` filter if and only if it is complete in terms
of `CauSeq` Cauchy sequences.
-/
universe u v
open Set Filter
open scoped Classical
open Topology
variable {β : Type v}
theorem CauSeq.tendsto_limit [NormedRing β] [hn : IsAbsoluteValue (norm : β → ℝ)]
(f : CauSeq β norm) [CauSeq.IsComplete β norm] : Tendsto f atTop (𝓝 f.lim) :=
tendsto_nhds.mpr
(by
intro s os lfs
suffices ∃ a : ℕ, ∀ b : ℕ, b ≥ a → f b ∈ s by simpa using this
rcases Metric.isOpen_iff.1 os _ lfs with ⟨ε, ⟨hε, hεs⟩⟩
cases' Setoid.symm (CauSeq.equiv_lim f) _ hε with N hN
exists N
intro b hb
apply hεs
dsimp [Metric.ball]
rw [dist_comm, dist_eq_norm]
solve_by_elim)
variable [NormedField β]
/-
This section shows that if we have a uniform space generated by an absolute value, topological
completeness and Cauchy sequence completeness coincide. The problem is that there isn't
a good notion of "uniform space generated by an absolute value", so right now this is
specific to norm. Furthermore, norm only instantiates IsAbsoluteValue on NormedDivisionRing.
This needs to be fixed, since it prevents showing that ℤ_[hp] is complete.
-/
open Metric
theorem CauchySeq.isCauSeq {f : ℕ → β} (hf : CauchySeq f) : IsCauSeq norm f := by
cases' cauchy_iff.1 hf with hf1 hf2
intro ε hε
rcases hf2 { x | dist x.1 x.2 < ε } (dist_mem_uniformity hε) with ⟨t, ⟨ht, htsub⟩⟩
simp only [mem_map, mem_atTop_sets, mem_preimage] at ht; cases' ht with N hN
exists N
intro j hj
rw [← dist_eq_norm]
apply @htsub (f j, f N)
apply Set.mk_mem_prod <;> solve_by_elim [le_refl]
theorem CauSeq.cauchySeq (f : CauSeq β norm) : CauchySeq f := by
refine cauchy_iff.2 ⟨by infer_instance, fun s hs => ?_⟩
rcases mem_uniformity_dist.1 hs with ⟨ε, ⟨hε, hεs⟩⟩
cases' CauSeq.cauchy₂ f hε with N hN
exists { n | n ≥ N }.image f
simp only [exists_prop, mem_atTop_sets, mem_map, mem_image, mem_setOf_eq]
constructor
· exists N
intro b hb
exists b
· rintro ⟨a, b⟩ ⟨⟨a', ⟨ha'1, ha'2⟩⟩, ⟨b', ⟨hb'1, hb'2⟩⟩⟩
dsimp at ha'1 ha'2 hb'1 hb'2
rw [← ha'2, ← hb'2]
apply hεs
rw [dist_eq_norm]
apply hN <;> assumption
/-- In a normed field, `CauSeq` coincides with the usual notion of Cauchy sequences. -/
theorem isCauSeq_iff_cauchySeq {α : Type u} [NormedField α] {u : ℕ → α} :
IsCauSeq norm u ↔ CauchySeq u :=
⟨fun h => CauSeq.cauchySeq ⟨u, h⟩, fun h => h.isCauSeq⟩
-- see Note [lower instance priority]
/-- A complete normed field is complete as a metric space, as Cauchy sequences converge by
assumption and this suffices to characterize completeness. -/
instance (priority := 100) completeSpace_of_cauSeq_isComplete [CauSeq.IsComplete β norm] :
CompleteSpace β := by
apply complete_of_cauchySeq_tendsto
intro u hu
have C : IsCauSeq norm u := isCauSeq_iff_cauchySeq.2 hu
exists CauSeq.lim ⟨u, C⟩
rw [Metric.tendsto_atTop]
intro ε εpos
cases' (CauSeq.equiv_lim ⟨u, C⟩) _ εpos with N hN
exists N
simpa [dist_eq_norm] using hN
|
Topology\MetricSpace\Closeds.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.Analysis.SpecificLimits.Basic
import Mathlib.Topology.MetricSpace.HausdorffDistance
import Mathlib.Topology.Sets.Compacts
/-!
# Closed subsets
This file defines the metric and emetric space structure on the types of closed subsets and nonempty
compact subsets of a metric or emetric space.
The Hausdorff distance induces an emetric space structure on the type of closed subsets
of an emetric space, called `Closeds`. Its completeness, resp. compactness, resp.
second-countability, follow from the corresponding properties of the original space.
In a metric space, the type of nonempty compact subsets (called `NonemptyCompacts`) also
inherits a metric space structure from the Hausdorff distance, as the Hausdorff edistance is
always finite in this context.
-/
noncomputable section
open scoped Classical
open Topology ENNReal
universe u
open scoped Classical
open Set Function TopologicalSpace Filter
namespace EMetric
section
variable {α : Type u} [EMetricSpace α] {s : Set α}
/-- In emetric spaces, the Hausdorff edistance defines an emetric space structure
on the type of closed subsets -/
instance Closeds.emetricSpace : EMetricSpace (Closeds α) where
edist s t := hausdorffEdist (s : Set α) t
edist_self s := hausdorffEdist_self
edist_comm s t := hausdorffEdist_comm
edist_triangle s t u := hausdorffEdist_triangle
eq_of_edist_eq_zero {s t} h :=
Closeds.ext <| (hausdorffEdist_zero_iff_eq_of_closed s.closed t.closed).1 h
/-- The edistance to a closed set depends continuously on the point and the set -/
theorem continuous_infEdist_hausdorffEdist :
Continuous fun p : α × Closeds α => infEdist p.1 p.2 := by
refine continuous_of_le_add_edist 2 (by simp) ?_
rintro ⟨x, s⟩ ⟨y, t⟩
calc
infEdist x s ≤ infEdist x t + hausdorffEdist (t : Set α) s :=
infEdist_le_infEdist_add_hausdorffEdist
_ ≤ infEdist y t + edist x y + hausdorffEdist (t : Set α) s :=
(add_le_add_right infEdist_le_infEdist_add_edist _)
_ = infEdist y t + (edist x y + hausdorffEdist (s : Set α) t) := by
rw [add_assoc, hausdorffEdist_comm]
_ ≤ infEdist y t + (edist (x, s) (y, t) + edist (x, s) (y, t)) :=
(add_le_add_left (add_le_add (le_max_left _ _) (le_max_right _ _)) _)
_ = infEdist y t + 2 * edist (x, s) (y, t) := by rw [← mul_two, mul_comm]
/-- Subsets of a given closed subset form a closed set -/
theorem isClosed_subsets_of_isClosed (hs : IsClosed s) :
IsClosed { t : Closeds α | (t : Set α) ⊆ s } := by
refine isClosed_of_closure_subset fun
(t : Closeds α) (ht : t ∈ closure {t : Closeds α | (t : Set α) ⊆ s}) (x : α) (hx : x ∈ t) => ?_
have : x ∈ closure s := by
refine mem_closure_iff.2 fun ε εpos => ?_
obtain ⟨u : Closeds α, hu : u ∈ {t : Closeds α | (t : Set α) ⊆ s}, Dtu : edist t u < ε⟩ :=
mem_closure_iff.1 ht ε εpos
obtain ⟨y : α, hy : y ∈ u, Dxy : edist x y < ε⟩ := exists_edist_lt_of_hausdorffEdist_lt hx Dtu
exact ⟨y, hu hy, Dxy⟩
rwa [hs.closure_eq] at this
/-- By definition, the edistance on `Closeds α` is given by the Hausdorff edistance -/
theorem Closeds.edist_eq {s t : Closeds α} : edist s t = hausdorffEdist (s : Set α) t :=
rfl
/-- In a complete space, the type of closed subsets is complete for the
Hausdorff edistance. -/
instance Closeds.completeSpace [CompleteSpace α] : CompleteSpace (Closeds α) := by
/- We will show that, if a sequence of sets `s n` satisfies
`edist (s n) (s (n+1)) < 2^{-n}`, then it converges. This is enough to guarantee
completeness, by a standard completeness criterion.
We use the shorthand `B n = 2^{-n}` in ennreal. -/
let B : ℕ → ℝ≥0∞ := fun n => 2⁻¹ ^ n
have B_pos : ∀ n, (0 : ℝ≥0∞) < B n := by simp [B, ENNReal.pow_pos]
have B_ne_top : ∀ n, B n ≠ ⊤ := by simp [B, ENNReal.pow_ne_top]
/- Consider a sequence of closed sets `s n` with `edist (s n) (s (n+1)) < B n`.
We will show that it converges. The limit set is `t0 = ⋂n, closure (⋃m≥n, s m)`.
We will have to show that a point in `s n` is close to a point in `t0`, and a point
in `t0` is close to a point in `s n`. The completeness then follows from a
standard criterion. -/
refine complete_of_convergent_controlled_sequences B B_pos fun s hs => ?_
let t0 := ⋂ n, closure (⋃ m ≥ n, s m : Set α)
let t : Closeds α := ⟨t0, isClosed_iInter fun _ => isClosed_closure⟩
use t
-- The inequality is written this way to agree with `edist_le_of_edist_le_geometric_of_tendsto₀`
have I1 : ∀ n, ∀ x ∈ s n, ∃ y ∈ t0, edist x y ≤ 2 * B n := by
/- This is the main difficulty of the proof. Starting from `x ∈ s n`, we want
to find a point in `t0` which is close to `x`. Define inductively a sequence of
points `z m` with `z n = x` and `z m ∈ s m` and `edist (z m) (z (m+1)) ≤ B m`. This is
possible since the Hausdorff distance between `s m` and `s (m+1)` is at most `B m`.
This sequence is a Cauchy sequence, therefore converging as the space is complete, to
a limit which satisfies the required properties. -/
intro n x hx
obtain ⟨z, hz₀, hz⟩ :
∃ z : ∀ l, s (n + l), (z 0 : α) = x ∧ ∀ k, edist (z k : α) (z (k + 1) : α) ≤ B n / 2 ^ k := by
-- We prove existence of the sequence by induction.
have : ∀ (l) (z : s (n + l)), ∃ z' : s (n + l + 1), edist (z : α) z' ≤ B n / 2 ^ l := by
intro l z
obtain ⟨z', z'_mem, hz'⟩ : ∃ z' ∈ s (n + l + 1), edist (z : α) z' < B n / 2 ^ l := by
refine exists_edist_lt_of_hausdorffEdist_lt (s := s (n + l)) z.2 ?_
simp only [ENNReal.inv_pow, div_eq_mul_inv]
rw [← pow_add]
apply hs <;> simp
exact ⟨⟨z', z'_mem⟩, le_of_lt hz'⟩
use fun k => Nat.recOn k ⟨x, hx⟩ fun l z => (this l z).choose
simp only [Nat.add_zero, Nat.zero_eq, Nat.rec_zero, Nat.rec_add_one, true_and]
exact fun k => (this k _).choose_spec
-- it follows from the previous bound that `z` is a Cauchy sequence
have : CauchySeq fun k => (z k : α) := cauchySeq_of_edist_le_geometric_two (B n) (B_ne_top n) hz
-- therefore, it converges
rcases cauchySeq_tendsto_of_complete this with ⟨y, y_lim⟩
use y
-- the limit point `y` will be the desired point, in `t0` and close to our initial point `x`.
-- First, we check it belongs to `t0`.
have : y ∈ t0 :=
mem_iInter.2 fun k =>
mem_closure_of_tendsto y_lim
(by
simp only [exists_prop, Set.mem_iUnion, Filter.eventually_atTop, Set.mem_preimage,
Set.preimage_iUnion]
exact ⟨k, fun m hm => ⟨n + m, zero_add k ▸ add_le_add (zero_le n) hm, (z m).2⟩⟩)
use this
-- Then, we check that `y` is close to `x = z n`. This follows from the fact that `y`
-- is the limit of `z k`, and the distance between `z n` and `z k` has already been estimated.
rw [← hz₀]
exact edist_le_of_edist_le_geometric_two_of_tendsto₀ (B n) hz y_lim
have I2 : ∀ n, ∀ x ∈ t0, ∃ y ∈ s n, edist x y ≤ 2 * B n := by
/- For the (much easier) reverse inequality, we start from a point `x ∈ t0` and we want
to find a point `y ∈ s n` which is close to `x`.
`x` belongs to `t0`, the intersection of the closures. In particular, it is well
approximated by a point `z` in `⋃m≥n, s m`, say in `s m`. Since `s m` and
`s n` are close, this point is itself well approximated by a point `y` in `s n`,
as required. -/
intro n x xt0
have : x ∈ closure (⋃ m ≥ n, s m : Set α) := by apply mem_iInter.1 xt0 n
obtain ⟨z : α, hz, Dxz : edist x z < B n⟩ := mem_closure_iff.1 this (B n) (B_pos n)
simp only [exists_prop, Set.mem_iUnion] at hz
obtain ⟨m : ℕ, m_ge_n : m ≥ n, hm : z ∈ (s m : Set α)⟩ := hz
have : hausdorffEdist (s m : Set α) (s n) < B n := hs n m n m_ge_n (le_refl n)
obtain ⟨y : α, hy : y ∈ (s n : Set α), Dzy : edist z y < B n⟩ :=
exists_edist_lt_of_hausdorffEdist_lt hm this
exact
⟨y, hy,
calc
edist x y ≤ edist x z + edist z y := edist_triangle _ _ _
_ ≤ B n + B n := add_le_add (le_of_lt Dxz) (le_of_lt Dzy)
_ = 2 * B n := (two_mul _).symm
⟩
-- Deduce from the above inequalities that the distance between `s n` and `t0` is at most `2 B n`.
have main : ∀ n : ℕ, edist (s n) t ≤ 2 * B n := fun n =>
hausdorffEdist_le_of_mem_edist (I1 n) (I2 n)
-- from this, the convergence of `s n` to `t0` follows.
refine tendsto_atTop.2 fun ε εpos => ?_
have : Tendsto (fun n => 2 * B n) atTop (𝓝 (2 * 0)) :=
ENNReal.Tendsto.const_mul (ENNReal.tendsto_pow_atTop_nhds_zero_of_lt_one <|
by simp [ENNReal.one_lt_two]) (Or.inr <| by simp)
rw [mul_zero] at this
obtain ⟨N, hN⟩ : ∃ N, ∀ b ≥ N, ε > 2 * B b :=
((tendsto_order.1 this).2 ε εpos).exists_forall_of_atTop
exact ⟨N, fun n hn => lt_of_le_of_lt (main n) (hN n hn)⟩
/-- In a compact space, the type of closed subsets is compact. -/
instance Closeds.compactSpace [CompactSpace α] : CompactSpace (Closeds α) :=
⟨by
/- by completeness, it suffices to show that it is totally bounded,
i.e., for all ε>0, there is a finite set which is ε-dense.
start from a set `s` which is ε-dense in α. Then the subsets of `s`
are finitely many, and ε-dense for the Hausdorff distance. -/
refine
isCompact_of_totallyBounded_isClosed (EMetric.totallyBounded_iff.2 fun ε εpos => ?_)
isClosed_univ
rcases exists_between εpos with ⟨δ, δpos, δlt⟩
obtain ⟨s : Set α, fs : s.Finite, hs : univ ⊆ ⋃ y ∈ s, ball y δ⟩ :=
EMetric.totallyBounded_iff.1
(isCompact_iff_totallyBounded_isComplete.1 (@isCompact_univ α _ _)).1 δ δpos
-- we first show that any set is well approximated by a subset of `s`.
have main : ∀ u : Set α, ∃ v ⊆ s, hausdorffEdist u v ≤ δ := by
intro u
let v := { x : α | x ∈ s ∧ ∃ y ∈ u, edist x y < δ }
exists v, (fun x hx => hx.1 : v ⊆ s)
refine hausdorffEdist_le_of_mem_edist ?_ ?_
· intro x hx
have : x ∈ ⋃ y ∈ s, ball y δ := hs (by simp)
rcases mem_iUnion₂.1 this with ⟨y, ys, dy⟩
have : edist y x < δ := by simpa [edist_comm]
exact ⟨y, ⟨ys, ⟨x, hx, this⟩⟩, le_of_lt dy⟩
· rintro x ⟨_, ⟨y, yu, hy⟩⟩
exact ⟨y, yu, le_of_lt hy⟩
-- introduce the set F of all subsets of `s` (seen as members of `Closeds α`).
let F := { f : Closeds α | (f : Set α) ⊆ s }
refine ⟨F, ?_, fun u _ => ?_⟩
-- `F` is finite
· apply @Finite.of_finite_image _ _ F _
· apply fs.finite_subsets.subset fun b => _
· exact fun s => (s : Set α)
simp only [F, and_imp, Set.mem_image, Set.mem_setOf_eq, exists_imp]
intro _ x hx hx'
rwa [hx'] at hx
· exact SetLike.coe_injective.injOn
-- `F` is ε-dense
· obtain ⟨t0, t0s, Dut0⟩ := main u
have : IsClosed t0 := (fs.subset t0s).isCompact.isClosed
let t : Closeds α := ⟨t0, this⟩
have : t ∈ F := t0s
have : edist u t < ε := lt_of_le_of_lt Dut0 δlt
apply mem_iUnion₂.2
exact ⟨t, ‹t ∈ F›, this⟩⟩
/-- In an emetric space, the type of non-empty compact subsets is an emetric space,
where the edistance is the Hausdorff edistance -/
instance NonemptyCompacts.emetricSpace : EMetricSpace (NonemptyCompacts α) where
edist s t := hausdorffEdist (s : Set α) t
edist_self s := hausdorffEdist_self
edist_comm s t := hausdorffEdist_comm
edist_triangle s t u := hausdorffEdist_triangle
eq_of_edist_eq_zero {s t} h := NonemptyCompacts.ext <| by
have : closure (s : Set α) = closure t := hausdorffEdist_zero_iff_closure_eq_closure.1 h
rwa [s.isCompact.isClosed.closure_eq, t.isCompact.isClosed.closure_eq] at this
/-- `NonemptyCompacts.toCloseds` is a uniform embedding (as it is an isometry) -/
theorem NonemptyCompacts.ToCloseds.uniformEmbedding :
UniformEmbedding (@NonemptyCompacts.toCloseds α _ _) :=
Isometry.uniformEmbedding fun _ _ => rfl
/-- The range of `NonemptyCompacts.toCloseds` is closed in a complete space -/
theorem NonemptyCompacts.isClosed_in_closeds [CompleteSpace α] :
IsClosed (range <| @NonemptyCompacts.toCloseds α _ _) := by
have :
range NonemptyCompacts.toCloseds =
{ s : Closeds α | (s : Set α).Nonempty ∧ IsCompact (s : Set α) } := by
ext s
refine ⟨?_, fun h => ⟨⟨⟨s, h.2⟩, h.1⟩, Closeds.ext rfl⟩⟩
rintro ⟨s, hs, rfl⟩
exact ⟨s.nonempty, s.isCompact⟩
rw [this]
refine isClosed_of_closure_subset fun s hs => ⟨?_, ?_⟩
· -- take a set t which is nonempty and at a finite distance of s
rcases mem_closure_iff.1 hs ⊤ ENNReal.coe_lt_top with ⟨t, ht, Dst⟩
rw [edist_comm] at Dst
-- since `t` is nonempty, so is `s`
exact nonempty_of_hausdorffEdist_ne_top ht.1 (ne_of_lt Dst)
· refine isCompact_iff_totallyBounded_isComplete.2 ⟨?_, s.closed.isComplete⟩
refine totallyBounded_iff.2 fun ε (εpos : 0 < ε) => ?_
-- we have to show that s is covered by finitely many eballs of radius ε
-- pick a nonempty compact set t at distance at most ε/2 of s
rcases mem_closure_iff.1 hs (ε / 2) (ENNReal.half_pos εpos.ne') with ⟨t, ht, Dst⟩
-- cover this space with finitely many balls of radius ε/2
rcases totallyBounded_iff.1 (isCompact_iff_totallyBounded_isComplete.1 ht.2).1 (ε / 2)
(ENNReal.half_pos εpos.ne') with
⟨u, fu, ut⟩
refine ⟨u, ⟨fu, fun x hx => ?_⟩⟩
-- u : set α, fu : u.finite, ut : t ⊆ ⋃ (y : α) (H : y ∈ u), eball y (ε / 2)
-- then s is covered by the union of the balls centered at u of radius ε
rcases exists_edist_lt_of_hausdorffEdist_lt hx Dst with ⟨z, hz, Dxz⟩
rcases mem_iUnion₂.1 (ut hz) with ⟨y, hy, Dzy⟩
have : edist x y < ε :=
calc
edist x y ≤ edist x z + edist z y := edist_triangle _ _ _
_ < ε / 2 + ε / 2 := ENNReal.add_lt_add Dxz Dzy
_ = ε := ENNReal.add_halves _
exact mem_biUnion hy this
/-- In a complete space, the type of nonempty compact subsets is complete. This follows
from the same statement for closed subsets -/
instance NonemptyCompacts.completeSpace [CompleteSpace α] : CompleteSpace (NonemptyCompacts α) :=
(completeSpace_iff_isComplete_range
NonemptyCompacts.ToCloseds.uniformEmbedding.toUniformInducing).2 <|
NonemptyCompacts.isClosed_in_closeds.isComplete
/-- In a compact space, the type of nonempty compact subsets is compact. This follows from
the same statement for closed subsets -/
instance NonemptyCompacts.compactSpace [CompactSpace α] : CompactSpace (NonemptyCompacts α) :=
⟨by
rw [NonemptyCompacts.ToCloseds.uniformEmbedding.embedding.isCompact_iff, image_univ]
exact NonemptyCompacts.isClosed_in_closeds.isCompact⟩
/-- In a second countable space, the type of nonempty compact subsets is second countable -/
instance NonemptyCompacts.secondCountableTopology [SecondCountableTopology α] :
SecondCountableTopology (NonemptyCompacts α) :=
haveI : SeparableSpace (NonemptyCompacts α) := by
/- To obtain a countable dense subset of `NonemptyCompacts α`, start from
a countable dense subset `s` of α, and then consider all its finite nonempty subsets.
This set is countable and made of nonempty compact sets. It turns out to be dense:
by total boundedness, any compact set `t` can be covered by finitely many small balls, and
approximations in `s` of the centers of these balls give the required finite approximation
of `t`. -/
rcases exists_countable_dense α with ⟨s, cs, s_dense⟩
let v0 := { t : Set α | t.Finite ∧ t ⊆ s }
let v : Set (NonemptyCompacts α) := { t : NonemptyCompacts α | (t : Set α) ∈ v0 }
refine ⟨⟨v, ?_, ?_⟩⟩
· have : v0.Countable := countable_setOf_finite_subset cs
exact this.preimage SetLike.coe_injective
· refine fun t => mem_closure_iff.2 fun ε εpos => ?_
-- t is a compact nonempty set, that we have to approximate uniformly by a a set in `v`.
rcases exists_between εpos with ⟨δ, δpos, δlt⟩
have δpos' : 0 < δ / 2 := ENNReal.half_pos δpos.ne'
-- construct a map F associating to a point in α an approximating point in s, up to δ/2.
have Exy : ∀ x, ∃ y, y ∈ s ∧ edist x y < δ / 2 := by
intro x
rcases mem_closure_iff.1 (s_dense x) (δ / 2) δpos' with ⟨y, ys, hy⟩
exact ⟨y, ⟨ys, hy⟩⟩
let F x := (Exy x).choose
have Fspec : ∀ x, F x ∈ s ∧ edist x (F x) < δ / 2 := fun x => (Exy x).choose_spec
-- cover `t` with finitely many balls. Their centers form a set `a`
have : TotallyBounded (t : Set α) := t.isCompact.totallyBounded
obtain ⟨a : Set α, af : Set.Finite a, ta : (t : Set α) ⊆ ⋃ y ∈ a, ball y (δ / 2)⟩ :=
totallyBounded_iff.1 this (δ / 2) δpos'
-- replace each center by a nearby approximation in `s`, giving a new set `b`
let b := F '' a
have : b.Finite := af.image _
have tb : ∀ x ∈ t, ∃ y ∈ b, edist x y < δ := by
intro x hx
rcases mem_iUnion₂.1 (ta hx) with ⟨z, za, Dxz⟩
exists F z, mem_image_of_mem _ za
calc
edist x (F z) ≤ edist x z + edist z (F z) := edist_triangle _ _ _
_ < δ / 2 + δ / 2 := ENNReal.add_lt_add Dxz (Fspec z).2
_ = δ := ENNReal.add_halves _
-- keep only the points in `b` that are close to point in `t`, yielding a new set `c`
let c := { y ∈ b | ∃ x ∈ t, edist x y < δ }
have : c.Finite := ‹b.Finite›.subset fun x hx => hx.1
-- points in `t` are well approximated by points in `c`
have tc : ∀ x ∈ t, ∃ y ∈ c, edist x y ≤ δ := by
intro x hx
rcases tb x hx with ⟨y, yv, Dxy⟩
have : y ∈ c := by simpa [c, -mem_image] using ⟨yv, ⟨x, hx, Dxy⟩⟩
exact ⟨y, this, le_of_lt Dxy⟩
-- points in `c` are well approximated by points in `t`
have ct : ∀ y ∈ c, ∃ x ∈ t, edist y x ≤ δ := by
rintro y ⟨_, x, xt, Dyx⟩
have : edist y x ≤ δ :=
calc
edist y x = edist x y := edist_comm _ _
_ ≤ δ := le_of_lt Dyx
exact ⟨x, xt, this⟩
-- it follows that their Hausdorff distance is small
have : hausdorffEdist (t : Set α) c ≤ δ := hausdorffEdist_le_of_mem_edist tc ct
have Dtc : hausdorffEdist (t : Set α) c < ε := this.trans_lt δlt
-- the set `c` is not empty, as it is well approximated by a nonempty set
have hc : c.Nonempty := nonempty_of_hausdorffEdist_ne_top t.nonempty (ne_top_of_lt Dtc)
-- let `d` be the version of `c` in the type `NonemptyCompacts α`
let d : NonemptyCompacts α := ⟨⟨c, ‹c.Finite›.isCompact⟩, hc⟩
have : c ⊆ s := by
intro x hx
rcases (mem_image _ _ _).1 hx.1 with ⟨y, ⟨_, yx⟩⟩
rw [← yx]
exact (Fspec y).1
have : d ∈ v := ⟨‹c.Finite›, this⟩
-- we have proved that `d` is a good approximation of `t` as requested
exact ⟨d, ‹d ∈ v›, Dtc⟩
UniformSpace.secondCountable_of_separable (NonemptyCompacts α)
end
--section
end EMetric
--namespace
namespace Metric
section
variable {α : Type u} [MetricSpace α]
/-- `NonemptyCompacts α` inherits a metric space structure, as the Hausdorff
edistance between two such sets is finite. -/
instance NonemptyCompacts.metricSpace : MetricSpace (NonemptyCompacts α) :=
EMetricSpace.toMetricSpace fun x y =>
hausdorffEdist_ne_top_of_nonempty_of_bounded x.nonempty y.nonempty x.isCompact.isBounded
y.isCompact.isBounded
/-- The distance on `NonemptyCompacts α` is the Hausdorff distance, by construction -/
theorem NonemptyCompacts.dist_eq {x y : NonemptyCompacts α} :
dist x y = hausdorffDist (x : Set α) y :=
rfl
theorem lipschitz_infDist_set (x : α) : LipschitzWith 1 fun s : NonemptyCompacts α => infDist x s :=
LipschitzWith.of_le_add fun s t => by
rw [dist_comm]
exact infDist_le_infDist_add_hausdorffDist (edist_ne_top t s)
theorem lipschitz_infDist : LipschitzWith 2 fun p : α × NonemptyCompacts α => infDist p.1 p.2 := by
-- Porting note: Changed tactic from `exact` to `convert`, because Lean had trouble with 2 = 1 + 1
convert @LipschitzWith.uncurry α (NonemptyCompacts α) ℝ _ _ _
(fun (x : α) (s : NonemptyCompacts α) => infDist x s) 1 1
(fun s => lipschitz_infDist_pt ↑s) lipschitz_infDist_set
norm_num
theorem uniformContinuous_infDist_Hausdorff_dist :
UniformContinuous fun p : α × NonemptyCompacts α => infDist p.1 p.2 :=
lipschitz_infDist.uniformContinuous
end --section
end Metric --namespace
|
Topology\MetricSpace\Completion.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.Completion
import Mathlib.Topology.MetricSpace.Isometry
import Mathlib.Topology.MetricSpace.Lipschitz
import Mathlib.Topology.Instances.Real
/-!
# The completion of a metric space
Completion of uniform spaces are already defined in `Topology.UniformSpace.Completion`. We show
here that the uniform space completion of a metric space inherits a metric space structure,
by extending the distance to the completion and checking that it is indeed a distance, and that
it defines the same uniformity as the already defined uniform structure on the completion
-/
open Set Filter UniformSpace Metric
open Filter Topology Uniformity
noncomputable section
universe u v
variable {α : Type u} {β : Type v} [PseudoMetricSpace α]
namespace UniformSpace.Completion
/-- The distance on the completion is obtained by extending the distance on the original space,
by uniform continuity. -/
instance : Dist (Completion α) :=
⟨Completion.extension₂ dist⟩
/-- The new distance is uniformly continuous. -/
protected theorem uniformContinuous_dist :
UniformContinuous fun p : Completion α × Completion α ↦ dist p.1 p.2 :=
uniformContinuous_extension₂ dist
/-- The new distance is continuous. -/
protected theorem continuous_dist [TopologicalSpace β] {f g : β → Completion α} (hf : Continuous f)
(hg : Continuous g) : Continuous fun x ↦ dist (f x) (g x) :=
Completion.uniformContinuous_dist.continuous.comp (hf.prod_mk hg : _)
/-- The new distance is an extension of the original distance. -/
@[simp]
protected theorem dist_eq (x y : α) : dist (x : Completion α) y = dist x y :=
Completion.extension₂_coe_coe uniformContinuous_dist _ _
/- Let us check that the new distance satisfies the axioms of a distance, by starting from the
properties on α and extending them to `Completion α` by continuity. -/
protected theorem dist_self (x : Completion α) : dist x x = 0 := by
refine induction_on x ?_ ?_
· refine isClosed_eq ?_ continuous_const
exact Completion.continuous_dist continuous_id continuous_id
· intro a
rw [Completion.dist_eq, dist_self]
protected theorem dist_comm (x y : Completion α) : dist x y = dist y x := by
refine induction_on₂ x y ?_ ?_
· exact isClosed_eq (Completion.continuous_dist continuous_fst continuous_snd)
(Completion.continuous_dist continuous_snd continuous_fst)
· intro a b
rw [Completion.dist_eq, Completion.dist_eq, dist_comm]
protected theorem dist_triangle (x y z : Completion α) : dist x z ≤ dist x y + dist y z := by
refine induction_on₃ x y z ?_ ?_
· refine isClosed_le ?_ (Continuous.add ?_ ?_) <;>
apply_rules [Completion.continuous_dist, Continuous.fst, Continuous.snd, continuous_id]
· intro a b c
rw [Completion.dist_eq, Completion.dist_eq, Completion.dist_eq]
exact dist_triangle a b c
/-- Elements of the uniformity (defined generally for completions) can be characterized in terms
of the distance. -/
protected theorem mem_uniformity_dist (s : Set (Completion α × Completion α)) :
s ∈ 𝓤 (Completion α) ↔ ∃ ε > 0, ∀ {a b}, dist a b < ε → (a, b) ∈ s := by
constructor
· /- Start from an entourage `s`. It contains a closed entourage `t`. Its pullback in `α` is an
entourage, so it contains an `ε`-neighborhood of the diagonal by definition of the entourages
in metric spaces. Then `t` contains an `ε`-neighborhood of the diagonal in `Completion α`, as
closed properties pass to the completion. -/
intro hs
rcases mem_uniformity_isClosed hs with ⟨t, ht, ⟨tclosed, ts⟩⟩
have A : { x : α × α | (↑x.1, ↑x.2) ∈ t } ∈ uniformity α :=
uniformContinuous_def.1 (uniformContinuous_coe α) t ht
rcases mem_uniformity_dist.1 A with ⟨ε, εpos, hε⟩
refine ⟨ε, εpos, @fun x y hxy ↦ ?_⟩
have : ε ≤ dist x y ∨ (x, y) ∈ t := by
refine induction_on₂ x y ?_ ?_
· have : { x : Completion α × Completion α | ε ≤ dist x.fst x.snd ∨ (x.fst, x.snd) ∈ t } =
{ p : Completion α × Completion α | ε ≤ dist p.1 p.2 } ∪ t := by ext; simp
rw [this]
apply IsClosed.union _ tclosed
exact isClosed_le continuous_const Completion.uniformContinuous_dist.continuous
· intro x y
rw [Completion.dist_eq]
by_cases h : ε ≤ dist x y
· exact Or.inl h
· have Z := hε (not_le.1 h)
simp only [Set.mem_setOf_eq] at Z
exact Or.inr Z
simp only [not_le.mpr hxy, false_or_iff, not_le] at this
exact ts this
· /- Start from a set `s` containing an ε-neighborhood of the diagonal in `Completion α`. To show
that it is an entourage, we use the fact that `dist` is uniformly continuous on
`Completion α × Completion α` (this is a general property of the extension of uniformly
continuous functions). Therefore, the preimage of the ε-neighborhood of the diagonal in ℝ
is an entourage in `Completion α × Completion α`. Massaging this property, it follows that
the ε-neighborhood of the diagonal is an entourage in `Completion α`, and therefore this is
also the case of `s`. -/
rintro ⟨ε, εpos, hε⟩
let r : Set (ℝ × ℝ) := { p | dist p.1 p.2 < ε }
have : r ∈ uniformity ℝ := Metric.dist_mem_uniformity εpos
have T := uniformContinuous_def.1 (@Completion.uniformContinuous_dist α _) r this
simp only [uniformity_prod_eq_prod, mem_prod_iff, exists_prop, Filter.mem_map,
Set.mem_setOf_eq] at T
rcases T with ⟨t1, ht1, t2, ht2, ht⟩
refine mem_of_superset ht1 ?_
have A : ∀ a b : Completion α, (a, b) ∈ t1 → dist a b < ε := by
intro a b hab
have : ((a, b), (a, a)) ∈ t1 ×ˢ t2 := ⟨hab, refl_mem_uniformity ht2⟩
have I := ht this
simp? [r, Completion.dist_self, Real.dist_eq, Completion.dist_comm] at I says
simp only [Real.dist_eq, mem_setOf_eq, preimage_setOf_eq, Completion.dist_self,
Completion.dist_comm, zero_sub, abs_neg, r] at I
exact lt_of_le_of_lt (le_abs_self _) I
show t1 ⊆ s
rintro ⟨a, b⟩ hp
have : dist a b < ε := A a b hp
exact hε this
/-- Reformulate `Completion.mem_uniformity_dist` in terms that are suitable for the definition
of the metric space structure. -/
protected theorem uniformity_dist' :
𝓤 (Completion α) = ⨅ ε : { ε : ℝ // 0 < ε }, 𝓟 { p | dist p.1 p.2 < ε.val } := by
ext s; rw [mem_iInf_of_directed]
· simp [Completion.mem_uniformity_dist, subset_def]
· rintro ⟨r, hr⟩ ⟨p, hp⟩
use ⟨min r p, lt_min hr hp⟩
simp (config := { contextual := true }) [lt_min_iff]
protected theorem uniformity_dist : 𝓤 (Completion α) = ⨅ ε > 0, 𝓟 { p | dist p.1 p.2 < ε } := by
simpa [iInf_subtype] using @Completion.uniformity_dist' α _
/-- Metric space structure on the completion of a pseudo_metric space. -/
instance instMetricSpace : MetricSpace (Completion α) :=
@MetricSpace.ofT0PseudoMetricSpace _
{ dist_self := Completion.dist_self
dist_comm := Completion.dist_comm
dist_triangle := Completion.dist_triangle
dist := dist
toUniformSpace := inferInstance
uniformity_dist := Completion.uniformity_dist } _
@[deprecated eq_of_dist_eq_zero (since := "2024-03-10")]
protected theorem eq_of_dist_eq_zero (x y : Completion α) (h : dist x y = 0) : x = y :=
eq_of_dist_eq_zero h
/-- The embedding of a metric space in its completion is an isometry. -/
theorem coe_isometry : Isometry ((↑) : α → Completion α) :=
Isometry.of_dist_eq Completion.dist_eq
@[simp]
protected theorem edist_eq (x y : α) : edist (x : Completion α) y = edist x y :=
coe_isometry x y
end UniformSpace.Completion
open UniformSpace Completion NNReal
theorem LipschitzWith.completion_extension [MetricSpace β] [CompleteSpace β] {f : α → β}
{K : ℝ≥0} (h : LipschitzWith K f) : LipschitzWith K (Completion.extension f) :=
LipschitzWith.of_dist_le_mul fun x y => induction_on₂ x y
(isClosed_le (by fun_prop) (by fun_prop)) <| by
simpa only [extension_coe h.uniformContinuous, Completion.dist_eq] using h.dist_le_mul
theorem LipschitzWith.completion_map [PseudoMetricSpace β] {f : α → β} {K : ℝ≥0}
(h : LipschitzWith K f) : LipschitzWith K (Completion.map f) :=
one_mul K ▸ (coe_isometry.lipschitz.comp h).completion_extension
theorem Isometry.completion_extension [MetricSpace β] [CompleteSpace β] {f : α → β}
(h : Isometry f) : Isometry (Completion.extension f) :=
Isometry.of_dist_eq fun x y => induction_on₂ x y
(isClosed_eq (by fun_prop) (by fun_prop)) fun _ _ ↦ by
simp only [extension_coe h.uniformContinuous, Completion.dist_eq, h.dist_eq]
theorem Isometry.completion_map [PseudoMetricSpace β] {f : α → β}
(h : Isometry f) : Isometry (Completion.map f) :=
(coe_isometry.comp h).completion_extension
|
Topology\MetricSpace\Contracting.lean | /-
Copyright (c) 2019 Rohan Mitta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rohan Mitta, Kevin Buzzard, Alistair Tucker, Johannes Hölzl, Yury Kudryashov
-/
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.Data.Setoid.Basic
import Mathlib.Dynamics.FixedPoints.Topology
import Mathlib.Topology.MetricSpace.Lipschitz
/-!
# Contracting maps
A Lipschitz continuous self-map with Lipschitz constant `K < 1` is called a *contracting map*.
In this file we prove the Banach fixed point theorem, some explicit estimates on the rate
of convergence, and some properties of the map sending a contracting map to its fixed point.
## Main definitions
* `ContractingWith K f` : a Lipschitz continuous self-map with `K < 1`;
* `efixedPoint` : given a contracting map `f` on a complete emetric space and a point `x`
such that `edist x (f x) ≠ ∞`, `efixedPoint f hf x hx` is the unique fixed point of `f`
in `EMetric.ball x ∞`;
* `fixedPoint` : the unique fixed point of a contracting map on a complete nonempty metric space.
## Tags
contracting map, fixed point, Banach fixed point theorem
-/
open scoped Classical
open NNReal Topology ENNReal Filter Function
variable {α : Type*}
/-- A map is said to be `ContractingWith K`, if `K < 1` and `f` is `LipschitzWith K`. -/
def ContractingWith [EMetricSpace α] (K : ℝ≥0) (f : α → α) :=
K < 1 ∧ LipschitzWith K f
namespace ContractingWith
variable [EMetricSpace α] [cs : CompleteSpace α] {K : ℝ≥0} {f : α → α}
open EMetric Set
theorem toLipschitzWith (hf : ContractingWith K f) : LipschitzWith K f := hf.2
theorem one_sub_K_pos' (hf : ContractingWith K f) : (0 : ℝ≥0∞) < 1 - K := by simp [hf.1]
theorem one_sub_K_ne_zero (hf : ContractingWith K f) : (1 : ℝ≥0∞) - K ≠ 0 :=
ne_of_gt hf.one_sub_K_pos'
theorem one_sub_K_ne_top : (1 : ℝ≥0∞) - K ≠ ∞ := by
norm_cast
exact ENNReal.coe_ne_top
theorem edist_inequality (hf : ContractingWith K f) {x y} (h : edist x y ≠ ∞) :
edist x y ≤ (edist x (f x) + edist y (f y)) / (1 - K) :=
suffices edist x y ≤ edist x (f x) + edist y (f y) + K * edist x y by
rwa [ENNReal.le_div_iff_mul_le (Or.inl hf.one_sub_K_ne_zero) (Or.inl one_sub_K_ne_top),
mul_comm, ENNReal.sub_mul fun _ _ ↦ h, one_mul, tsub_le_iff_right]
calc
edist x y ≤ edist x (f x) + edist (f x) (f y) + edist (f y) y := edist_triangle4 _ _ _ _
_ = edist x (f x) + edist y (f y) + edist (f x) (f y) := by rw [edist_comm y, add_right_comm]
_ ≤ edist x (f x) + edist y (f y) + K * edist x y := add_le_add le_rfl (hf.2 _ _)
theorem edist_le_of_fixedPoint (hf : ContractingWith K f) {x y} (h : edist x y ≠ ∞)
(hy : IsFixedPt f y) : edist x y ≤ edist x (f x) / (1 - K) := by
simpa only [hy.eq, edist_self, add_zero] using hf.edist_inequality h
theorem eq_or_edist_eq_top_of_fixedPoints (hf : ContractingWith K f) {x y} (hx : IsFixedPt f x)
(hy : IsFixedPt f y) : x = y ∨ edist x y = ∞ := by
refine or_iff_not_imp_right.2 fun h ↦ edist_le_zero.1 ?_
simpa only [hx.eq, edist_self, add_zero, ENNReal.zero_div] using hf.edist_le_of_fixedPoint h hy
/-- If a map `f` is `ContractingWith K`, and `s` is a forward-invariant set, then
restriction of `f` to `s` is `ContractingWith K` as well. -/
theorem restrict (hf : ContractingWith K f) {s : Set α} (hs : MapsTo f s s) :
ContractingWith K (hs.restrict f s s) :=
⟨hf.1, fun x y ↦ hf.2 x y⟩
/-- Banach fixed-point theorem, contraction mapping theorem, `EMetricSpace` version.
A contracting map on a complete metric space has a fixed point.
We include more conclusions in this theorem to avoid proving them again later.
The main API for this theorem are the functions `efixedPoint` and `fixedPoint`,
and lemmas about these functions. -/
theorem exists_fixedPoint (hf : ContractingWith K f) (x : α) (hx : edist x (f x) ≠ ∞) :
∃ y, IsFixedPt f y ∧ Tendsto (fun n ↦ f^[n] x) atTop (𝓝 y) ∧
∀ n : ℕ, edist (f^[n] x) y ≤ edist x (f x) * (K : ℝ≥0∞) ^ n / (1 - K) :=
have : CauchySeq fun n ↦ f^[n] x :=
cauchySeq_of_edist_le_geometric K (edist x (f x)) (ENNReal.coe_lt_one_iff.2 hf.1) hx
(hf.toLipschitzWith.edist_iterate_succ_le_geometric x)
let ⟨y, hy⟩ := cauchySeq_tendsto_of_complete this
⟨y, isFixedPt_of_tendsto_iterate hy hf.2.continuous.continuousAt, hy,
edist_le_of_edist_le_geometric_of_tendsto K (edist x (f x))
(hf.toLipschitzWith.edist_iterate_succ_le_geometric x) hy⟩
variable (f)
-- avoid `efixedPoint _` in pretty printer
/-- Let `x` be a point of a complete emetric space. Suppose that `f` is a contracting map,
and `edist x (f x) ≠ ∞`. Then `efixedPoint` is the unique fixed point of `f`
in `EMetric.ball x ∞`. -/
noncomputable def efixedPoint (hf : ContractingWith K f) (x : α) (hx : edist x (f x) ≠ ∞) : α :=
Classical.choose <| hf.exists_fixedPoint x hx
variable {f}
theorem efixedPoint_isFixedPt (hf : ContractingWith K f) {x : α} (hx : edist x (f x) ≠ ∞) :
IsFixedPt f (efixedPoint f hf x hx) :=
(Classical.choose_spec <| hf.exists_fixedPoint x hx).1
theorem tendsto_iterate_efixedPoint (hf : ContractingWith K f) {x : α} (hx : edist x (f x) ≠ ∞) :
Tendsto (fun n ↦ f^[n] x) atTop (𝓝 <| efixedPoint f hf x hx) :=
(Classical.choose_spec <| hf.exists_fixedPoint x hx).2.1
theorem apriori_edist_iterate_efixedPoint_le (hf : ContractingWith K f) {x : α}
(hx : edist x (f x) ≠ ∞) (n : ℕ) :
edist (f^[n] x) (efixedPoint f hf x hx) ≤ edist x (f x) * (K : ℝ≥0∞) ^ n / (1 - K) :=
(Classical.choose_spec <| hf.exists_fixedPoint x hx).2.2 n
theorem edist_efixedPoint_le (hf : ContractingWith K f) {x : α} (hx : edist x (f x) ≠ ∞) :
edist x (efixedPoint f hf x hx) ≤ edist x (f x) / (1 - K) := by
convert hf.apriori_edist_iterate_efixedPoint_le hx 0
simp only [pow_zero, mul_one]
theorem edist_efixedPoint_lt_top (hf : ContractingWith K f) {x : α} (hx : edist x (f x) ≠ ∞) :
edist x (efixedPoint f hf x hx) < ∞ :=
(hf.edist_efixedPoint_le hx).trans_lt
(ENNReal.mul_lt_top hx <| ENNReal.inv_ne_top.2 hf.one_sub_K_ne_zero)
theorem efixedPoint_eq_of_edist_lt_top (hf : ContractingWith K f) {x : α} (hx : edist x (f x) ≠ ∞)
{y : α} (hy : edist y (f y) ≠ ∞) (h : edist x y ≠ ∞) :
efixedPoint f hf x hx = efixedPoint f hf y hy := by
refine (hf.eq_or_edist_eq_top_of_fixedPoints ?_ ?_).elim id fun h' ↦ False.elim (ne_of_lt ?_ h')
<;> try apply efixedPoint_isFixedPt
change edistLtTopSetoid.Rel _ _
trans x
· apply Setoid.symm' -- Porting note: Originally `symm`
exact hf.edist_efixedPoint_lt_top hx
trans y
exacts [lt_top_iff_ne_top.2 h, hf.edist_efixedPoint_lt_top hy]
/-- Banach fixed-point theorem for maps contracting on a complete subset. -/
theorem exists_fixedPoint' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s)
(hf : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) :
∃ y ∈ s, IsFixedPt f y ∧ Tendsto (fun n ↦ f^[n] x) atTop (𝓝 y) ∧
∀ n : ℕ, edist (f^[n] x) y ≤ edist x (f x) * (K : ℝ≥0∞) ^ n / (1 - K) := by
haveI := hsc.completeSpace_coe
rcases hf.exists_fixedPoint ⟨x, hxs⟩ hx with ⟨y, hfy, h_tendsto, hle⟩
refine ⟨y, y.2, Subtype.ext_iff_val.1 hfy, ?_, fun n ↦ ?_⟩
· convert (continuous_subtype_val.tendsto _).comp h_tendsto
simp only [(· ∘ ·), MapsTo.iterate_restrict, MapsTo.val_restrict_apply]
· convert hle n
rw [MapsTo.iterate_restrict]
rfl
variable (f)
-- avoid `efixedPoint _` in pretty printer
/-- Let `s` be a complete forward-invariant set of a self-map `f`. If `f` contracts on `s`
and `x ∈ s` satisfies `edist x (f x) ≠ ∞`, then `efixedPoint'` is the unique fixed point
of the restriction of `f` to `s ∩ EMetric.ball x ∞`. -/
noncomputable def efixedPoint' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s)
(hf : ContractingWith K <| hsf.restrict f s s) (x : α) (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) :
α :=
Classical.choose <| hf.exists_fixedPoint' hsc hsf hxs hx
variable {f}
theorem efixedPoint_mem' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s)
(hf : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) :
efixedPoint' f hsc hsf hf x hxs hx ∈ s :=
(Classical.choose_spec <| hf.exists_fixedPoint' hsc hsf hxs hx).1
theorem efixedPoint_isFixedPt' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s)
(hf : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) :
IsFixedPt f (efixedPoint' f hsc hsf hf x hxs hx) :=
(Classical.choose_spec <| hf.exists_fixedPoint' hsc hsf hxs hx).2.1
theorem tendsto_iterate_efixedPoint' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s)
(hf : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) :
Tendsto (fun n ↦ f^[n] x) atTop (𝓝 <| efixedPoint' f hsc hsf hf x hxs hx) :=
(Classical.choose_spec <| hf.exists_fixedPoint' hsc hsf hxs hx).2.2.1
theorem apriori_edist_iterate_efixedPoint_le' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s)
(hf : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞)
(n : ℕ) :
edist (f^[n] x) (efixedPoint' f hsc hsf hf x hxs hx) ≤
edist x (f x) * (K : ℝ≥0∞) ^ n / (1 - K) :=
(Classical.choose_spec <| hf.exists_fixedPoint' hsc hsf hxs hx).2.2.2 n
theorem edist_efixedPoint_le' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s)
(hf : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) :
edist x (efixedPoint' f hsc hsf hf x hxs hx) ≤ edist x (f x) / (1 - K) := by
convert hf.apriori_edist_iterate_efixedPoint_le' hsc hsf hxs hx 0
rw [pow_zero, mul_one]
theorem edist_efixedPoint_lt_top' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s)
(hf : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) :
edist x (efixedPoint' f hsc hsf hf x hxs hx) < ∞ :=
(hf.edist_efixedPoint_le' hsc hsf hxs hx).trans_lt
(ENNReal.mul_lt_top hx <| ENNReal.inv_ne_top.2 hf.one_sub_K_ne_zero)
/-- If a globally contracting map `f` has two complete forward-invariant sets `s`, `t`,
and `x ∈ s` is at a finite distance from `y ∈ t`, then the `efixedPoint'` constructed by `x`
is the same as the `efixedPoint'` constructed by `y`.
This lemma takes additional arguments stating that `f` contracts on `s` and `t` because this way
it can be used to prove the desired equality with non-trivial proofs of these facts. -/
theorem efixedPoint_eq_of_edist_lt_top' (hf : ContractingWith K f) {s : Set α} (hsc : IsComplete s)
(hsf : MapsTo f s s) (hfs : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s)
(hx : edist x (f x) ≠ ∞) {t : Set α} (htc : IsComplete t) (htf : MapsTo f t t)
(hft : ContractingWith K <| htf.restrict f t t) {y : α} (hyt : y ∈ t) (hy : edist y (f y) ≠ ∞)
(hxy : edist x y ≠ ∞) :
efixedPoint' f hsc hsf hfs x hxs hx = efixedPoint' f htc htf hft y hyt hy := by
refine (hf.eq_or_edist_eq_top_of_fixedPoints ?_ ?_).elim id fun h' ↦ False.elim (ne_of_lt ?_ h')
<;> try apply efixedPoint_isFixedPt'
change edistLtTopSetoid.Rel _ _
trans x
· apply Setoid.symm' -- Porting note: Originally `symm`
apply edist_efixedPoint_lt_top'
trans y
· exact lt_top_iff_ne_top.2 hxy
· apply edist_efixedPoint_lt_top'
end ContractingWith
namespace ContractingWith
variable [MetricSpace α] {K : ℝ≥0} {f : α → α} (hf : ContractingWith K f)
theorem one_sub_K_pos (hf : ContractingWith K f) : (0 : ℝ) < 1 - K :=
sub_pos.2 hf.1
theorem dist_le_mul (x y : α) : dist (f x) (f y) ≤ K * dist x y :=
hf.toLipschitzWith.dist_le_mul x y
theorem dist_inequality (x y) : dist x y ≤ (dist x (f x) + dist y (f y)) / (1 - K) :=
suffices dist x y ≤ dist x (f x) + dist y (f y) + K * dist x y by
rwa [le_div_iff hf.one_sub_K_pos, mul_comm, _root_.sub_mul, one_mul, sub_le_iff_le_add]
calc
dist x y ≤ dist x (f x) + dist y (f y) + dist (f x) (f y) := dist_triangle4_right _ _ _ _
_ ≤ dist x (f x) + dist y (f y) + K * dist x y := add_le_add_left (hf.dist_le_mul _ _) _
theorem dist_le_of_fixedPoint (x) {y} (hy : IsFixedPt f y) : dist x y ≤ dist x (f x) / (1 - K) := by
simpa only [hy.eq, dist_self, add_zero] using hf.dist_inequality x y
theorem fixedPoint_unique' {x y} (hx : IsFixedPt f x) (hy : IsFixedPt f y) : x = y :=
(hf.eq_or_edist_eq_top_of_fixedPoints hx hy).resolve_right (edist_ne_top _ _)
/-- Let `f` be a contracting map with constant `K`; let `g` be another map uniformly
`C`-close to `f`. If `x` and `y` are their fixed points, then `dist x y ≤ C / (1 - K)`. -/
theorem dist_fixedPoint_fixedPoint_of_dist_le' (g : α → α) {x y} (hx : IsFixedPt f x)
(hy : IsFixedPt g y) {C} (hfg : ∀ z, dist (f z) (g z) ≤ C) : dist x y ≤ C / (1 - K) :=
calc
dist x y = dist y x := dist_comm x y
_ ≤ dist y (f y) / (1 - K) := hf.dist_le_of_fixedPoint y hx
_ = dist (f y) (g y) / (1 - K) := by rw [hy.eq, dist_comm]
_ ≤ C / (1 - K) := (div_le_div_right hf.one_sub_K_pos).2 (hfg y)
variable [Nonempty α] [CompleteSpace α]
variable (f)
/-- The unique fixed point of a contracting map in a nonempty complete metric space. -/
noncomputable def fixedPoint : α :=
efixedPoint f hf _ (edist_ne_top (Classical.choice ‹Nonempty α›) _)
variable {f}
/-- The point provided by `ContractingWith.fixedPoint` is actually a fixed point. -/
theorem fixedPoint_isFixedPt : IsFixedPt f (fixedPoint f hf) :=
hf.efixedPoint_isFixedPt _
theorem fixedPoint_unique {x} (hx : IsFixedPt f x) : x = fixedPoint f hf :=
hf.fixedPoint_unique' hx hf.fixedPoint_isFixedPt
theorem dist_fixedPoint_le (x) : dist x (fixedPoint f hf) ≤ dist x (f x) / (1 - K) :=
hf.dist_le_of_fixedPoint x hf.fixedPoint_isFixedPt
/-- Aposteriori estimates on the convergence of iterates to the fixed point. -/
theorem aposteriori_dist_iterate_fixedPoint_le (x n) :
dist (f^[n] x) (fixedPoint f hf) ≤ dist (f^[n] x) (f^[n + 1] x) / (1 - K) := by
rw [iterate_succ']
apply hf.dist_fixedPoint_le
theorem apriori_dist_iterate_fixedPoint_le (x n) :
dist (f^[n] x) (fixedPoint f hf) ≤ dist x (f x) * (K : ℝ) ^ n / (1 - K) :=
le_trans (hf.aposteriori_dist_iterate_fixedPoint_le x n) <|
(div_le_div_right hf.one_sub_K_pos).2 <| hf.toLipschitzWith.dist_iterate_succ_le_geometric x n
theorem tendsto_iterate_fixedPoint (x) :
Tendsto (fun n ↦ f^[n] x) atTop (𝓝 <| fixedPoint f hf) := by
convert tendsto_iterate_efixedPoint hf (edist_ne_top x _)
refine (fixedPoint_unique _ ?_).symm
apply efixedPoint_isFixedPt
theorem fixedPoint_lipschitz_in_map {g : α → α} (hg : ContractingWith K g) {C}
(hfg : ∀ z, dist (f z) (g z) ≤ C) : dist (fixedPoint f hf) (fixedPoint g hg) ≤ C / (1 - K) :=
hf.dist_fixedPoint_fixedPoint_of_dist_le' g hf.fixedPoint_isFixedPt hg.fixedPoint_isFixedPt hfg
/-- If a map `f` has a contracting iterate `f^[n]`, then the fixed point of `f^[n]` is also a fixed
point of `f`. -/
theorem isFixedPt_fixedPoint_iterate {n : ℕ} (hf : ContractingWith K f^[n]) :
IsFixedPt f (hf.fixedPoint f^[n]) := by
set x := hf.fixedPoint f^[n]
have hx : f^[n] x = x := hf.fixedPoint_isFixedPt
have := hf.toLipschitzWith.dist_le_mul x (f x)
rw [← iterate_succ_apply, iterate_succ_apply', hx] at this
-- Porting note: Originally `contrapose! this`
revert this
contrapose!
intro this
have := dist_pos.2 (Ne.symm this)
simpa only [NNReal.coe_one, one_mul, NNReal.val_eq_coe] using (mul_lt_mul_right this).mpr hf.left
end ContractingWith
|
Topology\MetricSpace\Dilation.lean | /-
Copyright (c) 2022 Hanting Zhang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Hanting Zhang
-/
import Mathlib.Topology.MetricSpace.Antilipschitz
import Mathlib.Topology.MetricSpace.Isometry
import Mathlib.Topology.MetricSpace.Lipschitz
import Mathlib.Data.FunLike.Basic
/-!
# Dilations
We define dilations, i.e., maps between emetric spaces that satisfy
`edist (f x) (f y) = r * edist x y` for some `r ∉ {0, ∞}`.
The value `r = 0` is not allowed because we want dilations of (e)metric spaces to be automatically
injective. The value `r = ∞` is not allowed because this way we can define `Dilation.ratio f : ℝ≥0`,
not `Dilation.ratio f : ℝ≥0∞`. Also, we do not often need maps sending distinct points to points at
infinite distance.
## Main definitions
* `Dilation.ratio f : ℝ≥0`: the value of `r` in the relation above, defaulting to 1 in the case
where it is not well-defined.
## Notation
- `α →ᵈ β`: notation for `Dilation α β`.
## Implementation notes
The type of dilations defined in this file are also referred to as "similarities" or "similitudes"
by other authors. The name `Dilation` was chosen to match the Wikipedia name.
Since a lot of elementary properties don't require `eq_of_dist_eq_zero` we start setting up the
theory for `PseudoEMetricSpace` and we specialize to `PseudoMetricSpace` and `MetricSpace` when
needed.
## TODO
- Introduce dilation equivs.
- Refactor the `Isometry` API to match the `*HomClass` API below.
## References
- https://en.wikipedia.org/wiki/Dilation_(metric_space)
- [Marcel Berger, *Geometry*][berger1987]
-/
noncomputable section
open Function Set Bornology
open scoped Topology ENNReal NNReal Classical
section Defs
variable (α : Type*) (β : Type*) [PseudoEMetricSpace α] [PseudoEMetricSpace β]
/-- A dilation is a map that uniformly scales the edistance between any two points. -/
structure Dilation where
toFun : α → β
edist_eq' : ∃ r : ℝ≥0, r ≠ 0 ∧ ∀ x y : α, edist (toFun x) (toFun y) = r * edist x y
infixl:25 " →ᵈ " => Dilation
/-- `DilationClass F α β r` states that `F` is a type of `r`-dilations.
You should extend this typeclass when you extend `Dilation`. -/
class DilationClass (F α β : Type*) [PseudoEMetricSpace α] [PseudoEMetricSpace β]
[FunLike F α β] : Prop where
edist_eq' : ∀ f : F, ∃ r : ℝ≥0, r ≠ 0 ∧ ∀ x y : α, edist (f x) (f y) = r * edist x y
end Defs
namespace Dilation
variable {α : Type*} {β : Type*} {γ : Type*} {F : Type*} {G : Type*}
section Setup
variable [PseudoEMetricSpace α] [PseudoEMetricSpace β]
instance funLike : FunLike (α →ᵈ β) α β where
coe := toFun
coe_injective' f g h := by cases f; cases g; congr
instance toDilationClass : DilationClass (α →ᵈ β) α β where
edist_eq' f := edist_eq' f
instance : CoeFun (α →ᵈ β) fun _ => α → β :=
DFunLike.hasCoeToFun
@[simp]
theorem toFun_eq_coe {f : α →ᵈ β} : f.toFun = (f : α → β) :=
rfl
@[simp]
theorem coe_mk (f : α → β) (h) : ⇑(⟨f, h⟩ : α →ᵈ β) = f :=
rfl
protected theorem congr_fun {f g : α →ᵈ β} (h : f = g) (x : α) : f x = g x :=
DFunLike.congr_fun h x
protected theorem congr_arg (f : α →ᵈ β) {x y : α} (h : x = y) : f x = f y :=
DFunLike.congr_arg f h
@[ext]
theorem ext {f g : α →ᵈ β} (h : ∀ x, f x = g x) : f = g :=
DFunLike.ext f g h
@[simp]
theorem mk_coe (f : α →ᵈ β) (h) : Dilation.mk f h = f :=
ext fun _ => rfl
/-- Copy of a `Dilation` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
@[simps (config := .asFn)]
protected def copy (f : α →ᵈ β) (f' : α → β) (h : f' = ⇑f) : α →ᵈ β where
toFun := f'
edist_eq' := h.symm ▸ f.edist_eq'
theorem copy_eq_self (f : α →ᵈ β) {f' : α → β} (h : f' = f) : f.copy f' h = f :=
DFunLike.ext' h
variable [FunLike F α β]
/-- The ratio of a dilation `f`. If the ratio is undefined (i.e., the distance between any two
points in `α` is either zero or infinity), then we choose one as the ratio. -/
def ratio [DilationClass F α β] (f : F) : ℝ≥0 :=
if ∀ x y : α, edist x y = 0 ∨ edist x y = ⊤ then 1 else (DilationClass.edist_eq' f).choose
theorem ratio_of_trivial [DilationClass F α β] (f : F)
(h : ∀ x y : α, edist x y = 0 ∨ edist x y = ∞) : ratio f = 1 :=
if_pos h
@[nontriviality]
theorem ratio_of_subsingleton [Subsingleton α] [DilationClass F α β] (f : F) : ratio f = 1 :=
if_pos fun x y ↦ by simp [Subsingleton.elim x y]
theorem ratio_ne_zero [DilationClass F α β] (f : F) : ratio f ≠ 0 := by
rw [ratio]; split_ifs
· exact one_ne_zero
exact (DilationClass.edist_eq' f).choose_spec.1
theorem ratio_pos [DilationClass F α β] (f : F) : 0 < ratio f :=
(ratio_ne_zero f).bot_lt
@[simp]
theorem edist_eq [DilationClass F α β] (f : F) (x y : α) :
edist (f x) (f y) = ratio f * edist x y := by
rw [ratio]; split_ifs with key
· rcases DilationClass.edist_eq' f with ⟨r, hne, hr⟩
replace hr := hr x y
cases' key x y with h h
· simp only [hr, h, mul_zero]
· simp [hr, h, hne]
exact (DilationClass.edist_eq' f).choose_spec.2 x y
@[simp]
theorem nndist_eq {α β F : Type*} [PseudoMetricSpace α] [PseudoMetricSpace β] [FunLike F α β]
[DilationClass F α β] (f : F) (x y : α) :
nndist (f x) (f y) = ratio f * nndist x y := by
simp only [← ENNReal.coe_inj, ← edist_nndist, ENNReal.coe_mul, edist_eq]
@[simp]
theorem dist_eq {α β F : Type*} [PseudoMetricSpace α] [PseudoMetricSpace β] [FunLike F α β]
[DilationClass F α β] (f : F) (x y : α) :
dist (f x) (f y) = ratio f * dist x y := by
simp only [dist_nndist, nndist_eq, NNReal.coe_mul]
/-- The `ratio` is equal to the distance ratio for any two points with nonzero finite distance.
`dist` and `nndist` versions below -/
theorem ratio_unique [DilationClass F α β] {f : F} {x y : α} {r : ℝ≥0} (h₀ : edist x y ≠ 0)
(htop : edist x y ≠ ⊤) (hr : edist (f x) (f y) = r * edist x y) : r = ratio f := by
simpa only [hr, ENNReal.mul_eq_mul_right h₀ htop, ENNReal.coe_inj] using edist_eq f x y
/-- The `ratio` is equal to the distance ratio for any two points
with nonzero finite distance; `nndist` version -/
theorem ratio_unique_of_nndist_ne_zero {α β F : Type*} [PseudoMetricSpace α] [PseudoMetricSpace β]
[FunLike F α β] [DilationClass F α β] {f : F} {x y : α} {r : ℝ≥0} (hxy : nndist x y ≠ 0)
(hr : nndist (f x) (f y) = r * nndist x y) : r = ratio f :=
ratio_unique (by rwa [edist_nndist, ENNReal.coe_ne_zero]) (edist_ne_top x y)
(by rw [edist_nndist, edist_nndist, hr, ENNReal.coe_mul])
/-- The `ratio` is equal to the distance ratio for any two points
with nonzero finite distance; `dist` version -/
theorem ratio_unique_of_dist_ne_zero {α β} {F : Type*} [PseudoMetricSpace α] [PseudoMetricSpace β]
[FunLike F α β] [DilationClass F α β] {f : F} {x y : α} {r : ℝ≥0} (hxy : dist x y ≠ 0)
(hr : dist (f x) (f y) = r * dist x y) : r = ratio f :=
ratio_unique_of_nndist_ne_zero (NNReal.coe_ne_zero.1 hxy) <|
NNReal.eq <| by rw [coe_nndist, hr, NNReal.coe_mul, coe_nndist]
/-- Alternative `Dilation` constructor when the distance hypothesis is over `nndist` -/
def mkOfNNDistEq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α → β)
(h : ∃ r : ℝ≥0, r ≠ 0 ∧ ∀ x y : α, nndist (f x) (f y) = r * nndist x y) : α →ᵈ β where
toFun := f
edist_eq' := by
rcases h with ⟨r, hne, h⟩
refine ⟨r, hne, fun x y => ?_⟩
rw [edist_nndist, edist_nndist, ← ENNReal.coe_mul, h x y]
@[simp]
theorem coe_mkOfNNDistEq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α → β) (h) :
⇑(mkOfNNDistEq f h : α →ᵈ β) = f :=
rfl
@[simp]
theorem mk_coe_of_nndist_eq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α →ᵈ β)
(h) : Dilation.mkOfNNDistEq f h = f :=
ext fun _ => rfl
/-- Alternative `Dilation` constructor when the distance hypothesis is over `dist` -/
def mkOfDistEq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α → β)
(h : ∃ r : ℝ≥0, r ≠ 0 ∧ ∀ x y : α, dist (f x) (f y) = r * dist x y) : α →ᵈ β :=
mkOfNNDistEq f <|
h.imp fun r hr =>
⟨hr.1, fun x y => NNReal.eq <| by rw [coe_nndist, hr.2, NNReal.coe_mul, coe_nndist]⟩
@[simp]
theorem coe_mkOfDistEq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α → β) (h) :
⇑(mkOfDistEq f h : α →ᵈ β) = f :=
rfl
@[simp]
theorem mk_coe_of_dist_eq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α →ᵈ β) (h) :
Dilation.mkOfDistEq f h = f :=
ext fun _ => rfl
end Setup
section PseudoEmetricDilation
variable [PseudoEMetricSpace α] [PseudoEMetricSpace β] [PseudoEMetricSpace γ]
variable [FunLike F α β] [DilationClass F α β] [FunLike G β γ] [DilationClass G β γ]
variable (f : F) (g : G) {x y z : α} {s : Set α}
/-- Every isometry is a dilation of ratio `1`. -/
@[simps]
def _root_.Isometry.toDilation (f : α → β) (hf : Isometry f) : α →ᵈ β where
toFun := f
edist_eq' := ⟨1, one_ne_zero, by simpa using hf⟩
@[simp]
lemma _root_.Isometry.toDilation_ratio {f : α → β} {hf : Isometry f} : ratio hf.toDilation = 1 := by
by_cases h : ∀ x y : α, edist x y = 0 ∨ edist x y = ⊤
· exact ratio_of_trivial hf.toDilation h
· push_neg at h
obtain ⟨x, y, h₁, h₂⟩ := h
exact ratio_unique h₁ h₂ (by simp [hf x y]) |>.symm
theorem lipschitz : LipschitzWith (ratio f) (f : α → β) := fun x y => (edist_eq f x y).le
theorem antilipschitz : AntilipschitzWith (ratio f)⁻¹ (f : α → β) := fun x y => by
have hr : ratio f ≠ 0 := ratio_ne_zero f
exact mod_cast
(ENNReal.mul_le_iff_le_inv (ENNReal.coe_ne_zero.2 hr) ENNReal.coe_ne_top).1 (edist_eq f x y).ge
/-- A dilation from an emetric space is injective -/
protected theorem injective {α : Type*} [EMetricSpace α] [FunLike F α β] [DilationClass F α β]
(f : F) :
Injective f :=
(antilipschitz f).injective
/-- The identity is a dilation -/
protected def id (α) [PseudoEMetricSpace α] : α →ᵈ α where
toFun := id
edist_eq' := ⟨1, one_ne_zero, fun x y => by simp only [id, ENNReal.coe_one, one_mul]⟩
instance : Inhabited (α →ᵈ α) :=
⟨Dilation.id α⟩
@[simp] -- Porting note: Removed `@[protected]`
theorem coe_id : ⇑(Dilation.id α) = id :=
rfl
theorem ratio_id : ratio (Dilation.id α) = 1 := by
by_cases h : ∀ x y : α, edist x y = 0 ∨ edist x y = ∞
· rw [ratio, if_pos h]
· push_neg at h
rcases h with ⟨x, y, hne⟩
refine (ratio_unique hne.1 hne.2 ?_).symm
simp
/-- The composition of dilations is a dilation -/
def comp (g : β →ᵈ γ) (f : α →ᵈ β) : α →ᵈ γ where
toFun := g ∘ f
edist_eq' := ⟨ratio g * ratio f, mul_ne_zero (ratio_ne_zero g) (ratio_ne_zero f),
fun x y => by simp_rw [Function.comp, edist_eq, ENNReal.coe_mul, mul_assoc]⟩
theorem comp_assoc {δ : Type*} [PseudoEMetricSpace δ] (f : α →ᵈ β) (g : β →ᵈ γ)
(h : γ →ᵈ δ) : (h.comp g).comp f = h.comp (g.comp f) :=
rfl
@[simp]
theorem coe_comp (g : β →ᵈ γ) (f : α →ᵈ β) : (g.comp f : α → γ) = g ∘ f :=
rfl
theorem comp_apply (g : β →ᵈ γ) (f : α →ᵈ β) (x : α) : (g.comp f : α → γ) x = g (f x) :=
rfl
-- Porting note: removed `simp` because it's difficult to auto prove `hne`
/-- Ratio of the composition `g.comp f` of two dilations is the product of their ratios. We assume
that there exist two points in `α` at extended distance neither `0` nor `∞` because otherwise
`Dilation.ratio (g.comp f) = Dilation.ratio f = 1` while `Dilation.ratio g` can be any number. This
version works for most general spaces, see also `Dilation.ratio_comp` for a version assuming that
`α` is a nontrivial metric space. -/
theorem ratio_comp' {g : β →ᵈ γ} {f : α →ᵈ β}
(hne : ∃ x y : α, edist x y ≠ 0 ∧ edist x y ≠ ⊤) : ratio (g.comp f) = ratio g * ratio f := by
rcases hne with ⟨x, y, hα⟩
have hgf := (edist_eq (g.comp f) x y).symm
simp_rw [coe_comp, Function.comp, edist_eq, ← mul_assoc, ENNReal.mul_eq_mul_right hα.1 hα.2]
at hgf
rwa [← ENNReal.coe_inj, ENNReal.coe_mul]
@[simp]
theorem comp_id (f : α →ᵈ β) : f.comp (Dilation.id α) = f :=
ext fun _ => rfl
@[simp]
theorem id_comp (f : α →ᵈ β) : (Dilation.id β).comp f = f :=
ext fun _ => rfl
instance : Monoid (α →ᵈ α) where
one := Dilation.id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
theorem one_def : (1 : α →ᵈ α) = Dilation.id α :=
rfl
theorem mul_def (f g : α →ᵈ α) : f * g = f.comp g :=
rfl
@[simp]
theorem coe_one : ⇑(1 : α →ᵈ α) = id :=
rfl
@[simp]
theorem coe_mul (f g : α →ᵈ α) : ⇑(f * g) = f ∘ g :=
rfl
@[simp] theorem ratio_one : ratio (1 : α →ᵈ α) = 1 := ratio_id
@[simp]
theorem ratio_mul (f g : α →ᵈ α) : ratio (f * g) = ratio f * ratio g := by
by_cases h : ∀ x y : α, edist x y = 0 ∨ edist x y = ∞
· simp [ratio_of_trivial, h]
push_neg at h
exact ratio_comp' h
/-- `Dilation.ratio` as a monoid homomorphism from `α →ᵈ α` to `ℝ≥0`. -/
@[simps]
def ratioHom : (α →ᵈ α) →* ℝ≥0 := ⟨⟨ratio, ratio_one⟩, ratio_mul⟩
@[simp]
theorem ratio_pow (f : α →ᵈ α) (n : ℕ) : ratio (f ^ n) = ratio f ^ n :=
ratioHom.map_pow _ _
@[simp]
theorem cancel_right {g₁ g₂ : β →ᵈ γ} {f : α →ᵈ β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => Dilation.ext <| hf.forall.2 (Dilation.ext_iff.1 h), fun h => h ▸ rfl⟩
@[simp]
theorem cancel_left {g : β →ᵈ γ} {f₁ f₂ : α →ᵈ β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => Dilation.ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩
/-- A dilation from a metric space is a uniform inducing map -/
protected theorem uniformInducing : UniformInducing (f : α → β) :=
(antilipschitz f).uniformInducing (lipschitz f).uniformContinuous
theorem tendsto_nhds_iff {ι : Type*} {g : ι → α} {a : Filter ι} {b : α} :
Filter.Tendsto g a (𝓝 b) ↔ Filter.Tendsto ((f : α → β) ∘ g) a (𝓝 (f b)) :=
(Dilation.uniformInducing f).inducing.tendsto_nhds_iff
/-- A dilation is continuous. -/
theorem toContinuous : Continuous (f : α → β) :=
(lipschitz f).continuous
/-- Dilations scale the diameter by `ratio f` in pseudoemetric spaces. -/
theorem ediam_image (s : Set α) : EMetric.diam ((f : α → β) '' s) = ratio f * EMetric.diam s := by
refine ((lipschitz f).ediam_image_le s).antisymm ?_
apply ENNReal.mul_le_of_le_div'
rw [div_eq_mul_inv, mul_comm, ← ENNReal.coe_inv]
exacts [(antilipschitz f).le_mul_ediam_image s, ratio_ne_zero f]
/-- A dilation scales the diameter of the range by `ratio f`. -/
theorem ediam_range : EMetric.diam (range (f : α → β)) = ratio f * EMetric.diam (univ : Set α) := by
rw [← image_univ]; exact ediam_image f univ
/-- A dilation maps balls to balls and scales the radius by `ratio f`. -/
theorem mapsTo_emetric_ball (x : α) (r : ℝ≥0∞) :
MapsTo (f : α → β) (EMetric.ball x r) (EMetric.ball (f x) (ratio f * r)) :=
fun y hy => (edist_eq f y x).trans_lt <|
(ENNReal.mul_lt_mul_left (ENNReal.coe_ne_zero.2 <| ratio_ne_zero f) ENNReal.coe_ne_top).2 hy
/-- A dilation maps closed balls to closed balls and scales the radius by `ratio f`. -/
theorem mapsTo_emetric_closedBall (x : α) (r' : ℝ≥0∞) :
MapsTo (f : α → β) (EMetric.closedBall x r') (EMetric.closedBall (f x) (ratio f * r')) :=
-- Porting note: Added `by exact`
fun y hy => (edist_eq f y x).trans_le <| mul_le_mul_left' (by exact hy) _
theorem comp_continuousOn_iff {γ} [TopologicalSpace γ] {g : γ → α} {s : Set γ} :
ContinuousOn ((f : α → β) ∘ g) s ↔ ContinuousOn g s :=
(Dilation.uniformInducing f).inducing.continuousOn_iff.symm
theorem comp_continuous_iff {γ} [TopologicalSpace γ] {g : γ → α} :
Continuous ((f : α → β) ∘ g) ↔ Continuous g :=
(Dilation.uniformInducing f).inducing.continuous_iff.symm
end PseudoEmetricDilation
section EmetricDilation
variable [EMetricSpace α]
variable [FunLike F α β]
/-- A dilation from a metric space is a uniform embedding -/
protected theorem uniformEmbedding [PseudoEMetricSpace β] [DilationClass F α β] (f : F) :
UniformEmbedding f :=
(antilipschitz f).uniformEmbedding (lipschitz f).uniformContinuous
/-- A dilation from a metric space is an embedding -/
protected theorem embedding [PseudoEMetricSpace β] [DilationClass F α β] (f : F) :
Embedding (f : α → β) :=
(Dilation.uniformEmbedding f).embedding
/-- A dilation from a complete emetric space is a closed embedding -/
protected theorem closedEmbedding [CompleteSpace α] [EMetricSpace β] [DilationClass F α β] (f : F) :
ClosedEmbedding f :=
(antilipschitz f).closedEmbedding (lipschitz f).uniformContinuous
end EmetricDilation
/-- Ratio of the composition `g.comp f` of two dilations is the product of their ratios. We assume
that the domain `α` of `f` is a nontrivial metric space, otherwise
`Dilation.ratio f = Dilation.ratio (g.comp f) = 1` but `Dilation.ratio g` may have any value.
See also `Dilation.ratio_comp'` for a version that works for more general spaces. -/
@[simp]
theorem ratio_comp [MetricSpace α] [Nontrivial α] [PseudoEMetricSpace β]
[PseudoEMetricSpace γ] {g : β →ᵈ γ} {f : α →ᵈ β} : ratio (g.comp f) = ratio g * ratio f :=
ratio_comp' <|
let ⟨x, y, hne⟩ := exists_pair_ne α; ⟨x, y, mt edist_eq_zero.1 hne, edist_ne_top _ _⟩
section PseudoMetricDilation
variable [PseudoMetricSpace α] [PseudoMetricSpace β] [FunLike F α β] [DilationClass F α β] (f : F)
/-- A dilation scales the diameter by `ratio f` in pseudometric spaces. -/
theorem diam_image (s : Set α) : Metric.diam ((f : α → β) '' s) = ratio f * Metric.diam s := by
simp [Metric.diam, ediam_image, ENNReal.toReal_mul]
theorem diam_range : Metric.diam (range (f : α → β)) = ratio f * Metric.diam (univ : Set α) := by
rw [← image_univ, diam_image]
/-- A dilation maps balls to balls and scales the radius by `ratio f`. -/
theorem mapsTo_ball (x : α) (r' : ℝ) :
MapsTo (f : α → β) (Metric.ball x r') (Metric.ball (f x) (ratio f * r')) :=
fun y hy => (dist_eq f y x).trans_lt <| (mul_lt_mul_left <| NNReal.coe_pos.2 <| ratio_pos f).2 hy
/-- A dilation maps spheres to spheres and scales the radius by `ratio f`. -/
theorem mapsTo_sphere (x : α) (r' : ℝ) :
MapsTo (f : α → β) (Metric.sphere x r') (Metric.sphere (f x) (ratio f * r')) :=
fun y hy => Metric.mem_sphere.mp hy ▸ dist_eq f y x
/-- A dilation maps closed balls to closed balls and scales the radius by `ratio f`. -/
theorem mapsTo_closedBall (x : α) (r' : ℝ) :
MapsTo (f : α → β) (Metric.closedBall x r') (Metric.closedBall (f x) (ratio f * r')) :=
fun y hy => (dist_eq f y x).trans_le <| mul_le_mul_of_nonneg_left hy (NNReal.coe_nonneg _)
lemma tendsto_cobounded : Filter.Tendsto f (cobounded α) (cobounded β) :=
(Dilation.antilipschitz f).tendsto_cobounded
@[simp]
lemma comap_cobounded : Filter.comap f (cobounded β) = cobounded α :=
le_antisymm (lipschitz f).comap_cobounded_le (tendsto_cobounded f).le_comap
end PseudoMetricDilation
end Dilation
|
Topology\MetricSpace\DilationEquiv.lean | /-
Copyright (c) 2023 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Topology.MetricSpace.Dilation
/-!
# Dilation equivalence
In this file we define `DilationEquiv X Y`, a type of bundled equivalences between `X` and Y` such
that `edist (f x) (f y) = r * edist x y` for some `r : ℝ≥0`, `r ≠ 0`.
We also develop basic API about these equivalences.
## TODO
- Add missing lemmas (compare to other `*Equiv` structures).
- [after-port] Add `DilationEquivInstance` for `IsometryEquiv`.
-/
open scoped NNReal ENNReal
open Function Set Filter Bornology
open Dilation (ratio ratio_ne_zero ratio_pos edist_eq)
section Class
variable (F : Type*) (X Y : outParam Type*) [PseudoEMetricSpace X] [PseudoEMetricSpace Y]
/-- Typeclass saying that `F` is a type of bundled equivalences such that all `e : F` are
dilations. -/
class DilationEquivClass [EquivLike F X Y] : Prop where
edist_eq' : ∀ f : F, ∃ r : ℝ≥0, r ≠ 0 ∧ ∀ x y : X, edist (f x) (f y) = r * edist x y
instance (priority := 100) [EquivLike F X Y] [DilationEquivClass F X Y] : DilationClass F X Y :=
{ inferInstanceAs (FunLike F X Y), ‹DilationEquivClass F X Y› with }
end Class
/-- Type of equivalences `X ≃ Y` such that `∀ x y, edist (f x) (f y) = r * edist x y` for some
`r : ℝ≥0`, `r ≠ 0`. -/
structure DilationEquiv (X Y : Type*) [PseudoEMetricSpace X] [PseudoEMetricSpace Y]
extends X ≃ Y, Dilation X Y
infixl:25 " ≃ᵈ " => DilationEquiv
namespace DilationEquiv
section PseudoEMetricSpace
variable {X Y Z : Type*} [PseudoEMetricSpace X] [PseudoEMetricSpace Y] [PseudoEMetricSpace Z]
instance : EquivLike (X ≃ᵈ Y) X Y where
coe f := f.1
inv f := f.1.symm
left_inv f := f.left_inv'
right_inv f := f.right_inv'
coe_injective' := by rintro ⟨⟩ ⟨⟩ h -; congr; exact DFunLike.ext' h
instance : DilationEquivClass (X ≃ᵈ Y) X Y where
edist_eq' f := f.edist_eq'
instance : CoeFun (X ≃ᵈ Y) fun _ ↦ (X → Y) where
coe f := f
@[simp] theorem coe_toEquiv (e : X ≃ᵈ Y) : ⇑e.toEquiv = e := rfl
@[ext]
protected theorem ext {e e' : X ≃ᵈ Y} (h : ∀ x, e x = e' x) : e = e' :=
DFunLike.ext _ _ h
/-- Inverse `DilationEquiv`. -/
def symm (e : X ≃ᵈ Y) : Y ≃ᵈ X where
toEquiv := e.1.symm
edist_eq' := by
refine ⟨(ratio e)⁻¹, inv_ne_zero <| ratio_ne_zero e, e.surjective.forall₂.2 fun x y ↦ ?_⟩
simp_rw [Equiv.toFun_as_coe, Equiv.symm_apply_apply, coe_toEquiv, edist_eq]
rw [← mul_assoc, ← ENNReal.coe_mul, inv_mul_cancel (ratio_ne_zero e),
ENNReal.coe_one, one_mul]
@[simp] theorem symm_symm (e : X ≃ᵈ Y) : e.symm.symm = e := rfl
theorem symm_bijective : Function.Bijective (DilationEquiv.symm : (X ≃ᵈ Y) → Y ≃ᵈ X) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
@[simp] theorem apply_symm_apply (e : X ≃ᵈ Y) (x : Y) : e (e.symm x) = x := e.right_inv x
@[simp] theorem symm_apply_apply (e : X ≃ᵈ Y) (x : X) : e.symm (e x) = x := e.left_inv x
/-- See Note [custom simps projection]. -/
def Simps.symm_apply (e : X ≃ᵈ Y) : Y → X := e.symm
initialize_simps_projections DilationEquiv (toFun → apply, invFun → symm_apply)
lemma ratio_toDilation (e : X ≃ᵈ Y) : ratio e.toDilation = ratio e := rfl
/-- Identity map as a `DilationEquiv`. -/
@[simps! (config := .asFn) apply]
def refl (X : Type*) [PseudoEMetricSpace X] : X ≃ᵈ X where
toEquiv := .refl X
edist_eq' := ⟨1, one_ne_zero, fun _ _ ↦ by simp⟩
@[simp] theorem refl_symm : (refl X).symm = refl X := rfl
@[simp] theorem ratio_refl : ratio (refl X) = 1 := Dilation.ratio_id
/-- Composition of `DilationEquiv`s. -/
@[simps! (config := .asFn) apply]
def trans (e₁ : X ≃ᵈ Y) (e₂ : Y ≃ᵈ Z) : X ≃ᵈ Z where
toEquiv := e₁.1.trans e₂.1
__ := e₂.toDilation.comp e₁.toDilation
@[simp] theorem refl_trans (e : X ≃ᵈ Y) : (refl X).trans e = e := rfl
@[simp] theorem trans_refl (e : X ≃ᵈ Y) : e.trans (refl Y) = e := rfl
@[simp] theorem symm_trans_self (e : X ≃ᵈ Y) : e.symm.trans e = refl Y :=
DilationEquiv.ext e.apply_symm_apply
@[simp] theorem self_trans_symm (e : X ≃ᵈ Y) : e.trans e.symm = refl X :=
DilationEquiv.ext e.symm_apply_apply
protected theorem surjective (e : X ≃ᵈ Y) : Surjective e := e.1.surjective
protected theorem bijective (e : X ≃ᵈ Y) : Bijective e := e.1.bijective
protected theorem injective (e : X ≃ᵈ Y) : Injective e := e.1.injective
@[simp]
theorem ratio_trans (e : X ≃ᵈ Y) (e' : Y ≃ᵈ Z) : ratio (e.trans e') = ratio e * ratio e' := by
-- If `X` is trivial, then so is `Y`, otherwise we apply `Dilation.ratio_comp'`
by_cases hX : ∀ x y : X, edist x y = 0 ∨ edist x y = ∞
· have hY : ∀ x y : Y, edist x y = 0 ∨ edist x y = ∞ := e.surjective.forall₂.2 fun x y ↦ by
refine (hX x y).imp (fun h ↦ ?_) fun h ↦ ?_ <;> simp [*, Dilation.ratio_ne_zero]
simp [Dilation.ratio_of_trivial, *]
push_neg at hX
exact (Dilation.ratio_comp' (g := e'.toDilation) (f := e.toDilation) hX).trans (mul_comm _ _)
@[simp]
theorem ratio_symm (e : X ≃ᵈ Y) : ratio e.symm = (ratio e)⁻¹ :=
eq_inv_of_mul_eq_one_left <| by rw [← ratio_trans, symm_trans_self, ratio_refl]
instance : Group (X ≃ᵈ X) where
mul e e' := e'.trans e
mul_assoc _ _ _ := rfl
one := refl _
one_mul _ := rfl
mul_one _ := rfl
inv := symm
mul_left_inv := self_trans_symm
theorem mul_def (e e' : X ≃ᵈ X) : e * e' = e'.trans e := rfl
theorem one_def : (1 : X ≃ᵈ X) = refl X := rfl
theorem inv_def (e : X ≃ᵈ X) : e⁻¹ = e.symm := rfl
@[simp] theorem coe_mul (e e' : X ≃ᵈ X) : ⇑(e * e') = e ∘ e' := rfl
@[simp] theorem coe_one : ⇑(1 : X ≃ᵈ X) = id := rfl
theorem coe_inv (e : X ≃ᵈ X) : ⇑(e⁻¹) = e.symm := rfl
/-- `Dilation.ratio` as a monoid homomorphism. -/
noncomputable def ratioHom : (X ≃ᵈ X) →* ℝ≥0 where
toFun := Dilation.ratio
map_one' := ratio_refl
map_mul' _ _ := (ratio_trans _ _).trans (mul_comm _ _)
@[simp]
theorem ratio_inv (e : X ≃ᵈ X) : ratio (e⁻¹) = (ratio e)⁻¹ := ratio_symm e
@[simp]
theorem ratio_pow (e : X ≃ᵈ X) (n : ℕ) : ratio (e ^ n) = ratio e ^ n :=
ratioHom.map_pow _ _
@[simp]
theorem ratio_zpow (e : X ≃ᵈ X) (n : ℤ) : ratio (e ^ n) = ratio e ^ n :=
ratioHom.map_zpow _ _
/-- `DilationEquiv.toEquiv` as a monoid homomorphism. -/
@[simps]
def toPerm : (X ≃ᵈ X) →* Equiv.Perm X where
toFun e := e.1
map_mul' _ _ := rfl
map_one' := rfl
@[norm_cast]
theorem coe_pow (e : X ≃ᵈ X) (n : ℕ) : ⇑(e ^ n) = e^[n] := by
rw [← coe_toEquiv, ← toPerm_apply, map_pow, Equiv.Perm.coe_pow]; rfl
-- TODO: Once `IsometryEquiv` follows the `*EquivClass` pattern, replace this with an instance
-- of `DilationEquivClass` assuming `IsometryEquivClass`.
/-- Every isometry equivalence is a dilation equivalence of ratio `1`. -/
def _root_.IsometryEquiv.toDilationEquiv (e : X ≃ᵢ Y) : X ≃ᵈ Y where
edist_eq' := ⟨1, one_ne_zero, by simpa using e.isometry⟩
__ := e.toEquiv
@[simp]
lemma _root_.IsometryEquiv.toDilationEquiv_apply (e : X ≃ᵢ Y) (x : X) :
e.toDilationEquiv x = e x :=
rfl
@[simp]
lemma _root_.IsometryEquiv.toDilationEquiv_symm (e : X ≃ᵢ Y) :
e.toDilationEquiv.symm = e.symm.toDilationEquiv :=
rfl
@[simp]
lemma _root_.IsometryEquiv.toDilationEquiv_toDilation (e : X ≃ᵢ Y) :
(e.toDilationEquiv.toDilation : X →ᵈ Y) = e.isometry.toDilation :=
rfl
@[simp]
lemma _root_.IsometryEquiv.toDilationEquiv_ratio (e : X ≃ᵢ Y) : ratio e.toDilationEquiv = 1 := by
rw [← ratio_toDilation, IsometryEquiv.toDilationEquiv_toDilation, Isometry.toDilation_ratio]
/-- Reinterpret a `DilationEquiv` as a homeomorphism. -/
def toHomeomorph (e : X ≃ᵈ Y) : X ≃ₜ Y where
continuous_toFun := Dilation.toContinuous e
continuous_invFun := Dilation.toContinuous e.symm
__ := e.toEquiv
@[simp]
lemma coe_toHomeomorph (e : X ≃ᵈ Y) : ⇑e.toHomeomorph = e :=
rfl
@[simp]
lemma toHomeomorph_symm (e : X ≃ᵈ Y) : e.toHomeomorph.symm = e.symm.toHomeomorph :=
rfl
end PseudoEMetricSpace
section PseudoMetricSpace
variable {X Y F : Type*} [PseudoMetricSpace X] [PseudoMetricSpace Y]
variable [EquivLike F X Y] [DilationEquivClass F X Y]
@[simp]
lemma map_cobounded (e : F) : map e (cobounded X) = cobounded Y := by
rw [← Dilation.comap_cobounded e, map_comap_of_surjective (EquivLike.surjective e)]
end PseudoMetricSpace
end DilationEquiv
|
Topology\MetricSpace\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.MetricSpace.Pseudo.Lemmas
import Mathlib.Topology.UniformSpace.Equicontinuity
/-!
# Equicontinuity in metric spaces
This files contains various facts about (uniform) equicontinuity in metric spaces. Most
importantly, we prove the usual characterization of equicontinuity of `F` at `x₀` in the case of
(pseudo) metric spaces: `∀ ε > 0, ∃ δ > 0, ∀ x, dist x x₀ < δ → ∀ i, dist (F i x₀) (F i x) < ε`,
and we prove that functions sharing a common (local or global) continuity modulus are
(locally or uniformly) equicontinuous.
## Main statements
* `Metric.equicontinuousAt_iff`: characterization of equicontinuity for families of functions
between (pseudo) metric spaces.
* `Metric.equicontinuousAt_of_continuity_modulus`: convenient way to prove equicontinuity at a
point of a family of functions to a (pseudo) metric space by showing that they share a common
*local* continuity modulus.
* `Metric.uniformEquicontinuous_of_continuity_modulus`: convenient way to prove uniform
equicontinuity of a family of functions to a (pseudo) metric space by showing that they share a
common *global* continuity modulus.
## Tags
equicontinuity, continuity modulus
-/
open Filter Topology Uniformity
variable {α β ι : Type*} [PseudoMetricSpace α]
namespace Metric
/-- Characterization of equicontinuity for families of functions taking values in a (pseudo) metric
space. -/
theorem equicontinuousAt_iff_right {ι : Type*} [TopologicalSpace β] {F : ι → β → α} {x₀ : β} :
EquicontinuousAt F x₀ ↔ ∀ ε > 0, ∀ᶠ x in 𝓝 x₀, ∀ i, dist (F i x₀) (F i x) < ε :=
uniformity_basis_dist.equicontinuousAt_iff_right
/-- Characterization of equicontinuity for families of functions between (pseudo) metric spaces. -/
theorem equicontinuousAt_iff {ι : Type*} [PseudoMetricSpace β] {F : ι → β → α} {x₀ : β} :
EquicontinuousAt F x₀ ↔ ∀ ε > 0, ∃ δ > 0, ∀ x, dist x x₀ < δ → ∀ i, dist (F i x₀) (F i x) < ε :=
nhds_basis_ball.equicontinuousAt_iff uniformity_basis_dist
/-- Reformulation of `equicontinuousAt_iff_pair` for families of functions taking values in a
(pseudo) metric space. -/
protected theorem equicontinuousAt_iff_pair {ι : Type*} [TopologicalSpace β] {F : ι → β → α}
{x₀ : β} :
EquicontinuousAt F x₀ ↔
∀ ε > 0, ∃ U ∈ 𝓝 x₀, ∀ x ∈ U, ∀ x' ∈ U, ∀ i, dist (F i x) (F i x') < ε := by
rw [equicontinuousAt_iff_pair]
constructor <;> intro H
· intro ε hε
exact H _ (dist_mem_uniformity hε)
· intro U hU
rcases mem_uniformity_dist.mp hU with ⟨ε, hε, hεU⟩
refine Exists.imp (fun V => And.imp_right fun h => ?_) (H _ hε)
exact fun x hx x' hx' i => hεU (h _ hx _ hx' i)
/-- Characterization of uniform equicontinuity for families of functions taking values in a
(pseudo) metric space. -/
theorem uniformEquicontinuous_iff_right {ι : Type*} [UniformSpace β] {F : ι → β → α} :
UniformEquicontinuous F ↔ ∀ ε > 0, ∀ᶠ xy : β × β in 𝓤 β, ∀ i, dist (F i xy.1) (F i xy.2) < ε :=
uniformity_basis_dist.uniformEquicontinuous_iff_right
/-- Characterization of uniform equicontinuity for families of functions between
(pseudo) metric spaces. -/
theorem uniformEquicontinuous_iff {ι : Type*} [PseudoMetricSpace β] {F : ι → β → α} :
UniformEquicontinuous F ↔
∀ ε > 0, ∃ δ > 0, ∀ x y, dist x y < δ → ∀ i, dist (F i x) (F i y) < ε :=
uniformity_basis_dist.uniformEquicontinuous_iff uniformity_basis_dist
/-- For a family of functions to a (pseudo) metric spaces, a convenient way to prove
equicontinuity at a point is to show that all of the functions share a common *local* continuity
modulus. -/
theorem equicontinuousAt_of_continuity_modulus {ι : Type*} [TopologicalSpace β] {x₀ : β}
(b : β → ℝ) (b_lim : Tendsto b (𝓝 x₀) (𝓝 0)) (F : ι → β → α)
(H : ∀ᶠ x in 𝓝 x₀, ∀ i, dist (F i x₀) (F i x) ≤ b x) : EquicontinuousAt F x₀ := by
rw [Metric.equicontinuousAt_iff_right]
intro ε ε0
-- Porting note: Lean 3 didn't need `Filter.mem_map.mp` here
filter_upwards [Filter.mem_map.mp <| b_lim (Iio_mem_nhds ε0), H] using
fun x hx₁ hx₂ i => (hx₂ i).trans_lt hx₁
/-- For a family of functions between (pseudo) metric spaces, a convenient way to prove
uniform equicontinuity is to show that all of the functions share a common *global* continuity
modulus. -/
theorem uniformEquicontinuous_of_continuity_modulus {ι : Type*} [PseudoMetricSpace β] (b : ℝ → ℝ)
(b_lim : Tendsto b (𝓝 0) (𝓝 0)) (F : ι → β → α)
(H : ∀ (x y : β) (i), dist (F i x) (F i y) ≤ b (dist x y)) : UniformEquicontinuous F := by
rw [Metric.uniformEquicontinuous_iff]
intro ε ε0
rcases tendsto_nhds_nhds.1 b_lim ε ε0 with ⟨δ, δ0, hδ⟩
refine ⟨δ, δ0, fun x y hxy i => ?_⟩
calc
dist (F i x) (F i y) ≤ b (dist x y) := H x y i
_ ≤ |b (dist x y)| := le_abs_self _
_ = dist (b (dist x y)) 0 := by simp [Real.dist_eq]
_ < ε := hδ (by simpa only [Real.dist_eq, tsub_zero, abs_dist] using hxy)
/-- For a family of functions between (pseudo) metric spaces, a convenient way to prove
equicontinuity is to show that all of the functions share a common *global* continuity modulus. -/
theorem equicontinuous_of_continuity_modulus {ι : Type*} [PseudoMetricSpace β] (b : ℝ → ℝ)
(b_lim : Tendsto b (𝓝 0) (𝓝 0)) (F : ι → β → α)
(H : ∀ (x y : β) (i), dist (F i x) (F i y) ≤ b (dist x y)) : Equicontinuous F :=
(uniformEquicontinuous_of_continuity_modulus b b_lim F H).equicontinuous
end Metric
|
Topology\MetricSpace\Gluing.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.MetricSpace.Isometry
/-!
# Metric space gluing
Gluing two metric spaces along a common subset. Formally, we are given
```
Φ
Z ---> X
|
|Ψ
v
Y
```
where `hΦ : Isometry Φ` and `hΨ : Isometry Ψ`.
We want to complete the square by a space `GlueSpacescan hΦ hΨ` and two isometries
`toGlueL hΦ hΨ` and `toGlueR hΦ hΨ` that make the square commute.
We start by defining a predistance on the disjoint union `X ⊕ Y`, for which
points `Φ p` and `Ψ p` are at distance 0. The (quotient) metric space associated
to this predistance is the desired space.
This is an instance of a more general construction, where `Φ` and `Ψ` do not have to be isometries,
but the distances in the image almost coincide, up to `2ε` say. Then one can almost glue the two
spaces so that the images of a point under `Φ` and `Ψ` are `ε`-close. If `ε > 0`, this yields a
metric space structure on `X ⊕ Y`, without the need to take a quotient. In particular,
this gives a natural metric space structure on `X ⊕ Y`, where the basepoints
are at distance 1, say, and the distances between other points are obtained by going through the two
basepoints.
(We also register the same metric space structure on a general disjoint union `Σ i, E i`).
We also define the inductive limit of metric spaces. Given
```
f 0 f 1 f 2 f 3
X 0 -----> X 1 -----> X 2 -----> X 3 -----> ...
```
where the `X n` are metric spaces and `f n` isometric embeddings, we define the inductive
limit of the `X n`, also known as the increasing union of the `X n` in this context, if we
identify `X n` and `X (n+1)` through `f n`. This is a metric space in which all `X n` embed
isometrically and in a way compatible with `f n`.
-/
noncomputable section
universe u v w
open Function Set Uniformity Topology
namespace Metric
section ApproxGluing
variable {X : Type u} {Y : Type v} {Z : Type w}
variable [MetricSpace X] [MetricSpace Y] {Φ : Z → X} {Ψ : Z → Y} {ε : ℝ}
/-- Define a predistance on `X ⊕ Y`, for which `Φ p` and `Ψ p` are at distance `ε` -/
def glueDist (Φ : Z → X) (Ψ : Z → Y) (ε : ℝ) : X ⊕ Y → X ⊕ Y → ℝ
| .inl x, .inl y => dist x y
| .inr x, .inr y => dist x y
| .inl x, .inr y => (⨅ p, dist x (Φ p) + dist y (Ψ p)) + ε
| .inr x, .inl y => (⨅ p, dist y (Φ p) + dist x (Ψ p)) + ε
private theorem glueDist_self (Φ : Z → X) (Ψ : Z → Y) (ε : ℝ) : ∀ x, glueDist Φ Ψ ε x x = 0
| .inl _ => dist_self _
| .inr _ => dist_self _
theorem glueDist_glued_points [Nonempty Z] (Φ : Z → X) (Ψ : Z → Y) (ε : ℝ) (p : Z) :
glueDist Φ Ψ ε (.inl (Φ p)) (.inr (Ψ p)) = ε := by
have : ⨅ q, dist (Φ p) (Φ q) + dist (Ψ p) (Ψ q) = 0 := by
have A : ∀ q, 0 ≤ dist (Φ p) (Φ q) + dist (Ψ p) (Ψ q) := fun _ =>
add_nonneg dist_nonneg dist_nonneg
refine le_antisymm ?_ (le_ciInf A)
have : 0 = dist (Φ p) (Φ p) + dist (Ψ p) (Ψ p) := by simp
rw [this]
exact ciInf_le ⟨0, forall_mem_range.2 A⟩ p
simp only [glueDist, this, zero_add]
private theorem glueDist_comm (Φ : Z → X) (Ψ : Z → Y) (ε : ℝ) :
∀ x y, glueDist Φ Ψ ε x y = glueDist Φ Ψ ε y x
| .inl _, .inl _ => dist_comm _ _
| .inr _, .inr _ => dist_comm _ _
| .inl _, .inr _ => rfl
| .inr _, .inl _ => rfl
theorem glueDist_swap (Φ : Z → X) (Ψ : Z → Y) (ε : ℝ) :
∀ x y, glueDist Ψ Φ ε x.swap y.swap = glueDist Φ Ψ ε x y
| .inl _, .inl _ => rfl
| .inr _, .inr _ => rfl
| .inl _, .inr _ => by simp only [glueDist, Sum.swap_inl, Sum.swap_inr, dist_comm, add_comm]
| .inr _, .inl _ => by simp only [glueDist, Sum.swap_inl, Sum.swap_inr, dist_comm, add_comm]
theorem le_glueDist_inl_inr (Φ : Z → X) (Ψ : Z → Y) (ε : ℝ) (x y) :
ε ≤ glueDist Φ Ψ ε (.inl x) (.inr y) :=
le_add_of_nonneg_left <| Real.iInf_nonneg fun _ => add_nonneg dist_nonneg dist_nonneg
theorem le_glueDist_inr_inl (Φ : Z → X) (Ψ : Z → Y) (ε : ℝ) (x y) :
ε ≤ glueDist Φ Ψ ε (.inr x) (.inl y) := by
rw [glueDist_comm]; apply le_glueDist_inl_inr
section
variable [Nonempty Z]
private theorem glueDist_triangle_inl_inr_inr (Φ : Z → X) (Ψ : Z → Y) (ε : ℝ) (x : X) (y z : Y) :
glueDist Φ Ψ ε (.inl x) (.inr z) ≤
glueDist Φ Ψ ε (.inl x) (.inr y) + glueDist Φ Ψ ε (.inr y) (.inr z) := by
simp only [glueDist]
rw [add_right_comm, add_le_add_iff_right]
refine le_ciInf_add fun p => ciInf_le_of_le ⟨0, ?_⟩ p ?_
· exact forall_mem_range.2 fun _ => add_nonneg dist_nonneg dist_nonneg
· linarith [dist_triangle_left z (Ψ p) y]
private theorem glueDist_triangle_inl_inr_inl (Φ : Z → X) (Ψ : Z → Y) (ε : ℝ)
(H : ∀ p q, |dist (Φ p) (Φ q) - dist (Ψ p) (Ψ q)| ≤ 2 * ε) (x : X) (y : Y) (z : X) :
glueDist Φ Ψ ε (.inl x) (.inl z) ≤
glueDist Φ Ψ ε (.inl x) (.inr y) + glueDist Φ Ψ ε (.inr y) (.inl z) := by
simp_rw [glueDist, add_add_add_comm _ ε, add_assoc]
refine le_ciInf_add fun p => ?_
rw [add_left_comm, add_assoc, ← two_mul]
refine le_ciInf_add fun q => ?_
rw [dist_comm z]
linarith [dist_triangle4 x (Φ p) (Φ q) z, dist_triangle_left (Ψ p) (Ψ q) y, (abs_le.1 (H p q)).2]
private theorem glueDist_triangle (Φ : Z → X) (Ψ : Z → Y) (ε : ℝ)
(H : ∀ p q, |dist (Φ p) (Φ q) - dist (Ψ p) (Ψ q)| ≤ 2 * ε) :
∀ x y z, glueDist Φ Ψ ε x z ≤ glueDist Φ Ψ ε x y + glueDist Φ Ψ ε y z
| .inl x, .inl y, .inl z => dist_triangle _ _ _
| .inr x, .inr y, .inr z => dist_triangle _ _ _
| .inr x, .inl y, .inl z => by
simp only [← glueDist_swap Φ]
apply glueDist_triangle_inl_inr_inr
| .inr x, .inr y, .inl z => by
simpa only [glueDist_comm, add_comm] using glueDist_triangle_inl_inr_inr _ _ _ z y x
| .inl x, .inl y, .inr z => by
simpa only [← glueDist_swap Φ, glueDist_comm, add_comm, Sum.swap_inl, Sum.swap_inr]
using glueDist_triangle_inl_inr_inr Ψ Φ ε z y x
| .inl x, .inr y, .inr z => glueDist_triangle_inl_inr_inr ..
| .inl x, .inr y, .inl z => glueDist_triangle_inl_inr_inl Φ Ψ ε H x y z
| .inr x, .inl y, .inr z => by
simp only [← glueDist_swap Φ]
apply glueDist_triangle_inl_inr_inl
simpa only [abs_sub_comm]
end
private theorem eq_of_glueDist_eq_zero (Φ : Z → X) (Ψ : Z → Y) (ε : ℝ) (ε0 : 0 < ε) :
∀ p q : X ⊕ Y, glueDist Φ Ψ ε p q = 0 → p = q
| .inl x, .inl y, h => by rw [eq_of_dist_eq_zero h]
| .inl x, .inr y, h => by exfalso; linarith [le_glueDist_inl_inr Φ Ψ ε x y]
| .inr x, .inl y, h => by exfalso; linarith [le_glueDist_inr_inl Φ Ψ ε x y]
| .inr x, .inr y, h => by rw [eq_of_dist_eq_zero h]
theorem Sum.mem_uniformity_iff_glueDist (hε : 0 < ε) (s : Set ((X ⊕ Y) × (X ⊕ Y))) :
s ∈ 𝓤 (X ⊕ Y) ↔ ∃ δ > 0, ∀ a b, glueDist Φ Ψ ε a b < δ → (a, b) ∈ s := by
simp only [Sum.uniformity, Filter.mem_sup, Filter.mem_map, mem_uniformity_dist, mem_preimage]
constructor
· rintro ⟨⟨δX, δX0, hX⟩, δY, δY0, hY⟩
refine ⟨min (min δX δY) ε, lt_min (lt_min δX0 δY0) hε, ?_⟩
rintro (a | a) (b | b) h <;> simp only [lt_min_iff] at h
· exact hX h.1.1
· exact absurd h.2 (le_glueDist_inl_inr _ _ _ _ _).not_lt
· exact absurd h.2 (le_glueDist_inr_inl _ _ _ _ _).not_lt
· exact hY h.1.2
· rintro ⟨ε, ε0, H⟩
constructor <;> exact ⟨ε, ε0, fun h => H _ _ h⟩
/-- Given two maps `Φ` and `Ψ` intro metric spaces `X` and `Y` such that the distances between
`Φ p` and `Φ q`, and between `Ψ p` and `Ψ q`, coincide up to `2 ε` where `ε > 0`, one can almost
glue the two spaces `X` and `Y` along the images of `Φ` and `Ψ`, so that `Φ p` and `Ψ p` are
at distance `ε`. -/
def glueMetricApprox [Nonempty Z] (Φ : Z → X) (Ψ : Z → Y) (ε : ℝ) (ε0 : 0 < ε)
(H : ∀ p q, |dist (Φ p) (Φ q) - dist (Ψ p) (Ψ q)| ≤ 2 * ε) : MetricSpace (X ⊕ Y) where
dist := glueDist Φ Ψ ε
dist_self := glueDist_self Φ Ψ ε
dist_comm := glueDist_comm Φ Ψ ε
dist_triangle := glueDist_triangle Φ Ψ ε H
eq_of_dist_eq_zero := eq_of_glueDist_eq_zero Φ Ψ ε ε0 _ _
toUniformSpace := Sum.instUniformSpace
uniformity_dist := uniformity_dist_of_mem_uniformity _ _ <| Sum.mem_uniformity_iff_glueDist ε0
end ApproxGluing
section Sum
/-!
### Metric on `X ⊕ Y`
A particular case of the previous construction is when one uses basepoints in `X` and `Y` and one
glues only along the basepoints, putting them at distance 1. We give a direct definition of
the distance, without `iInf`, as it is easier to use in applications, and show that it is equal to
the gluing distance defined above to take advantage of the lemmas we have already proved.
-/
variable {X : Type u} {Y : Type v} {Z : Type w}
variable [MetricSpace X] [MetricSpace Y]
/-- Distance on a disjoint union. There are many (noncanonical) ways to put a distance compatible
with each factor.
If the two spaces are bounded, one can say for instance that each point in the first is at distance
`diam X + diam Y + 1` of each point in the second.
Instead, we choose a construction that works for unbounded spaces, but requires basepoints,
chosen arbitrarily.
We embed isometrically each factor, set the basepoints at distance 1,
arbitrarily, and say that the distance from `a` to `b` is the sum of the distances of `a` and `b` to
their respective basepoints, plus the distance 1 between the basepoints.
Since there is an arbitrary choice in this construction, it is not an instance by default. -/
protected def Sum.dist : X ⊕ Y → X ⊕ Y → ℝ
| .inl a, .inl a' => dist a a'
| .inr b, .inr b' => dist b b'
| .inl a, .inr b => dist a (Nonempty.some ⟨a⟩) + 1 + dist (Nonempty.some ⟨b⟩) b
| .inr b, .inl a => dist b (Nonempty.some ⟨b⟩) + 1 + dist (Nonempty.some ⟨a⟩) a
theorem Sum.dist_eq_glueDist {p q : X ⊕ Y} (x : X) (y : Y) :
Sum.dist p q =
glueDist (fun _ : Unit => Nonempty.some ⟨x⟩) (fun _ : Unit => Nonempty.some ⟨y⟩) 1 p q := by
cases p <;> cases q <;> first |rfl|simp [Sum.dist, glueDist, dist_comm, add_comm,
add_left_comm, add_assoc]
private theorem Sum.dist_comm (x y : X ⊕ Y) : Sum.dist x y = Sum.dist y x := by
cases x <;> cases y <;> simp [Sum.dist, _root_.dist_comm, add_comm, add_left_comm, add_assoc]
theorem Sum.one_le_dist_inl_inr {x : X} {y : Y} : 1 ≤ Sum.dist (.inl x) (.inr y) :=
le_trans (le_add_of_nonneg_right dist_nonneg) <|
add_le_add_right (le_add_of_nonneg_left dist_nonneg) _
theorem Sum.one_le_dist_inr_inl {x : X} {y : Y} : 1 ≤ Sum.dist (.inr y) (.inl x) := by
rw [Sum.dist_comm]; exact Sum.one_le_dist_inl_inr
private theorem Sum.mem_uniformity (s : Set ((X ⊕ Y) × (X ⊕ Y))) :
s ∈ 𝓤 (X ⊕ Y) ↔ ∃ ε > 0, ∀ a b, Sum.dist a b < ε → (a, b) ∈ s := by
constructor
· rintro ⟨hsX, hsY⟩
rcases mem_uniformity_dist.1 hsX with ⟨εX, εX0, hX⟩
rcases mem_uniformity_dist.1 hsY with ⟨εY, εY0, hY⟩
refine ⟨min (min εX εY) 1, lt_min (lt_min εX0 εY0) zero_lt_one, ?_⟩
rintro (a | a) (b | b) h
· exact hX (lt_of_lt_of_le h (le_trans (min_le_left _ _) (min_le_left _ _)))
· cases not_le_of_lt (lt_of_lt_of_le h (min_le_right _ _)) Sum.one_le_dist_inl_inr
· cases not_le_of_lt (lt_of_lt_of_le h (min_le_right _ _)) Sum.one_le_dist_inr_inl
· exact hY (lt_of_lt_of_le h (le_trans (min_le_left _ _) (min_le_right _ _)))
· rintro ⟨ε, ε0, H⟩
constructor <;> rw [Filter.mem_sets, Filter.mem_map, mem_uniformity_dist] <;>
exact ⟨ε, ε0, fun h => H _ _ h⟩
/-- The distance on the disjoint union indeed defines a metric space. All the distance properties
follow from our choice of the distance. The harder work is to show that the uniform structure
defined by the distance coincides with the disjoint union uniform structure. -/
def metricSpaceSum : MetricSpace (X ⊕ Y) where
dist := Sum.dist
dist_self x := by cases x <;> simp only [Sum.dist, dist_self]
dist_comm := Sum.dist_comm
dist_triangle
| .inl p, .inl q, .inl r => dist_triangle p q r
| .inl p, .inr q, _ => by
simp only [Sum.dist_eq_glueDist p q]
exact glueDist_triangle _ _ _ (by norm_num) _ _ _
| _, .inl q, .inr r => by
simp only [Sum.dist_eq_glueDist q r]
exact glueDist_triangle _ _ _ (by norm_num) _ _ _
| .inr p, _, .inl r => by
simp only [Sum.dist_eq_glueDist r p]
exact glueDist_triangle _ _ _ (by norm_num) _ _ _
| .inr p, .inr q, .inr r => dist_triangle p q r
eq_of_dist_eq_zero {p q} h := by
cases' p with p p <;> cases' q with q q
· rw [eq_of_dist_eq_zero h]
· exact eq_of_glueDist_eq_zero _ _ _ one_pos _ _ ((Sum.dist_eq_glueDist p q).symm.trans h)
· exact eq_of_glueDist_eq_zero _ _ _ one_pos _ _ ((Sum.dist_eq_glueDist q p).symm.trans h)
· rw [eq_of_dist_eq_zero h]
toUniformSpace := Sum.instUniformSpace
uniformity_dist := uniformity_dist_of_mem_uniformity _ _ Sum.mem_uniformity
attribute [local instance] metricSpaceSum
theorem Sum.dist_eq {x y : X ⊕ Y} : dist x y = Sum.dist x y := rfl
/-- The left injection of a space in a disjoint union is an isometry -/
theorem isometry_inl : Isometry (Sum.inl : X → X ⊕ Y) :=
Isometry.of_dist_eq fun _ _ => rfl
/-- The right injection of a space in a disjoint union is an isometry -/
theorem isometry_inr : Isometry (Sum.inr : Y → X ⊕ Y) :=
Isometry.of_dist_eq fun _ _ => rfl
end Sum
namespace Sigma
/- Copy of the previous paragraph, but for arbitrary disjoint unions instead of the disjoint union
of two spaces. I.e., work with sigma types instead of sum types. -/
variable {ι : Type*} {E : ι → Type*} [∀ i, MetricSpace (E i)]
open scoped Classical
/-- Distance on a disjoint union. There are many (noncanonical) ways to put a distance compatible
with each factor.
We choose a construction that works for unbounded spaces, but requires basepoints,
chosen arbitrarily.
We embed isometrically each factor, set the basepoints at distance 1, arbitrarily,
and say that the distance from `a` to `b` is the sum of the distances of `a` and `b` to
their respective basepoints, plus the distance 1 between the basepoints.
Since there is an arbitrary choice in this construction, it is not an instance by default. -/
protected def dist : (Σ i, E i) → (Σ i, E i) → ℝ
| ⟨i, x⟩, ⟨j, y⟩ =>
if h : i = j then
haveI : E j = E i := by rw [h]
Dist.dist x (cast this y)
else Dist.dist x (Nonempty.some ⟨x⟩) + 1 + Dist.dist (Nonempty.some ⟨y⟩) y
/-- A `Dist` instance on the disjoint union `Σ i, E i`.
We embed isometrically each factor, set the basepoints at distance 1, arbitrarily,
and say that the distance from `a` to `b` is the sum of the distances of `a` and `b` to
their respective basepoints, plus the distance 1 between the basepoints.
Since there is an arbitrary choice in this construction, it is not an instance by default. -/
def instDist : Dist (Σi, E i) :=
⟨Sigma.dist⟩
attribute [local instance] Sigma.instDist
@[simp]
theorem dist_same (i : ι) (x y : E i) : dist (Sigma.mk i x) ⟨i, y⟩ = dist x y := by
simp [Dist.dist, Sigma.dist]
@[simp]
theorem dist_ne {i j : ι} (h : i ≠ j) (x : E i) (y : E j) :
dist (⟨i, x⟩ : Σk, E k) ⟨j, y⟩ = dist x (Nonempty.some ⟨x⟩) + 1 + dist (Nonempty.some ⟨y⟩) y :=
dif_neg h
theorem one_le_dist_of_ne {i j : ι} (h : i ≠ j) (x : E i) (y : E j) :
1 ≤ dist (⟨i, x⟩ : Σk, E k) ⟨j, y⟩ := by
rw [Sigma.dist_ne h x y]
linarith [@dist_nonneg _ _ x (Nonempty.some ⟨x⟩), @dist_nonneg _ _ (Nonempty.some ⟨y⟩) y]
theorem fst_eq_of_dist_lt_one (x y : Σi, E i) (h : dist x y < 1) : x.1 = y.1 := by
cases x; cases y
contrapose! h
apply one_le_dist_of_ne h
protected theorem dist_triangle (x y z : Σi, E i) : dist x z ≤ dist x y + dist y z := by
rcases x with ⟨i, x⟩; rcases y with ⟨j, y⟩; rcases z with ⟨k, z⟩
rcases eq_or_ne i k with (rfl | hik)
· rcases eq_or_ne i j with (rfl | hij)
· simpa using dist_triangle x y z
· simp only [Sigma.dist_same, Sigma.dist_ne hij, Sigma.dist_ne hij.symm]
calc
dist x z ≤ dist x (Nonempty.some ⟨x⟩) + 0 + 0 + (0 + 0 + dist (Nonempty.some ⟨z⟩) z) := by
simpa only [zero_add, add_zero] using dist_triangle _ _ _
_ ≤ _ := by apply_rules [add_le_add, le_rfl, dist_nonneg, zero_le_one]
· rcases eq_or_ne i j with (rfl | hij)
· simp only [Sigma.dist_ne hik, Sigma.dist_same]
calc
dist x (Nonempty.some ⟨x⟩) + 1 + dist (Nonempty.some ⟨z⟩) z ≤
dist x y + dist y (Nonempty.some ⟨y⟩) + 1 + dist (Nonempty.some ⟨z⟩) z := by
apply_rules [add_le_add, le_rfl, dist_triangle]
_ = _ := by abel
· rcases eq_or_ne j k with (rfl | hjk)
· simp only [Sigma.dist_ne hij, Sigma.dist_same]
calc
dist x (Nonempty.some ⟨x⟩) + 1 + dist (Nonempty.some ⟨z⟩) z ≤
dist x (Nonempty.some ⟨x⟩) + 1 + (dist (Nonempty.some ⟨z⟩) y + dist y z) := by
apply_rules [add_le_add, le_rfl, dist_triangle]
_ = _ := by abel
· simp only [hik, hij, hjk, Sigma.dist_ne, Ne, not_false_iff]
calc
dist x (Nonempty.some ⟨x⟩) + 1 + dist (Nonempty.some ⟨z⟩) z =
dist x (Nonempty.some ⟨x⟩) + 1 + 0 + (0 + 0 + dist (Nonempty.some ⟨z⟩) z) := by
simp only [add_zero, zero_add]
_ ≤ _ := by apply_rules [add_le_add, zero_le_one, dist_nonneg, le_rfl]
protected theorem isOpen_iff (s : Set (Σi, E i)) :
IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, ∀ y, dist x y < ε → y ∈ s := by
constructor
· rintro hs ⟨i, x⟩ hx
obtain ⟨ε, εpos, hε⟩ : ∃ ε > 0, ball x ε ⊆ Sigma.mk i ⁻¹' s :=
Metric.isOpen_iff.1 (isOpen_sigma_iff.1 hs i) x hx
refine ⟨min ε 1, lt_min εpos zero_lt_one, ?_⟩
rintro ⟨j, y⟩ hy
rcases eq_or_ne i j with (rfl | hij)
· simp only [Sigma.dist_same, lt_min_iff] at hy
exact hε (mem_ball'.2 hy.1)
· apply (lt_irrefl (1 : ℝ) _).elim
calc
1 ≤ Sigma.dist ⟨i, x⟩ ⟨j, y⟩ := Sigma.one_le_dist_of_ne hij _ _
_ < 1 := hy.trans_le (min_le_right _ _)
· refine fun H => isOpen_sigma_iff.2 fun i => Metric.isOpen_iff.2 fun x hx => ?_
obtain ⟨ε, εpos, hε⟩ : ∃ ε > 0, ∀ y, dist (⟨i, x⟩ : Σj, E j) y < ε → y ∈ s :=
H ⟨i, x⟩ hx
refine ⟨ε, εpos, fun y hy => ?_⟩
apply hε ⟨i, y⟩
rw [Sigma.dist_same]
exact mem_ball'.1 hy
/-- A metric space structure on the disjoint union `Σ i, E i`.
We embed isometrically each factor, set the basepoints at distance 1, arbitrarily,
and say that the distance from `a` to `b` is the sum of the distances of `a` and `b` to
their respective basepoints, plus the distance 1 between the basepoints.
Since there is an arbitrary choice in this construction, it is not an instance by default. -/
protected def metricSpace : MetricSpace (Σi, E i) := by
refine MetricSpace.ofDistTopology Sigma.dist ?_ ?_ Sigma.dist_triangle Sigma.isOpen_iff ?_
· rintro ⟨i, x⟩
simp [Sigma.dist]
· rintro ⟨i, x⟩ ⟨j, y⟩
rcases eq_or_ne i j with (rfl | h)
· simp [Sigma.dist, dist_comm]
· simp only [Sigma.dist, dist_comm, h, h.symm, not_false_iff, dif_neg]
abel
· rintro ⟨i, x⟩ ⟨j, y⟩
rcases eq_or_ne i j with (rfl | hij)
· simp [Sigma.dist]
· intro h
apply (lt_irrefl (1 : ℝ) _).elim
calc
1 ≤ Sigma.dist (⟨i, x⟩ : Σk, E k) ⟨j, y⟩ := Sigma.one_le_dist_of_ne hij _ _
_ < 1 := by rw [h]; exact zero_lt_one
attribute [local instance] Sigma.metricSpace
open Topology
open Filter
/-- The injection of a space in a disjoint union is an isometry -/
theorem isometry_mk (i : ι) : Isometry (Sigma.mk i : E i → Σk, E k) :=
Isometry.of_dist_eq fun x y => by simp
/-- A disjoint union of complete metric spaces is complete. -/
protected theorem completeSpace [∀ i, CompleteSpace (E i)] : CompleteSpace (Σi, E i) := by
set s : ι → Set (Σi, E i) := fun i => Sigma.fst ⁻¹' {i}
set U := { p : (Σk, E k) × Σk, E k | dist p.1 p.2 < 1 }
have hc : ∀ i, IsComplete (s i) := fun i => by
simp only [s, ← range_sigmaMk]
exact (isometry_mk i).uniformInducing.isComplete_range
have hd : ∀ (i j), ∀ x ∈ s i, ∀ y ∈ s j, (x, y) ∈ U → i = j := fun i j x hx y hy hxy =>
(Eq.symm hx).trans ((fst_eq_of_dist_lt_one _ _ hxy).trans hy)
refine completeSpace_of_isComplete_univ ?_
convert isComplete_iUnion_separated hc (dist_mem_uniformity zero_lt_one) hd
simp only [s, ← preimage_iUnion, iUnion_of_singleton, preimage_univ]
end Sigma
section Gluing
-- Exact gluing of two metric spaces along isometric subsets.
variable {X : Type u} {Y : Type v} {Z : Type w}
variable [Nonempty Z] [MetricSpace Z] [MetricSpace X] [MetricSpace Y] {Φ : Z → X} {Ψ : Z → Y}
{ε : ℝ}
/-- Given two isometric embeddings `Φ : Z → X` and `Ψ : Z → Y`, we define a pseudo metric space
structure on `X ⊕ Y` by declaring that `Φ x` and `Ψ x` are at distance `0`. -/
def gluePremetric (hΦ : Isometry Φ) (hΨ : Isometry Ψ) : PseudoMetricSpace (X ⊕ Y) where
dist := glueDist Φ Ψ 0
dist_self := glueDist_self Φ Ψ 0
dist_comm := glueDist_comm Φ Ψ 0
dist_triangle := glueDist_triangle Φ Ψ 0 fun p q => by rw [hΦ.dist_eq, hΨ.dist_eq]; simp
/-- Given two isometric embeddings `Φ : Z → X` and `Ψ : Z → Y`, we define a
space `GlueSpace hΦ hΨ` by identifying in `X ⊕ Y` the points `Φ x` and `Ψ x`. -/
def GlueSpace (hΦ : Isometry Φ) (hΨ : Isometry Ψ) : Type _ :=
@SeparationQuotient _ (gluePremetric hΦ hΨ).toUniformSpace.toTopologicalSpace
instance (hΦ : Isometry Φ) (hΨ : Isometry Ψ) : MetricSpace (GlueSpace hΦ hΨ) :=
inferInstanceAs <| MetricSpace <|
@SeparationQuotient _ (gluePremetric hΦ hΨ).toUniformSpace.toTopologicalSpace
/-- The canonical map from `X` to the space obtained by gluing isometric subsets in `X` and `Y`. -/
def toGlueL (hΦ : Isometry Φ) (hΨ : Isometry Ψ) (x : X) : GlueSpace hΦ hΨ :=
Quotient.mk'' (.inl x)
/-- The canonical map from `Y` to the space obtained by gluing isometric subsets in `X` and `Y`. -/
def toGlueR (hΦ : Isometry Φ) (hΨ : Isometry Ψ) (y : Y) : GlueSpace hΦ hΨ :=
Quotient.mk'' (.inr y)
instance inhabitedLeft (hΦ : Isometry Φ) (hΨ : Isometry Ψ) [Inhabited X] :
Inhabited (GlueSpace hΦ hΨ) :=
⟨toGlueL _ _ default⟩
instance inhabitedRight (hΦ : Isometry Φ) (hΨ : Isometry Ψ) [Inhabited Y] :
Inhabited (GlueSpace hΦ hΨ) :=
⟨toGlueR _ _ default⟩
theorem toGlue_commute (hΦ : Isometry Φ) (hΨ : Isometry Ψ) :
toGlueL hΦ hΨ ∘ Φ = toGlueR hΦ hΨ ∘ Ψ := by
let i : PseudoMetricSpace (X ⊕ Y) := gluePremetric hΦ hΨ
let _ := i.toUniformSpace.toTopologicalSpace
funext
simp only [comp, toGlueL, toGlueR]
refine SeparationQuotient.mk_eq_mk.2 (Metric.inseparable_iff.2 ?_)
exact glueDist_glued_points Φ Ψ 0 _
theorem toGlueL_isometry (hΦ : Isometry Φ) (hΨ : Isometry Ψ) : Isometry (toGlueL hΦ hΨ) :=
Isometry.of_dist_eq fun _ _ => rfl
theorem toGlueR_isometry (hΦ : Isometry Φ) (hΨ : Isometry Ψ) : Isometry (toGlueR hΦ hΨ) :=
Isometry.of_dist_eq fun _ _ => rfl
end Gluing
--section
section InductiveLimit
/-!
### Inductive limit of metric spaces
In this section, we define the inductive limit of
```
f 0 f 1 f 2 f 3
X 0 -----> X 1 -----> X 2 -----> X 3 -----> ...
```
where the `X n` are metric spaces and f n isometric embeddings. We do it by defining a premetric
space structure on `Σ n, X n`, where the predistance `dist x y` is obtained by pushing `x` and `y`
in a common `X k` using composition by the `f n`, and taking the distance there. This does not
depend on the choice of `k` as the `f n` are isometries. The metric space associated to this
premetric space is the desired inductive limit.
-/
open Nat
variable {X : ℕ → Type u} [∀ n, MetricSpace (X n)] {f : ∀ n, X n → X (n + 1)}
/-- Predistance on the disjoint union `Σ n, X n`. -/
def inductiveLimitDist (f : ∀ n, X n → X (n + 1)) (x y : Σn, X n) : ℝ :=
dist (leRecOn (le_max_left x.1 y.1) (f _) x.2 : X (max x.1 y.1))
(leRecOn (le_max_right x.1 y.1) (f _) y.2 : X (max x.1 y.1))
/-- The predistance on the disjoint union `Σ n, X n` can be computed in any `X k` for large
enough `k`. -/
theorem inductiveLimitDist_eq_dist (I : ∀ n, Isometry (f n)) (x y : Σn, X n) :
∀ m (hx : x.1 ≤ m) (hy : y.1 ≤ m), inductiveLimitDist f x y =
dist (leRecOn hx (f _) x.2 : X m) (leRecOn hy (f _) y.2 : X m)
| 0, hx, hy => by
cases' x with i x; cases' y with j y
obtain rfl : i = 0 := nonpos_iff_eq_zero.1 hx
obtain rfl : j = 0 := nonpos_iff_eq_zero.1 hy
rfl
| (m + 1), hx, hy => by
by_cases h : max x.1 y.1 = (m + 1)
· generalize m + 1 = m' at *
subst m'
rfl
· have : max x.1 y.1 ≤ succ m := by simp [hx, hy]
have : max x.1 y.1 ≤ m := by simpa [h] using of_le_succ this
have xm : x.1 ≤ m := le_trans (le_max_left _ _) this
have ym : y.1 ≤ m := le_trans (le_max_right _ _) this
rw [leRecOn_succ xm, leRecOn_succ ym, (I m).dist_eq]
exact inductiveLimitDist_eq_dist I x y m xm ym
/-- Premetric space structure on `Σ n, X n`. -/
def inductivePremetric (I : ∀ n, Isometry (f n)) : PseudoMetricSpace (Σn, X n) where
dist := inductiveLimitDist f
dist_self x := by simp [dist, inductiveLimitDist]
dist_comm x y := by
let m := max x.1 y.1
have hx : x.1 ≤ m := le_max_left _ _
have hy : y.1 ≤ m := le_max_right _ _
unfold dist; simp only
rw [inductiveLimitDist_eq_dist I x y m hx hy, inductiveLimitDist_eq_dist I y x m hy hx,
dist_comm]
dist_triangle x y z := by
let m := max (max x.1 y.1) z.1
have hx : x.1 ≤ m := le_trans (le_max_left _ _) (le_max_left _ _)
have hy : y.1 ≤ m := le_trans (le_max_right _ _) (le_max_left _ _)
have hz : z.1 ≤ m := le_max_right _ _
calc
inductiveLimitDist f x z = dist (leRecOn hx (f _) x.2 : X m) (leRecOn hz (f _) z.2 : X m) :=
inductiveLimitDist_eq_dist I x z m hx hz
_ ≤ dist (leRecOn hx (f _) x.2 : X m) (leRecOn hy (f _) y.2 : X m) +
dist (leRecOn hy (f _) y.2 : X m) (leRecOn hz (f _) z.2 : X m) :=
(dist_triangle _ _ _)
_ = inductiveLimitDist f x y + inductiveLimitDist f y z := by
rw [inductiveLimitDist_eq_dist I x y m hx hy, inductiveLimitDist_eq_dist I y z m hy hz]
attribute [local instance] inductivePremetric
/-- The type giving the inductive limit in a metric space context. -/
def InductiveLimit (I : ∀ n, Isometry (f n)) : Type _ :=
@SeparationQuotient _ (inductivePremetric I).toUniformSpace.toTopologicalSpace
set_option autoImplicit true in
instance : MetricSpace (InductiveLimit (f := f) I) :=
inferInstanceAs <| MetricSpace <|
@SeparationQuotient _ (inductivePremetric I).toUniformSpace.toTopologicalSpace
/-- Mapping each `X n` to the inductive limit. -/
def toInductiveLimit (I : ∀ n, Isometry (f n)) (n : ℕ) (x : X n) : Metric.InductiveLimit I :=
Quotient.mk'' (Sigma.mk n x)
instance (I : ∀ n, Isometry (f n)) [Inhabited (X 0)] : Inhabited (InductiveLimit I) :=
⟨toInductiveLimit _ 0 default⟩
/-- The map `toInductiveLimit n` mapping `X n` to the inductive limit is an isometry. -/
theorem toInductiveLimit_isometry (I : ∀ n, Isometry (f n)) (n : ℕ) :
Isometry (toInductiveLimit I n) :=
Isometry.of_dist_eq fun x y => by
change inductiveLimitDist f ⟨n, x⟩ ⟨n, y⟩ = dist x y
rw [inductiveLimitDist_eq_dist I ⟨n, x⟩ ⟨n, y⟩ n (le_refl n) (le_refl n), leRecOn_self,
leRecOn_self]
/-- The maps `toInductiveLimit n` are compatible with the maps `f n`. -/
theorem toInductiveLimit_commute (I : ∀ n, Isometry (f n)) (n : ℕ) :
toInductiveLimit I n.succ ∘ f n = toInductiveLimit I n := by
let h := inductivePremetric I
let _ := h.toUniformSpace.toTopologicalSpace
funext x
simp only [comp, toInductiveLimit]
refine SeparationQuotient.mk_eq_mk.2 (Metric.inseparable_iff.2 ?_)
show inductiveLimitDist f ⟨n.succ, f n x⟩ ⟨n, x⟩ = 0
rw [inductiveLimitDist_eq_dist I ⟨n.succ, f n x⟩ ⟨n, x⟩ n.succ, leRecOn_self,
leRecOn_succ, leRecOn_self, dist_self]
exact le_succ _
end InductiveLimit
--section
end Metric
--namespace
|
Topology\MetricSpace\GromovHausdorff.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.SetTheory.Cardinal.Basic
import Mathlib.Topology.MetricSpace.Closeds
import Mathlib.Topology.MetricSpace.Completion
import Mathlib.Topology.MetricSpace.GromovHausdorffRealized
import Mathlib.Topology.MetricSpace.Kuratowski
/-!
# Gromov-Hausdorff distance
This file defines the Gromov-Hausdorff distance on the space of nonempty compact metric spaces
up to isometry.
We introduce the space of all nonempty compact metric spaces, up to isometry,
called `GHSpace`, and endow it with a metric space structure. The distance,
known as the Gromov-Hausdorff distance, is defined as follows: given two
nonempty compact spaces `X` and `Y`, their distance is the minimum Hausdorff distance
between all possible isometric embeddings of `X` and `Y` in all metric spaces.
To define properly the Gromov-Hausdorff space, we consider the non-empty
compact subsets of `ℓ^∞(ℝ)` up to isometry, which is a well-defined type,
and define the distance as the infimum of the Hausdorff distance over all
embeddings in `ℓ^∞(ℝ)`. We prove that this coincides with the previous description,
as all separable metric spaces embed isometrically into `ℓ^∞(ℝ)`, through an
embedding called the Kuratowski embedding.
To prove that we have a distance, we should show that if spaces can be coupled
to be arbitrarily close, then they are isometric. More generally, the Gromov-Hausdorff
distance is realized, i.e., there is a coupling for which the Hausdorff distance
is exactly the Gromov-Hausdorff distance. This follows from a compactness
argument, essentially following from Arzela-Ascoli.
## Main results
We prove the most important properties of the Gromov-Hausdorff space: it is a polish space,
i.e., it is complete and second countable. We also prove the Gromov compactness criterion.
-/
noncomputable section
open scoped Topology ENNReal Cardinal
open Set Function TopologicalSpace Filter Metric Quotient Bornology
open BoundedContinuousFunction Nat Int kuratowskiEmbedding
open Sum (inl inr)
local notation "ℓ_infty_ℝ" => lp (fun n : ℕ => ℝ) ∞
universe u v w
attribute [local instance] metricSpaceSum
namespace GromovHausdorff
/-! In this section, we define the Gromov-Hausdorff space, denoted `GHSpace` as the quotient
of nonempty compact subsets of `ℓ^∞(ℝ)` by identifying isometric sets.
Using the Kuratwoski embedding, we get a canonical map `toGHSpace` mapping any nonempty
compact type to `GHSpace`. -/
section GHSpace
/-- Equivalence relation identifying two nonempty compact sets which are isometric -/
private def IsometryRel (x : NonemptyCompacts ℓ_infty_ℝ) (y : NonemptyCompacts ℓ_infty_ℝ) : Prop :=
Nonempty (x ≃ᵢ y)
/-- This is indeed an equivalence relation -/
private theorem equivalence_isometryRel : Equivalence IsometryRel :=
⟨fun _ => Nonempty.intro (IsometryEquiv.refl _), fun ⟨e⟩ => ⟨e.symm⟩, fun ⟨e⟩ ⟨f⟩ => ⟨e.trans f⟩⟩
/-- setoid instance identifying two isometric nonempty compact subspaces of ℓ^∞(ℝ) -/
instance IsometryRel.setoid : Setoid (NonemptyCompacts ℓ_infty_ℝ) :=
Setoid.mk IsometryRel equivalence_isometryRel
/-- The Gromov-Hausdorff space -/
def GHSpace : Type :=
Quotient IsometryRel.setoid
/-- Map any nonempty compact type to `GHSpace` -/
def toGHSpace (X : Type u) [MetricSpace X] [CompactSpace X] [Nonempty X] : GHSpace :=
⟦NonemptyCompacts.kuratowskiEmbedding X⟧
instance : Inhabited GHSpace :=
⟨Quot.mk _ ⟨⟨{0}, isCompact_singleton⟩, singleton_nonempty _⟩⟩
/-- A metric space representative of any abstract point in `GHSpace` -/
-- Porting note(#5171): linter not yet ported; removed @[nolint has_nonempty_instance]; why?
def GHSpace.Rep (p : GHSpace) : Type :=
(Quotient.out p : NonemptyCompacts ℓ_infty_ℝ)
theorem eq_toGHSpace_iff {X : Type u} [MetricSpace X] [CompactSpace X] [Nonempty X]
{p : NonemptyCompacts ℓ_infty_ℝ} :
⟦p⟧ = toGHSpace X ↔ ∃ Ψ : X → ℓ_infty_ℝ, Isometry Ψ ∧ range Ψ = p := by
simp only [toGHSpace, Quotient.eq]
refine ⟨fun h => ?_, ?_⟩
· rcases Setoid.symm h with ⟨e⟩
have f := (kuratowskiEmbedding.isometry X).isometryEquivOnRange.trans e
use fun x => f x, isometry_subtype_coe.comp f.isometry
erw [range_comp, f.range_eq_univ, Set.image_univ, Subtype.range_coe]
· rintro ⟨Ψ, ⟨isomΨ, rangeΨ⟩⟩
have f :=
((kuratowskiEmbedding.isometry X).isometryEquivOnRange.symm.trans
isomΨ.isometryEquivOnRange).symm
have E : (range Ψ ≃ᵢ NonemptyCompacts.kuratowskiEmbedding X)
= (p ≃ᵢ range (kuratowskiEmbedding X)) := by
dsimp only [NonemptyCompacts.kuratowskiEmbedding]; rw [rangeΨ]; rfl
exact ⟨cast E f⟩
theorem eq_toGHSpace {p : NonemptyCompacts ℓ_infty_ℝ} : ⟦p⟧ = toGHSpace p :=
eq_toGHSpace_iff.2 ⟨fun x => x, isometry_subtype_coe, Subtype.range_coe⟩
section
instance repGHSpaceMetricSpace {p : GHSpace} : MetricSpace p.Rep :=
inferInstanceAs <| MetricSpace p.out
instance rep_gHSpace_compactSpace {p : GHSpace} : CompactSpace p.Rep :=
inferInstanceAs <| CompactSpace p.out
instance rep_gHSpace_nonempty {p : GHSpace} : Nonempty p.Rep :=
inferInstanceAs <| Nonempty p.out
end
theorem GHSpace.toGHSpace_rep (p : GHSpace) : toGHSpace p.Rep = p := by
change toGHSpace (Quot.out p : NonemptyCompacts ℓ_infty_ℝ) = p
rw [← eq_toGHSpace]
exact Quot.out_eq p
/-- Two nonempty compact spaces have the same image in `GHSpace` if and only if they are
isometric. -/
theorem toGHSpace_eq_toGHSpace_iff_isometryEquiv {X : Type u} [MetricSpace X] [CompactSpace X]
[Nonempty X] {Y : Type v} [MetricSpace Y] [CompactSpace Y] [Nonempty Y] :
toGHSpace X = toGHSpace Y ↔ Nonempty (X ≃ᵢ Y) :=
⟨by
simp only [toGHSpace]
rw [Quotient.eq]
rintro ⟨e⟩
have I :
(NonemptyCompacts.kuratowskiEmbedding X ≃ᵢ NonemptyCompacts.kuratowskiEmbedding Y) =
(range (kuratowskiEmbedding X) ≃ᵢ range (kuratowskiEmbedding Y)) := by
dsimp only [NonemptyCompacts.kuratowskiEmbedding]; rfl
have f := (kuratowskiEmbedding.isometry X).isometryEquivOnRange
have g := (kuratowskiEmbedding.isometry Y).isometryEquivOnRange.symm
exact ⟨f.trans <| (cast I e).trans g⟩, by
rintro ⟨e⟩
simp only [toGHSpace, Quotient.eq']
have f := (kuratowskiEmbedding.isometry X).isometryEquivOnRange.symm
have g := (kuratowskiEmbedding.isometry Y).isometryEquivOnRange
have I :
(range (kuratowskiEmbedding X) ≃ᵢ range (kuratowskiEmbedding Y)) =
(NonemptyCompacts.kuratowskiEmbedding X ≃ᵢ NonemptyCompacts.kuratowskiEmbedding Y) := by
dsimp only [NonemptyCompacts.kuratowskiEmbedding]; rfl
rw [Quotient.eq]
exact ⟨cast I ((f.trans e).trans g)⟩⟩
/-- Distance on `GHSpace`: the distance between two nonempty compact spaces is the infimum
Hausdorff distance between isometric copies of the two spaces in a metric space. For the definition,
we only consider embeddings in `ℓ^∞(ℝ)`, but we will prove below that it works for all spaces. -/
instance : Dist GHSpace where
dist x y := sInf <| (fun p : NonemptyCompacts ℓ_infty_ℝ × NonemptyCompacts ℓ_infty_ℝ =>
hausdorffDist (p.1 : Set ℓ_infty_ℝ) p.2) '' { a | ⟦a⟧ = x } ×ˢ { b | ⟦b⟧ = y }
/-- The Gromov-Hausdorff distance between two nonempty compact metric spaces, equal by definition to
the distance of the equivalence classes of these spaces in the Gromov-Hausdorff space. -/
def ghDist (X : Type u) (Y : Type v) [MetricSpace X] [Nonempty X] [CompactSpace X] [MetricSpace Y]
[Nonempty Y] [CompactSpace Y] : ℝ :=
dist (toGHSpace X) (toGHSpace Y)
theorem dist_ghDist (p q : GHSpace) : dist p q = ghDist p.Rep q.Rep := by
rw [ghDist, p.toGHSpace_rep, q.toGHSpace_rep]
/-- The Gromov-Hausdorff distance between two spaces is bounded by the Hausdorff distance
of isometric copies of the spaces, in any metric space. -/
theorem ghDist_le_hausdorffDist {X : Type u} [MetricSpace X] [CompactSpace X] [Nonempty X]
{Y : Type v} [MetricSpace Y] [CompactSpace Y] [Nonempty Y] {γ : Type w} [MetricSpace γ]
{Φ : X → γ} {Ψ : Y → γ} (ha : Isometry Φ) (hb : Isometry Ψ) :
ghDist X Y ≤ hausdorffDist (range Φ) (range Ψ) := by
/- For the proof, we want to embed `γ` in `ℓ^∞(ℝ)`, to say that the Hausdorff distance is realized
in `ℓ^∞(ℝ)` and therefore bounded below by the Gromov-Hausdorff-distance. However, `γ` is not
separable in general. We restrict to the union of the images of `X` and `Y` in `γ`, which is
separable and therefore embeddable in `ℓ^∞(ℝ)`. -/
rcases exists_mem_of_nonempty X with ⟨xX, _⟩
let s : Set γ := range Φ ∪ range Ψ
let Φ' : X → Subtype s := fun y => ⟨Φ y, mem_union_left _ (mem_range_self _)⟩
let Ψ' : Y → Subtype s := fun y => ⟨Ψ y, mem_union_right _ (mem_range_self _)⟩
have IΦ' : Isometry Φ' := fun x y => ha x y
have IΨ' : Isometry Ψ' := fun x y => hb x y
have : IsCompact s := (isCompact_range ha.continuous).union (isCompact_range hb.continuous)
letI : MetricSpace (Subtype s) := by infer_instance
haveI : CompactSpace (Subtype s) := ⟨isCompact_iff_isCompact_univ.1 ‹IsCompact s›⟩
haveI : Nonempty (Subtype s) := ⟨Φ' xX⟩
have ΦΦ' : Φ = Subtype.val ∘ Φ' := by funext; rfl
have ΨΨ' : Ψ = Subtype.val ∘ Ψ' := by funext; rfl
have : hausdorffDist (range Φ) (range Ψ) = hausdorffDist (range Φ') (range Ψ') := by
rw [ΦΦ', ΨΨ', range_comp, range_comp]
exact hausdorffDist_image isometry_subtype_coe
rw [this]
-- Embed `s` in `ℓ^∞(ℝ)` through its Kuratowski embedding
let F := kuratowskiEmbedding (Subtype s)
have : hausdorffDist (F '' range Φ') (F '' range Ψ') = hausdorffDist (range Φ') (range Ψ') :=
hausdorffDist_image (kuratowskiEmbedding.isometry _)
rw [← this]
-- Let `A` and `B` be the images of `X` and `Y` under this embedding. They are in `ℓ^∞(ℝ)`, and
-- their Hausdorff distance is the same as in the original space.
let A : NonemptyCompacts ℓ_infty_ℝ :=
⟨⟨F '' range Φ',
(isCompact_range IΦ'.continuous).image (kuratowskiEmbedding.isometry _).continuous⟩,
(range_nonempty _).image _⟩
let B : NonemptyCompacts ℓ_infty_ℝ :=
⟨⟨F '' range Ψ',
(isCompact_range IΨ'.continuous).image (kuratowskiEmbedding.isometry _).continuous⟩,
(range_nonempty _).image _⟩
have AX : ⟦A⟧ = toGHSpace X := by
rw [eq_toGHSpace_iff]
exact ⟨fun x => F (Φ' x), (kuratowskiEmbedding.isometry _).comp IΦ', range_comp _ _⟩
have BY : ⟦B⟧ = toGHSpace Y := by
rw [eq_toGHSpace_iff]
exact ⟨fun x => F (Ψ' x), (kuratowskiEmbedding.isometry _).comp IΨ', range_comp _ _⟩
refine csInf_le ⟨0, ?_⟩ ?_
· simp only [lowerBounds, mem_image, mem_prod, mem_setOf_eq, Prod.exists, and_imp,
forall_exists_index]
intro t _ _ _ _ ht
rw [← ht]
exact hausdorffDist_nonneg
apply (mem_image _ _ _).2
exists (⟨A, B⟩ : NonemptyCompacts ℓ_infty_ℝ × NonemptyCompacts ℓ_infty_ℝ)
/-- The optimal coupling constructed above realizes exactly the Gromov-Hausdorff distance,
essentially by design. -/
theorem hausdorffDist_optimal {X : Type u} [MetricSpace X] [CompactSpace X] [Nonempty X]
{Y : Type v} [MetricSpace Y] [CompactSpace Y] [Nonempty Y] :
hausdorffDist (range (optimalGHInjl X Y)) (range (optimalGHInjr X Y)) = ghDist X Y := by
inhabit X; inhabit Y
/- we only need to check the inequality `≤`, as the other one follows from the previous lemma.
As the Gromov-Hausdorff distance is an infimum, we need to check that the Hausdorff distance
in the optimal coupling is smaller than the Hausdorff distance of any coupling.
First, we check this for couplings which already have small Hausdorff distance: in this
case, the induced "distance" on `X ⊕ Y` belongs to the candidates family introduced in the
definition of the optimal coupling, and the conclusion follows from the optimality
of the optimal coupling within this family.
-/
have A :
∀ p q : NonemptyCompacts ℓ_infty_ℝ,
⟦p⟧ = toGHSpace X →
⟦q⟧ = toGHSpace Y →
hausdorffDist (p : Set ℓ_infty_ℝ) q < diam (univ : Set X) + 1 + diam (univ : Set Y) →
hausdorffDist (range (optimalGHInjl X Y)) (range (optimalGHInjr X Y)) ≤
hausdorffDist (p : Set ℓ_infty_ℝ) q := by
intro p q hp hq bound
rcases eq_toGHSpace_iff.1 hp with ⟨Φ, ⟨Φisom, Φrange⟩⟩
rcases eq_toGHSpace_iff.1 hq with ⟨Ψ, ⟨Ψisom, Ψrange⟩⟩
have I : diam (range Φ ∪ range Ψ) ≤ 2 * diam (univ : Set X) + 1 + 2 * diam (univ : Set Y) := by
rcases exists_mem_of_nonempty X with ⟨xX, _⟩
have : ∃ y ∈ range Ψ, dist (Φ xX) y < diam (univ : Set X) + 1 + diam (univ : Set Y) := by
rw [Ψrange]
have : Φ xX ∈ ↑p := Φrange.subst (mem_range_self _)
exact
exists_dist_lt_of_hausdorffDist_lt this bound
(hausdorffEdist_ne_top_of_nonempty_of_bounded p.nonempty q.nonempty
p.isCompact.isBounded q.isCompact.isBounded)
rcases this with ⟨y, hy, dy⟩
rcases mem_range.1 hy with ⟨z, hzy⟩
rw [← hzy] at dy
have DΦ : diam (range Φ) = diam (univ : Set X) := Φisom.diam_range
have DΨ : diam (range Ψ) = diam (univ : Set Y) := Ψisom.diam_range
calc
diam (range Φ ∪ range Ψ) ≤ diam (range Φ) + dist (Φ xX) (Ψ z) + diam (range Ψ) :=
diam_union (mem_range_self _) (mem_range_self _)
_ ≤
diam (univ : Set X) + (diam (univ : Set X) + 1 + diam (univ : Set Y)) +
diam (univ : Set Y) := by
rw [DΦ, DΨ]
gcongr
-- apply add_le_add (add_le_add le_rfl (le_of_lt dy)) le_rfl
_ = 2 * diam (univ : Set X) + 1 + 2 * diam (univ : Set Y) := by ring
let f : X ⊕ Y → ℓ_infty_ℝ := fun x =>
match x with
| inl y => Φ y
| inr z => Ψ z
let F : (X ⊕ Y) × (X ⊕ Y) → ℝ := fun p => dist (f p.1) (f p.2)
-- check that the induced "distance" is a candidate
have Fgood : F ∈ candidates X Y := by
simp only [F, candidates, forall_const, and_true_iff, add_comm, eq_self_iff_true,
dist_eq_zero, and_self_iff, Set.mem_setOf_eq]
repeat' constructor
· exact fun x y =>
calc
F (inl x, inl y) = dist (Φ x) (Φ y) := rfl
_ = dist x y := Φisom.dist_eq x y
· exact fun x y =>
calc
F (inr x, inr y) = dist (Ψ x) (Ψ y) := rfl
_ = dist x y := Ψisom.dist_eq x y
· exact fun x y => dist_comm _ _
· exact fun x y z => dist_triangle _ _ _
· exact fun x y =>
calc
F (x, y) ≤ diam (range Φ ∪ range Ψ) := by
have A : ∀ z : X ⊕ Y, f z ∈ range Φ ∪ range Ψ := by
intro z
cases z
· apply mem_union_left; apply mem_range_self
· apply mem_union_right; apply mem_range_self
refine dist_le_diam_of_mem ?_ (A _) (A _)
rw [Φrange, Ψrange]
exact (p ⊔ q).isCompact.isBounded
_ ≤ 2 * diam (univ : Set X) + 1 + 2 * diam (univ : Set Y) := I
let Fb := candidatesBOfCandidates F Fgood
have : hausdorffDist (range (optimalGHInjl X Y)) (range (optimalGHInjr X Y)) ≤ HD Fb :=
hausdorffDist_optimal_le_HD _ _ (candidatesBOfCandidates_mem F Fgood)
refine le_trans this (le_of_forall_le_of_dense fun r hr => ?_)
have I1 : ∀ x : X, (⨅ y, Fb (inl x, inr y)) ≤ r := by
intro x
have : f (inl x) ∈ ↑p := Φrange.subst (mem_range_self _)
rcases exists_dist_lt_of_hausdorffDist_lt this hr
(hausdorffEdist_ne_top_of_nonempty_of_bounded p.nonempty q.nonempty p.isCompact.isBounded
q.isCompact.isBounded) with
⟨z, zq, hz⟩
have : z ∈ range Ψ := by rwa [← Ψrange] at zq
rcases mem_range.1 this with ⟨y, hy⟩
calc
(⨅ y, Fb (inl x, inr y)) ≤ Fb (inl x, inr y) :=
ciInf_le (by simpa only [add_zero] using HD_below_aux1 0) y
_ = dist (Φ x) (Ψ y) := rfl
_ = dist (f (inl x)) z := by rw [hy]
_ ≤ r := le_of_lt hz
have I2 : ∀ y : Y, (⨅ x, Fb (inl x, inr y)) ≤ r := by
intro y
have : f (inr y) ∈ ↑q := Ψrange.subst (mem_range_self _)
rcases exists_dist_lt_of_hausdorffDist_lt' this hr
(hausdorffEdist_ne_top_of_nonempty_of_bounded p.nonempty q.nonempty p.isCompact.isBounded
q.isCompact.isBounded) with
⟨z, zq, hz⟩
have : z ∈ range Φ := by rwa [← Φrange] at zq
rcases mem_range.1 this with ⟨x, hx⟩
calc
(⨅ x, Fb (inl x, inr y)) ≤ Fb (inl x, inr y) :=
ciInf_le (by simpa only [add_zero] using HD_below_aux2 0) x
_ = dist (Φ x) (Ψ y) := rfl
_ = dist z (f (inr y)) := by rw [hx]
_ ≤ r := le_of_lt hz
simp only [HD, ciSup_le I1, ciSup_le I2, max_le_iff, and_self_iff]
/- Get the same inequality for any coupling. If the coupling is quite good, the desired
inequality has been proved above. If it is bad, then the inequality is obvious. -/
have B :
∀ p q : NonemptyCompacts ℓ_infty_ℝ,
⟦p⟧ = toGHSpace X →
⟦q⟧ = toGHSpace Y →
hausdorffDist (range (optimalGHInjl X Y)) (range (optimalGHInjr X Y)) ≤
hausdorffDist (p : Set ℓ_infty_ℝ) q := by
intro p q hp hq
by_cases h :
hausdorffDist (p : Set ℓ_infty_ℝ) q < diam (univ : Set X) + 1 + diam (univ : Set Y)
· exact A p q hp hq h
· calc
hausdorffDist (range (optimalGHInjl X Y)) (range (optimalGHInjr X Y)) ≤
HD (candidatesBDist X Y) :=
hausdorffDist_optimal_le_HD _ _ candidatesBDist_mem_candidatesB
_ ≤ diam (univ : Set X) + 1 + diam (univ : Set Y) := HD_candidatesBDist_le
_ ≤ hausdorffDist (p : Set ℓ_infty_ℝ) q := not_lt.1 h
refine le_antisymm ?_ ?_
· apply le_csInf
· refine (Set.Nonempty.prod ?_ ?_).image _ <;> exact ⟨_, rfl⟩
· rintro b ⟨⟨p, q⟩, ⟨hp, hq⟩, rfl⟩
exact B p q hp hq
· exact ghDist_le_hausdorffDist (isometry_optimalGHInjl X Y) (isometry_optimalGHInjr X Y)
/-- The Gromov-Hausdorff distance can also be realized by a coupling in `ℓ^∞(ℝ)`, by embedding
the optimal coupling through its Kuratowski embedding. -/
theorem ghDist_eq_hausdorffDist (X : Type u) [MetricSpace X] [CompactSpace X] [Nonempty X]
(Y : Type v) [MetricSpace Y] [CompactSpace Y] [Nonempty Y] :
∃ Φ : X → ℓ_infty_ℝ,
∃ Ψ : Y → ℓ_infty_ℝ,
Isometry Φ ∧ Isometry Ψ ∧ ghDist X Y = hausdorffDist (range Φ) (range Ψ) := by
let F := kuratowskiEmbedding (OptimalGHCoupling X Y)
let Φ := F ∘ optimalGHInjl X Y
let Ψ := F ∘ optimalGHInjr X Y
refine ⟨Φ, Ψ, ?_, ?_, ?_⟩
· exact (kuratowskiEmbedding.isometry _).comp (isometry_optimalGHInjl X Y)
· exact (kuratowskiEmbedding.isometry _).comp (isometry_optimalGHInjr X Y)
· rw [← image_univ, ← image_univ, image_comp F, image_univ, image_comp F (optimalGHInjr X Y),
image_univ, ← hausdorffDist_optimal]
exact (hausdorffDist_image (kuratowskiEmbedding.isometry _)).symm
/-- The Gromov-Hausdorff distance defines a genuine distance on the Gromov-Hausdorff space. -/
instance : MetricSpace GHSpace where
dist := dist
dist_self x := by
rcases exists_rep x with ⟨y, hy⟩
refine le_antisymm ?_ ?_
· apply csInf_le
· exact ⟨0, by rintro b ⟨⟨u, v⟩, -, rfl⟩; exact hausdorffDist_nonneg⟩
· simp only [mem_image, mem_prod, mem_setOf_eq, Prod.exists]
exists y, y
simpa only [and_self_iff, hausdorffDist_self_zero, eq_self_iff_true, and_true_iff]
· apply le_csInf
· exact Set.Nonempty.image _ <| Set.Nonempty.prod ⟨y, hy⟩ ⟨y, hy⟩
· rintro b ⟨⟨u, v⟩, -, rfl⟩; exact hausdorffDist_nonneg
dist_comm x y := by
have A :
(fun p : NonemptyCompacts ℓ_infty_ℝ × NonemptyCompacts ℓ_infty_ℝ =>
hausdorffDist (p.1 : Set ℓ_infty_ℝ) p.2) ''
{ a | ⟦a⟧ = x } ×ˢ { b | ⟦b⟧ = y } =
(fun p : NonemptyCompacts ℓ_infty_ℝ × NonemptyCompacts ℓ_infty_ℝ =>
hausdorffDist (p.1 : Set ℓ_infty_ℝ) p.2) ∘
Prod.swap ''
{ a | ⟦a⟧ = x } ×ˢ { b | ⟦b⟧ = y } := by
funext
simp only [comp_apply, Prod.fst_swap, Prod.snd_swap]
congr
-- The next line had `singlePass := true` before #9928,
-- then was changed to be `simp only [hausdorffDist_comm]`,
-- then `singlePass := true` was readded in #8386 because of timeouts.
-- TODO: figure out what causes the slowdown and make it a `simp only` again?
simp (config := { singlePass := true }) only [hausdorffDist_comm]
simp only [dist, A, image_comp, image_swap_prod]
eq_of_dist_eq_zero {x} {y} hxy := by
/- To show that two spaces at zero distance are isometric,
we argue that the distance is realized by some coupling.
In this coupling, the two spaces are at zero Hausdorff distance,
i.e., they coincide. Therefore, the original spaces are isometric. -/
rcases ghDist_eq_hausdorffDist x.Rep y.Rep with ⟨Φ, Ψ, Φisom, Ψisom, DΦΨ⟩
rw [← dist_ghDist] at DΦΨ
simp_rw [hxy] at DΦΨ -- Porting note: I have no idea why this needed `simp_rw` versus `rw`
have : range Φ = range Ψ := by
have hΦ : IsCompact (range Φ) := isCompact_range Φisom.continuous
have hΨ : IsCompact (range Ψ) := isCompact_range Ψisom.continuous
apply (IsClosed.hausdorffDist_zero_iff_eq _ _ _).1 DΦΨ.symm
· exact hΦ.isClosed
· exact hΨ.isClosed
· exact hausdorffEdist_ne_top_of_nonempty_of_bounded (range_nonempty _) (range_nonempty _)
hΦ.isBounded hΨ.isBounded
have T : (range Ψ ≃ᵢ y.Rep) = (range Φ ≃ᵢ y.Rep) := by rw [this]
have eΨ := cast T Ψisom.isometryEquivOnRange.symm
have e := Φisom.isometryEquivOnRange.trans eΨ
rw [← x.toGHSpace_rep, ← y.toGHSpace_rep, toGHSpace_eq_toGHSpace_iff_isometryEquiv]
exact ⟨e⟩
dist_triangle x y z := by
/- To show the triangular inequality between `X`, `Y` and `Z`,
realize an optimal coupling between `X` and `Y` in a space `γ1`,
and an optimal coupling between `Y` and `Z` in a space `γ2`.
Then, glue these metric spaces along `Y`. We get a new space `γ`
in which `X` and `Y` are optimally coupled, as well as `Y` and `Z`.
Apply the triangle inequality for the Hausdorff distance in `γ`
to conclude. -/
let X := x.Rep
let Y := y.Rep
let Z := z.Rep
let γ1 := OptimalGHCoupling X Y
let γ2 := OptimalGHCoupling Y Z
let Φ : Y → γ1 := optimalGHInjr X Y
have hΦ : Isometry Φ := isometry_optimalGHInjr X Y
let Ψ : Y → γ2 := optimalGHInjl Y Z
have hΨ : Isometry Ψ := isometry_optimalGHInjl Y Z
have Comm : toGlueL hΦ hΨ ∘ optimalGHInjr X Y = toGlueR hΦ hΨ ∘ optimalGHInjl Y Z :=
toGlue_commute hΦ hΨ
calc
dist x z = dist (toGHSpace X) (toGHSpace Z) := by
rw [x.toGHSpace_rep, z.toGHSpace_rep]
_ ≤ hausdorffDist (range (toGlueL hΦ hΨ ∘ optimalGHInjl X Y))
(range (toGlueR hΦ hΨ ∘ optimalGHInjr Y Z)) :=
(ghDist_le_hausdorffDist ((toGlueL_isometry hΦ hΨ).comp (isometry_optimalGHInjl X Y))
((toGlueR_isometry hΦ hΨ).comp (isometry_optimalGHInjr Y Z)))
_ ≤ hausdorffDist (range (toGlueL hΦ hΨ ∘ optimalGHInjl X Y))
(range (toGlueL hΦ hΨ ∘ optimalGHInjr X Y)) +
hausdorffDist (range (toGlueL hΦ hΨ ∘ optimalGHInjr X Y))
(range (toGlueR hΦ hΨ ∘ optimalGHInjr Y Z)) := by
refine hausdorffDist_triangle <| hausdorffEdist_ne_top_of_nonempty_of_bounded
(range_nonempty _) (range_nonempty _) ?_ ?_
· exact (isCompact_range (Isometry.continuous
((toGlueL_isometry hΦ hΨ).comp (isometry_optimalGHInjl X Y)))).isBounded
· exact (isCompact_range (Isometry.continuous
((toGlueL_isometry hΦ hΨ).comp (isometry_optimalGHInjr X Y)))).isBounded
_ = hausdorffDist (toGlueL hΦ hΨ '' range (optimalGHInjl X Y))
(toGlueL hΦ hΨ '' range (optimalGHInjr X Y)) +
hausdorffDist (toGlueR hΦ hΨ '' range (optimalGHInjl Y Z))
(toGlueR hΦ hΨ '' range (optimalGHInjr Y Z)) := by
simp only [← range_comp, Comm, eq_self_iff_true, add_right_inj]
_ = hausdorffDist (range (optimalGHInjl X Y)) (range (optimalGHInjr X Y)) +
hausdorffDist (range (optimalGHInjl Y Z)) (range (optimalGHInjr Y Z)) := by
rw [hausdorffDist_image (toGlueL_isometry hΦ hΨ),
hausdorffDist_image (toGlueR_isometry hΦ hΨ)]
_ = dist (toGHSpace X) (toGHSpace Y) + dist (toGHSpace Y) (toGHSpace Z) := by
rw [hausdorffDist_optimal, hausdorffDist_optimal, ghDist, ghDist]
_ = dist x y + dist y z := by rw [x.toGHSpace_rep, y.toGHSpace_rep, z.toGHSpace_rep]
end GHSpace
--section
end GromovHausdorff
/-- In particular, nonempty compacts of a metric space map to `GHSpace`.
We register this in the `TopologicalSpace` namespace to take advantage
of the notation `p.toGHSpace`. -/
def TopologicalSpace.NonemptyCompacts.toGHSpace {X : Type u} [MetricSpace X]
(p : NonemptyCompacts X) : GromovHausdorff.GHSpace :=
GromovHausdorff.toGHSpace p
open TopologicalSpace
namespace GromovHausdorff
section NonemptyCompacts
variable {X : Type u} [MetricSpace X]
theorem ghDist_le_nonemptyCompacts_dist (p q : NonemptyCompacts X) :
dist p.toGHSpace q.toGHSpace ≤ dist p q := by
have ha : Isometry ((↑) : p → X) := isometry_subtype_coe
have hb : Isometry ((↑) : q → X) := isometry_subtype_coe
have A : dist p q = hausdorffDist (p : Set X) q := rfl
have I : ↑p = range ((↑) : p → X) := Subtype.range_coe_subtype.symm
have J : ↑q = range ((↑) : q → X) := Subtype.range_coe_subtype.symm
rw [A, I, J]
exact ghDist_le_hausdorffDist ha hb
theorem toGHSpace_lipschitz :
LipschitzWith 1 (NonemptyCompacts.toGHSpace : NonemptyCompacts X → GHSpace) :=
LipschitzWith.mk_one ghDist_le_nonemptyCompacts_dist
theorem toGHSpace_continuous :
Continuous (NonemptyCompacts.toGHSpace : NonemptyCompacts X → GHSpace) :=
toGHSpace_lipschitz.continuous
end NonemptyCompacts
section
/- In this section, we show that if two metric spaces are isometric up to `ε₂`, then their
Gromov-Hausdorff distance is bounded by `ε₂ / 2`. More generally, if there are subsets which are
`ε₁`-dense and `ε₃`-dense in two spaces, and isometric up to `ε₂`, then the Gromov-Hausdorff
distance between the spaces is bounded by `ε₁ + ε₂/2 + ε₃`. For this, we construct a suitable
coupling between the two spaces, by gluing them (approximately) along the two matching subsets. -/
variable {X : Type u} [MetricSpace X] [CompactSpace X] [Nonempty X] {Y : Type v} [MetricSpace Y]
[CompactSpace Y] [Nonempty Y]
/-- If there are subsets which are `ε₁`-dense and `ε₃`-dense in two spaces, and
isometric up to `ε₂`, then the Gromov-Hausdorff distance between the spaces is bounded by
`ε₁ + ε₂/2 + ε₃`. -/
theorem ghDist_le_of_approx_subsets {s : Set X} (Φ : s → Y) {ε₁ ε₂ ε₃ : ℝ}
(hs : ∀ x : X, ∃ y ∈ s, dist x y ≤ ε₁) (hs' : ∀ x : Y, ∃ y : s, dist x (Φ y) ≤ ε₃)
(H : ∀ x y : s, |dist x y - dist (Φ x) (Φ y)| ≤ ε₂) : ghDist X Y ≤ ε₁ + ε₂ / 2 + ε₃ := by
refine le_of_forall_pos_le_add fun δ δ0 => ?_
rcases exists_mem_of_nonempty X with ⟨xX, _⟩
rcases hs xX with ⟨xs, hxs, Dxs⟩
have sne : s.Nonempty := ⟨xs, hxs⟩
letI : Nonempty s := sne.to_subtype
have : 0 ≤ ε₂ := le_trans (abs_nonneg _) (H ⟨xs, hxs⟩ ⟨xs, hxs⟩)
have : ∀ p q : s, |dist p q - dist (Φ p) (Φ q)| ≤ 2 * (ε₂ / 2 + δ) := fun p q =>
calc
|dist p q - dist (Φ p) (Φ q)| ≤ ε₂ := H p q
_ ≤ 2 * (ε₂ / 2 + δ) := by linarith
-- glue `X` and `Y` along the almost matching subsets
letI : MetricSpace (X ⊕ Y) :=
glueMetricApprox (fun x : s => (x : X)) (fun x => Φ x) (ε₂ / 2 + δ) (by linarith) this
let Fl := @Sum.inl X Y
let Fr := @Sum.inr X Y
have Il : Isometry Fl := Isometry.of_dist_eq fun x y => rfl
have Ir : Isometry Fr := Isometry.of_dist_eq fun x y => rfl
/- The proof goes as follows : the `GH_dist` is bounded by the Hausdorff distance of the images
in the coupling, which is bounded (using the triangular inequality) by the sum of the Hausdorff
distances of `X` and `s` (in the coupling or, equivalently in the original space), of `s` and
`Φ s`, and of `Φ s` and `Y` (in the coupling or, equivalently, in the original space).
The first term is bounded by `ε₁`, by `ε₁`-density. The third one is bounded by `ε₃`.
And the middle one is bounded by `ε₂/2` as in the coupling the points `x` and `Φ x` are
at distance `ε₂/2` by construction of the coupling (in fact `ε₂/2 + δ` where `δ` is an
arbitrarily small positive constant where positivity is used to ensure that the coupling
is really a metric space and not a premetric space on `X ⊕ Y`). -/
have : ghDist X Y ≤ hausdorffDist (range Fl) (range Fr) := ghDist_le_hausdorffDist Il Ir
have :
hausdorffDist (range Fl) (range Fr) ≤
hausdorffDist (range Fl) (Fl '' s) + hausdorffDist (Fl '' s) (range Fr) :=
have B : IsBounded (range Fl) := (isCompact_range Il.continuous).isBounded
hausdorffDist_triangle
(hausdorffEdist_ne_top_of_nonempty_of_bounded (range_nonempty _) (sne.image _) B
(B.subset (image_subset_range _ _)))
have :
hausdorffDist (Fl '' s) (range Fr) ≤
hausdorffDist (Fl '' s) (Fr '' range Φ) + hausdorffDist (Fr '' range Φ) (range Fr) :=
have B : IsBounded (range Fr) := (isCompact_range Ir.continuous).isBounded
hausdorffDist_triangle'
(hausdorffEdist_ne_top_of_nonempty_of_bounded ((range_nonempty _).image _) (range_nonempty _)
(B.subset (image_subset_range _ _)) B)
have : hausdorffDist (range Fl) (Fl '' s) ≤ ε₁ := by
rw [← image_univ, hausdorffDist_image Il]
have : 0 ≤ ε₁ := le_trans dist_nonneg Dxs
refine hausdorffDist_le_of_mem_dist this (fun x _ => hs x) fun x _ =>
⟨x, mem_univ _, by simpa only [dist_self]⟩
have : hausdorffDist (Fl '' s) (Fr '' range Φ) ≤ ε₂ / 2 + δ := by
refine hausdorffDist_le_of_mem_dist (by linarith) ?_ ?_
· intro x' hx'
rcases (Set.mem_image _ _ _).1 hx' with ⟨x, ⟨x_in_s, xx'⟩⟩
rw [← xx']
use Fr (Φ ⟨x, x_in_s⟩), mem_image_of_mem Fr (mem_range_self _)
exact le_of_eq (glueDist_glued_points (fun x : s => (x : X)) Φ (ε₂ / 2 + δ) ⟨x, x_in_s⟩)
· intro x' hx'
rcases (Set.mem_image _ _ _).1 hx' with ⟨y, ⟨y_in_s', yx'⟩⟩
rcases mem_range.1 y_in_s' with ⟨x, xy⟩
use Fl x, mem_image_of_mem _ x.2
rw [← yx', ← xy, dist_comm]
exact le_of_eq (glueDist_glued_points (Z := s) (@Subtype.val X s) Φ (ε₂ / 2 + δ) x)
have : hausdorffDist (Fr '' range Φ) (range Fr) ≤ ε₃ := by
rw [← @image_univ _ _ Fr, hausdorffDist_image Ir]
rcases exists_mem_of_nonempty Y with ⟨xY, _⟩
rcases hs' xY with ⟨xs', Dxs'⟩
have : 0 ≤ ε₃ := le_trans dist_nonneg Dxs'
refine hausdorffDist_le_of_mem_dist this
(fun x _ => ⟨x, mem_univ _, by simpa only [dist_self]⟩)
fun x _ => ?_
rcases hs' x with ⟨y, Dy⟩
exact ⟨Φ y, mem_range_self _, Dy⟩
linarith
end
--section
/-- The Gromov-Hausdorff space is second countable. -/
instance : SecondCountableTopology GHSpace := by
refine secondCountable_of_countable_discretization fun δ δpos => ?_
let ε := 2 / 5 * δ
have εpos : 0 < ε := mul_pos (by norm_num) δpos
have : ∀ p : GHSpace, ∃ s : Set p.Rep, s.Finite ∧ univ ⊆ ⋃ x ∈ s, ball x ε := fun p => by
simpa only [subset_univ, true_and] using
finite_cover_balls_of_compact (α := p.Rep) isCompact_univ εpos
-- for each `p`, `s p` is a finite `ε`-dense subset of `p` (or rather the metric space
-- `p.rep` representing `p`)
choose s hs using this
have : ∀ p : GHSpace, ∀ t : Set p.Rep, t.Finite → ∃ n : ℕ, ∃ _ : Equiv t (Fin n), True := by
intro p t ht
letI : Fintype t := Finite.fintype ht
exact ⟨Fintype.card t, Fintype.equivFin t, trivial⟩
choose N e _ using this
-- cardinality of the nice finite subset `s p` of `p.rep`, called `N p`
let N := fun p : GHSpace => N p (s p) (hs p).1
-- equiv from `s p`, a nice finite subset of `p.rep`, to `Fin (N p)`, called `E p`
let E := fun p : GHSpace => e p (s p) (hs p).1
-- A function `F` associating to `p : GHSpace` the data of all distances between points
-- in the `ε`-dense set `s p`.
let F : GHSpace → Σ n : ℕ, Fin n → Fin n → ℤ := fun p =>
⟨N p, fun a b => ⌊ε⁻¹ * dist ((E p).symm a) ((E p).symm b)⌋⟩
refine ⟨Σ n, Fin n → Fin n → ℤ, by infer_instance, F, fun p q hpq => ?_⟩
/- As the target space of F is countable, it suffices to show that two points
`p` and `q` with `F p = F q` are at distance `≤ δ`.
For this, we construct a map `Φ` from `s p ⊆ p.rep` (representing `p`)
to `q.rep` (representing `q`) which is almost an isometry on `s p`, and
with image `s q`. For this, we compose the identification of `s p` with `Fin (N p)`
and the inverse of the identification of `s q` with `Fin (N q)`. Together with
the fact that `N p = N q`, this constructs `Ψ` between `s p` and `s q`, and then
composing with the canonical inclusion we get `Φ`. -/
have Npq : N p = N q := (Sigma.mk.inj_iff.1 hpq).1
let Ψ : s p → s q := fun x => (E q).symm (Fin.cast Npq ((E p) x))
let Φ : s p → q.Rep := fun x => Ψ x
-- Use the almost isometry `Φ` to show that `p.rep` and `q.rep`
-- are within controlled Gromov-Hausdorff distance.
have main : ghDist p.Rep q.Rep ≤ ε + ε / 2 + ε := by
refine ghDist_le_of_approx_subsets Φ ?_ ?_ ?_
· show ∀ x : p.Rep, ∃ y ∈ s p, dist x y ≤ ε
-- by construction, `s p` is `ε`-dense
intro x
have : x ∈ ⋃ y ∈ s p, ball y ε := (hs p).2 (mem_univ _)
rcases mem_iUnion₂.1 this with ⟨y, ys, hy⟩
exact ⟨y, ys, le_of_lt hy⟩
· show ∀ x : q.Rep, ∃ z : s p, dist x (Φ z) ≤ ε
-- by construction, `s q` is `ε`-dense, and it is the range of `Φ`
intro x
have : x ∈ ⋃ y ∈ s q, ball y ε := (hs q).2 (mem_univ _)
rcases mem_iUnion₂.1 this with ⟨y, ys, hy⟩
let i : ℕ := E q ⟨y, ys⟩
let hi := ((E q) ⟨y, ys⟩).is_lt
have ihi_eq : (⟨i, hi⟩ : Fin (N q)) = (E q) ⟨y, ys⟩ := by rw [Fin.ext_iff, Fin.val_mk]
have hiq : i < N q := hi
have hip : i < N p := by rwa [Npq.symm] at hiq
let z := (E p).symm ⟨i, hip⟩
use z
have C1 : (E p) z = ⟨i, hip⟩ := (E p).apply_symm_apply ⟨i, hip⟩
have C2 : Fin.cast Npq ⟨i, hip⟩ = ⟨i, hi⟩ := rfl
have C3 : (E q).symm ⟨i, hi⟩ = ⟨y, ys⟩ := by
rw [ihi_eq]; exact (E q).symm_apply_apply ⟨y, ys⟩
have : Φ z = y := by simp only [Φ, Ψ]; rw [C1, C2, C3]
rw [this]
exact le_of_lt hy
· show ∀ x y : s p, |dist x y - dist (Φ x) (Φ y)| ≤ ε
/- the distance between `x` and `y` is encoded in `F p`, and the distance between
`Φ x` and `Φ y` (two points of `s q`) is encoded in `F q`, all this up to `ε`.
As `F p = F q`, the distances are almost equal. -/
-- Porting note: we have to circumvent the absence of `change … with … `
intro x y
-- have : dist (Φ x) (Φ y) = dist (Ψ x) (Ψ y) := rfl
rw [show dist (Φ x) (Φ y) = dist (Ψ x) (Ψ y) from rfl]
-- introduce `i`, that codes both `x` and `Φ x` in `Fin (N p) = Fin (N q)`
let i : ℕ := E p x
have hip : i < N p := ((E p) x).2
have hiq : i < N q := by rwa [Npq] at hip
have i' : i = (E q) (Ψ x) := by simp only [Ψ, Equiv.apply_symm_apply, Fin.coe_cast]
-- introduce `j`, that codes both `y` and `Φ y` in `Fin (N p) = Fin (N q)`
let j : ℕ := E p y
have hjp : j < N p := ((E p) y).2
have hjq : j < N q := by rwa [Npq] at hjp
have j' : j = ((E q) (Ψ y)).1 := by
simp only [Ψ, Equiv.apply_symm_apply, Fin.coe_cast]
-- Express `dist x y` in terms of `F p`
have : (F p).2 ((E p) x) ((E p) y) = ⌊ε⁻¹ * dist x y⌋ := by
simp only [(E p).symm_apply_apply]
have Ap : (F p).2 ⟨i, hip⟩ ⟨j, hjp⟩ = ⌊ε⁻¹ * dist x y⌋ := by rw [← this]
-- Express `dist (Φ x) (Φ y)` in terms of `F q`
have : (F q).2 ((E q) (Ψ x)) ((E q) (Ψ y)) = ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋ := by
simp only [(E q).symm_apply_apply]
have Aq : (F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩ = ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋ := by
rw [← this]
-- Porting note: `congr` fails to make progress
refine congr_arg₂ (F q).2 ?_ ?_ <;> ext1
exacts [i', j']
-- use the equality between `F p` and `F q` to deduce that the distances have equal
-- integer parts
have : (F p).2 ⟨i, hip⟩ ⟨j, hjp⟩ = (F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩ := by
have hpq' : HEq (F p).snd (F q).snd := (Sigma.mk.inj_iff.1 hpq).2
rw [Fin.heq_fun₂_iff Npq Npq] at hpq'
rw [← hpq']
-- Porting note: new version above, because `change … with…` is not implemented
-- we want to `subst hpq` where `hpq : F p = F q`, except that `subst` only works
-- with a constant, so replace `F q` (and everything that depends on it) by a constant `f`
-- then `subst`
-- revert hiq hjq
-- change N q with (F q).1
-- generalize F q = f at hpq ⊢
-- subst hpq
-- rfl
rw [Ap, Aq] at this
-- deduce that the distances coincide up to `ε`, by a straightforward computation
-- that should be automated
have I :=
calc
|ε⁻¹| * |dist x y - dist (Ψ x) (Ψ y)| = |ε⁻¹ * (dist x y - dist (Ψ x) (Ψ y))| :=
(abs_mul _ _).symm
_ = |ε⁻¹ * dist x y - ε⁻¹ * dist (Ψ x) (Ψ y)| := by congr; ring
_ ≤ 1 := le_of_lt (abs_sub_lt_one_of_floor_eq_floor this)
calc
|dist x y - dist (Ψ x) (Ψ y)| = ε * ε⁻¹ * |dist x y - dist (Ψ x) (Ψ y)| := by
rw [mul_inv_cancel (ne_of_gt εpos), one_mul]
_ = ε * (|ε⁻¹| * |dist x y - dist (Ψ x) (Ψ y)|) := by
rw [abs_of_nonneg (le_of_lt (inv_pos.2 εpos)), mul_assoc]
_ ≤ ε * 1 := mul_le_mul_of_nonneg_left I (le_of_lt εpos)
_ = ε := mul_one _
calc
dist p q = ghDist p.Rep q.Rep := dist_ghDist p q
_ ≤ ε + ε / 2 + ε := main
_ = δ := by ring
/-- Compactness criterion: a closed set of compact metric spaces is compact if the spaces have
a uniformly bounded diameter, and for all `ε` the number of balls of radius `ε` required
to cover the spaces is uniformly bounded. This is an equivalence, but we only prove the
interesting direction that these conditions imply compactness. -/
theorem totallyBounded {t : Set GHSpace} {C : ℝ} {u : ℕ → ℝ} {K : ℕ → ℕ}
(ulim : Tendsto u atTop (𝓝 0)) (hdiam : ∀ p ∈ t, diam (univ : Set (GHSpace.Rep p)) ≤ C)
(hcov : ∀ p ∈ t, ∀ n : ℕ, ∃ s : Set (GHSpace.Rep p),
(#s) ≤ K n ∧ univ ⊆ ⋃ x ∈ s, ball x (u n)) :
TotallyBounded t := by
/- Let `δ>0`, and `ε = δ/5`. For each `p`, we construct a finite subset `s p` of `p`, which
is `ε`-dense and has cardinality at most `K n`. Encoding the mutual distances of points
in `s p`, up to `ε`, we will get a map `F` associating to `p` finitely many data, and making
it possible to reconstruct `p` up to `ε`. This is enough to prove total boundedness. -/
refine Metric.totallyBounded_of_finite_discretization fun δ δpos => ?_
let ε := 1 / 5 * δ
have εpos : 0 < ε := mul_pos (by norm_num) δpos
-- choose `n` for which `u n < ε`
rcases Metric.tendsto_atTop.1 ulim ε εpos with ⟨n, hn⟩
have u_le_ε : u n ≤ ε := by
have := hn n le_rfl
simp only [Real.dist_eq, add_zero, sub_eq_add_neg, neg_zero] at this
exact le_of_lt (lt_of_le_of_lt (le_abs_self _) this)
-- construct a finite subset `s p` of `p` which is `ε`-dense and has cardinal `≤ K n`
have :
∀ p : GHSpace,
∃ s : Set p.Rep, ∃ N ≤ K n, ∃ _ : Equiv s (Fin N), p ∈ t → univ ⊆ ⋃ x ∈ s, ball x (u n) := by
intro p
by_cases hp : p ∉ t
· have : Nonempty (Equiv (∅ : Set p.Rep) (Fin 0)) := by
rw [← Fintype.card_eq]
simp only [empty_card', Fintype.card_fin]
use ∅, 0, bot_le, this.some
-- Porting note: unclear why this next line wasn't needed in Lean 3
exact fun hp' => (hp hp').elim
· rcases hcov _ (Set.not_not_mem.1 hp) n with ⟨s, ⟨scard, scover⟩⟩
rcases Cardinal.lt_aleph0.1 (lt_of_le_of_lt scard (Cardinal.nat_lt_aleph0 _)) with ⟨N, hN⟩
rw [hN, Cardinal.natCast_le] at scard
have : #s = #(Fin N) := by rw [hN, Cardinal.mk_fin]
cases' Quotient.exact this with E
use s, N, scard, E
simp only [scover, imp_true_iff]
choose s N hN E hs using this
-- Define a function `F` taking values in a finite type and associating to `p` enough data
-- to reconstruct it up to `ε`, namely the (discretized) distances between elements of `s p`.
let M := ⌊ε⁻¹ * max C 0⌋₊
let F : GHSpace → Σ k : Fin (K n).succ, Fin k → Fin k → Fin M.succ := fun p =>
⟨⟨N p, lt_of_le_of_lt (hN p) (Nat.lt_succ_self _)⟩, fun a b =>
⟨min M ⌊ε⁻¹ * dist ((E p).symm a) ((E p).symm b)⌋₊,
(min_le_left _ _).trans_lt (Nat.lt_succ_self _)⟩⟩
refine ⟨_, ?_, fun p => F p, ?_⟩
· infer_instance
-- It remains to show that if `F p = F q`, then `p` and `q` are `ε`-close
rintro ⟨p, pt⟩ ⟨q, qt⟩ hpq
have Npq : N p = N q := Fin.ext_iff.1 (Sigma.mk.inj_iff.1 hpq).1
let Ψ : s p → s q := fun x => (E q).symm (Fin.cast Npq ((E p) x))
let Φ : s p → q.Rep := fun x => Ψ x
have main : ghDist p.Rep q.Rep ≤ ε + ε / 2 + ε := by
-- to prove the main inequality, argue that `s p` is `ε`-dense in `p`, and `s q` is `ε`-dense
-- in `q`, and `s p` and `s q` are almost isometric. Then closeness follows
-- from `ghDist_le_of_approx_subsets`
refine ghDist_le_of_approx_subsets Φ ?_ ?_ ?_
· show ∀ x : p.Rep, ∃ y ∈ s p, dist x y ≤ ε
-- by construction, `s p` is `ε`-dense
intro x
have : x ∈ ⋃ y ∈ s p, ball y (u n) := (hs p pt) (mem_univ _)
rcases mem_iUnion₂.1 this with ⟨y, ys, hy⟩
exact ⟨y, ys, le_trans (le_of_lt hy) u_le_ε⟩
· show ∀ x : q.Rep, ∃ z : s p, dist x (Φ z) ≤ ε
-- by construction, `s q` is `ε`-dense, and it is the range of `Φ`
intro x
have : x ∈ ⋃ y ∈ s q, ball y (u n) := (hs q qt) (mem_univ _)
rcases mem_iUnion₂.1 this with ⟨y, ys, hy⟩
let i : ℕ := E q ⟨y, ys⟩
let hi := ((E q) ⟨y, ys⟩).2
have ihi_eq : (⟨i, hi⟩ : Fin (N q)) = (E q) ⟨y, ys⟩ := by rw [Fin.ext_iff, Fin.val_mk]
have hiq : i < N q := hi
have hip : i < N p := by rwa [Npq.symm] at hiq
let z := (E p).symm ⟨i, hip⟩
use z
have C1 : (E p) z = ⟨i, hip⟩ := (E p).apply_symm_apply ⟨i, hip⟩
have C2 : Fin.cast Npq ⟨i, hip⟩ = ⟨i, hi⟩ := rfl
have C3 : (E q).symm ⟨i, hi⟩ = ⟨y, ys⟩ := by
rw [ihi_eq]; exact (E q).symm_apply_apply ⟨y, ys⟩
have : Φ z = y := by simp only [Ψ, Φ]; rw [C1, C2, C3]
rw [this]
exact le_trans (le_of_lt hy) u_le_ε
· show ∀ x y : s p, |dist x y - dist (Φ x) (Φ y)| ≤ ε
/- the distance between `x` and `y` is encoded in `F p`, and the distance between
`Φ x` and `Φ y` (two points of `s q`) is encoded in `F q`, all this up to `ε`.
As `F p = F q`, the distances are almost equal. -/
intro x y
have : dist (Φ x) (Φ y) = dist (Ψ x) (Ψ y) := rfl
rw [this]
-- introduce `i`, that codes both `x` and `Φ x` in `Fin (N p) = Fin (N q)`
let i : ℕ := E p x
have hip : i < N p := ((E p) x).2
have hiq : i < N q := by rwa [Npq] at hip
have i' : i = (E q) (Ψ x) := by simp only [Ψ, Equiv.apply_symm_apply, Fin.coe_cast]
-- introduce `j`, that codes both `y` and `Φ y` in `Fin (N p) = Fin (N q)`
let j : ℕ := E p y
have hjp : j < N p := ((E p) y).2
have hjq : j < N q := by rwa [Npq] at hjp
have j' : j = (E q) (Ψ y) := by simp only [Ψ, Equiv.apply_symm_apply, Fin.coe_cast]
-- Express `dist x y` in terms of `F p`
have Ap : ((F p).2 ⟨i, hip⟩ ⟨j, hjp⟩).1 = ⌊ε⁻¹ * dist x y⌋₊ :=
calc
((F p).2 ⟨i, hip⟩ ⟨j, hjp⟩).1 = ((F p).2 ((E p) x) ((E p) y)).1 := by
congr
_ = min M ⌊ε⁻¹ * dist x y⌋₊ := by simp only [(E p).symm_apply_apply]
_ = ⌊ε⁻¹ * dist x y⌋₊ := by
refine min_eq_right (Nat.floor_mono ?_)
refine mul_le_mul_of_nonneg_left (le_trans ?_ (le_max_left _ _)) (inv_pos.2 εpos).le
change dist (x : p.Rep) y ≤ C
refine (dist_le_diam_of_mem isCompact_univ.isBounded (mem_univ _) (mem_univ _)).trans ?_
exact hdiam p pt
-- Express `dist (Φ x) (Φ y)` in terms of `F q`
have Aq : ((F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩).1 = ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋₊ :=
calc
((F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩).1 = ((F q).2 ((E q) (Ψ x)) ((E q) (Ψ y))).1 := by
-- Porting note: `congr` drops `Fin.val` but fails to make further progress
exact congr_arg₂ (Fin.val <| (F q).2 · ·) (Fin.ext i') (Fin.ext j')
_ = min M ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋₊ := by simp only [(E q).symm_apply_apply]
_ = ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋₊ := by
refine min_eq_right (Nat.floor_mono ?_)
refine mul_le_mul_of_nonneg_left (le_trans ?_ (le_max_left _ _)) (inv_pos.2 εpos).le
change dist (Ψ x : q.Rep) (Ψ y) ≤ C
refine (dist_le_diam_of_mem isCompact_univ.isBounded (mem_univ _) (mem_univ _)).trans ?_
exact hdiam q qt
-- use the equality between `F p` and `F q` to deduce that the distances have equal
-- integer parts
have : ((F p).2 ⟨i, hip⟩ ⟨j, hjp⟩).1 = ((F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩).1 := by
have hpq' : HEq (F p).snd (F q).snd := (Sigma.mk.inj_iff.1 hpq).2
rw [Fin.heq_fun₂_iff Npq Npq] at hpq'
rw [← hpq']
-- Porting note: new version above because `subst…` does not work
-- we want to `subst hpq` where `hpq : F p = F q`, except that `subst` only works
-- with a constant, so replace `F q` (and everything that depends on it) by a constant `f`
-- then `subst`
-- dsimp only [show N q = (F q).1 from rfl] at hiq hjq ⊢
-- generalize F q = f at hpq ⊢
-- subst hpq
-- intros
-- rfl
have : ⌊ε⁻¹ * dist x y⌋ = ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋ := by
rw [Ap, Aq] at this
have D : 0 ≤ ⌊ε⁻¹ * dist x y⌋ :=
floor_nonneg.2 (mul_nonneg (le_of_lt (inv_pos.2 εpos)) dist_nonneg)
have D' : 0 ≤ ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋ :=
floor_nonneg.2 (mul_nonneg (le_of_lt (inv_pos.2 εpos)) dist_nonneg)
rw [← Int.toNat_of_nonneg D, ← Int.toNat_of_nonneg D', Int.floor_toNat, Int.floor_toNat,
this]
-- deduce that the distances coincide up to `ε`, by a straightforward computation
-- that should be automated
have I :=
calc
|ε⁻¹| * |dist x y - dist (Ψ x) (Ψ y)| = |ε⁻¹ * (dist x y - dist (Ψ x) (Ψ y))| :=
(abs_mul _ _).symm
_ = |ε⁻¹ * dist x y - ε⁻¹ * dist (Ψ x) (Ψ y)| := by congr; ring
_ ≤ 1 := le_of_lt (abs_sub_lt_one_of_floor_eq_floor this)
calc
|dist x y - dist (Ψ x) (Ψ y)| = ε * ε⁻¹ * |dist x y - dist (Ψ x) (Ψ y)| := by
rw [mul_inv_cancel (ne_of_gt εpos), one_mul]
_ = ε * (|ε⁻¹| * |dist x y - dist (Ψ x) (Ψ y)|) := by
rw [abs_of_nonneg (le_of_lt (inv_pos.2 εpos)), mul_assoc]
_ ≤ ε * 1 := mul_le_mul_of_nonneg_left I (le_of_lt εpos)
_ = ε := mul_one _
calc
dist p q = ghDist p.Rep q.Rep := dist_ghDist p q
_ ≤ ε + ε / 2 + ε := main
_ = δ / 2 := by simp only [ε, one_div]; ring
_ < δ := half_lt_self δpos
section Complete
/- We will show that a sequence `u n` of compact metric spaces satisfying
`dist (u n) (u (n+1)) < 1/2^n` converges, which implies completeness of the Gromov-Hausdorff space.
We need to exhibit the limiting compact metric space. For this, start from
a sequence `X n` of representatives of `u n`, and glue in an optimal way `X n` to `X (n+1)`
for all `n`, in a common metric space. Formally, this is done as follows.
Start from `Y 0 = X 0`. Then, glue `X 0` to `X 1` in an optimal way, yielding a space
`Y 1` (with an embedding of `X 1`). Then, consider an optimal gluing of `X 1` and `X 2`, and
glue it to `Y 1` along their common subspace `X 1`. This gives a new space `Y 2`, with an
embedding of `X 2`. Go on, to obtain a sequence of spaces `Y n`. Let `Z0` be the inductive
limit of the `Y n`, and finally let `Z` be the completion of `Z0`.
The images `X2 n` of `X n` in `Z` are at Hausdorff distance `< 1/2^n` by construction, hence they
form a Cauchy sequence for the Hausdorff distance. By completeness (of `Z`, and therefore of its
set of nonempty compact subsets), they converge to a limit `L`. This is the nonempty
compact metric space we are looking for. -/
variable (X : ℕ → Type) [∀ n, MetricSpace (X n)] [∀ n, CompactSpace (X n)] [∀ n, Nonempty (X n)]
/-- Auxiliary structure used to glue metric spaces below, recording an isometric embedding
of a type `A` in another metric space. -/
structure AuxGluingStruct (A : Type) [MetricSpace A] : Type 1 where
Space : Type
metric : MetricSpace Space
embed : A → Space
isom : Isometry embed
attribute [local instance] AuxGluingStruct.metric
instance (A : Type) [MetricSpace A] : Inhabited (AuxGluingStruct A) :=
⟨{ Space := A
metric := by infer_instance
embed := id
-- Porting note: without `by exact` there was an unsolved metavariable
isom := fun x y => by exact rfl }⟩
/-- Auxiliary sequence of metric spaces, containing copies of `X 0`, ..., `X n`, where each
`X i` is glued to `X (i+1)` in an optimal way. The space at step `n+1` is obtained from the space
at step `n` by adding `X (n+1)`, glued in an optimal way to the `X n` already sitting there. -/
def auxGluing (n : ℕ) : AuxGluingStruct (X n) :=
Nat.recOn n default fun n Y =>
{ Space := GlueSpace Y.isom (isometry_optimalGHInjl (X n) (X (n + 1)))
metric := by infer_instance
embed :=
toGlueR Y.isom (isometry_optimalGHInjl (X n) (X (n + 1))) ∘ optimalGHInjr (X n) (X (n + 1))
isom := (toGlueR_isometry _ _).comp (isometry_optimalGHInjr (X n) (X (n + 1))) }
/-- The Gromov-Hausdorff space is complete. -/
instance : CompleteSpace GHSpace := by
set d := fun n : ℕ ↦ ((1 : ℝ) / 2) ^ n
have : ∀ n : ℕ, 0 < d n := fun _ ↦ by positivity
-- start from a sequence of nonempty compact metric spaces within distance `1/2^n` of each other
refine Metric.complete_of_convergent_controlled_sequences d this fun u hu => ?_
-- `X n` is a representative of `u n`
let X n := (u n).Rep
-- glue them together successively in an optimal way, getting a sequence of metric spaces `Y n`
let Y := auxGluing X
-- this equality is true by definition but Lean unfolds some defs in the wrong order
have E :
∀ n : ℕ,
GlueSpace (Y n).isom (isometry_optimalGHInjl (X n) (X (n + 1))) = (Y (n + 1)).Space :=
fun n => by dsimp only [Y, auxGluing]
let c n := cast (E n)
have ic : ∀ n, Isometry (c n) := fun n x y => by dsimp only [Y, auxGluing]; exact rfl
-- there is a canonical embedding of `Y n` in `Y (n+1)`, by construction
let f : ∀ n, (Y n).Space → (Y (n + 1)).Space := fun n =>
c n ∘ toGlueL (Y n).isom (isometry_optimalGHInjl (X n) (X n.succ))
have I : ∀ n, Isometry (f n) := fun n => (ic n).comp (toGlueL_isometry _ _)
-- consider the inductive limit `Z0` of the `Y n`, and then its completion `Z`
let Z0 := Metric.InductiveLimit I
let Z := UniformSpace.Completion Z0
let Φ := toInductiveLimit I
let coeZ := ((↑) : Z0 → Z)
-- let `X2 n` be the image of `X n` in the space `Z`
let X2 n := range (coeZ ∘ Φ n ∘ (Y n).embed)
have isom : ∀ n, Isometry (coeZ ∘ Φ n ∘ (Y n).embed) := by
intro n
refine UniformSpace.Completion.coe_isometry.comp ?_
exact (toInductiveLimit_isometry _ _).comp (Y n).isom
-- The Hausdorff distance of `X2 n` and `X2 (n+1)` is by construction the distance between
-- `u n` and `u (n+1)`, therefore bounded by `1/2^n`
have X2n : ∀ n, X2 n =
range ((coeZ ∘ Φ n.succ ∘ c n ∘ toGlueR (Y n).isom
(isometry_optimalGHInjl (X n) (X n.succ))) ∘ optimalGHInjl (X n) (X n.succ)) := by
intro n
change X2 n = range (coeZ ∘ Φ n.succ ∘ c n ∘
toGlueR (Y n).isom (isometry_optimalGHInjl (X n) (X n.succ)) ∘
optimalGHInjl (X n) (X n.succ))
simp only [X2, Φ]
rw [← toInductiveLimit_commute I]
simp only [f]
rw [← toGlue_commute]
rfl
-- simp_rw [range_comp] at X2n
have X2nsucc : ∀ n, X2 n.succ =
range ((coeZ ∘ Φ n.succ ∘ c n ∘ toGlueR (Y n).isom
(isometry_optimalGHInjl (X n) (X n.succ))) ∘ optimalGHInjr (X n) (X n.succ)) := by
intro n
rfl
-- simp_rw [range_comp] at X2nsucc
have D2 : ∀ n, hausdorffDist (X2 n) (X2 n.succ) < d n := fun n ↦ by
rw [X2n n, X2nsucc n, range_comp, range_comp, hausdorffDist_image,
hausdorffDist_optimal, ← dist_ghDist]
· exact hu n n n.succ (le_refl n) (le_succ n)
· apply UniformSpace.Completion.coe_isometry.comp _
exact (toInductiveLimit_isometry _ _).comp ((ic n).comp (toGlueR_isometry _ _))
-- consider `X2 n` as a member `X3 n` of the type of nonempty compact subsets of `Z`, which
-- is a metric space
let X3 : ℕ → NonemptyCompacts Z := fun n =>
⟨⟨X2 n, isCompact_range (isom n).continuous⟩, range_nonempty _⟩
-- `X3 n` is a Cauchy sequence by construction, as the successive distances are
-- bounded by `(1/2)^n`
have : CauchySeq X3 := by
refine cauchySeq_of_le_geometric (1 / 2) 1 (by norm_num) fun n => ?_
rw [one_mul]
exact le_of_lt (D2 n)
-- therefore, it converges to a limit `L`
rcases cauchySeq_tendsto_of_complete this with ⟨L, hL⟩
-- By construction, the image of `X3 n` in the Gromov-Hausdorff space is `u n`.
have : ∀ n, (NonemptyCompacts.toGHSpace ∘ X3) n = u n := by
intro n
rw [Function.comp_apply, NonemptyCompacts.toGHSpace, ← (u n).toGHSpace_rep,
toGHSpace_eq_toGHSpace_iff_isometryEquiv]
constructor
convert (isom n).isometryEquivOnRange.symm
-- the images of `X3 n` in the Gromov-Hausdorff space converge to the image of `L`
-- so the images of `u n` converge to the image of `L` as well
use L.toGHSpace
apply Filter.Tendsto.congr this
refine Tendsto.comp ?_ hL
apply toGHSpace_continuous.tendsto
end Complete
--section
end GromovHausdorff
--namespace
|
Topology\MetricSpace\GromovHausdorffRealized.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.MetricSpace.Gluing
import Mathlib.Topology.MetricSpace.HausdorffDistance
import Mathlib.Topology.ContinuousFunction.Bounded
/-!
# The Gromov-Hausdorff distance is realized
In this file, we construct of a good coupling between nonempty compact metric spaces, minimizing
their Hausdorff distance. This construction is instrumental to study the Gromov-Hausdorff
distance between nonempty compact metric spaces.
Given two nonempty compact metric spaces `X` and `Y`, we define `OptimalGHCoupling X Y` as a
compact metric space, together with two isometric embeddings `optimalGHInjl` and `optimalGHInjr`
respectively of `X` and `Y` into `OptimalGHCoupling X Y`. The main property of the optimal
coupling is that the Hausdorff distance between `X` and `Y` in `OptimalGHCoupling X Y` is smaller
than the corresponding distance in any other coupling. We do not prove completely this fact in this
file, but we show a good enough approximation of this fact in `hausdorffDist_optimal_le_HD`, that
will suffice to obtain the full statement once the Gromov-Hausdorff distance is properly defined,
in `hausdorffDist_optimal`.
The key point in the construction is that the set of possible distances coming from isometric
embeddings of `X` and `Y` in metric spaces is a set of equicontinuous functions. By Arzela-Ascoli,
it is compact, and one can find such a distance which is minimal. This distance defines a premetric
space structure on `X ⊕ Y`. The corresponding metric quotient is `OptimalGHCoupling X Y`.
-/
noncomputable section
universe u v w
open Topology NNReal Set Function TopologicalSpace Filter Metric Quotient BoundedContinuousFunction
open Sum (inl inr)
attribute [local instance] metricSpaceSum
namespace GromovHausdorff
section GromovHausdorffRealized
/-! This section shows that the Gromov-Hausdorff distance
is realized. For this, we consider candidate distances on the disjoint union
`X ⊕ Y` of two compact nonempty metric spaces, almost realizing the Gromov-Hausdorff
distance, and show that they form a compact family by applying Arzela-Ascoli
theorem. The existence of a minimizer follows. -/
section Definitions
variable (X : Type u) (Y : Type v) [MetricSpace X] [CompactSpace X] [Nonempty X] [MetricSpace Y]
[CompactSpace Y] [Nonempty Y]
private abbrev ProdSpaceFun : Type _ :=
(X ⊕ Y) × (X ⊕ Y) → ℝ
private abbrev Cb : Type _ :=
BoundedContinuousFunction ((X ⊕ Y) × (X ⊕ Y)) ℝ
private def maxVar : ℝ≥0 :=
2 * ⟨diam (univ : Set X), diam_nonneg⟩ + 1 + 2 * ⟨diam (univ : Set Y), diam_nonneg⟩
private theorem one_le_maxVar : 1 ≤ maxVar X Y :=
calc
(1 : Real) = 2 * 0 + 1 + 2 * 0 := by simp
_ ≤ 2 * diam (univ : Set X) + 1 + 2 * diam (univ : Set Y) := by gcongr <;> positivity
/-- The set of functions on `X ⊕ Y` that are candidates distances to realize the
minimum of the Hausdorff distances between `X` and `Y` in a coupling. -/
def candidates : Set (ProdSpaceFun X Y) :=
{ f | (((((∀ x y : X, f (Sum.inl x, Sum.inl y) = dist x y) ∧
∀ x y : Y, f (Sum.inr x, Sum.inr y) = dist x y) ∧
∀ x y, f (x, y) = f (y, x)) ∧
∀ x y z, f (x, z) ≤ f (x, y) + f (y, z)) ∧
∀ x, f (x, x) = 0) ∧
∀ x y, f (x, y) ≤ maxVar X Y }
/-- Version of the set of candidates in bounded_continuous_functions, to apply Arzela-Ascoli. -/
private def candidatesB : Set (Cb X Y) :=
{ f : Cb X Y | (f : _ → ℝ) ∈ candidates X Y }
end Definitions
section Constructions
variable {X : Type u} {Y : Type v} [MetricSpace X] [CompactSpace X] [Nonempty X] [MetricSpace Y]
[CompactSpace Y] [Nonempty Y] {f : ProdSpaceFun X Y} {x y z t : X ⊕ Y}
attribute [local instance 10] Classical.inhabited_of_nonempty'
private theorem maxVar_bound : dist x y ≤ maxVar X Y :=
calc
dist x y ≤ diam (univ : Set (X ⊕ Y)) :=
dist_le_diam_of_mem isBounded_of_compactSpace (mem_univ _) (mem_univ _)
_ = diam (range inl ∪ range inr : Set (X ⊕ Y)) := by rw [range_inl_union_range_inr]
_ ≤ diam (range inl : Set (X ⊕ Y)) + dist (inl default) (inr default) +
diam (range inr : Set (X ⊕ Y)) :=
(diam_union (mem_range_self _) (mem_range_self _))
_ = diam (univ : Set X) + (dist default default + 1 + dist default default) +
diam (univ : Set Y) := by
rw [isometry_inl.diam_range, isometry_inr.diam_range]
rfl
_ = 1 * diam (univ : Set X) + 1 + 1 * diam (univ : Set Y) := by simp
_ ≤ 2 * diam (univ : Set X) + 1 + 2 * diam (univ : Set Y) := by gcongr <;> norm_num
private theorem candidates_symm (fA : f ∈ candidates X Y) : f (x, y) = f (y, x) :=
fA.1.1.1.2 x y
private theorem candidates_triangle (fA : f ∈ candidates X Y) : f (x, z) ≤ f (x, y) + f (y, z) :=
fA.1.1.2 x y z
private theorem candidates_refl (fA : f ∈ candidates X Y) : f (x, x) = 0 :=
fA.1.2 x
private theorem candidates_nonneg (fA : f ∈ candidates X Y) : 0 ≤ f (x, y) := by
have : 0 ≤ 2 * f (x, y) :=
calc
0 = f (x, x) := (candidates_refl fA).symm
_ ≤ f (x, y) + f (y, x) := candidates_triangle fA
_ = f (x, y) + f (x, y) := by rw [candidates_symm fA]
_ = 2 * f (x, y) := by ring
linarith
private theorem candidates_dist_inl (fA : f ∈ candidates X Y) (x y : X) :
f (inl x, inl y) = dist x y :=
fA.1.1.1.1.1 x y
private theorem candidates_dist_inr (fA : f ∈ candidates X Y) (x y : Y) :
f (inr x, inr y) = dist x y :=
fA.1.1.1.1.2 x y
private theorem candidates_le_maxVar (fA : f ∈ candidates X Y) : f (x, y) ≤ maxVar X Y :=
fA.2 x y
/-- candidates are bounded by `maxVar X Y` -/
private theorem candidates_dist_bound (fA : f ∈ candidates X Y) :
∀ {x y : X ⊕ Y}, f (x, y) ≤ maxVar X Y * dist x y
| inl x, inl y =>
calc
f (inl x, inl y) = dist x y := candidates_dist_inl fA x y
_ = dist (inl x) (inl y) := by
rw [@Sum.dist_eq X Y]
rfl
_ = 1 * dist (inl x) (inl y) := by ring
_ ≤ maxVar X Y * dist (inl x) (inl y) := by gcongr; exact one_le_maxVar X Y
| inl x, inr y =>
calc
f (inl x, inr y) ≤ maxVar X Y := candidates_le_maxVar fA
_ = maxVar X Y * 1 := by simp
_ ≤ maxVar X Y * dist (inl x) (inr y) := by gcongr; apply Sum.one_le_dist_inl_inr
| inr x, inl y =>
calc
f (inr x, inl y) ≤ maxVar X Y := candidates_le_maxVar fA
_ = maxVar X Y * 1 := by simp
_ ≤ maxVar X Y * dist (inl x) (inr y) := by gcongr; apply Sum.one_le_dist_inl_inr
| inr x, inr y =>
calc
f (inr x, inr y) = dist x y := candidates_dist_inr fA x y
_ = dist (inr x) (inr y) := by
rw [@Sum.dist_eq X Y]
rfl
_ = 1 * dist (inr x) (inr y) := by ring
_ ≤ maxVar X Y * dist (inr x) (inr y) := by gcongr; exact one_le_maxVar X Y
/-- Technical lemma to prove that candidates are Lipschitz -/
private theorem candidates_lipschitz_aux (fA : f ∈ candidates X Y) :
f (x, y) - f (z, t) ≤ 2 * maxVar X Y * dist (x, y) (z, t) :=
calc
f (x, y) - f (z, t) ≤ f (x, t) + f (t, y) - f (z, t) := by gcongr; exact candidates_triangle fA
_ ≤ f (x, z) + f (z, t) + f (t, y) - f (z, t) := by gcongr; exact candidates_triangle fA
_ = f (x, z) + f (t, y) := by simp [sub_eq_add_neg, add_assoc]
_ ≤ maxVar X Y * dist x z + maxVar X Y * dist t y := by
gcongr <;> apply candidates_dist_bound fA
_ ≤ maxVar X Y * max (dist x z) (dist t y) + maxVar X Y * max (dist x z) (dist t y) := by
gcongr
· apply le_max_left
· apply le_max_right
_ = 2 * maxVar X Y * max (dist x z) (dist y t) := by
rw [dist_comm t y]
ring
_ = 2 * maxVar X Y * dist (x, y) (z, t) := rfl
/-- Candidates are Lipschitz -/
private theorem candidates_lipschitz (fA : f ∈ candidates X Y) :
LipschitzWith (2 * maxVar X Y) f := by
apply LipschitzWith.of_dist_le_mul
rintro ⟨x, y⟩ ⟨z, t⟩
rw [Real.dist_eq, abs_sub_le_iff]
use candidates_lipschitz_aux fA
rw [dist_comm]
exact candidates_lipschitz_aux fA
/-- To apply Arzela-Ascoli, we need to check that the set of candidates is closed and
equicontinuous. Equicontinuity follows from the Lipschitz control, we check closedness. -/
private theorem closed_candidatesB : IsClosed (candidatesB X Y) := by
have I1 : ∀ x y, IsClosed { f : Cb X Y | f (inl x, inl y) = dist x y } := fun x y =>
isClosed_eq continuous_eval_const continuous_const
have I2 : ∀ x y, IsClosed { f : Cb X Y | f (inr x, inr y) = dist x y } := fun x y =>
isClosed_eq continuous_eval_const continuous_const
have I3 : ∀ x y, IsClosed { f : Cb X Y | f (x, y) = f (y, x) } := fun x y =>
isClosed_eq continuous_eval_const continuous_eval_const
have I4 : ∀ x y z, IsClosed { f : Cb X Y | f (x, z) ≤ f (x, y) + f (y, z) } := fun x y z =>
isClosed_le continuous_eval_const (continuous_eval_const.add continuous_eval_const)
have I5 : ∀ x, IsClosed { f : Cb X Y | f (x, x) = 0 } := fun x =>
isClosed_eq continuous_eval_const continuous_const
have I6 : ∀ x y, IsClosed { f : Cb X Y | f (x, y) ≤ maxVar X Y } := fun x y =>
isClosed_le continuous_eval_const continuous_const
have : candidatesB X Y = (((((⋂ (x) (y), { f : Cb X Y | f (@inl X Y x, @inl X Y y) = dist x y }) ∩
⋂ (x) (y), { f : Cb X Y | f (@inr X Y x, @inr X Y y) = dist x y }) ∩
⋂ (x) (y), { f : Cb X Y | f (x, y) = f (y, x) }) ∩
⋂ (x) (y) (z), { f : Cb X Y | f (x, z) ≤ f (x, y) + f (y, z) }) ∩
⋂ x, { f : Cb X Y | f (x, x) = 0 }) ∩
⋂ (x) (y), { f : Cb X Y | f (x, y) ≤ maxVar X Y } := by
ext
simp only [candidatesB, candidates, mem_inter_iff, mem_iInter, mem_setOf_eq]
rw [this]
repeat'
first
|apply IsClosed.inter _ _
|apply isClosed_iInter _
|apply I1 _ _|apply I2 _ _|apply I3 _ _|apply I4 _ _ _|apply I5 _|apply I6 _ _|intro x
/-- We will then choose the candidate minimizing the Hausdorff distance. Except that we are not
in a metric space setting, so we need to define our custom version of Hausdorff distance,
called `HD`, and prove its basic properties. -/
def HD (f : Cb X Y) :=
max (⨆ x, ⨅ y, f (inl x, inr y)) (⨆ y, ⨅ x, f (inl x, inr y))
/- We will show that `HD` is continuous on `BoundedContinuousFunction`s, to deduce that its
minimum on the compact set `candidatesB` is attained. Since it is defined in terms of
infimum and supremum on `ℝ`, which is only conditionally complete, we will need all the time
to check that the defining sets are bounded below or above. This is done in the next few
technical lemmas. -/
theorem HD_below_aux1 {f : Cb X Y} (C : ℝ) {x : X} :
BddBelow (range fun y : Y => f (inl x, inr y) + C) :=
let ⟨cf, hcf⟩ := f.isBounded_range.bddBelow
⟨cf + C, forall_mem_range.2 fun _ => add_le_add_right ((fun x => hcf (mem_range_self x)) _) _⟩
private theorem HD_bound_aux1 [Nonempty Y] (f : Cb X Y) (C : ℝ) :
BddAbove (range fun x : X => ⨅ y, f (inl x, inr y) + C) := by
obtain ⟨Cf, hCf⟩ := f.isBounded_range.bddAbove
refine ⟨Cf + C, forall_mem_range.2 fun x => ?_⟩
calc
⨅ y, f (inl x, inr y) + C ≤ f (inl x, inr default) + C := ciInf_le (HD_below_aux1 C) default
_ ≤ Cf + C := add_le_add ((fun x => hCf (mem_range_self x)) _) le_rfl
theorem HD_below_aux2 {f : Cb X Y} (C : ℝ) {y : Y} :
BddBelow (range fun x : X => f (inl x, inr y) + C) :=
let ⟨cf, hcf⟩ := f.isBounded_range.bddBelow
⟨cf + C, forall_mem_range.2 fun _ => add_le_add_right ((fun x => hcf (mem_range_self x)) _) _⟩
private theorem HD_bound_aux2 [Nonempty X] (f : Cb X Y) (C : ℝ) :
BddAbove (range fun y : Y => ⨅ x, f (inl x, inr y) + C) := by
obtain ⟨Cf, hCf⟩ := f.isBounded_range.bddAbove
refine ⟨Cf + C, forall_mem_range.2 fun y => ?_⟩
calc
⨅ x, f (inl x, inr y) + C ≤ f (inl default, inr y) + C := ciInf_le (HD_below_aux2 C) default
_ ≤ Cf + C := add_le_add ((fun x => hCf (mem_range_self x)) _) le_rfl
section Nonempty
variable [Nonempty X] [Nonempty Y]
/- To check that `HD` is continuous, we check that it is Lipschitz. As `HD` is a max, we
prove separately inequalities controlling the two terms (relying too heavily on copy-paste...) -/
private theorem HD_lipschitz_aux1 (f g : Cb X Y) :
(⨆ x, ⨅ y, f (inl x, inr y)) ≤ (⨆ x, ⨅ y, g (inl x, inr y)) + dist f g := by
obtain ⟨cg, hcg⟩ := g.isBounded_range.bddBelow
have Hcg : ∀ x, cg ≤ g x := fun x => hcg (mem_range_self x)
obtain ⟨cf, hcf⟩ := f.isBounded_range.bddBelow
have Hcf : ∀ x, cf ≤ f x := fun x => hcf (mem_range_self x)
-- prove the inequality but with `dist f g` inside, by using inequalities comparing
-- iSup to iSup and iInf to iInf
have Z : (⨆ x, ⨅ y, f (inl x, inr y)) ≤ ⨆ x, ⨅ y, g (inl x, inr y) + dist f g :=
ciSup_mono (HD_bound_aux1 _ (dist f g)) fun x =>
ciInf_mono ⟨cf, forall_mem_range.2 fun i => Hcf _⟩ fun y => coe_le_coe_add_dist
-- move the `dist f g` out of the infimum and the supremum, arguing that continuous monotone maps
-- (here the addition of `dist f g`) preserve infimum and supremum
have E1 : ∀ x, (⨅ y, g (inl x, inr y)) + dist f g = ⨅ y, g (inl x, inr y) + dist f g := by
intro x
refine Monotone.map_ciInf_of_continuousAt (continuousAt_id.add continuousAt_const) ?_ ?_
· intro x y hx
simpa
· show BddBelow (range fun y : Y => g (inl x, inr y))
exact ⟨cg, forall_mem_range.2 fun i => Hcg _⟩
have E2 : (⨆ x, ⨅ y, g (inl x, inr y)) + dist f g = ⨆ x, (⨅ y, g (inl x, inr y)) + dist f g := by
refine Monotone.map_ciSup_of_continuousAt (continuousAt_id.add continuousAt_const) ?_ ?_
· intro x y hx
simpa
· simpa using HD_bound_aux1 _ 0
-- deduce the result from the above two steps
simpa [E2, E1, Function.comp]
private theorem HD_lipschitz_aux2 (f g : Cb X Y) :
(⨆ y, ⨅ x, f (inl x, inr y)) ≤ (⨆ y, ⨅ x, g (inl x, inr y)) + dist f g := by
obtain ⟨cg, hcg⟩ := g.isBounded_range.bddBelow
have Hcg : ∀ x, cg ≤ g x := fun x => hcg (mem_range_self x)
obtain ⟨cf, hcf⟩ := f.isBounded_range.bddBelow
have Hcf : ∀ x, cf ≤ f x := fun x => hcf (mem_range_self x)
-- prove the inequality but with `dist f g` inside, by using inequalities comparing
-- iSup to iSup and iInf to iInf
have Z : (⨆ y, ⨅ x, f (inl x, inr y)) ≤ ⨆ y, ⨅ x, g (inl x, inr y) + dist f g :=
ciSup_mono (HD_bound_aux2 _ (dist f g)) fun y =>
ciInf_mono ⟨cf, forall_mem_range.2 fun i => Hcf _⟩ fun y => coe_le_coe_add_dist
-- move the `dist f g` out of the infimum and the supremum, arguing that continuous monotone maps
-- (here the addition of `dist f g`) preserve infimum and supremum
have E1 : ∀ y, (⨅ x, g (inl x, inr y)) + dist f g = ⨅ x, g (inl x, inr y) + dist f g := by
intro y
refine Monotone.map_ciInf_of_continuousAt (continuousAt_id.add continuousAt_const) ?_ ?_
· intro x y hx
simpa
· show BddBelow (range fun x : X => g (inl x, inr y))
exact ⟨cg, forall_mem_range.2 fun i => Hcg _⟩
have E2 : (⨆ y, ⨅ x, g (inl x, inr y)) + dist f g = ⨆ y, (⨅ x, g (inl x, inr y)) + dist f g := by
refine Monotone.map_ciSup_of_continuousAt (continuousAt_id.add continuousAt_const) ?_ ?_
· intro x y hx
simpa
· simpa using HD_bound_aux2 _ 0
-- deduce the result from the above two steps
simpa [E2, E1]
private theorem HD_lipschitz_aux3 (f g : Cb X Y) :
HD f ≤ HD g + dist f g :=
max_le (le_trans (HD_lipschitz_aux1 f g) (add_le_add_right (le_max_left _ _) _))
(le_trans (HD_lipschitz_aux2 f g) (add_le_add_right (le_max_right _ _) _))
/-- Conclude that `HD`, being Lipschitz, is continuous -/
private theorem HD_continuous : Continuous (HD : Cb X Y → ℝ) :=
LipschitzWith.continuous (LipschitzWith.of_le_add HD_lipschitz_aux3)
end Nonempty
variable [CompactSpace X] [CompactSpace Y]
/-- Compactness of candidates (in `BoundedContinuousFunction`s) follows. -/
private theorem isCompact_candidatesB : IsCompact (candidatesB X Y) := by
refine arzela_ascoli₂
(Icc 0 (maxVar X Y) : Set ℝ) isCompact_Icc (candidatesB X Y) closed_candidatesB ?_ ?_
· rintro f ⟨x1, x2⟩ hf
simp only [Set.mem_Icc]
exact ⟨candidates_nonneg hf, candidates_le_maxVar hf⟩
· refine equicontinuous_of_continuity_modulus (fun t => 2 * maxVar X Y * t) ?_ _ ?_
· have : Tendsto (fun t : ℝ => 2 * (maxVar X Y : ℝ) * t) (𝓝 0) (𝓝 (2 * maxVar X Y * 0)) :=
tendsto_const_nhds.mul tendsto_id
simpa using this
· rintro x y ⟨f, hf⟩
exact (candidates_lipschitz hf).dist_le_mul _ _
/-- candidates give rise to elements of `BoundedContinuousFunction`s -/
def candidatesBOfCandidates (f : ProdSpaceFun X Y) (fA : f ∈ candidates X Y) : Cb X Y :=
BoundedContinuousFunction.mkOfCompact ⟨f, (candidates_lipschitz fA).continuous⟩
theorem candidatesBOfCandidates_mem (f : ProdSpaceFun X Y) (fA : f ∈ candidates X Y) :
candidatesBOfCandidates f fA ∈ candidatesB X Y :=
fA
variable [Nonempty X] [Nonempty Y]
/-- The distance on `X ⊕ Y` is a candidate -/
private theorem dist_mem_candidates :
(fun p : (X ⊕ Y) × (X ⊕ Y) => dist p.1 p.2) ∈ candidates X Y := by
simp_rw [candidates, Set.mem_setOf_eq, dist_comm, dist_triangle, dist_self, maxVar_bound,
forall_const, and_true]
exact ⟨fun x y => rfl, fun x y => rfl⟩
/-- The distance on `X ⊕ Y` as a candidate -/
def candidatesBDist (X : Type u) (Y : Type v) [MetricSpace X] [CompactSpace X] [Nonempty X]
[MetricSpace Y] [CompactSpace Y] [Nonempty Y] : Cb X Y :=
candidatesBOfCandidates _ dist_mem_candidates
theorem candidatesBDist_mem_candidatesB :
candidatesBDist X Y ∈ candidatesB X Y :=
candidatesBOfCandidates_mem _ _
private theorem candidatesB_nonempty : (candidatesB X Y).Nonempty :=
⟨_, candidatesBDist_mem_candidatesB⟩
/-- Explicit bound on `HD (dist)`. This means that when looking for minimizers it will
be sufficient to look for functions with `HD(f)` bounded by this bound. -/
theorem HD_candidatesBDist_le :
HD (candidatesBDist X Y) ≤ diam (univ : Set X) + 1 + diam (univ : Set Y) := by
refine max_le (ciSup_le fun x => ?_) (ciSup_le fun y => ?_)
· have A : ⨅ y, candidatesBDist X Y (inl x, inr y) ≤ candidatesBDist X Y (inl x, inr default) :=
ciInf_le (by simpa using HD_below_aux1 0) default
have B : dist (inl x) (inr default) ≤ diam (univ : Set X) + 1 + diam (univ : Set Y) :=
calc
dist (inl x) (inr (default : Y)) = dist x (default : X) + 1 + dist default default := rfl
_ ≤ diam (univ : Set X) + 1 + diam (univ : Set Y) := by
gcongr <;>
exact dist_le_diam_of_mem isBounded_of_compactSpace (mem_univ _) (mem_univ _)
exact le_trans A B
· have A : ⨅ x, candidatesBDist X Y (inl x, inr y) ≤ candidatesBDist X Y (inl default, inr y) :=
ciInf_le (by simpa using HD_below_aux2 0) default
have B : dist (inl default) (inr y) ≤ diam (univ : Set X) + 1 + diam (univ : Set Y) :=
calc
dist (inl (default : X)) (inr y) = dist default default + 1 + dist default y := rfl
_ ≤ diam (univ : Set X) + 1 + diam (univ : Set Y) := by
gcongr <;>
exact dist_le_diam_of_mem isBounded_of_compactSpace (mem_univ _) (mem_univ _)
exact le_trans A B
end Constructions
section Consequences
variable (X : Type u) (Y : Type v) [MetricSpace X] [CompactSpace X] [Nonempty X] [MetricSpace Y]
[CompactSpace Y] [Nonempty Y]
/- Now that we have proved that the set of candidates is compact, and that `HD` is continuous,
we can finally select a candidate minimizing `HD`. This will be the candidate realizing the
optimal coupling. -/
private theorem exists_minimizer : ∃ f ∈ candidatesB X Y, ∀ g ∈ candidatesB X Y, HD f ≤ HD g :=
isCompact_candidatesB.exists_isMinOn candidatesB_nonempty HD_continuous.continuousOn
private def optimalGHDist : Cb X Y :=
Classical.choose (exists_minimizer X Y)
private theorem optimalGHDist_mem_candidatesB : optimalGHDist X Y ∈ candidatesB X Y := by
cases Classical.choose_spec (exists_minimizer X Y)
assumption
private theorem HD_optimalGHDist_le (g : Cb X Y) (hg : g ∈ candidatesB X Y) :
HD (optimalGHDist X Y) ≤ HD g :=
let ⟨_, Z2⟩ := Classical.choose_spec (exists_minimizer X Y)
Z2 g hg
/-- With the optimal candidate, construct a premetric space structure on `X ⊕ Y`, on which the
predistance is given by the candidate. Then, we will identify points at `0` predistance
to obtain a genuine metric space. -/
def premetricOptimalGHDist : PseudoMetricSpace (X ⊕ Y) where
dist p q := optimalGHDist X Y (p, q)
dist_self x := candidates_refl (optimalGHDist_mem_candidatesB X Y)
dist_comm x y := candidates_symm (optimalGHDist_mem_candidatesB X Y)
dist_triangle x y z := candidates_triangle (optimalGHDist_mem_candidatesB X Y)
-- Porting note (#10888): added proof for `edist_dist`
edist_dist x y := by
simp only
congr
simp only [max, left_eq_sup]
exact candidates_nonneg (optimalGHDist_mem_candidatesB X Y)
attribute [local instance] premetricOptimalGHDist
/-- A metric space which realizes the optimal coupling between `X` and `Y` -/
-- @[nolint has_nonempty_instance] -- Porting note(#5171): This linter does not exist yet.
def OptimalGHCoupling : Type _ :=
@SeparationQuotient (X ⊕ Y) (premetricOptimalGHDist X Y).toUniformSpace.toTopologicalSpace
instance : MetricSpace (OptimalGHCoupling X Y) := by
unfold OptimalGHCoupling
infer_instance
/-- Injection of `X` in the optimal coupling between `X` and `Y` -/
def optimalGHInjl (x : X) : OptimalGHCoupling X Y :=
Quotient.mk'' (inl x)
/-- The injection of `X` in the optimal coupling between `X` and `Y` is an isometry. -/
theorem isometry_optimalGHInjl : Isometry (optimalGHInjl X Y) :=
Isometry.of_dist_eq fun _ _ => candidates_dist_inl (optimalGHDist_mem_candidatesB X Y) _ _
/-- Injection of `Y` in the optimal coupling between `X` and `Y` -/
def optimalGHInjr (y : Y) : OptimalGHCoupling X Y :=
Quotient.mk'' (inr y)
/-- The injection of `Y` in the optimal coupling between `X` and `Y` is an isometry. -/
theorem isometry_optimalGHInjr : Isometry (optimalGHInjr X Y) :=
Isometry.of_dist_eq fun _ _ => candidates_dist_inr (optimalGHDist_mem_candidatesB X Y) _ _
/-- The optimal coupling between two compact spaces `X` and `Y` is still a compact space -/
instance compactSpace_optimalGHCoupling : CompactSpace (OptimalGHCoupling X Y) := ⟨by
rw [← range_quotient_mk']
exact isCompact_range (continuous_sum_dom.2
⟨(isometry_optimalGHInjl X Y).continuous, (isometry_optimalGHInjr X Y).continuous⟩)⟩
/-- For any candidate `f`, `HD(f)` is larger than or equal to the Hausdorff distance in the
optimal coupling. This follows from the fact that `HD` of the optimal candidate is exactly
the Hausdorff distance in the optimal coupling, although we only prove here the inequality
we need. -/
theorem hausdorffDist_optimal_le_HD {f} (h : f ∈ candidatesB X Y) :
hausdorffDist (range (optimalGHInjl X Y)) (range (optimalGHInjr X Y)) ≤ HD f := by
refine le_trans (le_of_forall_le_of_dense fun r hr => ?_) (HD_optimalGHDist_le X Y f h)
have A : ∀ x ∈ range (optimalGHInjl X Y), ∃ y ∈ range (optimalGHInjr X Y), dist x y ≤ r := by
rintro _ ⟨z, rfl⟩
have I1 : (⨆ x, ⨅ y, optimalGHDist X Y (inl x, inr y)) < r :=
lt_of_le_of_lt (le_max_left _ _) hr
have I2 :
⨅ y, optimalGHDist X Y (inl z, inr y) ≤ ⨆ x, ⨅ y, optimalGHDist X Y (inl x, inr y) :=
le_csSup (by simpa using HD_bound_aux1 _ 0) (mem_range_self _)
have I : ⨅ y, optimalGHDist X Y (inl z, inr y) < r := lt_of_le_of_lt I2 I1
rcases exists_lt_of_csInf_lt (range_nonempty _) I with ⟨r', ⟨z', rfl⟩, hr'⟩
exact ⟨optimalGHInjr X Y z', mem_range_self _, le_of_lt hr'⟩
refine hausdorffDist_le_of_mem_dist ?_ A ?_
· inhabit X
rcases A _ (mem_range_self default) with ⟨y, -, hy⟩
exact le_trans dist_nonneg hy
· rintro _ ⟨z, rfl⟩
have I1 : (⨆ y, ⨅ x, optimalGHDist X Y (inl x, inr y)) < r :=
lt_of_le_of_lt (le_max_right _ _) hr
have I2 :
⨅ x, optimalGHDist X Y (inl x, inr z) ≤ ⨆ y, ⨅ x, optimalGHDist X Y (inl x, inr y) :=
le_csSup (by simpa using HD_bound_aux2 _ 0) (mem_range_self _)
have I : ⨅ x, optimalGHDist X Y (inl x, inr z) < r := lt_of_le_of_lt I2 I1
rcases exists_lt_of_csInf_lt (range_nonempty _) I with ⟨r', ⟨z', rfl⟩, hr'⟩
refine ⟨optimalGHInjl X Y z', mem_range_self _, le_of_lt ?_⟩
rwa [dist_comm]
end Consequences
-- We are done with the construction of the optimal coupling
end GromovHausdorffRealized
end GromovHausdorff
|
Topology\MetricSpace\HausdorffDimension.lean | /-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Analysis.Calculus.ContDiff.RCLike
import Mathlib.MeasureTheory.Measure.Hausdorff
/-!
# Hausdorff dimension
The Hausdorff dimension of a set `X` in an (extended) metric space is the unique number
`dimH s : ℝ≥0∞` such that for any `d : ℝ≥0` we have
- `μH[d] s = 0` if `dimH s < d`, and
- `μH[d] s = ∞` if `d < dimH s`.
In this file we define `dimH s` to be the Hausdorff dimension of `s`, then prove some basic
properties of Hausdorff dimension.
## Main definitions
* `MeasureTheory.dimH`: the Hausdorff dimension of a set. For the Hausdorff dimension of the whole
space we use `MeasureTheory.dimH (Set.univ : Set X)`.
## Main results
### Basic properties of Hausdorff dimension
* `hausdorffMeasure_of_lt_dimH`, `dimH_le_of_hausdorffMeasure_ne_top`,
`le_dimH_of_hausdorffMeasure_eq_top`, `hausdorffMeasure_of_dimH_lt`, `measure_zero_of_dimH_lt`,
`le_dimH_of_hausdorffMeasure_ne_zero`, `dimH_of_hausdorffMeasure_ne_zero_ne_top`: various forms
of the characteristic property of the Hausdorff dimension;
* `dimH_union`: the Hausdorff dimension of the union of two sets is the maximum of their Hausdorff
dimensions.
* `dimH_iUnion`, `dimH_bUnion`, `dimH_sUnion`: the Hausdorff dimension of a countable union of sets
is the supremum of their Hausdorff dimensions;
* `dimH_empty`, `dimH_singleton`, `Set.Subsingleton.dimH_zero`, `Set.Countable.dimH_zero` : `dimH s
= 0` whenever `s` is countable;
### (Pre)images under (anti)lipschitz and Hölder continuous maps
* `HolderWith.dimH_image_le` etc: if `f : X → Y` is Hölder continuous with exponent `r > 0`, then
for any `s`, `dimH (f '' s) ≤ dimH s / r`. We prove versions of this statement for `HolderWith`,
`HolderOnWith`, and locally Hölder maps, as well as for `Set.image` and `Set.range`.
* `LipschitzWith.dimH_image_le` etc: Lipschitz continuous maps do not increase the Hausdorff
dimension of sets.
* for a map that is known to be both Lipschitz and antilipschitz (e.g., for an `Isometry` or
a `ContinuousLinearEquiv`) we also prove `dimH (f '' s) = dimH s`.
### Hausdorff measure in `ℝⁿ`
* `Real.dimH_of_nonempty_interior`: if `s` is a set in a finite dimensional real vector space `E`
with nonempty interior, then the Hausdorff dimension of `s` is equal to the dimension of `E`.
* `dense_compl_of_dimH_lt_finrank`: if `s` is a set in a finite dimensional real vector space `E`
with Hausdorff dimension strictly less than the dimension of `E`, the `s` has a dense complement.
* `ContDiff.dense_compl_range_of_finrank_lt_finrank`: the complement to the range of a `C¹`
smooth map is dense provided that the dimension of the domain is strictly less than the dimension
of the codomain.
## Notations
We use the following notation localized in `MeasureTheory`. It is defined in
`MeasureTheory.Measure.Hausdorff`.
- `μH[d]` : `MeasureTheory.Measure.hausdorffMeasure d`
## Implementation notes
* The definition of `dimH` explicitly uses `borel X` as a measurable space structure. This way we
can formulate lemmas about Hausdorff dimension without assuming that the environment has a
`[MeasurableSpace X]` instance that is equal but possibly not defeq to `borel X`.
Lemma `dimH_def` unfolds this definition using whatever `[MeasurableSpace X]` instance we have in
the environment (as long as it is equal to `borel X`).
* The definition `dimH` is irreducible; use API lemmas or `dimH_def` instead.
## Tags
Hausdorff measure, Hausdorff dimension, dimension
-/
open scoped MeasureTheory ENNReal NNReal Topology
open MeasureTheory MeasureTheory.Measure Set TopologicalSpace FiniteDimensional Filter
variable {ι X Y : Type*} [EMetricSpace X] [EMetricSpace Y]
/-- Hausdorff dimension of a set in an (e)metric space. -/
@[irreducible] noncomputable def dimH (s : Set X) : ℝ≥0∞ := by
borelize X; exact ⨆ (d : ℝ≥0) (_ : @hausdorffMeasure X _ _ ⟨rfl⟩ d s = ∞), d
/-!
### Basic properties
-/
section Measurable
variable [MeasurableSpace X] [BorelSpace X]
/-- Unfold the definition of `dimH` using `[MeasurableSpace X] [BorelSpace X]` from the
environment. -/
theorem dimH_def (s : Set X) : dimH s = ⨆ (d : ℝ≥0) (_ : μH[d] s = ∞), (d : ℝ≥0∞) := by
borelize X; rw [dimH]
theorem hausdorffMeasure_of_lt_dimH {s : Set X} {d : ℝ≥0} (h : ↑d < dimH s) : μH[d] s = ∞ := by
simp only [dimH_def, lt_iSup_iff] at h
rcases h with ⟨d', hsd', hdd'⟩
rw [ENNReal.coe_lt_coe, ← NNReal.coe_lt_coe] at hdd'
exact top_unique (hsd' ▸ hausdorffMeasure_mono hdd'.le _)
theorem dimH_le {s : Set X} {d : ℝ≥0∞} (H : ∀ d' : ℝ≥0, μH[d'] s = ∞ → ↑d' ≤ d) : dimH s ≤ d :=
(dimH_def s).trans_le <| iSup₂_le H
theorem dimH_le_of_hausdorffMeasure_ne_top {s : Set X} {d : ℝ≥0} (h : μH[d] s ≠ ∞) : dimH s ≤ d :=
le_of_not_lt <| mt hausdorffMeasure_of_lt_dimH h
theorem le_dimH_of_hausdorffMeasure_eq_top {s : Set X} {d : ℝ≥0} (h : μH[d] s = ∞) :
↑d ≤ dimH s := by
rw [dimH_def]; exact le_iSup₂ (α := ℝ≥0∞) d h
theorem hausdorffMeasure_of_dimH_lt {s : Set X} {d : ℝ≥0} (h : dimH s < d) : μH[d] s = 0 := by
rw [dimH_def] at h
rcases ENNReal.lt_iff_exists_nnreal_btwn.1 h with ⟨d', hsd', hd'd⟩
rw [ENNReal.coe_lt_coe, ← NNReal.coe_lt_coe] at hd'd
exact (hausdorffMeasure_zero_or_top hd'd s).resolve_right fun h₂ => hsd'.not_le <|
le_iSup₂ (α := ℝ≥0∞) d' h₂
theorem measure_zero_of_dimH_lt {μ : Measure X} {d : ℝ≥0} (h : μ ≪ μH[d]) {s : Set X}
(hd : dimH s < d) : μ s = 0 :=
h <| hausdorffMeasure_of_dimH_lt hd
theorem le_dimH_of_hausdorffMeasure_ne_zero {s : Set X} {d : ℝ≥0} (h : μH[d] s ≠ 0) : ↑d ≤ dimH s :=
le_of_not_lt <| mt hausdorffMeasure_of_dimH_lt h
theorem dimH_of_hausdorffMeasure_ne_zero_ne_top {d : ℝ≥0} {s : Set X} (h : μH[d] s ≠ 0)
(h' : μH[d] s ≠ ∞) : dimH s = d :=
le_antisymm (dimH_le_of_hausdorffMeasure_ne_top h') (le_dimH_of_hausdorffMeasure_ne_zero h)
end Measurable
@[mono]
theorem dimH_mono {s t : Set X} (h : s ⊆ t) : dimH s ≤ dimH t := by
borelize X
exact dimH_le fun d hd => le_dimH_of_hausdorffMeasure_eq_top <| top_unique <| hd ▸ measure_mono h
theorem dimH_subsingleton {s : Set X} (h : s.Subsingleton) : dimH s = 0 := by
borelize X
apply le_antisymm _ (zero_le _)
refine dimH_le_of_hausdorffMeasure_ne_top ?_
exact ((hausdorffMeasure_le_one_of_subsingleton h le_rfl).trans_lt ENNReal.one_lt_top).ne
alias Set.Subsingleton.dimH_zero := dimH_subsingleton
@[simp]
theorem dimH_empty : dimH (∅ : Set X) = 0 :=
subsingleton_empty.dimH_zero
@[simp]
theorem dimH_singleton (x : X) : dimH ({x} : Set X) = 0 :=
subsingleton_singleton.dimH_zero
@[simp]
theorem dimH_iUnion {ι : Sort*} [Countable ι] (s : ι → Set X) :
dimH (⋃ i, s i) = ⨆ i, dimH (s i) := by
borelize X
refine le_antisymm (dimH_le fun d hd => ?_) (iSup_le fun i => dimH_mono <| subset_iUnion _ _)
contrapose! hd
have : ∀ i, μH[d] (s i) = 0 := fun i =>
hausdorffMeasure_of_dimH_lt ((le_iSup (fun i => dimH (s i)) i).trans_lt hd)
rw [measure_iUnion_null this]
exact ENNReal.zero_ne_top
@[simp]
theorem dimH_bUnion {s : Set ι} (hs : s.Countable) (t : ι → Set X) :
dimH (⋃ i ∈ s, t i) = ⨆ i ∈ s, dimH (t i) := by
haveI := hs.toEncodable
rw [biUnion_eq_iUnion, dimH_iUnion, ← iSup_subtype'']
@[simp]
theorem dimH_sUnion {S : Set (Set X)} (hS : S.Countable) : dimH (⋃₀ S) = ⨆ s ∈ S, dimH s := by
rw [sUnion_eq_biUnion, dimH_bUnion hS]
@[simp]
theorem dimH_union (s t : Set X) : dimH (s ∪ t) = max (dimH s) (dimH t) := by
rw [union_eq_iUnion, dimH_iUnion, iSup_bool_eq, cond, cond, ENNReal.sup_eq_max]
theorem dimH_countable {s : Set X} (hs : s.Countable) : dimH s = 0 :=
biUnion_of_singleton s ▸ by simp only [dimH_bUnion hs, dimH_singleton, ENNReal.iSup_zero_eq_zero]
alias Set.Countable.dimH_zero := dimH_countable
theorem dimH_finite {s : Set X} (hs : s.Finite) : dimH s = 0 :=
hs.countable.dimH_zero
alias Set.Finite.dimH_zero := dimH_finite
@[simp]
theorem dimH_coe_finset (s : Finset X) : dimH (s : Set X) = 0 :=
s.finite_toSet.dimH_zero
alias Finset.dimH_zero := dimH_coe_finset
/-!
### Hausdorff dimension as the supremum of local Hausdorff dimensions
-/
section
variable [SecondCountableTopology X]
/-- If `r` is less than the Hausdorff dimension of a set `s` in an (extended) metric space with
second countable topology, then there exists a point `x ∈ s` such that every neighborhood
`t` of `x` within `s` has Hausdorff dimension greater than `r`. -/
theorem exists_mem_nhdsWithin_lt_dimH_of_lt_dimH {s : Set X} {r : ℝ≥0∞} (h : r < dimH s) :
∃ x ∈ s, ∀ t ∈ 𝓝[s] x, r < dimH t := by
contrapose! h; choose! t htx htr using h
rcases countable_cover_nhdsWithin htx with ⟨S, hSs, hSc, hSU⟩
calc
dimH s ≤ dimH (⋃ x ∈ S, t x) := dimH_mono hSU
_ = ⨆ x ∈ S, dimH (t x) := dimH_bUnion hSc _
_ ≤ r := iSup₂_le fun x hx => htr x <| hSs hx
/-- In an (extended) metric space with second countable topology, the Hausdorff dimension
of a set `s` is the supremum over `x ∈ s` of the limit superiors of `dimH t` along
`(𝓝[s] x).smallSets`. -/
theorem bsupr_limsup_dimH (s : Set X) : ⨆ x ∈ s, limsup dimH (𝓝[s] x).smallSets = dimH s := by
refine le_antisymm (iSup₂_le fun x _ => ?_) ?_
· refine limsup_le_of_le isCobounded_le_of_bot ?_
exact eventually_smallSets.2 ⟨s, self_mem_nhdsWithin, fun t => dimH_mono⟩
· refine le_of_forall_ge_of_dense fun r hr => ?_
rcases exists_mem_nhdsWithin_lt_dimH_of_lt_dimH hr with ⟨x, hxs, hxr⟩
refine le_iSup₂_of_le x hxs ?_; rw [limsup_eq]; refine le_sInf fun b hb => ?_
rcases eventually_smallSets.1 hb with ⟨t, htx, ht⟩
exact (hxr t htx).le.trans (ht t Subset.rfl)
/-- In an (extended) metric space with second countable topology, the Hausdorff dimension
of a set `s` is the supremum over all `x` of the limit superiors of `dimH t` along
`(𝓝[s] x).smallSets`. -/
theorem iSup_limsup_dimH (s : Set X) : ⨆ x, limsup dimH (𝓝[s] x).smallSets = dimH s := by
refine le_antisymm (iSup_le fun x => ?_) ?_
· refine limsup_le_of_le isCobounded_le_of_bot ?_
exact eventually_smallSets.2 ⟨s, self_mem_nhdsWithin, fun t => dimH_mono⟩
· rw [← bsupr_limsup_dimH]; exact iSup₂_le_iSup _ _
end
/-!
### Hausdorff dimension and Hölder continuity
-/
variable {C K r : ℝ≥0} {f : X → Y} {s t : Set X}
/-- If `f` is a Hölder continuous map with exponent `r > 0`, then `dimH (f '' s) ≤ dimH s / r`. -/
theorem HolderOnWith.dimH_image_le (h : HolderOnWith C r f s) (hr : 0 < r) :
dimH (f '' s) ≤ dimH s / r := by
borelize X Y
refine dimH_le fun d hd => ?_
have := h.hausdorffMeasure_image_le hr d.coe_nonneg
rw [hd, ENNReal.coe_rpow_of_nonneg _ d.coe_nonneg, top_le_iff] at this
have Hrd : μH[(r * d : ℝ≥0)] s = ⊤ := by
contrapose this
exact ENNReal.mul_ne_top ENNReal.coe_ne_top this
rw [ENNReal.le_div_iff_mul_le, mul_comm, ← ENNReal.coe_mul]
exacts [le_dimH_of_hausdorffMeasure_eq_top Hrd, Or.inl (mt ENNReal.coe_eq_zero.1 hr.ne'),
Or.inl ENNReal.coe_ne_top]
namespace HolderWith
/-- If `f : X → Y` is Hölder continuous with a positive exponent `r`, then the Hausdorff dimension
of the image of a set `s` is at most `dimH s / r`. -/
theorem dimH_image_le (h : HolderWith C r f) (hr : 0 < r) (s : Set X) :
dimH (f '' s) ≤ dimH s / r :=
(h.holderOnWith s).dimH_image_le hr
/-- If `f` is a Hölder continuous map with exponent `r > 0`, then the Hausdorff dimension of its
range is at most the Hausdorff dimension of its domain divided by `r`. -/
theorem dimH_range_le (h : HolderWith C r f) (hr : 0 < r) :
dimH (range f) ≤ dimH (univ : Set X) / r :=
@image_univ _ _ f ▸ h.dimH_image_le hr univ
end HolderWith
/-- If `s` is a set in a space `X` with second countable topology and `f : X → Y` is Hölder
continuous in a neighborhood within `s` of every point `x ∈ s` with the same positive exponent `r`
but possibly different coefficients, then the Hausdorff dimension of the image `f '' s` is at most
the Hausdorff dimension of `s` divided by `r`. -/
theorem dimH_image_le_of_locally_holder_on [SecondCountableTopology X] {r : ℝ≥0} {f : X → Y}
(hr : 0 < r) {s : Set X} (hf : ∀ x ∈ s, ∃ C : ℝ≥0, ∃ t ∈ 𝓝[s] x, HolderOnWith C r f t) :
dimH (f '' s) ≤ dimH s / r := by
choose! C t htn hC using hf
rcases countable_cover_nhdsWithin htn with ⟨u, hus, huc, huU⟩
replace huU := inter_eq_self_of_subset_left huU; rw [inter_iUnion₂] at huU
rw [← huU, image_iUnion₂, dimH_bUnion huc, dimH_bUnion huc]; simp only [ENNReal.iSup_div]
exact iSup₂_mono fun x hx => ((hC x (hus hx)).mono inter_subset_right).dimH_image_le hr
/-- If `f : X → Y` is Hölder continuous in a neighborhood of every point `x : X` with the same
positive exponent `r` but possibly different coefficients, then the Hausdorff dimension of the range
of `f` is at most the Hausdorff dimension of `X` divided by `r`. -/
theorem dimH_range_le_of_locally_holder_on [SecondCountableTopology X] {r : ℝ≥0} {f : X → Y}
(hr : 0 < r) (hf : ∀ x : X, ∃ C : ℝ≥0, ∃ s ∈ 𝓝 x, HolderOnWith C r f s) :
dimH (range f) ≤ dimH (univ : Set X) / r := by
rw [← image_univ]
refine dimH_image_le_of_locally_holder_on hr fun x _ => ?_
simpa only [exists_prop, nhdsWithin_univ] using hf x
/-!
### Hausdorff dimension and Lipschitz continuity
-/
/-- If `f : X → Y` is Lipschitz continuous on `s`, then `dimH (f '' s) ≤ dimH s`. -/
theorem LipschitzOnWith.dimH_image_le (h : LipschitzOnWith K f s) : dimH (f '' s) ≤ dimH s := by
simpa using h.holderOnWith.dimH_image_le zero_lt_one
namespace LipschitzWith
/-- If `f` is a Lipschitz continuous map, then `dimH (f '' s) ≤ dimH s`. -/
theorem dimH_image_le (h : LipschitzWith K f) (s : Set X) : dimH (f '' s) ≤ dimH s :=
(h.lipschitzOnWith s).dimH_image_le
/-- If `f` is a Lipschitz continuous map, then the Hausdorff dimension of its range is at most the
Hausdorff dimension of its domain. -/
theorem dimH_range_le (h : LipschitzWith K f) : dimH (range f) ≤ dimH (univ : Set X) :=
@image_univ _ _ f ▸ h.dimH_image_le univ
end LipschitzWith
/-- If `s` is a set in an extended metric space `X` with second countable topology and `f : X → Y`
is Lipschitz in a neighborhood within `s` of every point `x ∈ s`, then the Hausdorff dimension of
the image `f '' s` is at most the Hausdorff dimension of `s`. -/
theorem dimH_image_le_of_locally_lipschitzOn [SecondCountableTopology X] {f : X → Y} {s : Set X}
(hf : ∀ x ∈ s, ∃ C : ℝ≥0, ∃ t ∈ 𝓝[s] x, LipschitzOnWith C f t) : dimH (f '' s) ≤ dimH s := by
have : ∀ x ∈ s, ∃ C : ℝ≥0, ∃ t ∈ 𝓝[s] x, HolderOnWith C 1 f t := by
simpa only [holderOnWith_one] using hf
simpa only [ENNReal.coe_one, div_one] using dimH_image_le_of_locally_holder_on zero_lt_one this
/-- If `f : X → Y` is Lipschitz in a neighborhood of each point `x : X`, then the Hausdorff
dimension of `range f` is at most the Hausdorff dimension of `X`. -/
theorem dimH_range_le_of_locally_lipschitzOn [SecondCountableTopology X] {f : X → Y}
(hf : ∀ x : X, ∃ C : ℝ≥0, ∃ s ∈ 𝓝 x, LipschitzOnWith C f s) :
dimH (range f) ≤ dimH (univ : Set X) := by
rw [← image_univ]
refine dimH_image_le_of_locally_lipschitzOn fun x _ => ?_
simpa only [exists_prop, nhdsWithin_univ] using hf x
namespace AntilipschitzWith
theorem dimH_preimage_le (hf : AntilipschitzWith K f) (s : Set Y) : dimH (f ⁻¹' s) ≤ dimH s := by
borelize X Y
refine dimH_le fun d hd => le_dimH_of_hausdorffMeasure_eq_top ?_
have := hf.hausdorffMeasure_preimage_le d.coe_nonneg s
rw [hd, top_le_iff] at this
contrapose! this
exact ENNReal.mul_ne_top (by simp) this
theorem le_dimH_image (hf : AntilipschitzWith K f) (s : Set X) : dimH s ≤ dimH (f '' s) :=
calc
dimH s ≤ dimH (f ⁻¹' (f '' s)) := dimH_mono (subset_preimage_image _ _)
_ ≤ dimH (f '' s) := hf.dimH_preimage_le _
end AntilipschitzWith
/-!
### Isometries preserve Hausdorff dimension
-/
theorem Isometry.dimH_image (hf : Isometry f) (s : Set X) : dimH (f '' s) = dimH s :=
le_antisymm (hf.lipschitz.dimH_image_le _) (hf.antilipschitz.le_dimH_image _)
namespace IsometryEquiv
@[simp]
theorem dimH_image (e : X ≃ᵢ Y) (s : Set X) : dimH (e '' s) = dimH s :=
e.isometry.dimH_image s
@[simp]
theorem dimH_preimage (e : X ≃ᵢ Y) (s : Set Y) : dimH (e ⁻¹' s) = dimH s := by
rw [← e.image_symm, e.symm.dimH_image]
theorem dimH_univ (e : X ≃ᵢ Y) : dimH (univ : Set X) = dimH (univ : Set Y) := by
rw [← e.dimH_preimage univ, preimage_univ]
end IsometryEquiv
namespace ContinuousLinearEquiv
variable {𝕜 E F : Type*} [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E]
[NormedAddCommGroup F] [NormedSpace 𝕜 F]
@[simp]
theorem dimH_image (e : E ≃L[𝕜] F) (s : Set E) : dimH (e '' s) = dimH s :=
le_antisymm (e.lipschitz.dimH_image_le s) <| by
simpa only [e.symm_image_image] using e.symm.lipschitz.dimH_image_le (e '' s)
@[simp]
theorem dimH_preimage (e : E ≃L[𝕜] F) (s : Set F) : dimH (e ⁻¹' s) = dimH s := by
rw [← e.image_symm_eq_preimage, e.symm.dimH_image]
theorem dimH_univ (e : E ≃L[𝕜] F) : dimH (univ : Set E) = dimH (univ : Set F) := by
rw [← e.dimH_preimage, preimage_univ]
end ContinuousLinearEquiv
/-!
### Hausdorff dimension in a real vector space
-/
namespace Real
variable {E : Type*} [Fintype ι] [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E]
theorem dimH_ball_pi (x : ι → ℝ) {r : ℝ} (hr : 0 < r) :
dimH (Metric.ball x r) = Fintype.card ι := by
cases isEmpty_or_nonempty ι
· rwa [dimH_subsingleton, eq_comm, Nat.cast_eq_zero, Fintype.card_eq_zero_iff]
exact fun x _ y _ => Subsingleton.elim x y
· rw [← ENNReal.coe_natCast]
have : μH[Fintype.card ι] (Metric.ball x r) = ENNReal.ofReal ((2 * r) ^ Fintype.card ι) := by
rw [hausdorffMeasure_pi_real, Real.volume_pi_ball _ hr]
refine dimH_of_hausdorffMeasure_ne_zero_ne_top ?_ ?_ <;> rw [NNReal.coe_natCast, this]
· simp [pow_pos (mul_pos (zero_lt_two' ℝ) hr)]
· exact ENNReal.ofReal_ne_top
theorem dimH_ball_pi_fin {n : ℕ} (x : Fin n → ℝ) {r : ℝ} (hr : 0 < r) :
dimH (Metric.ball x r) = n := by rw [dimH_ball_pi x hr, Fintype.card_fin]
theorem dimH_univ_pi (ι : Type*) [Fintype ι] : dimH (univ : Set (ι → ℝ)) = Fintype.card ι := by
simp only [← Metric.iUnion_ball_nat_succ (0 : ι → ℝ), dimH_iUnion,
dimH_ball_pi _ (Nat.cast_add_one_pos _), iSup_const]
theorem dimH_univ_pi_fin (n : ℕ) : dimH (univ : Set (Fin n → ℝ)) = n := by
rw [dimH_univ_pi, Fintype.card_fin]
theorem dimH_of_mem_nhds {x : E} {s : Set E} (h : s ∈ 𝓝 x) : dimH s = finrank ℝ E := by
have e : E ≃L[ℝ] Fin (finrank ℝ E) → ℝ :=
ContinuousLinearEquiv.ofFinrankEq (FiniteDimensional.finrank_fin_fun ℝ).symm
rw [← e.dimH_image]
refine le_antisymm ?_ ?_
· exact (dimH_mono (subset_univ _)).trans_eq (dimH_univ_pi_fin _)
· have : e '' s ∈ 𝓝 (e x) := by rw [← e.map_nhds_eq]; exact image_mem_map h
rcases Metric.nhds_basis_ball.mem_iff.1 this with ⟨r, hr0, hr⟩
simpa only [dimH_ball_pi_fin (e x) hr0] using dimH_mono hr
theorem dimH_of_nonempty_interior {s : Set E} (h : (interior s).Nonempty) : dimH s = finrank ℝ E :=
let ⟨_, hx⟩ := h
dimH_of_mem_nhds (mem_interior_iff_mem_nhds.1 hx)
variable (E)
theorem dimH_univ_eq_finrank : dimH (univ : Set E) = finrank ℝ E :=
dimH_of_mem_nhds (@univ_mem _ (𝓝 0))
theorem dimH_univ : dimH (univ : Set ℝ) = 1 := by
rw [dimH_univ_eq_finrank ℝ, FiniteDimensional.finrank_self, Nat.cast_one]
variable {E}
lemma hausdorffMeasure_of_finrank_lt [MeasurableSpace E] [BorelSpace E] {d : ℝ}
(hd : finrank ℝ E < d) : (μH[d] : Measure E) = 0 := by
lift d to ℝ≥0 using (Nat.cast_nonneg _).trans hd.le
rw [← measure_univ_eq_zero]
apply hausdorffMeasure_of_dimH_lt
rw [dimH_univ_eq_finrank]
exact mod_cast hd
end Real
variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E]
[NormedAddCommGroup F] [NormedSpace ℝ F]
theorem dense_compl_of_dimH_lt_finrank {s : Set E} (hs : dimH s < finrank ℝ E) : Dense sᶜ := by
refine fun x => mem_closure_iff_nhds.2 fun t ht => nonempty_iff_ne_empty.2 fun he => hs.not_le ?_
rw [← diff_eq, diff_eq_empty] at he
rw [← Real.dimH_of_mem_nhds ht]
exact dimH_mono he
/-!
### Hausdorff dimension and `C¹`-smooth maps
`C¹`-smooth maps are locally Lipschitz continuous, hence they do not increase the Hausdorff
dimension of sets.
-/
/-- Let `f` be a function defined on a finite dimensional real normed space. If `f` is `C¹`-smooth
on a convex set `s`, then the Hausdorff dimension of `f '' s` is less than or equal to the Hausdorff
dimension of `s`.
TODO: do we actually need `Convex ℝ s`? -/
theorem ContDiffOn.dimH_image_le {f : E → F} {s t : Set E} (hf : ContDiffOn ℝ 1 f s)
(hc : Convex ℝ s) (ht : t ⊆ s) : dimH (f '' t) ≤ dimH t :=
dimH_image_le_of_locally_lipschitzOn fun x hx =>
let ⟨C, u, hu, hf⟩ := (hf x (ht hx)).exists_lipschitzOnWith hc
⟨C, u, nhdsWithin_mono _ ht hu, hf⟩
/-- The Hausdorff dimension of the range of a `C¹`-smooth function defined on a finite dimensional
real normed space is at most the dimension of its domain as a vector space over `ℝ`. -/
theorem ContDiff.dimH_range_le {f : E → F} (h : ContDiff ℝ 1 f) : dimH (range f) ≤ finrank ℝ E :=
calc
dimH (range f) = dimH (f '' univ) := by rw [image_univ]
_ ≤ dimH (univ : Set E) := h.contDiffOn.dimH_image_le convex_univ Subset.rfl
_ = finrank ℝ E := Real.dimH_univ_eq_finrank E
/-- A particular case of Sard's Theorem. Let `f : E → F` be a map between finite dimensional real
vector spaces. Suppose that `f` is `C¹` smooth on a convex set `s` of Hausdorff dimension strictly
less than the dimension of `F`. Then the complement of the image `f '' s` is dense in `F`. -/
theorem ContDiffOn.dense_compl_image_of_dimH_lt_finrank [FiniteDimensional ℝ F] {f : E → F}
{s t : Set E} (h : ContDiffOn ℝ 1 f s) (hc : Convex ℝ s) (ht : t ⊆ s)
(htF : dimH t < finrank ℝ F) : Dense (f '' t)ᶜ :=
dense_compl_of_dimH_lt_finrank <| (h.dimH_image_le hc ht).trans_lt htF
/-- A particular case of Sard's Theorem. If `f` is a `C¹` smooth map from a real vector space to a
real vector space `F` of strictly larger dimension, then the complement of the range of `f` is dense
in `F`. -/
theorem ContDiff.dense_compl_range_of_finrank_lt_finrank [FiniteDimensional ℝ F] {f : E → F}
(h : ContDiff ℝ 1 f) (hEF : finrank ℝ E < finrank ℝ F) : Dense (range f)ᶜ :=
dense_compl_of_dimH_lt_finrank <| h.dimH_range_le.trans_lt <| Nat.cast_lt.2 hEF
|
Topology\MetricSpace\HausdorffDistance.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.Analysis.SpecificLimits.Basic
import Mathlib.Topology.MetricSpace.IsometricSMul
/-!
# Hausdorff distance
The Hausdorff distance on subsets of a metric (or emetric) space.
Given two subsets `s` and `t` of a metric space, their Hausdorff distance is the smallest `d`
such that any point `s` is within `d` of a point in `t`, and conversely. This quantity
is often infinite (think of `s` bounded and `t` unbounded), and therefore better
expressed in the setting of emetric spaces.
## Main definitions
This files introduces:
* `EMetric.infEdist x s`, the infimum edistance of a point `x` to a set `s` in an emetric space
* `EMetric.hausdorffEdist s t`, the Hausdorff edistance of two sets in an emetric space
* Versions of these notions on metric spaces, called respectively `Metric.infDist`
and `Metric.hausdorffDist`
## Main results
* `infEdist_closure`: the edistance to a set and its closure coincide
* `EMetric.mem_closure_iff_infEdist_zero`: a point `x` belongs to the closure of `s` iff
`infEdist x s = 0`
* `IsCompact.exists_infEdist_eq_edist`: if `s` is compact and non-empty, there exists a point `y`
which attains this edistance
* `IsOpen.exists_iUnion_isClosed`: every open set `U` can be written as the increasing union
of countably many closed subsets of `U`
* `hausdorffEdist_closure`: replacing a set by its closure does not change the Hausdorff edistance
* `hausdorffEdist_zero_iff_closure_eq_closure`: two sets have Hausdorff edistance zero
iff their closures coincide
* the Hausdorff edistance is symmetric and satisfies the triangle inequality
* in particular, closed sets in an emetric space are an emetric space
(this is shown in `EMetricSpace.closeds.emetricspace`)
* versions of these notions on metric spaces
* `hausdorffEdist_ne_top_of_nonempty_of_bounded`: if two sets in a metric space
are nonempty and bounded in a metric space, they are at finite Hausdorff edistance.
## Tags
metric space, Hausdorff distance
-/
noncomputable section
open NNReal ENNReal Topology Set Filter Pointwise Bornology
universe u v w
variable {ι : Sort*} {α : Type u} {β : Type v}
namespace EMetric
section InfEdist
variable [PseudoEMetricSpace α] [PseudoEMetricSpace β] {x y : α} {s t : Set α} {Φ : α → β}
/-! ### Distance of a point to a set as a function into `ℝ≥0∞`. -/
/-- The minimal edistance of a point to a set -/
def infEdist (x : α) (s : Set α) : ℝ≥0∞ :=
⨅ y ∈ s, edist x y
@[simp]
theorem infEdist_empty : infEdist x ∅ = ∞ :=
iInf_emptyset
theorem le_infEdist {d} : d ≤ infEdist x s ↔ ∀ y ∈ s, d ≤ edist x y := by
simp only [infEdist, le_iInf_iff]
/-- The edist to a union is the minimum of the edists -/
@[simp]
theorem infEdist_union : infEdist x (s ∪ t) = infEdist x s ⊓ infEdist x t :=
iInf_union
@[simp]
theorem infEdist_iUnion (f : ι → Set α) (x : α) : infEdist x (⋃ i, f i) = ⨅ i, infEdist x (f i) :=
iInf_iUnion f _
lemma infEdist_biUnion {ι : Type*} (f : ι → Set α) (I : Set ι) (x : α) :
infEdist x (⋃ i ∈ I, f i) = ⨅ i ∈ I, infEdist x (f i) := by simp only [infEdist_iUnion]
/-- The edist to a singleton is the edistance to the single point of this singleton -/
@[simp]
theorem infEdist_singleton : infEdist x {y} = edist x y :=
iInf_singleton
/-- The edist to a set is bounded above by the edist to any of its points -/
theorem infEdist_le_edist_of_mem (h : y ∈ s) : infEdist x s ≤ edist x y :=
iInf₂_le y h
/-- If a point `x` belongs to `s`, then its edist to `s` vanishes -/
theorem infEdist_zero_of_mem (h : x ∈ s) : infEdist x s = 0 :=
nonpos_iff_eq_zero.1 <| @edist_self _ _ x ▸ infEdist_le_edist_of_mem h
/-- The edist is antitone with respect to inclusion. -/
theorem infEdist_anti (h : s ⊆ t) : infEdist x t ≤ infEdist x s :=
iInf_le_iInf_of_subset h
/-- The edist to a set is `< r` iff there exists a point in the set at edistance `< r` -/
theorem infEdist_lt_iff {r : ℝ≥0∞} : infEdist x s < r ↔ ∃ y ∈ s, edist x y < r := by
simp_rw [infEdist, iInf_lt_iff, exists_prop]
/-- The edist of `x` to `s` is bounded by the sum of the edist of `y` to `s` and
the edist from `x` to `y` -/
theorem infEdist_le_infEdist_add_edist : infEdist x s ≤ infEdist y s + edist x y :=
calc
⨅ z ∈ s, edist x z ≤ ⨅ z ∈ s, edist y z + edist x y :=
iInf₂_mono fun z _ => (edist_triangle _ _ _).trans_eq (add_comm _ _)
_ = (⨅ z ∈ s, edist y z) + edist x y := by simp only [ENNReal.iInf_add]
theorem infEdist_le_edist_add_infEdist : infEdist x s ≤ edist x y + infEdist y s := by
rw [add_comm]
exact infEdist_le_infEdist_add_edist
theorem edist_le_infEdist_add_ediam (hy : y ∈ s) : edist x y ≤ infEdist x s + diam s := by
simp_rw [infEdist, ENNReal.iInf_add]
refine le_iInf₂ fun i hi => ?_
calc
edist x y ≤ edist x i + edist i y := edist_triangle _ _ _
_ ≤ edist x i + diam s := add_le_add le_rfl (edist_le_diam_of_mem hi hy)
/-- The edist to a set depends continuously on the point -/
@[continuity]
theorem continuous_infEdist : Continuous fun x => infEdist x s :=
continuous_of_le_add_edist 1 (by simp) <| by
simp only [one_mul, infEdist_le_infEdist_add_edist, forall₂_true_iff]
/-- The edist to a set and to its closure coincide -/
theorem infEdist_closure : infEdist x (closure s) = infEdist x s := by
refine le_antisymm (infEdist_anti subset_closure) ?_
refine ENNReal.le_of_forall_pos_le_add fun ε εpos h => ?_
have ε0 : 0 < (ε / 2 : ℝ≥0∞) := by simpa [pos_iff_ne_zero] using εpos
have : infEdist x (closure s) < infEdist x (closure s) + ε / 2 :=
ENNReal.lt_add_right h.ne ε0.ne'
obtain ⟨y : α, ycs : y ∈ closure s, hy : edist x y < infEdist x (closure s) + ↑ε / 2⟩ :=
infEdist_lt_iff.mp this
obtain ⟨z : α, zs : z ∈ s, dyz : edist y z < ↑ε / 2⟩ := EMetric.mem_closure_iff.1 ycs (ε / 2) ε0
calc
infEdist x s ≤ edist x z := infEdist_le_edist_of_mem zs
_ ≤ edist x y + edist y z := edist_triangle _ _ _
_ ≤ infEdist x (closure s) + ε / 2 + ε / 2 := add_le_add (le_of_lt hy) (le_of_lt dyz)
_ = infEdist x (closure s) + ↑ε := by rw [add_assoc, ENNReal.add_halves]
/-- A point belongs to the closure of `s` iff its infimum edistance to this set vanishes -/
theorem mem_closure_iff_infEdist_zero : x ∈ closure s ↔ infEdist x s = 0 :=
⟨fun h => by
rw [← infEdist_closure]
exact infEdist_zero_of_mem h,
fun h =>
EMetric.mem_closure_iff.2 fun ε εpos => infEdist_lt_iff.mp <| by rwa [h]⟩
/-- Given a closed set `s`, a point belongs to `s` iff its infimum edistance to this set vanishes -/
theorem mem_iff_infEdist_zero_of_closed (h : IsClosed s) : x ∈ s ↔ infEdist x s = 0 := by
rw [← mem_closure_iff_infEdist_zero, h.closure_eq]
/-- The infimum edistance of a point to a set is positive if and only if the point is not in the
closure of the set. -/
theorem infEdist_pos_iff_not_mem_closure {x : α} {E : Set α} :
0 < infEdist x E ↔ x ∉ closure E := by
rw [mem_closure_iff_infEdist_zero, pos_iff_ne_zero]
theorem infEdist_closure_pos_iff_not_mem_closure {x : α} {E : Set α} :
0 < infEdist x (closure E) ↔ x ∉ closure E := by
rw [infEdist_closure, infEdist_pos_iff_not_mem_closure]
theorem exists_real_pos_lt_infEdist_of_not_mem_closure {x : α} {E : Set α} (h : x ∉ closure E) :
∃ ε : ℝ, 0 < ε ∧ ENNReal.ofReal ε < infEdist x E := by
rw [← infEdist_pos_iff_not_mem_closure, ENNReal.lt_iff_exists_real_btwn] at h
rcases h with ⟨ε, ⟨_, ⟨ε_pos, ε_lt⟩⟩⟩
exact ⟨ε, ⟨ENNReal.ofReal_pos.mp ε_pos, ε_lt⟩⟩
theorem disjoint_closedBall_of_lt_infEdist {r : ℝ≥0∞} (h : r < infEdist x s) :
Disjoint (closedBall x r) s := by
rw [disjoint_left]
intro y hy h'y
apply lt_irrefl (infEdist x s)
calc
infEdist x s ≤ edist x y := infEdist_le_edist_of_mem h'y
_ ≤ r := by rwa [mem_closedBall, edist_comm] at hy
_ < infEdist x s := h
/-- The infimum edistance is invariant under isometries -/
theorem infEdist_image (hΦ : Isometry Φ) : infEdist (Φ x) (Φ '' t) = infEdist x t := by
simp only [infEdist, iInf_image, hΦ.edist_eq]
@[to_additive (attr := simp)]
theorem infEdist_smul {M} [SMul M α] [IsometricSMul M α] (c : M) (x : α) (s : Set α) :
infEdist (c • x) (c • s) = infEdist x s :=
infEdist_image (isometry_smul _ _)
theorem _root_.IsOpen.exists_iUnion_isClosed {U : Set α} (hU : IsOpen U) :
∃ F : ℕ → Set α, (∀ n, IsClosed (F n)) ∧ (∀ n, F n ⊆ U) ∧ ⋃ n, F n = U ∧ Monotone F := by
obtain ⟨a, a_pos, a_lt_one⟩ : ∃ a : ℝ≥0∞, 0 < a ∧ a < 1 := exists_between zero_lt_one
let F := fun n : ℕ => (fun x => infEdist x Uᶜ) ⁻¹' Ici (a ^ n)
have F_subset : ∀ n, F n ⊆ U := fun n x hx ↦ by
by_contra h
have : infEdist x Uᶜ ≠ 0 := ((ENNReal.pow_pos a_pos _).trans_le hx).ne'
exact this (infEdist_zero_of_mem h)
refine ⟨F, fun n => IsClosed.preimage continuous_infEdist isClosed_Ici, F_subset, ?_, ?_⟩
· show ⋃ n, F n = U
refine Subset.antisymm (by simp only [iUnion_subset_iff, F_subset, forall_const]) fun x hx => ?_
have : ¬x ∈ Uᶜ := by simpa using hx
rw [mem_iff_infEdist_zero_of_closed hU.isClosed_compl] at this
have B : 0 < infEdist x Uᶜ := by simpa [pos_iff_ne_zero] using this
have : Filter.Tendsto (fun n => a ^ n) atTop (𝓝 0) :=
ENNReal.tendsto_pow_atTop_nhds_zero_of_lt_one a_lt_one
rcases ((tendsto_order.1 this).2 _ B).exists with ⟨n, hn⟩
simp only [mem_iUnion, mem_Ici, mem_preimage]
exact ⟨n, hn.le⟩
show Monotone F
intro m n hmn x hx
simp only [F, mem_Ici, mem_preimage] at hx ⊢
apply le_trans (pow_le_pow_right_of_le_one' a_lt_one.le hmn) hx
theorem _root_.IsCompact.exists_infEdist_eq_edist (hs : IsCompact s) (hne : s.Nonempty) (x : α) :
∃ y ∈ s, infEdist x s = edist x y := by
have A : Continuous fun y => edist x y := continuous_const.edist continuous_id
obtain ⟨y, ys, hy⟩ := hs.exists_isMinOn hne A.continuousOn
exact ⟨y, ys, le_antisymm (infEdist_le_edist_of_mem ys) (by rwa [le_infEdist])⟩
theorem exists_pos_forall_lt_edist (hs : IsCompact s) (ht : IsClosed t) (hst : Disjoint s t) :
∃ r : ℝ≥0, 0 < r ∧ ∀ x ∈ s, ∀ y ∈ t, (r : ℝ≥0∞) < edist x y := by
rcases s.eq_empty_or_nonempty with (rfl | hne)
· use 1
simp
obtain ⟨x, hx, h⟩ := hs.exists_isMinOn hne continuous_infEdist.continuousOn
have : 0 < infEdist x t :=
pos_iff_ne_zero.2 fun H => hst.le_bot ⟨hx, (mem_iff_infEdist_zero_of_closed ht).mpr H⟩
rcases ENNReal.lt_iff_exists_nnreal_btwn.1 this with ⟨r, h₀, hr⟩
exact ⟨r, ENNReal.coe_pos.mp h₀, fun y hy z hz => hr.trans_le <| le_infEdist.1 (h hy) z hz⟩
end InfEdist
/-! ### The Hausdorff distance as a function into `ℝ≥0∞`. -/
/-- The Hausdorff edistance between two sets is the smallest `r` such that each set
is contained in the `r`-neighborhood of the other one -/
irreducible_def hausdorffEdist {α : Type u} [PseudoEMetricSpace α] (s t : Set α) : ℝ≥0∞ :=
(⨆ x ∈ s, infEdist x t) ⊔ ⨆ y ∈ t, infEdist y s
section HausdorffEdist
variable [PseudoEMetricSpace α] [PseudoEMetricSpace β] {x y : α} {s t u : Set α} {Φ : α → β}
/-- The Hausdorff edistance of a set to itself vanishes. -/
@[simp]
theorem hausdorffEdist_self : hausdorffEdist s s = 0 := by
simp only [hausdorffEdist_def, sup_idem, ENNReal.iSup_eq_zero]
exact fun x hx => infEdist_zero_of_mem hx
/-- The Haudorff edistances of `s` to `t` and of `t` to `s` coincide. -/
theorem hausdorffEdist_comm : hausdorffEdist s t = hausdorffEdist t s := by
simp only [hausdorffEdist_def]; apply sup_comm
/-- Bounding the Hausdorff edistance by bounding the edistance of any point
in each set to the other set -/
theorem hausdorffEdist_le_of_infEdist {r : ℝ≥0∞} (H1 : ∀ x ∈ s, infEdist x t ≤ r)
(H2 : ∀ x ∈ t, infEdist x s ≤ r) : hausdorffEdist s t ≤ r := by
simp only [hausdorffEdist_def, sup_le_iff, iSup_le_iff]
exact ⟨H1, H2⟩
/-- Bounding the Hausdorff edistance by exhibiting, for any point in each set,
another point in the other set at controlled distance -/
theorem hausdorffEdist_le_of_mem_edist {r : ℝ≥0∞} (H1 : ∀ x ∈ s, ∃ y ∈ t, edist x y ≤ r)
(H2 : ∀ x ∈ t, ∃ y ∈ s, edist x y ≤ r) : hausdorffEdist s t ≤ r := by
refine hausdorffEdist_le_of_infEdist (fun x xs ↦ ?_) (fun x xt ↦ ?_)
· rcases H1 x xs with ⟨y, yt, hy⟩
exact le_trans (infEdist_le_edist_of_mem yt) hy
· rcases H2 x xt with ⟨y, ys, hy⟩
exact le_trans (infEdist_le_edist_of_mem ys) hy
/-- The distance to a set is controlled by the Hausdorff distance. -/
theorem infEdist_le_hausdorffEdist_of_mem (h : x ∈ s) : infEdist x t ≤ hausdorffEdist s t := by
rw [hausdorffEdist_def]
refine le_trans ?_ le_sup_left
exact le_iSup₂ (α := ℝ≥0∞) x h
/-- If the Hausdorff distance is `< r`, then any point in one of the sets has
a corresponding point at distance `< r` in the other set. -/
theorem exists_edist_lt_of_hausdorffEdist_lt {r : ℝ≥0∞} (h : x ∈ s) (H : hausdorffEdist s t < r) :
∃ y ∈ t, edist x y < r :=
infEdist_lt_iff.mp <|
calc
infEdist x t ≤ hausdorffEdist s t := infEdist_le_hausdorffEdist_of_mem h
_ < r := H
/-- The distance from `x` to `s` or `t` is controlled in terms of the Hausdorff distance
between `s` and `t`. -/
theorem infEdist_le_infEdist_add_hausdorffEdist :
infEdist x t ≤ infEdist x s + hausdorffEdist s t :=
ENNReal.le_of_forall_pos_le_add fun ε εpos h => by
have ε0 : (ε / 2 : ℝ≥0∞) ≠ 0 := by simpa [pos_iff_ne_zero] using εpos
have : infEdist x s < infEdist x s + ε / 2 :=
ENNReal.lt_add_right (ENNReal.add_lt_top.1 h).1.ne ε0
obtain ⟨y : α, ys : y ∈ s, dxy : edist x y < infEdist x s + ↑ε / 2⟩ := infEdist_lt_iff.mp this
have : hausdorffEdist s t < hausdorffEdist s t + ε / 2 :=
ENNReal.lt_add_right (ENNReal.add_lt_top.1 h).2.ne ε0
obtain ⟨z : α, zt : z ∈ t, dyz : edist y z < hausdorffEdist s t + ↑ε / 2⟩ :=
exists_edist_lt_of_hausdorffEdist_lt ys this
calc
infEdist x t ≤ edist x z := infEdist_le_edist_of_mem zt
_ ≤ edist x y + edist y z := edist_triangle _ _ _
_ ≤ infEdist x s + ε / 2 + (hausdorffEdist s t + ε / 2) := add_le_add dxy.le dyz.le
_ = infEdist x s + hausdorffEdist s t + ε := by
simp [ENNReal.add_halves, add_comm, add_left_comm]
/-- The Hausdorff edistance is invariant under isometries. -/
theorem hausdorffEdist_image (h : Isometry Φ) :
hausdorffEdist (Φ '' s) (Φ '' t) = hausdorffEdist s t := by
simp only [hausdorffEdist_def, iSup_image, infEdist_image h]
/-- The Hausdorff distance is controlled by the diameter of the union. -/
theorem hausdorffEdist_le_ediam (hs : s.Nonempty) (ht : t.Nonempty) :
hausdorffEdist s t ≤ diam (s ∪ t) := by
rcases hs with ⟨x, xs⟩
rcases ht with ⟨y, yt⟩
refine hausdorffEdist_le_of_mem_edist ?_ ?_
· intro z hz
exact ⟨y, yt, edist_le_diam_of_mem (subset_union_left hz) (subset_union_right yt)⟩
· intro z hz
exact ⟨x, xs, edist_le_diam_of_mem (subset_union_right hz) (subset_union_left xs)⟩
/-- The Hausdorff distance satisfies the triangle inequality. -/
theorem hausdorffEdist_triangle : hausdorffEdist s u ≤ hausdorffEdist s t + hausdorffEdist t u := by
rw [hausdorffEdist_def]
simp only [sup_le_iff, iSup_le_iff]
constructor
· show ∀ x ∈ s, infEdist x u ≤ hausdorffEdist s t + hausdorffEdist t u
exact fun x xs =>
calc
infEdist x u ≤ infEdist x t + hausdorffEdist t u :=
infEdist_le_infEdist_add_hausdorffEdist
_ ≤ hausdorffEdist s t + hausdorffEdist t u :=
add_le_add_right (infEdist_le_hausdorffEdist_of_mem xs) _
· show ∀ x ∈ u, infEdist x s ≤ hausdorffEdist s t + hausdorffEdist t u
exact fun x xu =>
calc
infEdist x s ≤ infEdist x t + hausdorffEdist t s :=
infEdist_le_infEdist_add_hausdorffEdist
_ ≤ hausdorffEdist u t + hausdorffEdist t s :=
add_le_add_right (infEdist_le_hausdorffEdist_of_mem xu) _
_ = hausdorffEdist s t + hausdorffEdist t u := by simp [hausdorffEdist_comm, add_comm]
/-- Two sets are at zero Hausdorff edistance if and only if they have the same closure. -/
theorem hausdorffEdist_zero_iff_closure_eq_closure :
hausdorffEdist s t = 0 ↔ closure s = closure t := by
simp only [hausdorffEdist_def, ENNReal.sup_eq_zero, ENNReal.iSup_eq_zero, ← subset_def,
← mem_closure_iff_infEdist_zero, subset_antisymm_iff, isClosed_closure.closure_subset_iff]
/-- The Hausdorff edistance between a set and its closure vanishes. -/
@[simp]
theorem hausdorffEdist_self_closure : hausdorffEdist s (closure s) = 0 := by
rw [hausdorffEdist_zero_iff_closure_eq_closure, closure_closure]
/-- Replacing a set by its closure does not change the Hausdorff edistance. -/
@[simp]
theorem hausdorffEdist_closure₁ : hausdorffEdist (closure s) t = hausdorffEdist s t := by
refine le_antisymm ?_ ?_
· calc
_ ≤ hausdorffEdist (closure s) s + hausdorffEdist s t := hausdorffEdist_triangle
_ = hausdorffEdist s t := by simp [hausdorffEdist_comm]
· calc
_ ≤ hausdorffEdist s (closure s) + hausdorffEdist (closure s) t := hausdorffEdist_triangle
_ = hausdorffEdist (closure s) t := by simp
/-- Replacing a set by its closure does not change the Hausdorff edistance. -/
@[simp]
theorem hausdorffEdist_closure₂ : hausdorffEdist s (closure t) = hausdorffEdist s t := by
simp [@hausdorffEdist_comm _ _ s _]
/-- The Hausdorff edistance between sets or their closures is the same. -/
-- @[simp] -- Porting note (#10618): simp can prove this
theorem hausdorffEdist_closure : hausdorffEdist (closure s) (closure t) = hausdorffEdist s t := by
simp
/-- Two closed sets are at zero Hausdorff edistance if and only if they coincide. -/
theorem hausdorffEdist_zero_iff_eq_of_closed (hs : IsClosed s) (ht : IsClosed t) :
hausdorffEdist s t = 0 ↔ s = t := by
rw [hausdorffEdist_zero_iff_closure_eq_closure, hs.closure_eq, ht.closure_eq]
/-- The Haudorff edistance to the empty set is infinite. -/
theorem hausdorffEdist_empty (ne : s.Nonempty) : hausdorffEdist s ∅ = ∞ := by
rcases ne with ⟨x, xs⟩
have : infEdist x ∅ ≤ hausdorffEdist s ∅ := infEdist_le_hausdorffEdist_of_mem xs
simpa using this
/-- If a set is at finite Hausdorff edistance of a nonempty set, it is nonempty. -/
theorem nonempty_of_hausdorffEdist_ne_top (hs : s.Nonempty) (fin : hausdorffEdist s t ≠ ⊤) :
t.Nonempty :=
t.eq_empty_or_nonempty.resolve_left fun ht ↦ fin (ht.symm ▸ hausdorffEdist_empty hs)
theorem empty_or_nonempty_of_hausdorffEdist_ne_top (fin : hausdorffEdist s t ≠ ⊤) :
(s = ∅ ∧ t = ∅) ∨ (s.Nonempty ∧ t.Nonempty) := by
rcases s.eq_empty_or_nonempty with hs | hs
· rcases t.eq_empty_or_nonempty with ht | ht
· exact Or.inl ⟨hs, ht⟩
· rw [hausdorffEdist_comm] at fin
exact Or.inr ⟨nonempty_of_hausdorffEdist_ne_top ht fin, ht⟩
· exact Or.inr ⟨hs, nonempty_of_hausdorffEdist_ne_top hs fin⟩
end HausdorffEdist
-- section
end EMetric
/-! Now, we turn to the same notions in metric spaces. To avoid the difficulties related to
`sInf` and `sSup` on `ℝ` (which is only conditionally complete), we use the notions in `ℝ≥0∞`
formulated in terms of the edistance, and coerce them to `ℝ`.
Then their properties follow readily from the corresponding properties in `ℝ≥0∞`,
modulo some tedious rewriting of inequalities from one to the other. -/
--namespace
namespace Metric
section
variable [PseudoMetricSpace α] [PseudoMetricSpace β] {s t u : Set α} {x y : α} {Φ : α → β}
open EMetric
/-! ### Distance of a point to a set as a function into `ℝ`. -/
/-- The minimal distance of a point to a set -/
def infDist (x : α) (s : Set α) : ℝ :=
ENNReal.toReal (infEdist x s)
theorem infDist_eq_iInf : infDist x s = ⨅ y : s, dist x y := by
rw [infDist, infEdist, iInf_subtype', ENNReal.toReal_iInf]
· simp only [dist_edist]
· exact fun _ ↦ edist_ne_top _ _
/-- The minimal distance is always nonnegative -/
theorem infDist_nonneg : 0 ≤ infDist x s := toReal_nonneg
/-- The minimal distance to the empty set is 0 (if you want to have the more reasonable
value `∞` instead, use `EMetric.infEdist`, which takes values in `ℝ≥0∞`) -/
@[simp]
theorem infDist_empty : infDist x ∅ = 0 := by simp [infDist]
/-- In a metric space, the minimal edistance to a nonempty set is finite. -/
theorem infEdist_ne_top (h : s.Nonempty) : infEdist x s ≠ ⊤ := by
rcases h with ⟨y, hy⟩
exact ne_top_of_le_ne_top (edist_ne_top _ _) (infEdist_le_edist_of_mem hy)
-- Porting note (#11215): TODO: make it a `simp` lemma
theorem infEdist_eq_top_iff : infEdist x s = ∞ ↔ s = ∅ := by
rcases s.eq_empty_or_nonempty with rfl | hs <;> simp [*, Nonempty.ne_empty, infEdist_ne_top]
/-- The minimal distance of a point to a set containing it vanishes. -/
theorem infDist_zero_of_mem (h : x ∈ s) : infDist x s = 0 := by
simp [infEdist_zero_of_mem h, infDist]
/-- The minimal distance to a singleton is the distance to the unique point in this singleton. -/
@[simp]
theorem infDist_singleton : infDist x {y} = dist x y := by simp [infDist, dist_edist]
/-- The minimal distance to a set is bounded by the distance to any point in this set. -/
theorem infDist_le_dist_of_mem (h : y ∈ s) : infDist x s ≤ dist x y := by
rw [dist_edist, infDist]
exact ENNReal.toReal_mono (edist_ne_top _ _) (infEdist_le_edist_of_mem h)
/-- The minimal distance is monotone with respect to inclusion. -/
theorem infDist_le_infDist_of_subset (h : s ⊆ t) (hs : s.Nonempty) : infDist x t ≤ infDist x s :=
ENNReal.toReal_mono (infEdist_ne_top hs) (infEdist_anti h)
/-- The minimal distance to a set `s` is `< r` iff there exists a point in `s` at distance `< r`. -/
theorem infDist_lt_iff {r : ℝ} (hs : s.Nonempty) : infDist x s < r ↔ ∃ y ∈ s, dist x y < r := by
simp_rw [infDist, ← ENNReal.lt_ofReal_iff_toReal_lt (infEdist_ne_top hs), infEdist_lt_iff,
ENNReal.lt_ofReal_iff_toReal_lt (edist_ne_top _ _), ← dist_edist]
/-- The minimal distance from `x` to `s` is bounded by the distance from `y` to `s`, modulo
the distance between `x` and `y`. -/
theorem infDist_le_infDist_add_dist : infDist x s ≤ infDist y s + dist x y := by
rw [infDist, infDist, dist_edist]
refine ENNReal.toReal_le_add' infEdist_le_infEdist_add_edist ?_ (flip absurd (edist_ne_top _ _))
simp only [infEdist_eq_top_iff, imp_self]
theorem not_mem_of_dist_lt_infDist (h : dist x y < infDist x s) : y ∉ s := fun hy =>
h.not_le <| infDist_le_dist_of_mem hy
theorem disjoint_ball_infDist : Disjoint (ball x (infDist x s)) s :=
disjoint_left.2 fun _y hy => not_mem_of_dist_lt_infDist <| mem_ball'.1 hy
theorem ball_infDist_subset_compl : ball x (infDist x s) ⊆ sᶜ :=
(disjoint_ball_infDist (s := s)).subset_compl_right
theorem ball_infDist_compl_subset : ball x (infDist x sᶜ) ⊆ s :=
ball_infDist_subset_compl.trans_eq (compl_compl s)
theorem disjoint_closedBall_of_lt_infDist {r : ℝ} (h : r < infDist x s) :
Disjoint (closedBall x r) s :=
disjoint_ball_infDist.mono_left <| closedBall_subset_ball h
theorem dist_le_infDist_add_diam (hs : IsBounded s) (hy : y ∈ s) :
dist x y ≤ infDist x s + diam s := by
rw [infDist, diam, dist_edist]
exact toReal_le_add (edist_le_infEdist_add_ediam hy) (infEdist_ne_top ⟨y, hy⟩) hs.ediam_ne_top
variable (s)
/-- The minimal distance to a set is Lipschitz in point with constant 1 -/
theorem lipschitz_infDist_pt : LipschitzWith 1 (infDist · s) :=
LipschitzWith.of_le_add fun _ _ => infDist_le_infDist_add_dist
/-- The minimal distance to a set is uniformly continuous in point -/
theorem uniformContinuous_infDist_pt : UniformContinuous (infDist · s) :=
(lipschitz_infDist_pt s).uniformContinuous
/-- The minimal distance to a set is continuous in point -/
@[continuity]
theorem continuous_infDist_pt : Continuous (infDist · s) :=
(uniformContinuous_infDist_pt s).continuous
variable {s}
/-- The minimal distances to a set and its closure coincide. -/
theorem infDist_closure : infDist x (closure s) = infDist x s := by
simp [infDist, infEdist_closure]
/-- If a point belongs to the closure of `s`, then its infimum distance to `s` equals zero.
The converse is true provided that `s` is nonempty, see `Metric.mem_closure_iff_infDist_zero`. -/
theorem infDist_zero_of_mem_closure (hx : x ∈ closure s) : infDist x s = 0 := by
rw [← infDist_closure]
exact infDist_zero_of_mem hx
/-- A point belongs to the closure of `s` iff its infimum distance to this set vanishes. -/
theorem mem_closure_iff_infDist_zero (h : s.Nonempty) : x ∈ closure s ↔ infDist x s = 0 := by
simp [mem_closure_iff_infEdist_zero, infDist, ENNReal.toReal_eq_zero_iff, infEdist_ne_top h]
/-- Given a closed set `s`, a point belongs to `s` iff its infimum distance to this set vanishes -/
theorem _root_.IsClosed.mem_iff_infDist_zero (h : IsClosed s) (hs : s.Nonempty) :
x ∈ s ↔ infDist x s = 0 := by rw [← mem_closure_iff_infDist_zero hs, h.closure_eq]
/-- Given a closed set `s`, a point belongs to `s` iff its infimum distance to this set vanishes. -/
theorem _root_.IsClosed.not_mem_iff_infDist_pos (h : IsClosed s) (hs : s.Nonempty) :
x ∉ s ↔ 0 < infDist x s := by
simp [h.mem_iff_infDist_zero hs, infDist_nonneg.gt_iff_ne]
theorem continuousAt_inv_infDist_pt (h : x ∉ closure s) :
ContinuousAt (fun x ↦ (infDist x s)⁻¹) x := by
rcases s.eq_empty_or_nonempty with (rfl | hs)
· simp only [infDist_empty, continuousAt_const]
· refine (continuous_infDist_pt s).continuousAt.inv₀ ?_
rwa [Ne, ← mem_closure_iff_infDist_zero hs]
/-- The infimum distance is invariant under isometries. -/
theorem infDist_image (hΦ : Isometry Φ) : infDist (Φ x) (Φ '' t) = infDist x t := by
simp [infDist, infEdist_image hΦ]
theorem infDist_inter_closedBall_of_mem (h : y ∈ s) :
infDist x (s ∩ closedBall x (dist y x)) = infDist x s := by
replace h : y ∈ s ∩ closedBall x (dist y x) := ⟨h, mem_closedBall.2 le_rfl⟩
refine le_antisymm ?_ (infDist_le_infDist_of_subset inter_subset_left ⟨y, h⟩)
refine not_lt.1 fun hlt => ?_
rcases (infDist_lt_iff ⟨y, h.1⟩).mp hlt with ⟨z, hzs, hz⟩
rcases le_or_lt (dist z x) (dist y x) with hle | hlt
· exact hz.not_le (infDist_le_dist_of_mem ⟨hzs, hle⟩)
· rw [dist_comm z, dist_comm y] at hlt
exact (hlt.trans hz).not_le (infDist_le_dist_of_mem h)
theorem _root_.IsCompact.exists_infDist_eq_dist (h : IsCompact s) (hne : s.Nonempty) (x : α) :
∃ y ∈ s, infDist x s = dist x y :=
let ⟨y, hys, hy⟩ := h.exists_infEdist_eq_edist hne x
⟨y, hys, by rw [infDist, dist_edist, hy]⟩
theorem _root_.IsClosed.exists_infDist_eq_dist [ProperSpace α] (h : IsClosed s) (hne : s.Nonempty)
(x : α) : ∃ y ∈ s, infDist x s = dist x y := by
rcases hne with ⟨z, hz⟩
rw [← infDist_inter_closedBall_of_mem hz]
set t := s ∩ closedBall x (dist z x)
have htc : IsCompact t := (isCompact_closedBall x (dist z x)).inter_left h
have htne : t.Nonempty := ⟨z, hz, mem_closedBall.2 le_rfl⟩
obtain ⟨y, ⟨hys, -⟩, hyd⟩ : ∃ y ∈ t, infDist x t = dist x y := htc.exists_infDist_eq_dist htne x
exact ⟨y, hys, hyd⟩
theorem exists_mem_closure_infDist_eq_dist [ProperSpace α] (hne : s.Nonempty) (x : α) :
∃ y ∈ closure s, infDist x s = dist x y := by
simpa only [infDist_closure] using isClosed_closure.exists_infDist_eq_dist hne.closure x
/-! ### Distance of a point to a set as a function into `ℝ≥0`. -/
/-- The minimal distance of a point to a set as a `ℝ≥0` -/
def infNndist (x : α) (s : Set α) : ℝ≥0 :=
ENNReal.toNNReal (infEdist x s)
@[simp]
theorem coe_infNndist : (infNndist x s : ℝ) = infDist x s :=
rfl
/-- The minimal distance to a set (as `ℝ≥0`) is Lipschitz in point with constant 1 -/
theorem lipschitz_infNndist_pt (s : Set α) : LipschitzWith 1 fun x => infNndist x s :=
LipschitzWith.of_le_add fun _ _ => infDist_le_infDist_add_dist
/-- The minimal distance to a set (as `ℝ≥0`) is uniformly continuous in point -/
theorem uniformContinuous_infNndist_pt (s : Set α) : UniformContinuous fun x => infNndist x s :=
(lipschitz_infNndist_pt s).uniformContinuous
/-- The minimal distance to a set (as `ℝ≥0`) is continuous in point -/
theorem continuous_infNndist_pt (s : Set α) : Continuous fun x => infNndist x s :=
(uniformContinuous_infNndist_pt s).continuous
/-! ### The Hausdorff distance as a function into `ℝ`. -/
/-- The Hausdorff distance between two sets is the smallest nonnegative `r` such that each set is
included in the `r`-neighborhood of the other. If there is no such `r`, it is defined to
be `0`, arbitrarily. -/
def hausdorffDist (s t : Set α) : ℝ :=
ENNReal.toReal (hausdorffEdist s t)
/-- The Hausdorff distance is nonnegative. -/
theorem hausdorffDist_nonneg : 0 ≤ hausdorffDist s t := by simp [hausdorffDist]
/-- If two sets are nonempty and bounded in a metric space, they are at finite Hausdorff
edistance. -/
theorem hausdorffEdist_ne_top_of_nonempty_of_bounded (hs : s.Nonempty) (ht : t.Nonempty)
(bs : IsBounded s) (bt : IsBounded t) : hausdorffEdist s t ≠ ⊤ := by
rcases hs with ⟨cs, hcs⟩
rcases ht with ⟨ct, hct⟩
rcases bs.subset_closedBall ct with ⟨rs, hrs⟩
rcases bt.subset_closedBall cs with ⟨rt, hrt⟩
have : hausdorffEdist s t ≤ ENNReal.ofReal (max rs rt) := by
apply hausdorffEdist_le_of_mem_edist
· intro x xs
exists ct, hct
have : dist x ct ≤ max rs rt := le_trans (hrs xs) (le_max_left _ _)
rwa [edist_dist, ENNReal.ofReal_le_ofReal_iff]
exact le_trans dist_nonneg this
· intro x xt
exists cs, hcs
have : dist x cs ≤ max rs rt := le_trans (hrt xt) (le_max_right _ _)
rwa [edist_dist, ENNReal.ofReal_le_ofReal_iff]
exact le_trans dist_nonneg this
exact ne_top_of_le_ne_top ENNReal.ofReal_ne_top this
/-- The Hausdorff distance between a set and itself is zero. -/
@[simp]
theorem hausdorffDist_self_zero : hausdorffDist s s = 0 := by simp [hausdorffDist]
/-- The Hausdorff distances from `s` to `t` and from `t` to `s` coincide. -/
theorem hausdorffDist_comm : hausdorffDist s t = hausdorffDist t s := by
simp [hausdorffDist, hausdorffEdist_comm]
/-- The Hausdorff distance to the empty set vanishes (if you want to have the more reasonable
value `∞` instead, use `EMetric.hausdorffEdist`, which takes values in `ℝ≥0∞`). -/
@[simp]
theorem hausdorffDist_empty : hausdorffDist s ∅ = 0 := by
rcases s.eq_empty_or_nonempty with h | h
· simp [h]
· simp [hausdorffDist, hausdorffEdist_empty h]
/-- The Hausdorff distance to the empty set vanishes (if you want to have the more reasonable
value `∞` instead, use `EMetric.hausdorffEdist`, which takes values in `ℝ≥0∞`). -/
@[simp]
theorem hausdorffDist_empty' : hausdorffDist ∅ s = 0 := by simp [hausdorffDist_comm]
/-- Bounding the Hausdorff distance by bounding the distance of any point
in each set to the other set -/
theorem hausdorffDist_le_of_infDist {r : ℝ} (hr : 0 ≤ r) (H1 : ∀ x ∈ s, infDist x t ≤ r)
(H2 : ∀ x ∈ t, infDist x s ≤ r) : hausdorffDist s t ≤ r := by
by_cases h1 : hausdorffEdist s t = ⊤
· rwa [hausdorffDist, h1, ENNReal.top_toReal]
rcases s.eq_empty_or_nonempty with hs | hs
· rwa [hs, hausdorffDist_empty']
rcases t.eq_empty_or_nonempty with ht | ht
· rwa [ht, hausdorffDist_empty]
have : hausdorffEdist s t ≤ ENNReal.ofReal r := by
apply hausdorffEdist_le_of_infEdist _ _
· intro x hx
have I := H1 x hx
rwa [infDist, ← ENNReal.toReal_ofReal hr,
ENNReal.toReal_le_toReal (infEdist_ne_top ht) ENNReal.ofReal_ne_top] at I
· intro x hx
have I := H2 x hx
rwa [infDist, ← ENNReal.toReal_ofReal hr,
ENNReal.toReal_le_toReal (infEdist_ne_top hs) ENNReal.ofReal_ne_top] at I
rwa [hausdorffDist, ← ENNReal.toReal_ofReal hr,
ENNReal.toReal_le_toReal h1 ENNReal.ofReal_ne_top]
/-- Bounding the Hausdorff distance by exhibiting, for any point in each set,
another point in the other set at controlled distance -/
theorem hausdorffDist_le_of_mem_dist {r : ℝ} (hr : 0 ≤ r) (H1 : ∀ x ∈ s, ∃ y ∈ t, dist x y ≤ r)
(H2 : ∀ x ∈ t, ∃ y ∈ s, dist x y ≤ r) : hausdorffDist s t ≤ r := by
apply hausdorffDist_le_of_infDist hr
· intro x xs
rcases H1 x xs with ⟨y, yt, hy⟩
exact le_trans (infDist_le_dist_of_mem yt) hy
· intro x xt
rcases H2 x xt with ⟨y, ys, hy⟩
exact le_trans (infDist_le_dist_of_mem ys) hy
/-- The Hausdorff distance is controlled by the diameter of the union. -/
theorem hausdorffDist_le_diam (hs : s.Nonempty) (bs : IsBounded s) (ht : t.Nonempty)
(bt : IsBounded t) : hausdorffDist s t ≤ diam (s ∪ t) := by
rcases hs with ⟨x, xs⟩
rcases ht with ⟨y, yt⟩
refine hausdorffDist_le_of_mem_dist diam_nonneg ?_ ?_
· exact fun z hz => ⟨y, yt, dist_le_diam_of_mem (bs.union bt) (subset_union_left hz)
(subset_union_right yt)⟩
· exact fun z hz => ⟨x, xs, dist_le_diam_of_mem (bs.union bt) (subset_union_right hz)
(subset_union_left xs)⟩
/-- The distance to a set is controlled by the Hausdorff distance. -/
theorem infDist_le_hausdorffDist_of_mem (hx : x ∈ s) (fin : hausdorffEdist s t ≠ ⊤) :
infDist x t ≤ hausdorffDist s t :=
toReal_mono fin (infEdist_le_hausdorffEdist_of_mem hx)
/-- If the Hausdorff distance is `< r`, any point in one of the sets is at distance
`< r` of a point in the other set. -/
theorem exists_dist_lt_of_hausdorffDist_lt {r : ℝ} (h : x ∈ s) (H : hausdorffDist s t < r)
(fin : hausdorffEdist s t ≠ ⊤) : ∃ y ∈ t, dist x y < r := by
have r0 : 0 < r := lt_of_le_of_lt hausdorffDist_nonneg H
have : hausdorffEdist s t < ENNReal.ofReal r := by
rwa [hausdorffDist, ← ENNReal.toReal_ofReal (le_of_lt r0),
ENNReal.toReal_lt_toReal fin ENNReal.ofReal_ne_top] at H
rcases exists_edist_lt_of_hausdorffEdist_lt h this with ⟨y, hy, yr⟩
rw [edist_dist, ENNReal.ofReal_lt_ofReal_iff r0] at yr
exact ⟨y, hy, yr⟩
/-- If the Hausdorff distance is `< r`, any point in one of the sets is at distance
`< r` of a point in the other set. -/
theorem exists_dist_lt_of_hausdorffDist_lt' {r : ℝ} (h : y ∈ t) (H : hausdorffDist s t < r)
(fin : hausdorffEdist s t ≠ ⊤) : ∃ x ∈ s, dist x y < r := by
rw [hausdorffDist_comm] at H
rw [hausdorffEdist_comm] at fin
simpa [dist_comm] using exists_dist_lt_of_hausdorffDist_lt h H fin
/-- The infimum distance to `s` and `t` are the same, up to the Hausdorff distance
between `s` and `t` -/
theorem infDist_le_infDist_add_hausdorffDist (fin : hausdorffEdist s t ≠ ⊤) :
infDist x t ≤ infDist x s + hausdorffDist s t := by
refine toReal_le_add' infEdist_le_infEdist_add_hausdorffEdist (fun h ↦ ?_) (flip absurd fin)
rw [infEdist_eq_top_iff, ← not_nonempty_iff_eq_empty] at h ⊢
rw [hausdorffEdist_comm] at fin
exact mt (nonempty_of_hausdorffEdist_ne_top · fin) h
/-- The Hausdorff distance is invariant under isometries. -/
theorem hausdorffDist_image (h : Isometry Φ) :
hausdorffDist (Φ '' s) (Φ '' t) = hausdorffDist s t := by
simp [hausdorffDist, hausdorffEdist_image h]
/-- The Hausdorff distance satisfies the triangle inequality. -/
theorem hausdorffDist_triangle (fin : hausdorffEdist s t ≠ ⊤) :
hausdorffDist s u ≤ hausdorffDist s t + hausdorffDist t u := by
refine toReal_le_add' hausdorffEdist_triangle (flip absurd fin) (not_imp_not.1 fun h ↦ ?_)
rw [hausdorffEdist_comm] at fin
exact ne_top_of_le_ne_top (add_ne_top.2 ⟨fin, h⟩) hausdorffEdist_triangle
/-- The Hausdorff distance satisfies the triangle inequality. -/
theorem hausdorffDist_triangle' (fin : hausdorffEdist t u ≠ ⊤) :
hausdorffDist s u ≤ hausdorffDist s t + hausdorffDist t u := by
rw [hausdorffEdist_comm] at fin
have I : hausdorffDist u s ≤ hausdorffDist u t + hausdorffDist t s :=
hausdorffDist_triangle fin
simpa [add_comm, hausdorffDist_comm] using I
/-- The Hausdorff distance between a set and its closure vanishes. -/
@[simp]
theorem hausdorffDist_self_closure : hausdorffDist s (closure s) = 0 := by simp [hausdorffDist]
/-- Replacing a set by its closure does not change the Hausdorff distance. -/
@[simp]
theorem hausdorffDist_closure₁ : hausdorffDist (closure s) t = hausdorffDist s t := by
simp [hausdorffDist]
/-- Replacing a set by its closure does not change the Hausdorff distance. -/
@[simp]
theorem hausdorffDist_closure₂ : hausdorffDist s (closure t) = hausdorffDist s t := by
simp [hausdorffDist]
/-- The Hausdorff distances between two sets and their closures coincide. -/
-- @[simp] -- Porting note (#10618): simp can prove this
theorem hausdorffDist_closure : hausdorffDist (closure s) (closure t) = hausdorffDist s t := by
simp [hausdorffDist]
/-- Two sets are at zero Hausdorff distance if and only if they have the same closures. -/
theorem hausdorffDist_zero_iff_closure_eq_closure (fin : hausdorffEdist s t ≠ ⊤) :
hausdorffDist s t = 0 ↔ closure s = closure t := by
simp [← hausdorffEdist_zero_iff_closure_eq_closure, hausdorffDist,
ENNReal.toReal_eq_zero_iff, fin]
/-- Two closed sets are at zero Hausdorff distance if and only if they coincide. -/
theorem _root_.IsClosed.hausdorffDist_zero_iff_eq (hs : IsClosed s) (ht : IsClosed t)
(fin : hausdorffEdist s t ≠ ⊤) : hausdorffDist s t = 0 ↔ s = t := by
simp [← hausdorffEdist_zero_iff_eq_of_closed hs ht, hausdorffDist, ENNReal.toReal_eq_zero_iff,
fin]
end
end Metric
|
Topology\MetricSpace\Holder.lean | /-
Copyright (c) 2021 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov
-/
import Mathlib.Topology.MetricSpace.Lipschitz
import Mathlib.Analysis.SpecialFunctions.Pow.Continuity
/-!
# Hölder continuous functions
In this file we define Hölder continuity on a set and on the whole space. We also prove some basic
properties of Hölder continuous functions.
## Main definitions
* `HolderOnWith`: `f : X → Y` is said to be *Hölder continuous* with constant `C : ℝ≥0` and
exponent `r : ℝ≥0` on a set `s`, if `edist (f x) (f y) ≤ C * edist x y ^ r` for all `x y ∈ s`;
* `HolderWith`: `f : X → Y` is said to be *Hölder continuous* with constant `C : ℝ≥0` and exponent
`r : ℝ≥0`, if `edist (f x) (f y) ≤ C * edist x y ^ r` for all `x y : X`.
## Implementation notes
We use the type `ℝ≥0` (a.k.a. `NNReal`) for `C` because this type has coercion both to `ℝ` and
`ℝ≥0∞`, so it can be easily used both in inequalities about `dist` and `edist`. We also use `ℝ≥0`
for `r` to ensure that `d ^ r` is monotone in `d`. It might be a good idea to use
`ℝ>0` for `r` but we don't have this type in `mathlib` (yet).
## Tags
Hölder continuity, Lipschitz continuity
-/
variable {X Y Z : Type*}
open Filter Set
open NNReal ENNReal Topology
section Emetric
variable [PseudoEMetricSpace X] [PseudoEMetricSpace Y] [PseudoEMetricSpace Z]
/-- A function `f : X → Y` between two `PseudoEMetricSpace`s is Hölder continuous with constant
`C : ℝ≥0` and exponent `r : ℝ≥0`, if `edist (f x) (f y) ≤ C * edist x y ^ r` for all `x y : X`. -/
def HolderWith (C r : ℝ≥0) (f : X → Y) : Prop :=
∀ x y, edist (f x) (f y) ≤ (C : ℝ≥0∞) * edist x y ^ (r : ℝ)
/-- A function `f : X → Y` between two `PseudoEMetricSpace`s is Hölder continuous with constant
`C : ℝ≥0` and exponent `r : ℝ≥0` on a set `s : Set X`, if `edist (f x) (f y) ≤ C * edist x y ^ r`
for all `x y ∈ s`. -/
def HolderOnWith (C r : ℝ≥0) (f : X → Y) (s : Set X) : Prop :=
∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) ≤ (C : ℝ≥0∞) * edist x y ^ (r : ℝ)
@[simp]
theorem holderOnWith_empty (C r : ℝ≥0) (f : X → Y) : HolderOnWith C r f ∅ := fun _ hx => hx.elim
@[simp]
theorem holderOnWith_singleton (C r : ℝ≥0) (f : X → Y) (x : X) : HolderOnWith C r f {x} := by
rintro a (rfl : a = x) b (rfl : b = a)
rw [edist_self]
exact zero_le _
theorem Set.Subsingleton.holderOnWith {s : Set X} (hs : s.Subsingleton) (C r : ℝ≥0) (f : X → Y) :
HolderOnWith C r f s :=
hs.induction_on (holderOnWith_empty C r f) (holderOnWith_singleton C r f)
theorem holderOnWith_univ {C r : ℝ≥0} {f : X → Y} : HolderOnWith C r f univ ↔ HolderWith C r f := by
simp only [HolderOnWith, HolderWith, mem_univ, true_imp_iff]
@[simp]
theorem holderOnWith_one {C : ℝ≥0} {f : X → Y} {s : Set X} :
HolderOnWith C 1 f s ↔ LipschitzOnWith C f s := by
simp only [HolderOnWith, LipschitzOnWith, NNReal.coe_one, ENNReal.rpow_one]
alias ⟨_, LipschitzOnWith.holderOnWith⟩ := holderOnWith_one
@[simp]
theorem holderWith_one {C : ℝ≥0} {f : X → Y} : HolderWith C 1 f ↔ LipschitzWith C f :=
holderOnWith_univ.symm.trans <| holderOnWith_one.trans lipschitzOnWith_univ
alias ⟨_, LipschitzWith.holderWith⟩ := holderWith_one
theorem holderWith_id : HolderWith 1 1 (id : X → X) :=
LipschitzWith.id.holderWith
protected theorem HolderWith.holderOnWith {C r : ℝ≥0} {f : X → Y} (h : HolderWith C r f)
(s : Set X) : HolderOnWith C r f s := fun x _ y _ => h x y
namespace HolderOnWith
variable {C r : ℝ≥0} {f : X → Y} {s t : Set X}
theorem edist_le (h : HolderOnWith C r f s) {x y : X} (hx : x ∈ s) (hy : y ∈ s) :
edist (f x) (f y) ≤ (C : ℝ≥0∞) * edist x y ^ (r : ℝ) :=
h x hx y hy
theorem edist_le_of_le (h : HolderOnWith C r f s) {x y : X} (hx : x ∈ s) (hy : y ∈ s) {d : ℝ≥0∞}
(hd : edist x y ≤ d) : edist (f x) (f y) ≤ (C : ℝ≥0∞) * d ^ (r : ℝ) :=
(h.edist_le hx hy).trans <| by gcongr
theorem comp {Cg rg : ℝ≥0} {g : Y → Z} {t : Set Y} (hg : HolderOnWith Cg rg g t) {Cf rf : ℝ≥0}
{f : X → Y} (hf : HolderOnWith Cf rf f s) (hst : MapsTo f s t) :
HolderOnWith (Cg * Cf ^ (rg : ℝ)) (rg * rf) (g ∘ f) s := by
intro x hx y hy
rw [ENNReal.coe_mul, mul_comm rg, NNReal.coe_mul, ENNReal.rpow_mul, mul_assoc,
← ENNReal.coe_rpow_of_nonneg _ rg.coe_nonneg, ← ENNReal.mul_rpow_of_nonneg _ _ rg.coe_nonneg]
exact hg.edist_le_of_le (hst hx) (hst hy) (hf.edist_le hx hy)
theorem comp_holderWith {Cg rg : ℝ≥0} {g : Y → Z} {t : Set Y} (hg : HolderOnWith Cg rg g t)
{Cf rf : ℝ≥0} {f : X → Y} (hf : HolderWith Cf rf f) (ht : ∀ x, f x ∈ t) :
HolderWith (Cg * Cf ^ (rg : ℝ)) (rg * rf) (g ∘ f) :=
holderOnWith_univ.mp <| hg.comp (hf.holderOnWith univ) fun x _ => ht x
/-- A Hölder continuous function is uniformly continuous -/
protected theorem uniformContinuousOn (hf : HolderOnWith C r f s) (h0 : 0 < r) :
UniformContinuousOn f s := by
refine EMetric.uniformContinuousOn_iff.2 fun ε εpos => ?_
have : Tendsto (fun d : ℝ≥0∞ => (C : ℝ≥0∞) * d ^ (r : ℝ)) (𝓝 0) (𝓝 0) :=
ENNReal.tendsto_const_mul_rpow_nhds_zero_of_pos ENNReal.coe_ne_top h0
rcases ENNReal.nhds_zero_basis.mem_iff.1 (this (gt_mem_nhds εpos)) with ⟨δ, δ0, H⟩
exact ⟨δ, δ0, fun hx y hy h => (hf.edist_le hx hy).trans_lt (H h)⟩
protected theorem continuousOn (hf : HolderOnWith C r f s) (h0 : 0 < r) : ContinuousOn f s :=
(hf.uniformContinuousOn h0).continuousOn
protected theorem mono (hf : HolderOnWith C r f s) (ht : t ⊆ s) : HolderOnWith C r f t :=
fun _ hx _ hy => hf.edist_le (ht hx) (ht hy)
theorem ediam_image_le_of_le (hf : HolderOnWith C r f s) {d : ℝ≥0∞} (hd : EMetric.diam s ≤ d) :
EMetric.diam (f '' s) ≤ (C : ℝ≥0∞) * d ^ (r : ℝ) :=
EMetric.diam_image_le_iff.2 fun _ hx _ hy =>
hf.edist_le_of_le hx hy <| (EMetric.edist_le_diam_of_mem hx hy).trans hd
theorem ediam_image_le (hf : HolderOnWith C r f s) :
EMetric.diam (f '' s) ≤ (C : ℝ≥0∞) * EMetric.diam s ^ (r : ℝ) :=
hf.ediam_image_le_of_le le_rfl
theorem ediam_image_le_of_subset (hf : HolderOnWith C r f s) (ht : t ⊆ s) :
EMetric.diam (f '' t) ≤ (C : ℝ≥0∞) * EMetric.diam t ^ (r : ℝ) :=
(hf.mono ht).ediam_image_le
theorem ediam_image_le_of_subset_of_le (hf : HolderOnWith C r f s) (ht : t ⊆ s) {d : ℝ≥0∞}
(hd : EMetric.diam t ≤ d) : EMetric.diam (f '' t) ≤ (C : ℝ≥0∞) * d ^ (r : ℝ) :=
(hf.mono ht).ediam_image_le_of_le hd
theorem ediam_image_inter_le_of_le (hf : HolderOnWith C r f s) {d : ℝ≥0∞}
(hd : EMetric.diam t ≤ d) : EMetric.diam (f '' (t ∩ s)) ≤ (C : ℝ≥0∞) * d ^ (r : ℝ) :=
hf.ediam_image_le_of_subset_of_le inter_subset_right <|
(EMetric.diam_mono inter_subset_left).trans hd
theorem ediam_image_inter_le (hf : HolderOnWith C r f s) (t : Set X) :
EMetric.diam (f '' (t ∩ s)) ≤ (C : ℝ≥0∞) * EMetric.diam t ^ (r : ℝ) :=
hf.ediam_image_inter_le_of_le le_rfl
end HolderOnWith
namespace HolderWith
variable {C r : ℝ≥0} {f : X → Y}
theorem edist_le (h : HolderWith C r f) (x y : X) :
edist (f x) (f y) ≤ (C : ℝ≥0∞) * edist x y ^ (r : ℝ) :=
h x y
theorem edist_le_of_le (h : HolderWith C r f) {x y : X} {d : ℝ≥0∞} (hd : edist x y ≤ d) :
edist (f x) (f y) ≤ (C : ℝ≥0∞) * d ^ (r : ℝ) :=
(h.holderOnWith univ).edist_le_of_le trivial trivial hd
theorem comp {Cg rg : ℝ≥0} {g : Y → Z} (hg : HolderWith Cg rg g) {Cf rf : ℝ≥0} {f : X → Y}
(hf : HolderWith Cf rf f) : HolderWith (Cg * Cf ^ (rg : ℝ)) (rg * rf) (g ∘ f) :=
(hg.holderOnWith univ).comp_holderWith hf fun _ => trivial
theorem comp_holderOnWith {Cg rg : ℝ≥0} {g : Y → Z} (hg : HolderWith Cg rg g) {Cf rf : ℝ≥0}
{f : X → Y} {s : Set X} (hf : HolderOnWith Cf rf f s) :
HolderOnWith (Cg * Cf ^ (rg : ℝ)) (rg * rf) (g ∘ f) s :=
(hg.holderOnWith univ).comp hf fun _ _ => trivial
/-- A Hölder continuous function is uniformly continuous -/
protected theorem uniformContinuous (hf : HolderWith C r f) (h0 : 0 < r) : UniformContinuous f :=
uniformContinuousOn_univ.mp <| (hf.holderOnWith univ).uniformContinuousOn h0
protected theorem continuous (hf : HolderWith C r f) (h0 : 0 < r) : Continuous f :=
(hf.uniformContinuous h0).continuous
theorem ediam_image_le (hf : HolderWith C r f) (s : Set X) :
EMetric.diam (f '' s) ≤ (C : ℝ≥0∞) * EMetric.diam s ^ (r : ℝ) :=
EMetric.diam_image_le_iff.2 fun _ hx _ hy =>
hf.edist_le_of_le <| EMetric.edist_le_diam_of_mem hx hy
end HolderWith
end Emetric
section Metric
variable [PseudoMetricSpace X] [PseudoMetricSpace Y] {C r : ℝ≥0} {f : X → Y}
namespace HolderWith
theorem nndist_le_of_le (hf : HolderWith C r f) {x y : X} {d : ℝ≥0} (hd : nndist x y ≤ d) :
nndist (f x) (f y) ≤ C * d ^ (r : ℝ) := by
rw [← ENNReal.coe_le_coe, ← edist_nndist, ENNReal.coe_mul, ←
ENNReal.coe_rpow_of_nonneg _ r.coe_nonneg]
apply hf.edist_le_of_le
rwa [edist_nndist, ENNReal.coe_le_coe]
theorem nndist_le (hf : HolderWith C r f) (x y : X) :
nndist (f x) (f y) ≤ C * nndist x y ^ (r : ℝ) :=
hf.nndist_le_of_le le_rfl
theorem dist_le_of_le (hf : HolderWith C r f) {x y : X} {d : ℝ} (hd : dist x y ≤ d) :
dist (f x) (f y) ≤ C * d ^ (r : ℝ) := by
lift d to ℝ≥0 using dist_nonneg.trans hd
rw [dist_nndist] at hd ⊢
norm_cast at hd ⊢
exact hf.nndist_le_of_le hd
theorem dist_le (hf : HolderWith C r f) (x y : X) : dist (f x) (f y) ≤ C * dist x y ^ (r : ℝ) :=
hf.dist_le_of_le le_rfl
end HolderWith
end Metric
|
Topology\MetricSpace\Infsep.lean | /-
Copyright (c) 2022 Wrenna Robson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Wrenna Robson
-/
import Mathlib.Topology.MetricSpace.Basic
/-!
# Infimum separation
This file defines the extended infimum separation of a set. This is approximately dual to the
diameter of a set, but where the extended diameter of a set is the supremum of the extended distance
between elements of the set, the extended infimum separation is the infimum of the (extended)
distance between *distinct* elements in the set.
We also define the infimum separation as the cast of the extended infimum separation to the reals.
This is the infimum of the distance between distinct elements of the set when in a pseudometric
space.
All lemmas and definitions are in the `Set` namespace to give access to dot notation.
## Main definitions
* `Set.einfsep`: Extended infimum separation of a set.
* `Set.infsep`: Infimum separation of a set (when in a pseudometric space).
!-/
variable {α β : Type*}
namespace Set
section Einfsep
open ENNReal
open Function
/-- The "extended infimum separation" of a set with an edist function. -/
noncomputable def einfsep [EDist α] (s : Set α) : ℝ≥0∞ :=
⨅ (x ∈ s) (y ∈ s) (_ : x ≠ y), edist x y
section EDist
variable [EDist α] {x y : α} {s t : Set α}
theorem le_einfsep_iff {d} :
d ≤ s.einfsep ↔ ∀ x ∈ s, ∀ y ∈ s, x ≠ y → d ≤ edist x y := by
simp_rw [einfsep, le_iInf_iff]
theorem einfsep_zero : s.einfsep = 0 ↔ ∀ C > 0, ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < C := by
simp_rw [einfsep, ← _root_.bot_eq_zero, iInf_eq_bot, iInf_lt_iff, exists_prop]
theorem einfsep_pos : 0 < s.einfsep ↔ ∃ C > 0, ∀ x ∈ s, ∀ y ∈ s, x ≠ y → C ≤ edist x y := by
rw [pos_iff_ne_zero, Ne, einfsep_zero]
simp only [not_forall, not_exists, not_lt, exists_prop, not_and]
theorem einfsep_top :
s.einfsep = ∞ ↔ ∀ x ∈ s, ∀ y ∈ s, x ≠ y → edist x y = ∞ := by
simp_rw [einfsep, iInf_eq_top]
theorem einfsep_lt_top :
s.einfsep < ∞ ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < ∞ := by
simp_rw [einfsep, iInf_lt_iff, exists_prop]
theorem einfsep_ne_top :
s.einfsep ≠ ∞ ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y ≠ ∞ := by
simp_rw [← lt_top_iff_ne_top, einfsep_lt_top]
theorem einfsep_lt_iff {d} :
s.einfsep < d ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < d := by
simp_rw [einfsep, iInf_lt_iff, exists_prop]
theorem nontrivial_of_einfsep_lt_top (hs : s.einfsep < ∞) : s.Nontrivial := by
rcases einfsep_lt_top.1 hs with ⟨_, hx, _, hy, hxy, _⟩
exact ⟨_, hx, _, hy, hxy⟩
theorem nontrivial_of_einfsep_ne_top (hs : s.einfsep ≠ ∞) : s.Nontrivial :=
nontrivial_of_einfsep_lt_top (lt_top_iff_ne_top.mpr hs)
theorem Subsingleton.einfsep (hs : s.Subsingleton) : s.einfsep = ∞ := by
rw [einfsep_top]
exact fun _ hx _ hy hxy => (hxy <| hs hx hy).elim
theorem le_einfsep_image_iff {d} {f : β → α} {s : Set β} : d ≤ einfsep (f '' s)
↔ ∀ x ∈ s, ∀ y ∈ s, f x ≠ f y → d ≤ edist (f x) (f y) := by
simp_rw [le_einfsep_iff, forall_mem_image]
theorem le_edist_of_le_einfsep {d x} (hx : x ∈ s) {y} (hy : y ∈ s) (hxy : x ≠ y)
(hd : d ≤ s.einfsep) : d ≤ edist x y :=
le_einfsep_iff.1 hd x hx y hy hxy
theorem einfsep_le_edist_of_mem {x} (hx : x ∈ s) {y} (hy : y ∈ s) (hxy : x ≠ y) :
s.einfsep ≤ edist x y :=
le_edist_of_le_einfsep hx hy hxy le_rfl
theorem einfsep_le_of_mem_of_edist_le {d x} (hx : x ∈ s) {y} (hy : y ∈ s) (hxy : x ≠ y)
(hxy' : edist x y ≤ d) : s.einfsep ≤ d :=
le_trans (einfsep_le_edist_of_mem hx hy hxy) hxy'
theorem le_einfsep {d} (h : ∀ x ∈ s, ∀ y ∈ s, x ≠ y → d ≤ edist x y) : d ≤ s.einfsep :=
le_einfsep_iff.2 h
@[simp]
theorem einfsep_empty : (∅ : Set α).einfsep = ∞ :=
subsingleton_empty.einfsep
@[simp]
theorem einfsep_singleton : ({x} : Set α).einfsep = ∞ :=
subsingleton_singleton.einfsep
theorem einfsep_iUnion_mem_option {ι : Type*} (o : Option ι) (s : ι → Set α) :
(⋃ i ∈ o, s i).einfsep = ⨅ i ∈ o, (s i).einfsep := by cases o <;> simp
theorem einfsep_anti (hst : s ⊆ t) : t.einfsep ≤ s.einfsep :=
le_einfsep fun _x hx _y hy => einfsep_le_edist_of_mem (hst hx) (hst hy)
theorem einfsep_insert_le : (insert x s).einfsep ≤ ⨅ (y ∈ s) (_ : x ≠ y), edist x y := by
simp_rw [le_iInf_iff]
exact fun _ hy hxy => einfsep_le_edist_of_mem (mem_insert _ _) (mem_insert_of_mem _ hy) hxy
theorem le_einfsep_pair : edist x y ⊓ edist y x ≤ ({x, y} : Set α).einfsep := by
simp_rw [le_einfsep_iff, inf_le_iff, mem_insert_iff, mem_singleton_iff]
rintro a (rfl | rfl) b (rfl | rfl) hab <;> (try simp only [le_refl, true_or, or_true]) <;>
contradiction
theorem einfsep_pair_le_left (hxy : x ≠ y) : ({x, y} : Set α).einfsep ≤ edist x y :=
einfsep_le_edist_of_mem (mem_insert _ _) (mem_insert_of_mem _ (mem_singleton _)) hxy
theorem einfsep_pair_le_right (hxy : x ≠ y) : ({x, y} : Set α).einfsep ≤ edist y x := by
rw [pair_comm]; exact einfsep_pair_le_left hxy.symm
theorem einfsep_pair_eq_inf (hxy : x ≠ y) : ({x, y} : Set α).einfsep = edist x y ⊓ edist y x :=
le_antisymm (le_inf (einfsep_pair_le_left hxy) (einfsep_pair_le_right hxy)) le_einfsep_pair
theorem einfsep_eq_iInf : s.einfsep = ⨅ d : s.offDiag, (uncurry edist) (d : α × α) := by
refine eq_of_forall_le_iff fun _ => ?_
simp_rw [le_einfsep_iff, le_iInf_iff, imp_forall_iff, SetCoe.forall, mem_offDiag,
Prod.forall, uncurry_apply_pair, and_imp]
theorem einfsep_of_fintype [DecidableEq α] [Fintype s] :
s.einfsep = s.offDiag.toFinset.inf (uncurry edist) := by
refine eq_of_forall_le_iff fun _ => ?_
simp_rw [le_einfsep_iff, imp_forall_iff, Finset.le_inf_iff, mem_toFinset, mem_offDiag,
Prod.forall, uncurry_apply_pair, and_imp]
theorem Finite.einfsep (hs : s.Finite) : s.einfsep = hs.offDiag.toFinset.inf (uncurry edist) := by
refine eq_of_forall_le_iff fun _ => ?_
simp_rw [le_einfsep_iff, imp_forall_iff, Finset.le_inf_iff, Finite.mem_toFinset, mem_offDiag,
Prod.forall, uncurry_apply_pair, and_imp]
theorem Finset.coe_einfsep [DecidableEq α] {s : Finset α} :
(s : Set α).einfsep = s.offDiag.inf (uncurry edist) := by
simp_rw [einfsep_of_fintype, ← Finset.coe_offDiag, Finset.toFinset_coe]
theorem Nontrivial.einfsep_exists_of_finite [Finite s] (hs : s.Nontrivial) :
∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ s.einfsep = edist x y := by
classical
cases nonempty_fintype s
simp_rw [einfsep_of_fintype]
rcases Finset.exists_mem_eq_inf s.offDiag.toFinset (by simpa) (uncurry edist) with ⟨w, hxy, hed⟩
simp_rw [mem_toFinset] at hxy
exact ⟨w.fst, hxy.1, w.snd, hxy.2.1, hxy.2.2, hed⟩
theorem Finite.einfsep_exists_of_nontrivial (hsf : s.Finite) (hs : s.Nontrivial) :
∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ s.einfsep = edist x y :=
letI := hsf.fintype
hs.einfsep_exists_of_finite
end EDist
section PseudoEMetricSpace
variable [PseudoEMetricSpace α] {x y z : α} {s t : Set α}
theorem einfsep_pair (hxy : x ≠ y) : ({x, y} : Set α).einfsep = edist x y := by
nth_rw 1 [← min_self (edist x y)]
convert einfsep_pair_eq_inf hxy using 2
rw [edist_comm]
theorem einfsep_insert : einfsep (insert x s) =
(⨅ (y ∈ s) (_ : x ≠ y), edist x y) ⊓ s.einfsep := by
refine le_antisymm (le_min einfsep_insert_le (einfsep_anti (subset_insert _ _))) ?_
simp_rw [le_einfsep_iff, inf_le_iff, mem_insert_iff]
rintro y (rfl | hy) z (rfl | hz) hyz
· exact False.elim (hyz rfl)
· exact Or.inl (iInf_le_of_le _ (iInf₂_le hz hyz))
· rw [edist_comm]
exact Or.inl (iInf_le_of_le _ (iInf₂_le hy hyz.symm))
· exact Or.inr (einfsep_le_edist_of_mem hy hz hyz)
theorem einfsep_triple (hxy : x ≠ y) (hyz : y ≠ z) (hxz : x ≠ z) :
einfsep ({x, y, z} : Set α) = edist x y ⊓ edist x z ⊓ edist y z := by
simp_rw [einfsep_insert, iInf_insert, iInf_singleton, einfsep_singleton, inf_top_eq,
ciInf_pos hxy, ciInf_pos hyz, ciInf_pos hxz]
theorem le_einfsep_pi_of_le {π : β → Type*} [Fintype β] [∀ b, PseudoEMetricSpace (π b)]
{s : ∀ b : β, Set (π b)} {c : ℝ≥0∞} (h : ∀ b, c ≤ einfsep (s b)) :
c ≤ einfsep (Set.pi univ s) := by
refine le_einfsep fun x hx y hy hxy => ?_
rw [mem_univ_pi] at hx hy
rcases Function.ne_iff.mp hxy with ⟨i, hi⟩
exact le_trans (le_einfsep_iff.1 (h i) _ (hx _) _ (hy _) hi) (edist_le_pi_edist _ _ i)
end PseudoEMetricSpace
section PseudoMetricSpace
variable [PseudoMetricSpace α] {s : Set α}
theorem subsingleton_of_einfsep_eq_top (hs : s.einfsep = ∞) : s.Subsingleton := by
rw [einfsep_top] at hs
exact fun _ hx _ hy => of_not_not fun hxy => edist_ne_top _ _ (hs _ hx _ hy hxy)
theorem einfsep_eq_top_iff : s.einfsep = ∞ ↔ s.Subsingleton :=
⟨subsingleton_of_einfsep_eq_top, Subsingleton.einfsep⟩
theorem Nontrivial.einfsep_ne_top (hs : s.Nontrivial) : s.einfsep ≠ ∞ := by
contrapose! hs
rw [not_nontrivial_iff]
exact subsingleton_of_einfsep_eq_top hs
theorem Nontrivial.einfsep_lt_top (hs : s.Nontrivial) : s.einfsep < ∞ := by
rw [lt_top_iff_ne_top]
exact hs.einfsep_ne_top
theorem einfsep_lt_top_iff : s.einfsep < ∞ ↔ s.Nontrivial :=
⟨nontrivial_of_einfsep_lt_top, Nontrivial.einfsep_lt_top⟩
theorem einfsep_ne_top_iff : s.einfsep ≠ ∞ ↔ s.Nontrivial :=
⟨nontrivial_of_einfsep_ne_top, Nontrivial.einfsep_ne_top⟩
theorem le_einfsep_of_forall_dist_le {d} (h : ∀ x ∈ s, ∀ y ∈ s, x ≠ y → d ≤ dist x y) :
ENNReal.ofReal d ≤ s.einfsep :=
le_einfsep fun x hx y hy hxy => (edist_dist x y).symm ▸ ENNReal.ofReal_le_ofReal (h x hx y hy hxy)
end PseudoMetricSpace
section EMetricSpace
variable [EMetricSpace α] {x y z : α} {s t : Set α} {C : ℝ≥0∞} {sC : Set ℝ≥0∞}
theorem einfsep_pos_of_finite [Finite s] : 0 < s.einfsep := by
cases nonempty_fintype s
by_cases hs : s.Nontrivial
· rcases hs.einfsep_exists_of_finite with ⟨x, _hx, y, _hy, hxy, hxy'⟩
exact hxy'.symm ▸ edist_pos.2 hxy
· rw [not_nontrivial_iff] at hs
exact hs.einfsep.symm ▸ WithTop.zero_lt_top
theorem relatively_discrete_of_finite [Finite s] :
∃ C > 0, ∀ x ∈ s, ∀ y ∈ s, x ≠ y → C ≤ edist x y := by
rw [← einfsep_pos]
exact einfsep_pos_of_finite
theorem Finite.einfsep_pos (hs : s.Finite) : 0 < s.einfsep :=
letI := hs.fintype
einfsep_pos_of_finite
theorem Finite.relatively_discrete (hs : s.Finite) :
∃ C > 0, ∀ x ∈ s, ∀ y ∈ s, x ≠ y → C ≤ edist x y :=
letI := hs.fintype
relatively_discrete_of_finite
end EMetricSpace
end Einfsep
section Infsep
open ENNReal
open Set Function
/-- The "infimum separation" of a set with an edist function. -/
noncomputable def infsep [EDist α] (s : Set α) : ℝ :=
ENNReal.toReal s.einfsep
section EDist
variable [EDist α] {x y : α} {s : Set α}
theorem infsep_zero : s.infsep = 0 ↔ s.einfsep = 0 ∨ s.einfsep = ∞ := by
rw [infsep, ENNReal.toReal_eq_zero_iff]
theorem infsep_nonneg : 0 ≤ s.infsep :=
ENNReal.toReal_nonneg
theorem infsep_pos : 0 < s.infsep ↔ 0 < s.einfsep ∧ s.einfsep < ∞ := by
simp_rw [infsep, ENNReal.toReal_pos_iff]
theorem Subsingleton.infsep_zero (hs : s.Subsingleton) : s.infsep = 0 :=
Set.infsep_zero.mpr <| Or.inr hs.einfsep
theorem nontrivial_of_infsep_pos (hs : 0 < s.infsep) : s.Nontrivial := by
contrapose hs
rw [not_nontrivial_iff] at hs
exact hs.infsep_zero ▸ lt_irrefl _
theorem infsep_empty : (∅ : Set α).infsep = 0 :=
subsingleton_empty.infsep_zero
theorem infsep_singleton : ({x} : Set α).infsep = 0 :=
subsingleton_singleton.infsep_zero
theorem infsep_pair_le_toReal_inf (hxy : x ≠ y) :
({x, y} : Set α).infsep ≤ (edist x y ⊓ edist y x).toReal := by
simp_rw [infsep, einfsep_pair_eq_inf hxy]
simp
end EDist
section PseudoEMetricSpace
variable [PseudoEMetricSpace α] {x y : α} {s : Set α}
theorem infsep_pair_eq_toReal : ({x, y} : Set α).infsep = (edist x y).toReal := by
by_cases hxy : x = y
· rw [hxy]
simp only [infsep_singleton, pair_eq_singleton, edist_self, ENNReal.zero_toReal]
· rw [infsep, einfsep_pair hxy]
end PseudoEMetricSpace
section PseudoMetricSpace
variable [PseudoMetricSpace α] {x y z : α} {s t : Set α}
theorem Nontrivial.le_infsep_iff {d} (hs : s.Nontrivial) :
d ≤ s.infsep ↔ ∀ x ∈ s, ∀ y ∈ s, x ≠ y → d ≤ dist x y := by
simp_rw [infsep, ← ENNReal.ofReal_le_iff_le_toReal hs.einfsep_ne_top, le_einfsep_iff, edist_dist,
ENNReal.ofReal_le_ofReal_iff dist_nonneg]
theorem Nontrivial.infsep_lt_iff {d} (hs : s.Nontrivial) :
s.infsep < d ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ dist x y < d := by
rw [← not_iff_not]
push_neg
exact hs.le_infsep_iff
theorem Nontrivial.le_infsep {d} (hs : s.Nontrivial)
(h : ∀ x ∈ s, ∀ y ∈ s, x ≠ y → d ≤ dist x y) : d ≤ s.infsep :=
hs.le_infsep_iff.2 h
theorem le_edist_of_le_infsep {d x} (hx : x ∈ s) {y} (hy : y ∈ s) (hxy : x ≠ y)
(hd : d ≤ s.infsep) : d ≤ dist x y := by
by_cases hs : s.Nontrivial
· exact hs.le_infsep_iff.1 hd x hx y hy hxy
· rw [not_nontrivial_iff] at hs
rw [hs.infsep_zero] at hd
exact le_trans hd dist_nonneg
theorem infsep_le_dist_of_mem (hx : x ∈ s) (hy : y ∈ s) (hxy : x ≠ y) : s.infsep ≤ dist x y :=
le_edist_of_le_infsep hx hy hxy le_rfl
theorem infsep_le_of_mem_of_edist_le {d x} (hx : x ∈ s) {y} (hy : y ∈ s) (hxy : x ≠ y)
(hxy' : dist x y ≤ d) : s.infsep ≤ d :=
le_trans (infsep_le_dist_of_mem hx hy hxy) hxy'
theorem infsep_pair : ({x, y} : Set α).infsep = dist x y := by
rw [infsep_pair_eq_toReal, edist_dist]
exact ENNReal.toReal_ofReal dist_nonneg
theorem infsep_triple (hxy : x ≠ y) (hyz : y ≠ z) (hxz : x ≠ z) :
({x, y, z} : Set α).infsep = dist x y ⊓ dist x z ⊓ dist y z := by
simp only [infsep, einfsep_triple hxy hyz hxz, ENNReal.toReal_inf, edist_ne_top x y,
edist_ne_top x z, edist_ne_top y z, dist_edist, Ne, inf_eq_top_iff, and_self_iff,
not_false_iff]
theorem Nontrivial.infsep_anti (hs : s.Nontrivial) (hst : s ⊆ t) : t.infsep ≤ s.infsep :=
ENNReal.toReal_mono hs.einfsep_ne_top (einfsep_anti hst)
theorem infsep_eq_iInf [Decidable s.Nontrivial] :
s.infsep = if s.Nontrivial then ⨅ d : s.offDiag, (uncurry dist) (d : α × α) else 0 := by
split_ifs with hs
· have hb : BddBelow (uncurry dist '' s.offDiag) := by
refine ⟨0, fun d h => ?_⟩
simp_rw [mem_image, Prod.exists, uncurry_apply_pair] at h
rcases h with ⟨_, _, _, rfl⟩
exact dist_nonneg
refine eq_of_forall_le_iff fun _ => ?_
simp_rw [hs.le_infsep_iff, le_ciInf_set_iff (offDiag_nonempty.mpr hs) hb, imp_forall_iff,
mem_offDiag, Prod.forall, uncurry_apply_pair, and_imp]
· exact (not_nontrivial_iff.mp hs).infsep_zero
theorem Nontrivial.infsep_eq_iInf (hs : s.Nontrivial) :
s.infsep = ⨅ d : s.offDiag, (uncurry dist) (d : α × α) := by
classical rw [Set.infsep_eq_iInf, if_pos hs]
theorem infsep_of_fintype [Decidable s.Nontrivial] [DecidableEq α] [Fintype s] : s.infsep =
if hs : s.Nontrivial then s.offDiag.toFinset.inf' (by simpa) (uncurry dist) else 0 := by
split_ifs with hs
· refine eq_of_forall_le_iff fun _ => ?_
simp_rw [hs.le_infsep_iff, imp_forall_iff, Finset.le_inf'_iff, mem_toFinset, mem_offDiag,
Prod.forall, uncurry_apply_pair, and_imp]
· rw [not_nontrivial_iff] at hs
exact hs.infsep_zero
theorem Nontrivial.infsep_of_fintype [DecidableEq α] [Fintype s] (hs : s.Nontrivial) :
s.infsep = s.offDiag.toFinset.inf' (by simpa) (uncurry dist) := by
classical rw [Set.infsep_of_fintype, dif_pos hs]
theorem Finite.infsep [Decidable s.Nontrivial] (hsf : s.Finite) :
s.infsep =
if hs : s.Nontrivial then hsf.offDiag.toFinset.inf' (by simpa) (uncurry dist) else 0 := by
split_ifs with hs
· refine eq_of_forall_le_iff fun _ => ?_
simp_rw [hs.le_infsep_iff, imp_forall_iff, Finset.le_inf'_iff, Finite.mem_toFinset,
mem_offDiag, Prod.forall, uncurry_apply_pair, and_imp]
· rw [not_nontrivial_iff] at hs
exact hs.infsep_zero
theorem Finite.infsep_of_nontrivial (hsf : s.Finite) (hs : s.Nontrivial) :
s.infsep = hsf.offDiag.toFinset.inf' (by simpa) (uncurry dist) := by
classical simp_rw [hsf.infsep, dif_pos hs]
theorem _root_.Finset.coe_infsep [DecidableEq α] (s : Finset α) : (s : Set α).infsep =
if hs : s.offDiag.Nonempty then s.offDiag.inf' hs (uncurry dist) else 0 := by
have H : (s : Set α).Nontrivial ↔ s.offDiag.Nonempty := by
rw [← Set.offDiag_nonempty, ← Finset.coe_offDiag, Finset.coe_nonempty]
split_ifs with hs
· simp_rw [(H.mpr hs).infsep_of_fintype, ← Finset.coe_offDiag, Finset.toFinset_coe]
· exact (not_nontrivial_iff.mp (H.mp.mt hs)).infsep_zero
theorem _root_.Finset.coe_infsep_of_offDiag_nonempty [DecidableEq α] {s : Finset α}
(hs : s.offDiag.Nonempty) : (s : Set α).infsep = s.offDiag.inf' hs (uncurry dist) := by
rw [Finset.coe_infsep, dif_pos hs]
theorem _root_.Finset.coe_infsep_of_offDiag_empty
[DecidableEq α] {s : Finset α} (hs : s.offDiag = ∅) : (s : Set α).infsep = 0 := by
rw [← Finset.not_nonempty_iff_eq_empty] at hs
rw [Finset.coe_infsep, dif_neg hs]
theorem Nontrivial.infsep_exists_of_finite [Finite s] (hs : s.Nontrivial) :
∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ s.infsep = dist x y := by
classical
cases nonempty_fintype s
simp_rw [hs.infsep_of_fintype]
rcases Finset.exists_mem_eq_inf' (s := s.offDiag.toFinset) (by simpa) (uncurry dist) with
⟨w, hxy, hed⟩
simp_rw [mem_toFinset] at hxy
exact ⟨w.fst, hxy.1, w.snd, hxy.2.1, hxy.2.2, hed⟩
theorem Finite.infsep_exists_of_nontrivial (hsf : s.Finite) (hs : s.Nontrivial) :
∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ s.infsep = dist x y :=
letI := hsf.fintype
hs.infsep_exists_of_finite
end PseudoMetricSpace
section MetricSpace
variable [MetricSpace α] {s : Set α}
theorem infsep_zero_iff_subsingleton_of_finite [Finite s] : s.infsep = 0 ↔ s.Subsingleton := by
rw [infsep_zero, einfsep_eq_top_iff, or_iff_right_iff_imp]
exact fun H => (einfsep_pos_of_finite.ne' H).elim
theorem infsep_pos_iff_nontrivial_of_finite [Finite s] : 0 < s.infsep ↔ s.Nontrivial := by
rw [infsep_pos, einfsep_lt_top_iff, and_iff_right_iff_imp]
exact fun _ => einfsep_pos_of_finite
theorem Finite.infsep_zero_iff_subsingleton (hs : s.Finite) : s.infsep = 0 ↔ s.Subsingleton :=
letI := hs.fintype
infsep_zero_iff_subsingleton_of_finite
theorem Finite.infsep_pos_iff_nontrivial (hs : s.Finite) : 0 < s.infsep ↔ s.Nontrivial :=
letI := hs.fintype
infsep_pos_iff_nontrivial_of_finite
theorem _root_.Finset.infsep_zero_iff_subsingleton (s : Finset α) :
(s : Set α).infsep = 0 ↔ (s : Set α).Subsingleton :=
infsep_zero_iff_subsingleton_of_finite
theorem _root_.Finset.infsep_pos_iff_nontrivial (s : Finset α) :
0 < (s : Set α).infsep ↔ (s : Set α).Nontrivial :=
infsep_pos_iff_nontrivial_of_finite
end MetricSpace
end Infsep
end Set
|
Topology\MetricSpace\IsometricSMul.lean | /-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Data.Set.Pointwise.SMul
import Mathlib.Topology.MetricSpace.Isometry
import Mathlib.Topology.MetricSpace.Lipschitz
/-!
# Group actions by isometries
In this file we define two typeclasses:
- `IsometricSMul M X` says that `M` multiplicatively acts on a (pseudo extended) metric space
`X` by isometries;
- `IsometricVAdd` is an additive version of `IsometricSMul`.
We also prove basic facts about isometric actions and define bundled isometries
`IsometryEquiv.constSMul`, `IsometryEquiv.mulLeft`, `IsometryEquiv.mulRight`,
`IsometryEquiv.divLeft`, `IsometryEquiv.divRight`, and `IsometryEquiv.inv`, as well as their
additive versions.
If `G` is a group, then `IsometricSMul G G` means that `G` has a left-invariant metric while
`IsometricSMul Gᵐᵒᵖ G` means that `G` has a right-invariant metric. For a commutative group,
these two notions are equivalent. A group with a right-invariant metric can be also represented as a
`NormedGroup`.
-/
open Set
open ENNReal Pointwise
universe u v w
variable (M : Type u) (G : Type v) (X : Type w)
/-- An additive action is isometric if each map `x ↦ c +ᵥ x` is an isometry. -/
class IsometricVAdd [PseudoEMetricSpace X] [VAdd M X] : Prop where
protected isometry_vadd : ∀ c : M, Isometry ((c +ᵥ ·) : X → X)
/-- A multiplicative action is isometric if each map `x ↦ c • x` is an isometry. -/
@[to_additive]
class IsometricSMul [PseudoEMetricSpace X] [SMul M X] : Prop where
protected isometry_smul : ∀ c : M, Isometry ((c • ·) : X → X)
-- Porting note: Lean 4 doesn't support `[]` in classes, so make a lemma instead of `export`ing
@[to_additive]
theorem isometry_smul {M : Type u} (X : Type w) [PseudoEMetricSpace X] [SMul M X]
[IsometricSMul M X] (c : M) : Isometry (c • · : X → X) :=
IsometricSMul.isometry_smul c
@[to_additive]
instance (priority := 100) IsometricSMul.to_continuousConstSMul [PseudoEMetricSpace X] [SMul M X]
[IsometricSMul M X] : ContinuousConstSMul M X :=
⟨fun c => (isometry_smul X c).continuous⟩
@[to_additive]
instance (priority := 100) IsometricSMul.opposite_of_comm [PseudoEMetricSpace X] [SMul M X]
[SMul Mᵐᵒᵖ X] [IsCentralScalar M X] [IsometricSMul M X] : IsometricSMul Mᵐᵒᵖ X :=
⟨fun c x y => by simpa only [← op_smul_eq_smul] using isometry_smul X c.unop x y⟩
variable {M G X}
section EMetric
variable [PseudoEMetricSpace X] [Group G] [MulAction G X] [IsometricSMul G X]
@[to_additive (attr := simp)]
theorem edist_smul_left [SMul M X] [IsometricSMul M X] (c : M) (x y : X) :
edist (c • x) (c • y) = edist x y :=
isometry_smul X c x y
@[to_additive (attr := simp)]
theorem ediam_smul [SMul M X] [IsometricSMul M X] (c : M) (s : Set X) :
EMetric.diam (c • s) = EMetric.diam s :=
(isometry_smul _ _).ediam_image s
@[to_additive]
theorem isometry_mul_left [Mul M] [PseudoEMetricSpace M] [IsometricSMul M M] (a : M) :
Isometry (a * ·) :=
isometry_smul M a
@[to_additive (attr := simp)]
theorem edist_mul_left [Mul M] [PseudoEMetricSpace M] [IsometricSMul M M] (a b c : M) :
edist (a * b) (a * c) = edist b c :=
isometry_mul_left a b c
@[to_additive]
theorem isometry_mul_right [Mul M] [PseudoEMetricSpace M] [IsometricSMul Mᵐᵒᵖ M] (a : M) :
Isometry fun x => x * a :=
isometry_smul M (MulOpposite.op a)
@[to_additive (attr := simp)]
theorem edist_mul_right [Mul M] [PseudoEMetricSpace M] [IsometricSMul Mᵐᵒᵖ M] (a b c : M) :
edist (a * c) (b * c) = edist a b :=
isometry_mul_right c a b
@[to_additive (attr := simp)]
theorem edist_div_right [DivInvMonoid M] [PseudoEMetricSpace M] [IsometricSMul Mᵐᵒᵖ M]
(a b c : M) : edist (a / c) (b / c) = edist a b := by
simp only [div_eq_mul_inv, edist_mul_right]
@[to_additive (attr := simp)]
theorem edist_inv_inv [PseudoEMetricSpace G] [IsometricSMul G G] [IsometricSMul Gᵐᵒᵖ G]
(a b : G) : edist a⁻¹ b⁻¹ = edist a b := by
rw [← edist_mul_left a, ← edist_mul_right _ _ b, mul_right_inv, one_mul, inv_mul_cancel_right,
edist_comm]
@[to_additive]
theorem isometry_inv [PseudoEMetricSpace G] [IsometricSMul G G] [IsometricSMul Gᵐᵒᵖ G] :
Isometry (Inv.inv : G → G) :=
edist_inv_inv
@[to_additive]
theorem edist_inv [PseudoEMetricSpace G] [IsometricSMul G G] [IsometricSMul Gᵐᵒᵖ G]
(x y : G) : edist x⁻¹ y = edist x y⁻¹ := by rw [← edist_inv_inv, inv_inv]
@[to_additive (attr := simp)]
theorem edist_div_left [PseudoEMetricSpace G] [IsometricSMul G G] [IsometricSMul Gᵐᵒᵖ G]
(a b c : G) : edist (a / b) (a / c) = edist b c := by
rw [div_eq_mul_inv, div_eq_mul_inv, edist_mul_left, edist_inv_inv]
namespace IsometryEquiv
/-- If a group `G` acts on `X` by isometries, then `IsometryEquiv.constSMul` is the isometry of
`X` given by multiplication of a constant element of the group. -/
@[to_additive (attr := simps! toEquiv apply) "If an additive group `G` acts on `X` by isometries,
then `IsometryEquiv.constVAdd` is the isometry of `X` given by addition of a constant element of the
group."]
def constSMul (c : G) : X ≃ᵢ X where
toEquiv := MulAction.toPerm c
isometry_toFun := isometry_smul X c
@[to_additive (attr := simp)]
theorem constSMul_symm (c : G) : (constSMul c : X ≃ᵢ X).symm = constSMul c⁻¹ :=
ext fun _ => rfl
variable [PseudoEMetricSpace G]
/-- Multiplication `y ↦ x * y` as an `IsometryEquiv`. -/
@[to_additive (attr := simps! apply toEquiv) "Addition `y ↦ x + y` as an `IsometryEquiv`."]
def mulLeft [IsometricSMul G G] (c : G) : G ≃ᵢ G where
toEquiv := Equiv.mulLeft c
isometry_toFun := edist_mul_left c
@[to_additive (attr := simp)]
theorem mulLeft_symm [IsometricSMul G G] (x : G) :
(mulLeft x).symm = IsometryEquiv.mulLeft x⁻¹ :=
constSMul_symm x
/-- Multiplication `y ↦ y * x` as an `IsometryEquiv`. -/
@[to_additive (attr := simps! apply toEquiv) "Addition `y ↦ y + x` as an `IsometryEquiv`."]
def mulRight [IsometricSMul Gᵐᵒᵖ G] (c : G) : G ≃ᵢ G where
toEquiv := Equiv.mulRight c
isometry_toFun a b := edist_mul_right a b c
@[to_additive (attr := simp)]
theorem mulRight_symm [IsometricSMul Gᵐᵒᵖ G] (x : G) : (mulRight x).symm = mulRight x⁻¹ :=
ext fun _ => rfl
/-- Division `y ↦ y / x` as an `IsometryEquiv`. -/
@[to_additive (attr := simps! apply toEquiv) "Subtraction `y ↦ y - x` as an `IsometryEquiv`."]
def divRight [IsometricSMul Gᵐᵒᵖ G] (c : G) : G ≃ᵢ G where
toEquiv := Equiv.divRight c
isometry_toFun a b := edist_div_right a b c
@[to_additive (attr := simp)]
theorem divRight_symm [IsometricSMul Gᵐᵒᵖ G] (c : G) : (divRight c).symm = mulRight c :=
ext fun _ => rfl
variable [IsometricSMul G G] [IsometricSMul Gᵐᵒᵖ G]
/-- Division `y ↦ x / y` as an `IsometryEquiv`. -/
@[to_additive (attr := simps! apply symm_apply toEquiv)
"Subtraction `y ↦ x - y` as an `IsometryEquiv`."]
def divLeft (c : G) : G ≃ᵢ G where
toEquiv := Equiv.divLeft c
isometry_toFun := edist_div_left c
variable (G)
/-- Inversion `x ↦ x⁻¹` as an `IsometryEquiv`. -/
@[to_additive (attr := simps! apply toEquiv) "Negation `x ↦ -x` as an `IsometryEquiv`."]
def inv : G ≃ᵢ G where
toEquiv := Equiv.inv G
isometry_toFun := edist_inv_inv
@[to_additive (attr := simp)] theorem inv_symm : (inv G).symm = inv G := rfl
end IsometryEquiv
namespace EMetric
@[to_additive (attr := simp)]
theorem smul_ball (c : G) (x : X) (r : ℝ≥0∞) : c • ball x r = ball (c • x) r :=
(IsometryEquiv.constSMul c).image_emetric_ball _ _
@[to_additive (attr := simp)]
theorem preimage_smul_ball (c : G) (x : X) (r : ℝ≥0∞) :
(c • ·) ⁻¹' ball x r = ball (c⁻¹ • x) r := by
rw [preimage_smul, smul_ball]
@[to_additive (attr := simp)]
theorem smul_closedBall (c : G) (x : X) (r : ℝ≥0∞) : c • closedBall x r = closedBall (c • x) r :=
(IsometryEquiv.constSMul c).image_emetric_closedBall _ _
@[to_additive (attr := simp)]
theorem preimage_smul_closedBall (c : G) (x : X) (r : ℝ≥0∞) :
(c • ·) ⁻¹' closedBall x r = closedBall (c⁻¹ • x) r := by
rw [preimage_smul, smul_closedBall]
variable [PseudoEMetricSpace G]
@[to_additive (attr := simp)]
theorem preimage_mul_left_ball [IsometricSMul G G] (a b : G) (r : ℝ≥0∞) :
(a * ·) ⁻¹' ball b r = ball (a⁻¹ * b) r :=
preimage_smul_ball a b r
@[to_additive (attr := simp)]
theorem preimage_mul_right_ball [IsometricSMul Gᵐᵒᵖ G] (a b : G) (r : ℝ≥0∞) :
(fun x => x * a) ⁻¹' ball b r = ball (b / a) r := by
rw [div_eq_mul_inv]
exact preimage_smul_ball (MulOpposite.op a) b r
@[to_additive (attr := simp)]
theorem preimage_mul_left_closedBall [IsometricSMul G G] (a b : G) (r : ℝ≥0∞) :
(a * ·) ⁻¹' closedBall b r = closedBall (a⁻¹ * b) r :=
preimage_smul_closedBall a b r
@[to_additive (attr := simp)]
theorem preimage_mul_right_closedBall [IsometricSMul Gᵐᵒᵖ G] (a b : G) (r : ℝ≥0∞) :
(fun x => x * a) ⁻¹' closedBall b r = closedBall (b / a) r := by
rw [div_eq_mul_inv]
exact preimage_smul_closedBall (MulOpposite.op a) b r
end EMetric
end EMetric
@[to_additive (attr := simp)]
theorem dist_smul [PseudoMetricSpace X] [SMul M X] [IsometricSMul M X] (c : M) (x y : X) :
dist (c • x) (c • y) = dist x y :=
(isometry_smul X c).dist_eq x y
@[to_additive (attr := simp)]
theorem nndist_smul [PseudoMetricSpace X] [SMul M X] [IsometricSMul M X] (c : M) (x y : X) :
nndist (c • x) (c • y) = nndist x y :=
(isometry_smul X c).nndist_eq x y
@[to_additive (attr := simp)]
theorem diam_smul [PseudoMetricSpace X] [SMul M X] [IsometricSMul M X] (c : M) (s : Set X) :
Metric.diam (c • s) = Metric.diam s :=
(isometry_smul _ _).diam_image s
@[to_additive (attr := simp)]
theorem dist_mul_left [PseudoMetricSpace M] [Mul M] [IsometricSMul M M] (a b c : M) :
dist (a * b) (a * c) = dist b c :=
dist_smul a b c
@[to_additive (attr := simp)]
theorem nndist_mul_left [PseudoMetricSpace M] [Mul M] [IsometricSMul M M] (a b c : M) :
nndist (a * b) (a * c) = nndist b c :=
nndist_smul a b c
@[to_additive (attr := simp)]
theorem dist_mul_right [Mul M] [PseudoMetricSpace M] [IsometricSMul Mᵐᵒᵖ M] (a b c : M) :
dist (a * c) (b * c) = dist a b :=
dist_smul (MulOpposite.op c) a b
@[to_additive (attr := simp)]
theorem nndist_mul_right [PseudoMetricSpace M] [Mul M] [IsometricSMul Mᵐᵒᵖ M] (a b c : M) :
nndist (a * c) (b * c) = nndist a b :=
nndist_smul (MulOpposite.op c) a b
@[to_additive (attr := simp)]
theorem dist_div_right [DivInvMonoid M] [PseudoMetricSpace M] [IsometricSMul Mᵐᵒᵖ M]
(a b c : M) : dist (a / c) (b / c) = dist a b := by simp only [div_eq_mul_inv, dist_mul_right]
@[to_additive (attr := simp)]
theorem nndist_div_right [DivInvMonoid M] [PseudoMetricSpace M] [IsometricSMul Mᵐᵒᵖ M]
(a b c : M) : nndist (a / c) (b / c) = nndist a b := by
simp only [div_eq_mul_inv, nndist_mul_right]
@[to_additive (attr := simp)]
theorem dist_inv_inv [Group G] [PseudoMetricSpace G] [IsometricSMul G G]
[IsometricSMul Gᵐᵒᵖ G] (a b : G) : dist a⁻¹ b⁻¹ = dist a b :=
(IsometryEquiv.inv G).dist_eq a b
@[to_additive (attr := simp)]
theorem nndist_inv_inv [Group G] [PseudoMetricSpace G] [IsometricSMul G G]
[IsometricSMul Gᵐᵒᵖ G] (a b : G) : nndist a⁻¹ b⁻¹ = nndist a b :=
(IsometryEquiv.inv G).nndist_eq a b
@[to_additive (attr := simp)]
theorem dist_div_left [Group G] [PseudoMetricSpace G] [IsometricSMul G G]
[IsometricSMul Gᵐᵒᵖ G] (a b c : G) : dist (a / b) (a / c) = dist b c := by
simp [div_eq_mul_inv]
@[to_additive (attr := simp)]
theorem nndist_div_left [Group G] [PseudoMetricSpace G] [IsometricSMul G G]
[IsometricSMul Gᵐᵒᵖ G] (a b c : G) : nndist (a / b) (a / c) = nndist b c := by
simp [div_eq_mul_inv]
/-- If `G` acts isometrically on `X`, then the image of a bounded set in `X` under scalar
multiplication by `c : G` is bounded. See also `Bornology.IsBounded.smul₀` for a similar lemma about
normed spaces. -/
@[to_additive "Given an additive isometric action of `G` on `X`, the image of a bounded set in `X`
under translation by `c : G` is bounded"]
theorem Bornology.IsBounded.smul [PseudoMetricSpace X] [SMul G X] [IsometricSMul G X] {s : Set X}
(hs : IsBounded s) (c : G) : IsBounded (c • s) :=
(isometry_smul X c).lipschitz.isBounded_image hs
namespace Metric
variable [PseudoMetricSpace X] [Group G] [MulAction G X] [IsometricSMul G X]
@[to_additive (attr := simp)]
theorem smul_ball (c : G) (x : X) (r : ℝ) : c • ball x r = ball (c • x) r :=
(IsometryEquiv.constSMul c).image_ball _ _
@[to_additive (attr := simp)]
theorem preimage_smul_ball (c : G) (x : X) (r : ℝ) : (c • ·) ⁻¹' ball x r = ball (c⁻¹ • x) r := by
rw [preimage_smul, smul_ball]
@[to_additive (attr := simp)]
theorem smul_closedBall (c : G) (x : X) (r : ℝ) : c • closedBall x r = closedBall (c • x) r :=
(IsometryEquiv.constSMul c).image_closedBall _ _
@[to_additive (attr := simp)]
theorem preimage_smul_closedBall (c : G) (x : X) (r : ℝ) :
(c • ·) ⁻¹' closedBall x r = closedBall (c⁻¹ • x) r := by rw [preimage_smul, smul_closedBall]
@[to_additive (attr := simp)]
theorem smul_sphere (c : G) (x : X) (r : ℝ) : c • sphere x r = sphere (c • x) r :=
(IsometryEquiv.constSMul c).image_sphere _ _
@[to_additive (attr := simp)]
theorem preimage_smul_sphere (c : G) (x : X) (r : ℝ) :
(c • ·) ⁻¹' sphere x r = sphere (c⁻¹ • x) r := by rw [preimage_smul, smul_sphere]
variable [PseudoMetricSpace G]
@[to_additive (attr := simp)]
theorem preimage_mul_left_ball [IsometricSMul G G] (a b : G) (r : ℝ) :
(a * ·) ⁻¹' ball b r = ball (a⁻¹ * b) r :=
preimage_smul_ball a b r
@[to_additive (attr := simp)]
theorem preimage_mul_right_ball [IsometricSMul Gᵐᵒᵖ G] (a b : G) (r : ℝ) :
(fun x => x * a) ⁻¹' ball b r = ball (b / a) r := by
rw [div_eq_mul_inv]
exact preimage_smul_ball (MulOpposite.op a) b r
@[to_additive (attr := simp)]
theorem preimage_mul_left_closedBall [IsometricSMul G G] (a b : G) (r : ℝ) :
(a * ·) ⁻¹' closedBall b r = closedBall (a⁻¹ * b) r :=
preimage_smul_closedBall a b r
@[to_additive (attr := simp)]
theorem preimage_mul_right_closedBall [IsometricSMul Gᵐᵒᵖ G] (a b : G) (r : ℝ) :
(fun x => x * a) ⁻¹' closedBall b r = closedBall (b / a) r := by
rw [div_eq_mul_inv]
exact preimage_smul_closedBall (MulOpposite.op a) b r
end Metric
section Instances
variable {Y : Type*} [PseudoEMetricSpace X] [PseudoEMetricSpace Y] [SMul M X]
[IsometricSMul M X]
@[to_additive]
instance [SMul M Y] [IsometricSMul M Y] : IsometricSMul M (X × Y) :=
⟨fun c => (isometry_smul X c).prod_map (isometry_smul Y c)⟩
@[to_additive]
instance Prod.isometricSMul' {N} [Mul M] [PseudoEMetricSpace M] [IsometricSMul M M] [Mul N]
[PseudoEMetricSpace N] [IsometricSMul N N] : IsometricSMul (M × N) (M × N) :=
⟨fun c => (isometry_smul M c.1).prod_map (isometry_smul N c.2)⟩
@[to_additive]
instance Prod.isometricSMul'' {N} [Mul M] [PseudoEMetricSpace M] [IsometricSMul Mᵐᵒᵖ M]
[Mul N] [PseudoEMetricSpace N] [IsometricSMul Nᵐᵒᵖ N] :
IsometricSMul (M × N)ᵐᵒᵖ (M × N) :=
⟨fun c => (isometry_mul_right c.unop.1).prod_map (isometry_mul_right c.unop.2)⟩
@[to_additive]
instance Units.isometricSMul [Monoid M] : IsometricSMul Mˣ X :=
⟨fun c => isometry_smul X (c : M)⟩
@[to_additive]
instance : IsometricSMul M Xᵐᵒᵖ :=
⟨fun c x y => by simpa only using edist_smul_left c x.unop y.unop⟩
@[to_additive]
instance ULift.isometricSMul : IsometricSMul (ULift M) X :=
⟨fun c => by simpa only using isometry_smul X c.down⟩
@[to_additive]
instance ULift.isometricSMul' : IsometricSMul M (ULift X) :=
⟨fun c x y => by simpa only using edist_smul_left c x.1 y.1⟩
@[to_additive]
instance {ι} {X : ι → Type*} [Fintype ι] [∀ i, SMul M (X i)] [∀ i, PseudoEMetricSpace (X i)]
[∀ i, IsometricSMul M (X i)] : IsometricSMul M (∀ i, X i) :=
⟨fun c => isometry_dcomp (fun _ => (c • ·)) fun i => isometry_smul (X i) c⟩
@[to_additive]
instance Pi.isometricSMul' {ι} {M X : ι → Type*} [Fintype ι] [∀ i, SMul (M i) (X i)]
[∀ i, PseudoEMetricSpace (X i)] [∀ i, IsometricSMul (M i) (X i)] :
IsometricSMul (∀ i, M i) (∀ i, X i) :=
⟨fun c => isometry_dcomp (fun i => (c i • ·)) fun _ => isometry_smul _ _⟩
@[to_additive]
instance Pi.isometricSMul'' {ι} {M : ι → Type*} [Fintype ι] [∀ i, Mul (M i)]
[∀ i, PseudoEMetricSpace (M i)] [∀ i, IsometricSMul (M i)ᵐᵒᵖ (M i)] :
IsometricSMul (∀ i, M i)ᵐᵒᵖ (∀ i, M i) :=
⟨fun c => isometry_dcomp (fun i (x : M i) => x * c.unop i) fun _ => isometry_mul_right _⟩
instance Additive.isometricVAdd : IsometricVAdd (Additive M) X :=
⟨fun c => isometry_smul X (toMul c)⟩
instance Additive.isometricVAdd' [Mul M] [PseudoEMetricSpace M] [IsometricSMul M M] :
IsometricVAdd (Additive M) (Additive M) :=
⟨fun c x y => edist_smul_left (toMul c) (toMul x) (toMul y)⟩
instance Additive.isometricVAdd'' [Mul M] [PseudoEMetricSpace M] [IsometricSMul Mᵐᵒᵖ M] :
IsometricVAdd (Additive M)ᵃᵒᵖ (Additive M) :=
⟨fun c x y => edist_smul_left (MulOpposite.op (toMul c.unop)) (toMul x) (toMul y)⟩
instance Multiplicative.isometricSMul {M X} [VAdd M X] [PseudoEMetricSpace X]
[IsometricVAdd M X] : IsometricSMul (Multiplicative M) X :=
⟨fun c => isometry_vadd X (toAdd c)⟩
instance Multiplicative.isometricSMul' [Add M] [PseudoEMetricSpace M] [IsometricVAdd M M] :
IsometricSMul (Multiplicative M) (Multiplicative M) :=
⟨fun c x y => edist_vadd_left (toAdd c) (toAdd x) (toAdd y)⟩
instance Multiplicative.isometricVAdd'' [Add M] [PseudoEMetricSpace M]
[IsometricVAdd Mᵃᵒᵖ M] : IsometricSMul (Multiplicative M)ᵐᵒᵖ (Multiplicative M) :=
⟨fun c x y => edist_vadd_left (AddOpposite.op (toAdd c.unop)) (toAdd x) (toAdd y)⟩
end Instances
|
Topology\MetricSpace\Isometry.lean | /-
Copyright (c) 2018 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.MetricSpace.Antilipschitz
/-!
# Isometries
We define isometries, i.e., maps between emetric spaces that preserve
the edistance (on metric spaces, these are exactly the maps that preserve distances),
and prove their basic properties. We also introduce isometric bijections.
Since a lot of elementary properties don't require `eq_of_dist_eq_zero` we start setting up the
theory for `PseudoMetricSpace` and we specialize to `MetricSpace` when needed.
-/
noncomputable section
universe u v w
variable {ι : Type*} {α : Type u} {β : Type v} {γ : Type w}
open Function Set
open scoped Topology ENNReal
/-- An isometry (also known as isometric embedding) is a map preserving the edistance
between pseudoemetric spaces, or equivalently the distance between pseudometric space. -/
def Isometry [PseudoEMetricSpace α] [PseudoEMetricSpace β] (f : α → β) : Prop :=
∀ x1 x2 : α, edist (f x1) (f x2) = edist x1 x2
/-- On pseudometric spaces, a map is an isometry if and only if it preserves nonnegative
distances. -/
theorem isometry_iff_nndist_eq [PseudoMetricSpace α] [PseudoMetricSpace β] {f : α → β} :
Isometry f ↔ ∀ x y, nndist (f x) (f y) = nndist x y := by
simp only [Isometry, edist_nndist, ENNReal.coe_inj]
/-- On pseudometric spaces, a map is an isometry if and only if it preserves distances. -/
theorem isometry_iff_dist_eq [PseudoMetricSpace α] [PseudoMetricSpace β] {f : α → β} :
Isometry f ↔ ∀ x y, dist (f x) (f y) = dist x y := by
simp only [isometry_iff_nndist_eq, ← coe_nndist, NNReal.coe_inj]
/-- An isometry preserves distances. -/
alias ⟨Isometry.dist_eq, _⟩ := isometry_iff_dist_eq
/-- A map that preserves distances is an isometry -/
alias ⟨_, Isometry.of_dist_eq⟩ := isometry_iff_dist_eq
/-- An isometry preserves non-negative distances. -/
alias ⟨Isometry.nndist_eq, _⟩ := isometry_iff_nndist_eq
/-- A map that preserves non-negative distances is an isometry. -/
alias ⟨_, Isometry.of_nndist_eq⟩ := isometry_iff_nndist_eq
namespace Isometry
section PseudoEmetricIsometry
variable [PseudoEMetricSpace α] [PseudoEMetricSpace β] [PseudoEMetricSpace γ]
variable {f : α → β} {x y z : α} {s : Set α}
/-- An isometry preserves edistances. -/
theorem edist_eq (hf : Isometry f) (x y : α) : edist (f x) (f y) = edist x y :=
hf x y
theorem lipschitz (h : Isometry f) : LipschitzWith 1 f :=
LipschitzWith.of_edist_le fun x y => (h x y).le
theorem antilipschitz (h : Isometry f) : AntilipschitzWith 1 f := fun x y => by
simp only [h x y, ENNReal.coe_one, one_mul, le_refl]
/-- Any map on a subsingleton is an isometry -/
@[nontriviality]
theorem _root_.isometry_subsingleton [Subsingleton α] : Isometry f := fun x y => by
rw [Subsingleton.elim x y]; simp
/-- The identity is an isometry -/
theorem _root_.isometry_id : Isometry (id : α → α) := fun _ _ => rfl
theorem prod_map {δ} [PseudoEMetricSpace δ] {f : α → β} {g : γ → δ} (hf : Isometry f)
(hg : Isometry g) : Isometry (Prod.map f g) := fun x y => by
simp only [Prod.edist_eq, Prod.map_fst, hf.edist_eq, Prod.map_snd, hg.edist_eq]
theorem _root_.isometry_dcomp {ι} [Fintype ι] {α β : ι → Type*} [∀ i, PseudoEMetricSpace (α i)]
[∀ i, PseudoEMetricSpace (β i)] (f : ∀ i, α i → β i) (hf : ∀ i, Isometry (f i)) :
Isometry (fun g : (i : ι) → α i => fun i => f i (g i)) := fun x y => by
simp only [edist_pi_def, (hf _).edist_eq]
/-- The composition of isometries is an isometry. -/
theorem comp {g : β → γ} {f : α → β} (hg : Isometry g) (hf : Isometry f) : Isometry (g ∘ f) :=
fun _ _ => (hg _ _).trans (hf _ _)
/-- An isometry from a metric space is a uniform continuous map -/
protected theorem uniformContinuous (hf : Isometry f) : UniformContinuous f :=
hf.lipschitz.uniformContinuous
/-- An isometry from a metric space is a uniform inducing map -/
protected theorem uniformInducing (hf : Isometry f) : UniformInducing f :=
hf.antilipschitz.uniformInducing hf.uniformContinuous
theorem tendsto_nhds_iff {ι : Type*} {f : α → β} {g : ι → α} {a : Filter ι} {b : α}
(hf : Isometry f) : Filter.Tendsto g a (𝓝 b) ↔ Filter.Tendsto (f ∘ g) a (𝓝 (f b)) :=
hf.uniformInducing.inducing.tendsto_nhds_iff
/-- An isometry is continuous. -/
protected theorem continuous (hf : Isometry f) : Continuous f :=
hf.lipschitz.continuous
/-- The right inverse of an isometry is an isometry. -/
theorem right_inv {f : α → β} {g : β → α} (h : Isometry f) (hg : RightInverse g f) : Isometry g :=
fun x y => by rw [← h, hg _, hg _]
theorem preimage_emetric_closedBall (h : Isometry f) (x : α) (r : ℝ≥0∞) :
f ⁻¹' EMetric.closedBall (f x) r = EMetric.closedBall x r := by
ext y
simp [h.edist_eq]
theorem preimage_emetric_ball (h : Isometry f) (x : α) (r : ℝ≥0∞) :
f ⁻¹' EMetric.ball (f x) r = EMetric.ball x r := by
ext y
simp [h.edist_eq]
/-- Isometries preserve the diameter in pseudoemetric spaces. -/
theorem ediam_image (hf : Isometry f) (s : Set α) : EMetric.diam (f '' s) = EMetric.diam s :=
eq_of_forall_ge_iff fun d => by simp only [EMetric.diam_le_iff, forall_mem_image, hf.edist_eq]
theorem ediam_range (hf : Isometry f) : EMetric.diam (range f) = EMetric.diam (univ : Set α) := by
rw [← image_univ]
exact hf.ediam_image univ
theorem mapsTo_emetric_ball (hf : Isometry f) (x : α) (r : ℝ≥0∞) :
MapsTo f (EMetric.ball x r) (EMetric.ball (f x) r) :=
(hf.preimage_emetric_ball x r).ge
theorem mapsTo_emetric_closedBall (hf : Isometry f) (x : α) (r : ℝ≥0∞) :
MapsTo f (EMetric.closedBall x r) (EMetric.closedBall (f x) r) :=
(hf.preimage_emetric_closedBall x r).ge
/-- The injection from a subtype is an isometry -/
theorem _root_.isometry_subtype_coe {s : Set α} : Isometry ((↑) : s → α) := fun _ _ => rfl
theorem comp_continuousOn_iff {γ} [TopologicalSpace γ] (hf : Isometry f) {g : γ → α} {s : Set γ} :
ContinuousOn (f ∘ g) s ↔ ContinuousOn g s :=
hf.uniformInducing.inducing.continuousOn_iff.symm
theorem comp_continuous_iff {γ} [TopologicalSpace γ] (hf : Isometry f) {g : γ → α} :
Continuous (f ∘ g) ↔ Continuous g :=
hf.uniformInducing.inducing.continuous_iff.symm
end PseudoEmetricIsometry
--section
section EmetricIsometry
variable [EMetricSpace α] [PseudoEMetricSpace β] {f : α → β}
/-- An isometry from an emetric space is injective -/
protected theorem injective (h : Isometry f) : Injective f :=
h.antilipschitz.injective
/-- An isometry from an emetric space is a uniform embedding -/
protected theorem uniformEmbedding (hf : Isometry f) : UniformEmbedding f :=
hf.antilipschitz.uniformEmbedding hf.lipschitz.uniformContinuous
/-- An isometry from an emetric space is an embedding -/
protected theorem embedding (hf : Isometry f) : Embedding f :=
hf.uniformEmbedding.embedding
/-- An isometry from a complete emetric space is a closed embedding -/
theorem closedEmbedding [CompleteSpace α] [EMetricSpace γ] {f : α → γ} (hf : Isometry f) :
ClosedEmbedding f :=
hf.antilipschitz.closedEmbedding hf.lipschitz.uniformContinuous
end EmetricIsometry
--section
section PseudoMetricIsometry
variable [PseudoMetricSpace α] [PseudoMetricSpace β] {f : α → β}
/-- An isometry preserves the diameter in pseudometric spaces. -/
theorem diam_image (hf : Isometry f) (s : Set α) : Metric.diam (f '' s) = Metric.diam s := by
rw [Metric.diam, Metric.diam, hf.ediam_image]
theorem diam_range (hf : Isometry f) : Metric.diam (range f) = Metric.diam (univ : Set α) := by
rw [← image_univ]
exact hf.diam_image univ
theorem preimage_setOf_dist (hf : Isometry f) (x : α) (p : ℝ → Prop) :
f ⁻¹' { y | p (dist y (f x)) } = { y | p (dist y x) } := by
ext y
simp [hf.dist_eq]
theorem preimage_closedBall (hf : Isometry f) (x : α) (r : ℝ) :
f ⁻¹' Metric.closedBall (f x) r = Metric.closedBall x r :=
hf.preimage_setOf_dist x (· ≤ r)
theorem preimage_ball (hf : Isometry f) (x : α) (r : ℝ) :
f ⁻¹' Metric.ball (f x) r = Metric.ball x r :=
hf.preimage_setOf_dist x (· < r)
theorem preimage_sphere (hf : Isometry f) (x : α) (r : ℝ) :
f ⁻¹' Metric.sphere (f x) r = Metric.sphere x r :=
hf.preimage_setOf_dist x (· = r)
theorem mapsTo_ball (hf : Isometry f) (x : α) (r : ℝ) :
MapsTo f (Metric.ball x r) (Metric.ball (f x) r) :=
(hf.preimage_ball x r).ge
theorem mapsTo_sphere (hf : Isometry f) (x : α) (r : ℝ) :
MapsTo f (Metric.sphere x r) (Metric.sphere (f x) r) :=
(hf.preimage_sphere x r).ge
theorem mapsTo_closedBall (hf : Isometry f) (x : α) (r : ℝ) :
MapsTo f (Metric.closedBall x r) (Metric.closedBall (f x) r) :=
(hf.preimage_closedBall x r).ge
end PseudoMetricIsometry
-- section
end Isometry
-- namespace
/-- A uniform embedding from a uniform space to a metric space is an isometry with respect to the
induced metric space structure on the source space. -/
theorem UniformEmbedding.to_isometry {α β} [UniformSpace α] [MetricSpace β] {f : α → β}
(h : UniformEmbedding f) : (letI := h.comapMetricSpace f; Isometry f) :=
let _ := h.comapMetricSpace f
Isometry.of_dist_eq fun _ _ => rfl
/-- An embedding from a topological space to a metric space is an isometry with respect to the
induced metric space structure on the source space. -/
theorem Embedding.to_isometry {α β} [TopologicalSpace α] [MetricSpace β] {f : α → β}
(h : Embedding f) : (letI := h.comapMetricSpace f; Isometry f) :=
let _ := h.comapMetricSpace f
Isometry.of_dist_eq fun _ _ => rfl
-- such a bijection need not exist
/-- `α` and `β` are isometric if there is an isometric bijection between them. -/
-- Porting note(#5171): was @[nolint has_nonempty_instance]
structure IsometryEquiv (α : Type u) (β : Type v) [PseudoEMetricSpace α] [PseudoEMetricSpace β]
extends α ≃ β where
isometry_toFun : Isometry toFun
@[inherit_doc]
infixl:25 " ≃ᵢ " => IsometryEquiv
namespace IsometryEquiv
section PseudoEMetricSpace
variable [PseudoEMetricSpace α] [PseudoEMetricSpace β] [PseudoEMetricSpace γ]
-- Porting note (#11215): TODO: add `IsometryEquivClass`
theorem toEquiv_injective : Injective (toEquiv : (α ≃ᵢ β) → (α ≃ β))
| ⟨_, _⟩, ⟨_, _⟩, rfl => rfl
@[simp] theorem toEquiv_inj {e₁ e₂ : α ≃ᵢ β} : e₁.toEquiv = e₂.toEquiv ↔ e₁ = e₂ :=
toEquiv_injective.eq_iff
instance : EquivLike (α ≃ᵢ β) α β where
coe e := e.toEquiv
inv e := e.toEquiv.symm
left_inv e := e.left_inv
right_inv e := e.right_inv
coe_injective' _ _ h _ := toEquiv_injective <| DFunLike.ext' h
theorem coe_eq_toEquiv (h : α ≃ᵢ β) (a : α) : h a = h.toEquiv a := rfl
@[simp] theorem coe_toEquiv (h : α ≃ᵢ β) : ⇑h.toEquiv = h := rfl
@[simp] theorem coe_mk (e : α ≃ β) (h) : ⇑(mk e h) = e := rfl
protected theorem isometry (h : α ≃ᵢ β) : Isometry h :=
h.isometry_toFun
protected theorem bijective (h : α ≃ᵢ β) : Bijective h :=
h.toEquiv.bijective
protected theorem injective (h : α ≃ᵢ β) : Injective h :=
h.toEquiv.injective
protected theorem surjective (h : α ≃ᵢ β) : Surjective h :=
h.toEquiv.surjective
protected theorem edist_eq (h : α ≃ᵢ β) (x y : α) : edist (h x) (h y) = edist x y :=
h.isometry.edist_eq x y
protected theorem dist_eq {α β : Type*} [PseudoMetricSpace α] [PseudoMetricSpace β] (h : α ≃ᵢ β)
(x y : α) : dist (h x) (h y) = dist x y :=
h.isometry.dist_eq x y
protected theorem nndist_eq {α β : Type*} [PseudoMetricSpace α] [PseudoMetricSpace β] (h : α ≃ᵢ β)
(x y : α) : nndist (h x) (h y) = nndist x y :=
h.isometry.nndist_eq x y
protected theorem continuous (h : α ≃ᵢ β) : Continuous h :=
h.isometry.continuous
@[simp]
theorem ediam_image (h : α ≃ᵢ β) (s : Set α) : EMetric.diam (h '' s) = EMetric.diam s :=
h.isometry.ediam_image s
@[ext]
theorem ext ⦃h₁ h₂ : α ≃ᵢ β⦄ (H : ∀ x, h₁ x = h₂ x) : h₁ = h₂ :=
DFunLike.ext _ _ H
/-- Alternative constructor for isometric bijections,
taking as input an isometry, and a right inverse. -/
def mk' {α : Type u} [EMetricSpace α] (f : α → β) (g : β → α) (hfg : ∀ x, f (g x) = x)
(hf : Isometry f) : α ≃ᵢ β where
toFun := f
invFun := g
left_inv _ := hf.injective <| hfg _
right_inv := hfg
isometry_toFun := hf
/-- The identity isometry of a space. -/
protected def refl (α : Type*) [PseudoEMetricSpace α] : α ≃ᵢ α :=
{ Equiv.refl α with isometry_toFun := isometry_id }
/-- The composition of two isometric isomorphisms, as an isometric isomorphism. -/
protected def trans (h₁ : α ≃ᵢ β) (h₂ : β ≃ᵢ γ) : α ≃ᵢ γ :=
{ Equiv.trans h₁.toEquiv h₂.toEquiv with
isometry_toFun := h₂.isometry_toFun.comp h₁.isometry_toFun }
@[simp]
theorem trans_apply (h₁ : α ≃ᵢ β) (h₂ : β ≃ᵢ γ) (x : α) : h₁.trans h₂ x = h₂ (h₁ x) :=
rfl
/-- The inverse of an isometric isomorphism, as an isometric isomorphism. -/
protected def symm (h : α ≃ᵢ β) : β ≃ᵢ α where
isometry_toFun := h.isometry.right_inv h.right_inv
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 IsometryEquiv (toEquiv_toFun → apply, toEquiv_invFun → symm_apply)
@[simp]
theorem symm_symm (h : α ≃ᵢ β) : h.symm.symm = h := rfl
theorem symm_bijective : Bijective (IsometryEquiv.symm : (α ≃ᵢ β) → β ≃ᵢ α) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
@[simp]
theorem apply_symm_apply (h : α ≃ᵢ β) (y : β) : h (h.symm y) = y :=
h.toEquiv.apply_symm_apply y
@[simp]
theorem symm_apply_apply (h : α ≃ᵢ β) (x : α) : h.symm (h x) = x :=
h.toEquiv.symm_apply_apply x
theorem symm_apply_eq (h : α ≃ᵢ β) {x : α} {y : β} : h.symm y = x ↔ y = h x :=
h.toEquiv.symm_apply_eq
theorem eq_symm_apply (h : α ≃ᵢ β) {x : α} {y : β} : x = h.symm y ↔ h x = y :=
h.toEquiv.eq_symm_apply
theorem symm_comp_self (h : α ≃ᵢ β) : (h.symm : β → α) ∘ h = id := funext h.left_inv
theorem self_comp_symm (h : α ≃ᵢ β) : (h : α → β) ∘ h.symm = id := funext h.right_inv
@[simp]
theorem range_eq_univ (h : α ≃ᵢ β) : range h = univ :=
h.toEquiv.range_eq_univ
theorem image_symm (h : α ≃ᵢ β) : image h.symm = preimage h :=
image_eq_preimage_of_inverse h.symm.toEquiv.left_inv h.symm.toEquiv.right_inv
theorem preimage_symm (h : α ≃ᵢ β) : preimage h.symm = image h :=
(image_eq_preimage_of_inverse h.toEquiv.left_inv h.toEquiv.right_inv).symm
@[simp]
theorem symm_trans_apply (h₁ : α ≃ᵢ β) (h₂ : β ≃ᵢ γ) (x : γ) :
(h₁.trans h₂).symm x = h₁.symm (h₂.symm x) :=
rfl
theorem ediam_univ (h : α ≃ᵢ β) : EMetric.diam (univ : Set α) = EMetric.diam (univ : Set β) := by
rw [← h.range_eq_univ, h.isometry.ediam_range]
@[simp]
theorem ediam_preimage (h : α ≃ᵢ β) (s : Set β) : EMetric.diam (h ⁻¹' s) = EMetric.diam s := by
rw [← image_symm, ediam_image]
@[simp]
theorem preimage_emetric_ball (h : α ≃ᵢ β) (x : β) (r : ℝ≥0∞) :
h ⁻¹' EMetric.ball x r = EMetric.ball (h.symm x) r := by
rw [← h.isometry.preimage_emetric_ball (h.symm x) r, h.apply_symm_apply]
@[simp]
theorem preimage_emetric_closedBall (h : α ≃ᵢ β) (x : β) (r : ℝ≥0∞) :
h ⁻¹' EMetric.closedBall x r = EMetric.closedBall (h.symm x) r := by
rw [← h.isometry.preimage_emetric_closedBall (h.symm x) r, h.apply_symm_apply]
@[simp]
theorem image_emetric_ball (h : α ≃ᵢ β) (x : α) (r : ℝ≥0∞) :
h '' EMetric.ball x r = EMetric.ball (h x) r := by
rw [← h.preimage_symm, h.symm.preimage_emetric_ball, symm_symm]
@[simp]
theorem image_emetric_closedBall (h : α ≃ᵢ β) (x : α) (r : ℝ≥0∞) :
h '' EMetric.closedBall x r = EMetric.closedBall (h x) r := by
rw [← h.preimage_symm, h.symm.preimage_emetric_closedBall, symm_symm]
/-- The (bundled) homeomorphism associated to an isometric isomorphism. -/
@[simps toEquiv]
protected def toHomeomorph (h : α ≃ᵢ β) : α ≃ₜ β where
continuous_toFun := h.continuous
continuous_invFun := h.symm.continuous
toEquiv := h.toEquiv
@[simp]
theorem coe_toHomeomorph (h : α ≃ᵢ β) : ⇑h.toHomeomorph = h :=
rfl
@[simp]
theorem coe_toHomeomorph_symm (h : α ≃ᵢ β) : ⇑h.toHomeomorph.symm = h.symm :=
rfl
@[simp]
theorem comp_continuousOn_iff {γ} [TopologicalSpace γ] (h : α ≃ᵢ β) {f : γ → α} {s : Set γ} :
ContinuousOn (h ∘ f) s ↔ ContinuousOn f s :=
h.toHomeomorph.comp_continuousOn_iff _ _
@[simp]
theorem comp_continuous_iff {γ} [TopologicalSpace γ] (h : α ≃ᵢ β) {f : γ → α} :
Continuous (h ∘ f) ↔ Continuous f :=
h.toHomeomorph.comp_continuous_iff
@[simp]
theorem comp_continuous_iff' {γ} [TopologicalSpace γ] (h : α ≃ᵢ β) {f : β → γ} :
Continuous (f ∘ h) ↔ Continuous f :=
h.toHomeomorph.comp_continuous_iff'
/-- The group of isometries. -/
instance : Group (α ≃ᵢ α) where
one := IsometryEquiv.refl _
mul e₁ e₂ := e₂.trans e₁
inv := IsometryEquiv.symm
mul_assoc e₁ e₂ e₃ := rfl
one_mul e := ext fun _ => rfl
mul_one e := ext fun _ => rfl
mul_left_inv e := ext e.symm_apply_apply
@[simp] theorem coe_one : ⇑(1 : α ≃ᵢ α) = id := rfl
@[simp] theorem coe_mul (e₁ e₂ : α ≃ᵢ α) : ⇑(e₁ * e₂) = e₁ ∘ e₂ := rfl
theorem mul_apply (e₁ e₂ : α ≃ᵢ α) (x : α) : (e₁ * e₂) x = e₁ (e₂ x) := rfl
@[simp] theorem inv_apply_self (e : α ≃ᵢ α) (x : α) : e⁻¹ (e x) = x := e.symm_apply_apply x
@[simp] theorem apply_inv_self (e : α ≃ᵢ α) (x : α) : e (e⁻¹ x) = x := e.apply_symm_apply x
theorem completeSpace_iff (e : α ≃ᵢ β) : CompleteSpace α ↔ CompleteSpace β := by
simp only [completeSpace_iff_isComplete_univ, ← e.range_eq_univ, ← image_univ,
isComplete_image_iff e.isometry.uniformInducing]
protected theorem completeSpace [CompleteSpace β] (e : α ≃ᵢ β) : CompleteSpace α :=
e.completeSpace_iff.2 ‹_›
variable (ι α)
/-- `Equiv.funUnique` as an `IsometryEquiv`. -/
@[simps!]
def funUnique [Unique ι] [Fintype ι] : (ι → α) ≃ᵢ α where
toEquiv := Equiv.funUnique ι α
isometry_toFun x hx := by simp [edist_pi_def, Finset.univ_unique, Finset.sup_singleton]
/-- `piFinTwoEquiv` as an `IsometryEquiv`. -/
@[simps!]
def piFinTwo (α : Fin 2 → Type*) [∀ i, PseudoEMetricSpace (α i)] : (∀ i, α i) ≃ᵢ α 0 × α 1 where
toEquiv := piFinTwoEquiv α
isometry_toFun x hx := by simp [edist_pi_def, Fin.univ_succ, Prod.edist_eq]
end PseudoEMetricSpace
section PseudoMetricSpace
variable [PseudoMetricSpace α] [PseudoMetricSpace β] (h : α ≃ᵢ β)
@[simp]
theorem diam_image (s : Set α) : Metric.diam (h '' s) = Metric.diam s :=
h.isometry.diam_image s
@[simp]
theorem diam_preimage (s : Set β) : Metric.diam (h ⁻¹' s) = Metric.diam s := by
rw [← image_symm, diam_image]
theorem diam_univ : Metric.diam (univ : Set α) = Metric.diam (univ : Set β) :=
congr_arg ENNReal.toReal h.ediam_univ
@[simp]
theorem preimage_ball (h : α ≃ᵢ β) (x : β) (r : ℝ) :
h ⁻¹' Metric.ball x r = Metric.ball (h.symm x) r := by
rw [← h.isometry.preimage_ball (h.symm x) r, h.apply_symm_apply]
@[simp]
theorem preimage_sphere (h : α ≃ᵢ β) (x : β) (r : ℝ) :
h ⁻¹' Metric.sphere x r = Metric.sphere (h.symm x) r := by
rw [← h.isometry.preimage_sphere (h.symm x) r, h.apply_symm_apply]
@[simp]
theorem preimage_closedBall (h : α ≃ᵢ β) (x : β) (r : ℝ) :
h ⁻¹' Metric.closedBall x r = Metric.closedBall (h.symm x) r := by
rw [← h.isometry.preimage_closedBall (h.symm x) r, h.apply_symm_apply]
@[simp]
theorem image_ball (h : α ≃ᵢ β) (x : α) (r : ℝ) : h '' Metric.ball x r = Metric.ball (h x) r := by
rw [← h.preimage_symm, h.symm.preimage_ball, symm_symm]
@[simp]
theorem image_sphere (h : α ≃ᵢ β) (x : α) (r : ℝ) :
h '' Metric.sphere x r = Metric.sphere (h x) r := by
rw [← h.preimage_symm, h.symm.preimage_sphere, symm_symm]
@[simp]
theorem image_closedBall (h : α ≃ᵢ β) (x : α) (r : ℝ) :
h '' Metric.closedBall x r = Metric.closedBall (h x) r := by
rw [← h.preimage_symm, h.symm.preimage_closedBall, symm_symm]
end PseudoMetricSpace
end IsometryEquiv
/-- An isometry induces an isometric isomorphism between the source space and the
range of the isometry. -/
@[simps! (config := { simpRhs := true }) toEquiv apply]
def Isometry.isometryEquivOnRange [EMetricSpace α] [PseudoEMetricSpace β] {f : α → β}
(h : Isometry f) : α ≃ᵢ range f where
isometry_toFun := h
toEquiv := Equiv.ofInjective f h.injective
open NNReal in
/-- Post-composition by an isometry does not change the Lipschitz-property of a function. -/
lemma Isometry.lipschitzWith_iff {α β γ : Type*} [PseudoEMetricSpace α] [PseudoEMetricSpace β]
[PseudoEMetricSpace γ] {f : α → β} {g : β → γ} (K : ℝ≥0) (h : Isometry g) :
LipschitzWith K (g ∘ f) ↔ LipschitzWith K f := by
simp [LipschitzWith, h.edist_eq]
|
Topology\MetricSpace\Kuratowski.lean | /-
Copyright (c) 2018 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.Analysis.Normed.Lp.lpSpace
import Mathlib.Topology.Sets.Compacts
/-!
# The Kuratowski embedding
Any separable metric space can be embedded isometrically in `ℓ^∞(ℕ, ℝ)`.
Any partially defined Lipschitz map into `ℓ^∞` can be extended to the whole space.
-/
noncomputable section
open Set Metric TopologicalSpace NNReal ENNReal lp Function
universe u v w
variable {α : Type u} {β : Type v} {γ : Type w}
namespace KuratowskiEmbedding
/-! ### Any separable metric space can be embedded isometrically in ℓ^∞(ℕ, ℝ) -/
variable {f g : ℓ^∞(ℕ)} {n : ℕ} {C : ℝ} [MetricSpace α] (x : ℕ → α) (a b : α)
/-- A metric space can be embedded in `l^∞(ℝ)` via the distances to points in
a fixed countable set, if this set is dense. This map is given in `kuratowskiEmbedding`,
without density assumptions. -/
def embeddingOfSubset : ℓ^∞(ℕ) :=
⟨fun n => dist a (x n) - dist (x 0) (x n), by
apply memℓp_infty
use dist a (x 0)
rintro - ⟨n, rfl⟩
exact abs_dist_sub_le _ _ _⟩
theorem embeddingOfSubset_coe : embeddingOfSubset x a n = dist a (x n) - dist (x 0) (x n) :=
rfl
/-- The embedding map is always a semi-contraction. -/
theorem embeddingOfSubset_dist_le (a b : α) :
dist (embeddingOfSubset x a) (embeddingOfSubset x b) ≤ dist a b := by
refine lp.norm_le_of_forall_le dist_nonneg fun n => ?_
simp only [lp.coeFn_sub, Pi.sub_apply, embeddingOfSubset_coe, Real.dist_eq]
convert abs_dist_sub_le a b (x n) using 2
ring
/-- When the reference set is dense, the embedding map is an isometry on its image. -/
theorem embeddingOfSubset_isometry (H : DenseRange x) : Isometry (embeddingOfSubset x) := by
refine Isometry.of_dist_eq fun a b => ?_
refine (embeddingOfSubset_dist_le x a b).antisymm (le_of_forall_pos_le_add fun e epos => ?_)
-- First step: find n with dist a (x n) < e
rcases Metric.mem_closure_range_iff.1 (H a) (e / 2) (half_pos epos) with ⟨n, hn⟩
-- Second step: use the norm control at index n to conclude
have C : dist b (x n) - dist a (x n) = embeddingOfSubset x b n - embeddingOfSubset x a n := by
simp only [embeddingOfSubset_coe, sub_sub_sub_cancel_right]
have :=
calc
dist a b ≤ dist a (x n) + dist (x n) b := dist_triangle _ _ _
_ = 2 * dist a (x n) + (dist b (x n) - dist a (x n)) := by simp [dist_comm]; ring
_ ≤ 2 * dist a (x n) + |dist b (x n) - dist a (x n)| := by
apply_rules [add_le_add_left, le_abs_self]
_ ≤ 2 * (e / 2) + |embeddingOfSubset x b n - embeddingOfSubset x a n| := by
rw [C]
apply_rules [add_le_add, mul_le_mul_of_nonneg_left, hn.le, le_refl]
norm_num
_ ≤ 2 * (e / 2) + dist (embeddingOfSubset x b) (embeddingOfSubset x a) := by
have : |embeddingOfSubset x b n - embeddingOfSubset x a n| ≤
dist (embeddingOfSubset x b) (embeddingOfSubset x a) := by
simp only [dist_eq_norm]
exact lp.norm_apply_le_norm ENNReal.top_ne_zero
(embeddingOfSubset x b - embeddingOfSubset x a) n
nlinarith
_ = dist (embeddingOfSubset x b) (embeddingOfSubset x a) + e := by ring
simpa [dist_comm] using this
/-- Every separable metric space embeds isometrically in `ℓ^∞(ℕ)`. -/
theorem exists_isometric_embedding (α : Type u) [MetricSpace α] [SeparableSpace α] :
∃ f : α → ℓ^∞(ℕ), Isometry f := by
rcases (univ : Set α).eq_empty_or_nonempty with h | h
· use fun _ => 0; intro x; exact absurd h (Nonempty.ne_empty ⟨x, mem_univ x⟩)
· -- We construct a map x : ℕ → α with dense image
rcases h with ⟨basepoint⟩
haveI : Inhabited α := ⟨basepoint⟩
have : ∃ s : Set α, s.Countable ∧ Dense s := exists_countable_dense α
rcases this with ⟨S, ⟨S_countable, S_dense⟩⟩
rcases Set.countable_iff_exists_subset_range.1 S_countable with ⟨x, x_range⟩
-- Use embeddingOfSubset to construct the desired isometry
exact ⟨embeddingOfSubset x, embeddingOfSubset_isometry x (S_dense.mono x_range)⟩
end KuratowskiEmbedding
open TopologicalSpace KuratowskiEmbedding
/-- The Kuratowski embedding is an isometric embedding of a separable metric space in `ℓ^∞(ℕ, ℝ)`.
-/
def kuratowskiEmbedding (α : Type u) [MetricSpace α] [SeparableSpace α] : α → ℓ^∞(ℕ) :=
Classical.choose (KuratowskiEmbedding.exists_isometric_embedding α)
/--
The Kuratowski embedding is an isometry.
Theorem 2.1 of [Assaf Naor, *Metric Embeddings and Lipschitz Extensions*][Naor-2015]. -/
protected theorem kuratowskiEmbedding.isometry (α : Type u) [MetricSpace α] [SeparableSpace α] :
Isometry (kuratowskiEmbedding α) :=
Classical.choose_spec (exists_isometric_embedding α)
/-- Version of the Kuratowski embedding for nonempty compacts -/
nonrec def NonemptyCompacts.kuratowskiEmbedding (α : Type u) [MetricSpace α] [CompactSpace α]
[Nonempty α] : NonemptyCompacts ℓ^∞(ℕ) where
carrier := range (kuratowskiEmbedding α)
isCompact' := isCompact_range (kuratowskiEmbedding.isometry α).continuous
nonempty' := range_nonempty _
/--
A function `f : α → ℓ^∞(ι, ℝ)` which is `K`-Lipschitz on a subset `s` admits a `K`-Lipschitz
extension to the whole space.
Theorem 2.2 of [Assaf Naor, *Metric Embeddings and Lipschitz Extensions*][Naor-2015]
The same result for the case of a finite type `ι` is implemented in
`LipschitzOnWith.extend_pi`.
-/
theorem LipschitzOnWith.extend_lp_infty [PseudoMetricSpace α] {s : Set α} {ι : Type*}
{f : α → ℓ^∞(ι)} {K : ℝ≥0} (hfl : LipschitzOnWith K f s) :
∃ g : α → ℓ^∞(ι), LipschitzWith K g ∧ EqOn f g s := by
-- Construct the coordinate-wise extensions
rw [LipschitzOnWith.coordinate] at hfl
have (i : ι) : ∃ g : α → ℝ, LipschitzWith K g ∧ EqOn (fun x => f x i) g s :=
LipschitzOnWith.extend_real (hfl i) -- use the nonlinear Hahn-Banach theorem here!
choose g hgl hgeq using this
rcases s.eq_empty_or_nonempty with rfl | ⟨a₀, ha₀_in_s⟩
· exact ⟨0, LipschitzWith.const' 0, by simp⟩
· -- Show that the extensions are uniformly bounded
have hf_extb : ∀ a : α, Memℓp (swap g a) ∞ := by
apply LipschitzWith.uniformly_bounded (swap g) hgl a₀
use ‖f a₀‖
rintro - ⟨i, rfl⟩
simp_rw [← hgeq i ha₀_in_s]
exact lp.norm_apply_le_norm top_ne_zero (f a₀) i
-- Construct witness by bundling the function with its certificate of membership in ℓ^∞
let f_ext' : α → ℓ^∞(ι) := fun i ↦ ⟨swap g i, hf_extb i⟩
refine ⟨f_ext', ?_, ?_⟩
· rw [LipschitzWith.coordinate]
exact hgl
· intro a hyp
ext i
exact (hgeq i) hyp
|
Topology\MetricSpace\Lipschitz.lean | /-
Copyright (c) 2018 Rohan Mitta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rohan Mitta, Kevin Buzzard, Alistair Tucker, Johannes Hölzl, Yury Kudryashov
-/
import Mathlib.Order.Interval.Set.ProjIcc
import Mathlib.Topology.Algebra.Order.Field
import Mathlib.Topology.Bornology.Hom
import Mathlib.Topology.EMetricSpace.Lipschitz
import Mathlib.Topology.MetricSpace.Basic
import Mathlib.Topology.MetricSpace.Bounded
/-!
# Lipschitz continuous functions
A map `f : α → β` between two (extended) metric spaces is called *Lipschitz continuous*
with constant `K ≥ 0` if for all `x, y` we have `edist (f x) (f y) ≤ K * edist x y`.
For a metric space, the latter inequality is equivalent to `dist (f x) (f y) ≤ K * dist x y`.
There is also a version asserting this inequality only for `x` and `y` in some set `s`.
Finally, `f : α → β` is called *locally Lipschitz continuous* if each `x : α` has a neighbourhood
on which `f` is Lipschitz continuous (with some constant).
In this file we specialize various facts about Lipschitz continuous maps
to the case of (pseudo) metric spaces.
## Implementation notes
The parameter `K` has type `ℝ≥0`. This way we avoid conjunction in the definition and have
coercions both to `ℝ` and `ℝ≥0∞`. Constructors whose names end with `'` take `K : ℝ` as an
argument, and return `LipschitzWith (Real.toNNReal K) f`.
-/
universe u v w x
open Filter Function Set Topology NNReal ENNReal Bornology
variable {α : Type u} {β : Type v} {γ : Type w} {ι : Type x}
theorem lipschitzWith_iff_dist_le_mul [PseudoMetricSpace α] [PseudoMetricSpace β] {K : ℝ≥0}
{f : α → β} : LipschitzWith K f ↔ ∀ x y, dist (f x) (f y) ≤ K * dist x y := by
simp only [LipschitzWith, edist_nndist, dist_nndist]
norm_cast
alias ⟨LipschitzWith.dist_le_mul, LipschitzWith.of_dist_le_mul⟩ := lipschitzWith_iff_dist_le_mul
theorem lipschitzOnWith_iff_dist_le_mul [PseudoMetricSpace α] [PseudoMetricSpace β] {K : ℝ≥0}
{s : Set α} {f : α → β} :
LipschitzOnWith K f s ↔ ∀ x ∈ s, ∀ y ∈ s, dist (f x) (f y) ≤ K * dist x y := by
simp only [LipschitzOnWith, edist_nndist, dist_nndist]
norm_cast
alias ⟨LipschitzOnWith.dist_le_mul, LipschitzOnWith.of_dist_le_mul⟩ :=
lipschitzOnWith_iff_dist_le_mul
namespace LipschitzWith
section Metric
variable [PseudoMetricSpace α] [PseudoMetricSpace β] [PseudoMetricSpace γ] {K : ℝ≥0} {f : α → β}
{x y : α} {r : ℝ}
protected theorem of_dist_le' {K : ℝ} (h : ∀ x y, dist (f x) (f y) ≤ K * dist x y) :
LipschitzWith (Real.toNNReal K) f :=
of_dist_le_mul fun x y =>
le_trans (h x y) <| by gcongr; apply Real.le_coe_toNNReal
protected theorem mk_one (h : ∀ x y, dist (f x) (f y) ≤ dist x y) : LipschitzWith 1 f :=
of_dist_le_mul <| by simpa only [NNReal.coe_one, one_mul] using h
/-- For functions to `ℝ`, it suffices to prove `f x ≤ f y + K * dist x y`; this version
doesn't assume `0≤K`. -/
protected theorem of_le_add_mul' {f : α → ℝ} (K : ℝ) (h : ∀ x y, f x ≤ f y + K * dist x y) :
LipschitzWith (Real.toNNReal K) f :=
have I : ∀ x y, f x - f y ≤ K * dist x y := fun x y => sub_le_iff_le_add'.2 (h x y)
LipschitzWith.of_dist_le' fun x y => abs_sub_le_iff.2 ⟨I x y, dist_comm y x ▸ I y x⟩
/-- For functions to `ℝ`, it suffices to prove `f x ≤ f y + K * dist x y`; this version
assumes `0≤K`. -/
protected theorem of_le_add_mul {f : α → ℝ} (K : ℝ≥0) (h : ∀ x y, f x ≤ f y + K * dist x y) :
LipschitzWith K f := by simpa only [Real.toNNReal_coe] using LipschitzWith.of_le_add_mul' K h
protected theorem of_le_add {f : α → ℝ} (h : ∀ x y, f x ≤ f y + dist x y) : LipschitzWith 1 f :=
LipschitzWith.of_le_add_mul 1 <| by simpa only [NNReal.coe_one, one_mul]
protected theorem le_add_mul {f : α → ℝ} {K : ℝ≥0} (h : LipschitzWith K f) (x y) :
f x ≤ f y + K * dist x y :=
sub_le_iff_le_add'.1 <| le_trans (le_abs_self _) <| h.dist_le_mul x y
protected theorem iff_le_add_mul {f : α → ℝ} {K : ℝ≥0} :
LipschitzWith K f ↔ ∀ x y, f x ≤ f y + K * dist x y :=
⟨LipschitzWith.le_add_mul, LipschitzWith.of_le_add_mul K⟩
theorem nndist_le (hf : LipschitzWith K f) (x y : α) : nndist (f x) (f y) ≤ K * nndist x y :=
hf.dist_le_mul x y
theorem dist_le_mul_of_le (hf : LipschitzWith K f) (hr : dist x y ≤ r) : dist (f x) (f y) ≤ K * r :=
(hf.dist_le_mul x y).trans <| by gcongr
theorem mapsTo_closedBall (hf : LipschitzWith K f) (x : α) (r : ℝ) :
MapsTo f (Metric.closedBall x r) (Metric.closedBall (f x) (K * r)) := fun _y hy =>
hf.dist_le_mul_of_le hy
theorem dist_lt_mul_of_lt (hf : LipschitzWith K f) (hK : K ≠ 0) (hr : dist x y < r) :
dist (f x) (f y) < K * r :=
(hf.dist_le_mul x y).trans_lt <| (mul_lt_mul_left <| NNReal.coe_pos.2 hK.bot_lt).2 hr
theorem mapsTo_ball (hf : LipschitzWith K f) (hK : K ≠ 0) (x : α) (r : ℝ) :
MapsTo f (Metric.ball x r) (Metric.ball (f x) (K * r)) := fun _y hy =>
hf.dist_lt_mul_of_lt hK hy
/-- A Lipschitz continuous map is a locally bounded map. -/
def toLocallyBoundedMap (f : α → β) (hf : LipschitzWith K f) : LocallyBoundedMap α β :=
LocallyBoundedMap.ofMapBounded f fun _s hs =>
let ⟨C, hC⟩ := Metric.isBounded_iff.1 hs
Metric.isBounded_iff.2 ⟨K * C, forall_mem_image.2 fun _x hx => forall_mem_image.2 fun _y hy =>
hf.dist_le_mul_of_le (hC hx hy)⟩
@[simp]
theorem coe_toLocallyBoundedMap (hf : LipschitzWith K f) : ⇑(hf.toLocallyBoundedMap f) = f :=
rfl
theorem comap_cobounded_le (hf : LipschitzWith K f) :
comap f (Bornology.cobounded β) ≤ Bornology.cobounded α :=
(hf.toLocallyBoundedMap f).2
/-- The image of a bounded set under a Lipschitz map is bounded. -/
theorem isBounded_image (hf : LipschitzWith K f) {s : Set α} (hs : IsBounded s) :
IsBounded (f '' s) :=
hs.image (toLocallyBoundedMap f hf)
theorem diam_image_le (hf : LipschitzWith K f) (s : Set α) (hs : IsBounded s) :
Metric.diam (f '' s) ≤ K * Metric.diam s :=
Metric.diam_le_of_forall_dist_le (mul_nonneg K.coe_nonneg Metric.diam_nonneg) <|
forall_mem_image.2 fun _x hx =>
forall_mem_image.2 fun _y hy => hf.dist_le_mul_of_le <| Metric.dist_le_diam_of_mem hs hx hy
protected theorem dist_left (y : α) : LipschitzWith 1 (dist · y) :=
LipschitzWith.mk_one fun _ _ => dist_dist_dist_le_left _ _ _
protected theorem dist_right (x : α) : LipschitzWith 1 (dist x) :=
LipschitzWith.of_le_add fun _ _ => dist_triangle_right _ _ _
protected theorem dist : LipschitzWith 2 (Function.uncurry <| @dist α _) := by
rw [← one_add_one_eq_two]
exact LipschitzWith.uncurry LipschitzWith.dist_left LipschitzWith.dist_right
theorem dist_iterate_succ_le_geometric {f : α → α} (hf : LipschitzWith K f) (x n) :
dist (f^[n] x) (f^[n + 1] x) ≤ dist x (f x) * (K : ℝ) ^ n := by
rw [iterate_succ, mul_comm]
simpa only [NNReal.coe_pow] using (hf.iterate n).dist_le_mul x (f x)
theorem _root_.lipschitzWith_max : LipschitzWith 1 fun p : ℝ × ℝ => max p.1 p.2 :=
LipschitzWith.of_le_add fun _ _ => sub_le_iff_le_add'.1 <|
(le_abs_self _).trans (abs_max_sub_max_le_max _ _ _ _)
theorem _root_.lipschitzWith_min : LipschitzWith 1 fun p : ℝ × ℝ => min p.1 p.2 :=
LipschitzWith.of_le_add fun _ _ => sub_le_iff_le_add'.1 <|
(le_abs_self _).trans (abs_min_sub_min_le_max _ _ _ _)
lemma _root_.Real.lipschitzWith_toNNReal : LipschitzWith 1 Real.toNNReal := by
refine lipschitzWith_iff_dist_le_mul.mpr (fun x y ↦ ?_)
simpa only [NNReal.coe_one, dist_prod_same_right, one_mul, Real.dist_eq] using
lipschitzWith_iff_dist_le_mul.mp lipschitzWith_max (x, 0) (y, 0)
lemma cauchySeq_comp (hf : LipschitzWith K f) {u : ℕ → α} (hu : CauchySeq u) :
CauchySeq (f ∘ u) := by
rcases cauchySeq_iff_le_tendsto_0.1 hu with ⟨b, b_nonneg, hb, blim⟩
refine cauchySeq_iff_le_tendsto_0.2 ⟨fun n ↦ K * b n, ?_, ?_, ?_⟩
· exact fun n ↦ mul_nonneg (by positivity) (b_nonneg n)
· exact fun n m N hn hm ↦ hf.dist_le_mul_of_le (hb n m N hn hm)
· rw [← mul_zero (K : ℝ)]
exact blim.const_mul _
end Metric
section EMetric
variable [PseudoEMetricSpace α] {f g : α → ℝ} {Kf Kg : ℝ≥0}
protected theorem max (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) :
LipschitzWith (max Kf Kg) fun x => max (f x) (g x) := by
simpa only [(· ∘ ·), one_mul] using lipschitzWith_max.comp (hf.prod hg)
protected theorem min (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) :
LipschitzWith (max Kf Kg) fun x => min (f x) (g x) := by
simpa only [(· ∘ ·), one_mul] using lipschitzWith_min.comp (hf.prod hg)
theorem max_const (hf : LipschitzWith Kf f) (a : ℝ) : LipschitzWith Kf fun x => max (f x) a := by
simpa only [max_eq_left (zero_le Kf)] using hf.max (LipschitzWith.const a)
theorem const_max (hf : LipschitzWith Kf f) (a : ℝ) : LipschitzWith Kf fun x => max a (f x) := by
simpa only [max_comm] using hf.max_const a
theorem min_const (hf : LipschitzWith Kf f) (a : ℝ) : LipschitzWith Kf fun x => min (f x) a := by
simpa only [max_eq_left (zero_le Kf)] using hf.min (LipschitzWith.const a)
theorem const_min (hf : LipschitzWith Kf f) (a : ℝ) : LipschitzWith Kf fun x => min a (f x) := by
simpa only [min_comm] using hf.min_const a
end EMetric
protected theorem projIcc {a b : ℝ} (h : a ≤ b) : LipschitzWith 1 (projIcc a b h) :=
((LipschitzWith.id.const_min _).const_max _).subtype_mk _
end LipschitzWith
namespace Metric
variable [PseudoMetricSpace α] [PseudoMetricSpace β] {s : Set α} {t : Set β}
end Metric
namespace LipschitzOnWith
section Metric
variable [PseudoMetricSpace α] [PseudoMetricSpace β] [PseudoMetricSpace γ]
variable {K : ℝ≥0} {s : Set α} {f : α → β}
protected theorem of_dist_le' {K : ℝ} (h : ∀ x ∈ s, ∀ y ∈ s, dist (f x) (f y) ≤ K * dist x y) :
LipschitzOnWith (Real.toNNReal K) f s :=
of_dist_le_mul fun x hx y hy =>
le_trans (h x hx y hy) <| by gcongr; apply Real.le_coe_toNNReal
protected theorem mk_one (h : ∀ x ∈ s, ∀ y ∈ s, dist (f x) (f y) ≤ dist x y) :
LipschitzOnWith 1 f s :=
of_dist_le_mul <| by simpa only [NNReal.coe_one, one_mul] using h
/-- For functions to `ℝ`, it suffices to prove `f x ≤ f y + K * dist x y`; this version
doesn't assume `0≤K`. -/
protected theorem of_le_add_mul' {f : α → ℝ} (K : ℝ)
(h : ∀ x ∈ s, ∀ y ∈ s, f x ≤ f y + K * dist x y) : LipschitzOnWith (Real.toNNReal K) f s :=
have I : ∀ x ∈ s, ∀ y ∈ s, f x - f y ≤ K * dist x y := fun x hx y hy =>
sub_le_iff_le_add'.2 (h x hx y hy)
LipschitzOnWith.of_dist_le' fun x hx y hy =>
abs_sub_le_iff.2 ⟨I x hx y hy, dist_comm y x ▸ I y hy x hx⟩
/-- For functions to `ℝ`, it suffices to prove `f x ≤ f y + K * dist x y`; this version
assumes `0≤K`. -/
protected theorem of_le_add_mul {f : α → ℝ} (K : ℝ≥0)
(h : ∀ x ∈ s, ∀ y ∈ s, f x ≤ f y + K * dist x y) : LipschitzOnWith K f s := by
simpa only [Real.toNNReal_coe] using LipschitzOnWith.of_le_add_mul' K h
protected theorem of_le_add {f : α → ℝ} (h : ∀ x ∈ s, ∀ y ∈ s, f x ≤ f y + dist x y) :
LipschitzOnWith 1 f s :=
LipschitzOnWith.of_le_add_mul 1 <| by simpa only [NNReal.coe_one, one_mul]
protected theorem le_add_mul {f : α → ℝ} {K : ℝ≥0} (h : LipschitzOnWith K f s) {x : α} (hx : x ∈ s)
{y : α} (hy : y ∈ s) : f x ≤ f y + K * dist x y :=
sub_le_iff_le_add'.1 <| le_trans (le_abs_self _) <| h.dist_le_mul x hx y hy
protected theorem iff_le_add_mul {f : α → ℝ} {K : ℝ≥0} :
LipschitzOnWith K f s ↔ ∀ x ∈ s, ∀ y ∈ s, f x ≤ f y + K * dist x y :=
⟨LipschitzOnWith.le_add_mul, LipschitzOnWith.of_le_add_mul K⟩
theorem isBounded_image2 (f : α → β → γ) {K₁ K₂ : ℝ≥0} {s : Set α} {t : Set β}
(hs : Bornology.IsBounded s) (ht : Bornology.IsBounded t)
(hf₁ : ∀ b ∈ t, LipschitzOnWith K₁ (fun a => f a b) s)
(hf₂ : ∀ a ∈ s, LipschitzOnWith K₂ (f a) t) : Bornology.IsBounded (Set.image2 f s t) :=
Metric.isBounded_iff_ediam_ne_top.2 <|
ne_top_of_le_ne_top
(ENNReal.add_ne_top.mpr
⟨ENNReal.mul_ne_top ENNReal.coe_ne_top hs.ediam_ne_top,
ENNReal.mul_ne_top ENNReal.coe_ne_top ht.ediam_ne_top⟩)
(ediam_image2_le _ _ _ hf₁ hf₂)
lemma cauchySeq_comp (hf : LipschitzOnWith K f s)
{u : ℕ → α} (hu : CauchySeq u) (h'u : range u ⊆ s) :
CauchySeq (f ∘ u) := by
rcases cauchySeq_iff_le_tendsto_0.1 hu with ⟨b, b_nonneg, hb, blim⟩
refine cauchySeq_iff_le_tendsto_0.2 ⟨fun n ↦ K * b n, ?_, ?_, ?_⟩
· exact fun n ↦ mul_nonneg (by positivity) (b_nonneg n)
· intro n m N hn hm
have A n : u n ∈ s := h'u (mem_range_self _)
apply (hf.dist_le_mul _ (A n) _ (A m)).trans
exact mul_le_mul_of_nonneg_left (hb n m N hn hm) K.2
· rw [← mul_zero (K : ℝ)]
exact blim.const_mul _
end Metric
end LipschitzOnWith
namespace LocallyLipschitz
section Real
variable [PseudoEMetricSpace α] {f g : α → ℝ}
/-- The minimum of locally Lipschitz functions is locally Lipschitz. -/
protected lemma min (hf : LocallyLipschitz f) (hg : LocallyLipschitz g) :
LocallyLipschitz (fun x => min (f x) (g x)) :=
lipschitzWith_min.locallyLipschitz.comp (hf.prod hg)
/-- The maximum of locally Lipschitz functions is locally Lipschitz. -/
protected lemma max (hf : LocallyLipschitz f) (hg : LocallyLipschitz g) :
LocallyLipschitz (fun x => max (f x) (g x)) :=
lipschitzWith_max.locallyLipschitz.comp (hf.prod hg)
theorem max_const (hf : LocallyLipschitz f) (a : ℝ) : LocallyLipschitz fun x => max (f x) a :=
hf.max (LocallyLipschitz.const a)
theorem const_max (hf : LocallyLipschitz f) (a : ℝ) : LocallyLipschitz fun x => max a (f x) := by
simpa [max_comm] using (hf.max_const a)
theorem min_const (hf : LocallyLipschitz f) (a : ℝ) : LocallyLipschitz fun x => min (f x) a :=
hf.min (LocallyLipschitz.const a)
theorem const_min (hf : LocallyLipschitz f) (a : ℝ) : LocallyLipschitz fun x => min a (f x) := by
simpa [min_comm] using (hf.min_const a)
end Real
end LocallyLipschitz
open Metric
variable [PseudoMetricSpace α] [PseudoMetricSpace β] {f : α → β}
/-- If a function is locally Lipschitz around a point, then it is continuous at this point. -/
theorem continuousAt_of_locally_lipschitz {x : α} {r : ℝ} (hr : 0 < r) (K : ℝ)
(h : ∀ y, dist y x < r → dist (f y) (f x) ≤ K * dist y x) : ContinuousAt f x := by
-- We use `h` to squeeze `dist (f y) (f x)` between `0` and `K * dist y x`
refine tendsto_iff_dist_tendsto_zero.2 (squeeze_zero' (eventually_of_forall fun _ => dist_nonneg)
(mem_of_superset (ball_mem_nhds _ hr) h) ?_)
-- Then show that `K * dist y x` tends to zero as `y → x`
refine (continuous_const.mul (continuous_id.dist continuous_const)).tendsto' _ _ ?_
simp
/-- A function `f : α → ℝ` which is `K`-Lipschitz on a subset `s` admits a `K`-Lipschitz extension
to the whole space. -/
theorem LipschitzOnWith.extend_real {f : α → ℝ} {s : Set α} {K : ℝ≥0} (hf : LipschitzOnWith K f s) :
∃ g : α → ℝ, LipschitzWith K g ∧ EqOn f g s := by
/- An extension is given by `g y = Inf {f x + K * dist y x | x ∈ s}`. Taking `x = y`, one has
`g y ≤ f y` for `y ∈ s`, and the other inequality holds because `f` is `K`-Lipschitz, so that it
can not counterbalance the growth of `K * dist y x`. One readily checks from the formula that
the extended function is also `K`-Lipschitz. -/
rcases eq_empty_or_nonempty s with (rfl | hs)
· exact ⟨fun _ => 0, (LipschitzWith.const _).weaken (zero_le _), eqOn_empty _ _⟩
have : Nonempty s := by simp only [hs, nonempty_coe_sort]
let g := fun y : α => iInf fun x : s => f x + K * dist y x
have B : ∀ y : α, BddBelow (range fun x : s => f x + K * dist y x) := fun y => by
rcases hs with ⟨z, hz⟩
refine ⟨f z - K * dist y z, ?_⟩
rintro w ⟨t, rfl⟩
dsimp
rw [sub_le_iff_le_add, add_assoc, ← mul_add, add_comm (dist y t)]
calc
f z ≤ f t + K * dist z t := hf.le_add_mul hz t.2
_ ≤ f t + K * (dist y z + dist y t) := by gcongr; apply dist_triangle_left
have E : EqOn f g s := fun x hx => by
refine le_antisymm (le_ciInf fun y => hf.le_add_mul hx y.2) ?_
simpa only [add_zero, Subtype.coe_mk, mul_zero, dist_self] using ciInf_le (B x) ⟨x, hx⟩
refine ⟨g, LipschitzWith.of_le_add_mul K fun x y => ?_, E⟩
rw [← sub_le_iff_le_add]
refine le_ciInf fun z => ?_
rw [sub_le_iff_le_add]
calc
g x ≤ f z + K * dist x z := ciInf_le (B x) _
_ ≤ f z + K * dist y z + K * dist x y := by
rw [add_assoc, ← mul_add, add_comm (dist y z)]
gcongr
apply dist_triangle
/-- A function `f : α → (ι → ℝ)` which is `K`-Lipschitz on a subset `s` admits a `K`-Lipschitz
extension to the whole space. The same result for the space `ℓ^∞ (ι, ℝ)` over a possibly infinite
type `ι` is implemented in `LipschitzOnWith.extend_lp_infty`. -/
theorem LipschitzOnWith.extend_pi [Fintype ι] {f : α → ι → ℝ} {s : Set α}
{K : ℝ≥0} (hf : LipschitzOnWith K f s) : ∃ g : α → ι → ℝ, LipschitzWith K g ∧ EqOn f g s := by
have : ∀ i, ∃ g : α → ℝ, LipschitzWith K g ∧ EqOn (fun x => f x i) g s := fun i => by
have : LipschitzOnWith K (fun x : α => f x i) s :=
LipschitzOnWith.of_dist_le_mul fun x hx y hy =>
(dist_le_pi_dist _ _ i).trans (hf.dist_le_mul x hx y hy)
exact this.extend_real
choose g hg using this
refine ⟨fun x i => g i x, LipschitzWith.of_dist_le_mul fun x y => ?_, fun x hx ↦ ?_⟩
· exact (dist_pi_le_iff (mul_nonneg K.2 dist_nonneg)).2 fun i => (hg i).1.dist_le_mul x y
· ext1 i
exact (hg i).2 hx
|
Topology\MetricSpace\MetricSeparated.lean | /-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Topology.EMetricSpace.Basic
/-!
# Metric separated pairs of sets
In this file we define the predicate `IsMetricSeparated`. We say that two sets in an (extended)
metric space are *metric separated* if the (extended) distance between `x ∈ s` and `y ∈ t` is
bounded from below by a positive constant.
This notion is useful, e.g., to define metric outer measures.
-/
open EMetric Set
noncomputable section
/-- Two sets in an (extended) metric space are called *metric separated* if the (extended) distance
between `x ∈ s` and `y ∈ t` is bounded from below by a positive constant. -/
def IsMetricSeparated {X : Type*} [EMetricSpace X] (s t : Set X) :=
∃ r, r ≠ 0 ∧ ∀ x ∈ s, ∀ y ∈ t, r ≤ edist x y
namespace IsMetricSeparated
variable {X : Type*} [EMetricSpace X] {s t : Set X} {x y : X}
@[symm]
theorem symm (h : IsMetricSeparated s t) : IsMetricSeparated t s :=
let ⟨r, r0, hr⟩ := h
⟨r, r0, fun y hy x hx => edist_comm x y ▸ hr x hx y hy⟩
theorem comm : IsMetricSeparated s t ↔ IsMetricSeparated t s :=
⟨symm, symm⟩
@[simp]
theorem empty_left (s : Set X) : IsMetricSeparated ∅ s :=
⟨1, one_ne_zero, fun _x => False.elim⟩
@[simp]
theorem empty_right (s : Set X) : IsMetricSeparated s ∅ :=
(empty_left s).symm
protected theorem disjoint (h : IsMetricSeparated s t) : Disjoint s t :=
let ⟨r, r0, hr⟩ := h
Set.disjoint_left.mpr fun x hx1 hx2 => r0 <| by simpa using hr x hx1 x hx2
theorem subset_compl_right (h : IsMetricSeparated s t) : s ⊆ tᶜ := fun _ hs ht =>
h.disjoint.le_bot ⟨hs, ht⟩
@[mono]
theorem mono {s' t'} (hs : s ⊆ s') (ht : t ⊆ t') :
IsMetricSeparated s' t' → IsMetricSeparated s t := fun ⟨r, r0, hr⟩ =>
⟨r, r0, fun x hx y hy => hr x (hs hx) y (ht hy)⟩
theorem mono_left {s'} (h' : IsMetricSeparated s' t) (hs : s ⊆ s') : IsMetricSeparated s t :=
h'.mono hs Subset.rfl
theorem mono_right {t'} (h' : IsMetricSeparated s t') (ht : t ⊆ t') : IsMetricSeparated s t :=
h'.mono Subset.rfl ht
theorem union_left {s'} (h : IsMetricSeparated s t) (h' : IsMetricSeparated s' t) :
IsMetricSeparated (s ∪ s') t := by
rcases h, h' with ⟨⟨r, r0, hr⟩, ⟨r', r0', hr'⟩⟩
refine ⟨min r r', ?_, fun x hx y hy => hx.elim ?_ ?_⟩
· rw [← pos_iff_ne_zero] at r0 r0' ⊢
exact lt_min r0 r0'
· exact fun hx => (min_le_left _ _).trans (hr _ hx _ hy)
· exact fun hx => (min_le_right _ _).trans (hr' _ hx _ hy)
@[simp]
theorem union_left_iff {s'} :
IsMetricSeparated (s ∪ s') t ↔ IsMetricSeparated s t ∧ IsMetricSeparated s' t :=
⟨fun h => ⟨h.mono_left subset_union_left, h.mono_left subset_union_right⟩, fun h =>
h.1.union_left h.2⟩
theorem union_right {t'} (h : IsMetricSeparated s t) (h' : IsMetricSeparated s t') :
IsMetricSeparated s (t ∪ t') :=
(h.symm.union_left h'.symm).symm
@[simp]
theorem union_right_iff {t'} :
IsMetricSeparated s (t ∪ t') ↔ IsMetricSeparated s t ∧ IsMetricSeparated s t' :=
comm.trans <| union_left_iff.trans <| and_congr comm comm
theorem finite_iUnion_left_iff {ι : Type*} {I : Set ι} (hI : I.Finite) {s : ι → Set X}
{t : Set X} : IsMetricSeparated (⋃ i ∈ I, s i) t ↔ ∀ i ∈ I, IsMetricSeparated (s i) t := by
refine Finite.induction_on hI (by simp) @fun i I _ _ hI => ?_
rw [biUnion_insert, forall_mem_insert, union_left_iff, hI]
alias ⟨_, finite_iUnion_left⟩ := finite_iUnion_left_iff
theorem finite_iUnion_right_iff {ι : Type*} {I : Set ι} (hI : I.Finite) {s : Set X}
{t : ι → Set X} : IsMetricSeparated s (⋃ i ∈ I, t i) ↔ ∀ i ∈ I, IsMetricSeparated s (t i) := by
simpa only [@comm _ _ s] using finite_iUnion_left_iff hI
@[simp]
theorem finset_iUnion_left_iff {ι : Type*} {I : Finset ι} {s : ι → Set X} {t : Set X} :
IsMetricSeparated (⋃ i ∈ I, s i) t ↔ ∀ i ∈ I, IsMetricSeparated (s i) t :=
finite_iUnion_left_iff I.finite_toSet
alias ⟨_, finset_iUnion_left⟩ := finset_iUnion_left_iff
@[simp]
theorem finset_iUnion_right_iff {ι : Type*} {I : Finset ι} {s : Set X} {t : ι → Set X} :
IsMetricSeparated s (⋃ i ∈ I, t i) ↔ ∀ i ∈ I, IsMetricSeparated s (t i) :=
finite_iUnion_right_iff I.finite_toSet
alias ⟨_, finset_iUnion_right⟩ := finset_iUnion_right_iff
end IsMetricSeparated
|
Topology\MetricSpace\PartitionOfUnity.lean | /-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Topology.EMetricSpace.Paracompact
import Mathlib.Topology.Instances.ENNReal
import Mathlib.Analysis.Convex.PartitionOfUnity
/-!
# Lemmas about (e)metric spaces that need partition of unity
The main lemma in this file (see `Metric.exists_continuous_real_forall_closedBall_subset`) says the
following. Let `X` be a metric space. Let `K : ι → Set X` be a locally finite family of closed sets,
let `U : ι → Set X` be a family of open sets such that `K i ⊆ U i` for all `i`. Then there exists a
positive continuous function `δ : C(X, → ℝ)` such that for any `i` and `x ∈ K i`, we have
`Metric.closedBall x (δ x) ⊆ U i`. We also formulate versions of this lemma for extended metric
spaces and for different codomains (`ℝ`, `ℝ≥0`, and `ℝ≥0∞`).
We also prove a few auxiliary lemmas to be used later in a proof of the smooth version of this
lemma.
## Tags
metric space, partition of unity, locally finite
-/
open Topology ENNReal NNReal Filter Set Function TopologicalSpace
variable {ι X : Type*}
namespace EMetric
variable [EMetricSpace X] {K : ι → Set X} {U : ι → Set X}
/-- Let `K : ι → Set X` be a locally finite family of closed sets in an emetric space. Let
`U : ι → Set X` be a family of open sets such that `K i ⊆ U i` for all `i`. Then for any point
`x : X`, for sufficiently small `r : ℝ≥0∞` and for `y` sufficiently close to `x`, for all `i`, if
`y ∈ K i`, then `EMetric.closedBall y r ⊆ U i`. -/
theorem eventually_nhds_zero_forall_closedBall_subset (hK : ∀ i, IsClosed (K i))
(hU : ∀ i, IsOpen (U i)) (hKU : ∀ i, K i ⊆ U i) (hfin : LocallyFinite K) (x : X) :
∀ᶠ p : ℝ≥0∞ × X in 𝓝 0 ×ˢ 𝓝 x, ∀ i, p.2 ∈ K i → closedBall p.2 p.1 ⊆ U i := by
suffices ∀ i, x ∈ K i → ∀ᶠ p : ℝ≥0∞ × X in 𝓝 0 ×ˢ 𝓝 x, closedBall p.2 p.1 ⊆ U i by
apply mp_mem ((eventually_all_finite (hfin.point_finite x)).2 this)
(mp_mem (@tendsto_snd ℝ≥0∞ _ (𝓝 0) _ _ (hfin.iInter_compl_mem_nhds hK x)) _)
apply univ_mem'
rintro ⟨r, y⟩ hxy hyU i hi
simp only [mem_iInter, mem_compl_iff, not_imp_not, mem_preimage] at hxy
exact hyU _ (hxy _ hi)
intro i hi
rcases nhds_basis_closed_eball.mem_iff.1 ((hU i).mem_nhds <| hKU i hi) with ⟨R, hR₀, hR⟩
rcases ENNReal.lt_iff_exists_nnreal_btwn.mp hR₀ with ⟨r, hr₀, hrR⟩
filter_upwards [prod_mem_prod (eventually_lt_nhds hr₀)
(closedBall_mem_nhds x (tsub_pos_iff_lt.2 hrR))] with p hp z hz
apply hR
calc
edist z x ≤ edist z p.2 + edist p.2 x := edist_triangle _ _ _
_ ≤ p.1 + (R - p.1) := add_le_add hz <| le_trans hp.2 <| tsub_le_tsub_left hp.1.out.le _
_ = R := add_tsub_cancel_of_le (lt_trans (by exact hp.1) hrR).le
theorem exists_forall_closedBall_subset_aux₁ (hK : ∀ i, IsClosed (K i)) (hU : ∀ i, IsOpen (U i))
(hKU : ∀ i, K i ⊆ U i) (hfin : LocallyFinite K) (x : X) :
∃ r : ℝ, ∀ᶠ y in 𝓝 x,
r ∈ Ioi (0 : ℝ) ∩ ENNReal.ofReal ⁻¹' ⋂ (i) (_ : y ∈ K i), { r | closedBall y r ⊆ U i } := by
have := (ENNReal.continuous_ofReal.tendsto' 0 0 ENNReal.ofReal_zero).eventually
(eventually_nhds_zero_forall_closedBall_subset hK hU hKU hfin x).curry
rcases this.exists_gt with ⟨r, hr0, hr⟩
refine ⟨r, hr.mono fun y hy => ⟨hr0, ?_⟩⟩
rwa [mem_preimage, mem_iInter₂]
theorem exists_forall_closedBall_subset_aux₂ (y : X) :
Convex ℝ
(Ioi (0 : ℝ) ∩ ENNReal.ofReal ⁻¹' ⋂ (i) (_ : y ∈ K i), { r | closedBall y r ⊆ U i }) :=
(convex_Ioi _).inter <| OrdConnected.convex <| OrdConnected.preimage_ennreal_ofReal <|
ordConnected_iInter fun i => ordConnected_iInter fun (_ : y ∈ K i) =>
ordConnected_setOf_closedBall_subset y (U i)
/-- Let `X` be an extended metric space. Let `K : ι → Set X` be a locally finite family of closed
sets, let `U : ι → Set X` be a family of open sets such that `K i ⊆ U i` for all `i`. Then there
exists a positive continuous function `δ : C(X, ℝ)` such that for any `i` and `x ∈ K i`,
we have `EMetric.closedBall x (ENNReal.ofReal (δ x)) ⊆ U i`. -/
theorem exists_continuous_real_forall_closedBall_subset (hK : ∀ i, IsClosed (K i))
(hU : ∀ i, IsOpen (U i)) (hKU : ∀ i, K i ⊆ U i) (hfin : LocallyFinite K) :
∃ δ : C(X, ℝ), (∀ x, 0 < δ x) ∧
∀ (i), ∀ x ∈ K i, closedBall x (ENNReal.ofReal <| δ x) ⊆ U i := by
simpa only [mem_inter_iff, forall_and, mem_preimage, mem_iInter, @forall_swap ι X] using
exists_continuous_forall_mem_convex_of_local_const exists_forall_closedBall_subset_aux₂
(exists_forall_closedBall_subset_aux₁ hK hU hKU hfin)
/-- Let `X` be an extended metric space. Let `K : ι → Set X` be a locally finite family of closed
sets, let `U : ι → Set X` be a family of open sets such that `K i ⊆ U i` for all `i`. Then there
exists a positive continuous function `δ : C(X, ℝ≥0)` such that for any `i` and `x ∈ K i`,
we have `EMetric.closedBall x (δ x) ⊆ U i`. -/
theorem exists_continuous_nnreal_forall_closedBall_subset (hK : ∀ i, IsClosed (K i))
(hU : ∀ i, IsOpen (U i)) (hKU : ∀ i, K i ⊆ U i) (hfin : LocallyFinite K) :
∃ δ : C(X, ℝ≥0), (∀ x, 0 < δ x) ∧ ∀ (i), ∀ x ∈ K i, closedBall x (δ x) ⊆ U i := by
rcases exists_continuous_real_forall_closedBall_subset hK hU hKU hfin with ⟨δ, hδ₀, hδ⟩
lift δ to C(X, ℝ≥0) using fun x => (hδ₀ x).le
refine ⟨δ, hδ₀, fun i x hi => ?_⟩
simpa only [← ENNReal.ofReal_coe_nnreal] using hδ i x hi
/-- Let `X` be an extended metric space. Let `K : ι → Set X` be a locally finite family of closed
sets, let `U : ι → Set X` be a family of open sets such that `K i ⊆ U i` for all `i`. Then there
exists a positive continuous function `δ : C(X, ℝ≥0∞)` such that for any `i` and `x ∈ K i`,
we have `EMetric.closedBall x (δ x) ⊆ U i`. -/
theorem exists_continuous_eNNReal_forall_closedBall_subset (hK : ∀ i, IsClosed (K i))
(hU : ∀ i, IsOpen (U i)) (hKU : ∀ i, K i ⊆ U i) (hfin : LocallyFinite K) :
∃ δ : C(X, ℝ≥0∞), (∀ x, 0 < δ x) ∧ ∀ (i), ∀ x ∈ K i, closedBall x (δ x) ⊆ U i :=
let ⟨δ, hδ₀, hδ⟩ := exists_continuous_nnreal_forall_closedBall_subset hK hU hKU hfin
⟨ContinuousMap.comp ⟨Coe.coe, ENNReal.continuous_coe⟩ δ, fun x => ENNReal.coe_pos.2 (hδ₀ x), hδ⟩
end EMetric
namespace Metric
variable [MetricSpace X] {K : ι → Set X} {U : ι → Set X}
/-- Let `X` be a metric space. Let `K : ι → Set X` be a locally finite family of closed sets, let
`U : ι → Set X` be a family of open sets such that `K i ⊆ U i` for all `i`. Then there exists a
positive continuous function `δ : C(X, ℝ≥0)` such that for any `i` and `x ∈ K i`, we have
`Metric.closedBall x (δ x) ⊆ U i`. -/
theorem exists_continuous_nnreal_forall_closedBall_subset (hK : ∀ i, IsClosed (K i))
(hU : ∀ i, IsOpen (U i)) (hKU : ∀ i, K i ⊆ U i) (hfin : LocallyFinite K) :
∃ δ : C(X, ℝ≥0), (∀ x, 0 < δ x) ∧ ∀ (i), ∀ x ∈ K i, closedBall x (δ x) ⊆ U i := by
rcases EMetric.exists_continuous_nnreal_forall_closedBall_subset hK hU hKU hfin with ⟨δ, hδ0, hδ⟩
refine ⟨δ, hδ0, fun i x hx => ?_⟩
rw [← emetric_closedBall_nnreal]
exact hδ i x hx
/-- Let `X` be a metric space. Let `K : ι → Set X` be a locally finite family of closed sets, let
`U : ι → Set X` be a family of open sets such that `K i ⊆ U i` for all `i`. Then there exists a
positive continuous function `δ : C(X, ℝ)` such that for any `i` and `x ∈ K i`, we have
`Metric.closedBall x (δ x) ⊆ U i`. -/
theorem exists_continuous_real_forall_closedBall_subset (hK : ∀ i, IsClosed (K i))
(hU : ∀ i, IsOpen (U i)) (hKU : ∀ i, K i ⊆ U i) (hfin : LocallyFinite K) :
∃ δ : C(X, ℝ), (∀ x, 0 < δ x) ∧ ∀ (i), ∀ x ∈ K i, closedBall x (δ x) ⊆ U i :=
let ⟨δ, hδ₀, hδ⟩ := exists_continuous_nnreal_forall_closedBall_subset hK hU hKU hfin
⟨ContinuousMap.comp ⟨Coe.coe, NNReal.continuous_coe⟩ δ, hδ₀, hδ⟩
end Metric
|
Topology\MetricSpace\Perfect.lean | /-
Copyright (c) 2022 Felix Weilacher. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Felix Weilacher
-/
import Mathlib.Topology.Perfect
import Mathlib.Topology.MetricSpace.Polish
import Mathlib.Topology.MetricSpace.CantorScheme
/-!
# Perfect Sets
In this file we define properties of `Perfect` subsets of a metric space,
including a version of the Cantor-Bendixson Theorem.
## Main Statements
* `Perfect.exists_nat_bool_injection`: A perfect nonempty set in a complete metric space
admits an embedding from the Cantor space.
## References
* [kechris1995] (Chapters 6-7)
## Tags
accumulation point, perfect set, cantor-bendixson.
--/
open Set Filter
section CantorInjMetric
open Function ENNReal
variable {α : Type*} [MetricSpace α] {C : Set α} {ε : ℝ≥0∞}
private theorem Perfect.small_diam_aux (hC : Perfect C) (ε_pos : 0 < ε) {x : α} (xC : x ∈ C) :
let D := closure (EMetric.ball x (ε / 2) ∩ C)
Perfect D ∧ D.Nonempty ∧ D ⊆ C ∧ EMetric.diam D ≤ ε := by
have : x ∈ EMetric.ball x (ε / 2) := by
apply EMetric.mem_ball_self
rw [ENNReal.div_pos_iff]
exact ⟨ne_of_gt ε_pos, by norm_num⟩
have := hC.closure_nhds_inter x xC this EMetric.isOpen_ball
refine ⟨this.1, this.2, ?_, ?_⟩
· rw [IsClosed.closure_subset_iff hC.closed]
apply inter_subset_right
rw [EMetric.diam_closure]
apply le_trans (EMetric.diam_mono inter_subset_left)
convert EMetric.diam_ball (x := x)
rw [mul_comm, ENNReal.div_mul_cancel] <;> norm_num
/-- A refinement of `Perfect.splitting` for metric spaces, where we also control
the diameter of the new perfect sets. -/
theorem Perfect.small_diam_splitting (hC : Perfect C) (hnonempty : C.Nonempty) (ε_pos : 0 < ε) :
∃ C₀ C₁ : Set α, (Perfect C₀ ∧ C₀.Nonempty ∧ C₀ ⊆ C ∧ EMetric.diam C₀ ≤ ε) ∧
(Perfect C₁ ∧ C₁.Nonempty ∧ C₁ ⊆ C ∧ EMetric.diam C₁ ≤ ε) ∧ Disjoint C₀ C₁ := by
rcases hC.splitting hnonempty with ⟨D₀, D₁, ⟨perf0, non0, sub0⟩, ⟨perf1, non1, sub1⟩, hdisj⟩
cases' non0 with x₀ hx₀
cases' non1 with x₁ hx₁
rcases perf0.small_diam_aux ε_pos hx₀ with ⟨perf0', non0', sub0', diam0⟩
rcases perf1.small_diam_aux ε_pos hx₁ with ⟨perf1', non1', sub1', diam1⟩
refine
⟨closure (EMetric.ball x₀ (ε / 2) ∩ D₀), closure (EMetric.ball x₁ (ε / 2) ∩ D₁),
⟨perf0', non0', sub0'.trans sub0, diam0⟩, ⟨perf1', non1', sub1'.trans sub1, diam1⟩, ?_⟩
apply Disjoint.mono _ _ hdisj <;> assumption
open CantorScheme
/-- Any nonempty perfect set in a complete metric space admits a continuous injection
from the Cantor space, `ℕ → Bool`. -/
theorem Perfect.exists_nat_bool_injection
(hC : Perfect C) (hnonempty : C.Nonempty) [CompleteSpace α] :
∃ f : (ℕ → Bool) → α, range f ⊆ C ∧ Continuous f ∧ Injective f := by
obtain ⟨u, -, upos', hu⟩ := exists_seq_strictAnti_tendsto' (zero_lt_one' ℝ≥0∞)
have upos := fun n => (upos' n).1
let P := Subtype fun E : Set α => Perfect E ∧ E.Nonempty
choose C0 C1 h0 h1 hdisj using
fun {C : Set α} (hC : Perfect C) (hnonempty : C.Nonempty) {ε : ℝ≥0∞} (hε : 0 < ε) =>
hC.small_diam_splitting hnonempty hε
let DP : List Bool → P := fun l => by
induction' l with a l ih; · exact ⟨C, ⟨hC, hnonempty⟩⟩
cases a
· use C0 ih.property.1 ih.property.2 (upos (l.length + 1))
exact ⟨(h0 _ _ _).1, (h0 _ _ _).2.1⟩
use C1 ih.property.1 ih.property.2 (upos (l.length + 1))
exact ⟨(h1 _ _ _).1, (h1 _ _ _).2.1⟩
let D : List Bool → Set α := fun l => (DP l).val
have hanti : ClosureAntitone D := by
refine Antitone.closureAntitone ?_ fun l => (DP l).property.1.closed
intro l a
cases a
· exact (h0 _ _ _).2.2.1
exact (h1 _ _ _).2.2.1
have hdiam : VanishingDiam D := by
intro x
apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds hu
· simp
rw [eventually_atTop]
refine ⟨1, fun m (hm : 1 ≤ m) => ?_⟩
rw [Nat.one_le_iff_ne_zero] at hm
rcases Nat.exists_eq_succ_of_ne_zero hm with ⟨n, rfl⟩
dsimp
cases x n
· convert (h0 _ _ _).2.2.2
rw [PiNat.res_length]
convert (h1 _ _ _).2.2.2
rw [PiNat.res_length]
have hdisj' : CantorScheme.Disjoint D := by
rintro l (a | a) (b | b) hab <;> try contradiction
· exact hdisj _ _ _
exact (hdisj _ _ _).symm
have hdom : ∀ {x : ℕ → Bool}, x ∈ (inducedMap D).1 := fun {x} => by
rw [hanti.map_of_vanishingDiam hdiam fun l => (DP l).property.2]
apply mem_univ
refine ⟨fun x => (inducedMap D).2 ⟨x, hdom⟩, ?_, ?_, ?_⟩
· rintro y ⟨x, rfl⟩
exact map_mem ⟨_, hdom⟩ 0
· apply hdiam.map_continuous.comp
continuity
intro x y hxy
simpa only [← Subtype.val_inj] using hdisj'.map_injective hxy
end CantorInjMetric
/-- Any closed uncountable subset of a Polish space admits a continuous injection
from the Cantor space `ℕ → Bool`. -/
theorem IsClosed.exists_nat_bool_injection_of_not_countable {α : Type*} [TopologicalSpace α]
[PolishSpace α] {C : Set α} (hC : IsClosed C) (hunc : ¬C.Countable) :
∃ f : (ℕ → Bool) → α, range f ⊆ C ∧ Continuous f ∧ Function.Injective f := by
letI := upgradePolishSpace α
obtain ⟨D, hD, Dnonempty, hDC⟩ := exists_perfect_nonempty_of_isClosed_of_not_countable hC hunc
obtain ⟨f, hfD, hf⟩ := hD.exists_nat_bool_injection Dnonempty
exact ⟨f, hfD.trans hDC, hf⟩
|
Topology\MetricSpace\PiNat.lean | /-
Copyright (c) 2022 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.MetricSpace.HausdorffDistance
/-!
# Topological study of spaces `Π (n : ℕ), E n`
When `E n` are topological spaces, the space `Π (n : ℕ), E n` is naturally a topological space
(with the product topology). When `E n` are uniform spaces, it also inherits a uniform structure.
However, it does not inherit a canonical metric space structure of the `E n`. Nevertheless, one
can put a noncanonical metric space structure (or rather, several of them). This is done in this
file.
## Main definitions and results
One can define a combinatorial distance on `Π (n : ℕ), E n`, as follows:
* `PiNat.cylinder x n` is the set of points `y` with `x i = y i` for `i < n`.
* `PiNat.firstDiff x y` is the first index at which `x i ≠ y i`.
* `PiNat.dist x y` is equal to `(1/2) ^ (firstDiff x y)`. It defines a distance
on `Π (n : ℕ), E n`, compatible with the topology when the `E n` have the discrete topology.
* `PiNat.metricSpace`: the metric space structure, given by this distance. Not registered as an
instance. This space is a complete metric space.
* `PiNat.metricSpaceOfDiscreteUniformity`: the same metric space structure, but adjusting the
uniformity defeqness when the `E n` already have the discrete uniformity. Not registered as an
instance
* `PiNat.metricSpaceNatNat`: the particular case of `ℕ → ℕ`, not registered as an instance.
These results are used to construct continuous functions on `Π n, E n`:
* `PiNat.exists_retraction_of_isClosed`: given a nonempty closed subset `s` of `Π (n : ℕ), E n`,
there exists a retraction onto `s`, i.e., a continuous map from the whole space to `s`
restricting to the identity on `s`.
* `exists_nat_nat_continuous_surjective_of_completeSpace`: given any nonempty complete metric
space with second-countable topology, there exists a continuous surjection from `ℕ → ℕ` onto
this space.
One can also put distances on `Π (i : ι), E i` when the spaces `E i` are metric spaces (not discrete
in general), and `ι` is countable.
* `PiCountable.dist` is the distance on `Π i, E i` given by
`dist x y = ∑' i, min (1/2)^(encode i) (dist (x i) (y i))`.
* `PiCountable.metricSpace` is the corresponding metric space structure, adjusted so that
the uniformity is definitionally the product uniformity. Not registered as an instance.
-/
noncomputable section
open scoped Classical
open Topology Filter
open TopologicalSpace Set Metric Filter Function
attribute [local simp] pow_le_pow_iff_right one_lt_two inv_le_inv zero_le_two zero_lt_two
variable {E : ℕ → Type*}
namespace PiNat
/-! ### The firstDiff function -/
/-- In a product space `Π n, E n`, then `firstDiff x y` is the first index at which `x` and `y`
differ. If `x = y`, then by convention we set `firstDiff x x = 0`. -/
irreducible_def firstDiff (x y : ∀ n, E n) : ℕ :=
if h : x ≠ y then Nat.find (ne_iff.1 h) else 0
theorem apply_firstDiff_ne {x y : ∀ n, E n} (h : x ≠ y) :
x (firstDiff x y) ≠ y (firstDiff x y) := by
rw [firstDiff_def, dif_pos h]
exact Nat.find_spec (ne_iff.1 h)
theorem apply_eq_of_lt_firstDiff {x y : ∀ n, E n} {n : ℕ} (hn : n < firstDiff x y) : x n = y n := by
rw [firstDiff_def] at hn
split_ifs at hn with h
· convert Nat.find_min (ne_iff.1 h) hn
simp
· exact (not_lt_zero' hn).elim
theorem firstDiff_comm (x y : ∀ n, E n) : firstDiff x y = firstDiff y x := by
simp only [firstDiff_def, ne_comm]
theorem min_firstDiff_le (x y z : ∀ n, E n) (h : x ≠ z) :
min (firstDiff x y) (firstDiff y z) ≤ firstDiff x z := by
by_contra! H
rw [lt_min_iff] at H
refine apply_firstDiff_ne h ?_
calc
x (firstDiff x z) = y (firstDiff x z) := apply_eq_of_lt_firstDiff H.1
_ = z (firstDiff x z) := apply_eq_of_lt_firstDiff H.2
/-! ### Cylinders -/
/-- In a product space `Π n, E n`, the cylinder set of length `n` around `x`, denoted
`cylinder x n`, is the set of sequences `y` that coincide with `x` on the first `n` symbols, i.e.,
such that `y i = x i` for all `i < n`.
-/
def cylinder (x : ∀ n, E n) (n : ℕ) : Set (∀ n, E n) :=
{ y | ∀ i, i < n → y i = x i }
theorem cylinder_eq_pi (x : ∀ n, E n) (n : ℕ) :
cylinder x n = Set.pi (Finset.range n : Set ℕ) fun i : ℕ => {x i} := by
ext y
simp [cylinder]
@[simp]
theorem cylinder_zero (x : ∀ n, E n) : cylinder x 0 = univ := by simp [cylinder_eq_pi]
theorem cylinder_anti (x : ∀ n, E n) {m n : ℕ} (h : m ≤ n) : cylinder x n ⊆ cylinder x m :=
fun _y hy i hi => hy i (hi.trans_le h)
@[simp]
theorem mem_cylinder_iff {x y : ∀ n, E n} {n : ℕ} : y ∈ cylinder x n ↔ ∀ i < n, y i = x i :=
Iff.rfl
theorem self_mem_cylinder (x : ∀ n, E n) (n : ℕ) : x ∈ cylinder x n := by simp
theorem mem_cylinder_iff_eq {x y : ∀ n, E n} {n : ℕ} :
y ∈ cylinder x n ↔ cylinder y n = cylinder x n := by
constructor
· intro hy
apply Subset.antisymm
· intro z hz i hi
rw [← hy i hi]
exact hz i hi
· intro z hz i hi
rw [hy i hi]
exact hz i hi
· intro h
rw [← h]
exact self_mem_cylinder _ _
theorem mem_cylinder_comm (x y : ∀ n, E n) (n : ℕ) : y ∈ cylinder x n ↔ x ∈ cylinder y n := by
simp [mem_cylinder_iff_eq, eq_comm]
theorem mem_cylinder_iff_le_firstDiff {x y : ∀ n, E n} (hne : x ≠ y) (i : ℕ) :
x ∈ cylinder y i ↔ i ≤ firstDiff x y := by
constructor
· intro h
by_contra!
exact apply_firstDiff_ne hne (h _ this)
· intro hi j hj
exact apply_eq_of_lt_firstDiff (hj.trans_le hi)
theorem mem_cylinder_firstDiff (x y : ∀ n, E n) : x ∈ cylinder y (firstDiff x y) := fun _i hi =>
apply_eq_of_lt_firstDiff hi
theorem cylinder_eq_cylinder_of_le_firstDiff (x y : ∀ n, E n) {n : ℕ} (hn : n ≤ firstDiff x y) :
cylinder x n = cylinder y n := by
rw [← mem_cylinder_iff_eq]
intro i hi
exact apply_eq_of_lt_firstDiff (hi.trans_le hn)
theorem iUnion_cylinder_update (x : ∀ n, E n) (n : ℕ) :
⋃ k, cylinder (update x n k) (n + 1) = cylinder x n := by
ext y
simp only [mem_cylinder_iff, mem_iUnion]
constructor
· rintro ⟨k, hk⟩ i hi
simpa [hi.ne] using hk i (Nat.lt_succ_of_lt hi)
· intro H
refine ⟨y n, fun i hi => ?_⟩
rcases Nat.lt_succ_iff_lt_or_eq.1 hi with (h'i | rfl)
· simp [H i h'i, h'i.ne]
· simp
theorem update_mem_cylinder (x : ∀ n, E n) (n : ℕ) (y : E n) : update x n y ∈ cylinder x n :=
mem_cylinder_iff.2 fun i hi => by simp [hi.ne]
section Res
variable {α : Type*}
open List
/-- In the case where `E` has constant value `α`,
the cylinder `cylinder x n` can be identified with the element of `List α`
consisting of the first `n` entries of `x`. See `cylinder_eq_res`.
We call this list `res x n`, the restriction of `x` to `n`. -/
def res (x : ℕ → α) : ℕ → List α
| 0 => nil
| Nat.succ n => x n :: res x n
@[simp]
theorem res_zero (x : ℕ → α) : res x 0 = @nil α :=
rfl
@[simp]
theorem res_succ (x : ℕ → α) (n : ℕ) : res x n.succ = x n :: res x n :=
rfl
@[simp]
theorem res_length (x : ℕ → α) (n : ℕ) : (res x n).length = n := by induction n <;> simp [*]
/-- The restrictions of `x` and `y` to `n` are equal if and only if `x m = y m` for all `m < n`. -/
theorem res_eq_res {x y : ℕ → α} {n : ℕ} :
res x n = res y n ↔ ∀ ⦃m⦄, m < n → x m = y m := by
constructor <;> intro h <;> induction' n with n ih; · simp
· intro m hm
rw [Nat.lt_succ_iff_lt_or_eq] at hm
simp only [res_succ, cons.injEq] at h
cases' hm with hm hm
· exact ih h.2 hm
rw [hm]
exact h.1
· simp
simp only [res_succ, cons.injEq]
refine ⟨h (Nat.lt_succ_self _), ih fun m hm => ?_⟩
exact h (hm.trans (Nat.lt_succ_self _))
theorem res_injective : Injective (@res α) := by
intro x y h
ext n
apply res_eq_res.mp _ (Nat.lt_succ_self _)
rw [h]
/-- `cylinder x n` is equal to the set of sequences `y` with the same restriction to `n` as `x`. -/
theorem cylinder_eq_res (x : ℕ → α) (n : ℕ) :
cylinder x n = { y | res y n = res x n } := by
ext y
dsimp [cylinder]
rw [res_eq_res]
end Res
/-!
### A distance function on `Π n, E n`
We define a distance function on `Π n, E n`, given by `dist x y = (1/2)^n` where `n` is the first
index at which `x` and `y` differ. When each `E n` has the discrete topology, this distance will
define the right topology on the product space. We do not record a global `Dist` instance nor
a `MetricSpace` instance, as other distances may be used on these spaces, but we register them as
local instances in this section.
-/
/-- The distance function on a product space `Π n, E n`, given by `dist x y = (1/2)^n` where `n` is
the first index at which `x` and `y` differ. -/
protected def dist : Dist (∀ n, E n) :=
⟨fun x y => if x ≠ y then (1 / 2 : ℝ) ^ firstDiff x y else 0⟩
attribute [local instance] PiNat.dist
theorem dist_eq_of_ne {x y : ∀ n, E n} (h : x ≠ y) : dist x y = (1 / 2 : ℝ) ^ firstDiff x y := by
simp [dist, h]
protected theorem dist_self (x : ∀ n, E n) : dist x x = 0 := by simp [dist]
protected theorem dist_comm (x y : ∀ n, E n) : dist x y = dist y x := by
simp [dist, @eq_comm _ x y, firstDiff_comm]
protected theorem dist_nonneg (x y : ∀ n, E n) : 0 ≤ dist x y := by
rcases eq_or_ne x y with (rfl | h)
· simp [dist]
· simp [dist, h, zero_le_two]
theorem dist_triangle_nonarch (x y z : ∀ n, E n) : dist x z ≤ max (dist x y) (dist y z) := by
rcases eq_or_ne x z with (rfl | hxz)
· simp [PiNat.dist_self x, PiNat.dist_nonneg]
rcases eq_or_ne x y with (rfl | hxy)
· simp
rcases eq_or_ne y z with (rfl | hyz)
· simp
simp only [dist_eq_of_ne, hxz, hxy, hyz, inv_le_inv, one_div, inv_pow, zero_lt_two, Ne,
not_false_iff, le_max_iff, pow_le_pow_iff_right, one_lt_two, pow_pos,
min_le_iff.1 (min_firstDiff_le x y z hxz)]
protected theorem dist_triangle (x y z : ∀ n, E n) : dist x z ≤ dist x y + dist y z :=
calc
dist x z ≤ max (dist x y) (dist y z) := dist_triangle_nonarch x y z
_ ≤ dist x y + dist y z := max_le_add_of_nonneg (PiNat.dist_nonneg _ _) (PiNat.dist_nonneg _ _)
protected theorem eq_of_dist_eq_zero (x y : ∀ n, E n) (hxy : dist x y = 0) : x = y := by
rcases eq_or_ne x y with (rfl | h); · rfl
simp [dist_eq_of_ne h] at hxy
theorem mem_cylinder_iff_dist_le {x y : ∀ n, E n} {n : ℕ} :
y ∈ cylinder x n ↔ dist y x ≤ (1 / 2) ^ n := by
rcases eq_or_ne y x with (rfl | hne)
· simp [PiNat.dist_self]
suffices (∀ i : ℕ, i < n → y i = x i) ↔ n ≤ firstDiff y x by simpa [dist_eq_of_ne hne]
constructor
· intro hy
by_contra! H
exact apply_firstDiff_ne hne (hy _ H)
· intro h i hi
exact apply_eq_of_lt_firstDiff (hi.trans_le h)
theorem apply_eq_of_dist_lt {x y : ∀ n, E n} {n : ℕ} (h : dist x y < (1 / 2) ^ n) {i : ℕ}
(hi : i ≤ n) : x i = y i := by
rcases eq_or_ne x y with (rfl | hne)
· rfl
have : n < firstDiff x y := by
simpa [dist_eq_of_ne hne, inv_lt_inv, pow_lt_pow_iff_right, one_lt_two] using h
exact apply_eq_of_lt_firstDiff (hi.trans_lt this)
/-- A function to a pseudo-metric-space is `1`-Lipschitz if and only if points in the same cylinder
of length `n` are sent to points within distance `(1/2)^n`.
Not expressed using `LipschitzWith` as we don't have a metric space structure -/
theorem lipschitz_with_one_iff_forall_dist_image_le_of_mem_cylinder {α : Type*}
[PseudoMetricSpace α] {f : (∀ n, E n) → α} :
(∀ x y : ∀ n, E n, dist (f x) (f y) ≤ dist x y) ↔
∀ x y n, y ∈ cylinder x n → dist (f x) (f y) ≤ (1 / 2) ^ n := by
constructor
· intro H x y n hxy
apply (H x y).trans
rw [PiNat.dist_comm]
exact mem_cylinder_iff_dist_le.1 hxy
· intro H x y
rcases eq_or_ne x y with (rfl | hne)
· simp [PiNat.dist_nonneg]
rw [dist_eq_of_ne hne]
apply H x y (firstDiff x y)
rw [firstDiff_comm]
exact mem_cylinder_firstDiff _ _
variable (E)
variable [∀ n, TopologicalSpace (E n)] [∀ n, DiscreteTopology (E n)]
theorem isOpen_cylinder (x : ∀ n, E n) (n : ℕ) : IsOpen (cylinder x n) := by
rw [PiNat.cylinder_eq_pi]
exact isOpen_set_pi (Finset.range n).finite_toSet fun a _ => isOpen_discrete _
theorem isTopologicalBasis_cylinders :
IsTopologicalBasis { s : Set (∀ n, E n) | ∃ (x : ∀ n, E n) (n : ℕ), s = cylinder x n } := by
apply isTopologicalBasis_of_isOpen_of_nhds
· rintro u ⟨x, n, rfl⟩
apply isOpen_cylinder
· intro x u hx u_open
obtain ⟨v, ⟨U, F, -, rfl⟩, xU, Uu⟩ :
∃ v ∈ { S : Set (∀ i : ℕ, E i) | ∃ (U : ∀ i : ℕ, Set (E i)) (F : Finset ℕ),
(∀ i : ℕ, i ∈ F → U i ∈ { s : Set (E i) | IsOpen s }) ∧ S = (F : Set ℕ).pi U },
x ∈ v ∧ v ⊆ u :=
(isTopologicalBasis_pi fun n : ℕ => isTopologicalBasis_opens).exists_subset_of_mem_open hx
u_open
rcases Finset.bddAbove F with ⟨n, hn⟩
refine ⟨cylinder x (n + 1), ⟨x, n + 1, rfl⟩, self_mem_cylinder _ _, Subset.trans ?_ Uu⟩
intro y hy
suffices ∀ i : ℕ, i ∈ F → y i ∈ U i by simpa
intro i hi
have : y i = x i := mem_cylinder_iff.1 hy i ((hn hi).trans_lt (lt_add_one n))
rw [this]
simp only [Set.mem_pi, Finset.mem_coe] at xU
exact xU i hi
variable {E}
theorem isOpen_iff_dist (s : Set (∀ n, E n)) :
IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, ∀ y, dist x y < ε → y ∈ s := by
constructor
· intro hs x hx
obtain ⟨v, ⟨y, n, rfl⟩, h'x, h's⟩ :
∃ v ∈ { s | ∃ (x : ∀ n : ℕ, E n) (n : ℕ), s = cylinder x n }, x ∈ v ∧ v ⊆ s :=
(isTopologicalBasis_cylinders E).exists_subset_of_mem_open hx hs
rw [← mem_cylinder_iff_eq.1 h'x] at h's
exact
⟨(1 / 2 : ℝ) ^ n, by simp, fun y hy => h's fun i hi => (apply_eq_of_dist_lt hy hi.le).symm⟩
· intro h
refine (isTopologicalBasis_cylinders E).isOpen_iff.2 fun x hx => ?_
rcases h x hx with ⟨ε, εpos, hε⟩
obtain ⟨n, hn⟩ : ∃ n : ℕ, (1 / 2 : ℝ) ^ n < ε := exists_pow_lt_of_lt_one εpos one_half_lt_one
refine ⟨cylinder x n, ⟨x, n, rfl⟩, self_mem_cylinder x n, fun y hy => hε y ?_⟩
rw [PiNat.dist_comm]
exact (mem_cylinder_iff_dist_le.1 hy).trans_lt hn
/-- Metric space structure on `Π (n : ℕ), E n` when the spaces `E n` have the discrete topology,
where the distance is given by `dist x y = (1/2)^n`, where `n` is the smallest index where `x` and
`y` differ. Not registered as a global instance by default.
Warning: this definition makes sure that the topology is defeq to the original product topology,
but it does not take care of a possible uniformity. If the `E n` have a uniform structure, then
there will be two non-defeq uniform structures on `Π n, E n`, the product one and the one coming
from the metric structure. In this case, use `metricSpaceOfDiscreteUniformity` instead. -/
protected def metricSpace : MetricSpace (∀ n, E n) :=
MetricSpace.ofDistTopology dist PiNat.dist_self PiNat.dist_comm PiNat.dist_triangle
isOpen_iff_dist PiNat.eq_of_dist_eq_zero
/-- Metric space structure on `Π (n : ℕ), E n` when the spaces `E n` have the discrete uniformity,
where the distance is given by `dist x y = (1/2)^n`, where `n` is the smallest index where `x` and
`y` differ. Not registered as a global instance by default. -/
protected def metricSpaceOfDiscreteUniformity {E : ℕ → Type*} [∀ n, UniformSpace (E n)]
(h : ∀ n, uniformity (E n) = 𝓟 idRel) : MetricSpace (∀ n, E n) :=
haveI : ∀ n, DiscreteTopology (E n) := fun n => discreteTopology_of_discrete_uniformity (h n)
{ dist_triangle := PiNat.dist_triangle
dist_comm := PiNat.dist_comm
dist_self := PiNat.dist_self
eq_of_dist_eq_zero := PiNat.eq_of_dist_eq_zero _ _
toUniformSpace := Pi.uniformSpace _
uniformity_dist := by
simp only [Pi.uniformity, h, idRel, comap_principal, preimage_setOf_eq]
apply le_antisymm
· simp only [le_iInf_iff, le_principal_iff]
intro ε εpos
obtain ⟨n, hn⟩ : ∃ n, (1 / 2 : ℝ) ^ n < ε := exists_pow_lt_of_lt_one εpos (by norm_num)
apply
@mem_iInf_of_iInter _ _ _ _ _ (Finset.range n).finite_toSet fun i =>
{ p : (∀ n : ℕ, E n) × ∀ n : ℕ, E n | p.fst i = p.snd i }
· simp only [mem_principal, setOf_subset_setOf, imp_self, imp_true_iff]
· rintro ⟨x, y⟩ hxy
simp only [Finset.mem_coe, Finset.mem_range, iInter_coe_set, mem_iInter, mem_setOf_eq]
at hxy
apply lt_of_le_of_lt _ hn
rw [← mem_cylinder_iff_dist_le, mem_cylinder_iff]
exact hxy
· simp only [le_iInf_iff, le_principal_iff]
intro n
refine mem_iInf_of_mem ((1 / 2) ^ n : ℝ) ?_
refine mem_iInf_of_mem (by positivity) ?_
simp only [mem_principal, setOf_subset_setOf, Prod.forall]
intro x y hxy
exact apply_eq_of_dist_lt hxy le_rfl }
/-- Metric space structure on `ℕ → ℕ` where the distance is given by `dist x y = (1/2)^n`,
where `n` is the smallest index where `x` and `y` differ.
Not registered as a global instance by default. -/
def metricSpaceNatNat : MetricSpace (ℕ → ℕ) :=
PiNat.metricSpaceOfDiscreteUniformity fun _ => rfl
attribute [local instance] PiNat.metricSpace
protected theorem completeSpace : CompleteSpace (∀ n, E n) := by
refine Metric.complete_of_convergent_controlled_sequences (fun n => (1 / 2) ^ n) (by simp) ?_
intro u hu
refine ⟨fun n => u n n, tendsto_pi_nhds.2 fun i => ?_⟩
refine tendsto_const_nhds.congr' ?_
filter_upwards [Filter.Ici_mem_atTop i] with n hn
exact apply_eq_of_dist_lt (hu i i n le_rfl hn) le_rfl
/-!
### Retractions inside product spaces
We show that, in a space `Π (n : ℕ), E n` where each `E n` is discrete, there is a retraction on
any closed nonempty subset `s`, i.e., a continuous map `f` from the whole space to `s` restricting
to the identity on `s`. The map `f` is defined as follows. For `x ∈ s`, let `f x = x`. Otherwise,
consider the longest prefix `w` that `x` shares with an element of `s`, and let `f x = z_w`
where `z_w` is an element of `s` starting with `w`.
-/
theorem exists_disjoint_cylinder {s : Set (∀ n, E n)} (hs : IsClosed s) {x : ∀ n, E n}
(hx : x ∉ s) : ∃ n, Disjoint s (cylinder x n) := by
rcases eq_empty_or_nonempty s with (rfl | hne)
· exact ⟨0, by simp⟩
have A : 0 < infDist x s := (hs.not_mem_iff_infDist_pos hne).1 hx
obtain ⟨n, hn⟩ : ∃ n, (1 / 2 : ℝ) ^ n < infDist x s := exists_pow_lt_of_lt_one A one_half_lt_one
refine ⟨n, disjoint_left.2 fun y ys hy => ?_⟩
apply lt_irrefl (infDist x s)
calc
infDist x s ≤ dist x y := infDist_le_dist_of_mem ys
_ ≤ (1 / 2) ^ n := by
rw [mem_cylinder_comm] at hy
exact mem_cylinder_iff_dist_le.1 hy
_ < infDist x s := hn
/-- Given a point `x` in a product space `Π (n : ℕ), E n`, and `s` a subset of this space, then
`shortestPrefixDiff x s` if the smallest `n` for which there is no element of `s` having the same
prefix of length `n` as `x`. If there is no such `n`, then use `0` by convention. -/
def shortestPrefixDiff {E : ℕ → Type*} (x : ∀ n, E n) (s : Set (∀ n, E n)) : ℕ :=
if h : ∃ n, Disjoint s (cylinder x n) then Nat.find h else 0
theorem firstDiff_lt_shortestPrefixDiff {s : Set (∀ n, E n)} (hs : IsClosed s) {x y : ∀ n, E n}
(hx : x ∉ s) (hy : y ∈ s) : firstDiff x y < shortestPrefixDiff x s := by
have A := exists_disjoint_cylinder hs hx
rw [shortestPrefixDiff, dif_pos A]
have B := Nat.find_spec A
contrapose! B
rw [not_disjoint_iff_nonempty_inter]
refine ⟨y, hy, ?_⟩
rw [mem_cylinder_comm]
exact cylinder_anti y B (mem_cylinder_firstDiff x y)
theorem shortestPrefixDiff_pos {s : Set (∀ n, E n)} (hs : IsClosed s) (hne : s.Nonempty)
{x : ∀ n, E n} (hx : x ∉ s) : 0 < shortestPrefixDiff x s := by
rcases hne with ⟨y, hy⟩
exact (zero_le _).trans_lt (firstDiff_lt_shortestPrefixDiff hs hx hy)
/-- Given a point `x` in a product space `Π (n : ℕ), E n`, and `s` a subset of this space, then
`longestPrefix x s` if the largest `n` for which there is an element of `s` having the same
prefix of length `n` as `x`. If there is no such `n`, use `0` by convention. -/
def longestPrefix {E : ℕ → Type*} (x : ∀ n, E n) (s : Set (∀ n, E n)) : ℕ :=
shortestPrefixDiff x s - 1
theorem firstDiff_le_longestPrefix {s : Set (∀ n, E n)} (hs : IsClosed s) {x y : ∀ n, E n}
(hx : x ∉ s) (hy : y ∈ s) : firstDiff x y ≤ longestPrefix x s := by
rw [longestPrefix, le_tsub_iff_right]
· exact firstDiff_lt_shortestPrefixDiff hs hx hy
· exact shortestPrefixDiff_pos hs ⟨y, hy⟩ hx
theorem inter_cylinder_longestPrefix_nonempty {s : Set (∀ n, E n)} (hs : IsClosed s)
(hne : s.Nonempty) (x : ∀ n, E n) : (s ∩ cylinder x (longestPrefix x s)).Nonempty := by
by_cases hx : x ∈ s
· exact ⟨x, hx, self_mem_cylinder _ _⟩
have A := exists_disjoint_cylinder hs hx
have B : longestPrefix x s < shortestPrefixDiff x s :=
Nat.pred_lt (shortestPrefixDiff_pos hs hne hx).ne'
rw [longestPrefix, shortestPrefixDiff, dif_pos A] at B ⊢
obtain ⟨y, ys, hy⟩ : ∃ y : ∀ n : ℕ, E n, y ∈ s ∧ x ∈ cylinder y (Nat.find A - 1) := by
simpa only [not_disjoint_iff, mem_cylinder_comm] using Nat.find_min A B
refine ⟨y, ys, ?_⟩
rw [mem_cylinder_iff_eq] at hy ⊢
rw [hy]
theorem disjoint_cylinder_of_longestPrefix_lt {s : Set (∀ n, E n)} (hs : IsClosed s) {x : ∀ n, E n}
(hx : x ∉ s) {n : ℕ} (hn : longestPrefix x s < n) : Disjoint s (cylinder x n) := by
contrapose! hn
rcases not_disjoint_iff_nonempty_inter.1 hn with ⟨y, ys, hy⟩
apply le_trans _ (firstDiff_le_longestPrefix hs hx ys)
apply (mem_cylinder_iff_le_firstDiff (ne_of_mem_of_not_mem ys hx).symm _).1
rwa [mem_cylinder_comm]
/-- If two points `x, y` coincide up to length `n`, and the longest common prefix of `x` with `s`
is strictly shorter than `n`, then the longest common prefix of `y` with `s` is the same, and both
cylinders of this length based at `x` and `y` coincide. -/
theorem cylinder_longestPrefix_eq_of_longestPrefix_lt_firstDiff {x y : ∀ n, E n}
{s : Set (∀ n, E n)} (hs : IsClosed s) (hne : s.Nonempty)
(H : longestPrefix x s < firstDiff x y) (xs : x ∉ s) (ys : y ∉ s) :
cylinder x (longestPrefix x s) = cylinder y (longestPrefix y s) := by
have l_eq : longestPrefix y s = longestPrefix x s := by
rcases lt_trichotomy (longestPrefix y s) (longestPrefix x s) with (L | L | L)
· have Ax : (s ∩ cylinder x (longestPrefix x s)).Nonempty :=
inter_cylinder_longestPrefix_nonempty hs hne x
have Z := disjoint_cylinder_of_longestPrefix_lt hs ys L
rw [firstDiff_comm] at H
rw [cylinder_eq_cylinder_of_le_firstDiff _ _ H.le] at Z
exact (Ax.not_disjoint Z).elim
· exact L
· have Ay : (s ∩ cylinder y (longestPrefix y s)).Nonempty :=
inter_cylinder_longestPrefix_nonempty hs hne y
have A'y : (s ∩ cylinder y (longestPrefix x s).succ).Nonempty :=
Ay.mono (inter_subset_inter_right s (cylinder_anti _ L))
have Z := disjoint_cylinder_of_longestPrefix_lt hs xs (Nat.lt_succ_self _)
rw [cylinder_eq_cylinder_of_le_firstDiff _ _ H] at Z
exact (A'y.not_disjoint Z).elim
rw [l_eq, ← mem_cylinder_iff_eq]
exact cylinder_anti y H.le (mem_cylinder_firstDiff x y)
/-- Given a closed nonempty subset `s` of `Π (n : ℕ), E n`, there exists a Lipschitz retraction
onto this set, i.e., a Lipschitz map with range equal to `s`, equal to the identity on `s`. -/
theorem exists_lipschitz_retraction_of_isClosed {s : Set (∀ n, E n)} (hs : IsClosed s)
(hne : s.Nonempty) :
∃ f : (∀ n, E n) → ∀ n, E n, (∀ x ∈ s, f x = x) ∧ range f = s ∧ LipschitzWith 1 f := by
/- The map `f` is defined as follows. For `x ∈ s`, let `f x = x`. Otherwise, consider the longest
prefix `w` that `x` shares with an element of `s`, and let `f x = z_w` where `z_w` is an element
of `s` starting with `w`. All the desired properties are clear, except the fact that `f` is
`1`-Lipschitz: if two points `x, y` belong to a common cylinder of length `n`, one should show
that their images also belong to a common cylinder of length `n`. This is a case analysis:
* if both `x, y ∈ s`, then this is clear.
* if `x ∈ s` but `y ∉ s`, then the longest prefix `w` of `y` shared by an element of `s` is of
length at least `n` (because of `x`), and then `f y` starts with `w` and therefore stays in the
same length `n` cylinder.
* if `x ∉ s`, `y ∉ s`, let `w` be the longest prefix of `x` shared by an element of `s`. If its
length is `< n`, then it is also the longest prefix of `y`, and we get `f x = f y = z_w`.
Otherwise, `f x` remains in the same `n`-cylinder as `x`. Similarly for `y`. Finally, `f x` and
`f y` are again in the same `n`-cylinder, as desired. -/
set f := fun x => if x ∈ s then x else (inter_cylinder_longestPrefix_nonempty hs hne x).some
have fs : ∀ x ∈ s, f x = x := fun x xs => by simp [f, xs]
refine ⟨f, fs, ?_, ?_⟩
-- check that the range of `f` is `s`.
· apply Subset.antisymm
· rintro x ⟨y, rfl⟩
by_cases hy : y ∈ s
· rwa [fs y hy]
simpa [f, if_neg hy] using (inter_cylinder_longestPrefix_nonempty hs hne y).choose_spec.1
· intro x hx
rw [← fs x hx]
exact mem_range_self _
-- check that `f` is `1`-Lipschitz, by a case analysis.
· refine LipschitzWith.mk_one fun x y => ?_
-- exclude the trivial cases where `x = y`, or `f x = f y`.
rcases eq_or_ne x y with (rfl | hxy)
· simp
rcases eq_or_ne (f x) (f y) with (h' | hfxfy)
· simp [h', dist_nonneg]
have I2 : cylinder x (firstDiff x y) = cylinder y (firstDiff x y) := by
rw [← mem_cylinder_iff_eq]
apply mem_cylinder_firstDiff
suffices firstDiff x y ≤ firstDiff (f x) (f y) by
simpa [dist_eq_of_ne hxy, dist_eq_of_ne hfxfy]
-- case where `x ∈ s`
by_cases xs : x ∈ s
· rw [fs x xs] at hfxfy ⊢
-- case where `y ∈ s`, trivial
by_cases ys : y ∈ s
· rw [fs y ys]
-- case where `y ∉ s`
have A : (s ∩ cylinder y (longestPrefix y s)).Nonempty :=
inter_cylinder_longestPrefix_nonempty hs hne y
have fy : f y = A.some := by simp_rw [f, if_neg ys]
have I : cylinder A.some (firstDiff x y) = cylinder y (firstDiff x y) := by
rw [← mem_cylinder_iff_eq, firstDiff_comm]
apply cylinder_anti y _ A.some_mem.2
exact firstDiff_le_longestPrefix hs ys xs
rwa [← fy, ← I2, ← mem_cylinder_iff_eq, mem_cylinder_iff_le_firstDiff hfxfy.symm,
firstDiff_comm _ x] at I
-- case where `x ∉ s`
· by_cases ys : y ∈ s
-- case where `y ∈ s` (similar to the above)
· have A : (s ∩ cylinder x (longestPrefix x s)).Nonempty :=
inter_cylinder_longestPrefix_nonempty hs hne x
have fx : f x = A.some := by simp_rw [f, if_neg xs]
have I : cylinder A.some (firstDiff x y) = cylinder x (firstDiff x y) := by
rw [← mem_cylinder_iff_eq]
apply cylinder_anti x _ A.some_mem.2
apply firstDiff_le_longestPrefix hs xs ys
rw [fs y ys] at hfxfy ⊢
rwa [← fx, I2, ← mem_cylinder_iff_eq, mem_cylinder_iff_le_firstDiff hfxfy] at I
-- case where `y ∉ s`
· have Ax : (s ∩ cylinder x (longestPrefix x s)).Nonempty :=
inter_cylinder_longestPrefix_nonempty hs hne x
have fx : f x = Ax.some := by simp_rw [f, if_neg xs]
have Ay : (s ∩ cylinder y (longestPrefix y s)).Nonempty :=
inter_cylinder_longestPrefix_nonempty hs hne y
have fy : f y = Ay.some := by simp_rw [f, if_neg ys]
-- case where the common prefix to `x` and `s`, or `y` and `s`, is shorter than the
-- common part to `x` and `y` -- then `f x = f y`.
by_cases H : longestPrefix x s < firstDiff x y ∨ longestPrefix y s < firstDiff x y
· have : cylinder x (longestPrefix x s) = cylinder y (longestPrefix y s) := by
cases' H with H H
· exact cylinder_longestPrefix_eq_of_longestPrefix_lt_firstDiff hs hne H xs ys
· symm
rw [firstDiff_comm] at H
exact cylinder_longestPrefix_eq_of_longestPrefix_lt_firstDiff hs hne H ys xs
rw [fx, fy] at hfxfy
apply (hfxfy _).elim
congr
-- case where the common prefix to `x` and `s` is long, as well as the common prefix to
-- `y` and `s`. Then all points remain in the same cylinders.
· push_neg at H
have I1 : cylinder Ax.some (firstDiff x y) = cylinder x (firstDiff x y) := by
rw [← mem_cylinder_iff_eq]
exact cylinder_anti x H.1 Ax.some_mem.2
have I3 : cylinder y (firstDiff x y) = cylinder Ay.some (firstDiff x y) := by
rw [eq_comm, ← mem_cylinder_iff_eq]
exact cylinder_anti y H.2 Ay.some_mem.2
have : cylinder Ax.some (firstDiff x y) = cylinder Ay.some (firstDiff x y) := by
rw [I1, I2, I3]
rw [← fx, ← fy, ← mem_cylinder_iff_eq, mem_cylinder_iff_le_firstDiff hfxfy] at this
exact this
/-- Given a closed nonempty subset `s` of `Π (n : ℕ), E n`, there exists a retraction onto this
set, i.e., a continuous map with range equal to `s`, equal to the identity on `s`. -/
theorem exists_retraction_of_isClosed {s : Set (∀ n, E n)} (hs : IsClosed s) (hne : s.Nonempty) :
∃ f : (∀ n, E n) → ∀ n, E n, (∀ x ∈ s, f x = x) ∧ range f = s ∧ Continuous f := by
rcases exists_lipschitz_retraction_of_isClosed hs hne with ⟨f, fs, frange, hf⟩
exact ⟨f, fs, frange, hf.continuous⟩
theorem exists_retraction_subtype_of_isClosed {s : Set (∀ n, E n)} (hs : IsClosed s)
(hne : s.Nonempty) :
∃ f : (∀ n, E n) → s, (∀ x : s, f x = x) ∧ Surjective f ∧ Continuous f := by
obtain ⟨f, fs, rfl, f_cont⟩ :
∃ f : (∀ n, E n) → ∀ n, E n, (∀ x ∈ s, f x = x) ∧ range f = s ∧ Continuous f :=
exists_retraction_of_isClosed hs hne
have A : ∀ x : range f, rangeFactorization f x = x := fun x ↦ Subtype.eq <| fs x x.2
exact ⟨rangeFactorization f, A, fun x => ⟨x, A x⟩, f_cont.subtype_mk _⟩
end PiNat
open PiNat
/-- Any nonempty complete second countable metric space is the continuous image of the
fundamental space `ℕ → ℕ`. For a version of this theorem in the context of Polish spaces, see
`exists_nat_nat_continuous_surjective_of_polishSpace`. -/
theorem exists_nat_nat_continuous_surjective_of_completeSpace (α : Type*) [MetricSpace α]
[CompleteSpace α] [SecondCountableTopology α] [Nonempty α] :
∃ f : (ℕ → ℕ) → α, Continuous f ∧ Surjective f := by
/- First, we define a surjective map from a closed subset `s` of `ℕ → ℕ`. Then, we compose
this map with a retraction of `ℕ → ℕ` onto `s` to obtain the desired map.
Let us consider a dense sequence `u` in `α`. Then `s` is the set of sequences `xₙ` such that the
balls `closedBall (u xₙ) (1/2^n)` have a nonempty intersection. This set is closed,
and we define `f x` there to be the unique point in the intersection.
This function is continuous and surjective by design. -/
letI : MetricSpace (ℕ → ℕ) := PiNat.metricSpaceNatNat
have I0 : (0 : ℝ) < 1 / 2 := by norm_num
have I1 : (1 / 2 : ℝ) < 1 := by norm_num
rcases exists_dense_seq α with ⟨u, hu⟩
let s : Set (ℕ → ℕ) := { x | (⋂ n : ℕ, closedBall (u (x n)) ((1 / 2) ^ n)).Nonempty }
let g : s → α := fun x => x.2.some
have A : ∀ (x : s) (n : ℕ), dist (g x) (u ((x : ℕ → ℕ) n)) ≤ (1 / 2) ^ n := fun x n =>
(mem_iInter.1 x.2.some_mem n : _)
have g_cont : Continuous g := by
refine continuous_iff_continuousAt.2 fun y => ?_
refine continuousAt_of_locally_lipschitz zero_lt_one 4 fun x hxy => ?_
rcases eq_or_ne x y with (rfl | hne)
· simp
have hne' : x.1 ≠ y.1 := Subtype.coe_injective.ne hne
have dist' : dist x y = dist x.1 y.1 := rfl
let n := firstDiff x.1 y.1 - 1
have diff_pos : 0 < firstDiff x.1 y.1 := by
by_contra! h
apply apply_firstDiff_ne hne'
rw [Nat.le_zero.1 h]
apply apply_eq_of_dist_lt _ le_rfl
rw [pow_zero]
exact hxy
have hn : firstDiff x.1 y.1 = n + 1 := (Nat.succ_pred_eq_of_pos diff_pos).symm
rw [dist', dist_eq_of_ne hne', hn]
have B : x.1 n = y.1 n := mem_cylinder_firstDiff x.1 y.1 n (Nat.pred_lt diff_pos.ne')
calc
dist (g x) (g y) ≤ dist (g x) (u (x.1 n)) + dist (g y) (u (x.1 n)) :=
dist_triangle_right _ _ _
_ = dist (g x) (u (x.1 n)) + dist (g y) (u (y.1 n)) := by rw [← B]
_ ≤ (1 / 2) ^ n + (1 / 2) ^ n := add_le_add (A x n) (A y n)
_ = 4 * (1 / 2) ^ (n + 1) := by ring
have g_surj : Surjective g := fun y ↦ by
have : ∀ n : ℕ, ∃ j, y ∈ closedBall (u j) ((1 / 2) ^ n) := fun n ↦ by
rcases hu.exists_dist_lt y (by simp : (0 : ℝ) < (1 / 2) ^ n) with ⟨j, hj⟩
exact ⟨j, hj.le⟩
choose x hx using this
have I : (⋂ n : ℕ, closedBall (u (x n)) ((1 / 2) ^ n)).Nonempty := ⟨y, mem_iInter.2 hx⟩
refine ⟨⟨x, I⟩, ?_⟩
refine dist_le_zero.1 ?_
have J : ∀ n : ℕ, dist (g ⟨x, I⟩) y ≤ (1 / 2) ^ n + (1 / 2) ^ n := fun n =>
calc
dist (g ⟨x, I⟩) y ≤ dist (g ⟨x, I⟩) (u (x n)) + dist y (u (x n)) :=
dist_triangle_right _ _ _
_ ≤ (1 / 2) ^ n + (1 / 2) ^ n := add_le_add (A ⟨x, I⟩ n) (hx n)
have L : Tendsto (fun n : ℕ => (1 / 2 : ℝ) ^ n + (1 / 2) ^ n) atTop (𝓝 (0 + 0)) :=
(tendsto_pow_atTop_nhds_zero_of_lt_one I0.le I1).add
(tendsto_pow_atTop_nhds_zero_of_lt_one I0.le I1)
rw [add_zero] at L
exact ge_of_tendsto' L J
have s_closed : IsClosed s := by
refine isClosed_iff_clusterPt.mpr fun x hx ↦ ?_
have L : Tendsto (fun n : ℕ => diam (closedBall (u (x n)) ((1 / 2) ^ n))) atTop (𝓝 0) := by
have : Tendsto (fun n : ℕ => (2 : ℝ) * (1 / 2) ^ n) atTop (𝓝 (2 * 0)) :=
(tendsto_pow_atTop_nhds_zero_of_lt_one I0.le I1).const_mul _
rw [mul_zero] at this
exact
squeeze_zero (fun n => diam_nonneg) (fun n => diam_closedBall (pow_nonneg I0.le _)) this
refine nonempty_iInter_of_nonempty_biInter (fun n => isClosed_ball)
(fun n => isBounded_closedBall) (fun N ↦ ?_) L
obtain ⟨y, hxy, ys⟩ : ∃ y, y ∈ ball x ((1 / 2) ^ N) ∩ s :=
clusterPt_principal_iff.1 hx _ (ball_mem_nhds x (pow_pos I0 N))
have E :
⋂ (n : ℕ) (H : n ≤ N), closedBall (u (x n)) ((1 / 2) ^ n) =
⋂ (n : ℕ) (H : n ≤ N), closedBall (u (y n)) ((1 / 2) ^ n) := by
refine iInter_congr fun n ↦ iInter_congr fun hn ↦ ?_
have : x n = y n := apply_eq_of_dist_lt (mem_ball'.1 hxy) hn
rw [this]
rw [E]
apply Nonempty.mono _ ys
apply iInter_subset_iInter₂
obtain ⟨f, -, f_surj, f_cont⟩ :
∃ f : (ℕ → ℕ) → s, (∀ x : s, f x = x) ∧ Surjective f ∧ Continuous f := by
apply exists_retraction_subtype_of_isClosed s_closed
simpa only [nonempty_coe_sort] using g_surj.nonempty
exact ⟨g ∘ f, g_cont.comp f_cont, g_surj.comp f_surj⟩
namespace PiCountable
/-!
### Products of (possibly non-discrete) metric spaces
-/
variable {ι : Type*} [Encodable ι] {F : ι → Type*} [∀ i, MetricSpace (F i)]
open Encodable
/-- Given a countable family of metric spaces, one may put a distance on their product `Π i, E i`.
It is highly non-canonical, though, and therefore not registered as a global instance.
The distance we use here is `dist x y = ∑' i, min (1/2)^(encode i) (dist (x i) (y i))`. -/
protected def dist : Dist (∀ i, F i) :=
⟨fun x y => ∑' i : ι, min ((1 / 2) ^ encode i) (dist (x i) (y i))⟩
attribute [local instance] PiCountable.dist
theorem dist_eq_tsum (x y : ∀ i, F i) :
dist x y = ∑' i : ι, min ((1 / 2) ^ encode i : ℝ) (dist (x i) (y i)) :=
rfl
theorem dist_summable (x y : ∀ i, F i) :
Summable fun i : ι => min ((1 / 2) ^ encode i : ℝ) (dist (x i) (y i)) := by
refine .of_nonneg_of_le (fun i => ?_) (fun i => min_le_left _ _)
summable_geometric_two_encode
exact le_min (pow_nonneg (by norm_num) _) dist_nonneg
theorem min_dist_le_dist_pi (x y : ∀ i, F i) (i : ι) :
min ((1 / 2) ^ encode i : ℝ) (dist (x i) (y i)) ≤ dist x y :=
le_tsum (dist_summable x y) i fun j _ => le_min (by simp) dist_nonneg
theorem dist_le_dist_pi_of_dist_lt {x y : ∀ i, F i} {i : ι} (h : dist x y < (1 / 2) ^ encode i) :
dist (x i) (y i) ≤ dist x y := by
simpa only [not_le.2 h, false_or_iff] using min_le_iff.1 (min_dist_le_dist_pi x y i)
open Topology Filter NNReal
variable (E)
/-- Given a countable family of metric spaces, one may put a distance on their product `Π i, E i`,
defining the right topology and uniform structure. It is highly non-canonical, though, and therefore
not registered as a global instance.
The distance we use here is `dist x y = ∑' n, min (1/2)^(encode i) (dist (x n) (y n))`. -/
protected def metricSpace : MetricSpace (∀ i, F i) where
dist_self x := by simp [dist_eq_tsum]
dist_comm x y := by simp [dist_eq_tsum, dist_comm]
dist_triangle x y z :=
have I : ∀ i, min ((1 / 2) ^ encode i : ℝ) (dist (x i) (z i)) ≤
min ((1 / 2) ^ encode i : ℝ) (dist (x i) (y i)) +
min ((1 / 2) ^ encode i : ℝ) (dist (y i) (z i)) := fun i =>
calc
min ((1 / 2) ^ encode i : ℝ) (dist (x i) (z i)) ≤
min ((1 / 2) ^ encode i : ℝ) (dist (x i) (y i) + dist (y i) (z i)) :=
min_le_min le_rfl (dist_triangle _ _ _)
_ = min ((1 / 2) ^ encode i : ℝ) (min ((1 / 2) ^ encode i : ℝ) (dist (x i) (y i)) +
min ((1 / 2) ^ encode i : ℝ) (dist (y i) (z i))) := by
convert congr_arg ((↑) : ℝ≥0 → ℝ)
(min_add_distrib ((1 / 2 : ℝ≥0) ^ encode i) (nndist (x i) (y i))
(nndist (y i) (z i)))
_ ≤ min ((1 / 2) ^ encode i : ℝ) (dist (x i) (y i)) +
min ((1 / 2) ^ encode i : ℝ) (dist (y i) (z i)) :=
min_le_right _ _
calc dist x z ≤ ∑' i, (min ((1 / 2) ^ encode i : ℝ) (dist (x i) (y i)) +
min ((1 / 2) ^ encode i : ℝ) (dist (y i) (z i))) :=
tsum_le_tsum I (dist_summable x z) ((dist_summable x y).add (dist_summable y z))
_ = dist x y + dist y z := tsum_add (dist_summable x y) (dist_summable y z)
eq_of_dist_eq_zero hxy := by
ext1 n
rw [← dist_le_zero, ← hxy]
apply dist_le_dist_pi_of_dist_lt
rw [hxy]
simp
toUniformSpace := Pi.uniformSpace _
uniformity_dist := by
simp only [Pi.uniformity, comap_iInf, gt_iff_lt, preimage_setOf_eq, comap_principal,
PseudoMetricSpace.uniformity_dist]
apply le_antisymm
· simp only [le_iInf_iff, le_principal_iff]
intro ε εpos
obtain ⟨K, hK⟩ :
∃ K : Finset ι, (∑' i : { j // j ∉ K }, (1 / 2 : ℝ) ^ encode (i : ι)) < ε / 2 :=
((tendsto_order.1 (tendsto_tsum_compl_atTop_zero fun i : ι => (1 / 2 : ℝ) ^ encode i)).2 _
(half_pos εpos)).exists
obtain ⟨δ, δpos, hδ⟩ : ∃ δ : ℝ, 0 < δ ∧ (K.card : ℝ) * δ < ε / 2 :=
exists_pos_mul_lt (half_pos εpos) _
apply @mem_iInf_of_iInter _ _ _ _ _ K.finite_toSet fun i =>
{ p : (∀ i : ι, F i) × ∀ i : ι, F i | dist (p.fst i) (p.snd i) < δ }
· rintro ⟨i, hi⟩
refine mem_iInf_of_mem δ (mem_iInf_of_mem δpos ?_)
simp only [Prod.forall, imp_self, mem_principal, Subset.rfl]
· rintro ⟨x, y⟩ hxy
simp only [mem_iInter, mem_setOf_eq, SetCoe.forall, Finset.mem_range, Finset.mem_coe] at hxy
calc
dist x y = ∑' i : ι, min ((1 / 2) ^ encode i : ℝ) (dist (x i) (y i)) := rfl
_ = (∑ i ∈ K, min ((1 / 2) ^ encode i : ℝ) (dist (x i) (y i))) +
∑' i : ↑(K : Set ι)ᶜ, min ((1 / 2) ^ encode (i : ι) : ℝ) (dist (x i) (y i)) :=
(sum_add_tsum_compl (dist_summable _ _)).symm
_ ≤ (∑ i ∈ K, dist (x i) (y i)) +
∑' i : ↑(K : Set ι)ᶜ, ((1 / 2) ^ encode (i : ι) : ℝ) := by
refine add_le_add (Finset.sum_le_sum fun i _ => min_le_right _ _) ?_
refine tsum_le_tsum (fun i => min_le_left _ _) ?_ ?_
· apply Summable.subtype (dist_summable x y) (↑K : Set ι)ᶜ
· apply Summable.subtype summable_geometric_two_encode (↑K : Set ι)ᶜ
_ < (∑ _i ∈ K, δ) + ε / 2 := by
apply add_lt_add_of_le_of_lt _ hK
refine Finset.sum_le_sum fun i hi => (hxy i ?_).le
simpa using hi
_ ≤ ε / 2 + ε / 2 :=
(add_le_add_right (by simpa only [Finset.sum_const, nsmul_eq_mul] using hδ.le) _)
_ = ε := add_halves _
· simp only [le_iInf_iff, le_principal_iff]
intro i ε εpos
refine mem_iInf_of_mem (min ((1 / 2) ^ encode i : ℝ) ε) ?_
have : 0 < min ((1 / 2) ^ encode i : ℝ) ε := lt_min (by simp) εpos
refine mem_iInf_of_mem this ?_
simp only [and_imp, Prod.forall, setOf_subset_setOf, lt_min_iff, mem_principal]
intro x y hn hε
calc
dist (x i) (y i) ≤ dist x y := dist_le_dist_pi_of_dist_lt hn
_ < ε := hε
end PiCountable
|
Topology\MetricSpace\Polish.lean | /-
Copyright (c) 2022 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.MetricSpace.PiNat
import Mathlib.Topology.MetricSpace.Isometry
import Mathlib.Topology.MetricSpace.Gluing
import Mathlib.Topology.Sets.Opens
import Mathlib.Analysis.Normed.Field.Basic
/-!
# Polish spaces
A topological space is Polish if its topology is second-countable and there exists a compatible
complete metric. This is the class of spaces that is well-behaved with respect to measure theory.
In this file, we establish the basic properties of Polish spaces.
## Main definitions and results
* `PolishSpace α` is a mixin typeclass on a topological space, requiring that the topology is
second-countable and compatible with a complete metric. To endow the space with such a metric,
use in a proof `letI := upgradePolishSpace α`.
We register an instance from complete second-countable metric spaces to Polish spaces, not the
other way around.
* We register that countable products and sums of Polish spaces are Polish.
* `IsClosed.polishSpace`: a closed subset of a Polish space is Polish.
* `IsOpen.polishSpace`: an open subset of a Polish space is Polish.
* `exists_nat_nat_continuous_surjective`: any nonempty Polish space is the continuous image
of the fundamental Polish space `ℕ → ℕ`.
A fundamental property of Polish spaces is that one can put finer topologies, still Polish,
with additional properties:
* `exists_polishSpace_forall_le`: on a topological space, consider countably many topologies
`t n`, all Polish and finer than the original topology. Then there exists another Polish
topology which is finer than all the `t n`.
* `IsClopenable s` is a property of a subset `s` of a topological space, requiring that there
exists a finer topology, which is Polish, for which `s` becomes open and closed. We show that
this property is satisfied for open sets, closed sets, for complements, and for countable unions.
Once Borel-measurable sets are defined in later files, it will follow that any Borel-measurable
set is clopenable. Once the Lusin-Souslin theorem is proved using analytic sets, we will even
show that a set is clopenable if and only if it is Borel-measurable, see
`isClopenable_iff_measurableSet`.
-/
noncomputable section
open scoped Topology Uniformity
open Filter TopologicalSpace Set Metric Function
variable {α : Type*} {β : Type*}
/-! ### Basic properties of Polish spaces -/
/-- A Polish space is a topological space with second countable topology, that can be endowed
with a metric for which it is complete.
We register an instance from complete second countable metric space to polish space, and not the
other way around as this is the most common use case.
To endow a Polish space with a complete metric space structure, do `letI := upgradePolishSpace α`.
-/
class PolishSpace (α : Type*) [h : TopologicalSpace α]
extends SecondCountableTopology α : Prop where
complete : ∃ m : MetricSpace α, m.toUniformSpace.toTopologicalSpace = h ∧
@CompleteSpace α m.toUniformSpace
/-- A convenience class, for a Polish space endowed with a complete metric. No instance of this
class should be registered: It should be used as `letI := upgradePolishSpace α` to endow a Polish
space with a complete metric. -/
class UpgradedPolishSpace (α : Type*) extends MetricSpace α, SecondCountableTopology α,
CompleteSpace α
instance (priority := 100) PolishSpace.of_separableSpace_completeSpace_metrizable [UniformSpace α]
[SeparableSpace α] [CompleteSpace α] [(𝓤 α).IsCountablyGenerated] [T0Space α] :
PolishSpace α where
toSecondCountableTopology := UniformSpace.secondCountable_of_separable α
complete := ⟨UniformSpace.metricSpace α, rfl, ‹_›⟩
/-- Construct on a Polish space a metric (compatible with the topology) which is complete. -/
def polishSpaceMetric (α : Type*) [TopologicalSpace α] [h : PolishSpace α] : MetricSpace α :=
h.complete.choose.replaceTopology h.complete.choose_spec.1.symm
theorem complete_polishSpaceMetric (α : Type*) [ht : TopologicalSpace α] [h : PolishSpace α] :
@CompleteSpace α (polishSpaceMetric α).toUniformSpace := by
convert h.complete.choose_spec.2
exact MetricSpace.replaceTopology_eq _ _
/-- This definition endows a Polish space with a complete metric. Use it as:
`letI := upgradePolishSpace α`. -/
def upgradePolishSpace (α : Type*) [TopologicalSpace α] [PolishSpace α] :
UpgradedPolishSpace α :=
letI := polishSpaceMetric α
{ complete_polishSpaceMetric α with }
namespace PolishSpace
instance (priority := 100) instMetrizableSpace (α : Type*) [TopologicalSpace α] [PolishSpace α] :
MetrizableSpace α := by
letI := upgradePolishSpace α
infer_instance
@[deprecated (since := "2024-02-23")]
theorem t2Space (α : Type*) [TopologicalSpace α] [PolishSpace α] : T2Space α := inferInstance
/-- A countable product of Polish spaces is Polish. -/
instance pi_countable {ι : Type*} [Countable ι] {E : ι → Type*} [∀ i, TopologicalSpace (E i)]
[∀ i, PolishSpace (E i)] : PolishSpace (∀ i, E i) := by
letI := fun i => upgradePolishSpace (E i)
infer_instance
/-- A countable disjoint union of Polish spaces is Polish. -/
instance sigma {ι : Type*} [Countable ι] {E : ι → Type*} [∀ n, TopologicalSpace (E n)]
[∀ n, PolishSpace (E n)] : PolishSpace (Σn, E n) :=
letI := fun n => upgradePolishSpace (E n)
letI : MetricSpace (Σn, E n) := Sigma.metricSpace
haveI : CompleteSpace (Σn, E n) := Sigma.completeSpace
inferInstance
/-- The product of two Polish spaces is Polish. -/
instance prod [TopologicalSpace α] [PolishSpace α] [TopologicalSpace β] [PolishSpace β] :
PolishSpace (α × β) :=
letI := upgradePolishSpace α
letI := upgradePolishSpace β
inferInstance
/-- The disjoint union of two Polish spaces is Polish. -/
instance sum [TopologicalSpace α] [PolishSpace α] [TopologicalSpace β] [PolishSpace β] :
PolishSpace (α ⊕ β) :=
letI := upgradePolishSpace α
letI := upgradePolishSpace β
inferInstance
/-- Any nonempty Polish space is the continuous image of the fundamental space `ℕ → ℕ`. -/
theorem exists_nat_nat_continuous_surjective (α : Type*) [TopologicalSpace α] [PolishSpace α]
[Nonempty α] : ∃ f : (ℕ → ℕ) → α, Continuous f ∧ Surjective f :=
letI := upgradePolishSpace α
exists_nat_nat_continuous_surjective_of_completeSpace α
/-- Given a closed embedding into a Polish space, the source space is also Polish. -/
theorem _root_.ClosedEmbedding.polishSpace [TopologicalSpace α] [TopologicalSpace β] [PolishSpace β]
{f : α → β} (hf : ClosedEmbedding f) : PolishSpace α := by
letI := upgradePolishSpace β
letI : MetricSpace α := hf.toEmbedding.comapMetricSpace f
haveI : SecondCountableTopology α := hf.toEmbedding.secondCountableTopology
have : CompleteSpace α := by
rw [completeSpace_iff_isComplete_range hf.toEmbedding.to_isometry.uniformInducing]
exact hf.isClosed_range.isComplete
infer_instance
/-- Any countable discrete space is Polish. -/
instance (priority := 50) polish_of_countable [TopologicalSpace α]
[h : Countable α] [DiscreteTopology α] : PolishSpace α := by
obtain ⟨f, hf⟩ := h.exists_injective_nat
have : ClosedEmbedding f := by
apply closedEmbedding_of_continuous_injective_closed continuous_of_discreteTopology hf
exact fun t _ => isClosed_discrete _
exact this.polishSpace
/-- Pulling back a Polish topology under an equiv gives again a Polish topology. -/
theorem _root_.Equiv.polishSpace_induced [t : TopologicalSpace β] [PolishSpace β] (f : α ≃ β) :
@PolishSpace α (t.induced f) :=
letI : TopologicalSpace α := t.induced f
(f.toHomeomorphOfInducing ⟨rfl⟩).closedEmbedding.polishSpace
/-- A closed subset of a Polish space is also Polish. -/
theorem _root_.IsClosed.polishSpace [TopologicalSpace α] [PolishSpace α] {s : Set α}
(hs : IsClosed s) : PolishSpace s :=
(IsClosed.closedEmbedding_subtype_val hs).polishSpace
instance instPolishSpaceUniv [TopologicalSpace α] [PolishSpace α] :
PolishSpace (univ : Set α) :=
isClosed_univ.polishSpace
protected theorem _root_.CompletePseudometrizable.iInf {ι : Type*} [Countable ι]
{t : ι → TopologicalSpace α} (ht₀ : ∃ t₀, @T2Space α t₀ ∧ ∀ i, t i ≤ t₀)
(ht : ∀ i, ∃ u : UniformSpace α, CompleteSpace α ∧ 𝓤[u].IsCountablyGenerated ∧
u.toTopologicalSpace = t i) :
∃ u : UniformSpace α, CompleteSpace α ∧
𝓤[u].IsCountablyGenerated ∧ u.toTopologicalSpace = ⨅ i, t i := by
choose u hcomp hcount hut using ht
obtain rfl : t = fun i ↦ (u i).toTopologicalSpace := (funext hut).symm
refine ⟨⨅ i, u i, .iInf hcomp ht₀, ?_, UniformSpace.toTopologicalSpace_iInf⟩
rw [iInf_uniformity]
infer_instance
protected theorem iInf {ι : Type*} [Countable ι] {t : ι → TopologicalSpace α}
(ht₀ : ∃ i₀, ∀ i, t i ≤ t i₀) (ht : ∀ i, @PolishSpace α (t i)) : @PolishSpace α (⨅ i, t i) := by
rcases ht₀ with ⟨i₀, hi₀⟩
rcases CompletePseudometrizable.iInf ⟨t i₀, letI := t i₀; haveI := ht i₀; inferInstance, hi₀⟩
fun i ↦
letI := t i; haveI := ht i; letI := upgradePolishSpace α
⟨inferInstance, inferInstance, inferInstance, rfl⟩
with ⟨u, hcomp, hcount, htop⟩
rw [← htop]
have : @SecondCountableTopology α u.toTopologicalSpace :=
htop.symm ▸ secondCountableTopology_iInf fun i ↦ letI := t i; (ht i).toSecondCountableTopology
have : @T1Space α u.toTopologicalSpace :=
htop.symm ▸ t1Space_antitone (iInf_le _ i₀) (by letI := t i₀; haveI := ht i₀; infer_instance)
infer_instance
/-- Given a Polish space, and countably many finer Polish topologies, there exists another Polish
topology which is finer than all of them. -/
theorem exists_polishSpace_forall_le {ι : Type*} [Countable ι] [t : TopologicalSpace α]
[p : PolishSpace α] (m : ι → TopologicalSpace α) (hm : ∀ n, m n ≤ t)
(h'm : ∀ n, @PolishSpace α (m n)) :
∃ t' : TopologicalSpace α, (∀ n, t' ≤ m n) ∧ t' ≤ t ∧ @PolishSpace α t' :=
⟨⨅ i : Option ι, i.elim t m, fun i ↦ iInf_le _ (some i), iInf_le _ none,
.iInf ⟨none, Option.forall.2 ⟨le_rfl, hm⟩⟩ <| Option.forall.2 ⟨p, h'm⟩⟩
instance : PolishSpace ENNReal :=
ClosedEmbedding.polishSpace ⟨ENNReal.orderIsoUnitIntervalBirational.toHomeomorph.embedding,
ENNReal.orderIsoUnitIntervalBirational.range_eq ▸ isClosed_univ⟩
end PolishSpace
/-!
### An open subset of a Polish space is Polish
To prove this fact, one needs to construct another metric, giving rise to the same topology,
for which the open subset is complete. This is not obvious, as for instance `(0,1) ⊆ ℝ` is not
complete for the usual metric of `ℝ`: one should build a new metric that blows up close to the
boundary.
Porting note: definitions and lemmas in this section now take `(s : Opens α)` instead of
`{s : Set α} (hs : IsOpen s)` so that we can turn various definitions and lemmas into instances.
Also, some lemmas used to assume `Set.Nonempty sᶜ` in Lean 3. In fact, this assumption is not
needed, so it was dropped.
-/
namespace TopologicalSpace.Opens
variable [MetricSpace α] {s : Opens α}
/-- A type synonym for a subset `s` of a metric space, on which we will construct another metric
for which it will be complete. -/
-- Porting note(#5171): was @[nolint has_nonempty_instance]
def CompleteCopy {α : Type*} [MetricSpace α] (s : Opens α) : Type _ := s
namespace CompleteCopy
/-- A distance on an open subset `s` of a metric space, designed to make it complete. It is given
by `dist' x y = dist x y + |1 / dist x sᶜ - 1 / dist y sᶜ|`, where the second term blows up close to
the boundary to ensure that Cauchy sequences for `dist'` remain well inside `s`. -/
-- Porting note: in mathlib3 this was only a local instance.
instance instDist : Dist (CompleteCopy s) where
dist x y := dist x.1 y.1 + abs (1 / infDist x.1 sᶜ - 1 / infDist y.1 sᶜ)
theorem dist_eq (x y : CompleteCopy s) :
dist x y = dist x.1 y.1 + abs (1 / infDist x.1 sᶜ - 1 / infDist y.1 sᶜ) :=
rfl
theorem dist_val_le_dist (x y : CompleteCopy s) : dist x.1 y.1 ≤ dist x y :=
le_add_of_nonneg_right (abs_nonneg _)
instance : TopologicalSpace (CompleteCopy s) := inferInstanceAs (TopologicalSpace s)
instance : T0Space (CompleteCopy s) := inferInstanceAs (T0Space s)
/-- A metric space structure on a subset `s` of a metric space, designed to make it complete
if `s` is open. It is given by `dist' x y = dist x y + |1 / dist x sᶜ - 1 / dist y sᶜ|`, where the
second term blows up close to the boundary to ensure that Cauchy sequences for `dist'` remain well
inside `s`.
Porting note: the definition changed to ensure that the `TopologicalSpace` structure on
`TopologicalSpace.Opens.CompleteCopy s` is definitionally equal to the original one. -/
-- Porting note: in mathlib3 this was only a local instance.
instance instMetricSpace : MetricSpace (CompleteCopy s) := by
refine @MetricSpace.ofT0PseudoMetricSpace (CompleteCopy s)
(.ofDistTopology dist (fun _ ↦ ?_) (fun _ _ ↦ ?_) (fun x y z ↦ ?_) fun t ↦ ?_) _
· simp only [dist_eq, dist_self, one_div, sub_self, abs_zero, add_zero]
· simp only [dist_eq, dist_comm, abs_sub_comm]
· calc
dist x z = dist x.1 z.1 + |1 / infDist x.1 sᶜ - 1 / infDist z.1 sᶜ| := rfl
_ ≤ dist x.1 y.1 + dist y.1 z.1 + (|1 / infDist x.1 sᶜ - 1 / infDist y.1 sᶜ| +
|1 / infDist y.1 sᶜ - 1 / infDist z.1 sᶜ|) :=
add_le_add (dist_triangle _ _ _) (dist_triangle (1 / infDist _ _) _ _)
_ = dist x y + dist y z := add_add_add_comm ..
· refine ⟨fun h x hx ↦ ?_, fun h ↦ isOpen_iff_mem_nhds.2 fun x hx ↦ ?_⟩
· rcases (Metric.isOpen_iff (α := s)).1 h x hx with ⟨ε, ε0, hε⟩
exact ⟨ε, ε0, fun y hy ↦ hε <| (dist_comm _ _).trans_lt <| (dist_val_le_dist _ _).trans_lt hy⟩
· rcases h x hx with ⟨ε, ε0, hε⟩
simp only [dist_eq, one_div] at hε
have : Tendsto (fun y : s ↦ dist x.1 y.1 + |(infDist x.1 sᶜ)⁻¹ - (infDist y.1 sᶜ)⁻¹|)
(𝓝 x) (𝓝 (dist x.1 x.1 + |(infDist x.1 sᶜ)⁻¹ - (infDist x.1 sᶜ)⁻¹|)) := by
refine (tendsto_const_nhds.dist continuous_subtype_val.continuousAt).add
(tendsto_const_nhds.sub <| ?_).abs
refine (continuousAt_inv_infDist_pt ?_).comp continuous_subtype_val.continuousAt
rw [s.isOpen.isClosed_compl.closure_eq, mem_compl_iff, not_not]
exact x.2
simp only [dist_self, sub_self, abs_zero, zero_add] at this
exact mem_of_superset (this <| gt_mem_nhds ε0) hε
-- Porting note: no longer needed because the topologies are defeq
instance instCompleteSpace [CompleteSpace α] : CompleteSpace (CompleteCopy s) := by
refine Metric.complete_of_convergent_controlled_sequences ((1 / 2) ^ ·) (by simp) fun u hu ↦ ?_
have A : CauchySeq fun n => (u n).1 := by
refine cauchySeq_of_le_tendsto_0 (fun n : ℕ => (1 / 2) ^ n) (fun n m N hNn hNm => ?_) ?_
· exact (dist_val_le_dist (u n) (u m)).trans (hu N n m hNn hNm).le
· exact tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num) (by norm_num)
obtain ⟨x, xlim⟩ : ∃ x, Tendsto (fun n => (u n).1) atTop (𝓝 x) := cauchySeq_tendsto_of_complete A
by_cases xs : x ∈ s
· exact ⟨⟨x, xs⟩, tendsto_subtype_rng.2 xlim⟩
obtain ⟨C, hC⟩ : ∃ C, ∀ n, 1 / infDist (u n).1 sᶜ < C := by
refine ⟨(1 / 2) ^ 0 + 1 / infDist (u 0).1 sᶜ, fun n ↦ ?_⟩
rw [← sub_lt_iff_lt_add]
calc
_ ≤ |1 / infDist (u n).1 sᶜ - 1 / infDist (u 0).1 sᶜ| := le_abs_self _
_ = |1 / infDist (u 0).1 sᶜ - 1 / infDist (u n).1 sᶜ| := abs_sub_comm _ _
_ ≤ dist (u 0) (u n) := le_add_of_nonneg_left dist_nonneg
_ < (1 / 2) ^ 0 := hu 0 0 n le_rfl n.zero_le
have Cpos : 0 < C := lt_of_le_of_lt (div_nonneg zero_le_one infDist_nonneg) (hC 0)
have Hmem : ∀ {y}, y ∈ s ↔ 0 < infDist y sᶜ := fun {y} ↦ by
rw [← s.isOpen.isClosed_compl.not_mem_iff_infDist_pos ⟨x, xs⟩]; exact not_not.symm
have I : ∀ n, 1 / C ≤ infDist (u n).1 sᶜ := fun n ↦ by
have : 0 < infDist (u n).1 sᶜ := Hmem.1 (u n).2
rw [div_le_iff' Cpos]
exact (div_le_iff this).1 (hC n).le
have I' : 1 / C ≤ infDist x sᶜ :=
have : Tendsto (fun n => infDist (u n).1 sᶜ) atTop (𝓝 (infDist x sᶜ)) :=
((continuous_infDist_pt (sᶜ : Set α)).tendsto x).comp xlim
ge_of_tendsto' this I
exact absurd (Hmem.2 <| lt_of_lt_of_le (div_pos one_pos Cpos) I') xs
/-- An open subset of a Polish space is also Polish. -/
theorem _root_.IsOpen.polishSpace {α : Type*} [TopologicalSpace α] [PolishSpace α] {s : Set α}
(hs : IsOpen s) : PolishSpace s := by
letI := upgradePolishSpace α
lift s to Opens α using hs
have : SecondCountableTopology s.CompleteCopy := inferInstanceAs (SecondCountableTopology s)
exact inferInstanceAs (PolishSpace s.CompleteCopy)
end CompleteCopy
end TopologicalSpace.Opens
namespace PolishSpace
/-! ### Clopenable sets in Polish spaces -/
/-- A set in a topological space is clopenable if there exists a finer Polish topology for which
this set is open and closed. It turns out that this notion is equivalent to being Borel-measurable,
but this is nontrivial (see `isClopenable_iff_measurableSet`). -/
def IsClopenable [t : TopologicalSpace α] (s : Set α) : Prop :=
∃ t' : TopologicalSpace α, t' ≤ t ∧ @PolishSpace α t' ∧ IsClosed[t'] s ∧ IsOpen[t'] s
/-- Given a closed set `s` in a Polish space, one can construct a finer Polish topology for
which `s` is both open and closed. -/
theorem _root_.IsClosed.isClopenable [TopologicalSpace α] [PolishSpace α] {s : Set α}
(hs : IsClosed s) : IsClopenable s := by
/- Both sets `s` and `sᶜ` admit a Polish topology. So does their disjoint union `s ⊕ sᶜ`.
Pulling back this topology by the canonical bijection with `α` gives the desired Polish
topology in which `s` is both open and closed. -/
classical
haveI : PolishSpace s := hs.polishSpace
let t : Set α := sᶜ
haveI : PolishSpace t := hs.isOpen_compl.polishSpace
let f : s ⊕ t ≃ α := Equiv.Set.sumCompl s
have hle : TopologicalSpace.coinduced f instTopologicalSpaceSum ≤ ‹_› := by
simp only [instTopologicalSpaceSum, coinduced_sup, coinduced_compose, sup_le_iff,
← continuous_iff_coinduced_le]
exact ⟨continuous_subtype_val, continuous_subtype_val⟩
refine ⟨.coinduced f instTopologicalSpaceSum, hle, ?_, hs.mono hle, ?_⟩
· rw [← f.induced_symm]
exact f.symm.polishSpace_induced
· rw [isOpen_coinduced, isOpen_sum_iff]
simp [f, preimage_preimage]
theorem IsClopenable.compl [TopologicalSpace α] {s : Set α} (hs : IsClopenable s) :
IsClopenable sᶜ := by
rcases hs with ⟨t, t_le, t_polish, h, h'⟩
exact ⟨t, t_le, t_polish, @IsOpen.isClosed_compl α t s h', @IsClosed.isOpen_compl α t s h⟩
theorem _root_.IsOpen.isClopenable [TopologicalSpace α] [PolishSpace α] {s : Set α}
(hs : IsOpen s) : IsClopenable s := by
simpa using hs.isClosed_compl.isClopenable.compl
-- Porting note (#11215): TODO: generalize for free to `[Countable ι] {s : ι → Set α}`
theorem IsClopenable.iUnion [t : TopologicalSpace α] [PolishSpace α] {s : ℕ → Set α}
(hs : ∀ n, IsClopenable (s n)) : IsClopenable (⋃ n, s n) := by
choose m mt m_polish _ m_open using hs
obtain ⟨t', t'm, -, t'_polish⟩ :
∃ t' : TopologicalSpace α, (∀ n : ℕ, t' ≤ m n) ∧ t' ≤ t ∧ @PolishSpace α t' :=
exists_polishSpace_forall_le m mt m_polish
have A : IsOpen[t'] (⋃ n, s n) := by
apply isOpen_iUnion
intro n
apply t'm n
exact m_open n
obtain ⟨t'', t''_le, t''_polish, h1, h2⟩ : ∃ t'' : TopologicalSpace α,
t'' ≤ t' ∧ @PolishSpace α t'' ∧ IsClosed[t''] (⋃ n, s n) ∧ IsOpen[t''] (⋃ n, s n) :=
@IsOpen.isClopenable α t' t'_polish _ A
exact ⟨t'', t''_le.trans ((t'm 0).trans (mt 0)), t''_polish, h1, h2⟩
end PolishSpace
|
Topology\MetricSpace\ProperSpace.lean | /-
Copyright (c) 2018 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.MetricSpace.Pseudo.Lemmas
import Mathlib.Topology.Order.IsLUB
import Mathlib.Topology.Support
/-! ## Proper spaces
## Main definitions and results
* `ProperSpace α`: a `PseudoMetricSpace` where all closed balls are compact
* `isCompact_sphere`: any sphere in a proper space is compact.
* `proper_of_compact`: compact spaces are proper.
* `secondCountable_of_proper`: proper spaces are sigma-compact, hence second countable.
* `locally_compact_of_proper`: proper spaces are locally compact.
* `pi_properSpace`: finite products of proper spaces are proper.
-/
open Set Filter
universe u v w
variable {α : Type u} {β : Type v} {X ι : Type*}
section ProperSpace
open Metric
/-- A pseudometric space is proper if all closed balls are compact. -/
class ProperSpace (α : Type u) [PseudoMetricSpace α] : Prop where
isCompact_closedBall : ∀ x : α, ∀ r, IsCompact (closedBall x r)
export ProperSpace (isCompact_closedBall)
/-- In a proper pseudometric space, all spheres are compact. -/
theorem isCompact_sphere {α : Type*} [PseudoMetricSpace α] [ProperSpace α] (x : α) (r : ℝ) :
IsCompact (sphere x r) :=
(isCompact_closedBall x r).of_isClosed_subset isClosed_sphere sphere_subset_closedBall
/-- In a proper pseudometric space, any sphere is a `CompactSpace` when considered as a subtype. -/
instance Metric.sphere.compactSpace {α : Type*} [PseudoMetricSpace α] [ProperSpace α]
(x : α) (r : ℝ) : CompactSpace (sphere x r) :=
isCompact_iff_compactSpace.mp (isCompact_sphere _ _)
variable [PseudoMetricSpace α]
-- see Note [lower instance priority]
/-- A proper pseudo metric space is sigma compact, and therefore second countable. -/
instance (priority := 100) secondCountable_of_proper [ProperSpace α] :
SecondCountableTopology α := by
-- We already have `sigmaCompactSpace_of_locallyCompact_secondCountable`, so we don't
-- add an instance for `SigmaCompactSpace`.
suffices SigmaCompactSpace α from EMetric.secondCountable_of_sigmaCompact α
rcases em (Nonempty α) with (⟨⟨x⟩⟩ | hn)
· exact ⟨⟨fun n => closedBall x n, fun n => isCompact_closedBall _ _, iUnion_closedBall_nat _⟩⟩
· exact ⟨⟨fun _ => ∅, fun _ => isCompact_empty, iUnion_eq_univ_iff.2 fun x => (hn ⟨x⟩).elim⟩⟩
/-- If all closed balls of large enough radius are compact, then the space is proper. Especially
useful when the lower bound for the radius is 0. -/
theorem ProperSpace.of_isCompact_closedBall_of_le (R : ℝ)
(h : ∀ x : α, ∀ r, R ≤ r → IsCompact (closedBall x r)) : ProperSpace α :=
⟨fun x r => IsCompact.of_isClosed_subset (h x (max r R) (le_max_right _ _)) isClosed_ball
(closedBall_subset_closedBall <| le_max_left _ _)⟩
@[deprecated (since := "2024-01-31")]
alias properSpace_of_compact_closedBall_of_le := ProperSpace.of_isCompact_closedBall_of_le
/-- If there exists a sequence of compact closed balls with the same center
such that the radii tend to infinity, then the space is proper. -/
theorem ProperSpace.of_seq_closedBall {β : Type*} {l : Filter β} [NeBot l] {x : α} {r : β → ℝ}
(hr : Tendsto r l atTop) (hc : ∀ᶠ i in l, IsCompact (closedBall x (r i))) :
ProperSpace α where
isCompact_closedBall a r :=
let ⟨_i, hci, hir⟩ := (hc.and <| hr.eventually_ge_atTop <| r + dist a x).exists
hci.of_isClosed_subset isClosed_ball <| closedBall_subset_closedBall' hir
-- A compact pseudometric space is proper
-- see Note [lower instance priority]
instance (priority := 100) proper_of_compact [CompactSpace α] : ProperSpace α :=
⟨fun _ _ => isClosed_ball.isCompact⟩
-- see Note [lower instance priority]
/-- A proper space is locally compact -/
instance (priority := 100) locally_compact_of_proper [ProperSpace α] : LocallyCompactSpace α :=
.of_hasBasis (fun _ => nhds_basis_closedBall) fun _ _ _ =>
isCompact_closedBall _ _
-- see Note [lower instance priority]
/-- A proper space is complete -/
instance (priority := 100) complete_of_proper [ProperSpace α] : CompleteSpace α :=
⟨fun {f} hf => by
/- We want to show that the Cauchy filter `f` is converging. It suffices to find a closed
ball (therefore compact by properness) where it is nontrivial. -/
obtain ⟨t, t_fset, ht⟩ : ∃ t ∈ f, ∀ x ∈ t, ∀ y ∈ t, dist x y < 1 :=
(Metric.cauchy_iff.1 hf).2 1 zero_lt_one
rcases hf.1.nonempty_of_mem t_fset with ⟨x, xt⟩
have : closedBall x 1 ∈ f := mem_of_superset t_fset fun y yt => (ht y yt x xt).le
rcases (isCompact_iff_totallyBounded_isComplete.1 (isCompact_closedBall x 1)).2 f hf
(le_principal_iff.2 this) with
⟨y, -, hy⟩
exact ⟨y, hy⟩⟩
/-- A binary product of proper spaces is proper. -/
instance prod_properSpace {α : Type*} {β : Type*} [PseudoMetricSpace α] [PseudoMetricSpace β]
[ProperSpace α] [ProperSpace β] : ProperSpace (α × β) where
isCompact_closedBall := by
rintro ⟨x, y⟩ r
rw [← closedBall_prod_same x y]
exact (isCompact_closedBall x r).prod (isCompact_closedBall y r)
/-- A finite product of proper spaces is proper. -/
instance pi_properSpace {π : β → Type*} [Fintype β] [∀ b, PseudoMetricSpace (π b)]
[h : ∀ b, ProperSpace (π b)] : ProperSpace (∀ b, π b) := by
refine .of_isCompact_closedBall_of_le 0 fun x r hr => ?_
rw [closedBall_pi _ hr]
exact isCompact_univ_pi fun _ => isCompact_closedBall _ _
end ProperSpace
instance [PseudoMetricSpace X] [ProperSpace X] : ProperSpace (Additive X) := ‹ProperSpace X›
instance [PseudoMetricSpace X] [ProperSpace X] : ProperSpace (Multiplicative X) := ‹ProperSpace X›
instance [PseudoMetricSpace X] [ProperSpace X] : ProperSpace Xᵒᵈ := ‹ProperSpace X›
|
Topology\MetricSpace\Sequences.lean | /-
Copyright (c) 2018 Jan-David Salchow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jan-David Salchow, Patrick Massot, Yury Kudryashov
-/
import Mathlib.Topology.Sequences
import Mathlib.Topology.MetricSpace.Bounded
/-!
# Sequencial compacts in metric spaces
In this file we prove 2 versions of Bolzano-Weierstrass theorem for proper metric spaces.
-/
open Filter Bornology Metric
open scoped Topology
variable {X : Type*} [PseudoMetricSpace X]
@[deprecated lebesgue_number_lemma_of_metric (since := "2024-02-24")]
nonrec theorem SeqCompact.lebesgue_number_lemma_of_metric {ι : Sort*} {c : ι → Set X} {s : Set X}
(hs : IsSeqCompact s) (hc₁ : ∀ i, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i, c i) :
∃ δ > 0, ∀ a ∈ s, ∃ i, ball a δ ⊆ c i :=
lebesgue_number_lemma_of_metric hs.isCompact hc₁ hc₂
variable [ProperSpace X] {s : Set X}
/-- A version of **Bolzano-Weierstrass**: in a proper metric space (eg. $ℝ^n$),
every bounded sequence has a converging subsequence. This version assumes only
that the sequence is frequently in some bounded set. -/
theorem tendsto_subseq_of_frequently_bounded (hs : IsBounded s) {x : ℕ → X}
(hx : ∃ᶠ n in atTop, x n ∈ s) :
∃ a ∈ closure s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (x ∘ φ) atTop (𝓝 a) :=
have hcs : IsSeqCompact (closure s) := hs.isCompact_closure.isSeqCompact
have hu' : ∃ᶠ n in atTop, x n ∈ closure s := hx.mono fun _n hn => subset_closure hn
hcs.subseq_of_frequently_in hu'
/-- A version of **Bolzano-Weierstrass**: in a proper metric space (eg. $ℝ^n$),
every bounded sequence has a converging subsequence. -/
theorem tendsto_subseq_of_bounded (hs : IsBounded s) {x : ℕ → X} (hx : ∀ n, x n ∈ s) :
∃ a ∈ closure s, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (x ∘ φ) atTop (𝓝 a) :=
tendsto_subseq_of_frequently_bounded hs <| frequently_of_forall hx
|
Topology\MetricSpace\ShrinkingLemma.lean | /-
Copyright (c) 2021 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov
-/
import Mathlib.Topology.EMetricSpace.Paracompact
import Mathlib.Topology.MetricSpace.Basic
import Mathlib.Topology.MetricSpace.ProperSpace.Lemmas
import Mathlib.Topology.ShrinkingLemma
/-!
# Shrinking lemma in a proper metric space
In this file we prove a few versions of the shrinking lemma for coverings by balls in a proper
(pseudo) metric space.
## Tags
shrinking lemma, metric space
-/
universe u v
open Set Metric
open Topology
variable {α : Type u} {ι : Type v} [MetricSpace α] [ProperSpace α] {c : ι → α}
variable {x : α} {r : ℝ} {s : Set α}
/-- **Shrinking lemma** for coverings by open balls in a proper metric space. A point-finite open
cover of a closed subset of a proper metric space by open balls can be shrunk to a new cover by
open balls so that each of the new balls has strictly smaller radius than the old one. This version
assumes that `fun x ↦ ball (c i) (r i)` is a locally finite covering and provides a covering
indexed by the same type. -/
theorem exists_subset_iUnion_ball_radius_lt {r : ι → ℝ} (hs : IsClosed s)
(uf : ∀ x ∈ s, { i | x ∈ ball (c i) (r i) }.Finite) (us : s ⊆ ⋃ i, ball (c i) (r i)) :
∃ r' : ι → ℝ, (s ⊆ ⋃ i, ball (c i) (r' i)) ∧ ∀ i, r' i < r i := by
rcases exists_subset_iUnion_closed_subset hs (fun i => @isOpen_ball _ _ (c i) (r i)) uf us with
⟨v, hsv, hvc, hcv⟩
have := fun i => exists_lt_subset_ball (hvc i) (hcv i)
choose r' hlt hsub using this
exact ⟨r', hsv.trans <| iUnion_mono <| hsub, hlt⟩
/-- Shrinking lemma for coverings by open balls in a proper metric space. A point-finite open cover
of a proper metric space by open balls can be shrunk to a new cover by open balls so that each of
the new balls has strictly smaller radius than the old one. -/
theorem exists_iUnion_ball_eq_radius_lt {r : ι → ℝ} (uf : ∀ x, { i | x ∈ ball (c i) (r i) }.Finite)
(uU : ⋃ i, ball (c i) (r i) = univ) :
∃ r' : ι → ℝ, ⋃ i, ball (c i) (r' i) = univ ∧ ∀ i, r' i < r i :=
let ⟨r', hU, hv⟩ := exists_subset_iUnion_ball_radius_lt isClosed_univ (fun x _ => uf x) uU.ge
⟨r', univ_subset_iff.1 hU, hv⟩
/-- Shrinking lemma for coverings by open balls in a proper metric space. A point-finite open cover
of a closed subset of a proper metric space by nonempty open balls can be shrunk to a new cover by
nonempty open balls so that each of the new balls has strictly smaller radius than the old one. -/
theorem exists_subset_iUnion_ball_radius_pos_lt {r : ι → ℝ} (hr : ∀ i, 0 < r i) (hs : IsClosed s)
(uf : ∀ x ∈ s, { i | x ∈ ball (c i) (r i) }.Finite) (us : s ⊆ ⋃ i, ball (c i) (r i)) :
∃ r' : ι → ℝ, (s ⊆ ⋃ i, ball (c i) (r' i)) ∧ ∀ i, r' i ∈ Ioo 0 (r i) := by
rcases exists_subset_iUnion_closed_subset hs (fun i => @isOpen_ball _ _ (c i) (r i)) uf us with
⟨v, hsv, hvc, hcv⟩
have := fun i => exists_pos_lt_subset_ball (hr i) (hvc i) (hcv i)
choose r' hlt hsub using this
exact ⟨r', hsv.trans <| iUnion_mono hsub, hlt⟩
/-- Shrinking lemma for coverings by open balls in a proper metric space. A point-finite open cover
of a proper metric space by nonempty open balls can be shrunk to a new cover by nonempty open balls
so that each of the new balls has strictly smaller radius than the old one. -/
theorem exists_iUnion_ball_eq_radius_pos_lt {r : ι → ℝ} (hr : ∀ i, 0 < r i)
(uf : ∀ x, { i | x ∈ ball (c i) (r i) }.Finite) (uU : ⋃ i, ball (c i) (r i) = univ) :
∃ r' : ι → ℝ, ⋃ i, ball (c i) (r' i) = univ ∧ ∀ i, r' i ∈ Ioo 0 (r i) :=
let ⟨r', hU, hv⟩ :=
exists_subset_iUnion_ball_radius_pos_lt hr isClosed_univ (fun x _ => uf x) uU.ge
⟨r', univ_subset_iff.1 hU, hv⟩
/-- Let `R : α → ℝ` be a (possibly discontinuous) function on a proper metric space.
Let `s` be a closed set in `α` such that `R` is positive on `s`. Then there exists a collection of
pairs of balls `Metric.ball (c i) (r i)`, `Metric.ball (c i) (r' i)` such that
* all centers belong to `s`;
* for all `i` we have `0 < r i < r' i < R (c i)`;
* the family of balls `Metric.ball (c i) (r' i)` is locally finite;
* the balls `Metric.ball (c i) (r i)` cover `s`.
This is a simple corollary of `refinement_of_locallyCompact_sigmaCompact_of_nhds_basis_set`
and `exists_subset_iUnion_ball_radius_pos_lt`. -/
theorem exists_locallyFinite_subset_iUnion_ball_radius_lt (hs : IsClosed s) {R : α → ℝ}
(hR : ∀ x ∈ s, 0 < R x) :
∃ (ι : Type u) (c : ι → α) (r r' : ι → ℝ),
(∀ i, c i ∈ s ∧ 0 < r i ∧ r i < r' i ∧ r' i < R (c i)) ∧
(LocallyFinite fun i => ball (c i) (r' i)) ∧ s ⊆ ⋃ i, ball (c i) (r i) := by
have : ∀ x ∈ s, (𝓝 x).HasBasis (fun r : ℝ => 0 < r ∧ r < R x) fun r => ball x r := fun x hx =>
nhds_basis_uniformity (uniformity_basis_dist_lt (hR x hx))
rcases refinement_of_locallyCompact_sigmaCompact_of_nhds_basis_set hs this with
⟨ι, c, r', hr', hsub', hfin⟩
rcases exists_subset_iUnion_ball_radius_pos_lt (fun i => (hr' i).2.1) hs
(fun x _ => hfin.point_finite x) hsub' with
⟨r, hsub, hlt⟩
exact ⟨ι, c, r, r', fun i => ⟨(hr' i).1, (hlt i).1, (hlt i).2, (hr' i).2.2⟩, hfin, hsub⟩
/-- Let `R : α → ℝ` be a (possibly discontinuous) positive function on a proper metric space. Then
there exists a collection of pairs of balls `Metric.ball (c i) (r i)`, `Metric.ball (c i) (r' i)`
such that
* for all `i` we have `0 < r i < r' i < R (c i)`;
* the family of balls `Metric.ball (c i) (r' i)` is locally finite;
* the balls `Metric.ball (c i) (r i)` cover the whole space.
This is a simple corollary of `refinement_of_locallyCompact_sigmaCompact_of_nhds_basis`
and `exists_iUnion_ball_eq_radius_pos_lt` or `exists_locallyFinite_subset_iUnion_ball_radius_lt`. -/
theorem exists_locallyFinite_iUnion_eq_ball_radius_lt {R : α → ℝ} (hR : ∀ x, 0 < R x) :
∃ (ι : Type u) (c : ι → α) (r r' : ι → ℝ),
(∀ i, 0 < r i ∧ r i < r' i ∧ r' i < R (c i)) ∧
(LocallyFinite fun i => ball (c i) (r' i)) ∧ ⋃ i, ball (c i) (r i) = univ :=
let ⟨ι, c, r, r', hlt, hfin, hsub⟩ :=
exists_locallyFinite_subset_iUnion_ball_radius_lt isClosed_univ fun x _ => hR x
⟨ι, c, r, r', fun i => (hlt i).2, hfin, univ_subset_iff.1 hsub⟩
|
Topology\MetricSpace\ThickenedIndicator.lean | /-
Copyright (c) 2022 Kalle Kytölä. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kalle Kytölä
-/
import Mathlib.Data.ENNReal.Basic
import Mathlib.Topology.ContinuousFunction.Bounded
import Mathlib.Topology.MetricSpace.Thickening
/-!
# Thickened indicators
This file is about thickened indicators of sets in (pseudo e)metric spaces. For a decreasing
sequence of thickening radii tending to 0, the thickened indicators of a closed set form a
decreasing pointwise converging approximation of the indicator function of the set, where the
members of the approximating sequence are nonnegative bounded continuous functions.
## Main definitions
* `thickenedIndicatorAux δ E`: The `δ`-thickened indicator of a set `E` as an
unbundled `ℝ≥0∞`-valued function.
* `thickenedIndicator δ E`: The `δ`-thickened indicator of a set `E` as a bundled
bounded continuous `ℝ≥0`-valued function.
## Main results
* For a sequence of thickening radii tending to 0, the `δ`-thickened indicators of a set `E` tend
pointwise to the indicator of `closure E`.
- `thickenedIndicatorAux_tendsto_indicator_closure`: The version is for the
unbundled `ℝ≥0∞`-valued functions.
- `thickenedIndicator_tendsto_indicator_closure`: The version is for the bundled `ℝ≥0`-valued
bounded continuous functions.
-/
open scoped Classical
open NNReal ENNReal Topology BoundedContinuousFunction
open NNReal ENNReal Set Metric EMetric Filter
noncomputable section thickenedIndicator
variable {α : Type*} [PseudoEMetricSpace α]
/-- The `δ`-thickened indicator of a set `E` is the function that equals `1` on `E`
and `0` outside a `δ`-thickening of `E` and interpolates (continuously) between
these values using `infEdist _ E`.
`thickenedIndicatorAux` is the unbundled `ℝ≥0∞`-valued function. See `thickenedIndicator`
for the (bundled) bounded continuous function with `ℝ≥0`-values. -/
def thickenedIndicatorAux (δ : ℝ) (E : Set α) : α → ℝ≥0∞ :=
fun x : α => (1 : ℝ≥0∞) - infEdist x E / ENNReal.ofReal δ
theorem continuous_thickenedIndicatorAux {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) :
Continuous (thickenedIndicatorAux δ E) := by
unfold thickenedIndicatorAux
let f := fun x : α => (⟨1, infEdist x E / ENNReal.ofReal δ⟩ : ℝ≥0 × ℝ≥0∞)
let sub := fun p : ℝ≥0 × ℝ≥0∞ => (p.1 : ℝ≥0∞) - p.2
rw [show (fun x : α => (1 : ℝ≥0∞) - infEdist x E / ENNReal.ofReal δ) = sub ∘ f by rfl]
apply (@ENNReal.continuous_nnreal_sub 1).comp
apply (ENNReal.continuous_div_const (ENNReal.ofReal δ) _).comp continuous_infEdist
norm_num [δ_pos]
theorem thickenedIndicatorAux_le_one (δ : ℝ) (E : Set α) (x : α) :
thickenedIndicatorAux δ E x ≤ 1 := by
apply @tsub_le_self _ _ _ _ (1 : ℝ≥0∞)
theorem thickenedIndicatorAux_lt_top {δ : ℝ} {E : Set α} {x : α} :
thickenedIndicatorAux δ E x < ∞ :=
lt_of_le_of_lt (thickenedIndicatorAux_le_one _ _ _) one_lt_top
theorem thickenedIndicatorAux_closure_eq (δ : ℝ) (E : Set α) :
thickenedIndicatorAux δ (closure E) = thickenedIndicatorAux δ E := by
simp (config := { unfoldPartialApp := true }) only [thickenedIndicatorAux, infEdist_closure]
theorem thickenedIndicatorAux_one (δ : ℝ) (E : Set α) {x : α} (x_in_E : x ∈ E) :
thickenedIndicatorAux δ E x = 1 := by
simp [thickenedIndicatorAux, infEdist_zero_of_mem x_in_E, tsub_zero]
theorem thickenedIndicatorAux_one_of_mem_closure (δ : ℝ) (E : Set α) {x : α}
(x_mem : x ∈ closure E) : thickenedIndicatorAux δ E x = 1 := by
rw [← thickenedIndicatorAux_closure_eq, thickenedIndicatorAux_one δ (closure E) x_mem]
theorem thickenedIndicatorAux_zero {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) {x : α}
(x_out : x ∉ thickening δ E) : thickenedIndicatorAux δ E x = 0 := by
rw [thickening, mem_setOf_eq, not_lt] at x_out
unfold thickenedIndicatorAux
apply le_antisymm _ bot_le
have key := tsub_le_tsub
(@rfl _ (1 : ℝ≥0∞)).le (ENNReal.div_le_div x_out (@rfl _ (ENNReal.ofReal δ : ℝ≥0∞)).le)
rw [ENNReal.div_self (ne_of_gt (ENNReal.ofReal_pos.mpr δ_pos)) ofReal_ne_top] at key
simpa using key
theorem thickenedIndicatorAux_mono {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : Set α) :
thickenedIndicatorAux δ₁ E ≤ thickenedIndicatorAux δ₂ E :=
fun _ => tsub_le_tsub (@rfl ℝ≥0∞ 1).le (ENNReal.div_le_div rfl.le (ofReal_le_ofReal hle))
theorem indicator_le_thickenedIndicatorAux (δ : ℝ) (E : Set α) :
(E.indicator fun _ => (1 : ℝ≥0∞)) ≤ thickenedIndicatorAux δ E := by
intro a
by_cases h : a ∈ E
· simp only [h, indicator_of_mem, thickenedIndicatorAux_one δ E h, le_refl]
· simp only [h, indicator_of_not_mem, not_false_iff, zero_le]
theorem thickenedIndicatorAux_subset (δ : ℝ) {E₁ E₂ : Set α} (subset : E₁ ⊆ E₂) :
thickenedIndicatorAux δ E₁ ≤ thickenedIndicatorAux δ E₂ :=
fun _ => tsub_le_tsub (@rfl ℝ≥0∞ 1).le (ENNReal.div_le_div (infEdist_anti subset) rfl.le)
/-- As the thickening radius δ tends to 0, the δ-thickened indicator of a set E (in α) tends
pointwise (i.e., w.r.t. the product topology on `α → ℝ≥0∞`) to the indicator function of the
closure of E.
This statement is for the unbundled `ℝ≥0∞`-valued functions `thickenedIndicatorAux δ E`, see
`thickenedIndicator_tendsto_indicator_closure` for the version for bundled `ℝ≥0`-valued
bounded continuous functions. -/
theorem thickenedIndicatorAux_tendsto_indicator_closure {δseq : ℕ → ℝ}
(δseq_lim : Tendsto δseq atTop (𝓝 0)) (E : Set α) :
Tendsto (fun n => thickenedIndicatorAux (δseq n) E) atTop
(𝓝 (indicator (closure E) fun _ => (1 : ℝ≥0∞))) := by
rw [tendsto_pi_nhds]
intro x
by_cases x_mem_closure : x ∈ closure E
· simp_rw [thickenedIndicatorAux_one_of_mem_closure _ E x_mem_closure]
rw [show (indicator (closure E) fun _ => (1 : ℝ≥0∞)) x = 1 by
simp only [x_mem_closure, indicator_of_mem]]
exact tendsto_const_nhds
· rw [show (closure E).indicator (fun _ => (1 : ℝ≥0∞)) x = 0 by
simp only [x_mem_closure, indicator_of_not_mem, not_false_iff]]
rcases exists_real_pos_lt_infEdist_of_not_mem_closure x_mem_closure with ⟨ε, ⟨ε_pos, ε_lt⟩⟩
rw [Metric.tendsto_nhds] at δseq_lim
specialize δseq_lim ε ε_pos
simp only [dist_zero_right, Real.norm_eq_abs, eventually_atTop] at δseq_lim
rcases δseq_lim with ⟨N, hN⟩
apply @tendsto_atTop_of_eventually_const _ _ _ _ _ _ _ N
intro n n_large
have key : x ∉ thickening ε E := by simpa only [thickening, mem_setOf_eq, not_lt] using ε_lt.le
refine le_antisymm ?_ bot_le
apply (thickenedIndicatorAux_mono (lt_of_abs_lt (hN n n_large)).le E x).trans
exact (thickenedIndicatorAux_zero ε_pos E key).le
/-- The `δ`-thickened indicator of a set `E` is the function that equals `1` on `E`
and `0` outside a `δ`-thickening of `E` and interpolates (continuously) between
these values using `infEdist _ E`.
`thickenedIndicator` is the (bundled) bounded continuous function with `ℝ≥0`-values.
See `thickenedIndicatorAux` for the unbundled `ℝ≥0∞`-valued function. -/
@[simps]
def thickenedIndicator {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) : α →ᵇ ℝ≥0 where
toFun := fun x : α => (thickenedIndicatorAux δ E x).toNNReal
continuous_toFun := by
apply ContinuousOn.comp_continuous continuousOn_toNNReal
(continuous_thickenedIndicatorAux δ_pos E)
intro x
exact (lt_of_le_of_lt (@thickenedIndicatorAux_le_one _ _ δ E x) one_lt_top).ne
map_bounded' := by
use 2
intro x y
rw [NNReal.dist_eq]
apply (abs_sub _ _).trans
rw [NNReal.abs_eq, NNReal.abs_eq, ← one_add_one_eq_two]
have key := @thickenedIndicatorAux_le_one _ _ δ E
apply add_le_add <;>
· norm_cast
exact (toNNReal_le_toNNReal (lt_of_le_of_lt (key _) one_lt_top).ne one_ne_top).mpr (key _)
theorem thickenedIndicator.coeFn_eq_comp {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) :
⇑(thickenedIndicator δ_pos E) = ENNReal.toNNReal ∘ thickenedIndicatorAux δ E :=
rfl
theorem thickenedIndicator_le_one {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) (x : α) :
thickenedIndicator δ_pos E x ≤ 1 := by
rw [thickenedIndicator.coeFn_eq_comp]
simpa using (toNNReal_le_toNNReal thickenedIndicatorAux_lt_top.ne one_ne_top).mpr
(thickenedIndicatorAux_le_one δ E x)
theorem thickenedIndicator_one_of_mem_closure {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) {x : α}
(x_mem : x ∈ closure E) : thickenedIndicator δ_pos E x = 1 := by
rw [thickenedIndicator_apply, thickenedIndicatorAux_one_of_mem_closure δ E x_mem, one_toNNReal]
lemma one_le_thickenedIndicator_apply' {X : Type _} [PseudoEMetricSpace X]
{δ : ℝ} (δ_pos : 0 < δ) {F : Set X} {x : X} (hxF : x ∈ closure F) :
1 ≤ thickenedIndicator δ_pos F x := by
rw [thickenedIndicator_one_of_mem_closure δ_pos F hxF]
lemma one_le_thickenedIndicator_apply (X : Type _) [PseudoEMetricSpace X]
{δ : ℝ} (δ_pos : 0 < δ) {F : Set X} {x : X} (hxF : x ∈ F) :
1 ≤ thickenedIndicator δ_pos F x :=
one_le_thickenedIndicator_apply' δ_pos (subset_closure hxF)
theorem thickenedIndicator_one {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) {x : α} (x_in_E : x ∈ E) :
thickenedIndicator δ_pos E x = 1 :=
thickenedIndicator_one_of_mem_closure _ _ (subset_closure x_in_E)
theorem thickenedIndicator_zero {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) {x : α}
(x_out : x ∉ thickening δ E) : thickenedIndicator δ_pos E x = 0 := by
rw [thickenedIndicator_apply, thickenedIndicatorAux_zero δ_pos E x_out, zero_toNNReal]
theorem indicator_le_thickenedIndicator {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) :
(E.indicator fun _ => (1 : ℝ≥0)) ≤ thickenedIndicator δ_pos E := by
intro a
by_cases h : a ∈ E
· simp only [h, indicator_of_mem, thickenedIndicator_one δ_pos E h, le_refl]
· simp only [h, indicator_of_not_mem, not_false_iff, zero_le]
theorem thickenedIndicator_mono {δ₁ δ₂ : ℝ} (δ₁_pos : 0 < δ₁) (δ₂_pos : 0 < δ₂) (hle : δ₁ ≤ δ₂)
(E : Set α) : ⇑(thickenedIndicator δ₁_pos E) ≤ thickenedIndicator δ₂_pos E := by
intro x
apply (toNNReal_le_toNNReal thickenedIndicatorAux_lt_top.ne thickenedIndicatorAux_lt_top.ne).mpr
apply thickenedIndicatorAux_mono hle
theorem thickenedIndicator_subset {δ : ℝ} (δ_pos : 0 < δ) {E₁ E₂ : Set α} (subset : E₁ ⊆ E₂) :
⇑(thickenedIndicator δ_pos E₁) ≤ thickenedIndicator δ_pos E₂ := fun x =>
(toNNReal_le_toNNReal thickenedIndicatorAux_lt_top.ne thickenedIndicatorAux_lt_top.ne).mpr
(thickenedIndicatorAux_subset δ subset x)
/-- As the thickening radius δ tends to 0, the δ-thickened indicator of a set E (in α) tends
pointwise to the indicator function of the closure of E.
Note: This version is for the bundled bounded continuous functions, but the topology is not
the topology on `α →ᵇ ℝ≥0`. Coercions to functions `α → ℝ≥0` are done first, so the topology
instance is the product topology (the topology of pointwise convergence). -/
theorem thickenedIndicator_tendsto_indicator_closure {δseq : ℕ → ℝ} (δseq_pos : ∀ n, 0 < δseq n)
(δseq_lim : Tendsto δseq atTop (𝓝 0)) (E : Set α) :
Tendsto (fun n : ℕ => ((↑) : (α →ᵇ ℝ≥0) → α → ℝ≥0) (thickenedIndicator (δseq_pos n) E)) atTop
(𝓝 (indicator (closure E) fun _ => (1 : ℝ≥0))) := by
have key := thickenedIndicatorAux_tendsto_indicator_closure δseq_lim E
rw [tendsto_pi_nhds] at *
intro x
rw [show indicator (closure E) (fun _ => (1 : ℝ≥0)) x =
(indicator (closure E) (fun _ => (1 : ℝ≥0∞)) x).toNNReal
by refine (congr_fun (comp_indicator_const 1 ENNReal.toNNReal zero_toNNReal) x).symm]
refine Tendsto.comp (tendsto_toNNReal ?_) (key x)
by_cases x_mem : x ∈ closure E <;> simp [x_mem]
end thickenedIndicator
section indicator
variable {α : Type*} [PseudoEMetricSpace α] {β : Type*} [One β]
/-- Pointwise, the multiplicative indicators of δ-thickenings of a set eventually coincide
with the multiplicative indicator of the set as δ>0 tends to zero. -/
@[to_additive "Pointwise, the indicators of δ-thickenings of a set eventually coincide
with the indicator of the set as δ>0 tends to zero."]
lemma mulIndicator_thickening_eventually_eq_mulIndicator_closure (f : α → β) (E : Set α) (x : α) :
∀ᶠ δ in 𝓝[>] (0 : ℝ),
(Metric.thickening δ E).mulIndicator f x = (closure E).mulIndicator f x := by
by_cases x_mem_closure : x ∈ closure E
· filter_upwards [self_mem_nhdsWithin] with δ δ_pos
simp only [closure_subset_thickening δ_pos E x_mem_closure, mulIndicator_of_mem, x_mem_closure]
· have obs := eventually_not_mem_thickening_of_infEdist_pos x_mem_closure
filter_upwards [mem_nhdsWithin_of_mem_nhds obs, self_mem_nhdsWithin]
with δ x_notin_thE _
simp only [x_notin_thE, not_false_eq_true, mulIndicator_of_not_mem, x_mem_closure]
/-- Pointwise, the multiplicative indicators of closed δ-thickenings of a set eventually coincide
with the multiplicative indicator of the set as δ tends to zero. -/
@[to_additive "Pointwise, the indicators of closed δ-thickenings of a set eventually coincide
with the indicator of the set as δ tends to zero."]
lemma mulIndicator_cthickening_eventually_eq_mulIndicator_closure (f : α → β) (E : Set α) (x : α) :
∀ᶠ δ in 𝓝 (0 : ℝ),
(Metric.cthickening δ E).mulIndicator f x = (closure E).mulIndicator f x := by
by_cases x_mem_closure : x ∈ closure E
· filter_upwards [univ_mem] with δ _
have obs : x ∈ cthickening δ E := closure_subset_cthickening δ E x_mem_closure
rw [mulIndicator_of_mem obs f, mulIndicator_of_mem x_mem_closure f]
· filter_upwards [eventually_not_mem_cthickening_of_infEdist_pos x_mem_closure] with δ hδ
simp only [hδ, not_false_eq_true, mulIndicator_of_not_mem, x_mem_closure]
variable [TopologicalSpace β]
/-- The multiplicative indicators of δ-thickenings of a set tend pointwise to the multiplicative
indicator of the set, as δ>0 tends to zero. -/
@[to_additive "The indicators of δ-thickenings of a set tend pointwise to the indicator of the
set, as δ>0 tends to zero."]
lemma tendsto_mulIndicator_thickening_mulIndicator_closure (f : α → β) (E : Set α) :
Tendsto (fun δ ↦ (Metric.thickening δ E).mulIndicator f) (𝓝[>] 0)
(𝓝 ((closure E).mulIndicator f)) := by
rw [tendsto_pi_nhds]
intro x
rw [tendsto_congr' (mulIndicator_thickening_eventually_eq_mulIndicator_closure f E x)]
apply tendsto_const_nhds
/-- The multiplicative indicators of closed δ-thickenings of a set tend pointwise to the
multiplicative indicator of the set, as δ tends to zero. -/
@[to_additive "The indicators of closed δ-thickenings of a set tend pointwise to the indicator
of the set, as δ tends to zero."]
lemma tendsto_mulIndicator_cthickening_mulIndicator_closure (f : α → β) (E : Set α) :
Tendsto (fun δ ↦ (Metric.cthickening δ E).mulIndicator f) (𝓝 0)
(𝓝 ((closure E).mulIndicator f)) := by
rw [tendsto_pi_nhds]
intro x
rw [tendsto_congr' (mulIndicator_cthickening_eventually_eq_mulIndicator_closure f E x)]
apply tendsto_const_nhds
end indicator
|
Topology\MetricSpace\Thickening.lean | /-
Copyright (c) 2021 Kalle Kytölä. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kalle Kytölä
-/
import Mathlib.Topology.MetricSpace.HausdorffDistance
/-!
# Thickenings in pseudo-metric spaces
## Main definitions
* `Metric.thickening δ s`, the open thickening by radius `δ` of a set `s` in a pseudo emetric space.
* `Metric.cthickening δ s`, the closed thickening by radius `δ` of a set `s` in a pseudo emetric
space.
## Main results
* `Disjoint.exists_thickenings`: two disjoint sets admit disjoint thickenings
* `Disjoint.exists_cthickenings`: two disjoint sets admit disjoint closed thickenings
* `IsCompact.exists_cthickening_subset_open`: if `s` is compact, `t` is open and `s ⊆ t`,
some `cthickening` of `s` is contained in `t`.
* `Metric.hasBasis_nhdsSet_cthickening`: the `cthickening`s of a compact set `K` form a basis
of the neighbourhoods of `K`
* `Metric.closure_eq_iInter_cthickening'`: the closure of a set equals the intersection
of its closed thickenings of positive radii accumulating at zero.
The same holds for open thickenings.
* `IsCompact.cthickening_eq_biUnion_closedBall`: if `s` is compact, `cthickening δ s` is the union
of `closedBall`s of radius `δ` around `x : E`.
-/
noncomputable section
open NNReal ENNReal Topology Set Filter Bornology
universe u v w
variable {ι : Sort*} {α : Type u} {β : Type v}
namespace Metric
section Thickening
variable [PseudoEMetricSpace α] {δ : ℝ} {s : Set α} {x : α}
open EMetric
/-- The (open) `δ`-thickening `Metric.thickening δ E` of a subset `E` in a pseudo emetric space
consists of those points that are at distance less than `δ` from some point of `E`. -/
def thickening (δ : ℝ) (E : Set α) : Set α :=
{ x : α | infEdist x E < ENNReal.ofReal δ }
theorem mem_thickening_iff_infEdist_lt : x ∈ thickening δ s ↔ infEdist x s < ENNReal.ofReal δ :=
Iff.rfl
/-- An exterior point of a subset `E` (i.e., a point outside the closure of `E`) is not in the
(open) `δ`-thickening of `E` for small enough positive `δ`. -/
lemma eventually_not_mem_thickening_of_infEdist_pos {E : Set α} {x : α} (h : x ∉ closure E) :
∀ᶠ δ in 𝓝 (0 : ℝ), x ∉ Metric.thickening δ E := by
obtain ⟨ε, ⟨ε_pos, ε_lt⟩⟩ := exists_real_pos_lt_infEdist_of_not_mem_closure h
filter_upwards [eventually_lt_nhds ε_pos] with δ hδ
simp only [thickening, mem_setOf_eq, not_lt]
exact (ENNReal.ofReal_le_ofReal hδ.le).trans ε_lt.le
/-- The (open) thickening equals the preimage of an open interval under `EMetric.infEdist`. -/
theorem thickening_eq_preimage_infEdist (δ : ℝ) (E : Set α) :
thickening δ E = (infEdist · E) ⁻¹' Iio (ENNReal.ofReal δ) :=
rfl
/-- The (open) thickening is an open set. -/
theorem isOpen_thickening {δ : ℝ} {E : Set α} : IsOpen (thickening δ E) :=
Continuous.isOpen_preimage continuous_infEdist _ isOpen_Iio
/-- The (open) thickening of the empty set is empty. -/
@[simp]
theorem thickening_empty (δ : ℝ) : thickening δ (∅ : Set α) = ∅ := by
simp only [thickening, setOf_false, infEdist_empty, not_top_lt]
theorem thickening_of_nonpos (hδ : δ ≤ 0) (s : Set α) : thickening δ s = ∅ :=
eq_empty_of_forall_not_mem fun _ => ((ENNReal.ofReal_of_nonpos hδ).trans_le bot_le).not_lt
/-- The (open) thickening `Metric.thickening δ E` of a fixed subset `E` is an increasing function of
the thickening radius `δ`. -/
theorem thickening_mono {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : Set α) :
thickening δ₁ E ⊆ thickening δ₂ E :=
preimage_mono (Iio_subset_Iio (ENNReal.ofReal_le_ofReal hle))
/-- The (open) thickening `Metric.thickening δ E` with a fixed thickening radius `δ` is
an increasing function of the subset `E`. -/
theorem thickening_subset_of_subset (δ : ℝ) {E₁ E₂ : Set α} (h : E₁ ⊆ E₂) :
thickening δ E₁ ⊆ thickening δ E₂ := fun _ hx => lt_of_le_of_lt (infEdist_anti h) hx
theorem mem_thickening_iff_exists_edist_lt {δ : ℝ} (E : Set α) (x : α) :
x ∈ thickening δ E ↔ ∃ z ∈ E, edist x z < ENNReal.ofReal δ :=
infEdist_lt_iff
/-- The frontier of the (open) thickening of a set is contained in an `EMetric.infEdist` level
set. -/
theorem frontier_thickening_subset (E : Set α) {δ : ℝ} :
frontier (thickening δ E) ⊆ { x : α | infEdist x E = ENNReal.ofReal δ } :=
frontier_lt_subset_eq continuous_infEdist continuous_const
theorem frontier_thickening_disjoint (A : Set α) :
Pairwise (Disjoint on fun r : ℝ => frontier (thickening r A)) := by
refine (pairwise_disjoint_on _).2 fun r₁ r₂ hr => ?_
rcases le_total r₁ 0 with h₁ | h₁
· simp [thickening_of_nonpos h₁]
refine ((disjoint_singleton.2 fun h => hr.ne ?_).preimage _).mono (frontier_thickening_subset _)
(frontier_thickening_subset _)
apply_fun ENNReal.toReal at h
rwa [ENNReal.toReal_ofReal h₁, ENNReal.toReal_ofReal (h₁.trans hr.le)] at h
/-- Any set is contained in the complement of the δ-thickening of the complement of its
δ-thickening. -/
lemma subset_compl_thickening_compl_thickening_self (δ : ℝ) (E : Set α) :
E ⊆ (thickening δ (thickening δ E)ᶜ)ᶜ := by
intro x x_in_E
simp only [thickening, mem_compl_iff, mem_setOf_eq, not_lt]
apply EMetric.le_infEdist.mpr fun y hy ↦ ?_
simp only [mem_compl_iff, mem_setOf_eq, not_lt] at hy
simpa only [edist_comm] using le_trans hy <| EMetric.infEdist_le_edist_of_mem x_in_E
/-- The δ-thickening of the complement of the δ-thickening of a set is contained in the complement
of the set. -/
lemma thickening_compl_thickening_self_subset_compl (δ : ℝ) (E : Set α) :
thickening δ (thickening δ E)ᶜ ⊆ Eᶜ := by
apply compl_subset_compl.mp
simpa only [compl_compl] using subset_compl_thickening_compl_thickening_self δ E
variable {X : Type u} [PseudoMetricSpace X]
theorem mem_thickening_iff_infDist_lt {E : Set X} {x : X} (h : E.Nonempty) :
x ∈ thickening δ E ↔ infDist x E < δ :=
lt_ofReal_iff_toReal_lt (infEdist_ne_top h)
/-- A point in a metric space belongs to the (open) `δ`-thickening of a subset `E` if and only if
it is at distance less than `δ` from some point of `E`. -/
theorem mem_thickening_iff {E : Set X} {x : X} : x ∈ thickening δ E ↔ ∃ z ∈ E, dist x z < δ := by
have key_iff : ∀ z : X, edist x z < ENNReal.ofReal δ ↔ dist x z < δ := fun z ↦ by
rw [dist_edist, lt_ofReal_iff_toReal_lt (edist_ne_top _ _)]
simp_rw [mem_thickening_iff_exists_edist_lt, key_iff]
@[simp]
theorem thickening_singleton (δ : ℝ) (x : X) : thickening δ ({x} : Set X) = ball x δ := by
ext
simp [mem_thickening_iff]
theorem ball_subset_thickening {x : X} {E : Set X} (hx : x ∈ E) (δ : ℝ) :
ball x δ ⊆ thickening δ E :=
Subset.trans (by simp [Subset.rfl]) (thickening_subset_of_subset δ <| singleton_subset_iff.mpr hx)
/-- The (open) `δ`-thickening `Metric.thickening δ E` of a subset `E` in a metric space equals the
union of balls of radius `δ` centered at points of `E`. -/
theorem thickening_eq_biUnion_ball {δ : ℝ} {E : Set X} : thickening δ E = ⋃ x ∈ E, ball x δ := by
ext x
simp only [mem_iUnion₂, exists_prop]
exact mem_thickening_iff
protected theorem _root_.Bornology.IsBounded.thickening {δ : ℝ} {E : Set X} (h : IsBounded E) :
IsBounded (thickening δ E) := by
rcases E.eq_empty_or_nonempty with rfl | ⟨x, hx⟩
· simp
· refine (isBounded_iff_subset_closedBall x).2 ⟨δ + diam E, fun y hy ↦ ?_⟩
calc
dist y x ≤ infDist y E + diam E := dist_le_infDist_add_diam (x := y) h hx
_ ≤ δ + diam E := add_le_add_right ((mem_thickening_iff_infDist_lt ⟨x, hx⟩).1 hy).le _
end Thickening
section Cthickening
variable [PseudoEMetricSpace α] {δ ε : ℝ} {s t : Set α} {x : α}
open EMetric
/-- The closed `δ`-thickening `Metric.cthickening δ E` of a subset `E` in a pseudo emetric space
consists of those points that are at infimum distance at most `δ` from `E`. -/
def cthickening (δ : ℝ) (E : Set α) : Set α :=
{ x : α | infEdist x E ≤ ENNReal.ofReal δ }
@[simp]
theorem mem_cthickening_iff : x ∈ cthickening δ s ↔ infEdist x s ≤ ENNReal.ofReal δ :=
Iff.rfl
/-- An exterior point of a subset `E` (i.e., a point outside the closure of `E`) is not in the
closed `δ`-thickening of `E` for small enough positive `δ`. -/
lemma eventually_not_mem_cthickening_of_infEdist_pos {E : Set α} {x : α} (h : x ∉ closure E) :
∀ᶠ δ in 𝓝 (0 : ℝ), x ∉ Metric.cthickening δ E := by
obtain ⟨ε, ⟨ε_pos, ε_lt⟩⟩ := exists_real_pos_lt_infEdist_of_not_mem_closure h
filter_upwards [eventually_lt_nhds ε_pos] with δ hδ
simp only [cthickening, mem_setOf_eq, not_le]
exact ((ofReal_lt_ofReal_iff ε_pos).mpr hδ).trans ε_lt
theorem mem_cthickening_of_edist_le (x y : α) (δ : ℝ) (E : Set α) (h : y ∈ E)
(h' : edist x y ≤ ENNReal.ofReal δ) : x ∈ cthickening δ E :=
(infEdist_le_edist_of_mem h).trans h'
theorem mem_cthickening_of_dist_le {α : Type*} [PseudoMetricSpace α] (x y : α) (δ : ℝ) (E : Set α)
(h : y ∈ E) (h' : dist x y ≤ δ) : x ∈ cthickening δ E := by
apply mem_cthickening_of_edist_le x y δ E h
rw [edist_dist]
exact ENNReal.ofReal_le_ofReal h'
theorem cthickening_eq_preimage_infEdist (δ : ℝ) (E : Set α) :
cthickening δ E = (fun x => infEdist x E) ⁻¹' Iic (ENNReal.ofReal δ) :=
rfl
/-- The closed thickening is a closed set. -/
theorem isClosed_cthickening {δ : ℝ} {E : Set α} : IsClosed (cthickening δ E) :=
IsClosed.preimage continuous_infEdist isClosed_Iic
/-- The closed thickening of the empty set is empty. -/
@[simp]
theorem cthickening_empty (δ : ℝ) : cthickening δ (∅ : Set α) = ∅ := by
simp only [cthickening, ENNReal.ofReal_ne_top, setOf_false, infEdist_empty, top_le_iff]
theorem cthickening_of_nonpos {δ : ℝ} (hδ : δ ≤ 0) (E : Set α) : cthickening δ E = closure E := by
ext x
simp [mem_closure_iff_infEdist_zero, cthickening, ENNReal.ofReal_eq_zero.2 hδ]
/-- The closed thickening with radius zero is the closure of the set. -/
@[simp]
theorem cthickening_zero (E : Set α) : cthickening 0 E = closure E :=
cthickening_of_nonpos le_rfl E
theorem cthickening_max_zero (δ : ℝ) (E : Set α) : cthickening (max 0 δ) E = cthickening δ E := by
cases le_total δ 0 <;> simp [cthickening_of_nonpos, *]
/-- The closed thickening `Metric.cthickening δ E` of a fixed subset `E` is an increasing function
of the thickening radius `δ`. -/
theorem cthickening_mono {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : Set α) :
cthickening δ₁ E ⊆ cthickening δ₂ E :=
preimage_mono (Iic_subset_Iic.mpr (ENNReal.ofReal_le_ofReal hle))
@[simp]
theorem cthickening_singleton {α : Type*} [PseudoMetricSpace α] (x : α) {δ : ℝ} (hδ : 0 ≤ δ) :
cthickening δ ({x} : Set α) = closedBall x δ := by
ext y
simp [cthickening, edist_dist, ENNReal.ofReal_le_ofReal_iff hδ]
theorem closedBall_subset_cthickening_singleton {α : Type*} [PseudoMetricSpace α] (x : α) (δ : ℝ) :
closedBall x δ ⊆ cthickening δ ({x} : Set α) := by
rcases lt_or_le δ 0 with (hδ | hδ)
· simp only [closedBall_eq_empty.mpr hδ, empty_subset]
· simp only [cthickening_singleton x hδ, Subset.rfl]
/-- The closed thickening `Metric.cthickening δ E` with a fixed thickening radius `δ` is
an increasing function of the subset `E`. -/
theorem cthickening_subset_of_subset (δ : ℝ) {E₁ E₂ : Set α} (h : E₁ ⊆ E₂) :
cthickening δ E₁ ⊆ cthickening δ E₂ := fun _ hx => le_trans (infEdist_anti h) hx
theorem cthickening_subset_thickening {δ₁ : ℝ≥0} {δ₂ : ℝ} (hlt : (δ₁ : ℝ) < δ₂) (E : Set α) :
cthickening δ₁ E ⊆ thickening δ₂ E := fun _ hx =>
hx.out.trans_lt ((ENNReal.ofReal_lt_ofReal_iff (lt_of_le_of_lt δ₁.prop hlt)).mpr hlt)
/-- The closed thickening `Metric.cthickening δ₁ E` is contained in the open thickening
`Metric.thickening δ₂ E` if the radius of the latter is positive and larger. -/
theorem cthickening_subset_thickening' {δ₁ δ₂ : ℝ} (δ₂_pos : 0 < δ₂) (hlt : δ₁ < δ₂) (E : Set α) :
cthickening δ₁ E ⊆ thickening δ₂ E := fun _ hx =>
lt_of_le_of_lt hx.out ((ENNReal.ofReal_lt_ofReal_iff δ₂_pos).mpr hlt)
/-- The open thickening `Metric.thickening δ E` is contained in the closed thickening
`Metric.cthickening δ E` with the same radius. -/
theorem thickening_subset_cthickening (δ : ℝ) (E : Set α) : thickening δ E ⊆ cthickening δ E := by
intro x hx
rw [thickening, mem_setOf_eq] at hx
exact hx.le
theorem thickening_subset_cthickening_of_le {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : Set α) :
thickening δ₁ E ⊆ cthickening δ₂ E :=
(thickening_subset_cthickening δ₁ E).trans (cthickening_mono hle E)
theorem _root_.Bornology.IsBounded.cthickening {α : Type*} [PseudoMetricSpace α] {δ : ℝ} {E : Set α}
(h : IsBounded E) : IsBounded (cthickening δ E) := by
have : IsBounded (thickening (max (δ + 1) 1) E) := h.thickening
apply this.subset
exact cthickening_subset_thickening' (zero_lt_one.trans_le (le_max_right _ _))
((lt_add_one _).trans_le (le_max_left _ _)) _
protected theorem _root_.IsCompact.cthickening
{α : Type*} [PseudoMetricSpace α] [ProperSpace α] {s : Set α}
(hs : IsCompact s) {r : ℝ} : IsCompact (cthickening r s) :=
isCompact_of_isClosed_isBounded isClosed_cthickening hs.isBounded.cthickening
theorem thickening_subset_interior_cthickening (δ : ℝ) (E : Set α) :
thickening δ E ⊆ interior (cthickening δ E) :=
(subset_interior_iff_isOpen.mpr isOpen_thickening).trans
(interior_mono (thickening_subset_cthickening δ E))
theorem closure_thickening_subset_cthickening (δ : ℝ) (E : Set α) :
closure (thickening δ E) ⊆ cthickening δ E :=
(closure_mono (thickening_subset_cthickening δ E)).trans isClosed_cthickening.closure_subset
/-- The closed thickening of a set contains the closure of the set. -/
theorem closure_subset_cthickening (δ : ℝ) (E : Set α) : closure E ⊆ cthickening δ E := by
rw [← cthickening_of_nonpos (min_le_right δ 0)]
exact cthickening_mono (min_le_left δ 0) E
/-- The (open) thickening of a set contains the closure of the set. -/
theorem closure_subset_thickening {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) :
closure E ⊆ thickening δ E := by
rw [← cthickening_zero]
exact cthickening_subset_thickening' δ_pos δ_pos E
/-- A set is contained in its own (open) thickening. -/
theorem self_subset_thickening {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) : E ⊆ thickening δ E :=
(@subset_closure _ E).trans (closure_subset_thickening δ_pos E)
/-- A set is contained in its own closed thickening. -/
theorem self_subset_cthickening {δ : ℝ} (E : Set α) : E ⊆ cthickening δ E :=
subset_closure.trans (closure_subset_cthickening δ E)
theorem thickening_mem_nhdsSet (E : Set α) {δ : ℝ} (hδ : 0 < δ) : thickening δ E ∈ 𝓝ˢ E :=
isOpen_thickening.mem_nhdsSet.2 <| self_subset_thickening hδ E
theorem cthickening_mem_nhdsSet (E : Set α) {δ : ℝ} (hδ : 0 < δ) : cthickening δ E ∈ 𝓝ˢ E :=
mem_of_superset (thickening_mem_nhdsSet E hδ) (thickening_subset_cthickening _ _)
@[simp]
theorem thickening_union (δ : ℝ) (s t : Set α) :
thickening δ (s ∪ t) = thickening δ s ∪ thickening δ t := by
simp_rw [thickening, infEdist_union, inf_eq_min, min_lt_iff, setOf_or]
@[simp]
theorem cthickening_union (δ : ℝ) (s t : Set α) :
cthickening δ (s ∪ t) = cthickening δ s ∪ cthickening δ t := by
simp_rw [cthickening, infEdist_union, inf_eq_min, min_le_iff, setOf_or]
@[simp]
theorem thickening_iUnion (δ : ℝ) (f : ι → Set α) :
thickening δ (⋃ i, f i) = ⋃ i, thickening δ (f i) := by
simp_rw [thickening, infEdist_iUnion, iInf_lt_iff, setOf_exists]
lemma thickening_biUnion {ι : Type*} (δ : ℝ) (f : ι → Set α) (I : Set ι) :
thickening δ (⋃ i ∈ I, f i) = ⋃ i ∈ I, thickening δ (f i) := by simp only [thickening_iUnion]
theorem ediam_cthickening_le (ε : ℝ≥0) :
EMetric.diam (cthickening ε s) ≤ EMetric.diam s + 2 * ε := by
refine diam_le fun x hx y hy => ENNReal.le_of_forall_pos_le_add fun δ hδ _ => ?_
rw [mem_cthickening_iff, ENNReal.ofReal_coe_nnreal] at hx hy
have hε : (ε : ℝ≥0∞) < ε + δ := ENNReal.coe_lt_coe.2 (lt_add_of_pos_right _ hδ)
replace hx := hx.trans_lt hε
obtain ⟨x', hx', hxx'⟩ := infEdist_lt_iff.mp hx
calc
edist x y ≤ edist x x' + edist y x' := edist_triangle_right _ _ _
_ ≤ ε + δ + (infEdist y s + EMetric.diam s) :=
add_le_add hxx'.le (edist_le_infEdist_add_ediam hx')
_ ≤ ε + δ + (ε + EMetric.diam s) := add_le_add_left (add_le_add_right hy _) _
_ = _ := by rw [two_mul]; ac_rfl
theorem ediam_thickening_le (ε : ℝ≥0) : EMetric.diam (thickening ε s) ≤ EMetric.diam s + 2 * ε :=
(EMetric.diam_mono <| thickening_subset_cthickening _ _).trans <| ediam_cthickening_le _
theorem diam_cthickening_le {α : Type*} [PseudoMetricSpace α] (s : Set α) (hε : 0 ≤ ε) :
diam (cthickening ε s) ≤ diam s + 2 * ε := by
lift ε to ℝ≥0 using hε
refine (toReal_le_add' (ediam_cthickening_le _) ?_ ?_).trans_eq ?_
· exact fun h ↦ top_unique <| h ▸ EMetric.diam_mono (self_subset_cthickening _)
· simp [mul_eq_top]
· simp [diam]
theorem diam_thickening_le {α : Type*} [PseudoMetricSpace α] (s : Set α) (hε : 0 ≤ ε) :
diam (thickening ε s) ≤ diam s + 2 * ε := by
by_cases hs : IsBounded s
· exact (diam_mono (thickening_subset_cthickening _ _) hs.cthickening).trans
(diam_cthickening_le _ hε)
obtain rfl | hε := hε.eq_or_lt
· simp [thickening_of_nonpos, diam_nonneg]
· rw [diam_eq_zero_of_unbounded (mt (IsBounded.subset · <| self_subset_thickening hε _) hs)]
positivity
@[simp]
theorem thickening_closure : thickening δ (closure s) = thickening δ s := by
simp_rw [thickening, infEdist_closure]
@[simp]
theorem cthickening_closure : cthickening δ (closure s) = cthickening δ s := by
simp_rw [cthickening, infEdist_closure]
open ENNReal
theorem _root_.Disjoint.exists_thickenings (hst : Disjoint s t) (hs : IsCompact s)
(ht : IsClosed t) :
∃ δ, 0 < δ ∧ Disjoint (thickening δ s) (thickening δ t) := by
obtain ⟨r, hr, h⟩ := exists_pos_forall_lt_edist hs ht hst
refine ⟨r / 2, half_pos (NNReal.coe_pos.2 hr), ?_⟩
rw [disjoint_iff_inf_le]
rintro z ⟨hzs, hzt⟩
rw [mem_thickening_iff_exists_edist_lt] at hzs hzt
rw [← NNReal.coe_two, ← NNReal.coe_div, ENNReal.ofReal_coe_nnreal] at hzs hzt
obtain ⟨x, hx, hzx⟩ := hzs
obtain ⟨y, hy, hzy⟩ := hzt
refine (h x hx y hy).not_le ?_
calc
edist x y ≤ edist z x + edist z y := edist_triangle_left _ _ _
_ ≤ ↑(r / 2) + ↑(r / 2) := add_le_add hzx.le hzy.le
_ = r := by rw [← ENNReal.coe_add, add_halves]
theorem _root_.Disjoint.exists_cthickenings (hst : Disjoint s t) (hs : IsCompact s)
(ht : IsClosed t) :
∃ δ, 0 < δ ∧ Disjoint (cthickening δ s) (cthickening δ t) := by
obtain ⟨δ, hδ, h⟩ := hst.exists_thickenings hs ht
refine ⟨δ / 2, half_pos hδ, h.mono ?_ ?_⟩ <;>
exact cthickening_subset_thickening' hδ (half_lt_self hδ) _
/-- If `s` is compact, `t` is open and `s ⊆ t`, some `cthickening` of `s` is contained in `t`. -/
theorem _root_.IsCompact.exists_cthickening_subset_open (hs : IsCompact s) (ht : IsOpen t)
(hst : s ⊆ t) :
∃ δ, 0 < δ ∧ cthickening δ s ⊆ t :=
(hst.disjoint_compl_right.exists_cthickenings hs ht.isClosed_compl).imp fun _ h =>
⟨h.1, disjoint_compl_right_iff_subset.1 <| h.2.mono_right <| self_subset_cthickening _⟩
theorem _root_.IsCompact.exists_isCompact_cthickening [LocallyCompactSpace α] (hs : IsCompact s) :
∃ δ, 0 < δ ∧ IsCompact (cthickening δ s) := by
rcases exists_compact_superset hs with ⟨K, K_compact, hK⟩
rcases hs.exists_cthickening_subset_open isOpen_interior hK with ⟨δ, δpos, hδ⟩
refine ⟨δ, δpos, ?_⟩
exact K_compact.of_isClosed_subset isClosed_cthickening (hδ.trans interior_subset)
theorem _root_.IsCompact.exists_thickening_subset_open (hs : IsCompact s) (ht : IsOpen t)
(hst : s ⊆ t) : ∃ δ, 0 < δ ∧ thickening δ s ⊆ t :=
let ⟨δ, h₀, hδ⟩ := hs.exists_cthickening_subset_open ht hst
⟨δ, h₀, (thickening_subset_cthickening _ _).trans hδ⟩
theorem hasBasis_nhdsSet_thickening {K : Set α} (hK : IsCompact K) :
(𝓝ˢ K).HasBasis (fun δ : ℝ => 0 < δ) fun δ => thickening δ K :=
(hasBasis_nhdsSet K).to_hasBasis' (fun _U hU => hK.exists_thickening_subset_open hU.1 hU.2)
fun _ => thickening_mem_nhdsSet K
theorem hasBasis_nhdsSet_cthickening {K : Set α} (hK : IsCompact K) :
(𝓝ˢ K).HasBasis (fun δ : ℝ => 0 < δ) fun δ => cthickening δ K :=
(hasBasis_nhdsSet K).to_hasBasis' (fun _U hU => hK.exists_cthickening_subset_open hU.1 hU.2)
fun _ => cthickening_mem_nhdsSet K
theorem cthickening_eq_iInter_cthickening' {δ : ℝ} (s : Set ℝ) (hsδ : s ⊆ Ioi δ)
(hs : ∀ ε, δ < ε → (s ∩ Ioc δ ε).Nonempty) (E : Set α) :
cthickening δ E = ⋂ ε ∈ s, cthickening ε E := by
apply Subset.antisymm
· exact subset_iInter₂ fun _ hε => cthickening_mono (le_of_lt (hsδ hε)) E
· unfold cthickening
intro x hx
simp only [mem_iInter, mem_setOf_eq] at *
apply ENNReal.le_of_forall_pos_le_add
intro η η_pos _
rcases hs (δ + η) (lt_add_of_pos_right _ (NNReal.coe_pos.mpr η_pos)) with ⟨ε, ⟨hsε, hε⟩⟩
apply ((hx ε hsε).trans (ENNReal.ofReal_le_ofReal hε.2)).trans
rw [ENNReal.coe_nnreal_eq η]
exact ENNReal.ofReal_add_le
theorem cthickening_eq_iInter_cthickening {δ : ℝ} (E : Set α) :
cthickening δ E = ⋂ (ε : ℝ) (_ : δ < ε), cthickening ε E := by
apply cthickening_eq_iInter_cthickening' (Ioi δ) rfl.subset
simp_rw [inter_eq_right.mpr Ioc_subset_Ioi_self]
exact fun _ hε => nonempty_Ioc.mpr hε
theorem cthickening_eq_iInter_thickening' {δ : ℝ} (δ_nn : 0 ≤ δ) (s : Set ℝ) (hsδ : s ⊆ Ioi δ)
(hs : ∀ ε, δ < ε → (s ∩ Ioc δ ε).Nonempty) (E : Set α) :
cthickening δ E = ⋂ ε ∈ s, thickening ε E := by
refine (subset_iInter₂ fun ε hε => ?_).antisymm ?_
· obtain ⟨ε', -, hε'⟩ := hs ε (hsδ hε)
have ss := cthickening_subset_thickening' (lt_of_le_of_lt δ_nn hε'.1) hε'.1 E
exact ss.trans (thickening_mono hε'.2 E)
· rw [cthickening_eq_iInter_cthickening' s hsδ hs E]
exact iInter₂_mono fun ε _ => thickening_subset_cthickening ε E
theorem cthickening_eq_iInter_thickening {δ : ℝ} (δ_nn : 0 ≤ δ) (E : Set α) :
cthickening δ E = ⋂ (ε : ℝ) (_ : δ < ε), thickening ε E := by
apply cthickening_eq_iInter_thickening' δ_nn (Ioi δ) rfl.subset
simp_rw [inter_eq_right.mpr Ioc_subset_Ioi_self]
exact fun _ hε => nonempty_Ioc.mpr hε
theorem cthickening_eq_iInter_thickening'' (δ : ℝ) (E : Set α) :
cthickening δ E = ⋂ (ε : ℝ) (_ : max 0 δ < ε), thickening ε E := by
rw [← cthickening_max_zero, cthickening_eq_iInter_thickening]
exact le_max_left _ _
/-- The closure of a set equals the intersection of its closed thickenings of positive radii
accumulating at zero. -/
theorem closure_eq_iInter_cthickening' (E : Set α) (s : Set ℝ)
(hs : ∀ ε, 0 < ε → (s ∩ Ioc 0 ε).Nonempty) : closure E = ⋂ δ ∈ s, cthickening δ E := by
by_cases hs₀ : s ⊆ Ioi 0
· rw [← cthickening_zero]
apply cthickening_eq_iInter_cthickening' _ hs₀ hs
obtain ⟨δ, hδs, δ_nonpos⟩ := not_subset.mp hs₀
rw [Set.mem_Ioi, not_lt] at δ_nonpos
apply Subset.antisymm
· exact subset_iInter₂ fun ε _ => closure_subset_cthickening ε E
· rw [← cthickening_of_nonpos δ_nonpos E]
exact biInter_subset_of_mem hδs
/-- The closure of a set equals the intersection of its closed thickenings of positive radii. -/
theorem closure_eq_iInter_cthickening (E : Set α) :
closure E = ⋂ (δ : ℝ) (_ : 0 < δ), cthickening δ E := by
rw [← cthickening_zero]
exact cthickening_eq_iInter_cthickening E
/-- The closure of a set equals the intersection of its open thickenings of positive radii
accumulating at zero. -/
theorem closure_eq_iInter_thickening' (E : Set α) (s : Set ℝ) (hs₀ : s ⊆ Ioi 0)
(hs : ∀ ε, 0 < ε → (s ∩ Ioc 0 ε).Nonempty) : closure E = ⋂ δ ∈ s, thickening δ E := by
rw [← cthickening_zero]
apply cthickening_eq_iInter_thickening' le_rfl _ hs₀ hs
/-- The closure of a set equals the intersection of its (open) thickenings of positive radii. -/
theorem closure_eq_iInter_thickening (E : Set α) :
closure E = ⋂ (δ : ℝ) (_ : 0 < δ), thickening δ E := by
rw [← cthickening_zero]
exact cthickening_eq_iInter_thickening rfl.ge E
/-- The frontier of the closed thickening of a set is contained in an `EMetric.infEdist` level
set. -/
theorem frontier_cthickening_subset (E : Set α) {δ : ℝ} :
frontier (cthickening δ E) ⊆ { x : α | infEdist x E = ENNReal.ofReal δ } :=
frontier_le_subset_eq continuous_infEdist continuous_const
/-- The closed ball of radius `δ` centered at a point of `E` is included in the closed
thickening of `E`. -/
theorem closedBall_subset_cthickening {α : Type*} [PseudoMetricSpace α] {x : α} {E : Set α}
(hx : x ∈ E) (δ : ℝ) : closedBall x δ ⊆ cthickening δ E := by
refine (closedBall_subset_cthickening_singleton _ _).trans (cthickening_subset_of_subset _ ?_)
simpa using hx
theorem cthickening_subset_iUnion_closedBall_of_lt {α : Type*} [PseudoMetricSpace α] (E : Set α)
{δ δ' : ℝ} (hδ₀ : 0 < δ') (hδδ' : δ < δ') : cthickening δ E ⊆ ⋃ x ∈ E, closedBall x δ' := by
refine (cthickening_subset_thickening' hδ₀ hδδ' E).trans fun x hx => ?_
obtain ⟨y, hy₁, hy₂⟩ := mem_thickening_iff.mp hx
exact mem_iUnion₂.mpr ⟨y, hy₁, hy₂.le⟩
/-- The closed thickening of a compact set `E` is the union of the balls `Metric.closedBall x δ`
over `x ∈ E`.
See also `Metric.cthickening_eq_biUnion_closedBall`. -/
theorem _root_.IsCompact.cthickening_eq_biUnion_closedBall {α : Type*} [PseudoMetricSpace α]
{δ : ℝ} {E : Set α} (hE : IsCompact E) (hδ : 0 ≤ δ) :
cthickening δ E = ⋃ x ∈ E, closedBall x δ := by
rcases eq_empty_or_nonempty E with (rfl | hne)
· simp only [cthickening_empty, biUnion_empty]
refine Subset.antisymm (fun x hx ↦ ?_)
(iUnion₂_subset fun x hx ↦ closedBall_subset_cthickening hx _)
obtain ⟨y, yE, hy⟩ : ∃ y ∈ E, infEdist x E = edist x y := hE.exists_infEdist_eq_edist hne _
have D1 : edist x y ≤ ENNReal.ofReal δ := (le_of_eq hy.symm).trans hx
have D2 : dist x y ≤ δ := by
rw [edist_dist] at D1
exact (ENNReal.ofReal_le_ofReal_iff hδ).1 D1
exact mem_biUnion yE D2
theorem cthickening_eq_biUnion_closedBall {α : Type*} [PseudoMetricSpace α] [ProperSpace α]
(E : Set α) (hδ : 0 ≤ δ) : cthickening δ E = ⋃ x ∈ closure E, closedBall x δ := by
rcases eq_empty_or_nonempty E with (rfl | hne)
· simp only [cthickening_empty, biUnion_empty, closure_empty]
rw [← cthickening_closure]
refine Subset.antisymm (fun x hx ↦ ?_)
(iUnion₂_subset fun x hx ↦ closedBall_subset_cthickening hx _)
obtain ⟨y, yE, hy⟩ : ∃ y ∈ closure E, infDist x (closure E) = dist x y :=
isClosed_closure.exists_infDist_eq_dist (closure_nonempty_iff.mpr hne) x
replace hy : dist x y ≤ δ :=
(ENNReal.ofReal_le_ofReal_iff hδ).mp
(((congr_arg ENNReal.ofReal hy.symm).le.trans ENNReal.ofReal_toReal_le).trans hx)
exact mem_biUnion yE hy
nonrec theorem _root_.IsClosed.cthickening_eq_biUnion_closedBall {α : Type*} [PseudoMetricSpace α]
[ProperSpace α] {E : Set α} (hE : IsClosed E) (hδ : 0 ≤ δ) :
cthickening δ E = ⋃ x ∈ E, closedBall x δ := by
rw [cthickening_eq_biUnion_closedBall E hδ, hE.closure_eq]
/-- For the equality, see `infEdist_cthickening`. -/
theorem infEdist_le_infEdist_cthickening_add :
infEdist x s ≤ infEdist x (cthickening δ s) + ENNReal.ofReal δ := by
refine le_of_forall_lt' fun r h => ?_
simp_rw [← lt_tsub_iff_right, infEdist_lt_iff, mem_cthickening_iff] at h
obtain ⟨y, hy, hxy⟩ := h
exact infEdist_le_edist_add_infEdist.trans_lt
((ENNReal.add_lt_add_of_lt_of_le (hy.trans_lt ENNReal.ofReal_lt_top).ne hxy hy).trans_eq
(tsub_add_cancel_of_le <| le_self_add.trans (lt_tsub_iff_left.1 hxy).le))
/-- For the equality, see `infEdist_thickening`. -/
theorem infEdist_le_infEdist_thickening_add :
infEdist x s ≤ infEdist x (thickening δ s) + ENNReal.ofReal δ :=
infEdist_le_infEdist_cthickening_add.trans <|
add_le_add_right (infEdist_anti <| thickening_subset_cthickening _ _) _
/-- For the equality, see `thickening_thickening`. -/
@[simp]
theorem thickening_thickening_subset (ε δ : ℝ) (s : Set α) :
thickening ε (thickening δ s) ⊆ thickening (ε + δ) s := by
obtain hε | hε := le_total ε 0
· simp only [thickening_of_nonpos hε, empty_subset]
obtain hδ | hδ := le_total δ 0
· simp only [thickening_of_nonpos hδ, thickening_empty, empty_subset]
intro x
simp_rw [mem_thickening_iff_exists_edist_lt, ENNReal.ofReal_add hε hδ]
exact fun ⟨y, ⟨z, hz, hy⟩, hx⟩ =>
⟨z, hz, (edist_triangle _ _ _).trans_lt <| ENNReal.add_lt_add hx hy⟩
/-- For the equality, see `thickening_cthickening`. -/
@[simp]
theorem thickening_cthickening_subset (ε : ℝ) (hδ : 0 ≤ δ) (s : Set α) :
thickening ε (cthickening δ s) ⊆ thickening (ε + δ) s := by
obtain hε | hε := le_total ε 0
· simp only [thickening_of_nonpos hε, empty_subset]
intro x
simp_rw [mem_thickening_iff_exists_edist_lt, mem_cthickening_iff, ← infEdist_lt_iff,
ENNReal.ofReal_add hε hδ]
rintro ⟨y, hy, hxy⟩
exact infEdist_le_edist_add_infEdist.trans_lt
(ENNReal.add_lt_add_of_lt_of_le (hy.trans_lt ENNReal.ofReal_lt_top).ne hxy hy)
/-- For the equality, see `cthickening_thickening`. -/
@[simp]
theorem cthickening_thickening_subset (hε : 0 ≤ ε) (δ : ℝ) (s : Set α) :
cthickening ε (thickening δ s) ⊆ cthickening (ε + δ) s := by
obtain hδ | hδ := le_total δ 0
· simp only [thickening_of_nonpos hδ, cthickening_empty, empty_subset]
intro x
simp_rw [mem_cthickening_iff, ENNReal.ofReal_add hε hδ]
exact fun hx => infEdist_le_infEdist_thickening_add.trans (add_le_add_right hx _)
/-- For the equality, see `cthickening_cthickening`. -/
@[simp]
theorem cthickening_cthickening_subset (hε : 0 ≤ ε) (hδ : 0 ≤ δ) (s : Set α) :
cthickening ε (cthickening δ s) ⊆ cthickening (ε + δ) s := by
intro x
simp_rw [mem_cthickening_iff, ENNReal.ofReal_add hε hδ]
exact fun hx => infEdist_le_infEdist_cthickening_add.trans (add_le_add_right hx _)
theorem frontier_cthickening_disjoint (A : Set α) :
Pairwise (Disjoint on fun r : ℝ≥0 => frontier (cthickening r A)) := fun r₁ r₂ hr =>
((disjoint_singleton.2 <| by simpa).preimage _).mono (frontier_cthickening_subset _)
(frontier_cthickening_subset _)
end Cthickening
end Metric
|
Topology\MetricSpace\ProperSpace\Lemmas.lean | /-
Copyright (c) 2018 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.Algebra.Order.Compact
import Mathlib.Topology.MetricSpace.ProperSpace
import Mathlib.Topology.Order.IntermediateValue
import Mathlib.Topology.Order.LocalExtr
/-!
# Proper spaces
This file contains some more involved results about `ProperSpace`s.
## Main definitions and results
* `exists_pos_lt_subset_ball`
* `exists_lt_subset_ball`
* `Metric.exists_isLocalMin_mem_ball`
-/
open Set Metric
variable {α : Type*} {β : Type*} [PseudoMetricSpace α] [ProperSpace α] {x : α} {r : ℝ} {s : Set α}
/-- If a nonempty ball in a proper space includes a closed set `s`, then there exists a nonempty
ball with the same center and a strictly smaller radius that includes `s`. -/
theorem exists_pos_lt_subset_ball (hr : 0 < r) (hs : IsClosed s) (h : s ⊆ ball x r) :
∃ r' ∈ Ioo 0 r, s ⊆ ball x r' := by
rcases eq_empty_or_nonempty s with (rfl | hne)
· exact ⟨r / 2, ⟨half_pos hr, half_lt_self hr⟩, empty_subset _⟩
have : IsCompact s :=
(isCompact_closedBall x r).of_isClosed_subset hs (h.trans ball_subset_closedBall)
obtain ⟨y, hys, hy⟩ : ∃ y ∈ s, s ⊆ closedBall x (dist y x) :=
this.exists_isMaxOn (β := α) (α := ℝ) hne (continuous_id.dist continuous_const).continuousOn
have hyr : dist y x < r := h hys
rcases exists_between hyr with ⟨r', hyr', hrr'⟩
exact ⟨r', ⟨dist_nonneg.trans_lt hyr', hrr'⟩, hy.trans <| closedBall_subset_ball hyr'⟩
/-- If a ball in a proper space includes a closed set `s`, then there exists a ball with the same
center and a strictly smaller radius that includes `s`. -/
theorem exists_lt_subset_ball (hs : IsClosed s) (h : s ⊆ ball x r) : ∃ r' < r, s ⊆ ball x r' := by
rcases le_or_lt r 0 with hr | hr
· rw [ball_eq_empty.2 hr, subset_empty_iff] at h
subst s
exact (exists_lt r).imp fun r' hr' => ⟨hr', empty_subset _⟩
· exact (exists_pos_lt_subset_ball hr hs h).imp fun r' hr' => ⟨hr'.1.2, hr'.2⟩
theorem Metric.exists_isLocalMin_mem_ball [TopologicalSpace β]
[ConditionallyCompleteLinearOrder β] [OrderTopology β] {f : α → β} {a z : α} {r : ℝ}
(hf : ContinuousOn f (closedBall a r)) (hz : z ∈ closedBall a r)
(hf1 : ∀ z' ∈ sphere a r, f z < f z') : ∃ z ∈ ball a r, IsLocalMin f z := by
simp_rw [← closedBall_diff_ball] at hf1
exact (isCompact_closedBall a r).exists_isLocalMin_mem_open ball_subset_closedBall hf hz hf1
isOpen_ball
|
Topology\MetricSpace\Pseudo\Constructions.lean | /-
Copyright (c) 2015, 2017 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Robert Y. Lewis, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel
-/
import Mathlib.Topology.Bornology.Constructions
import Mathlib.Topology.MetricSpace.Pseudo.Defs
/-!
# Product of pseudo-metric spaces and other constructions
This file constructs the infinity distance on finite products of normed groups and provides
instances for type synonyms.
-/
open Bornology Filter Metric Set
open scoped NNReal Topology
variable {α β : Type*} [PseudoMetricSpace α]
/-- Pseudometric space structure pulled back by a function. -/
abbrev PseudoMetricSpace.induced {α β} (f : α → β) (m : PseudoMetricSpace β) :
PseudoMetricSpace α where
dist x y := dist (f x) (f y)
dist_self x := dist_self _
dist_comm x y := dist_comm _ _
dist_triangle x y z := dist_triangle _ _ _
edist x y := edist (f x) (f y)
edist_dist x y := edist_dist _ _
toUniformSpace := UniformSpace.comap f m.toUniformSpace
uniformity_dist := (uniformity_basis_dist.comap _).eq_biInf
toBornology := Bornology.induced f
cobounded_sets := Set.ext fun s => mem_comap_iff_compl.trans <| by
simp only [← isBounded_def, isBounded_iff, forall_mem_image, mem_setOf]
/-- Pull back a pseudometric space structure by an inducing map. This is a version of
`PseudoMetricSpace.induced` useful in case if the domain already has a `TopologicalSpace`
structure. -/
def Inducing.comapPseudoMetricSpace {α β} [TopologicalSpace α] [m : PseudoMetricSpace β] {f : α → β}
(hf : Inducing f) : PseudoMetricSpace α :=
.replaceTopology (.induced f m) hf.induced
/-- Pull back a pseudometric space structure by a uniform inducing map. This is a version of
`PseudoMetricSpace.induced` useful in case if the domain already has a `UniformSpace`
structure. -/
def UniformInducing.comapPseudoMetricSpace {α β} [UniformSpace α] [m : PseudoMetricSpace β]
(f : α → β) (h : UniformInducing f) : PseudoMetricSpace α :=
.replaceUniformity (.induced f m) h.comap_uniformity.symm
instance Subtype.pseudoMetricSpace {p : α → Prop} : PseudoMetricSpace (Subtype p) :=
PseudoMetricSpace.induced Subtype.val ‹_›
lemma Subtype.dist_eq {p : α → Prop} (x y : Subtype p) : dist x y = dist (x : α) y := rfl
lemma Subtype.nndist_eq {p : α → Prop} (x y : Subtype p) : nndist x y = nndist (x : α) y := rfl
namespace MulOpposite
@[to_additive]
instance instPseudoMetricSpace : PseudoMetricSpace αᵐᵒᵖ :=
PseudoMetricSpace.induced MulOpposite.unop ‹_›
@[to_additive (attr := simp)]
lemma dist_unop (x y : αᵐᵒᵖ) : dist (unop x) (unop y) = dist x y := rfl
@[to_additive (attr := simp)]
lemma dist_op (x y : α) : dist (op x) (op y) = dist x y := rfl
@[to_additive (attr := simp)]
lemma nndist_unop (x y : αᵐᵒᵖ) : nndist (unop x) (unop y) = nndist x y := rfl
@[to_additive (attr := simp)]
lemma nndist_op (x y : α) : nndist (op x) (op y) = nndist x y := rfl
end MulOpposite
section NNReal
instance : PseudoMetricSpace ℝ≥0 := Subtype.pseudoMetricSpace
lemma NNReal.dist_eq (a b : ℝ≥0) : dist a b = |(a : ℝ) - b| := rfl
lemma NNReal.nndist_eq (a b : ℝ≥0) : nndist a b = max (a - b) (b - a) :=
eq_of_forall_ge_iff fun _ => by
simp only [max_le_iff, tsub_le_iff_right (α := ℝ≥0)]
simp only [← NNReal.coe_le_coe, coe_nndist, dist_eq, abs_sub_le_iff,
tsub_le_iff_right, NNReal.coe_add]
@[simp]
lemma NNReal.nndist_zero_eq_val (z : ℝ≥0) : nndist 0 z = z := by
simp only [NNReal.nndist_eq, max_eq_right, tsub_zero, zero_tsub, zero_le']
@[simp]
lemma NNReal.nndist_zero_eq_val' (z : ℝ≥0) : nndist z 0 = z := by
rw [nndist_comm]
exact NNReal.nndist_zero_eq_val z
lemma NNReal.le_add_nndist (a b : ℝ≥0) : a ≤ b + nndist a b := by
suffices (a : ℝ) ≤ (b : ℝ) + dist a b by
rwa [← NNReal.coe_le_coe, NNReal.coe_add, coe_nndist]
rw [← sub_le_iff_le_add']
exact le_of_abs_le (dist_eq a b).ge
lemma NNReal.ball_zero_eq_Ico' (c : ℝ≥0) :
Metric.ball (0 : ℝ≥0) c.toReal = Set.Ico 0 c := by ext x; simp
lemma NNReal.ball_zero_eq_Ico (c : ℝ) :
Metric.ball (0 : ℝ≥0) c = Set.Ico 0 c.toNNReal := by
by_cases c_pos : 0 < c
· convert NNReal.ball_zero_eq_Ico' ⟨c, c_pos.le⟩
simp [Real.toNNReal, c_pos.le]
simp [not_lt.mp c_pos]
lemma NNReal.closedBall_zero_eq_Icc' (c : ℝ≥0) :
Metric.closedBall (0 : ℝ≥0) c.toReal = Set.Icc 0 c := by ext x; simp
lemma NNReal.closedBall_zero_eq_Icc {c : ℝ} (c_nn : 0 ≤ c) :
Metric.closedBall (0 : ℝ≥0) c = Set.Icc 0 c.toNNReal := by
convert NNReal.closedBall_zero_eq_Icc' ⟨c, c_nn⟩
simp [Real.toNNReal, c_nn]
end NNReal
namespace ULift
variable [PseudoMetricSpace β]
instance : PseudoMetricSpace (ULift β) := PseudoMetricSpace.induced ULift.down ‹_›
lemma dist_eq (x y : ULift β) : dist x y = dist x.down y.down := rfl
lemma nndist_eq (x y : ULift β) : nndist x y = nndist x.down y.down := rfl
@[simp] lemma dist_up_up (x y : β) : dist (ULift.up x) (ULift.up y) = dist x y := rfl
@[simp] lemma nndist_up_up (x y : β) : nndist (ULift.up x) (ULift.up y) = nndist x y := rfl
end ULift
section Prod
variable [PseudoMetricSpace β]
-- Porting note: added `let`, otherwise `simp` failed
instance Prod.pseudoMetricSpaceMax : PseudoMetricSpace (α × β) :=
let i := PseudoEMetricSpace.toPseudoMetricSpaceOfDist
(fun x y : α × β => dist x.1 y.1 ⊔ dist x.2 y.2)
(fun x y => (max_lt (edist_lt_top _ _) (edist_lt_top _ _)).ne) fun x y => by
simp only [sup_eq_max, dist_edist, ← ENNReal.toReal_max (edist_ne_top _ _) (edist_ne_top _ _),
Prod.edist_eq]
i.replaceBornology fun s => by
simp only [← isBounded_image_fst_and_snd, isBounded_iff_eventually, forall_mem_image, ←
eventually_and, ← forall_and, ← max_le_iff]
rfl
lemma Prod.dist_eq {x y : α × β} : dist x y = max (dist x.1 y.1) (dist x.2 y.2) := rfl
@[simp]
lemma dist_prod_same_left {x : α} {y₁ y₂ : β} : dist (x, y₁) (x, y₂) = dist y₁ y₂ := by
simp [Prod.dist_eq, dist_nonneg]
@[simp]
lemma dist_prod_same_right {x₁ x₂ : α} {y : β} : dist (x₁, y) (x₂, y) = dist x₁ x₂ := by
simp [Prod.dist_eq, dist_nonneg]
lemma ball_prod_same (x : α) (y : β) (r : ℝ) : ball x r ×ˢ ball y r = ball (x, y) r :=
ext fun z => by simp [Prod.dist_eq]
lemma closedBall_prod_same (x : α) (y : β) (r : ℝ) :
closedBall x r ×ˢ closedBall y r = closedBall (x, y) r := ext fun z => by simp [Prod.dist_eq]
lemma sphere_prod (x : α × β) (r : ℝ) :
sphere x r = sphere x.1 r ×ˢ closedBall x.2 r ∪ closedBall x.1 r ×ˢ sphere x.2 r := by
obtain hr | rfl | hr := lt_trichotomy r 0
· simp [hr]
· cases x
simp_rw [← closedBall_eq_sphere_of_nonpos le_rfl, union_self, closedBall_prod_same]
· ext ⟨x', y'⟩
simp_rw [Set.mem_union, Set.mem_prod, Metric.mem_closedBall, Metric.mem_sphere, Prod.dist_eq,
max_eq_iff]
refine or_congr (and_congr_right ?_) (and_comm.trans (and_congr_left ?_))
all_goals rintro rfl; rfl
end Prod
lemma uniformContinuous_dist : UniformContinuous fun p : α × α => dist p.1 p.2 :=
Metric.uniformContinuous_iff.2 fun ε ε0 =>
⟨ε / 2, half_pos ε0, fun {a b} h =>
calc dist (dist a.1 a.2) (dist b.1 b.2) ≤ dist a.1 b.1 + dist a.2 b.2 :=
dist_dist_dist_le _ _ _ _
_ ≤ dist a b + dist a b := add_le_add (le_max_left _ _) (le_max_right _ _)
_ < ε / 2 + ε / 2 := add_lt_add h h
_ = ε := add_halves ε⟩
protected lemma UniformContinuous.dist [UniformSpace β] {f g : β → α} (hf : UniformContinuous f)
(hg : UniformContinuous g) : UniformContinuous fun b => dist (f b) (g b) :=
uniformContinuous_dist.comp (hf.prod_mk hg)
@[continuity]
lemma continuous_dist : Continuous fun p : α × α ↦ dist p.1 p.2 := uniformContinuous_dist.continuous
@[continuity, fun_prop]
protected lemma Continuous.dist [TopologicalSpace β] {f g : β → α} (hf : Continuous f)
(hg : Continuous g) : Continuous fun b => dist (f b) (g b) :=
continuous_dist.comp (hf.prod_mk hg : _)
protected lemma Filter.Tendsto.dist {f g : β → α} {x : Filter β} {a b : α}
(hf : Tendsto f x (𝓝 a)) (hg : Tendsto g x (𝓝 b)) :
Tendsto (fun x => dist (f x) (g x)) x (𝓝 (dist a b)) :=
(continuous_dist.tendsto (a, b)).comp (hf.prod_mk_nhds hg)
lemma continuous_iff_continuous_dist [TopologicalSpace β] {f : β → α} :
Continuous f ↔ Continuous fun x : β × β => dist (f x.1) (f x.2) :=
⟨fun h => h.fst'.dist h.snd', fun h =>
continuous_iff_continuousAt.2 fun _ => tendsto_iff_dist_tendsto_zero.2 <|
(h.comp (continuous_id.prod_mk continuous_const)).tendsto' _ _ <| dist_self _⟩
lemma uniformContinuous_nndist : UniformContinuous fun p : α × α => nndist p.1 p.2 :=
uniformContinuous_dist.subtype_mk _
protected lemma UniformContinuous.nndist [UniformSpace β] {f g : β → α} (hf : UniformContinuous f)
(hg : UniformContinuous g) : UniformContinuous fun b => nndist (f b) (g b) :=
uniformContinuous_nndist.comp (hf.prod_mk hg)
lemma continuous_nndist : Continuous fun p : α × α => nndist p.1 p.2 :=
uniformContinuous_nndist.continuous
@[fun_prop]
protected lemma Continuous.nndist [TopologicalSpace β] {f g : β → α} (hf : Continuous f)
(hg : Continuous g) : Continuous fun b => nndist (f b) (g b) :=
continuous_nndist.comp (hf.prod_mk hg : _)
protected lemma Filter.Tendsto.nndist {f g : β → α} {x : Filter β} {a b : α}
(hf : Tendsto f x (𝓝 a)) (hg : Tendsto g x (𝓝 b)) :
Tendsto (fun x => nndist (f x) (g x)) x (𝓝 (nndist a b)) :=
(continuous_nndist.tendsto (a, b)).comp (hf.prod_mk_nhds hg)
section Pi
open Finset
variable {π : β → Type*} [Fintype β] [∀ b, PseudoMetricSpace (π b)]
/-- A finite product of pseudometric spaces is a pseudometric space, with the sup distance. -/
instance pseudoMetricSpacePi : PseudoMetricSpace (∀ b, π b) := by
/- we construct the instance from the pseudoemetric space instance to avoid checking again that
the uniformity is the same as the product uniformity, but we register nevertheless a nice
formula for the distance -/
let i := PseudoEMetricSpace.toPseudoMetricSpaceOfDist
(fun f g : ∀ b, π b => ((sup univ fun b => nndist (f b) (g b) : ℝ≥0) : ℝ))
(fun f g => ((Finset.sup_lt_iff bot_lt_top).2 fun b _ => edist_lt_top _ _).ne)
(fun f g => by
simp only [edist_pi_def, edist_nndist, ← ENNReal.coe_finset_sup, ENNReal.coe_toReal])
refine i.replaceBornology fun s => ?_
simp only [← isBounded_def, isBounded_iff_eventually, ← forall_isBounded_image_eval_iff,
forall_mem_image, ← Filter.eventually_all, Function.eval_apply, @dist_nndist (π _)]
refine eventually_congr ((eventually_ge_atTop 0).mono fun C hC ↦ ?_)
lift C to ℝ≥0 using hC
refine ⟨fun H x hx y hy ↦ NNReal.coe_le_coe.2 <| Finset.sup_le fun b _ ↦ H b hx hy,
fun H b x hx y hy ↦ NNReal.coe_le_coe.2 ?_⟩
simpa only using Finset.sup_le_iff.1 (NNReal.coe_le_coe.1 <| H hx hy) b (Finset.mem_univ b)
lemma nndist_pi_def (f g : ∀ b, π b) : nndist f g = sup univ fun b => nndist (f b) (g b) := rfl
lemma dist_pi_def (f g : ∀ b, π b) : dist f g = (sup univ fun b => nndist (f b) (g b) : ℝ≥0) := rfl
lemma nndist_pi_le_iff {f g : ∀ b, π b} {r : ℝ≥0} :
nndist f g ≤ r ↔ ∀ b, nndist (f b) (g b) ≤ r := by simp [nndist_pi_def]
lemma nndist_pi_lt_iff {f g : ∀ b, π b} {r : ℝ≥0} (hr : 0 < r) :
nndist f g < r ↔ ∀ b, nndist (f b) (g b) < r := by
rw [← bot_eq_zero'] at hr
simp [nndist_pi_def, Finset.sup_lt_iff hr]
lemma nndist_pi_eq_iff {f g : ∀ b, π b} {r : ℝ≥0} (hr : 0 < r) :
nndist f g = r ↔ (∃ i, nndist (f i) (g i) = r) ∧ ∀ b, nndist (f b) (g b) ≤ r := by
rw [eq_iff_le_not_lt, nndist_pi_lt_iff hr, nndist_pi_le_iff, not_forall, and_comm]
simp_rw [not_lt, and_congr_left_iff, le_antisymm_iff]
intro h
refine exists_congr fun b => ?_
apply (and_iff_right <| h _).symm
lemma dist_pi_lt_iff {f g : ∀ b, π b} {r : ℝ} (hr : 0 < r) :
dist f g < r ↔ ∀ b, dist (f b) (g b) < r := by
lift r to ℝ≥0 using hr.le
exact nndist_pi_lt_iff hr
lemma dist_pi_le_iff {f g : ∀ b, π b} {r : ℝ} (hr : 0 ≤ r) :
dist f g ≤ r ↔ ∀ b, dist (f b) (g b) ≤ r := by
lift r to ℝ≥0 using hr
exact nndist_pi_le_iff
lemma dist_pi_eq_iff {f g : ∀ b, π b} {r : ℝ} (hr : 0 < r) :
dist f g = r ↔ (∃ i, dist (f i) (g i) = r) ∧ ∀ b, dist (f b) (g b) ≤ r := by
lift r to ℝ≥0 using hr.le
simp_rw [← coe_nndist, NNReal.coe_inj, nndist_pi_eq_iff hr, NNReal.coe_le_coe]
lemma dist_pi_le_iff' [Nonempty β] {f g : ∀ b, π b} {r : ℝ} :
dist f g ≤ r ↔ ∀ b, dist (f b) (g b) ≤ r := by
by_cases hr : 0 ≤ r
· exact dist_pi_le_iff hr
· exact iff_of_false (fun h => hr <| dist_nonneg.trans h) fun h =>
hr <| dist_nonneg.trans <| h <| Classical.arbitrary _
lemma dist_pi_const_le (a b : α) : (dist (fun _ : β => a) fun _ => b) ≤ dist a b :=
(dist_pi_le_iff dist_nonneg).2 fun _ => le_rfl
lemma nndist_pi_const_le (a b : α) : (nndist (fun _ : β => a) fun _ => b) ≤ nndist a b :=
nndist_pi_le_iff.2 fun _ => le_rfl
@[simp]
lemma dist_pi_const [Nonempty β] (a b : α) : (dist (fun _ : β => a) fun _ => b) = dist a b := by
simpa only [dist_edist] using congr_arg ENNReal.toReal (edist_pi_const a b)
@[simp]
lemma nndist_pi_const [Nonempty β] (a b : α) : (nndist (fun _ : β => a) fun _ => b) = nndist a b :=
NNReal.eq <| dist_pi_const a b
lemma nndist_le_pi_nndist (f g : ∀ b, π b) (b : β) : nndist (f b) (g b) ≤ nndist f g := by
rw [← ENNReal.coe_le_coe, ← edist_nndist, ← edist_nndist]
exact edist_le_pi_edist f g b
lemma dist_le_pi_dist (f g : ∀ b, π b) (b : β) : dist (f b) (g b) ≤ dist f g := by
simp only [dist_nndist, NNReal.coe_le_coe, nndist_le_pi_nndist f g b]
/-- An open ball in a product space is a product of open balls. See also `ball_pi'`
for a version assuming `Nonempty β` instead of `0 < r`. -/
lemma ball_pi (x : ∀ b, π b) {r : ℝ} (hr : 0 < r) :
ball x r = Set.pi univ fun b => ball (x b) r := by
ext p
simp [dist_pi_lt_iff hr]
/-- An open ball in a product space is a product of open balls. See also `ball_pi`
for a version assuming `0 < r` instead of `Nonempty β`. -/
lemma ball_pi' [Nonempty β] (x : ∀ b, π b) (r : ℝ) :
ball x r = Set.pi univ fun b => ball (x b) r :=
(lt_or_le 0 r).elim (ball_pi x) fun hr => by simp [ball_eq_empty.2 hr]
/-- A closed ball in a product space is a product of closed balls. See also `closedBall_pi'`
for a version assuming `Nonempty β` instead of `0 ≤ r`. -/
lemma closedBall_pi (x : ∀ b, π b) {r : ℝ} (hr : 0 ≤ r) :
closedBall x r = Set.pi univ fun b => closedBall (x b) r := by
ext p
simp [dist_pi_le_iff hr]
/-- A closed ball in a product space is a product of closed balls. See also `closedBall_pi`
for a version assuming `0 ≤ r` instead of `Nonempty β`. -/
lemma closedBall_pi' [Nonempty β] (x : ∀ b, π b) (r : ℝ) :
closedBall x r = Set.pi univ fun b => closedBall (x b) r :=
(le_or_lt 0 r).elim (closedBall_pi x) fun hr => by simp [closedBall_eq_empty.2 hr]
/-- A sphere in a product space is a union of spheres on each component restricted to the closed
ball. -/
lemma sphere_pi (x : ∀ b, π b) {r : ℝ} (h : 0 < r ∨ Nonempty β) :
sphere x r = (⋃ i : β, Function.eval i ⁻¹' sphere (x i) r) ∩ closedBall x r := by
obtain hr | rfl | hr := lt_trichotomy r 0
· simp [hr]
· rw [closedBall_eq_sphere_of_nonpos le_rfl, eq_comm, Set.inter_eq_right]
letI := h.resolve_left (lt_irrefl _)
inhabit β
refine subset_iUnion_of_subset default ?_
intro x hx
replace hx := hx.le
rw [dist_pi_le_iff le_rfl] at hx
exact le_antisymm (hx default) dist_nonneg
· ext
simp [dist_pi_eq_iff hr, dist_pi_le_iff hr.le]
@[simp]
lemma Fin.nndist_insertNth_insertNth {n : ℕ} {α : Fin (n + 1) → Type*}
[∀ i, PseudoMetricSpace (α i)] (i : Fin (n + 1)) (x y : α i) (f g : ∀ j, α (i.succAbove j)) :
nndist (i.insertNth x f) (i.insertNth y g) = max (nndist x y) (nndist f g) :=
eq_of_forall_ge_iff fun c => by simp [nndist_pi_le_iff, i.forall_iff_succAbove]
@[simp]
lemma Fin.dist_insertNth_insertNth {n : ℕ} {α : Fin (n + 1) → Type*}
[∀ i, PseudoMetricSpace (α i)] (i : Fin (n + 1)) (x y : α i) (f g : ∀ j, α (i.succAbove j)) :
dist (i.insertNth x f) (i.insertNth y g) = max (dist x y) (dist f g) := by
simp only [dist_nndist, Fin.nndist_insertNth_insertNth, NNReal.coe_max]
end Pi
instance : PseudoMetricSpace (Additive α) := ‹_›
instance : PseudoMetricSpace (Multiplicative α) := ‹_›
instance : PseudoMetricSpace αᵒᵈ := ‹_›
|
Topology\MetricSpace\Pseudo\Defs.lean | /-
Copyright (c) 2015, 2017 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Robert Y. Lewis, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel
-/
import Mathlib.Topology.EMetricSpace.Basic
import Mathlib.Tactic.Bound.Attribute
/-!
## Pseudo-metric spaces
This file defines pseudo-metric spaces: these differ from metric spaces by not imposing the
condition `dist x y = 0 → x = y`.
Many definitions and theorems expected on (pseudo-)metric spaces are already introduced on uniform
spaces and topological spaces. For example: open and closed sets, compactness, completeness,
continuity and uniform continuity.
## Main definitions
* `Dist α`: Endows a space `α` with a function `dist a b`.
* `PseudoMetricSpace α`: A space endowed with a distance function, which can
be zero even if the two elements are non-equal.
* `Metric.ball x ε`: The set of all points `y` with `dist y x < ε`.
* `Metric.Bounded s`: Whether a subset of a `PseudoMetricSpace` is bounded.
* `MetricSpace α`: A `PseudoMetricSpace` with the guarantee `dist x y = 0 → x = y`.
Additional useful definitions:
* `nndist a b`: `dist` as a function to the non-negative reals.
* `Metric.closedBall x ε`: The set of all points `y` with `dist y x ≤ ε`.
* `Metric.sphere x ε`: The set of all points `y` with `dist y x = ε`.
TODO (anyone): Add "Main results" section.
## Tags
pseudo_metric, dist
-/
open Set Filter TopologicalSpace Bornology
open scoped ENNReal NNReal Uniformity Topology
universe u v w
variable {α : Type u} {β : Type v} {X ι : Type*}
theorem UniformSpace.ofDist_aux (ε : ℝ) (hε : 0 < ε) : ∃ δ > (0 : ℝ), ∀ x < δ, ∀ y < δ, x + y < ε :=
⟨ε / 2, half_pos hε, fun _x hx _y hy => add_halves ε ▸ add_lt_add hx hy⟩
/-- Construct a uniform structure from a distance function and metric space axioms -/
def UniformSpace.ofDist (dist : α → α → ℝ) (dist_self : ∀ x : α, dist x x = 0)
(dist_comm : ∀ x y : α, dist x y = dist y x)
(dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z) : UniformSpace α :=
.ofFun dist dist_self dist_comm dist_triangle ofDist_aux
-- Porting note: dropped the `dist_self` argument
/-- Construct a bornology from a distance function and metric space axioms. -/
abbrev Bornology.ofDist {α : Type*} (dist : α → α → ℝ) (dist_comm : ∀ x y, dist x y = dist y x)
(dist_triangle : ∀ x y z, dist x z ≤ dist x y + dist y z) : Bornology α :=
Bornology.ofBounded { s : Set α | ∃ C, ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → dist x y ≤ C }
⟨0, fun x hx y => hx.elim⟩ (fun s ⟨c, hc⟩ t h => ⟨c, fun x hx y hy => hc (h hx) (h hy)⟩)
(fun s hs t ht => by
rcases s.eq_empty_or_nonempty with rfl | ⟨x, hx⟩
· rwa [empty_union]
rcases t.eq_empty_or_nonempty with rfl | ⟨y, hy⟩
· rwa [union_empty]
rsuffices ⟨C, hC⟩ : ∃ C, ∀ z ∈ s ∪ t, dist x z ≤ C
· refine ⟨C + C, fun a ha b hb => (dist_triangle a x b).trans ?_⟩
simpa only [dist_comm] using add_le_add (hC _ ha) (hC _ hb)
rcases hs with ⟨Cs, hs⟩; rcases ht with ⟨Ct, ht⟩
refine ⟨max Cs (dist x y + Ct), fun z hz => hz.elim
(fun hz => (hs hx hz).trans (le_max_left _ _))
(fun hz => (dist_triangle x y z).trans <|
(add_le_add le_rfl (ht hy hz)).trans (le_max_right _ _))⟩)
fun z => ⟨dist z z, forall_eq.2 <| forall_eq.2 le_rfl⟩
/-- The distance function (given an ambient metric space on `α`), which returns
a nonnegative real number `dist x y` given `x y : α`. -/
@[ext]
class Dist (α : Type*) where
dist : α → α → ℝ
export Dist (dist)
-- the uniform structure and the emetric space structure are embedded in the metric space structure
-- to avoid instance diamond issues. See Note [forgetful inheritance].
/-- This is an internal lemma used inside the default of `PseudoMetricSpace.edist`. -/
private theorem dist_nonneg' {α} {x y : α} (dist : α → α → ℝ)
(dist_self : ∀ x : α, dist x x = 0) (dist_comm : ∀ x y : α, dist x y = dist y x)
(dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z) : 0 ≤ dist x y :=
have : 0 ≤ 2 * dist x y :=
calc 0 = dist x x := (dist_self _).symm
_ ≤ dist x y + dist y x := dist_triangle _ _ _
_ = 2 * dist x y := by rw [two_mul, dist_comm]
nonneg_of_mul_nonneg_right this two_pos
/-- Pseudo metric and Metric spaces
A pseudo metric space is endowed with a distance for which the requirement `d(x,y)=0 → x = y` might
not hold. A metric space is a pseudo metric space such that `d(x,y)=0 → x = y`.
Each pseudo metric space induces a canonical `UniformSpace` and hence a canonical
`TopologicalSpace` This is enforced in the type class definition, by extending the `UniformSpace`
structure. When instantiating a `PseudoMetricSpace` structure, the uniformity fields are not
necessary, they will be filled in by default. In the same way, each (pseudo) metric space induces a
(pseudo) emetric space structure. It is included in the structure, but filled in by default.
-/
class PseudoMetricSpace (α : Type u) extends Dist α : Type u where
dist_self : ∀ x : α, dist x x = 0
dist_comm : ∀ x y : α, dist x y = dist y x
dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z
edist : α → α → ℝ≥0∞ := fun x y => ENNReal.ofNNReal ⟨dist x y, dist_nonneg' _ ‹_› ‹_› ‹_›⟩
edist_dist : ∀ x y : α, edist x y = ENNReal.ofReal (dist x y) := by
intros x y; exact ENNReal.coe_nnreal_eq _
toUniformSpace : UniformSpace α := .ofDist dist dist_self dist_comm dist_triangle
uniformity_dist : 𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α | dist p.1 p.2 < ε } := by intros; rfl
toBornology : Bornology α := Bornology.ofDist dist dist_comm dist_triangle
cobounded_sets : (Bornology.cobounded α).sets =
{ s | ∃ C : ℝ, ∀ x ∈ sᶜ, ∀ y ∈ sᶜ, dist x y ≤ C } := by intros; rfl
/-- Two pseudo metric space structures with the same distance function coincide. -/
@[ext]
theorem PseudoMetricSpace.ext {α : Type*} {m m' : PseudoMetricSpace α}
(h : m.toDist = m'.toDist) : m = m' := by
cases' m with d _ _ _ ed hed U hU B hB
cases' m' with d' _ _ _ ed' hed' U' hU' B' hB'
obtain rfl : d = d' := h
congr
· ext x y : 2
rw [hed, hed']
· exact UniformSpace.ext (hU.trans hU'.symm)
· ext : 2
rw [← Filter.mem_sets, ← Filter.mem_sets, hB, hB']
variable [PseudoMetricSpace α]
attribute [instance] PseudoMetricSpace.toUniformSpace PseudoMetricSpace.toBornology
-- see Note [lower instance priority]
instance (priority := 200) PseudoMetricSpace.toEDist : EDist α :=
⟨PseudoMetricSpace.edist⟩
/-- Construct a pseudo-metric space structure whose underlying topological space structure
(definitionally) agrees which a pre-existing topology which is compatible with a given distance
function. -/
def PseudoMetricSpace.ofDistTopology {α : Type u} [TopologicalSpace α] (dist : α → α → ℝ)
(dist_self : ∀ x : α, dist x x = 0) (dist_comm : ∀ x y : α, dist x y = dist y x)
(dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z)
(H : ∀ s : Set α, IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, ∀ y, dist x y < ε → y ∈ s) :
PseudoMetricSpace α :=
{ dist := dist
dist_self := dist_self
dist_comm := dist_comm
dist_triangle := dist_triangle
toUniformSpace :=
(UniformSpace.ofDist dist dist_self dist_comm dist_triangle).replaceTopology <|
TopologicalSpace.ext_iff.2 fun s ↦ (H s).trans <| forall₂_congr fun x _ ↦
((UniformSpace.hasBasis_ofFun (exists_gt (0 : ℝ)) dist dist_self dist_comm dist_triangle
UniformSpace.ofDist_aux).comap (Prod.mk x)).mem_iff.symm
uniformity_dist := rfl
toBornology := Bornology.ofDist dist dist_comm dist_triangle
cobounded_sets := rfl }
@[simp]
theorem dist_self (x : α) : dist x x = 0 :=
PseudoMetricSpace.dist_self x
theorem dist_comm (x y : α) : dist x y = dist y x :=
PseudoMetricSpace.dist_comm x y
theorem edist_dist (x y : α) : edist x y = ENNReal.ofReal (dist x y) :=
PseudoMetricSpace.edist_dist x y
@[bound]
theorem dist_triangle (x y z : α) : dist x z ≤ dist x y + dist y z :=
PseudoMetricSpace.dist_triangle x y z
theorem dist_triangle_left (x y z : α) : dist x y ≤ dist z x + dist z y := by
rw [dist_comm z]; apply dist_triangle
theorem dist_triangle_right (x y z : α) : dist x y ≤ dist x z + dist y z := by
rw [dist_comm y]; apply dist_triangle
theorem dist_triangle4 (x y z w : α) : dist x w ≤ dist x y + dist y z + dist z w :=
calc
dist x w ≤ dist x z + dist z w := dist_triangle x z w
_ ≤ dist x y + dist y z + dist z w := add_le_add_right (dist_triangle x y z) _
theorem dist_triangle4_left (x₁ y₁ x₂ y₂ : α) :
dist x₂ y₂ ≤ dist x₁ y₁ + (dist x₁ x₂ + dist y₁ y₂) := by
rw [add_left_comm, dist_comm x₁, ← add_assoc]
apply dist_triangle4
theorem dist_triangle4_right (x₁ y₁ x₂ y₂ : α) :
dist x₁ y₁ ≤ dist x₁ x₂ + dist y₁ y₂ + dist x₂ y₂ := by
rw [add_right_comm, dist_comm y₁]
apply dist_triangle4
/-- The triangle (polygon) inequality for sequences of points; `Finset.Ico` version. -/
theorem dist_le_Ico_sum_dist (f : ℕ → α) {m n} (h : m ≤ n) :
dist (f m) (f n) ≤ ∑ i ∈ Finset.Ico m n, dist (f i) (f (i + 1)) := by
induction n, h using Nat.le_induction with
| base => rw [Finset.Ico_self, Finset.sum_empty, dist_self]
| succ n hle ihn =>
calc
dist (f m) (f (n + 1)) ≤ dist (f m) (f n) + dist (f n) (f (n + 1)) := dist_triangle _ _ _
_ ≤ (∑ i ∈ Finset.Ico m n, _) + _ := add_le_add ihn le_rfl
_ = ∑ i ∈ Finset.Ico m (n + 1), _ := by
{ rw [Nat.Ico_succ_right_eq_insert_Ico hle, Finset.sum_insert, add_comm]; simp }
/-- The triangle (polygon) inequality for sequences of points; `Finset.range` version. -/
theorem dist_le_range_sum_dist (f : ℕ → α) (n : ℕ) :
dist (f 0) (f n) ≤ ∑ i ∈ Finset.range n, dist (f i) (f (i + 1)) :=
Nat.Ico_zero_eq_range ▸ dist_le_Ico_sum_dist f (Nat.zero_le n)
/-- A version of `dist_le_Ico_sum_dist` with each intermediate distance replaced
with an upper estimate. -/
theorem dist_le_Ico_sum_of_dist_le {f : ℕ → α} {m n} (hmn : m ≤ n) {d : ℕ → ℝ}
(hd : ∀ {k}, m ≤ k → k < n → dist (f k) (f (k + 1)) ≤ d k) :
dist (f m) (f n) ≤ ∑ i ∈ Finset.Ico m n, d i :=
le_trans (dist_le_Ico_sum_dist f hmn) <|
Finset.sum_le_sum fun _k hk => hd (Finset.mem_Ico.1 hk).1 (Finset.mem_Ico.1 hk).2
/-- A version of `dist_le_range_sum_dist` with each intermediate distance replaced
with an upper estimate. -/
theorem dist_le_range_sum_of_dist_le {f : ℕ → α} (n : ℕ) {d : ℕ → ℝ}
(hd : ∀ {k}, k < n → dist (f k) (f (k + 1)) ≤ d k) :
dist (f 0) (f n) ≤ ∑ i ∈ Finset.range n, d i :=
Nat.Ico_zero_eq_range ▸ dist_le_Ico_sum_of_dist_le (zero_le n) fun _ => hd
theorem swap_dist : Function.swap (@dist α _) = dist := by funext x y; exact dist_comm _ _
theorem abs_dist_sub_le (x y z : α) : |dist x z - dist y z| ≤ dist x y :=
abs_sub_le_iff.2
⟨sub_le_iff_le_add.2 (dist_triangle _ _ _), sub_le_iff_le_add.2 (dist_triangle_left _ _ _)⟩
@[bound]
theorem dist_nonneg {x y : α} : 0 ≤ dist x y :=
dist_nonneg' dist dist_self dist_comm dist_triangle
namespace Mathlib.Meta.Positivity
open Lean Meta Qq Function
/-- Extension for the `positivity` tactic: distances are nonnegative. -/
@[positivity Dist.dist _ _]
def evalDist : PositivityExt where eval {u α} _zα _pα e := do
match u, α, e with
| 0, ~q(ℝ), ~q(@Dist.dist $β $inst $a $b) =>
let _inst ← synthInstanceQ q(PseudoMetricSpace $β)
assertInstancesCommute
pure (.nonnegative q(dist_nonneg))
| _, _, _ => throwError "not dist"
end Mathlib.Meta.Positivity
example {x y : α} : 0 ≤ dist x y := by positivity
@[simp] theorem abs_dist {a b : α} : |dist a b| = dist a b := abs_of_nonneg dist_nonneg
/-- A version of `Dist` that takes value in `ℝ≥0`. -/
class NNDist (α : Type*) where
nndist : α → α → ℝ≥0
export NNDist (nndist)
-- see Note [lower instance priority]
/-- Distance as a nonnegative real number. -/
instance (priority := 100) PseudoMetricSpace.toNNDist : NNDist α :=
⟨fun a b => ⟨dist a b, dist_nonneg⟩⟩
/-- Express `dist` in terms of `nndist`-/
theorem dist_nndist (x y : α) : dist x y = nndist x y := rfl
@[simp, norm_cast]
theorem coe_nndist (x y : α) : ↑(nndist x y) = dist x y := rfl
/-- Express `edist` in terms of `nndist`-/
theorem edist_nndist (x y : α) : edist x y = nndist x y := by
rw [edist_dist, dist_nndist, ENNReal.ofReal_coe_nnreal]
/-- Express `nndist` in terms of `edist`-/
theorem nndist_edist (x y : α) : nndist x y = (edist x y).toNNReal := by
simp [edist_nndist]
@[simp, norm_cast]
theorem coe_nnreal_ennreal_nndist (x y : α) : ↑(nndist x y) = edist x y :=
(edist_nndist x y).symm
@[simp, norm_cast]
theorem edist_lt_coe {x y : α} {c : ℝ≥0} : edist x y < c ↔ nndist x y < c := by
rw [edist_nndist, ENNReal.coe_lt_coe]
@[simp, norm_cast]
theorem edist_le_coe {x y : α} {c : ℝ≥0} : edist x y ≤ c ↔ nndist x y ≤ c := by
rw [edist_nndist, ENNReal.coe_le_coe]
/-- In a pseudometric space, the extended distance is always finite-/
theorem edist_lt_top {α : Type*} [PseudoMetricSpace α] (x y : α) : edist x y < ⊤ :=
(edist_dist x y).symm ▸ ENNReal.ofReal_lt_top
/-- In a pseudometric space, the extended distance is always finite-/
theorem edist_ne_top (x y : α) : edist x y ≠ ⊤ :=
(edist_lt_top x y).ne
/-- `nndist x x` vanishes-/
@[simp] theorem nndist_self (a : α) : nndist a a = 0 := NNReal.coe_eq_zero.1 (dist_self a)
-- Porting note: `dist_nndist` and `coe_nndist` moved up
@[simp, norm_cast]
theorem dist_lt_coe {x y : α} {c : ℝ≥0} : dist x y < c ↔ nndist x y < c :=
Iff.rfl
@[simp, norm_cast]
theorem dist_le_coe {x y : α} {c : ℝ≥0} : dist x y ≤ c ↔ nndist x y ≤ c :=
Iff.rfl
@[simp]
theorem edist_lt_ofReal {x y : α} {r : ℝ} : edist x y < ENNReal.ofReal r ↔ dist x y < r := by
rw [edist_dist, ENNReal.ofReal_lt_ofReal_iff_of_nonneg dist_nonneg]
@[simp]
theorem edist_le_ofReal {x y : α} {r : ℝ} (hr : 0 ≤ r) :
edist x y ≤ ENNReal.ofReal r ↔ dist x y ≤ r := by
rw [edist_dist, ENNReal.ofReal_le_ofReal_iff hr]
/-- Express `nndist` in terms of `dist`-/
theorem nndist_dist (x y : α) : nndist x y = Real.toNNReal (dist x y) := by
rw [dist_nndist, Real.toNNReal_coe]
theorem nndist_comm (x y : α) : nndist x y = nndist y x := NNReal.eq <| dist_comm x y
/-- Triangle inequality for the nonnegative distance-/
theorem nndist_triangle (x y z : α) : nndist x z ≤ nndist x y + nndist y z :=
dist_triangle _ _ _
theorem nndist_triangle_left (x y z : α) : nndist x y ≤ nndist z x + nndist z y :=
dist_triangle_left _ _ _
theorem nndist_triangle_right (x y z : α) : nndist x y ≤ nndist x z + nndist y z :=
dist_triangle_right _ _ _
/-- Express `dist` in terms of `edist`-/
theorem dist_edist (x y : α) : dist x y = (edist x y).toReal := by
rw [edist_dist, ENNReal.toReal_ofReal dist_nonneg]
namespace Metric
-- instantiate pseudometric space as a topology
variable {x y z : α} {δ ε ε₁ ε₂ : ℝ} {s : Set α}
/-- `ball x ε` is the set of all points `y` with `dist y x < ε` -/
def ball (x : α) (ε : ℝ) : Set α :=
{ y | dist y x < ε }
@[simp]
theorem mem_ball : y ∈ ball x ε ↔ dist y x < ε :=
Iff.rfl
theorem mem_ball' : y ∈ ball x ε ↔ dist x y < ε := by rw [dist_comm, mem_ball]
theorem pos_of_mem_ball (hy : y ∈ ball x ε) : 0 < ε :=
dist_nonneg.trans_lt hy
theorem mem_ball_self (h : 0 < ε) : x ∈ ball x ε := by
rwa [mem_ball, dist_self]
@[simp]
theorem nonempty_ball : (ball x ε).Nonempty ↔ 0 < ε :=
⟨fun ⟨_x, hx⟩ => pos_of_mem_ball hx, fun h => ⟨x, mem_ball_self h⟩⟩
@[simp]
theorem ball_eq_empty : ball x ε = ∅ ↔ ε ≤ 0 := by
rw [← not_nonempty_iff_eq_empty, nonempty_ball, not_lt]
@[simp]
theorem ball_zero : ball x 0 = ∅ := by rw [ball_eq_empty]
/-- If a point belongs to an open ball, then there is a strictly smaller radius whose ball also
contains it.
See also `exists_lt_subset_ball`. -/
theorem exists_lt_mem_ball_of_mem_ball (h : x ∈ ball y ε) : ∃ ε' < ε, x ∈ ball y ε' := by
simp only [mem_ball] at h ⊢
exact ⟨(dist x y + ε) / 2, by linarith, by linarith⟩
theorem ball_eq_ball (ε : ℝ) (x : α) :
UniformSpace.ball x { p | dist p.2 p.1 < ε } = Metric.ball x ε :=
rfl
theorem ball_eq_ball' (ε : ℝ) (x : α) :
UniformSpace.ball x { p | dist p.1 p.2 < ε } = Metric.ball x ε := by
ext
simp [dist_comm, UniformSpace.ball]
@[simp]
theorem iUnion_ball_nat (x : α) : ⋃ n : ℕ, ball x n = univ :=
iUnion_eq_univ_iff.2 fun y => exists_nat_gt (dist y x)
@[simp]
theorem iUnion_ball_nat_succ (x : α) : ⋃ n : ℕ, ball x (n + 1) = univ :=
iUnion_eq_univ_iff.2 fun y => (exists_nat_gt (dist y x)).imp fun _ h => h.trans (lt_add_one _)
/-- `closedBall x ε` is the set of all points `y` with `dist y x ≤ ε` -/
def closedBall (x : α) (ε : ℝ) :=
{ y | dist y x ≤ ε }
@[simp] theorem mem_closedBall : y ∈ closedBall x ε ↔ dist y x ≤ ε := Iff.rfl
theorem mem_closedBall' : y ∈ closedBall x ε ↔ dist x y ≤ ε := by rw [dist_comm, mem_closedBall]
/-- `sphere x ε` is the set of all points `y` with `dist y x = ε` -/
def sphere (x : α) (ε : ℝ) := { y | dist y x = ε }
@[simp] theorem mem_sphere : y ∈ sphere x ε ↔ dist y x = ε := Iff.rfl
theorem mem_sphere' : y ∈ sphere x ε ↔ dist x y = ε := by rw [dist_comm, mem_sphere]
theorem ne_of_mem_sphere (h : y ∈ sphere x ε) (hε : ε ≠ 0) : y ≠ x :=
ne_of_mem_of_not_mem h <| by simpa using hε.symm
theorem nonneg_of_mem_sphere (hy : y ∈ sphere x ε) : 0 ≤ ε :=
dist_nonneg.trans_eq hy
@[simp]
theorem sphere_eq_empty_of_neg (hε : ε < 0) : sphere x ε = ∅ :=
Set.eq_empty_iff_forall_not_mem.mpr fun _y hy => (nonneg_of_mem_sphere hy).not_lt hε
theorem sphere_eq_empty_of_subsingleton [Subsingleton α] (hε : ε ≠ 0) : sphere x ε = ∅ :=
Set.eq_empty_iff_forall_not_mem.mpr fun _ h => ne_of_mem_sphere h hε (Subsingleton.elim _ _)
instance sphere_isEmpty_of_subsingleton [Subsingleton α] [NeZero ε] : IsEmpty (sphere x ε) := by
rw [sphere_eq_empty_of_subsingleton (NeZero.ne ε)]; infer_instance
theorem mem_closedBall_self (h : 0 ≤ ε) : x ∈ closedBall x ε := by
rwa [mem_closedBall, dist_self]
@[simp]
theorem nonempty_closedBall : (closedBall x ε).Nonempty ↔ 0 ≤ ε :=
⟨fun ⟨_x, hx⟩ => dist_nonneg.trans hx, fun h => ⟨x, mem_closedBall_self h⟩⟩
@[simp]
theorem closedBall_eq_empty : closedBall x ε = ∅ ↔ ε < 0 := by
rw [← not_nonempty_iff_eq_empty, nonempty_closedBall, not_le]
/-- Closed balls and spheres coincide when the radius is non-positive -/
theorem closedBall_eq_sphere_of_nonpos (hε : ε ≤ 0) : closedBall x ε = sphere x ε :=
Set.ext fun _ => (hε.trans dist_nonneg).le_iff_eq
theorem ball_subset_closedBall : ball x ε ⊆ closedBall x ε := fun _y hy =>
mem_closedBall.2 (le_of_lt hy)
theorem sphere_subset_closedBall : sphere x ε ⊆ closedBall x ε := fun _ => le_of_eq
lemma sphere_subset_ball {r R : ℝ} (h : r < R) : sphere x r ⊆ ball x R := fun _x hx ↦
(mem_sphere.1 hx).trans_lt h
theorem closedBall_disjoint_ball (h : δ + ε ≤ dist x y) : Disjoint (closedBall x δ) (ball y ε) :=
Set.disjoint_left.mpr fun _a ha1 ha2 =>
(h.trans <| dist_triangle_left _ _ _).not_lt <| add_lt_add_of_le_of_lt ha1 ha2
theorem ball_disjoint_closedBall (h : δ + ε ≤ dist x y) : Disjoint (ball x δ) (closedBall y ε) :=
(closedBall_disjoint_ball <| by rwa [add_comm, dist_comm]).symm
theorem ball_disjoint_ball (h : δ + ε ≤ dist x y) : Disjoint (ball x δ) (ball y ε) :=
(closedBall_disjoint_ball h).mono_left ball_subset_closedBall
theorem closedBall_disjoint_closedBall (h : δ + ε < dist x y) :
Disjoint (closedBall x δ) (closedBall y ε) :=
Set.disjoint_left.mpr fun _a ha1 ha2 =>
h.not_le <| (dist_triangle_left _ _ _).trans <| add_le_add ha1 ha2
theorem sphere_disjoint_ball : Disjoint (sphere x ε) (ball x ε) :=
Set.disjoint_left.mpr fun _y hy₁ hy₂ => absurd hy₁ <| ne_of_lt hy₂
@[simp]
theorem ball_union_sphere : ball x ε ∪ sphere x ε = closedBall x ε :=
Set.ext fun _y => (@le_iff_lt_or_eq ℝ _ _ _).symm
@[simp]
theorem sphere_union_ball : sphere x ε ∪ ball x ε = closedBall x ε := by
rw [union_comm, ball_union_sphere]
@[simp]
theorem closedBall_diff_sphere : closedBall x ε \ sphere x ε = ball x ε := by
rw [← ball_union_sphere, Set.union_diff_cancel_right sphere_disjoint_ball.symm.le_bot]
@[simp]
theorem closedBall_diff_ball : closedBall x ε \ ball x ε = sphere x ε := by
rw [← ball_union_sphere, Set.union_diff_cancel_left sphere_disjoint_ball.symm.le_bot]
theorem mem_ball_comm : x ∈ ball y ε ↔ y ∈ ball x ε := by rw [mem_ball', mem_ball]
theorem mem_closedBall_comm : x ∈ closedBall y ε ↔ y ∈ closedBall x ε := by
rw [mem_closedBall', mem_closedBall]
theorem mem_sphere_comm : x ∈ sphere y ε ↔ y ∈ sphere x ε := by rw [mem_sphere', mem_sphere]
@[gcongr]
theorem ball_subset_ball (h : ε₁ ≤ ε₂) : ball x ε₁ ⊆ ball x ε₂ := fun _y yx =>
lt_of_lt_of_le (mem_ball.1 yx) h
theorem closedBall_eq_bInter_ball : closedBall x ε = ⋂ δ > ε, ball x δ := by
ext y; rw [mem_closedBall, ← forall_lt_iff_le', mem_iInter₂]; rfl
theorem ball_subset_ball' (h : ε₁ + dist x y ≤ ε₂) : ball x ε₁ ⊆ ball y ε₂ := fun z hz =>
calc
dist z y ≤ dist z x + dist x y := dist_triangle _ _ _
_ < ε₁ + dist x y := add_lt_add_right (mem_ball.1 hz) _
_ ≤ ε₂ := h
@[gcongr]
theorem closedBall_subset_closedBall (h : ε₁ ≤ ε₂) : closedBall x ε₁ ⊆ closedBall x ε₂ :=
fun _y (yx : _ ≤ ε₁) => le_trans yx h
theorem closedBall_subset_closedBall' (h : ε₁ + dist x y ≤ ε₂) :
closedBall x ε₁ ⊆ closedBall y ε₂ := fun z hz =>
calc
dist z y ≤ dist z x + dist x y := dist_triangle _ _ _
_ ≤ ε₁ + dist x y := add_le_add_right (mem_closedBall.1 hz) _
_ ≤ ε₂ := h
theorem closedBall_subset_ball (h : ε₁ < ε₂) : closedBall x ε₁ ⊆ ball x ε₂ :=
fun y (yh : dist y x ≤ ε₁) => lt_of_le_of_lt yh h
theorem closedBall_subset_ball' (h : ε₁ + dist x y < ε₂) :
closedBall x ε₁ ⊆ ball y ε₂ := fun z hz =>
calc
dist z y ≤ dist z x + dist x y := dist_triangle _ _ _
_ ≤ ε₁ + dist x y := add_le_add_right (mem_closedBall.1 hz) _
_ < ε₂ := h
theorem dist_le_add_of_nonempty_closedBall_inter_closedBall
(h : (closedBall x ε₁ ∩ closedBall y ε₂).Nonempty) : dist x y ≤ ε₁ + ε₂ :=
let ⟨z, hz⟩ := h
calc
dist x y ≤ dist z x + dist z y := dist_triangle_left _ _ _
_ ≤ ε₁ + ε₂ := add_le_add hz.1 hz.2
theorem dist_lt_add_of_nonempty_closedBall_inter_ball (h : (closedBall x ε₁ ∩ ball y ε₂).Nonempty) :
dist x y < ε₁ + ε₂ :=
let ⟨z, hz⟩ := h
calc
dist x y ≤ dist z x + dist z y := dist_triangle_left _ _ _
_ < ε₁ + ε₂ := add_lt_add_of_le_of_lt hz.1 hz.2
theorem dist_lt_add_of_nonempty_ball_inter_closedBall (h : (ball x ε₁ ∩ closedBall y ε₂).Nonempty) :
dist x y < ε₁ + ε₂ := by
rw [inter_comm] at h
rw [add_comm, dist_comm]
exact dist_lt_add_of_nonempty_closedBall_inter_ball h
theorem dist_lt_add_of_nonempty_ball_inter_ball (h : (ball x ε₁ ∩ ball y ε₂).Nonempty) :
dist x y < ε₁ + ε₂ :=
dist_lt_add_of_nonempty_closedBall_inter_ball <|
h.mono (inter_subset_inter ball_subset_closedBall Subset.rfl)
@[simp]
theorem iUnion_closedBall_nat (x : α) : ⋃ n : ℕ, closedBall x n = univ :=
iUnion_eq_univ_iff.2 fun y => exists_nat_ge (dist y x)
theorem iUnion_inter_closedBall_nat (s : Set α) (x : α) : ⋃ n : ℕ, s ∩ closedBall x n = s := by
rw [← inter_iUnion, iUnion_closedBall_nat, inter_univ]
theorem ball_subset (h : dist x y ≤ ε₂ - ε₁) : ball x ε₁ ⊆ ball y ε₂ := fun z zx => by
rw [← add_sub_cancel ε₁ ε₂]
exact lt_of_le_of_lt (dist_triangle z x y) (add_lt_add_of_lt_of_le zx h)
theorem ball_half_subset (y) (h : y ∈ ball x (ε / 2)) : ball y (ε / 2) ⊆ ball x ε :=
ball_subset <| by rw [sub_self_div_two]; exact le_of_lt h
theorem exists_ball_subset_ball (h : y ∈ ball x ε) : ∃ ε' > 0, ball y ε' ⊆ ball x ε :=
⟨_, sub_pos.2 h, ball_subset <| by rw [sub_sub_self]⟩
/-- If a property holds for all points in closed balls of arbitrarily large radii, then it holds for
all points. -/
theorem forall_of_forall_mem_closedBall (p : α → Prop) (x : α)
(H : ∃ᶠ R : ℝ in atTop, ∀ y ∈ closedBall x R, p y) (y : α) : p y := by
obtain ⟨R, hR, h⟩ : ∃ R ≥ dist y x, ∀ z : α, z ∈ closedBall x R → p z :=
frequently_iff.1 H (Ici_mem_atTop (dist y x))
exact h _ hR
/-- If a property holds for all points in balls of arbitrarily large radii, then it holds for all
points. -/
theorem forall_of_forall_mem_ball (p : α → Prop) (x : α)
(H : ∃ᶠ R : ℝ in atTop, ∀ y ∈ ball x R, p y) (y : α) : p y := by
obtain ⟨R, hR, h⟩ : ∃ R > dist y x, ∀ z : α, z ∈ ball x R → p z :=
frequently_iff.1 H (Ioi_mem_atTop (dist y x))
exact h _ hR
theorem isBounded_iff {s : Set α} :
IsBounded s ↔ ∃ C : ℝ, ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → dist x y ≤ C := by
rw [isBounded_def, ← Filter.mem_sets, @PseudoMetricSpace.cobounded_sets α, mem_setOf_eq,
compl_compl]
theorem isBounded_iff_eventually {s : Set α} :
IsBounded s ↔ ∀ᶠ C in atTop, ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → dist x y ≤ C :=
isBounded_iff.trans
⟨fun ⟨C, h⟩ => eventually_atTop.2 ⟨C, fun _C' hC' _x hx _y hy => (h hx hy).trans hC'⟩,
Eventually.exists⟩
theorem isBounded_iff_exists_ge {s : Set α} (c : ℝ) :
IsBounded s ↔ ∃ C, c ≤ C ∧ ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → dist x y ≤ C :=
⟨fun h => ((eventually_ge_atTop c).and (isBounded_iff_eventually.1 h)).exists, fun h =>
isBounded_iff.2 <| h.imp fun _ => And.right⟩
theorem isBounded_iff_nndist {s : Set α} :
IsBounded s ↔ ∃ C : ℝ≥0, ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → nndist x y ≤ C := by
simp only [isBounded_iff_exists_ge 0, NNReal.exists, ← NNReal.coe_le_coe, ← dist_nndist,
NNReal.coe_mk, exists_prop]
theorem toUniformSpace_eq :
‹PseudoMetricSpace α›.toUniformSpace = .ofDist dist dist_self dist_comm dist_triangle :=
UniformSpace.ext PseudoMetricSpace.uniformity_dist
theorem uniformity_basis_dist :
(𝓤 α).HasBasis (fun ε : ℝ => 0 < ε) fun ε => { p : α × α | dist p.1 p.2 < ε } := by
rw [toUniformSpace_eq]
exact UniformSpace.hasBasis_ofFun (exists_gt _) _ _ _ _ _
/-- Given `f : β → ℝ`, if `f` sends `{i | p i}` to a set of positive numbers
accumulating to zero, then `f i`-neighborhoods of the diagonal form a basis of `𝓤 α`.
For specific bases see `uniformity_basis_dist`, `uniformity_basis_dist_inv_nat_succ`,
and `uniformity_basis_dist_inv_nat_pos`. -/
protected theorem mk_uniformity_basis {β : Type*} {p : β → Prop} {f : β → ℝ}
(hf₀ : ∀ i, p i → 0 < f i) (hf : ∀ ⦃ε⦄, 0 < ε → ∃ i, p i ∧ f i ≤ ε) :
(𝓤 α).HasBasis p fun i => { p : α × α | dist p.1 p.2 < f i } := by
refine ⟨fun s => uniformity_basis_dist.mem_iff.trans ?_⟩
constructor
· rintro ⟨ε, ε₀, hε⟩
rcases hf ε₀ with ⟨i, hi, H⟩
exact ⟨i, hi, fun x (hx : _ < _) => hε <| lt_of_lt_of_le hx H⟩
· exact fun ⟨i, hi, H⟩ => ⟨f i, hf₀ i hi, H⟩
theorem uniformity_basis_dist_rat :
(𝓤 α).HasBasis (fun r : ℚ => 0 < r) fun r => { p : α × α | dist p.1 p.2 < r } :=
Metric.mk_uniformity_basis (fun _ => Rat.cast_pos.2) fun _ε hε =>
let ⟨r, hr0, hrε⟩ := exists_rat_btwn hε
⟨r, Rat.cast_pos.1 hr0, hrε.le⟩
theorem uniformity_basis_dist_inv_nat_succ :
(𝓤 α).HasBasis (fun _ => True) fun n : ℕ => { p : α × α | dist p.1 p.2 < 1 / (↑n + 1) } :=
Metric.mk_uniformity_basis (fun n _ => div_pos zero_lt_one <| Nat.cast_add_one_pos n) fun _ε ε0 =>
(exists_nat_one_div_lt ε0).imp fun _n hn => ⟨trivial, le_of_lt hn⟩
theorem uniformity_basis_dist_inv_nat_pos :
(𝓤 α).HasBasis (fun n : ℕ => 0 < n) fun n : ℕ => { p : α × α | dist p.1 p.2 < 1 / ↑n } :=
Metric.mk_uniformity_basis (fun _ hn => div_pos zero_lt_one <| Nat.cast_pos.2 hn) fun _ ε0 =>
let ⟨n, hn⟩ := exists_nat_one_div_lt ε0
⟨n + 1, Nat.succ_pos n, mod_cast hn.le⟩
theorem uniformity_basis_dist_pow {r : ℝ} (h0 : 0 < r) (h1 : r < 1) :
(𝓤 α).HasBasis (fun _ : ℕ => True) fun n : ℕ => { p : α × α | dist p.1 p.2 < r ^ n } :=
Metric.mk_uniformity_basis (fun _ _ => pow_pos h0 _) fun _ε ε0 =>
let ⟨n, hn⟩ := exists_pow_lt_of_lt_one ε0 h1
⟨n, trivial, hn.le⟩
theorem uniformity_basis_dist_lt {R : ℝ} (hR : 0 < R) :
(𝓤 α).HasBasis (fun r : ℝ => 0 < r ∧ r < R) fun r => { p : α × α | dist p.1 p.2 < r } :=
Metric.mk_uniformity_basis (fun _ => And.left) fun r hr =>
⟨min r (R / 2), ⟨lt_min hr (half_pos hR), min_lt_iff.2 <| Or.inr (half_lt_self hR)⟩,
min_le_left _ _⟩
/-- Given `f : β → ℝ`, if `f` sends `{i | p i}` to a set of positive numbers
accumulating to zero, then closed neighborhoods of the diagonal of sizes `{f i | p i}`
form a basis of `𝓤 α`.
Currently we have only one specific basis `uniformity_basis_dist_le` based on this constructor.
More can be easily added if needed in the future. -/
protected theorem mk_uniformity_basis_le {β : Type*} {p : β → Prop} {f : β → ℝ}
(hf₀ : ∀ x, p x → 0 < f x) (hf : ∀ ε, 0 < ε → ∃ x, p x ∧ f x ≤ ε) :
(𝓤 α).HasBasis p fun x => { p : α × α | dist p.1 p.2 ≤ f x } := by
refine ⟨fun s => uniformity_basis_dist.mem_iff.trans ?_⟩
constructor
· rintro ⟨ε, ε₀, hε⟩
rcases exists_between ε₀ with ⟨ε', hε'⟩
rcases hf ε' hε'.1 with ⟨i, hi, H⟩
exact ⟨i, hi, fun x (hx : _ ≤ _) => hε <| lt_of_le_of_lt (le_trans hx H) hε'.2⟩
· exact fun ⟨i, hi, H⟩ => ⟨f i, hf₀ i hi, fun x (hx : _ < _) => H (mem_setOf.2 hx.le)⟩
/-- Constant size closed neighborhoods of the diagonal form a basis
of the uniformity filter. -/
theorem uniformity_basis_dist_le :
(𝓤 α).HasBasis ((0 : ℝ) < ·) fun ε => { p : α × α | dist p.1 p.2 ≤ ε } :=
Metric.mk_uniformity_basis_le (fun _ => id) fun ε ε₀ => ⟨ε, ε₀, le_refl ε⟩
theorem uniformity_basis_dist_le_pow {r : ℝ} (h0 : 0 < r) (h1 : r < 1) :
(𝓤 α).HasBasis (fun _ : ℕ => True) fun n : ℕ => { p : α × α | dist p.1 p.2 ≤ r ^ n } :=
Metric.mk_uniformity_basis_le (fun _ _ => pow_pos h0 _) fun _ε ε0 =>
let ⟨n, hn⟩ := exists_pow_lt_of_lt_one ε0 h1
⟨n, trivial, hn.le⟩
theorem mem_uniformity_dist {s : Set (α × α)} :
s ∈ 𝓤 α ↔ ∃ ε > 0, ∀ {a b : α}, dist a b < ε → (a, b) ∈ s :=
uniformity_basis_dist.mem_uniformity_iff
/-- A constant size neighborhood of the diagonal is an entourage. -/
theorem dist_mem_uniformity {ε : ℝ} (ε0 : 0 < ε) : { p : α × α | dist p.1 p.2 < ε } ∈ 𝓤 α :=
mem_uniformity_dist.2 ⟨ε, ε0, id⟩
theorem uniformContinuous_iff [PseudoMetricSpace β] {f : α → β} :
UniformContinuous f ↔ ∀ ε > 0, ∃ δ > 0, ∀ {a b : α}, dist a b < δ → dist (f a) (f b) < ε :=
uniformity_basis_dist.uniformContinuous_iff uniformity_basis_dist
theorem uniformContinuousOn_iff [PseudoMetricSpace β] {f : α → β} {s : Set α} :
UniformContinuousOn f s ↔
∀ ε > 0, ∃ δ > 0, ∀ x ∈ s, ∀ y ∈ s, dist x y < δ → dist (f x) (f y) < ε :=
Metric.uniformity_basis_dist.uniformContinuousOn_iff Metric.uniformity_basis_dist
theorem uniformContinuousOn_iff_le [PseudoMetricSpace β] {f : α → β} {s : Set α} :
UniformContinuousOn f s ↔
∀ ε > 0, ∃ δ > 0, ∀ x ∈ s, ∀ y ∈ s, dist x y ≤ δ → dist (f x) (f y) ≤ ε :=
Metric.uniformity_basis_dist_le.uniformContinuousOn_iff Metric.uniformity_basis_dist_le
nonrec theorem uniformInducing_iff [PseudoMetricSpace β] {f : α → β} :
UniformInducing f ↔ UniformContinuous f ∧
∀ δ > 0, ∃ ε > 0, ∀ {a b : α}, dist (f a) (f b) < ε → dist a b < δ :=
uniformInducing_iff'.trans <| Iff.rfl.and <|
((uniformity_basis_dist.comap _).le_basis_iff uniformity_basis_dist).trans <| by
simp only [subset_def, Prod.forall, gt_iff_lt, preimage_setOf_eq, Prod.map_apply, mem_setOf]
nonrec theorem uniformEmbedding_iff [PseudoMetricSpace β] {f : α → β} :
UniformEmbedding f ↔ Function.Injective f ∧ UniformContinuous f ∧
∀ δ > 0, ∃ ε > 0, ∀ {a b : α}, dist (f a) (f b) < ε → dist a b < δ := by
rw [uniformEmbedding_iff, and_comm, uniformInducing_iff]
/-- If a map between pseudometric spaces is a uniform embedding then the distance between `f x`
and `f y` is controlled in terms of the distance between `x` and `y`. -/
theorem controlled_of_uniformEmbedding [PseudoMetricSpace β] {f : α → β} (h : UniformEmbedding f) :
(∀ ε > 0, ∃ δ > 0, ∀ {a b : α}, dist a b < δ → dist (f a) (f b) < ε) ∧
∀ δ > 0, ∃ ε > 0, ∀ {a b : α}, dist (f a) (f b) < ε → dist a b < δ :=
⟨uniformContinuous_iff.1 h.uniformContinuous, (uniformEmbedding_iff.1 h).2.2⟩
theorem totallyBounded_iff {s : Set α} :
TotallyBounded s ↔ ∀ ε > 0, ∃ t : Set α, t.Finite ∧ s ⊆ ⋃ y ∈ t, ball y ε :=
uniformity_basis_dist.totallyBounded_iff
/-- A pseudometric space is totally bounded if one can reconstruct up to any ε>0 any element of the
space from finitely many data. -/
theorem totallyBounded_of_finite_discretization {s : Set α}
(H : ∀ ε > (0 : ℝ),
∃ (β : Type u) (_ : Fintype β) (F : s → β), ∀ x y, F x = F y → dist (x : α) y < ε) :
TotallyBounded s := by
rcases s.eq_empty_or_nonempty with hs | hs
· rw [hs]
exact totallyBounded_empty
rcases hs with ⟨x0, hx0⟩
haveI : Inhabited s := ⟨⟨x0, hx0⟩⟩
refine totallyBounded_iff.2 fun ε ε0 => ?_
rcases H ε ε0 with ⟨β, fβ, F, hF⟩
let Finv := Function.invFun F
refine ⟨range (Subtype.val ∘ Finv), finite_range _, fun x xs => ?_⟩
let x' := Finv (F ⟨x, xs⟩)
have : F x' = F ⟨x, xs⟩ := Function.invFun_eq ⟨⟨x, xs⟩, rfl⟩
simp only [Set.mem_iUnion, Set.mem_range]
exact ⟨_, ⟨F ⟨x, xs⟩, rfl⟩, hF _ _ this.symm⟩
theorem finite_approx_of_totallyBounded {s : Set α} (hs : TotallyBounded s) :
∀ ε > 0, ∃ t, t ⊆ s ∧ Set.Finite t ∧ s ⊆ ⋃ y ∈ t, ball y ε := by
intro ε ε_pos
rw [totallyBounded_iff_subset] at hs
exact hs _ (dist_mem_uniformity ε_pos)
/-- Expressing uniform convergence using `dist` -/
theorem tendstoUniformlyOnFilter_iff {F : ι → β → α} {f : β → α} {p : Filter ι} {p' : Filter β} :
TendstoUniformlyOnFilter F f p p' ↔
∀ ε > 0, ∀ᶠ n : ι × β in p ×ˢ p', dist (f n.snd) (F n.fst n.snd) < ε := by
refine ⟨fun H ε hε => H _ (dist_mem_uniformity hε), fun H u hu => ?_⟩
rcases mem_uniformity_dist.1 hu with ⟨ε, εpos, hε⟩
exact (H ε εpos).mono fun n hn => hε hn
/-- Expressing locally uniform convergence on a set using `dist`. -/
theorem tendstoLocallyUniformlyOn_iff [TopologicalSpace β] {F : ι → β → α} {f : β → α}
{p : Filter ι} {s : Set β} :
TendstoLocallyUniformlyOn F f p s ↔
∀ ε > 0, ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, ∀ᶠ n in p, ∀ y ∈ t, dist (f y) (F n y) < ε := by
refine ⟨fun H ε hε => H _ (dist_mem_uniformity hε), fun H u hu x hx => ?_⟩
rcases mem_uniformity_dist.1 hu with ⟨ε, εpos, hε⟩
rcases H ε εpos x hx with ⟨t, ht, Ht⟩
exact ⟨t, ht, Ht.mono fun n hs x hx => hε (hs x hx)⟩
/-- Expressing uniform convergence on a set using `dist`. -/
theorem tendstoUniformlyOn_iff {F : ι → β → α} {f : β → α} {p : Filter ι} {s : Set β} :
TendstoUniformlyOn F f p s ↔ ∀ ε > 0, ∀ᶠ n in p, ∀ x ∈ s, dist (f x) (F n x) < ε := by
refine ⟨fun H ε hε => H _ (dist_mem_uniformity hε), fun H u hu => ?_⟩
rcases mem_uniformity_dist.1 hu with ⟨ε, εpos, hε⟩
exact (H ε εpos).mono fun n hs x hx => hε (hs x hx)
/-- Expressing locally uniform convergence using `dist`. -/
theorem tendstoLocallyUniformly_iff [TopologicalSpace β] {F : ι → β → α} {f : β → α}
{p : Filter ι} :
TendstoLocallyUniformly F f p ↔
∀ ε > 0, ∀ x : β, ∃ t ∈ 𝓝 x, ∀ᶠ n in p, ∀ y ∈ t, dist (f y) (F n y) < ε := by
simp only [← tendstoLocallyUniformlyOn_univ, tendstoLocallyUniformlyOn_iff, nhdsWithin_univ,
mem_univ, forall_const, exists_prop]
/-- Expressing uniform convergence using `dist`. -/
theorem tendstoUniformly_iff {F : ι → β → α} {f : β → α} {p : Filter ι} :
TendstoUniformly F f p ↔ ∀ ε > 0, ∀ᶠ n in p, ∀ x, dist (f x) (F n x) < ε := by
rw [← tendstoUniformlyOn_univ, tendstoUniformlyOn_iff]
simp
protected theorem cauchy_iff {f : Filter α} :
Cauchy f ↔ NeBot f ∧ ∀ ε > 0, ∃ t ∈ f, ∀ x ∈ t, ∀ y ∈ t, dist x y < ε :=
uniformity_basis_dist.cauchy_iff
theorem nhds_basis_ball : (𝓝 x).HasBasis (0 < ·) (ball x) :=
nhds_basis_uniformity uniformity_basis_dist
theorem mem_nhds_iff : s ∈ 𝓝 x ↔ ∃ ε > 0, ball x ε ⊆ s :=
nhds_basis_ball.mem_iff
theorem eventually_nhds_iff {p : α → Prop} :
(∀ᶠ y in 𝓝 x, p y) ↔ ∃ ε > 0, ∀ ⦃y⦄, dist y x < ε → p y :=
mem_nhds_iff
theorem eventually_nhds_iff_ball {p : α → Prop} :
(∀ᶠ y in 𝓝 x, p y) ↔ ∃ ε > 0, ∀ y ∈ ball x ε, p y :=
mem_nhds_iff
/-- A version of `Filter.eventually_prod_iff` where the first filter consists of neighborhoods
in a pseudo-metric space. -/
theorem eventually_nhds_prod_iff {f : Filter ι} {x₀ : α} {p : α × ι → Prop} :
(∀ᶠ x in 𝓝 x₀ ×ˢ f, p x) ↔ ∃ ε > (0 : ℝ), ∃ pa : ι → Prop, (∀ᶠ i in f, pa i) ∧
∀ {x}, dist x x₀ < ε → ∀ {i}, pa i → p (x, i) := by
refine (nhds_basis_ball.prod f.basis_sets).eventually_iff.trans ?_
simp only [Prod.exists, forall_prod_set, id, mem_ball, and_assoc, exists_and_left, and_imp]
rfl
/-- A version of `Filter.eventually_prod_iff` where the second filter consists of neighborhoods
in a pseudo-metric space. -/
theorem eventually_prod_nhds_iff {f : Filter ι} {x₀ : α} {p : ι × α → Prop} :
(∀ᶠ x in f ×ˢ 𝓝 x₀, p x) ↔ ∃ pa : ι → Prop, (∀ᶠ i in f, pa i) ∧
∃ ε > 0, ∀ {i}, pa i → ∀ {x}, dist x x₀ < ε → p (i, x) := by
rw [eventually_swap_iff, Metric.eventually_nhds_prod_iff]
constructor <;>
· rintro ⟨a1, a2, a3, a4, a5⟩
exact ⟨a3, a4, a1, a2, fun b1 b2 b3 => a5 b3 b1⟩
theorem nhds_basis_closedBall : (𝓝 x).HasBasis (fun ε : ℝ => 0 < ε) (closedBall x) :=
nhds_basis_uniformity uniformity_basis_dist_le
theorem nhds_basis_ball_inv_nat_succ :
(𝓝 x).HasBasis (fun _ => True) fun n : ℕ => ball x (1 / (↑n + 1)) :=
nhds_basis_uniformity uniformity_basis_dist_inv_nat_succ
theorem nhds_basis_ball_inv_nat_pos :
(𝓝 x).HasBasis (fun n => 0 < n) fun n : ℕ => ball x (1 / ↑n) :=
nhds_basis_uniformity uniformity_basis_dist_inv_nat_pos
theorem nhds_basis_ball_pow {r : ℝ} (h0 : 0 < r) (h1 : r < 1) :
(𝓝 x).HasBasis (fun _ => True) fun n : ℕ => ball x (r ^ n) :=
nhds_basis_uniformity (uniformity_basis_dist_pow h0 h1)
theorem nhds_basis_closedBall_pow {r : ℝ} (h0 : 0 < r) (h1 : r < 1) :
(𝓝 x).HasBasis (fun _ => True) fun n : ℕ => closedBall x (r ^ n) :=
nhds_basis_uniformity (uniformity_basis_dist_le_pow h0 h1)
theorem isOpen_iff : IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, ball x ε ⊆ s := by
simp only [isOpen_iff_mem_nhds, mem_nhds_iff]
theorem isOpen_ball : IsOpen (ball x ε) :=
isOpen_iff.2 fun _ => exists_ball_subset_ball
theorem ball_mem_nhds (x : α) {ε : ℝ} (ε0 : 0 < ε) : ball x ε ∈ 𝓝 x :=
isOpen_ball.mem_nhds (mem_ball_self ε0)
theorem closedBall_mem_nhds (x : α) {ε : ℝ} (ε0 : 0 < ε) : closedBall x ε ∈ 𝓝 x :=
mem_of_superset (ball_mem_nhds x ε0) ball_subset_closedBall
theorem closedBall_mem_nhds_of_mem {x c : α} {ε : ℝ} (h : x ∈ ball c ε) : closedBall c ε ∈ 𝓝 x :=
mem_of_superset (isOpen_ball.mem_nhds h) ball_subset_closedBall
theorem nhdsWithin_basis_ball {s : Set α} :
(𝓝[s] x).HasBasis (fun ε : ℝ => 0 < ε) fun ε => ball x ε ∩ s :=
nhdsWithin_hasBasis nhds_basis_ball s
theorem mem_nhdsWithin_iff {t : Set α} : s ∈ 𝓝[t] x ↔ ∃ ε > 0, ball x ε ∩ t ⊆ s :=
nhdsWithin_basis_ball.mem_iff
theorem tendsto_nhdsWithin_nhdsWithin [PseudoMetricSpace β] {t : Set β} {f : α → β} {a b} :
Tendsto f (𝓝[s] a) (𝓝[t] b) ↔
∀ ε > 0, ∃ δ > 0, ∀ {x : α}, x ∈ s → dist x a < δ → f x ∈ t ∧ dist (f x) b < ε :=
(nhdsWithin_basis_ball.tendsto_iff nhdsWithin_basis_ball).trans <| by
simp only [inter_comm _ s, inter_comm _ t, mem_inter_iff, and_imp, gt_iff_lt, mem_ball]
theorem tendsto_nhdsWithin_nhds [PseudoMetricSpace β] {f : α → β} {a b} :
Tendsto f (𝓝[s] a) (𝓝 b) ↔
∀ ε > 0, ∃ δ > 0, ∀ {x : α}, x ∈ s → dist x a < δ → dist (f x) b < ε := by
rw [← nhdsWithin_univ b, tendsto_nhdsWithin_nhdsWithin]
simp only [mem_univ, true_and_iff]
theorem tendsto_nhds_nhds [PseudoMetricSpace β] {f : α → β} {a b} :
Tendsto f (𝓝 a) (𝓝 b) ↔ ∀ ε > 0, ∃ δ > 0, ∀ {x : α}, dist x a < δ → dist (f x) b < ε :=
nhds_basis_ball.tendsto_iff nhds_basis_ball
theorem continuousAt_iff [PseudoMetricSpace β] {f : α → β} {a : α} :
ContinuousAt f a ↔ ∀ ε > 0, ∃ δ > 0, ∀ {x : α}, dist x a < δ → dist (f x) (f a) < ε := by
rw [ContinuousAt, tendsto_nhds_nhds]
theorem continuousWithinAt_iff [PseudoMetricSpace β] {f : α → β} {a : α} {s : Set α} :
ContinuousWithinAt f s a ↔
∀ ε > 0, ∃ δ > 0, ∀ {x : α}, x ∈ s → dist x a < δ → dist (f x) (f a) < ε := by
rw [ContinuousWithinAt, tendsto_nhdsWithin_nhds]
theorem continuousOn_iff [PseudoMetricSpace β] {f : α → β} {s : Set α} :
ContinuousOn f s ↔ ∀ b ∈ s, ∀ ε > 0, ∃ δ > 0, ∀ a ∈ s, dist a b < δ → dist (f a) (f b) < ε := by
simp [ContinuousOn, continuousWithinAt_iff]
theorem continuous_iff [PseudoMetricSpace β] {f : α → β} :
Continuous f ↔ ∀ b, ∀ ε > 0, ∃ δ > 0, ∀ a, dist a b < δ → dist (f a) (f b) < ε :=
continuous_iff_continuousAt.trans <| forall_congr' fun _ => tendsto_nhds_nhds
theorem tendsto_nhds {f : Filter β} {u : β → α} {a : α} :
Tendsto u f (𝓝 a) ↔ ∀ ε > 0, ∀ᶠ x in f, dist (u x) a < ε :=
nhds_basis_ball.tendsto_right_iff
theorem continuousAt_iff' [TopologicalSpace β] {f : β → α} {b : β} :
ContinuousAt f b ↔ ∀ ε > 0, ∀ᶠ x in 𝓝 b, dist (f x) (f b) < ε := by
rw [ContinuousAt, tendsto_nhds]
theorem continuousWithinAt_iff' [TopologicalSpace β] {f : β → α} {b : β} {s : Set β} :
ContinuousWithinAt f s b ↔ ∀ ε > 0, ∀ᶠ x in 𝓝[s] b, dist (f x) (f b) < ε := by
rw [ContinuousWithinAt, tendsto_nhds]
theorem continuousOn_iff' [TopologicalSpace β] {f : β → α} {s : Set β} :
ContinuousOn f s ↔ ∀ b ∈ s, ∀ ε > 0, ∀ᶠ x in 𝓝[s] b, dist (f x) (f b) < ε := by
simp [ContinuousOn, continuousWithinAt_iff']
theorem continuous_iff' [TopologicalSpace β] {f : β → α} :
Continuous f ↔ ∀ (a), ∀ ε > 0, ∀ᶠ x in 𝓝 a, dist (f x) (f a) < ε :=
continuous_iff_continuousAt.trans <| forall_congr' fun _ => tendsto_nhds
theorem tendsto_atTop [Nonempty β] [SemilatticeSup β] {u : β → α} {a : α} :
Tendsto u atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, dist (u n) a < ε :=
(atTop_basis.tendsto_iff nhds_basis_ball).trans <| by
simp only [true_and, mem_ball, mem_Ici]
/-- A variant of `tendsto_atTop` that
uses `∃ N, ∀ n > N, ...` rather than `∃ N, ∀ n ≥ N, ...`
-/
theorem tendsto_atTop' [Nonempty β] [SemilatticeSup β] [NoMaxOrder β] {u : β → α} {a : α} :
Tendsto u atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n > N, dist (u n) a < ε :=
(atTop_basis_Ioi.tendsto_iff nhds_basis_ball).trans <| by
simp only [true_and, gt_iff_lt, mem_Ioi, mem_ball]
theorem isOpen_singleton_iff {α : Type*} [PseudoMetricSpace α] {x : α} :
IsOpen ({x} : Set α) ↔ ∃ ε > 0, ∀ y, dist y x < ε → y = x := by
simp [isOpen_iff, subset_singleton_iff, mem_ball]
/-- Given a point `x` in a discrete subset `s` of a pseudometric space, there is an open ball
centered at `x` and intersecting `s` only at `x`. -/
theorem exists_ball_inter_eq_singleton_of_mem_discrete [DiscreteTopology s] {x : α} (hx : x ∈ s) :
∃ ε > 0, Metric.ball x ε ∩ s = {x} :=
nhds_basis_ball.exists_inter_eq_singleton_of_mem_discrete hx
/-- Given a point `x` in a discrete subset `s` of a pseudometric space, there is a closed ball
of positive radius centered at `x` and intersecting `s` only at `x`. -/
theorem exists_closedBall_inter_eq_singleton_of_discrete [DiscreteTopology s] {x : α} (hx : x ∈ s) :
∃ ε > 0, Metric.closedBall x ε ∩ s = {x} :=
nhds_basis_closedBall.exists_inter_eq_singleton_of_mem_discrete hx
theorem _root_.Dense.exists_dist_lt {s : Set α} (hs : Dense s) (x : α) {ε : ℝ} (hε : 0 < ε) :
∃ y ∈ s, dist x y < ε := by
have : (ball x ε).Nonempty := by simp [hε]
simpa only [mem_ball'] using hs.exists_mem_open isOpen_ball this
nonrec theorem _root_.DenseRange.exists_dist_lt {β : Type*} {f : β → α} (hf : DenseRange f) (x : α)
{ε : ℝ} (hε : 0 < ε) : ∃ y, dist x (f y) < ε :=
exists_range_iff.1 (hf.exists_dist_lt x hε)
/-- (Pseudo) metric space has discrete `UniformSpace` structure
iff the distances between distinct points are uniformly bounded away from zero. -/
protected lemma uniformSpace_eq_bot :
‹PseudoMetricSpace α›.toUniformSpace = ⊥ ↔
∃ r : ℝ, 0 < r ∧ Pairwise (r ≤ dist · · : α → α → Prop) := by
simp only [uniformity_basis_dist.uniformSpace_eq_bot, mem_setOf_eq, not_lt]
end Metric
open Metric
/-- If the distances between distinct points in a (pseudo) metric space
are uniformly bounded away from zero, then the space has discrete topology. -/
lemma DiscreteTopology.of_forall_le_dist {α} [PseudoMetricSpace α] {r : ℝ} (hpos : 0 < r)
(hr : Pairwise (r ≤ dist · · : α → α → Prop)) : DiscreteTopology α :=
⟨by rw [Metric.uniformSpace_eq_bot.2 ⟨r, hpos, hr⟩, UniformSpace.toTopologicalSpace_bot]⟩
/- Instantiate a pseudometric space as a pseudoemetric space. Before we can state the instance,
we need to show that the uniform structure coming from the edistance and the
distance coincide. -/
theorem Metric.uniformity_edist_aux {α} (d : α → α → ℝ≥0) :
⨅ ε > (0 : ℝ), 𝓟 { p : α × α | ↑(d p.1 p.2) < ε } =
⨅ ε > (0 : ℝ≥0∞), 𝓟 { p : α × α | ↑(d p.1 p.2) < ε } := by
simp only [le_antisymm_iff, le_iInf_iff, le_principal_iff]
refine ⟨fun ε hε => ?_, fun ε hε => ?_⟩
· rcases ENNReal.lt_iff_exists_nnreal_btwn.1 hε with ⟨ε', ε'0, ε'ε⟩
refine mem_iInf_of_mem (ε' : ℝ) (mem_iInf_of_mem (ENNReal.coe_pos.1 ε'0) ?_)
exact fun x hx => lt_trans (ENNReal.coe_lt_coe.2 hx) ε'ε
· lift ε to ℝ≥0 using le_of_lt hε
refine mem_iInf_of_mem (ε : ℝ≥0∞) (mem_iInf_of_mem (ENNReal.coe_pos.2 hε) ?_)
exact fun _ => ENNReal.coe_lt_coe.1
theorem Metric.uniformity_edist : 𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α | edist p.1 p.2 < ε } := by
simp only [PseudoMetricSpace.uniformity_dist, dist_nndist, edist_nndist,
Metric.uniformity_edist_aux]
-- see Note [lower instance priority]
/-- A pseudometric space induces a pseudoemetric space -/
instance (priority := 100) PseudoMetricSpace.toPseudoEMetricSpace : PseudoEMetricSpace α :=
{ ‹PseudoMetricSpace α› with
edist_self := by simp [edist_dist]
edist_comm := fun _ _ => by simp only [edist_dist, dist_comm]
edist_triangle := fun x y z => by
simp only [edist_dist, ← ENNReal.ofReal_add, dist_nonneg]
rw [ENNReal.ofReal_le_ofReal_iff _]
· exact dist_triangle _ _ _
· simpa using add_le_add (dist_nonneg : 0 ≤ dist x y) dist_nonneg
uniformity_edist := Metric.uniformity_edist }
/-- In a pseudometric space, an open ball of infinite radius is the whole space -/
theorem Metric.eball_top_eq_univ (x : α) : EMetric.ball x ∞ = Set.univ :=
Set.eq_univ_iff_forall.mpr fun y => edist_lt_top y x
/-- Balls defined using the distance or the edistance coincide -/
@[simp]
theorem Metric.emetric_ball {x : α} {ε : ℝ} : EMetric.ball x (ENNReal.ofReal ε) = ball x ε := by
ext y
simp only [EMetric.mem_ball, mem_ball, edist_dist]
exact ENNReal.ofReal_lt_ofReal_iff_of_nonneg dist_nonneg
/-- Balls defined using the distance or the edistance coincide -/
@[simp]
theorem Metric.emetric_ball_nnreal {x : α} {ε : ℝ≥0} : EMetric.ball x ε = ball x ε := by
rw [← Metric.emetric_ball]
simp
/-- Closed balls defined using the distance or the edistance coincide -/
theorem Metric.emetric_closedBall {x : α} {ε : ℝ} (h : 0 ≤ ε) :
EMetric.closedBall x (ENNReal.ofReal ε) = closedBall x ε := by
ext y; simp [edist_le_ofReal h]
/-- Closed balls defined using the distance or the edistance coincide -/
@[simp]
theorem Metric.emetric_closedBall_nnreal {x : α} {ε : ℝ≥0} :
EMetric.closedBall x ε = closedBall x ε := by
rw [← Metric.emetric_closedBall ε.coe_nonneg, ENNReal.ofReal_coe_nnreal]
@[simp]
theorem Metric.emetric_ball_top (x : α) : EMetric.ball x ⊤ = univ :=
eq_univ_of_forall fun _ => edist_lt_top _ _
theorem Metric.inseparable_iff {x y : α} : Inseparable x y ↔ dist x y = 0 := by
rw [EMetric.inseparable_iff, edist_nndist, dist_nndist, ENNReal.coe_eq_zero, NNReal.coe_eq_zero]
/-- Build a new pseudometric space from an old one where the bundled uniform structure is provably
(but typically non-definitionaly) equal to some given uniform structure.
See Note [forgetful inheritance].
-/
abbrev PseudoMetricSpace.replaceUniformity {α} [U : UniformSpace α] (m : PseudoMetricSpace α)
(H : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace]) : PseudoMetricSpace α :=
{ m with
toUniformSpace := U
uniformity_dist := H.trans PseudoMetricSpace.uniformity_dist }
theorem PseudoMetricSpace.replaceUniformity_eq {α} [U : UniformSpace α] (m : PseudoMetricSpace α)
(H : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace]) : m.replaceUniformity H = m := by
ext
rfl
-- ensure that the bornology is unchanged when replacing the uniformity.
example {α} [U : UniformSpace α] (m : PseudoMetricSpace α)
(H : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace]) :
(PseudoMetricSpace.replaceUniformity m H).toBornology = m.toBornology := rfl
/-- Build a new pseudo metric space from an old one where the bundled topological structure is
provably (but typically non-definitionaly) equal to some given topological structure.
See Note [forgetful inheritance].
-/
abbrev PseudoMetricSpace.replaceTopology {γ} [U : TopologicalSpace γ] (m : PseudoMetricSpace γ)
(H : U = m.toUniformSpace.toTopologicalSpace) : PseudoMetricSpace γ :=
@PseudoMetricSpace.replaceUniformity γ (m.toUniformSpace.replaceTopology H) m rfl
theorem PseudoMetricSpace.replaceTopology_eq {γ} [U : TopologicalSpace γ] (m : PseudoMetricSpace γ)
(H : U = m.toUniformSpace.toTopologicalSpace) : m.replaceTopology H = m := by
ext
rfl
/-- One gets a pseudometric space from an emetric space if the edistance
is everywhere finite, by pushing the edistance to reals. We set it up so that the edist and the
uniformity are defeq in the pseudometric space and the pseudoemetric space. In this definition, the
distance is given separately, to be able to prescribe some expression which is not defeq to the
push-forward of the edistance to reals. See note [reducible non-instances]. -/
abbrev PseudoEMetricSpace.toPseudoMetricSpaceOfDist {α : Type u} [e : PseudoEMetricSpace α]
(dist : α → α → ℝ) (edist_ne_top : ∀ x y : α, edist x y ≠ ⊤)
(h : ∀ x y, dist x y = ENNReal.toReal (edist x y)) : PseudoMetricSpace α where
dist := dist
dist_self x := by simp [h]
dist_comm x y := by simp [h, edist_comm]
dist_triangle x y z := by
simp only [h]
exact ENNReal.toReal_le_add (edist_triangle _ _ _) (edist_ne_top _ _) (edist_ne_top _ _)
edist := edist
edist_dist _ _ := by simp only [h, ENNReal.ofReal_toReal (edist_ne_top _ _)]
toUniformSpace := e.toUniformSpace
uniformity_dist := e.uniformity_edist.trans <| by
simpa only [ENNReal.coe_toNNReal (edist_ne_top _ _), h]
using (Metric.uniformity_edist_aux fun x y : α => (edist x y).toNNReal).symm
/-- One gets a pseudometric space from an emetric space if the edistance
is everywhere finite, by pushing the edistance to reals. We set it up so that the edist and the
uniformity are defeq in the pseudometric space and the emetric space. -/
abbrev PseudoEMetricSpace.toPseudoMetricSpace {α : Type u} [PseudoEMetricSpace α]
(h : ∀ x y : α, edist x y ≠ ⊤) : PseudoMetricSpace α :=
PseudoEMetricSpace.toPseudoMetricSpaceOfDist (fun x y => ENNReal.toReal (edist x y)) h fun _ _ =>
rfl
/-- Build a new pseudometric space from an old one where the bundled bornology structure is provably
(but typically non-definitionaly) equal to some given bornology structure.
See Note [forgetful inheritance].
-/
abbrev PseudoMetricSpace.replaceBornology {α} [B : Bornology α] (m : PseudoMetricSpace α)
(H : ∀ s, @IsBounded _ B s ↔ @IsBounded _ PseudoMetricSpace.toBornology s) :
PseudoMetricSpace α :=
{ m with
toBornology := B
cobounded_sets := Set.ext <| compl_surjective.forall.2 fun s =>
(H s).trans <| by rw [isBounded_iff, mem_setOf_eq, compl_compl] }
theorem PseudoMetricSpace.replaceBornology_eq {α} [m : PseudoMetricSpace α] [B : Bornology α]
(H : ∀ s, @IsBounded _ B s ↔ @IsBounded _ PseudoMetricSpace.toBornology s) :
PseudoMetricSpace.replaceBornology _ H = m := by
ext
rfl
-- ensure that the uniformity is unchanged when replacing the bornology.
example {α} [B : Bornology α] (m : PseudoMetricSpace α)
(H : ∀ s, @IsBounded _ B s ↔ @IsBounded _ PseudoMetricSpace.toBornology s) :
(PseudoMetricSpace.replaceBornology m H).toUniformSpace = m.toUniformSpace := rfl
section Real
/-- Instantiate the reals as a pseudometric space. -/
instance Real.pseudoMetricSpace : PseudoMetricSpace ℝ where
dist x y := |x - y|
dist_self := by simp [abs_zero]
dist_comm x y := abs_sub_comm _ _
dist_triangle x y z := abs_sub_le _ _ _
theorem Real.dist_eq (x y : ℝ) : dist x y = |x - y| := rfl
theorem Real.nndist_eq (x y : ℝ) : nndist x y = Real.nnabs (x - y) := rfl
theorem Real.nndist_eq' (x y : ℝ) : nndist x y = Real.nnabs (y - x) :=
nndist_comm _ _
theorem Real.dist_0_eq_abs (x : ℝ) : dist x 0 = |x| := by simp [Real.dist_eq]
theorem Real.sub_le_dist (x y : ℝ) : x - y ≤ dist x y := by
rw [Real.dist_eq, le_abs]
exact Or.inl (le_refl _)
theorem Real.ball_eq_Ioo (x r : ℝ) : ball x r = Ioo (x - r) (x + r) :=
Set.ext fun y => by
rw [mem_ball, dist_comm, Real.dist_eq, abs_sub_lt_iff, mem_Ioo, ← sub_lt_iff_lt_add',
sub_lt_comm]
theorem Real.closedBall_eq_Icc {x r : ℝ} : closedBall x r = Icc (x - r) (x + r) := by
ext y
rw [mem_closedBall, dist_comm, Real.dist_eq, abs_sub_le_iff, mem_Icc, ← sub_le_iff_le_add',
sub_le_comm]
theorem Real.Ioo_eq_ball (x y : ℝ) : Ioo x y = ball ((x + y) / 2) ((y - x) / 2) := by
rw [Real.ball_eq_Ioo, ← sub_div, add_comm, ← sub_add, add_sub_cancel_left, add_self_div_two,
← add_div, add_assoc, add_sub_cancel, add_self_div_two]
theorem Real.Icc_eq_closedBall (x y : ℝ) : Icc x y = closedBall ((x + y) / 2) ((y - x) / 2) := by
rw [Real.closedBall_eq_Icc, ← sub_div, add_comm, ← sub_add, add_sub_cancel_left, add_self_div_two,
← add_div, add_assoc, add_sub_cancel, add_self_div_two]
theorem Metric.uniformity_eq_comap_nhds_zero :
𝓤 α = comap (fun p : α × α => dist p.1 p.2) (𝓝 (0 : ℝ)) := by
ext s
simp only [mem_uniformity_dist, (nhds_basis_ball.comap _).mem_iff]
simp [subset_def, Real.dist_0_eq_abs]
theorem cauchySeq_iff_tendsto_dist_atTop_0 [Nonempty β] [SemilatticeSup β] {u : β → α} :
CauchySeq u ↔ Tendsto (fun n : β × β => dist (u n.1) (u n.2)) atTop (𝓝 0) := by
rw [cauchySeq_iff_tendsto, Metric.uniformity_eq_comap_nhds_zero, tendsto_comap_iff,
Function.comp_def]
simp_rw [Prod.map_fst, Prod.map_snd]
theorem tendsto_uniformity_iff_dist_tendsto_zero {f : ι → α × α} {p : Filter ι} :
Tendsto f p (𝓤 α) ↔ Tendsto (fun x => dist (f x).1 (f x).2) p (𝓝 0) := by
rw [Metric.uniformity_eq_comap_nhds_zero, tendsto_comap_iff, Function.comp_def]
theorem Filter.Tendsto.congr_dist {f₁ f₂ : ι → α} {p : Filter ι} {a : α}
(h₁ : Tendsto f₁ p (𝓝 a)) (h : Tendsto (fun x => dist (f₁ x) (f₂ x)) p (𝓝 0)) :
Tendsto f₂ p (𝓝 a) :=
h₁.congr_uniformity <| tendsto_uniformity_iff_dist_tendsto_zero.2 h
alias tendsto_of_tendsto_of_dist := Filter.Tendsto.congr_dist
theorem tendsto_iff_of_dist {f₁ f₂ : ι → α} {p : Filter ι} {a : α}
(h : Tendsto (fun x => dist (f₁ x) (f₂ x)) p (𝓝 0)) : Tendsto f₁ p (𝓝 a) ↔ Tendsto f₂ p (𝓝 a) :=
Uniform.tendsto_congr <| tendsto_uniformity_iff_dist_tendsto_zero.2 h
end Real
-- Porting note: 3 new lemmas
theorem dist_dist_dist_le_left (x y z : α) : dist (dist x z) (dist y z) ≤ dist x y :=
abs_dist_sub_le ..
theorem dist_dist_dist_le_right (x y z : α) : dist (dist x y) (dist x z) ≤ dist y z := by
simpa only [dist_comm x] using dist_dist_dist_le_left y z x
theorem dist_dist_dist_le (x y x' y' : α) : dist (dist x y) (dist x' y') ≤ dist x x' + dist y y' :=
(dist_triangle _ _ _).trans <|
add_le_add (dist_dist_dist_le_left _ _ _) (dist_dist_dist_le_right _ _ _)
theorem nhds_comap_dist (a : α) : ((𝓝 (0 : ℝ)).comap (dist · a)) = 𝓝 a := by
simp only [@nhds_eq_comap_uniformity α, Metric.uniformity_eq_comap_nhds_zero, comap_comap,
(· ∘ ·), dist_comm]
theorem tendsto_iff_dist_tendsto_zero {f : β → α} {x : Filter β} {a : α} :
Tendsto f x (𝓝 a) ↔ Tendsto (fun b => dist (f b) a) x (𝓝 0) := by
rw [← nhds_comap_dist a, tendsto_comap_iff, Function.comp_def]
namespace Metric
variable {x y z : α} {ε ε₁ ε₂ : ℝ} {s : Set α}
theorem ball_subset_interior_closedBall : ball x ε ⊆ interior (closedBall x ε) :=
interior_maximal ball_subset_closedBall isOpen_ball
/-- ε-characterization of the closure in pseudometric spaces-/
theorem mem_closure_iff {s : Set α} {a : α} : a ∈ closure s ↔ ∀ ε > 0, ∃ b ∈ s, dist a b < ε :=
(mem_closure_iff_nhds_basis nhds_basis_ball).trans <| by simp only [mem_ball, dist_comm]
theorem mem_closure_range_iff {e : β → α} {a : α} :
a ∈ closure (range e) ↔ ∀ ε > 0, ∃ k : β, dist a (e k) < ε := by
simp only [mem_closure_iff, exists_range_iff]
theorem mem_closure_range_iff_nat {e : β → α} {a : α} :
a ∈ closure (range e) ↔ ∀ n : ℕ, ∃ k : β, dist a (e k) < 1 / ((n : ℝ) + 1) :=
(mem_closure_iff_nhds_basis nhds_basis_ball_inv_nat_succ).trans <| by
simp only [mem_ball, dist_comm, exists_range_iff, forall_const]
theorem mem_of_closed' {s : Set α} (hs : IsClosed s) {a : α} :
a ∈ s ↔ ∀ ε > 0, ∃ b ∈ s, dist a b < ε := by
simpa only [hs.closure_eq] using @mem_closure_iff _ _ s a
theorem dense_iff {s : Set α} : Dense s ↔ ∀ x, ∀ r > 0, (ball x r ∩ s).Nonempty :=
forall_congr' fun x => by
simp only [mem_closure_iff, Set.Nonempty, exists_prop, mem_inter_iff, mem_ball', and_comm]
theorem denseRange_iff {f : β → α} : DenseRange f ↔ ∀ x, ∀ r > 0, ∃ y, dist x (f y) < r :=
forall_congr' fun x => by simp only [mem_closure_iff, exists_range_iff]
-- Porting note: `TopologicalSpace.IsSeparable.separableSpace` moved to `EMetricSpace`
/-- The preimage of a separable set by an inducing map is separable. -/
protected theorem _root_.Inducing.isSeparable_preimage {f : β → α} [TopologicalSpace β]
(hf : Inducing f) {s : Set α} (hs : IsSeparable s) : IsSeparable (f ⁻¹' s) := by
have : SeparableSpace s := hs.separableSpace
have : SecondCountableTopology s := UniformSpace.secondCountable_of_separable _
have : Inducing ((mapsTo_preimage f s).restrict _ _ _) :=
(hf.comp inducing_subtype_val).codRestrict _
have := this.secondCountableTopology
exact .of_subtype _
protected theorem _root_.Embedding.isSeparable_preimage {f : β → α} [TopologicalSpace β]
(hf : Embedding f) {s : Set α} (hs : IsSeparable s) : IsSeparable (f ⁻¹' s) :=
hf.toInducing.isSeparable_preimage hs
/-- If a map is continuous on a separable set `s`, then the image of `s` is also separable. -/
theorem _root_.ContinuousOn.isSeparable_image [TopologicalSpace β] {f : α → β} {s : Set α}
(hf : ContinuousOn f s) (hs : IsSeparable s) : IsSeparable (f '' s) := by
rw [image_eq_range, ← image_univ]
exact (isSeparable_univ_iff.2 hs.separableSpace).image hf.restrict
end Metric
/-- A compact set is separable. -/
theorem IsCompact.isSeparable {s : Set α} (hs : IsCompact s) : IsSeparable s :=
haveI : CompactSpace s := isCompact_iff_compactSpace.mp hs
.of_subtype s
section Compact
/-- Any compact set in a pseudometric space can be covered by finitely many balls of a given
positive radius -/
theorem finite_cover_balls_of_compact {α : Type u} [PseudoMetricSpace α] {s : Set α}
(hs : IsCompact s) {e : ℝ} (he : 0 < e) :
∃ t, t ⊆ s ∧ Set.Finite t ∧ s ⊆ ⋃ x ∈ t, ball x e :=
let ⟨t, hts, ht⟩ := hs.elim_nhds_subcover _ (fun x _ => ball_mem_nhds x he)
⟨t, hts, t.finite_toSet, ht⟩
alias IsCompact.finite_cover_balls := finite_cover_balls_of_compact
end Compact
namespace Metric
section SecondCountable
open TopologicalSpace
/-- A pseudometric space is second countable if, for every `ε > 0`, there is a countable set which
is `ε`-dense. -/
theorem secondCountable_of_almost_dense_set
(H : ∀ ε > (0 : ℝ), ∃ s : Set α, s.Countable ∧ ∀ x, ∃ y ∈ s, dist x y ≤ ε) :
SecondCountableTopology α := by
refine EMetric.secondCountable_of_almost_dense_set fun ε ε0 => ?_
rcases ENNReal.lt_iff_exists_nnreal_btwn.1 ε0 with ⟨ε', ε'0, ε'ε⟩
choose s hsc y hys hyx using H ε' (mod_cast ε'0)
refine ⟨s, hsc, iUnion₂_eq_univ_iff.2 fun x => ⟨y x, hys _, le_trans ?_ ε'ε.le⟩⟩
exact mod_cast hyx x
end SecondCountable
end Metric
theorem lebesgue_number_lemma_of_metric {s : Set α} {ι : Sort*} {c : ι → Set α} (hs : IsCompact s)
(hc₁ : ∀ i, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i, c i) : ∃ δ > 0, ∀ x ∈ s, ∃ i, ball x δ ⊆ c i := by
simpa only [ball, UniformSpace.ball, preimage_setOf_eq, dist_comm]
using uniformity_basis_dist.lebesgue_number_lemma hs hc₁ hc₂
theorem lebesgue_number_lemma_of_metric_sUnion {s : Set α} {c : Set (Set α)} (hs : IsCompact s)
(hc₁ : ∀ t ∈ c, IsOpen t) (hc₂ : s ⊆ ⋃₀ c) : ∃ δ > 0, ∀ x ∈ s, ∃ t ∈ c, ball x δ ⊆ t := by
rw [sUnion_eq_iUnion] at hc₂; simpa using lebesgue_number_lemma_of_metric hs (by simpa) hc₂
|
Topology\MetricSpace\Pseudo\Lemmas.lean | /-
Copyright (c) 2015, 2017 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Robert Y. Lewis, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel
-/
import Mathlib.Data.Set.Pointwise.Interval
import Mathlib.Topology.MetricSpace.Pseudo.Constructions
import Mathlib.Topology.Order.DenselyOrdered
/-!
# Extra lemmas about pseudo-metric spaces
-/
open Bornology Filter Metric Set
open scoped NNReal Topology
variable {ι α : Type*} [PseudoMetricSpace α]
lemma Real.dist_left_le_of_mem_uIcc {x y z : ℝ} (h : y ∈ uIcc x z) : dist x y ≤ dist x z := by
simpa only [dist_comm x] using abs_sub_left_of_mem_uIcc h
lemma Real.dist_right_le_of_mem_uIcc {x y z : ℝ} (h : y ∈ uIcc x z) : dist y z ≤ dist x z := by
simpa only [dist_comm _ z] using abs_sub_right_of_mem_uIcc h
lemma Real.dist_le_of_mem_uIcc {x y x' y' : ℝ} (hx : x ∈ uIcc x' y') (hy : y ∈ uIcc x' y') :
dist x y ≤ dist x' y' :=
abs_sub_le_of_uIcc_subset_uIcc <| uIcc_subset_uIcc (by rwa [uIcc_comm]) (by rwa [uIcc_comm])
lemma Real.dist_le_of_mem_Icc {x y x' y' : ℝ} (hx : x ∈ Icc x' y') (hy : y ∈ Icc x' y') :
dist x y ≤ y' - x' := by
simpa only [Real.dist_eq, abs_of_nonpos (sub_nonpos.2 <| hx.1.trans hx.2), neg_sub] using
Real.dist_le_of_mem_uIcc (Icc_subset_uIcc hx) (Icc_subset_uIcc hy)
lemma Real.dist_le_of_mem_Icc_01 {x y : ℝ} (hx : x ∈ Icc (0 : ℝ) 1) (hy : y ∈ Icc (0 : ℝ) 1) :
dist x y ≤ 1 := by simpa only [sub_zero] using Real.dist_le_of_mem_Icc hx hy
instance : OrderTopology ℝ :=
orderTopology_of_nhds_abs fun x => by
simp only [nhds_basis_ball.eq_biInf, ball, Real.dist_eq, abs_sub_comm]
lemma Real.singleton_eq_inter_Icc (b : ℝ) : {b} = ⋂ (r > 0), Icc (b - r) (b + r) := by
simp [Icc_eq_closedBall, biInter_basis_nhds Metric.nhds_basis_closedBall]
/-- Special case of the sandwich lemma; see `tendsto_of_tendsto_of_tendsto_of_le_of_le'` for the
general case. -/
lemma squeeze_zero' {α} {f g : α → ℝ} {t₀ : Filter α} (hf : ∀ᶠ t in t₀, 0 ≤ f t)
(hft : ∀ᶠ t in t₀, f t ≤ g t) (g0 : Tendsto g t₀ (𝓝 0)) : Tendsto f t₀ (𝓝 0) :=
tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds g0 hf hft
/-- Special case of the sandwich lemma; see `tendsto_of_tendsto_of_tendsto_of_le_of_le`
and `tendsto_of_tendsto_of_tendsto_of_le_of_le'` for the general case. -/
lemma squeeze_zero {α} {f g : α → ℝ} {t₀ : Filter α} (hf : ∀ t, 0 ≤ f t) (hft : ∀ t, f t ≤ g t)
(g0 : Tendsto g t₀ (𝓝 0)) : Tendsto f t₀ (𝓝 0) :=
squeeze_zero' (eventually_of_forall hf) (eventually_of_forall hft) g0
/-- If `u` is a neighborhood of `x`, then for small enough `r`, the closed ball
`Metric.closedBall x r` is contained in `u`. -/
lemma eventually_closedBall_subset {x : α} {u : Set α} (hu : u ∈ 𝓝 x) :
∀ᶠ r in 𝓝 (0 : ℝ), closedBall x r ⊆ u := by
obtain ⟨ε, εpos, hε⟩ : ∃ ε, 0 < ε ∧ closedBall x ε ⊆ u := nhds_basis_closedBall.mem_iff.1 hu
have : Iic ε ∈ 𝓝 (0 : ℝ) := Iic_mem_nhds εpos
filter_upwards [this] with _ hr using Subset.trans (closedBall_subset_closedBall hr) hε
lemma tendsto_closedBall_smallSets (x : α) : Tendsto (closedBall x) (𝓝 0) (𝓝 x).smallSets :=
tendsto_smallSets_iff.2 fun _ ↦ eventually_closedBall_subset
namespace Metric
variable {x y z : α} {ε ε₁ ε₂ : ℝ} {s : Set α}
lemma isClosed_ball : IsClosed (closedBall x ε) :=
isClosed_le (continuous_id.dist continuous_const) continuous_const
lemma isClosed_sphere : IsClosed (sphere x ε) :=
isClosed_eq (continuous_id.dist continuous_const) continuous_const
@[simp]
lemma closure_closedBall : closure (closedBall x ε) = closedBall x ε :=
isClosed_ball.closure_eq
@[simp]
lemma closure_sphere : closure (sphere x ε) = sphere x ε :=
isClosed_sphere.closure_eq
lemma closure_ball_subset_closedBall : closure (ball x ε) ⊆ closedBall x ε :=
closure_minimal ball_subset_closedBall isClosed_ball
lemma frontier_ball_subset_sphere : frontier (ball x ε) ⊆ sphere x ε :=
frontier_lt_subset_eq (continuous_id.dist continuous_const) continuous_const
lemma frontier_closedBall_subset_sphere : frontier (closedBall x ε) ⊆ sphere x ε :=
frontier_le_subset_eq (continuous_id.dist continuous_const) continuous_const
lemma closedBall_zero' (x : α) : closedBall x 0 = closure {x} :=
Subset.antisymm
(fun _y hy =>
mem_closure_iff.2 fun _ε ε0 => ⟨x, mem_singleton x, (mem_closedBall.1 hy).trans_lt ε0⟩)
(closure_minimal (singleton_subset_iff.2 (dist_self x).le) isClosed_ball)
lemma eventually_isCompact_closedBall [WeaklyLocallyCompactSpace α] (x : α) :
∀ᶠ r in 𝓝 (0 : ℝ), IsCompact (closedBall x r) := by
rcases exists_compact_mem_nhds x with ⟨s, s_compact, hs⟩
filter_upwards [eventually_closedBall_subset hs] with r hr
exact IsCompact.of_isClosed_subset s_compact isClosed_ball hr
lemma exists_isCompact_closedBall [WeaklyLocallyCompactSpace α] (x : α) :
∃ r, 0 < r ∧ IsCompact (closedBall x r) := by
have : ∀ᶠ r in 𝓝[>] 0, IsCompact (closedBall x r) :=
eventually_nhdsWithin_of_eventually_nhds (eventually_isCompact_closedBall x)
simpa only [and_comm] using (this.and self_mem_nhdsWithin).exists
end Metric
namespace Real
variable {π : ι → Type*} [Fintype ι] [∀ i, PseudoMetricSpace (π i)] {x y x' y' : ι → ℝ}
lemma dist_le_of_mem_pi_Icc (hx : x ∈ Icc x' y') (hy : y ∈ Icc x' y') : dist x y ≤ dist x' y' := by
refine (dist_pi_le_iff dist_nonneg).2 fun b =>
(Real.dist_le_of_mem_uIcc ?_ ?_).trans (dist_le_pi_dist x' y' b) <;> refine Icc_subset_uIcc ?_
exacts [⟨hx.1 _, hx.2 _⟩, ⟨hy.1 _, hy.2 _⟩]
end Real
|
Topology\MetricSpace\Ultra\Basic.lean | /-
Copyright (c) 2024 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
import Mathlib.Topology.MetricSpace.Pseudo.Lemmas
/-!
## Ultrametric spaces
This file defines ultrametric spaces, implemented as a mixin on the `Dist`,
so that it can apply on pseudometric spaces as well.
## Main definitions
* `IsUltrametricDist X`: Annotates `dist : X → X → ℝ` as respecting the ultrametric inequality
of `dist(x, z) ≤ max {dist(x,y), dist(y,z)}`
## Implementation details
The mixin could have been defined as a hypothesis to be carried around, instead of relying on
typeclass synthesis. However, since we declare a (pseudo)metric space on a type using
typeclass arguments, one can declare the ultrametricity at the same time.
For example, one could say `[Norm K] [Fact (IsNonarchimedean (norm : K → ℝ))]`,
The file imports a later file in the hierarchy of pseudometric spaces, since
`Metric.isClosed_ball` and `Metric.isClosed_sphere` is proven in a later file
using more conceptual results.
TODO: Generalize to ultrametric uniformities
## Tags
ultrametric, nonarchimedean
-/
variable {X : Type*}
/-- The `dist : X → X → ℝ` respects the ultrametric inequality
of `dist(x, z) ≤ max (dist(x,y)) (dist(y,z))`. -/
class IsUltrametricDist (X : Type*) [Dist X] : Prop where
dist_triangle_max : ∀ x y z : X, dist x z ≤ max (dist x y) (dist y z)
open Metric
variable [PseudoMetricSpace X] [IsUltrametricDist X] (x y z : X) (r s : ℝ)
lemma dist_triangle_max : dist x z ≤ max (dist x y) (dist y z) :=
IsUltrametricDist.dist_triangle_max x y z
namespace IsUltrametricDist
instance subtype (p : X → Prop) : IsUltrametricDist (Subtype p) :=
⟨fun _ _ _ ↦ by simpa [Subtype.dist_eq] using dist_triangle_max _ _ _⟩
lemma ball_eq_of_mem {x y : X} {r : ℝ} (h : y ∈ ball x r) : ball x r = ball y r := by
ext a
simp_rw [mem_ball] at h ⊢
constructor <;> intro h' <;>
exact (dist_triangle_max _ _ _).trans_lt (max_lt h' (dist_comm x _ ▸ h))
lemma mem_ball_iff {x y : X} {r : ℝ} : y ∈ ball x r ↔ x ∈ ball y r := by
cases lt_or_le 0 r with
| inl hr =>
constructor <;> intro h <;>
rw [← ball_eq_of_mem h] <;>
simp [hr]
| inr hr => simp [ball_eq_empty.mpr hr]
lemma ball_subset_trichotomy :
ball x r ⊆ ball y s ∨ ball y s ⊆ ball x r ∨ Disjoint (ball x r) (ball y s) := by
wlog hrs : r ≤ s generalizing x y r s
· rw [disjoint_comm, ← or_assoc, or_comm (b := _ ⊆ _), or_assoc]
exact this y x s r (lt_of_not_le hrs).le
· refine Set.disjoint_or_nonempty_inter (ball x r) (ball y s) |>.symm.imp (fun h ↦ ?_) (Or.inr ·)
obtain ⟨hxz, hyz⟩ := (Set.mem_inter_iff _ _ _).mp h.some_mem
have hx := ball_subset_ball hrs (x := x)
rwa [ball_eq_of_mem hyz |>.trans (ball_eq_of_mem <| hx hxz).symm]
lemma ball_eq_or_disjoint :
ball x r = ball y r ∨ Disjoint (ball x r) (ball y r) := by
refine Set.disjoint_or_nonempty_inter (ball x r) (ball y r) |>.symm.imp (fun h ↦ ?_) id
have h₁ := ball_eq_of_mem <| Set.inter_subset_left h.some_mem
have h₂ := ball_eq_of_mem <| Set.inter_subset_right h.some_mem
exact h₁.trans h₂.symm
lemma closedBall_eq_of_mem {x y: X} {r : ℝ} (h : y ∈ closedBall x r) :
closedBall x r = closedBall y r := by
ext
simp_rw [mem_closedBall] at h ⊢
constructor <;> intro h' <;>
exact (dist_triangle_max _ _ _).trans (max_le h' (dist_comm x _ ▸ h))
lemma mem_closedBall_iff {x y: X} {r : ℝ} :
y ∈ closedBall x r ↔ x ∈ closedBall y r := by
cases le_or_lt 0 r with
| inl hr =>
constructor <;> intro h <;>
rw [← closedBall_eq_of_mem h] <;>
simp [hr]
| inr hr => simp [closedBall_eq_empty.mpr hr]
lemma closedBall_subset_trichotomy :
closedBall x r ⊆ closedBall y s ∨ closedBall y s ⊆ closedBall x r ∨
Disjoint (closedBall x r) (closedBall y s) := by
wlog hrs : r ≤ s generalizing x y r s
· rw [disjoint_comm, ← or_assoc, or_comm (b := _ ⊆ _), or_assoc]
exact this y x s r (lt_of_not_le hrs).le
· refine Set.disjoint_or_nonempty_inter (closedBall x r) (closedBall y s) |>.symm.imp
(fun h ↦ ?_) (Or.inr ·)
obtain ⟨hxz, hyz⟩ := (Set.mem_inter_iff _ _ _).mp h.some_mem
have hx := closedBall_subset_closedBall hrs (x := x)
rwa [closedBall_eq_of_mem hyz |>.trans (closedBall_eq_of_mem <| hx hxz).symm]
lemma isClosed_ball (x : X) (r : ℝ) : IsClosed (ball x r) := by
cases le_or_lt r 0 with
| inl hr =>
simp [ball_eq_empty.mpr hr]
| inr h =>
rw [← isOpen_compl_iff, isOpen_iff]
simp only [Set.mem_compl_iff, not_lt, gt_iff_lt]
intro y hy
cases ball_eq_or_disjoint x y r with
| inl hd =>
rw [hd] at hy
simp [h.not_le] at hy
| inr hd =>
use r
simp [h, hy, ← Set.le_iff_subset, le_compl_iff_disjoint_left, hd]
lemma isClopen_ball : IsClopen (ball x r) := ⟨isClosed_ball x r, isOpen_ball⟩
lemma frontier_ball_eq_empty : frontier (ball x r) = ∅ :=
isClopen_iff_frontier_eq_empty.mp (isClopen_ball x r)
lemma closedBall_eq_or_disjoint :
closedBall x r = closedBall y r ∨ Disjoint (closedBall x r) (closedBall y r) := by
refine Set.disjoint_or_nonempty_inter (closedBall x r) (closedBall y r) |>.symm.imp
(fun h ↦ ?_) id
have h₁ := closedBall_eq_of_mem <| Set.inter_subset_left h.some_mem
have h₂ := closedBall_eq_of_mem <| Set.inter_subset_right h.some_mem
exact h₁.trans h₂.symm
lemma isOpen_closedBall {r : ℝ} (hr : r ≠ 0) : IsOpen (closedBall x r) := by
cases lt_or_gt_of_ne hr with
| inl h =>
simp [closedBall_eq_empty.mpr h]
| inr h =>
rw [isOpen_iff]
simp only [Set.mem_compl_iff, not_lt, gt_iff_lt]
intro y hy
cases closedBall_eq_or_disjoint x y r with
| inl hd =>
use r
simp [h, hd, ball_subset_closedBall]
| inr hd =>
simp [closedBall_eq_of_mem hy, h.not_lt] at hd
lemma isClopen_closedBall {r : ℝ} (hr : r ≠ 0) : IsClopen (closedBall x r) :=
⟨Metric.isClosed_ball, isOpen_closedBall x hr⟩
lemma frontier_closedBall_eq_empty {r : ℝ} (hr : r ≠ 0) : frontier (closedBall x r) = ∅ :=
isClopen_iff_frontier_eq_empty.mp (isClopen_closedBall x hr)
lemma isOpen_sphere {r : ℝ} (hr : r ≠ 0) : IsOpen (sphere x r) := by
rw [← closedBall_diff_ball, sdiff_eq]
exact (isOpen_closedBall x hr).inter (isClosed_ball x r).isOpen_compl
lemma isClopen_sphere {r : ℝ} (hr : r ≠ 0) : IsClopen (sphere x r) :=
⟨Metric.isClosed_sphere, isOpen_sphere x hr⟩
end IsUltrametricDist
|
Topology\Metrizable\Basic.lean | /-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Topology.MetricSpace.Basic
/-!
# Metrizability of a T₃ topological space with second countable topology
In this file we define metrizable topological spaces, i.e., topological spaces for which there
exists a metric space structure that generates the same topology.
-/
open Set Filter Metric
open scoped Filter Topology
namespace TopologicalSpace
variable {ι X Y : Type*} {π : ι → Type*} [TopologicalSpace X] [TopologicalSpace Y] [Finite ι]
[∀ i, TopologicalSpace (π i)]
/-- A topological space is *pseudo metrizable* if there exists a pseudo metric space structure
compatible with the topology. To endow such a space with a compatible distance, use
`letI : PseudoMetricSpace X := TopologicalSpace.pseudoMetrizableSpacePseudoMetric X`. -/
class PseudoMetrizableSpace (X : Type*) [t : TopologicalSpace X] : Prop where
exists_pseudo_metric : ∃ m : PseudoMetricSpace X, m.toUniformSpace.toTopologicalSpace = t
instance (priority := 100) _root_.PseudoMetricSpace.toPseudoMetrizableSpace {X : Type*}
[m : PseudoMetricSpace X] : PseudoMetrizableSpace X :=
⟨⟨m, rfl⟩⟩
/-- Construct on a metrizable space a metric compatible with the topology. -/
noncomputable def pseudoMetrizableSpacePseudoMetric (X : Type*) [TopologicalSpace X]
[h : PseudoMetrizableSpace X] : PseudoMetricSpace X :=
h.exists_pseudo_metric.choose.replaceTopology h.exists_pseudo_metric.choose_spec.symm
instance pseudoMetrizableSpace_prod [PseudoMetrizableSpace X] [PseudoMetrizableSpace Y] :
PseudoMetrizableSpace (X × Y) :=
letI : PseudoMetricSpace X := pseudoMetrizableSpacePseudoMetric X
letI : PseudoMetricSpace Y := pseudoMetrizableSpacePseudoMetric Y
inferInstance
/-- Given an inducing map of a topological space into a pseudo metrizable space, the source space
is also pseudo metrizable. -/
theorem _root_.Inducing.pseudoMetrizableSpace [PseudoMetrizableSpace Y] {f : X → Y}
(hf : Inducing f) : PseudoMetrizableSpace X :=
letI : PseudoMetricSpace Y := pseudoMetrizableSpacePseudoMetric Y
⟨⟨hf.comapPseudoMetricSpace, rfl⟩⟩
/-- Every pseudo-metrizable space is first countable. -/
instance (priority := 100) PseudoMetrizableSpace.firstCountableTopology
[h : PseudoMetrizableSpace X] : FirstCountableTopology X := by
rcases h with ⟨_, hm⟩
rw [← hm]
exact @UniformSpace.firstCountableTopology X PseudoMetricSpace.toUniformSpace
EMetric.instIsCountablyGeneratedUniformity
instance PseudoMetrizableSpace.subtype [PseudoMetrizableSpace X] (s : Set X) :
PseudoMetrizableSpace s :=
inducing_subtype_val.pseudoMetrizableSpace
instance pseudoMetrizableSpace_pi [∀ i, PseudoMetrizableSpace (π i)] :
PseudoMetrizableSpace (∀ i, π i) := by
cases nonempty_fintype ι
letI := fun i => pseudoMetrizableSpacePseudoMetric (π i)
infer_instance
/-- A topological space is metrizable if there exists a metric space structure compatible with the
topology. To endow such a space with a compatible distance, use
`letI : MetricSpace X := TopologicalSpace.metrizableSpaceMetric X`. -/
class MetrizableSpace (X : Type*) [t : TopologicalSpace X] : Prop where
exists_metric : ∃ m : MetricSpace X, m.toUniformSpace.toTopologicalSpace = t
instance (priority := 100) _root_.MetricSpace.toMetrizableSpace {X : Type*} [m : MetricSpace X] :
MetrizableSpace X :=
⟨⟨m, rfl⟩⟩
instance (priority := 100) MetrizableSpace.toPseudoMetrizableSpace [h : MetrizableSpace X] :
PseudoMetrizableSpace X :=
let ⟨m, hm⟩ := h.1
⟨⟨m.toPseudoMetricSpace, hm⟩⟩
/-- Construct on a metrizable space a metric compatible with the topology. -/
noncomputable def metrizableSpaceMetric (X : Type*) [TopologicalSpace X] [h : MetrizableSpace X] :
MetricSpace X :=
h.exists_metric.choose.replaceTopology h.exists_metric.choose_spec.symm
instance (priority := 100) t2Space_of_metrizableSpace [MetrizableSpace X] : T2Space X :=
letI : MetricSpace X := metrizableSpaceMetric X
inferInstance
instance metrizableSpace_prod [MetrizableSpace X] [MetrizableSpace Y] : MetrizableSpace (X × Y) :=
letI : MetricSpace X := metrizableSpaceMetric X
letI : MetricSpace Y := metrizableSpaceMetric Y
inferInstance
/-- Given an embedding of a topological space into a metrizable space, the source space is also
metrizable. -/
theorem _root_.Embedding.metrizableSpace [MetrizableSpace Y] {f : X → Y} (hf : Embedding f) :
MetrizableSpace X :=
letI : MetricSpace Y := metrizableSpaceMetric Y
⟨⟨hf.comapMetricSpace f, rfl⟩⟩
instance MetrizableSpace.subtype [MetrizableSpace X] (s : Set X) : MetrizableSpace s :=
embedding_subtype_val.metrizableSpace
instance metrizableSpace_pi [∀ i, MetrizableSpace (π i)] : MetrizableSpace (∀ i, π i) := by
cases nonempty_fintype ι
letI := fun i => metrizableSpaceMetric (π i)
infer_instance
theorem IsSeparable.secondCountableTopology [PseudoMetrizableSpace X] {s : Set X}
(hs : IsSeparable s) : SecondCountableTopology s := by
letI := pseudoMetrizableSpacePseudoMetric X
have := hs.separableSpace
exact UniformSpace.secondCountable_of_separable s
instance (X : Type*) [TopologicalSpace X] [c : CompactSpace X] [MetrizableSpace X] :
SecondCountableTopology X := by
obtain ⟨_, h⟩ := MetrizableSpace.exists_metric (X := X)
rw [← h] at c ⊢
infer_instance
end TopologicalSpace
|
Topology\Metrizable\ContinuousMap.lean | /-
Copyright (c) 2024 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Topology.Metrizable.Uniformity
import Mathlib.Topology.UniformSpace.CompactConvergence
/-!
# Metrizability of `C(X, Y)`
If `X` is a weakly locally compact σ-compact space and `Y` is a (pseudo)metrizable space,
then `C(X, Y)` is a (pseudo)metrizable space.
-/
open TopologicalSpace
namespace ContinuousMap
variable {X Y : Type*}
[TopologicalSpace X] [WeaklyLocallyCompactSpace X] [SigmaCompactSpace X]
[TopologicalSpace Y]
instance [PseudoMetrizableSpace Y] : PseudoMetrizableSpace C(X, Y) :=
let _ := pseudoMetrizableSpacePseudoMetric Y
inferInstance
instance [MetrizableSpace Y] : MetrizableSpace C(X, Y) :=
let _ := metrizableSpaceMetric Y
UniformSpace.metrizableSpace
end ContinuousMap
|
Topology\Metrizable\Uniformity.lean | /-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Topology.Metrizable.Basic
import Mathlib.Data.Nat.Lattice
/-!
# Metrizable uniform spaces
In this file we prove that a uniform space with countably generated uniformity filter is
pseudometrizable: there exists a `PseudoMetricSpace` structure that generates the same uniformity.
The proof follows [Sergey Melikhov, Metrizable uniform spaces][melikhov2011].
## Main definitions
* `PseudoMetricSpace.ofPreNNDist`: given a function `d : X → X → ℝ≥0` such that `d x x = 0` and
`d x y = d y x` for all `x y : X`, constructs the maximal pseudo metric space structure such that
`NNDist x y ≤ d x y` for all `x y : X`.
* `UniformSpace.pseudoMetricSpace`: given a uniform space `X` with countably generated `𝓤 X`,
constructs a `PseudoMetricSpace X` instance that is compatible with the uniform space structure.
* `UniformSpace.metricSpace`: given a T₀ uniform space `X` with countably generated `𝓤 X`,
constructs a `MetricSpace X` instance that is compatible with the uniform space structure.
## Main statements
* `UniformSpace.metrizable_uniformity`: if `X` is a uniform space with countably generated `𝓤 X`,
then there exists a `PseudoMetricSpace` structure that is compatible with this `UniformSpace`
structure. Use `UniformSpace.pseudoMetricSpace` or `UniformSpace.metricSpace` instead.
* `UniformSpace.pseudoMetrizableSpace`: a uniform space with countably generated `𝓤 X` is pseudo
metrizable.
* `UniformSpace.metrizableSpace`: a T₀ uniform space with countably generated `𝓤 X` is
metrizable. This is not an instance to avoid loops.
## Tags
metrizable space, uniform space
-/
open Set Function Metric List Filter
open NNReal Filter Uniformity
variable {X : Type*}
namespace PseudoMetricSpace
/-- The maximal pseudo metric space structure on `X` such that `dist x y ≤ d x y` for all `x y`,
where `d : X → X → ℝ≥0` is a function such that `d x x = 0` and `d x y = d y x` for all `x`, `y`. -/
noncomputable def ofPreNNDist (d : X → X → ℝ≥0) (dist_self : ∀ x, d x x = 0)
(dist_comm : ∀ x y, d x y = d y x) : PseudoMetricSpace X where
dist x y := ↑(⨅ l : List X, ((x::l).zipWith d (l ++ [y])).sum : ℝ≥0)
dist_self x := NNReal.coe_eq_zero.2 <|
nonpos_iff_eq_zero.1 <| (ciInf_le (OrderBot.bddBelow _) []).trans_eq <| by simp [dist_self]
dist_comm x y :=
NNReal.coe_inj.2 <| by
refine reverse_surjective.iInf_congr _ fun l ↦ ?_
rw [← sum_reverse, reverse_zipWith, reverse_append, reverse_reverse,
reverse_singleton, singleton_append, reverse_cons, reverse_reverse,
zipWith_comm_of_comm _ dist_comm]
simp only [length, length_append]
dist_triangle x y z := by
-- Porting note: added `unfold`
unfold dist
rw [← NNReal.coe_add, NNReal.coe_le_coe]
refine NNReal.le_iInf_add_iInf fun lxy lyz ↦ ?_
calc
⨅ l, (zipWith d (x::l) (l ++ [z])).sum ≤
(zipWith d (x::lxy ++ y::lyz) ((lxy ++ y::lyz) ++ [z])).sum :=
ciInf_le (OrderBot.bddBelow _) (lxy ++ y::lyz)
_ = (zipWith d (x::lxy) (lxy ++ [y])).sum + (zipWith d (y::lyz) (lyz ++ [z])).sum := by
rw [← sum_append, ← zipWith_append, cons_append, ← @singleton_append _ y, append_assoc,
append_assoc, append_assoc]
rw [length_cons, length_append, length_singleton]
-- Porting note: `edist_dist` is no longer inferred
edist_dist x y := rfl
theorem dist_ofPreNNDist (d : X → X → ℝ≥0) (dist_self : ∀ x, d x x = 0)
(dist_comm : ∀ x y, d x y = d y x) (x y : X) :
@dist X (@PseudoMetricSpace.toDist X (PseudoMetricSpace.ofPreNNDist d dist_self dist_comm)) x
y =
↑(⨅ l : List X, ((x::l).zipWith d (l ++ [y])).sum : ℝ≥0) :=
rfl
theorem dist_ofPreNNDist_le (d : X → X → ℝ≥0) (dist_self : ∀ x, d x x = 0)
(dist_comm : ∀ x y, d x y = d y x) (x y : X) :
@dist X (@PseudoMetricSpace.toDist X (PseudoMetricSpace.ofPreNNDist d dist_self dist_comm)) x
y ≤
d x y :=
NNReal.coe_le_coe.2 <| (ciInf_le (OrderBot.bddBelow _) []).trans_eq <| by simp
/-- Consider a function `d : X → X → ℝ≥0` such that `d x x = 0` and `d x y = d y x` for all `x`,
`y`. Let `dist` be the largest pseudometric distance such that `dist x y ≤ d x y`, see
`PseudoMetricSpace.ofPreNNDist`. Suppose that `d` satisfies the following triangle-like
inequality: `d x₁ x₄ ≤ 2 * max (d x₁ x₂, d x₂ x₃, d x₃ x₄)`. Then `d x y ≤ 2 * dist x y` for all
`x`, `y`. -/
theorem le_two_mul_dist_ofPreNNDist (d : X → X → ℝ≥0) (dist_self : ∀ x, d x x = 0)
(dist_comm : ∀ x y, d x y = d y x)
(hd : ∀ x₁ x₂ x₃ x₄, d x₁ x₄ ≤ 2 * max (d x₁ x₂) (max (d x₂ x₃) (d x₃ x₄))) (x y : X) :
↑(d x y) ≤ 2 * @dist X
(@PseudoMetricSpace.toDist X (PseudoMetricSpace.ofPreNNDist d dist_self dist_comm)) x y := by
/- We need to show that `d x y` is at most twice the sum `L` of `d xᵢ xᵢ₊₁` over a path
`x₀=x, ..., xₙ=y`. We prove it by induction on the length `n` of the sequence. Find an edge that
splits the path into two parts of almost equal length: both `d x₀ x₁ + ... + d xₖ₋₁ xₖ` and
`d xₖ₊₁ xₖ₊₂ + ... + d xₙ₋₁ xₙ` are less than or equal to `L / 2`.
Then `d x₀ xₖ ≤ L`, `d xₖ xₖ₊₁ ≤ L`, and `d xₖ₊₁ xₙ ≤ L`, thus `d x₀ xₙ ≤ 2 * L`. -/
rw [dist_ofPreNNDist, ← NNReal.coe_two, ← NNReal.coe_mul, NNReal.mul_iInf, NNReal.coe_le_coe]
refine le_ciInf fun l => ?_
have hd₀_trans : Transitive fun x y => d x y = 0 := by
intro a b c hab hbc
rw [← nonpos_iff_eq_zero]
simpa only [nonpos_iff_eq_zero, hab, hbc, dist_self c, max_self, mul_zero] using hd a b c c
haveI : IsTrans X fun x y => d x y = 0 := ⟨hd₀_trans⟩
induction' hn : length l using Nat.strong_induction_on with n ihn generalizing x y l
simp only at ihn
subst n
set L := zipWith d (x::l) (l ++ [y])
have hL_len : length L = length l + 1 := by simp [L]
rcases eq_or_ne (d x y) 0 with hd₀ | hd₀
· simp only [hd₀, zero_le]
rsuffices ⟨z, z', hxz, hzz', hz'y⟩ : ∃ z z' : X, d x z ≤ L.sum ∧ d z z' ≤ L.sum ∧ d z' y ≤ L.sum
· exact (hd x z z' y).trans (mul_le_mul_left' (max_le hxz (max_le hzz' hz'y)) _)
set s : Set ℕ := { m : ℕ | 2 * (take m L).sum ≤ L.sum }
have hs₀ : 0 ∈ s := by simp [s]
have hsne : s.Nonempty := ⟨0, hs₀⟩
obtain ⟨M, hMl, hMs⟩ : ∃ M ≤ length l, IsGreatest s M := by
have hs_ub : length l ∈ upperBounds s := by
intro m hm
rw [← not_lt, Nat.lt_iff_add_one_le, ← hL_len]
intro hLm
rw [mem_setOf_eq, take_of_length_le hLm, two_mul, add_le_iff_nonpos_left, nonpos_iff_eq_zero,
sum_eq_zero_iff, ← forall_iff_forall_mem, forall_zipWith,
← chain_append_singleton_iff_forall₂]
at hm <;>
[skip; simp]
exact hd₀ (hm.rel (mem_append.2 <| Or.inr <| mem_singleton_self _))
have hs_bdd : BddAbove s := ⟨length l, hs_ub⟩
exact ⟨sSup s, csSup_le hsne hs_ub, ⟨Nat.sSup_mem hsne hs_bdd, fun k => le_csSup hs_bdd⟩⟩
have hM_lt : M < length L := by rwa [hL_len, Nat.lt_succ_iff]
have hM_ltx : M < length (x::l) := lt_length_left_of_zipWith hM_lt
have hM_lty : M < length (l ++ [y]) := lt_length_right_of_zipWith hM_lt
refine ⟨(x::l)[M], (l ++ [y])[M], ?_, ?_, ?_⟩
· cases M with
| zero =>
simp [dist_self, List.get]
| succ M =>
rw [Nat.succ_le_iff] at hMl
have hMl' : length (take M l) = M := (length_take _ _).trans (min_eq_left hMl.le)
refine (ihn _ hMl _ _ _ hMl').trans ?_
convert hMs.1.out
rw [take_zipWith, take, take_succ, getElem?_append hMl, getElem?_eq_getElem hMl,
← Option.coe_def, Option.toList_some, take_append_of_le_length hMl.le, getElem_cons_succ]
· exact single_le_sum (fun x _ => zero_le x) _ (mem_iff_get.2 ⟨⟨M, hM_lt⟩, getElem_zipWith⟩)
· rcases hMl.eq_or_lt with (rfl | hMl)
· simp only [getElem_append_right' le_rfl, sub_self, getElem_singleton, dist_self, zero_le]
rw [getElem_append _ hMl]
have hlen : length (drop (M + 1) l) = length l - (M + 1) := length_drop _ _
have hlen_lt : length l - (M + 1) < length l := Nat.sub_lt_of_pos_le M.succ_pos hMl
refine (ihn _ hlen_lt _ y _ hlen).trans ?_
rw [cons_getElem_drop_succ]
have hMs' : L.sum ≤ 2 * (L.take (M + 1)).sum :=
not_lt.1 fun h => (hMs.2 h.le).not_lt M.lt_succ_self
rw [← sum_take_add_sum_drop L (M + 1), two_mul, add_le_add_iff_left, ← add_le_add_iff_right,
sum_take_add_sum_drop, ← two_mul] at hMs'
convert hMs'
rwa [drop_zipWith, drop, drop_append_of_le_length]
end PseudoMetricSpace
-- Porting note (#11083): this is slower than in Lean3 for some reason...
/-- If `X` is a uniform space with countably generated uniformity filter, there exists a
`PseudoMetricSpace` structure compatible with the `UniformSpace` structure. Use
`UniformSpace.pseudoMetricSpace` or `UniformSpace.metricSpace` instead. -/
protected theorem UniformSpace.metrizable_uniformity (X : Type*) [UniformSpace X]
[IsCountablyGenerated (𝓤 X)] : ∃ I : PseudoMetricSpace X, I.toUniformSpace = ‹_› := by
classical
/- Choose a fast decreasing antitone basis `U : ℕ → set (X × X)` of the uniformity filter `𝓤 X`.
Define `d x y : ℝ≥0` to be `(1 / 2) ^ n`, where `n` is the minimal index of `U n` that
separates `x` and `y`: `(x, y) ∉ U n`, or `0` if `x` is not separated from `y`. This function
satisfies the assumptions of `PseudoMetricSpace.ofPreNNDist` and
`PseudoMetricSpace.le_two_mul_dist_ofPreNNDist`, hence the distance given by the former pseudo
metric space structure is Lipschitz equivalent to the `d`. Thus the uniformities generated by
`d` and `dist` are equal. Since the former uniformity is equal to `𝓤 X`, the latter is equal to
`𝓤 X` as well. -/
obtain ⟨U, hU_symm, hU_comp, hB⟩ :
∃ U : ℕ → Set (X × X),
(∀ n, SymmetricRel (U n)) ∧
(∀ ⦃m n⦄, m < n → U n ○ (U n ○ U n) ⊆ U m) ∧ (𝓤 X).HasAntitoneBasis U := by
rcases UniformSpace.has_seq_basis X with ⟨V, hB, hV_symm⟩
rcases hB.subbasis_with_rel fun m =>
hB.tendsto_smallSets.eventually
(eventually_uniformity_iterate_comp_subset (hB.mem m) 2) with
⟨φ, -, hφ_comp, hφB⟩
exact ⟨V ∘ φ, fun n => hV_symm _, hφ_comp, hφB⟩
set d : X → X → ℝ≥0 := fun x y => if h : ∃ n, (x, y) ∉ U n then (1 / 2) ^ Nat.find h else 0
have hd₀ : ∀ {x y}, d x y = 0 ↔ Inseparable x y := by
intro x y
refine Iff.trans ?_ hB.inseparable_iff_uniformity.symm
simp only [d, true_imp_iff]
split_ifs with h
· rw [← not_forall] at h
simp [h, pow_eq_zero_iff']
· simpa only [not_exists, Classical.not_not, eq_self_iff_true, true_iff_iff] using h
have hd_symm : ∀ x y, d x y = d y x := by
intro x y
simp only [d, @SymmetricRel.mk_mem_comm _ _ (hU_symm _) x y]
have hr : (1 / 2 : ℝ≥0) ∈ Ioo (0 : ℝ≥0) 1 := ⟨half_pos one_pos, NNReal.half_lt_self one_ne_zero⟩
letI I := PseudoMetricSpace.ofPreNNDist d (fun x => hd₀.2 rfl) hd_symm
have hdist_le : ∀ x y, dist x y ≤ d x y := PseudoMetricSpace.dist_ofPreNNDist_le _ _ _
have hle_d : ∀ {x y : X} {n : ℕ}, (1 / 2) ^ n ≤ d x y ↔ (x, y) ∉ U n := by
intro x y n
dsimp only [d]
split_ifs with h
· rw [(pow_right_strictAnti hr.1 hr.2).le_iff_le, Nat.find_le_iff]
exact ⟨fun ⟨m, hmn, hm⟩ hn => hm (hB.antitone hmn hn), fun h => ⟨n, le_rfl, h⟩⟩
· push_neg at h
simp only [h, not_true, (pow_pos hr.1 _).not_le]
have hd_le : ∀ x y, ↑(d x y) ≤ 2 * dist x y := by
refine PseudoMetricSpace.le_two_mul_dist_ofPreNNDist _ _ _ fun x₁ x₂ x₃ x₄ => ?_
by_cases H : ∃ n, (x₁, x₄) ∉ U n
· refine (dif_pos H).trans_le ?_
rw [← NNReal.div_le_iff' two_ne_zero, ← mul_one_div (_ ^ _), ← pow_succ]
simp only [le_max_iff, hle_d, ← not_and_or]
rintro ⟨h₁₂, h₂₃, h₃₄⟩
refine Nat.find_spec H (hU_comp (lt_add_one <| Nat.find H) ?_)
exact ⟨x₂, h₁₂, x₃, h₂₃, h₃₄⟩
· exact (dif_neg H).trans_le (zero_le _)
-- Porting note: without the next line, `uniformity_basis_dist_pow` ends up introducing some
-- `Subtype.val` applications instead of `NNReal.toReal`.
rw [mem_Ioo, ← NNReal.coe_lt_coe, ← NNReal.coe_lt_coe] at hr
refine ⟨I, UniformSpace.ext <| (uniformity_basis_dist_pow hr.1 hr.2).ext hB.toHasBasis ?_ ?_⟩
· refine fun n hn => ⟨n, hn, fun x hx => (hdist_le _ _).trans_lt ?_⟩
rwa [← NNReal.coe_pow, NNReal.coe_lt_coe, ← not_le, hle_d, Classical.not_not]
· refine fun n _ => ⟨n + 1, trivial, fun x hx => ?_⟩
rw [mem_setOf_eq] at hx
contrapose! hx
refine le_trans ?_ ((div_le_iff' (zero_lt_two' ℝ)).2 (hd_le x.1 x.2))
rwa [← NNReal.coe_two, ← NNReal.coe_div, ← NNReal.coe_pow, NNReal.coe_le_coe, pow_succ,
mul_one_div, NNReal.div_le_iff two_ne_zero, div_mul_cancel₀ _ (two_ne_zero' ℝ≥0), hle_d]
/-- A `PseudoMetricSpace` instance compatible with a given `UniformSpace` structure. -/
protected noncomputable def UniformSpace.pseudoMetricSpace (X : Type*) [UniformSpace X]
[IsCountablyGenerated (𝓤 X)] : PseudoMetricSpace X :=
(UniformSpace.metrizable_uniformity X).choose.replaceUniformity <|
congr_arg _ (UniformSpace.metrizable_uniformity X).choose_spec.symm
/-- A `MetricSpace` instance compatible with a given `UniformSpace` structure. -/
protected noncomputable def UniformSpace.metricSpace (X : Type*) [UniformSpace X]
[IsCountablyGenerated (𝓤 X)] [T0Space X] : MetricSpace X :=
@MetricSpace.ofT0PseudoMetricSpace X (UniformSpace.pseudoMetricSpace X) _
/-- A uniform space with countably generated `𝓤 X` is pseudo metrizable. -/
instance (priority := 100) UniformSpace.pseudoMetrizableSpace [UniformSpace X]
[IsCountablyGenerated (𝓤 X)] : TopologicalSpace.PseudoMetrizableSpace X := by
letI := UniformSpace.pseudoMetricSpace X
infer_instance
/-- A T₀ uniform space with countably generated `𝓤 X` is metrizable. This is not an instance to
avoid loops. -/
theorem UniformSpace.metrizableSpace [UniformSpace X] [IsCountablyGenerated (𝓤 X)] [T0Space X] :
TopologicalSpace.MetrizableSpace X := by
letI := UniformSpace.metricSpace X
infer_instance
/-- A totally bounded set is separable in countably generated uniform spaces. This can be obtained
from the more general `EMetric.subset_countable_closure_of_almost_dense_set`.-/
lemma TotallyBounded.isSeparable [UniformSpace X] [i : IsCountablyGenerated (𝓤 X)]
{s : Set X} (h : TotallyBounded s) : TopologicalSpace.IsSeparable s := by
letI := (UniformSpace.pseudoMetricSpace (X := X)).toPseudoEMetricSpace
rw [EMetric.totallyBounded_iff] at h
have h' : ∀ ε > 0, ∃ t, Set.Countable t ∧ s ⊆ ⋃ y ∈ t, EMetric.closedBall y ε := by
intro ε hε
obtain ⟨t, ht⟩ := h ε hε
refine ⟨t, ht.1.countable, subset_trans ht.2 ?_⟩
gcongr
exact EMetric.ball_subset_closedBall
obtain ⟨t, _, htc, hts⟩ := EMetric.subset_countable_closure_of_almost_dense_set s h'
exact ⟨t, htc, hts⟩
|
Topology\Metrizable\Urysohn.lean | /-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.Topology.UrysohnsLemma
import Mathlib.Topology.ContinuousFunction.Bounded
import Mathlib.Topology.Metrizable.Basic
/-!
# Urysohn's Metrization Theorem
In this file we prove Urysohn's Metrization Theorem:
a T₃ topological space with second countable topology `X` is metrizable.
First we prove that `X` can be embedded into `l^∞`, then use this embedding to pull back the metric
space structure.
## Implementation notes
We use `ℕ →ᵇ ℝ`, not `lpSpace` for `l^∞` to avoid heavy imports.
-/
open Set Filter Metric
open scoped Topology BoundedContinuousFunction
namespace TopologicalSpace
section RegularSpace
variable (X : Type*) [TopologicalSpace X] [RegularSpace X] [SecondCountableTopology X]
/-- For a regular topological space with second countable topology,
there exists an inducing map to `l^∞ = ℕ →ᵇ ℝ`. -/
theorem exists_inducing_l_infty : ∃ f : X → ℕ →ᵇ ℝ, Inducing f := by
-- Choose a countable basis, and consider the set `s` of pairs of set `(U, V)` such that `U ∈ B`,
-- `V ∈ B`, and `closure U ⊆ V`.
rcases exists_countable_basis X with ⟨B, hBc, -, hB⟩
let s : Set (Set X × Set X) := { UV ∈ B ×ˢ B | closure UV.1 ⊆ UV.2 }
-- `s` is a countable set.
haveI : Encodable s := ((hBc.prod hBc).mono inter_subset_left).toEncodable
-- We don't have the space of bounded (possibly discontinuous) functions, so we equip `s`
-- with the discrete topology and deal with `s →ᵇ ℝ` instead.
letI : TopologicalSpace s := ⊥
haveI : DiscreteTopology s := ⟨rfl⟩
rsuffices ⟨f, hf⟩ : ∃ f : X → s →ᵇ ℝ, Inducing f
· exact ⟨fun x => (f x).extend (Encodable.encode' s) 0,
(BoundedContinuousFunction.isometry_extend (Encodable.encode' s)
(0 : ℕ →ᵇ ℝ)).embedding.toInducing.comp hf⟩
have hd : ∀ UV : s, Disjoint (closure UV.1.1) UV.1.2ᶜ :=
fun UV => disjoint_compl_right.mono_right (compl_subset_compl.2 UV.2.2)
-- Choose a sequence of `εₙ > 0`, `n : s`, that is bounded above by `1` and tends to zero
-- along the `cofinite` filter.
obtain ⟨ε, ε01, hε⟩ : ∃ ε : s → ℝ, (∀ UV, ε UV ∈ Ioc (0 : ℝ) 1) ∧ Tendsto ε cofinite (𝓝 0) := by
rcases posSumOfEncodable zero_lt_one s with ⟨ε, ε0, c, hεc, hc1⟩
refine ⟨ε, fun UV => ⟨ε0 UV, ?_⟩, hεc.summable.tendsto_cofinite_zero⟩
exact (le_hasSum hεc UV fun _ _ => (ε0 _).le).trans hc1
/- For each `UV = (U, V) ∈ s` we use Urysohn's lemma to choose a function `f UV` that is equal to
zero on `U` and is equal to `ε UV` on the complement to `V`. -/
have : ∀ UV : s, ∃ f : C(X, ℝ),
EqOn f 0 UV.1.1 ∧ EqOn f (fun _ => ε UV) UV.1.2ᶜ ∧ ∀ x, f x ∈ Icc 0 (ε UV) := by
intro UV
rcases exists_continuous_zero_one_of_isClosed isClosed_closure
(hB.isOpen UV.2.1.2).isClosed_compl (hd UV) with
⟨f, hf₀, hf₁, hf01⟩
exact ⟨ε UV • f, fun x hx => by simp [hf₀ (subset_closure hx)], fun x hx => by simp [hf₁ hx],
fun x => ⟨mul_nonneg (ε01 _).1.le (hf01 _).1, mul_le_of_le_one_right (ε01 _).1.le (hf01 _).2⟩⟩
choose f hf0 hfε hf0ε using this
have hf01 : ∀ UV x, f UV x ∈ Icc (0 : ℝ) 1 :=
fun UV x => Icc_subset_Icc_right (ε01 _).2 (hf0ε _ _)
-- The embedding is given by `F x UV = f UV x`.
set F : X → s →ᵇ ℝ := fun x =>
⟨⟨fun UV => f UV x, continuous_of_discreteTopology⟩, 1,
fun UV₁ UV₂ => Real.dist_le_of_mem_Icc_01 (hf01 _ _) (hf01 _ _)⟩
have hF : ∀ x UV, F x UV = f UV x := fun _ _ => rfl
refine ⟨F, inducing_iff_nhds.2 fun x => le_antisymm ?_ ?_⟩
· /- First we prove that `F` is continuous. Given `δ > 0`, consider the set `T` of `(U, V) ∈ s`
such that `ε (U, V) ≥ δ`. Since `ε` tends to zero, `T` is finite. Since each `f` is continuous,
we can choose a neighborhood such that `dist (F y (U, V)) (F x (U, V)) ≤ δ` for any
`(U, V) ∈ T`. For `(U, V) ∉ T`, the same inequality is true because both `F y (U, V)` and
`F x (U, V)` belong to the interval `[0, ε (U, V)]`. -/
refine (nhds_basis_closedBall.comap _).ge_iff.2 fun δ δ0 => ?_
have h_fin : { UV : s | δ ≤ ε UV }.Finite := by simpa only [← not_lt] using hε (gt_mem_nhds δ0)
have : ∀ᶠ y in 𝓝 x, ∀ UV, δ ≤ ε UV → dist (F y UV) (F x UV) ≤ δ := by
refine (eventually_all_finite h_fin).2 fun UV _ => ?_
exact (f UV).continuous.tendsto x (closedBall_mem_nhds _ δ0)
refine this.mono fun y hy => (BoundedContinuousFunction.dist_le δ0.le).2 fun UV => ?_
rcases le_total δ (ε UV) with hle | hle
exacts [hy _ hle, (Real.dist_le_of_mem_Icc (hf0ε _ _) (hf0ε _ _)).trans (by rwa [sub_zero])]
· /- Finally, we prove that each neighborhood `V` of `x : X`
includes a preimage of a neighborhood of `F x` under `F`.
Without loss of generality, `V` belongs to `B`.
Choose `U ∈ B` such that `x ∈ V` and `closure V ⊆ U`.
Then the preimage of the `(ε (U, V))`-neighborhood of `F x` is included by `V`. -/
refine ((nhds_basis_ball.comap _).le_basis_iff hB.nhds_hasBasis).2 ?_
rintro V ⟨hVB, hxV⟩
rcases hB.exists_closure_subset (hB.mem_nhds hVB hxV) with ⟨U, hUB, hxU, hUV⟩
set UV : ↥s := ⟨(U, V), ⟨hUB, hVB⟩, hUV⟩
refine ⟨ε UV, (ε01 UV).1, fun y (hy : dist (F y) (F x) < ε UV) => ?_⟩
replace hy : dist (F y UV) (F x UV) < ε UV :=
(BoundedContinuousFunction.dist_coe_le_dist _).trans_lt hy
contrapose! hy
rw [hF, hF, hfε UV hy, hf0 UV hxU, Pi.zero_apply, dist_zero_right]
exact le_abs_self _
/-- *Urysohn's metrization theorem* (Tychonoff's version):
a regular topological space with second countable topology `X` is metrizable,
i.e., there exists a pseudometric space structure that generates the same topology. -/
instance (priority := 90) PseudoMetrizableSpace.of_regularSpace_secondCountableTopology :
PseudoMetrizableSpace X :=
let ⟨_, hf⟩ := exists_inducing_l_infty X
hf.pseudoMetrizableSpace
end RegularSpace
variable (X : Type*) [TopologicalSpace X] [T3Space X] [SecondCountableTopology X]
/-- A T₃ topological space with second countable topology can be embedded into `l^∞ = ℕ →ᵇ ℝ`. -/
theorem exists_embedding_l_infty : ∃ f : X → ℕ →ᵇ ℝ, Embedding f :=
let ⟨f, hf⟩ := exists_inducing_l_infty X; ⟨f, hf.embedding⟩
/-- *Urysohn's metrization theorem* (Tychonoff's version): a T₃ topological space with second
countable topology `X` is metrizable, i.e., there exists a metric space structure that generates the
same topology. -/
instance (priority := 90) metrizableSpace_of_t3_second_countable : MetrizableSpace X :=
let ⟨_, hf⟩ := exists_embedding_l_infty X
hf.metrizableSpace
end TopologicalSpace
|
Topology\Order\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, Yury Kudryashov
-/
import Mathlib.Order.Filter.Interval
import Mathlib.Order.Interval.Set.Pi
import Mathlib.Tactic.TFAE
import Mathlib.Tactic.NormNum
import Mathlib.Topology.Order.LeftRight
import Mathlib.Topology.Order.OrderClosed
/-!
# Theory of topology on ordered spaces
## Main definitions
The order topology on an ordered space is the topology generated by all open intervals (or
equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`.
However, we do *not* register it as an instance (as many existing ordered types already have
topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead,
we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on
the type `α` having already a topological space structure and a preorder structure, the topological
structure is equal to the order topology.
We prove many basic properties of such topologies.
## Main statements
This file contains the proofs of the following facts. For exact requirements
(`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc)
see their statements.
* `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any
neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood
of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`.
* `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem,
sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h`
both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`.
## Implementation notes
We do _not_ register the order topology as an instance on a preorder (or even on a linear order).
Indeed, on many such spaces, a topology has already been constructed in a different way (think
of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`),
and is in general not defeq to the one generated by the intervals. We make it available as a
definition `Preorder.topology α` though, that can be registered as an instance when necessary, or
for specific types.
-/
open Set Filter TopologicalSpace Topology Function
open OrderDual (toDual ofDual)
universe u v w
variable {α : Type u} {β : Type v} {γ : Type w}
-- Porting note (#11215): TODO: define `Preorder.topology` before `OrderTopology` and reuse the def
/-- The order topology on an ordered type is the topology generated by open intervals. We register
it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed.
We define it as a mixin. If you want to introduce the order topology on a preorder, use
`Preorder.topology`. -/
class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where
/-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/
topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a }
/-- (Order) topology on a partial order `α` generated by the subbase of open intervals
`(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an
instance as many ordered sets are already endowed with the same topology, most often in a non-defeq
way though. Register as a local instance when necessary. -/
def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α :=
generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } }
section OrderTopology
section Preorder
variable [TopologicalSpace α] [Preorder α]
instance [t : OrderTopology α] : OrderTopology αᵒᵈ :=
⟨by
convert OrderTopology.topology_eq_generate_intervals (α := α) using 6
apply or_comm⟩
theorem isOpen_iff_generate_intervals [t : OrderTopology α] {s : Set α} :
IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by
rw [t.topology_eq_generate_intervals]; rfl
theorem isOpen_lt' [OrderTopology α] (a : α) : IsOpen { b : α | a < b } :=
isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩
theorem isOpen_gt' [OrderTopology α] (a : α) : IsOpen { b : α | b < a } :=
isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩
theorem lt_mem_nhds [OrderTopology α] {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x :=
(isOpen_lt' _).mem_nhds h
theorem le_mem_nhds [OrderTopology α] {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x :=
(lt_mem_nhds h).mono fun _ => le_of_lt
theorem gt_mem_nhds [OrderTopology α] {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b :=
(isOpen_gt' _).mem_nhds h
theorem ge_mem_nhds [OrderTopology α] {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b :=
(gt_mem_nhds h).mono fun _ => le_of_lt
theorem nhds_eq_order [OrderTopology α] (a : α) :
𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by
rw [OrderTopology.topology_eq_generate_intervals (α := α), nhds_generateFrom]
simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and,
iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio]
theorem tendsto_order [OrderTopology α] {f : β → α} {a : α} {x : Filter β} :
Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by
simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl
instance tendstoIccClassNhds [OrderTopology α] (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by
simp only [nhds_eq_order, iInf_subtype']
refine
((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass
fun s _ => ?_
refine ((ordConnected_biInter ?_).inter (ordConnected_biInter ?_)).out <;> intro _ _
exacts [ordConnected_Ioi, ordConnected_Iio]
instance tendstoIcoClassNhds [OrderTopology α] (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) :=
tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self
instance tendstoIocClassNhds [OrderTopology α] (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) :=
tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self
instance tendstoIooClassNhds [OrderTopology α] (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) :=
tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self
/-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities
hold eventually for the filter. -/
theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' [OrderTopology α] {f g h : β → α} {b : Filter β}
{a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b)
(hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) :=
(hg.Icc hh).of_smallSets <| hgf.and hfh
/-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities
hold everywhere. -/
theorem tendsto_of_tendsto_of_tendsto_of_le_of_le [OrderTopology α] {f g h : β → α} {b : Filter β}
{a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) :
Tendsto f b (𝓝 a) :=
tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf)
(eventually_of_forall hfh)
theorem nhds_order_unbounded [OrderTopology α] {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) :
𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by
simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl
theorem tendsto_order_unbounded [OrderTopology α] {f : β → α} {a : α} {x : Filter β}
(hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) :
Tendsto f x (𝓝 a) := by
simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal]
exact fun l hl u => h l u hl
end Preorder
instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α}
{Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] :
TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) :=
Filter.tendstoIxxClass_inf
instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)]
[∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) :
TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by
constructor
conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi]
simp only [smallSets_iInf, smallSets_comap_eq_comap_image, tendsto_iInf, tendsto_comap_iff]
intro i
have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f
refine (this.comp tendsto_fst).Icc (this.comp tendsto_snd) |>.smallSets_mono ?_
filter_upwards [] using fun ⟨f, g⟩ ↦ image_subset_iff.mpr fun p hp ↦ ⟨hp.1 i, hp.2 i⟩
theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β]
[OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) :
induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by
let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩
refine le_of_nhds_le_nhds fun x => ?_
simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf]
refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_)
exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha]
theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β]
[OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y)
(H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y)
(H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) :
induced f ‹TopologicalSpace β› = Preorder.topology α := by
let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩
refine le_antisymm (induced_topology_le_preorder hf) ?_
refine le_of_nhds_le_nhds fun a => ?_
simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal]
refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_)
· rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb)
· rcases H₁ hb hx with ⟨y, hya, hyb⟩
exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz))
· push_neg at hb
exact le_principal_iff.2 (univ_mem' hb)
· rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb)
· rcases H₂ hb hx with ⟨y, hya, hyb⟩
exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb)
· push_neg at hb
exact le_principal_iff.2 (univ_mem' hb)
theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β]
[Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y)
(H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) :
@OrderTopology _ (induced f ta) _ :=
let _ := induced f ta
⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩
theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β]
[Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y)
(H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ :=
induced_orderTopology' f (hf)
(fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩)
fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩
/-- The topology induced by a strictly monotone function with order-connected range is the preorder
topology. -/
nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α]
[LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β}
(hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by
refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_
· rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩
exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩
· rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩
exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩
/-- A strictly monotone function between linear orders with order topology is a topological
embedding provided that the range of `f` is order-connected. -/
theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β]
[TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β}
(hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f :=
⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩
/-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the
order is the same as the restriction to the subset of the order topology. -/
instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α]
[OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t :=
⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder <| by
rwa [← @Subtype.range_val _ t] at ht⟩
theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) :
𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by
rw [nhdsWithin, nhds_eq_order]
refine le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf ?_ inf_le_left) inf_le_right)
exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl)
theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) :
𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) :=
nhdsWithin_Ici_eq'' (toDual a)
theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α}
(ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by
simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici]
theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α}
(ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by
simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic]
theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α}
(ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u :=
(nhdsWithin_Ici_eq' ha).symm ▸
hasBasis_biInf_principal
(fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _),
Ico_subset_Ico_right (min_le_right _ _)⟩)
ha
theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α}
(ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by
convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2
exact dual_Ico.symm
theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α]
(a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u :=
nhdsWithin_Ici_basis' (exists_gt a)
theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α]
(a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a :=
nhdsWithin_Iic_basis' (exists_lt a)
theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] :
𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)]
theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] :
𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)]
theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α]
[Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by
have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top
simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this
theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α]
[Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a :=
nhds_top_basis (α := αᵒᵈ)
theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α]
[Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici :=
nhds_top_basis.to_hasBasis
(fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩)
fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩
theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α]
[Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic :=
nhds_top_basis_Ici (α := αᵒᵈ)
theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β]
{l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by
simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢
intro x hx
filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le
theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β]
{l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) :=
tendsto_nhds_top_mono (β := βᵒᵈ) hf hg
theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β]
{l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) :=
tendsto_nhds_top_mono hf (eventually_of_forall hg)
theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β]
{l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) :=
tendsto_nhds_bot_mono hf (eventually_of_forall hg)
section LinearOrder
variable [TopologicalSpace α] [LinearOrder α]
section OrderTopology
theorem order_separated [OrderTopology α] {a₁ a₂ : α} (h : a₁ < a₂) :
∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ :=
let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi
⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩
-- see Note [lower instance priority]
instance (priority := 100) OrderTopology.to_orderClosedTopology [OrderTopology α] :
OrderClosedTopology α where
isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) =>
have h : a₂ < a₁ := lt_of_not_ge h
let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h
⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩
theorem exists_Ioc_subset_of_mem_nhds [OrderTopology α] {a : α} {s : Set α} (hs : s ∈ 𝓝 a)
(h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s :=
(nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs)
theorem exists_Ioc_subset_of_mem_nhds' [OrderTopology α] {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α}
(hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s :=
let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩
⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩,
(Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩
theorem exists_Ico_subset_of_mem_nhds' [OrderTopology α] {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α}
(hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by
simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using
exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual
theorem exists_Ico_subset_of_mem_nhds [OrderTopology α] {a : α} {s : Set α} (hs : s ∈ 𝓝 a)
(h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s :=
let ⟨_l', hl'⟩ := h
let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl'
⟨l, hl.1.1, hl.2⟩
theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici [OrderTopology α] {a : α} {s : Set α}
(hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by
rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha)
· use a
simpa [ha.Ici_eq] using hs
· rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩
rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩)
· have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty]
exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩
· refine ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, ?_⟩
exact (Icc_subset_Ico_right hcb).trans hbs
theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic [OrderTopology α] {a : α} {s : Set α}
(hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by
simpa only [dual_Icc, toDual.surjective.exists] using
exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs
theorem exists_Icc_mem_subset_of_mem_nhds [OrderTopology α] {a : α} {s : Set α} (hs : s ∈ 𝓝 a) :
∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by
rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with
⟨b, hba, hb_nhds, hbs⟩
rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with
⟨c, hac, hc_nhds, hcs⟩
refine ⟨b, c, ⟨hba, hac⟩, ?_⟩
rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right]
exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩
theorem IsOpen.exists_Ioo_subset [OrderTopology α] [Nontrivial α] {s : Set α} (hs : IsOpen s)
(h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by
obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h
obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x
rcases lt_trichotomy x y with (H | rfl | H)
· obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s :=
exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩
exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩
· exact (hy rfl).elim
· obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s :=
exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩
exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩
theorem dense_of_exists_between [OrderTopology α] [Nontrivial α] {s : Set α}
(h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by
refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_
obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty
obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab
exact ⟨x, ⟨H hx, xs⟩⟩
/-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only
if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass
assumptions. -/
theorem dense_iff_exists_between [OrderTopology α] [DenselyOrdered α] [Nontrivial α] {s : Set α} :
Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b :=
⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩
/-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`,
provided `a` is neither a bottom element nor a top element. -/
theorem mem_nhds_iff_exists_Ioo_subset' [OrderTopology α] {a : α} {s : Set α} (hl : ∃ l, l < a)
(hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by
constructor
· intro h
rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩
rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩
exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩
· rintro ⟨l, u, ha, h⟩
apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h
/-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`.
-/
theorem mem_nhds_iff_exists_Ioo_subset [OrderTopology α] [NoMaxOrder α] [NoMinOrder α] {a : α}
{s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s :=
mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a)
theorem nhds_basis_Ioo' [OrderTopology α] {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) :
(𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 :=
⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩
theorem nhds_basis_Ioo [OrderTopology α] [NoMaxOrder α] [NoMinOrder α] (a : α) :
(𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 :=
nhds_basis_Ioo' (exists_lt a) (exists_gt a)
theorem Filter.Eventually.exists_Ioo_subset [OrderTopology α] [NoMaxOrder α] [NoMinOrder α] {a : α}
{p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } :=
mem_nhds_iff_exists_Ioo_subset.1 hp
theorem Dense.topology_eq_generateFrom [OrderTopology α] [DenselyOrdered α] {s : Set α}
(hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by
refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_
refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_)
· simp only [union_subset_iff, image_subset_iff]
exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩
· rintro _ ⟨a, rfl | rfl⟩
· rw [hs.Ioi_eq_biUnion]
let _ := generateFrom (Ioi '' s ∪ Iio '' s)
exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1
· rw [hs.Iio_eq_biUnion]
let _ := generateFrom (Ioi '' s ∪ Iio '' s)
exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1
@[deprecated OrderBot.atBot_eq (since := "2024-02-14")]
theorem atBot_le_nhds_bot [OrderBot α] : (atBot : Filter α) ≤ 𝓝 ⊥ := by
rw [OrderBot.atBot_eq]
apply pure_le_nhds
@[deprecated OrderTop.atTop_eq (since := "2024-02-14")]
theorem atTop_le_nhds_top [OrderTop α] : (atTop : Filter α) ≤ 𝓝 ⊤ :=
set_option linter.deprecated false in @atBot_le_nhds_bot αᵒᵈ _ _ _
variable (α)
/-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then
it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see
[double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/
theorem SecondCountableTopology.of_separableSpace_orderTopology [OrderTopology α] [DenselyOrdered α]
[SeparableSpace α] : SecondCountableTopology α := by
rcases exists_countable_dense α with ⟨s, hc, hd⟩
refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩
exact (hc.image _).union (hc.image _)
variable {α}
/-- The set of points which are isolated on the right is countable when the space is
second-countable. -/
theorem countable_setOf_covBy_right [OrderTopology α] [SecondCountableTopology α] :
Set.Countable { x : α | ∃ y, x ⋖ y } := by
nontriviality α
let s := { x : α | ∃ y, x ⋖ y }
have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id
choose! y hy using this
have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt
suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } by
have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by
rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩
exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩
refine Set.Countable.mono this ?_
refine Countable.biUnion (countable_countableBasis α) fun a ha => H _ ?_
exact isOpen_of_mem_countableBasis ha
intro a ha
suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } from
H.of_diff (subsingleton_isBot α).countable
simp only [and_assoc]
let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x }
have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by
intro x hx
apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1)
simpa only [IsBot, not_forall, not_le] using hx.right.right.right
choose! z hz h'z using this
have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by
rcases hxx'.lt_or_lt with (h' | h')
· refine disjoint_left.2 fun u ux ux' => xt.2.2.1 ?_
refine h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), ?_⟩
by_contra! H
exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h')
· refine disjoint_left.2 fun u ux ux' => x't.2.2.1 ?_
refine h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), ?_⟩
by_contra! H
exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h')
refine this.countable_of_isOpen (fun x hx => ?_) fun x hx => ⟨x, hz x hx, le_rfl⟩
suffices H : Ioc (z x) x = Ioo (z x) (y x) by
rw [H]
exact isOpen_Ioo
exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩
/-- The set of points which are isolated on the left is countable when the space is
second-countable. -/
theorem countable_setOf_covBy_left [OrderTopology α] [SecondCountableTopology α] :
Set.Countable { x : α | ∃ y, y ⋖ x } := by
convert countable_setOf_covBy_right (α := αᵒᵈ) using 5
exact toDual_covBy_toDual_iff.symm
/-- The set of points which are isolated on the left is countable when the space is
second-countable. -/
theorem countable_of_isolated_left' [OrderTopology α] [SecondCountableTopology α] :
Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by
simpa only [← covBy_iff_Ioo_eq] using countable_setOf_covBy_left
/-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space.
Then the family is countable.
This is not a straightforward consequence of second-countability as some of these intervals might be
empty (but in fact this can happen only for countably many of them). -/
theorem Set.PairwiseDisjoint.countable_of_Ioo [OrderTopology α] [SecondCountableTopology α]
{y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x))
(h' : ∀ x ∈ s, x < y x) : s.Countable :=
have : (s \ { x | ∃ y, x ⋖ y }).Countable :=
(h.subset diff_subset).countable_of_isOpen (fun _ _ => isOpen_Ioo)
fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2)
this.of_diff countable_setOf_covBy_right
/-- For a function taking values in a second countable space, the set of points `x` for
which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/
theorem countable_image_lt_image_Ioi [OrderTopology α] [LinearOrder β] (f : β → α)
[SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by
/- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)`
which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a
family can only be countable as `α` is second-countable. -/
nontriviality β
have : Nonempty α := Nonempty.map f (by infer_instance)
let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx
-- choose `z x` such that `f` does not take the values in `(f x, z x)`.
choose! z hz using this
have I : InjOn f s := by
apply StrictMonoOn.injOn
intro x hx y _ hxy
calc
f x < z x := (hz x hx).1
_ ≤ f y := (hz x hx).2 y hxy
-- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals
-- (the intervals `(f x, z x)`) is at most countable.
have fs_count : (f '' s).Countable := by
have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by
rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv
wlog hle : u ≤ v generalizing u v
· exact (this v vs u us huv.symm (le_of_not_le hle)).symm
have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv)
apply disjoint_iff_forall_ne.2
rintro a ha b hb rfl
simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb
exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1)
apply Set.PairwiseDisjoint.countable_of_Ioo A
rintro _ ⟨y, ys, rfl⟩
simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1
exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count
/-- For a function taking values in a second countable space, the set of points `x` for
which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/
theorem countable_image_gt_image_Ioi [OrderTopology α] [LinearOrder β] (f : β → α)
[SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} :=
countable_image_lt_image_Ioi (α := αᵒᵈ) f
/-- For a function taking values in a second countable space, the set of points `x` for
which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/
theorem countable_image_lt_image_Iio [OrderTopology α] [LinearOrder β] (f : β → α)
[SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} :=
countable_image_lt_image_Ioi (β := βᵒᵈ) f
/-- For a function taking values in a second countable space, the set of points `x` for
which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/
theorem countable_image_gt_image_Iio [OrderTopology α] [LinearOrder β] (f : β → α)
[SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} :=
countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f
instance instIsCountablyGenerated_atTop [OrderTopology α] [SecondCountableTopology α] :
IsCountablyGenerated (atTop : Filter α) := by
by_cases h : ∃ (x : α), IsTop x
· rcases h with ⟨x, hx⟩
rw [atTop_eq_pure_of_isTop hx]
exact isCountablyGenerated_pure x
· rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩
have : Countable b := by exact Iff.mpr countable_coe_iff b_count
have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by
intro s
have : (s : Set α) ≠ ∅ := by
intro H
apply b_ne
convert s.2
exact H.symm
exact Iff.mp nmem_singleton_empty this
choose a ha using A
have : (atTop : Filter α) = (generate (Ici '' (range a))) := by
apply atTop_eq_generate_of_not_bddAbove
intro ⟨x, hx⟩
simp only [IsTop, not_exists, not_forall, not_le] at h
rcases h x with ⟨y, hy⟩
obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x :=
hb.exists_subset_of_mem_open hy isOpen_Ioi
have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _)
have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩)
exact lt_irrefl _ (I.trans_lt J)
rw [this]
exact ⟨_, (countable_range _).image _, rfl⟩
instance instIsCountablyGenerated_atBot [OrderTopology α] [SecondCountableTopology α] :
IsCountablyGenerated (atBot : Filter α) :=
@instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _
section Pi
/-!
### Intervals in `Π i, π i` belong to `𝓝 x`
For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because
sometimes Lean fails to unify different instances while trying to apply the dependent version to,
e.g., `ι → ℝ`.
-/
variable [OrderTopology α] {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)]
[∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α}
theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x :=
pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _)
theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' :=
pi_Iic_mem_nhds ha
theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x :=
pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _)
theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' :=
pi_Ici_mem_nhds ha
theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x :=
pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _)
theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' :=
pi_Icc_mem_nhds ha hb
variable [Nonempty ι]
theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := mem_of_superset
(set_pi_mem_nhds finite_univ fun i _ ↦ Iio_mem_nhds (ha i)) (pi_univ_Iio_subset a)
theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' :=
pi_Iio_mem_nhds ha
theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x :=
pi_Iio_mem_nhds (π := fun i => (π i)ᵒᵈ) ha
theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' :=
pi_Ioi_mem_nhds ha
theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by
refine mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => ?_) (pi_univ_Ioc_subset a b)
exact Ioc_mem_nhds (ha i) (hb i)
theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' :=
pi_Ioc_mem_nhds ha hb
theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by
refine mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => ?_) (pi_univ_Ico_subset a b)
exact Ico_mem_nhds (ha i) (hb i)
theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' :=
pi_Ico_mem_nhds ha hb
theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by
refine mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => ?_) (pi_univ_Ioo_subset a b)
exact Ioo_mem_nhds (ha i) (hb i)
theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' :=
pi_Ioo_mem_nhds ha hb
end Pi
end OrderTopology
end LinearOrder
end OrderTopology
|
Topology\Order\Bornology.lean | /-
Copyright (c) 2024 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Topology.Bornology.Constructions
/-!
# Bornology of order-bounded sets
This file relates the notion of bornology-boundedness (sets that lie in a bornology) to the notion
of order-boundedness (sets that are bounded above and below).
## Main declarations
* `orderBornology`: The bornology of order-bounded sets of a nonempty lattice.
* `IsOrderBornology`: Typeclass predicate for a preorder to be equipped with its order-bornology.
-/
open Bornology Set
variable {α : Type*} {s t : Set α}
section Lattice
variable [Lattice α] [Nonempty α]
/-- Order-bornology on a nonempty lattice. The bounded sets are the sets that are bounded both above
and below. -/
def orderBornology : Bornology α := .ofBounded
{s | BddBelow s ∧ BddAbove s}
(by simp)
(fun s hs t hst ↦ ⟨hs.1.mono hst, hs.2.mono hst⟩)
(fun s hs t ht ↦ ⟨hs.1.union ht.1, hs.2.union ht.2⟩)
(by simp)
@[simp] lemma orderBornology_isBounded : orderBornology.IsBounded s ↔ BddBelow s ∧ BddAbove s := by
simp [IsBounded, IsCobounded, -isCobounded_compl_iff]
end Lattice
variable [Bornology α]
variable (α) [Preorder α] in
/-- Predicate for a preorder to be equipped with its order-bornology, namely for its bounded sets
to be the ones that are bounded both above and below. -/
class IsOrderBornology : Prop where
protected isBounded_iff_bddBelow_bddAbove (s : Set α) : IsBounded s ↔ BddBelow s ∧ BddAbove s
lemma isOrderBornology_iff_eq_orderBornology [Lattice α] [Nonempty α] :
IsOrderBornology α ↔ ‹Bornology α› = orderBornology := by
refine ⟨fun h ↦ ?_, fun h ↦ ⟨fun s ↦ by rw [h, orderBornology_isBounded]⟩⟩
ext s
exact isBounded_compl_iff.symm.trans (h.1 _)
section Preorder
variable [Preorder α] [IsOrderBornology α]
lemma isBounded_iff_bddBelow_bddAbove : IsBounded s ↔ BddBelow s ∧ BddAbove s :=
IsOrderBornology.isBounded_iff_bddBelow_bddAbove _
protected lemma Bornology.IsBounded.bddBelow (hs : IsBounded s) : BddBelow s :=
(isBounded_iff_bddBelow_bddAbove.1 hs).1
protected lemma Bornology.IsBounded.bddAbove (hs : IsBounded s) : BddAbove s :=
(isBounded_iff_bddBelow_bddAbove.1 hs).2
protected lemma BddBelow.isBounded (hs₀ : BddBelow s) (hs₁ : BddAbove s) : IsBounded s :=
isBounded_iff_bddBelow_bddAbove.2 ⟨hs₀, hs₁⟩
protected lemma BddAbove.isBounded (hs₀ : BddAbove s) (hs₁ : BddBelow s) : IsBounded s :=
isBounded_iff_bddBelow_bddAbove.2 ⟨hs₁, hs₀⟩
lemma BddBelow.isBounded_inter (hs : BddBelow s) (ht : BddAbove t) : IsBounded (s ∩ t) :=
(hs.mono inter_subset_left).isBounded $ ht.mono inter_subset_right
lemma BddAbove.isBounded_inter (hs : BddAbove s) (ht : BddBelow t) : IsBounded (s ∩ t) :=
(hs.mono inter_subset_left).isBounded $ ht.mono inter_subset_right
instance OrderDual.instIsOrderBornology : IsOrderBornology αᵒᵈ where
isBounded_iff_bddBelow_bddAbove s := by
rw [← isBounded_preimage_toDual, ← bddBelow_preimage_toDual, ← bddAbove_preimage_toDual,
isBounded_iff_bddBelow_bddAbove, and_comm]
instance Prod.instIsOrderBornology {β : Type*} [Preorder β] [Bornology β] [IsOrderBornology β] :
IsOrderBornology (α × β) where
isBounded_iff_bddBelow_bddAbove s := by
rw [← isBounded_image_fst_and_snd, bddBelow_prod, bddAbove_prod, and_and_and_comm,
isBounded_iff_bddBelow_bddAbove, isBounded_iff_bddBelow_bddAbove]
instance Pi.instIsOrderBornology {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)]
[∀ i, Bornology (α i)] [∀ i, IsOrderBornology (α i)] : IsOrderBornology (∀ i, α i) where
isBounded_iff_bddBelow_bddAbove s := by
simp_rw [← forall_isBounded_image_eval_iff, bddBelow_pi, bddAbove_pi, ← forall_and,
isBounded_iff_bddBelow_bddAbove]
end Preorder
section ConditionallyCompleteLattice
variable [ConditionallyCompleteLattice α] [IsOrderBornology α] {s : Set α}
protected lemma Bornology.IsBounded.subset_Icc_sInf_sSup (hs : IsBounded s) :
s ⊆ Icc (sInf s) (sSup s) := subset_Icc_csInf_csSup hs.bddBelow hs.bddAbove
end ConditionallyCompleteLattice
|
Topology\Order\Bounded.lean | /-
Copyright (c) 2023 Kalle Kytölä. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kalle Kytölä
-/
import Mathlib.Topology.Bornology.Basic
import Mathlib.Topology.Instances.Real
import Mathlib.Order.LiminfLimsup
/-!
# Relating order and metric boundedness
In spaces equipped with both an order and a metric, there are separate notions of boundedness
associated with each of the two structures. In specific cases such as ℝ, there are results which
relate the two notions.
## Tags
bounded, bornology, order, metric
-/
open Set Filter
section Real
@[deprecated isBoundedUnder_of (since := "2024-06-07")]
lemma Filter.isBounded_le_map_of_bounded_range {ι : Type*} (F : Filter ι) {f : ι → ℝ}
(h : Bornology.IsBounded (Set.range f)) :
(F.map f).IsBounded (· ≤ ·) := by
obtain ⟨c, hc⟩ := h.bddAbove
exact isBoundedUnder_of ⟨c, by simpa [mem_upperBounds] using hc⟩
@[deprecated isBoundedUnder_of (since := "2024-06-07")]
lemma Filter.isBounded_ge_map_of_bounded_range {ι : Type*} (F : Filter ι) {f : ι → ℝ}
(h : Bornology.IsBounded (Set.range f)) :
(F.map f).IsBounded (· ≥ ·) := by
obtain ⟨c, hc⟩ := h.bddBelow
apply isBoundedUnder_of ⟨c, by simpa [mem_lowerBounds] using hc⟩
end Real
|
Topology\Order\DenselyOrdered.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, Yury Kudryashov
-/
import Mathlib.Topology.Order.IsLUB
/-!
# Order topology on a densely ordered set
-/
open Set Filter TopologicalSpace Topology Function
open OrderDual (toDual ofDual)
variable {α β γ : Type*}
section DenselyOrdered
variable [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [DenselyOrdered α] {a b : α}
{s : Set α}
/-- The closure of the interval `(a, +∞)` is the closed interval `[a, +∞)`, unless `a` is a top
element. -/
theorem closure_Ioi' {a : α} (h : (Ioi a).Nonempty) : closure (Ioi a) = Ici a := by
apply Subset.antisymm
· exact closure_minimal Ioi_subset_Ici_self isClosed_Ici
· rw [← diff_subset_closure_iff, Ici_diff_Ioi_same, singleton_subset_iff]
exact isGLB_Ioi.mem_closure h
/-- The closure of the interval `(a, +∞)` is the closed interval `[a, +∞)`. -/
@[simp]
theorem closure_Ioi (a : α) [NoMaxOrder α] : closure (Ioi a) = Ici a :=
closure_Ioi' nonempty_Ioi
/-- The closure of the interval `(-∞, a)` is the closed interval `(-∞, a]`, unless `a` is a bottom
element. -/
theorem closure_Iio' (h : (Iio a).Nonempty) : closure (Iio a) = Iic a :=
closure_Ioi' (α := αᵒᵈ) h
/-- The closure of the interval `(-∞, a)` is the interval `(-∞, a]`. -/
@[simp]
theorem closure_Iio (a : α) [NoMinOrder α] : closure (Iio a) = Iic a :=
closure_Iio' nonempty_Iio
/-- The closure of the open interval `(a, b)` is the closed interval `[a, b]`. -/
@[simp]
theorem closure_Ioo {a b : α} (hab : a ≠ b) : closure (Ioo a b) = Icc a b := by
apply Subset.antisymm
· exact closure_minimal Ioo_subset_Icc_self isClosed_Icc
· cases' hab.lt_or_lt with hab hab
· rw [← diff_subset_closure_iff, Icc_diff_Ioo_same hab.le]
have hab' : (Ioo a b).Nonempty := nonempty_Ioo.2 hab
simp only [insert_subset_iff, singleton_subset_iff]
exact ⟨(isGLB_Ioo hab).mem_closure hab', (isLUB_Ioo hab).mem_closure hab'⟩
· rw [Icc_eq_empty_of_lt hab]
exact empty_subset _
/-- The closure of the interval `(a, b]` is the closed interval `[a, b]`. -/
@[simp]
theorem closure_Ioc {a b : α} (hab : a ≠ b) : closure (Ioc a b) = Icc a b := by
apply Subset.antisymm
· exact closure_minimal Ioc_subset_Icc_self isClosed_Icc
· apply Subset.trans _ (closure_mono Ioo_subset_Ioc_self)
rw [closure_Ioo hab]
/-- The closure of the interval `[a, b)` is the closed interval `[a, b]`. -/
@[simp]
theorem closure_Ico {a b : α} (hab : a ≠ b) : closure (Ico a b) = Icc a b := by
apply Subset.antisymm
· exact closure_minimal Ico_subset_Icc_self isClosed_Icc
· apply Subset.trans _ (closure_mono Ioo_subset_Ico_self)
rw [closure_Ioo hab]
@[simp]
theorem interior_Ici' {a : α} (ha : (Iio a).Nonempty) : interior (Ici a) = Ioi a := by
rw [← compl_Iio, interior_compl, closure_Iio' ha, compl_Iic]
theorem interior_Ici [NoMinOrder α] {a : α} : interior (Ici a) = Ioi a :=
interior_Ici' nonempty_Iio
@[simp]
theorem interior_Iic' {a : α} (ha : (Ioi a).Nonempty) : interior (Iic a) = Iio a :=
interior_Ici' (α := αᵒᵈ) ha
theorem interior_Iic [NoMaxOrder α] {a : α} : interior (Iic a) = Iio a :=
interior_Iic' nonempty_Ioi
@[simp]
theorem interior_Icc [NoMinOrder α] [NoMaxOrder α] {a b : α} : interior (Icc a b) = Ioo a b := by
rw [← Ici_inter_Iic, interior_inter, interior_Ici, interior_Iic, Ioi_inter_Iio]
@[simp]
theorem Icc_mem_nhds_iff [NoMinOrder α] [NoMaxOrder α] {a b x : α} :
Icc a b ∈ 𝓝 x ↔ x ∈ Ioo a b := by
rw [← interior_Icc, mem_interior_iff_mem_nhds]
@[simp]
theorem interior_Ico [NoMinOrder α] {a b : α} : interior (Ico a b) = Ioo a b := by
rw [← Ici_inter_Iio, interior_inter, interior_Ici, interior_Iio, Ioi_inter_Iio]
@[simp]
theorem Ico_mem_nhds_iff [NoMinOrder α] {a b x : α} : Ico a b ∈ 𝓝 x ↔ x ∈ Ioo a b := by
rw [← interior_Ico, mem_interior_iff_mem_nhds]
@[simp]
theorem interior_Ioc [NoMaxOrder α] {a b : α} : interior (Ioc a b) = Ioo a b := by
rw [← Ioi_inter_Iic, interior_inter, interior_Ioi, interior_Iic, Ioi_inter_Iio]
@[simp]
theorem Ioc_mem_nhds_iff [NoMaxOrder α] {a b x : α} : Ioc a b ∈ 𝓝 x ↔ x ∈ Ioo a b := by
rw [← interior_Ioc, mem_interior_iff_mem_nhds]
theorem closure_interior_Icc {a b : α} (h : a ≠ b) : closure (interior (Icc a b)) = Icc a b :=
(closure_minimal interior_subset isClosed_Icc).antisymm <|
calc
Icc a b = closure (Ioo a b) := (closure_Ioo h).symm
_ ⊆ closure (interior (Icc a b)) :=
closure_mono (interior_maximal Ioo_subset_Icc_self isOpen_Ioo)
theorem Ioc_subset_closure_interior (a b : α) : Ioc a b ⊆ closure (interior (Ioc a b)) := by
rcases eq_or_ne a b with (rfl | h)
· simp
· calc
Ioc a b ⊆ Icc a b := Ioc_subset_Icc_self
_ = closure (Ioo a b) := (closure_Ioo h).symm
_ ⊆ closure (interior (Ioc a b)) :=
closure_mono (interior_maximal Ioo_subset_Ioc_self isOpen_Ioo)
theorem Ico_subset_closure_interior (a b : α) : Ico a b ⊆ closure (interior (Ico a b)) := by
simpa only [dual_Ioc] using Ioc_subset_closure_interior (OrderDual.toDual b) (OrderDual.toDual a)
@[simp]
theorem frontier_Ici' {a : α} (ha : (Iio a).Nonempty) : frontier (Ici a) = {a} := by
simp [frontier, ha]
theorem frontier_Ici [NoMinOrder α] {a : α} : frontier (Ici a) = {a} :=
frontier_Ici' nonempty_Iio
@[simp]
theorem frontier_Iic' {a : α} (ha : (Ioi a).Nonempty) : frontier (Iic a) = {a} := by
simp [frontier, ha]
theorem frontier_Iic [NoMaxOrder α] {a : α} : frontier (Iic a) = {a} :=
frontier_Iic' nonempty_Ioi
@[simp]
theorem frontier_Ioi' {a : α} (ha : (Ioi a).Nonempty) : frontier (Ioi a) = {a} := by
simp [frontier, closure_Ioi' ha, Iic_diff_Iio, Icc_self]
theorem frontier_Ioi [NoMaxOrder α] {a : α} : frontier (Ioi a) = {a} :=
frontier_Ioi' nonempty_Ioi
@[simp]
theorem frontier_Iio' {a : α} (ha : (Iio a).Nonempty) : frontier (Iio a) = {a} := by
simp [frontier, closure_Iio' ha, Iic_diff_Iio, Icc_self]
theorem frontier_Iio [NoMinOrder α] {a : α} : frontier (Iio a) = {a} :=
frontier_Iio' nonempty_Iio
@[simp]
theorem frontier_Icc [NoMinOrder α] [NoMaxOrder α] {a b : α} (h : a ≤ b) :
frontier (Icc a b) = {a, b} := by simp [frontier, h, Icc_diff_Ioo_same]
@[simp]
theorem frontier_Ioo {a b : α} (h : a < b) : frontier (Ioo a b) = {a, b} := by
rw [frontier, closure_Ioo h.ne, interior_Ioo, Icc_diff_Ioo_same h.le]
@[simp]
theorem frontier_Ico [NoMinOrder α] {a b : α} (h : a < b) : frontier (Ico a b) = {a, b} := by
rw [frontier, closure_Ico h.ne, interior_Ico, Icc_diff_Ioo_same h.le]
@[simp]
theorem frontier_Ioc [NoMaxOrder α] {a b : α} (h : a < b) : frontier (Ioc a b) = {a, b} := by
rw [frontier, closure_Ioc h.ne, interior_Ioc, Icc_diff_Ioo_same h.le]
theorem nhdsWithin_Ioi_neBot' {a b : α} (H₁ : (Ioi a).Nonempty) (H₂ : a ≤ b) :
NeBot (𝓝[Ioi a] b) :=
mem_closure_iff_nhdsWithin_neBot.1 <| by rwa [closure_Ioi' H₁]
theorem nhdsWithin_Ioi_neBot [NoMaxOrder α] {a b : α} (H : a ≤ b) : NeBot (𝓝[Ioi a] b) :=
nhdsWithin_Ioi_neBot' nonempty_Ioi H
theorem nhdsWithin_Ioi_self_neBot' {a : α} (H : (Ioi a).Nonempty) : NeBot (𝓝[>] a) :=
nhdsWithin_Ioi_neBot' H (le_refl a)
instance nhdsWithin_Ioi_self_neBot [NoMaxOrder α] (a : α) : NeBot (𝓝[>] a) :=
nhdsWithin_Ioi_neBot (le_refl a)
theorem nhdsWithin_Iio_neBot' {b c : α} (H₁ : (Iio c).Nonempty) (H₂ : b ≤ c) :
NeBot (𝓝[Iio c] b) :=
mem_closure_iff_nhdsWithin_neBot.1 <| by rwa [closure_Iio' H₁]
theorem nhdsWithin_Iio_neBot [NoMinOrder α] {a b : α} (H : a ≤ b) : NeBot (𝓝[Iio b] a) :=
nhdsWithin_Iio_neBot' nonempty_Iio H
theorem nhdsWithin_Iio_self_neBot' {b : α} (H : (Iio b).Nonempty) : NeBot (𝓝[<] b) :=
nhdsWithin_Iio_neBot' H (le_refl b)
instance nhdsWithin_Iio_self_neBot [NoMinOrder α] (a : α) : NeBot (𝓝[<] a) :=
nhdsWithin_Iio_neBot (le_refl a)
theorem right_nhdsWithin_Ico_neBot {a b : α} (H : a < b) : NeBot (𝓝[Ico a b] b) :=
(isLUB_Ico H).nhdsWithin_neBot (nonempty_Ico.2 H)
theorem left_nhdsWithin_Ioc_neBot {a b : α} (H : a < b) : NeBot (𝓝[Ioc a b] a) :=
(isGLB_Ioc H).nhdsWithin_neBot (nonempty_Ioc.2 H)
theorem left_nhdsWithin_Ioo_neBot {a b : α} (H : a < b) : NeBot (𝓝[Ioo a b] a) :=
(isGLB_Ioo H).nhdsWithin_neBot (nonempty_Ioo.2 H)
theorem right_nhdsWithin_Ioo_neBot {a b : α} (H : a < b) : NeBot (𝓝[Ioo a b] b) :=
(isLUB_Ioo H).nhdsWithin_neBot (nonempty_Ioo.2 H)
theorem comap_coe_nhdsWithin_Iio_of_Ioo_subset (hb : s ⊆ Iio b)
(hs : s.Nonempty → ∃ a < b, Ioo a b ⊆ s) : comap ((↑) : s → α) (𝓝[<] b) = atTop := by
nontriviality
haveI : Nonempty s := nontrivial_iff_nonempty.1 ‹_›
rcases hs (nonempty_subtype.1 ‹_›) with ⟨a, h, hs⟩
ext u; constructor
· rintro ⟨t, ht, hts⟩
obtain ⟨x, ⟨hxa : a ≤ x, hxb : x < b⟩, hxt : Ioo x b ⊆ t⟩ :=
(mem_nhdsWithin_Iio_iff_exists_mem_Ico_Ioo_subset h).mp ht
obtain ⟨y, hxy, hyb⟩ := exists_between hxb
refine mem_of_superset (mem_atTop ⟨y, hs ⟨hxa.trans_lt hxy, hyb⟩⟩) ?_
rintro ⟨z, hzs⟩ (hyz : y ≤ z)
exact hts (hxt ⟨hxy.trans_le hyz, hb hzs⟩)
· intro hu
obtain ⟨x : s, hx : ∀ z, x ≤ z → z ∈ u⟩ := mem_atTop_sets.1 hu
exact ⟨Ioo x b, Ioo_mem_nhdsWithin_Iio' (hb x.2), fun z hz => hx _ hz.1.le⟩
set_option backward.isDefEq.lazyWhnfCore false in -- See https://github.com/leanprover-community/mathlib4/issues/12534
theorem comap_coe_nhdsWithin_Ioi_of_Ioo_subset (ha : s ⊆ Ioi a)
(hs : s.Nonempty → ∃ b > a, Ioo a b ⊆ s) : comap ((↑) : s → α) (𝓝[>] a) = atBot :=
comap_coe_nhdsWithin_Iio_of_Ioo_subset (show ofDual ⁻¹' s ⊆ Iio (toDual a) from ha) fun h => by
simpa only [OrderDual.exists, dual_Ioo] using hs h
theorem map_coe_atTop_of_Ioo_subset (hb : s ⊆ Iio b) (hs : ∀ a' < b, ∃ a < b, Ioo a b ⊆ s) :
map ((↑) : s → α) atTop = 𝓝[<] b := by
rcases eq_empty_or_nonempty (Iio b) with (hb' | ⟨a, ha⟩)
· have : IsEmpty s := ⟨fun x => hb'.subset (hb x.2)⟩
rw [filter_eq_bot_of_isEmpty atTop, Filter.map_bot, hb', nhdsWithin_empty]
· rw [← comap_coe_nhdsWithin_Iio_of_Ioo_subset hb fun _ => hs a ha, map_comap_of_mem]
rw [Subtype.range_val]
exact (mem_nhdsWithin_Iio_iff_exists_Ioo_subset' ha).2 (hs a ha)
theorem map_coe_atBot_of_Ioo_subset (ha : s ⊆ Ioi a) (hs : ∀ b' > a, ∃ b > a, Ioo a b ⊆ s) :
map ((↑) : s → α) atBot = 𝓝[>] a := by
-- the elaborator gets stuck without `(... : _)`
refine (map_coe_atTop_of_Ioo_subset (show ofDual ⁻¹' s ⊆ Iio (toDual a) from ha)
fun b' hb' => ?_ : _)
simpa only [OrderDual.exists, dual_Ioo] using hs b' hb'
/-- The `atTop` filter for an open interval `Ioo a b` comes from the left-neighbourhoods filter at
the right endpoint in the ambient order. -/
theorem comap_coe_Ioo_nhdsWithin_Iio (a b : α) : comap ((↑) : Ioo a b → α) (𝓝[<] b) = atTop :=
comap_coe_nhdsWithin_Iio_of_Ioo_subset Ioo_subset_Iio_self fun h =>
⟨a, nonempty_Ioo.1 h, Subset.refl _⟩
/-- The `atBot` filter for an open interval `Ioo a b` comes from the right-neighbourhoods filter at
the left endpoint in the ambient order. -/
theorem comap_coe_Ioo_nhdsWithin_Ioi (a b : α) : comap ((↑) : Ioo a b → α) (𝓝[>] a) = atBot :=
comap_coe_nhdsWithin_Ioi_of_Ioo_subset Ioo_subset_Ioi_self fun h =>
⟨b, nonempty_Ioo.1 h, Subset.refl _⟩
theorem comap_coe_Ioi_nhdsWithin_Ioi (a : α) : comap ((↑) : Ioi a → α) (𝓝[>] a) = atBot :=
comap_coe_nhdsWithin_Ioi_of_Ioo_subset (Subset.refl _) fun ⟨x, hx⟩ => ⟨x, hx, Ioo_subset_Ioi_self⟩
theorem comap_coe_Iio_nhdsWithin_Iio (a : α) : comap ((↑) : Iio a → α) (𝓝[<] a) = atTop :=
comap_coe_Ioi_nhdsWithin_Ioi (α := αᵒᵈ) a
@[simp]
theorem map_coe_Ioo_atTop {a b : α} (h : a < b) : map ((↑) : Ioo a b → α) atTop = 𝓝[<] b :=
map_coe_atTop_of_Ioo_subset Ioo_subset_Iio_self fun _ _ => ⟨_, h, Subset.refl _⟩
@[simp]
theorem map_coe_Ioo_atBot {a b : α} (h : a < b) : map ((↑) : Ioo a b → α) atBot = 𝓝[>] a :=
map_coe_atBot_of_Ioo_subset Ioo_subset_Ioi_self fun _ _ => ⟨_, h, Subset.refl _⟩
@[simp]
theorem map_coe_Ioi_atBot (a : α) : map ((↑) : Ioi a → α) atBot = 𝓝[>] a :=
map_coe_atBot_of_Ioo_subset (Subset.refl _) fun b hb => ⟨b, hb, Ioo_subset_Ioi_self⟩
@[simp]
theorem map_coe_Iio_atTop (a : α) : map ((↑) : Iio a → α) atTop = 𝓝[<] a :=
map_coe_Ioi_atBot (α := αᵒᵈ) _
variable {l : Filter β} {f : α → β}
@[simp]
theorem tendsto_comp_coe_Ioo_atTop (h : a < b) :
Tendsto (fun x : Ioo a b => f x) atTop l ↔ Tendsto f (𝓝[<] b) l := by
rw [← map_coe_Ioo_atTop h, tendsto_map'_iff]; rfl
@[simp]
theorem tendsto_comp_coe_Ioo_atBot (h : a < b) :
Tendsto (fun x : Ioo a b => f x) atBot l ↔ Tendsto f (𝓝[>] a) l := by
rw [← map_coe_Ioo_atBot h, tendsto_map'_iff]; rfl
-- Porting note (#11215): TODO: `simpNF` claims that `simp` can't use
-- this lemma to simplify LHS but it can
@[simp, nolint simpNF]
theorem tendsto_comp_coe_Ioi_atBot :
Tendsto (fun x : Ioi a => f x) atBot l ↔ Tendsto f (𝓝[>] a) l := by
rw [← map_coe_Ioi_atBot, tendsto_map'_iff]; rfl
-- Porting note (#11215): TODO: `simpNF` claims that `simp` can't use
-- this lemma to simplify LHS but it can
@[simp, nolint simpNF]
theorem tendsto_comp_coe_Iio_atTop :
Tendsto (fun x : Iio a => f x) atTop l ↔ Tendsto f (𝓝[<] a) l := by
rw [← map_coe_Iio_atTop, tendsto_map'_iff]; rfl
@[simp]
theorem tendsto_Ioo_atTop {f : β → Ioo a b} :
Tendsto f l atTop ↔ Tendsto (fun x => (f x : α)) l (𝓝[<] b) := by
rw [← comap_coe_Ioo_nhdsWithin_Iio, tendsto_comap_iff]; rfl
@[simp]
theorem tendsto_Ioo_atBot {f : β → Ioo a b} :
Tendsto f l atBot ↔ Tendsto (fun x => (f x : α)) l (𝓝[>] a) := by
rw [← comap_coe_Ioo_nhdsWithin_Ioi, tendsto_comap_iff]; rfl
@[simp]
theorem tendsto_Ioi_atBot {f : β → Ioi a} :
Tendsto f l atBot ↔ Tendsto (fun x => (f x : α)) l (𝓝[>] a) := by
rw [← comap_coe_Ioi_nhdsWithin_Ioi, tendsto_comap_iff]; rfl
@[simp]
theorem tendsto_Iio_atTop {f : β → Iio a} :
Tendsto f l atTop ↔ Tendsto (fun x => (f x : α)) l (𝓝[<] a) := by
rw [← comap_coe_Iio_nhdsWithin_Iio, tendsto_comap_iff]; rfl
instance (x : α) [Nontrivial α] : NeBot (𝓝[≠] x) := by
refine forall_mem_nonempty_iff_neBot.1 fun s hs => ?_
obtain ⟨u, u_open, xu, us⟩ : ∃ u : Set α, IsOpen u ∧ x ∈ u ∧ u ∩ {x}ᶜ ⊆ s := mem_nhdsWithin.1 hs
obtain ⟨a, b, a_lt_b, hab⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ u := u_open.exists_Ioo_subset ⟨x, xu⟩
obtain ⟨y, hy⟩ : ∃ y, a < y ∧ y < b := exists_between a_lt_b
rcases ne_or_eq x y with (xy | rfl)
· exact ⟨y, us ⟨hab hy, xy.symm⟩⟩
obtain ⟨z, hz⟩ : ∃ z, a < z ∧ z < x := exists_between hy.1
exact ⟨z, us ⟨hab ⟨hz.1, hz.2.trans hy.2⟩, hz.2.ne⟩⟩
/-- Let `s` be a dense set in a nontrivial dense linear order `α`. If `s` is a
separable space (e.g., if `α` has a second countable topology), then there exists a countable
dense subset `t ⊆ s` such that `t` does not contain bottom/top elements of `α`. -/
theorem Dense.exists_countable_dense_subset_no_bot_top [Nontrivial α] {s : Set α} [SeparableSpace s]
(hs : Dense s) :
∃ t, t ⊆ s ∧ t.Countable ∧ Dense t ∧ (∀ x, IsBot x → x ∉ t) ∧ ∀ x, IsTop x → x ∉ t := by
rcases hs.exists_countable_dense_subset with ⟨t, hts, htc, htd⟩
refine ⟨t \ ({ x | IsBot x } ∪ { x | IsTop x }), ?_, ?_, ?_, fun x hx => ?_, fun x hx => ?_⟩
· exact diff_subset.trans hts
· exact htc.mono diff_subset
· exact htd.diff_finite ((subsingleton_isBot α).finite.union (subsingleton_isTop α).finite)
· simp [hx]
· simp [hx]
variable (α)
/-- If `α` is a nontrivial separable dense linear order, then there exists a
countable dense set `s : Set α` that contains neither top nor bottom elements of `α`.
For a dense set containing both bot and top elements, see
`exists_countable_dense_bot_top`. -/
theorem exists_countable_dense_no_bot_top [SeparableSpace α] [Nontrivial α] :
∃ s : Set α, s.Countable ∧ Dense s ∧ (∀ x, IsBot x → x ∉ s) ∧ ∀ x, IsTop x → x ∉ s := by
simpa using dense_univ.exists_countable_dense_subset_no_bot_top
end DenselyOrdered
|
Topology\Order\ExtendFrom.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, Yury Kudryashov
-/
import Mathlib.Topology.ExtendFrom
import Mathlib.Topology.Order.DenselyOrdered
/-!
# Lemmas about `extendFrom` in an order topology.
-/
open Filter Set Topology
variable {α β : Type*}
theorem continuousOn_Icc_extendFrom_Ioo [TopologicalSpace α] [LinearOrder α] [DenselyOrdered α]
[OrderTopology α] [TopologicalSpace β] [RegularSpace β] {f : α → β} {a b : α} {la lb : β}
(hab : a ≠ b) (hf : ContinuousOn f (Ioo a b)) (ha : Tendsto f (𝓝[>] a) (𝓝 la))
(hb : Tendsto f (𝓝[<] b) (𝓝 lb)) : ContinuousOn (extendFrom (Ioo a b) f) (Icc a b) := by
apply continuousOn_extendFrom
· rw [closure_Ioo hab]
· intro x x_in
rcases eq_endpoints_or_mem_Ioo_of_mem_Icc x_in with (rfl | rfl | h)
· exact ⟨la, ha.mono_left <| nhdsWithin_mono _ Ioo_subset_Ioi_self⟩
· exact ⟨lb, hb.mono_left <| nhdsWithin_mono _ Ioo_subset_Iio_self⟩
· exact ⟨f x, hf x h⟩
theorem eq_lim_at_left_extendFrom_Ioo [TopologicalSpace α] [LinearOrder α] [DenselyOrdered α]
[OrderTopology α] [TopologicalSpace β] [T2Space β] {f : α → β} {a b : α} {la : β} (hab : a < b)
(ha : Tendsto f (𝓝[>] a) (𝓝 la)) : extendFrom (Ioo a b) f a = la := by
apply extendFrom_eq
· rw [closure_Ioo hab.ne]
simp only [le_of_lt hab, left_mem_Icc, right_mem_Icc]
· simpa [hab]
theorem eq_lim_at_right_extendFrom_Ioo [TopologicalSpace α] [LinearOrder α] [DenselyOrdered α]
[OrderTopology α] [TopologicalSpace β] [T2Space β] {f : α → β} {a b : α} {lb : β} (hab : a < b)
(hb : Tendsto f (𝓝[<] b) (𝓝 lb)) : extendFrom (Ioo a b) f b = lb := by
apply extendFrom_eq
· rw [closure_Ioo hab.ne]
simp only [le_of_lt hab, left_mem_Icc, right_mem_Icc]
· simpa [hab]
theorem continuousOn_Ico_extendFrom_Ioo [TopologicalSpace α] [LinearOrder α] [DenselyOrdered α]
[OrderTopology α] [TopologicalSpace β] [RegularSpace β] {f : α → β} {a b : α} {la : β}
(hab : a < b) (hf : ContinuousOn f (Ioo a b)) (ha : Tendsto f (𝓝[>] a) (𝓝 la)) :
ContinuousOn (extendFrom (Ioo a b) f) (Ico a b) := by
apply continuousOn_extendFrom
· rw [closure_Ioo hab.ne]
exact Ico_subset_Icc_self
· intro x x_in
rcases eq_left_or_mem_Ioo_of_mem_Ico x_in with (rfl | h)
· use la
simpa [hab]
· exact ⟨f x, hf x h⟩
theorem continuousOn_Ioc_extendFrom_Ioo [TopologicalSpace α] [LinearOrder α] [DenselyOrdered α]
[OrderTopology α] [TopologicalSpace β] [RegularSpace β] {f : α → β} {a b : α} {lb : β}
(hab : a < b) (hf : ContinuousOn f (Ioo a b)) (hb : Tendsto f (𝓝[<] b) (𝓝 lb)) :
ContinuousOn (extendFrom (Ioo a b) f) (Ioc a b) := by
have := @continuousOn_Ico_extendFrom_Ioo αᵒᵈ _ _ _ _ _ _ _ f _ _ lb hab
erw [dual_Ico, dual_Ioi, dual_Ioo] at this
exact this hf hb
|
Topology\Order\ExtrClosure.lean | /-
Copyright (c) 2022 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov
-/
import Mathlib.Topology.Order.OrderClosed
import Mathlib.Topology.Order.LocalExtr
/-!
# Maximum/minimum on the closure of a set
In this file we prove several versions of the following statement: if `f : X → Y` has a (local or
not) maximum (or minimum) on a set `s` at a point `a` and is continuous on the closure of `s`, then
`f` has an extremum of the same type on `Closure s` at `a`.
-/
open Filter Set
open Topology
variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [Preorder Y]
[OrderClosedTopology Y] {f g : X → Y} {s : Set X} {a : X}
protected theorem IsMaxOn.closure (h : IsMaxOn f s a) (hc : ContinuousOn f (closure s)) :
IsMaxOn f (closure s) a := fun x hx =>
ContinuousWithinAt.closure_le hx ((hc x hx).mono subset_closure) continuousWithinAt_const h
protected theorem IsMinOn.closure (h : IsMinOn f s a) (hc : ContinuousOn f (closure s)) :
IsMinOn f (closure s) a :=
h.dual.closure hc
protected theorem IsExtrOn.closure (h : IsExtrOn f s a) (hc : ContinuousOn f (closure s)) :
IsExtrOn f (closure s) a :=
h.elim (fun h => Or.inl <| h.closure hc) fun h => Or.inr <| h.closure hc
protected theorem IsLocalMaxOn.closure (h : IsLocalMaxOn f s a) (hc : ContinuousOn f (closure s)) :
IsLocalMaxOn f (closure s) a := by
rcases mem_nhdsWithin.1 h with ⟨U, Uo, aU, hU⟩
refine mem_nhdsWithin.2 ⟨U, Uo, aU, ?_⟩
rintro x ⟨hxU, hxs⟩
refine ContinuousWithinAt.closure_le ?_ ?_ continuousWithinAt_const hU
· rwa [mem_closure_iff_nhdsWithin_neBot, nhdsWithin_inter_of_mem, ←
mem_closure_iff_nhdsWithin_neBot]
exact nhdsWithin_le_nhds (Uo.mem_nhds hxU)
· exact (hc _ hxs).mono (inter_subset_right.trans subset_closure)
protected theorem IsLocalMinOn.closure (h : IsLocalMinOn f s a) (hc : ContinuousOn f (closure s)) :
IsLocalMinOn f (closure s) a :=
IsLocalMaxOn.closure h.dual hc
protected theorem IsLocalExtrOn.closure (h : IsLocalExtrOn f s a)
(hc : ContinuousOn f (closure s)) : IsLocalExtrOn f (closure s) a :=
h.elim (fun h => Or.inl <| h.closure hc) fun h => Or.inr <| h.closure hc
|
Topology\Order\Filter.lean | /-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Topology.Filter
import Mathlib.Topology.Order.Basic
/-!
# Topology on filters of a space with order topology
In this file we prove that `𝓝 (f x)` tends to `𝓝 Filter.atTop` provided that `f` tends to
`Filter.atTop`, and similarly for `Filter.atBot`.
-/
open Topology
namespace Filter
variable {α X : Type*} [TopologicalSpace X] [PartialOrder X] [OrderTopology X]
protected theorem tendsto_nhds_atTop [NoMaxOrder X] : Tendsto 𝓝 (atTop : Filter X) (𝓝 atTop) :=
Filter.tendsto_nhds_atTop_iff.2 fun x => (eventually_gt_atTop x).mono fun _ => le_mem_nhds
protected theorem tendsto_nhds_atBot [NoMinOrder X] : Tendsto 𝓝 (atBot : Filter X) (𝓝 atBot) :=
@Filter.tendsto_nhds_atTop Xᵒᵈ _ _ _ _
theorem Tendsto.nhds_atTop [NoMaxOrder X] {f : α → X} {l : Filter α} (h : Tendsto f l atTop) :
Tendsto (𝓝 ∘ f) l (𝓝 atTop) :=
Filter.tendsto_nhds_atTop.comp h
theorem Tendsto.nhds_atBot [NoMinOrder X] {f : α → X} {l : Filter α} (h : Tendsto f l atBot) :
Tendsto (𝓝 ∘ f) l (𝓝 atBot) :=
@Tendsto.nhds_atTop α Xᵒᵈ _ _ _ _ _ _ h
end Filter
|
Topology\Order\IntermediateValue.lean | /-
Copyright (c) 2021 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov, Alistair Tucker, Wen Yang
-/
import Mathlib.Order.Interval.Set.Image
import Mathlib.Order.CompleteLatticeIntervals
import Mathlib.Topology.Order.DenselyOrdered
import Mathlib.Topology.Order.Monotone
/-!
# Intermediate Value Theorem
In this file we prove the Intermediate Value Theorem: if `f : α → β` is a function defined on a
connected set `s` that takes both values `≤ a` and values `≥ a` on `s`, then it is equal to `a` at
some point of `s`. We also prove that intervals in a dense conditionally complete order are
preconnected and any preconnected set is an interval. Then we specialize IVT to functions continuous
on intervals.
## Main results
* `IsPreconnected_I??` : all intervals `I??` are preconnected,
* `IsPreconnected.intermediate_value`, `intermediate_value_univ` : Intermediate Value Theorem for
connected sets and connected spaces, respectively;
* `intermediate_value_Icc`, `intermediate_value_Icc'`: Intermediate Value Theorem for functions
on closed intervals.
### Miscellaneous facts
* `IsClosed.Icc_subset_of_forall_mem_nhdsWithin` : “Continuous induction” principle;
if `s ∩ [a, b]` is closed, `a ∈ s`, and for each `x ∈ [a, b) ∩ s` some of its right neighborhoods
is included `s`, then `[a, b] ⊆ s`.
* `IsClosed.Icc_subset_of_forall_exists_gt`, `IsClosed.mem_of_ge_of_forall_exists_gt` : two
other versions of the “continuous induction” principle.
* `ContinuousOn.StrictMonoOn_of_InjOn_Ioo` :
Every continuous injective `f : (a, b) → δ` is strictly monotone
or antitone (increasing or decreasing).
## Tags
intermediate value theorem, connected space, connected set
-/
open Filter OrderDual TopologicalSpace Function Set
open scoped Topology Filter Interval
universe u v w
/-!
### Intermediate value theorem on a (pre)connected space
In this section we prove the following theorem (see `IsPreconnected.intermediate_value₂`): if `f`
and `g` are two functions continuous on a preconnected set `s`, `f a ≤ g a` at some `a ∈ s` and
`g b ≤ f b` at some `b ∈ s`, then `f c = g c` at some `c ∈ s`. We prove several versions of this
statement, including the classical IVT that corresponds to a constant function `g`.
-/
section
variable {X : Type u} {α : Type v} [TopologicalSpace X] [LinearOrder α] [TopologicalSpace α]
[OrderClosedTopology α]
/-- Intermediate value theorem for two functions: if `f` and `g` are two continuous functions
on a preconnected space and `f a ≤ g a` and `g b ≤ f b`, then for some `x` we have `f x = g x`. -/
theorem intermediate_value_univ₂ [PreconnectedSpace X] {a b : X} {f g : X → α} (hf : Continuous f)
(hg : Continuous g) (ha : f a ≤ g a) (hb : g b ≤ f b) : ∃ x, f x = g x := by
obtain ⟨x, _, hfg, hgf⟩ : (univ ∩ { x | f x ≤ g x ∧ g x ≤ f x }).Nonempty :=
isPreconnected_closed_iff.1 PreconnectedSpace.isPreconnected_univ _ _ (isClosed_le hf hg)
(isClosed_le hg hf) (fun _ _ => le_total _ _) ⟨a, trivial, ha⟩ ⟨b, trivial, hb⟩
exact ⟨x, le_antisymm hfg hgf⟩
theorem intermediate_value_univ₂_eventually₁ [PreconnectedSpace X] {a : X} {l : Filter X} [NeBot l]
{f g : X → α} (hf : Continuous f) (hg : Continuous g) (ha : f a ≤ g a) (he : g ≤ᶠ[l] f) :
∃ x, f x = g x :=
let ⟨_, h⟩ := he.exists; intermediate_value_univ₂ hf hg ha h
theorem intermediate_value_univ₂_eventually₂ [PreconnectedSpace X] {l₁ l₂ : Filter X} [NeBot l₁]
[NeBot l₂] {f g : X → α} (hf : Continuous f) (hg : Continuous g) (he₁ : f ≤ᶠ[l₁] g)
(he₂ : g ≤ᶠ[l₂] f) : ∃ x, f x = g x :=
let ⟨_, h₁⟩ := he₁.exists
let ⟨_, h₂⟩ := he₂.exists
intermediate_value_univ₂ hf hg h₁ h₂
/-- Intermediate value theorem for two functions: if `f` and `g` are two functions continuous
on a preconnected set `s` and for some `a b ∈ s` we have `f a ≤ g a` and `g b ≤ f b`,
then for some `x ∈ s` we have `f x = g x`. -/
theorem IsPreconnected.intermediate_value₂ {s : Set X} (hs : IsPreconnected s) {a b : X}
(ha : a ∈ s) (hb : b ∈ s) {f g : X → α} (hf : ContinuousOn f s) (hg : ContinuousOn g s)
(ha' : f a ≤ g a) (hb' : g b ≤ f b) : ∃ x ∈ s, f x = g x :=
let ⟨x, hx⟩ :=
@intermediate_value_univ₂ s α _ _ _ _ (Subtype.preconnectedSpace hs) ⟨a, ha⟩ ⟨b, hb⟩ _ _
(continuousOn_iff_continuous_restrict.1 hf) (continuousOn_iff_continuous_restrict.1 hg) ha'
hb'
⟨x, x.2, hx⟩
theorem IsPreconnected.intermediate_value₂_eventually₁ {s : Set X} (hs : IsPreconnected s) {a : X}
{l : Filter X} (ha : a ∈ s) [NeBot l] (hl : l ≤ 𝓟 s) {f g : X → α} (hf : ContinuousOn f s)
(hg : ContinuousOn g s) (ha' : f a ≤ g a) (he : g ≤ᶠ[l] f) : ∃ x ∈ s, f x = g x := by
rw [continuousOn_iff_continuous_restrict] at hf hg
obtain ⟨b, h⟩ :=
@intermediate_value_univ₂_eventually₁ _ _ _ _ _ _ (Subtype.preconnectedSpace hs) ⟨a, ha⟩ _
(comap_coe_neBot_of_le_principal hl) _ _ hf hg ha' (he.comap _)
exact ⟨b, b.prop, h⟩
theorem IsPreconnected.intermediate_value₂_eventually₂ {s : Set X} (hs : IsPreconnected s)
{l₁ l₂ : Filter X} [NeBot l₁] [NeBot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f g : X → α}
(hf : ContinuousOn f s) (hg : ContinuousOn g s) (he₁ : f ≤ᶠ[l₁] g) (he₂ : g ≤ᶠ[l₂] f) :
∃ x ∈ s, f x = g x := by
rw [continuousOn_iff_continuous_restrict] at hf hg
obtain ⟨b, h⟩ :=
@intermediate_value_univ₂_eventually₂ _ _ _ _ _ _ (Subtype.preconnectedSpace hs) _ _
(comap_coe_neBot_of_le_principal hl₁) (comap_coe_neBot_of_le_principal hl₂) _ _ hf hg
(he₁.comap _) (he₂.comap _)
exact ⟨b, b.prop, h⟩
/-- **Intermediate Value Theorem** for continuous functions on connected sets. -/
theorem IsPreconnected.intermediate_value {s : Set X} (hs : IsPreconnected s) {a b : X} (ha : a ∈ s)
(hb : b ∈ s) {f : X → α} (hf : ContinuousOn f s) : Icc (f a) (f b) ⊆ f '' s := fun _x hx =>
hs.intermediate_value₂ ha hb hf continuousOn_const hx.1 hx.2
theorem IsPreconnected.intermediate_value_Ico {s : Set X} (hs : IsPreconnected s) {a : X}
{l : Filter X} (ha : a ∈ s) [NeBot l] (hl : l ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s) {v : α}
(ht : Tendsto f l (𝓝 v)) : Ico (f a) v ⊆ f '' s := fun _ h =>
hs.intermediate_value₂_eventually₁ ha hl hf continuousOn_const h.1
(eventually_ge_of_tendsto_gt h.2 ht)
theorem IsPreconnected.intermediate_value_Ioc {s : Set X} (hs : IsPreconnected s) {a : X}
{l : Filter X} (ha : a ∈ s) [NeBot l] (hl : l ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s) {v : α}
(ht : Tendsto f l (𝓝 v)) : Ioc v (f a) ⊆ f '' s := fun _ h =>
(hs.intermediate_value₂_eventually₁ ha hl continuousOn_const hf h.2
(eventually_le_of_tendsto_lt h.1 ht)).imp fun _ h => h.imp_right Eq.symm
theorem IsPreconnected.intermediate_value_Ioo {s : Set X} (hs : IsPreconnected s) {l₁ l₂ : Filter X}
[NeBot l₁] [NeBot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)
{v₁ v₂ : α} (ht₁ : Tendsto f l₁ (𝓝 v₁)) (ht₂ : Tendsto f l₂ (𝓝 v₂)) :
Ioo v₁ v₂ ⊆ f '' s := fun _ h =>
hs.intermediate_value₂_eventually₂ hl₁ hl₂ hf continuousOn_const
(eventually_le_of_tendsto_lt h.1 ht₁) (eventually_ge_of_tendsto_gt h.2 ht₂)
theorem IsPreconnected.intermediate_value_Ici {s : Set X} (hs : IsPreconnected s) {a : X}
{l : Filter X} (ha : a ∈ s) [NeBot l] (hl : l ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)
(ht : Tendsto f l atTop) : Ici (f a) ⊆ f '' s := fun y h =>
hs.intermediate_value₂_eventually₁ ha hl hf continuousOn_const h (tendsto_atTop.1 ht y)
theorem IsPreconnected.intermediate_value_Iic {s : Set X} (hs : IsPreconnected s) {a : X}
{l : Filter X} (ha : a ∈ s) [NeBot l] (hl : l ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)
(ht : Tendsto f l atBot) : Iic (f a) ⊆ f '' s := fun y h =>
(hs.intermediate_value₂_eventually₁ ha hl continuousOn_const hf h (tendsto_atBot.1 ht y)).imp
fun _ h => h.imp_right Eq.symm
theorem IsPreconnected.intermediate_value_Ioi {s : Set X} (hs : IsPreconnected s) {l₁ l₂ : Filter X}
[NeBot l₁] [NeBot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)
{v : α} (ht₁ : Tendsto f l₁ (𝓝 v)) (ht₂ : Tendsto f l₂ atTop) : Ioi v ⊆ f '' s := fun y h =>
hs.intermediate_value₂_eventually₂ hl₁ hl₂ hf continuousOn_const
(eventually_le_of_tendsto_lt h ht₁) (tendsto_atTop.1 ht₂ y)
theorem IsPreconnected.intermediate_value_Iio {s : Set X} (hs : IsPreconnected s) {l₁ l₂ : Filter X}
[NeBot l₁] [NeBot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)
{v : α} (ht₁ : Tendsto f l₁ atBot) (ht₂ : Tendsto f l₂ (𝓝 v)) : Iio v ⊆ f '' s := fun y h =>
hs.intermediate_value₂_eventually₂ hl₁ hl₂ hf continuousOn_const (tendsto_atBot.1 ht₁ y)
(eventually_ge_of_tendsto_gt h ht₂)
theorem IsPreconnected.intermediate_value_Iii {s : Set X} (hs : IsPreconnected s) {l₁ l₂ : Filter X}
[NeBot l₁] [NeBot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)
(ht₁ : Tendsto f l₁ atBot) (ht₂ : Tendsto f l₂ atTop) : univ ⊆ f '' s := fun y _ =>
hs.intermediate_value₂_eventually₂ hl₁ hl₂ hf continuousOn_const (tendsto_atBot.1 ht₁ y)
(tendsto_atTop.1 ht₂ y)
/-- **Intermediate Value Theorem** for continuous functions on connected spaces. -/
theorem intermediate_value_univ [PreconnectedSpace X] (a b : X) {f : X → α} (hf : Continuous f) :
Icc (f a) (f b) ⊆ range f := fun _ hx => intermediate_value_univ₂ hf continuous_const hx.1 hx.2
/-- **Intermediate Value Theorem** for continuous functions on connected spaces. -/
theorem mem_range_of_exists_le_of_exists_ge [PreconnectedSpace X] {c : α} {f : X → α}
(hf : Continuous f) (h₁ : ∃ a, f a ≤ c) (h₂ : ∃ b, c ≤ f b) : c ∈ range f :=
let ⟨a, ha⟩ := h₁; let ⟨b, hb⟩ := h₂; intermediate_value_univ a b hf ⟨ha, hb⟩
/-!
### (Pre)connected sets in a linear order
In this section we prove the following results:
* `IsPreconnected.ordConnected`: any preconnected set `s` in a linear order is `OrdConnected`,
i.e. `a ∈ s` and `b ∈ s` imply `Icc a b ⊆ s`;
* `IsPreconnected.mem_intervals`: any preconnected set `s` in a conditionally complete linear order
is one of the intervals `Set.Icc`, `set.`Ico`, `set.Ioc`, `set.Ioo`, ``Set.Ici`, `Set.Iic`,
`Set.Ioi`, `Set.Iio`; note that this is false for non-complete orders: e.g., in `ℝ \ {0}`, the set
of positive numbers cannot be represented as `Set.Ioi _`.
-/
/-- If a preconnected set contains endpoints of an interval, then it includes the whole interval. -/
theorem IsPreconnected.Icc_subset {s : Set α} (hs : IsPreconnected s) {a b : α} (ha : a ∈ s)
(hb : b ∈ s) : Icc a b ⊆ s := by
simpa only [image_id] using hs.intermediate_value ha hb continuousOn_id
theorem IsPreconnected.ordConnected {s : Set α} (h : IsPreconnected s) : OrdConnected s :=
⟨fun _ hx _ hy => h.Icc_subset hx hy⟩
/-- If a preconnected set contains endpoints of an interval, then it includes the whole interval. -/
theorem IsConnected.Icc_subset {s : Set α} (hs : IsConnected s) {a b : α} (ha : a ∈ s)
(hb : b ∈ s) : Icc a b ⊆ s :=
hs.2.Icc_subset ha hb
/-- If preconnected set in a linear order space is unbounded below and above, then it is the whole
space. -/
theorem IsPreconnected.eq_univ_of_unbounded {s : Set α} (hs : IsPreconnected s) (hb : ¬BddBelow s)
(ha : ¬BddAbove s) : s = univ := by
refine eq_univ_of_forall fun x => ?_
obtain ⟨y, ys, hy⟩ : ∃ y ∈ s, y < x := not_bddBelow_iff.1 hb x
obtain ⟨z, zs, hz⟩ : ∃ z ∈ s, x < z := not_bddAbove_iff.1 ha x
exact hs.Icc_subset ys zs ⟨le_of_lt hy, le_of_lt hz⟩
end
variable {α : Type u} {β : Type v} {γ : Type w} [ConditionallyCompleteLinearOrder α]
[TopologicalSpace α] [OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β]
[OrderTopology β] [Nonempty γ]
/-- A bounded connected subset of a conditionally complete linear order includes the open interval
`(Inf s, Sup s)`. -/
theorem IsConnected.Ioo_csInf_csSup_subset {s : Set α} (hs : IsConnected s) (hb : BddBelow s)
(ha : BddAbove s) : Ioo (sInf s) (sSup s) ⊆ s := fun _x hx =>
let ⟨_y, ys, hy⟩ := (isGLB_lt_iff (isGLB_csInf hs.nonempty hb)).1 hx.1
let ⟨_z, zs, hz⟩ := (lt_isLUB_iff (isLUB_csSup hs.nonempty ha)).1 hx.2
hs.Icc_subset ys zs ⟨hy.le, hz.le⟩
theorem eq_Icc_csInf_csSup_of_connected_bdd_closed {s : Set α} (hc : IsConnected s)
(hb : BddBelow s) (ha : BddAbove s) (hcl : IsClosed s) : s = Icc (sInf s) (sSup s) :=
(subset_Icc_csInf_csSup hb ha).antisymm <|
hc.Icc_subset (hcl.csInf_mem hc.nonempty hb) (hcl.csSup_mem hc.nonempty ha)
theorem IsPreconnected.Ioi_csInf_subset {s : Set α} (hs : IsPreconnected s) (hb : BddBelow s)
(ha : ¬BddAbove s) : Ioi (sInf s) ⊆ s := fun x hx =>
have sne : s.Nonempty := nonempty_of_not_bddAbove ha
let ⟨_y, ys, hy⟩ : ∃ y ∈ s, y < x := (isGLB_lt_iff (isGLB_csInf sne hb)).1 hx
let ⟨_z, zs, hz⟩ : ∃ z ∈ s, x < z := not_bddAbove_iff.1 ha x
hs.Icc_subset ys zs ⟨hy.le, hz.le⟩
theorem IsPreconnected.Iio_csSup_subset {s : Set α} (hs : IsPreconnected s) (hb : ¬BddBelow s)
(ha : BddAbove s) : Iio (sSup s) ⊆ s :=
IsPreconnected.Ioi_csInf_subset (α := αᵒᵈ) hs ha hb
/-- A preconnected set in a conditionally complete linear order is either one of the intervals
`[Inf s, Sup s]`, `[Inf s, Sup s)`, `(Inf s, Sup s]`, `(Inf s, Sup s)`, `[Inf s, +∞)`,
`(Inf s, +∞)`, `(-∞, Sup s]`, `(-∞, Sup s)`, `(-∞, +∞)`, or `∅`. The converse statement requires
`α` to be densely ordered. -/
theorem IsPreconnected.mem_intervals {s : Set α} (hs : IsPreconnected s) :
s ∈
({Icc (sInf s) (sSup s), Ico (sInf s) (sSup s), Ioc (sInf s) (sSup s), Ioo (sInf s) (sSup s),
Ici (sInf s), Ioi (sInf s), Iic (sSup s), Iio (sSup s), univ, ∅} : Set (Set α)) := by
rcases s.eq_empty_or_nonempty with (rfl | hne)
· apply_rules [Or.inr, mem_singleton]
have hs' : IsConnected s := ⟨hne, hs⟩
by_cases hb : BddBelow s <;> by_cases ha : BddAbove s
· refine mem_of_subset_of_mem ?_ <| mem_Icc_Ico_Ioc_Ioo_of_subset_of_subset
(hs'.Ioo_csInf_csSup_subset hb ha) (subset_Icc_csInf_csSup hb ha)
simp only [insert_subset_iff, mem_insert_iff, mem_singleton_iff, true_or, or_true,
singleton_subset_iff, and_self]
· refine Or.inr <| Or.inr <| Or.inr <| Or.inr ?_
cases'
mem_Ici_Ioi_of_subset_of_subset (hs.Ioi_csInf_subset hb ha) fun x hx => csInf_le hb hx with
hs hs
· exact Or.inl hs
· exact Or.inr (Or.inl hs)
· iterate 6 apply Or.inr
cases' mem_Iic_Iio_of_subset_of_subset (hs.Iio_csSup_subset hb ha) fun x hx => le_csSup ha hx
with hs hs
· exact Or.inl hs
· exact Or.inr (Or.inl hs)
· iterate 8 apply Or.inr
exact Or.inl (hs.eq_univ_of_unbounded hb ha)
/-- A preconnected set is either one of the intervals `Icc`, `Ico`, `Ioc`, `Ioo`, `Ici`, `Ioi`,
`Iic`, `Iio`, or `univ`, or `∅`. The converse statement requires `α` to be densely ordered. Though
one can represent `∅` as `(Inf ∅, Inf ∅)`, we include it into the list of possible cases to improve
readability. -/
theorem setOf_isPreconnected_subset_of_ordered :
{ s : Set α | IsPreconnected s } ⊆
-- bounded intervals
(range (uncurry Icc) ∪ range (uncurry Ico) ∪ range (uncurry Ioc) ∪ range (uncurry Ioo)) ∪
-- unbounded intervals and `univ`
(range Ici ∪ range Ioi ∪ range Iic ∪ range Iio ∪ {univ, ∅}) := by
intro s hs
rcases hs.mem_intervals with (hs | hs | hs | hs | hs | hs | hs | hs | hs | hs) <;> rw [hs] <;>
simp only [union_insert, union_singleton, mem_insert_iff, mem_union, mem_range, Prod.exists,
uncurry_apply_pair, exists_apply_eq_apply, true_or, or_true, exists_apply_eq_apply2]
/-!
### Intervals are connected
In this section we prove that a closed interval (hence, any `OrdConnected` set) in a dense
conditionally complete linear order is preconnected.
-/
/-- A "continuous induction principle" for a closed interval: if a set `s` meets `[a, b]`
on a closed subset, contains `a`, and the set `s ∩ [a, b)` has no maximal point, then `b ∈ s`. -/
theorem IsClosed.mem_of_ge_of_forall_exists_gt {a b : α} {s : Set α} (hs : IsClosed (s ∩ Icc a b))
(ha : a ∈ s) (hab : a ≤ b) (hgt : ∀ x ∈ s ∩ Ico a b, (s ∩ Ioc x b).Nonempty) : b ∈ s := by
let S := s ∩ Icc a b
replace ha : a ∈ S := ⟨ha, left_mem_Icc.2 hab⟩
have Sbd : BddAbove S := ⟨b, fun z hz => hz.2.2⟩
let c := sSup (s ∩ Icc a b)
have c_mem : c ∈ S := hs.csSup_mem ⟨_, ha⟩ Sbd
have c_le : c ≤ b := csSup_le ⟨_, ha⟩ fun x hx => hx.2.2
cases' eq_or_lt_of_le c_le with hc hc
· exact hc ▸ c_mem.1
exfalso
rcases hgt c ⟨c_mem.1, c_mem.2.1, hc⟩ with ⟨x, xs, cx, xb⟩
exact not_lt_of_le (le_csSup Sbd ⟨xs, le_trans (le_csSup Sbd ha) (le_of_lt cx), xb⟩) cx
/-- A "continuous induction principle" for a closed interval: if a set `s` meets `[a, b]`
on a closed subset, contains `a`, and for any `a ≤ x < y ≤ b`, `x ∈ s`, the set `s ∩ (x, y]`
is not empty, then `[a, b] ⊆ s`. -/
theorem IsClosed.Icc_subset_of_forall_exists_gt {a b : α} {s : Set α} (hs : IsClosed (s ∩ Icc a b))
(ha : a ∈ s) (hgt : ∀ x ∈ s ∩ Ico a b, ∀ y ∈ Ioi x, (s ∩ Ioc x y).Nonempty) : Icc a b ⊆ s := by
intro y hy
have : IsClosed (s ∩ Icc a y) := by
suffices s ∩ Icc a y = s ∩ Icc a b ∩ Icc a y by
rw [this]
exact IsClosed.inter hs isClosed_Icc
rw [inter_assoc]
congr
exact (inter_eq_self_of_subset_right <| Icc_subset_Icc_right hy.2).symm
exact
IsClosed.mem_of_ge_of_forall_exists_gt this ha hy.1 fun x hx =>
hgt x ⟨hx.1, Ico_subset_Ico_right hy.2 hx.2⟩ y hx.2.2
variable [DenselyOrdered α] {a b : α}
/-- A "continuous induction principle" for a closed interval: if a set `s` meets `[a, b]`
on a closed subset, contains `a`, and for any `x ∈ s ∩ [a, b)` the set `s` includes some open
neighborhood of `x` within `(x, +∞)`, then `[a, b] ⊆ s`. -/
theorem IsClosed.Icc_subset_of_forall_mem_nhdsWithin {a b : α} {s : Set α}
(hs : IsClosed (s ∩ Icc a b)) (ha : a ∈ s) (hgt : ∀ x ∈ s ∩ Ico a b, s ∈ 𝓝[>] x) :
Icc a b ⊆ s := by
apply hs.Icc_subset_of_forall_exists_gt ha
rintro x ⟨hxs, hxab⟩ y hyxb
have : s ∩ Ioc x y ∈ 𝓝[>] x :=
inter_mem (hgt x ⟨hxs, hxab⟩) (Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, hyxb⟩)
exact (nhdsWithin_Ioi_self_neBot' ⟨b, hxab.2⟩).nonempty_of_mem this
theorem isPreconnected_Icc_aux (x y : α) (s t : Set α) (hxy : x ≤ y) (hs : IsClosed s)
(ht : IsClosed t) (hab : Icc a b ⊆ s ∪ t) (hx : x ∈ Icc a b ∩ s) (hy : y ∈ Icc a b ∩ t) :
(Icc a b ∩ (s ∩ t)).Nonempty := by
have xyab : Icc x y ⊆ Icc a b := Icc_subset_Icc hx.1.1 hy.1.2
by_contra hst
suffices Icc x y ⊆ s from
hst ⟨y, xyab <| right_mem_Icc.2 hxy, this <| right_mem_Icc.2 hxy, hy.2⟩
apply (IsClosed.inter hs isClosed_Icc).Icc_subset_of_forall_mem_nhdsWithin hx.2
rintro z ⟨zs, hz⟩
have zt : z ∈ tᶜ := fun zt => hst ⟨z, xyab <| Ico_subset_Icc_self hz, zs, zt⟩
have : tᶜ ∩ Ioc z y ∈ 𝓝[>] z := by
rw [← nhdsWithin_Ioc_eq_nhdsWithin_Ioi hz.2]
exact mem_nhdsWithin.2 ⟨tᶜ, ht.isOpen_compl, zt, Subset.rfl⟩
apply mem_of_superset this
have : Ioc z y ⊆ s ∪ t := fun w hw => hab (xyab ⟨le_trans hz.1 (le_of_lt hw.1), hw.2⟩)
exact fun w ⟨wt, wzy⟩ => (this wzy).elim id fun h => (wt h).elim
/-- A closed interval in a densely ordered conditionally complete linear order is preconnected. -/
theorem isPreconnected_Icc : IsPreconnected (Icc a b) :=
isPreconnected_closed_iff.2
(by
rintro s t hs ht hab ⟨x, hx⟩ ⟨y, hy⟩
-- This used to use `wlog`, but it was causing timeouts.
rcases le_total x y with h | h
· exact isPreconnected_Icc_aux x y s t h hs ht hab hx hy
· rw [inter_comm s t]
rw [union_comm s t] at hab
exact isPreconnected_Icc_aux y x t s h ht hs hab hy hx)
theorem isPreconnected_uIcc : IsPreconnected ([[a, b]]) :=
isPreconnected_Icc
theorem Set.OrdConnected.isPreconnected {s : Set α} (h : s.OrdConnected) : IsPreconnected s :=
isPreconnected_of_forall_pair fun x hx y hy =>
⟨[[x, y]], h.uIcc_subset hx hy, left_mem_uIcc, right_mem_uIcc, isPreconnected_uIcc⟩
theorem isPreconnected_iff_ordConnected {s : Set α} : IsPreconnected s ↔ OrdConnected s :=
⟨IsPreconnected.ordConnected, Set.OrdConnected.isPreconnected⟩
theorem isPreconnected_Ici : IsPreconnected (Ici a) :=
ordConnected_Ici.isPreconnected
theorem isPreconnected_Iic : IsPreconnected (Iic a) :=
ordConnected_Iic.isPreconnected
theorem isPreconnected_Iio : IsPreconnected (Iio a) :=
ordConnected_Iio.isPreconnected
theorem isPreconnected_Ioi : IsPreconnected (Ioi a) :=
ordConnected_Ioi.isPreconnected
theorem isPreconnected_Ioo : IsPreconnected (Ioo a b) :=
ordConnected_Ioo.isPreconnected
theorem isPreconnected_Ioc : IsPreconnected (Ioc a b) :=
ordConnected_Ioc.isPreconnected
theorem isPreconnected_Ico : IsPreconnected (Ico a b) :=
ordConnected_Ico.isPreconnected
theorem isConnected_Ici : IsConnected (Ici a) :=
⟨nonempty_Ici, isPreconnected_Ici⟩
theorem isConnected_Iic : IsConnected (Iic a) :=
⟨nonempty_Iic, isPreconnected_Iic⟩
theorem isConnected_Ioi [NoMaxOrder α] : IsConnected (Ioi a) :=
⟨nonempty_Ioi, isPreconnected_Ioi⟩
theorem isConnected_Iio [NoMinOrder α] : IsConnected (Iio a) :=
⟨nonempty_Iio, isPreconnected_Iio⟩
theorem isConnected_Icc (h : a ≤ b) : IsConnected (Icc a b) :=
⟨nonempty_Icc.2 h, isPreconnected_Icc⟩
theorem isConnected_Ioo (h : a < b) : IsConnected (Ioo a b) :=
⟨nonempty_Ioo.2 h, isPreconnected_Ioo⟩
theorem isConnected_Ioc (h : a < b) : IsConnected (Ioc a b) :=
⟨nonempty_Ioc.2 h, isPreconnected_Ioc⟩
theorem isConnected_Ico (h : a < b) : IsConnected (Ico a b) :=
⟨nonempty_Ico.2 h, isPreconnected_Ico⟩
instance (priority := 100) ordered_connected_space : PreconnectedSpace α :=
⟨ordConnected_univ.isPreconnected⟩
/-- In a dense conditionally complete linear order, the set of preconnected sets is exactly
the set of the intervals `Icc`, `Ico`, `Ioc`, `Ioo`, `Ici`, `Ioi`, `Iic`, `Iio`, `(-∞, +∞)`,
or `∅`. Though one can represent `∅` as `(sInf s, sInf s)`, we include it into the list of
possible cases to improve readability. -/
theorem setOf_isPreconnected_eq_of_ordered :
{ s : Set α | IsPreconnected s } =
-- bounded intervals
range (uncurry Icc) ∪ range (uncurry Ico) ∪ range (uncurry Ioc) ∪ range (uncurry Ioo) ∪
-- unbounded intervals and `univ`
(range Ici ∪ range Ioi ∪ range Iic ∪ range Iio ∪ {univ, ∅}) := by
refine Subset.antisymm setOf_isPreconnected_subset_of_ordered ?_
simp only [subset_def, forall_mem_range, uncurry, or_imp, forall_and, mem_union,
mem_setOf_eq, insert_eq, mem_singleton_iff, forall_eq, forall_true_iff, and_true_iff,
isPreconnected_Icc, isPreconnected_Ico, isPreconnected_Ioc, isPreconnected_Ioo,
isPreconnected_Ioi, isPreconnected_Iio, isPreconnected_Ici, isPreconnected_Iic,
isPreconnected_univ, isPreconnected_empty]
/-- This lemmas characterizes when a subset `s` of a densely ordered conditionally complete linear
order is totally disconnected with respect to the order topology: between any two distinct points
of `s` must lie a point not in `s`. -/
lemma isTotallyDisconnected_iff_lt {s : Set α} :
IsTotallyDisconnected s ↔ ∀ x ∈ s, ∀ y ∈ s, x < y → ∃ z ∉ s, z ∈ Ioo x y := by
simp only [IsTotallyDisconnected, isPreconnected_iff_ordConnected, ← not_nontrivial_iff,
nontrivial_iff_exists_lt, not_exists, not_and]
refine ⟨fun h x hx y hy hxy ↦ ?_, fun h t hts ht x hx y hy hxy ↦ ?_⟩
· simp_rw [← not_ordConnected_inter_Icc_iff hx hy]
exact fun hs ↦ h _ inter_subset_left hs _ ⟨hx, le_rfl, hxy.le⟩ _ ⟨hy, hxy.le, le_rfl⟩ hxy
· obtain ⟨z, h1z, h2z⟩ := h x (hts hx) y (hts hy) hxy
exact h1z <| hts <| ht.1 hx hy ⟨h2z.1.le, h2z.2.le⟩
/-!
### Intermediate Value Theorem on an interval
In this section we prove several versions of the Intermediate Value Theorem for a function
continuous on an interval.
-/
variable {δ : Type*} [LinearOrder δ] [TopologicalSpace δ] [OrderClosedTopology δ]
/-- **Intermediate Value Theorem** for continuous functions on closed intervals, case
`f a ≤ t ≤ f b`. -/
theorem intermediate_value_Icc {a b : α} (hab : a ≤ b) {f : α → δ} (hf : ContinuousOn f (Icc a b)) :
Icc (f a) (f b) ⊆ f '' Icc a b :=
isPreconnected_Icc.intermediate_value (left_mem_Icc.2 hab) (right_mem_Icc.2 hab) hf
/-- **Intermediate Value Theorem** for continuous functions on closed intervals, case
`f a ≥ t ≥ f b`. -/
theorem intermediate_value_Icc' {a b : α} (hab : a ≤ b) {f : α → δ}
(hf : ContinuousOn f (Icc a b)) : Icc (f b) (f a) ⊆ f '' Icc a b :=
isPreconnected_Icc.intermediate_value (right_mem_Icc.2 hab) (left_mem_Icc.2 hab) hf
/-- **Intermediate Value Theorem** for continuous functions on closed intervals, unordered case. -/
theorem intermediate_value_uIcc {a b : α} {f : α → δ} (hf : ContinuousOn f [[a, b]]) :
[[f a, f b]] ⊆ f '' uIcc a b := by
cases le_total (f a) (f b) <;> simp [*, isPreconnected_uIcc.intermediate_value]
/-- If `f : α → α` is continuous on `[[a, b]]`, `a ≤ f a`, and `f b ≤ b`,
then `f` has a fixed point on `[[a, b]]`. -/
theorem exists_mem_uIcc_isFixedPt {a b : α} {f : α → α} (hf : ContinuousOn f (uIcc a b))
(ha : a ≤ f a) (hb : f b ≤ b) : ∃ c ∈ [[a, b]], IsFixedPt f c :=
isPreconnected_uIcc.intermediate_value₂ right_mem_uIcc left_mem_uIcc hf continuousOn_id hb ha
/-- If `f : α → α` is continuous on `[a, b]`, `a ≤ b`, `a ≤ f a`, and `f b ≤ b`,
then `f` has a fixed point on `[a, b]`.
In particular, if `[a, b]` is forward-invariant under `f`,
then `f` has a fixed point on `[a, b]`, see `exists_mem_Icc_isFixedPt_of_mapsTo`. -/
theorem exists_mem_Icc_isFixedPt {a b : α} {f : α → α} (hf : ContinuousOn f (Icc a b))
(hle : a ≤ b) (ha : a ≤ f a) (hb : f b ≤ b) : ∃ c ∈ Icc a b, IsFixedPt f c :=
isPreconnected_Icc.intermediate_value₂
(right_mem_Icc.2 hle) (left_mem_Icc.2 hle) hf continuousOn_id hb ha
/-- If a closed interval is forward-invariant under a continuous map `f : α → α`,
then this map has a fixed point on this interval. -/
theorem exists_mem_Icc_isFixedPt_of_mapsTo {a b : α} {f : α → α} (hf : ContinuousOn f (Icc a b))
(hle : a ≤ b) (hmaps : MapsTo f (Icc a b) (Icc a b)) : ∃ c ∈ Icc a b, IsFixedPt f c :=
exists_mem_Icc_isFixedPt hf hle (hmaps <| left_mem_Icc.2 hle).1 (hmaps <| right_mem_Icc.2 hle).2
theorem intermediate_value_Ico {a b : α} (hab : a ≤ b) {f : α → δ} (hf : ContinuousOn f (Icc a b)) :
Ico (f a) (f b) ⊆ f '' Ico a b :=
Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.2 (not_lt_of_le (he ▸ h.1))) fun hlt =>
@IsPreconnected.intermediate_value_Ico _ _ _ _ _ _ _ isPreconnected_Ico _ _ ⟨refl a, hlt⟩
(right_nhdsWithin_Ico_neBot hlt) inf_le_right _ (hf.mono Ico_subset_Icc_self) _
((hf.continuousWithinAt ⟨hab, refl b⟩).mono Ico_subset_Icc_self)
theorem intermediate_value_Ico' {a b : α} (hab : a ≤ b) {f : α → δ}
(hf : ContinuousOn f (Icc a b)) : Ioc (f b) (f a) ⊆ f '' Ico a b :=
Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.1 (not_lt_of_le (he ▸ h.2))) fun hlt =>
@IsPreconnected.intermediate_value_Ioc _ _ _ _ _ _ _ isPreconnected_Ico _ _ ⟨refl a, hlt⟩
(right_nhdsWithin_Ico_neBot hlt) inf_le_right _ (hf.mono Ico_subset_Icc_self) _
((hf.continuousWithinAt ⟨hab, refl b⟩).mono Ico_subset_Icc_self)
theorem intermediate_value_Ioc {a b : α} (hab : a ≤ b) {f : α → δ} (hf : ContinuousOn f (Icc a b)) :
Ioc (f a) (f b) ⊆ f '' Ioc a b :=
Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.2 (not_le_of_lt (he ▸ h.1))) fun hlt =>
@IsPreconnected.intermediate_value_Ioc _ _ _ _ _ _ _ isPreconnected_Ioc _ _ ⟨hlt, refl b⟩
(left_nhdsWithin_Ioc_neBot hlt) inf_le_right _ (hf.mono Ioc_subset_Icc_self) _
((hf.continuousWithinAt ⟨refl a, hab⟩).mono Ioc_subset_Icc_self)
theorem intermediate_value_Ioc' {a b : α} (hab : a ≤ b) {f : α → δ}
(hf : ContinuousOn f (Icc a b)) : Ico (f b) (f a) ⊆ f '' Ioc a b :=
Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.1 (not_le_of_lt (he ▸ h.2))) fun hlt =>
@IsPreconnected.intermediate_value_Ico _ _ _ _ _ _ _ isPreconnected_Ioc _ _ ⟨hlt, refl b⟩
(left_nhdsWithin_Ioc_neBot hlt) inf_le_right _ (hf.mono Ioc_subset_Icc_self) _
((hf.continuousWithinAt ⟨refl a, hab⟩).mono Ioc_subset_Icc_self)
theorem intermediate_value_Ioo {a b : α} (hab : a ≤ b) {f : α → δ} (hf : ContinuousOn f (Icc a b)) :
Ioo (f a) (f b) ⊆ f '' Ioo a b :=
Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.2 (not_lt_of_lt (he ▸ h.1))) fun hlt =>
@IsPreconnected.intermediate_value_Ioo _ _ _ _ _ _ _ isPreconnected_Ioo _ _
(left_nhdsWithin_Ioo_neBot hlt) (right_nhdsWithin_Ioo_neBot hlt) inf_le_right inf_le_right _
(hf.mono Ioo_subset_Icc_self) _ _
((hf.continuousWithinAt ⟨refl a, hab⟩).mono Ioo_subset_Icc_self)
((hf.continuousWithinAt ⟨hab, refl b⟩).mono Ioo_subset_Icc_self)
theorem intermediate_value_Ioo' {a b : α} (hab : a ≤ b) {f : α → δ}
(hf : ContinuousOn f (Icc a b)) : Ioo (f b) (f a) ⊆ f '' Ioo a b :=
Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.1 (not_lt_of_lt (he ▸ h.2))) fun hlt =>
@IsPreconnected.intermediate_value_Ioo _ _ _ _ _ _ _ isPreconnected_Ioo _ _
(right_nhdsWithin_Ioo_neBot hlt) (left_nhdsWithin_Ioo_neBot hlt) inf_le_right inf_le_right _
(hf.mono Ioo_subset_Icc_self) _ _
((hf.continuousWithinAt ⟨hab, refl b⟩).mono Ioo_subset_Icc_self)
((hf.continuousWithinAt ⟨refl a, hab⟩).mono Ioo_subset_Icc_self)
/-- **Intermediate value theorem**: if `f` is continuous on an order-connected set `s` and `a`,
`b` are two points of this set, then `f` sends `s` to a superset of `Icc (f x) (f y)`. -/
theorem ContinuousOn.surjOn_Icc {s : Set α} [hs : OrdConnected s] {f : α → δ}
(hf : ContinuousOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) : SurjOn f s (Icc (f a) (f b)) :=
hs.isPreconnected.intermediate_value ha hb hf
/-- **Intermediate value theorem**: if `f` is continuous on an order-connected set `s` and `a`,
`b` are two points of this set, then `f` sends `s` to a superset of `[f x, f y]`. -/
theorem ContinuousOn.surjOn_uIcc {s : Set α} [hs : OrdConnected s] {f : α → δ}
(hf : ContinuousOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) :
SurjOn f s (uIcc (f a) (f b)) := by
rcases le_total (f a) (f b) with hab | hab <;> simp [hf.surjOn_Icc, *]
/-- A continuous function which tendsto `Filter.atTop` along `Filter.atTop` and to `atBot` along
`at_bot` is surjective. -/
theorem Continuous.surjective {f : α → δ} (hf : Continuous f) (h_top : Tendsto f atTop atTop)
(h_bot : Tendsto f atBot atBot) : Function.Surjective f := fun p =>
mem_range_of_exists_le_of_exists_ge hf (h_bot.eventually (eventually_le_atBot p)).exists
(h_top.eventually (eventually_ge_atTop p)).exists
/-- A continuous function which tendsto `Filter.atBot` along `Filter.atTop` and to `Filter.atTop`
along `atBot` is surjective. -/
theorem Continuous.surjective' {f : α → δ} (hf : Continuous f) (h_top : Tendsto f atBot atTop)
(h_bot : Tendsto f atTop atBot) : Function.Surjective f :=
Continuous.surjective (α := αᵒᵈ) hf h_top h_bot
/-- If a function `f : α → β` is continuous on a nonempty interval `s`, its restriction to `s`
tends to `at_bot : Filter β` along `at_bot : Filter ↥s` and tends to `Filter.atTop : Filter β` along
`Filter.atTop : Filter ↥s`, then the restriction of `f` to `s` is surjective. We formulate the
conclusion as `Function.surjOn f s Set.univ`. -/
theorem ContinuousOn.surjOn_of_tendsto {f : α → δ} {s : Set α} [OrdConnected s] (hs : s.Nonempty)
(hf : ContinuousOn f s) (hbot : Tendsto (fun x : s => f x) atBot atBot)
(htop : Tendsto (fun x : s => f x) atTop atTop) : SurjOn f s univ :=
haveI := Classical.inhabited_of_nonempty hs.to_subtype
surjOn_iff_surjective.2 <| hf.restrict.surjective htop hbot
/-- If a function `f : α → β` is continuous on a nonempty interval `s`, its restriction to `s`
tends to `Filter.atTop : Filter β` along `Filter.atBot : Filter ↥s` and tends to
`Filter.atBot : Filter β` along `Filter.atTop : Filter ↥s`, then the restriction of `f` to `s` is
surjective. We formulate the conclusion as `Function.surjOn f s Set.univ`. -/
theorem ContinuousOn.surjOn_of_tendsto' {f : α → δ} {s : Set α} [OrdConnected s] (hs : s.Nonempty)
(hf : ContinuousOn f s) (hbot : Tendsto (fun x : s => f x) atBot atTop)
(htop : Tendsto (fun x : s => f x) atTop atBot) : SurjOn f s univ :=
ContinuousOn.surjOn_of_tendsto (δ := δᵒᵈ) hs hf hbot htop
theorem Continuous.strictMono_of_inj_boundedOrder [BoundedOrder α] {f : α → δ}
(hf_c : Continuous f) (hf : f ⊥ ≤ f ⊤) (hf_i : Injective f) : StrictMono f := by
intro a b hab
by_contra! h
have H : f b < f a := lt_of_le_of_ne h <| hf_i.ne hab.ne'
by_cases ha : f a ≤ f ⊥
· obtain ⟨u, hu⟩ := intermediate_value_Ioc le_top hf_c.continuousOn ⟨H.trans_le ha, hf⟩
have : u = ⊥ := hf_i hu.2
aesop
· by_cases hb : f ⊥ < f b
· obtain ⟨u, hu⟩ := intermediate_value_Ioo bot_le hf_c.continuousOn ⟨hb, H⟩
rw [hf_i hu.2] at hu
exact (hab.trans hu.1.2).false
· push_neg at ha hb
replace hb : f b < f ⊥ := lt_of_le_of_ne hb <| hf_i.ne (lt_of_lt_of_le' hab bot_le).ne'
obtain ⟨u, hu⟩ := intermediate_value_Ioo' hab.le hf_c.continuousOn ⟨hb, ha⟩
have : u = ⊥ := hf_i hu.2
aesop
theorem Continuous.strictAnti_of_inj_boundedOrder [BoundedOrder α] {f : α → δ}
(hf_c : Continuous f) (hf : f ⊤ ≤ f ⊥) (hf_i : Injective f) : StrictAnti f :=
hf_c.strictMono_of_inj_boundedOrder (δ := δᵒᵈ) hf hf_i
theorem Continuous.strictMono_of_inj_boundedOrder' [BoundedOrder α] {f : α → δ}
(hf_c : Continuous f) (hf_i : Injective f) : StrictMono f ∨ StrictAnti f :=
(le_total (f ⊥) (f ⊤)).imp
(hf_c.strictMono_of_inj_boundedOrder · hf_i)
(hf_c.strictAnti_of_inj_boundedOrder · hf_i)
/-- Suppose `α` is equipped with a conditionally complete linear dense order and `f : α → δ` is
continuous and injective. Then `f` is strictly monotone (increasing) if
it is strictly monotone (increasing) on some closed interval `[a, b]`. -/
theorem Continuous.strictMonoOn_of_inj_rigidity {f : α → δ}
(hf_c : Continuous f) (hf_i : Injective f) {a b : α} (hab : a < b)
(hf_mono : StrictMonoOn f (Icc a b)) : StrictMono f := by
intro x y hxy
let s := min a x
let t := max b y
have hsa : s ≤ a := min_le_left a x
have hbt : b ≤ t := le_max_left b y
have hst : s ≤ t := hsa.trans $ hbt.trans' hab.le
have hf_mono_st : StrictMonoOn f (Icc s t) ∨ StrictAntiOn f (Icc s t) := by
letI := Icc.completeLinearOrder hst
have := Continuous.strictMono_of_inj_boundedOrder' (f := Set.restrict (Icc s t) f)
hf_c.continuousOn.restrict hf_i.injOn.injective
exact this.imp strictMono_restrict.mp strictAntiOn_iff_strictAnti.mpr
have (h : StrictAntiOn f (Icc s t)) : False := by
have : Icc a b ⊆ Icc s t := Icc_subset_Icc hsa hbt
replace : StrictAntiOn f (Icc a b) := StrictAntiOn.mono h this
replace : IsAntichain (· ≤ ·) (Icc a b) :=
IsAntichain.of_strictMonoOn_antitoneOn hf_mono this.antitoneOn
exact this.not_lt (left_mem_Icc.mpr (le_of_lt hab)) (right_mem_Icc.mpr (le_of_lt hab)) hab
replace hf_mono_st : StrictMonoOn f (Icc s t) := hf_mono_st.resolve_right this
have hsx : s ≤ x := min_le_right a x
have hyt : y ≤ t := le_max_right b y
replace : Icc x y ⊆ Icc s t := Icc_subset_Icc hsx hyt
replace : StrictMonoOn f (Icc x y) := StrictMonoOn.mono hf_mono_st this
exact this (left_mem_Icc.mpr (le_of_lt hxy)) (right_mem_Icc.mpr (le_of_lt hxy)) hxy
/-- Suppose `f : [a, b] → δ` is
continuous and injective. Then `f` is strictly monotone (increasing) if `f(a) ≤ f(b)`. -/
theorem ContinuousOn.strictMonoOn_of_injOn_Icc {a b : α} {f : α → δ}
(hab : a ≤ b) (hfab : f a ≤ f b)
(hf_c : ContinuousOn f (Icc a b)) (hf_i : InjOn f (Icc a b)) :
StrictMonoOn f (Icc a b) := by
letI := Icc.completeLinearOrder hab
refine StrictMono.of_restrict ?_
set g : Icc a b → δ := Set.restrict (Icc a b) f
have hgab : g ⊥ ≤ g ⊤ := by aesop
exact Continuous.strictMono_of_inj_boundedOrder (f := g) hf_c.restrict hgab hf_i.injective
/-- Suppose `f : [a, b] → δ` is
continuous and injective. Then `f` is strictly antitone (decreasing) if `f(b) ≤ f(a)`. -/
theorem ContinuousOn.strictAntiOn_of_injOn_Icc {a b : α} {f : α → δ}
(hab : a ≤ b) (hfab : f b ≤ f a)
(hf_c : ContinuousOn f (Icc a b)) (hf_i : InjOn f (Icc a b)) :
StrictAntiOn f (Icc a b) := ContinuousOn.strictMonoOn_of_injOn_Icc (δ := δᵒᵈ) hab hfab hf_c hf_i
/-- Suppose `f : [a, b] → δ` is continuous and injective. Then `f` is strictly monotone
or antitone (increasing or decreasing). -/
theorem ContinuousOn.strictMonoOn_of_injOn_Icc' {a b : α} {f : α → δ} (hab : a ≤ b)
(hf_c : ContinuousOn f (Icc a b)) (hf_i : InjOn f (Icc a b)) :
StrictMonoOn f (Icc a b) ∨ StrictAntiOn f (Icc a b) :=
(le_total (f a) (f b)).imp
(ContinuousOn.strictMonoOn_of_injOn_Icc hab · hf_c hf_i)
(ContinuousOn.strictAntiOn_of_injOn_Icc hab · hf_c hf_i)
/-- Suppose `α` is equipped with a conditionally complete linear dense order and `f : α → δ` is
continuous and injective. Then `f` is strictly monotone or antitone (increasing or decreasing). -/
theorem Continuous.strictMono_of_inj {f : α → δ}
(hf_c : Continuous f) (hf_i : Injective f) : StrictMono f ∨ StrictAnti f := by
have H {c d : α} (hcd : c < d) : StrictMono f ∨ StrictAnti f :=
(hf_c.continuousOn.strictMonoOn_of_injOn_Icc' hcd.le hf_i.injOn).imp
(hf_c.strictMonoOn_of_inj_rigidity hf_i hcd)
(hf_c.strictMonoOn_of_inj_rigidity (δ := δᵒᵈ) hf_i hcd)
by_cases hn : Nonempty α
· let a : α := Classical.choice ‹_›
by_cases h : ∃ b : α, a ≠ b
· choose b hb using h
by_cases hab : a < b
· exact H hab
· push_neg at hab
have : b < a := by exact Ne.lt_of_le (id (Ne.symm hb)) hab
exact H this
· push_neg at h
haveI : Subsingleton α := ⟨fun c d => Trans.trans (h c).symm (h d)⟩
exact Or.inl <| Subsingleton.strictMono f
· aesop
/-- Every continuous injective `f : (a, b) → δ` is strictly monotone
or antitone (increasing or decreasing). -/
theorem ContinuousOn.strictMonoOn_of_injOn_Ioo {a b : α} {f : α → δ} (hab : a < b)
(hf_c : ContinuousOn f (Ioo a b)) (hf_i : InjOn f (Ioo a b)) :
StrictMonoOn f (Ioo a b) ∨ StrictAntiOn f (Ioo a b) := by
haveI : Inhabited (Ioo a b) := Classical.inhabited_of_nonempty (nonempty_Ioo_subtype hab)
let g : Ioo a b → δ := Set.restrict (Ioo a b) f
have : StrictMono g ∨ StrictAnti g :=
Continuous.strictMono_of_inj hf_c.restrict hf_i.injective
exact this.imp strictMono_restrict.mp strictAntiOn_iff_strictAnti.mpr
|
Topology\Order\IsLUB.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, Yury Kudryashov
-/
import Mathlib.Topology.Order.LeftRightNhds
/-!
# Properties of LUB and GLB in an order topology
-/
open Set Filter TopologicalSpace Topology Function
open OrderDual (toDual ofDual)
variable {α β γ : Type*}
section OrderTopology
variable [TopologicalSpace α] [TopologicalSpace β] [LinearOrder α] [LinearOrder β] [OrderTopology α]
[OrderTopology β]
theorem IsLUB.frequently_mem {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) :
∃ᶠ x in 𝓝[≤] a, x ∈ s := by
rcases hs with ⟨a', ha'⟩
intro h
rcases (ha.1 ha').eq_or_lt with (rfl | ha'a)
· exact h.self_of_nhdsWithin le_rfl ha'
· rcases (mem_nhdsWithin_Iic_iff_exists_Ioc_subset' ha'a).1 h with ⟨b, hba, hb⟩
rcases ha.exists_between hba with ⟨b', hb's, hb'⟩
exact hb hb' hb's
theorem IsLUB.frequently_nhds_mem {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) :
∃ᶠ x in 𝓝 a, x ∈ s :=
(ha.frequently_mem hs).filter_mono inf_le_left
theorem IsGLB.frequently_mem {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty) :
∃ᶠ x in 𝓝[≥] a, x ∈ s :=
IsLUB.frequently_mem (α := αᵒᵈ) ha hs
theorem IsGLB.frequently_nhds_mem {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty) :
∃ᶠ x in 𝓝 a, x ∈ s :=
(ha.frequently_mem hs).filter_mono inf_le_left
theorem IsLUB.mem_closure {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) : a ∈ closure s :=
(ha.frequently_nhds_mem hs).mem_closure
theorem IsGLB.mem_closure {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty) : a ∈ closure s :=
(ha.frequently_nhds_mem hs).mem_closure
theorem IsLUB.nhdsWithin_neBot {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) :
NeBot (𝓝[s] a) :=
mem_closure_iff_nhdsWithin_neBot.1 (ha.mem_closure hs)
theorem IsGLB.nhdsWithin_neBot : ∀ {a : α} {s : Set α}, IsGLB s a → s.Nonempty → NeBot (𝓝[s] a) :=
IsLUB.nhdsWithin_neBot (α := αᵒᵈ)
theorem isLUB_of_mem_nhds {s : Set α} {a : α} {f : Filter α} (hsa : a ∈ upperBounds s) (hsf : s ∈ f)
[NeBot (f ⊓ 𝓝 a)] : IsLUB s a :=
⟨hsa, fun b hb =>
not_lt.1 fun hba =>
have : s ∩ { a | b < a } ∈ f ⊓ 𝓝 a := inter_mem_inf hsf (IsOpen.mem_nhds (isOpen_lt' _) hba)
let ⟨_x, ⟨hxs, hxb⟩⟩ := Filter.nonempty_of_mem this
have : b < b := lt_of_lt_of_le hxb <| hb hxs
lt_irrefl b this⟩
theorem isLUB_of_mem_closure {s : Set α} {a : α} (hsa : a ∈ upperBounds s) (hsf : a ∈ closure s) :
IsLUB s a := by
rw [mem_closure_iff_clusterPt, ClusterPt, inf_comm] at hsf
exact isLUB_of_mem_nhds hsa (mem_principal_self s)
theorem isGLB_of_mem_nhds :
∀ {s : Set α} {a : α} {f : Filter α}, a ∈ lowerBounds s → s ∈ f → NeBot (f ⊓ 𝓝 a) → IsGLB s a :=
isLUB_of_mem_nhds (α := αᵒᵈ)
theorem isGLB_of_mem_closure {s : Set α} {a : α} (hsa : a ∈ lowerBounds s) (hsf : a ∈ closure s) :
IsGLB s a :=
isLUB_of_mem_closure (α := αᵒᵈ) hsa hsf
theorem IsLUB.mem_upperBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ]
{f : α → γ} {s : Set α} {a : α} {b : γ} (hf : MonotoneOn f s) (ha : IsLUB s a)
(hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ upperBounds (f '' s) := by
rintro _ ⟨x, hx, rfl⟩
replace ha := ha.inter_Ici_of_mem hx
haveI := ha.nhdsWithin_neBot ⟨x, hx, le_rfl⟩
refine ge_of_tendsto (hb.mono_left (nhdsWithin_mono a (inter_subset_left (t := Ici x)))) ?_
exact mem_of_superset self_mem_nhdsWithin fun y hy => hf hx hy.1 hy.2
-- For a version of this theorem in which the convergence considered on the domain `α` is as `x : α`
-- tends to infinity, rather than tending to a point `x` in `α`, see `isLUB_of_tendsto_atTop`
theorem IsLUB.isLUB_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ}
{s : Set α} {a : α} {b : γ} (hf : MonotoneOn f s) (ha : IsLUB s a) (hs : s.Nonempty)
(hb : Tendsto f (𝓝[s] a) (𝓝 b)) : IsLUB (f '' s) b :=
haveI := ha.nhdsWithin_neBot hs
⟨ha.mem_upperBounds_of_tendsto hf hb, fun _b' hb' =>
le_of_tendsto hb (mem_of_superset self_mem_nhdsWithin fun _ hx => hb' <| mem_image_of_mem _ hx)⟩
theorem IsGLB.mem_lowerBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ]
{f : α → γ} {s : Set α} {a : α} {b : γ} (hf : MonotoneOn f s) (ha : IsGLB s a)
(hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ lowerBounds (f '' s) :=
IsLUB.mem_upperBounds_of_tendsto (α := αᵒᵈ) (γ := γᵒᵈ) hf.dual ha hb
-- For a version of this theorem in which the convergence considered on the domain `α` is as
-- `x : α` tends to negative infinity, rather than tending to a point `x` in `α`, see
-- `isGLB_of_tendsto_atBot`
theorem IsGLB.isGLB_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ}
{s : Set α} {a : α} {b : γ} (hf : MonotoneOn f s) :
IsGLB s a → s.Nonempty → Tendsto f (𝓝[s] a) (𝓝 b) → IsGLB (f '' s) b :=
IsLUB.isLUB_of_tendsto (α := αᵒᵈ) (γ := γᵒᵈ) hf.dual
theorem IsLUB.mem_lowerBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ]
{f : α → γ} {s : Set α} {a : α} {b : γ} (hf : AntitoneOn f s) (ha : IsLUB s a)
(hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ lowerBounds (f '' s) :=
IsLUB.mem_upperBounds_of_tendsto (γ := γᵒᵈ) hf ha hb
theorem IsLUB.isGLB_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] :
∀ {f : α → γ} {s : Set α} {a : α} {b : γ},
AntitoneOn f s → IsLUB s a → s.Nonempty → Tendsto f (𝓝[s] a) (𝓝 b) → IsGLB (f '' s) b :=
IsLUB.isLUB_of_tendsto (γ := γᵒᵈ)
theorem IsGLB.mem_upperBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ]
{f : α → γ} {s : Set α} {a : α} {b : γ} (hf : AntitoneOn f s) (ha : IsGLB s a)
(hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ upperBounds (f '' s) :=
IsGLB.mem_lowerBounds_of_tendsto (γ := γᵒᵈ) hf ha hb
theorem IsGLB.isLUB_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] :
∀ {f : α → γ} {s : Set α} {a : α} {b : γ},
AntitoneOn f s → IsGLB s a → s.Nonempty → Tendsto f (𝓝[s] a) (𝓝 b) → IsLUB (f '' s) b :=
IsGLB.isGLB_of_tendsto (γ := γᵒᵈ)
theorem IsLUB.mem_of_isClosed {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty)
(sc : IsClosed s) : a ∈ s :=
sc.closure_subset <| ha.mem_closure hs
alias IsClosed.isLUB_mem := IsLUB.mem_of_isClosed
theorem IsGLB.mem_of_isClosed {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty)
(sc : IsClosed s) : a ∈ s :=
sc.closure_subset <| ha.mem_closure hs
alias IsClosed.isGLB_mem := IsGLB.mem_of_isClosed
/-!
### Existence of sequences tending to `sInf` or `sSup` of a given set
-/
theorem IsLUB.exists_seq_strictMono_tendsto_of_not_mem {t : Set α} {x : α}
[IsCountablyGenerated (𝓝 x)] (htx : IsLUB t x) (not_mem : x ∉ t) (ht : t.Nonempty) :
∃ u : ℕ → α, StrictMono u ∧ (∀ n, u n < x) ∧ Tendsto u atTop (𝓝 x) ∧ ∀ n, u n ∈ t := by
obtain ⟨v, hvx, hvt⟩ := exists_seq_forall_of_frequently (htx.frequently_mem ht)
replace hvx := hvx.mono_right nhdsWithin_le_nhds
have hvx' : ∀ {n}, v n < x := (htx.1 (hvt _)).lt_of_ne (ne_of_mem_of_not_mem (hvt _) not_mem)
have : ∀ k, ∀ᶠ l in atTop, v k < v l := fun k => hvx.eventually (lt_mem_nhds hvx')
choose N hN hvN using fun k => ((eventually_gt_atTop k).and (this k)).exists
refine ⟨fun k => v (N^[k] 0), strictMono_nat_of_lt_succ fun _ => ?_, fun _ => hvx',
hvx.comp (strictMono_nat_of_lt_succ fun _ => ?_).tendsto_atTop, fun _ => hvt _⟩
· rw [iterate_succ_apply']; exact hvN _
· rw [iterate_succ_apply']; exact hN _
theorem IsLUB.exists_seq_monotone_tendsto {t : Set α} {x : α} [IsCountablyGenerated (𝓝 x)]
(htx : IsLUB t x) (ht : t.Nonempty) :
∃ u : ℕ → α, Monotone u ∧ (∀ n, u n ≤ x) ∧ Tendsto u atTop (𝓝 x) ∧ ∀ n, u n ∈ t := by
by_cases h : x ∈ t
· exact ⟨fun _ => x, monotone_const, fun n => le_rfl, tendsto_const_nhds, fun _ => h⟩
· rcases htx.exists_seq_strictMono_tendsto_of_not_mem h ht with ⟨u, hu⟩
exact ⟨u, hu.1.monotone, fun n => (hu.2.1 n).le, hu.2.2⟩
theorem exists_seq_strictMono_tendsto' {α : Type*} [LinearOrder α] [TopologicalSpace α]
[DenselyOrdered α] [OrderTopology α] [FirstCountableTopology α] {x y : α} (hy : y < x) :
∃ u : ℕ → α, StrictMono u ∧ (∀ n, u n ∈ Ioo y x) ∧ Tendsto u atTop (𝓝 x) := by
have hx : x ∉ Ioo y x := fun h => (lt_irrefl x h.2).elim
have ht : Set.Nonempty (Ioo y x) := nonempty_Ioo.2 hy
rcases (isLUB_Ioo hy).exists_seq_strictMono_tendsto_of_not_mem hx ht with ⟨u, hu⟩
exact ⟨u, hu.1, hu.2.2.symm⟩
theorem exists_seq_strictMono_tendsto [DenselyOrdered α] [NoMinOrder α] [FirstCountableTopology α]
(x : α) : ∃ u : ℕ → α, StrictMono u ∧ (∀ n, u n < x) ∧ Tendsto u atTop (𝓝 x) := by
obtain ⟨y, hy⟩ : ∃ y, y < x := exists_lt x
rcases exists_seq_strictMono_tendsto' hy with ⟨u, hu_mono, hu_mem, hux⟩
exact ⟨u, hu_mono, fun n => (hu_mem n).2, hux⟩
theorem exists_seq_strictMono_tendsto_nhdsWithin [DenselyOrdered α] [NoMinOrder α]
[FirstCountableTopology α] (x : α) :
∃ u : ℕ → α, StrictMono u ∧ (∀ n, u n < x) ∧ Tendsto u atTop (𝓝[<] x) :=
let ⟨u, hu, hx, h⟩ := exists_seq_strictMono_tendsto x
⟨u, hu, hx, tendsto_nhdsWithin_mono_right (range_subset_iff.2 hx) <| tendsto_nhdsWithin_range.2 h⟩
theorem exists_seq_tendsto_sSup {α : Type*} [ConditionallyCompleteLinearOrder α]
[TopologicalSpace α] [OrderTopology α] [FirstCountableTopology α] {S : Set α} (hS : S.Nonempty)
(hS' : BddAbove S) : ∃ u : ℕ → α, Monotone u ∧ Tendsto u atTop (𝓝 (sSup S)) ∧ ∀ n, u n ∈ S := by
rcases (isLUB_csSup hS hS').exists_seq_monotone_tendsto hS with ⟨u, hu⟩
exact ⟨u, hu.1, hu.2.2⟩
theorem IsGLB.exists_seq_strictAnti_tendsto_of_not_mem {t : Set α} {x : α}
[IsCountablyGenerated (𝓝 x)] (htx : IsGLB t x) (not_mem : x ∉ t) (ht : t.Nonempty) :
∃ u : ℕ → α, StrictAnti u ∧ (∀ n, x < u n) ∧ Tendsto u atTop (𝓝 x) ∧ ∀ n, u n ∈ t :=
IsLUB.exists_seq_strictMono_tendsto_of_not_mem (α := αᵒᵈ) htx not_mem ht
theorem IsGLB.exists_seq_antitone_tendsto {t : Set α} {x : α} [IsCountablyGenerated (𝓝 x)]
(htx : IsGLB t x) (ht : t.Nonempty) :
∃ u : ℕ → α, Antitone u ∧ (∀ n, x ≤ u n) ∧ Tendsto u atTop (𝓝 x) ∧ ∀ n, u n ∈ t :=
IsLUB.exists_seq_monotone_tendsto (α := αᵒᵈ) htx ht
theorem exists_seq_strictAnti_tendsto' [DenselyOrdered α] [FirstCountableTopology α] {x y : α}
(hy : x < y) : ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, u n ∈ Ioo x y) ∧ Tendsto u atTop (𝓝 x) := by
simpa only [dual_Ioo]
using exists_seq_strictMono_tendsto' (α := αᵒᵈ) (OrderDual.toDual_lt_toDual.2 hy)
theorem exists_seq_strictAnti_tendsto [DenselyOrdered α] [NoMaxOrder α] [FirstCountableTopology α]
(x : α) : ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, x < u n) ∧ Tendsto u atTop (𝓝 x) :=
exists_seq_strictMono_tendsto (α := αᵒᵈ) x
theorem exists_seq_strictAnti_tendsto_nhdsWithin [DenselyOrdered α] [NoMaxOrder α]
[FirstCountableTopology α] (x : α) :
∃ u : ℕ → α, StrictAnti u ∧ (∀ n, x < u n) ∧ Tendsto u atTop (𝓝[>] x) :=
exists_seq_strictMono_tendsto_nhdsWithin (α := αᵒᵈ) _
theorem exists_seq_strictAnti_strictMono_tendsto [DenselyOrdered α] [FirstCountableTopology α]
{x y : α} (h : x < y) :
∃ u v : ℕ → α, StrictAnti u ∧ StrictMono v ∧ (∀ k, u k ∈ Ioo x y) ∧ (∀ l, v l ∈ Ioo x y) ∧
(∀ k l, u k < v l) ∧ Tendsto u atTop (𝓝 x) ∧ Tendsto v atTop (𝓝 y) := by
rcases exists_seq_strictAnti_tendsto' h with ⟨u, hu_anti, hu_mem, hux⟩
rcases exists_seq_strictMono_tendsto' (hu_mem 0).2 with ⟨v, hv_mono, hv_mem, hvy⟩
exact
⟨u, v, hu_anti, hv_mono, hu_mem, fun l => ⟨(hu_mem 0).1.trans (hv_mem l).1, (hv_mem l).2⟩,
fun k l => (hu_anti.antitone (zero_le k)).trans_lt (hv_mem l).1, hux, hvy⟩
theorem exists_seq_tendsto_sInf {α : Type*} [ConditionallyCompleteLinearOrder α]
[TopologicalSpace α] [OrderTopology α] [FirstCountableTopology α] {S : Set α} (hS : S.Nonempty)
(hS' : BddBelow S) : ∃ u : ℕ → α, Antitone u ∧ Tendsto u atTop (𝓝 (sInf S)) ∧ ∀ n, u n ∈ S :=
exists_seq_tendsto_sSup (α := αᵒᵈ) hS hS'
end OrderTopology
|
Topology\Order\Lattice.lean | /-
Copyright (c) 2021 Christopher Hoskin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Christopher Hoskin
-/
import Mathlib.Topology.Constructions
import Mathlib.Topology.Order.OrderClosed
/-!
# Topological lattices
In this file we define mixin classes `ContinuousInf` and `ContinuousSup`. We define the
class `TopologicalLattice` as a topological space and lattice `L` extending `ContinuousInf` and
`ContinuousSup`.
## References
* [Gierz et al, A Compendium of Continuous Lattices][GierzEtAl1980]
## Tags
topological, lattice
-/
open Filter
open Topology
/-- Let `L` be a topological space and let `L×L` be equipped with the product topology and let
`⊓:L×L → L` be an infimum. Then `L` is said to have *(jointly) continuous infimum* if the map
`⊓:L×L → L` is continuous.
-/
class ContinuousInf (L : Type*) [TopologicalSpace L] [Inf L] : Prop where
/-- The infimum is continuous -/
continuous_inf : Continuous fun p : L × L => p.1 ⊓ p.2
/-- Let `L` be a topological space and let `L×L` be equipped with the product topology and let
`⊓:L×L → L` be a supremum. Then `L` is said to have *(jointly) continuous supremum* if the map
`⊓:L×L → L` is continuous.
-/
class ContinuousSup (L : Type*) [TopologicalSpace L] [Sup L] : Prop where
/-- The supremum is continuous -/
continuous_sup : Continuous fun p : L × L => p.1 ⊔ p.2
-- see Note [lower instance priority]
instance (priority := 100) OrderDual.continuousSup (L : Type*) [TopologicalSpace L] [Inf L]
[ContinuousInf L] : ContinuousSup Lᵒᵈ where
continuous_sup := @ContinuousInf.continuous_inf L _ _ _
-- see Note [lower instance priority]
instance (priority := 100) OrderDual.continuousInf (L : Type*) [TopologicalSpace L] [Sup L]
[ContinuousSup L] : ContinuousInf Lᵒᵈ where
continuous_inf := @ContinuousSup.continuous_sup L _ _ _
/-- Let `L` be a lattice equipped with a topology such that `L` has continuous infimum and supremum.
Then `L` is said to be a *topological lattice*.
-/
class TopologicalLattice (L : Type*) [TopologicalSpace L] [Lattice L]
extends ContinuousInf L, ContinuousSup L : Prop
-- see Note [lower instance priority]
instance (priority := 100) OrderDual.topologicalLattice (L : Type*) [TopologicalSpace L]
[Lattice L] [TopologicalLattice L] : TopologicalLattice Lᵒᵈ where
-- see Note [lower instance priority]
instance (priority := 100) LinearOrder.topologicalLattice {L : Type*} [TopologicalSpace L]
[LinearOrder L] [OrderClosedTopology L] : TopologicalLattice L where
continuous_inf := continuous_min
continuous_sup := continuous_max
variable {L X : Type*} [TopologicalSpace L] [TopologicalSpace X]
@[continuity]
theorem continuous_inf [Inf L] [ContinuousInf L] : Continuous fun p : L × L => p.1 ⊓ p.2 :=
ContinuousInf.continuous_inf
@[continuity, fun_prop]
theorem Continuous.inf [Inf L] [ContinuousInf L] {f g : X → L} (hf : Continuous f)
(hg : Continuous g) : Continuous fun x => f x ⊓ g x :=
continuous_inf.comp (hf.prod_mk hg : _)
@[continuity]
theorem continuous_sup [Sup L] [ContinuousSup L] : Continuous fun p : L × L => p.1 ⊔ p.2 :=
ContinuousSup.continuous_sup
@[continuity, fun_prop]
theorem Continuous.sup [Sup L] [ContinuousSup L] {f g : X → L} (hf : Continuous f)
(hg : Continuous g) : Continuous fun x => f x ⊔ g x :=
continuous_sup.comp (hf.prod_mk hg : _)
namespace Filter.Tendsto
section SupInf
variable {α : Type*} {l : Filter α} {f g : α → L} {x y : L}
lemma sup_nhds' [Sup L] [ContinuousSup L] (hf : Tendsto f l (𝓝 x)) (hg : Tendsto g l (𝓝 y)) :
Tendsto (f ⊔ g) l (𝓝 (x ⊔ y)) :=
(continuous_sup.tendsto _).comp (Tendsto.prod_mk_nhds hf hg)
lemma sup_nhds [Sup L] [ContinuousSup L] (hf : Tendsto f l (𝓝 x)) (hg : Tendsto g l (𝓝 y)) :
Tendsto (fun i => f i ⊔ g i) l (𝓝 (x ⊔ y)) :=
hf.sup_nhds' hg
lemma inf_nhds' [Inf L] [ContinuousInf L] (hf : Tendsto f l (𝓝 x)) (hg : Tendsto g l (𝓝 y)) :
Tendsto (f ⊓ g) l (𝓝 (x ⊓ y)) :=
(continuous_inf.tendsto _).comp (Tendsto.prod_mk_nhds hf hg)
lemma inf_nhds [Inf L] [ContinuousInf L] (hf : Tendsto f l (𝓝 x)) (hg : Tendsto g l (𝓝 y)) :
Tendsto (fun i => f i ⊓ g i) l (𝓝 (x ⊓ y)) :=
hf.inf_nhds' hg
end SupInf
open Finset
variable {ι α : Type*} {s : Finset ι} {f : ι → α → L} {l : Filter α} {g : ι → L}
lemma finset_sup'_nhds [SemilatticeSup L] [ContinuousSup L]
(hne : s.Nonempty) (hs : ∀ i ∈ s, Tendsto (f i) l (𝓝 (g i))) :
Tendsto (s.sup' hne f) l (𝓝 (s.sup' hne g)) := by
induction hne using Finset.Nonempty.cons_induction with
| singleton => simpa using hs
| cons a s ha hne ihs =>
rw [forall_mem_cons] at hs
simp only [sup'_cons, hne]
exact hs.1.sup_nhds (ihs hs.2)
lemma finset_sup'_nhds_apply [SemilatticeSup L] [ContinuousSup L]
(hne : s.Nonempty) (hs : ∀ i ∈ s, Tendsto (f i) l (𝓝 (g i))) :
Tendsto (fun a ↦ s.sup' hne (f · a)) l (𝓝 (s.sup' hne g)) := by
simpa only [← Finset.sup'_apply] using finset_sup'_nhds hne hs
lemma finset_inf'_nhds [SemilatticeInf L] [ContinuousInf L]
(hne : s.Nonempty) (hs : ∀ i ∈ s, Tendsto (f i) l (𝓝 (g i))) :
Tendsto (s.inf' hne f) l (𝓝 (s.inf' hne g)) :=
finset_sup'_nhds (L := Lᵒᵈ) hne hs
lemma finset_inf'_nhds_apply [SemilatticeInf L] [ContinuousInf L]
(hne : s.Nonempty) (hs : ∀ i ∈ s, Tendsto (f i) l (𝓝 (g i))) :
Tendsto (fun a ↦ s.inf' hne (f · a)) l (𝓝 (s.inf' hne g)) :=
finset_sup'_nhds_apply (L := Lᵒᵈ) hne hs
lemma finset_sup_nhds [SemilatticeSup L] [OrderBot L] [ContinuousSup L]
(hs : ∀ i ∈ s, Tendsto (f i) l (𝓝 (g i))) : Tendsto (s.sup f) l (𝓝 (s.sup g)) := by
rcases s.eq_empty_or_nonempty with rfl | hne
· simpa using tendsto_const_nhds
· simp only [← sup'_eq_sup hne]
exact finset_sup'_nhds hne hs
lemma finset_sup_nhds_apply [SemilatticeSup L] [OrderBot L] [ContinuousSup L]
(hs : ∀ i ∈ s, Tendsto (f i) l (𝓝 (g i))) :
Tendsto (fun a ↦ s.sup (f · a)) l (𝓝 (s.sup g)) := by
simpa only [← Finset.sup_apply] using finset_sup_nhds hs
lemma finset_inf_nhds [SemilatticeInf L] [OrderTop L] [ContinuousInf L]
(hs : ∀ i ∈ s, Tendsto (f i) l (𝓝 (g i))) : Tendsto (s.inf f) l (𝓝 (s.inf g)) :=
finset_sup_nhds (L := Lᵒᵈ) hs
lemma finset_inf_nhds_apply [SemilatticeInf L] [OrderTop L] [ContinuousInf L]
(hs : ∀ i ∈ s, Tendsto (f i) l (𝓝 (g i))) :
Tendsto (fun a ↦ s.inf (f · a)) l (𝓝 (s.inf g)) :=
finset_sup_nhds_apply (L := Lᵒᵈ) hs
end Filter.Tendsto
section Sup
variable [Sup L] [ContinuousSup L] {f g : X → L} {s : Set X} {x : X}
lemma ContinuousAt.sup' (hf : ContinuousAt f x) (hg : ContinuousAt g x) :
ContinuousAt (f ⊔ g) x :=
hf.sup_nhds' hg
@[fun_prop]
lemma ContinuousAt.sup (hf : ContinuousAt f x) (hg : ContinuousAt g x) :
ContinuousAt (fun a ↦ f a ⊔ g a) x :=
hf.sup' hg
lemma ContinuousWithinAt.sup' (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) :
ContinuousWithinAt (f ⊔ g) s x :=
hf.sup_nhds' hg
lemma ContinuousWithinAt.sup (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) :
ContinuousWithinAt (fun a ↦ f a ⊔ g a) s x :=
hf.sup' hg
lemma ContinuousOn.sup' (hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (f ⊔ g) s := fun x hx ↦
(hf x hx).sup' (hg x hx)
@[fun_prop]
lemma ContinuousOn.sup (hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (fun a ↦ f a ⊔ g a) s :=
hf.sup' hg
lemma Continuous.sup' (hf : Continuous f) (hg : Continuous g) : Continuous (f ⊔ g) := hf.sup hg
end Sup
section Inf
variable [Inf L] [ContinuousInf L] {f g : X → L} {s : Set X} {x : X}
lemma ContinuousAt.inf' (hf : ContinuousAt f x) (hg : ContinuousAt g x) :
ContinuousAt (f ⊓ g) x :=
hf.inf_nhds' hg
@[fun_prop]
lemma ContinuousAt.inf (hf : ContinuousAt f x) (hg : ContinuousAt g x) :
ContinuousAt (fun a ↦ f a ⊓ g a) x :=
hf.inf' hg
lemma ContinuousWithinAt.inf' (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) :
ContinuousWithinAt (f ⊓ g) s x :=
hf.inf_nhds' hg
lemma ContinuousWithinAt.inf (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) :
ContinuousWithinAt (fun a ↦ f a ⊓ g a) s x :=
hf.inf' hg
lemma ContinuousOn.inf' (hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (f ⊓ g) s := fun x hx ↦
(hf x hx).inf' (hg x hx)
@[fun_prop]
lemma ContinuousOn.inf (hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (fun a ↦ f a ⊓ g a) s :=
hf.inf' hg
lemma Continuous.inf' (hf : Continuous f) (hg : Continuous g) : Continuous (f ⊓ g) := hf.inf hg
end Inf
section FinsetSup'
variable {ι : Type*} [SemilatticeSup L] [ContinuousSup L] {s : Finset ι}
{f : ι → X → L} {t : Set X} {x : X}
lemma ContinuousAt.finset_sup'_apply (hne : s.Nonempty) (hs : ∀ i ∈ s, ContinuousAt (f i) x) :
ContinuousAt (fun a ↦ s.sup' hne (f · a)) x :=
Tendsto.finset_sup'_nhds_apply hne hs
lemma ContinuousAt.finset_sup' (hne : s.Nonempty) (hs : ∀ i ∈ s, ContinuousAt (f i) x) :
ContinuousAt (s.sup' hne f) x := by
simpa only [← Finset.sup'_apply] using finset_sup'_apply hne hs
lemma ContinuousWithinAt.finset_sup'_apply (hne : s.Nonempty)
(hs : ∀ i ∈ s, ContinuousWithinAt (f i) t x) :
ContinuousWithinAt (fun a ↦ s.sup' hne (f · a)) t x :=
Tendsto.finset_sup'_nhds_apply hne hs
lemma ContinuousWithinAt.finset_sup' (hne : s.Nonempty)
(hs : ∀ i ∈ s, ContinuousWithinAt (f i) t x) : ContinuousWithinAt (s.sup' hne f) t x := by
simpa only [← Finset.sup'_apply] using finset_sup'_apply hne hs
lemma ContinuousOn.finset_sup'_apply (hne : s.Nonempty) (hs : ∀ i ∈ s, ContinuousOn (f i) t) :
ContinuousOn (fun a ↦ s.sup' hne (f · a)) t := fun x hx ↦
ContinuousWithinAt.finset_sup'_apply hne fun i hi ↦ hs i hi x hx
lemma ContinuousOn.finset_sup' (hne : s.Nonempty) (hs : ∀ i ∈ s, ContinuousOn (f i) t) :
ContinuousOn (s.sup' hne f) t := fun x hx ↦
ContinuousWithinAt.finset_sup' hne fun i hi ↦ hs i hi x hx
lemma Continuous.finset_sup'_apply (hne : s.Nonempty) (hs : ∀ i ∈ s, Continuous (f i)) :
Continuous (fun a ↦ s.sup' hne (f · a)) :=
continuous_iff_continuousAt.2 fun _ ↦ ContinuousAt.finset_sup'_apply _ fun i hi ↦
(hs i hi).continuousAt
lemma Continuous.finset_sup' (hne : s.Nonempty) (hs : ∀ i ∈ s, Continuous (f i)) :
Continuous (s.sup' hne f) :=
continuous_iff_continuousAt.2 fun _ ↦ ContinuousAt.finset_sup' _ fun i hi ↦ (hs i hi).continuousAt
end FinsetSup'
section FinsetSup
variable {ι : Type*} [SemilatticeSup L] [OrderBot L] [ContinuousSup L] {s : Finset ι}
{f : ι → X → L} {t : Set X} {x : X}
lemma ContinuousAt.finset_sup_apply (hs : ∀ i ∈ s, ContinuousAt (f i) x) :
ContinuousAt (fun a ↦ s.sup (f · a)) x :=
Tendsto.finset_sup_nhds_apply hs
lemma ContinuousAt.finset_sup (hs : ∀ i ∈ s, ContinuousAt (f i) x) :
ContinuousAt (s.sup f) x := by
simpa only [← Finset.sup_apply] using finset_sup_apply hs
lemma ContinuousWithinAt.finset_sup_apply
(hs : ∀ i ∈ s, ContinuousWithinAt (f i) t x) :
ContinuousWithinAt (fun a ↦ s.sup (f · a)) t x :=
Tendsto.finset_sup_nhds_apply hs
lemma ContinuousWithinAt.finset_sup
(hs : ∀ i ∈ s, ContinuousWithinAt (f i) t x) : ContinuousWithinAt (s.sup f) t x := by
simpa only [← Finset.sup_apply] using finset_sup_apply hs
lemma ContinuousOn.finset_sup_apply (hs : ∀ i ∈ s, ContinuousOn (f i) t) :
ContinuousOn (fun a ↦ s.sup (f · a)) t := fun x hx ↦
ContinuousWithinAt.finset_sup_apply fun i hi ↦ hs i hi x hx
lemma ContinuousOn.finset_sup (hs : ∀ i ∈ s, ContinuousOn (f i) t) :
ContinuousOn (s.sup f) t := fun x hx ↦
ContinuousWithinAt.finset_sup fun i hi ↦ hs i hi x hx
lemma Continuous.finset_sup_apply (hs : ∀ i ∈ s, Continuous (f i)) :
Continuous (fun a ↦ s.sup (f · a)) :=
continuous_iff_continuousAt.2 fun _ ↦ ContinuousAt.finset_sup_apply fun i hi ↦
(hs i hi).continuousAt
lemma Continuous.finset_sup (hs : ∀ i ∈ s, Continuous (f i)) : Continuous (s.sup f) :=
continuous_iff_continuousAt.2 fun _ ↦ ContinuousAt.finset_sup fun i hi ↦ (hs i hi).continuousAt
end FinsetSup
section FinsetInf'
variable {ι : Type*} [SemilatticeInf L] [ContinuousInf L] {s : Finset ι}
{f : ι → X → L} {t : Set X} {x : X}
lemma ContinuousAt.finset_inf'_apply (hne : s.Nonempty) (hs : ∀ i ∈ s, ContinuousAt (f i) x) :
ContinuousAt (fun a ↦ s.inf' hne (f · a)) x :=
Tendsto.finset_inf'_nhds_apply hne hs
lemma ContinuousAt.finset_inf' (hne : s.Nonempty) (hs : ∀ i ∈ s, ContinuousAt (f i) x) :
ContinuousAt (s.inf' hne f) x := by
simpa only [← Finset.inf'_apply] using finset_inf'_apply hne hs
lemma ContinuousWithinAt.finset_inf'_apply (hne : s.Nonempty)
(hs : ∀ i ∈ s, ContinuousWithinAt (f i) t x) :
ContinuousWithinAt (fun a ↦ s.inf' hne (f · a)) t x :=
Tendsto.finset_inf'_nhds_apply hne hs
lemma ContinuousWithinAt.finset_inf' (hne : s.Nonempty)
(hs : ∀ i ∈ s, ContinuousWithinAt (f i) t x) : ContinuousWithinAt (s.inf' hne f) t x := by
simpa only [← Finset.inf'_apply] using finset_inf'_apply hne hs
lemma ContinuousOn.finset_inf'_apply (hne : s.Nonempty) (hs : ∀ i ∈ s, ContinuousOn (f i) t) :
ContinuousOn (fun a ↦ s.inf' hne (f · a)) t := fun x hx ↦
ContinuousWithinAt.finset_inf'_apply hne fun i hi ↦ hs i hi x hx
lemma ContinuousOn.finset_inf' (hne : s.Nonempty) (hs : ∀ i ∈ s, ContinuousOn (f i) t) :
ContinuousOn (s.inf' hne f) t := fun x hx ↦
ContinuousWithinAt.finset_inf' hne fun i hi ↦ hs i hi x hx
lemma Continuous.finset_inf'_apply (hne : s.Nonempty) (hs : ∀ i ∈ s, Continuous (f i)) :
Continuous (fun a ↦ s.inf' hne (f · a)) :=
continuous_iff_continuousAt.2 fun _ ↦ ContinuousAt.finset_inf'_apply _ fun i hi ↦
(hs i hi).continuousAt
lemma Continuous.finset_inf' (hne : s.Nonempty) (hs : ∀ i ∈ s, Continuous (f i)) :
Continuous (s.inf' hne f) :=
continuous_iff_continuousAt.2 fun _ ↦ ContinuousAt.finset_inf' _ fun i hi ↦ (hs i hi).continuousAt
end FinsetInf'
section FinsetInf
variable {ι : Type*} [SemilatticeInf L] [OrderTop L] [ContinuousInf L] {s : Finset ι}
{f : ι → X → L} {t : Set X} {x : X}
lemma ContinuousAt.finset_inf_apply (hs : ∀ i ∈ s, ContinuousAt (f i) x) :
ContinuousAt (fun a ↦ s.inf (f · a)) x :=
Tendsto.finset_inf_nhds_apply hs
lemma ContinuousAt.finset_inf (hs : ∀ i ∈ s, ContinuousAt (f i) x) :
ContinuousAt (s.inf f) x := by
simpa only [← Finset.inf_apply] using finset_inf_apply hs
lemma ContinuousWithinAt.finset_inf_apply
(hs : ∀ i ∈ s, ContinuousWithinAt (f i) t x) :
ContinuousWithinAt (fun a ↦ s.inf (f · a)) t x :=
Tendsto.finset_inf_nhds_apply hs
lemma ContinuousWithinAt.finset_inf
(hs : ∀ i ∈ s, ContinuousWithinAt (f i) t x) : ContinuousWithinAt (s.inf f) t x := by
simpa only [← Finset.inf_apply] using finset_inf_apply hs
lemma ContinuousOn.finset_inf_apply (hs : ∀ i ∈ s, ContinuousOn (f i) t) :
ContinuousOn (fun a ↦ s.inf (f · a)) t := fun x hx ↦
ContinuousWithinAt.finset_inf_apply fun i hi ↦ hs i hi x hx
lemma ContinuousOn.finset_inf (hs : ∀ i ∈ s, ContinuousOn (f i) t) :
ContinuousOn (s.inf f) t := fun x hx ↦
ContinuousWithinAt.finset_inf fun i hi ↦ hs i hi x hx
lemma Continuous.finset_inf_apply (hs : ∀ i ∈ s, Continuous (f i)) :
Continuous (fun a ↦ s.inf (f · a)) :=
continuous_iff_continuousAt.2 fun _ ↦ ContinuousAt.finset_inf_apply fun i hi ↦
(hs i hi).continuousAt
lemma Continuous.finset_inf (hs : ∀ i ∈ s, Continuous (f i)) : Continuous (s.inf f) :=
continuous_iff_continuousAt.2 fun _ ↦ ContinuousAt.finset_inf fun i hi ↦ (hs i hi).continuousAt
end FinsetInf
|
Topology\Order\LawsonTopology.lean | /-
Copyright (c) 2023 Christopher Hoskin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Christopher Hoskin
-/
import Mathlib.Topology.Order.LowerUpperTopology
import Mathlib.Topology.Order.ScottTopology
/-!
# Lawson topology
This file introduces the Lawson topology on a preorder.
## Main definitions
- `Topology.lawson` - the Lawson topology is defined as the meet of the lower topology and the
Scott topology.
- `Topology.IsLawson.lawsonBasis` - The complements of the upper closures of finite sets
intersected with Scott open sets.
## Main statements
- `Topology.IsLawson.isTopologicalBasis` - `Topology.IsLawson.lawsonBasis` is a basis for
`Topology.IsLawson`
- `Topology.lawsonOpen_iff_scottOpen_of_isUpperSet'` - An upper set is Lawson open if and only if it
is Scott open
- `Topology.lawsonClosed_iff_dirSupClosed_of_isLowerSet` - A lower set is Lawson closed if and only
if it is closed under sups of directed sets
- `Topology.IsLawson.t0Space` - The Lawson topology is T₀
## Implementation notes
A type synonym `Topology.WithLawson` is introduced and for a preorder `α`, `Topology.WithLawson α`
is made an instance of `TopologicalSpace` by `Topology.lawson`.
We define a mixin class `Topology.IsLawson` for the class of types which are both a preorder and a
topology and where the topology is `Topology.lawson`.
It is shown that `Topology.WithLawson α` is an instance of `Topology.IsLawson`.
## References
* [Gierz et al, *A Compendium of Continuous Lattices*][GierzEtAl1980]
## Tags
Lawson topology, preorder
-/
open Set TopologicalSpace
variable {α β : Type*}
namespace Topology
/-! ### Lawson topology -/
section Lawson
section Preorder
/--
The Lawson topology is defined as the meet of `Topology.lower` and the `Topology.scott`.
-/
def lawson (α : Type*) [Preorder α] : TopologicalSpace α := lower α ⊓ scott α
variable (α) [Preorder α] [TopologicalSpace α]
/-- Predicate for an ordered topological space to be equipped with its Lawson topology.
The Lawson topology is defined as the meet of `Topology.lower` and the `Topology.scott`.
-/
class IsLawson : Prop where
topology_eq_lawson : ‹TopologicalSpace α› = lawson α
end Preorder
namespace IsLawson
section Preorder
variable (α) [Preorder α] [TopologicalSpace α] [IsLawson α]
/-- The complements of the upper closures of finite sets intersected with Scott open sets form
a basis for the lawson topology. -/
def lawsonBasis := { s : Set α | ∃ t : Set α, t.Finite ∧ ∃ u : Set α, IsOpen[scott α] u ∧
u \ upperClosure t = s }
protected theorem isTopologicalBasis : TopologicalSpace.IsTopologicalBasis (lawsonBasis α) := by
have lawsonBasis_image2 : lawsonBasis α =
(image2 (fun x x_1 ↦ ⇑WithLower.toLower ⁻¹' x ∩ ⇑WithScott.toScott ⁻¹' x_1)
(IsLower.lowerBasis (WithLower α)) {U | IsOpen[scott α] U}) := by
rw [lawsonBasis, image2, IsLower.lowerBasis]
simp_rw [diff_eq_compl_inter]
aesop
rw [lawsonBasis_image2]
convert IsTopologicalBasis.inf_induced IsLower.isTopologicalBasis
(isTopologicalBasis_opens (α := WithScott α))
WithLower.toLower WithScott.toScott
erw [@topology_eq_lawson α _ _ _]
rw [lawson]
apply (congrArg₂ Inf.inf _) _
· letI _ := lower α; exact @IsLower.withLowerHomeomorph α ‹_› (lower α) ⟨rfl⟩ |>.inducing.induced
letI _ := scott α; exact @IsScott.withScottHomeomorph α _ (scott α) ⟨rfl⟩ |>.inducing.induced
end Preorder
end IsLawson
/--
Type synonym for a preorder equipped with the Lawson topology.
-/
def WithLawson (α : Type*) := α
namespace WithLawson
/-- `toLawson` is the identity function to the `WithLawson` of a type. -/
@[match_pattern] def toLawson : α ≃ WithLawson α := Equiv.refl _
/-- `ofLawson` is the identity function from the `WithLawson` of a type. -/
@[match_pattern] def ofLawson : WithLawson α ≃ α := Equiv.refl _
@[simp] lemma to_Lawson_symm_eq : (@toLawson α).symm = ofLawson := rfl
@[simp] lemma of_Lawson_symm_eq : (@ofLawson α).symm = toLawson := rfl
@[simp] lemma toLawson_ofLawson (a : WithLawson α) : toLawson (ofLawson a) = a := rfl
@[simp] lemma ofLawson_toLawson (a : α) : ofLawson (toLawson a) = a := rfl
@[simp, nolint simpNF]
lemma toLawson_inj {a b : α} : toLawson a = toLawson b ↔ a = b := Iff.rfl
@[simp, nolint simpNF]
lemma ofLawson_inj {a b : WithLawson α} : ofLawson a = ofLawson b ↔ a = b := Iff.rfl
/-- A recursor for `WithLawson`. Use as `induction' x`. -/
@[elab_as_elim, cases_eliminator, induction_eliminator]
protected def rec {β : WithLawson α → Sort*}
(h : ∀ a, β (toLawson a)) : ∀ a, β a := fun a => h (ofLawson a)
instance [Nonempty α] : Nonempty (WithLawson α) := ‹Nonempty α›
instance [Inhabited α] : Inhabited (WithLawson α) := ‹Inhabited α›
variable [Preorder α]
instance instPreorder : Preorder (WithLawson α) := ‹Preorder α›
instance instTopologicalSpace : TopologicalSpace (WithLawson α) := lawson α
instance instIsLawson : IsLawson (WithLawson α) := ⟨rfl⟩
/-- If `α` is equipped with the Lawson topology, then it is homeomorphic to `WithLawson α`.
-/
def homeomorph [TopologicalSpace α] [IsLawson α] : WithLawson α ≃ₜ α :=
ofLawson.toHomeomorphOfInducing ⟨by erw [@IsLawson.topology_eq_lawson α _ _, induced_id]; rfl⟩
theorem isOpen_preimage_ofLawson {S : Set α} :
IsOpen (ofLawson ⁻¹' S) ↔ (lawson α).IsOpen S := Iff.rfl
theorem isClosed_preimage_ofLawson {S : Set α} :
IsClosed (ofLawson ⁻¹' S) ↔ IsClosed[lawson α] S := Iff.rfl
theorem isOpen_def {T : Set (WithLawson α)} :
IsOpen T ↔ (lawson α).IsOpen (toLawson ⁻¹' T) := Iff.rfl
end WithLawson
end Lawson
section Preorder
variable [Preorder α]
lemma lawson_le_scott : lawson α ≤ scott α := inf_le_right
lemma lawson_le_lower : lawson α ≤ lower α := inf_le_left
lemma scottHausdorff_le_lawson : scottHausdorff α ≤ lawson α :=
le_inf scottHausdorff_le_lower scottHausdorff_le_scott
lemma lawsonClosed_of_scottClosed (s : Set α) (h : IsClosed (WithScott.ofScott ⁻¹' s)) :
IsClosed (WithLawson.ofLawson ⁻¹' s) := h.mono lawson_le_scott
lemma lawsonClosed_of_lowerClosed (s : Set α) (h : IsClosed (WithLower.ofLower ⁻¹' s)) :
IsClosed (WithLawson.ofLawson ⁻¹' s) := h.mono lawson_le_lower
/-- An upper set is Lawson open if and only if it is Scott open -/
lemma lawsonOpen_iff_scottOpen_of_isUpperSet {s : Set α} (h : IsUpperSet s) :
IsOpen (WithLawson.ofLawson ⁻¹' s) ↔ IsOpen (WithScott.ofScott ⁻¹' s) :=
⟨fun hs => IsScott.isOpen_iff_isUpperSet_and_scottHausdorff_open.mpr
⟨h, (scottHausdorff_le_lawson s) hs⟩, lawson_le_scott _⟩
variable (L : TopologicalSpace α) (S : TopologicalSpace α)
variable [@IsLawson α _ L] [@IsScott α _ S]
lemma isLawson_le_isScott : L ≤ S := by
rw [@IsScott.topology_eq α _ S _, @IsLawson.topology_eq_lawson α _ L _]
exact inf_le_right
lemma scottHausdorff_le_isLawson : scottHausdorff α ≤ L := by
rw [@IsLawson.topology_eq_lawson α _ L _]
exact scottHausdorff_le_lawson
/-- An upper set is Lawson open if and only if it is Scott open -/
lemma lawsonOpen_iff_scottOpen_of_isUpperSet' (s : Set α) (h : IsUpperSet s) :
IsOpen[L] s ↔ IsOpen[S] s := by
rw [@IsLawson.topology_eq_lawson α _ L _, @IsScott.topology_eq α _ S _]
exact lawsonOpen_iff_scottOpen_of_isUpperSet h
lemma lawsonClosed_iff_scottClosed_of_isLowerSet (s : Set α) (h : IsLowerSet s) :
IsClosed[L] s ↔ IsClosed[S] s := by
rw [← @isOpen_compl_iff, ← isOpen_compl_iff,
(lawsonOpen_iff_scottOpen_of_isUpperSet' L S _ (isUpperSet_compl.mpr h))]
/-- A lower set is Lawson closed if and only if it is closed under sups of directed sets -/
lemma lawsonClosed_iff_dirSupClosed_of_isLowerSet (s : Set α) (h : IsLowerSet s) :
IsClosed[L] s ↔ DirSupClosed s := by
rw [(lawsonClosed_iff_scottClosed_of_isLowerSet L S _ h),
@IsScott.isClosed_iff_isLowerSet_and_dirSupClosed]
aesop
end Preorder
namespace IsLawson
section PartialOrder
variable [PartialOrder α] [TopologicalSpace α] [IsLawson α]
lemma singleton_isClosed (a : α) : IsClosed ({a} : Set α) := by
simp only [IsLawson.topology_eq_lawson]
rw [← (Set.OrdConnected.upperClosure_inter_lowerClosure ordConnected_singleton),
← WithLawson.isClosed_preimage_ofLawson]
apply IsClosed.inter
(lawsonClosed_of_lowerClosed _ (IsLower.isClosed_upperClosure (finite_singleton a)))
rw [lowerClosure_singleton, LowerSet.coe_Iic, ← WithLawson.isClosed_preimage_ofLawson]
apply lawsonClosed_of_scottClosed
exact IsScott.isClosed_Iic
-- see Note [lower instance priority]
/-- The Lawson topology on a partial order is T₀. -/
instance (priority := 90) t0Space : T0Space α :=
(t0Space_iff_inseparable α).2 fun a b h => by
simpa only [inseparable_iff_closure_eq, closure_eq_iff_isClosed.mpr (singleton_isClosed a),
closure_eq_iff_isClosed.mpr (singleton_isClosed b), singleton_eq_singleton_iff] using h
end PartialOrder
end IsLawson
end Topology
|
Topology\Order\LeftRight.lean | /-
Copyright (c) 2021 Anatole Dedecker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anatole Dedecker
-/
import Mathlib.Topology.ContinuousOn
/-!
# Left and right continuity
In this file we prove a few lemmas about left and right continuous functions:
* `continuousWithinAt_Ioi_iff_Ici`: two definitions of right continuity
(with `(a, ∞)` and with `[a, ∞)`) are equivalent;
* `continuousWithinAt_Iio_iff_Iic`: two definitions of left continuity
(with `(-∞, a)` and with `(-∞, a]`) are equivalent;
* `continuousAt_iff_continuous_left_right`, `continuousAt_iff_continuous_left'_right'` :
a function is continuous at `a` if and only if it is left and right continuous at `a`.
## Tags
left continuous, right continuous
-/
open Set Filter Topology
section Preorder
variable {α : Type*} [TopologicalSpace α] [Preorder α]
lemma frequently_lt_nhds (a : α) [NeBot (𝓝[<] a)] : ∃ᶠ x in 𝓝 a, x < a :=
frequently_iff_neBot.2 ‹_›
lemma frequently_gt_nhds (a : α) [NeBot (𝓝[>] a)] : ∃ᶠ x in 𝓝 a, a < x :=
frequently_iff_neBot.2 ‹_›
theorem Filter.Eventually.exists_lt {a : α} [NeBot (𝓝[<] a)] {p : α → Prop}
(h : ∀ᶠ x in 𝓝 a, p x) : ∃ b < a, p b :=
((frequently_lt_nhds a).and_eventually h).exists
theorem Filter.Eventually.exists_gt {a : α} [NeBot (𝓝[>] a)] {p : α → Prop}
(h : ∀ᶠ x in 𝓝 a, p x) : ∃ b > a, p b :=
((frequently_gt_nhds a).and_eventually h).exists
theorem nhdsWithin_Ici_neBot {a b : α} (H₂ : a ≤ b) : NeBot (𝓝[Ici a] b) :=
nhdsWithin_neBot_of_mem H₂
instance nhdsWithin_Ici_self_neBot (a : α) : NeBot (𝓝[≥] a) :=
nhdsWithin_Ici_neBot (le_refl a)
theorem nhdsWithin_Iic_neBot {a b : α} (H : a ≤ b) : NeBot (𝓝[Iic b] a) :=
nhdsWithin_neBot_of_mem H
instance nhdsWithin_Iic_self_neBot (a : α) : NeBot (𝓝[≤] a) :=
nhdsWithin_Iic_neBot (le_refl a)
theorem nhds_left'_le_nhds_ne (a : α) : 𝓝[<] a ≤ 𝓝[≠] a :=
nhdsWithin_mono a fun _ => ne_of_lt
theorem nhds_right'_le_nhds_ne (a : α) : 𝓝[>] a ≤ 𝓝[≠] a :=
nhdsWithin_mono a fun _ => ne_of_gt
-- TODO: add instances for `NeBot (𝓝[<] x)` on (indexed) product types
lemma IsAntichain.interior_eq_empty [∀ x : α, (𝓝[<] x).NeBot] {s : Set α}
(hs : IsAntichain (· ≤ ·) s) : interior s = ∅ := by
refine eq_empty_of_forall_not_mem fun x hx ↦ ?_
have : ∀ᶠ y in 𝓝 x, y ∈ s := mem_interior_iff_mem_nhds.1 hx
rcases this.exists_lt with ⟨y, hyx, hys⟩
exact hs hys (interior_subset hx) hyx.ne hyx.le
lemma IsAntichain.interior_eq_empty' [∀ x : α, (𝓝[>] x).NeBot] {s : Set α}
(hs : IsAntichain (· ≤ ·) s) : interior s = ∅ :=
have : ∀ x : αᵒᵈ, NeBot (𝓝[<] x) := ‹_›
hs.to_dual.interior_eq_empty
end Preorder
section PartialOrder
variable {α β : Type*} [TopologicalSpace α] [PartialOrder α] [TopologicalSpace β]
theorem continuousWithinAt_Ioi_iff_Ici {a : α} {f : α → β} :
ContinuousWithinAt f (Ioi a) a ↔ ContinuousWithinAt f (Ici a) a := by
simp only [← Ici_diff_left, continuousWithinAt_diff_self]
theorem continuousWithinAt_Iio_iff_Iic {a : α} {f : α → β} :
ContinuousWithinAt f (Iio a) a ↔ ContinuousWithinAt f (Iic a) a :=
@continuousWithinAt_Ioi_iff_Ici αᵒᵈ _ _ _ _ _ f
end PartialOrder
section TopologicalSpace
variable {α β : Type*} [TopologicalSpace α] [LinearOrder α] [TopologicalSpace β]
theorem nhds_left_sup_nhds_right (a : α) : 𝓝[≤] a ⊔ 𝓝[≥] a = 𝓝 a := by
rw [← nhdsWithin_union, Iic_union_Ici, nhdsWithin_univ]
theorem nhds_left'_sup_nhds_right (a : α) : 𝓝[<] a ⊔ 𝓝[≥] a = 𝓝 a := by
rw [← nhdsWithin_union, Iio_union_Ici, nhdsWithin_univ]
theorem nhds_left_sup_nhds_right' (a : α) : 𝓝[≤] a ⊔ 𝓝[>] a = 𝓝 a := by
rw [← nhdsWithin_union, Iic_union_Ioi, nhdsWithin_univ]
theorem nhds_left'_sup_nhds_right' (a : α) : 𝓝[<] a ⊔ 𝓝[>] a = 𝓝[≠] a := by
rw [← nhdsWithin_union, Iio_union_Ioi]
lemma nhdsWithin_right_sup_nhds_singleton (a : α) :
𝓝[>] a ⊔ 𝓝[{a}] a = 𝓝[≥] a := by
simp only [union_singleton, Ioi_insert, ← nhdsWithin_union]
theorem continuousAt_iff_continuous_left_right {a : α} {f : α → β} :
ContinuousAt f a ↔ ContinuousWithinAt f (Iic a) a ∧ ContinuousWithinAt f (Ici a) a := by
simp only [ContinuousWithinAt, ContinuousAt, ← tendsto_sup, nhds_left_sup_nhds_right]
theorem continuousAt_iff_continuous_left'_right' {a : α} {f : α → β} :
ContinuousAt f a ↔ ContinuousWithinAt f (Iio a) a ∧ ContinuousWithinAt f (Ioi a) a := by
rw [continuousWithinAt_Ioi_iff_Ici, continuousWithinAt_Iio_iff_Iic,
continuousAt_iff_continuous_left_right]
end TopologicalSpace
|
Topology\Order\LeftRightLim.lean | /-
Copyright (c) 2022 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.Order.LeftRight
import Mathlib.Topology.Order.Monotone
/-!
# Left and right limits
We define the (strict) left and right limits of a function.
* `leftLim f x` is the strict left limit of `f` at `x` (using `f x` as a garbage value if `x`
is isolated to its left).
* `rightLim f x` is the strict right limit of `f` at `x` (using `f x` as a garbage value if `x`
is isolated to its right).
We develop a comprehensive API for monotone functions. Notably,
* `Monotone.continuousAt_iff_leftLim_eq_rightLim` states that a monotone function is continuous
at a point if and only if its left and right limits coincide.
* `Monotone.countable_not_continuousAt` asserts that a monotone function taking values in a
second-countable space has at most countably many discontinuity points.
We also port the API to antitone functions.
## TODO
Prove corresponding stronger results for `StrictMono` and `StrictAnti` functions.
-/
open Set Filter
open Topology
section
variable {α β : Type*} [LinearOrder α] [TopologicalSpace β]
/-- Let `f : α → β` be a function from a linear order `α` to a topological space `β`, and
let `a : α`. The limit strictly to the left of `f` at `a`, denoted with `leftLim f a`, is defined
by using the order topology on `α`. If `a` is isolated to its left or the function has no left
limit, we use `f a` instead to guarantee a good behavior in most cases. -/
noncomputable def Function.leftLim (f : α → β) (a : α) : β := by
classical
haveI : Nonempty β := ⟨f a⟩
letI : TopologicalSpace α := Preorder.topology α
exact if 𝓝[<] a = ⊥ ∨ ¬∃ y, Tendsto f (𝓝[<] a) (𝓝 y) then f a else limUnder (𝓝[<] a) f
/-- Let `f : α → β` be a function from a linear order `α` to a topological space `β`, and
let `a : α`. The limit strictly to the right of `f` at `a`, denoted with `rightLim f a`, is defined
by using the order topology on `α`. If `a` is isolated to its right or the function has no right
limit, , we use `f a` instead to guarantee a good behavior in most cases. -/
noncomputable def Function.rightLim (f : α → β) (a : α) : β :=
@Function.leftLim αᵒᵈ β _ _ f a
open Function
theorem leftLim_eq_of_tendsto [hα : TopologicalSpace α] [h'α : OrderTopology α] [T2Space β]
{f : α → β} {a : α} {y : β} (h : 𝓝[<] a ≠ ⊥) (h' : Tendsto f (𝓝[<] a) (𝓝 y)) :
leftLim f a = y := by
have h'' : ∃ y, Tendsto f (𝓝[<] a) (𝓝 y) := ⟨y, h'⟩
rw [h'α.topology_eq_generate_intervals] at h h' h''
simp only [leftLim, h, h'', not_true, or_self_iff, if_false]
haveI := neBot_iff.2 h
exact lim_eq h'
theorem leftLim_eq_of_eq_bot [hα : TopologicalSpace α] [h'α : OrderTopology α] (f : α → β) {a : α}
(h : 𝓝[<] a = ⊥) : leftLim f a = f a := by
rw [h'α.topology_eq_generate_intervals] at h
simp [leftLim, ite_eq_left_iff, h]
theorem rightLim_eq_of_tendsto [TopologicalSpace α] [OrderTopology α] [T2Space β]
{f : α → β} {a : α} {y : β} (h : 𝓝[>] a ≠ ⊥) (h' : Tendsto f (𝓝[>] a) (𝓝 y)) :
Function.rightLim f a = y :=
@leftLim_eq_of_tendsto αᵒᵈ _ _ _ _ _ _ f a y h h'
theorem rightLim_eq_of_eq_bot [TopologicalSpace α] [OrderTopology α] (f : α → β) {a : α}
(h : 𝓝[>] a = ⊥) : rightLim f a = f a :=
@leftLim_eq_of_eq_bot αᵒᵈ _ _ _ _ _ f a h
end
open Function
namespace Monotone
variable {α β : Type*} [LinearOrder α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β]
[OrderTopology β] {f : α → β} (hf : Monotone f) {x y : α}
theorem leftLim_eq_sSup [TopologicalSpace α] [OrderTopology α] (h : 𝓝[<] x ≠ ⊥) :
leftLim f x = sSup (f '' Iio x) :=
leftLim_eq_of_tendsto h (hf.tendsto_nhdsWithin_Iio x)
theorem rightLim_eq_sInf [TopologicalSpace α] [OrderTopology α] (h : 𝓝[>] x ≠ ⊥) :
rightLim f x = sInf (f '' Ioi x) :=
rightLim_eq_of_tendsto h (hf.tendsto_nhdsWithin_Ioi x)
theorem leftLim_le (h : x ≤ y) : leftLim f x ≤ f y := by
letI : TopologicalSpace α := Preorder.topology α
haveI : OrderTopology α := ⟨rfl⟩
rcases eq_or_ne (𝓝[<] x) ⊥ with (h' | h')
· simpa [leftLim, h'] using hf h
haveI A : NeBot (𝓝[<] x) := neBot_iff.2 h'
rw [leftLim_eq_sSup hf h']
refine csSup_le ?_ ?_
· simp only [image_nonempty]
exact (forall_mem_nonempty_iff_neBot.2 A) _ self_mem_nhdsWithin
· simp only [mem_image, mem_Iio, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂]
intro z hz
exact hf (hz.le.trans h)
theorem le_leftLim (h : x < y) : f x ≤ leftLim f y := by
letI : TopologicalSpace α := Preorder.topology α
haveI : OrderTopology α := ⟨rfl⟩
rcases eq_or_ne (𝓝[<] y) ⊥ with (h' | h')
· rw [leftLim_eq_of_eq_bot _ h']
exact hf h.le
rw [leftLim_eq_sSup hf h']
refine le_csSup ⟨f y, ?_⟩ (mem_image_of_mem _ h)
simp only [upperBounds, mem_image, mem_Iio, forall_exists_index, and_imp,
forall_apply_eq_imp_iff₂, mem_setOf_eq]
intro z hz
exact hf hz.le
@[mono]
protected theorem leftLim : Monotone (leftLim f) := by
intro x y h
rcases eq_or_lt_of_le h with (rfl | hxy)
· exact le_rfl
· exact (hf.leftLim_le le_rfl).trans (hf.le_leftLim hxy)
theorem le_rightLim (h : x ≤ y) : f x ≤ rightLim f y :=
hf.dual.leftLim_le h
theorem rightLim_le (h : x < y) : rightLim f x ≤ f y :=
hf.dual.le_leftLim h
@[mono]
protected theorem rightLim : Monotone (rightLim f) := fun _ _ h => hf.dual.leftLim h
theorem leftLim_le_rightLim (h : x ≤ y) : leftLim f x ≤ rightLim f y :=
(hf.leftLim_le le_rfl).trans (hf.le_rightLim h)
theorem rightLim_le_leftLim (h : x < y) : rightLim f x ≤ leftLim f y := by
letI : TopologicalSpace α := Preorder.topology α
haveI : OrderTopology α := ⟨rfl⟩
rcases eq_or_ne (𝓝[<] y) ⊥ with (h' | h')
· simp [leftLim, h']
exact rightLim_le hf h
obtain ⟨a, ⟨xa, ay⟩⟩ : (Ioo x y).Nonempty :=
forall_mem_nonempty_iff_neBot.2 (neBot_iff.2 h') (Ioo x y)
(Ioo_mem_nhdsWithin_Iio ⟨h, le_refl _⟩)
calc
rightLim f x ≤ f a := hf.rightLim_le xa
_ ≤ leftLim f y := hf.le_leftLim ay
variable [TopologicalSpace α] [OrderTopology α]
theorem tendsto_leftLim (x : α) : Tendsto f (𝓝[<] x) (𝓝 (leftLim f x)) := by
rcases eq_or_ne (𝓝[<] x) ⊥ with (h' | h')
· simp [h']
rw [leftLim_eq_sSup hf h']
exact hf.tendsto_nhdsWithin_Iio x
theorem tendsto_leftLim_within (x : α) : Tendsto f (𝓝[<] x) (𝓝[≤] leftLim f x) := by
apply tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within f (hf.tendsto_leftLim x)
filter_upwards [@self_mem_nhdsWithin _ _ x (Iio x)] with y hy using hf.le_leftLim hy
theorem tendsto_rightLim (x : α) : Tendsto f (𝓝[>] x) (𝓝 (rightLim f x)) :=
hf.dual.tendsto_leftLim x
theorem tendsto_rightLim_within (x : α) : Tendsto f (𝓝[>] x) (𝓝[≥] rightLim f x) :=
hf.dual.tendsto_leftLim_within x
/-- A monotone function is continuous to the left at a point if and only if its left limit
coincides with the value of the function. -/
theorem continuousWithinAt_Iio_iff_leftLim_eq :
ContinuousWithinAt f (Iio x) x ↔ leftLim f x = f x := by
rcases eq_or_ne (𝓝[<] x) ⊥ with (h' | h')
· simp [leftLim_eq_of_eq_bot f h', ContinuousWithinAt, h']
haveI : (𝓝[Iio x] x).NeBot := neBot_iff.2 h'
refine ⟨fun h => tendsto_nhds_unique (hf.tendsto_leftLim x) h.tendsto, fun h => ?_⟩
have := hf.tendsto_leftLim x
rwa [h] at this
/-- A monotone function is continuous to the right at a point if and only if its right limit
coincides with the value of the function. -/
theorem continuousWithinAt_Ioi_iff_rightLim_eq :
ContinuousWithinAt f (Ioi x) x ↔ rightLim f x = f x :=
hf.dual.continuousWithinAt_Iio_iff_leftLim_eq
/-- A monotone function is continuous at a point if and only if its left and right limits
coincide. -/
theorem continuousAt_iff_leftLim_eq_rightLim : ContinuousAt f x ↔ leftLim f x = rightLim f x := by
refine ⟨fun h => ?_, fun h => ?_⟩
· have A : leftLim f x = f x :=
hf.continuousWithinAt_Iio_iff_leftLim_eq.1 h.continuousWithinAt
have B : rightLim f x = f x :=
hf.continuousWithinAt_Ioi_iff_rightLim_eq.1 h.continuousWithinAt
exact A.trans B.symm
· have h' : leftLim f x = f x := by
apply le_antisymm (leftLim_le hf (le_refl _))
rw [h]
exact le_rightLim hf (le_refl _)
refine continuousAt_iff_continuous_left'_right'.2 ⟨?_, ?_⟩
· exact hf.continuousWithinAt_Iio_iff_leftLim_eq.2 h'
· rw [h] at h'
exact hf.continuousWithinAt_Ioi_iff_rightLim_eq.2 h'
/-- In a second countable space, the set of points where a monotone function is not right-continuous
is at most countable. Superseded by `countable_not_continuousAt` which gives the two-sided
version. -/
theorem countable_not_continuousWithinAt_Ioi [SecondCountableTopology β] :
Set.Countable { x | ¬ContinuousWithinAt f (Ioi x) x } := by
apply (countable_image_lt_image_Ioi f).mono
rintro x (hx : ¬ContinuousWithinAt f (Ioi x) x)
dsimp
contrapose! hx
refine tendsto_order.2 ⟨fun m hm => ?_, fun u hu => ?_⟩
· filter_upwards [@self_mem_nhdsWithin _ _ x (Ioi x)] with y hy using hm.trans_le
(hf (le_of_lt hy))
rcases hx u hu with ⟨v, xv, fvu⟩
have : Ioo x v ∈ 𝓝[>] x := Ioo_mem_nhdsWithin_Ioi ⟨le_refl _, xv⟩
filter_upwards [this] with y hy
apply (hf hy.2.le).trans_lt fvu
/-- In a second countable space, the set of points where a monotone function is not left-continuous
is at most countable. Superseded by `countable_not_continuousAt` which gives the two-sided
version. -/
theorem countable_not_continuousWithinAt_Iio [SecondCountableTopology β] :
Set.Countable { x | ¬ContinuousWithinAt f (Iio x) x } :=
hf.dual.countable_not_continuousWithinAt_Ioi
/-- In a second countable space, the set of points where a monotone function is not continuous
is at most countable. -/
theorem countable_not_continuousAt [SecondCountableTopology β] :
Set.Countable { x | ¬ContinuousAt f x } := by
apply
(hf.countable_not_continuousWithinAt_Ioi.union hf.countable_not_continuousWithinAt_Iio).mono
_
refine compl_subset_compl.1 ?_
simp only [compl_union]
rintro x ⟨hx, h'x⟩
simp only [mem_setOf_eq, Classical.not_not, mem_compl_iff] at hx h'x ⊢
exact continuousAt_iff_continuous_left'_right'.2 ⟨h'x, hx⟩
end Monotone
namespace Antitone
variable {α β : Type*} [LinearOrder α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β]
[OrderTopology β] {f : α → β} (hf : Antitone f) {x y : α}
theorem le_leftLim (h : x ≤ y) : f y ≤ leftLim f x :=
hf.dual_right.leftLim_le h
theorem leftLim_le (h : x < y) : leftLim f y ≤ f x :=
hf.dual_right.le_leftLim h
@[mono]
protected theorem leftLim : Antitone (leftLim f) :=
hf.dual_right.leftLim
theorem rightLim_le (h : x ≤ y) : rightLim f y ≤ f x :=
hf.dual_right.le_rightLim h
theorem le_rightLim (h : x < y) : f y ≤ rightLim f x :=
hf.dual_right.rightLim_le h
@[mono]
protected theorem rightLim : Antitone (rightLim f) :=
hf.dual_right.rightLim
theorem rightLim_le_leftLim (h : x ≤ y) : rightLim f y ≤ leftLim f x :=
hf.dual_right.leftLim_le_rightLim h
theorem leftLim_le_rightLim (h : x < y) : leftLim f y ≤ rightLim f x :=
hf.dual_right.rightLim_le_leftLim h
variable [TopologicalSpace α] [OrderTopology α]
theorem tendsto_leftLim (x : α) : Tendsto f (𝓝[<] x) (𝓝 (leftLim f x)) :=
hf.dual_right.tendsto_leftLim x
theorem tendsto_leftLim_within (x : α) : Tendsto f (𝓝[<] x) (𝓝[≥] leftLim f x) :=
hf.dual_right.tendsto_leftLim_within x
theorem tendsto_rightLim (x : α) : Tendsto f (𝓝[>] x) (𝓝 (rightLim f x)) :=
hf.dual_right.tendsto_rightLim x
theorem tendsto_rightLim_within (x : α) : Tendsto f (𝓝[>] x) (𝓝[≤] rightLim f x) :=
hf.dual_right.tendsto_rightLim_within x
/-- An antitone function is continuous to the left at a point if and only if its left limit
coincides with the value of the function. -/
theorem continuousWithinAt_Iio_iff_leftLim_eq :
ContinuousWithinAt f (Iio x) x ↔ leftLim f x = f x :=
hf.dual_right.continuousWithinAt_Iio_iff_leftLim_eq
/-- An antitone function is continuous to the right at a point if and only if its right limit
coincides with the value of the function. -/
theorem continuousWithinAt_Ioi_iff_rightLim_eq :
ContinuousWithinAt f (Ioi x) x ↔ rightLim f x = f x :=
hf.dual_right.continuousWithinAt_Ioi_iff_rightLim_eq
/-- An antitone function is continuous at a point if and only if its left and right limits
coincide. -/
theorem continuousAt_iff_leftLim_eq_rightLim : ContinuousAt f x ↔ leftLim f x = rightLim f x :=
hf.dual_right.continuousAt_iff_leftLim_eq_rightLim
/-- In a second countable space, the set of points where an antitone function is not continuous
is at most countable. -/
theorem countable_not_continuousAt [SecondCountableTopology β] :
Set.Countable { x | ¬ContinuousAt f x } :=
hf.dual_right.countable_not_continuousAt
end Antitone
|
Topology\Order\LeftRightNhds.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, Yury Kudryashov
-/
import Mathlib.Topology.Order.Basic
import Mathlib.Data.Set.Pointwise.Basic
/-!
# Neighborhoods to the left and to the right on an `OrderTopology`
We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`.
In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable
intervals to the right or to the left of `a`. We give now these characterizations. -/
open Set Filter TopologicalSpace Topology Function
open OrderDual (toDual ofDual)
variable {α β γ : Type*}
section LinearOrder
variable [TopologicalSpace α] [LinearOrder α]
section OrderTopology
variable [OrderTopology α]
open List in
/-- The following statements are equivalent:
0. `s` is a neighborhood of `a` within `(a, +∞)`;
1. `s` is a neighborhood of `a` within `(a, b]`;
2. `s` is a neighborhood of `a` within `(a, b)`;
3. `s` includes `(a, u)` for some `u ∈ (a, b]`;
4. `s` includes `(a, u)` for some `u > a`.
-/
theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) :
TFAE [s ∈ 𝓝[>] a,
s ∈ 𝓝[Ioc a b] a,
s ∈ 𝓝[Ioo a b] a,
∃ u ∈ Ioc a b, Ioo a u ⊆ s,
∃ u ∈ Ioi a, Ioo a u ⊆ s] := by
tfae_have 1 ↔ 2
· rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab]
tfae_have 1 ↔ 3
· rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab]
tfae_have 4 → 5
· exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩
tfae_have 5 → 1
· rintro ⟨u, hau, hu⟩
exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu
tfae_have 1 → 4
· intro h
rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩
rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩
exact ⟨u, au, fun x hx => hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, hx.1⟩⟩
tfae_finish
theorem mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset {a u' : α} {s : Set α} (hu' : a < u') :
s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioc a u', Ioo a u ⊆ s :=
(TFAE_mem_nhdsWithin_Ioi hu' s).out 0 3
/-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)`
with `a < u < u'`, provided `a` is not a top element. -/
theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' {a u' : α} {s : Set α} (hu' : a < u') :
s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s :=
(TFAE_mem_nhdsWithin_Ioi hu' s).out 0 4
theorem nhdsWithin_Ioi_basis' {a : α} (h : ∃ b, a < b) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) :=
let ⟨_, h⟩ := h
⟨fun _ => mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' h⟩
lemma nhdsWithin_Ioi_basis [NoMaxOrder α] (a : α) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) :=
nhdsWithin_Ioi_basis' <| exists_gt a
theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by
by_cases ha : IsTop a
· simp [ha, ha.isMax.Ioi_eq]
· simp only [ha, false_or]
rw [isTop_iff_isMax, not_isMax_iff] at ha
simp only [(nhdsWithin_Ioi_basis' ha).eq_bot_iff, covBy_iff_Ioo_eq]
/-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)`
with `a < u`. -/
theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset [NoMaxOrder α] {a : α} {s : Set α} :
s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s :=
let ⟨_u', hu'⟩ := exists_gt a
mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' hu'
/-- The set of points which are isolated on the right is countable when the space is
second-countable. -/
theorem countable_setOf_isolated_right [SecondCountableTopology α] :
{ x : α | 𝓝[>] x = ⊥ }.Countable := by
simp only [nhdsWithin_Ioi_eq_bot_iff, setOf_or]
exact (subsingleton_isTop α).countable.union countable_setOf_covBy_right
/-- The set of points which are isolated on the left is countable when the space is
second-countable. -/
theorem countable_setOf_isolated_left [SecondCountableTopology α] :
{ x : α | 𝓝[<] x = ⊥ }.Countable :=
countable_setOf_isolated_right (α := αᵒᵈ)
/-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u]`
with `a < u`. -/
theorem mem_nhdsWithin_Ioi_iff_exists_Ioc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α}
{s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s := by
rw [mem_nhdsWithin_Ioi_iff_exists_Ioo_subset]
constructor
· rintro ⟨u, au, as⟩
rcases exists_between au with ⟨v, hv⟩
exact ⟨v, hv.1, fun x hx => as ⟨hx.1, lt_of_le_of_lt hx.2 hv.2⟩⟩
· rintro ⟨u, au, as⟩
exact ⟨u, au, Subset.trans Ioo_subset_Ioc_self as⟩
open List in
/-- The following statements are equivalent:
0. `s` is a neighborhood of `b` within `(-∞, b)`
1. `s` is a neighborhood of `b` within `[a, b)`
2. `s` is a neighborhood of `b` within `(a, b)`
3. `s` includes `(l, b)` for some `l ∈ [a, b)`
4. `s` includes `(l, b)` for some `l < b` -/
theorem TFAE_mem_nhdsWithin_Iio {a b : α} (h : a < b) (s : Set α) :
TFAE [s ∈ 𝓝[<] b,-- 0 : `s` is a neighborhood of `b` within `(-∞, b)`
s ∈ 𝓝[Ico a b] b,-- 1 : `s` is a neighborhood of `b` within `[a, b)`
s ∈ 𝓝[Ioo a b] b,-- 2 : `s` is a neighborhood of `b` within `(a, b)`
∃ l ∈ Ico a b, Ioo l b ⊆ s,-- 3 : `s` includes `(l, b)` for some `l ∈ [a, b)`
∃ l ∈ Iio b, Ioo l b ⊆ s] := by-- 4 : `s` includes `(l, b)` for some `l < b`
simpa only [exists_prop, OrderDual.exists, dual_Ioi, dual_Ioc, dual_Ioo] using
TFAE_mem_nhdsWithin_Ioi h.dual (ofDual ⁻¹' s)
theorem mem_nhdsWithin_Iio_iff_exists_mem_Ico_Ioo_subset {a l' : α} {s : Set α} (hl' : l' < a) :
s ∈ 𝓝[<] a ↔ ∃ l ∈ Ico l' a, Ioo l a ⊆ s :=
(TFAE_mem_nhdsWithin_Iio hl' s).out 0 3
/-- A set is a neighborhood of `a` within `(-∞, a)` if and only if it contains an interval `(l, a)`
with `l < a`, provided `a` is not a bottom element. -/
theorem mem_nhdsWithin_Iio_iff_exists_Ioo_subset' {a l' : α} {s : Set α} (hl' : l' < a) :
s ∈ 𝓝[<] a ↔ ∃ l ∈ Iio a, Ioo l a ⊆ s :=
(TFAE_mem_nhdsWithin_Iio hl' s).out 0 4
/-- A set is a neighborhood of `a` within `(-∞, a)` if and only if it contains an interval `(l, a)`
with `l < a`. -/
theorem mem_nhdsWithin_Iio_iff_exists_Ioo_subset [NoMinOrder α] {a : α} {s : Set α} :
s ∈ 𝓝[<] a ↔ ∃ l ∈ Iio a, Ioo l a ⊆ s :=
let ⟨_, h⟩ := exists_lt a
mem_nhdsWithin_Iio_iff_exists_Ioo_subset' h
/-- A set is a neighborhood of `a` within `(-∞, a)` if and only if it contains an interval `[l, a)`
with `l < a`. -/
theorem mem_nhdsWithin_Iio_iff_exists_Ico_subset [NoMinOrder α] [DenselyOrdered α] {a : α}
{s : Set α} : s ∈ 𝓝[<] a ↔ ∃ l ∈ Iio a, Ico l a ⊆ s := by
have : ofDual ⁻¹' s ∈ 𝓝[>] toDual a ↔ _ := mem_nhdsWithin_Ioi_iff_exists_Ioc_subset
simpa only [OrderDual.exists, exists_prop, dual_Ioc] using this
theorem nhdsWithin_Iio_basis' {a : α} (h : ∃ b, b < a) : (𝓝[<] a).HasBasis (· < a) (Ioo · a) :=
let ⟨_, h⟩ := h
⟨fun _ => mem_nhdsWithin_Iio_iff_exists_Ioo_subset' h⟩
theorem nhdsWithin_Iio_basis [NoMinOrder α] (a : α) : (𝓝[<] a).HasBasis (· < a) (Ioo · a) :=
nhdsWithin_Iio_basis' <| exists_lt a
theorem nhdsWithin_Iio_eq_bot_iff {a : α} : 𝓝[<] a = ⊥ ↔ IsBot a ∨ ∃ b, b ⋖ a := by
convert (config := {preTransparency := .default})
nhdsWithin_Ioi_eq_bot_iff (a := OrderDual.toDual a) using 4
exact ofDual_covBy_ofDual_iff
open List in
/-- The following statements are equivalent:
0. `s` is a neighborhood of `a` within `[a, +∞)`;
1. `s` is a neighborhood of `a` within `[a, b]`;
2. `s` is a neighborhood of `a` within `[a, b)`;
3. `s` includes `[a, u)` for some `u ∈ (a, b]`;
4. `s` includes `[a, u)` for some `u > a`.
-/
theorem TFAE_mem_nhdsWithin_Ici {a b : α} (hab : a < b) (s : Set α) :
TFAE [s ∈ 𝓝[≥] a,
s ∈ 𝓝[Icc a b] a,
s ∈ 𝓝[Ico a b] a,
∃ u ∈ Ioc a b, Ico a u ⊆ s,
∃ u ∈ Ioi a , Ico a u ⊆ s] := by
tfae_have 1 ↔ 2
· rw [nhdsWithin_Icc_eq_nhdsWithin_Ici hab]
tfae_have 1 ↔ 3
· rw [nhdsWithin_Ico_eq_nhdsWithin_Ici hab]
tfae_have 1 ↔ 5
· exact (nhdsWithin_Ici_basis' ⟨b, hab⟩).mem_iff
tfae_have 4 → 5
· exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩
tfae_have 5 → 4
· rintro ⟨u, hua, hus⟩
exact
⟨min u b, ⟨lt_min hua hab, min_le_right _ _⟩,
(Ico_subset_Ico_right <| min_le_left _ _).trans hus⟩
tfae_finish
theorem mem_nhdsWithin_Ici_iff_exists_mem_Ioc_Ico_subset {a u' : α} {s : Set α} (hu' : a < u') :
s ∈ 𝓝[≥] a ↔ ∃ u ∈ Ioc a u', Ico a u ⊆ s :=
(TFAE_mem_nhdsWithin_Ici hu' s).out 0 3 (by norm_num) (by norm_num)
/-- A set is a neighborhood of `a` within `[a, +∞)` if and only if it contains an interval `[a, u)`
with `a < u < u'`, provided `a` is not a top element. -/
theorem mem_nhdsWithin_Ici_iff_exists_Ico_subset' {a u' : α} {s : Set α} (hu' : a < u') :
s ∈ 𝓝[≥] a ↔ ∃ u ∈ Ioi a, Ico a u ⊆ s :=
(TFAE_mem_nhdsWithin_Ici hu' s).out 0 4 (by norm_num) (by norm_num)
/-- A set is a neighborhood of `a` within `[a, +∞)` if and only if it contains an interval `[a, u)`
with `a < u`. -/
theorem mem_nhdsWithin_Ici_iff_exists_Ico_subset [NoMaxOrder α] {a : α} {s : Set α} :
s ∈ 𝓝[≥] a ↔ ∃ u ∈ Ioi a, Ico a u ⊆ s :=
let ⟨_, hu'⟩ := exists_gt a
mem_nhdsWithin_Ici_iff_exists_Ico_subset' hu'
theorem nhdsWithin_Ici_basis_Ico [NoMaxOrder α] (a : α) :
(𝓝[≥] a).HasBasis (fun u => a < u) (Ico a) :=
⟨fun _ => mem_nhdsWithin_Ici_iff_exists_Ico_subset⟩
/-- The filter of right neighborhoods has a basis of closed intervals. -/
theorem nhdsWithin_Ici_basis_Icc [NoMaxOrder α] [DenselyOrdered α] {a : α} :
(𝓝[≥] a).HasBasis (a < ·) (Icc a) :=
(nhdsWithin_Ici_basis _).to_hasBasis
(fun _u hu ↦ (exists_between hu).imp fun _v hv ↦ hv.imp_right Icc_subset_Ico_right)
fun u hu ↦ ⟨u, hu, Ico_subset_Icc_self⟩
/-- A set is a neighborhood of `a` within `[a, +∞)` if and only if it contains an interval `[a, u]`
with `a < u`. -/
theorem mem_nhdsWithin_Ici_iff_exists_Icc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α}
{s : Set α} : s ∈ 𝓝[≥] a ↔ ∃ u, a < u ∧ Icc a u ⊆ s :=
nhdsWithin_Ici_basis_Icc.mem_iff
open List in
/-- The following statements are equivalent:
0. `s` is a neighborhood of `b` within `(-∞, b]`
1. `s` is a neighborhood of `b` within `[a, b]`
2. `s` is a neighborhood of `b` within `(a, b]`
3. `s` includes `(l, b]` for some `l ∈ [a, b)`
4. `s` includes `(l, b]` for some `l < b` -/
theorem TFAE_mem_nhdsWithin_Iic {a b : α} (h : a < b) (s : Set α) :
TFAE [s ∈ 𝓝[≤] b,-- 0 : `s` is a neighborhood of `b` within `(-∞, b]`
s ∈ 𝓝[Icc a b] b,-- 1 : `s` is a neighborhood of `b` within `[a, b]`
s ∈ 𝓝[Ioc a b] b,-- 2 : `s` is a neighborhood of `b` within `(a, b]`
∃ l ∈ Ico a b, Ioc l b ⊆ s,-- 3 : `s` includes `(l, b]` for some `l ∈ [a, b)`
∃ l ∈ Iio b, Ioc l b ⊆ s] := by-- 4 : `s` includes `(l, b]` for some `l < b`
simpa only [exists_prop, OrderDual.exists, dual_Ici, dual_Ioc, dual_Icc, dual_Ico] using
TFAE_mem_nhdsWithin_Ici h.dual (ofDual ⁻¹' s)
theorem mem_nhdsWithin_Iic_iff_exists_mem_Ico_Ioc_subset {a l' : α} {s : Set α} (hl' : l' < a) :
s ∈ 𝓝[≤] a ↔ ∃ l ∈ Ico l' a, Ioc l a ⊆ s :=
(TFAE_mem_nhdsWithin_Iic hl' s).out 0 3 (by norm_num) (by norm_num)
/-- A set is a neighborhood of `a` within `(-∞, a]` if and only if it contains an interval `(l, a]`
with `l < a`, provided `a` is not a bottom element. -/
theorem mem_nhdsWithin_Iic_iff_exists_Ioc_subset' {a l' : α} {s : Set α} (hl' : l' < a) :
s ∈ 𝓝[≤] a ↔ ∃ l ∈ Iio a, Ioc l a ⊆ s :=
(TFAE_mem_nhdsWithin_Iic hl' s).out 0 4 (by norm_num) (by norm_num)
/-- A set is a neighborhood of `a` within `(-∞, a]` if and only if it contains an interval `(l, a]`
with `l < a`. -/
theorem mem_nhdsWithin_Iic_iff_exists_Ioc_subset [NoMinOrder α] {a : α} {s : Set α} :
s ∈ 𝓝[≤] a ↔ ∃ l ∈ Iio a, Ioc l a ⊆ s :=
let ⟨_, hl'⟩ := exists_lt a
mem_nhdsWithin_Iic_iff_exists_Ioc_subset' hl'
/-- A set is a neighborhood of `a` within `(-∞, a]` if and only if it contains an interval `[l, a]`
with `l < a`. -/
theorem mem_nhdsWithin_Iic_iff_exists_Icc_subset [NoMinOrder α] [DenselyOrdered α] {a : α}
{s : Set α} : s ∈ 𝓝[≤] a ↔ ∃ l, l < a ∧ Icc l a ⊆ s :=
calc s ∈ 𝓝[≤] a ↔ ofDual ⁻¹' s ∈ 𝓝[≥] (toDual a) := Iff.rfl
_ ↔ ∃ u : α, toDual a < toDual u ∧ Icc (toDual a) (toDual u) ⊆ ofDual ⁻¹' s :=
mem_nhdsWithin_Ici_iff_exists_Icc_subset
_ ↔ ∃ l, l < a ∧ Icc l a ⊆ s := by simp only [dual_Icc]; rfl
/-- The filter of left neighborhoods has a basis of closed intervals. -/
theorem nhdsWithin_Iic_basis_Icc [NoMinOrder α] [DenselyOrdered α] {a : α} :
(𝓝[≤] a).HasBasis (· < a) (Icc · a) :=
⟨fun _ ↦ mem_nhdsWithin_Iic_iff_exists_Icc_subset⟩
end OrderTopology
end LinearOrder
section LinearOrderedAddCommGroup
variable [TopologicalSpace α] [LinearOrderedAddCommGroup α] [OrderTopology α]
variable {l : Filter β} {f g : β → α}
theorem nhds_eq_iInf_abs_sub (a : α) : 𝓝 a = ⨅ r > 0, 𝓟 { b | |a - b| < r } := by
simp only [nhds_eq_order, abs_lt, setOf_and, ← inf_principal, iInf_inf_eq]
refine (congr_arg₂ _ ?_ ?_).trans (inf_comm ..)
· refine (Equiv.subLeft a).iInf_congr fun x => ?_; simp [Ioi]
· refine (Equiv.subRight a).iInf_congr fun x => ?_; simp [Iio]
theorem orderTopology_of_nhds_abs {α : Type*} [TopologicalSpace α] [LinearOrderedAddCommGroup α]
(h_nhds : ∀ a : α, 𝓝 a = ⨅ r > 0, 𝓟 { b | |a - b| < r }) : OrderTopology α := by
refine ⟨TopologicalSpace.ext_nhds fun a => ?_⟩
rw [h_nhds]
letI := Preorder.topology α; letI : OrderTopology α := ⟨rfl⟩
exact (nhds_eq_iInf_abs_sub a).symm
theorem LinearOrderedAddCommGroup.tendsto_nhds {x : Filter β} {a : α} :
Tendsto f x (𝓝 a) ↔ ∀ ε > (0 : α), ∀ᶠ b in x, |f b - a| < ε := by
simp [nhds_eq_iInf_abs_sub, abs_sub_comm a]
theorem eventually_abs_sub_lt (a : α) {ε : α} (hε : 0 < ε) : ∀ᶠ x in 𝓝 a, |x - a| < ε :=
(nhds_eq_iInf_abs_sub a).symm ▸
mem_iInf_of_mem ε (mem_iInf_of_mem hε <| by simp only [abs_sub_comm, mem_principal_self])
/-- In a linearly ordered additive commutative group with the order topology, if `f` tends to `C`
and `g` tends to `atTop` then `f + g` tends to `atTop`. -/
theorem Filter.Tendsto.add_atTop {C : α} (hf : Tendsto f l (𝓝 C)) (hg : Tendsto g l atTop) :
Tendsto (fun x => f x + g x) l atTop := by
nontriviality α
obtain ⟨C', hC'⟩ : ∃ C', C' < C := exists_lt C
refine tendsto_atTop_add_left_of_le' _ C' ?_ hg
exact (hf.eventually (lt_mem_nhds hC')).mono fun x => le_of_lt
/-- In a linearly ordered additive commutative group with the order topology, if `f` tends to `C`
and `g` tends to `atBot` then `f + g` tends to `atBot`. -/
theorem Filter.Tendsto.add_atBot {C : α} (hf : Tendsto f l (𝓝 C)) (hg : Tendsto g l atBot) :
Tendsto (fun x => f x + g x) l atBot :=
Filter.Tendsto.add_atTop (α := αᵒᵈ) hf hg
/-- In a linearly ordered additive commutative group with the order topology, if `f` tends to
`atTop` and `g` tends to `C` then `f + g` tends to `atTop`. -/
theorem Filter.Tendsto.atTop_add {C : α} (hf : Tendsto f l atTop) (hg : Tendsto g l (𝓝 C)) :
Tendsto (fun x => f x + g x) l atTop := by
conv in _ + _ => rw [add_comm]
exact hg.add_atTop hf
/-- In a linearly ordered additive commutative group with the order topology, if `f` tends to
`atBot` and `g` tends to `C` then `f + g` tends to `atBot`. -/
theorem Filter.Tendsto.atBot_add {C : α} (hf : Tendsto f l atBot) (hg : Tendsto g l (𝓝 C)) :
Tendsto (fun x => f x + g x) l atBot := by
conv in _ + _ => rw [add_comm]
exact hg.add_atBot hf
theorem nhds_basis_abs_sub_lt [NoMaxOrder α] (a : α) :
(𝓝 a).HasBasis (fun ε : α => (0 : α) < ε) fun ε => { b | |b - a| < ε } := by
simp only [nhds_eq_iInf_abs_sub, abs_sub_comm (a := a)]
refine hasBasis_biInf_principal' (fun x hx y hy => ?_) (exists_gt _)
exact ⟨min x y, lt_min hx hy, fun _ hz => hz.trans_le (min_le_left _ _),
fun _ hz => hz.trans_le (min_le_right _ _)⟩
theorem nhds_basis_Ioo_pos [NoMaxOrder α] (a : α) :
(𝓝 a).HasBasis (fun ε : α => (0 : α) < ε) fun ε => Ioo (a - ε) (a + ε) := by
convert nhds_basis_abs_sub_lt a
simp only [Ioo, abs_lt, ← sub_lt_iff_lt_add, neg_lt_sub_iff_lt_add, sub_lt_comm]
theorem nhds_basis_Icc_pos [NoMaxOrder α] [DenselyOrdered α] (a : α) :
(𝓝 a).HasBasis ((0 : α) < ·) fun ε ↦ Icc (a - ε) (a + ε) :=
(nhds_basis_Ioo_pos a).to_hasBasis
(fun _ε ε₀ ↦ let ⟨δ, δ₀, δε⟩ := exists_between ε₀
⟨δ, δ₀, Icc_subset_Ioo (sub_lt_sub_left δε _) (add_lt_add_left δε _)⟩)
(fun ε ε₀ ↦ ⟨ε, ε₀, Ioo_subset_Icc_self⟩)
variable (α)
theorem nhds_basis_zero_abs_sub_lt [NoMaxOrder α] :
(𝓝 (0 : α)).HasBasis (fun ε : α => (0 : α) < ε) fun ε => { b | |b| < ε } := by
simpa using nhds_basis_abs_sub_lt (0 : α)
variable {α}
/-- If `a` is positive we can form a basis from only nonnegative `Set.Ioo` intervals -/
theorem nhds_basis_Ioo_pos_of_pos [NoMaxOrder α] {a : α} (ha : 0 < a) :
(𝓝 a).HasBasis (fun ε : α => (0 : α) < ε ∧ ε ≤ a) fun ε => Ioo (a - ε) (a + ε) :=
(nhds_basis_Ioo_pos a).restrict fun ε hε => ⟨min a ε, lt_min ha hε, min_le_left _ _,
Ioo_subset_Ioo (sub_le_sub_left (min_le_right _ _) _) (add_le_add_left (min_le_right _ _) _)⟩
end LinearOrderedAddCommGroup
namespace Set.OrdConnected
variable [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [DenselyOrdered α]
/-- If `S` is order-connected and contains two points `x < y`, then `S` is a right neighbourhood
of `x`. -/
lemma mem_nhdsWithin_Ici [NoMaxOrder α] {S : Set α} (hS : OrdConnected S)
{x y : α} (hx : x ∈ S) (hy : y ∈ S) (hxy : x < y) :
S ∈ 𝓝[≥] x :=
mem_nhdsWithin_Ici_iff_exists_Icc_subset.2 ⟨y, hxy, hS.out hx hy⟩
/-- If `S` is order-connected and contains two points `x < y`, then `S` is a punctured right
neighbourhood of `x`. -/
lemma mem_nhdsWithin_Ioi [NoMaxOrder α] {S : Set α} (hS : OrdConnected S)
{x y : α} (hx : x ∈ S) (hy : y ∈ S) (hxy : x < y) :
S ∈ 𝓝[>] x :=
nhdsWithin_mono _ Ioi_subset_Ici_self <| hS.mem_nhdsWithin_Ici hx hy hxy
/-- If `S` is order-connected and contains two points `x < y`, then `S` is a left neighbourhood
of `y`. -/
lemma mem_nhdsWithin_Iic [NoMinOrder α] {S : Set α} (hS : OrdConnected S)
{x y : α} (hx : x ∈ S) (hy : y ∈ S) (hxy : x < y) :
S ∈ 𝓝[≤] y :=
mem_nhdsWithin_Iic_iff_exists_Icc_subset.2 ⟨x, hxy, hS.out hx hy⟩
/-- If `S` is order-connected and contains two points `x < y`, then `S` is a punctured left
neighbourhood of `y`. -/
lemma mem_nhdsWithin_Iio [NoMinOrder α] {S : Set α} (hS : OrdConnected S)
{x y : α} (hx : x ∈ S) (hy : y ∈ S) (hxy : x < y) :
S ∈ 𝓝[<] y :=
nhdsWithin_mono _ Iio_subset_Iic_self <| hS.mem_nhdsWithin_Iic hx hy hxy
end OrdConnected
end Set
|
Topology\Order\LocalExtr.lean | /-
Copyright (c) 2019 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Order.Filter.Extr
import Mathlib.Topology.ContinuousOn
/-!
# Local extrema of functions on topological spaces
## Main definitions
This file defines special versions of `Is*Filter f a l`, `*=Min/Max/Extr`, from
`Mathlib.Order.Filter.Extr` for two kinds of filters: `nhdsWithin` and `nhds`. These versions are
called `IsLocal*On` and `IsLocal*`, respectively.
## Main statements
Many lemmas in this file restate those from `Mathlib.Order.Filter.Extr`, and you can find a detailed
documentation there. These convenience lemmas are provided only to make the dot notation return
propositions of expected types, not just `Is*Filter`.
Here is the list of statements specific to these two types of filters:
* `IsLocal*.on`, `IsLocal*On.on_subset`: restrict to a subset;
* `IsLocal*On.inter` : intersect the set with another one;
* `Is*On.localize` : a global extremum is a local extremum too.
* `Is[Local]*On.isLocal*` : if we have `IsLocal*On f s a` and `s ∈ 𝓝 a`, then we have
`IsLocal* f a`.
-/
universe u v w x
variable {α : Type u} {β : Type v} {γ : Type w} {δ : Type x} [TopologicalSpace α]
open Set Filter Topology
section Preorder
variable [Preorder β] [Preorder γ] (f : α → β) (s : Set α) (a : α)
/-- `IsLocalMinOn f s a` means that `f a ≤ f x` for all `x ∈ s` in some neighborhood of `a`. -/
def IsLocalMinOn :=
IsMinFilter f (𝓝[s] a) a
/-- `IsLocalMaxOn f s a` means that `f x ≤ f a` for all `x ∈ s` in some neighborhood of `a`. -/
def IsLocalMaxOn :=
IsMaxFilter f (𝓝[s] a) a
/-- `IsLocalExtrOn f s a` means `IsLocalMinOn f s a ∨ IsLocalMaxOn f s a`. -/
def IsLocalExtrOn :=
IsExtrFilter f (𝓝[s] a) a
/-- `IsLocalMin f a` means that `f a ≤ f x` for all `x` in some neighborhood of `a`. -/
def IsLocalMin :=
IsMinFilter f (𝓝 a) a
/-- `IsLocalMax f a` means that `f x ≤ f a` for all `x ∈ s` in some neighborhood of `a`. -/
def IsLocalMax :=
IsMaxFilter f (𝓝 a) a
/-- `IsLocalExtrOn f s a` means `IsLocalMinOn f s a ∨ IsLocalMaxOn f s a`. -/
def IsLocalExtr :=
IsExtrFilter f (𝓝 a) a
variable {f s a}
theorem IsLocalExtrOn.elim {p : Prop} :
IsLocalExtrOn f s a → (IsLocalMinOn f s a → p) → (IsLocalMaxOn f s a → p) → p :=
Or.elim
theorem IsLocalExtr.elim {p : Prop} :
IsLocalExtr f a → (IsLocalMin f a → p) → (IsLocalMax f a → p) → p :=
Or.elim
/-! ### Restriction to (sub)sets -/
theorem IsLocalMin.on (h : IsLocalMin f a) (s) : IsLocalMinOn f s a :=
h.filter_inf _
theorem IsLocalMax.on (h : IsLocalMax f a) (s) : IsLocalMaxOn f s a :=
h.filter_inf _
theorem IsLocalExtr.on (h : IsLocalExtr f a) (s) : IsLocalExtrOn f s a :=
h.filter_inf _
theorem IsLocalMinOn.on_subset {t : Set α} (hf : IsLocalMinOn f t a) (h : s ⊆ t) :
IsLocalMinOn f s a :=
hf.filter_mono <| nhdsWithin_mono a h
theorem IsLocalMaxOn.on_subset {t : Set α} (hf : IsLocalMaxOn f t a) (h : s ⊆ t) :
IsLocalMaxOn f s a :=
hf.filter_mono <| nhdsWithin_mono a h
theorem IsLocalExtrOn.on_subset {t : Set α} (hf : IsLocalExtrOn f t a) (h : s ⊆ t) :
IsLocalExtrOn f s a :=
hf.filter_mono <| nhdsWithin_mono a h
theorem IsLocalMinOn.inter (hf : IsLocalMinOn f s a) (t) : IsLocalMinOn f (s ∩ t) a :=
hf.on_subset inter_subset_left
theorem IsLocalMaxOn.inter (hf : IsLocalMaxOn f s a) (t) : IsLocalMaxOn f (s ∩ t) a :=
hf.on_subset inter_subset_left
theorem IsLocalExtrOn.inter (hf : IsLocalExtrOn f s a) (t) : IsLocalExtrOn f (s ∩ t) a :=
hf.on_subset inter_subset_left
theorem IsMinOn.localize (hf : IsMinOn f s a) : IsLocalMinOn f s a :=
hf.filter_mono <| inf_le_right
theorem IsMaxOn.localize (hf : IsMaxOn f s a) : IsLocalMaxOn f s a :=
hf.filter_mono <| inf_le_right
theorem IsExtrOn.localize (hf : IsExtrOn f s a) : IsLocalExtrOn f s a :=
hf.filter_mono <| inf_le_right
theorem IsLocalMinOn.isLocalMin (hf : IsLocalMinOn f s a) (hs : s ∈ 𝓝 a) : IsLocalMin f a :=
have : 𝓝 a ≤ 𝓟 s := le_principal_iff.2 hs
hf.filter_mono <| le_inf le_rfl this
theorem IsLocalMaxOn.isLocalMax (hf : IsLocalMaxOn f s a) (hs : s ∈ 𝓝 a) : IsLocalMax f a :=
have : 𝓝 a ≤ 𝓟 s := le_principal_iff.2 hs
hf.filter_mono <| le_inf le_rfl this
theorem IsLocalExtrOn.isLocalExtr (hf : IsLocalExtrOn f s a) (hs : s ∈ 𝓝 a) : IsLocalExtr f a :=
hf.elim (fun hf => (hf.isLocalMin hs).isExtr) fun hf => (hf.isLocalMax hs).isExtr
theorem IsMinOn.isLocalMin (hf : IsMinOn f s a) (hs : s ∈ 𝓝 a) : IsLocalMin f a :=
hf.localize.isLocalMin hs
theorem IsMaxOn.isLocalMax (hf : IsMaxOn f s a) (hs : s ∈ 𝓝 a) : IsLocalMax f a :=
hf.localize.isLocalMax hs
theorem IsExtrOn.isLocalExtr (hf : IsExtrOn f s a) (hs : s ∈ 𝓝 a) : IsLocalExtr f a :=
hf.localize.isLocalExtr hs
theorem IsLocalMinOn.not_nhds_le_map [TopologicalSpace β] (hf : IsLocalMinOn f s a)
[NeBot (𝓝[<] f a)] : ¬𝓝 (f a) ≤ map f (𝓝[s] a) := fun hle =>
have : ∀ᶠ y in 𝓝[<] f a, f a ≤ y := (eventually_map.2 hf).filter_mono (inf_le_left.trans hle)
let ⟨_y, hy⟩ := (this.and self_mem_nhdsWithin).exists
hy.1.not_lt hy.2
theorem IsLocalMaxOn.not_nhds_le_map [TopologicalSpace β] (hf : IsLocalMaxOn f s a)
[NeBot (𝓝[>] f a)] : ¬𝓝 (f a) ≤ map f (𝓝[s] a) :=
@IsLocalMinOn.not_nhds_le_map α βᵒᵈ _ _ _ _ _ ‹_› hf ‹_›
theorem IsLocalExtrOn.not_nhds_le_map [TopologicalSpace β] (hf : IsLocalExtrOn f s a)
[NeBot (𝓝[<] f a)] [NeBot (𝓝[>] f a)] : ¬𝓝 (f a) ≤ map f (𝓝[s] a) :=
hf.elim (fun h => h.not_nhds_le_map) fun h => h.not_nhds_le_map
/-! ### Constant -/
theorem isLocalMinOn_const {b : β} : IsLocalMinOn (fun _ => b) s a :=
isMinFilter_const
theorem isLocalMaxOn_const {b : β} : IsLocalMaxOn (fun _ => b) s a :=
isMaxFilter_const
theorem isLocalExtrOn_const {b : β} : IsLocalExtrOn (fun _ => b) s a :=
isExtrFilter_const
theorem isLocalMin_const {b : β} : IsLocalMin (fun _ => b) a :=
isMinFilter_const
theorem isLocalMax_const {b : β} : IsLocalMax (fun _ => b) a :=
isMaxFilter_const
theorem isLocalExtr_const {b : β} : IsLocalExtr (fun _ => b) a :=
isExtrFilter_const
/-! ### Composition with (anti)monotone functions -/
nonrec theorem IsLocalMin.comp_mono (hf : IsLocalMin f a) {g : β → γ} (hg : Monotone g) :
IsLocalMin (g ∘ f) a :=
hf.comp_mono hg
nonrec theorem IsLocalMax.comp_mono (hf : IsLocalMax f a) {g : β → γ} (hg : Monotone g) :
IsLocalMax (g ∘ f) a :=
hf.comp_mono hg
nonrec theorem IsLocalExtr.comp_mono (hf : IsLocalExtr f a) {g : β → γ} (hg : Monotone g) :
IsLocalExtr (g ∘ f) a :=
hf.comp_mono hg
nonrec theorem IsLocalMin.comp_antitone (hf : IsLocalMin f a) {g : β → γ} (hg : Antitone g) :
IsLocalMax (g ∘ f) a :=
hf.comp_antitone hg
nonrec theorem IsLocalMax.comp_antitone (hf : IsLocalMax f a) {g : β → γ} (hg : Antitone g) :
IsLocalMin (g ∘ f) a :=
hf.comp_antitone hg
nonrec theorem IsLocalExtr.comp_antitone (hf : IsLocalExtr f a) {g : β → γ} (hg : Antitone g) :
IsLocalExtr (g ∘ f) a :=
hf.comp_antitone hg
nonrec theorem IsLocalMinOn.comp_mono (hf : IsLocalMinOn f s a) {g : β → γ} (hg : Monotone g) :
IsLocalMinOn (g ∘ f) s a :=
hf.comp_mono hg
nonrec theorem IsLocalMaxOn.comp_mono (hf : IsLocalMaxOn f s a) {g : β → γ} (hg : Monotone g) :
IsLocalMaxOn (g ∘ f) s a :=
hf.comp_mono hg
nonrec theorem IsLocalExtrOn.comp_mono (hf : IsLocalExtrOn f s a) {g : β → γ} (hg : Monotone g) :
IsLocalExtrOn (g ∘ f) s a :=
hf.comp_mono hg
nonrec theorem IsLocalMinOn.comp_antitone (hf : IsLocalMinOn f s a) {g : β → γ} (hg : Antitone g) :
IsLocalMaxOn (g ∘ f) s a :=
hf.comp_antitone hg
nonrec theorem IsLocalMaxOn.comp_antitone (hf : IsLocalMaxOn f s a) {g : β → γ} (hg : Antitone g) :
IsLocalMinOn (g ∘ f) s a :=
hf.comp_antitone hg
nonrec theorem IsLocalExtrOn.comp_antitone (hf : IsLocalExtrOn f s a) {g : β → γ}
(hg : Antitone g) : IsLocalExtrOn (g ∘ f) s a :=
hf.comp_antitone hg
nonrec theorem IsLocalMin.bicomp_mono [Preorder δ] {op : β → γ → δ}
(hop : ((· ≤ ·) ⇒ (· ≤ ·) ⇒ (· ≤ ·)) op op) (hf : IsLocalMin f a) {g : α → γ}
(hg : IsLocalMin g a) : IsLocalMin (fun x => op (f x) (g x)) a :=
hf.bicomp_mono hop hg
nonrec theorem IsLocalMax.bicomp_mono [Preorder δ] {op : β → γ → δ}
(hop : ((· ≤ ·) ⇒ (· ≤ ·) ⇒ (· ≤ ·)) op op) (hf : IsLocalMax f a) {g : α → γ}
(hg : IsLocalMax g a) : IsLocalMax (fun x => op (f x) (g x)) a :=
hf.bicomp_mono hop hg
nonrec theorem IsLocalMinOn.bicomp_mono [Preorder δ] {op : β → γ → δ}
(hop : ((· ≤ ·) ⇒ (· ≤ ·) ⇒ (· ≤ ·)) op op) (hf : IsLocalMinOn f s a) {g : α → γ}
(hg : IsLocalMinOn g s a) : IsLocalMinOn (fun x => op (f x) (g x)) s a :=
hf.bicomp_mono hop hg
nonrec theorem IsLocalMaxOn.bicomp_mono [Preorder δ] {op : β → γ → δ}
(hop : ((· ≤ ·) ⇒ (· ≤ ·) ⇒ (· ≤ ·)) op op) (hf : IsLocalMaxOn f s a) {g : α → γ}
(hg : IsLocalMaxOn g s a) : IsLocalMaxOn (fun x => op (f x) (g x)) s a :=
hf.bicomp_mono hop hg
/-! ### Composition with `ContinuousAt` -/
theorem IsLocalMin.comp_continuous [TopologicalSpace δ] {g : δ → α} {b : δ}
(hf : IsLocalMin f (g b)) (hg : ContinuousAt g b) : IsLocalMin (f ∘ g) b :=
hg hf
theorem IsLocalMax.comp_continuous [TopologicalSpace δ] {g : δ → α} {b : δ}
(hf : IsLocalMax f (g b)) (hg : ContinuousAt g b) : IsLocalMax (f ∘ g) b :=
hg hf
theorem IsLocalExtr.comp_continuous [TopologicalSpace δ] {g : δ → α} {b : δ}
(hf : IsLocalExtr f (g b)) (hg : ContinuousAt g b) : IsLocalExtr (f ∘ g) b :=
hf.comp_tendsto hg
theorem IsLocalMin.comp_continuousOn [TopologicalSpace δ] {s : Set δ} {g : δ → α} {b : δ}
(hf : IsLocalMin f (g b)) (hg : ContinuousOn g s) (hb : b ∈ s) : IsLocalMinOn (f ∘ g) s b :=
hf.comp_tendsto (hg b hb)
theorem IsLocalMax.comp_continuousOn [TopologicalSpace δ] {s : Set δ} {g : δ → α} {b : δ}
(hf : IsLocalMax f (g b)) (hg : ContinuousOn g s) (hb : b ∈ s) : IsLocalMaxOn (f ∘ g) s b :=
hf.comp_tendsto (hg b hb)
theorem IsLocalExtr.comp_continuousOn [TopologicalSpace δ] {s : Set δ} (g : δ → α) {b : δ}
(hf : IsLocalExtr f (g b)) (hg : ContinuousOn g s) (hb : b ∈ s) : IsLocalExtrOn (f ∘ g) s b :=
hf.elim (fun hf => (hf.comp_continuousOn hg hb).isExtr) fun hf =>
(IsLocalMax.comp_continuousOn hf hg hb).isExtr
theorem IsLocalMinOn.comp_continuousOn [TopologicalSpace δ] {t : Set α} {s : Set δ} {g : δ → α}
{b : δ} (hf : IsLocalMinOn f t (g b)) (hst : s ⊆ g ⁻¹' t) (hg : ContinuousOn g s) (hb : b ∈ s) :
IsLocalMinOn (f ∘ g) s b :=
hf.comp_tendsto
(tendsto_nhdsWithin_mono_right (image_subset_iff.mpr hst)
(ContinuousWithinAt.tendsto_nhdsWithin_image (hg b hb)))
theorem IsLocalMaxOn.comp_continuousOn [TopologicalSpace δ] {t : Set α} {s : Set δ} {g : δ → α}
{b : δ} (hf : IsLocalMaxOn f t (g b)) (hst : s ⊆ g ⁻¹' t) (hg : ContinuousOn g s) (hb : b ∈ s) :
IsLocalMaxOn (f ∘ g) s b :=
hf.comp_tendsto
(tendsto_nhdsWithin_mono_right (image_subset_iff.mpr hst)
(ContinuousWithinAt.tendsto_nhdsWithin_image (hg b hb)))
theorem IsLocalExtrOn.comp_continuousOn [TopologicalSpace δ] {t : Set α} {s : Set δ} (g : δ → α)
{b : δ} (hf : IsLocalExtrOn f t (g b)) (hst : s ⊆ g ⁻¹' t) (hg : ContinuousOn g s)
(hb : b ∈ s) : IsLocalExtrOn (f ∘ g) s b :=
hf.elim (fun hf => (hf.comp_continuousOn hst hg hb).isExtr) fun hf =>
(IsLocalMaxOn.comp_continuousOn hf hst hg hb).isExtr
end Preorder
/-! ### Pointwise addition -/
section OrderedAddCommMonoid
variable [OrderedAddCommMonoid β] {f g : α → β} {a : α} {s : Set α} {l : Filter α}
nonrec theorem IsLocalMin.add (hf : IsLocalMin f a) (hg : IsLocalMin g a) :
IsLocalMin (fun x => f x + g x) a :=
hf.add hg
nonrec theorem IsLocalMax.add (hf : IsLocalMax f a) (hg : IsLocalMax g a) :
IsLocalMax (fun x => f x + g x) a :=
hf.add hg
nonrec theorem IsLocalMinOn.add (hf : IsLocalMinOn f s a) (hg : IsLocalMinOn g s a) :
IsLocalMinOn (fun x => f x + g x) s a :=
hf.add hg
nonrec theorem IsLocalMaxOn.add (hf : IsLocalMaxOn f s a) (hg : IsLocalMaxOn g s a) :
IsLocalMaxOn (fun x => f x + g x) s a :=
hf.add hg
end OrderedAddCommMonoid
/-! ### Pointwise negation and subtraction -/
section OrderedAddCommGroup
variable [OrderedAddCommGroup β] {f g : α → β} {a : α} {s : Set α} {l : Filter α}
nonrec theorem IsLocalMin.neg (hf : IsLocalMin f a) : IsLocalMax (fun x => -f x) a :=
hf.neg
nonrec theorem IsLocalMax.neg (hf : IsLocalMax f a) : IsLocalMin (fun x => -f x) a :=
hf.neg
nonrec theorem IsLocalExtr.neg (hf : IsLocalExtr f a) : IsLocalExtr (fun x => -f x) a :=
hf.neg
nonrec theorem IsLocalMinOn.neg (hf : IsLocalMinOn f s a) : IsLocalMaxOn (fun x => -f x) s a :=
hf.neg
nonrec theorem IsLocalMaxOn.neg (hf : IsLocalMaxOn f s a) : IsLocalMinOn (fun x => -f x) s a :=
hf.neg
nonrec theorem IsLocalExtrOn.neg (hf : IsLocalExtrOn f s a) : IsLocalExtrOn (fun x => -f x) s a :=
hf.neg
nonrec theorem IsLocalMin.sub (hf : IsLocalMin f a) (hg : IsLocalMax g a) :
IsLocalMin (fun x => f x - g x) a :=
hf.sub hg
nonrec theorem IsLocalMax.sub (hf : IsLocalMax f a) (hg : IsLocalMin g a) :
IsLocalMax (fun x => f x - g x) a :=
hf.sub hg
nonrec theorem IsLocalMinOn.sub (hf : IsLocalMinOn f s a) (hg : IsLocalMaxOn g s a) :
IsLocalMinOn (fun x => f x - g x) s a :=
hf.sub hg
nonrec theorem IsLocalMaxOn.sub (hf : IsLocalMaxOn f s a) (hg : IsLocalMinOn g s a) :
IsLocalMaxOn (fun x => f x - g x) s a :=
hf.sub hg
end OrderedAddCommGroup
/-! ### Pointwise `sup`/`inf` -/
section SemilatticeSup
variable [SemilatticeSup β] {f g : α → β} {a : α} {s : Set α} {l : Filter α}
nonrec theorem IsLocalMin.sup (hf : IsLocalMin f a) (hg : IsLocalMin g a) :
IsLocalMin (fun x => f x ⊔ g x) a :=
hf.sup hg
nonrec theorem IsLocalMax.sup (hf : IsLocalMax f a) (hg : IsLocalMax g a) :
IsLocalMax (fun x => f x ⊔ g x) a :=
hf.sup hg
nonrec theorem IsLocalMinOn.sup (hf : IsLocalMinOn f s a) (hg : IsLocalMinOn g s a) :
IsLocalMinOn (fun x => f x ⊔ g x) s a :=
hf.sup hg
nonrec theorem IsLocalMaxOn.sup (hf : IsLocalMaxOn f s a) (hg : IsLocalMaxOn g s a) :
IsLocalMaxOn (fun x => f x ⊔ g x) s a :=
hf.sup hg
end SemilatticeSup
section SemilatticeInf
variable [SemilatticeInf β] {f g : α → β} {a : α} {s : Set α} {l : Filter α}
nonrec theorem IsLocalMin.inf (hf : IsLocalMin f a) (hg : IsLocalMin g a) :
IsLocalMin (fun x => f x ⊓ g x) a :=
hf.inf hg
nonrec theorem IsLocalMax.inf (hf : IsLocalMax f a) (hg : IsLocalMax g a) :
IsLocalMax (fun x => f x ⊓ g x) a :=
hf.inf hg
nonrec theorem IsLocalMinOn.inf (hf : IsLocalMinOn f s a) (hg : IsLocalMinOn g s a) :
IsLocalMinOn (fun x => f x ⊓ g x) s a :=
hf.inf hg
nonrec theorem IsLocalMaxOn.inf (hf : IsLocalMaxOn f s a) (hg : IsLocalMaxOn g s a) :
IsLocalMaxOn (fun x => f x ⊓ g x) s a :=
hf.inf hg
end SemilatticeInf
/-! ### Pointwise `min`/`max` -/
section LinearOrder
variable [LinearOrder β] {f g : α → β} {a : α} {s : Set α} {l : Filter α}
nonrec theorem IsLocalMin.min (hf : IsLocalMin f a) (hg : IsLocalMin g a) :
IsLocalMin (fun x => min (f x) (g x)) a :=
hf.min hg
nonrec theorem IsLocalMax.min (hf : IsLocalMax f a) (hg : IsLocalMax g a) :
IsLocalMax (fun x => min (f x) (g x)) a :=
hf.min hg
nonrec theorem IsLocalMinOn.min (hf : IsLocalMinOn f s a) (hg : IsLocalMinOn g s a) :
IsLocalMinOn (fun x => min (f x) (g x)) s a :=
hf.min hg
nonrec theorem IsLocalMaxOn.min (hf : IsLocalMaxOn f s a) (hg : IsLocalMaxOn g s a) :
IsLocalMaxOn (fun x => min (f x) (g x)) s a :=
hf.min hg
nonrec theorem IsLocalMin.max (hf : IsLocalMin f a) (hg : IsLocalMin g a) :
IsLocalMin (fun x => max (f x) (g x)) a :=
hf.max hg
nonrec theorem IsLocalMax.max (hf : IsLocalMax f a) (hg : IsLocalMax g a) :
IsLocalMax (fun x => max (f x) (g x)) a :=
hf.max hg
nonrec theorem IsLocalMinOn.max (hf : IsLocalMinOn f s a) (hg : IsLocalMinOn g s a) :
IsLocalMinOn (fun x => max (f x) (g x)) s a :=
hf.max hg
nonrec theorem IsLocalMaxOn.max (hf : IsLocalMaxOn f s a) (hg : IsLocalMaxOn g s a) :
IsLocalMaxOn (fun x => max (f x) (g x)) s a :=
hf.max hg
end LinearOrder
section Eventually
/-! ### Relation with `eventually` comparisons of two functions -/
variable [Preorder β] {s : Set α}
theorem Filter.EventuallyLE.isLocalMaxOn {f g : α → β} {a : α} (hle : g ≤ᶠ[𝓝[s] a] f)
(hfga : f a = g a) (h : IsLocalMaxOn f s a) : IsLocalMaxOn g s a :=
hle.isMaxFilter hfga h
nonrec theorem IsLocalMaxOn.congr {f g : α → β} {a : α} (h : IsLocalMaxOn f s a)
(heq : f =ᶠ[𝓝[s] a] g) (hmem : a ∈ s) : IsLocalMaxOn g s a :=
h.congr heq <| heq.eq_of_nhdsWithin hmem
theorem Filter.EventuallyEq.isLocalMaxOn_iff {f g : α → β} {a : α} (heq : f =ᶠ[𝓝[s] a] g)
(hmem : a ∈ s) : IsLocalMaxOn f s a ↔ IsLocalMaxOn g s a :=
heq.isMaxFilter_iff <| heq.eq_of_nhdsWithin hmem
theorem Filter.EventuallyLE.isLocalMinOn {f g : α → β} {a : α} (hle : f ≤ᶠ[𝓝[s] a] g)
(hfga : f a = g a) (h : IsLocalMinOn f s a) : IsLocalMinOn g s a :=
hle.isMinFilter hfga h
nonrec theorem IsLocalMinOn.congr {f g : α → β} {a : α} (h : IsLocalMinOn f s a)
(heq : f =ᶠ[𝓝[s] a] g) (hmem : a ∈ s) : IsLocalMinOn g s a :=
h.congr heq <| heq.eq_of_nhdsWithin hmem
nonrec theorem Filter.EventuallyEq.isLocalMinOn_iff {f g : α → β} {a : α} (heq : f =ᶠ[𝓝[s] a] g)
(hmem : a ∈ s) : IsLocalMinOn f s a ↔ IsLocalMinOn g s a :=
heq.isMinFilter_iff <| heq.eq_of_nhdsWithin hmem
nonrec theorem IsLocalExtrOn.congr {f g : α → β} {a : α} (h : IsLocalExtrOn f s a)
(heq : f =ᶠ[𝓝[s] a] g) (hmem : a ∈ s) : IsLocalExtrOn g s a :=
h.congr heq <| heq.eq_of_nhdsWithin hmem
theorem Filter.EventuallyEq.isLocalExtrOn_iff {f g : α → β} {a : α} (heq : f =ᶠ[𝓝[s] a] g)
(hmem : a ∈ s) : IsLocalExtrOn f s a ↔ IsLocalExtrOn g s a :=
heq.isExtrFilter_iff <| heq.eq_of_nhdsWithin hmem
theorem Filter.EventuallyLE.isLocalMax {f g : α → β} {a : α} (hle : g ≤ᶠ[𝓝 a] f) (hfga : f a = g a)
(h : IsLocalMax f a) : IsLocalMax g a :=
hle.isMaxFilter hfga h
nonrec theorem IsLocalMax.congr {f g : α → β} {a : α} (h : IsLocalMax f a) (heq : f =ᶠ[𝓝 a] g) :
IsLocalMax g a :=
h.congr heq heq.eq_of_nhds
theorem Filter.EventuallyEq.isLocalMax_iff {f g : α → β} {a : α} (heq : f =ᶠ[𝓝 a] g) :
IsLocalMax f a ↔ IsLocalMax g a :=
heq.isMaxFilter_iff heq.eq_of_nhds
theorem Filter.EventuallyLE.isLocalMin {f g : α → β} {a : α} (hle : f ≤ᶠ[𝓝 a] g) (hfga : f a = g a)
(h : IsLocalMin f a) : IsLocalMin g a :=
hle.isMinFilter hfga h
nonrec theorem IsLocalMin.congr {f g : α → β} {a : α} (h : IsLocalMin f a) (heq : f =ᶠ[𝓝 a] g) :
IsLocalMin g a :=
h.congr heq heq.eq_of_nhds
theorem Filter.EventuallyEq.isLocalMin_iff {f g : α → β} {a : α} (heq : f =ᶠ[𝓝 a] g) :
IsLocalMin f a ↔ IsLocalMin g a :=
heq.isMinFilter_iff heq.eq_of_nhds
nonrec theorem IsLocalExtr.congr {f g : α → β} {a : α} (h : IsLocalExtr f a) (heq : f =ᶠ[𝓝 a] g) :
IsLocalExtr g a :=
h.congr heq heq.eq_of_nhds
theorem Filter.EventuallyEq.isLocalExtr_iff {f g : α → β} {a : α} (heq : f =ᶠ[𝓝 a] g) :
IsLocalExtr f a ↔ IsLocalExtr g a :=
heq.isExtrFilter_iff heq.eq_of_nhds
end Eventually
|
Topology\Order\LowerUpperTopology.lean | /-
Copyright (c) 2023 Christopher Hoskin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Christopher Hoskin
-/
import Mathlib.Order.Hom.CompleteLattice
import Mathlib.Topology.Homeomorph
import Mathlib.Topology.Order.Lattice
/-!
# Lower and Upper topology
This file introduces the lower topology on a preorder as the topology generated by the complements
of the left-closed right-infinite intervals.
For completeness we also introduce the dual upper topology, generated by the complements of the
right-closed left-infinite intervals.
## Main statements
- `IsLower.t0Space` - the lower topology on a partial order is T₀
- `IsLower.isTopologicalBasis` - the complements of the upper closures of finite
subsets form a basis for the lower topology
- `IsLower.continuousInf` - the inf map is continuous with respect to the lower topology
## Implementation notes
A type synonym `WithLower` is introduced and for a preorder `α`, `WithLower α`
is made an instance of `TopologicalSpace` by the topology generated by the complements of the
closed intervals to infinity.
We define a mixin class `IsLower` for the class of types which are both a preorder and a
topology and where the topology is generated by the complements of the closed intervals to infinity.
It is shown that `WithLower α` is an instance of `IsLower`.
Similarly for the upper topology.
## Motivation
The lower topology is used with the `Scott` topology to define the Lawson topology. The restriction
of the lower topology to the spectrum of a complete lattice coincides with the hull-kernel topology.
## References
* [Gierz et al, *A Compendium of Continuous Lattices*][GierzEtAl1980]
## Tags
lower topology, upper topology, preorder
-/
open Set TopologicalSpace Topology
namespace Topology
/--
The lower topology is the topology generated by the complements of the left-closed right-infinite
intervals.
-/
def lower (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom {s | ∃ a, (Ici a)ᶜ = s}
/--
The upper topology is the topology generated by the complements of the right-closed left-infinite
intervals.
-/
def upper (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom {s | ∃ a, (Iic a)ᶜ = s}
/-- Type synonym for a preorder equipped with the lower set topology. -/
def WithLower (α : Type*) := α
variable {α β}
namespace WithLower
/-- `toLower` is the identity function to the `WithLower` of a type. -/
@[match_pattern] def toLower : α ≃ WithLower α := Equiv.refl _
/-- `ofLower` is the identity function from the `WithLower` of a type. -/
@[match_pattern] def ofLower : WithLower α ≃ α := Equiv.refl _
@[simp] lemma to_WithLower_symm_eq : (@toLower α).symm = ofLower := rfl
@[simp] lemma of_WithLower_symm_eq : (@ofLower α).symm = toLower := rfl
@[simp] lemma toLower_ofLower (a : WithLower α) : toLower (ofLower a) = a := rfl
@[simp] lemma ofLower_toLower (a : α) : ofLower (toLower a) = a := rfl
lemma toLower_inj {a b : α} : toLower a = toLower b ↔ a = b := Iff.rfl
-- Porting note: removed @[simp] to make linter happy
theorem ofLower_inj {a b : WithLower α} : ofLower a = ofLower b ↔ a = b :=
Iff.rfl
/-- A recursor for `WithLower`. Use as `induction x`. -/
@[elab_as_elim, cases_eliminator, induction_eliminator]
protected def rec {β : WithLower α → Sort*} (h : ∀ a, β (toLower a)) : ∀ a, β a := fun a =>
h (ofLower a)
instance [Nonempty α] : Nonempty (WithLower α) := ‹Nonempty α›
instance [Inhabited α] : Inhabited (WithLower α) := ‹Inhabited α›
variable [Preorder α] {s : Set α}
instance : Preorder (WithLower α) := ‹Preorder α›
instance : TopologicalSpace (WithLower α) := lower α
lemma isOpen_preimage_ofLower : IsOpen (ofLower ⁻¹' s) ↔ (lower α).IsOpen s := Iff.rfl
lemma isOpen_def (T : Set (WithLower α)) : IsOpen T ↔ (lower α).IsOpen (WithLower.toLower ⁻¹' T) :=
Iff.rfl
end WithLower
/-- Type synonym for a preorder equipped with the upper topology. -/
def WithUpper (α : Type*) := α
namespace WithUpper
/-- `toUpper` is the identity function to the `WithUpper` of a type. -/
@[match_pattern] def toUpper : α ≃ WithUpper α := Equiv.refl _
/-- `ofUpper` is the identity function from the `WithUpper` of a type. -/
@[match_pattern] def ofUpper : WithUpper α ≃ α := Equiv.refl _
@[simp] lemma to_WithUpper_symm_eq {α} : (@toUpper α).symm = ofUpper := rfl
@[simp] lemma of_WithUpper_symm_eq : (@ofUpper α).symm = toUpper := rfl
@[simp] lemma toUpper_ofUpper (a : WithUpper α) : toUpper (ofUpper a) = a := rfl
@[simp] lemma ofUpper_toUpper (a : α) : ofUpper (toUpper a) = a := rfl
lemma toUpper_inj {a b : α} : toUpper a = toUpper b ↔ a = b := Iff.rfl
lemma ofUpper_inj {a b : WithUpper α} : ofUpper a = ofUpper b ↔ a = b := Iff.rfl
/-- A recursor for `WithUpper`. Use as `induction x`. -/
@[elab_as_elim, cases_eliminator, induction_eliminator]
protected def rec {β : WithUpper α → Sort*} (h : ∀ a, β (toUpper a)) : ∀ a, β a := fun a =>
h (ofUpper a)
instance [Nonempty α] : Nonempty (WithUpper α) := ‹Nonempty α›
instance [Inhabited α] : Inhabited (WithUpper α) := ‹Inhabited α›
variable [Preorder α] {s : Set α}
instance : Preorder (WithUpper α) := ‹Preorder α›
instance : TopologicalSpace (WithUpper α) := upper α
lemma isOpen_preimage_ofUpper : IsOpen (ofUpper ⁻¹' s) ↔ (upper α).IsOpen s := Iff.rfl
lemma isOpen_def {s : Set (WithUpper α)} : IsOpen s ↔ (upper α).IsOpen (toUpper ⁻¹' s) := Iff.rfl
end WithUpper
/--
The lower topology is the topology generated by the complements of the left-closed right-infinite
intervals.
-/
class IsLower (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where
topology_eq_lowerTopology : t = lower α
attribute [nolint docBlame] IsLower.topology_eq_lowerTopology
/--
The upper topology is the topology generated by the complements of the right-closed left-infinite
intervals.
-/
class IsUpper (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where
topology_eq_upperTopology : t = upper α
attribute [nolint docBlame] IsUpper.topology_eq_upperTopology
instance [Preorder α] : IsLower (WithLower α) := ⟨rfl⟩
instance [Preorder α] : IsUpper (WithUpper α) := ⟨rfl⟩
/--
The lower topology is homeomorphic to the upper topology on the dual order
-/
def WithLower.toDualHomeomorph [Preorder α] : WithLower α ≃ₜ WithUpper αᵒᵈ where
toFun := OrderDual.toDual
invFun := OrderDual.ofDual
left_inv := OrderDual.toDual_ofDual
right_inv := OrderDual.ofDual_toDual
continuous_toFun := continuous_coinduced_rng
continuous_invFun := continuous_coinduced_rng
namespace IsLower
/-- The complements of the upper closures of finite sets are a collection of lower sets
which form a basis for the lower topology. -/
def lowerBasis (α : Type*) [Preorder α] :=
{ s : Set α | ∃ t : Set α, t.Finite ∧ (upperClosure t : Set α)ᶜ = s }
section Preorder
variable (α)
variable [Preorder α] [TopologicalSpace α] [IsLower α] {s : Set α}
lemma topology_eq : ‹_› = lower α := topology_eq_lowerTopology
variable {α}
/-- If `α` is equipped with the lower topology, then it is homeomorphic to `WithLower α`.
-/
def withLowerHomeomorph : WithLower α ≃ₜ α :=
WithLower.ofLower.toHomeomorphOfInducing ⟨by erw [topology_eq α, induced_id]; rfl⟩
theorem isOpen_iff_generate_Ici_compl : IsOpen s ↔ GenerateOpen { t | ∃ a, (Ici a)ᶜ = t } s := by
rw [topology_eq α]; rfl
instance _root_.OrderDual.instIsUpper [Preorder α] [TopologicalSpace α] [IsLower α] :
IsUpper αᵒᵈ where
topology_eq_upperTopology := topology_eq_lowerTopology (α := α)
/-- Left-closed right-infinite intervals [a, ∞) are closed in the lower topology. -/
instance : ClosedIciTopology α :=
⟨fun a ↦ isOpen_compl_iff.1 <| isOpen_iff_generate_Ici_compl.2 <| GenerateOpen.basic _ ⟨a, rfl⟩⟩
-- Porting note: The old `IsLower.isClosed_Ici` was removed, since one can now use
-- the general `isClosed_Ici` lemma thanks to the instance above.
/-- The upper closure of a finite set is closed in the lower topology. -/
theorem isClosed_upperClosure (h : s.Finite) : IsClosed (upperClosure s : Set α) := by
simp only [← UpperSet.iInf_Ici, UpperSet.coe_iInf]
exact h.isClosed_biUnion fun _ _ => isClosed_Ici
/-- Every set open in the lower topology is a lower set. -/
theorem isLowerSet_of_isOpen (h : IsOpen s) : IsLowerSet s := by
-- Porting note: `rw` leaves a shadowed assumption
replace h := isOpen_iff_generate_Ici_compl.1 h
induction h with
| basic u h' => obtain ⟨a, rfl⟩ := h'; exact (isUpperSet_Ici a).compl
| univ => exact isLowerSet_univ
| inter u v _ _ hu2 hv2 => exact hu2.inter hv2
| sUnion _ _ ih => exact isLowerSet_sUnion ih
theorem isUpperSet_of_isClosed (h : IsClosed s) : IsUpperSet s :=
isLowerSet_compl.1 <| isLowerSet_of_isOpen h.isOpen_compl
/--
The closure of a singleton `{a}` in the lower topology is the left-closed right-infinite interval
[a, ∞).
-/
@[simp]
theorem closure_singleton (a : α) : closure {a} = Ici a :=
Subset.antisymm ((closure_minimal fun _ h => h.ge) <| isClosed_Ici) <|
(isUpperSet_of_isClosed isClosed_closure).Ici_subset <| subset_closure rfl
protected theorem isTopologicalBasis : IsTopologicalBasis (lowerBasis α) := by
convert isTopologicalBasis_of_subbasis (topology_eq α)
simp_rw [lowerBasis, coe_upperClosure, compl_iUnion]
ext s
constructor
· rintro ⟨F, hF, rfl⟩
refine ⟨(fun a => (Ici a)ᶜ) '' F, ⟨hF.image _, image_subset_iff.2 fun _ _ => ⟨_, rfl⟩⟩, ?_⟩
simp only [sInter_image]
· rintro ⟨F, ⟨hF, hs⟩, rfl⟩
haveI := hF.to_subtype
rw [subset_def, Subtype.forall'] at hs
choose f hf using hs
exact ⟨_, finite_range f, by simp_rw [biInter_range, hf, sInter_eq_iInter]⟩
/-- A function `f : β → α` with lower topology in the codomain is continuous
if and only if the preimage of every interval `Set.Ici a` is a closed set.
-/
lemma continuous_iff_Ici [TopologicalSpace β] {f : β → α} :
Continuous f ↔ ∀ a, IsClosed (f ⁻¹' (Ici a)) := by
obtain rfl := IsLower.topology_eq α
simp [continuous_generateFrom_iff]
/-- A function `f : β → α` with lower topology in the codomain is continuous provided that the
preimage of every interval `Set.Ici a` is a closed set. -/
@[deprecated (since := "2023-12-24")] alias ⟨_, continuous_of_Ici⟩ := continuous_iff_Ici
end Preorder
section PartialOrder
variable [PartialOrder α] [TopologicalSpace α] [IsLower α]
-- see Note [lower instance priority]
/-- The lower topology on a partial order is T₀. -/
instance (priority := 90) t0Space : T0Space α :=
(t0Space_iff_inseparable α).2 fun x y h =>
Ici_injective <| by simpa only [inseparable_iff_closure_eq, closure_singleton] using h
end PartialOrder
end IsLower
namespace IsUpper
/-- The complements of the lower closures of finite sets are a collection of upper sets
which form a basis for the upper topology. -/
def upperBasis (α : Type*) [Preorder α] :=
{ s : Set α | ∃ t : Set α, t.Finite ∧ (lowerClosure t : Set α)ᶜ = s }
section Preorder
variable (α)
variable [Preorder α] [TopologicalSpace α] [IsUpper α] {s : Set α}
lemma topology_eq : ‹_› = upper α := topology_eq_upperTopology
variable {α}
/-- If `α` is equipped with the upper topology, then it is homeomorphic to `WithUpper α`.
-/
def withUpperHomeomorph : WithUpper α ≃ₜ α :=
WithUpper.ofUpper.toHomeomorphOfInducing ⟨by erw [topology_eq α, induced_id]; rfl⟩
theorem isOpen_iff_generate_Iic_compl : IsOpen s ↔ GenerateOpen { t | ∃ a, (Iic a)ᶜ = t } s := by
rw [topology_eq α]; rfl
instance _root_.OrderDual.instIsLower [Preorder α] [TopologicalSpace α] [IsUpper α] :
IsLower αᵒᵈ where
topology_eq_lowerTopology := topology_eq_upperTopology (α := α)
/-- Left-infinite right-closed intervals (-∞,a] are closed in the upper topology. -/
instance : ClosedIicTopology α :=
⟨fun a ↦ isOpen_compl_iff.1 <| isOpen_iff_generate_Iic_compl.2 <| GenerateOpen.basic _ ⟨a, rfl⟩⟩
/-- The lower closure of a finite set is closed in the upper topology. -/
theorem isClosed_lowerClosure (h : s.Finite) : IsClosed (lowerClosure s : Set α) :=
IsLower.isClosed_upperClosure (α := αᵒᵈ) h
/-- Every set open in the upper topology is a upper set. -/
theorem isUpperSet_of_isOpen (h : IsOpen s) : IsUpperSet s :=
IsLower.isLowerSet_of_isOpen (α := αᵒᵈ) h
theorem isLowerSet_of_isClosed (h : IsClosed s) : IsLowerSet s :=
isUpperSet_compl.1 <| isUpperSet_of_isOpen h.isOpen_compl
/--
The closure of a singleton `{a}` in the upper topology is the left-infinite right-closed interval
(-∞,a].
-/
@[simp]
theorem closure_singleton (a : α) : closure {a} = Iic a :=
IsLower.closure_singleton (α := αᵒᵈ) _
protected theorem isTopologicalBasis : IsTopologicalBasis (upperBasis α) :=
IsLower.isTopologicalBasis (α := αᵒᵈ)
/-- A function `f : β → α` with upper topology in the codomain is continuous
if and only if the preimage of every interval `Set.Iic a` is a closed set. -/
lemma continuous_iff_Iic [TopologicalSpace β] {f : β → α} :
Continuous f ↔ ∀ a, IsClosed (f ⁻¹' (Iic a)) :=
IsLower.continuous_iff_Ici (α := αᵒᵈ)
/-- A function `f : β → α` with upper topology in the codomain is continuous
provided that the preimage of every interval `Set.Iic a` is a closed set. -/
@[deprecated (since := "2023-12-24")]
lemma continuous_of_Iic [TopologicalSpace β] {f : β → α} (h : ∀ a, IsClosed (f ⁻¹' (Iic a))) :
Continuous f :=
continuous_iff_Iic.2 h
end Preorder
section PartialOrder
variable [PartialOrder α] [TopologicalSpace α] [IsUpper α]
-- see Note [lower instance priority]
/-- The upper topology on a partial order is T₀. -/
instance (priority := 90) t0Space : T0Space α :=
IsLower.t0Space (α := αᵒᵈ)
end PartialOrder
end IsUpper
instance instIsLowerProd [Preorder α] [TopologicalSpace α] [IsLower α]
[OrderBot α] [Preorder β] [TopologicalSpace β] [IsLower β] [OrderBot β] :
IsLower (α × β) where
topology_eq_lowerTopology := by
refine le_antisymm (le_generateFrom ?_) ?_
· rintro _ ⟨x, rfl⟩
exact (isClosed_Ici.prod isClosed_Ici).isOpen_compl
rw [(IsLower.isTopologicalBasis.prod
IsLower.isTopologicalBasis).eq_generateFrom, le_generateFrom_iff_subset_isOpen,
image2_subset_iff]
rintro _ ⟨s, hs, rfl⟩ _ ⟨t, ht, rfl⟩
dsimp
simp_rw [coe_upperClosure, compl_iUnion, prod_eq, preimage_iInter, preimage_compl]
-- without `let`, `refine` tries to use the product topology and fails
let _ : TopologicalSpace (α × β) := lower (α × β)
refine (hs.isOpen_biInter fun a _ => ?_).inter (ht.isOpen_biInter fun b _ => ?_)
· exact GenerateOpen.basic _ ⟨(a, ⊥), by simp [Ici_prod_eq, prod_univ]⟩
· exact GenerateOpen.basic _ ⟨(⊥, b), by simp [Ici_prod_eq, univ_prod]⟩
instance instIsUpperProd [Preorder α] [TopologicalSpace α] [IsUpper α]
[OrderTop α] [Preorder β] [TopologicalSpace β] [IsUpper β] [OrderTop β] :
IsUpper (α × β) where
topology_eq_upperTopology := by
suffices IsLower (α × β)ᵒᵈ from IsLower.topology_eq_lowerTopology (α := (α × β)ᵒᵈ)
exact instIsLowerProd (α := αᵒᵈ) (β := βᵒᵈ)
section CompleteLattice_IsLower
variable [CompleteLattice α] [CompleteLattice β] [TopologicalSpace α] [IsLower α]
[TopologicalSpace β] [IsLower β]
protected lemma _root_.sInfHom.continuous (f : sInfHom α β) : Continuous f := by
refine IsLower.continuous_iff_Ici.2 fun b => ?_
convert isClosed_Ici (a := sInf <| f ⁻¹' Ici b)
refine Subset.antisymm (fun a => sInf_le) fun a ha => le_trans ?_ <|
OrderHomClass.mono (f : α →o β) ha
refine LE.le.trans ?_ (map_sInf f _).ge
simp
-- see Note [lower instance priority]
instance (priority := 90) IsLower.toContinuousInf : ContinuousInf α :=
⟨(infsInfHom : sInfHom (α × α) α).continuous⟩
end CompleteLattice_IsLower
section CompleteLattice_IsUpper
variable [CompleteLattice α] [CompleteLattice β] [TopologicalSpace α] [IsUpper α]
[TopologicalSpace β] [IsUpper β]
protected lemma _root_.sSupHom.continuous (f : sSupHom α β) : Continuous f :=
sInfHom.continuous (α := αᵒᵈ) (β := βᵒᵈ) (sSupHom.dual.toFun f)
-- see Note [lower instance priority]
instance (priority := 90) IsUpper.toContinuousInf : ContinuousSup α :=
⟨(supsSupHom : sSupHom (α × α) α).continuous⟩
end CompleteLattice_IsUpper
lemma isUpper_orderDual [Preorder α] [TopologicalSpace α] : IsUpper αᵒᵈ ↔ IsLower α := by
constructor
· apply OrderDual.instIsLower
· apply OrderDual.instIsUpper
lemma isLower_orderDual [Preorder α] [TopologicalSpace α] : IsLower αᵒᵈ ↔ IsUpper α :=
isUpper_orderDual.symm
end Topology
|
Topology\Order\Monotone.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, Yury Kudryashov
-/
import Mathlib.Topology.Order.IsLUB
/-!
# Monotone functions on an order topology
This file contains lemmas about limits and continuity for monotone / antitone functions on
linearly-ordered sets (with the order topology). For example, we prove that a monotone function
has left and right limits at any point (`Monotone.tendsto_nhdsWithin_Iio`,
`Monotone.tendsto_nhdsWithin_Ioi`).
-/
open Set Filter TopologicalSpace Topology Function
open OrderDual (toDual ofDual)
variable {α β γ : Type*}
section ConditionallyCompleteLinearOrder
variable [ConditionallyCompleteLinearOrder α] [TopologicalSpace α] [OrderTopology α]
[ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderClosedTopology β] [Nonempty γ]
/-- A monotone function continuous at the supremum of a nonempty set sends this supremum to
the supremum of the image of this set. -/
theorem Monotone.map_sSup_of_continuousAt' {f : α → β} {A : Set α} (Cf : ContinuousAt f (sSup A))
(Mf : Monotone f) (A_nonemp : A.Nonempty) (A_bdd : BddAbove A := by bddDefault) :
f (sSup A) = sSup (f '' A) :=
--This is a particular case of the more general `IsLUB.isLUB_of_tendsto`
.symm <| ((isLUB_csSup A_nonemp A_bdd).isLUB_of_tendsto (Mf.monotoneOn _) A_nonemp <|
Cf.mono_left inf_le_left).csSup_eq (A_nonemp.image f)
/-- A monotone function continuous at the indexed supremum over a nonempty `Sort` sends this indexed
supremum to the indexed supremum of the composition. -/
theorem Monotone.map_iSup_of_continuousAt' {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α}
(Cf : ContinuousAt f (iSup g)) (Mf : Monotone f)
(bdd : BddAbove (range g) := by bddDefault) : f (⨆ i, g i) = ⨆ i, f (g i) := by
rw [iSup, Monotone.map_sSup_of_continuousAt' Cf Mf (range_nonempty g) bdd, ← range_comp, iSup]
rfl
/-- A monotone function continuous at the infimum of a nonempty set sends this infimum to
the infimum of the image of this set. -/
theorem Monotone.map_sInf_of_continuousAt' {f : α → β} {A : Set α} (Cf : ContinuousAt f (sInf A))
(Mf : Monotone f) (A_nonemp : A.Nonempty) (A_bdd : BddBelow A := by bddDefault) :
f (sInf A) = sInf (f '' A) :=
Monotone.map_sSup_of_continuousAt' (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual A_nonemp A_bdd
/-- A monotone function continuous at the indexed infimum over a nonempty `Sort` sends this indexed
infimum to the indexed infimum of the composition. -/
theorem Monotone.map_iInf_of_continuousAt' {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α}
(Cf : ContinuousAt f (iInf g)) (Mf : Monotone f)
(bdd : BddBelow (range g) := by bddDefault) : f (⨅ i, g i) = ⨅ i, f (g i) := by
rw [iInf, Monotone.map_sInf_of_continuousAt' Cf Mf (range_nonempty g) bdd, ← range_comp, iInf]
rfl
/-- An antitone function continuous at the infimum of a nonempty set sends this infimum to
the supremum of the image of this set. -/
theorem Antitone.map_sInf_of_continuousAt' {f : α → β} {A : Set α} (Cf : ContinuousAt f (sInf A))
(Af : Antitone f) (A_nonemp : A.Nonempty) (A_bdd : BddBelow A := by bddDefault) :
f (sInf A) = sSup (f '' A) :=
Monotone.map_sInf_of_continuousAt' (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd
/-- An antitone function continuous at the indexed infimum over a nonempty `Sort` sends this indexed
infimum to the indexed supremum of the composition. -/
theorem Antitone.map_iInf_of_continuousAt' {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α}
(Cf : ContinuousAt f (iInf g)) (Af : Antitone f)
(bdd : BddBelow (range g) := by bddDefault) : f (⨅ i, g i) = ⨆ i, f (g i) := by
rw [iInf, Antitone.map_sInf_of_continuousAt' Cf Af (range_nonempty g) bdd, ← range_comp, iSup]
rfl
/-- An antitone function continuous at the supremum of a nonempty set sends this supremum to
the infimum of the image of this set. -/
theorem Antitone.map_sSup_of_continuousAt' {f : α → β} {A : Set α} (Cf : ContinuousAt f (sSup A))
(Af : Antitone f) (A_nonemp : A.Nonempty) (A_bdd : BddAbove A := by bddDefault) :
f (sSup A) = sInf (f '' A) :=
Monotone.map_sSup_of_continuousAt' (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd
/-- An antitone function continuous at the indexed supremum over a nonempty `Sort` sends this
indexed supremum to the indexed infimum of the composition. -/
theorem Antitone.map_iSup_of_continuousAt' {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α}
(Cf : ContinuousAt f (iSup g)) (Af : Antitone f)
(bdd : BddAbove (range g) := by bddDefault) : f (⨆ i, g i) = ⨅ i, f (g i) := by
rw [iSup, Antitone.map_sSup_of_continuousAt' Cf Af (range_nonempty g) bdd, ← range_comp, iInf]
rfl
end ConditionallyCompleteLinearOrder
section CompleteLinearOrder
variable [CompleteLinearOrder α] [TopologicalSpace α] [OrderTopology α] [CompleteLinearOrder β]
[TopologicalSpace β] [OrderClosedTopology β] [Nonempty γ]
theorem sSup_mem_closure {s : Set α} (hs : s.Nonempty) : sSup s ∈ closure s :=
(isLUB_sSup s).mem_closure hs
theorem sInf_mem_closure {s : Set α} (hs : s.Nonempty) : sInf s ∈ closure s :=
(isGLB_sInf s).mem_closure hs
theorem IsClosed.sSup_mem {s : Set α} (hs : s.Nonempty) (hc : IsClosed s) : sSup s ∈ s :=
(isLUB_sSup s).mem_of_isClosed hs hc
theorem IsClosed.sInf_mem {s : Set α} (hs : s.Nonempty) (hc : IsClosed s) : sInf s ∈ s :=
(isGLB_sInf s).mem_of_isClosed hs hc
/-- A monotone function `f` sending `bot` to `bot` and continuous at the supremum of a set sends
this supremum to the supremum of the image of this set. -/
theorem Monotone.map_sSup_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sSup s))
(Mf : Monotone f) (fbot : f ⊥ = ⊥) : f (sSup s) = sSup (f '' s) := by
rcases s.eq_empty_or_nonempty with h | h
· simp [h, fbot]
· exact Mf.map_sSup_of_continuousAt' Cf h
/-- If a monotone function sending `bot` to `bot` is continuous at the indexed supremum over
a `Sort`, then it sends this indexed supremum to the indexed supremum of the composition. -/
theorem Monotone.map_iSup_of_continuousAt {ι : Sort*} {f : α → β} {g : ι → α}
(Cf : ContinuousAt f (iSup g)) (Mf : Monotone f) (fbot : f ⊥ = ⊥) :
f (⨆ i, g i) = ⨆ i, f (g i) := by
rw [iSup, Mf.map_sSup_of_continuousAt Cf fbot, ← range_comp, iSup]; rfl
/-- A monotone function `f` sending `top` to `top` and continuous at the infimum of a set sends
this infimum to the infimum of the image of this set. -/
theorem Monotone.map_sInf_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sInf s))
(Mf : Monotone f) (ftop : f ⊤ = ⊤) : f (sInf s) = sInf (f '' s) :=
Monotone.map_sSup_of_continuousAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual ftop
/-- If a monotone function sending `top` to `top` is continuous at the indexed infimum over
a `Sort`, then it sends this indexed infimum to the indexed infimum of the composition. -/
theorem Monotone.map_iInf_of_continuousAt {ι : Sort*} {f : α → β} {g : ι → α}
(Cf : ContinuousAt f (iInf g)) (Mf : Monotone f) (ftop : f ⊤ = ⊤) : f (iInf g) = iInf (f ∘ g) :=
Monotone.map_iSup_of_continuousAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual ftop
/-- An antitone function `f` sending `bot` to `top` and continuous at the supremum of a set sends
this supremum to the infimum of the image of this set. -/
theorem Antitone.map_sSup_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sSup s))
(Af : Antitone f) (fbot : f ⊥ = ⊤) : f (sSup s) = sInf (f '' s) :=
Monotone.map_sSup_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (sSup s) from Cf) Af
fbot
/-- An antitone function sending `bot` to `top` is continuous at the indexed supremum over
a `Sort`, then it sends this indexed supremum to the indexed supremum of the composition. -/
theorem Antitone.map_iSup_of_continuousAt {ι : Sort*} {f : α → β} {g : ι → α}
(Cf : ContinuousAt f (iSup g)) (Af : Antitone f) (fbot : f ⊥ = ⊤) :
f (⨆ i, g i) = ⨅ i, f (g i) :=
Monotone.map_iSup_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (iSup g) from Cf) Af
fbot
/-- An antitone function `f` sending `top` to `bot` and continuous at the infimum of a set sends
this infimum to the supremum of the image of this set. -/
theorem Antitone.map_sInf_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sInf s))
(Af : Antitone f) (ftop : f ⊤ = ⊥) : f (sInf s) = sSup (f '' s) :=
Monotone.map_sInf_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (sInf s) from Cf) Af
ftop
/-- If an antitone function sending `top` to `bot` is continuous at the indexed infimum over
a `Sort`, then it sends this indexed infimum to the indexed supremum of the composition. -/
theorem Antitone.map_iInf_of_continuousAt {ι : Sort*} {f : α → β} {g : ι → α}
(Cf : ContinuousAt f (iInf g)) (Af : Antitone f) (ftop : f ⊤ = ⊥) : f (iInf g) = iSup (f ∘ g) :=
Monotone.map_iInf_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (iInf g) from Cf) Af
ftop
end CompleteLinearOrder
section ConditionallyCompleteLinearOrder
variable [ConditionallyCompleteLinearOrder α] [TopologicalSpace α] [OrderTopology α]
[ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderClosedTopology β] [Nonempty γ]
theorem csSup_mem_closure {s : Set α} (hs : s.Nonempty) (B : BddAbove s) : sSup s ∈ closure s :=
(isLUB_csSup hs B).mem_closure hs
theorem csInf_mem_closure {s : Set α} (hs : s.Nonempty) (B : BddBelow s) : sInf s ∈ closure s :=
(isGLB_csInf hs B).mem_closure hs
theorem IsClosed.csSup_mem {s : Set α} (hc : IsClosed s) (hs : s.Nonempty) (B : BddAbove s) :
sSup s ∈ s :=
(isLUB_csSup hs B).mem_of_isClosed hs hc
theorem IsClosed.csInf_mem {s : Set α} (hc : IsClosed s) (hs : s.Nonempty) (B : BddBelow s) :
sInf s ∈ s :=
(isGLB_csInf hs B).mem_of_isClosed hs hc
theorem IsClosed.isLeast_csInf {s : Set α} (hc : IsClosed s) (hs : s.Nonempty) (B : BddBelow s) :
IsLeast s (sInf s) :=
⟨hc.csInf_mem hs B, (isGLB_csInf hs B).1⟩
theorem IsClosed.isGreatest_csSup {s : Set α} (hc : IsClosed s) (hs : s.Nonempty) (B : BddAbove s) :
IsGreatest s (sSup s) :=
IsClosed.isLeast_csInf (α := αᵒᵈ) hc hs B
/-- If a monotone function is continuous at the supremum of a nonempty bounded above set `s`,
then it sends this supremum to the supremum of the image of `s`. -/
theorem Monotone.map_csSup_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sSup s))
(Mf : Monotone f) (ne : s.Nonempty) (H : BddAbove s) : f (sSup s) = sSup (f '' s) := by
refine ((isLUB_csSup (ne.image f) (Mf.map_bddAbove H)).unique ?_).symm
refine (isLUB_csSup ne H).isLUB_of_tendsto (fun x _ y _ xy => Mf xy) ne ?_
exact Cf.mono_left inf_le_left
/-- If a monotone function is continuous at the indexed supremum of a bounded function on
a nonempty `Sort`, then it sends this supremum to the supremum of the composition. -/
theorem Monotone.map_ciSup_of_continuousAt {f : α → β} {g : γ → α} (Cf : ContinuousAt f (⨆ i, g i))
(Mf : Monotone f) (H : BddAbove (range g)) : f (⨆ i, g i) = ⨆ i, f (g i) := by
rw [iSup, Mf.map_csSup_of_continuousAt Cf (range_nonempty _) H, ← range_comp, iSup]; rfl
/-- If a monotone function is continuous at the infimum of a nonempty bounded below set `s`,
then it sends this infimum to the infimum of the image of `s`. -/
theorem Monotone.map_csInf_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sInf s))
(Mf : Monotone f) (ne : s.Nonempty) (H : BddBelow s) : f (sInf s) = sInf (f '' s) :=
Monotone.map_csSup_of_continuousAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual ne H
/-- A continuous monotone function sends indexed infimum to indexed infimum in conditionally
complete linear order, under a boundedness assumption. -/
theorem Monotone.map_ciInf_of_continuousAt {f : α → β} {g : γ → α} (Cf : ContinuousAt f (⨅ i, g i))
(Mf : Monotone f) (H : BddBelow (range g)) : f (⨅ i, g i) = ⨅ i, f (g i) :=
Monotone.map_ciSup_of_continuousAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual H
/-- If an antitone function is continuous at the supremum of a nonempty bounded above set `s`,
then it sends this supremum to the infimum of the image of `s`. -/
theorem Antitone.map_csSup_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sSup s))
(Af : Antitone f) (ne : s.Nonempty) (H : BddAbove s) : f (sSup s) = sInf (f '' s) :=
Monotone.map_csSup_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (sSup s) from Cf) Af
ne H
/-- If an antitone function is continuous at the indexed supremum of a bounded function on
a nonempty `Sort`, then it sends this supremum to the infimum of the composition. -/
theorem Antitone.map_ciSup_of_continuousAt {f : α → β} {g : γ → α} (Cf : ContinuousAt f (⨆ i, g i))
(Af : Antitone f) (H : BddAbove (range g)) : f (⨆ i, g i) = ⨅ i, f (g i) :=
Monotone.map_ciSup_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (⨆ i, g i) from Cf)
Af H
/-- If an antitone function is continuous at the infimum of a nonempty bounded below set `s`,
then it sends this infimum to the supremum of the image of `s`. -/
theorem Antitone.map_csInf_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sInf s))
(Af : Antitone f) (ne : s.Nonempty) (H : BddBelow s) : f (sInf s) = sSup (f '' s) :=
Monotone.map_csInf_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (sInf s) from Cf) Af
ne H
/-- A continuous antitone function sends indexed infimum to indexed supremum in conditionally
complete linear order, under a boundedness assumption. -/
theorem Antitone.map_ciInf_of_continuousAt {f : α → β} {g : γ → α} (Cf : ContinuousAt f (⨅ i, g i))
(Af : Antitone f) (H : BddBelow (range g)) : f (⨅ i, g i) = ⨆ i, f (g i) :=
Monotone.map_ciInf_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (⨅ i, g i) from Cf)
Af H
/-- A monotone map has a limit to the left of any point `x`, equal to `sSup (f '' (Iio x))`. -/
theorem Monotone.tendsto_nhdsWithin_Iio {α β : Type*} [LinearOrder α] [TopologicalSpace α]
[OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderTopology β]
{f : α → β} (Mf : Monotone f) (x : α) : Tendsto f (𝓝[<] x) (𝓝 (sSup (f '' Iio x))) := by
rcases eq_empty_or_nonempty (Iio x) with (h | h); · simp [h]
refine tendsto_order.2 ⟨fun l hl => ?_, fun m hm => ?_⟩
· obtain ⟨z, zx, lz⟩ : ∃ a : α, a < x ∧ l < f a := by
simpa only [mem_image, exists_prop, exists_exists_and_eq_and] using
exists_lt_of_lt_csSup (h.image _) hl
exact mem_of_superset (Ioo_mem_nhdsWithin_Iio' zx) fun y hy => lz.trans_le (Mf hy.1.le)
· refine mem_of_superset self_mem_nhdsWithin fun _ hy => lt_of_le_of_lt ?_ hm
exact le_csSup (Mf.map_bddAbove bddAbove_Iio) (mem_image_of_mem _ hy)
/-- A monotone map has a limit to the right of any point `x`, equal to `sInf (f '' (Ioi x))`. -/
theorem Monotone.tendsto_nhdsWithin_Ioi {α β : Type*} [LinearOrder α] [TopologicalSpace α]
[OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderTopology β]
{f : α → β} (Mf : Monotone f) (x : α) : Tendsto f (𝓝[>] x) (𝓝 (sInf (f '' Ioi x))) :=
Monotone.tendsto_nhdsWithin_Iio (α := αᵒᵈ) (β := βᵒᵈ) Mf.dual x
end ConditionallyCompleteLinearOrder
|
Topology\Order\MonotoneContinuity.lean | /-
Copyright (c) 2021 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov, Heather Macbeth
-/
import Mathlib.Topology.Homeomorph
import Mathlib.Topology.Order.LeftRightNhds
/-!
# Continuity of monotone functions
In this file we prove the following fact: if `f` is a monotone function on a neighborhood of `a`
and the image of this neighborhood is a neighborhood of `f a`, then `f` is continuous at `a`, see
`continuousWithinAt_of_monotoneOn_of_image_mem_nhds`, as well as several similar facts.
We also prove that an `OrderIso` is continuous.
## Tags
continuous, monotone
-/
open Set Filter
open Topology
section LinearOrder
variable {α β : Type*} [LinearOrder α] [TopologicalSpace α] [OrderTopology α]
variable [LinearOrder β] [TopologicalSpace β] [OrderTopology β]
/-- If `f` is a function strictly monotone on a right neighborhood of `a` and the
image of this neighborhood under `f` meets every interval `(f a, b]`, `b > f a`, then `f` is
continuous at `a` from the right.
The assumption `hfs : ∀ b > f a, ∃ c ∈ s, f c ∈ Ioc (f a) b` is required because otherwise the
function `f : ℝ → ℝ` given by `f x = if x ≤ 0 then x else x + 1` would be a counter-example at
`a = 0`. -/
theorem StrictMonoOn.continuousWithinAt_right_of_exists_between {f : α → β} {s : Set α} {a : α}
(h_mono : StrictMonoOn f s) (hs : s ∈ 𝓝[≥] a) (hfs : ∀ b > f a, ∃ c ∈ s, f c ∈ Ioc (f a) b) :
ContinuousWithinAt f (Ici a) a := by
have ha : a ∈ Ici a := left_mem_Ici
have has : a ∈ s := mem_of_mem_nhdsWithin ha hs
refine tendsto_order.2 ⟨fun b hb => ?_, fun b hb => ?_⟩
· filter_upwards [hs, @self_mem_nhdsWithin _ _ a (Ici a)] with _ hxs hxa using hb.trans_le
((h_mono.le_iff_le has hxs).2 hxa)
· rcases hfs b hb with ⟨c, hcs, hac, hcb⟩
rw [h_mono.lt_iff_lt has hcs] at hac
filter_upwards [hs, Ico_mem_nhdsWithin_Ici (left_mem_Ico.2 hac)]
rintro x hx ⟨_, hxc⟩
exact ((h_mono.lt_iff_lt hx hcs).2 hxc).trans_le hcb
/-- If `f` is a monotone function on a right neighborhood of `a` and the image of this neighborhood
under `f` meets every interval `(f a, b)`, `b > f a`, then `f` is continuous at `a` from the right.
The assumption `hfs : ∀ b > f a, ∃ c ∈ s, f c ∈ Ioo (f a) b` cannot be replaced by the weaker
assumption `hfs : ∀ b > f a, ∃ c ∈ s, f c ∈ Ioc (f a) b` we use for strictly monotone functions
because otherwise the function `ceil : ℝ → ℤ` would be a counter-example at `a = 0`. -/
theorem continuousWithinAt_right_of_monotoneOn_of_exists_between {f : α → β} {s : Set α} {a : α}
(h_mono : MonotoneOn f s) (hs : s ∈ 𝓝[≥] a) (hfs : ∀ b > f a, ∃ c ∈ s, f c ∈ Ioo (f a) b) :
ContinuousWithinAt f (Ici a) a := by
have ha : a ∈ Ici a := left_mem_Ici
have has : a ∈ s := mem_of_mem_nhdsWithin ha hs
refine tendsto_order.2 ⟨fun b hb => ?_, fun b hb => ?_⟩
· filter_upwards [hs, @self_mem_nhdsWithin _ _ a (Ici a)] with _ hxs hxa using hb.trans_le
(h_mono has hxs hxa)
· rcases hfs b hb with ⟨c, hcs, hac, hcb⟩
have : a < c := not_le.1 fun h => hac.not_le <| h_mono hcs has h
filter_upwards [hs, Ico_mem_nhdsWithin_Ici (left_mem_Ico.2 this)]
rintro x hx ⟨_, hxc⟩
exact (h_mono hx hcs hxc.le).trans_lt hcb
/-- If a function `f` with a densely ordered codomain is monotone on a right neighborhood of `a` and
the closure of the image of this neighborhood under `f` is a right neighborhood of `f a`, then `f`
is continuous at `a` from the right. -/
theorem continuousWithinAt_right_of_monotoneOn_of_closure_image_mem_nhdsWithin [DenselyOrdered β]
{f : α → β} {s : Set α} {a : α} (h_mono : MonotoneOn f s) (hs : s ∈ 𝓝[≥] a)
(hfs : closure (f '' s) ∈ 𝓝[≥] f a) : ContinuousWithinAt f (Ici a) a := by
refine continuousWithinAt_right_of_monotoneOn_of_exists_between h_mono hs fun b hb => ?_
rcases (mem_nhdsWithin_Ici_iff_exists_mem_Ioc_Ico_subset hb).1 hfs with ⟨b', ⟨hab', hbb'⟩, hb'⟩
rcases exists_between hab' with ⟨c', hc'⟩
rcases mem_closure_iff.1 (hb' ⟨hc'.1.le, hc'.2⟩) (Ioo (f a) b') isOpen_Ioo hc' with
⟨_, hc, ⟨c, hcs, rfl⟩⟩
exact ⟨c, hcs, hc.1, hc.2.trans_le hbb'⟩
/-- If a function `f` with a densely ordered codomain is monotone on a right neighborhood of `a` and
the image of this neighborhood under `f` is a right neighborhood of `f a`, then `f` is continuous at
`a` from the right. -/
theorem continuousWithinAt_right_of_monotoneOn_of_image_mem_nhdsWithin [DenselyOrdered β]
{f : α → β} {s : Set α} {a : α} (h_mono : MonotoneOn f s) (hs : s ∈ 𝓝[≥] a)
(hfs : f '' s ∈ 𝓝[≥] f a) : ContinuousWithinAt f (Ici a) a :=
continuousWithinAt_right_of_monotoneOn_of_closure_image_mem_nhdsWithin h_mono hs <|
mem_of_superset hfs subset_closure
/-- If a function `f` with a densely ordered codomain is strictly monotone on a right neighborhood
of `a` and the closure of the image of this neighborhood under `f` is a right neighborhood of `f a`,
then `f` is continuous at `a` from the right. -/
theorem StrictMonoOn.continuousWithinAt_right_of_closure_image_mem_nhdsWithin [DenselyOrdered β]
{f : α → β} {s : Set α} {a : α} (h_mono : StrictMonoOn f s) (hs : s ∈ 𝓝[≥] a)
(hfs : closure (f '' s) ∈ 𝓝[≥] f a) : ContinuousWithinAt f (Ici a) a :=
continuousWithinAt_right_of_monotoneOn_of_closure_image_mem_nhdsWithin
(fun _ hx _ hy => (h_mono.le_iff_le hx hy).2) hs hfs
/-- If a function `f` with a densely ordered codomain is strictly monotone on a right neighborhood
of `a` and the image of this neighborhood under `f` is a right neighborhood of `f a`, then `f` is
continuous at `a` from the right. -/
theorem StrictMonoOn.continuousWithinAt_right_of_image_mem_nhdsWithin [DenselyOrdered β] {f : α → β}
{s : Set α} {a : α} (h_mono : StrictMonoOn f s) (hs : s ∈ 𝓝[≥] a) (hfs : f '' s ∈ 𝓝[≥] f a) :
ContinuousWithinAt f (Ici a) a :=
h_mono.continuousWithinAt_right_of_closure_image_mem_nhdsWithin hs
(mem_of_superset hfs subset_closure)
/-- If a function `f` is strictly monotone on a right neighborhood of `a` and the image of this
neighborhood under `f` includes `Ioi (f a)`, then `f` is continuous at `a` from the right. -/
theorem StrictMonoOn.continuousWithinAt_right_of_surjOn {f : α → β} {s : Set α} {a : α}
(h_mono : StrictMonoOn f s) (hs : s ∈ 𝓝[≥] a) (hfs : SurjOn f s (Ioi (f a))) :
ContinuousWithinAt f (Ici a) a :=
h_mono.continuousWithinAt_right_of_exists_between hs fun _ hb =>
let ⟨c, hcs, hcb⟩ := hfs hb
⟨c, hcs, hcb.symm ▸ hb, hcb.le⟩
/-- If `f` is a strictly monotone function on a left neighborhood of `a` and the image of this
neighborhood under `f` meets every interval `[b, f a)`, `b < f a`, then `f` is continuous at `a`
from the left.
The assumption `hfs : ∀ b < f a, ∃ c ∈ s, f c ∈ Ico b (f a)` is required because otherwise the
function `f : ℝ → ℝ` given by `f x = if x < 0 then x else x + 1` would be a counter-example at
`a = 0`. -/
theorem StrictMonoOn.continuousWithinAt_left_of_exists_between {f : α → β} {s : Set α} {a : α}
(h_mono : StrictMonoOn f s) (hs : s ∈ 𝓝[≤] a) (hfs : ∀ b < f a, ∃ c ∈ s, f c ∈ Ico b (f a)) :
ContinuousWithinAt f (Iic a) a :=
h_mono.dual.continuousWithinAt_right_of_exists_between hs fun b hb =>
let ⟨c, hcs, hcb, hca⟩ := hfs b hb
⟨c, hcs, hca, hcb⟩
/-- If `f` is a monotone function on a left neighborhood of `a` and the image of this neighborhood
under `f` meets every interval `(b, f a)`, `b < f a`, then `f` is continuous at `a` from the left.
The assumption `hfs : ∀ b < f a, ∃ c ∈ s, f c ∈ Ioo b (f a)` cannot be replaced by the weaker
assumption `hfs : ∀ b < f a, ∃ c ∈ s, f c ∈ Ico b (f a)` we use for strictly monotone functions
because otherwise the function `floor : ℝ → ℤ` would be a counter-example at `a = 0`. -/
theorem continuousWithinAt_left_of_monotoneOn_of_exists_between {f : α → β} {s : Set α} {a : α}
(hf : MonotoneOn f s) (hs : s ∈ 𝓝[≤] a) (hfs : ∀ b < f a, ∃ c ∈ s, f c ∈ Ioo b (f a)) :
ContinuousWithinAt f (Iic a) a :=
@continuousWithinAt_right_of_monotoneOn_of_exists_between αᵒᵈ βᵒᵈ _ _ _ _ _ _ f s a hf.dual hs
fun b hb =>
let ⟨c, hcs, hcb, hca⟩ := hfs b hb
⟨c, hcs, hca, hcb⟩
/-- If a function `f` with a densely ordered codomain is monotone on a left neighborhood of `a` and
the closure of the image of this neighborhood under `f` is a left neighborhood of `f a`, then `f` is
continuous at `a` from the left -/
theorem continuousWithinAt_left_of_monotoneOn_of_closure_image_mem_nhdsWithin [DenselyOrdered β]
{f : α → β} {s : Set α} {a : α} (hf : MonotoneOn f s) (hs : s ∈ 𝓝[≤] a)
(hfs : closure (f '' s) ∈ 𝓝[≤] f a) : ContinuousWithinAt f (Iic a) a :=
@continuousWithinAt_right_of_monotoneOn_of_closure_image_mem_nhdsWithin αᵒᵈ βᵒᵈ _ _ _ _ _ _ _ f s
a hf.dual hs hfs
/-- If a function `f` with a densely ordered codomain is monotone on a left neighborhood of `a` and
the image of this neighborhood under `f` is a left neighborhood of `f a`, then `f` is continuous at
`a` from the left. -/
theorem continuousWithinAt_left_of_monotoneOn_of_image_mem_nhdsWithin [DenselyOrdered β] {f : α → β}
{s : Set α} {a : α} (h_mono : MonotoneOn f s) (hs : s ∈ 𝓝[≤] a) (hfs : f '' s ∈ 𝓝[≤] f a) :
ContinuousWithinAt f (Iic a) a :=
continuousWithinAt_left_of_monotoneOn_of_closure_image_mem_nhdsWithin h_mono hs
(mem_of_superset hfs subset_closure)
/-- If a function `f` with a densely ordered codomain is strictly monotone on a left neighborhood of
`a` and the closure of the image of this neighborhood under `f` is a left neighborhood of `f a`,
then `f` is continuous at `a` from the left. -/
theorem StrictMonoOn.continuousWithinAt_left_of_closure_image_mem_nhdsWithin [DenselyOrdered β]
{f : α → β} {s : Set α} {a : α} (h_mono : StrictMonoOn f s) (hs : s ∈ 𝓝[≤] a)
(hfs : closure (f '' s) ∈ 𝓝[≤] f a) : ContinuousWithinAt f (Iic a) a :=
h_mono.dual.continuousWithinAt_right_of_closure_image_mem_nhdsWithin hs hfs
/-- If a function `f` with a densely ordered codomain is strictly monotone on a left neighborhood of
`a` and the image of this neighborhood under `f` is a left neighborhood of `f a`, then `f` is
continuous at `a` from the left. -/
theorem StrictMonoOn.continuousWithinAt_left_of_image_mem_nhdsWithin [DenselyOrdered β] {f : α → β}
{s : Set α} {a : α} (h_mono : StrictMonoOn f s) (hs : s ∈ 𝓝[≤] a) (hfs : f '' s ∈ 𝓝[≤] f a) :
ContinuousWithinAt f (Iic a) a :=
h_mono.dual.continuousWithinAt_right_of_image_mem_nhdsWithin hs hfs
/-- If a function `f` is strictly monotone on a left neighborhood of `a` and the image of this
neighborhood under `f` includes `Iio (f a)`, then `f` is continuous at `a` from the left. -/
theorem StrictMonoOn.continuousWithinAt_left_of_surjOn {f : α → β} {s : Set α} {a : α}
(h_mono : StrictMonoOn f s) (hs : s ∈ 𝓝[≤] a) (hfs : SurjOn f s (Iio (f a))) :
ContinuousWithinAt f (Iic a) a :=
h_mono.dual.continuousWithinAt_right_of_surjOn hs hfs
/-- If a function `f` is strictly monotone on a neighborhood of `a` and the image of this
neighborhood under `f` meets every interval `[b, f a)`, `b < f a`, and every interval
`(f a, b]`, `b > f a`, then `f` is continuous at `a`. -/
theorem StrictMonoOn.continuousAt_of_exists_between {f : α → β} {s : Set α} {a : α}
(h_mono : StrictMonoOn f s) (hs : s ∈ 𝓝 a) (hfs_l : ∀ b < f a, ∃ c ∈ s, f c ∈ Ico b (f a))
(hfs_r : ∀ b > f a, ∃ c ∈ s, f c ∈ Ioc (f a) b) : ContinuousAt f a :=
continuousAt_iff_continuous_left_right.2
⟨h_mono.continuousWithinAt_left_of_exists_between (mem_nhdsWithin_of_mem_nhds hs) hfs_l,
h_mono.continuousWithinAt_right_of_exists_between (mem_nhdsWithin_of_mem_nhds hs) hfs_r⟩
/-- If a function `f` with a densely ordered codomain is strictly monotone on a neighborhood of `a`
and the closure of the image of this neighborhood under `f` is a neighborhood of `f a`, then `f` is
continuous at `a`. -/
theorem StrictMonoOn.continuousAt_of_closure_image_mem_nhds [DenselyOrdered β] {f : α → β}
{s : Set α} {a : α} (h_mono : StrictMonoOn f s) (hs : s ∈ 𝓝 a)
(hfs : closure (f '' s) ∈ 𝓝 (f a)) : ContinuousAt f a :=
continuousAt_iff_continuous_left_right.2
⟨h_mono.continuousWithinAt_left_of_closure_image_mem_nhdsWithin (mem_nhdsWithin_of_mem_nhds hs)
(mem_nhdsWithin_of_mem_nhds hfs),
h_mono.continuousWithinAt_right_of_closure_image_mem_nhdsWithin
(mem_nhdsWithin_of_mem_nhds hs) (mem_nhdsWithin_of_mem_nhds hfs)⟩
/-- If a function `f` with a densely ordered codomain is strictly monotone on a neighborhood of `a`
and the image of this set under `f` is a neighborhood of `f a`, then `f` is continuous at `a`. -/
theorem StrictMonoOn.continuousAt_of_image_mem_nhds [DenselyOrdered β] {f : α → β} {s : Set α}
{a : α} (h_mono : StrictMonoOn f s) (hs : s ∈ 𝓝 a) (hfs : f '' s ∈ 𝓝 (f a)) :
ContinuousAt f a :=
h_mono.continuousAt_of_closure_image_mem_nhds hs (mem_of_superset hfs subset_closure)
/-- If `f` is a monotone function on a neighborhood of `a` and the image of this neighborhood under
`f` meets every interval `(b, f a)`, `b < f a`, and every interval `(f a, b)`, `b > f a`, then `f`
is continuous at `a`. -/
theorem continuousAt_of_monotoneOn_of_exists_between {f : α → β} {s : Set α} {a : α}
(h_mono : MonotoneOn f s) (hs : s ∈ 𝓝 a) (hfs_l : ∀ b < f a, ∃ c ∈ s, f c ∈ Ioo b (f a))
(hfs_r : ∀ b > f a, ∃ c ∈ s, f c ∈ Ioo (f a) b) : ContinuousAt f a :=
continuousAt_iff_continuous_left_right.2
⟨continuousWithinAt_left_of_monotoneOn_of_exists_between h_mono (mem_nhdsWithin_of_mem_nhds hs)
hfs_l,
continuousWithinAt_right_of_monotoneOn_of_exists_between h_mono
(mem_nhdsWithin_of_mem_nhds hs) hfs_r⟩
/-- If a function `f` with a densely ordered codomain is monotone on a neighborhood of `a` and the
closure of the image of this neighborhood under `f` is a neighborhood of `f a`, then `f` is
continuous at `a`. -/
theorem continuousAt_of_monotoneOn_of_closure_image_mem_nhds [DenselyOrdered β] {f : α → β}
{s : Set α} {a : α} (h_mono : MonotoneOn f s) (hs : s ∈ 𝓝 a)
(hfs : closure (f '' s) ∈ 𝓝 (f a)) : ContinuousAt f a :=
continuousAt_iff_continuous_left_right.2
⟨continuousWithinAt_left_of_monotoneOn_of_closure_image_mem_nhdsWithin h_mono
(mem_nhdsWithin_of_mem_nhds hs) (mem_nhdsWithin_of_mem_nhds hfs),
continuousWithinAt_right_of_monotoneOn_of_closure_image_mem_nhdsWithin h_mono
(mem_nhdsWithin_of_mem_nhds hs) (mem_nhdsWithin_of_mem_nhds hfs)⟩
/-- If a function `f` with a densely ordered codomain is monotone on a neighborhood of `a` and the
image of this neighborhood under `f` is a neighborhood of `f a`, then `f` is continuous at `a`. -/
theorem continuousAt_of_monotoneOn_of_image_mem_nhds [DenselyOrdered β] {f : α → β} {s : Set α}
{a : α} (h_mono : MonotoneOn f s) (hs : s ∈ 𝓝 a) (hfs : f '' s ∈ 𝓝 (f a)) : ContinuousAt f a :=
continuousAt_of_monotoneOn_of_closure_image_mem_nhds h_mono hs
(mem_of_superset hfs subset_closure)
/-- A monotone function with densely ordered codomain and a dense range is continuous. -/
theorem Monotone.continuous_of_denseRange [DenselyOrdered β] {f : α → β} (h_mono : Monotone f)
(h_dense : DenseRange f) : Continuous f :=
continuous_iff_continuousAt.mpr fun a =>
continuousAt_of_monotoneOn_of_closure_image_mem_nhds (fun x _ y _ hxy => h_mono hxy)
univ_mem <|
by simp only [image_univ, h_dense.closure_eq, univ_mem]
/-- A monotone surjective function with a densely ordered codomain is continuous. -/
theorem Monotone.continuous_of_surjective [DenselyOrdered β] {f : α → β} (h_mono : Monotone f)
(h_surj : Function.Surjective f) : Continuous f :=
h_mono.continuous_of_denseRange h_surj.denseRange
end LinearOrder
/-!
### Continuity of order isomorphisms
In this section we prove that an `OrderIso` is continuous, hence it is a `Homeomorph`. We prove
this for an `OrderIso` between to partial orders with order topology.
-/
namespace OrderIso
variable {α β : Type*} [PartialOrder α] [PartialOrder β] [TopologicalSpace α] [TopologicalSpace β]
[OrderTopology α] [OrderTopology β]
protected theorem continuous (e : α ≃o β) : Continuous e := by
rw [‹OrderTopology β›.topology_eq_generate_intervals, continuous_generateFrom_iff]
rintro s ⟨a, rfl | rfl⟩
· rw [e.preimage_Ioi]
apply isOpen_lt'
· rw [e.preimage_Iio]
apply isOpen_gt'
/-- An order isomorphism between two linear order `OrderTopology` spaces is a homeomorphism. -/
def toHomeomorph (e : α ≃o β) : α ≃ₜ β :=
{ e with
continuous_toFun := e.continuous
continuous_invFun := e.symm.continuous }
@[simp]
theorem coe_toHomeomorph (e : α ≃o β) : ⇑e.toHomeomorph = e :=
rfl
@[simp]
theorem coe_toHomeomorph_symm (e : α ≃o β) : ⇑e.toHomeomorph.symm = e.symm :=
rfl
end OrderIso
|
Topology\Order\MonotoneConvergence.lean | /-
Copyright (c) 2021 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth, Yury Kudryashov
-/
import Mathlib.Topology.Order.Basic
/-!
# Bounded monotone sequences converge
In this file we prove a few theorems of the form “if the range of a monotone function `f : ι → α`
admits a least upper bound `a`, then `f x` tends to `a` as `x → ∞`”, as well as version of this
statement for (conditionally) complete lattices that use `⨆ x, f x` instead of `IsLUB`.
These theorems work for linear orders with order topologies as well as their products (both in terms
of `Prod` and in terms of function types). In order to reduce code duplication, we introduce two
typeclasses (one for the property formulated above and one for the dual property), prove theorems
assuming one of these typeclasses, and provide instances for linear orders and their products.
We also prove some "inverse" results: if `f n` is a monotone sequence and `a` is its limit,
then `f n ≤ a` for all `n`.
## Tags
monotone convergence
-/
open Filter Set Function
open scoped Classical
open Filter Topology
variable {α β : Type*}
/-- We say that `α` is a `SupConvergenceClass` if the following holds. Let `f : ι → α` be a
monotone function, let `a : α` be a least upper bound of `Set.range f`. Then `f x` tends to `𝓝 a`
as `x → ∞` (formally, at the filter `Filter.atTop`). We require this for `ι = (s : Set α)`,
`f = CoeTC.coe` in the definition, then prove it for any `f` in `tendsto_atTop_isLUB`.
This property holds for linear orders with order topology as well as their products. -/
class SupConvergenceClass (α : Type*) [Preorder α] [TopologicalSpace α] : Prop where
/-- proof that a monotone function tends to `𝓝 a` as `x → ∞` -/
tendsto_coe_atTop_isLUB :
∀ (a : α) (s : Set α), IsLUB s a → Tendsto (CoeTC.coe : s → α) atTop (𝓝 a)
/-- We say that `α` is an `InfConvergenceClass` if the following holds. Let `f : ι → α` be a
monotone function, let `a : α` be a greatest lower bound of `Set.range f`. Then `f x` tends to `𝓝 a`
as `x → -∞` (formally, at the filter `Filter.atBot`). We require this for `ι = (s : Set α)`,
`f = CoeTC.coe` in the definition, then prove it for any `f` in `tendsto_atBot_isGLB`.
This property holds for linear orders with order topology as well as their products. -/
class InfConvergenceClass (α : Type*) [Preorder α] [TopologicalSpace α] : Prop where
/-- proof that a monotone function tends to `𝓝 a` as `x → -∞`-/
tendsto_coe_atBot_isGLB :
∀ (a : α) (s : Set α), IsGLB s a → Tendsto (CoeTC.coe : s → α) atBot (𝓝 a)
instance OrderDual.supConvergenceClass [Preorder α] [TopologicalSpace α] [InfConvergenceClass α] :
SupConvergenceClass αᵒᵈ :=
⟨‹InfConvergenceClass α›.1⟩
instance OrderDual.infConvergenceClass [Preorder α] [TopologicalSpace α] [SupConvergenceClass α] :
InfConvergenceClass αᵒᵈ :=
⟨‹SupConvergenceClass α›.1⟩
-- see Note [lower instance priority]
instance (priority := 100) LinearOrder.supConvergenceClass [TopologicalSpace α] [LinearOrder α]
[OrderTopology α] : SupConvergenceClass α := by
refine ⟨fun a s ha => tendsto_order.2 ⟨fun b hb => ?_, fun b hb => ?_⟩⟩
· rcases ha.exists_between hb with ⟨c, hcs, bc, bca⟩
lift c to s using hcs
exact (eventually_ge_atTop c).mono fun x hx => bc.trans_le hx
· exact eventually_of_forall fun x => (ha.1 x.2).trans_lt hb
-- see Note [lower instance priority]
instance (priority := 100) LinearOrder.infConvergenceClass [TopologicalSpace α] [LinearOrder α]
[OrderTopology α] : InfConvergenceClass α :=
show InfConvergenceClass αᵒᵈᵒᵈ from OrderDual.infConvergenceClass
section
variable {ι : Type*} [Preorder ι] [TopologicalSpace α]
section IsLUB
variable [Preorder α] [SupConvergenceClass α] {f : ι → α} {a : α}
theorem tendsto_atTop_isLUB (h_mono : Monotone f) (ha : IsLUB (Set.range f) a) :
Tendsto f atTop (𝓝 a) := by
suffices Tendsto (rangeFactorization f) atTop atTop from
(SupConvergenceClass.tendsto_coe_atTop_isLUB _ _ ha).comp this
exact h_mono.rangeFactorization.tendsto_atTop_atTop fun b => b.2.imp fun a ha => ha.ge
theorem tendsto_atBot_isLUB (h_anti : Antitone f) (ha : IsLUB (Set.range f) a) :
Tendsto f atBot (𝓝 a) := by convert tendsto_atTop_isLUB h_anti.dual_left ha using 1
end IsLUB
section IsGLB
variable [Preorder α] [InfConvergenceClass α] {f : ι → α} {a : α}
theorem tendsto_atBot_isGLB (h_mono : Monotone f) (ha : IsGLB (Set.range f) a) :
Tendsto f atBot (𝓝 a) := by convert tendsto_atTop_isLUB h_mono.dual ha.dual using 1
theorem tendsto_atTop_isGLB (h_anti : Antitone f) (ha : IsGLB (Set.range f) a) :
Tendsto f atTop (𝓝 a) := by convert tendsto_atBot_isLUB h_anti.dual ha.dual using 1
end IsGLB
section CiSup
variable [ConditionallyCompleteLattice α] [SupConvergenceClass α] {f : ι → α} {a : α}
theorem tendsto_atTop_ciSup (h_mono : Monotone f) (hbdd : BddAbove <| range f) :
Tendsto f atTop (𝓝 (⨆ i, f i)) := by
cases isEmpty_or_nonempty ι
exacts [tendsto_of_isEmpty, tendsto_atTop_isLUB h_mono (isLUB_ciSup hbdd)]
theorem tendsto_atBot_ciSup (h_anti : Antitone f) (hbdd : BddAbove <| range f) :
Tendsto f atBot (𝓝 (⨆ i, f i)) := by convert tendsto_atTop_ciSup h_anti.dual hbdd.dual using 1
end CiSup
section CiInf
variable [ConditionallyCompleteLattice α] [InfConvergenceClass α] {f : ι → α} {a : α}
theorem tendsto_atBot_ciInf (h_mono : Monotone f) (hbdd : BddBelow <| range f) :
Tendsto f atBot (𝓝 (⨅ i, f i)) := by convert tendsto_atTop_ciSup h_mono.dual hbdd.dual using 1
theorem tendsto_atTop_ciInf (h_anti : Antitone f) (hbdd : BddBelow <| range f) :
Tendsto f atTop (𝓝 (⨅ i, f i)) := by convert tendsto_atBot_ciSup h_anti.dual hbdd.dual using 1
end CiInf
section iSup
variable [CompleteLattice α] [SupConvergenceClass α] {f : ι → α} {a : α}
theorem tendsto_atTop_iSup (h_mono : Monotone f) : Tendsto f atTop (𝓝 (⨆ i, f i)) :=
tendsto_atTop_ciSup h_mono (OrderTop.bddAbove _)
theorem tendsto_atBot_iSup (h_anti : Antitone f) : Tendsto f atBot (𝓝 (⨆ i, f i)) :=
tendsto_atBot_ciSup h_anti (OrderTop.bddAbove _)
end iSup
section iInf
variable [CompleteLattice α] [InfConvergenceClass α] {f : ι → α} {a : α}
theorem tendsto_atBot_iInf (h_mono : Monotone f) : Tendsto f atBot (𝓝 (⨅ i, f i)) :=
tendsto_atBot_ciInf h_mono (OrderBot.bddBelow _)
theorem tendsto_atTop_iInf (h_anti : Antitone f) : Tendsto f atTop (𝓝 (⨅ i, f i)) :=
tendsto_atTop_ciInf h_anti (OrderBot.bddBelow _)
end iInf
end
instance Prod.supConvergenceClass
[Preorder α] [Preorder β] [TopologicalSpace α] [TopologicalSpace β]
[SupConvergenceClass α] [SupConvergenceClass β] : SupConvergenceClass (α × β) := by
constructor
rintro ⟨a, b⟩ s h
rw [isLUB_prod, ← range_restrict, ← range_restrict] at h
have A : Tendsto (fun x : s => (x : α × β).1) atTop (𝓝 a) :=
tendsto_atTop_isLUB (monotone_fst.restrict s) h.1
have B : Tendsto (fun x : s => (x : α × β).2) atTop (𝓝 b) :=
tendsto_atTop_isLUB (monotone_snd.restrict s) h.2
convert A.prod_mk_nhds B
-- Porting note: previously required below to close
-- ext1 ⟨⟨x, y⟩, h⟩
-- rfl
instance [Preorder α] [Preorder β] [TopologicalSpace α] [TopologicalSpace β] [InfConvergenceClass α]
[InfConvergenceClass β] : InfConvergenceClass (α × β) :=
show InfConvergenceClass (αᵒᵈ × βᵒᵈ)ᵒᵈ from OrderDual.infConvergenceClass
instance Pi.supConvergenceClass
{ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)]
[∀ i, SupConvergenceClass (α i)] : SupConvergenceClass (∀ i, α i) := by
refine ⟨fun f s h => ?_⟩
simp only [isLUB_pi, ← range_restrict] at h
exact tendsto_pi_nhds.2 fun i => tendsto_atTop_isLUB ((monotone_eval _).restrict _) (h i)
instance Pi.infConvergenceClass
{ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)]
[∀ i, InfConvergenceClass (α i)] : InfConvergenceClass (∀ i, α i) :=
show InfConvergenceClass (∀ i, (α i)ᵒᵈ)ᵒᵈ from OrderDual.infConvergenceClass
instance Pi.supConvergenceClass' {ι : Type*} [Preorder α] [TopologicalSpace α]
[SupConvergenceClass α] : SupConvergenceClass (ι → α) :=
supConvergenceClass
instance Pi.infConvergenceClass' {ι : Type*} [Preorder α] [TopologicalSpace α]
[InfConvergenceClass α] : InfConvergenceClass (ι → α) :=
Pi.infConvergenceClass
theorem tendsto_of_monotone {ι α : Type*} [Preorder ι] [TopologicalSpace α]
[ConditionallyCompleteLinearOrder α] [OrderTopology α] {f : ι → α} (h_mono : Monotone f) :
Tendsto f atTop atTop ∨ ∃ l, Tendsto f atTop (𝓝 l) :=
if H : BddAbove (range f) then Or.inr ⟨_, tendsto_atTop_ciSup h_mono H⟩
else Or.inl <| tendsto_atTop_atTop_of_monotone' h_mono H
theorem tendsto_of_antitone {ι α : Type*} [Preorder ι] [TopologicalSpace α]
[ConditionallyCompleteLinearOrder α] [OrderTopology α] {f : ι → α} (h_mono : Antitone f) :
Tendsto f atTop atBot ∨ ∃ l, Tendsto f atTop (𝓝 l) :=
@tendsto_of_monotone ι αᵒᵈ _ _ _ _ _ h_mono
theorem tendsto_iff_tendsto_subseq_of_monotone {ι₁ ι₂ α : Type*} [SemilatticeSup ι₁] [Preorder ι₂]
[Nonempty ι₁] [TopologicalSpace α] [ConditionallyCompleteLinearOrder α] [OrderTopology α]
[NoMaxOrder α] {f : ι₂ → α} {φ : ι₁ → ι₂} {l : α} (hf : Monotone f)
(hg : Tendsto φ atTop atTop) : Tendsto f atTop (𝓝 l) ↔ Tendsto (f ∘ φ) atTop (𝓝 l) := by
constructor <;> intro h
· exact h.comp hg
· rcases tendsto_of_monotone hf with (h' | ⟨l', hl'⟩)
· exact (not_tendsto_atTop_of_tendsto_nhds h (h'.comp hg)).elim
· rwa [tendsto_nhds_unique h (hl'.comp hg)]
theorem tendsto_iff_tendsto_subseq_of_antitone {ι₁ ι₂ α : Type*} [SemilatticeSup ι₁] [Preorder ι₂]
[Nonempty ι₁] [TopologicalSpace α] [ConditionallyCompleteLinearOrder α] [OrderTopology α]
[NoMinOrder α] {f : ι₂ → α} {φ : ι₁ → ι₂} {l : α} (hf : Antitone f)
(hg : Tendsto φ atTop atTop) : Tendsto f atTop (𝓝 l) ↔ Tendsto (f ∘ φ) atTop (𝓝 l) :=
tendsto_iff_tendsto_subseq_of_monotone (α := αᵒᵈ) hf hg
/-! The next family of results, such as `isLUB_of_tendsto_atTop` and `iSup_eq_of_tendsto`, are
converses to the standard fact that bounded monotone functions converge. They state, that if a
monotone function `f` tends to `a` along `Filter.atTop`, then that value `a` is a least upper bound
for the range of `f`.
Related theorems above (`IsLUB.isLUB_of_tendsto`, `IsGLB.isGLB_of_tendsto` etc) cover the case
when `f x` tends to `a` as `x` tends to some point `b` in the domain. -/
theorem Monotone.ge_of_tendsto [TopologicalSpace α] [Preorder α] [OrderClosedTopology α]
[SemilatticeSup β] {f : β → α} {a : α} (hf : Monotone f) (ha : Tendsto f atTop (𝓝 a)) (b : β) :
f b ≤ a :=
haveI : Nonempty β := Nonempty.intro b
_root_.ge_of_tendsto ha ((eventually_ge_atTop b).mono fun _ hxy => hf hxy)
theorem Monotone.le_of_tendsto [TopologicalSpace α] [Preorder α] [OrderClosedTopology α]
[SemilatticeInf β] {f : β → α} {a : α} (hf : Monotone f) (ha : Tendsto f atBot (𝓝 a)) (b : β) :
a ≤ f b :=
hf.dual.ge_of_tendsto ha b
theorem Antitone.le_of_tendsto [TopologicalSpace α] [Preorder α] [OrderClosedTopology α]
[SemilatticeSup β] {f : β → α} {a : α} (hf : Antitone f) (ha : Tendsto f atTop (𝓝 a)) (b : β) :
a ≤ f b :=
hf.dual_right.ge_of_tendsto ha b
theorem Antitone.ge_of_tendsto [TopologicalSpace α] [Preorder α] [OrderClosedTopology α]
[SemilatticeInf β] {f : β → α} {a : α} (hf : Antitone f) (ha : Tendsto f atBot (𝓝 a)) (b : β) :
f b ≤ a :=
hf.dual_right.le_of_tendsto ha b
theorem isLUB_of_tendsto_atTop [TopologicalSpace α] [Preorder α] [OrderClosedTopology α]
[Nonempty β] [SemilatticeSup β] {f : β → α} {a : α} (hf : Monotone f)
(ha : Tendsto f atTop (𝓝 a)) : IsLUB (Set.range f) a := by
constructor
· rintro _ ⟨b, rfl⟩
exact hf.ge_of_tendsto ha b
· exact fun _ hb => le_of_tendsto' ha fun x => hb (Set.mem_range_self x)
theorem isGLB_of_tendsto_atBot [TopologicalSpace α] [Preorder α] [OrderClosedTopology α]
[Nonempty β] [SemilatticeInf β] {f : β → α} {a : α} (hf : Monotone f)
(ha : Tendsto f atBot (𝓝 a)) : IsGLB (Set.range f) a :=
@isLUB_of_tendsto_atTop αᵒᵈ βᵒᵈ _ _ _ _ _ _ _ hf.dual ha
theorem isLUB_of_tendsto_atBot [TopologicalSpace α] [Preorder α] [OrderClosedTopology α]
[Nonempty β] [SemilatticeInf β] {f : β → α} {a : α} (hf : Antitone f)
(ha : Tendsto f atBot (𝓝 a)) : IsLUB (Set.range f) a :=
@isLUB_of_tendsto_atTop α βᵒᵈ _ _ _ _ _ _ _ hf.dual_left ha
theorem isGLB_of_tendsto_atTop [TopologicalSpace α] [Preorder α] [OrderClosedTopology α]
[Nonempty β] [SemilatticeSup β] {f : β → α} {a : α} (hf : Antitone f)
(ha : Tendsto f atTop (𝓝 a)) : IsGLB (Set.range f) a :=
@isGLB_of_tendsto_atBot α βᵒᵈ _ _ _ _ _ _ _ hf.dual_left ha
theorem iSup_eq_of_tendsto {α β} [TopologicalSpace α] [CompleteLinearOrder α] [OrderTopology α]
[Nonempty β] [SemilatticeSup β] {f : β → α} {a : α} (hf : Monotone f) :
Tendsto f atTop (𝓝 a) → iSup f = a :=
tendsto_nhds_unique (tendsto_atTop_iSup hf)
theorem iInf_eq_of_tendsto {α} [TopologicalSpace α] [CompleteLinearOrder α] [OrderTopology α]
[Nonempty β] [SemilatticeSup β] {f : β → α} {a : α} (hf : Antitone f) :
Tendsto f atTop (𝓝 a) → iInf f = a :=
tendsto_nhds_unique (tendsto_atTop_iInf hf)
theorem iSup_eq_iSup_subseq_of_monotone {ι₁ ι₂ α : Type*} [Preorder ι₂] [CompleteLattice α]
{l : Filter ι₁} [l.NeBot] {f : ι₂ → α} {φ : ι₁ → ι₂} (hf : Monotone f)
(hφ : Tendsto φ l atTop) : ⨆ i, f i = ⨆ i, f (φ i) :=
le_antisymm
(iSup_mono' fun i =>
Exists.imp (fun j (hj : i ≤ φ j) => hf hj) (hφ.eventually <| eventually_ge_atTop i).exists)
(iSup_mono' fun i => ⟨φ i, le_rfl⟩)
theorem iSup_eq_iSup_subseq_of_antitone {ι₁ ι₂ α : Type*} [Preorder ι₂] [CompleteLattice α]
{l : Filter ι₁} [l.NeBot] {f : ι₂ → α} {φ : ι₁ → ι₂} (hf : Antitone f)
(hφ : Tendsto φ l atBot) : ⨆ i, f i = ⨆ i, f (φ i) :=
le_antisymm
(iSup_mono' fun i =>
Exists.imp (fun j (hj : φ j ≤ i) => hf hj) (hφ.eventually <| eventually_le_atBot i).exists)
(iSup_mono' fun i => ⟨φ i, le_rfl⟩)
theorem iInf_eq_iInf_subseq_of_monotone {ι₁ ι₂ α : Type*} [Preorder ι₂] [CompleteLattice α]
{l : Filter ι₁} [l.NeBot] {f : ι₂ → α} {φ : ι₁ → ι₂} (hf : Monotone f)
(hφ : Tendsto φ l atBot) : ⨅ i, f i = ⨅ i, f (φ i) :=
iSup_eq_iSup_subseq_of_monotone hf.dual hφ
theorem iInf_eq_iInf_subseq_of_antitone {ι₁ ι₂ α : Type*} [Preorder ι₂] [CompleteLattice α]
{l : Filter ι₁} [l.NeBot] {f : ι₂ → α} {φ : ι₁ → ι₂} (hf : Antitone f)
(hφ : Tendsto φ l atTop) : ⨅ i, f i = ⨅ i, f (φ i) :=
iSup_eq_iSup_subseq_of_antitone hf.dual hφ
|
Topology\Order\NhdsSet.lean | /-
Copyright (c) 2023 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Topology.Order.Basic
/-!
# Set neighborhoods of intervals
In this file we prove basic theorems about `𝓝ˢ s`,
where `s` is one of the intervals
`Set.Ici`, `Set.Iic`, `Set.Ioi`, `Set.Iio`, `Set.Ico`, `Set.Ioc`, `Set.Ioo`, and `Set.Icc`.
First, we prove lemmas in terms of filter equalities.
Then we prove lemmas about `s ∈ 𝓝ˢ t`, where both `s` and `t` are intervals.
Finally, we prove a few lemmas about filter bases of `𝓝ˢ (Iic a)` and `𝓝ˢ (Ici a)`.
-/
open Set Filter OrderDual
open scoped Topology
section OrderClosedTopology
variable {α : Type*} [LinearOrder α] [TopologicalSpace α] [OrderClosedTopology α] {a b c d : α}
/-!
# Formulae for `𝓝ˢ` of intervals
-/
@[simp] theorem nhdsSet_Ioi : 𝓝ˢ (Ioi a) = 𝓟 (Ioi a) := isOpen_Ioi.nhdsSet_eq
@[simp] theorem nhdsSet_Iio : 𝓝ˢ (Iio a) = 𝓟 (Iio a) := isOpen_Iio.nhdsSet_eq
@[simp] theorem nhdsSet_Ioo : 𝓝ˢ (Ioo a b) = 𝓟 (Ioo a b) := isOpen_Ioo.nhdsSet_eq
theorem nhdsSet_Ici : 𝓝ˢ (Ici a) = 𝓝 a ⊔ 𝓟 (Ioi a) := by
rw [← Ioi_insert, nhdsSet_insert, nhdsSet_Ioi]
theorem nhdsSet_Iic : 𝓝ˢ (Iic a) = 𝓝 a ⊔ 𝓟 (Iio a) := nhdsSet_Ici (α := αᵒᵈ)
theorem nhdsSet_Ico (h : a < b) : 𝓝ˢ (Ico a b) = 𝓝 a ⊔ 𝓟 (Ioo a b) := by
rw [← Ioo_insert_left h, nhdsSet_insert, nhdsSet_Ioo]
theorem nhdsSet_Ioc (h : a < b) : 𝓝ˢ (Ioc a b) = 𝓝 b ⊔ 𝓟 (Ioo a b) := by
rw [← Ioo_insert_right h, nhdsSet_insert, nhdsSet_Ioo]
theorem nhdsSet_Icc (h : a ≤ b) : 𝓝ˢ (Icc a b) = 𝓝 a ⊔ 𝓝 b ⊔ 𝓟 (Ioo a b) := by
rcases h.eq_or_lt with rfl | hlt
· simp
· rw [← Ioc_insert_left h, nhdsSet_insert, nhdsSet_Ioc hlt, sup_assoc]
/-!
### Lemmas about `Ixi _ ∈ 𝓝ˢ (Set.Ici _)`
-/
@[simp]
theorem Ioi_mem_nhdsSet_Ici_iff : Ioi a ∈ 𝓝ˢ (Ici b) ↔ a < b := by
rw [isOpen_Ioi.mem_nhdsSet, Ici_subset_Ioi]
alias ⟨_, Ioi_mem_nhdsSet_Ici⟩ := Ioi_mem_nhdsSet_Ici_iff
theorem Ici_mem_nhdsSet_Ici (h : a < b) : Ici a ∈ 𝓝ˢ (Ici b) :=
mem_of_superset (Ioi_mem_nhdsSet_Ici h) Ioi_subset_Ici_self
/-!
### Lemmas about `Iix _ ∈ 𝓝ˢ (Set.Iic _)`
-/
theorem Iio_mem_nhdsSet_Iic_iff : Iio b ∈ 𝓝ˢ (Iic a) ↔ a < b :=
Ioi_mem_nhdsSet_Ici_iff (α := αᵒᵈ)
alias ⟨_, Iio_mem_nhdsSet_Iic⟩ := Iio_mem_nhdsSet_Iic_iff
theorem Iic_mem_nhdsSet_Iic (h : a < b) : Iic b ∈ 𝓝ˢ (Iic a) :=
Ici_mem_nhdsSet_Ici (α := αᵒᵈ) h
/-!
### Lemmas about `Ixx _ ?_ ∈ 𝓝ˢ (Set.Icc _ _)`
-/
theorem Ioi_mem_nhdsSet_Icc (h : a < b) : Ioi a ∈ 𝓝ˢ (Icc b c) :=
nhdsSet_mono Icc_subset_Ici_self <| Ioi_mem_nhdsSet_Ici h
theorem Ici_mem_nhdsSet_Icc (h : a < b) : Ici a ∈ 𝓝ˢ (Icc b c) :=
mem_of_superset (Ioi_mem_nhdsSet_Icc h) Ioi_subset_Ici_self
theorem Iio_mem_nhdsSet_Icc (h : b < c) : Iio c ∈ 𝓝ˢ (Icc a b) :=
nhdsSet_mono Icc_subset_Iic_self <| Iio_mem_nhdsSet_Iic h
theorem Iic_mem_nhdsSet_Icc (h : b < c) : Iic c ∈ 𝓝ˢ (Icc a b) :=
mem_of_superset (Iio_mem_nhdsSet_Icc h) Iio_subset_Iic_self
theorem Ioo_mem_nhdsSet_Icc (h : a < b) (h' : c < d) : Ioo a d ∈ 𝓝ˢ (Icc b c) :=
inter_mem (Ioi_mem_nhdsSet_Icc h) (Iio_mem_nhdsSet_Icc h')
theorem Ico_mem_nhdsSet_Icc (h : a < b) (h' : c < d) : Ico a d ∈ 𝓝ˢ (Icc b c) :=
inter_mem (Ici_mem_nhdsSet_Icc h) (Iio_mem_nhdsSet_Icc h')
theorem Ioc_mem_nhdsSet_Icc (h : a < b) (h' : c < d) : Ioc a d ∈ 𝓝ˢ (Icc b c) :=
inter_mem (Ioi_mem_nhdsSet_Icc h) (Iic_mem_nhdsSet_Icc h')
theorem Icc_mem_nhdsSet_Icc (h : a < b) (h' : c < d) : Icc a d ∈ 𝓝ˢ (Icc b c) :=
inter_mem (Ici_mem_nhdsSet_Icc h) (Iic_mem_nhdsSet_Icc h')
/-!
### Lemmas about `Ixx _ ?_ ∈ 𝓝ˢ (Set.Ico _ _)`
-/
theorem Ici_mem_nhdsSet_Ico (h : a < b) : Ici a ∈ 𝓝ˢ (Ico b c) :=
nhdsSet_mono Ico_subset_Icc_self <| Ici_mem_nhdsSet_Icc h
theorem Ioi_mem_nhdsSet_Ico (h : a < b) : Ioi a ∈ 𝓝ˢ (Ico b c) :=
nhdsSet_mono Ico_subset_Icc_self <| Ioi_mem_nhdsSet_Icc h
theorem Iio_mem_nhdsSet_Ico (h : b ≤ c) : Iio c ∈ 𝓝ˢ (Ico a b) :=
nhdsSet_mono Ico_subset_Iio_self <| by simpa
theorem Iic_mem_nhdsSet_Ico (h : b ≤ c) : Iic c ∈ 𝓝ˢ (Ico a b) :=
mem_of_superset (Iio_mem_nhdsSet_Ico h) Iio_subset_Iic_self
theorem Ioo_mem_nhdsSet_Ico (h : a < b) (h' : c ≤ d) : Ioo a d ∈ 𝓝ˢ (Ico b c) :=
inter_mem (Ioi_mem_nhdsSet_Ico h) (Iio_mem_nhdsSet_Ico h')
theorem Icc_mem_nhdsSet_Ico (h : a < b) (h' : c ≤ d) : Icc a d ∈ 𝓝ˢ (Ico b c) :=
inter_mem (Ici_mem_nhdsSet_Ico h) (Iic_mem_nhdsSet_Ico h')
theorem Ioc_mem_nhdsSet_Ico (h : a < b) (h' : c ≤ d) : Ioc a d ∈ 𝓝ˢ (Ico b c) :=
inter_mem (Ioi_mem_nhdsSet_Ico h) (Iic_mem_nhdsSet_Ico h')
theorem Ico_mem_nhdsSet_Ico (h : a < b) (h' : c ≤ d) : Ico a d ∈ 𝓝ˢ (Ico b c) :=
inter_mem (Ici_mem_nhdsSet_Ico h) (Iio_mem_nhdsSet_Ico h')
/-!
### Lemmas about `Ixx _ ?_ ∈ 𝓝ˢ (Set.Ioc _ _)`
-/
theorem Ioi_mem_nhdsSet_Ioc (h : a ≤ b) : Ioi a ∈ 𝓝ˢ (Ioc b c) :=
nhdsSet_mono Ioc_subset_Ioi_self <| by simpa
theorem Iio_mem_nhdsSet_Ioc (h : b < c) : Iio c ∈ 𝓝ˢ (Ioc a b) :=
nhdsSet_mono Ioc_subset_Icc_self <| Iio_mem_nhdsSet_Icc h
theorem Ici_mem_nhdsSet_Ioc (h : a ≤ b) : Ici a ∈ 𝓝ˢ (Ioc b c) :=
mem_of_superset (Ioi_mem_nhdsSet_Ioc h) Ioi_subset_Ici_self
theorem Iic_mem_nhdsSet_Ioc (h : b < c) : Iic c ∈ 𝓝ˢ (Ioc a b) :=
nhdsSet_mono Ioc_subset_Icc_self <| Iic_mem_nhdsSet_Icc h
theorem Ioo_mem_nhdsSet_Ioc (h : a ≤ b) (h' : c < d) : Ioo a d ∈ 𝓝ˢ (Ioc b c) :=
inter_mem (Ioi_mem_nhdsSet_Ioc h) (Iio_mem_nhdsSet_Ioc h')
theorem Icc_mem_nhdsSet_Ioc (h : a ≤ b) (h' : c < d) : Icc a d ∈ 𝓝ˢ (Ioc b c) :=
inter_mem (Ici_mem_nhdsSet_Ioc h) (Iic_mem_nhdsSet_Ioc h')
theorem Ioc_mem_nhdsSet_Ioc (h : a ≤ b) (h' : c < d) : Ioc a d ∈ 𝓝ˢ (Ioc b c) :=
inter_mem (Ioi_mem_nhdsSet_Ioc h) (Iic_mem_nhdsSet_Ioc h')
theorem Ico_mem_nhdsSet_Ioc (h : a ≤ b) (h' : c < d) : Ico a d ∈ 𝓝ˢ (Ioc b c) :=
inter_mem (Ici_mem_nhdsSet_Ioc h) (Iio_mem_nhdsSet_Ioc h')
end OrderClosedTopology
/-!
### Filter bases of `𝓝ˢ (Iic a)` and `𝓝ˢ (Ici a)`
-/
variable {α : Type*} [LinearOrder α] [TopologicalSpace α] [OrderTopology α]
theorem hasBasis_nhdsSet_Iic_Iio (a : α) [h : Nonempty (Ioi a)] :
HasBasis (𝓝ˢ (Iic a)) (a < ·) Iio := by
refine ⟨fun s ↦ ⟨fun hs ↦ ?_, fun ⟨b, hab, hb⟩ ↦ mem_of_superset (Iio_mem_nhdsSet_Iic hab) hb⟩⟩
rw [nhdsSet_Iic, mem_sup, mem_principal] at hs
rcases exists_Ico_subset_of_mem_nhds hs.1 (Set.nonempty_coe_sort.1 h) with ⟨b, hab, hbs⟩
exact ⟨b, hab, Iio_subset_Iio_union_Ico.trans (union_subset hs.2 hbs)⟩
theorem hasBasis_nhdsSet_Iic_Iic (a : α) [NeBot (𝓝[>] a)] :
HasBasis (𝓝ˢ (Iic a)) (a < ·) Iic := by
have : Nonempty (Ioi a) :=
(Filter.nonempty_of_mem (self_mem_nhdsWithin : Ioi a ∈ 𝓝[>] a)).to_subtype
refine (hasBasis_nhdsSet_Iic_Iio _).to_hasBasis
(fun c hc ↦ ?_) (fun _ h ↦ ⟨_, h, Iio_subset_Iic_self⟩)
simpa only [Iic_subset_Iio] using (Filter.nonempty_of_mem <| Ioo_mem_nhdsWithin_Ioi' hc)
@[simp]
theorem Iic_mem_nhdsSet_Iic_iff {a b : α} [NeBot (𝓝[>] b)] : Iic a ∈ 𝓝ˢ (Iic b) ↔ b < a :=
(hasBasis_nhdsSet_Iic_Iic b).mem_iff.trans
⟨fun ⟨_c, hbc, hca⟩ ↦ hbc.trans_le (Iic_subset_Iic.1 hca), fun h ↦ ⟨_, h, Subset.rfl⟩⟩
theorem hasBasis_nhdsSet_Ici_Ioi (a : α) [Nonempty (Iio a)] :
HasBasis (𝓝ˢ (Ici a)) (· < a) Ioi :=
have : Nonempty (Ioi (toDual a)) := ‹_›; hasBasis_nhdsSet_Iic_Iio (toDual a)
theorem hasBasis_nhdsSet_Ici_Ici (a : α) [NeBot (𝓝[<] a)] :
HasBasis (𝓝ˢ (Ici a)) (· < a) Ici :=
have : NeBot (𝓝[>] (toDual a)) := ‹_›; hasBasis_nhdsSet_Iic_Iic (toDual a)
@[simp]
theorem Ici_mem_nhdsSet_Ici_iff {a b : α} [NeBot (𝓝[<] b)] : Ici a ∈ 𝓝ˢ (Ici b) ↔ a < b :=
have : NeBot (𝓝[>] (toDual b)) := ‹_›; Iic_mem_nhdsSet_Iic_iff (a := toDual a) (b := toDual b)
|
Topology\Order\OrderClosed.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, Yury Kudryashov
-/
import Mathlib.Topology.Separation
/-!
# Order-closed topologies
In this file we introduce 3 typeclass mixins that relate topology and order structures:
- `ClosedIicTopology` says that all the intervals $(-∞, a]$ (formally, `Set.Iic a`)
are closed sets;
- `ClosedIciTopoplogy` says that all the intervals $[a, +∞)$ (formally, `Set.Ici a`)
are closed sets;
- `OrderClosedTopology` says that the set of points `(x, y)` such that `x ≤ y`
is closed in the product topology.
The last predicate implies the first two.
We prove many basic properties of such topologies.
## Main statements
This file contains the proofs of the following facts.
For exact requirements
(`OrderClosedTopology` vs `ClosedIciTopoplogy` vs `ClosedIicTopology,
`Preorder` vs `PartialOrder` vs `LinearOrder` etc)
see their statements.
### Open / closed sets
* `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open;
* `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open;
* `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed;
* `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed;
* `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}`
and `{x | f x < g x}` are included by `{x | f x = g x}`;
### Convergence and inequalities
* `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually
`f x ≤ g x`, then `a ≤ b`
* `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b`
(resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions
that assume the inequalities to hold for all `x`.
### Min, max, `sSup` and `sInf`
* `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is
continuous.
* `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise
`min`/`max` tend to `min a b` and `max a b`, respectively.
-/
open Set Filter
open OrderDual (toDual)
open scoped Topology
universe u v w
variable {α : Type u} {β : Type v} {γ : Type w}
/-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is
closed for all `a : α`. -/
class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where
/-- For any `a`, the set `(-∞, a]` is closed. -/
isClosed_Iic (a : α) : IsClosed (Iic a)
/-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is
closed for all `a : α`. -/
class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where
/-- For any `a`, the set `[a, +∞)` is closed. -/
isClosed_Ici (a : α) : IsClosed (Ici a)
/-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the
set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin.
This property is satisfied for the order topology on a linear order, but it can be satisfied more
generally, and suffices to derive many interesting properties relating order and topology. -/
class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where
/-- The set `{ (x, y) | x ≤ y }` is a closed set. -/
isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 }
instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h
instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h
theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) :
Dense (OrderDual.ofDual ⁻¹' s) :=
hs
section General
variable [TopologicalSpace α] [Preorder α] {s : Set α}
protected lemma BddAbove.of_closure : BddAbove (closure s) → BddAbove s :=
BddAbove.mono subset_closure
protected lemma BddBelow.of_closure : BddBelow (closure s) → BddBelow s :=
BddBelow.mono subset_closure
end General
section ClosedIicTopology
section Preorder
variable [TopologicalSpace α] [Preorder α] [ClosedIicTopology α] {f : β → α} {a b : α} {s : Set α}
theorem isClosed_Iic : IsClosed (Iic a) :=
ClosedIicTopology.isClosed_Iic a
@[deprecated isClosed_Iic (since := "2024-02-15")]
lemma ClosedIicTopology.isClosed_le' (a : α) : IsClosed {x | x ≤ a} := isClosed_Iic a
export ClosedIicTopology (isClosed_le')
instance : ClosedIciTopology αᵒᵈ where
isClosed_Ici _ := isClosed_Iic (α := α)
@[simp]
theorem closure_Iic (a : α) : closure (Iic a) = Iic a :=
isClosed_Iic.closure_eq
theorem le_of_tendsto_of_frequently {x : Filter β} (lim : Tendsto f x (𝓝 a))
(h : ∃ᶠ c in x, f c ≤ b) : a ≤ b :=
isClosed_Iic.mem_of_frequently_of_tendsto h lim
theorem le_of_tendsto {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a))
(h : ∀ᶠ c in x, f c ≤ b) : a ≤ b :=
isClosed_Iic.mem_of_tendsto lim h
theorem le_of_tendsto' {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a))
(h : ∀ c, f c ≤ b) : a ≤ b :=
le_of_tendsto lim (eventually_of_forall h)
@[simp] lemma upperBounds_closure (s : Set α) : upperBounds (closure s : Set α) = upperBounds s :=
ext fun a ↦ by simp_rw [mem_upperBounds_iff_subset_Iic, isClosed_Iic.closure_subset_iff]
@[simp] lemma bddAbove_closure : BddAbove (closure s) ↔ BddAbove s := by
simp_rw [BddAbove, upperBounds_closure]
protected alias ⟨_, BddAbove.closure⟩ := bddAbove_closure
@[simp]
theorem disjoint_nhds_atBot_iff : Disjoint (𝓝 a) atBot ↔ ¬IsBot a := by
constructor
· intro hd hbot
rw [hbot.atBot_eq, disjoint_principal_right] at hd
exact mem_of_mem_nhds hd le_rfl
· simp only [IsBot, not_forall]
rintro ⟨b, hb⟩
refine disjoint_of_disjoint_of_mem disjoint_compl_left ?_ (Iic_mem_atBot b)
exact isClosed_Iic.isOpen_compl.mem_nhds hb
end Preorder
section NoBotOrder
variable [Preorder α] [NoBotOrder α] [TopologicalSpace α] [ClosedIicTopology α] {a : α}
{l : Filter β} [NeBot l] {f : β → α}
theorem disjoint_nhds_atBot (a : α) : Disjoint (𝓝 a) atBot := by simp
@[simp]
theorem inf_nhds_atBot (a : α) : 𝓝 a ⊓ atBot = ⊥ := (disjoint_nhds_atBot a).eq_bot
theorem not_tendsto_nhds_of_tendsto_atBot (hf : Tendsto f l atBot) (a : α) : ¬Tendsto f l (𝓝 a) :=
hf.not_tendsto (disjoint_nhds_atBot a).symm
theorem not_tendsto_atBot_of_tendsto_nhds (hf : Tendsto f l (𝓝 a)) : ¬Tendsto f l atBot :=
hf.not_tendsto (disjoint_nhds_atBot a)
end NoBotOrder
section LinearOrder
variable [TopologicalSpace α] [LinearOrder α] [ClosedIicTopology α] [TopologicalSpace β]
{a b c : α} {f : α → β}
theorem isOpen_Ioi : IsOpen (Ioi a) := by
rw [← compl_Iic]
exact isClosed_Iic.isOpen_compl
@[simp]
theorem interior_Ioi : interior (Ioi a) = Ioi a :=
isOpen_Ioi.interior_eq
theorem Ioi_mem_nhds (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h
theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab
theorem Ici_mem_nhds (h : a < b) : Ici a ∈ 𝓝 b :=
mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self
theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab
theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v)
(h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a :=
h.eventually <| eventually_gt_nhds hv
theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v)
(h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a :=
h.eventually <| eventually_ge_nhds hv
protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) :
∃ y ∈ s, x < y :=
hs.exists_mem_open isOpen_Ioi (exists_gt x)
protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) :
∃ y ∈ s, x ≤ y :=
(hs.exists_gt x).imp fun _ h ↦ ⟨h.1, h.2.le⟩
theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) :
∃ y ∈ s, x ≤ y := by
by_cases hx : IsTop x
· exact ⟨x, htop x hx, le_rfl⟩
· simp only [IsTop, not_forall, not_le] at hx
rcases hs.exists_mem_open isOpen_Ioi hx with ⟨y, hys, hy : x < y⟩
exact ⟨y, hys, hy.le⟩
/-!
### Left neighborhoods on a `ClosedIicTopology`
Limits to the left of real functions are defined in terms of neighborhoods to the left,
either open or closed, i.e., members of `𝓝[<] a` and `𝓝[≤] a`.
Here we prove that all left-neighborhoods of a point are equal,
and we prove other useful characterizations which require the stronger hypothesis `OrderTopology α`
in another file.
-/
/-!
#### Point excluded
-/
-- Porting note (#11215): TODO: swap `'`?
theorem Ioo_mem_nhdsWithin_Iio' (H : a < b) : Ioo a b ∈ 𝓝[<] b := by
simpa only [← Iio_inter_Ioi] using inter_mem_nhdsWithin _ (Ioi_mem_nhds H)
theorem Ioo_mem_nhdsWithin_Iio (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b :=
mem_of_superset (Ioo_mem_nhdsWithin_Iio' H.1) <| Ioo_subset_Ioo_right H.2
theorem CovBy.nhdsWithin_Iio (h : a ⋖ b) : 𝓝[<] b = ⊥ :=
empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1
theorem Ico_mem_nhdsWithin_Iio (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b :=
mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self
-- Porting note (#11215): TODO: swap `'`?
-- Porting note (#11215): TODO: swap `'`?
theorem Ico_mem_nhdsWithin_Iio' (H : a < b) : Ico a b ∈ 𝓝[<] b :=
Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩
theorem Ioc_mem_nhdsWithin_Iio (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b :=
mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self
-- Porting note (#11215): TODO: swap `'`?
theorem Ioc_mem_nhdsWithin_Iio' (H : a < b) : Ioc a b ∈ 𝓝[<] b :=
Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩
theorem Icc_mem_nhdsWithin_Iio (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b :=
mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self
theorem Icc_mem_nhdsWithin_Iio' (H : a < b) : Icc a b ∈ 𝓝[<] b :=
Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩
@[simp]
theorem nhdsWithin_Ico_eq_nhdsWithin_Iio (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b :=
nhdsWithin_inter_of_mem <| nhdsWithin_le_nhds <| Ici_mem_nhds h
@[simp]
theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b :=
nhdsWithin_inter_of_mem <| nhdsWithin_le_nhds <| Ioi_mem_nhds h
@[simp]
theorem continuousWithinAt_Ico_iff_Iio (h : a < b) :
ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by
simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h]
@[simp]
theorem continuousWithinAt_Ioo_iff_Iio (h : a < b) :
ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by
simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h]
/-!
#### Point included
-/
theorem Ioc_mem_nhdsWithin_Iic' (H : a < b) : Ioc a b ∈ 𝓝[≤] b :=
inter_mem (nhdsWithin_le_nhds <| Ioi_mem_nhds H) self_mem_nhdsWithin
theorem Ioo_mem_nhdsWithin_Iic (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b :=
mem_of_superset (Ioc_mem_nhdsWithin_Iic' H.1) <| Ioc_subset_Ioo_right H.2
theorem Ico_mem_nhdsWithin_Iic (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b :=
mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self
theorem Ioc_mem_nhdsWithin_Iic (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b :=
mem_of_superset (Ioc_mem_nhdsWithin_Iic' H.1) <| Ioc_subset_Ioc_right H.2
theorem Icc_mem_nhdsWithin_Iic (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b :=
mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self
theorem Icc_mem_nhdsWithin_Iic' (H : a < b) : Icc a b ∈ 𝓝[≤] b :=
Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩
@[simp]
theorem nhdsWithin_Icc_eq_nhdsWithin_Iic (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b :=
nhdsWithin_inter_of_mem <| nhdsWithin_le_nhds <| Ici_mem_nhds h
@[simp]
theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b :=
nhdsWithin_inter_of_mem <| nhdsWithin_le_nhds <| Ioi_mem_nhds h
@[simp]
theorem continuousWithinAt_Icc_iff_Iic (h : a < b) :
ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by
simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h]
@[simp]
theorem continuousWithinAt_Ioc_iff_Iic (h : a < b) :
ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by
simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h]
end LinearOrder
end ClosedIicTopology
section ClosedIciTopology
section Preorder
variable [TopologicalSpace α] [Preorder α] [ClosedIciTopology α] {f : β → α} {a b : α} {s : Set α}
theorem isClosed_Ici {a : α} : IsClosed (Ici a) :=
ClosedIciTopology.isClosed_Ici a
@[deprecated (since := "2024-02-15")]
lemma ClosedIciTopology.isClosed_ge' (a : α) : IsClosed {x | a ≤ x} := isClosed_Ici a
export ClosedIciTopology (isClosed_ge')
instance : ClosedIicTopology αᵒᵈ where
isClosed_Iic _ := isClosed_Ici (α := α)
@[simp]
theorem closure_Ici (a : α) : closure (Ici a) = Ici a :=
isClosed_Ici.closure_eq
lemma ge_of_tendsto_of_frequently {x : Filter β} (lim : Tendsto f x (𝓝 a))
(h : ∃ᶠ c in x, b ≤ f c) : b ≤ a :=
isClosed_Ici.mem_of_frequently_of_tendsto h lim
theorem ge_of_tendsto {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a))
(h : ∀ᶠ c in x, b ≤ f c) : b ≤ a :=
isClosed_Ici.mem_of_tendsto lim h
theorem ge_of_tendsto' {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a))
(h : ∀ c, b ≤ f c) : b ≤ a :=
ge_of_tendsto lim (eventually_of_forall h)
@[simp] lemma lowerBounds_closure (s : Set α) : lowerBounds (closure s : Set α) = lowerBounds s :=
ext fun a ↦ by simp_rw [mem_lowerBounds_iff_subset_Ici, isClosed_Ici.closure_subset_iff]
@[simp] lemma bddBelow_closure : BddBelow (closure s) ↔ BddBelow s := by
simp_rw [BddBelow, lowerBounds_closure]
protected alias ⟨_, BddBelow.closure⟩ := bddBelow_closure
@[simp]
theorem disjoint_nhds_atTop_iff : Disjoint (𝓝 a) atTop ↔ ¬IsTop a :=
disjoint_nhds_atBot_iff (α := αᵒᵈ)
end Preorder
section NoTopOrder
variable [Preorder α] [NoTopOrder α] [TopologicalSpace α] [ClosedIciTopology α] {a : α}
{l : Filter β} [NeBot l] {f : β → α}
theorem disjoint_nhds_atTop (a : α) : Disjoint (𝓝 a) atTop := disjoint_nhds_atBot (toDual a)
@[simp]
theorem inf_nhds_atTop (a : α) : 𝓝 a ⊓ atTop = ⊥ := (disjoint_nhds_atTop a).eq_bot
theorem not_tendsto_nhds_of_tendsto_atTop (hf : Tendsto f l atTop) (a : α) : ¬Tendsto f l (𝓝 a) :=
hf.not_tendsto (disjoint_nhds_atTop a).symm
theorem not_tendsto_atTop_of_tendsto_nhds (hf : Tendsto f l (𝓝 a)) : ¬Tendsto f l atTop :=
hf.not_tendsto (disjoint_nhds_atTop a)
end NoTopOrder
section LinearOrder
variable [TopologicalSpace α] [LinearOrder α] [ClosedIciTopology α] [TopologicalSpace β]
{a b c : α} {f : α → β}
theorem isOpen_Iio : IsOpen (Iio a) := isOpen_Ioi (α := αᵒᵈ)
@[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq
theorem Iio_mem_nhds (h : a < b) : Iio b ∈ 𝓝 a := isOpen_Iio.mem_nhds h
theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab
theorem Iic_mem_nhds (h : a < b) : Iic b ∈ 𝓝 a :=
mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self
theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab
theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u)
(h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u :=
h.eventually <| eventually_lt_nhds hv
theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u)
(h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u :=
h.eventually <| eventually_le_nhds hv
protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) :
∃ y ∈ s, y < x :=
hs.orderDual.exists_gt x
protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) :
∃ y ∈ s, y ≤ x :=
hs.orderDual.exists_ge x
theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) :
∃ y ∈ s, y ≤ x :=
hs.orderDual.exists_ge' hbot x
/-!
### Right neighborhoods on a `ClosedIciTopology`
Limits to the right of real functions are defined in terms of neighborhoods to the right,
either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a`.
Here we prove that all right-neighborhoods of a point are equal,
and we prove other useful characterizations which require the stronger hypothesis `OrderTopology α`
in another file.
-/
/-!
#### Point excluded
-/
theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b :=
mem_nhdsWithin.2
⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩
-- Porting note (#11215): TODO: swap `'`?
theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a :=
Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩
theorem CovBy.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ :=
empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1
theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b :=
mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self
-- Porting note (#11215): TODO: swap `'`?
theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a :=
Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩
theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b :=
mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self
-- Porting note (#11215): TODO: swap `'`?
theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a :=
Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩
theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b :=
mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self
-- Porting note (#11215): TODO: swap `'`?
theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a :=
Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩
@[simp]
theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a :=
nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h
@[simp]
theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a :=
nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h
@[simp]
theorem continuousWithinAt_Ioc_iff_Ioi (h : a < b) :
ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by
simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h]
@[simp]
theorem continuousWithinAt_Ioo_iff_Ioi (h : a < b) :
ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by
simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h]
/-!
### Point included
-/
theorem Ico_mem_nhdsWithin_Ici' (H : a < b) : Ico a b ∈ 𝓝[≥] a :=
inter_mem_nhdsWithin _ <| Iio_mem_nhds H
theorem Ico_mem_nhdsWithin_Ici (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b :=
mem_of_superset (Ico_mem_nhdsWithin_Ici' H.2) <| Ico_subset_Ico_left H.1
theorem Ioo_mem_nhdsWithin_Ici (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b :=
mem_of_superset (Ico_mem_nhdsWithin_Ici' H.2) <| Ico_subset_Ioo_left H.1
theorem Ioc_mem_nhdsWithin_Ici (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b :=
mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self
theorem Icc_mem_nhdsWithin_Ici (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b :=
mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self
theorem Icc_mem_nhdsWithin_Ici' (H : a < b) : Icc a b ∈ 𝓝[≥] a :=
Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩
@[simp]
theorem nhdsWithin_Icc_eq_nhdsWithin_Ici (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a :=
nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h
@[simp]
theorem nhdsWithin_Ico_eq_nhdsWithin_Ici (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a :=
nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h
@[simp]
theorem continuousWithinAt_Icc_iff_Ici (h : a < b) :
ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by
simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h]
@[simp]
theorem continuousWithinAt_Ico_iff_Ici (h : a < b) :
ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by
simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h]
end LinearOrder
end ClosedIciTopology
section OrderClosedTopology
section Preorder
variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α]
namespace Subtype
-- todo: add `OrderEmbedding.orderClosedTopology`
instance {p : α → Prop} : OrderClosedTopology (Subtype p) :=
have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) :=
continuous_subtype_val.prod_map continuous_subtype_val
OrderClosedTopology.mk (t.isClosed_le'.preimage this)
end Subtype
theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } :=
t.isClosed_le'
theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) :
IsClosed { b | f b ≤ g b } :=
continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod
instance : ClosedIicTopology α where
isClosed_Iic _ := isClosed_le continuous_id continuous_const
instance : ClosedIciTopology α where
isClosed_Ici _ := isClosed_le continuous_const continuous_id
instance : OrderClosedTopology αᵒᵈ :=
⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩
theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) :=
IsClosed.inter isClosed_Ici isClosed_Iic
@[simp]
theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b :=
isClosed_Icc.closure_eq
theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b]
(hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ :=
have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg
show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h
alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto
theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b]
(hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ :=
le_of_tendsto_of_tendsto hf hg (eventually_of_forall h)
@[simp]
theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) :
closure { b | f b ≤ g b } = { b | f b ≤ g b } :=
(isClosed_le hf hg).closure_eq
theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f)
(hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } :=
(closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg
theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β}
(hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x)
(h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x :=
show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from
OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h)
/-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`,
then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/
theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s)
(hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) :=
(hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le'
theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x)
(hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) :
f x ≤ g x :=
have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩
(closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2
theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s)
(hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } :=
(hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd
theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s)
(hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } :=
(hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl)
end Preorder
section PartialOrder
variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α]
-- see Note [lower instance priority]
instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α :=
t2_iff_isClosed_diagonal.2 <| by
simpa only [diagonal, le_antisymm_iff] using
t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst)
end PartialOrder
section LinearOrder
variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α]
theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) :
IsOpen { b | f b < g b } := by
simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl
theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } :=
isOpen_lt continuous_fst continuous_snd
variable {a b : α}
theorem isOpen_Ioo : IsOpen (Ioo a b) :=
IsOpen.inter isOpen_Ioi isOpen_Iio
@[simp]
theorem interior_Ioo : interior (Ioo a b) = Ioo a b :=
isOpen_Ioo.interior_eq
theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by
simp only [interior_Ioo, subset_closure]
theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x :=
IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩
theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x :=
mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self
theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x :=
mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self
theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x :=
mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self
variable [TopologicalSpace γ]
end LinearOrder
section LinearOrder
variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α}
section
variable [TopologicalSpace β]
theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) :
{ b | f b < g b } ⊆ interior { b | f b ≤ g b } :=
(interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg
theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) :
frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by
rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg]
rintro b ⟨hb₁, hb₂⟩
refine le_antisymm hb₁ (closure_lt_subset_le hg hf ?_)
convert hb₂ using 2; simp only [not_le.symm]; rfl
theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} :=
frontier_le_subset_eq (@continuous_id α _) continuous_const
theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} :=
frontier_Iic_subset (α := αᵒᵈ) _
theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) :
frontier { b | f b < g b } ⊆ { b | f b = g b } := by
simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf
theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ}
(hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x })
(hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) :
Continuous fun x => if f x ≤ g x then f' x else g' x := by
refine continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) ?_ (hg'.mono ?_)
· rwa [(isClosed_le hf hg).closure_eq]
· simp only [not_le]
exact closure_lt_subset_le hg hf
theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ}
(hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g)
(hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x :=
continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg
theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y))
(hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x :=
let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi
(hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ =>
h _ h₁ _ h₂
nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀)
(hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x :=
hf.eventually_lt hg hfg
@[continuity, fun_prop]
protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) :
Continuous fun b => min (f b) (g b) := by
simp only [min_def]
exact hf.if_le hg hf hg fun x => id
@[continuity, fun_prop]
protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) :
Continuous fun b => max (f b) (g b) :=
Continuous.min (α := αᵒᵈ) hf hg
end
theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 :=
continuous_fst.min continuous_snd
theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 :=
continuous_fst.max continuous_snd
protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁))
(hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) :=
(continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg)
protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁))
(hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) :=
(continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg)
protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) :
Tendsto (fun i => max a (f i)) l (𝓝 a) := by
convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h
simp
protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) :
Tendsto (fun i => max (f i) a) l (𝓝 a) := by
simp_rw [max_comm _ a]
exact h.max_right
theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) :
Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by
obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h
exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩
theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) :
Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by
simp_rw [max_comm _ a]
exact Filter.tendsto_nhds_max_right h
theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) :
Tendsto (fun i => min a (f i)) l (𝓝 a) :=
Filter.Tendsto.max_right (α := αᵒᵈ) h
theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) :
Tendsto (fun i => min (f i) a) l (𝓝 a) :=
Filter.Tendsto.max_left (α := αᵒᵈ) h
theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) :
Tendsto (fun i => min a (f i)) l (𝓝[<] a) :=
Filter.tendsto_nhds_max_right (α := αᵒᵈ) h
theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) :
Tendsto (fun i => min (f i) a) l (𝓝[<] a) :=
Filter.tendsto_nhds_max_left (α := αᵒᵈ) h
theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) :
∃ z ∈ s, z ∈ Ioo x y :=
hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h)
theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) :
Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by
refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2))
rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩
exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩
theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) :
Iio x = ⋃ y ∈ s ∩ Iio x, Iio y :=
Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x
end LinearOrder
end OrderClosedTopology
instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β]
[OrderClosedTopology β] : OrderClosedTopology (α × β) :=
⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter
(isClosed_le continuous_fst.snd continuous_snd.snd)⟩
instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)]
[∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by
constructor
simp only [Pi.le_def, setOf_forall]
exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd'
instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] :
OrderClosedTopology (α → β) :=
inferInstance
|
Topology\Order\PartialSups.lean | /-
Copyright (c) 2023 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Topology.Order.Lattice
import Mathlib.Order.PartialSups
/-!
# Continuity of `partialSups`
In this file we prove that `partialSups` of a sequence of continuous functions is continuous
as well as versions for `Filter.Tendsto`, `ContinuousAt`, `ContinuousWithinAt`, and `ContinuousOn`.
-/
open Filter
open scoped Topology
variable {L : Type*} [SemilatticeSup L] [TopologicalSpace L] [ContinuousSup L]
namespace Filter.Tendsto
variable {α : Type*} {l : Filter α} {f : ℕ → α → L} {g : ℕ → L} {n : ℕ}
protected lemma partialSups (hf : ∀ k ≤ n, Tendsto (f k) l (𝓝 (g k))) :
Tendsto (partialSups f n) l (𝓝 (partialSups g n)) := by
simp only [partialSups_eq_sup'_range]
refine finset_sup'_nhds _ ?_
simpa [Nat.lt_succ_iff]
protected lemma partialSups_apply (hf : ∀ k ≤ n, Tendsto (f k) l (𝓝 (g k))) :
Tendsto (fun a ↦ partialSups (f · a) n) l (𝓝 (partialSups g n)) := by
simpa only [← partialSups_apply] using Tendsto.partialSups hf
end Filter.Tendsto
variable {X : Type*} [TopologicalSpace X] {f : ℕ → X → L} {n : ℕ} {s : Set X} {x : X}
protected lemma ContinuousAt.partialSups_apply (hf : ∀ k ≤ n, ContinuousAt (f k) x) :
ContinuousAt (fun a ↦ partialSups (f · a) n) x :=
Tendsto.partialSups_apply hf
protected lemma ContinuousAt.partialSups (hf : ∀ k ≤ n, ContinuousAt (f k) x) :
ContinuousAt (partialSups f n) x := by
simpa only [← partialSups_apply] using ContinuousAt.partialSups_apply hf
protected lemma ContinuousWithinAt.partialSups_apply (hf : ∀ k ≤ n, ContinuousWithinAt (f k) s x) :
ContinuousWithinAt (fun a ↦ partialSups (f · a) n) s x :=
Tendsto.partialSups_apply hf
protected lemma ContinuousWithinAt.partialSups (hf : ∀ k ≤ n, ContinuousWithinAt (f k) s x) :
ContinuousWithinAt (partialSups f n) s x := by
simpa only [← partialSups_apply] using ContinuousWithinAt.partialSups_apply hf
protected lemma ContinuousOn.partialSups_apply (hf : ∀ k ≤ n, ContinuousOn (f k) s) :
ContinuousOn (fun a ↦ partialSups (f · a) n) s := fun x hx ↦
ContinuousWithinAt.partialSups_apply fun k hk ↦ hf k hk x hx
protected lemma ContinuousOn.partialSups (hf : ∀ k ≤ n, ContinuousOn (f k) s) :
ContinuousOn (partialSups f n) s := fun x hx ↦
ContinuousWithinAt.partialSups fun k hk ↦ hf k hk x hx
protected lemma Continuous.partialSups_apply (hf : ∀ k ≤ n, Continuous (f k)) :
Continuous (fun a ↦ partialSups (f · a) n) :=
continuous_iff_continuousAt.2 fun _ ↦ ContinuousAt.partialSups_apply fun k hk ↦
(hf k hk).continuousAt
protected lemma Continuous.partialSups (hf : ∀ k ≤ n, Continuous (f k)) :
Continuous (partialSups f n) :=
continuous_iff_continuousAt.2 fun _ ↦ ContinuousAt.partialSups fun k hk ↦ (hf k hk).continuousAt
|
Topology\Order\Priestley.lean | /-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Order.UpperLower.Basic
import Mathlib.Topology.Separation
/-!
# Priestley spaces
This file defines Priestley spaces. A Priestley space is an ordered compact topological space such
that any two distinct points can be separated by a clopen upper set.
## Main declarations
* `PriestleySpace`: Prop-valued mixin stating the Priestley separation axiom: Any two distinct
points can be separated by a clopen upper set.
## Implementation notes
We do not include compactness in the definition, so a Priestley space is to be declared as follows:
`[Preorder α] [TopologicalSpace α] [CompactSpace α] [PriestleySpace α]`
## References
* [Wikipedia, *Priestley space*](https://en.wikipedia.org/wiki/Priestley_space)
* [Davey, Priestley *Introduction to Lattices and Order*][davey_priestley]
-/
open Set
variable {α : Type*}
/-- A Priestley space is an ordered topological space such that any two distinct points can be
separated by a clopen upper set. Compactness is often assumed, but we do not include it here. -/
class PriestleySpace (α : Type*) [Preorder α] [TopologicalSpace α] : Prop where
priestley {x y : α} : ¬x ≤ y → ∃ U : Set α, IsClopen U ∧ IsUpperSet U ∧ x ∈ U ∧ y ∉ U
variable [TopologicalSpace α]
section Preorder
variable [Preorder α] [PriestleySpace α] {x y : α}
theorem exists_isClopen_upper_of_not_le :
¬x ≤ y → ∃ U : Set α, IsClopen U ∧ IsUpperSet U ∧ x ∈ U ∧ y ∉ U :=
PriestleySpace.priestley
theorem exists_isClopen_lower_of_not_le (h : ¬x ≤ y) :
∃ U : Set α, IsClopen U ∧ IsLowerSet U ∧ x ∉ U ∧ y ∈ U :=
let ⟨U, hU, hU', hx, hy⟩ := exists_isClopen_upper_of_not_le h
⟨Uᶜ, hU.compl, hU'.compl, Classical.not_not.2 hx, hy⟩
end Preorder
section PartialOrder
variable [PartialOrder α] [PriestleySpace α] {x y : α}
theorem exists_isClopen_upper_or_lower_of_ne (h : x ≠ y) :
∃ U : Set α, IsClopen U ∧ (IsUpperSet U ∨ IsLowerSet U) ∧ x ∈ U ∧ y ∉ U := by
obtain h | h := h.not_le_or_not_le
· exact (exists_isClopen_upper_of_not_le h).imp fun _ ↦ And.imp_right <| And.imp_left Or.inl
· obtain ⟨U, hU, hU', hy, hx⟩ := exists_isClopen_lower_of_not_le h
exact ⟨U, hU, Or.inr hU', hx, hy⟩
-- See note [lower instance priority]
instance (priority := 100) PriestleySpace.toT2Space : T2Space α :=
⟨fun _ _ h ↦
let ⟨U, hU, _, hx, hy⟩ := exists_isClopen_upper_or_lower_of_ne h
⟨U, Uᶜ, hU.isOpen, hU.compl.isOpen, hx, hy, disjoint_compl_right⟩⟩
end PartialOrder
|
Topology\Order\ProjIcc.lean | /-
Copyright (c) 2020 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Patrick Massot
-/
import Mathlib.Order.Interval.Set.ProjIcc
import Mathlib.Topology.Order.Basic
/-!
# Projection onto a closed interval
In this file we prove that the projection `Set.projIcc f a b h` is a quotient map, and use it
to show that `Set.IccExtend h f` is continuous if and only if `f` is continuous.
-/
open Set Filter Topology
variable {α β γ : Type*} [LinearOrder α] {a b c : α} {h : a ≤ b}
protected theorem Filter.Tendsto.IccExtend (f : γ → Icc a b → β) {la : Filter α} {lb : Filter β}
{lc : Filter γ} (hf : Tendsto (↿f) (lc ×ˢ la.map (projIcc a b h)) lb) :
Tendsto (↿(IccExtend h ∘ f)) (lc ×ˢ la) lb :=
hf.comp <| tendsto_id.prod_map tendsto_map
variable [TopologicalSpace α] [OrderTopology α] [TopologicalSpace β] [TopologicalSpace γ]
@[continuity]
theorem continuous_projIcc : Continuous (projIcc a b h) :=
(continuous_const.max <| continuous_const.min continuous_id).subtype_mk _
theorem quotientMap_projIcc : QuotientMap (projIcc a b h) :=
quotientMap_iff.2 ⟨projIcc_surjective h, fun s =>
⟨fun hs => hs.preimage continuous_projIcc, fun hs => ⟨_, hs, by ext; simp⟩⟩⟩
@[simp]
theorem continuous_IccExtend_iff {f : Icc a b → β} : Continuous (IccExtend h f) ↔ Continuous f :=
quotientMap_projIcc.continuous_iff.symm
/-- See Note [continuity lemma statement]. -/
protected theorem Continuous.IccExtend {f : γ → Icc a b → β} {g : γ → α} (hf : Continuous ↿f)
(hg : Continuous g) : Continuous fun a => IccExtend h (f a) (g a) :=
show Continuous (↿f ∘ fun x => (x, projIcc a b h (g x)))
from hf.comp <| continuous_id.prod_mk <| continuous_projIcc.comp hg
/-- A useful special case of `Continuous.IccExtend`. -/
@[continuity]
protected theorem Continuous.Icc_extend' {f : Icc a b → β} (hf : Continuous f) :
Continuous (IccExtend h f) :=
hf.comp continuous_projIcc
theorem ContinuousAt.IccExtend {x : γ} (f : γ → Icc a b → β) {g : γ → α}
(hf : ContinuousAt (↿f) (x, projIcc a b h (g x))) (hg : ContinuousAt g x) :
ContinuousAt (fun a => IccExtend h (f a) (g a)) x :=
show ContinuousAt (↿f ∘ fun x => (x, projIcc a b h (g x))) x from
ContinuousAt.comp hf <| continuousAt_id.prod <| continuous_projIcc.continuousAt.comp hg
|
Topology\Order\ScottTopology.lean | /-
Copyright (c) 2023 Christopher Hoskin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Christopher Hoskin
-/
import Mathlib.Topology.Order.UpperLowerSetTopology
/-!
# Scott topology
This file introduces the Scott topology on a preorder.
## Main definitions
- `DirSupInacc` - a set `u` is said to be inaccessible by directed joins if, when the least upper
bound of a directed set `d` lies in `u` then `d` has non-empty intersection with `u`.
- `DirSupClosed` - a set `s` is said to be closed under directed joins if, whenever a directed set
`d` has a least upper bound `a` and is a subset of `s` then `a` also lies in `s`.
- `Topology.scott` - the Scott topology is defined as the join of the topology of upper sets and the
Scott-Hausdorff topology (the topological space where a set `u` is open if, when the least upper
bound of a directed set `d` lies in `u` then there is a tail of `d` which is a subset of `u`).
## Main statements
- `Topology.IsScott.isUpperSet_of_isOpen`: Scott open sets are upper.
- `Topology.IsScott.isLowerSet_of_isClosed`: Scott closed sets are lower.
- `Topology.IsScott.monotone_of_continuous`: Functions continuous wrt the Scott topology are
monotone.
- `Topology.IsScott.scottContinuous_iff_continuous` - a function is Scott continuous (preserves
least upper bounds of directed sets) if and only if it is continuous wrt the Scott topology.
- `Topology.IsScott.instT0Space` - the Scott topology on a partial order is T₀.
## Implementation notes
A type synonym `WithScott` is introduced and for a preorder `α`, `WithScott α` is made an instance
of `TopologicalSpace` by the `scott` topology.
We define a mixin class `IsScott` for the class of types which are both a preorder and a
topology and where the topology is the `scott` topology. It is shown that `WithScott α` is an
instance of `IsScott`.
A class `Scott` is defined in `Topology/OmegaCompletePartialOrder` and made an instance of a
topological space by defining the open sets to be those which have characteristic functions which
are monotone and preserve limits of countable chains (`OmegaCompletePartialOrder.Continuous'`).
A Scott continuous function between `OmegaCompletePartialOrder`s is always
`OmegaCompletePartialOrder.Continuous'` (`OmegaCompletePartialOrder.ScottContinuous.continuous'`).
The converse is true in some special cases, but not in general
([Domain Theory, 2.2.4][abramsky_gabbay_maibaum_1994]).
## References
* [Abramsky and Jung, *Domain Theory*][abramsky_gabbay_maibaum_1994]
* [Gierz et al, *A Compendium of Continuous Lattices*][GierzEtAl1980]
* [Karner, *Continuous monoids and semirings*][Karner2004]
## Tags
Scott topology, preorder
-/
open Set
variable {α β : Type*}
/-! ### Prerequisite order properties -/
section Preorder
variable [Preorder α] {s t : Set α}
/-- A set `s` is said to be inaccessible by directed joins if, when the least upper bound of a
directed set `d` lies in `s` then `d` has non-empty intersection with `s`. -/
def DirSupInacc (s : Set α) : Prop :=
∀ ⦃d⦄, d.Nonempty → DirectedOn (· ≤ ·) d → ∀ ⦃a⦄, IsLUB d a → a ∈ s → (d ∩ s).Nonempty
/--
A set `s` is said to be closed under directed joins if, whenever a directed set `d` has a least
upper bound `a` and is a subset of `s` then `a` also lies in `s`.
-/
def DirSupClosed (s : Set α) : Prop :=
∀ ⦃d⦄, d.Nonempty → DirectedOn (· ≤ ·) d → ∀ ⦃a⦄, IsLUB d a → d ⊆ s → a ∈ s
@[simp] lemma dirSupInacc_compl : DirSupInacc sᶜ ↔ DirSupClosed s := by
simp [DirSupInacc, DirSupClosed, ← not_disjoint_iff_nonempty_inter, not_imp_not,
disjoint_compl_right_iff]
@[simp] lemma dirSupClosed_compl : DirSupClosed sᶜ ↔ DirSupInacc s := by
rw [← dirSupInacc_compl, compl_compl]
alias ⟨DirSupInacc.of_compl, DirSupClosed.compl⟩ := dirSupInacc_compl
alias ⟨DirSupClosed.of_compl, DirSupInacc.compl⟩ := dirSupClosed_compl
lemma DirSupClosed.inter (hs : DirSupClosed s) (ht : DirSupClosed t) : DirSupClosed (s ∩ t) :=
fun _d hd hd' _a ha hds ↦ ⟨hs hd hd' ha <| hds.trans inter_subset_left,
ht hd hd' ha <| hds.trans inter_subset_right⟩
lemma DirSupInacc.union (hs : DirSupInacc s) (ht : DirSupInacc t) : DirSupInacc (s ∪ t) := by
rw [← dirSupClosed_compl, compl_union]; exact hs.compl.inter ht.compl
lemma IsUpperSet.dirSupClosed (hs : IsUpperSet s) : DirSupClosed s :=
fun _d ⟨_b, hb⟩ _ _a ha hds ↦ hs (ha.1 hb) <| hds hb
lemma IsLowerSet.dirSupInacc (hs : IsLowerSet s) : DirSupInacc s := hs.compl.dirSupClosed.of_compl
lemma dirSupClosed_Iic (a : α) : DirSupClosed (Iic a) := fun _d _ _ _a ha ↦ (isLUB_le_iff ha).2
end Preorder
section CompleteLattice
variable [CompleteLattice α] {s t : Set α}
lemma dirSupInacc_iff_forall_sSup :
DirSupInacc s ↔ ∀ ⦃d⦄, d.Nonempty → DirectedOn (· ≤ ·) d → sSup d ∈ s → (d ∩ s).Nonempty := by
simp [DirSupInacc, isLUB_iff_sSup_eq]
lemma dirSupClosed_iff_forall_sSup :
DirSupClosed s ↔ ∀ ⦃d⦄, d.Nonempty → DirectedOn (· ≤ ·) d → d ⊆ s → sSup d ∈ s := by
simp [DirSupClosed, isLUB_iff_sSup_eq]
end CompleteLattice
namespace Topology
/-! ### Scott-Hausdorff topology -/
section ScottHausdorff
variable [Preorder α] {s : Set α}
/-- The Scott-Hausdorff topology.
A set `u` is open in the Scott-Hausdorff topology iff when the least upper bound of a directed set
`d` lies in `u` then there is a tail of `d` which is a subset of `u`. -/
def scottHausdorff (α : Type*) [Preorder α] : TopologicalSpace α where
IsOpen u := ∀ ⦃d : Set α⦄, d.Nonempty → DirectedOn (· ≤ ·) d → ∀ ⦃a : α⦄, IsLUB d a →
a ∈ u → ∃ b ∈ d, Ici b ∩ d ⊆ u
isOpen_univ := fun d ⟨b, hb⟩ _ _ _ _ ↦ ⟨b, hb, (Ici b ∩ d).subset_univ⟩
isOpen_inter s t hs ht d hd₁ hd₂ a hd₃ ha := by
obtain ⟨b₁, hb₁d, hb₁ds⟩ := hs hd₁ hd₂ hd₃ ha.1
obtain ⟨b₂, hb₂d, hb₂dt⟩ := ht hd₁ hd₂ hd₃ ha.2
obtain ⟨c, hcd, hc⟩ := hd₂ b₁ hb₁d b₂ hb₂d
exact ⟨c, hcd, fun e ⟨hce, hed⟩ ↦ ⟨hb₁ds ⟨hc.1.trans hce, hed⟩, hb₂dt ⟨hc.2.trans hce, hed⟩⟩⟩
isOpen_sUnion := fun s h d hd₁ hd₂ a hd₃ ⟨s₀, hs₀s, has₀⟩ ↦ by
obtain ⟨b, hbd, hbds₀⟩ := h s₀ hs₀s hd₁ hd₂ hd₃ has₀
exact ⟨b, hbd, Set.subset_sUnion_of_subset s s₀ hbds₀ hs₀s⟩
variable (α) [TopologicalSpace α]
/-- Predicate for an ordered topological space to be equipped with its Scott-Hausdorff topology.
A set `u` is open in the Scott-Hausdorff topology iff when the least upper bound of a directed set
`d` lies in `u` then there is a tail of `d` which is a subset of `u`. -/
class IsScottHausdorff : Prop where
topology_eq_scottHausdorff : ‹TopologicalSpace α› = scottHausdorff α
instance : @IsScottHausdorff α _ (scottHausdorff α) :=
@IsScottHausdorff.mk _ _ (scottHausdorff α) rfl
namespace IsScottHausdorff
variable [IsScottHausdorff α] {s : Set α}
lemma topology_eq : ‹_› = scottHausdorff α := topology_eq_scottHausdorff
variable {α}
lemma isOpen_iff :
IsOpen s ↔ ∀ ⦃d : Set α⦄, d.Nonempty → DirectedOn (· ≤ ·) d → ∀ ⦃a : α⦄, IsLUB d a →
a ∈ s → ∃ b ∈ d, Ici b ∩ d ⊆ s := by erw [topology_eq_scottHausdorff (α := α)]; rfl
lemma isOpen_of_isLowerSet (h : IsLowerSet s) : IsOpen s :=
isOpen_iff.2 fun _d ⟨b, hb⟩ _ _ hda ha ↦ ⟨b, hb, fun _ hc ↦ h (mem_upperBounds.1 hda.1 _ hc.2) ha⟩
lemma isClosed_of_isUpperSet (h : IsUpperSet s) : IsClosed s :=
isOpen_compl_iff.1 <| isOpen_of_isLowerSet h.compl
lemma dirSupInacc_of_isOpen (h : IsOpen s) : DirSupInacc s :=
fun d hd₁ hd₂ a hda hd₃ ↦ by
obtain ⟨b, hbd, hb⟩ := isOpen_iff.1 h hd₁ hd₂ hda hd₃; exact ⟨b, hbd, hb ⟨le_rfl, hbd⟩⟩
lemma dirSupClosed_of_isClosed (h : IsClosed s) : DirSupClosed s :=
(dirSupInacc_of_isOpen h.isOpen_compl).of_compl
end IsScottHausdorff
end ScottHausdorff
/-! ### Scott topology -/
section Scott
section Preorder
variable [Preorder α]
/-- The Scott topology.
It is defined as the join of the topology of upper sets and the Scott-Hausdorff topology. -/
def scott (α : Type*) [Preorder α] : TopologicalSpace α := upperSet α ⊔ scottHausdorff α
lemma upperSet_le_scott : upperSet α ≤ scott α := le_sup_left
lemma scottHausdorff_le_scott : scottHausdorff α ≤ scott α := le_sup_right
variable (α) [TopologicalSpace α]
/-- Predicate for an ordered topological space to be equipped with its Scott topology.
The Scott topology is defined as the join of the topology of upper sets and the Scott Hausdorff
topology. -/
class IsScott : Prop where
topology_eq_scott : ‹TopologicalSpace α› = scott α
end Preorder
namespace IsScott
section Preorder
variable (α) [Preorder α] [TopologicalSpace α] [IsScott α]
lemma topology_eq : ‹_› = scott α := topology_eq_scott
variable {α} {s : Set α} {a : α}
lemma isOpen_iff_isUpperSet_and_scottHausdorff_open :
IsOpen s ↔ IsUpperSet s ∧ IsOpen[scottHausdorff α] s := by erw [topology_eq α]; rfl
lemma isOpen_iff_isUpperSet_and_dirSupInacc : IsOpen s ↔ IsUpperSet s ∧ DirSupInacc s := by
rw [isOpen_iff_isUpperSet_and_scottHausdorff_open]
refine and_congr_right fun h ↦
⟨@IsScottHausdorff.dirSupInacc_of_isOpen _ _ (scottHausdorff α) _ _,
fun h' d d₁ d₂ _ d₃ ha ↦ ?_⟩
obtain ⟨b, hbd, hbu⟩ := h' d₁ d₂ d₃ ha
exact ⟨b, hbd, Subset.trans inter_subset_left (h.Ici_subset hbu)⟩
lemma isClosed_iff_isLowerSet_and_dirSupClosed : IsClosed s ↔ IsLowerSet s ∧ DirSupClosed s := by
rw [← isOpen_compl_iff, isOpen_iff_isUpperSet_and_dirSupInacc, isUpperSet_compl,
dirSupInacc_compl]
lemma isUpperSet_of_isOpen : IsOpen s → IsUpperSet s := fun h ↦
(isOpen_iff_isUpperSet_and_scottHausdorff_open.mp h).left
lemma isLowerSet_of_isClosed : IsClosed s → IsLowerSet s := fun h ↦
(isClosed_iff_isLowerSet_and_dirSupClosed.mp h).left
lemma dirSupClosed_of_isClosed : IsClosed s → DirSupClosed s := fun h ↦
(isClosed_iff_isLowerSet_and_dirSupClosed.mp h).right
lemma lowerClosure_subset_closure : ↑(lowerClosure s) ⊆ closure s := by
convert closure.mono (@upperSet_le_scott α _)
· rw [@IsUpperSet.closure_eq_lowerClosure α _ (upperSet α) ?_ s]
infer_instance
· exact topology_eq α
lemma isClosed_Iic : IsClosed (Iic a) :=
isClosed_iff_isLowerSet_and_dirSupClosed.2 ⟨isLowerSet_Iic _, dirSupClosed_Iic _⟩
/--
The closure of a singleton `{a}` in the Scott topology is the right-closed left-infinite interval
`(-∞,a]`.
-/
@[simp] lemma closure_singleton : closure {a} = Iic a := le_antisymm
(closure_minimal (by rw [singleton_subset_iff, mem_Iic]) isClosed_Iic) <| by
rw [← LowerSet.coe_Iic, ← lowerClosure_singleton]
apply lowerClosure_subset_closure
variable [Preorder β] [TopologicalSpace β] [IsScott β] {f : α → β}
lemma monotone_of_continuous (hf : Continuous f) : Monotone f := fun _ b hab ↦ by
by_contra h
simpa only [mem_compl_iff, mem_preimage, mem_Iic, le_refl, not_true]
using isUpperSet_of_isOpen ((isOpen_compl_iff.2 isClosed_Iic).preimage hf) hab h
@[simp] lemma scottContinuous_iff_continuous : ScottContinuous f ↔ Continuous f := by
refine ⟨fun h ↦ continuous_def.2 fun u hu ↦ ?_, ?_⟩
· rw [isOpen_iff_isUpperSet_and_dirSupInacc]
exact ⟨(isUpperSet_of_isOpen hu).preimage h.monotone, fun _ hd₁ hd₂ _ hd₃ ha ↦
image_inter_nonempty_iff.mp <| (isOpen_iff_isUpperSet_and_dirSupInacc.mp hu).2 (hd₁.image f)
(directedOn_image.mpr (hd₂.mono @(h.monotone))) (h hd₁ hd₂ hd₃) ha⟩
· refine fun hf _ d₁ d₂ _ d₃ ↦ ⟨(monotone_of_continuous hf).mem_upperBounds_image d₃.1,
fun b hb ↦ ?_⟩
by_contra h
let u := (Iic b)ᶜ
have hu : IsOpen (f ⁻¹' u) := (isOpen_compl_iff.2 isClosed_Iic).preimage hf
rw [isOpen_iff_isUpperSet_and_dirSupInacc] at hu
obtain ⟨c, hcd, hfcb⟩ := hu.2 d₁ d₂ d₃ h
simp [upperBounds] at hb
exact hfcb <| hb _ hcd
end Preorder
section PartialOrder
variable [PartialOrder α] [TopologicalSpace α] [IsScott α]
/--
The Scott topology on a partial order is T₀.
-/
-- see Note [lower instance priority]
instance (priority := 90) : T0Space α :=
(t0Space_iff_inseparable α).2 fun x y h ↦ Iic_injective <| by
simpa only [inseparable_iff_closure_eq, IsScott.closure_singleton] using h
end PartialOrder
section CompleteLinearOrder
variable [CompleteLinearOrder α] [TopologicalSpace α] [Topology.IsScott α]
lemma isOpen_iff_Iic_compl_or_univ (U : Set α) :
IsOpen U ↔ (∃ (a : α), U = (Iic a)ᶜ) ∨ U = univ := by
constructor
· intro hU
rcases eq_empty_or_nonempty Uᶜ with eUc | neUc
· exact Or.inr (compl_empty_iff.mp eUc)
· apply Or.inl
use sSup Uᶜ
rw [eq_compl_comm, le_antisymm_iff]
exact ⟨(isLowerSet_of_isClosed hU.isClosed_compl).Iic_subset
(dirSupClosed_iff_forall_sSup.mp (dirSupClosed_of_isClosed hU.isClosed_compl)
neUc (isChain_of_trichotomous Uᶜ).directedOn le_rfl),
fun _ ha ↦ le_sSup ha⟩
· rintro (⟨a,rfl⟩ | rfl)
· exact isClosed_Iic.isOpen_compl
· exact isOpen_univ
end CompleteLinearOrder
end IsScott
/--
Type synonym for a preorder equipped with the Scott topology
-/
def WithScott (α : Type*) := α
namespace WithScott
/-- `toScott` is the identity function to the `WithScott` of a type. -/
@[match_pattern] def toScott : α ≃ WithScott α := Equiv.refl _
/-- `ofScott` is the identity function from the `WithScott` of a type. -/
@[match_pattern] def ofScott : WithScott α ≃ α := Equiv.refl _
@[simp] lemma toScott_symm_eq : (@toScott α).symm = ofScott := rfl
@[simp] lemma ofScott_symm_eq : (@ofScott α).symm = toScott := rfl
@[simp] lemma toScott_ofScott (a : WithScott α) : toScott (ofScott a) = a := rfl
@[simp] lemma ofScott_toScott (a : α) : ofScott (toScott a) = a := rfl
@[simp, nolint simpNF]
lemma toScott_inj {a b : α} : toScott a = toScott b ↔ a = b := Iff.rfl
@[simp, nolint simpNF]
lemma ofScott_inj {a b : WithScott α} : ofScott a = ofScott b ↔ a = b := Iff.rfl
/-- A recursor for `WithScott`. Use as `induction x`. -/
@[elab_as_elim, cases_eliminator, induction_eliminator]
protected def rec {β : WithScott α → Sort _}
(h : ∀ a, β (toScott a)) : ∀ a, β a := fun a ↦ h (ofScott a)
instance [Nonempty α] : Nonempty (WithScott α) := ‹Nonempty α›
instance [Inhabited α] : Inhabited (WithScott α) := ‹Inhabited α›
variable [Preorder α]
instance : Preorder (WithScott α) := ‹Preorder α›
instance : TopologicalSpace (WithScott α) := scott α
instance : IsScott (WithScott α) := ⟨rfl⟩
lemma isOpen_iff_isUpperSet_and_scottHausdorff_open' {u : Set α} :
IsOpen (WithScott.ofScott ⁻¹' u) ↔ IsUpperSet u ∧ (scottHausdorff α).IsOpen u := Iff.rfl
end WithScott
end Scott
variable [Preorder α]
lemma scottHausdorff_le_lower : scottHausdorff α ≤ lower α :=
fun s h => @IsScottHausdorff.isOpen_of_isLowerSet _ _ (scottHausdorff α) _ _
<| (@IsLower.isLowerSet_of_isOpen (Topology.WithLower α) _ _ _ s h)
variable [TopologicalSpace α]
/-- If `α` is equipped with the Scott topology, then it is homeomorphic to `WithScott α`.
-/
def IsScott.withScottHomeomorph [IsScott α] : WithScott α ≃ₜ α :=
WithScott.ofScott.toHomeomorphOfInducing ⟨by erw [IsScott.topology_eq α, induced_id]; rfl⟩
lemma IsScott.scottHausdorff_le [IsScott α] : scottHausdorff α ≤ ‹TopologicalSpace α› := by
rw [IsScott.topology_eq α, scott]; exact le_sup_right
lemma IsLower.scottHausdorff_le [IsLower α] : scottHausdorff α ≤ ‹TopologicalSpace α› :=
fun _ h ↦
@IsScottHausdorff.isOpen_of_isLowerSet _ _ (scottHausdorff α) _ _
<| IsLower.isLowerSet_of_isOpen h
end Topology
|
Topology\Order\T5.lean | /-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Order.Interval.Set.OrdConnectedComponent
import Mathlib.Topology.Order.Basic
/-!
# Linear order is a completely normal Hausdorff topological space
In this file we prove that a linear order with order topology is a completely normal Hausdorff
topological space.
-/
open Filter Set Function OrderDual Topology Interval
variable {X : Type*} [LinearOrder X] [TopologicalSpace X] [OrderTopology X] {a b c : X}
{s t : Set X}
namespace Set
@[simp]
theorem ordConnectedComponent_mem_nhds : ordConnectedComponent s a ∈ 𝓝 a ↔ s ∈ 𝓝 a := by
refine ⟨fun h => mem_of_superset h ordConnectedComponent_subset, fun h => ?_⟩
rcases exists_Icc_mem_subset_of_mem_nhds h with ⟨b, c, ha, ha', hs⟩
exact mem_of_superset ha' (subset_ordConnectedComponent ha hs)
theorem compl_section_ordSeparatingSet_mem_nhdsWithin_Ici (hd : Disjoint s (closure t))
(ha : a ∈ s) : (ordConnectedSection (ordSeparatingSet s t))ᶜ ∈ 𝓝[≥] a := by
have hmem : tᶜ ∈ 𝓝[≥] a := by
refine mem_nhdsWithin_of_mem_nhds ?_
rw [← mem_interior_iff_mem_nhds, interior_compl]
exact disjoint_left.1 hd ha
rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici hmem with ⟨b, hab, hmem', hsub⟩
by_cases H : Disjoint (Icc a b) (ordConnectedSection <| ordSeparatingSet s t)
· exact mem_of_superset hmem' (disjoint_left.1 H)
· simp only [Set.disjoint_left, not_forall, Classical.not_not] at H
rcases H with ⟨c, ⟨hac, hcb⟩, hc⟩
have hsub' : Icc a b ⊆ ordConnectedComponent tᶜ a :=
subset_ordConnectedComponent (left_mem_Icc.2 hab) hsub
have hd : Disjoint s (ordConnectedSection (ordSeparatingSet s t)) :=
disjoint_left_ordSeparatingSet.mono_right ordConnectedSection_subset
replace hac : a < c := hac.lt_of_ne <| Ne.symm <| ne_of_mem_of_not_mem hc <|
disjoint_left.1 hd ha
refine mem_of_superset (Ico_mem_nhdsWithin_Ici (left_mem_Ico.2 hac)) fun x hx hx' => ?_
refine hx.2.ne (eq_of_mem_ordConnectedSection_of_uIcc_subset hx' hc ?_)
refine subset_inter (subset_iUnion₂_of_subset a ha ?_) ?_
· exact OrdConnected.uIcc_subset inferInstance (hsub' ⟨hx.1, hx.2.le.trans hcb⟩)
(hsub' ⟨hac.le, hcb⟩)
· rcases mem_iUnion₂.1 (ordConnectedSection_subset hx').2 with ⟨y, hyt, hxy⟩
refine subset_iUnion₂_of_subset y hyt (OrdConnected.uIcc_subset inferInstance hxy ?_)
refine subset_ordConnectedComponent left_mem_uIcc hxy ?_
suffices c < y by
rw [uIcc_of_ge (hx.2.trans this).le]
exact ⟨hx.2.le, this.le⟩
refine lt_of_not_le fun hyc => ?_
have hya : y < a := not_le.1 fun hay => hsub ⟨hay, hyc.trans hcb⟩ hyt
exact hxy (Icc_subset_uIcc ⟨hya.le, hx.1⟩) ha
theorem compl_section_ordSeparatingSet_mem_nhdsWithin_Iic (hd : Disjoint s (closure t))
(ha : a ∈ s) : (ordConnectedSection <| ordSeparatingSet s t)ᶜ ∈ 𝓝[≤] a := by
have hd' : Disjoint (ofDual ⁻¹' s) (closure <| ofDual ⁻¹' t) := hd
have ha' : toDual a ∈ ofDual ⁻¹' s := ha
simpa only [dual_ordSeparatingSet, dual_ordConnectedSection] using
compl_section_ordSeparatingSet_mem_nhdsWithin_Ici hd' ha'
theorem compl_section_ordSeparatingSet_mem_nhds (hd : Disjoint s (closure t)) (ha : a ∈ s) :
(ordConnectedSection <| ordSeparatingSet s t)ᶜ ∈ 𝓝 a := by
rw [← nhds_left_sup_nhds_right, mem_sup]
exact
⟨compl_section_ordSeparatingSet_mem_nhdsWithin_Iic hd ha,
compl_section_ordSeparatingSet_mem_nhdsWithin_Ici hd ha⟩
theorem ordT5Nhd_mem_nhdsSet (hd : Disjoint s (closure t)) : ordT5Nhd s t ∈ 𝓝ˢ s :=
bUnion_mem_nhdsSet fun x hx => ordConnectedComponent_mem_nhds.2 <| inter_mem
(by
rw [← mem_interior_iff_mem_nhds, interior_compl]
exact disjoint_left.1 hd hx)
(compl_section_ordSeparatingSet_mem_nhds hd hx)
end Set
open Set
/-- A linear order with order topology is a completely normal Hausdorff topological space. -/
instance (priority := 100) OrderTopology.completelyNormalSpace : CompletelyNormalSpace X :=
⟨fun s t h₁ h₂ => Filter.disjoint_iff.2
⟨ordT5Nhd s t, ordT5Nhd_mem_nhdsSet h₂, ordT5Nhd t s, ordT5Nhd_mem_nhdsSet h₁.symm,
disjoint_ordT5Nhd⟩⟩
instance (priority := 100) OrderTopology.t5Space : T5Space X := T5Space.mk
|
Topology\Order\UpperLowerSetTopology.lean | /-
Copyright (c) 2023 Christopher Hoskin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Christopher Hoskin
-/
import Mathlib.Topology.AlexandrovDiscrete
import Mathlib.Topology.ContinuousFunction.Basic
import Mathlib.Topology.Order.LowerUpperTopology
/-!
# Upper and lower sets topologies
This file introduces the upper set topology on a preorder as the topology where the open sets are
the upper sets and the lower set topology on a preorder as the topology where the open sets are
the lower sets.
In general the upper set topology does not coincide with the upper topology and the lower set
topology does not coincide with the lower topology.
## Main statements
- `Topology.IsUpperSet.toAlexandrovDiscrete`: The upper set topology is Alexandrov-discrete.
- `Topology.IsUpperSet.isClosed_iff_isLower` - a set is closed if and only if it is a Lower set
- `Topology.IsUpperSet.closure_eq_lowerClosure` - topological closure coincides with lower closure
- `Topology.IsUpperSet.monotone_iff_continuous` - the continuous functions are the monotone
functions
- `IsUpperSet.monotone_to_upperTopology_continuous`: A monotone map from a preorder with the upper
set topology to a preorder with the upper topology is continuous.
We provide the upper set topology in three ways (and similarly for the lower set topology):
* `Topology.upperSet`: The upper set topology as a `TopologicalSpace α`
* `Topology.IsUpperSet`: Prop-valued mixin typeclass stating that an existing topology is the upper
set topology.
* `Topology.WithUpperSet`: Type synonym equipping a preorder with its upper set topology.
## Motivation
An Alexandrov topology is a topology where the intersection of any collection of open sets is open.
The upper set topology is an Alexandrov topology and, given any Alexandrov topological space, we can
equip it with a preorder (namely the specialization preorder) whose upper set topology coincides
with the original topology. See `Topology.Specialization`.
## Tags
upper set topology, lower set topology, preorder, Alexandrov
-/
open Set TopologicalSpace
variable {α β γ : Type*}
namespace Topology
/-- Topology whose open sets are upper sets.
Note: In general the upper set topology does not coincide with the upper topology. -/
def upperSet (α : Type*) [Preorder α] : TopologicalSpace α where
IsOpen := IsUpperSet
isOpen_univ := isUpperSet_univ
isOpen_inter _ _ := IsUpperSet.inter
isOpen_sUnion _ := isUpperSet_sUnion
/-- Topology whose open sets are lower sets.
Note: In general the lower set topology does not coincide with the lower topology. -/
def lowerSet (α : Type*) [Preorder α] : TopologicalSpace α where
IsOpen := IsLowerSet
isOpen_univ := isLowerSet_univ
isOpen_inter _ _ := IsLowerSet.inter
isOpen_sUnion _ := isLowerSet_sUnion
/-- Type synonym for a preorder equipped with the upper set topology. -/
def WithUpperSet (α : Type*) := α
namespace WithUpperSet
/-- `toUpperSet` is the identity function to the `WithUpperSet` of a type. -/
@[match_pattern] def toUpperSet : α ≃ WithUpperSet α := Equiv.refl _
/-- `ofUpperSet` is the identity function from the `WithUpperSet` of a type. -/
@[match_pattern] def ofUpperSet : WithUpperSet α ≃ α := Equiv.refl _
@[simp] lemma to_WithUpperSet_symm_eq : (@toUpperSet α).symm = ofUpperSet := rfl
@[simp] lemma of_WithUpperSet_symm_eq : (@ofUpperSet α).symm = toUpperSet := rfl
@[simp] lemma toUpperSet_ofUpperSet (a : WithUpperSet α) : toUpperSet (ofUpperSet a) = a := rfl
@[simp] lemma ofUpperSet_toUpperSet (a : α) : ofUpperSet (toUpperSet a) = a := rfl
lemma toUpperSet_inj {a b : α} : toUpperSet a = toUpperSet b ↔ a = b := Iff.rfl
lemma ofUpperSet_inj {a b : WithUpperSet α} : ofUpperSet a = ofUpperSet b ↔ a = b := Iff.rfl
/-- A recursor for `WithUpperSet`. Use as `induction x`. -/
@[elab_as_elim, cases_eliminator, induction_eliminator]
protected def rec {β : WithUpperSet α → Sort*} (h : ∀ a, β (toUpperSet a)) : ∀ a, β a :=
fun a => h (ofUpperSet a)
instance [Nonempty α] : Nonempty (WithUpperSet α) := ‹Nonempty α›
instance [Inhabited α] : Inhabited (WithUpperSet α) := ‹Inhabited α›
variable [Preorder α] [Preorder β] [Preorder γ]
instance : Preorder (WithUpperSet α) := ‹Preorder α›
instance : TopologicalSpace (WithUpperSet α) := upperSet α
lemma ofUpperSet_le_iff {a b : WithUpperSet α} : ofUpperSet a ≤ ofUpperSet b ↔ a ≤ b := Iff.rfl
lemma toUpperSet_le_iff {a b : α} : toUpperSet a ≤ toUpperSet b ↔ a ≤ b := Iff.rfl
/-- `ofUpperSet` as an `OrderIso` -/
def ofUpperSetOrderIso : WithUpperSet α ≃o α where
toEquiv := ofUpperSet
map_rel_iff' := ofUpperSet_le_iff
/-- `toUpperSet` as an `OrderIso` -/
def toUpperSetOrderIso : α ≃o WithUpperSet α where
toEquiv := toUpperSet
map_rel_iff' := toUpperSet_le_iff
end WithUpperSet
/-- Type synonym for a preorder equipped with the lower set topology. -/
def WithLowerSet (α : Type*) := α
namespace WithLowerSet
/-- `toLowerSet` is the identity function to the `WithLowerSet` of a type. -/
@[match_pattern] def toLowerSet : α ≃ WithLowerSet α := Equiv.refl _
/-- `ofLowerSet` is the identity function from the `WithLowerSet` of a type. -/
@[match_pattern] def ofLowerSet : WithLowerSet α ≃ α := Equiv.refl _
@[simp] lemma to_WithLowerSet_symm_eq : (@toLowerSet α).symm = ofLowerSet := rfl
@[simp] lemma of_WithLowerSet_symm_eq : (@ofLowerSet α).symm = toLowerSet := rfl
@[simp] lemma toLowerSet_ofLowerSet (a : WithLowerSet α) : toLowerSet (ofLowerSet a) = a := rfl
@[simp] lemma ofLowerSet_toLowerSet (a : α) : ofLowerSet (toLowerSet a) = a := rfl
lemma toLowerSet_inj {a b : α} : toLowerSet a = toLowerSet b ↔ a = b := Iff.rfl
lemma ofLowerSet_inj {a b : WithLowerSet α} : ofLowerSet a = ofLowerSet b ↔ a = b := Iff.rfl
/-- A recursor for `WithLowerSet`. Use as `induction x`. -/
@[elab_as_elim, cases_eliminator, induction_eliminator]
protected def rec {β : WithLowerSet α → Sort*} (h : ∀ a, β (toLowerSet a)) : ∀ a, β a :=
fun a => h (ofLowerSet a)
instance [Nonempty α] : Nonempty (WithLowerSet α) := ‹Nonempty α›
instance [Inhabited α] : Inhabited (WithLowerSet α) := ‹Inhabited α›
variable [Preorder α]
instance : Preorder (WithLowerSet α) := ‹Preorder α›
instance : TopologicalSpace (WithLowerSet α) := lowerSet α
lemma ofLowerSet_le_iff {a b : WithLowerSet α} : ofLowerSet a ≤ ofLowerSet b ↔ a ≤ b := Iff.rfl
lemma toLowerSet_le_iff {a b : α} : toLowerSet a ≤ toLowerSet b ↔ a ≤ b := Iff.rfl
/-- `ofLowerSet` as an `OrderIso` -/
def ofLowerSetOrderIso : WithLowerSet α ≃o α where
toEquiv := ofLowerSet
map_rel_iff' := ofLowerSet_le_iff
/-- `toLowerSet` as an `OrderIso` -/
def toLowerSetOrderIso : α ≃o WithLowerSet α where
toEquiv := toLowerSet
map_rel_iff' := toLowerSet_le_iff
end WithLowerSet
/--
The Upper Set topology is homeomorphic to the Lower Set topology on the dual order
-/
def WithUpperSet.toDualHomeomorph [Preorder α] : WithUpperSet α ≃ₜ WithLowerSet αᵒᵈ where
toFun := OrderDual.toDual
invFun := OrderDual.ofDual
left_inv := OrderDual.toDual_ofDual
right_inv := OrderDual.ofDual_toDual
continuous_toFun := continuous_coinduced_rng
continuous_invFun := continuous_coinduced_rng
/-- Prop-valued mixin for an ordered topological space to be
The upper set topology is the topology where the open sets are the upper sets. In general the upper
set topology does not coincide with the upper topology.
-/
protected class IsUpperSet (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where
topology_eq_upperSetTopology : t = upperSet α
attribute [nolint docBlame] IsUpperSet.topology_eq_upperSetTopology
instance [Preorder α] : Topology.IsUpperSet (WithUpperSet α) := ⟨rfl⟩
instance [Preorder α] : @Topology.IsUpperSet α (upperSet α) _ := by
letI := upperSet α
exact ⟨rfl⟩
/--
The lower set topology is the topology where the open sets are the lower sets. In general the lower
set topology does not coincide with the lower topology.
-/
protected class IsLowerSet (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where
topology_eq_lowerSetTopology : t = lowerSet α
attribute [nolint docBlame] IsLowerSet.topology_eq_lowerSetTopology
instance [Preorder α] : Topology.IsLowerSet (WithLowerSet α) := ⟨rfl⟩
instance [Preorder α] : @Topology.IsLowerSet α (lowerSet α) _ := by
letI := lowerSet α
exact ⟨rfl⟩
namespace IsUpperSet
section Preorder
variable (α)
variable [Preorder α] [TopologicalSpace α] [Topology.IsUpperSet α] {s : Set α}
lemma topology_eq : ‹_› = upperSet α := topology_eq_upperSetTopology
variable {α}
instance _root_.OrderDual.instIsLowerSet [Preorder α] [TopologicalSpace α] [Topology.IsUpperSet α] :
Topology.IsLowerSet αᵒᵈ where
topology_eq_lowerSetTopology := by ext; rw [IsUpperSet.topology_eq α]
/-- If `α` is equipped with the upper set topology, then it is homeomorphic to
`WithUpperSet α`. -/
def WithUpperSetHomeomorph : WithUpperSet α ≃ₜ α :=
WithUpperSet.ofUpperSet.toHomeomorphOfInducing ⟨by erw [topology_eq α, induced_id]; rfl⟩
lemma isOpen_iff_isUpperSet : IsOpen s ↔ IsUpperSet s := by
rw [topology_eq α]
rfl
instance toAlexandrovDiscrete : AlexandrovDiscrete α where
isOpen_sInter S := by simpa only [isOpen_iff_isUpperSet] using isUpperSet_sInter (α := α)
-- c.f. isClosed_iff_lower_and_subset_implies_LUB_mem
lemma isClosed_iff_isLower : IsClosed s ↔ IsLowerSet s := by
rw [← isOpen_compl_iff, isOpen_iff_isUpperSet,
isLowerSet_compl.symm, compl_compl]
lemma closure_eq_lowerClosure {s : Set α} : closure s = lowerClosure s := by
rw [subset_antisymm_iff]
refine ⟨?_, lowerClosure_min subset_closure (isClosed_iff_isLower.1 isClosed_closure)⟩
· apply closure_minimal subset_lowerClosure _
rw [isClosed_iff_isLower]
exact LowerSet.lower (lowerClosure s)
/--
The closure of a singleton `{a}` in the upper set topology is the right-closed left-infinite
interval (-∞,a].
-/
@[simp] lemma closure_singleton {a : α} : closure {a} = Iic a := by
rw [closure_eq_lowerClosure, lowerClosure_singleton]
rfl
end Preorder
section maps
variable [Preorder α] [Preorder β]
open Topology
protected lemma monotone_iff_continuous [TopologicalSpace α] [TopologicalSpace β]
[Topology.IsUpperSet α] [Topology.IsUpperSet β] {f : α → β} : Monotone f ↔ Continuous f := by
constructor
· intro hf
simp_rw [continuous_def, isOpen_iff_isUpperSet]
exact fun _ hs ↦ IsUpperSet.preimage hs hf
· intro hf a b hab
rw [← mem_Iic, ← closure_singleton] at hab ⊢
apply Continuous.closure_preimage_subset hf {f b}
apply mem_of_mem_of_subset hab
apply closure_mono
rw [singleton_subset_iff, mem_preimage, mem_singleton_iff]
lemma monotone_to_upperTopology_continuous [TopologicalSpace α] [TopologicalSpace β]
[Topology.IsUpperSet α] [IsUpper β] {f : α → β} (hf : Monotone f) : Continuous f := by
simp_rw [continuous_def, isOpen_iff_isUpperSet]
intro s hs
exact (IsUpper.isUpperSet_of_isOpen hs).preimage hf
lemma upperSet_le_upper {t₁ t₂ : TopologicalSpace α} [@Topology.IsUpperSet α t₁ _]
[@Topology.IsUpper α t₂ _] : t₁ ≤ t₂ := fun s hs => by
rw [@isOpen_iff_isUpperSet α _ t₁]
exact IsUpper.isUpperSet_of_isOpen hs
end maps
end IsUpperSet
namespace IsLowerSet
section Preorder
variable (α)
variable [Preorder α] [TopologicalSpace α] [Topology.IsLowerSet α] {s : Set α}
lemma topology_eq : ‹_› = lowerSet α := topology_eq_lowerSetTopology
variable {α}
instance _root_.OrderDual.instIsUpperSet [Preorder α] [TopologicalSpace α] [Topology.IsLowerSet α] :
Topology.IsUpperSet αᵒᵈ where
topology_eq_upperSetTopology := by ext; rw [IsLowerSet.topology_eq α]
/-- If `α` is equipped with the lower set topology, then it is homeomorphic to `WithLowerSet α`. -/
def WithLowerSetHomeomorph : WithLowerSet α ≃ₜ α :=
WithLowerSet.ofLowerSet.toHomeomorphOfInducing ⟨by erw [topology_eq α, induced_id]; rfl⟩
lemma isOpen_iff_isLowerSet : IsOpen s ↔ IsLowerSet s := by rw [topology_eq α]; rfl
instance toAlexandrovDiscrete : AlexandrovDiscrete α := IsUpperSet.toAlexandrovDiscrete (α := αᵒᵈ)
lemma isClosed_iff_isUpper : IsClosed s ↔ IsUpperSet s := by
rw [← isOpen_compl_iff, isOpen_iff_isLowerSet, isUpperSet_compl.symm, compl_compl]
lemma closure_eq_upperClosure {s : Set α} : closure s = upperClosure s :=
IsUpperSet.closure_eq_lowerClosure (α := αᵒᵈ)
/--
The closure of a singleton `{a}` in the lower set topology is the right-closed left-infinite
interval (-∞,a].
-/
@[simp] lemma closure_singleton {a : α} : closure {a} = Ici a := by
rw [closure_eq_upperClosure, upperClosure_singleton]
rfl
end Preorder
section maps
variable [Preorder α] [Preorder β]
open Topology
open OrderDual
protected lemma monotone_iff_continuous [TopologicalSpace α] [TopologicalSpace β]
[Topology.IsLowerSet α] [Topology.IsLowerSet β] {f : α → β} : Monotone f ↔ Continuous f := by
rw [← monotone_dual_iff]
exact IsUpperSet.monotone_iff_continuous (α := αᵒᵈ) (β := βᵒᵈ)
(f := (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ))
lemma monotone_to_lowerTopology_continuous [TopologicalSpace α] [TopologicalSpace β]
[Topology.IsLowerSet α] [IsLower β] {f : α → β} (hf : Monotone f) : Continuous f :=
IsUpperSet.monotone_to_upperTopology_continuous (α := αᵒᵈ) (β := βᵒᵈ) hf.dual
lemma lowerSet_le_lower {t₁ t₂ : TopologicalSpace α} [@Topology.IsLowerSet α t₁ _]
[@IsLower α t₂ _] : t₁ ≤ t₂ := fun s hs => by
rw [@isOpen_iff_isLowerSet α _ t₁]
exact IsLower.isLowerSet_of_isOpen hs
end maps
end IsLowerSet
lemma isUpperSet_orderDual [Preorder α] [TopologicalSpace α] :
Topology.IsUpperSet αᵒᵈ ↔ Topology.IsLowerSet α := by
constructor
· apply OrderDual.instIsLowerSet
· apply OrderDual.instIsUpperSet
lemma isLowerSet_orderDual [Preorder α] [TopologicalSpace α] :
Topology.IsLowerSet αᵒᵈ ↔ Topology.IsUpperSet α := isUpperSet_orderDual.symm
namespace WithUpperSet
variable [Preorder α] [Preorder β] [Preorder γ]
/-- A monotone map between preorders spaces induces a continuous map between themselves considered
with the upper set topology. -/
def map (f : α →o β) : C(WithUpperSet α, WithUpperSet β) where
toFun := toUpperSet ∘ f ∘ ofUpperSet
continuous_toFun := continuous_def.2 fun _s hs ↦ IsUpperSet.preimage hs f.monotone
@[simp] lemma map_id : map (OrderHom.id : α →o α) = ContinuousMap.id _ := rfl
@[simp] lemma map_comp (g : β →o γ) (f : α →o β) : map (g.comp f) = (map g).comp (map f) := rfl
@[simp] lemma toUpperSet_specializes_toUpperSet {a b : α} :
toUpperSet a ⤳ toUpperSet b ↔ b ≤ a := by
simp_rw [specializes_iff_closure_subset, IsUpperSet.closure_singleton, Iic_subset_Iic,
toUpperSet_le_iff]
@[simp] lemma ofUpperSet_le_ofUpperSet {a b : WithUpperSet α} :
ofUpperSet a ≤ ofUpperSet b ↔ b ⤳ a := toUpperSet_specializes_toUpperSet.symm
@[simp] lemma isUpperSet_toUpperSet_preimage {s : Set (WithUpperSet α)} :
IsUpperSet (toUpperSet ⁻¹' s) ↔ IsOpen s := Iff.rfl
@[simp] lemma isOpen_ofUpperSet_preimage {s : Set α} :
IsOpen (ofUpperSet ⁻¹' s) ↔ IsUpperSet s := isUpperSet_toUpperSet_preimage.symm
end WithUpperSet
namespace WithLowerSet
variable [Preorder α] [Preorder β] [Preorder γ]
/-- A monotone map between preorders spaces induces a continuous map between themselves considered
with the lower set topology. -/
def map (f : α →o β) : C(WithLowerSet α, WithLowerSet β) where
toFun := toLowerSet ∘ f ∘ ofLowerSet
continuous_toFun := continuous_def.2 fun _s hs ↦ IsLowerSet.preimage hs f.monotone
@[simp] lemma map_id : map (OrderHom.id : α →o α) = ContinuousMap.id _ := rfl
@[simp] lemma map_comp (g : β →o γ) (f : α →o β) : map (g.comp f) = (map g).comp (map f) := rfl
@[simp] lemma toLowerSet_specializes_toLowerSet {a b : α} :
toLowerSet a ⤳ toLowerSet b ↔ a ≤ b := by
simp_rw [specializes_iff_closure_subset, IsLowerSet.closure_singleton, Ici_subset_Ici,
toLowerSet_le_iff]
@[simp] lemma ofLowerSet_le_ofLowerSet {a b : WithLowerSet α} :
ofLowerSet a ≤ ofLowerSet b ↔ a ⤳ b := toLowerSet_specializes_toLowerSet.symm
@[simp] lemma isLowerSet_toLowerSet_preimage {s : Set (WithLowerSet α)} :
IsLowerSet (toLowerSet ⁻¹' s) ↔ IsOpen s := Iff.rfl
@[simp] lemma isOpen_ofLowerSet_preimage {s : Set α} :
IsOpen (ofLowerSet ⁻¹' s) ↔ IsLowerSet s := isLowerSet_toLowerSet_preimage.symm
end WithLowerSet
end Topology
|
Topology\Order\Category\AlexDisc.lean | /-
Copyright (c) 2023 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Topology.Specialization
/-!
# Category of Alexandrov-discrete topological spaces
This defines `AlexDisc`, the category of Alexandrov-discrete topological spaces with continuous
maps, and proves it's equivalent to the category of preorders.
-/
open CategoryTheory Topology
/-- Auxiliary typeclass to define the category of Alexandrov-discrete spaces. Do not use this
directly. Use `AlexandrovDiscrete` instead. -/
class AlexandrovDiscreteSpace (α : Type*) extends TopologicalSpace α, AlexandrovDiscrete α
/-- The category of Alexandrov-discrete spaces. -/
def AlexDisc := Bundled AlexandrovDiscreteSpace
namespace AlexDisc
instance instCoeSort : CoeSort AlexDisc Type* := Bundled.coeSort
instance instTopologicalSpace (α : AlexDisc) : TopologicalSpace α := α.2.1
instance instAlexandrovDiscrete (α : AlexDisc) : AlexandrovDiscrete α := α.2.2
instance : BundledHom.ParentProjection @AlexandrovDiscreteSpace.toTopologicalSpace := ⟨⟩
deriving instance LargeCategory for AlexDisc
instance instConcreteCategory : ConcreteCategory AlexDisc := BundledHom.concreteCategory _
instance instHasForgetToTop : HasForget₂ AlexDisc TopCat := BundledHom.forget₂ _ _
instance forgetToTop_full : (forget₂ AlexDisc TopCat).Full := BundledHom.forget₂_full _ _
instance forgetToTop_faithful : (forget₂ AlexDisc TopCat).Faithful where
@[simp] lemma coe_forgetToTop (X : AlexDisc) : ↥((forget₂ _ TopCat).obj X) = X := rfl
/-- Construct a bundled `AlexDisc` from the underlying topological space. -/
def of (α : Type*) [TopologicalSpace α] [AlexandrovDiscrete α] : AlexDisc := ⟨α, ⟨⟩⟩
@[simp] lemma coe_of (α : Type*) [TopologicalSpace α] [AlexandrovDiscrete α] : ↥(of α) = α := rfl
@[simp] lemma forgetToTop_of (α : Type*) [TopologicalSpace α] [AlexandrovDiscrete α] :
(forget₂ AlexDisc TopCat).obj (of α) = TopCat.of α := rfl
-- This was a global instance prior to #13170. We may experiment with removing it.
attribute [local instance] CategoryTheory.ConcreteCategory.instFunLike
/-- Constructs an equivalence between preorders from an order isomorphism between them. -/
@[simps]
def Iso.mk {α β : AlexDisc} (e : α ≃ₜ β) : α ≅ β where
hom := (e : ContinuousMap α β)
inv := (e.symm : ContinuousMap β α)
hom_inv_id := DFunLike.ext _ _ e.symm_apply_apply
inv_hom_id := DFunLike.ext _ _ e.apply_symm_apply
end AlexDisc
/-- Sends a topological space to its specialisation order. -/
@[simps]
def alexDiscEquivPreord : AlexDisc ≌ Preord where
functor := forget₂ _ _ ⋙ topToPreord
inverse := { obj := fun X ↦ AlexDisc.of (WithUpperSet X), map := WithUpperSet.map }
unitIso := NatIso.ofComponents fun X ↦ AlexDisc.Iso.mk <| by
dsimp; exact homeoWithUpperSetTopologyorderIso X
counitIso := NatIso.ofComponents fun X ↦ Preord.Iso.mk <| by
dsimp; exact (orderIsoSpecializationWithUpperSetTopology X).symm
|
Topology\Order\Category\FrameAdjunction.lean | /-
Copyright (c) 2023 Anne Baanen, Sam v. Gool, Leo Mayer, Brendan S. Murphy. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Sam v. Gool, Leo Mayer, Brendan S. Murphy
-/
import Mathlib.Topology.Category.Locale
/-!
# Adjunction between Locales and Topological Spaces
This file defines the point functor from the category of locales to topological spaces
and proves that it is right adjoint to the forgetful functor from topological spaces to locales.
## Main declarations
* `Locale.pt`: the *points* functor from the category of locales to the category of topological
spaces.
* `Locale.adjunctionTopToLocalePT`: the adjunction between the functors `topToLocale` and `pt`.
## Motivation
This adjunction provides a framework in which several Stone-type dualities fit.
## Implementation notes
* In naming the various functions below, we follow common terminology and reserve the word *point*
for an inhabitant of a type `X` which is a topological space, while we use the word *element* for
an inhabitant of a type `L` which is a locale.
## References
* [J. Picado and A. Pultr, Frames and Locales: topology without points][picado2011frames]
## Tags
topological space, frame, locale, Stone duality, adjunction, points
-/
open CategoryTheory Order Set Topology TopologicalSpace
namespace Locale
/-! ### Definition of the points functor `pt` --/
section pt_definition
variable (L : Type*) [CompleteLattice L]
/-- The type of points of a complete lattice `L`, where a *point* of a complete lattice is,
by definition, a frame homomorphism from `L` to `Prop`. -/
abbrev PT := FrameHom L Prop
/-- The frame homomorphism from a complete lattice `L` to the complete lattice of sets of
points of `L`. -/
@[simps]
def openOfElementHom : FrameHom L (Set (PT L)) where
toFun u := {x | x u}
map_inf' a b := by simp [Set.setOf_and]
map_top' := by simp
map_sSup' S := by ext; simp [Prop.exists_iff]
namespace PT
/-- The topology on the set of points of the complete lattice `L`. -/
instance instTopologicalSpace : TopologicalSpace (PT L) where
IsOpen s := ∃ u, {x | x u} = s
isOpen_univ := ⟨⊤, by simp⟩
isOpen_inter := by rintro s t ⟨u, rfl⟩ ⟨v, rfl⟩; use u ⊓ v; simp_rw [map_inf]; rfl
isOpen_sUnion S hS := by
choose f hf using hS
use ⨆ t, ⨆ ht, f t ht
simp_rw [map_iSup, iSup_Prop_eq, setOf_exists, hf, sUnion_eq_biUnion]
/-- Characterization of when a subset of the space of points is open. -/
lemma isOpen_iff (U : Set (PT L)) : IsOpen U ↔ ∃ u : L, {x | x u} = U := Iff.rfl
end PT
-- This was a global instance prior to #13170. We may experiment with removing it.
attribute [local instance] CategoryTheory.ConcreteCategory.instFunLike
/-- The covariant functor `pt` from the category of locales to the category of
topological spaces, which sends a locale `L` to the topological space `PT L` of homomorphisms
from `L` to `Prop` and a locale homomorphism `f` to a continuous function between the spaces
of points. -/
def pt : Locale ⥤ TopCat where
obj L := ⟨PT L.unop, inferInstance⟩
map f := ⟨fun p ↦ p.comp f.unop, continuous_def.2 <| by rintro s ⟨u, rfl⟩; use f.unop u; rfl⟩
end pt_definition
section locale_top_adjunction
variable (X : Type*) [TopologicalSpace X] (L : Locale)
/-- The unit of the adjunction between locales and topological spaces, which associates with
a point `x` of the space `X` a point of the locale of opens of `X`. -/
@[simps]
def localePointOfSpacePoint (x : X) : PT (Opens X) where
toFun := (x ∈ ·)
map_inf' a b := rfl
map_top' := rfl
map_sSup' S := by simp [Prop.exists_iff]
/-- The counit is a frame homomorphism. -/
def counitAppCont : FrameHom L (Opens <| PT L) where
toFun u := ⟨openOfElementHom L u, u, rfl⟩
map_inf' a b := by simp
map_top' := by simp
map_sSup' S := by ext; simp
/-- The forgetful functor `topToLocale` is left adjoint to the functor `pt`. -/
def adjunctionTopToLocalePT : topToLocale ⊣ pt :=
Adjunction.mkOfUnitCounit
{ unit := { app := fun X ↦ ⟨localePointOfSpacePoint X, continuous_def.2 <|
by rintro _ ⟨u, rfl⟩; simpa using u.2⟩ }
counit := { app := fun L ↦ ⟨counitAppCont L⟩ } }
end locale_top_adjunction
end Locale
|
Topology\Order\Hom\Basic.lean | /-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Order.Hom.Basic
import Mathlib.Topology.ContinuousFunction.Basic
/-!
# Continuous order homomorphisms
This file defines continuous order homomorphisms, that is maps which are both continuous and
monotone. They are also called Priestley homomorphisms because they are the morphisms of the
category of Priestley spaces.
We use the `DFunLike` design, so each type of morphisms has a companion typeclass which is meant to
be satisfied by itself and all stricter types.
## Types of morphisms
* `ContinuousOrderHom`: Continuous monotone functions, aka Priestley homomorphisms.
## Typeclasses
* `ContinuousOrderHomClass`
-/
open Function
variable {F α β γ δ : Type*}
/-- The type of continuous monotone maps from `α` to `β`, aka Priestley homomorphisms. -/
structure ContinuousOrderHom (α β : Type*) [Preorder α] [Preorder β] [TopologicalSpace α]
[TopologicalSpace β] extends OrderHom α β where
continuous_toFun : Continuous toFun
infixr:25 " →Co " => ContinuousOrderHom
section
-- Porting note: extending `ContinuousMapClass` instead of `OrderHomClass`
/-- `ContinuousOrderHomClass F α β` states that `F` is a type of continuous monotone maps.
You should extend this class when you extend `ContinuousOrderHom`. -/
class ContinuousOrderHomClass (F : Type*) (α β : outParam Type*) [Preorder α] [Preorder β]
[TopologicalSpace α] [TopologicalSpace β] [FunLike F α β] extends
ContinuousMapClass F α β : Prop where
map_monotone (f : F) : Monotone f
-- Porting note: namespaced these results since there are more than 3 now
namespace ContinuousOrderHomClass
variable [Preorder α] [Preorder β] [TopologicalSpace α] [TopologicalSpace β]
[FunLike F α β] [ContinuousOrderHomClass F α β]
-- See note [lower instance priority]
instance (priority := 100) toOrderHomClass :
OrderHomClass F α β :=
{ ‹ContinuousOrderHomClass F α β› with
map_rel := ContinuousOrderHomClass.map_monotone }
-- Porting note: following `OrderHomClass.toOrderHom` design, introduced a wrapper
-- for the original coercion. The original one directly exposed
-- ContinuousOrderHom.mk which allowed simp to apply more eagerly than in all
-- the other results in `Topology.Order.Hom.Esakia`.
/-- Turn an element of a type `F` satisfying `ContinuousOrderHomClass F α β` into an actual
`ContinuousOrderHom`. This is declared as the default coercion from `F` to `α →Co β`. -/
@[coe]
def toContinuousOrderHom (f : F) : α →Co β :=
{ toFun := f
monotone' := ContinuousOrderHomClass.map_monotone f
continuous_toFun := map_continuous f }
instance : CoeTC F (α →Co β) :=
⟨toContinuousOrderHom⟩
end ContinuousOrderHomClass
/-! ### Top homomorphisms -/
namespace ContinuousOrderHom
variable [TopologicalSpace α] [Preorder α] [TopologicalSpace β]
section Preorder
variable [Preorder β] [TopologicalSpace γ] [Preorder γ] [TopologicalSpace δ] [Preorder δ]
/-- Reinterpret a `ContinuousOrderHom` as a `ContinuousMap`. -/
def toContinuousMap (f : α →Co β) : C(α, β) :=
{ f with }
instance instFunLike : FunLike (α →Co β) α β where
coe f := f.toFun
coe_injective' f g h := by
obtain ⟨⟨_, _⟩, _⟩ := f
obtain ⟨⟨_, _⟩, _⟩ := g
congr
instance : ContinuousOrderHomClass (α →Co β) α β where
map_monotone f := f.monotone'
map_continuous f := f.continuous_toFun
@[simp] theorem coe_toOrderHom (f : α →Co β) : ⇑f.toOrderHom = f := rfl
theorem toFun_eq_coe {f : α →Co β} : f.toFun = (f : α → β) := rfl
@[ext]
theorem ext {f g : α →Co β} (h : ∀ a, f a = g a) : f = g :=
DFunLike.ext f g h
/-- Copy of a `ContinuousOrderHom` with a new `ContinuousMap` equal to the old one. Useful to fix
definitional equalities. -/
protected def copy (f : α →Co β) (f' : α → β) (h : f' = f) : α →Co β :=
⟨f.toOrderHom.copy f' h, h.symm.subst f.continuous_toFun⟩
@[simp]
theorem coe_copy (f : α →Co β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
theorem copy_eq (f : α →Co β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
DFunLike.ext' h
variable (α)
/-- `id` as a `ContinuousOrderHom`. -/
protected def id : α →Co α :=
⟨OrderHom.id, continuous_id⟩
instance : Inhabited (α →Co α) :=
⟨ContinuousOrderHom.id _⟩
@[simp]
theorem coe_id : ⇑(ContinuousOrderHom.id α) = id :=
rfl
variable {α}
@[simp]
theorem id_apply (a : α) : ContinuousOrderHom.id α a = a :=
rfl
/-- Composition of `ContinuousOrderHom`s as a `ContinuousOrderHom`. -/
def comp (f : β →Co γ) (g : α →Co β) : ContinuousOrderHom α γ :=
⟨f.toOrderHom.comp g.toOrderHom, f.continuous_toFun.comp g.continuous_toFun⟩
@[simp]
theorem coe_comp (f : β →Co γ) (g : α →Co β) : (f.comp g : α → γ) = f ∘ g :=
rfl
@[simp]
theorem comp_apply (f : β →Co γ) (g : α →Co β) (a : α) : (f.comp g) a = f (g a) :=
rfl
@[simp]
theorem comp_assoc (f : γ →Co δ) (g : β →Co γ) (h : α →Co β) :
(f.comp g).comp h = f.comp (g.comp h) :=
rfl
@[simp]
theorem comp_id (f : α →Co β) : f.comp (ContinuousOrderHom.id α) = f :=
ext fun _ => rfl
@[simp]
theorem id_comp (f : α →Co β) : (ContinuousOrderHom.id β).comp f = f :=
ext fun _ => rfl
@[simp]
theorem cancel_right {g₁ g₂ : β →Co γ} {f : α →Co β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 <| DFunLike.ext_iff.1 h, fun h => congr_arg₂ _ h rfl⟩
@[simp]
theorem cancel_left {g : β →Co γ} {f₁ f₂ : α →Co β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun a => hg <| by rw [← comp_apply, h, comp_apply], congr_arg _⟩
instance : Preorder (α →Co β) :=
Preorder.lift ((↑) : (α →Co β) → α → β)
end Preorder
instance [PartialOrder β] : PartialOrder (α →Co β) :=
PartialOrder.lift ((↑) : (α →Co β) → α → β) DFunLike.coe_injective
end ContinuousOrderHom
end
|
Topology\Order\Hom\Esakia.lean | /-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Order.Hom.Bounded
import Mathlib.Topology.Order.Hom.Basic
/-!
# Esakia morphisms
This file defines pseudo-epimorphisms and Esakia morphisms.
We use the `DFunLike` design, so each type of morphisms has a companion typeclass which is meant to
be satisfied by itself and all stricter types.
## Types of morphisms
* `PseudoEpimorphism`: Pseudo-epimorphisms. Maps `f` such that `f a ≤ b` implies the existence of
`a'` such that `a ≤ a'` and `f a' = b`.
* `EsakiaHom`: Esakia morphisms. Continuous pseudo-epimorphisms.
## Typeclasses
* `PseudoEpimorphismClass`
* `EsakiaHomClass`
## References
* [Wikipedia, *Esakia space*](https://en.wikipedia.org/wiki/Esakia_space)
-/
open Function
variable {F α β γ δ : Type*}
/-- The type of pseudo-epimorphisms, aka p-morphisms, aka bounded maps, from `α` to `β`. -/
structure PseudoEpimorphism (α β : Type*) [Preorder α] [Preorder β] extends α →o β where
exists_map_eq_of_map_le' ⦃a : α⦄ ⦃b : β⦄ : toFun a ≤ b → ∃ c, a ≤ c ∧ toFun c = b
/-- The type of Esakia morphisms, aka continuous pseudo-epimorphisms, from `α` to `β`. -/
structure EsakiaHom (α β : Type*) [TopologicalSpace α] [Preorder α] [TopologicalSpace β]
[Preorder β] extends α →Co β where
exists_map_eq_of_map_le' ⦃a : α⦄ ⦃b : β⦄ : toFun a ≤ b → ∃ c, a ≤ c ∧ toFun c = b
section
/-- `PseudoEpimorphismClass F α β` states that `F` is a type of `⊔`-preserving morphisms.
You should extend this class when you extend `PseudoEpimorphism`. -/
class PseudoEpimorphismClass (F : Type*) (α β : outParam Type*)
[Preorder α] [Preorder β] [FunLike F α β]
extends RelHomClass F ((· ≤ ·) : α → α → Prop) ((· ≤ ·) : β → β → Prop) : Prop where
exists_map_eq_of_map_le (f : F) ⦃a : α⦄ ⦃b : β⦄ : f a ≤ b → ∃ c, a ≤ c ∧ f c = b
/-- `EsakiaHomClass F α β` states that `F` is a type of lattice morphisms.
You should extend this class when you extend `EsakiaHom`. -/
class EsakiaHomClass (F : Type*) (α β : outParam Type*) [TopologicalSpace α] [Preorder α]
[TopologicalSpace β] [Preorder β] [FunLike F α β]
extends ContinuousOrderHomClass F α β : Prop where
exists_map_eq_of_map_le (f : F) ⦃a : α⦄ ⦃b : β⦄ : f a ≤ b → ∃ c, a ≤ c ∧ f c = b
end
export PseudoEpimorphismClass (exists_map_eq_of_map_le)
section Hom
variable [FunLike F α β]
-- See note [lower instance priority]
instance (priority := 100) PseudoEpimorphismClass.toTopHomClass [PartialOrder α] [OrderTop α]
[Preorder β] [OrderTop β] [PseudoEpimorphismClass F α β] : TopHomClass F α β where
map_top f := by
let ⟨b, h⟩ := exists_map_eq_of_map_le f (@le_top _ _ _ <| f ⊤)
rw [← top_le_iff.1 h.1, h.2]
-- See note [lower instance priority]
instance (priority := 100) EsakiaHomClass.toPseudoEpimorphismClass [TopologicalSpace α] [Preorder α]
[TopologicalSpace β] [Preorder β] [EsakiaHomClass F α β] : PseudoEpimorphismClass F α β :=
{ ‹EsakiaHomClass F α β› with
map_rel := ContinuousOrderHomClass.map_monotone }
instance [Preorder α] [Preorder β] [PseudoEpimorphismClass F α β] :
CoeTC F (PseudoEpimorphism α β) :=
⟨fun f => ⟨f, exists_map_eq_of_map_le f⟩⟩
instance [TopologicalSpace α] [Preorder α] [TopologicalSpace β] [Preorder β]
[EsakiaHomClass F α β] : CoeTC F (EsakiaHom α β) :=
⟨fun f => ⟨f, exists_map_eq_of_map_le f⟩⟩
end Hom
-- See note [lower instance priority]
instance (priority := 100) OrderIsoClass.toPseudoEpimorphismClass [Preorder α] [Preorder β]
[EquivLike F α β] [OrderIsoClass F α β] : PseudoEpimorphismClass F α β where
exists_map_eq_of_map_le f _a b h :=
⟨EquivLike.inv f b, (le_map_inv_iff f).2 h, EquivLike.right_inv _ _⟩
/-! ### Pseudo-epimorphisms -/
namespace PseudoEpimorphism
variable [Preorder α] [Preorder β] [Preorder γ] [Preorder δ]
instance instFunLike : FunLike (PseudoEpimorphism α β) α β where
coe f := f.toFun
coe_injective' f g h := by
obtain ⟨⟨_, _⟩, _⟩ := f
obtain ⟨⟨_, _⟩, _⟩ := g
congr
instance : PseudoEpimorphismClass (PseudoEpimorphism α β) α β where
map_rel f _ _ h := f.monotone' h
exists_map_eq_of_map_le := PseudoEpimorphism.exists_map_eq_of_map_le'
@[simp]
theorem toOrderHom_eq_coe (f : PseudoEpimorphism α β) : ⇑f.toOrderHom = f := rfl
theorem toFun_eq_coe {f : PseudoEpimorphism α β} : f.toFun = (f : α → β) := rfl
@[ext]
theorem ext {f g : PseudoEpimorphism α β} (h : ∀ a, f a = g a) : f = g :=
DFunLike.ext f g h
/-- Copy of a `PseudoEpimorphism` with a new `toFun` equal to the old one. Useful to fix
definitional equalities. -/
protected def copy (f : PseudoEpimorphism α β) (f' : α → β) (h : f' = f) : PseudoEpimorphism α β :=
⟨f.toOrderHom.copy f' h, by simpa only [h.symm, toFun_eq_coe] using f.exists_map_eq_of_map_le'⟩
@[simp]
theorem coe_copy (f : PseudoEpimorphism α β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' := rfl
theorem copy_eq (f : PseudoEpimorphism α β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
DFunLike.ext' h
variable (α)
/-- `id` as a `PseudoEpimorphism`. -/
protected def id : PseudoEpimorphism α α :=
⟨OrderHom.id, fun _ b h => ⟨b, h, rfl⟩⟩
instance : Inhabited (PseudoEpimorphism α α) :=
⟨PseudoEpimorphism.id α⟩
@[simp]
theorem coe_id : ⇑(PseudoEpimorphism.id α) = id := rfl
@[simp]
theorem coe_id_orderHom : (PseudoEpimorphism.id α : α →o α) = OrderHom.id := rfl
variable {α}
@[simp]
theorem id_apply (a : α) : PseudoEpimorphism.id α a = a := rfl
/-- Composition of `PseudoEpimorphism`s as a `PseudoEpimorphism`. -/
def comp (g : PseudoEpimorphism β γ) (f : PseudoEpimorphism α β) : PseudoEpimorphism α γ :=
⟨g.toOrderHom.comp f.toOrderHom, fun a b h₀ => by
obtain ⟨b, h₁, rfl⟩ := g.exists_map_eq_of_map_le' h₀
obtain ⟨b, h₂, rfl⟩ := f.exists_map_eq_of_map_le' h₁
exact ⟨b, h₂, rfl⟩⟩
@[simp]
theorem coe_comp (g : PseudoEpimorphism β γ) (f : PseudoEpimorphism α β) :
(g.comp f : α → γ) = g ∘ f := rfl
@[simp]
theorem coe_comp_orderHom (g : PseudoEpimorphism β γ) (f : PseudoEpimorphism α β) :
(g.comp f : α →o γ) = (g : β →o γ).comp f := rfl
@[simp]
theorem comp_apply (g : PseudoEpimorphism β γ) (f : PseudoEpimorphism α β) (a : α) :
(g.comp f) a = g (f a) := rfl
@[simp]
theorem comp_assoc (h : PseudoEpimorphism γ δ) (g : PseudoEpimorphism β γ)
(f : PseudoEpimorphism α β) : (h.comp g).comp f = h.comp (g.comp f) := rfl
@[simp]
theorem comp_id (f : PseudoEpimorphism α β) : f.comp (PseudoEpimorphism.id α) = f :=
ext fun _ => rfl
@[simp]
theorem id_comp (f : PseudoEpimorphism α β) : (PseudoEpimorphism.id β).comp f = f :=
ext fun _ => rfl
@[simp]
theorem cancel_right {g₁ g₂ : PseudoEpimorphism β γ} {f : PseudoEpimorphism α β}
(hf : Surjective f) : g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 <| DFunLike.ext_iff.1 h, congr_arg (comp · f)⟩
@[simp]
theorem cancel_left {g : PseudoEpimorphism β γ} {f₁ f₂ : PseudoEpimorphism α β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun a => hg <| by rw [← comp_apply, h, comp_apply], congr_arg _⟩
end PseudoEpimorphism
/-! ### Esakia morphisms -/
namespace EsakiaHom
variable [TopologicalSpace α] [Preorder α] [TopologicalSpace β] [Preorder β] [TopologicalSpace γ]
[Preorder γ] [TopologicalSpace δ] [Preorder δ]
def toPseudoEpimorphism (f : EsakiaHom α β) : PseudoEpimorphism α β :=
{ f with }
instance instFunLike : FunLike (EsakiaHom α β) α β where
coe f := f.toFun
coe_injective' f g h := by
obtain ⟨⟨⟨_, _⟩, _⟩, _⟩ := f
obtain ⟨⟨⟨_, _⟩, _⟩, _⟩ := g
congr
instance : EsakiaHomClass (EsakiaHom α β) α β where
map_monotone f := f.monotone'
map_continuous f := f.continuous_toFun
exists_map_eq_of_map_le f := f.exists_map_eq_of_map_le'
-- Porting note: introduced this to appease simpNF linter with `toFun_eq_coe`
@[simp]
theorem toContinuousOrderHom_coe {f : EsakiaHom α β} :
f.toContinuousOrderHom = (f : α → β) := rfl
-- Porting note: removed simp attribute as simp now solves this
theorem toFun_eq_coe {f : EsakiaHom α β} : f.toFun = (f : α → β) := rfl
@[ext]
theorem ext {f g : EsakiaHom α β} (h : ∀ a, f a = g a) : f = g :=
DFunLike.ext f g h
/-- Copy of an `EsakiaHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : EsakiaHom α β) (f' : α → β) (h : f' = f) : EsakiaHom α β :=
⟨f.toContinuousOrderHom.copy f' h, by
simpa only [h.symm, toFun_eq_coe] using f.exists_map_eq_of_map_le'⟩
@[simp]
theorem coe_copy (f : EsakiaHom α β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' := rfl
theorem copy_eq (f : EsakiaHom α β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
DFunLike.ext' h
variable (α)
/-- `id` as an `EsakiaHom`. -/
protected def id : EsakiaHom α α :=
⟨ContinuousOrderHom.id α, fun _ b h => ⟨b, h, rfl⟩⟩
instance : Inhabited (EsakiaHom α α) :=
⟨EsakiaHom.id α⟩
@[simp]
theorem coe_id : ⇑(EsakiaHom.id α) = id := rfl
@[simp]
theorem coe_id_pseudoEpimorphism :
(EsakiaHom.id α : PseudoEpimorphism α α) = PseudoEpimorphism.id α := rfl
variable {α}
@[simp]
theorem id_apply (a : α) : EsakiaHom.id α a = a := rfl
@[simp]
theorem coe_id_continuousOrderHom : (EsakiaHom.id α : α →Co α) = ContinuousOrderHom.id α := rfl
/-- Composition of `EsakiaHom`s as an `EsakiaHom`. -/
def comp (g : EsakiaHom β γ) (f : EsakiaHom α β) : EsakiaHom α γ :=
⟨g.toContinuousOrderHom.comp f.toContinuousOrderHom, fun a b h₀ => by
obtain ⟨b, h₁, rfl⟩ := g.exists_map_eq_of_map_le' h₀
obtain ⟨b, h₂, rfl⟩ := f.exists_map_eq_of_map_le' h₁
exact ⟨b, h₂, rfl⟩⟩
@[simp]
theorem coe_comp_continuousOrderHom (g : EsakiaHom β γ) (f : EsakiaHom α β) :
(g.comp f : α →Co γ) = (g : β →Co γ).comp f := rfl
@[simp]
theorem coe_comp_pseudoEpimorphism (g : EsakiaHom β γ) (f : EsakiaHom α β) :
(g.comp f : PseudoEpimorphism α γ) = (g : PseudoEpimorphism β γ).comp f := rfl
@[simp]
theorem coe_comp (g : EsakiaHom β γ) (f : EsakiaHom α β) : (g.comp f : α → γ) = g ∘ f := rfl
@[simp]
theorem comp_apply (g : EsakiaHom β γ) (f : EsakiaHom α β) (a : α) : (g.comp f) a = g (f a) := rfl
@[simp]
theorem comp_assoc (h : EsakiaHom γ δ) (g : EsakiaHom β γ) (f : EsakiaHom α β) :
(h.comp g).comp f = h.comp (g.comp f) := rfl
@[simp]
theorem comp_id (f : EsakiaHom α β) : f.comp (EsakiaHom.id α) = f :=
ext fun _ => rfl
@[simp]
theorem id_comp (f : EsakiaHom α β) : (EsakiaHom.id β).comp f = f :=
ext fun _ => rfl
@[simp]
theorem cancel_right {g₁ g₂ : EsakiaHom β γ} {f : EsakiaHom α β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 <| DFunLike.ext_iff.1 h, congr_arg (comp · f)⟩
@[simp]
theorem cancel_left {g : EsakiaHom β γ} {f₁ f₂ : EsakiaHom α β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun a => hg <| by rw [← comp_apply, h, comp_apply], congr_arg _⟩
end EsakiaHom
|
Topology\Separation\NotNormal.lean | /-
Copyright (c) 2023 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Data.Real.Cardinality
import Mathlib.Topology.Separation
import Mathlib.Topology.TietzeExtension
/-!
# Not normal topological spaces
In this file we prove (see `IsClosed.not_normal_of_continuum_le_mk`) that a separable space with a
discrete subspace of cardinality continuum is not a normal topological space.
-/
open Set Function Cardinal Topology TopologicalSpace
universe u
variable {X : Type u} [TopologicalSpace X] [SeparableSpace X]
/-- Let `s` be a closed set in a separable normal space. If the induced topology on `s` is discrete,
then `s` has cardinality less than continuum.
The proof follows
https://en.wikipedia.org/wiki/Moore_plane#Proof_that_the_Moore_plane_is_not_normal -/
theorem IsClosed.mk_lt_continuum [NormalSpace X] {s : Set X} (hs : IsClosed s)
[DiscreteTopology s] : #s < 𝔠 := by
-- Proof by contradiction: assume `𝔠 ≤ #s`
by_contra! h
-- Choose a countable dense set `t : Set X`
rcases exists_countable_dense X with ⟨t, htc, htd⟩
haveI := htc.to_subtype
-- To obtain a contradiction, we will prove `2 ^ 𝔠 ≤ 𝔠`.
refine (Cardinal.cantor 𝔠).not_le ?_
calc
-- Any function `s → ℝ` is continuous, hence `2 ^ 𝔠 ≤ #C(s, ℝ)`
2 ^ 𝔠 ≤ #C(s, ℝ) := by
rw [(ContinuousMap.equivFnOfDiscrete _ _).cardinal_eq, mk_arrow, mk_real, lift_continuum,
lift_uzero]
exact (power_le_power_left two_ne_zero h).trans (power_le_power_right (nat_lt_continuum 2).le)
-- By the Tietze Extension Theorem, any function `f : C(s, ℝ)` can be extended to `C(X, ℝ)`,
-- hence `#C(s, ℝ) ≤ #C(X, ℝ)`
_ ≤ #C(X, ℝ) := by
choose f hf using ContinuousMap.exists_restrict_eq (Y := ℝ) hs
have hfi : Injective f := LeftInverse.injective hf
exact mk_le_of_injective hfi
-- Since `t` is dense, restriction `C(X, ℝ) → C(t, ℝ)` is injective, hence `#C(X, ℝ) ≤ #C(t, ℝ)`
_ ≤ #C(t, ℝ) := mk_le_of_injective <| ContinuousMap.injective_restrict htd
_ ≤ #(t → ℝ) := mk_le_of_injective DFunLike.coe_injective
-- Since `t` is countable, we have `#(t → ℝ) ≤ 𝔠`
_ ≤ 𝔠 := by
rw [mk_arrow, mk_real, lift_uzero, lift_continuum, continuum, ← power_mul]
exact power_le_power_left two_ne_zero mk_le_aleph0
/-- Let `s` be a closed set in a separable space. If the induced topology on `s` is discrete and `s`
has cardinality at least continuum, then the ambient space is not a normal space. -/
theorem IsClosed.not_normal_of_continuum_le_mk {s : Set X} (hs : IsClosed s) [DiscreteTopology s]
(hmk : 𝔠 ≤ #s) : ¬NormalSpace X := fun _ ↦ hs.mk_lt_continuum.not_le hmk
|
Topology\Sets\Closeds.lean | /-
Copyright (c) 2020 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn, Yaël Dillies
-/
import Mathlib.Topology.Sets.Opens
/-!
# Closed sets
We define a few types of closed sets in a topological space.
## Main Definitions
For a topological space `α`,
* `TopologicalSpace.Closeds α`: The type of closed sets.
* `TopologicalSpace.Clopens α`: The type of clopen sets.
-/
open Order OrderDual Set
variable {ι α β : Type*} [TopologicalSpace α] [TopologicalSpace β]
namespace TopologicalSpace
/-! ### Closed sets -/
/-- The type of closed subsets of a topological space. -/
structure Closeds (α : Type*) [TopologicalSpace α] where
/-- the carrier set, i.e. the points in this set -/
carrier : Set α
closed' : IsClosed carrier
namespace Closeds
instance : SetLike (Closeds α) α where
coe := Closeds.carrier
coe_injective' s t h := by cases s; cases t; congr
instance : CanLift (Set α) (Closeds α) (↑) IsClosed where
prf s hs := ⟨⟨s, hs⟩, rfl⟩
theorem closed (s : Closeds α) : IsClosed (s : Set α) :=
s.closed'
/-- See Note [custom simps projection]. -/
def Simps.coe (s : Closeds α) : Set α := s
initialize_simps_projections Closeds (carrier → coe, as_prefix coe)
@[ext]
protected theorem ext {s t : Closeds α} (h : (s : Set α) = t) : s = t :=
SetLike.ext' h
@[simp]
theorem coe_mk (s : Set α) (h) : (mk s h : Set α) = s :=
rfl
/-- The closure of a set, as an element of `TopologicalSpace.Closeds`. -/
@[simps]
protected def closure (s : Set α) : Closeds α :=
⟨closure s, isClosed_closure⟩
theorem gc : GaloisConnection Closeds.closure ((↑) : Closeds α → Set α) := fun _ U =>
⟨subset_closure.trans, fun h => closure_minimal h U.closed⟩
/-- The galois coinsertion between sets and opens. -/
def gi : GaloisInsertion (@Closeds.closure α _) (↑) where
choice s hs := ⟨s, closure_eq_iff_isClosed.1 <| hs.antisymm subset_closure⟩
gc := gc
le_l_u _ := subset_closure
choice_eq _s hs := SetLike.coe_injective <| subset_closure.antisymm hs
instance completeLattice : CompleteLattice (Closeds α) :=
CompleteLattice.copy
(GaloisInsertion.liftCompleteLattice gi)
-- le
_ rfl
-- top
⟨univ, isClosed_univ⟩ rfl
-- bot
⟨∅, isClosed_empty⟩ (SetLike.coe_injective closure_empty.symm)
-- sup
(fun s t => ⟨s ∪ t, s.2.union t.2⟩)
(funext fun s => funext fun t => SetLike.coe_injective (s.2.union t.2).closure_eq.symm)
-- inf
(fun s t => ⟨s ∩ t, s.2.inter t.2⟩) rfl
-- sSup
_ rfl
-- sInf
(fun S => ⟨⋂ s ∈ S, ↑s, isClosed_biInter fun s _ => s.2⟩)
(funext fun _ => SetLike.coe_injective sInf_image.symm)
/-- The type of closed sets is inhabited, with default element the empty set. -/
instance : Inhabited (Closeds α) :=
⟨⊥⟩
@[simp, norm_cast]
theorem coe_sup (s t : Closeds α) : (↑(s ⊔ t) : Set α) = ↑s ∪ ↑t := by
rfl
@[simp, norm_cast]
theorem coe_inf (s t : Closeds α) : (↑(s ⊓ t) : Set α) = ↑s ∩ ↑t :=
rfl
@[simp, norm_cast]
theorem coe_top : (↑(⊤ : Closeds α) : Set α) = univ :=
rfl
@[simp, norm_cast]
theorem coe_eq_univ {s : Closeds α} : (s : Set α) = univ ↔ s = ⊤ :=
SetLike.coe_injective.eq_iff' rfl
@[simp, norm_cast]
theorem coe_bot : (↑(⊥ : Closeds α) : Set α) = ∅ :=
rfl
@[simp, norm_cast]
theorem coe_eq_empty {s : Closeds α} : (s : Set α) = ∅ ↔ s = ⊥ :=
SetLike.coe_injective.eq_iff' rfl
theorem coe_nonempty {s : Closeds α} : (s : Set α).Nonempty ↔ s ≠ ⊥ :=
nonempty_iff_ne_empty.trans coe_eq_empty.not
@[simp, norm_cast]
theorem coe_sInf {S : Set (Closeds α)} : (↑(sInf S) : Set α) = ⋂ i ∈ S, ↑i :=
rfl
@[simp]
lemma coe_sSup {S : Set (Closeds α)} : ((sSup S : Closeds α) : Set α) =
closure (⋃₀ ((↑) '' S)) := by rfl
@[simp, norm_cast]
theorem coe_finset_sup (f : ι → Closeds α) (s : Finset ι) :
(↑(s.sup f) : Set α) = s.sup ((↑) ∘ f) :=
map_finset_sup (⟨⟨(↑), coe_sup⟩, coe_bot⟩ : SupBotHom (Closeds α) (Set α)) _ _
@[simp, norm_cast]
theorem coe_finset_inf (f : ι → Closeds α) (s : Finset ι) :
(↑(s.inf f) : Set α) = s.inf ((↑) ∘ f) :=
map_finset_inf (⟨⟨(↑), coe_inf⟩, coe_top⟩ : InfTopHom (Closeds α) (Set α)) _ _
-- Porting note: Lean 3 proofs didn't work as expected, so I reordered lemmas to fix&golf the proofs
@[simp]
theorem mem_sInf {S : Set (Closeds α)} {x : α} : x ∈ sInf S ↔ ∀ s ∈ S, x ∈ s := mem_iInter₂
@[simp]
theorem mem_iInf {ι} {x : α} {s : ι → Closeds α} : x ∈ iInf s ↔ ∀ i, x ∈ s i := by simp [iInf]
@[simp, norm_cast]
theorem coe_iInf {ι} (s : ι → Closeds α) : ((⨅ i, s i : Closeds α) : Set α) = ⋂ i, s i := by
ext; simp
theorem iInf_def {ι} (s : ι → Closeds α) :
⨅ i, s i = ⟨⋂ i, s i, isClosed_iInter fun i => (s i).2⟩ := by ext1; simp
@[simp]
theorem iInf_mk {ι} (s : ι → Set α) (h : ∀ i, IsClosed (s i)) :
(⨅ i, ⟨s i, h i⟩ : Closeds α) = ⟨⋂ i, s i, isClosed_iInter h⟩ :=
iInf_def _
/-- Closed sets in a topological space form a coframe. -/
def coframeMinimalAxioms : Coframe.MinimalAxioms (Closeds α) where
iInf_sup_le_sup_sInf a s :=
(SetLike.coe_injective <| by simp only [coe_sup, coe_iInf, coe_sInf, Set.union_iInter₂]).le
instance instCoframe : Coframe (Closeds α) := .ofMinimalAxioms coframeMinimalAxioms
/-- The term of `TopologicalSpace.Closeds α` corresponding to a singleton. -/
@[simps]
def singleton [T1Space α] (x : α) : Closeds α :=
⟨{x}, isClosed_singleton⟩
@[simp] lemma mem_singleton [T1Space α] {a b : α} : a ∈ singleton b ↔ a = b := Iff.rfl
end Closeds
/-- The complement of a closed set as an open set. -/
@[simps]
def Closeds.compl (s : Closeds α) : Opens α :=
⟨sᶜ, s.2.isOpen_compl⟩
/-- The complement of an open set as a closed set. -/
@[simps]
def Opens.compl (s : Opens α) : Closeds α :=
⟨sᶜ, s.2.isClosed_compl⟩
nonrec theorem Closeds.compl_compl (s : Closeds α) : s.compl.compl = s :=
Closeds.ext (compl_compl (s : Set α))
nonrec theorem Opens.compl_compl (s : Opens α) : s.compl.compl = s :=
Opens.ext (compl_compl (s : Set α))
theorem Closeds.compl_bijective : Function.Bijective (@Closeds.compl α _) :=
Function.bijective_iff_has_inverse.mpr ⟨Opens.compl, Closeds.compl_compl, Opens.compl_compl⟩
theorem Opens.compl_bijective : Function.Bijective (@Opens.compl α _) :=
Function.bijective_iff_has_inverse.mpr ⟨Closeds.compl, Opens.compl_compl, Closeds.compl_compl⟩
variable (α)
/-- `TopologicalSpace.Closeds.compl` as an `OrderIso` to the order dual of
`TopologicalSpace.Opens α`. -/
@[simps]
def Closeds.complOrderIso : Closeds α ≃o (Opens α)ᵒᵈ where
toFun := OrderDual.toDual ∘ Closeds.compl
invFun := Opens.compl ∘ OrderDual.ofDual
left_inv s := by simp [Closeds.compl_compl]
right_inv s := by simp [Opens.compl_compl]
map_rel_iff' := (@OrderDual.toDual_le_toDual (Opens α)).trans compl_subset_compl
/-- `TopologicalSpace.Opens.compl` as an `OrderIso` to the order dual of
`TopologicalSpace.Closeds α`. -/
@[simps]
def Opens.complOrderIso : Opens α ≃o (Closeds α)ᵒᵈ where
toFun := OrderDual.toDual ∘ Opens.compl
invFun := Closeds.compl ∘ OrderDual.ofDual
left_inv s := by simp [Opens.compl_compl]
right_inv s := by simp [Closeds.compl_compl]
map_rel_iff' := (@OrderDual.toDual_le_toDual (Closeds α)).trans compl_subset_compl
variable {α}
lemma Closeds.coe_eq_singleton_of_isAtom [T0Space α] {s : Closeds α} (hs : IsAtom s) :
∃ a, (s : Set α) = {a} := by
refine minimal_nonempty_closed_eq_singleton s.2 (coe_nonempty.2 hs.1) fun t hts ht ht' ↦ ?_
lift t to Closeds α using ht'
exact SetLike.coe_injective.eq_iff.2 <| (hs.le_iff_eq <| coe_nonempty.1 ht).1 hts
@[simp, norm_cast] lemma Closeds.isAtom_coe [T1Space α] {s : Closeds α} :
IsAtom (s : Set α) ↔ IsAtom s :=
Closeds.gi.isAtom_iff' rfl
(fun t ht ↦ by obtain ⟨x, rfl⟩ := Set.isAtom_iff.1 ht; exact closure_singleton) s
/-- in a `T1Space`, atoms of `TopologicalSpace.Closeds α` are precisely the
`TopologicalSpace.Closeds.singleton`s. -/
theorem Closeds.isAtom_iff [T1Space α] {s : Closeds α} :
IsAtom s ↔ ∃ x, s = Closeds.singleton x := by
simp [← Closeds.isAtom_coe, Set.isAtom_iff, SetLike.ext_iff, Set.ext_iff]
/-- in a `T1Space`, coatoms of `TopologicalSpace.Opens α` are precisely complements of singletons:
`(TopologicalSpace.Closeds.singleton x).compl`. -/
theorem Opens.isCoatom_iff [T1Space α] {s : Opens α} :
IsCoatom s ↔ ∃ x, s = (Closeds.singleton x).compl := by
rw [← s.compl_compl, ← isAtom_dual_iff_isCoatom]
change IsAtom (Closeds.complOrderIso α s.compl) ↔ _
simp only [(Closeds.complOrderIso α).isAtom_iff, Closeds.isAtom_iff,
Closeds.compl_bijective.injective.eq_iff]
/-! ### Clopen sets -/
/-- The type of clopen sets of a topological space. -/
structure Clopens (α : Type*) [TopologicalSpace α] where
/-- the carrier set, i.e. the points in this set -/
carrier : Set α
isClopen' : IsClopen carrier
namespace Clopens
instance : SetLike (Clopens α) α where
coe s := s.carrier
coe_injective' s t h := by cases s; cases t; congr
theorem isClopen (s : Clopens α) : IsClopen (s : Set α) :=
s.isClopen'
/-- See Note [custom simps projection]. -/
def Simps.coe (s : Clopens α) : Set α := s
initialize_simps_projections Clopens (carrier → coe)
/-- Reinterpret a clopen as an open. -/
@[simps]
def toOpens (s : Clopens α) : Opens α :=
⟨s, s.isClopen.isOpen⟩
@[ext]
protected theorem ext {s t : Clopens α} (h : (s : Set α) = t) : s = t :=
SetLike.ext' h
@[simp]
theorem coe_mk (s : Set α) (h) : (mk s h : Set α) = s :=
rfl
@[simp] lemma mem_mk {s : Set α} {x h} : x ∈ mk s h ↔ x ∈ s := .rfl
instance : Sup (Clopens α) := ⟨fun s t => ⟨s ∪ t, s.isClopen.union t.isClopen⟩⟩
instance : Inf (Clopens α) := ⟨fun s t => ⟨s ∩ t, s.isClopen.inter t.isClopen⟩⟩
instance : Top (Clopens α) := ⟨⟨⊤, isClopen_univ⟩⟩
instance : Bot (Clopens α) := ⟨⟨⊥, isClopen_empty⟩⟩
instance : SDiff (Clopens α) := ⟨fun s t => ⟨s \ t, s.isClopen.diff t.isClopen⟩⟩
instance : HImp (Clopens α) where himp s t := ⟨s ⇨ t, s.isClopen.himp t.isClopen⟩
instance : HasCompl (Clopens α) := ⟨fun s => ⟨sᶜ, s.isClopen.compl⟩⟩
@[simp, norm_cast] lemma coe_sup (s t : Clopens α) : ↑(s ⊔ t) = (s ∪ t : Set α) := rfl
@[simp, norm_cast] lemma coe_inf (s t : Clopens α) : ↑(s ⊓ t) = (s ∩ t : Set α) := rfl
@[simp, norm_cast] lemma coe_top : (↑(⊤ : Clopens α) : Set α) = univ := rfl
@[simp, norm_cast] lemma coe_bot : (↑(⊥ : Clopens α) : Set α) = ∅ := rfl
@[simp, norm_cast] lemma coe_sdiff (s t : Clopens α) : ↑(s \ t) = (s \ t : Set α) := rfl
@[simp, norm_cast] lemma coe_himp (s t : Clopens α) : ↑(s ⇨ t) = (s ⇨ t : Set α) := rfl
@[simp, norm_cast] lemma coe_compl (s : Clopens α) : (↑sᶜ : Set α) = (↑s)ᶜ := rfl
instance : BooleanAlgebra (Clopens α) :=
SetLike.coe_injective.booleanAlgebra _ coe_sup coe_inf coe_top coe_bot coe_compl coe_sdiff
coe_himp
instance : Inhabited (Clopens α) := ⟨⊥⟩
instance : SProd (Clopens α) (Clopens β) (Clopens (α × β)) where
sprod s t := ⟨s ×ˢ t, s.2.prod t.2⟩
@[simp]
protected lemma mem_prod {s : Clopens α} {t : Clopens β} {x : α × β} :
x ∈ s ×ˢ t ↔ x.1 ∈ s ∧ x.2 ∈ t := .rfl
end Clopens
/-! ### Irreducible closed sets -/
/-- The type of irreducible closed subsets of a topological space. -/
structure IrreducibleCloseds (α : Type*) [TopologicalSpace α] where
/-- the carrier set, i.e. the points in this set -/
carrier : Set α
is_irreducible' : IsIrreducible carrier
is_closed' : IsClosed carrier
namespace IrreducibleCloseds
instance : SetLike (IrreducibleCloseds α) α where
coe := IrreducibleCloseds.carrier
coe_injective' s t h := by cases s; cases t; congr
instance : CanLift (Set α) (IrreducibleCloseds α) (↑) (fun s ↦ IsIrreducible s ∧ IsClosed s) where
prf s hs := ⟨⟨s, hs.1, hs.2⟩, rfl⟩
theorem isIrreducible (s : IrreducibleCloseds α) : IsIrreducible (s : Set α) := s.is_irreducible'
theorem isClosed (s : IrreducibleCloseds α) : IsClosed (s : Set α) := s.is_closed'
/-- See Note [custom simps projection]. -/
def Simps.coe (s : IrreducibleCloseds α) : Set α := s
initialize_simps_projections IrreducibleCloseds (carrier → coe, as_prefix coe)
@[ext]
protected theorem ext {s t : IrreducibleCloseds α} (h : (s : Set α) = t) : s = t :=
SetLike.ext' h
@[simp]
theorem coe_mk (s : Set α) (h : IsIrreducible s) (h' : IsClosed s) : (mk s h h' : Set α) = s :=
rfl
/-- The term of `TopologicalSpace.IrreducibleCloseds α` corresponding to a singleton. -/
@[simps]
def singleton [T1Space α] (x : α) : IrreducibleCloseds α :=
⟨{x}, isIrreducible_singleton, isClosed_singleton⟩
@[simp] lemma mem_singleton [T1Space α] {a b : α} : a ∈ singleton b ↔ a = b := Iff.rfl
/--
The equivalence between `IrreducibleCloseds α` and `{x : Set α // IsIrreducible x ∧ IsClosed x }`.
-/
@[simps apply symm_apply]
def equivSubtype : IrreducibleCloseds α ≃ { x : Set α // IsIrreducible x ∧ IsClosed x } where
toFun a := ⟨a.1, a.2, a.3⟩
invFun a := ⟨a.1, a.2.1, a.2.2⟩
left_inv := fun ⟨_, _, _⟩ => rfl
right_inv := fun ⟨_, _, _⟩ => rfl
/--
The equivalence between `IrreducibleCloseds α` and `{x : Set α // IsClosed x ∧ IsIrreducible x }`.
-/
@[simps apply symm_apply]
def equivSubtype' : IrreducibleCloseds α ≃ { x : Set α // IsClosed x ∧ IsIrreducible x } where
toFun a := ⟨a.1, a.3, a.2⟩
invFun a := ⟨a.1, a.2.2, a.2.1⟩
left_inv := fun ⟨_, _, _⟩ => rfl
right_inv := fun ⟨_, _, _⟩ => rfl
variable (α) in
/-- The equivalence `IrreducibleCloseds α ≃ { x : Set α // IsIrreducible x ∧ IsClosed x }` is an
order isomorphism.-/
def orderIsoSubtype : IrreducibleCloseds α ≃o { x : Set α // IsIrreducible x ∧ IsClosed x } :=
equivSubtype.toOrderIso (fun _ _ h ↦ h) (fun _ _ h ↦ h)
variable (α) in
/-- The equivalence `IrreducibleCloseds α ≃ { x : Set α // IsClosed x ∧ IsIrreducible x }` is an
order isomorphism.-/
def orderIsoSubtype' : IrreducibleCloseds α ≃o { x : Set α // IsClosed x ∧ IsIrreducible x } :=
equivSubtype'.toOrderIso (fun _ _ h ↦ h) (fun _ _ h ↦ h)
end IrreducibleCloseds
end TopologicalSpace
|
Topology\Sets\Compacts.lean | /-
Copyright (c) 2020 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn, Yaël Dillies
-/
import Mathlib.Topology.Sets.Closeds
import Mathlib.Topology.QuasiSeparated
/-!
# Compact sets
We define a few types of compact sets in a topological space.
## Main Definitions
For a topological space `α`,
* `TopologicalSpace.Compacts α`: The type of compact sets.
* `TopologicalSpace.NonemptyCompacts α`: The type of non-empty compact sets.
* `TopologicalSpace.PositiveCompacts α`: The type of compact sets with non-empty interior.
* `TopologicalSpace.CompactOpens α`: The type of compact open sets. This is a central object in the
study of spectral spaces.
-/
open Set
variable {α β γ : Type*} [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ]
namespace TopologicalSpace
/-! ### Compact sets -/
/-- The type of compact sets of a topological space. -/
structure Compacts (α : Type*) [TopologicalSpace α] where
/-- the carrier set, i.e. the points in this set -/
carrier : Set α
isCompact' : IsCompact carrier
namespace Compacts
instance : SetLike (Compacts α) α where
coe := Compacts.carrier
coe_injective' s t h := by cases s; cases t; congr
/-- See Note [custom simps projection]. -/
def Simps.coe (s : Compacts α) : Set α := s
initialize_simps_projections Compacts (carrier → coe)
protected theorem isCompact (s : Compacts α) : IsCompact (s : Set α) :=
s.isCompact'
instance (K : Compacts α) : CompactSpace K :=
isCompact_iff_compactSpace.1 K.isCompact
instance : CanLift (Set α) (Compacts α) (↑) IsCompact where prf K hK := ⟨⟨K, hK⟩, rfl⟩
@[ext]
protected theorem ext {s t : Compacts α} (h : (s : Set α) = t) : s = t :=
SetLike.ext' h
@[simp]
theorem coe_mk (s : Set α) (h) : (mk s h : Set α) = s :=
rfl
@[simp]
theorem carrier_eq_coe (s : Compacts α) : s.carrier = s :=
rfl
instance : Sup (Compacts α) :=
⟨fun s t => ⟨s ∪ t, s.isCompact.union t.isCompact⟩⟩
instance [T2Space α] : Inf (Compacts α) :=
⟨fun s t => ⟨s ∩ t, s.isCompact.inter t.isCompact⟩⟩
instance [CompactSpace α] : Top (Compacts α) :=
⟨⟨univ, isCompact_univ⟩⟩
instance : Bot (Compacts α) :=
⟨⟨∅, isCompact_empty⟩⟩
instance : SemilatticeSup (Compacts α) :=
SetLike.coe_injective.semilatticeSup _ fun _ _ => rfl
instance [T2Space α] : DistribLattice (Compacts α) :=
SetLike.coe_injective.distribLattice _ (fun _ _ => rfl) fun _ _ => rfl
instance : OrderBot (Compacts α) :=
OrderBot.lift ((↑) : _ → Set α) (fun _ _ => id) rfl
instance [CompactSpace α] : BoundedOrder (Compacts α) :=
BoundedOrder.lift ((↑) : _ → Set α) (fun _ _ => id) rfl rfl
/-- The type of compact sets is inhabited, with default element the empty set. -/
instance : Inhabited (Compacts α) := ⟨⊥⟩
@[simp]
theorem coe_sup (s t : Compacts α) : (↑(s ⊔ t) : Set α) = ↑s ∪ ↑t :=
rfl
@[simp]
theorem coe_inf [T2Space α] (s t : Compacts α) : (↑(s ⊓ t) : Set α) = ↑s ∩ ↑t :=
rfl
@[simp]
theorem coe_top [CompactSpace α] : (↑(⊤ : Compacts α) : Set α) = univ :=
rfl
@[simp]
theorem coe_bot : (↑(⊥ : Compacts α) : Set α) = ∅ :=
rfl
@[simp]
theorem coe_finset_sup {ι : Type*} {s : Finset ι} {f : ι → Compacts α} :
(↑(s.sup f) : Set α) = s.sup fun i => ↑(f i) := by
refine Finset.cons_induction_on s rfl fun a s _ h => ?_
simp_rw [Finset.sup_cons, coe_sup, sup_eq_union]
congr
/-- The image of a compact set under a continuous function. -/
protected def map (f : α → β) (hf : Continuous f) (K : Compacts α) : Compacts β :=
⟨f '' K.1, K.2.image hf⟩
@[simp, norm_cast]
theorem coe_map {f : α → β} (hf : Continuous f) (s : Compacts α) : (s.map f hf : Set β) = f '' s :=
rfl
@[simp]
theorem map_id (K : Compacts α) : K.map id continuous_id = K :=
Compacts.ext <| Set.image_id _
theorem map_comp (f : β → γ) (g : α → β) (hf : Continuous f) (hg : Continuous g) (K : Compacts α) :
K.map (f ∘ g) (hf.comp hg) = (K.map g hg).map f hf :=
Compacts.ext <| Set.image_comp _ _ _
/-- A homeomorphism induces an equivalence on compact sets, by taking the image. -/
@[simps]
protected def equiv (f : α ≃ₜ β) : Compacts α ≃ Compacts β where
toFun := Compacts.map f f.continuous
invFun := Compacts.map _ f.symm.continuous
left_inv s := by
ext1
simp only [coe_map, ← image_comp, f.symm_comp_self, image_id]
right_inv s := by
ext1
simp only [coe_map, ← image_comp, f.self_comp_symm, image_id]
@[simp]
theorem equiv_refl : Compacts.equiv (Homeomorph.refl α) = Equiv.refl _ :=
Equiv.ext map_id
@[simp]
theorem equiv_trans (f : α ≃ₜ β) (g : β ≃ₜ γ) :
Compacts.equiv (f.trans g) = (Compacts.equiv f).trans (Compacts.equiv g) :=
-- Porting note: can no longer write `map_comp _ _ _ _` and unify
Equiv.ext <| map_comp g f g.continuous f.continuous
@[simp]
theorem equiv_symm (f : α ≃ₜ β) : Compacts.equiv f.symm = (Compacts.equiv f).symm :=
rfl
/-- The image of a compact set under a homeomorphism can also be expressed as a preimage. -/
theorem coe_equiv_apply_eq_preimage (f : α ≃ₜ β) (K : Compacts α) :
(Compacts.equiv f K : Set β) = f.symm ⁻¹' (K : Set α) :=
f.toEquiv.image_eq_preimage K
/-- The product of two `TopologicalSpace.Compacts`, as a `TopologicalSpace.Compacts` in the product
space. -/
protected def prod (K : Compacts α) (L : Compacts β) : Compacts (α × β) where
carrier := K ×ˢ L
isCompact' := IsCompact.prod K.2 L.2
@[simp]
theorem coe_prod (K : Compacts α) (L : Compacts β) :
(K.prod L : Set (α × β)) = (K : Set α) ×ˢ (L : Set β) :=
rfl
-- todo: add `pi`
end Compacts
/-! ### Nonempty compact sets -/
/-- The type of nonempty compact sets of a topological space. -/
structure NonemptyCompacts (α : Type*) [TopologicalSpace α] extends Compacts α where
nonempty' : carrier.Nonempty
namespace NonemptyCompacts
instance : SetLike (NonemptyCompacts α) α where
coe s := s.carrier
coe_injective' s t h := by
obtain ⟨⟨_, _⟩, _⟩ := s
obtain ⟨⟨_, _⟩, _⟩ := t
congr
/-- See Note [custom simps projection]. -/
def Simps.coe (s : NonemptyCompacts α) : Set α := s
initialize_simps_projections NonemptyCompacts (carrier → coe)
protected theorem isCompact (s : NonemptyCompacts α) : IsCompact (s : Set α) :=
s.isCompact'
protected theorem nonempty (s : NonemptyCompacts α) : (s : Set α).Nonempty :=
s.nonempty'
/-- Reinterpret a nonempty compact as a closed set. -/
def toCloseds [T2Space α] (s : NonemptyCompacts α) : Closeds α :=
⟨s, s.isCompact.isClosed⟩
@[ext]
protected theorem ext {s t : NonemptyCompacts α} (h : (s : Set α) = t) : s = t :=
SetLike.ext' h
@[simp]
theorem coe_mk (s : Compacts α) (h) : (mk s h : Set α) = s :=
rfl
-- Porting note: `@[simp]` moved to `coe_toCompacts`
theorem carrier_eq_coe (s : NonemptyCompacts α) : s.carrier = s :=
rfl
@[simp]
theorem coe_toCompacts (s : NonemptyCompacts α) : (s.toCompacts : Set α) = s := rfl
instance : Sup (NonemptyCompacts α) :=
⟨fun s t => ⟨s.toCompacts ⊔ t.toCompacts, s.nonempty.mono subset_union_left⟩⟩
instance [CompactSpace α] [Nonempty α] : Top (NonemptyCompacts α) :=
⟨⟨⊤, univ_nonempty⟩⟩
instance : SemilatticeSup (NonemptyCompacts α) :=
SetLike.coe_injective.semilatticeSup _ fun _ _ => rfl
instance [CompactSpace α] [Nonempty α] : OrderTop (NonemptyCompacts α) :=
OrderTop.lift ((↑) : _ → Set α) (fun _ _ => id) rfl
@[simp]
theorem coe_sup (s t : NonemptyCompacts α) : (↑(s ⊔ t) : Set α) = ↑s ∪ ↑t :=
rfl
@[simp]
theorem coe_top [CompactSpace α] [Nonempty α] : (↑(⊤ : NonemptyCompacts α) : Set α) = univ :=
rfl
/-- In an inhabited space, the type of nonempty compact subsets is also inhabited, with
default element the singleton set containing the default element. -/
instance [Inhabited α] : Inhabited (NonemptyCompacts α) :=
⟨{ carrier := {default}
isCompact' := isCompact_singleton
nonempty' := singleton_nonempty _ }⟩
instance toCompactSpace {s : NonemptyCompacts α} : CompactSpace s :=
isCompact_iff_compactSpace.1 s.isCompact
instance toNonempty {s : NonemptyCompacts α} : Nonempty s :=
s.nonempty.to_subtype
/-- The product of two `TopologicalSpace.NonemptyCompacts`, as a `TopologicalSpace.NonemptyCompacts`
in the product space. -/
protected def prod (K : NonemptyCompacts α) (L : NonemptyCompacts β) : NonemptyCompacts (α × β) :=
{ K.toCompacts.prod L.toCompacts with nonempty' := K.nonempty.prod L.nonempty }
@[simp]
theorem coe_prod (K : NonemptyCompacts α) (L : NonemptyCompacts β) :
(K.prod L : Set (α × β)) = (K : Set α) ×ˢ (L : Set β) :=
rfl
end NonemptyCompacts
/-! ### Positive compact sets -/
/-- The type of compact sets with nonempty interior of a topological space.
See also `TopologicalSpace.Compacts` and `TopologicalSpace.NonemptyCompacts`. -/
structure PositiveCompacts (α : Type*) [TopologicalSpace α] extends Compacts α where
interior_nonempty' : (interior carrier).Nonempty
namespace PositiveCompacts
instance : SetLike (PositiveCompacts α) α where
coe s := s.carrier
coe_injective' s t h := by
obtain ⟨⟨_, _⟩, _⟩ := s
obtain ⟨⟨_, _⟩, _⟩ := t
congr
/-- See Note [custom simps projection]. -/
def Simps.coe (s : PositiveCompacts α) : Set α := s
initialize_simps_projections PositiveCompacts (carrier → coe)
protected theorem isCompact (s : PositiveCompacts α) : IsCompact (s : Set α) :=
s.isCompact'
theorem interior_nonempty (s : PositiveCompacts α) : (interior (s : Set α)).Nonempty :=
s.interior_nonempty'
protected theorem nonempty (s : PositiveCompacts α) : (s : Set α).Nonempty :=
s.interior_nonempty.mono interior_subset
/-- Reinterpret a positive compact as a nonempty compact. -/
def toNonemptyCompacts (s : PositiveCompacts α) : NonemptyCompacts α :=
⟨s.toCompacts, s.nonempty⟩
@[ext]
protected theorem ext {s t : PositiveCompacts α} (h : (s : Set α) = t) : s = t :=
SetLike.ext' h
@[simp]
theorem coe_mk (s : Compacts α) (h) : (mk s h : Set α) = s :=
rfl
-- Porting note: `@[simp]` moved to a new lemma
theorem carrier_eq_coe (s : PositiveCompacts α) : s.carrier = s :=
rfl
@[simp]
theorem coe_toCompacts (s : PositiveCompacts α) : (s.toCompacts : Set α) = s :=
rfl
instance : Sup (PositiveCompacts α) :=
⟨fun s t =>
⟨s.toCompacts ⊔ t.toCompacts,
s.interior_nonempty.mono <| interior_mono subset_union_left⟩⟩
instance [CompactSpace α] [Nonempty α] : Top (PositiveCompacts α) :=
⟨⟨⊤, interior_univ.symm.subst univ_nonempty⟩⟩
instance : SemilatticeSup (PositiveCompacts α) :=
SetLike.coe_injective.semilatticeSup _ fun _ _ => rfl
instance [CompactSpace α] [Nonempty α] : OrderTop (PositiveCompacts α) :=
OrderTop.lift ((↑) : _ → Set α) (fun _ _ => id) rfl
@[simp]
theorem coe_sup (s t : PositiveCompacts α) : (↑(s ⊔ t) : Set α) = ↑s ∪ ↑t :=
rfl
@[simp]
theorem coe_top [CompactSpace α] [Nonempty α] : (↑(⊤ : PositiveCompacts α) : Set α) = univ :=
rfl
/-- The image of a positive compact set under a continuous open map. -/
protected def map (f : α → β) (hf : Continuous f) (hf' : IsOpenMap f) (K : PositiveCompacts α) :
PositiveCompacts β :=
{ Compacts.map f hf K.toCompacts with
interior_nonempty' :=
(K.interior_nonempty'.image _).mono (hf'.image_interior_subset K.toCompacts) }
@[simp, norm_cast]
theorem coe_map {f : α → β} (hf : Continuous f) (hf' : IsOpenMap f) (s : PositiveCompacts α) :
(s.map f hf hf' : Set β) = f '' s :=
rfl
@[simp]
theorem map_id (K : PositiveCompacts α) : K.map id continuous_id IsOpenMap.id = K :=
PositiveCompacts.ext <| Set.image_id _
theorem map_comp (f : β → γ) (g : α → β) (hf : Continuous f) (hg : Continuous g) (hf' : IsOpenMap f)
(hg' : IsOpenMap g) (K : PositiveCompacts α) :
K.map (f ∘ g) (hf.comp hg) (hf'.comp hg') = (K.map g hg hg').map f hf hf' :=
PositiveCompacts.ext <| Set.image_comp _ _ _
theorem _root_.exists_positiveCompacts_subset [LocallyCompactSpace α] {U : Set α} (ho : IsOpen U)
(hn : U.Nonempty) : ∃ K : PositiveCompacts α, ↑K ⊆ U :=
let ⟨x, hx⟩ := hn
let ⟨K, hKc, hxK, hKU⟩ := exists_compact_subset ho hx
⟨⟨⟨K, hKc⟩, ⟨x, hxK⟩⟩, hKU⟩
theorem _root_.IsOpen.exists_positiveCompacts_closure_subset [R1Space α] [LocallyCompactSpace α]
{U : Set α} (ho : IsOpen U) (hn : U.Nonempty) : ∃ K : PositiveCompacts α, closure ↑K ⊆ U :=
let ⟨K, hKU⟩ := exists_positiveCompacts_subset ho hn
⟨K, K.isCompact.closure_subset_of_isOpen ho hKU⟩
instance [CompactSpace α] [Nonempty α] : Inhabited (PositiveCompacts α) :=
⟨⊤⟩
/-- In a nonempty locally compact space, there exists a compact set with nonempty interior. -/
instance nonempty' [WeaklyLocallyCompactSpace α] [Nonempty α] : Nonempty (PositiveCompacts α) := by
inhabit α
rcases exists_compact_mem_nhds (default : α) with ⟨K, hKc, hK⟩
exact ⟨⟨K, hKc⟩, _, mem_interior_iff_mem_nhds.2 hK⟩
/-- The product of two `TopologicalSpace.PositiveCompacts`, as a `TopologicalSpace.PositiveCompacts`
in the product space. -/
protected def prod (K : PositiveCompacts α) (L : PositiveCompacts β) :
PositiveCompacts (α × β) where
toCompacts := K.toCompacts.prod L.toCompacts
interior_nonempty' := by
simp only [Compacts.carrier_eq_coe, Compacts.coe_prod, interior_prod_eq]
exact K.interior_nonempty.prod L.interior_nonempty
@[simp]
theorem coe_prod (K : PositiveCompacts α) (L : PositiveCompacts β) :
(K.prod L : Set (α × β)) = (K : Set α) ×ˢ (L : Set β) :=
rfl
end PositiveCompacts
/-! ### Compact open sets -/
/-- The type of compact open sets of a topological space. This is useful in non Hausdorff contexts,
in particular spectral spaces. -/
structure CompactOpens (α : Type*) [TopologicalSpace α] extends Compacts α where
isOpen' : IsOpen carrier
namespace CompactOpens
instance : SetLike (CompactOpens α) α where
coe s := s.carrier
coe_injective' s t h := by
obtain ⟨⟨_, _⟩, _⟩ := s
obtain ⟨⟨_, _⟩, _⟩ := t
congr
/-- See Note [custom simps projection]. -/
def Simps.coe (s : CompactOpens α) : Set α := s
initialize_simps_projections CompactOpens (carrier → coe)
protected theorem isCompact (s : CompactOpens α) : IsCompact (s : Set α) :=
s.isCompact'
protected theorem isOpen (s : CompactOpens α) : IsOpen (s : Set α) :=
s.isOpen'
/-- Reinterpret a compact open as an open. -/
@[simps]
def toOpens (s : CompactOpens α) : Opens α := ⟨s, s.isOpen⟩
/-- Reinterpret a compact open as a clopen. -/
@[simps]
def toClopens [T2Space α] (s : CompactOpens α) : Clopens α :=
⟨s, s.isCompact.isClosed, s.isOpen⟩
@[ext]
protected theorem ext {s t : CompactOpens α} (h : (s : Set α) = t) : s = t :=
SetLike.ext' h
@[simp]
theorem coe_mk (s : Compacts α) (h) : (mk s h : Set α) = s :=
rfl
instance : Sup (CompactOpens α) :=
⟨fun s t => ⟨s.toCompacts ⊔ t.toCompacts, s.isOpen.union t.isOpen⟩⟩
instance : Bot (CompactOpens α) where bot := ⟨⊥, isOpen_empty⟩
@[simp, norm_cast] lemma coe_sup (s t : CompactOpens α) : ↑(s ⊔ t) = (s ∪ t : Set α) := rfl
@[simp, norm_cast] lemma coe_bot : ↑(⊥ : CompactOpens α) = (∅ : Set α) := rfl
instance : SemilatticeSup (CompactOpens α) := SetLike.coe_injective.semilatticeSup _ coe_sup
instance : OrderBot (CompactOpens α) := OrderBot.lift ((↑) : _ → Set α) (fun _ _ => id) coe_bot
instance : Inhabited (CompactOpens α) :=
⟨⊥⟩
section Inf
variable [QuasiSeparatedSpace α]
instance instInf : Inf (CompactOpens α) where
inf U V :=
⟨⟨U ∩ V, QuasiSeparatedSpace.inter_isCompact U.1.1 V.1.1 U.2 U.1.2 V.2 V.1.2⟩, U.2.inter V.2⟩
@[simp, norm_cast] lemma coe_inf (s t : CompactOpens α) : ↑(s ⊓ t) = (s ∩ t : Set α) := rfl
instance instSemilatticeInf : SemilatticeInf (CompactOpens α) :=
SetLike.coe_injective.semilatticeInf _ coe_inf
end Inf
section SDiff
variable [T2Space α]
instance instSDiff : SDiff (CompactOpens α) where
sdiff s t := ⟨⟨s \ t, s.isCompact.diff t.isOpen⟩, s.isOpen.sdiff t.isCompact.isClosed⟩
@[simp, norm_cast] lemma coe_sdiff (s t : CompactOpens α) : ↑(s \ t) = (s \ t : Set α) := rfl
instance instGeneralizedBooleanAlgebra : GeneralizedBooleanAlgebra (CompactOpens α) :=
SetLike.coe_injective.generalizedBooleanAlgebra _ coe_sup coe_inf coe_bot coe_sdiff
end SDiff
section Top
variable [CompactSpace α]
instance instTop : Top (CompactOpens α) where top := ⟨⊤, isOpen_univ⟩
@[simp, norm_cast] lemma coe_top : ↑(⊤ : CompactOpens α) = (univ : Set α) := rfl
instance instBoundedOrder : BoundedOrder (CompactOpens α) :=
BoundedOrder.lift ((↑) : _ → Set α) (fun _ _ => id) coe_top coe_bot
section Compl
variable [T2Space α]
instance instHasCompl : HasCompl (CompactOpens α) where
compl s := ⟨⟨sᶜ, s.isOpen.isClosed_compl.isCompact⟩, s.isCompact.isClosed.isOpen_compl⟩
instance instHImp : HImp (CompactOpens α) where
himp s t := ⟨⟨s ⇨ t, IsClosed.isCompact
(by simpa [himp_eq] using t.isCompact.isClosed.union s.isOpen.isClosed_compl)⟩,
by simpa [himp_eq] using t.isOpen.union s.isCompact.isClosed.isOpen_compl⟩
@[simp, norm_cast] lemma coe_compl (s : CompactOpens α) : ↑sᶜ = (sᶜ : Set α) := rfl
@[simp, norm_cast] lemma coe_himp (s t : CompactOpens α) : ↑(s ⇨ t) = (s ⇨ t : Set α) := rfl
instance instBooleanAlgebra : BooleanAlgebra (CompactOpens α) :=
SetLike.coe_injective.booleanAlgebra _ coe_sup coe_inf coe_top coe_bot coe_compl coe_sdiff
coe_himp
end Top.Compl
/-- The image of a compact open under a continuous open map. -/
@[simps toCompacts]
def map (f : α → β) (hf : Continuous f) (hf' : IsOpenMap f) (s : CompactOpens α) : CompactOpens β :=
⟨s.toCompacts.map f hf, hf' _ s.isOpen⟩
@[simp, norm_cast]
theorem coe_map {f : α → β} (hf : Continuous f) (hf' : IsOpenMap f) (s : CompactOpens α) :
(s.map f hf hf' : Set β) = f '' s :=
rfl
@[simp]
theorem map_id (K : CompactOpens α) : K.map id continuous_id IsOpenMap.id = K :=
CompactOpens.ext <| Set.image_id _
theorem map_comp (f : β → γ) (g : α → β) (hf : Continuous f) (hg : Continuous g) (hf' : IsOpenMap f)
(hg' : IsOpenMap g) (K : CompactOpens α) :
K.map (f ∘ g) (hf.comp hg) (hf'.comp hg') = (K.map g hg hg').map f hf hf' :=
CompactOpens.ext <| Set.image_comp _ _ _
/-- The product of two `TopologicalSpace.CompactOpens`, as a `TopologicalSpace.CompactOpens` in the
product space. -/
protected def prod (K : CompactOpens α) (L : CompactOpens β) : CompactOpens (α × β) :=
{ K.toCompacts.prod L.toCompacts with isOpen' := K.isOpen.prod L.isOpen }
@[simp]
theorem coe_prod (K : CompactOpens α) (L : CompactOpens β) :
(K.prod L : Set (α × β)) = (K : Set α) ×ˢ (L : Set β) :=
rfl
end CompactOpens
end TopologicalSpace
|
Topology\Sets\Opens.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, Floris van Doorn
-/
import Mathlib.Order.Hom.CompleteLattice
import Mathlib.Topology.Bases
import Mathlib.Topology.Homeomorph
import Mathlib.Topology.ContinuousFunction.Basic
import Mathlib.Order.CompactlyGenerated.Basic
import Mathlib.Order.Copy
/-!
# Open sets
## Summary
We define the subtype of open sets in a topological space.
## Main Definitions
### Bundled open sets
- `TopologicalSpace.Opens α` is the type of open subsets of a topological space `α`.
- `TopologicalSpace.Opens.IsBasis` is a predicate saying that a set of `Opens`s form a topological
basis.
- `TopologicalSpace.Opens.comap`: preimage of an open set under a continuous map as a `FrameHom`.
- `Homeomorph.opensCongr`: order-preserving equivalence between open sets in the domain and the
codomain of a homeomorphism.
### Bundled open neighborhoods
- `TopologicalSpace.OpenNhdsOf x` is the type of open subsets of a topological space `α` containing
`x : α`.
- `TopologicalSpace.OpenNhdsOf.comap f x U` is the preimage of open neighborhood `U` of `f x` under
`f : C(α, β)`.
## Main results
We define order structures on both `Opens α` (`CompleteLattice`, `Frame`) and `OpenNhdsOf x`
(`OrderTop`, `DistribLattice`).
## TODO
- Rename `TopologicalSpace.Opens` to `Open`?
- Port the `auto_cases` tactic version (as a plugin if the ported `auto_cases` will allow plugins).
-/
open Filter Function Order Set
open Topology
variable {ι α β γ : Type*} [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ]
namespace TopologicalSpace
variable (α)
/-- The type of open subsets of a topological space. -/
structure Opens where
/-- The underlying set of a bundled `TopologicalSpace.Opens` object. -/
carrier : Set α
/-- The `TopologicalSpace.Opens.carrier _` is an open set. -/
is_open' : IsOpen carrier
variable {α}
namespace Opens
instance : SetLike (Opens α) α where
coe := Opens.carrier
coe_injective' := fun ⟨_, _⟩ ⟨_, _⟩ _ => by congr
instance : CanLift (Set α) (Opens α) (↑) IsOpen :=
⟨fun s h => ⟨⟨s, h⟩, rfl⟩⟩
theorem «forall» {p : Opens α → Prop} : (∀ U, p U) ↔ ∀ (U : Set α) (hU : IsOpen U), p ⟨U, hU⟩ :=
⟨fun h _ _ => h _, fun h _ => h _ _⟩
@[simp] theorem carrier_eq_coe (U : Opens α) : U.1 = ↑U := rfl
/-- the coercion `Opens α → Set α` applied to a pair is the same as taking the first component -/
@[simp]
theorem coe_mk {U : Set α} {hU : IsOpen U} : ↑(⟨U, hU⟩ : Opens α) = U :=
rfl
@[simp]
theorem mem_mk {x : α} {U : Set α} {h : IsOpen U} : x ∈ mk U h ↔ x ∈ U := Iff.rfl
-- Porting note: removed @[simp] because LHS simplifies to `∃ x, x ∈ U`
protected theorem nonempty_coeSort {U : Opens α} : Nonempty U ↔ (U : Set α).Nonempty :=
Set.nonempty_coe_sort
-- TODO: should this theorem be proved for a `SetLike`?
protected theorem nonempty_coe {U : Opens α} : (U : Set α).Nonempty ↔ ∃ x, x ∈ U :=
Iff.rfl
@[ext] -- Porting note (#11215): TODO: replace with `∀ x, x ∈ U ↔ x ∈ V`
theorem ext {U V : Opens α} (h : (U : Set α) = V) : U = V :=
SetLike.coe_injective h
-- Porting note: removed @[simp], simp can prove it
theorem coe_inj {U V : Opens α} : (U : Set α) = V ↔ U = V :=
SetLike.ext'_iff.symm
protected theorem isOpen (U : Opens α) : IsOpen (U : Set α) :=
U.is_open'
@[simp] theorem mk_coe (U : Opens α) : mk (↑U) U.isOpen = U := rfl
/-- See Note [custom simps projection]. -/
def Simps.coe (U : Opens α) : Set α := U
initialize_simps_projections Opens (carrier → coe)
/-- The interior of a set, as an element of `Opens`. -/
nonrec def interior (s : Set α) : Opens α :=
⟨interior s, isOpen_interior⟩
theorem gc : GaloisConnection ((↑) : Opens α → Set α) interior := fun U _ =>
⟨fun h => interior_maximal h U.isOpen, fun h => le_trans h interior_subset⟩
/-- The galois coinsertion between sets and opens. -/
def gi : GaloisCoinsertion (↑) (@interior α _) where
choice s hs := ⟨s, interior_eq_iff_isOpen.mp <| le_antisymm interior_subset hs⟩
gc := gc
u_l_le _ := interior_subset
choice_eq _s hs := le_antisymm hs interior_subset
instance : CompleteLattice (Opens α) :=
CompleteLattice.copy (GaloisCoinsertion.liftCompleteLattice gi)
-- le
(fun U V => (U : Set α) ⊆ V) rfl
-- top
⟨univ, isOpen_univ⟩ (ext interior_univ.symm)
-- bot
⟨∅, isOpen_empty⟩ rfl
-- sup
(fun U V => ⟨↑U ∪ ↑V, U.2.union V.2⟩) rfl
-- inf
(fun U V => ⟨↑U ∩ ↑V, U.2.inter V.2⟩)
(funext₂ fun U V => ext (U.2.inter V.2).interior_eq.symm)
-- sSup
(fun S => ⟨⋃ s ∈ S, ↑s, isOpen_biUnion fun s _ => s.2⟩)
(funext fun _ => ext sSup_image.symm)
-- sInf
_ rfl
@[simp]
theorem mk_inf_mk {U V : Set α} {hU : IsOpen U} {hV : IsOpen V} :
(⟨U, hU⟩ ⊓ ⟨V, hV⟩ : Opens α) = ⟨U ⊓ V, IsOpen.inter hU hV⟩ :=
rfl
@[simp, norm_cast]
theorem coe_inf (s t : Opens α) : (↑(s ⊓ t) : Set α) = ↑s ∩ ↑t :=
rfl
@[simp, norm_cast]
theorem coe_sup (s t : Opens α) : (↑(s ⊔ t) : Set α) = ↑s ∪ ↑t :=
rfl
@[simp, norm_cast]
theorem coe_bot : ((⊥ : Opens α) : Set α) = ∅ :=
rfl
@[simp] theorem mk_empty : (⟨∅, isOpen_empty⟩ : Opens α) = ⊥ := rfl
@[simp, norm_cast]
theorem coe_eq_empty {U : Opens α} : (U : Set α) = ∅ ↔ U = ⊥ :=
SetLike.coe_injective.eq_iff' rfl
@[simp]
lemma mem_top (x : α) : x ∈ (⊤ : Opens α) := trivial
@[simp, norm_cast]
theorem coe_top : ((⊤ : Opens α) : Set α) = Set.univ :=
rfl
@[simp] theorem mk_univ : (⟨univ, isOpen_univ⟩ : Opens α) = ⊤ := rfl
@[simp, norm_cast]
theorem coe_eq_univ {U : Opens α} : (U : Set α) = univ ↔ U = ⊤ :=
SetLike.coe_injective.eq_iff' rfl
@[simp, norm_cast]
theorem coe_sSup {S : Set (Opens α)} : (↑(sSup S) : Set α) = ⋃ i ∈ S, ↑i :=
rfl
@[simp, norm_cast]
theorem coe_finset_sup (f : ι → Opens α) (s : Finset ι) : (↑(s.sup f) : Set α) = s.sup ((↑) ∘ f) :=
map_finset_sup (⟨⟨(↑), coe_sup⟩, coe_bot⟩ : SupBotHom (Opens α) (Set α)) _ _
@[simp, norm_cast]
theorem coe_finset_inf (f : ι → Opens α) (s : Finset ι) : (↑(s.inf f) : Set α) = s.inf ((↑) ∘ f) :=
map_finset_inf (⟨⟨(↑), coe_inf⟩, coe_top⟩ : InfTopHom (Opens α) (Set α)) _ _
instance : Inhabited (Opens α) := ⟨⊥⟩
-- porting note (#10754): new instance
instance [IsEmpty α] : Unique (Opens α) where
uniq _ := ext <| Subsingleton.elim _ _
-- porting note (#10754): new instance
instance [Nonempty α] : Nontrivial (Opens α) where
exists_pair_ne := ⟨⊥, ⊤, mt coe_inj.2 empty_ne_univ⟩
@[simp, norm_cast]
theorem coe_iSup {ι} (s : ι → Opens α) : ((⨆ i, s i : Opens α) : Set α) = ⋃ i, s i := by
simp [iSup]
theorem iSup_def {ι} (s : ι → Opens α) : ⨆ i, s i = ⟨⋃ i, s i, isOpen_iUnion fun i => (s i).2⟩ :=
ext <| coe_iSup s
@[simp]
theorem iSup_mk {ι} (s : ι → Set α) (h : ∀ i, IsOpen (s i)) :
(⨆ i, ⟨s i, h i⟩ : Opens α) = ⟨⋃ i, s i, isOpen_iUnion h⟩ :=
iSup_def _
@[simp]
theorem mem_iSup {ι} {x : α} {s : ι → Opens α} : x ∈ iSup s ↔ ∃ i, x ∈ s i := by
rw [← SetLike.mem_coe]
simp
@[simp]
theorem mem_sSup {Us : Set (Opens α)} {x : α} : x ∈ sSup Us ↔ ∃ u ∈ Us, x ∈ u := by
simp_rw [sSup_eq_iSup, mem_iSup, exists_prop]
/-- Open sets in a topological space form a frame. -/
def frameMinimalAxioms : Frame.MinimalAxioms (Opens α) where
inf_sSup_le_iSup_inf a s :=
(ext <| by simp only [coe_inf, coe_iSup, coe_sSup, Set.inter_iUnion₂]).le
instance instFrame : Frame (Opens α) := .ofMinimalAxioms frameMinimalAxioms
theorem openEmbedding' (U : Opens α) : OpenEmbedding (Subtype.val : U → α) :=
U.isOpen.openEmbedding_subtype_val
theorem openEmbedding_of_le {U V : Opens α} (i : U ≤ V) :
OpenEmbedding (Set.inclusion <| SetLike.coe_subset_coe.2 i) :=
{ toEmbedding := embedding_inclusion i
isOpen_range := by
rw [Set.range_inclusion i]
exact U.isOpen.preimage continuous_subtype_val }
theorem not_nonempty_iff_eq_bot (U : Opens α) : ¬Set.Nonempty (U : Set α) ↔ U = ⊥ := by
rw [← coe_inj, coe_bot, ← Set.not_nonempty_iff_eq_empty]
theorem ne_bot_iff_nonempty (U : Opens α) : U ≠ ⊥ ↔ Set.Nonempty (U : Set α) := by
rw [Ne, ← not_nonempty_iff_eq_bot, not_not]
/-- An open set in the indiscrete topology is either empty or the whole space. -/
theorem eq_bot_or_top {α} [t : TopologicalSpace α] (h : t = ⊤) (U : Opens α) : U = ⊥ ∨ U = ⊤ := by
subst h; letI : TopologicalSpace α := ⊤
rw [← coe_eq_empty, ← coe_eq_univ, ← isOpen_top_iff]
exact U.2
-- porting note (#10754): new instance
instance [Nonempty α] [Subsingleton α] : IsSimpleOrder (Opens α) where
eq_bot_or_eq_top := eq_bot_or_top <| Subsingleton.elim _ _
/-- A set of `opens α` is a basis if the set of corresponding sets is a topological basis. -/
def IsBasis (B : Set (Opens α)) : Prop :=
IsTopologicalBasis (((↑) : _ → Set α) '' B)
theorem isBasis_iff_nbhd {B : Set (Opens α)} :
IsBasis B ↔ ∀ {U : Opens α} {x}, x ∈ U → ∃ U' ∈ B, x ∈ U' ∧ U' ≤ U := by
constructor <;> intro h
· rintro ⟨sU, hU⟩ x hx
rcases h.mem_nhds_iff.mp (IsOpen.mem_nhds hU hx) with ⟨sV, ⟨⟨V, H₁, H₂⟩, hsV⟩⟩
refine ⟨V, H₁, ?_⟩
cases V
dsimp at H₂
subst H₂
exact hsV
· refine isTopologicalBasis_of_isOpen_of_nhds ?_ ?_
· rintro sU ⟨U, -, rfl⟩
exact U.2
· intro x sU hx hsU
rcases @h ⟨sU, hsU⟩ x hx with ⟨V, hV, H⟩
exact ⟨V, ⟨V, hV, rfl⟩, H⟩
theorem isBasis_iff_cover {B : Set (Opens α)} :
IsBasis B ↔ ∀ U : Opens α, ∃ Us, Us ⊆ B ∧ U = sSup Us := by
constructor
· intro hB U
refine ⟨{ V : Opens α | V ∈ B ∧ V ≤ U }, fun U hU => hU.left, ext ?_⟩
rw [coe_sSup, hB.open_eq_sUnion' U.isOpen]
simp_rw [sUnion_eq_biUnion, iUnion, mem_setOf_eq, iSup_and, iSup_image]
rfl
· intro h
rw [isBasis_iff_nbhd]
intro U x hx
rcases h U with ⟨Us, hUs, rfl⟩
rcases mem_sSup.1 hx with ⟨U, Us, xU⟩
exact ⟨U, hUs Us, xU, le_sSup Us⟩
/-- If `α` has a basis consisting of compact opens, then an open set in `α` is compact open iff
it is a finite union of some elements in the basis -/
theorem IsBasis.isCompact_open_iff_eq_finite_iUnion {ι : Type*} (b : ι → Opens α)
(hb : IsBasis (Set.range b)) (hb' : ∀ i, IsCompact (b i : Set α)) (U : Set α) :
IsCompact U ∧ IsOpen U ↔ ∃ s : Set ι, s.Finite ∧ U = ⋃ i ∈ s, b i := by
apply isCompact_open_iff_eq_finite_iUnion_of_isTopologicalBasis fun i : ι => (b i).1
· convert (config := {transparency := .default}) hb
ext
simp
· exact hb'
lemma IsBasis.le_iff {α} {t₁ t₂ : TopologicalSpace α}
{Us : Set (Opens α)} (hUs : @IsBasis α t₂ Us) :
t₁ ≤ t₂ ↔ ∀ U ∈ Us, IsOpen[t₁] U := by
conv_lhs => rw [hUs.eq_generateFrom]
simp [Set.subset_def, le_generateFrom_iff_subset_isOpen]
@[simp]
theorem isCompactElement_iff (s : Opens α) :
CompleteLattice.IsCompactElement s ↔ IsCompact (s : Set α) := by
rw [isCompact_iff_finite_subcover, CompleteLattice.isCompactElement_iff]
refine ⟨?_, fun H ι U hU => ?_⟩
· introv H hU hU'
obtain ⟨t, ht⟩ := H ι (fun i => ⟨U i, hU i⟩) (by simpa)
refine ⟨t, Set.Subset.trans ht ?_⟩
rw [coe_finset_sup, Finset.sup_eq_iSup]
rfl
· obtain ⟨t, ht⟩ :=
H (fun i => U i) (fun i => (U i).isOpen) (by simpa using show (s : Set α) ⊆ ↑(iSup U) from hU)
refine ⟨t, Set.Subset.trans ht ?_⟩
simp only [Set.iUnion_subset_iff]
show ∀ i ∈ t, U i ≤ t.sup U
exact fun i => Finset.le_sup
/-- The preimage of an open set, as an open set. -/
def comap (f : C(α, β)) : FrameHom (Opens β) (Opens α) where
toFun s := ⟨f ⁻¹' s, s.2.preimage f.continuous⟩
map_sSup' s := ext <| by simp only [coe_sSup, preimage_iUnion, biUnion_image, coe_mk]
map_inf' a b := rfl
map_top' := rfl
@[simp]
theorem comap_id : comap (ContinuousMap.id α) = FrameHom.id _ :=
FrameHom.ext fun _ => ext rfl
theorem comap_mono (f : C(α, β)) {s t : Opens β} (h : s ≤ t) : comap f s ≤ comap f t :=
OrderHomClass.mono (comap f) h
@[simp]
theorem coe_comap (f : C(α, β)) (U : Opens β) : ↑(comap f U) = f ⁻¹' U :=
rfl
protected theorem comap_comp (g : C(β, γ)) (f : C(α, β)) :
comap (g.comp f) = (comap f).comp (comap g) :=
rfl
protected theorem comap_comap (g : C(β, γ)) (f : C(α, β)) (U : Opens γ) :
comap f (comap g U) = comap (g.comp f) U :=
rfl
theorem comap_injective [T0Space β] : Injective (comap : C(α, β) → FrameHom (Opens β) (Opens α)) :=
fun f g h =>
ContinuousMap.ext fun a =>
Inseparable.eq <|
inseparable_iff_forall_open.2 fun s hs =>
have : comap f ⟨s, hs⟩ = comap g ⟨s, hs⟩ := DFunLike.congr_fun h ⟨_, hs⟩
show a ∈ f ⁻¹' s ↔ a ∈ g ⁻¹' s from Set.ext_iff.1 (coe_inj.2 this) a
/-- A homeomorphism induces an order-preserving equivalence on open sets, by taking comaps. -/
@[simps (config := .asFn) apply]
def _root_.Homeomorph.opensCongr (f : α ≃ₜ β) : Opens α ≃o Opens β where
toFun := Opens.comap f.symm.toContinuousMap
invFun := Opens.comap f.toContinuousMap
left_inv := fun U => ext <| f.toEquiv.preimage_symm_preimage _
right_inv := fun U => ext <| f.toEquiv.symm_preimage_preimage _
map_rel_iff' := by
simp only [← SetLike.coe_subset_coe]; exact f.symm.surjective.preimage_subset_preimage_iff
@[simp]
theorem _root_.Homeomorph.opensCongr_symm (f : α ≃ₜ β) : f.opensCongr.symm = f.symm.opensCongr :=
rfl
instance [Finite α] : Finite (Opens α) :=
Finite.of_injective _ SetLike.coe_injective
end Opens
/-- The open neighborhoods of a point. See also `Opens` or `nhds`. -/
structure OpenNhdsOf (x : α) extends Opens α where
/-- The point `x` belongs to every `U : TopologicalSpace.OpenNhdsOf x`. -/
mem' : x ∈ carrier
namespace OpenNhdsOf
variable {x : α}
theorem toOpens_injective : Injective (toOpens : OpenNhdsOf x → Opens α)
| ⟨_, _⟩, ⟨_, _⟩, rfl => rfl
instance : SetLike (OpenNhdsOf x) α where
coe U := U.1
coe_injective' := SetLike.coe_injective.comp toOpens_injective
instance canLiftSet : CanLift (Set α) (OpenNhdsOf x) (↑) fun s => IsOpen s ∧ x ∈ s :=
⟨fun s hs => ⟨⟨⟨s, hs.1⟩, hs.2⟩, rfl⟩⟩
protected theorem mem (U : OpenNhdsOf x) : x ∈ U :=
U.mem'
protected theorem isOpen (U : OpenNhdsOf x) : IsOpen (U : Set α) :=
U.is_open'
instance : OrderTop (OpenNhdsOf x) where
top := ⟨⊤, Set.mem_univ _⟩
le_top _ := subset_univ _
instance : Inhabited (OpenNhdsOf x) := ⟨⊤⟩
instance : Inf (OpenNhdsOf x) := ⟨fun U V => ⟨U.1 ⊓ V.1, U.2, V.2⟩⟩
instance : Sup (OpenNhdsOf x) := ⟨fun U V => ⟨U.1 ⊔ V.1, Or.inl U.2⟩⟩
-- porting note (#10754): new instance
instance [Subsingleton α] : Unique (OpenNhdsOf x) where
uniq U := SetLike.ext' <| Subsingleton.eq_univ_of_nonempty ⟨x, U.mem⟩
instance : DistribLattice (OpenNhdsOf x) :=
toOpens_injective.distribLattice _ (fun _ _ => rfl) fun _ _ => rfl
theorem basis_nhds : (𝓝 x).HasBasis (fun _ : OpenNhdsOf x => True) (↑) :=
(nhds_basis_opens x).to_hasBasis (fun U hU => ⟨⟨⟨U, hU.2⟩, hU.1⟩, trivial, Subset.rfl⟩) fun U _ =>
⟨U, ⟨⟨U.mem, U.isOpen⟩, Subset.rfl⟩⟩
/-- Preimage of an open neighborhood of `f x` under a continuous map `f` as a `LatticeHom`. -/
def comap (f : C(α, β)) (x : α) : LatticeHom (OpenNhdsOf (f x)) (OpenNhdsOf x) where
toFun U := ⟨Opens.comap f U.1, U.mem⟩
map_sup' _ _ := rfl
map_inf' _ _ := rfl
end OpenNhdsOf
end TopologicalSpace
-- Porting note (#11215): TODO: once we port `auto_cases`, port this
-- namespace Tactic
-- namespace AutoCases
-- /-- Find an `auto_cases_tac` which matches `TopologicalSpace.Opens`. -/
-- unsafe def opens_find_tac : expr → Option auto_cases_tac
-- | q(TopologicalSpace.Opens _) => tac_cases
-- | _ => none
-- end AutoCases
-- /-- A version of `tactic.auto_cases` that works for `TopologicalSpace.Opens`. -/
-- @[hint_tactic]
-- unsafe def auto_cases_opens : tactic String :=
-- auto_cases tactic.auto_cases.opens_find_tac
-- end Tactic
|
Topology\Sets\Order.lean | /-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Order.UpperLower.Basic
import Mathlib.Topology.Sets.Closeds
/-!
# Clopen upper sets
In this file we define the type of clopen upper sets.
-/
open Set TopologicalSpace
variable {α β : Type*} [TopologicalSpace α] [LE α] [TopologicalSpace β] [LE β]
/-! ### Compact open sets -/
/-- The type of clopen upper sets of a topological space. -/
structure ClopenUpperSet (α : Type*) [TopologicalSpace α] [LE α] extends Clopens α where
upper' : IsUpperSet carrier
namespace ClopenUpperSet
instance : SetLike (ClopenUpperSet α) α where
coe s := s.carrier
coe_injective' s t h := by
obtain ⟨⟨_, _⟩, _⟩ := s
obtain ⟨⟨_, _⟩, _⟩ := t
congr
/-- See Note [custom simps projection]. -/
def Simps.coe (s : ClopenUpperSet α) : Set α := s
initialize_simps_projections ClopenUpperSet (carrier → coe)
theorem upper (s : ClopenUpperSet α) : IsUpperSet (s : Set α) :=
s.upper'
theorem isClopen (s : ClopenUpperSet α) : IsClopen (s : Set α) :=
s.isClopen'
/-- Reinterpret an upper clopen as an upper set. -/
@[simps]
def toUpperSet (s : ClopenUpperSet α) : UpperSet α :=
⟨s, s.upper⟩
@[ext]
protected theorem ext {s t : ClopenUpperSet α} (h : (s : Set α) = t) : s = t :=
SetLike.ext' h
@[simp]
theorem coe_mk (s : Clopens α) (h) : (mk s h : Set α) = s :=
rfl
instance : Sup (ClopenUpperSet α) :=
⟨fun s t => ⟨s.toClopens ⊔ t.toClopens, s.upper.union t.upper⟩⟩
instance : Inf (ClopenUpperSet α) :=
⟨fun s t => ⟨s.toClopens ⊓ t.toClopens, s.upper.inter t.upper⟩⟩
instance : Top (ClopenUpperSet α) :=
⟨⟨⊤, isUpperSet_univ⟩⟩
instance : Bot (ClopenUpperSet α) :=
⟨⟨⊥, isUpperSet_empty⟩⟩
instance : Lattice (ClopenUpperSet α) :=
SetLike.coe_injective.lattice _ (fun _ _ => rfl) fun _ _ => rfl
instance : BoundedOrder (ClopenUpperSet α) :=
BoundedOrder.lift ((↑) : _ → Set α) (fun _ _ => id) rfl rfl
@[simp]
theorem coe_sup (s t : ClopenUpperSet α) : (↑(s ⊔ t) : Set α) = ↑s ∪ ↑t :=
rfl
@[simp]
theorem coe_inf (s t : ClopenUpperSet α) : (↑(s ⊓ t) : Set α) = ↑s ∩ ↑t :=
rfl
@[simp]
theorem coe_top : (↑(⊤ : ClopenUpperSet α) : Set α) = univ :=
rfl
@[simp]
theorem coe_bot : (↑(⊥ : ClopenUpperSet α) : Set α) = ∅ :=
rfl
instance : Inhabited (ClopenUpperSet α) :=
⟨⊥⟩
end ClopenUpperSet
|
Topology\Sheaves\Forget.lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Algebra.Category.Ring.Limits
import Mathlib.Topology.Sheaves.Sheaf
/-!
# Checking the sheaf condition on the underlying presheaf of types.
If `G : C ⥤ D` is a functor which reflects isomorphisms and preserves limits
(we assume all limits exist in `C`),
then checking the sheaf condition for a presheaf `F : Presheaf C X`
is equivalent to checking the sheaf condition for `F ⋙ G`.
The important special case is when
`C` is a concrete category with a forgetful functor
that preserves limits and reflects isomorphisms.
Then to check the sheaf condition it suffices
to check it on the underlying sheaf of types.
## References
* https://stacks.math.columbia.edu/tag/0073
-/
universe v v₁ v₂ u₁ u₂
noncomputable section
open CategoryTheory Limits
namespace TopCat.Presheaf
/-- If `G : C ⥤ D` is a functor which reflects isomorphisms and preserves limits
(we assume all limits exist in `C`),
then checking the sheaf condition for a presheaf `F : Presheaf C X`
is equivalent to checking the sheaf condition for `F ⋙ G`.
The important special case is when
`C` is a concrete category with a forgetful functor
that preserves limits and reflects isomorphisms.
Then to check the sheaf condition it suffices to check it on the underlying sheaf of types.
Another useful example is the forgetful functor `TopCommRingCat ⥤ TopCat`.
See <https://stacks.math.columbia.edu/tag/0073>.
In fact we prove a stronger version with arbitrary target category.
-/
theorem isSheaf_iff_isSheaf_comp' {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
(G : C ⥤ D) [G.ReflectsIsomorphisms] [HasLimitsOfSize.{v, v} C] [PreservesLimitsOfSize.{v, v} G]
{X : TopCat.{v}} (F : Presheaf C X) : Presheaf.IsSheaf F ↔ Presheaf.IsSheaf (F ⋙ G) :=
Presheaf.isSheaf_iff_isSheaf_comp _ F G
theorem isSheaf_iff_isSheaf_comp {C : Type u₁} [Category.{v} C] {D : Type u₂} [Category.{v} D]
(G : C ⥤ D) [G.ReflectsIsomorphisms] [HasLimits C] [PreservesLimits G]
{X : TopCat.{v}} (F : Presheaf C X) : Presheaf.IsSheaf F ↔ Presheaf.IsSheaf (F ⋙ G) :=
isSheaf_iff_isSheaf_comp' G F
/-!
As an example, we now have everything we need to check the sheaf condition
for a presheaf of commutative rings, merely by checking the sheaf condition
for the underlying sheaf of types.
Note that the universes for `TopCat` and `CommRingCat` must be the same for this argument
to go through.
-/
example (X : TopCat.{u₁}) (F : Presheaf CommRingCat.{u₁} X)
(h : Presheaf.IsSheaf (F ⋙ (forget CommRingCat))) :
F.IsSheaf :=
(isSheaf_iff_isSheaf_comp (forget CommRingCat) F).mpr h
end TopCat.Presheaf
|
Topology\Sheaves\Functors.lean | /-
Copyright (c) 2021 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu, Andrew Yang
-/
import Mathlib.Topology.Sheaves.SheafCondition.Sites
import Mathlib.CategoryTheory.Sites.Pullback
/-!
# functors between categories of sheaves
Show that the pushforward of a sheaf is a sheaf, and define
the pushforward functor from the category of C-valued sheaves
on X to that of sheaves on Y, given a continuous map between
topological spaces X and Y.
## Main definitions
- `TopCat.Sheaf.pushforward`:
The pushforward functor between sheaf categories over topological spaces.
- `TopCat.Sheaf.pullback`: The pullback functor between sheaf categories over topological spaces.
- `TopCat.Sheaf.pullbackPushforwardAdjunction`:
The adjunction between pullback and pushforward for sheaves on topological spaces.
-/
noncomputable section
universe w v u
open CategoryTheory
open CategoryTheory.Limits
open TopologicalSpace
variable {C : Type u} [Category.{v} C]
variable {X Y : TopCat.{w}} (f : X ⟶ Y)
variable ⦃ι : Type w⦄ {U : ι → Opens Y}
namespace TopCat
namespace Sheaf
open Presheaf
/-- The pushforward of a sheaf (by a continuous map) is a sheaf.
-/
theorem pushforward_sheaf_of_sheaf {F : X.Presheaf C} (h : F.IsSheaf) : (f _* F).IsSheaf :=
(Opens.map f).op_comp_isSheaf _ _ ⟨_, h⟩
variable (C)
/-- The pushforward functor.
-/
def pushforward (f : X ⟶ Y) : X.Sheaf C ⥤ Y.Sheaf C :=
(Opens.map f).sheafPushforwardContinuous _ _ _
lemma pushforward_forget (f : X ⟶ Y) :
pushforward C f ⋙ forget C Y = forget C X ⋙ Presheaf.pushforward C f := rfl
/--
Pushforward of sheaves is isomorphic (actually definitionally equal) to pushforward of presheaves.
-/
def pushforwardForgetIso (f : X ⟶ Y) :
pushforward C f ⋙ forget C Y ≅ forget C X ⋙ Presheaf.pushforward C f := Iso.refl _
variable {C}
@[simp] lemma pushforward_obj_val (f : X ⟶ Y) (F : X.Sheaf C) :
((pushforward C f).obj F).1 = f _* F.1 := rfl
@[simp] lemma pushforward_map (f : X ⟶ Y) {F F' : X.Sheaf C} (α : F ⟶ F') :
((pushforward C f).map α).1 = (Presheaf.pushforward C f).map α.1 := rfl
variable (A : Type*) [Category.{w} A] [ConcreteCategory.{w} A] [HasColimits A] [HasLimits A]
variable [PreservesLimits (CategoryTheory.forget A)]
variable [PreservesFilteredColimits (CategoryTheory.forget A)]
variable [(CategoryTheory.forget A).ReflectsIsomorphisms]
/--
The pullback functor.
-/
def pullback (f : X ⟶ Y) : Y.Sheaf A ⥤ X.Sheaf A :=
(Opens.map f).sheafPullback _ _ _
lemma pullback_eq (f : X ⟶ Y) :
pullback A f = forget A Y ⋙ Presheaf.pullback A f ⋙ presheafToSheaf _ _ := rfl
/--
The pullback of a sheaf is isomorphic (actually definitionally equal) to the sheafification
of the pullback as a presheaf.
-/
def pullbackIso (f : X ⟶ Y) :
pullback A f ≅ forget A Y ⋙ Presheaf.pullback A f ⋙ presheafToSheaf _ _ := Iso.refl _
/-- The adjunction between pullback and pushforward for sheaves on topological spaces. -/
def pullbackPushforwardAdjunction (f : X ⟶ Y) :
pullback A f ⊣ pushforward A f :=
(Opens.map f).sheafAdjunctionContinuous _ _ _
instance : (pullback A f).IsLeftAdjoint := (pullbackPushforwardAdjunction A f).isLeftAdjoint
instance : (pushforward A f).IsRightAdjoint := (pullbackPushforwardAdjunction A f).isRightAdjoint
end Sheaf
end TopCat
|
Topology\Sheaves\Init.lean | /-
Copyright (c) 2023 Jujian Zhang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jujian Zhang
-/
import Aesop
/-!
# Rule sets related to topological (pre)sheaves
This module defines the `Restrict` Aesop rule set. Aesop rule sets only become
visible once the file in which they're declared is imported, so we must put this
declaration into its own file.
-/
/- to prove subset relations -/
declare_aesop_rule_sets [Restrict]
|
Topology\Sheaves\Limits.lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Topology.Sheaves.Sheaf
import Mathlib.CategoryTheory.Sites.Limits
import Mathlib.CategoryTheory.Limits.FunctorCategory
/-!
# Presheaves in `C` have limits and colimits when `C` does.
-/
noncomputable section
universe v u w
open CategoryTheory
open CategoryTheory.Limits
variable {C : Type u} [Category.{v} C] {J : Type v} [SmallCategory J]
namespace TopCat
instance [HasLimits C] (X : TopCat.{v}) : HasLimits.{v} (Presheaf C X) :=
Limits.functorCategoryHasLimitsOfSize.{v, v}
instance [HasColimits.{v, u} C] (X : TopCat.{w}) : HasColimitsOfSize.{v, v} (Presheaf C X) :=
Limits.functorCategoryHasColimitsOfSize
instance [HasLimits C] (X : TopCat) : CreatesLimits.{v, v} (Sheaf.forget C X) :=
Sheaf.createsLimits.{u, v, v}
instance [HasLimits C] (X : TopCat.{v}) : HasLimitsOfSize.{v, v} (Sheaf.{v} C X) :=
hasLimits_of_hasLimits_createsLimits (Sheaf.forget C X)
theorem isSheaf_of_isLimit [HasLimits C] {X : TopCat} (F : J ⥤ Presheaf.{v} C X)
(H : ∀ j, (F.obj j).IsSheaf) {c : Cone F} (hc : IsLimit c) : c.pt.IsSheaf := by
let F' : J ⥤ Sheaf C X :=
{ obj := fun j => ⟨F.obj j, H j⟩
map := fun f => ⟨F.map f⟩ }
let e : F' ⋙ Sheaf.forget C X ≅ F := NatIso.ofComponents fun _ => Iso.refl _
exact Presheaf.isSheaf_of_iso
((isLimitOfPreserves (Sheaf.forget C X) (limit.isLimit F')).conePointsIsoOfNatIso hc e)
(limit F').2
theorem limit_isSheaf [HasLimits C] {X : TopCat} (F : J ⥤ Presheaf.{v} C X)
(H : ∀ j, (F.obj j).IsSheaf) : (limit F).IsSheaf :=
isSheaf_of_isLimit F H (limit.isLimit F)
end TopCat
|
Topology\Sheaves\LocallySurjective.lean | /-
Copyright (c) 2022 Sam van Gool and Jake Levinson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sam van Gool, Jake Levinson
-/
import Mathlib.Topology.Sheaves.Presheaf
import Mathlib.Topology.Sheaves.Stalks
import Mathlib.CategoryTheory.Limits.Preserves.Filtered
import Mathlib.CategoryTheory.Sites.LocallySurjective
/-!
# Locally surjective maps of presheaves.
Let `X` be a topological space, `ℱ` and `𝒢` presheaves on `X`, `T : ℱ ⟶ 𝒢` a map.
In this file we formulate two notions for what it means for
`T` to be locally surjective:
1. For each open set `U`, each section `t : 𝒢(U)` is in the image of `T`
after passing to some open cover of `U`.
2. For each `x : X`, the map of *stalks* `Tₓ : ℱₓ ⟶ 𝒢ₓ` is surjective.
We prove that these are equivalent.
-/
universe v u
attribute [local instance] CategoryTheory.ConcreteCategory.instFunLike
noncomputable section
open CategoryTheory
open TopologicalSpace
open Opposite
namespace TopCat.Presheaf
section LocallySurjective
open scoped AlgebraicGeometry
variable {C : Type u} [Category.{v} C] [ConcreteCategory.{v} C] {X : TopCat.{v}}
variable {ℱ 𝒢 : X.Presheaf C}
/-- A map of presheaves `T : ℱ ⟶ 𝒢` is **locally surjective** if for any open set `U`,
section `t` over `U`, and `x ∈ U`, there exists an open set `x ∈ V ⊆ U` and a section `s` over `V`
such that `$T_*(s_V) = t|_V$`.
See `TopCat.Presheaf.isLocallySurjective_iff` below.
-/
def IsLocallySurjective (T : ℱ ⟶ 𝒢) :=
CategoryTheory.Presheaf.IsLocallySurjective (Opens.grothendieckTopology X) T
theorem isLocallySurjective_iff (T : ℱ ⟶ 𝒢) :
IsLocallySurjective T ↔
∀ (U t), ∀ x ∈ U, ∃ (V : _) (ι : V ⟶ U), (∃ s, T.app _ s = t |_ₕ ι) ∧ x ∈ V :=
⟨fun h _ => h.imageSieve_mem, fun h => ⟨h _⟩⟩
section SurjectiveOnStalks
variable [Limits.HasColimits C] [Limits.PreservesFilteredColimits (forget C)]
/-- An equivalent condition for a map of presheaves to be locally surjective
is for all the induced maps on stalks to be surjective. -/
theorem locally_surjective_iff_surjective_on_stalks (T : ℱ ⟶ 𝒢) :
IsLocallySurjective T ↔ ∀ x : X, Function.Surjective ((stalkFunctor C x).map T) := by
constructor <;> intro hT
· /- human proof:
Let g ∈ Γₛₜ 𝒢 x be a germ. Represent it on an open set U ⊆ X
as ⟨t, U⟩. By local surjectivity, pass to a smaller open set V
on which there exists s ∈ Γ_ ℱ V mapping to t |_ V.
Then the germ of s maps to g -/
-- Let g ∈ Γₛₜ 𝒢 x be a germ.
intro x g
-- Represent it on an open set U ⊆ X as ⟨t, U⟩.
obtain ⟨U, hxU, t, rfl⟩ := 𝒢.germ_exist x g
-- By local surjectivity, pass to a smaller open set V
-- on which there exists s ∈ Γ_ ℱ V mapping to t |_ V.
rcases hT.imageSieve_mem t x hxU with ⟨V, ι, ⟨s, h_eq⟩, hxV⟩
-- Then the germ of s maps to g.
use ℱ.germ ⟨x, hxV⟩ s
-- Porting note: `convert` went too deep and swapped LHS and RHS of the remaining goal relative
-- to lean 3.
convert stalkFunctor_map_germ_apply V ⟨x, hxV⟩ T s using 1
simpa [h_eq] using (germ_res_apply 𝒢 ι ⟨x, hxV⟩ t).symm
· /- human proof:
Let U be an open set, t ∈ Γ ℱ U a section, x ∈ U a point.
By surjectivity on stalks, the germ of t is the image of
some germ f ∈ Γₛₜ ℱ x. Represent f on some open set V ⊆ X as ⟨s, V⟩.
Then there is some possibly smaller open set x ∈ W ⊆ V ∩ U on which
we have T(s) |_ W = t |_ W. -/
constructor
intro U t x hxU
set t_x := 𝒢.germ ⟨x, hxU⟩ t with ht_x
obtain ⟨s_x, hs_x : ((stalkFunctor C x).map T) s_x = t_x⟩ := hT x t_x
obtain ⟨V, hxV, s, rfl⟩ := ℱ.germ_exist x s_x
-- rfl : ℱ.germ x s = s_x
have key_W := 𝒢.germ_eq x hxV hxU (T.app _ s) t <| by
convert hs_x using 1
symm
convert stalkFunctor_map_germ_apply _ _ _ s
obtain ⟨W, hxW, hWV, hWU, h_eq⟩ := key_W
refine ⟨W, hWU, ⟨ℱ.map hWV.op s, ?_⟩, hxW⟩
convert h_eq using 1
simp only [← comp_apply, T.naturality]
end SurjectiveOnStalks
end LocallySurjective
end TopCat.Presheaf
|
Topology\Sheaves\LocalPredicate.lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison, Adam Topaz
-/
import Mathlib.Topology.Sheaves.SheafOfFunctions
import Mathlib.Topology.Sheaves.Stalks
import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing
/-!
# Functions satisfying a local predicate form a sheaf.
At this stage, in `Mathlib/Topology/Sheaves/SheafOfFunctions.lean`
we've proved that not-necessarily-continuous functions from a topological space
into some type (or type family) form a sheaf.
Why do the continuous functions form a sheaf?
The point is just that continuity is a local condition,
so one can use the lifting condition for functions to provide a candidate lift,
then verify that the lift is actually continuous by using the factorisation condition for the lift
(which guarantees that on each open set it agrees with the functions being lifted,
which were assumed to be continuous).
This file abstracts this argument to work for
any collection of dependent functions on a topological space
satisfying a "local predicate".
As an application, we check that continuity is a local predicate in this sense, and provide
* `TopCat.sheafToTop`: continuous functions into a topological space form a sheaf
A sheaf constructed in this way has a natural map `stalkToFiber` from the stalks
to the types in the ambient type family.
We give conditions sufficient to show that this map is injective and/or surjective.
-/
universe v
noncomputable section
variable {X : TopCat.{v}}
variable (T : X → Type v)
open TopologicalSpace
open Opposite
open CategoryTheory
open CategoryTheory.Limits
open CategoryTheory.Limits.Types
namespace TopCat
/-- Given a topological space `X : TopCat` and a type family `T : X → Type`,
a `P : PrelocalPredicate T` consists of:
* a family of predicates `P.pred`, one for each `U : Opens X`, of the form `(Π x : U, T x) → Prop`
* a proof that if `f : Π x : V, T x` satisfies the predicate on `V : Opens X`, then
the restriction of `f` to any open subset `U` also satisfies the predicate.
-/
structure PrelocalPredicate where
/-- The underlying predicate of a prelocal predicate -/
pred : ∀ {U : Opens X}, (∀ x : U, T x) → Prop
/-- The underlying predicate should be invariant under restriction -/
res : ∀ {U V : Opens X} (i : U ⟶ V) (f : ∀ x : V, T x) (_ : pred f), pred fun x : U => f (i x)
variable (X)
/-- Continuity is a "prelocal" predicate on functions to a fixed topological space `T`.
-/
@[simps!]
def continuousPrelocal (T : TopCat.{v}) : PrelocalPredicate fun _ : X => T where
pred {_} f := Continuous f
res {_ _} i _ h := Continuous.comp h (Opens.openEmbedding_of_le i.le).continuous
/-- Satisfying the inhabited linter. -/
instance inhabitedPrelocalPredicate (T : TopCat.{v}) :
Inhabited (PrelocalPredicate fun _ : X => T) :=
⟨continuousPrelocal X T⟩
variable {X}
/-- Given a topological space `X : TopCat` and a type family `T : X → Type`,
a `P : LocalPredicate T` consists of:
* a family of predicates `P.pred`, one for each `U : Opens X`, of the form `(Π x : U, T x) → Prop`
* a proof that if `f : Π x : V, T x` satisfies the predicate on `V : Opens X`, then
the restriction of `f` to any open subset `U` also satisfies the predicate, and
* a proof that given some `f : Π x : U, T x`,
if for every `x : U` we can find an open set `x ∈ V ≤ U`
so that the restriction of `f` to `V` satisfies the predicate,
then `f` itself satisfies the predicate.
-/
structure LocalPredicate extends PrelocalPredicate T where
/-- A local predicate must be local --- provided that it is locally satisfied, it is also globally
satisfied -/
locality :
∀ {U : Opens X} (f : ∀ x : U, T x)
(_ : ∀ x : U, ∃ (V : Opens X) (_ : x.1 ∈ V) (i : V ⟶ U),
pred fun x : V => f (i x : U)), pred f
variable (X)
/-- Continuity is a "local" predicate on functions to a fixed topological space `T`.
-/
def continuousLocal (T : TopCat.{v}) : LocalPredicate fun _ : X => T :=
{ continuousPrelocal X T with
locality := fun {U} f w => by
apply continuous_iff_continuousAt.2
intro x
specialize w x
rcases w with ⟨V, m, i, w⟩
dsimp at w
rw [continuous_iff_continuousAt] at w
specialize w ⟨x, m⟩
simpa using (Opens.openEmbedding_of_le i.le).continuousAt_iff.1 w }
/-- Satisfying the inhabited linter. -/
instance inhabitedLocalPredicate (T : TopCat.{v}) : Inhabited (LocalPredicate fun _ : X => T) :=
⟨continuousLocal X T⟩
variable {X T}
/-- Given a `P : PrelocalPredicate`, we can always construct a `LocalPredicate`
by asking that the condition from `P` holds locally near every point.
-/
def PrelocalPredicate.sheafify {T : X → Type v} (P : PrelocalPredicate T) : LocalPredicate T where
pred {U} f := ∀ x : U, ∃ (V : Opens X) (_ : x.1 ∈ V) (i : V ⟶ U), P.pred fun x : V => f (i x : U)
res {V U} i f w x := by
specialize w (i x)
rcases w with ⟨V', m', i', p⟩
refine ⟨V ⊓ V', ⟨x.2, m'⟩, Opens.infLELeft _ _, ?_⟩
convert P.res (Opens.infLERight V V') _ p
locality {U} f w x := by
specialize w x
rcases w with ⟨V, m, i, p⟩
specialize p ⟨x.1, m⟩
rcases p with ⟨V', m', i', p'⟩
exact ⟨V', m', i' ≫ i, p'⟩
theorem PrelocalPredicate.sheafifyOf {T : X → Type v} {P : PrelocalPredicate T} {U : Opens X}
{f : ∀ x : U, T x} (h : P.pred f) : P.sheafify.pred f := fun x =>
⟨U, x.2, 𝟙 _, by convert h⟩
/-- The subpresheaf of dependent functions on `X` satisfying the "pre-local" predicate `P`.
-/
@[simps!]
def subpresheafToTypes (P : PrelocalPredicate T) : Presheaf (Type v) X where
obj U := { f : ∀ x : U.unop , T x // P.pred f }
map {U V} i f := ⟨fun x => f.1 (i.unop x), P.res i.unop f.1 f.2⟩
namespace subpresheafToTypes
variable (P : PrelocalPredicate T)
/-- The natural transformation including the subpresheaf of functions satisfying a local predicate
into the presheaf of all functions.
-/
def subtype : subpresheafToTypes P ⟶ presheafToTypes X T where app U f := f.1
open TopCat.Presheaf
/-- The functions satisfying a local predicate satisfy the sheaf condition.
-/
theorem isSheaf (P : LocalPredicate T) : (subpresheafToTypes P.toPrelocalPredicate).IsSheaf :=
Presheaf.isSheaf_of_isSheafUniqueGluing_types.{v} _ fun ι U sf sf_comp => by
-- We show the sheaf condition in terms of unique gluing.
-- First we obtain a family of sections for the underlying sheaf of functions,
-- by forgetting that the predicate holds
let sf' : ∀ i : ι, (presheafToTypes X T).obj (op (U i)) := fun i => (sf i).val
-- Since our original family is compatible, this one is as well
have sf'_comp : (presheafToTypes X T).IsCompatible U sf' := fun i j =>
congr_arg Subtype.val (sf_comp i j)
-- So, we can obtain a unique gluing
obtain ⟨gl, gl_spec, gl_uniq⟩ := (sheafToTypes X T).existsUnique_gluing U sf' sf'_comp
refine ⟨⟨gl, ?_⟩, ?_, ?_⟩
· -- Our first goal is to show that this chosen gluing satisfies the
-- predicate. Of course, we use locality of the predicate.
apply P.locality
rintro ⟨x, mem⟩
-- Once we're at a particular point `x`, we can select some open set `x ∈ U i`.
choose i hi using Opens.mem_iSup.mp mem
-- We claim that the predicate holds in `U i`
use U i, hi, Opens.leSupr U i
-- This follows, since our original family `sf` satisfies the predicate
convert (sf i).property using 1
exact gl_spec i
-- It remains to show that the chosen lift is really a gluing for the subsheaf and
-- that it is unique. Both of which follow immediately from the corresponding facts
-- in the sheaf of functions without the local predicate.
· exact fun i => Subtype.ext (gl_spec i)
· intro gl' hgl'
refine Subtype.ext ?_
exact gl_uniq gl'.1 fun i => congr_arg Subtype.val (hgl' i)
end subpresheafToTypes
/-- The subsheaf of the sheaf of all dependently typed functions satisfying the local predicate `P`.
-/
@[simps]
def subsheafToTypes (P : LocalPredicate T) : Sheaf (Type v) X :=
⟨subpresheafToTypes P.toPrelocalPredicate, subpresheafToTypes.isSheaf P⟩
/-- There is a canonical map from the stalk to the original fiber, given by evaluating sections.
-/
def stalkToFiber (P : LocalPredicate T) (x : X) : (subsheafToTypes P).presheaf.stalk x ⟶ T x := by
refine
colimit.desc _
{ pt := T x
ι :=
{ app := fun U f => ?_
naturality := ?_ } }
· exact f.1 ⟨x, (unop U).2⟩
· aesop
-- Porting note (#11119): removed `simp` attribute,
-- due to left hand side is not in simple normal form.
theorem stalkToFiber_germ (P : LocalPredicate T) (U : Opens X) (x : U) (f) :
stalkToFiber P x ((subsheafToTypes P).presheaf.germ x f) = f.1 x := by
dsimp [Presheaf.germ, stalkToFiber]
cases x
simp
/-- The `stalkToFiber` map is surjective at `x` if
every point in the fiber `T x` has an allowed section passing through it.
-/
theorem stalkToFiber_surjective (P : LocalPredicate T) (x : X)
(w : ∀ t : T x, ∃ (U : OpenNhds x) (f : ∀ y : U.1, T y) (_ : P.pred f), f ⟨x, U.2⟩ = t) :
Function.Surjective (stalkToFiber P x) := fun t => by
rcases w t with ⟨U, f, h, rfl⟩
fconstructor
· exact (subsheafToTypes P).presheaf.germ ⟨x, U.2⟩ ⟨f, h⟩
· exact stalkToFiber_germ _ U.1 ⟨x, U.2⟩ ⟨f, h⟩
/-- The `stalkToFiber` map is injective at `x` if any two allowed sections which agree at `x`
agree on some neighborhood of `x`.
-/
theorem stalkToFiber_injective (P : LocalPredicate T) (x : X)
(w :
∀ (U V : OpenNhds x) (fU : ∀ y : U.1, T y) (_ : P.pred fU) (fV : ∀ y : V.1, T y)
(_ : P.pred fV) (_ : fU ⟨x, U.2⟩ = fV ⟨x, V.2⟩),
∃ (W : OpenNhds x) (iU : W ⟶ U) (iV : W ⟶ V), ∀ w : W.1,
fU (iU w : U.1) = fV (iV w : V.1)) :
Function.Injective (stalkToFiber P x) := fun tU tV h => by
-- We promise to provide all the ingredients of the proof later:
let Q :
∃ (W : (OpenNhds x)ᵒᵖ) (s : ∀ w : (unop W).1, T w) (hW : P.pred s),
tU = (subsheafToTypes P).presheaf.germ ⟨x, (unop W).2⟩ ⟨s, hW⟩ ∧
tV = (subsheafToTypes P).presheaf.germ ⟨x, (unop W).2⟩ ⟨s, hW⟩ :=
?_
· choose W s hW e using Q
exact e.1.trans e.2.symm
-- Then use induction to pick particular representatives of `tU tV : stalk x`
obtain ⟨U, ⟨fU, hU⟩, rfl⟩ := jointly_surjective'.{v, v} tU
obtain ⟨V, ⟨fV, hV⟩, rfl⟩ := jointly_surjective'.{v, v} tV
-- Decompose everything into its constituent parts:
dsimp
simp only [stalkToFiber, Types.Colimit.ι_desc_apply'] at h
specialize w (unop U) (unop V) fU hU fV hV h
rcases w with ⟨W, iU, iV, w⟩
-- and put it back together again in the correct order.
refine ⟨op W, fun w => fU (iU w : (unop U).1), P.res ?_ _ hU, ?_⟩
· rcases W with ⟨W, m⟩
exact iU
· exact ⟨colimit_sound iU.op (Subtype.eq rfl), colimit_sound iV.op (Subtype.eq (funext w).symm)⟩
/-- Some repackaging:
the presheaf of functions satisfying `continuousPrelocal` is just the same thing as
the presheaf of continuous functions.
-/
def subpresheafContinuousPrelocalIsoPresheafToTop (T : TopCat.{v}) :
subpresheafToTypes (continuousPrelocal X T) ≅ presheafToTop X T :=
NatIso.ofComponents fun X =>
{ hom := by rintro ⟨f, c⟩; exact ⟨f, c⟩
inv := by rintro ⟨f, c⟩; exact ⟨f, c⟩ }
/-- The sheaf of continuous functions on `X` with values in a space `T`.
-/
def sheafToTop (T : TopCat.{v}) : Sheaf (Type v) X :=
⟨presheafToTop X T,
Presheaf.isSheaf_of_iso (subpresheafContinuousPrelocalIsoPresheafToTop T)
(subpresheafToTypes.isSheaf (continuousLocal X T))⟩
end TopCat
|
Topology\Sheaves\Operations.lean | /-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.Algebra.Category.Ring.Instances
import Mathlib.Algebra.Category.Ring.FilteredColimits
import Mathlib.RingTheory.Localization.Basic
import Mathlib.Topology.Sheaves.Stalks
/-!
# Operations on sheaves
## Main definition
- `SubmonoidPresheaf` : A subpresheaf with a submonoid structure on each of the components.
- `LocalizationPresheaf` : The localization of a presheaf of commrings at a `SubmonoidPresheaf`.
- `TotalQuotientPresheaf` : The presheaf of total quotient rings.
-/
open scoped nonZeroDivisors
open TopologicalSpace Opposite CategoryTheory
universe v u w
namespace TopCat
namespace Presheaf
variable {X : TopCat.{w}} {C : Type u} [Category.{v} C] [ConcreteCategory C]
attribute [local instance 1000] ConcreteCategory.hasCoeToSort ConcreteCategory.instFunLike
/-- A subpresheaf with a submonoid structure on each of the components. -/
structure SubmonoidPresheaf [∀ X : C, MulOneClass X] [∀ X Y : C, MonoidHomClass (X ⟶ Y) X Y]
(F : X.Presheaf C) where
obj : ∀ U, Submonoid (F.obj U)
map : ∀ {U V : (Opens X)ᵒᵖ} (i : U ⟶ V), obj U ≤ (obj V).comap (F.map i)
variable {F : X.Presheaf CommRingCat.{w}} (G : F.SubmonoidPresheaf)
/-- The localization of a presheaf of `CommRing`s with respect to a `SubmonoidPresheaf`. -/
protected noncomputable def SubmonoidPresheaf.localizationPresheaf : X.Presheaf CommRingCat where
obj U := CommRingCat.of <| Localization (G.obj U)
map {U V} i := CommRingCat.ofHom <| IsLocalization.map _ (F.map i) (G.map i)
map_id U := by
simp_rw [F.map_id]
ext x
-- Porting note: `M` and `S` needs to be specified manually
exact IsLocalization.map_id (M := G.obj U) (S := Localization (G.obj U)) x
map_comp {U V W} i j := by
delta CommRingCat.ofHom CommRingCat.of Bundled.of
simp_rw [F.map_comp, CommRingCat.comp_eq_ring_hom_comp]
rw [IsLocalization.map_comp_map]
-- Porting note: this instance can't be synthesized
instance (U) : Algebra ((forget CommRingCat).obj (F.obj U)) (G.localizationPresheaf.obj U) :=
show Algebra _ (Localization (G.obj U)) from inferInstance
-- Porting note: this instance can't be synthesized
instance (U) : IsLocalization (G.obj U) (G.localizationPresheaf.obj U) :=
show IsLocalization (G.obj U) (Localization (G.obj U)) from inferInstance
/-- The map into the localization presheaf. -/
@[simps app]
def SubmonoidPresheaf.toLocalizationPresheaf : F ⟶ G.localizationPresheaf where
app U := CommRingCat.ofHom <| algebraMap (F.obj U) (Localization <| G.obj U)
naturality {_ _} i := (IsLocalization.map_comp (G.map i)).symm
instance epi_toLocalizationPresheaf : Epi G.toLocalizationPresheaf :=
@NatTrans.epi_of_epi_app _ _ _ _ _ _ G.toLocalizationPresheaf fun U => Localization.epi' (G.obj U)
variable (F)
/-- Given a submonoid at each of the stalks, we may define a submonoid presheaf consisting of
sections whose restriction onto each stalk falls in the given submonoid. -/
@[simps]
noncomputable def submonoidPresheafOfStalk (S : ∀ x : X, Submonoid (F.stalk x)) :
F.SubmonoidPresheaf where
obj U := ⨅ x : U.unop, Submonoid.comap (F.germ x) (S x)
map {U V} i := by
intro s hs
simp only [Submonoid.mem_comap, Submonoid.mem_iInf] at hs ⊢
intro x
change (F.map i.unop.op ≫ F.germ x) s ∈ _
rw [F.germ_res]
exact hs _
noncomputable instance : Inhabited F.SubmonoidPresheaf :=
⟨F.submonoidPresheafOfStalk fun _ => ⊥⟩
/-- The localization of a presheaf of `CommRing`s at locally non-zero-divisor sections. -/
noncomputable def totalQuotientPresheaf : X.Presheaf CommRingCat.{w} :=
(F.submonoidPresheafOfStalk fun x => (F.stalk x)⁰).localizationPresheaf
/-- The map into the presheaf of total quotient rings -/
noncomputable def toTotalQuotientPresheaf : F ⟶ F.totalQuotientPresheaf :=
SubmonoidPresheaf.toLocalizationPresheaf _
-- Porting note: deriving `Epi` failed
instance : Epi (toTotalQuotientPresheaf F) := epi_toLocalizationPresheaf _
instance (F : X.Sheaf CommRingCat.{w}) : Mono F.presheaf.toTotalQuotientPresheaf := by
-- Porting note: was an `apply (config := { instances := false })`
-- See https://github.com/leanprover/lean4/issues/2273
suffices ∀ (U : (Opens ↑X)ᵒᵖ), Mono (F.presheaf.toTotalQuotientPresheaf.app U) from
NatTrans.mono_of_mono_app _
intro U
apply ConcreteCategory.mono_of_injective
dsimp [toTotalQuotientPresheaf, CommRingCat.ofHom]
-- Porting note: this is a hack to make the `refine` below works
set m := _
change Function.Injective (algebraMap _ (Localization m))
change Function.Injective (algebraMap (F.presheaf.obj U) _)
haveI : IsLocalization _ (Localization m) := Localization.isLocalization
-- Porting note: `M` and `S` need to be specified manually, so used a hack to save some typing
refine IsLocalization.injective (M := m) (S := Localization m) ?_
intro s hs t e
apply section_ext F (unop U)
intro x
rw [map_zero]
apply Submonoid.mem_iInf.mp hs x
-- Porting note: added `dsimp` to make `rw [← map_mul]` work
dsimp
rw [← map_mul, e, map_zero]
end Presheaf
end TopCat
|
Topology\Sheaves\Presheaf.lean | /-
Copyright (c) 2018 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Mario Carneiro, Reid Barton, Andrew Yang
-/
import Mathlib.Topology.Category.TopCat.Opens
import Mathlib.CategoryTheory.Adjunction.Unique
import Mathlib.CategoryTheory.Functor.KanExtension.Adjunction
import Mathlib.Topology.Sheaves.Init
import Mathlib.Data.Set.Subsingleton
/-!
# Presheaves on a topological space
We define `TopCat.Presheaf C X` simply as `(TopologicalSpace.Opens X)ᵒᵖ ⥤ C`,
and inherit the category structure with natural transformations as morphisms.
We define
* Given `{X Y : TopCat.{w}}` and `f : X ⟶ Y`, we define
`TopCat.Presheaf.pushforward C f : X.Presheaf C ⥤ Y.Presheaf C`,
with notation `f _* ℱ` for `ℱ : X.Presheaf C`.
and for `ℱ : X.Presheaf C` provide the natural isomorphisms
* `TopCat.Presheaf.Pushforward.id : (𝟙 X) _* ℱ ≅ ℱ`
* `TopCat.Presheaf.Pushforward.comp : (f ≫ g) _* ℱ ≅ g _* (f _* ℱ)`
along with their `@[simp]` lemmas.
We also define the functors `pullback C f : Y.Presheaf C ⥤ X.Presheaf c`,
and provide their adjunction at
`TopCat.Presheaf.pushforwardPullbackAdjunction`.
-/
universe w v u
open CategoryTheory TopologicalSpace Opposite
variable (C : Type u) [Category.{v} C]
namespace TopCat
/-- The category of `C`-valued presheaves on a (bundled) topological space `X`. -/
-- Porting note(#5171): was @[nolint has_nonempty_instance]
def Presheaf (X : TopCat.{w}) : Type max u v w :=
(Opens X)ᵒᵖ ⥤ C
instance (X : TopCat.{w}) : Category (Presheaf.{w, v, u} C X) :=
inferInstanceAs (Category ((Opens X)ᵒᵖ ⥤ C : Type max u v w))
variable {C}
namespace Presheaf
@[simp] theorem comp_app {X : TopCat} {U : (Opens X)ᵒᵖ} {P Q R : Presheaf C X}
(f : P ⟶ Q) (g : Q ⟶ R) :
(f ≫ g).app U = f.app U ≫ g.app U := rfl
@[ext]
lemma ext {X : TopCat} {P Q : Presheaf C X} {f g : P ⟶ Q}
(w : ∀ U : Opens X, f.app (op U) = g.app (op U)) :
f = g := by
apply NatTrans.ext
ext U
induction U with | _ U => ?_
apply w
attribute [local instance] CategoryTheory.ConcreteCategory.hasCoeToSort
CategoryTheory.ConcreteCategory.instFunLike
/-- attribute `sheaf_restrict` to mark lemmas related to restricting sheaves -/
macro "sheaf_restrict" : attr =>
`(attr|aesop safe 50 apply (rule_sets := [$(Lean.mkIdent `Restrict):ident]))
attribute [sheaf_restrict] bot_le le_top le_refl inf_le_left inf_le_right
le_sup_left le_sup_right
/-- `restrict_tac` solves relations among subsets (copied from `aesop cat`) -/
macro (name := restrict_tac) "restrict_tac" c:Aesop.tactic_clause* : tactic =>
`(tactic| first | assumption |
aesop $c*
(config := { terminal := true
assumptionTransparency := .reducible
enableSimp := false })
(rule_sets := [-default, -builtin, $(Lean.mkIdent `Restrict):ident]))
/-- `restrict_tac?` passes along `Try this` from `aesop` -/
macro (name := restrict_tac?) "restrict_tac?" c:Aesop.tactic_clause* : tactic =>
`(tactic|
aesop? $c*
(config := { terminal := true
assumptionTransparency := .reducible
enableSimp := false
maxRuleApplications := 300 })
(rule_sets := [-default, -builtin, $(Lean.mkIdent `Restrict):ident]))
attribute[aesop 10% (rule_sets := [Restrict])] le_trans
attribute[aesop safe destruct (rule_sets := [Restrict])] Eq.trans_le
attribute[aesop safe -50 (rule_sets := [Restrict])] Aesop.BuiltinRules.assumption
example {X} [CompleteLattice X] (v : Nat → X) (w x y z : X) (e : v 0 = v 1) (_ : v 1 = v 2)
(h₀ : v 1 ≤ x) (_ : x ≤ z ⊓ w) (h₂ : x ≤ y ⊓ z) : v 0 ≤ y := by
restrict_tac
/-- The restriction of a section along an inclusion of open sets.
For `x : F.obj (op V)`, we provide the notation `x |_ₕ i` (`h` stands for `hom`) for `i : U ⟶ V`,
and the notation `x |_ₗ U ⟪i⟫` (`l` stands for `le`) for `i : U ≤ V`.
-/
def restrict {X : TopCat} {C : Type*} [Category C] [ConcreteCategory C] {F : X.Presheaf C}
{V : Opens X} (x : F.obj (op V)) {U : Opens X} (h : U ⟶ V) : F.obj (op U) :=
F.map h.op x
/-- restriction of a section along an inclusion -/
scoped[AlgebraicGeometry] infixl:80 " |_ₕ " => TopCat.Presheaf.restrict
/-- restriction of a section along a subset relation -/
scoped[AlgebraicGeometry] notation:80 x " |_ₗ " U " ⟪" e "⟫ " =>
@TopCat.Presheaf.restrict _ _ _ _ _ _ x U (@homOfLE (Opens _) _ U _ e)
open AlgebraicGeometry
/-- The restriction of a section along an inclusion of open sets.
For `x : F.obj (op V)`, we provide the notation `x |_ U`, where the proof `U ≤ V` is inferred by
the tactic `Top.presheaf.restrict_tac'` -/
abbrev restrictOpen {X : TopCat} {C : Type*} [Category C] [ConcreteCategory C] {F : X.Presheaf C}
{V : Opens X} (x : F.obj (op V)) (U : Opens X)
(e : U ≤ V := by restrict_tac) :
F.obj (op U) :=
x |_ₗ U ⟪e⟫
/-- restriction of a section to open subset -/
scoped[AlgebraicGeometry] infixl:80 " |_ " => TopCat.Presheaf.restrictOpen
-- Porting note: linter tells this lemma is no going to be picked up by the simplifier, hence
-- `@[simp]` is removed
theorem restrict_restrict {X : TopCat} {C : Type*} [Category C] [ConcreteCategory C]
{F : X.Presheaf C} {U V W : Opens X} (e₁ : U ≤ V) (e₂ : V ≤ W) (x : F.obj (op W)) :
x |_ V |_ U = x |_ U := by
delta restrictOpen restrict
rw [← comp_apply, ← Functor.map_comp]
rfl
-- Porting note: linter tells this lemma is no going to be picked up by the simplifier, hence
-- `@[simp]` is removed
theorem map_restrict {X : TopCat} {C : Type*} [Category C] [ConcreteCategory C]
{F G : X.Presheaf C} (e : F ⟶ G) {U V : Opens X} (h : U ≤ V) (x : F.obj (op V)) :
e.app _ (x |_ U) = e.app _ x |_ U := by
delta restrictOpen restrict
rw [← comp_apply, NatTrans.naturality, comp_apply]
open CategoryTheory.Limits
variable (C)
/-- The pushforward functor. -/
@[simps!]
def pushforward {X Y : TopCat.{w}} (f : X ⟶ Y) : X.Presheaf C ⥤ Y.Presheaf C :=
(whiskeringLeft _ _ _).obj (Opens.map f).op
set_option quotPrecheck false in
/-- push forward of a presheaf-/
notation f:80 " _* " P:81 => (pushforward _ f).obj P
@[simp]
theorem pushforward_map_app' {X Y : TopCat.{w}} (f : X ⟶ Y) {ℱ 𝒢 : X.Presheaf C} (α : ℱ ⟶ 𝒢)
{U : (Opens Y)ᵒᵖ} : ((pushforward C f).map α).app U = α.app (op <| (Opens.map f).obj U.unop) :=
rfl
lemma id_pushforward (X : TopCat.{w}) : pushforward C (𝟙 X) = 𝟭 (X.Presheaf C) := rfl
variable {C}
namespace Pushforward
/-- The natural isomorphism between the pushforward of a presheaf along the identity continuous map
and the original presheaf. -/
def id {X : TopCat.{w}} (ℱ : X.Presheaf C) : 𝟙 X _* ℱ ≅ ℱ := Iso.refl _
@[simp]
theorem id_hom_app {X : TopCat.{w}} (ℱ : X.Presheaf C) (U) : (id ℱ).hom.app U = 𝟙 _ := rfl
@[simp]
theorem id_inv_app {X : TopCat.{w}} (ℱ : X.Presheaf C) (U) :
(id ℱ).inv.app U = 𝟙 _ := rfl
theorem id_eq {X : TopCat.{w}} (ℱ : X.Presheaf C) : 𝟙 X _* ℱ = ℱ := rfl
/-- The natural isomorphism between
the pushforward of a presheaf along the composition of two continuous maps and
the corresponding pushforward of a pushforward. -/
def comp {X Y Z : TopCat.{w}} (f : X ⟶ Y) (g : Y ⟶ Z) (ℱ : X.Presheaf C) :
(f ≫ g) _* ℱ ≅ g _* (f _* ℱ) := Iso.refl _
theorem comp_eq {X Y Z : TopCat.{w}} (f : X ⟶ Y) (g : Y ⟶ Z) (ℱ : X.Presheaf C) :
(f ≫ g) _* ℱ = g _* (f _* ℱ) :=
rfl
@[simp]
theorem comp_hom_app {X Y Z : TopCat.{w}} (f : X ⟶ Y) (g : Y ⟶ Z) (ℱ : X.Presheaf C) (U) :
(comp f g ℱ).hom.app U = 𝟙 _ := rfl
@[simp]
theorem comp_inv_app {X Y Z : TopCat.{w}} (f : X ⟶ Y) (g : Y ⟶ Z) (ℱ : X.Presheaf C) (U) :
(comp f g ℱ).inv.app U = 𝟙 _ := rfl
end Pushforward
/--
An equality of continuous maps induces a natural isomorphism between the pushforwards of a presheaf
along those maps.
-/
def pushforwardEq {X Y : TopCat.{w}} {f g : X ⟶ Y} (h : f = g) (ℱ : X.Presheaf C) :
f _* ℱ ≅ g _* ℱ :=
isoWhiskerRight (NatIso.op (Opens.mapIso f g h).symm) ℱ
theorem pushforward_eq' {X Y : TopCat.{w}} {f g : X ⟶ Y} (h : f = g) (ℱ : X.Presheaf C) :
f _* ℱ = g _* ℱ := by rw [h]
@[simp]
theorem pushforwardEq_hom_app {X Y : TopCat.{w}} {f g : X ⟶ Y}
(h : f = g) (ℱ : X.Presheaf C) (U) :
(pushforwardEq h ℱ).hom.app U = ℱ.map (eqToHom (by aesop_cat)) := by
simp [pushforwardEq]
variable (C)
section Iso
/-- A homeomorphism of spaces gives an equivalence of categories of presheaves. -/
@[simps!]
def presheafEquivOfIso {X Y : TopCat} (H : X ≅ Y) : X.Presheaf C ≌ Y.Presheaf C :=
Equivalence.congrLeft (Opens.mapMapIso H).symm.op
variable {C}
/-- If `H : X ≅ Y` is a homeomorphism,
then given an `H _* ℱ ⟶ 𝒢`, we may obtain an `ℱ ⟶ H ⁻¹ _* 𝒢`.
-/
def toPushforwardOfIso {X Y : TopCat} (H : X ≅ Y) {ℱ : X.Presheaf C} {𝒢 : Y.Presheaf C}
(α : H.hom _* ℱ ⟶ 𝒢) : ℱ ⟶ H.inv _* 𝒢 :=
(presheafEquivOfIso _ H).toAdjunction.homEquiv ℱ 𝒢 α
@[simp]
theorem toPushforwardOfIso_app {X Y : TopCat} (H₁ : X ≅ Y) {ℱ : X.Presheaf C} {𝒢 : Y.Presheaf C}
(H₂ : H₁.hom _* ℱ ⟶ 𝒢) (U : (Opens X)ᵒᵖ) :
(toPushforwardOfIso H₁ H₂).app U =
ℱ.map (eqToHom (by simp [Opens.map, Set.preimage_preimage])) ≫
H₂.app (op ((Opens.map H₁.inv).obj (unop U))) := by
delta toPushforwardOfIso
simp [-Functor.map_comp, ← Functor.map_comp_assoc]
rfl
/-- If `H : X ≅ Y` is a homeomorphism,
then given an `H _* ℱ ⟶ 𝒢`, we may obtain an `ℱ ⟶ H ⁻¹ _* 𝒢`.
-/
def pushforwardToOfIso {X Y : TopCat} (H₁ : X ≅ Y) {ℱ : Y.Presheaf C} {𝒢 : X.Presheaf C}
(H₂ : ℱ ⟶ H₁.hom _* 𝒢) : H₁.inv _* ℱ ⟶ 𝒢 :=
((presheafEquivOfIso _ H₁.symm).toAdjunction.homEquiv ℱ 𝒢).symm H₂
@[simp]
theorem pushforwardToOfIso_app {X Y : TopCat} (H₁ : X ≅ Y) {ℱ : Y.Presheaf C} {𝒢 : X.Presheaf C}
(H₂ : ℱ ⟶ H₁.hom _* 𝒢) (U : (Opens X)ᵒᵖ) :
(pushforwardToOfIso H₁ H₂).app U =
H₂.app (op ((Opens.map H₁.inv).obj (unop U))) ≫
𝒢.map (eqToHom (by simp [Opens.map, Set.preimage_preimage])) := by
simp [pushforwardToOfIso, Equivalence.toAdjunction]
end Iso
variable [HasColimits C]
noncomputable section
/-- Pullback a presheaf on `Y` along a continuous map `f : X ⟶ Y`, obtaining a presheaf
on `X`. -/
def pullback {X Y : TopCat.{v}} (f : X ⟶ Y) : Y.Presheaf C ⥤ X.Presheaf C :=
(Opens.map f).op.lan
/-- The pullback and pushforward along a continuous map are adjoint to each other. -/
def pushforwardPullbackAdjunction {X Y : TopCat.{v}} (f : X ⟶ Y) :
pullback C f ⊣ pushforward C f :=
Functor.lanAdjunction _ _
/-- Pulling back along a homeomorphism is the same as pushing forward along its inverse. -/
def pullbackHomIsoPushforwardInv {X Y : TopCat.{v}} (H : X ≅ Y) :
pullback C H.hom ≅ pushforward C H.inv :=
Adjunction.leftAdjointUniq (pushforwardPullbackAdjunction C H.hom)
(presheafEquivOfIso C H.symm).toAdjunction
/-- Pulling back along the inverse of a homeomorphism is the same as pushing forward along it. -/
def pullbackInvIsoPushforwardHom {X Y : TopCat.{v}} (H : X ≅ Y) :
pullback C H.inv ≅ pushforward C H.hom :=
Adjunction.leftAdjointUniq (pushforwardPullbackAdjunction C H.inv)
(presheafEquivOfIso C H).toAdjunction
variable {C}
/-- If `f '' U` is open, then `f⁻¹ℱ U ≅ ℱ (f '' U)`. -/
def pullbackObjObjOfImageOpen {X Y : TopCat.{v}} (f : X ⟶ Y) (ℱ : Y.Presheaf C) (U : Opens X)
(H : IsOpen (f '' SetLike.coe U)) : ((pullback C f).obj ℱ).obj (op U) ≅ ℱ.obj (op ⟨_, H⟩) := by
let x : CostructuredArrow (Opens.map f).op (op U) := CostructuredArrow.mk
(@homOfLE _ _ _ ((Opens.map f).obj ⟨_, H⟩) (Set.image_preimage.le_u_l _)).op
have hx : IsTerminal x :=
{ lift := fun s ↦ by
fapply CostructuredArrow.homMk
· change op (unop _) ⟶ op (⟨_, H⟩ : Opens _)
refine (homOfLE ?_).op
apply (Set.image_subset f s.pt.hom.unop.le).trans
exact Set.image_preimage.l_u_le (SetLike.coe s.pt.left.unop)
· simp [autoParam, eq_iff_true_of_subsingleton] }
exact IsColimit.coconePointUniqueUpToIso
((Opens.map f).op.isPointwiseLeftKanExtensionLanUnit ℱ (op U))
(colimitOfDiagramTerminal hx _)
end
end Presheaf
end TopCat
|
Topology\Sheaves\PresheafOfFunctions.lean | /-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.CategoryTheory.Yoneda
import Mathlib.Topology.Sheaves.Presheaf
import Mathlib.Topology.Category.TopCommRingCat
import Mathlib.Topology.ContinuousFunction.Algebra
/-!
# Presheaves of functions
We construct some simple examples of presheaves of functions on a topological space.
* `presheafToTypes X T`, where `T : X → Type`,
is the presheaf of dependently-typed (not-necessarily continuous) functions
* `presheafToType X T`, where `T : Type`,
is the presheaf of (not-necessarily-continuous) functions to a fixed target type `T`
* `presheafToTop X T`, where `T : TopCat`,
is the presheaf of continuous functions into a topological space `T`
* `presheafToTopCommRing X R`, where `R : TopCommRingCat`
is the presheaf valued in `CommRing` of functions functions into a topological ring `R`
* as an example of the previous construction,
`presheafToTopCommRing X (TopCommRingCat.of ℂ)`
is the presheaf of rings of continuous complex-valued functions on `X`.
-/
universe v u
open CategoryTheory
open TopologicalSpace
open Opposite
namespace TopCat
variable (X : TopCat.{v})
/-- The presheaf of dependently typed functions on `X`, with fibres given by a type family `T`.
There is no requirement that the functions are continuous, here.
-/
def presheafToTypes (T : X → Type v) : X.Presheaf (Type v) where
obj U := ∀ x : U.unop, T x
map {U V} i g := fun x : V.unop => g (i.unop x)
map_id U := by
ext g
rfl
map_comp {U V W} i j := rfl
@[simp]
theorem presheafToTypes_obj {T : X → Type v} {U : (Opens X)ᵒᵖ} :
(presheafToTypes X T).obj U = ∀ x : U.unop, T x :=
rfl
@[simp]
theorem presheafToTypes_map {T : X → Type v} {U V : (Opens X)ᵒᵖ} {i : U ⟶ V} {f} :
(presheafToTypes X T).map i f = fun x => f (i.unop x) :=
rfl
-- We don't just define this in terms of `presheafToTypes`,
-- as it's helpful later to see (at a syntactic level) that `(presheafToType X T).obj U`
-- is a non-dependent function.
-- We don't use `@[simps]` to generate the projection lemmas here,
-- as it turns out to be useful to have `presheafToType_map`
-- written as an equality of functions (rather than being applied to some argument).
/-- The presheaf of functions on `X` with values in a type `T`.
There is no requirement that the functions are continuous, here.
-/
def presheafToType (T : Type v) : X.Presheaf (Type v) where
obj U := U.unop → T
map {U V} i g := g ∘ i.unop
map_id U := by
ext g
rfl
map_comp {U V W} i j := rfl
@[simp]
theorem presheafToType_obj {T : Type v} {U : (Opens X)ᵒᵖ} :
(presheafToType X T).obj U = (U.unop → T) :=
rfl
@[simp]
theorem presheafToType_map {T : Type v} {U V : (Opens X)ᵒᵖ} {i : U ⟶ V} {f} :
(presheafToType X T).map i f = f ∘ i.unop :=
rfl
/-- The presheaf of continuous functions on `X` with values in fixed target topological space
`T`. -/
def presheafToTop (T : TopCat.{v}) : X.Presheaf (Type v) :=
(Opens.toTopCat X).op ⋙ yoneda.obj T
@[simp]
theorem presheafToTop_obj (T : TopCat.{v}) (U : (Opens X)ᵒᵖ) :
(presheafToTop X T).obj U = ((Opens.toTopCat X).obj (unop U) ⟶ T) :=
rfl
-- TODO upgrade the result to TopCommRing?
/-- The (bundled) commutative ring of continuous functions from a topological space
to a topological commutative ring, with pointwise multiplication. -/
def continuousFunctions (X : TopCat.{v}ᵒᵖ) (R : TopCommRingCat.{v}) : CommRingCat.{v} :=
-- Porting note: Lean did not see through that `X.unop ⟶ R` is just continuous functions
-- hence forms a ring
@CommRingCat.of (X.unop ⟶ (forget₂ TopCommRingCat TopCat).obj R) <|
show CommRing (ContinuousMap _ _) by infer_instance
namespace continuousFunctions
/-- Pulling back functions into a topological ring along a continuous map is a ring homomorphism. -/
def pullback {X Y : TopCatᵒᵖ} (f : X ⟶ Y) (R : TopCommRingCat) :
continuousFunctions X R ⟶ continuousFunctions Y R where
toFun g := f.unop ≫ g
map_one' := rfl
map_zero' := rfl
map_add' := by aesop_cat
map_mul' := by aesop_cat
/-- A homomorphism of topological rings can be postcomposed with functions from a source space `X`;
this is a ring homomorphism (with respect to the pointwise ring operations on functions). -/
def map (X : TopCat.{u}ᵒᵖ) {R S : TopCommRingCat.{u}} (φ : R ⟶ S) :
continuousFunctions X R ⟶ continuousFunctions X S where
toFun g := g ≫ (forget₂ TopCommRingCat TopCat).map φ
-- Porting note: `ext` tactic does not work, since Lean can't see through `R ⟶ S` is just
-- continuous ring homomorphism
map_one' := ContinuousMap.ext fun _ => φ.1.map_one
map_zero' := ContinuousMap.ext fun _ => φ.1.map_zero
map_add' := fun _ _ => ContinuousMap.ext fun _ => φ.1.map_add _ _
map_mul' := fun _ _ => ContinuousMap.ext fun _ => φ.1.map_mul _ _
end continuousFunctions
/-- An upgraded version of the Yoneda embedding, observing that the continuous maps
from `X : TopCat` to `R : TopCommRingCat` form a commutative ring, functorial in both `X` and
`R`. -/
def commRingYoneda : TopCommRingCat.{u} ⥤ TopCat.{u}ᵒᵖ ⥤ CommRingCat.{u} where
obj R :=
{ obj := fun X => continuousFunctions X R
map := fun {X Y} f => continuousFunctions.pullback f R
map_id := fun X => by
ext
rfl
map_comp := fun {X Y Z} f g => rfl }
map {R S} φ :=
{ app := fun X => continuousFunctions.map X φ
naturality := fun X Y f => rfl }
map_id X := by
ext
rfl
map_comp {X Y Z} f g := rfl
/-- The presheaf (of commutative rings), consisting of functions on an open set `U ⊆ X` with
values in some topological commutative ring `T`.
For example, we could construct the presheaf of continuous complex valued functions of `X` as
```
presheafToTopCommRing X (TopCommRingCat.of ℂ)
```
(this requires `import Topology.Instances.Complex`).
-/
def presheafToTopCommRing (T : TopCommRingCat.{v}) : X.Presheaf CommRingCat.{v} :=
(Opens.toTopCat X).op ⋙ commRingYoneda.obj T
end TopCat
|
Topology\Sheaves\PUnit.lean | /-
Copyright (c) 2022 Jujian Zhang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jujian Zhang
-/
import Mathlib.Topology.Sheaves.SheafCondition.Sites
/-!
# Presheaves on `PUnit`
Presheaves on `PUnit` satisfy sheaf condition iff its value at empty set is a terminal object.
-/
namespace TopCat.Presheaf
universe u v w
open CategoryTheory CategoryTheory.Limits TopCat Opposite
variable {C : Type u} [Category.{v} C]
theorem isSheaf_of_isTerminal_of_indiscrete {X : TopCat.{w}} (hind : X.str = ⊤) (F : Presheaf C X)
(it : IsTerminal <| F.obj <| op ⊥) : F.IsSheaf := fun c U s hs => by
obtain rfl | hne := eq_or_ne U ⊥
· intro _ _
rw [@exists_unique_iff_exists _ ⟨fun _ _ => _⟩]
· refine ⟨it.from _, fun U hU hs => IsTerminal.hom_ext ?_ _ _⟩
rwa [le_bot_iff.1 hU.le]
· apply it.hom_ext
· convert Presieve.isSheafFor_top_sieve (F ⋙ coyoneda.obj (@op C c))
rw [← Sieve.id_mem_iff_eq_top]
have := (U.eq_bot_or_top hind).resolve_left hne
subst this
obtain he | ⟨⟨x⟩⟩ := isEmpty_or_nonempty X
· exact (hne <| SetLike.ext'_iff.2 <| Set.univ_eq_empty_iff.2 he).elim
obtain ⟨U, f, hf, hm⟩ := hs x _root_.trivial
obtain rfl | rfl := U.eq_bot_or_top hind
· cases hm
· convert hf
theorem isSheaf_iff_isTerminal_of_indiscrete {X : TopCat.{w}} (hind : X.str = ⊤)
(F : Presheaf C X) : F.IsSheaf ↔ Nonempty (IsTerminal <| F.obj <| op ⊥) :=
⟨fun h => ⟨Sheaf.isTerminalOfEmpty ⟨F, h⟩⟩, fun ⟨it⟩ =>
isSheaf_of_isTerminal_of_indiscrete hind F it⟩
theorem isSheaf_on_punit_of_isTerminal (F : Presheaf C (TopCat.of PUnit))
(it : IsTerminal <| F.obj <| op ⊥) : F.IsSheaf :=
isSheaf_of_isTerminal_of_indiscrete (@Subsingleton.elim (TopologicalSpace PUnit) _ _ _) F it
theorem isSheaf_on_punit_iff_isTerminal (F : Presheaf C (TopCat.of PUnit)) :
F.IsSheaf ↔ Nonempty (IsTerminal <| F.obj <| op ⊥) :=
⟨fun h => ⟨Sheaf.isTerminalOfEmpty ⟨F, h⟩⟩, fun ⟨it⟩ => isSheaf_on_punit_of_isTerminal F it⟩
end TopCat.Presheaf
|
Topology\Sheaves\Sheaf.lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Topology.Sheaves.Presheaf
import Mathlib.CategoryTheory.Sites.Sheaf
import Mathlib.CategoryTheory.Sites.Spaces
/-!
# Sheaves
We define sheaves on a topological space, with values in an arbitrary category.
A presheaf on a topological space `X` is a sheaf precisely when it is a sheaf under the
grothendieck topology on `opens X`, which expands out to say: For each open cover `{ Uᵢ }` of
`U`, and a family of compatible functions `A ⟶ F(Uᵢ)` for an `A : X`, there exists a unique
gluing `A ⟶ F(U)` compatible with the restriction.
See the docstring of `TopCat.Presheaf.IsSheaf` for an explanation on the design decisions and a list
of equivalent conditions.
We provide the instance `CategoryTheory.Category (TopCat.Sheaf C X)` as the full subcategory of
presheaves, and the fully faithful functor `Sheaf.forget : TopCat.Sheaf C X ⥤ TopCat.Presheaf C X`.
-/
universe w v u
noncomputable section
open CategoryTheory CategoryTheory.Limits TopologicalSpace Opposite TopologicalSpace.Opens
namespace TopCat
variable {C : Type u} [Category.{v} C]
variable {X : TopCat.{w}} (F : Presheaf C X) {ι : Type v} (U : ι → Opens X)
namespace Presheaf
/-- The sheaf condition has several different equivalent formulations.
The official definition chosen here is in terms of grothendieck topologies so that the results on
sites could be applied here easily, and this condition does not require additional constraints on
the value category.
The equivalent formulations of the sheaf condition on `presheaf C X` are as follows :
1. `TopCat.Presheaf.IsSheaf`: (the official definition)
It is a sheaf with respect to the grothendieck topology on `opens X`, which is to say:
For each open cover `{ Uᵢ }` of `U`, and a family of compatible functions `A ⟶ F(Uᵢ)` for an
`A : X`, there exists a unique gluing `A ⟶ F(U)` compatible with the restriction.
2. `TopCat.Presheaf.IsSheafEqualizerProducts`: (requires `C` to have all products)
For each open cover `{ Uᵢ }` of `U`, `F(U) ⟶ ∏ᶜ F(Uᵢ)` is the equalizer of the two morphisms
`∏ᶜ F(Uᵢ) ⟶ ∏ᶜ F(Uᵢ ∩ Uⱼ)`.
See `TopCat.Presheaf.isSheaf_iff_isSheafEqualizerProducts`.
3. `TopCat.Presheaf.IsSheafOpensLeCover`:
For each open cover `{ Uᵢ }` of `U`, `F(U)` is the limit of the diagram consisting of arrows
`F(V₁) ⟶ F(V₂)` for every pair of open sets `V₁ ⊇ V₂` that are contained in some `Uᵢ`.
See `TopCat.Presheaf.isSheaf_iff_isSheafOpensLeCover`.
4. `TopCat.Presheaf.IsSheafPairwiseIntersections`:
For each open cover `{ Uᵢ }` of `U`, `F(U)` is the limit of the diagram consisting of arrows
from `F(Uᵢ)` and `F(Uⱼ)` to `F(Uᵢ ∩ Uⱼ)` for each pair `(i, j)`.
See `TopCat.Presheaf.isSheaf_iff_isSheafPairwiseIntersections`.
The following requires `C` to be concrete and complete, and `forget C` to reflect isomorphisms and
preserve limits. This applies to most "algebraic" categories, e.g. groups, abelian groups and rings.
5. `TopCat.Presheaf.IsSheafUniqueGluing`:
(requires `C` to be concrete and complete; `forget C` to reflect isomorphisms and preserve limits)
For each open cover `{ Uᵢ }` of `U`, and a compatible family of elements `x : F(Uᵢ)`, there exists
a unique gluing `x : F(U)` that restricts to the given elements.
See `TopCat.Presheaf.isSheaf_iff_isSheafUniqueGluing`.
6. The underlying sheaf of types is a sheaf.
See `TopCat.Presheaf.isSheaf_iff_isSheaf_comp` and
`CategoryTheory.Presheaf.isSheaf_iff_isSheaf_forget`.
-/
nonrec def IsSheaf (F : Presheaf.{w, v, u} C X) : Prop :=
Presheaf.IsSheaf (Opens.grothendieckTopology X) F
/-- The presheaf valued in `Unit` over any topological space is a sheaf.
-/
theorem isSheaf_unit (F : Presheaf (CategoryTheory.Discrete Unit) X) : F.IsSheaf :=
fun x U S _ x _ => ⟨eqToHom (Subsingleton.elim _ _), by aesop_cat, fun _ => by aesop_cat⟩
theorem isSheaf_iso_iff {F G : Presheaf C X} (α : F ≅ G) : F.IsSheaf ↔ G.IsSheaf :=
Presheaf.isSheaf_of_iso_iff α
/-- Transfer the sheaf condition across an isomorphism of presheaves.
-/
theorem isSheaf_of_iso {F G : Presheaf C X} (α : F ≅ G) (h : F.IsSheaf) : G.IsSheaf :=
(isSheaf_iso_iff α).1 h
end Presheaf
variable (C X)
/-- A `TopCat.Sheaf C X` is a presheaf of objects from `C` over a (bundled) topological space `X`,
satisfying the sheaf condition.
-/
nonrec def Sheaf : Type max u v w :=
Sheaf (Opens.grothendieckTopology X) C
-- Porting note: `deriving Cat` failed
instance SheafCat : Category (Sheaf C X) :=
show Category (CategoryTheory.Sheaf (Opens.grothendieckTopology X) C) from inferInstance
variable {C X}
/-- The underlying presheaf of a sheaf -/
abbrev Sheaf.presheaf (F : X.Sheaf C) : TopCat.Presheaf C X :=
F.1
variable (C X)
-- Let's construct a trivial example, to keep the inhabited linter happy.
instance sheafInhabited : Inhabited (Sheaf (CategoryTheory.Discrete PUnit) X) :=
⟨⟨Functor.star _, Presheaf.isSheaf_unit _⟩⟩
namespace Sheaf
/-- The forgetful functor from sheaves to presheaves.
-/
def forget : TopCat.Sheaf C X ⥤ TopCat.Presheaf C X :=
sheafToPresheaf _ _
-- Porting note: `deriving Full` failed
instance forget_full : (forget C X).Full where
map_surjective f := ⟨Sheaf.Hom.mk f, rfl⟩
-- Porting note: `deriving Faithful` failed
instance forgetFaithful : (forget C X).Faithful where
map_injective := Sheaf.Hom.ext
-- Note: These can be proved by simp.
theorem id_app (F : Sheaf C X) (t) : (𝟙 F : F ⟶ F).1.app t = 𝟙 _ :=
rfl
theorem comp_app {F G H : Sheaf C X} (f : F ⟶ G) (g : G ⟶ H) (t) :
(f ≫ g).1.app t = f.1.app t ≫ g.1.app t :=
rfl
end Sheaf
end TopCat
|
Topology\Sheaves\Sheafify.lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Topology.Sheaves.LocalPredicate
import Mathlib.Topology.Sheaves.Stalks
/-!
# Sheafification of `Type` valued presheaves
We construct the sheafification of a `Type` valued presheaf,
as the subsheaf of dependent functions into the stalks
consisting of functions which are locally germs.
We show that the stalks of the sheafification are isomorphic to the original stalks,
via `stalkToFiber` which evaluates a germ of a dependent function at a point.
We construct a morphism `toSheafify` from a presheaf to (the underlying presheaf of)
its sheafification, given by sending a section to its collection of germs.
## Future work
Show that the map induced on stalks by `toSheafify` is the inverse of `stalkToFiber`.
Show sheafification is a functor from presheaves to sheaves,
and that it is the left adjoint of the forgetful functor,
following <https://stacks.math.columbia.edu/tag/007X>.
-/
universe v
noncomputable section
open TopCat Opposite TopologicalSpace CategoryTheory
variable {X : TopCat.{v}} (F : Presheaf (Type v) X)
namespace TopCat.Presheaf
namespace Sheafify
/--
The prelocal predicate on functions into the stalks, asserting that the function is equal to a germ.
-/
def isGerm : PrelocalPredicate fun x => F.stalk x where
pred {U} f := ∃ g : F.obj (op U), ∀ x : U, f x = F.germ x g
res := fun i _ ⟨g, p⟩ => ⟨F.map i.op g, fun x => (p (i x)).trans (F.germ_res_apply i x g).symm⟩
/-- The local predicate on functions into the stalks,
asserting that the function is locally equal to a germ.
-/
def isLocallyGerm : LocalPredicate fun x => F.stalk x :=
(isGerm F).sheafify
end Sheafify
/-- The sheafification of a `Type` valued presheaf, defined as the functions into the stalks which
are locally equal to germs.
-/
def sheafify : Sheaf (Type v) X :=
subsheafToTypes (Sheafify.isLocallyGerm F)
/-- The morphism from a presheaf to its sheafification,
sending each section to its germs.
(This forms the unit of the adjunction.)
-/
def toSheafify : F ⟶ F.sheafify.1 where
app U f := ⟨fun x => F.germ x f, PrelocalPredicate.sheafifyOf ⟨f, fun x => rfl⟩⟩
naturality U U' f := by
ext x
apply Subtype.ext -- Porting note: Added `apply`
ext ⟨u, m⟩
exact germ_res_apply F f.unop ⟨u, m⟩ x
/-- The natural morphism from the stalk of the sheafification to the original stalk.
In `sheafifyStalkIso` we show this is an isomorphism.
-/
def stalkToFiber (x : X) : F.sheafify.presheaf.stalk x ⟶ F.stalk x :=
TopCat.stalkToFiber (Sheafify.isLocallyGerm F) x
theorem stalkToFiber_surjective (x : X) : Function.Surjective (F.stalkToFiber x) := by
apply TopCat.stalkToFiber_surjective
intro t
obtain ⟨U, m, s, rfl⟩ := F.germ_exist _ t
use ⟨U, m⟩
fconstructor
· exact fun y => F.germ y s
· exact ⟨PrelocalPredicate.sheafifyOf ⟨s, fun _ => rfl⟩, rfl⟩
theorem stalkToFiber_injective (x : X) : Function.Injective (F.stalkToFiber x) := by
apply TopCat.stalkToFiber_injective
intro U V fU hU fV hV e
rcases hU ⟨x, U.2⟩ with ⟨U', mU, iU, gU, wU⟩
rcases hV ⟨x, V.2⟩ with ⟨V', mV, iV, gV, wV⟩
have wUx := wU ⟨x, mU⟩
dsimp at wUx; erw [wUx] at e; clear wUx
have wVx := wV ⟨x, mV⟩
dsimp at wVx; erw [wVx] at e; clear wVx
rcases F.germ_eq x mU mV gU gV e with ⟨W, mW, iU', iV', (e' : F.map iU'.op gU = F.map iV'.op gV)⟩
use ⟨W ⊓ (U' ⊓ V'), ⟨mW, mU, mV⟩⟩
refine ⟨?_, ?_, ?_⟩
· change W ⊓ (U' ⊓ V') ⟶ U.obj
exact Opens.infLERight _ _ ≫ Opens.infLELeft _ _ ≫ iU
· change W ⊓ (U' ⊓ V') ⟶ V.obj
exact Opens.infLERight _ _ ≫ Opens.infLERight _ _ ≫ iV
· intro w
specialize wU ⟨w.1, w.2.2.1⟩
specialize wV ⟨w.1, w.2.2.2⟩
dsimp at wU wV ⊢
erw [wU, ← F.germ_res iU' ⟨w, w.2.1⟩, wV, ← F.germ_res iV' ⟨w, w.2.1⟩,
CategoryTheory.types_comp_apply, CategoryTheory.types_comp_apply, e']
/-- The isomorphism between a stalk of the sheafification and the original stalk.
-/
def sheafifyStalkIso (x : X) : F.sheafify.presheaf.stalk x ≅ F.stalk x :=
(Equiv.ofBijective _ ⟨stalkToFiber_injective _ _, stalkToFiber_surjective _ _⟩).toIso
-- PROJECT functoriality, and that sheafification is the left adjoint of the forgetful functor.
end TopCat.Presheaf
|
Topology\Sheaves\SheafOfFunctions.lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Topology.Sheaves.PresheafOfFunctions
import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing
/-!
# Sheaf conditions for presheaves of (continuous) functions.
We show that
* `Top.Presheaf.toType_isSheaf`: not-necessarily-continuous functions into a type form a sheaf
* `Top.Presheaf.toTypes_isSheaf`: in fact, these may be dependent functions into a type family
For
* `Top.sheafToTop`: continuous functions into a topological space form a sheaf
please see `Topology/Sheaves/LocalPredicate.lean`, where we set up a general framework
for constructing sub(pre)sheaves of the sheaf of dependent functions.
## Future work
Obviously there's more to do:
* sections of a fiber bundle
* various classes of smooth and structure preserving functions
* functions into spaces with algebraic structure, which the sections inherit
-/
open CategoryTheory Limits TopologicalSpace Opens
universe u
noncomputable section
variable (X : TopCat.{u})
open TopCat
namespace TopCat.Presheaf
/-- We show that the presheaf of functions to a type `T`
(no continuity assumptions, just plain functions)
form a sheaf.
In fact, the proof is identical when we do this for dependent functions to a type family `T`,
so we do the more general case.
-/
theorem toTypes_isSheaf (T : X → Type u) : (presheafToTypes X T).IsSheaf :=
isSheaf_of_isSheafUniqueGluing_types.{u} _ fun ι U sf hsf => by
-- We use the sheaf condition in terms of unique gluing
-- U is a family of open sets, indexed by `ι` and `sf` is a compatible family of sections.
-- In the informal comments below, I'll just write `U` to represent the union.
-- Our first goal is to define a function "lifted" to all of `U`.
-- We do this one point at a time. Using the axiom of choice, we can pick for each
-- `x : ↑(iSup U)` an index `i : ι` such that `x` lies in `U i`
choose index index_spec using fun x : ↑(iSup U) => Opens.mem_iSup.mp x.2
-- Using this data, we can glue our functions together to a single section
let s : ∀ x : ↑(iSup U), T x := fun x => sf (index x) ⟨x.1, index_spec x⟩
refine ⟨s, ?_, ?_⟩
· intro i
funext x
-- Now we need to verify that this lifted function restricts correctly to each set `U i`.
-- Of course, the difficulty is that at any given point `x ∈ U i`,
-- we may have used the axiom of choice to pick a different `j` with `x ∈ U j`
-- when defining the function.
-- Thus we'll need to use the fact that the restrictions are compatible.
exact congr_fun (hsf (index ⟨x, _⟩) i) ⟨x, ⟨index_spec ⟨x.1, _⟩, x.2⟩⟩
· -- Now we just need to check that the lift we picked was the only possible one.
-- So we suppose we had some other gluing `t` of our sections
intro t ht
-- and observe that we need to check that it agrees with our choice
-- for each `x ∈ ↑(iSup U)`.
funext x
exact congr_fun (ht (index x)) ⟨x.1, index_spec x⟩
-- We verify that the non-dependent version is an immediate consequence:
/-- The presheaf of not-necessarily-continuous functions to
a target type `T` satsifies the sheaf condition.
-/
theorem toType_isSheaf (T : Type u) : (presheafToType X T).IsSheaf :=
toTypes_isSheaf X fun _ => T
end TopCat.Presheaf
namespace TopCat
/-- The sheaf of not-necessarily-continuous functions on `X` with values in type family
`T : X → Type u`.
-/
def sheafToTypes (T : X → Type u) : Sheaf (Type u) X :=
⟨presheafToTypes X T, Presheaf.toTypes_isSheaf _ _⟩
/-- The sheaf of not-necessarily-continuous functions on `X` with values in a type `T`.
-/
def sheafToType (T : Type u) : Sheaf (Type u) X :=
⟨presheafToType X T, Presheaf.toType_isSheaf _ _⟩
end TopCat
|
Topology\Sheaves\Skyscraper.lean | /-
Copyright (c) 2022 Jujian Zhang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jujian Zhang, Junyan Xu
-/
import Mathlib.Topology.Sheaves.PUnit
import Mathlib.Topology.Sheaves.Stalks
import Mathlib.Topology.Sheaves.Functors
/-!
# Skyscraper (pre)sheaves
A skyscraper (pre)sheaf `𝓕 : (Pre)Sheaf C X` is the (pre)sheaf with value `A` at point `p₀` that is
supported only at open sets contain `p₀`, i.e. `𝓕(U) = A` if `p₀ ∈ U` and `𝓕(U) = *` if `p₀ ∉ U`
where `*` is a terminal object of `C`. In terms of stalks, `𝓕` is supported at all specializations
of `p₀`, i.e. if `p₀ ⤳ x` then `𝓕ₓ ≅ A` and if `¬ p₀ ⤳ x` then `𝓕ₓ ≅ *`.
## Main definitions
* `skyscraperPresheaf`: `skyscraperPresheaf p₀ A` is the skyscraper presheaf at point `p₀` with
value `A`.
* `skyscraperSheaf`: the skyscraper presheaf satisfies the sheaf condition.
## Main statements
* `skyscraperPresheafStalkOfSpecializes`: if `y ∈ closure {p₀}` then the stalk of
`skyscraperPresheaf p₀ A` at `y` is `A`.
* `skyscraperPresheafStalkOfNotSpecializes`: if `y ∉ closure {p₀}` then the stalk of
`skyscraperPresheaf p₀ A` at `y` is `*` the terminal object.
TODO: generalize universe level when calculating stalks, after generalizing universe level of stalk.
-/
noncomputable section
open TopologicalSpace TopCat CategoryTheory CategoryTheory.Limits Opposite
universe u v w
variable {X : TopCat.{u}} (p₀ : X) [∀ U : Opens X, Decidable (p₀ ∈ U)]
section
variable {C : Type v} [Category.{w} C] [HasTerminal C] (A : C)
/-- A skyscraper presheaf is a presheaf supported at a single point: if `p₀ ∈ X` is a specified
point, then the skyscraper presheaf `𝓕` with value `A` is defined by `U ↦ A` if `p₀ ∈ U` and
`U ↦ *` if `p₀ ∉ A` where `*` is some terminal object.
-/
@[simps]
def skyscraperPresheaf : Presheaf C X where
obj U := if p₀ ∈ unop U then A else terminal C
map {U V} i :=
if h : p₀ ∈ unop V then eqToHom <| by dsimp; erw [if_pos h, if_pos (leOfHom i.unop h)]
else ((if_neg h).symm.ndrec terminalIsTerminal).from _
map_id U :=
(em (p₀ ∈ U.unop)).elim (fun h => dif_pos h) fun h =>
((if_neg h).symm.ndrec terminalIsTerminal).hom_ext _ _
map_comp {U V W} iVU iWV := by
by_cases hW : p₀ ∈ unop W
· have hV : p₀ ∈ unop V := leOfHom iWV.unop hW
simp only [dif_pos hW, dif_pos hV, eqToHom_trans]
· dsimp; rw [dif_neg hW]; apply ((if_neg hW).symm.ndrec terminalIsTerminal).hom_ext
theorem skyscraperPresheaf_eq_pushforward
[hd : ∀ U : Opens (TopCat.of PUnit.{u + 1}), Decidable (PUnit.unit ∈ U)] :
skyscraperPresheaf p₀ A =
ContinuousMap.const (TopCat.of PUnit) p₀ _*
skyscraperPresheaf (X := TopCat.of PUnit) PUnit.unit A := by
convert_to @skyscraperPresheaf X p₀ (fun U => hd <| (Opens.map <| ContinuousMap.const _ p₀).obj U)
C _ _ A = _ <;> congr
/-- Taking skyscraper presheaf at a point is functorial: `c ↦ skyscraper p₀ c` defines a functor by
sending every `f : a ⟶ b` to the natural transformation `α` defined as: `α(U) = f : a ⟶ b` if
`p₀ ∈ U` and the unique morphism to a terminal object in `C` if `p₀ ∉ U`.
-/
@[simps]
def SkyscraperPresheafFunctor.map' {a b : C} (f : a ⟶ b) :
skyscraperPresheaf p₀ a ⟶ skyscraperPresheaf p₀ b where
app U :=
if h : p₀ ∈ U.unop then eqToHom (if_pos h) ≫ f ≫ eqToHom (if_pos h).symm
else ((if_neg h).symm.ndrec terminalIsTerminal).from _
naturality U V i := by
simp only [skyscraperPresheaf_map]
by_cases hV : p₀ ∈ V.unop
· have hU : p₀ ∈ U.unop := leOfHom i.unop hV
simp only [skyscraperPresheaf_obj, hU, hV, ↓reduceDIte, eqToHom_trans_assoc, Category.assoc,
eqToHom_trans]
· apply ((if_neg hV).symm.ndrec terminalIsTerminal).hom_ext
theorem SkyscraperPresheafFunctor.map'_id {a : C} :
SkyscraperPresheafFunctor.map' p₀ (𝟙 a) = 𝟙 _ := by
ext U
simp only [SkyscraperPresheafFunctor.map'_app, NatTrans.id_app]; split_ifs <;> aesop_cat
theorem SkyscraperPresheafFunctor.map'_comp {a b c : C} (f : a ⟶ b) (g : b ⟶ c) :
SkyscraperPresheafFunctor.map' p₀ (f ≫ g) =
SkyscraperPresheafFunctor.map' p₀ f ≫ SkyscraperPresheafFunctor.map' p₀ g := by
ext U
simp only [SkyscraperPresheafFunctor.map'_app, NatTrans.comp_app]
split_ifs with h <;> aesop_cat
/-- Taking skyscraper presheaf at a point is functorial: `c ↦ skyscraper p₀ c` defines a functor by
sending every `f : a ⟶ b` to the natural transformation `α` defined as: `α(U) = f : a ⟶ b` if
`p₀ ∈ U` and the unique morphism to a terminal object in `C` if `p₀ ∉ U`.
-/
@[simps]
def skyscraperPresheafFunctor : C ⥤ Presheaf C X where
obj := skyscraperPresheaf p₀
map := SkyscraperPresheafFunctor.map' p₀
map_id _ := SkyscraperPresheafFunctor.map'_id p₀
map_comp := SkyscraperPresheafFunctor.map'_comp p₀
end
section
-- In this section, we calculate the stalks for skyscraper presheaves.
-- We need to restrict universe level.
variable {C : Type v} [Category.{u} C] (A : C) [HasTerminal C]
/-- The cocone at `A` for the stalk functor of `skyscraperPresheaf p₀ A` when `y ∈ closure {p₀}`
-/
@[simps]
def skyscraperPresheafCoconeOfSpecializes {y : X} (h : p₀ ⤳ y) :
Cocone ((OpenNhds.inclusion y).op ⋙ skyscraperPresheaf p₀ A) where
pt := A
ι :=
{ app := fun U => eqToHom <| if_pos <| h.mem_open U.unop.1.2 U.unop.2
naturality := fun U V inc => by
change dite _ _ _ ≫ _ = _; rw [dif_pos]
swap -- Porting note: swap goal to prevent proving same thing twice
· exact h.mem_open V.unop.1.2 V.unop.2
· simp only [Functor.comp_obj, Functor.op_obj, skyscraperPresheaf_obj, unop_op,
Functor.const_obj_obj, eqToHom_trans, Functor.const_obj_map, Category.comp_id] }
/--
The cocone at `A` for the stalk functor of `skyscraperPresheaf p₀ A` when `y ∈ closure {p₀}` is a
colimit
-/
noncomputable def skyscraperPresheafCoconeIsColimitOfSpecializes {y : X} (h : p₀ ⤳ y) :
IsColimit (skyscraperPresheafCoconeOfSpecializes p₀ A h) where
desc c := eqToHom (if_pos trivial).symm ≫ c.ι.app (op ⊤)
fac c U := by
dsimp -- Porting note (#11227):added a `dsimp`
rw [← c.w (homOfLE <| (le_top : unop U ≤ _)).op]
change _ ≫ _ ≫ dite _ _ _ ≫ _ = _
rw [dif_pos]
· simp only [skyscraperPresheafCoconeOfSpecializes_ι_app, eqToHom_trans_assoc,
eqToHom_refl, Category.id_comp, unop_op, op_unop]
· exact h.mem_open U.unop.1.2 U.unop.2
uniq c f h := by
dsimp -- Porting note (#11227):added a `dsimp`
rw [← h, skyscraperPresheafCoconeOfSpecializes_ι_app, eqToHom_trans_assoc, eqToHom_refl,
Category.id_comp]
/-- If `y ∈ closure {p₀}`, then the stalk of `skyscraperPresheaf p₀ A` at `y` is `A`.
-/
noncomputable def skyscraperPresheafStalkOfSpecializes [HasColimits C] {y : X} (h : p₀ ⤳ y) :
(skyscraperPresheaf p₀ A).stalk y ≅ A :=
colimit.isoColimitCocone ⟨_, skyscraperPresheafCoconeIsColimitOfSpecializes p₀ A h⟩
/-- The cocone at `*` for the stalk functor of `skyscraperPresheaf p₀ A` when `y ∉ closure {p₀}`
-/
@[simps]
def skyscraperPresheafCocone (y : X) :
Cocone ((OpenNhds.inclusion y).op ⋙ skyscraperPresheaf p₀ A) where
pt := terminal C
ι :=
{ app := fun _ => terminal.from _
naturality := fun _ _ _ => terminalIsTerminal.hom_ext _ _ }
/--
The cocone at `*` for the stalk functor of `skyscraperPresheaf p₀ A` when `y ∉ closure {p₀}` is a
colimit
-/
noncomputable def skyscraperPresheafCoconeIsColimitOfNotSpecializes {y : X} (h : ¬p₀ ⤳ y) :
IsColimit (skyscraperPresheafCocone p₀ A y) :=
let h1 : ∃ U : OpenNhds y, p₀ ∉ U.1 :=
let ⟨U, ho, h₀, hy⟩ := not_specializes_iff_exists_open.mp h
⟨⟨⟨U, ho⟩, h₀⟩, hy⟩
{ desc := fun c => eqToHom (if_neg h1.choose_spec).symm ≫ c.ι.app (op h1.choose)
fac := fun c U => by
change _ = c.ι.app (op U.unop)
simp only [← c.w (homOfLE <| @inf_le_left _ _ h1.choose U.unop).op, ←
c.w (homOfLE <| @inf_le_right _ _ h1.choose U.unop).op, ← Category.assoc]
congr 1
refine ((if_neg ?_).symm.ndrec terminalIsTerminal).hom_ext _ _
exact fun h => h1.choose_spec h.1
uniq := fun c f H => by
dsimp -- Porting note (#11227):added a `dsimp`
rw [← Category.id_comp f, ← H, ← Category.assoc]
congr 1; apply terminalIsTerminal.hom_ext }
/-- If `y ∉ closure {p₀}`, then the stalk of `skyscraperPresheaf p₀ A` at `y` is isomorphic to a
terminal object.
-/
noncomputable def skyscraperPresheafStalkOfNotSpecializes [HasColimits C] {y : X} (h : ¬p₀ ⤳ y) :
(skyscraperPresheaf p₀ A).stalk y ≅ terminal C :=
colimit.isoColimitCocone ⟨_, skyscraperPresheafCoconeIsColimitOfNotSpecializes _ A h⟩
/-- If `y ∉ closure {p₀}`, then the stalk of `skyscraperPresheaf p₀ A` at `y` is a terminal object
-/
def skyscraperPresheafStalkOfNotSpecializesIsTerminal [HasColimits C] {y : X} (h : ¬p₀ ⤳ y) :
IsTerminal ((skyscraperPresheaf p₀ A).stalk y) :=
IsTerminal.ofIso terminalIsTerminal <| (skyscraperPresheafStalkOfNotSpecializes _ _ h).symm
theorem skyscraperPresheaf_isSheaf : (skyscraperPresheaf p₀ A).IsSheaf := by
classical exact
(Presheaf.isSheaf_iso_iff (eqToIso <| skyscraperPresheaf_eq_pushforward p₀ A)).mpr <|
(Sheaf.pushforward_sheaf_of_sheaf _
(Presheaf.isSheaf_on_punit_of_isTerminal _ (by
dsimp [skyscraperPresheaf]
rw [if_neg]
· exact terminalIsTerminal
· #adaptation_note /-- 2024-03-24
Previously the universe annotation was not needed here. -/
exact Set.not_mem_empty PUnit.unit.{u+1})))
/--
The skyscraper presheaf supported at `p₀` with value `A` is the sheaf that assigns `A` to all opens
`U` that contain `p₀` and assigns `*` otherwise.
-/
def skyscraperSheaf : Sheaf C X :=
⟨skyscraperPresheaf p₀ A, skyscraperPresheaf_isSheaf _ _⟩
/-- Taking skyscraper sheaf at a point is functorial: `c ↦ skyscraper p₀ c` defines a functor by
sending every `f : a ⟶ b` to the natural transformation `α` defined as: `α(U) = f : a ⟶ b` if
`p₀ ∈ U` and the unique morphism to a terminal object in `C` if `p₀ ∉ U`.
-/
def skyscraperSheafFunctor : C ⥤ Sheaf C X where
obj c := skyscraperSheaf p₀ c
map f := Sheaf.Hom.mk <| (skyscraperPresheafFunctor p₀).map f
map_id _ := Sheaf.Hom.ext <| (skyscraperPresheafFunctor p₀).map_id _
map_comp _ _ := Sheaf.Hom.ext <| (skyscraperPresheafFunctor p₀).map_comp _ _
namespace StalkSkyscraperPresheafAdjunctionAuxs
variable [HasColimits C]
/-- If `f : 𝓕.stalk p₀ ⟶ c`, then a natural transformation `𝓕 ⟶ skyscraperPresheaf p₀ c` can be
defined by: `𝓕.germ p₀ ≫ f : 𝓕(U) ⟶ c` if `p₀ ∈ U` and the unique morphism to a terminal object
if `p₀ ∉ U`.
-/
@[simps]
def toSkyscraperPresheaf {𝓕 : Presheaf C X} {c : C} (f : 𝓕.stalk p₀ ⟶ c) :
𝓕 ⟶ skyscraperPresheaf p₀ c where
app U :=
if h : p₀ ∈ U.unop then 𝓕.germ ⟨p₀, h⟩ ≫ f ≫ eqToHom (if_pos h).symm
else ((if_neg h).symm.ndrec terminalIsTerminal).from _
naturality U V inc := by
-- Porting note: don't know why original proof fell short of working, add `aesop_cat` finished
-- the proofs anyway
dsimp
by_cases hV : p₀ ∈ V.unop
· have hU : p₀ ∈ U.unop := leOfHom inc.unop hV
split_ifs
erw [← Category.assoc, 𝓕.germ_res inc.unop, Category.assoc, Category.assoc, eqToHom_trans]
· split_ifs
exact ((if_neg hV).symm.ndrec terminalIsTerminal).hom_ext ..
/-- If `f : 𝓕 ⟶ skyscraperPresheaf p₀ c` is a natural transformation, then there is a morphism
`𝓕.stalk p₀ ⟶ c` defined as the morphism from colimit to cocone at `c`.
-/
def fromStalk {𝓕 : Presheaf C X} {c : C} (f : 𝓕 ⟶ skyscraperPresheaf p₀ c) : 𝓕.stalk p₀ ⟶ c :=
let χ : Cocone ((OpenNhds.inclusion p₀).op ⋙ 𝓕) :=
Cocone.mk c <|
{ app := fun U => f.app (op U.unop.1) ≫ eqToHom (if_pos U.unop.2)
naturality := fun U V inc => by
dsimp
erw [Category.comp_id, ← Category.assoc, comp_eqToHom_iff, Category.assoc,
eqToHom_trans, f.naturality, skyscraperPresheaf_map]
-- Porting note: added this `dsimp` and `rfl` in the end
dsimp only [skyscraperPresheaf_obj, unop_op, Eq.ndrec]
have hV : p₀ ∈ (OpenNhds.inclusion p₀).obj V.unop := V.unop.2; split_ifs <;>
simp only [comp_eqToHom_iff, Category.assoc, eqToHom_trans, eqToHom_refl,
Category.comp_id] <;> rfl }
colimit.desc _ χ
theorem to_skyscraper_fromStalk {𝓕 : Presheaf C X} {c : C} (f : 𝓕 ⟶ skyscraperPresheaf p₀ c) :
toSkyscraperPresheaf p₀ (fromStalk _ f) = f := by
apply NatTrans.ext
ext U
dsimp
split_ifs with h
· erw [← Category.assoc, colimit.ι_desc, Category.assoc, eqToHom_trans, eqToHom_refl,
Category.comp_id]
· exact ((if_neg h).symm.ndrec terminalIsTerminal).hom_ext ..
theorem fromStalk_to_skyscraper {𝓕 : Presheaf C X} {c : C} (f : 𝓕.stalk p₀ ⟶ c) :
fromStalk p₀ (toSkyscraperPresheaf _ f) = f :=
colimit.hom_ext fun U => by
erw [colimit.ι_desc]; dsimp; rw [dif_pos U.unop.2]
rw [Category.assoc, Category.assoc, eqToHom_trans, eqToHom_refl, Category.comp_id,
Presheaf.germ]
congr 3
/-- The unit in `Presheaf.stalkFunctor ⊣ skyscraperPresheafFunctor`
-/
@[simps]
protected def unit :
𝟭 (Presheaf C X) ⟶ Presheaf.stalkFunctor C p₀ ⋙ skyscraperPresheafFunctor p₀ where
app 𝓕 := toSkyscraperPresheaf _ <| 𝟙 _
naturality 𝓕 𝓖 f := by
ext U; dsimp
split_ifs with h
· simp only [Category.id_comp, ← Category.assoc]; rw [comp_eqToHom_iff]
simp only [Category.assoc, eqToHom_trans, eqToHom_refl, Category.comp_id]
erw [colimit.ι_map]; rfl
· apply ((if_neg h).symm.ndrec terminalIsTerminal).hom_ext
/-- The counit in `Presheaf.stalkFunctor ⊣ skyscraperPresheafFunctor`
-/
@[simps]
protected def counit :
skyscraperPresheafFunctor p₀ ⋙ (Presheaf.stalkFunctor C p₀ : Presheaf C X ⥤ C) ⟶ 𝟭 C where
app c := (skyscraperPresheafStalkOfSpecializes p₀ c specializes_rfl).hom
naturality x y f := colimit.hom_ext fun U => by
erw [← Category.assoc, colimit.ι_map, colimit.isoColimitCocone_ι_hom_assoc,
skyscraperPresheafCoconeOfSpecializes_ι_app (h := specializes_rfl), Category.assoc,
colimit.ι_desc, whiskeringLeft_obj_map, whiskerLeft_app, SkyscraperPresheafFunctor.map'_app,
dif_pos U.unop.2, skyscraperPresheafCoconeOfSpecializes_ι_app (h := specializes_rfl),
comp_eqToHom_iff, Category.assoc, eqToHom_comp_iff, ← Category.assoc, eqToHom_trans,
eqToHom_refl, Category.id_comp, comp_eqToHom_iff, Category.assoc, eqToHom_trans, eqToHom_refl,
Category.comp_id, CategoryTheory.Functor.id_map]
end StalkSkyscraperPresheafAdjunctionAuxs
section
open StalkSkyscraperPresheafAdjunctionAuxs
/-- `skyscraperPresheafFunctor` is the right adjoint of `Presheaf.stalkFunctor`
-/
def skyscraperPresheafStalkAdjunction [HasColimits C] :
(Presheaf.stalkFunctor C p₀ : Presheaf C X ⥤ C) ⊣ skyscraperPresheafFunctor p₀ where
homEquiv c 𝓕 :=
{ toFun := toSkyscraperPresheaf _
invFun := fromStalk _
left_inv := fromStalk_to_skyscraper _
right_inv := to_skyscraper_fromStalk _ }
unit := StalkSkyscraperPresheafAdjunctionAuxs.unit _
counit := StalkSkyscraperPresheafAdjunctionAuxs.counit _
homEquiv_unit {𝓕} c α := by
ext U
-- Porting note: `NatTrans.comp_app` is not picked up by `simp`
rw [NatTrans.comp_app]
simp only [Equiv.coe_fn_mk, toSkyscraperPresheaf_app, SkyscraperPresheafFunctor.map'_app,
skyscraperPresheafFunctor_map, unit_app]
split_ifs with h
· erw [Category.id_comp, ← Category.assoc, comp_eqToHom_iff, Category.assoc, Category.assoc,
Category.assoc, Category.assoc, eqToHom_trans, eqToHom_refl, Category.comp_id, ←
Category.assoc _ _ α, eqToHom_trans, eqToHom_refl, Category.id_comp]
· apply ((if_neg h).symm.ndrec terminalIsTerminal).hom_ext
homEquiv_counit {𝓕} c α := by
-- Porting note: added a `dsimp`
dsimp; ext U; simp only [Equiv.coe_fn_symm_mk, counit_app]
erw [colimit.ι_desc, ← Category.assoc, colimit.ι_map, whiskerLeft_app, Category.assoc,
colimit.ι_desc]
rfl
instance [HasColimits C] : (skyscraperPresheafFunctor p₀ : C ⥤ Presheaf C X).IsRightAdjoint :=
(skyscraperPresheafStalkAdjunction _).isRightAdjoint
instance [HasColimits C] : (Presheaf.stalkFunctor C p₀).IsLeftAdjoint :=
-- Use a classical instance instead of the one from `variable`s
have : ∀ U : Opens X, Decidable (p₀ ∈ U) := fun _ ↦ Classical.dec _
(skyscraperPresheafStalkAdjunction _).isLeftAdjoint
/-- Taking stalks of a sheaf is the left adjoint functor to `skyscraperSheafFunctor`
-/
def stalkSkyscraperSheafAdjunction [HasColimits C] :
Sheaf.forget C X ⋙ Presheaf.stalkFunctor _ p₀ ⊣ skyscraperSheafFunctor p₀ where
-- Porting note (#11041): `ext1` is changed to `Sheaf.Hom.ext`,
homEquiv 𝓕 c :=
⟨fun f => ⟨toSkyscraperPresheaf p₀ f⟩, fun g => fromStalk p₀ g.1, fromStalk_to_skyscraper p₀,
fun g => Sheaf.Hom.ext <| to_skyscraper_fromStalk _ _⟩
unit :=
{ app := fun 𝓕 => ⟨(StalkSkyscraperPresheafAdjunctionAuxs.unit p₀).app 𝓕.1⟩
naturality := fun 𝓐 𝓑 f => Sheaf.Hom.ext <| by
apply (StalkSkyscraperPresheafAdjunctionAuxs.unit p₀).naturality }
counit := StalkSkyscraperPresheafAdjunctionAuxs.counit p₀
homEquiv_unit {𝓐} c f := Sheaf.Hom.ext (skyscraperPresheafStalkAdjunction p₀).homEquiv_unit
homEquiv_counit {𝓐} c f := (skyscraperPresheafStalkAdjunction p₀).homEquiv_counit
instance [HasColimits C] : (skyscraperSheafFunctor p₀ : C ⥤ Sheaf C X).IsRightAdjoint :=
(stalkSkyscraperSheafAdjunction _).isRightAdjoint
end
end
|
Topology\Sheaves\Stalks.lean | /-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Justus Springer
-/
import Mathlib.Topology.Category.TopCat.OpenNhds
import Mathlib.Topology.Sheaves.Presheaf
import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing
import Mathlib.CategoryTheory.Adjunction.Evaluation
import Mathlib.CategoryTheory.Limits.Types
import Mathlib.CategoryTheory.Limits.Preserves.Filtered
import Mathlib.CategoryTheory.Limits.Final
import Mathlib.Tactic.CategoryTheory.Elementwise
import Mathlib.Algebra.Category.Ring.Colimits
import Mathlib.CategoryTheory.Sites.Pullback
/-!
# Stalks
For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F`
at the point `x : X` is defined as the colimit of the composition of the inclusion of categories
`(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`.
For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the
canonical morphism into this colimit.
Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`,
sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between
topological spaces, we define `stalkPushforward` as the induced map on the stalks
`(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`.
Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic
property of forgetful functors of categories of algebraic structures (like `MonCat`,
`CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits,
this ensures that the stalks of presheaves valued in these categories behave exactly as for
`Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every
element of the stalk is the germ of a section.
Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as
is the case for most algebraic structures), we have access to the unique gluing API and can prove
further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such
a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are
isomorphisms.
See also the definition of "algebraic structures" in the stacks project:
https://stacks.math.columbia.edu/tag/007L
-/
noncomputable section
universe v u v' u'
open CategoryTheory
open TopCat
open CategoryTheory.Limits
open TopologicalSpace
open Opposite
variable {C : Type u} [Category.{v} C]
variable [HasColimits.{v} C]
variable {X Y Z : TopCat.{v}}
namespace TopCat.Presheaf
variable (C)
/-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/
def stalkFunctor (x : X) : X.Presheaf C ⥤ C :=
(whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim
variable {C}
/-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor
nbhds x ⥤ opens F.X ⥤ C
-/
def stalk (ℱ : X.Presheaf C) (x : X) : C :=
(stalkFunctor C x).obj ℱ
-- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ)
@[simp]
theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x :=
rfl
/-- The germ of a section of a presheaf over an open at a point of that open.
-/
def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x :=
colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩)
/-- The germ of a global section of a presheaf at a point. -/
def Γgerm (F : X.Presheaf C) (x : X) : F.obj (op ⊤) ⟶ stalk F x :=
F.germ ⟨x, show x ∈ ⊤ by trivial⟩
@[reassoc (attr := simp)]
theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) :
F.map i.op ≫ germ F x = germ F (i x : V) :=
let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i
colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op
@[reassoc]
lemma map_germ_eq_Γgerm (F : X.Presheaf C) {U : Opens X} {i : U ⟶ ⊤} (x : U) :
F.map i.op ≫ germ F x = Γgerm F (i x) :=
germ_res F i x
-- Porting note: `@[elementwise]` did not generate the best lemma when applied to `germ_res`
attribute [local instance] ConcreteCategory.instFunLike in
theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C]
(s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res]
attribute [local instance] ConcreteCategory.instFunLike in
lemma Γgerm_res_apply (F : X.Presheaf C) {U : Opens X} {i : U ⟶ ⊤} (x : U) [ConcreteCategory C]
(s) : germ F x (F.map i.op s) = Γgerm F x.val s := germ_res_apply F i x s
/-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its
composition with the `germ` morphisms.
-/
@[ext]
theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y}
(ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ :=
colimit.hom_ext fun U => by
induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU
@[reassoc (attr := simp), elementwise (attr := simp)]
theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) :
germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x :=
colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩)
variable (C)
/-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the
stalk of `f _ * F` at `f x` and the stalk of `F` at `x`.
-/
def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by
-- This is a hack; Lean doesn't like to elaborate the term written directly.
-- Porting note: The original proof was `trans; swap`, but `trans` does nothing.
refine ?_ ≫ colimit.pre _ (OpenNhds.map f x).op
exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F)
@[reassoc (attr := simp), elementwise (attr := simp)]
theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y)
(x : (Opens.map f).obj U) :
(f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by
simp [germ, stalkPushforward]
-- Here are two other potential solutions, suggested by @fpvandoorn at
-- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240>
-- However, I can't get the subsequent two proofs to work with either one.
-- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) :
-- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x :=
-- colim.map ((Functor.associator _ _ _).inv ≫
-- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫
-- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op
-- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) :
-- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x :=
-- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) :
-- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫
-- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op
namespace stalkPushforward
@[simp]
theorem id (ℱ : X.Presheaf C) (x : X) :
ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by
ext
simp only [stalkPushforward, germ, colim_map, ι_colimMap_assoc, whiskerRight_app]
erw [CategoryTheory.Functor.map_id]
simp [stalkFunctor]
@[simp]
theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) :
ℱ.stalkPushforward C (f ≫ g) x =
(f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by
ext
simp [germ, stalkPushforward]
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C)
(x : X) : IsIso (F.stalkPushforward _ f x) := by
haveI := Functor.initial_of_adjunction (hf.isOpenMap.adjunctionNhds x)
convert
((Functor.Final.colimitIso (hf.isOpenMap.functorNhds x).op
((OpenNhds.inclusion (f x)).op ⋙ f _* F) :
_).symm ≪≫
colim.mapIso _).isIso_hom
swap
· fapply NatIso.ofComponents
· intro U
refine F.mapIso (eqToIso ?_)
dsimp only [Functor.op]
exact congr_arg op (Opens.ext <| Set.preimage_image_eq (unop U).1.1 hf.inj)
· intro U V i; erw [← F.map_comp, ← F.map_comp]; congr 1
· change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _)
ext U
rw [← Iso.comp_inv_eq]
erw [colimit.ι_map_assoc]
rw [colimit.ι_pre, Category.assoc]
erw [colimit.ι_map_assoc, colimit.ι_pre, ← F.map_comp_assoc]
apply colimit.w ((OpenNhds.inclusion (f x)).op ⋙ f _* F) _
dsimp only [Functor.op]
refine ((homOfLE ?_).op : op (unop U) ⟶ _)
exact Set.image_preimage_subset _ _
end stalkPushforward
section stalkPullback
/-- The morphism `ℱ_{f x} ⟶ (f⁻¹ℱ)ₓ` that factors through `(f_*f⁻¹ℱ)_{f x}`. -/
def stalkPullbackHom (f : X ⟶ Y) (F : Y.Presheaf C) (x : X) :
F.stalk (f x) ⟶ ((pullback C f).obj F).stalk x :=
(stalkFunctor _ (f x)).map ((pushforwardPullbackAdjunction C f).unit.app F) ≫
stalkPushforward _ _ _ x
@[reassoc (attr := simp)]
lemma germ_stalkPullbackHom
(f : X ⟶ Y) (F : Y.Presheaf C) (x : X) (U : Opens Y) (hU : f x ∈ U) :
F.germ ⟨f x, hU⟩ ≫ stalkPullbackHom C f F x =
((pushforwardPullbackAdjunction C f).unit.app F).app _ ≫
((pullback C f).obj F).germ ⟨x, show x ∈ (Opens.map f).obj U from hU⟩ := by
simp [stalkPullbackHom, germ, stalkFunctor, stalkPushforward]
/-- The morphism `(f⁻¹ℱ)(U) ⟶ ℱ_{f(x)}` for some `U ∋ x`. -/
def germToPullbackStalk (f : X ⟶ Y) (F : Y.Presheaf C) (U : Opens X) (x : U) :
((pullback C f).obj F).obj (op U) ⟶ F.stalk ((f : X → Y) (x : X)) :=
((Opens.map f).op.isPointwiseLeftKanExtensionLanUnit F (op U)).desc
{ pt := F.stalk ((f : X → Y) (x : X))
ι :=
{ app := fun V => F.germ ⟨((f : X → Y) (x : X)), V.hom.unop.le x.2⟩
naturality := fun _ _ i => by erw [Category.comp_id]; exact F.germ_res i.left.unop _ } }
variable {C} in
@[ext]
lemma pullback_obj_obj_ext {Z : C} {f : X ⟶ Y} {F : Y.Presheaf C} (U : (Opens X)ᵒᵖ)
{φ ψ : ((pullback C f).obj F).obj U ⟶ Z}
(h : ∀ (V : Opens Y) (hV : U.unop ≤ (Opens.map f).obj V),
((pushforwardPullbackAdjunction C f).unit.app F).app (op V) ≫
((pullback C f).obj F).map (homOfLE hV).op ≫ φ =
((pushforwardPullbackAdjunction C f).unit.app F).app (op V) ≫
((pullback C f).obj F).map (homOfLE hV).op ≫ ψ) : φ = ψ := by
obtain ⟨U⟩ := U
apply ((Opens.map f).op.isPointwiseLeftKanExtensionLanUnit F _).hom_ext
rintro ⟨⟨V⟩, ⟨⟩, ⟨b⟩⟩
simpa [pushforwardPullbackAdjunction, Functor.lanAdjunction_unit]
using h V (leOfHom b)
@[reassoc (attr := simp)]
lemma pushforwardPullbackAdjunction_unit_pullback_map_germToPullbackStalk
(f : X ⟶ Y) (F : Y.Presheaf C) (U : Opens X) (x : U) (V : Opens Y)
(hV : U ≤ (Opens.map f).obj V) :
((pushforwardPullbackAdjunction C f).unit.app F).app (op V) ≫
((pullback C f).obj F).map (homOfLE hV).op ≫ germToPullbackStalk C f F U x =
F.germ ⟨f x, hV x.2⟩ := by
simpa [pushforwardPullbackAdjunction] using
((Opens.map f).op.isPointwiseLeftKanExtensionLanUnit F (op U)).fac _
(CostructuredArrow.mk (homOfLE hV).op)
@[reassoc (attr := simp)]
lemma germToPullbackStalk_stalkPullbackHom
(f : X ⟶ Y) (F : Y.Presheaf C) (U : Opens X) (x : U) :
germToPullbackStalk C f F U x ≫ stalkPullbackHom C f F x =
((pullback C f).obj F).germ x := by
ext V hV
dsimp
simp only [pushforwardPullbackAdjunction_unit_pullback_map_germToPullbackStalk_assoc,
germ_stalkPullbackHom, germ_res]
@[reassoc (attr := simp)]
lemma pushforwardPullbackAdjunction_unit_app_app_germToPullbackStalk
(f : X ⟶ Y) (F : Y.Presheaf C) (V : (Opens Y)ᵒᵖ) (x : (Opens.map f).obj V.unop) :
((pushforwardPullbackAdjunction C f).unit.app F).app V ≫ germToPullbackStalk C f F _ x =
F.germ ⟨f x, x.2⟩ := by
simpa using pushforwardPullbackAdjunction_unit_pullback_map_germToPullbackStalk
C f F ((Opens.map f).obj V.unop) x V.unop (by rfl)
/-- The morphism `(f⁻¹ℱ)ₓ ⟶ ℱ_{f(x)}`. -/
def stalkPullbackInv (f : X ⟶ Y) (F : Y.Presheaf C) (x : X) :
((pullback C f).obj F).stalk x ⟶ F.stalk (f x) :=
colimit.desc ((OpenNhds.inclusion x).op ⋙ (Presheaf.pullback C f).obj F)
{ pt := F.stalk (f x)
ι :=
{ app := fun U => F.germToPullbackStalk _ f (unop U).1 ⟨x, (unop U).2⟩
naturality := fun U V i => by
dsimp
ext W hW
dsimp [OpenNhds.inclusion]
rw [Category.comp_id, ← Functor.map_comp_assoc,
pushforwardPullbackAdjunction_unit_pullback_map_germToPullbackStalk]
erw [pushforwardPullbackAdjunction_unit_pullback_map_germToPullbackStalk] } }
@[reassoc (attr := simp)]
lemma germ_stalkPullbackInv (f : X ⟶ Y) (F : Y.Presheaf C) (x : X) (V : Opens X) (hV : x ∈ V) :
((pullback C f).obj F).germ ⟨x, hV⟩ ≫ stalkPullbackInv C f F x =
F.germToPullbackStalk _ f V ⟨x, hV⟩ := by
apply colimit.ι_desc
/-- The isomorphism `ℱ_{f(x)} ≅ (f⁻¹ℱ)ₓ`. -/
def stalkPullbackIso (f : X ⟶ Y) (F : Y.Presheaf C) (x : X) :
F.stalk (f x) ≅ ((pullback C f).obj F).stalk x where
hom := stalkPullbackHom _ _ _ _
inv := stalkPullbackInv _ _ _ _
hom_inv_id := by
ext U hU
dsimp
rw [germ_stalkPullbackHom_assoc, germ_stalkPullbackInv, Category.comp_id,
pushforwardPullbackAdjunction_unit_app_app_germToPullbackStalk]
inv_hom_id := by
ext V hV
dsimp
rw [germ_stalkPullbackInv_assoc, Category.comp_id, germToPullbackStalk_stalkPullbackHom]
end stalkPullback
section stalkSpecializes
variable {C}
/-- If `x` specializes to `y`, then there is a natural map `F.stalk y ⟶ F.stalk x`. -/
noncomputable def stalkSpecializes (F : X.Presheaf C) {x y : X} (h : x ⤳ y) :
F.stalk y ⟶ F.stalk x := by
refine colimit.desc _ ⟨_, fun U => ?_, ?_⟩
· exact
colimit.ι ((OpenNhds.inclusion x).op ⋙ F)
(op ⟨(unop U).1, (specializes_iff_forall_open.mp h _ (unop U).1.2 (unop U).2 : _)⟩)
· intro U V i
dsimp
rw [Category.comp_id]
let U' : OpenNhds x := ⟨_, (specializes_iff_forall_open.mp h _ (unop U).1.2 (unop U).2 : _)⟩
let V' : OpenNhds x := ⟨_, (specializes_iff_forall_open.mp h _ (unop V).1.2 (unop V).2 : _)⟩
exact colimit.w ((OpenNhds.inclusion x).op ⋙ F) (show V' ⟶ U' from i.unop).op
@[reassoc (attr := simp), elementwise nosimp]
theorem germ_stalkSpecializes (F : X.Presheaf C) {U : Opens X} {y : U} {x : X} (h : x ⤳ y) :
F.germ y ≫ F.stalkSpecializes h = F.germ (⟨x, h.mem_open U.isOpen y.prop⟩ : U) :=
colimit.ι_desc _ _
@[reassoc, elementwise nosimp]
theorem germ_stalkSpecializes' (F : X.Presheaf C) {U : Opens X} {x y : X} (h : x ⤳ y)
(hy : y ∈ U) : F.germ ⟨y, hy⟩ ≫ F.stalkSpecializes h = F.germ ⟨x, h.mem_open U.isOpen hy⟩ :=
colimit.ι_desc _ _
@[simp]
theorem stalkSpecializes_refl {C : Type*} [Category C] [Limits.HasColimits C] {X : TopCat}
(F : X.Presheaf C) (x : X) : F.stalkSpecializes (specializes_refl x) = 𝟙 _ := by
ext
simp
@[reassoc (attr := simp), elementwise (attr := simp)]
theorem stalkSpecializes_comp {C : Type*} [Category C] [Limits.HasColimits C] {X : TopCat}
(F : X.Presheaf C) {x y z : X} (h : x ⤳ y) (h' : y ⤳ z) :
F.stalkSpecializes h' ≫ F.stalkSpecializes h = F.stalkSpecializes (h.trans h') := by
ext
simp
@[reassoc (attr := simp), elementwise (attr := simp)]
theorem stalkSpecializes_stalkFunctor_map {F G : X.Presheaf C} (f : F ⟶ G) {x y : X} (h : x ⤳ y) :
F.stalkSpecializes h ≫ (stalkFunctor C x).map f =
(stalkFunctor C y).map f ≫ G.stalkSpecializes h := by
change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _)
ext; delta stalkFunctor; simpa [stalkSpecializes] using by rfl
@[reassoc, elementwise, simp, nolint simpNF] -- see std4#365 for the simpNF issue
theorem stalkSpecializes_stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) {x y : X} (h : x ⤳ y) :
(f _* F).stalkSpecializes (f.map_specializes h) ≫ F.stalkPushforward _ f x =
F.stalkPushforward _ f y ≫ F.stalkSpecializes h := by
change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _)
ext; delta stalkPushforward
simp only [stalkSpecializes, colimit.ι_desc_assoc, colimit.ι_map_assoc, colimit.ι_pre,
Category.assoc, colimit.pre_desc, colimit.ι_desc]
rfl
/-- The stalks are isomorphic on inseparable points -/
@[simps]
def stalkCongr {X : TopCat} {C : Type*} [Category C] [HasColimits C] (F : X.Presheaf C) {x y : X}
(e : Inseparable x y) : F.stalk x ≅ F.stalk y :=
⟨F.stalkSpecializes e.ge, F.stalkSpecializes e.le, by simp, by simp⟩
end stalkSpecializes
section Concrete
variable {C}
variable [ConcreteCategory.{v} C]
attribute [local instance] ConcreteCategory.hasCoeToSort ConcreteCategory.instFunLike
-- Porting note (#11215): TODO: @[ext] attribute only applies to structures or lemmas proving x = y
-- @[ext]
theorem germ_ext (F : X.Presheaf C) {U V : Opens X} {x : X} {hxU : x ∈ U} {hxV : x ∈ V}
(W : Opens X) (hxW : x ∈ W) (iWU : W ⟶ U) (iWV : W ⟶ V) {sU : F.obj (op U)} {sV : F.obj (op V)}
(ih : F.map iWU.op sU = F.map iWV.op sV) :
F.germ ⟨x, hxU⟩ sU = F.germ ⟨x, hxV⟩ sV := by
erw [← F.germ_res iWU ⟨x, hxW⟩, ← F.germ_res iWV ⟨x, hxW⟩, comp_apply, comp_apply, ih]
variable [PreservesFilteredColimits (forget C)]
/--
For presheaves valued in a concrete category whose forgetful functor preserves filtered colimits,
every element of the stalk is the germ of a section.
-/
theorem germ_exist (F : X.Presheaf C) (x : X) (t : (stalk.{v, u} F x : Type v)) :
∃ (U : Opens X) (m : x ∈ U) (s : F.obj (op U)), F.germ ⟨x, m⟩ s = t := by
obtain ⟨U, s, e⟩ :=
Types.jointly_surjective.{v, v} _ (isColimitOfPreserves (forget C) (colimit.isColimit _)) t
revert s e
induction U with | h U => ?_
cases' U with V m
intro s e
exact ⟨V, m, s, e⟩
theorem germ_eq (F : X.Presheaf C) {U V : Opens X} (x : X) (mU : x ∈ U) (mV : x ∈ V)
(s : F.obj (op U)) (t : F.obj (op V)) (h : germ F ⟨x, mU⟩ s = germ F ⟨x, mV⟩ t) :
∃ (W : Opens X) (_m : x ∈ W) (iU : W ⟶ U) (iV : W ⟶ V), F.map iU.op s = F.map iV.op t := by
obtain ⟨W, iU, iV, e⟩ :=
(Types.FilteredColimit.isColimit_eq_iff.{v, v} _
(isColimitOfPreserves _ (colimit.isColimit ((OpenNhds.inclusion x).op ⋙ F)))).mp h
exact ⟨(unop W).1, (unop W).2, iU.unop, iV.unop, e⟩
theorem stalkFunctor_map_injective_of_app_injective {F G : Presheaf C X} (f : F ⟶ G)
(h : ∀ U : Opens X, Function.Injective (f.app (op U))) (x : X) :
Function.Injective ((stalkFunctor C x).map f) := fun s t hst => by
rcases germ_exist F x s with ⟨U₁, hxU₁, s, rfl⟩
rcases germ_exist F x t with ⟨U₂, hxU₂, t, rfl⟩
erw [stalkFunctor_map_germ_apply _ ⟨x, _⟩] at hst
erw [stalkFunctor_map_germ_apply _ ⟨x, _⟩] at hst
obtain ⟨W, hxW, iWU₁, iWU₂, heq⟩ := G.germ_eq x hxU₁ hxU₂ _ _ hst
rw [← comp_apply, ← comp_apply, ← f.naturality, ← f.naturality, comp_apply, comp_apply] at heq
replace heq := h W heq
convert congr_arg (F.germ ⟨x, hxW⟩) heq using 1
exacts [(F.germ_res_apply iWU₁ ⟨x, hxW⟩ s).symm, (F.germ_res_apply iWU₂ ⟨x, hxW⟩ t).symm]
variable [HasLimits C] [PreservesLimits (forget C)] [(forget C).ReflectsIsomorphisms]
/-- Let `F` be a sheaf valued in a concrete category, whose forgetful functor reflects isomorphisms,
preserves limits and filtered colimits. Then two sections who agree on every stalk must be equal.
-/
theorem section_ext (F : Sheaf C X) (U : Opens X) (s t : F.1.obj (op U))
(h : ∀ x : U, F.presheaf.germ x s = F.presheaf.germ x t) : s = t := by
-- We use `germ_eq` and the axiom of choice, to pick for every point `x` a neighbourhood
-- `V x`, such that the restrictions of `s` and `t` to `V x` coincide.
choose V m i₁ i₂ heq using fun x : U => F.presheaf.germ_eq x.1 x.2 x.2 s t (h x)
-- Since `F` is a sheaf, we can prove the equality locally, if we can show that these
-- neighborhoods form a cover of `U`.
apply F.eq_of_locally_eq' V U i₁
· intro x hxU
simp only [Opens.coe_iSup, Set.mem_iUnion, SetLike.mem_coe]
exact ⟨⟨x, hxU⟩, m ⟨x, hxU⟩⟩
· intro x
rw [heq, Subsingleton.elim (i₁ x) (i₂ x)]
/-
Note that the analogous statement for surjectivity is false: Surjectivity on stalks does not
imply surjectivity of the components of a sheaf morphism. However it does imply that the morphism
is an epi, but this fact is not yet formalized.
-/
theorem app_injective_of_stalkFunctor_map_injective {F : Sheaf C X} {G : Presheaf C X} (f : F.1 ⟶ G)
(U : Opens X) (h : ∀ x : U, Function.Injective ((stalkFunctor C x.val).map f)) :
Function.Injective (f.app (op U)) := fun s t hst =>
section_ext F _ _ _ fun x =>
h x <| by erw [stalkFunctor_map_germ_apply, stalkFunctor_map_germ_apply, hst]
theorem app_injective_iff_stalkFunctor_map_injective {F : Sheaf C X} {G : Presheaf C X}
(f : F.1 ⟶ G) :
(∀ x : X, Function.Injective ((stalkFunctor C x).map f)) ↔
∀ U : Opens X, Function.Injective (f.app (op U)) :=
⟨fun h U => app_injective_of_stalkFunctor_map_injective f U fun x => h x.1,
stalkFunctor_map_injective_of_app_injective f⟩
instance stalkFunctor_preserves_mono (x : X) :
Functor.PreservesMonomorphisms (Sheaf.forget C X ⋙ stalkFunctor C x) :=
⟨@fun _𝓐 _𝓑 f _ =>
ConcreteCategory.mono_of_injective _ <|
(app_injective_iff_stalkFunctor_map_injective f.1).mpr
(fun c =>
(ConcreteCategory.mono_iff_injective_of_preservesPullback (f.1.app (op c))).mp
((NatTrans.mono_iff_mono_app _ f.1).mp
(CategoryTheory.presheaf_mono_of_mono ..) <|
op c))
x⟩
theorem stalk_mono_of_mono {F G : Sheaf C X} (f : F ⟶ G) [Mono f] :
∀ x, Mono <| (stalkFunctor C x).map f.1 :=
fun x => Functor.map_mono (Sheaf.forget.{v} C X ⋙ stalkFunctor C x) f
theorem mono_of_stalk_mono {F G : Sheaf C X} (f : F ⟶ G) [∀ x, Mono <| (stalkFunctor C x).map f.1] :
Mono f :=
(Sheaf.Hom.mono_iff_presheaf_mono _ _ _).mpr <|
(NatTrans.mono_iff_mono_app _ _).mpr fun U =>
(ConcreteCategory.mono_iff_injective_of_preservesPullback _).mpr <|
app_injective_of_stalkFunctor_map_injective f.1 U.unop fun ⟨_x, _hx⟩ =>
(ConcreteCategory.mono_iff_injective_of_preservesPullback _).mp <| inferInstance
theorem mono_iff_stalk_mono {F G : Sheaf C X} (f : F ⟶ G) :
Mono f ↔ ∀ x, Mono ((stalkFunctor C x).map f.1) :=
⟨fun _ => stalk_mono_of_mono _, fun _ => mono_of_stalk_mono _⟩
/-- For surjectivity, we are given an arbitrary section `t` and need to find a preimage for it.
We claim that it suffices to find preimages *locally*. That is, for each `x : U` we construct
a neighborhood `V ≤ U` and a section `s : F.obj (op V))` such that `f.app (op V) s` and `t`
agree on `V`. -/
theorem app_surjective_of_injective_of_locally_surjective {F G : Sheaf C X} (f : F ⟶ G)
(U : Opens X) (hinj : ∀ x : U, Function.Injective ((stalkFunctor C x.1).map f.1))
(hsurj : ∀ (t) (x : U), ∃ (V : Opens X) (_ : x.1 ∈ V) (iVU : V ⟶ U) (s : F.1.obj (op V)),
f.1.app (op V) s = G.1.map iVU.op t) :
Function.Surjective (f.1.app (op U)) := by
intro t
-- We use the axiom of choice to pick around each point `x` an open neighborhood `V` and a
-- preimage under `f` on `V`.
choose V mV iVU sf heq using hsurj t
-- These neighborhoods clearly cover all of `U`.
have V_cover : U ≤ iSup V := by
intro x hxU
simp only [Opens.coe_iSup, Set.mem_iUnion, SetLike.mem_coe]
exact ⟨⟨x, hxU⟩, mV ⟨x, hxU⟩⟩
suffices IsCompatible F.val V sf by
-- Since `F` is a sheaf, we can glue all the local preimages together to get a global preimage.
obtain ⟨s, s_spec, -⟩ := F.existsUnique_gluing' V U iVU V_cover sf this
· use s
apply G.eq_of_locally_eq' V U iVU V_cover
intro x
rw [← comp_apply, ← f.1.naturality, comp_apply, s_spec, heq]
intro x y
-- What's left to show here is that the sections `sf` are compatible, i.e. they agree on
-- the intersections `V x ⊓ V y`. We prove this by showing that all germs are equal.
apply section_ext
intro z
-- Here, we need to use injectivity of the stalk maps.
apply hinj ⟨z, (iVU x).le ((inf_le_left : V x ⊓ V y ≤ V x) z.2)⟩
dsimp only
erw [stalkFunctor_map_germ_apply, stalkFunctor_map_germ_apply]
simp_rw [← comp_apply, f.1.naturality, comp_apply, heq, ← comp_apply, ← G.1.map_comp]
rfl
theorem app_surjective_of_stalkFunctor_map_bijective {F G : Sheaf C X} (f : F ⟶ G) (U : Opens X)
(h : ∀ x : U, Function.Bijective ((stalkFunctor C x.val).map f.1)) :
Function.Surjective (f.1.app (op U)) := by
refine app_surjective_of_injective_of_locally_surjective f U (fun x => (h x).1) fun t x => ?_
-- Now we need to prove our initial claim: That we can find preimages of `t` locally.
-- Since `f` is surjective on stalks, we can find a preimage `s₀` of the germ of `t` at `x`
obtain ⟨s₀, hs₀⟩ := (h x).2 (G.presheaf.germ x t)
-- ... and this preimage must come from some section `s₁` defined on some open neighborhood `V₁`
obtain ⟨V₁, hxV₁, s₁, hs₁⟩ := F.presheaf.germ_exist x.1 s₀
subst hs₁; rename' hs₀ => hs₁
erw [stalkFunctor_map_germ_apply V₁ ⟨x.1, hxV₁⟩ f.1 s₁] at hs₁
-- Now, the germ of `f.app (op V₁) s₁` equals the germ of `t`, hence they must coincide on
-- some open neighborhood `V₂`.
obtain ⟨V₂, hxV₂, iV₂V₁, iV₂U, heq⟩ := G.presheaf.germ_eq x.1 hxV₁ x.2 _ _ hs₁
-- The restriction of `s₁` to that neighborhood is our desired local preimage.
use V₂, hxV₂, iV₂U, F.1.map iV₂V₁.op s₁
rw [← comp_apply, f.1.naturality, comp_apply, heq]
theorem app_bijective_of_stalkFunctor_map_bijective {F G : Sheaf C X} (f : F ⟶ G) (U : Opens X)
(h : ∀ x : U, Function.Bijective ((stalkFunctor C x.val).map f.1)) :
Function.Bijective (f.1.app (op U)) :=
⟨app_injective_of_stalkFunctor_map_injective f.1 U fun x => (h x).1,
app_surjective_of_stalkFunctor_map_bijective f U h⟩
theorem app_isIso_of_stalkFunctor_map_iso {F G : Sheaf C X} (f : F ⟶ G) (U : Opens X)
[∀ x : U, IsIso ((stalkFunctor C x.val).map f.1)] : IsIso (f.1.app (op U)) := by
-- Since the forgetful functor of `C` reflects isomorphisms, it suffices to see that the
-- underlying map between types is an isomorphism, i.e. bijective.
suffices IsIso ((forget C).map (f.1.app (op U))) by
exact isIso_of_reflects_iso (f.1.app (op U)) (forget C)
rw [isIso_iff_bijective]
apply app_bijective_of_stalkFunctor_map_bijective
intro x
apply (isIso_iff_bijective _).mp
exact Functor.map_isIso (forget C) ((stalkFunctor C x.1).map f.1)
-- Making this an instance would cause a loop in typeclass resolution with `Functor.map_isIso`
/-- Let `F` and `G` be sheaves valued in a concrete category, whose forgetful functor reflects
isomorphisms, preserves limits and filtered colimits. Then if the stalk maps of a morphism
`f : F ⟶ G` are all isomorphisms, `f` must be an isomorphism.
-/
theorem isIso_of_stalkFunctor_map_iso {F G : Sheaf C X} (f : F ⟶ G)
[∀ x : X, IsIso ((stalkFunctor C x).map f.1)] : IsIso f := by
-- Since the inclusion functor from sheaves to presheaves is fully faithful, it suffices to
-- show that `f`, as a morphism between _presheaves_, is an isomorphism.
suffices IsIso ((Sheaf.forget C X).map f) by exact isIso_of_fully_faithful (Sheaf.forget C X) f
-- We show that all components of `f` are isomorphisms.
suffices ∀ U : (Opens X)ᵒᵖ, IsIso (f.1.app U) by
exact @NatIso.isIso_of_isIso_app _ _ _ _ F.1 G.1 f.1 this
intro U; induction U
apply app_isIso_of_stalkFunctor_map_iso
/-- Let `F` and `G` be sheaves valued in a concrete category, whose forgetful functor reflects
isomorphisms, preserves limits and filtered colimits. Then a morphism `f : F ⟶ G` is an
isomorphism if and only if all of its stalk maps are isomorphisms.
-/
theorem isIso_iff_stalkFunctor_map_iso {F G : Sheaf C X} (f : F ⟶ G) :
IsIso f ↔ ∀ x : X, IsIso ((stalkFunctor C x).map f.1) :=
⟨fun _ x =>
@Functor.map_isIso _ _ _ _ _ _ (stalkFunctor C x) f.1 ((Sheaf.forget C X).map_isIso f),
fun _ => isIso_of_stalkFunctor_map_iso f⟩
end Concrete
instance algebra_section_stalk (F : X.Presheaf CommRingCat) {U : Opens X} (x : U) :
Algebra (F.obj <| op U) (F.stalk x) :=
(F.germ x).toAlgebra
@[simp]
theorem stalk_open_algebraMap {X : TopCat} (F : X.Presheaf CommRingCat) {U : Opens X} (x : U) :
algebraMap (F.obj <| op U) (F.stalk x) = F.germ x :=
rfl
end TopCat.Presheaf
|
Topology\Sheaves\SheafCondition\EqualizerProducts.lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.CategoryTheory.Limits.Shapes.Equalizers
import Mathlib.CategoryTheory.Limits.Shapes.Products
import Mathlib.Topology.Sheaves.SheafCondition.PairwiseIntersections
/-!
# The sheaf condition in terms of an equalizer of products
Here we set up the machinery for the "usual" definition of the sheaf condition,
e.g. as in https://stacks.math.columbia.edu/tag/0072
in terms of an equalizer diagram where the two objects are
`∏ᶜ F.obj (U i)` and `∏ᶜ F.obj (U i) ⊓ (U j)`.
We show that this sheaf condition is equivalent to the "pairwise intersections" sheaf condition when
the presheaf is valued in a category with products, and thereby equivalent to the default sheaf
condition.
-/
universe v' v u
noncomputable section
open CategoryTheory CategoryTheory.Limits TopologicalSpace Opposite TopologicalSpace.Opens
namespace TopCat
variable {C : Type u} [Category.{v} C] [HasProducts.{v'} C]
variable {X : TopCat.{v'}} (F : Presheaf C X) {ι : Type v'} (U : ι → Opens X)
namespace Presheaf
namespace SheafConditionEqualizerProducts
/-- The product of the sections of a presheaf over a family of open sets. -/
def piOpens : C :=
∏ᶜ fun i : ι => F.obj (op (U i))
/-- The product of the sections of a presheaf over the pairwise intersections of
a family of open sets.
-/
def piInters : C :=
∏ᶜ fun p : ι × ι => F.obj (op (U p.1 ⊓ U p.2))
/-- The morphism `Π F.obj (U i) ⟶ Π F.obj (U i) ⊓ (U j)` whose components
are given by the restriction maps from `U i` to `U i ⊓ U j`.
-/
def leftRes : piOpens F U ⟶ piInters.{v'} F U :=
Pi.lift fun p : ι × ι => Pi.π _ p.1 ≫ F.map (infLELeft (U p.1) (U p.2)).op
/-- The morphism `Π F.obj (U i) ⟶ Π F.obj (U i) ⊓ (U j)` whose components
are given by the restriction maps from `U j` to `U i ⊓ U j`.
-/
def rightRes : piOpens F U ⟶ piInters.{v'} F U :=
Pi.lift fun p : ι × ι => Pi.π _ p.2 ≫ F.map (infLERight (U p.1) (U p.2)).op
/-- The morphism `F.obj U ⟶ Π F.obj (U i)` whose components
are given by the restriction maps from `U j` to `U i ⊓ U j`.
-/
def res : F.obj (op (iSup U)) ⟶ piOpens.{v'} F U :=
Pi.lift fun i : ι => F.map (TopologicalSpace.Opens.leSupr U i).op
@[simp, elementwise]
theorem res_π (i : ι) : res F U ≫ limit.π _ ⟨i⟩ = F.map (Opens.leSupr U i).op := by
rw [res, limit.lift_π, Fan.mk_π_app]
@[elementwise]
theorem w : res F U ≫ leftRes F U = res F U ≫ rightRes F U := by
dsimp [res, leftRes, rightRes]
-- Porting note (#11041): `ext` can't see `limit.hom_ext` applies here:
refine limit.hom_ext (fun _ => ?_)
simp only [limit.lift_π, limit.lift_π_assoc, Fan.mk_π_app, Category.assoc]
rw [← F.map_comp]
rw [← F.map_comp]
congr 1
/-- The equalizer diagram for the sheaf condition.
-/
abbrev diagram : WalkingParallelPair ⥤ C :=
parallelPair (leftRes.{v'} F U) (rightRes F U)
/-- The restriction map `F.obj U ⟶ Π F.obj (U i)` gives a cone over the equalizer diagram
for the sheaf condition. The sheaf condition asserts this cone is a limit cone.
-/
def fork : Fork.{v} (leftRes F U) (rightRes F U) :=
Fork.ofι _ (w F U)
@[simp]
theorem fork_pt : (fork F U).pt = F.obj (op (iSup U)) :=
rfl
@[simp]
theorem fork_ι : (fork F U).ι = res F U :=
rfl
@[simp]
theorem fork_π_app_walkingParallelPair_zero : (fork F U).π.app WalkingParallelPair.zero = res F U :=
rfl
-- Porting note: Shortcut simplifier
@[simp (high)]
theorem fork_π_app_walkingParallelPair_one :
(fork F U).π.app WalkingParallelPair.one = res F U ≫ leftRes F U :=
rfl
variable {F} {G : Presheaf C X}
/-- Isomorphic presheaves have isomorphic `piOpens` for any cover `U`. -/
@[simp]
def piOpens.isoOfIso (α : F ≅ G) : piOpens F U ≅ piOpens.{v'} G U :=
Pi.mapIso fun _ => α.app _
/-- Isomorphic presheaves have isomorphic `piInters` for any cover `U`. -/
@[simp]
def piInters.isoOfIso (α : F ≅ G) : piInters F U ≅ piInters.{v'} G U :=
Pi.mapIso fun _ => α.app _
/-- Isomorphic presheaves have isomorphic sheaf condition diagrams. -/
def diagram.isoOfIso (α : F ≅ G) : diagram F U ≅ diagram.{v'} G U :=
NatIso.ofComponents (by
rintro ⟨⟩
· exact piOpens.isoOfIso U α
· exact piInters.isoOfIso U α)
(by
rintro ⟨⟩ ⟨⟩ ⟨⟩
· simp
· -- Porting note (#11041): `ext` can't see `limit.hom_ext` applies here:
refine limit.hom_ext (fun _ => ?_)
simp only [leftRes, piOpens.isoOfIso, piInters.isoOfIso, parallelPair_map_left,
Functor.mapIso_hom, lim_map, limit.lift_map, limit.lift_π, Cones.postcompose_obj_π,
NatTrans.comp_app, Fan.mk_π_app, Discrete.natIso_hom_app, Iso.app_hom, Category.assoc,
NatTrans.naturality, limMap_π_assoc]
· -- Porting note (#11041): `ext` can't see `limit.hom_ext` applies here:
refine limit.hom_ext (fun _ => ?_)
simp only [rightRes, piOpens.isoOfIso, piInters.isoOfIso, parallelPair_map_right,
Functor.mapIso_hom, lim_map, limit.lift_map, limit.lift_π, Cones.postcompose_obj_π,
NatTrans.comp_app, Fan.mk_π_app, Discrete.natIso_hom_app, Iso.app_hom, Category.assoc,
NatTrans.naturality, limMap_π_assoc]
· simp)
/-- If `F G : Presheaf C X` are isomorphic presheaves,
then the `fork F U`, the canonical cone of the sheaf condition diagram for `F`,
is isomorphic to `fork F G` postcomposed with the corresponding isomorphism between
sheaf condition diagrams.
-/
def fork.isoOfIso (α : F ≅ G) :
fork F U ≅ (Cones.postcompose (diagram.isoOfIso U α).inv).obj (fork G U) := by
fapply Fork.ext
· apply α.app
· -- Porting note (#11041): `ext` can't see `limit.hom_ext` applies here:
refine limit.hom_ext (fun _ => ?_)
dsimp only [Fork.ι]
-- Ugh, `simp` can't unfold abbreviations.
simp only [res, diagram.isoOfIso, Iso.app_hom, piOpens.isoOfIso, Cones.postcompose_obj_π,
NatTrans.comp_app, fork_π_app_walkingParallelPair_zero, NatIso.ofComponents_inv_app,
Functor.mapIso_inv, lim_map, limit.lift_map, Category.assoc, limit.lift_π, Fan.mk_π_app,
Discrete.natIso_inv_app, Iso.app_inv, NatTrans.naturality, Iso.hom_inv_id_app_assoc]
end SheafConditionEqualizerProducts
/-- The sheaf condition for a `F : Presheaf C X` requires that the morphism
`F.obj U ⟶ ∏ᶜ F.obj (U i)` (where `U` is some open set which is the union of the `U i`)
is the equalizer of the two morphisms
`∏ᶜ F.obj (U i) ⟶ ∏ᶜ F.obj (U i) ⊓ (U j)`.
-/
def IsSheafEqualizerProducts (F : Presheaf.{v', v, u} C X) : Prop :=
∀ ⦃ι : Type v'⦄ (U : ι → Opens X), Nonempty (IsLimit (SheafConditionEqualizerProducts.fork F U))
/-!
The remainder of this file shows that the "equalizer products" sheaf condition is equivalent
to the "pairwise intersections" sheaf condition.
-/
namespace SheafConditionPairwiseIntersections
open CategoryTheory.Pairwise CategoryTheory.Pairwise.Hom
/-- Implementation of `SheafConditionPairwiseIntersections.coneEquiv`. -/
@[simps]
def coneEquivFunctorObj (c : Cone ((diagram U).op ⋙ F)) :
Cone (SheafConditionEqualizerProducts.diagram F U) where
pt := c.pt
π :=
{ app := fun Z =>
WalkingParallelPair.casesOn Z (Pi.lift fun i : ι => c.π.app (op (single i)))
(Pi.lift fun b : ι × ι => c.π.app (op (pair b.1 b.2)))
naturality := fun Y Z f => by
cases Y <;> cases Z <;> cases f
· -- Porting note (#11041): `ext` can't see `limit.hom_ext` applies here:
refine limit.hom_ext fun i => ?_
dsimp
simp only [limit.lift_π, Category.id_comp, Fan.mk_π_app, CategoryTheory.Functor.map_id,
Category.assoc]
dsimp
simp only [limit.lift_π, Category.id_comp, Fan.mk_π_app]
· -- Porting note (#11041): `ext` can't see `limit.hom_ext` applies here:
refine limit.hom_ext fun ⟨i, j⟩ => ?_
dsimp [SheafConditionEqualizerProducts.leftRes]
simp only [limit.lift_π, limit.lift_π_assoc, Category.id_comp, Fan.mk_π_app,
Category.assoc]
have h := c.π.naturality (Quiver.Hom.op (Hom.left i j))
dsimp at h
simpa using h
· -- Porting note (#11041): `ext` can't see `limit.hom_ext` applies here:
refine limit.hom_ext fun ⟨i, j⟩ => ?_
dsimp [SheafConditionEqualizerProducts.rightRes]
simp only [limit.lift_π, limit.lift_π_assoc, Category.id_comp, Fan.mk_π_app,
Category.assoc]
have h := c.π.naturality (Quiver.Hom.op (Hom.right i j))
dsimp at h
simpa using h
· -- Porting note (#11041): `ext` can't see `limit.hom_ext` applies here:
refine limit.hom_ext fun i => ?_
dsimp
simp only [limit.lift_π, Category.id_comp, Fan.mk_π_app, CategoryTheory.Functor.map_id,
Category.assoc]
dsimp
simp only [limit.lift_π, Category.id_comp, Fan.mk_π_app] }
section
/-- Implementation of `SheafConditionPairwiseIntersections.coneEquiv`. -/
@[simps!]
def coneEquivFunctor :
Limits.Cone ((diagram U).op ⋙ F) ⥤
Limits.Cone (SheafConditionEqualizerProducts.diagram F U) where
obj c := coneEquivFunctorObj F U c
map {c c'} f :=
{ hom := f.hom
w := fun j => by
cases j <;>
· -- Porting note (#11041): `ext` can't see `limit.hom_ext` applies here:
refine limit.hom_ext fun i => ?_
simp only [Limits.Fan.mk_π_app, Limits.ConeMorphism.w, Limits.limit.lift_π,
Category.assoc, coneEquivFunctorObj_π_app] }
end
/-- Implementation of `SheafConditionPairwiseIntersections.coneEquiv`. -/
@[simps]
def coneEquivInverseObj (c : Limits.Cone (SheafConditionEqualizerProducts.diagram F U)) :
Limits.Cone ((diagram U).op ⋙ F) where
pt := c.pt
π :=
{ app := by
intro x
induction x using Opposite.rec' with | h x => ?_
rcases x with (⟨i⟩ | ⟨i, j⟩)
· exact c.π.app WalkingParallelPair.zero ≫ Pi.π _ i
· exact c.π.app WalkingParallelPair.one ≫ Pi.π _ (i, j)
naturality := by
intro x y f
induction x using Opposite.rec' with | h x => ?_
induction y using Opposite.rec' with | h y => ?_
have ef : f = f.unop.op := rfl
revert ef
generalize f.unop = f'
rintro rfl
rcases x with (⟨i⟩ | ⟨⟩) <;> rcases y with (⟨⟩ | ⟨j, j⟩) <;> rcases f' with ⟨⟩
· dsimp
erw [F.map_id]
simp
· dsimp
simp only [Category.id_comp, Category.assoc]
have h := c.π.naturality WalkingParallelPairHom.left
dsimp [SheafConditionEqualizerProducts.leftRes] at h
simp only [Category.id_comp] at h
have h' := h =≫ Pi.π _ (i, j)
rw [h']
simp only [Category.assoc, limit.lift_π, Fan.mk_π_app]
rfl
· dsimp
simp only [Category.id_comp, Category.assoc]
have h := c.π.naturality WalkingParallelPairHom.right
dsimp [SheafConditionEqualizerProducts.rightRes] at h
simp only [Category.id_comp] at h
have h' := h =≫ Pi.π _ (j, i)
rw [h']
simp
rfl
· dsimp
erw [F.map_id]
simp }
/-- Implementation of `SheafConditionPairwiseIntersections.coneEquiv`. -/
@[simps!]
def coneEquivInverse :
Limits.Cone (SheafConditionEqualizerProducts.diagram F U) ⥤
Limits.Cone ((diagram U).op ⋙ F) where
obj c := coneEquivInverseObj F U c
map {c c'} f :=
{ hom := f.hom
w := by
intro x
induction x using Opposite.rec' with | h x => ?_
rcases x with (⟨i⟩ | ⟨i, j⟩)
· dsimp
dsimp only [Fork.ι]
rw [← f.w WalkingParallelPair.zero, Category.assoc]
· dsimp
rw [← f.w WalkingParallelPair.one, Category.assoc] }
/-- Implementation of `SheafConditionPairwiseIntersections.coneEquiv`. -/
@[simps]
def coneEquivUnitIsoApp (c : Cone ((diagram U).op ⋙ F)) :
(𝟭 (Cone ((diagram U).op ⋙ F))).obj c ≅
(coneEquivFunctor F U ⋙ coneEquivInverse F U).obj c where
hom :=
{ hom := 𝟙 _
w := fun j => by
induction j using Opposite.rec' with | h j => ?_
rcases j with ⟨⟩ <;>
· dsimp [coneEquivInverse]
simp only [Limits.Fan.mk_π_app, Category.id_comp, Limits.limit.lift_π] }
inv :=
{ hom := 𝟙 _
w := fun j => by
induction j using Opposite.rec' with | h j => ?_
rcases j with ⟨⟩ <;>
· dsimp [coneEquivInverse]
simp only [Limits.Fan.mk_π_app, Category.id_comp, Limits.limit.lift_π] }
/-- Implementation of `SheafConditionPairwiseIntersections.coneEquiv`. -/
@[simps!]
def coneEquivUnitIso :
𝟭 (Limits.Cone ((diagram U).op ⋙ F)) ≅ coneEquivFunctor F U ⋙ coneEquivInverse F U :=
NatIso.ofComponents (coneEquivUnitIsoApp F U)
/-- Implementation of `SheafConditionPairwiseIntersections.coneEquiv`. -/
@[simps!]
def coneEquivCounitIso :
coneEquivInverse F U ⋙ coneEquivFunctor F U ≅
𝟭 (Limits.Cone (SheafConditionEqualizerProducts.diagram F U)) :=
NatIso.ofComponents
(fun c =>
{ hom :=
{ hom := 𝟙 _
w := by
rintro ⟨_ | _⟩
· -- Porting note (#11041): `ext` can't see `limit.hom_ext` applies here:
refine limit.hom_ext fun ⟨j⟩ => ?_
dsimp [coneEquivInverse]
simp only [Limits.Fan.mk_π_app, Category.id_comp, Limits.limit.lift_π]
· -- Porting note (#11041): `ext` can't see `limit.hom_ext` applies here:
refine limit.hom_ext fun ⟨i, j⟩ => ?_
dsimp [coneEquivInverse]
simp only [Limits.Fan.mk_π_app, Category.id_comp, Limits.limit.lift_π] }
inv :=
{ hom := 𝟙 _
w := by
rintro ⟨_ | _⟩
· -- Porting note (#11041): `ext` can't see `limit.hom_ext` applies here:
refine limit.hom_ext fun ⟨j⟩ => ?_
dsimp [coneEquivInverse]
simp only [Limits.Fan.mk_π_app, Category.id_comp, Limits.limit.lift_π]
· -- Porting note (#11041): `ext` can't see `limit.hom_ext` applies here:
refine limit.hom_ext fun ⟨i, j⟩ => ?_
dsimp [coneEquivInverse]
simp only [Limits.Fan.mk_π_app, Category.id_comp, Limits.limit.lift_π] } })
fun {c d} f => by
ext
dsimp
simp only [Category.comp_id, Category.id_comp]
/--
Cones over `diagram U ⋙ F` are the same as a cones over the usual sheaf condition equalizer diagram.
-/
@[simps]
def coneEquiv :
Limits.Cone ((diagram U).op ⋙ F) ≌
Limits.Cone (SheafConditionEqualizerProducts.diagram F U) where
functor := coneEquivFunctor F U
inverse := coneEquivInverse F U
unitIso := coneEquivUnitIso F U
counitIso := coneEquivCounitIso F U
-- Porting note: not supported in Lean 4
-- attribute [local reducible]
-- SheafConditionEqualizerProducts.res SheafConditionEqualizerProducts.leftRes
/-- If `SheafConditionEqualizerProducts.fork` is an equalizer,
then `F.mapCone (cone U)` is a limit cone.
-/
def isLimitMapConeOfIsLimitSheafConditionFork
(P : IsLimit (SheafConditionEqualizerProducts.fork F U)) : IsLimit (F.mapCone (cocone U).op) :=
IsLimit.ofIsoLimit ((IsLimit.ofConeEquiv (coneEquiv F U).symm).symm P)
{ hom :=
{ hom := 𝟙 _
w := by
intro x
induction x with | h x => ?_
rcases x with ⟨⟩
· simp
rfl
· dsimp [coneEquivInverse, SheafConditionEqualizerProducts.res,
SheafConditionEqualizerProducts.leftRes]
simp only [limit.lift_π, limit.lift_π_assoc, Category.id_comp, Fan.mk_π_app,
Category.assoc]
rw [← F.map_comp]
rfl }
inv :=
{ hom := 𝟙 _
w := by
intro x
induction x with | h x => ?_
rcases x with ⟨⟩
· simp
rfl
· dsimp [coneEquivInverse, SheafConditionEqualizerProducts.res,
SheafConditionEqualizerProducts.leftRes]
simp only [limit.lift_π, limit.lift_π_assoc, Category.id_comp, Fan.mk_π_app,
Category.assoc]
rw [← F.map_comp]
rfl } }
/-- If `F.mapCone (cone U)` is a limit cone,
then `SheafConditionEqualizerProducts.fork` is an equalizer.
-/
def isLimitSheafConditionForkOfIsLimitMapCone (Q : IsLimit (F.mapCone (cocone U).op)) :
IsLimit (SheafConditionEqualizerProducts.fork F U) :=
IsLimit.ofIsoLimit ((IsLimit.ofConeEquiv (coneEquiv F U)).symm Q)
{ hom :=
{ hom := 𝟙 _
w := by
rintro ⟨⟩
· simp
rfl
· -- Porting note (#11041): `ext` can't see `limit.hom_ext` applies here:
refine limit.hom_ext fun ⟨i, j⟩ => ?_
dsimp [coneEquivInverse, SheafConditionEqualizerProducts.res,
SheafConditionEqualizerProducts.leftRes]
simp only [limit.lift_π, limit.lift_π_assoc, Category.id_comp, Fan.mk_π_app,
Category.assoc]
rw [← F.map_comp]
rfl }
inv :=
{ hom := 𝟙 _
w := by
rintro ⟨⟩
· simp
rfl
· -- Porting note (#11041): `ext` can't see `limit.hom_ext` applies here:
refine limit.hom_ext fun ⟨i, j⟩ => ?_
dsimp [coneEquivInverse, SheafConditionEqualizerProducts.res,
SheafConditionEqualizerProducts.leftRes]
simp only [limit.lift_π, limit.lift_π_assoc, Category.id_comp, Fan.mk_π_app,
Category.assoc]
rw [← F.map_comp]
rfl } }
end SheafConditionPairwiseIntersections
open SheafConditionPairwiseIntersections
/-- The sheaf condition in terms of an equalizer diagram is equivalent
to the default sheaf condition.
-/
theorem isSheaf_iff_isSheafEqualizerProducts (F : Presheaf C X) :
F.IsSheaf ↔ F.IsSheafEqualizerProducts :=
(isSheaf_iff_isSheafPairwiseIntersections F).trans <|
Iff.intro (fun h _ U => ⟨isLimitSheafConditionForkOfIsLimitMapCone F U (h U).some⟩) fun h _ U =>
⟨isLimitMapConeOfIsLimitSheafConditionFork F U (h U).some⟩
end Presheaf
end TopCat
|
Topology\Sheaves\SheafCondition\OpensLeCover.lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Topology.Sheaves.SheafCondition.Sites
/-!
# Another version of the sheaf condition.
Given a family of open sets `U : ι → Opens X` we can form the subcategory
`{ V : Opens X // ∃ i, V ≤ U i }`, which has `iSup U` as a cocone.
The sheaf condition on a presheaf `F` is equivalent to
`F` sending the opposite of this cocone to a limit cone in `C`, for every `U`.
This condition is particularly nice when checking the sheaf condition
because we don't need to do any case bashing
(depending on whether we're looking at single or double intersections,
or equivalently whether we're looking at the first or second object in an equalizer diagram).
## Main statement
`TopCat.Presheaf.isSheaf_iff_isSheafOpensLeCover`: for a presheaf on a topological space,
the sheaf condition in terms of Grothendieck topology is equivalent to the `OpensLeCover`
sheaf condition. This result will be used to further connect to other sheaf conditions on spaces,
like `pairwise_intersections` and `equalizer_products`.
## References
* This is the definition Lurie uses in [Spectral Algebraic Geometry][LurieSAG].
-/
universe w v u
noncomputable section
open CategoryTheory CategoryTheory.Limits TopologicalSpace TopologicalSpace.Opens Opposite
namespace TopCat
variable {C : Type u} [Category.{v} C]
variable {X : TopCat.{w}} (F : Presheaf C X) {ι : Type w} (U : ι → Opens X)
namespace Presheaf
namespace SheafCondition
/-- The category of open sets contained in some element of the cover.
-/
def OpensLeCover : Type w :=
FullSubcategory fun V : Opens X => ∃ i, V ≤ U i
-- Porting note: failed to derive `category`
instance : Category (OpensLeCover U) := FullSubcategory.category _
instance [h : Nonempty ι] : Inhabited (OpensLeCover U) :=
⟨⟨⊥, let ⟨i⟩ := h; ⟨i, bot_le⟩⟩⟩
namespace OpensLeCover
variable {U}
/-- An arbitrarily chosen index such that `V ≤ U i`.
-/
def index (V : OpensLeCover U) : ι :=
V.property.choose
/-- The morphism from `V` to `U i` for some `i`.
-/
def homToIndex (V : OpensLeCover U) : V.obj ⟶ U (index V) :=
V.property.choose_spec.hom
end OpensLeCover
/-- `iSup U` as a cocone over the opens sets contained in some element of the cover.
(In fact this is a colimit cocone.)
-/
def opensLeCoverCocone : Cocone (fullSubcategoryInclusion _ : OpensLeCover U ⥤ Opens X) where
pt := iSup U
ι := { app := fun V : OpensLeCover U => V.homToIndex ≫ Opens.leSupr U _ }
end SheafCondition
open SheafCondition
/-- An equivalent formulation of the sheaf condition
(which we prove equivalent to the usual one below as
`isSheaf_iff_isSheafOpensLeCover`).
A presheaf is a sheaf if `F` sends the cone `(opensLeCoverCocone U).op` to a limit cone.
(Recall `opensLeCoverCocone U`, has cone point `iSup U`,
mapping down to any `V` which is contained in some `U i`.)
-/
def IsSheafOpensLeCover : Prop :=
∀ ⦃ι : Type w⦄ (U : ι → Opens X), Nonempty (IsLimit (F.mapCone (opensLeCoverCocone U).op))
section
variable {Y : Opens X} (hY : Y = iSup U)
-- Porting note: split it out to prevent timeout
/-- Given a family of opens `U` and an open `Y` equal to the union of opens in `U`, we may
take the presieve on `Y` associated to `U` and the sieve generated by it, and form the
full subcategory (subposet) of opens contained in `Y` (`over Y`) consisting of arrows
in the sieve. This full subcategory is equivalent to `OpensLeCover U`, the (poset)
category of opens contained in some `U i`. -/
@[simps]
def generateEquivalenceOpensLe_functor' :
(FullSubcategory fun f : Over Y => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom) ⥤
OpensLeCover U :=
{ obj := fun f =>
⟨f.1.left,
let ⟨_, h, _, ⟨i, hY⟩, _⟩ := f.2
⟨i, hY ▸ h.le⟩⟩
map := fun {_ _} g => g.left }
-- Porting note: split it out to prevent timeout
/-- Given a family of opens `U` and an open `Y` equal to the union of opens in `U`, we may
take the presieve on `Y` associated to `U` and the sieve generated by it, and form the
full subcategory (subposet) of opens contained in `Y` (`over Y`) consisting of arrows
in the sieve. This full subcategory is equivalent to `OpensLeCover U`, the (poset)
category of opens contained in some `U i`. -/
@[simps]
def generateEquivalenceOpensLe_inverse' :
OpensLeCover U ⥤
(FullSubcategory fun f : Over Y =>
(Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom) where
obj := fun V => ⟨⟨V.obj, ⟨⟨⟩⟩, homOfLE <| hY ▸ (V.2.choose_spec.trans (le_iSup U (V.2.choose)))⟩,
⟨U V.2.choose, V.2.choose_spec.hom, homOfLE <| hY ▸ le_iSup U V.2.choose,
⟨V.2.choose, rfl⟩, rfl⟩⟩
map {_ _} g := Over.homMk g
map_id _ := by
refine Over.OverMorphism.ext ?_
simp only [Functor.id_obj, Sieve.generate_apply, Functor.const_obj_obj, Over.homMk_left,
eq_iff_true_of_subsingleton]
map_comp {_ _ _} f g := by
refine Over.OverMorphism.ext ?_
simp only [Functor.id_obj, Sieve.generate_apply, Functor.const_obj_obj, Over.homMk_left,
eq_iff_true_of_subsingleton]
/-- Given a family of opens `U` and an open `Y` equal to the union of opens in `U`, we may
take the presieve on `Y` associated to `U` and the sieve generated by it, and form the
full subcategory (subposet) of opens contained in `Y` (`over Y`) consisting of arrows
in the sieve. This full subcategory is equivalent to `OpensLeCover U`, the (poset)
category of opens contained in some `U i`. -/
@[simps]
def generateEquivalenceOpensLe :
(FullSubcategory fun f : Over Y => (Sieve.generate (presieveOfCoveringAux U Y)).arrows f.hom) ≌
OpensLeCover U where
-- Porting note: split it out to prevent timeout
functor := generateEquivalenceOpensLe_functor' _ _
inverse := generateEquivalenceOpensLe_inverse' _ _
unitIso := eqToIso <| CategoryTheory.Functor.ext
(by rintro ⟨⟨_, _⟩, _⟩; dsimp; congr)
(by intros; refine Over.OverMorphism.ext ?_; aesop_cat)
counitIso := eqToIso <| CategoryTheory.Functor.hext
(by intro; refine FullSubcategory.ext ?_; rfl) (by intros; rfl)
/-- Given a family of opens `opensLeCoverCocone U` is essentially the natural cocone
associated to the sieve generated by the presieve associated to `U` with indexing
category changed using the above equivalence. -/
@[simps]
def whiskerIsoMapGenerateCocone :
(F.mapCone (opensLeCoverCocone U).op).whisker (generateEquivalenceOpensLe U hY).op.functor ≅
F.mapCone (Sieve.generate (presieveOfCoveringAux U Y)).arrows.cocone.op where
hom :=
{ hom := F.map (eqToHom (congr_arg op hY.symm))
w := fun j => by
erw [← F.map_comp]
dsimp
congr 1 }
inv :=
{ hom := F.map (eqToHom (congr_arg op hY))
w := fun j => by
erw [← F.map_comp]
dsimp
congr 1 }
hom_inv_id := by
ext
simp [eqToHom_map]
inv_hom_id := by
ext
simp [eqToHom_map]
/-- Given a presheaf `F` on the topological space `X` and a family of opens `U` of `X`,
the natural cone associated to `F` and `U` used in the definition of
`F.IsSheafOpensLeCover` is a limit cone iff the natural cone associated to `F`
and the sieve generated by the presieve associated to `U` is a limit cone. -/
def isLimitOpensLeEquivGenerate₁ :
IsLimit (F.mapCone (opensLeCoverCocone U).op) ≃
IsLimit (F.mapCone (Sieve.generate (presieveOfCoveringAux U Y)).arrows.cocone.op) :=
(IsLimit.whiskerEquivalenceEquiv (generateEquivalenceOpensLe U hY).op).trans
(IsLimit.equivIsoLimit (whiskerIsoMapGenerateCocone F U hY))
/-- Given a presheaf `F` on the topological space `X` and a presieve `R` whose generated sieve
is covering for the associated Grothendieck topology (equivalently, the presieve is covering
for the associated pretopology), the natural cone associated to `F` and the family of opens
associated to `R` is a limit cone iff the natural cone associated to `F` and the generated
sieve is a limit cone.
Since only the existence of a 1-1 correspondence will be used, the exact definition does
not matter, so tactics are used liberally. -/
def isLimitOpensLeEquivGenerate₂ (R : Presieve Y)
(hR : Sieve.generate R ∈ Opens.grothendieckTopology X Y) :
IsLimit (F.mapCone (opensLeCoverCocone (coveringOfPresieve Y R)).op) ≃
IsLimit (F.mapCone (Sieve.generate R).arrows.cocone.op) := by
convert isLimitOpensLeEquivGenerate₁ F (coveringOfPresieve Y R)
(coveringOfPresieve.iSup_eq_of_mem_grothendieck Y R hR).symm using 1
rw [covering_presieve_eq_self R]
/-- A presheaf `(opens X)ᵒᵖ ⥤ C` on a topological space `X` is a sheaf on the site `opens X` iff
it satisfies the `IsSheafOpensLeCover` sheaf condition. The latter is not the
official definition of sheaves on spaces, but has the advantage that it does not
require `has_products C`. -/
theorem isSheaf_iff_isSheafOpensLeCover : F.IsSheaf ↔ F.IsSheafOpensLeCover := by
refine (Presheaf.isSheaf_iff_isLimit _ _).trans ?_
constructor
· intro h ι U
rw [(isLimitOpensLeEquivGenerate₁ F U rfl).nonempty_congr]
apply h
apply presieveOfCovering.mem_grothendieckTopology
· intro h Y S
rw [← Sieve.generate_sieve S]
intro hS
rw [← (isLimitOpensLeEquivGenerate₂ F S.1 hS).nonempty_congr]
apply h
end
end Presheaf
end TopCat
|
Topology\Sheaves\SheafCondition\PairwiseIntersections.lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Topology.Sheaves.SheafCondition.OpensLeCover
import Mathlib.CategoryTheory.Limits.Final
import Mathlib.CategoryTheory.Limits.Preserves.Basic
import Mathlib.CategoryTheory.Category.Pairwise
import Mathlib.CategoryTheory.Limits.Constructions.BinaryProducts
import Mathlib.Algebra.Category.Ring.Constructions
/-!
# Equivalent formulations of the sheaf condition
We give an equivalent formulation of the sheaf condition.
Given any indexed type `ι`, we define `overlap ι`,
a category with objects corresponding to
* individual open sets, `single i`, and
* intersections of pairs of open sets, `pair i j`,
with morphisms from `pair i j` to both `single i` and `single j`.
Any open cover `U : ι → Opens X` provides a functor `diagram U : overlap ι ⥤ (Opens X)ᵒᵖ`.
There is a canonical cone over this functor, `cone U`, whose cone point is `isup U`,
and in fact this is a limit cone.
A presheaf `F : Presheaf C X` is a sheaf precisely if it preserves this limit.
We express this in two equivalent ways, as
* `isLimit (F.mapCone (cone U))`, or
* `preservesLimit (diagram U) F`
We show that this sheaf condition is equivalent to the `OpensLeCover` sheaf condition, and
thereby also equivalent to the default sheaf condition.
-/
noncomputable section
universe w v u
open TopologicalSpace TopCat Opposite CategoryTheory CategoryTheory.Limits
variable {C : Type u} [Category.{v} C] {X : TopCat.{w}}
namespace TopCat.Presheaf
section
/-- An alternative formulation of the sheaf condition
(which we prove equivalent to the usual one below as
`isSheaf_iff_isSheafPairwiseIntersections`).
A presheaf is a sheaf if `F` sends the cone `(Pairwise.cocone U).op` to a limit cone.
(Recall `Pairwise.cocone U` has cone point `iSup U`, mapping down to the `U i` and the `U i ⊓ U j`.)
-/
def IsSheafPairwiseIntersections (F : Presheaf C X) : Prop :=
∀ ⦃ι : Type w⦄ (U : ι → Opens X), Nonempty (IsLimit (F.mapCone (Pairwise.cocone U).op))
/-- An alternative formulation of the sheaf condition
(which we prove equivalent to the usual one below as
`isSheaf_iff_isSheafPreservesLimitPairwiseIntersections`).
A presheaf is a sheaf if `F` preserves the limit of `Pairwise.diagram U`.
(Recall `Pairwise.diagram U` is the diagram consisting of the pairwise intersections
`U i ⊓ U j` mapping into the open sets `U i`. This diagram has limit `iSup U`.)
-/
def IsSheafPreservesLimitPairwiseIntersections (F : Presheaf C X) : Prop :=
∀ ⦃ι : Type w⦄ (U : ι → Opens X), Nonempty (PreservesLimit (Pairwise.diagram U).op F)
end
namespace SheafCondition
variable {ι : Type w} (U : ι → Opens X)
open CategoryTheory.Pairwise
/-- Implementation detail:
the object level of `pairwiseToOpensLeCover : Pairwise ι ⥤ OpensLeCover U`
-/
@[simp]
def pairwiseToOpensLeCoverObj : Pairwise ι → OpensLeCover U
| single i => ⟨U i, ⟨i, le_rfl⟩⟩
| Pairwise.pair i j => ⟨U i ⊓ U j, ⟨i, inf_le_left⟩⟩
open CategoryTheory.Pairwise.Hom
/-- Implementation detail:
the morphism level of `pairwiseToOpensLeCover : Pairwise ι ⥤ OpensLeCover U`
-/
def pairwiseToOpensLeCoverMap :
∀ {V W : Pairwise ι}, (V ⟶ W) → (pairwiseToOpensLeCoverObj U V ⟶ pairwiseToOpensLeCoverObj U W)
| _, _, id_single _ => 𝟙 _
| _, _, id_pair _ _ => 𝟙 _
| _, _, left _ _ => homOfLE inf_le_left
| _, _, right _ _ => homOfLE inf_le_right
/-- The category of single and double intersections of the `U i` maps into the category
of open sets below some `U i`.
-/
@[simps]
def pairwiseToOpensLeCover : Pairwise ι ⥤ OpensLeCover U where
obj := pairwiseToOpensLeCoverObj U
map {V W} i := pairwiseToOpensLeCoverMap U i
instance (V : OpensLeCover U) : Nonempty (StructuredArrow V (pairwiseToOpensLeCover U)) :=
⟨@StructuredArrow.mk _ _ _ _ _ (single V.index) _ V.homToIndex⟩
-- This is a case bash: for each pair of types of objects in `Pairwise ι`,
-- we have to explicitly construct a zigzag.
/-- The diagram consisting of the `U i` and `U i ⊓ U j` is cofinal in the diagram
of all opens contained in some `U i`.
-/
instance : Functor.Final (pairwiseToOpensLeCover U) :=
⟨fun V =>
isConnected_of_zigzag fun A B => by
rcases A with ⟨⟨⟨⟩⟩, ⟨i⟩ | ⟨i, j⟩, a⟩ <;> rcases B with ⟨⟨⟨⟩⟩, ⟨i'⟩ | ⟨i', j'⟩, b⟩
· refine
⟨[{ left := ⟨⟨⟩⟩
right := pair i i'
hom := (le_inf a.le b.le).hom }, _], ?_, rfl⟩
exact
List.Chain.cons
(Or.inr
⟨{ left := 𝟙 _
right := left i i' }⟩)
(List.Chain.cons
(Or.inl
⟨{ left := 𝟙 _
right := right i i' }⟩)
List.Chain.nil)
· refine
⟨[{ left := ⟨⟨⟩⟩
right := pair i' i
hom := (le_inf (b.le.trans inf_le_left) a.le).hom },
{ left := ⟨⟨⟩⟩
right := single i'
hom := (b.le.trans inf_le_left).hom }, _], ?_, rfl⟩
exact
List.Chain.cons
(Or.inr
⟨{ left := 𝟙 _
right := right i' i }⟩)
(List.Chain.cons
(Or.inl
⟨{ left := 𝟙 _
right := left i' i }⟩)
(List.Chain.cons
(Or.inr
⟨{ left := 𝟙 _
right := left i' j' }⟩)
List.Chain.nil))
· refine
⟨[{ left := ⟨⟨⟩⟩
right := single i
hom := (a.le.trans inf_le_left).hom },
{ left := ⟨⟨⟩⟩
right := pair i i'
hom := (le_inf (a.le.trans inf_le_left) b.le).hom }, _], ?_, rfl⟩
exact
List.Chain.cons
(Or.inl
⟨{ left := 𝟙 _
right := left i j }⟩)
(List.Chain.cons
(Or.inr
⟨{ left := 𝟙 _
right := left i i' }⟩)
(List.Chain.cons
(Or.inl
⟨{ left := 𝟙 _
right := right i i' }⟩)
List.Chain.nil))
· refine
⟨[{ left := ⟨⟨⟩⟩
right := single i
hom := (a.le.trans inf_le_left).hom },
{ left := ⟨⟨⟩⟩
right := pair i i'
hom := (le_inf (a.le.trans inf_le_left) (b.le.trans inf_le_left)).hom },
{ left := ⟨⟨⟩⟩
right := single i'
hom := (b.le.trans inf_le_left).hom }, _], ?_, rfl⟩
exact
List.Chain.cons
(Or.inl
⟨{ left := 𝟙 _
right := left i j }⟩)
(List.Chain.cons
(Or.inr
⟨{ left := 𝟙 _
right := left i i' }⟩)
(List.Chain.cons
(Or.inl
⟨{ left := 𝟙 _
right := right i i' }⟩)
(List.Chain.cons
(Or.inr
⟨{ left := 𝟙 _
right := left i' j' }⟩)
List.Chain.nil)))⟩
/-- The diagram in `Opens X` indexed by pairwise intersections from `U` is isomorphic
(in fact, equal) to the diagram factored through `OpensLeCover U`.
-/
def pairwiseDiagramIso :
Pairwise.diagram U ≅ pairwiseToOpensLeCover U ⋙ fullSubcategoryInclusion _ where
hom := { app := by rintro (i | ⟨i, j⟩) <;> exact 𝟙 _ }
inv := { app := by rintro (i | ⟨i, j⟩) <;> exact 𝟙 _ }
/--
The cocone `Pairwise.cocone U` with cocone point `iSup U` over `Pairwise.diagram U` is isomorphic
to the cocone `opensLeCoverCocone U` (with the same cocone point)
after appropriate whiskering and postcomposition.
-/
def pairwiseCoconeIso :
(Pairwise.cocone U).op ≅
(Cones.postcomposeEquivalence (NatIso.op (pairwiseDiagramIso U : _) : _)).functor.obj
((opensLeCoverCocone U).op.whisker (pairwiseToOpensLeCover U).op) :=
Cones.ext (Iso.refl _) (by aesop_cat)
end SheafCondition
open SheafCondition
variable (F : Presheaf C X)
/-- The sheaf condition
in terms of a limit diagram over all `{ V : Opens X // ∃ i, V ≤ U i }`
is equivalent to the reformulation
in terms of a limit diagram over `U i` and `U i ⊓ U j`.
-/
theorem isSheafOpensLeCover_iff_isSheafPairwiseIntersections :
F.IsSheafOpensLeCover ↔ F.IsSheafPairwiseIntersections :=
forall₂_congr fun _ U =>
Equiv.nonempty_congr <|
calc
IsLimit (F.mapCone (opensLeCoverCocone U).op) ≃
IsLimit ((F.mapCone (opensLeCoverCocone U).op).whisker (pairwiseToOpensLeCover U).op) :=
(Functor.Initial.isLimitWhiskerEquiv (pairwiseToOpensLeCover U).op _).symm
_ ≃ IsLimit (F.mapCone ((opensLeCoverCocone U).op.whisker (pairwiseToOpensLeCover U).op)) :=
(IsLimit.equivIsoLimit F.mapConeWhisker.symm)
_ ≃
IsLimit
((Cones.postcomposeEquivalence _).functor.obj
(F.mapCone ((opensLeCoverCocone U).op.whisker (pairwiseToOpensLeCover U).op))) :=
(IsLimit.postcomposeHomEquiv _ _).symm
_ ≃
IsLimit
(F.mapCone
((Cones.postcomposeEquivalence _).functor.obj
((opensLeCoverCocone U).op.whisker (pairwiseToOpensLeCover U).op))) :=
(IsLimit.equivIsoLimit (Functor.mapConePostcomposeEquivalenceFunctor _).symm)
_ ≃ IsLimit (F.mapCone (Pairwise.cocone U).op) :=
IsLimit.equivIsoLimit ((Cones.functoriality _ _).mapIso (pairwiseCoconeIso U : _).symm)
/-- The sheaf condition in terms of an equalizer diagram is equivalent
to the reformulation in terms of a limit diagram over `U i` and `U i ⊓ U j`.
-/
theorem isSheaf_iff_isSheafPairwiseIntersections : F.IsSheaf ↔ F.IsSheafPairwiseIntersections := by
rw [isSheaf_iff_isSheafOpensLeCover,
isSheafOpensLeCover_iff_isSheafPairwiseIntersections]
/-- The sheaf condition in terms of an equalizer diagram is equivalent
to the reformulation in terms of the presheaf preserving the limit of the diagram
consisting of the `U i` and `U i ⊓ U j`.
-/
theorem isSheaf_iff_isSheafPreservesLimitPairwiseIntersections :
F.IsSheaf ↔ F.IsSheafPreservesLimitPairwiseIntersections := by
rw [isSheaf_iff_isSheafPairwiseIntersections]
constructor
· intro h ι U
exact ⟨preservesLimitOfPreservesLimitCone (Pairwise.coconeIsColimit U).op (h U).some⟩
· intro h ι U
haveI := (h U).some
exact ⟨PreservesLimit.preserves (Pairwise.coconeIsColimit U).op⟩
end TopCat.Presheaf
namespace TopCat.Sheaf
variable (F : X.Sheaf C) (U V : Opens X)
open CategoryTheory.Limits
/-- For a sheaf `F`, `F(U ⊔ V)` is the pullback of `F(U) ⟶ F(U ⊓ V)` and `F(V) ⟶ F(U ⊓ V)`.
This is the pullback cone. -/
def interUnionPullbackCone :
PullbackCone (F.1.map (homOfLE inf_le_left : U ⊓ V ⟶ _).op)
(F.1.map (homOfLE inf_le_right).op) :=
PullbackCone.mk (F.1.map (homOfLE le_sup_left).op) (F.1.map (homOfLE le_sup_right).op) <| by
rw [← F.1.map_comp, ← F.1.map_comp]
congr 1
@[simp]
theorem interUnionPullbackCone_pt : (interUnionPullbackCone F U V).pt = F.1.obj (op <| U ⊔ V) :=
rfl
@[simp]
theorem interUnionPullbackCone_fst :
(interUnionPullbackCone F U V).fst = F.1.map (homOfLE le_sup_left).op :=
rfl
@[simp]
theorem interUnionPullbackCone_snd :
(interUnionPullbackCone F U V).snd = F.1.map (homOfLE le_sup_right).op :=
rfl
variable
(s :
PullbackCone (F.1.map (homOfLE inf_le_left : U ⊓ V ⟶ _).op) (F.1.map (homOfLE inf_le_right).op))
/-- (Implementation).
Every cone over `F(U) ⟶ F(U ⊓ V)` and `F(V) ⟶ F(U ⊓ V)` factors through `F(U ⊔ V)`.
-/
def interUnionPullbackConeLift : s.pt ⟶ F.1.obj (op (U ⊔ V)) := by
let ι : ULift.{w} WalkingPair → Opens X := fun j => WalkingPair.casesOn j.down U V
have hι : U ⊔ V = iSup ι := by
ext
rw [Opens.coe_iSup, Set.mem_iUnion]
constructor
· rintro (h | h)
exacts [⟨⟨WalkingPair.left⟩, h⟩, ⟨⟨WalkingPair.right⟩, h⟩]
· rintro ⟨⟨_ | _⟩, h⟩
exacts [Or.inl h, Or.inr h]
refine
(F.presheaf.isSheaf_iff_isSheafPairwiseIntersections.mp F.2 ι).some.lift
⟨s.pt,
{ app := ?_
naturality := ?_ }⟩ ≫
F.1.map (eqToHom hι).op
· rintro ((_ | _) | (_ | _))
exacts [s.fst, s.snd, s.fst ≫ F.1.map (homOfLE inf_le_left).op,
s.snd ≫ F.1.map (homOfLE inf_le_left).op]
rintro ⟨i⟩ ⟨j⟩ f
let g : j ⟶ i := f.unop
have : f = g.op := rfl
clear_value g
subst this
rcases i with (⟨⟨_ | _⟩⟩ | ⟨⟨_ | _⟩, ⟨_⟩⟩) <;>
rcases j with (⟨⟨_ | _⟩⟩ | ⟨⟨_ | _⟩, ⟨_⟩⟩) <;>
rcases g with ⟨⟩ <;>
dsimp [Pairwise.diagram] <;>
simp only [Category.id_comp, s.condition, CategoryTheory.Functor.map_id, Category.comp_id]
rw [← cancel_mono (F.1.map (eqToHom <| inf_comm U V : U ⊓ V ⟶ _).op), Category.assoc,
Category.assoc, ← F.1.map_comp, ← F.1.map_comp]
exact s.condition.symm
theorem interUnionPullbackConeLift_left :
interUnionPullbackConeLift F U V s ≫ F.1.map (homOfLE le_sup_left).op = s.fst := by
erw [Category.assoc]
simp_rw [← F.1.map_comp]
exact
(F.presheaf.isSheaf_iff_isSheafPairwiseIntersections.mp F.2 _).some.fac _ <|
op <| Pairwise.single <| ULift.up WalkingPair.left
theorem interUnionPullbackConeLift_right :
interUnionPullbackConeLift F U V s ≫ F.1.map (homOfLE le_sup_right).op = s.snd := by
erw [Category.assoc]
simp_rw [← F.1.map_comp]
exact
(F.presheaf.isSheaf_iff_isSheafPairwiseIntersections.mp F.2 _).some.fac _ <|
op <| Pairwise.single <| ULift.up WalkingPair.right
/-- For a sheaf `F`, `F(U ⊔ V)` is the pullback of `F(U) ⟶ F(U ⊓ V)` and `F(V) ⟶ F(U ⊓ V)`. -/
def isLimitPullbackCone : IsLimit (interUnionPullbackCone F U V) := by
let ι : ULift.{w} WalkingPair → Opens X := fun ⟨j⟩ => WalkingPair.casesOn j U V
have hι : U ⊔ V = iSup ι := by
ext
rw [Opens.coe_iSup, Set.mem_iUnion]
constructor
· rintro (h | h)
exacts [⟨⟨WalkingPair.left⟩, h⟩, ⟨⟨WalkingPair.right⟩, h⟩]
· rintro ⟨⟨_ | _⟩, h⟩
exacts [Or.inl h, Or.inr h]
apply PullbackCone.isLimitAux'
intro s
use interUnionPullbackConeLift F U V s
refine ⟨?_, ?_, ?_⟩
· apply interUnionPullbackConeLift_left
· apply interUnionPullbackConeLift_right
· intro m h₁ h₂
rw [← cancel_mono (F.1.map (eqToHom hι.symm).op)]
apply (F.presheaf.isSheaf_iff_isSheafPairwiseIntersections.mp F.2 ι).some.hom_ext
rintro ((_ | _) | (_ | _)) <;>
rw [Category.assoc, Category.assoc]
· erw [← F.1.map_comp]
convert h₁
apply interUnionPullbackConeLift_left
· erw [← F.1.map_comp]
convert h₂
apply interUnionPullbackConeLift_right
all_goals
dsimp only [Functor.op, Pairwise.cocone_ι_app, Functor.mapCone_π_app, Cocone.op,
Pairwise.coconeιApp, unop_op, op_comp, NatTrans.op]
simp_rw [F.1.map_comp, ← Category.assoc]
congr 1
simp_rw [Category.assoc, ← F.1.map_comp]
· convert h₁
apply interUnionPullbackConeLift_left
· convert h₂
apply interUnionPullbackConeLift_right
/-- If `U, V` are disjoint, then `F(U ⊔ V) = F(U) × F(V)`. -/
def isProductOfDisjoint (h : U ⊓ V = ⊥) :
IsLimit
(BinaryFan.mk (F.1.map (homOfLE le_sup_left : _ ⟶ U ⊔ V).op)
(F.1.map (homOfLE le_sup_right : _ ⟶ U ⊔ V).op)) :=
isProductOfIsTerminalIsPullback _ _ _ _ (F.isTerminalOfEqEmpty h) (isLimitPullbackCone F U V)
/-- `F(U ⊔ V)` is isomorphic to the `eq_locus` of the two maps `F(U) × F(V) ⟶ F(U ⊓ V)`. -/
def objSupIsoProdEqLocus {X : TopCat} (F : X.Sheaf CommRingCat) (U V : Opens X) :
F.1.obj (op <| U ⊔ V) ≅ CommRingCat.of <|
-- Porting note: Lean 3 is able to figure out the ring homomorphism automatically
RingHom.eqLocus
(RingHom.comp (F.val.map (homOfLE inf_le_left : U ⊓ V ⟶ U).op)
(RingHom.fst (F.val.obj <| op U) (F.val.obj <| op V)))
(RingHom.comp (F.val.map (homOfLE inf_le_right : U ⊓ V ⟶ V).op)
(RingHom.snd (F.val.obj <| op U) (F.val.obj <| op V))) :=
(F.isLimitPullbackCone U V).conePointUniqueUpToIso (CommRingCat.pullbackConeIsLimit _ _)
theorem objSupIsoProdEqLocus_hom_fst {X : TopCat} (F : X.Sheaf CommRingCat) (U V : Opens X) (x) :
((F.objSupIsoProdEqLocus U V).hom x).1.fst = F.1.map (homOfLE le_sup_left).op x :=
ConcreteCategory.congr_hom
((F.isLimitPullbackCone U V).conePointUniqueUpToIso_hom_comp
(CommRingCat.pullbackConeIsLimit _ _) WalkingCospan.left)
x
theorem objSupIsoProdEqLocus_hom_snd {X : TopCat} (F : X.Sheaf CommRingCat) (U V : Opens X) (x) :
((F.objSupIsoProdEqLocus U V).hom x).1.snd = F.1.map (homOfLE le_sup_right).op x :=
ConcreteCategory.congr_hom
((F.isLimitPullbackCone U V).conePointUniqueUpToIso_hom_comp
(CommRingCat.pullbackConeIsLimit _ _) WalkingCospan.right)
x
theorem objSupIsoProdEqLocus_inv_fst {X : TopCat} (F : X.Sheaf CommRingCat) (U V : Opens X) (x) :
F.1.map (homOfLE le_sup_left).op ((F.objSupIsoProdEqLocus U V).inv x) = x.1.1 :=
ConcreteCategory.congr_hom
((F.isLimitPullbackCone U V).conePointUniqueUpToIso_inv_comp
(CommRingCat.pullbackConeIsLimit _ _) WalkingCospan.left)
x
theorem objSupIsoProdEqLocus_inv_snd {X : TopCat} (F : X.Sheaf CommRingCat) (U V : Opens X) (x) :
F.1.map (homOfLE le_sup_right).op ((F.objSupIsoProdEqLocus U V).inv x) = x.1.2 :=
ConcreteCategory.congr_hom
((F.isLimitPullbackCone U V).conePointUniqueUpToIso_inv_comp
(CommRingCat.pullbackConeIsLimit _ _) WalkingCospan.right)
x
end TopCat.Sheaf
|
Topology\Sheaves\SheafCondition\Sites.lean | /-
Copyright (c) 2021 Justus Springer. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Justus Springer
-/
import Mathlib.CategoryTheory.Sites.Spaces
import Mathlib.Topology.Sheaves.Sheaf
import Mathlib.CategoryTheory.Sites.DenseSubsite
/-!
# Coverings and sieves; from sheaves on sites and sheaves on spaces
In this file, we connect coverings in a topological space to sieves in the associated Grothendieck
topology, in preparation of connecting the sheaf condition on sites to the various sheaf conditions
on spaces.
We also specialize results about sheaves on sites to sheaves on spaces; we show that the inclusion
functor from a topological basis to `TopologicalSpace.Opens` is cover dense, that open maps
induce cover preserving functors, and that open embeddings induce continuous functors.
-/
noncomputable section
universe w v u
open CategoryTheory TopologicalSpace
namespace TopCat.Presheaf
variable {X : TopCat.{w}}
/-- Given a presieve `R` on `U`, we obtain a covering family of open sets in `X`, by taking as index
type the type of dependent pairs `(V, f)`, where `f : V ⟶ U` is in `R`.
-/
def coveringOfPresieve (U : Opens X) (R : Presieve U) : (ΣV, { f : V ⟶ U // R f }) → Opens X :=
fun f => f.1
@[simp]
theorem coveringOfPresieve_apply (U : Opens X) (R : Presieve U) (f : ΣV, { f : V ⟶ U // R f }) :
coveringOfPresieve U R f = f.1 := rfl
namespace coveringOfPresieve
variable (U : Opens X) (R : Presieve U)
/-- If `R` is a presieve in the grothendieck topology on `Opens X`, the covering family associated
to `R` really is _covering_, i.e. the union of all open sets equals `U`.
-/
theorem iSup_eq_of_mem_grothendieck (hR : Sieve.generate R ∈ Opens.grothendieckTopology X U) :
iSup (coveringOfPresieve U R) = U := by
apply le_antisymm
· refine iSup_le ?_
intro f
exact f.2.1.le
intro x hxU
rw [Opens.coe_iSup, Set.mem_iUnion]
obtain ⟨V, iVU, ⟨W, iVW, iWU, hiWU, -⟩, hxV⟩ := hR x hxU
exact ⟨⟨W, ⟨iWU, hiWU⟩⟩, iVW.le hxV⟩
end coveringOfPresieve
/-- Given a family of opens `U : ι → Opens X` and any open `Y : Opens X`, we obtain a presieve
on `Y` by declaring that a morphism `f : V ⟶ Y` is a member of the presieve if and only if
there exists an index `i : ι` such that `V = U i`.
-/
def presieveOfCoveringAux {ι : Type v} (U : ι → Opens X) (Y : Opens X) : Presieve Y :=
fun V _ => ∃ i, V = U i
/-- Take `Y` to be `iSup U` and obtain a presieve over `iSup U`. -/
def presieveOfCovering {ι : Type v} (U : ι → Opens X) : Presieve (iSup U) :=
presieveOfCoveringAux U (iSup U)
/-- Given a presieve `R` on `Y`, if we take its associated family of opens via
`coveringOfPresieve` (which may not cover `Y` if `R` is not covering), and take
the presieve on `Y` associated to the family of opens via `presieveOfCoveringAux`,
then we get back the original presieve `R`. -/
@[simp]
theorem covering_presieve_eq_self {Y : Opens X} (R : Presieve Y) :
presieveOfCoveringAux (coveringOfPresieve Y R) Y = R := by
funext Z
ext f
exact ⟨fun ⟨⟨_, f', h⟩, rfl⟩ => by rwa [Subsingleton.elim f f'], fun h => ⟨⟨Z, f, h⟩, rfl⟩⟩
namespace presieveOfCovering
variable {ι : Type v} (U : ι → Opens X)
/-- The sieve generated by `presieveOfCovering U` is a member of the grothendieck topology.
-/
theorem mem_grothendieckTopology :
Sieve.generate (presieveOfCovering U) ∈ Opens.grothendieckTopology X (iSup U) := by
intro x hx
obtain ⟨i, hxi⟩ := Opens.mem_iSup.mp hx
exact ⟨U i, Opens.leSupr U i, ⟨U i, 𝟙 _, Opens.leSupr U i, ⟨i, rfl⟩, Category.id_comp _⟩, hxi⟩
/-- An index `i : ι` can be turned into a dependent pair `(V, f)`, where `V` is an open set and
`f : V ⟶ iSup U` is a member of `presieveOfCovering U f`.
-/
def homOfIndex (i : ι) : ΣV, { f : V ⟶ iSup U // presieveOfCovering U f } :=
⟨U i, Opens.leSupr U i, i, rfl⟩
/-- By using the axiom of choice, a dependent pair `(V, f)` where `f : V ⟶ iSup U` is a member of
`presieveOfCovering U f` can be turned into an index `i : ι`, such that `V = U i`.
-/
def indexOfHom (f : ΣV, { f : V ⟶ iSup U // presieveOfCovering U f }) : ι :=
f.2.2.choose
theorem indexOfHom_spec (f : ΣV, { f : V ⟶ iSup U // presieveOfCovering U f }) :
f.1 = U (indexOfHom U f) :=
f.2.2.choose_spec
end presieveOfCovering
end TopCat.Presheaf
namespace TopCat.Opens
variable {X : TopCat} {ι : Type*}
theorem coverDense_iff_isBasis [Category ι] (B : ι ⥤ Opens X) :
B.IsCoverDense (Opens.grothendieckTopology X) ↔ Opens.IsBasis (Set.range B.obj) := by
rw [Opens.isBasis_iff_nbhd]
constructor
· intro hd U x hx; rcases hd.1 U x hx with ⟨V, f, ⟨i, f₁, f₂, _⟩, hV⟩
exact ⟨B.obj i, ⟨i, rfl⟩, f₁.le hV, f₂.le⟩
intro hb; constructor; intro U x hx; rcases hb hx with ⟨_, ⟨i, rfl⟩, hx, hi⟩
exact ⟨B.obj i, ⟨⟨hi⟩⟩, ⟨⟨i, 𝟙 _, ⟨⟨hi⟩⟩, rfl⟩⟩, hx⟩
theorem coverDense_inducedFunctor {B : ι → Opens X} (h : Opens.IsBasis (Set.range B)) :
(inducedFunctor B).IsCoverDense (Opens.grothendieckTopology X) :=
(coverDense_iff_isBasis _).2 h
end TopCat.Opens
section OpenEmbedding
open TopCat.Presheaf Opposite
variable {C : Type u} [Category.{v} C]
variable {X Y : TopCat.{w}} {f : X ⟶ Y} {F : Y.Presheaf C}
theorem OpenEmbedding.compatiblePreserving (hf : OpenEmbedding f) :
CompatiblePreserving (Opens.grothendieckTopology Y) hf.isOpenMap.functor := by
haveI : Mono f := (TopCat.mono_iff_injective f).mpr hf.inj
apply compatiblePreservingOfDownwardsClosed
intro U V i
refine ⟨(Opens.map f).obj V, eqToIso <| Opens.ext <| Set.image_preimage_eq_of_subset fun x h ↦ ?_⟩
obtain ⟨_, _, rfl⟩ := i.le h
exact ⟨_, rfl⟩
theorem IsOpenMap.coverPreserving (hf : IsOpenMap f) :
CoverPreserving (Opens.grothendieckTopology X) (Opens.grothendieckTopology Y) hf.functor := by
constructor
rintro U S hU _ ⟨x, hx, rfl⟩
obtain ⟨V, i, hV, hxV⟩ := hU x hx
exact ⟨_, hf.functor.map i, ⟨_, i, 𝟙 _, hV, rfl⟩, Set.mem_image_of_mem f hxV⟩
lemma OpenEmbedding.functor_isContinuous (h : OpenEmbedding f) :
h.isOpenMap.functor.IsContinuous (Opens.grothendieckTopology X)
(Opens.grothendieckTopology Y) := by
apply Functor.isContinuous_of_coverPreserving
· exact h.compatiblePreserving
· exact h.isOpenMap.coverPreserving
theorem TopCat.Presheaf.isSheaf_of_openEmbedding (h : OpenEmbedding f) (hF : F.IsSheaf) :
IsSheaf (h.isOpenMap.functor.op ⋙ F) := by
have := h.functor_isContinuous
exact Functor.op_comp_isSheaf _ _ _ ⟨_, hF⟩
variable (f)
instance : RepresentablyFlat (Opens.map f) := by
constructor
intro U
refine @IsCofiltered.mk _ _ ?_ ?_
· constructor
· intro V W
exact ⟨⟨⟨PUnit.unit⟩, V.right ⊓ W.right, homOfLE <| le_inf V.hom.le W.hom.le⟩,
StructuredArrow.homMk (homOfLE inf_le_left),
StructuredArrow.homMk (homOfLE inf_le_right), trivial⟩
· exact fun _ _ _ _ ↦ ⟨_, 𝟙 _, by simp [eq_iff_true_of_subsingleton]⟩
· exact ⟨StructuredArrow.mk <| show U ⟶ (Opens.map f).obj ⊤ from homOfLE le_top⟩
theorem compatiblePreserving_opens_map :
CompatiblePreserving (Opens.grothendieckTopology X) (Opens.map f) :=
compatiblePreservingOfFlat _ _
theorem coverPreserving_opens_map : CoverPreserving (Opens.grothendieckTopology Y)
(Opens.grothendieckTopology X) (Opens.map f) := by
constructor
intro U S hS x hx
obtain ⟨V, i, hi, hxV⟩ := hS (f x) hx
exact ⟨_, (Opens.map f).map i, ⟨_, _, 𝟙 _, hi, Subsingleton.elim _ _⟩, hxV⟩
instance : (Opens.map f).IsContinuous (Opens.grothendieckTopology Y)
(Opens.grothendieckTopology X) := by
apply Functor.isContinuous_of_coverPreserving
· exact compatiblePreserving_opens_map f
· exact coverPreserving_opens_map f
end OpenEmbedding
namespace TopCat.Sheaf
open TopCat Opposite
variable {C : Type u} [Category.{v} C]
variable {X : TopCat.{w}} {ι : Type*} {B : ι → Opens X}
variable (F : X.Presheaf C) (F' : Sheaf C X)
/-- The empty component of a sheaf is terminal. -/
def isTerminalOfEmpty (F : Sheaf C X) : Limits.IsTerminal (F.val.obj (op ⊥)) :=
F.isTerminalOfBotCover ⊥ (fun _ h => h.elim)
/-- A variant of `isTerminalOfEmpty` that is easier to `apply`. -/
def isTerminalOfEqEmpty (F : X.Sheaf C) {U : Opens X} (h : U = ⊥) :
Limits.IsTerminal (F.val.obj (op U)) := by
convert F.isTerminalOfEmpty
/-- If a family `B` of open sets forms a basis of the topology on `X`, and if `F'`
is a sheaf on `X`, then a homomorphism between a presheaf `F` on `X` and `F'`
is equivalent to a homomorphism between their restrictions to the indexing type
`ι` of `B`, with the induced category structure on `ι`. -/
def restrictHomEquivHom (h : Opens.IsBasis (Set.range B)) :
((inducedFunctor B).op ⋙ F ⟶ (inducedFunctor B).op ⋙ F'.1) ≃ (F ⟶ F'.1) :=
@Functor.IsCoverDense.restrictHomEquivHom _ _ _ _ _ _ _ _
(Opens.coverDense_inducedFunctor h) _ F F'
@[simp]
theorem extend_hom_app (h : Opens.IsBasis (Set.range B))
(α : (inducedFunctor B).op ⋙ F ⟶ (inducedFunctor B).op ⋙ F'.1) (i : ι) :
(restrictHomEquivHom F F' h α).app (op (B i)) = α.app (op i) := by
nth_rw 2 [← (restrictHomEquivHom F F' h).left_inv α]
rfl
theorem hom_ext (h : Opens.IsBasis (Set.range B))
{α β : F ⟶ F'.1} (he : ∀ i, α.app (op (B i)) = β.app (op (B i))) : α = β := by
apply (restrictHomEquivHom F F' h).symm.injective
ext i
exact he i.unop
end TopCat.Sheaf
|
Topology\Sheaves\SheafCondition\UniqueGluing.lean | /-
Copyright (c) 2021 Justus Springer. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Justus Springer
-/
import Mathlib.Topology.Sheaves.Forget
import Mathlib.Topology.Sheaves.SheafCondition.PairwiseIntersections
import Mathlib.CategoryTheory.Limits.Shapes.Types
/-!
# The sheaf condition in terms of unique gluings
We provide an alternative formulation of the sheaf condition in terms of unique gluings.
We work with sheaves valued in a concrete category `C` admitting all limits, whose forgetful
functor `C ⥤ Type` preserves limits and reflects isomorphisms. The usual categories of algebraic
structures, such as `MonCat`, `AddCommGrp`, `RingCat`, `CommRingCat` etc. are all examples of
this kind of category.
A presheaf `F : Presheaf C X` satisfies the sheaf condition if and only if, for every
compatible family of sections `sf : Π i : ι, F.obj (op (U i))`, there exists a unique gluing
`s : F.obj (op (iSup U))`.
Here, the family `sf` is called compatible, if for all `i j : ι`, the restrictions of `sf i`
and `sf j` to `U i ⊓ U j` agree. A section `s : F.obj (op (iSup U))` is a gluing for the
family `sf`, if `s` restricts to `sf i` on `U i` for all `i : ι`
We show that the sheaf condition in terms of unique gluings is equivalent to the definition
in terms of pairwise intersections. Our approach is as follows: First, we show them to be equivalent
for `Type`-valued presheaves. Then we use that composing a presheaf with a limit-preserving and
isomorphism-reflecting functor leaves the sheaf condition invariant, as shown in
`Mathlib/Topology/Sheaves/Forget.lean`.
-/
noncomputable section
open TopCat TopCat.Presheaf CategoryTheory CategoryTheory.Limits
TopologicalSpace TopologicalSpace.Opens Opposite
universe v u x
variable {C : Type u} [Category.{v} C] [ConcreteCategory.{v} C]
namespace TopCat
namespace Presheaf
section
attribute [local instance] ConcreteCategory.hasCoeToSort ConcreteCategory.instFunLike
variable {X : TopCat.{x}} (F : Presheaf C X) {ι : Type x} (U : ι → Opens X)
/-- A family of sections `sf` is compatible, if the restrictions of `sf i` and `sf j` to `U i ⊓ U j`
agree, for all `i` and `j`
-/
def IsCompatible (sf : ∀ i : ι, F.obj (op (U i))) : Prop :=
∀ i j : ι, F.map (infLELeft (U i) (U j)).op (sf i) = F.map (infLERight (U i) (U j)).op (sf j)
/-- A section `s` is a gluing for a family of sections `sf` if it restricts to `sf i` on `U i`,
for all `i`
-/
def IsGluing (sf : ∀ i : ι, F.obj (op (U i))) (s : F.obj (op (iSup U))) : Prop :=
∀ i : ι, F.map (Opens.leSupr U i).op s = sf i
/--
The sheaf condition in terms of unique gluings. A presheaf `F : Presheaf C X` satisfies this sheaf
condition if and only if, for every compatible family of sections `sf : Π i : ι, F.obj (op (U i))`,
there exists a unique gluing `s : F.obj (op (iSup U))`.
We prove this to be equivalent to the usual one below in
`TopCat.Presheaf.isSheaf_iff_isSheafUniqueGluing`
-/
def IsSheafUniqueGluing : Prop :=
∀ ⦃ι : Type x⦄ (U : ι → Opens X) (sf : ∀ i : ι, F.obj (op (U i))),
IsCompatible F U sf → ∃! s : F.obj (op (iSup U)), IsGluing F U sf s
end
section TypeValued
variable {X : TopCat.{x}} {F : Presheaf (Type u) X} {ι : Type x} {U : ι → Opens X}
/-- Given sections over a family of open sets, extend it to include
sections over pairwise intersections of the open sets. -/
def objPairwiseOfFamily (sf : ∀ i, F.obj (op (U i))) :
∀ i, ((Pairwise.diagram U).op ⋙ F).obj i
| ⟨Pairwise.single i⟩ => sf i
| ⟨Pairwise.pair i j⟩ => F.map (infLELeft (U i) (U j)).op (sf i)
/-- Given a compatible family of sections over open sets, extend it to a
section of the functor `(Pairwise.diagram U).op ⋙ F`. -/
def IsCompatible.sectionPairwise {sf} (h : IsCompatible F U sf) :
((Pairwise.diagram U).op ⋙ F).sections := by
refine ⟨objPairwiseOfFamily sf, ?_⟩
let G := (Pairwise.diagram U).op ⋙ F
rintro (i|⟨i,j⟩) (i'|⟨i',j'⟩) (_|_|_|_)
· exact congr_fun (G.map_id <| op <| Pairwise.single i) _
· rfl
· exact (h i' i).symm
· exact congr_fun (G.map_id <| op <| Pairwise.pair i j) _
theorem isGluing_iff_pairwise {sf s} : IsGluing F U sf s ↔
∀ i, (F.mapCone (Pairwise.cocone U).op).π.app i s = objPairwiseOfFamily sf i := by
refine ⟨fun h ↦ ?_, fun h i ↦ h (op <| Pairwise.single i)⟩
rintro (i|⟨i,j⟩)
· exact h i
· rw [← (F.mapCone (Pairwise.cocone U).op).w (op <| Pairwise.Hom.left i j)]
exact congr_arg _ (h i)
variable (F)
/-- For type-valued presheaves, the sheaf condition in terms of unique gluings is equivalent to the
usual sheaf condition.
-/
theorem isSheaf_iff_isSheafUniqueGluing_types : F.IsSheaf ↔ F.IsSheafUniqueGluing := by
simp_rw [isSheaf_iff_isSheafPairwiseIntersections, IsSheafPairwiseIntersections,
Types.isLimit_iff, IsSheafUniqueGluing, isGluing_iff_pairwise]
refine forall₂_congr fun ι U ↦ ⟨fun h sf cpt ↦ ?_, fun h s hs ↦ ?_⟩
· exact h _ cpt.sectionPairwise.prop
· specialize h (fun i ↦ s <| op <| Pairwise.single i) fun i j ↦
(hs <| op <| Pairwise.Hom.left i j).trans (hs <| op <| Pairwise.Hom.right i j).symm
convert h; ext (i|⟨i,j⟩)
· rfl
· exact (hs <| op <| Pairwise.Hom.left i j).symm
/-- The usual sheaf condition can be obtained from the sheaf condition
in terms of unique gluings.
-/
theorem isSheaf_of_isSheafUniqueGluing_types (Fsh : F.IsSheafUniqueGluing) : F.IsSheaf :=
(isSheaf_iff_isSheafUniqueGluing_types F).mpr Fsh
end TypeValued
section
attribute [local instance] ConcreteCategory.hasCoeToSort ConcreteCategory.instFunLike
variable [HasLimits C] [(forget C).ReflectsIsomorphisms] [PreservesLimits (forget C)]
variable {X : TopCat.{v}} (F : Presheaf C X) {ι : Type v} (U : ι → Opens X)
/-- For presheaves valued in a concrete category, whose forgetful functor reflects isomorphisms and
preserves limits, the sheaf condition in terms of unique gluings is equivalent to the usual one.
-/
theorem isSheaf_iff_isSheafUniqueGluing : F.IsSheaf ↔ F.IsSheafUniqueGluing :=
Iff.trans (isSheaf_iff_isSheaf_comp (forget C) F)
(isSheaf_iff_isSheafUniqueGluing_types (F ⋙ forget C))
end
end Presheaf
namespace Sheaf
open Presheaf
open CategoryTheory
section
attribute [local instance] ConcreteCategory.hasCoeToSort ConcreteCategory.instFunLike
variable [HasLimits C] [(ConcreteCategory.forget (C := C)).ReflectsIsomorphisms]
variable [PreservesLimits (ConcreteCategory.forget (C := C))]
variable {X : TopCat.{v}} (F : Sheaf C X) {ι : Type v} (U : ι → Opens X)
/-- A more convenient way of obtaining a unique gluing of sections for a sheaf.
-/
theorem existsUnique_gluing (sf : ∀ i : ι, F.1.obj (op (U i))) (h : IsCompatible F.1 U sf) :
∃! s : F.1.obj (op (iSup U)), IsGluing F.1 U sf s :=
(isSheaf_iff_isSheafUniqueGluing F.1).mp F.cond U sf h
/-- In this version of the lemma, the inclusion homs `iUV` can be specified directly by the user,
which can be more convenient in practice.
-/
theorem existsUnique_gluing' (V : Opens X) (iUV : ∀ i : ι, U i ⟶ V) (hcover : V ≤ iSup U)
(sf : ∀ i : ι, F.1.obj (op (U i))) (h : IsCompatible F.1 U sf) :
∃! s : F.1.obj (op V), ∀ i : ι, F.1.map (iUV i).op s = sf i := by
have V_eq_supr_U : V = iSup U := le_antisymm hcover (iSup_le fun i => (iUV i).le)
obtain ⟨gl, gl_spec, gl_uniq⟩ := F.existsUnique_gluing U sf h
refine ⟨F.1.map (eqToHom V_eq_supr_U).op gl, ?_, ?_⟩
· intro i
rw [← comp_apply, ← F.1.map_comp]
exact gl_spec i
· intro gl' gl'_spec
convert congr_arg _ (gl_uniq (F.1.map (eqToHom V_eq_supr_U.symm).op gl') fun i => _) <;>
rw [← comp_apply, ← F.1.map_comp]
· rw [eqToHom_op, eqToHom_op, eqToHom_trans, eqToHom_refl, F.1.map_id, id_apply]
· convert gl'_spec i
@[ext]
theorem eq_of_locally_eq (s t : F.1.obj (op (iSup U)))
(h : ∀ i, F.1.map (Opens.leSupr U i).op s = F.1.map (Opens.leSupr U i).op t) : s = t := by
let sf : ∀ i : ι, F.1.obj (op (U i)) := fun i => F.1.map (Opens.leSupr U i).op s
have sf_compatible : IsCompatible _ U sf := by
intro i j
simp_rw [sf, ← comp_apply, ← F.1.map_comp]
rfl
obtain ⟨gl, -, gl_uniq⟩ := F.existsUnique_gluing U sf sf_compatible
trans gl
· apply gl_uniq
intro i
rfl
· symm
apply gl_uniq
intro i
rw [← h]
/-- In this version of the lemma, the inclusion homs `iUV` can be specified directly by the user,
which can be more convenient in practice.
-/
theorem eq_of_locally_eq' (V : Opens X) (iUV : ∀ i : ι, U i ⟶ V) (hcover : V ≤ iSup U)
(s t : F.1.obj (op V)) (h : ∀ i, F.1.map (iUV i).op s = F.1.map (iUV i).op t) : s = t := by
have V_eq_supr_U : V = iSup U := le_antisymm hcover (iSup_le fun i => (iUV i).le)
suffices F.1.map (eqToHom V_eq_supr_U.symm).op s = F.1.map (eqToHom V_eq_supr_U.symm).op t by
convert congr_arg (F.1.map (eqToHom V_eq_supr_U).op) this <;>
rw [← comp_apply, ← F.1.map_comp, eqToHom_op, eqToHom_op, eqToHom_trans, eqToHom_refl,
F.1.map_id, id_apply]
apply eq_of_locally_eq
intro i
rw [← comp_apply, ← comp_apply, ← F.1.map_comp]
convert h i
theorem eq_of_locally_eq₂ {U₁ U₂ V : Opens X} (i₁ : U₁ ⟶ V) (i₂ : U₂ ⟶ V) (hcover : V ≤ U₁ ⊔ U₂)
(s t : F.1.obj (op V)) (h₁ : F.1.map i₁.op s = F.1.map i₁.op t)
(h₂ : F.1.map i₂.op s = F.1.map i₂.op t) : s = t := by
classical
fapply F.eq_of_locally_eq' fun t : ULift Bool => if t.1 then U₁ else U₂
· exact fun i => if h : i.1 then eqToHom (if_pos h) ≫ i₁ else eqToHom (if_neg h) ≫ i₂
· refine le_trans hcover ?_
rw [sup_le_iff]
constructor
· convert le_iSup (fun t : ULift Bool => if t.1 then U₁ else U₂) (ULift.up true)
· convert le_iSup (fun t : ULift Bool => if t.1 then U₁ else U₂) (ULift.up false)
· rintro ⟨_ | _⟩
any_goals exact h₁
any_goals exact h₂
end
theorem objSupIsoProdEqLocus_inv_eq_iff {X : TopCat.{u}} (F : X.Sheaf CommRingCat.{u})
{U V W UW VW : Opens X} (e : W ≤ U ⊔ V) (x) (y : F.1.obj (op W))
(h₁ : UW = U ⊓ W) (h₂ : VW = V ⊓ W) :
F.1.map (homOfLE e).op ((F.objSupIsoProdEqLocus U V).inv x) = y ↔
F.1.map (homOfLE (h₁ ▸ inf_le_left : UW ≤ U)).op x.1.1 =
F.1.map (homOfLE <| h₁ ▸ inf_le_right).op y ∧
F.1.map (homOfLE (h₂ ▸ inf_le_left : VW ≤ V)).op x.1.2 =
F.1.map (homOfLE <| h₂ ▸ inf_le_right).op y := by
subst h₁ h₂
constructor
· rintro rfl
rw [← TopCat.Sheaf.objSupIsoProdEqLocus_inv_fst, ← TopCat.Sheaf.objSupIsoProdEqLocus_inv_snd]
-- `simp` doesn't see through the type equality of objects in `CommRingCat`, so use `rw` #8386
repeat rw [← comp_apply]
simp only [← Functor.map_comp, ← op_comp, Category.assoc, homOfLE_comp, and_self]
· rintro ⟨e₁, e₂⟩
refine F.eq_of_locally_eq₂
(homOfLE (inf_le_right : U ⊓ W ≤ W)) (homOfLE (inf_le_right : V ⊓ W ≤ W)) ?_ _ _ ?_ ?_
· rw [← inf_sup_right]
exact le_inf e le_rfl
· rw [← e₁, ← TopCat.Sheaf.objSupIsoProdEqLocus_inv_fst]
-- `simp` doesn't see through the type equality of objects in `CommRingCat`, so use `rw` #8386
repeat rw [← comp_apply]
simp only [← Functor.map_comp, ← op_comp, Category.assoc, homOfLE_comp]
· rw [← e₂, ← TopCat.Sheaf.objSupIsoProdEqLocus_inv_snd]
-- `simp` doesn't see through the type equality of objects in `CommRingCat`, so use `rw` #8386
repeat rw [← comp_apply]
simp only [← Functor.map_comp, ← op_comp, Category.assoc, homOfLE_comp]
end Sheaf
end TopCat
|
Topology\Spectral\Hom.lean | /-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Topology.ContinuousFunction.Basic
/-!
# Spectral maps
This file defines spectral maps. A map is spectral when it's continuous and the preimage of a
compact open set is compact open.
## Main declarations
* `IsSpectralMap`: Predicate for a map to be spectral.
* `SpectralMap`: Bundled spectral maps.
* `SpectralMapClass`: Typeclass for a type to be a type of spectral maps.
## TODO
Once we have `SpectralSpace`, `IsSpectralMap` should move to `Mathlib.Topology.Spectral.Basic`.
-/
open Function OrderDual
variable {F α β γ δ : Type*}
section Unbundled
variable [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ] {f : α → β} {s : Set β}
/-- A function between topological spaces is spectral if it is continuous and the preimage of every
compact open set is compact open. -/
structure IsSpectralMap (f : α → β) extends Continuous f : Prop where
/-- A function between topological spaces is spectral if it is continuous and the preimage of
every compact open set is compact open. -/
isCompact_preimage_of_isOpen ⦃s : Set β⦄ : IsOpen s → IsCompact s → IsCompact (f ⁻¹' s)
theorem IsCompact.preimage_of_isOpen (hf : IsSpectralMap f) (h₀ : IsCompact s) (h₁ : IsOpen s) :
IsCompact (f ⁻¹' s) :=
hf.isCompact_preimage_of_isOpen h₁ h₀
theorem IsSpectralMap.continuous {f : α → β} (hf : IsSpectralMap f) : Continuous f :=
hf.toContinuous
theorem isSpectralMap_id : IsSpectralMap (@id α) :=
⟨continuous_id, fun _s _ => id⟩
theorem IsSpectralMap.comp {f : β → γ} {g : α → β} (hf : IsSpectralMap f) (hg : IsSpectralMap g) :
IsSpectralMap (f ∘ g) :=
⟨hf.continuous.comp hg.continuous, fun _s hs₀ hs₁ =>
((hs₁.preimage_of_isOpen hf hs₀).preimage_of_isOpen hg) (hs₀.preimage hf.continuous)⟩
end Unbundled
/-- The type of spectral maps from `α` to `β`. -/
structure SpectralMap (α β : Type*) [TopologicalSpace α] [TopologicalSpace β] where
/-- function between topological spaces-/
toFun : α → β
/-- proof that `toFun` is a spectral map-/
spectral' : IsSpectralMap toFun
section
/-- `SpectralMapClass F α β` states that `F` is a type of spectral maps.
You should extend this class when you extend `SpectralMap`. -/
class SpectralMapClass (F α β : Type*) [TopologicalSpace α] [TopologicalSpace β]
[FunLike F α β] : Prop where
/-- statement that `F` is a type of spectral maps-/
map_spectral (f : F) : IsSpectralMap f
end
export SpectralMapClass (map_spectral)
attribute [simp] map_spectral
-- See note [lower instance priority]
instance (priority := 100) SpectralMapClass.toContinuousMapClass [TopologicalSpace α]
[TopologicalSpace β] [FunLike F α β] [SpectralMapClass F α β] : ContinuousMapClass F α β :=
{ ‹SpectralMapClass F α β› with map_continuous := fun f => (map_spectral f).continuous }
instance [TopologicalSpace α] [TopologicalSpace β] [FunLike F α β] [SpectralMapClass F α β] :
CoeTC F (SpectralMap α β) :=
⟨fun f => ⟨_, map_spectral f⟩⟩
/-! ### Spectral maps -/
namespace SpectralMap
variable [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ] [TopologicalSpace δ]
/-- Reinterpret a `SpectralMap` as a `ContinuousMap`. -/
def toContinuousMap (f : SpectralMap α β) : ContinuousMap α β :=
⟨_, f.spectral'.continuous⟩
instance instFunLike : FunLike (SpectralMap α β) α β where
coe := SpectralMap.toFun
coe_injective' f g h := by cases f; cases g; congr
instance : SpectralMapClass (SpectralMap α β) α β where
map_spectral f := f.spectral'
@[simp]
theorem toFun_eq_coe {f : SpectralMap α β} : f.toFun = (f : α → β) :=
rfl
@[ext]
theorem ext {f g : SpectralMap α β} (h : ∀ a, f a = g a) : f = g :=
DFunLike.ext f g h
/-- Copy of a `SpectralMap` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : SpectralMap α β) (f' : α → β) (h : f' = f) : SpectralMap α β :=
⟨f', h.symm.subst f.spectral'⟩
@[simp]
theorem coe_copy (f : SpectralMap α β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
theorem copy_eq (f : SpectralMap α β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
DFunLike.ext' h
variable (α)
/-- `id` as a `SpectralMap`. -/
protected def id : SpectralMap α α :=
⟨id, isSpectralMap_id⟩
instance : Inhabited (SpectralMap α α) :=
⟨SpectralMap.id α⟩
@[simp]
theorem coe_id : ⇑(SpectralMap.id α) = id :=
rfl
variable {α}
@[simp]
theorem id_apply (a : α) : SpectralMap.id α a = a :=
rfl
/-- Composition of `SpectralMap`s as a `SpectralMap`. -/
def comp (f : SpectralMap β γ) (g : SpectralMap α β) : SpectralMap α γ :=
⟨f.toContinuousMap.comp g.toContinuousMap, f.spectral'.comp g.spectral'⟩
@[simp]
theorem coe_comp (f : SpectralMap β γ) (g : SpectralMap α β) : (f.comp g : α → γ) = f ∘ g :=
rfl
@[simp]
theorem comp_apply (f : SpectralMap β γ) (g : SpectralMap α β) (a : α) : (f.comp g) a = f (g a) :=
rfl
theorem coe_comp_continuousMap (f : SpectralMap β γ) (g : SpectralMap α β) :
f ∘ g = (f : ContinuousMap β γ) ∘ (g : ContinuousMap α β) :=
rfl
@[simp]
theorem coe_comp_continuousMap' (f : SpectralMap β γ) (g : SpectralMap α β) :
(f.comp g : ContinuousMap α γ) = (f : ContinuousMap β γ).comp g :=
rfl
@[simp]
theorem comp_assoc (f : SpectralMap γ δ) (g : SpectralMap β γ) (h : SpectralMap α β) :
(f.comp g).comp h = f.comp (g.comp h) :=
rfl
@[simp]
theorem comp_id (f : SpectralMap α β) : f.comp (SpectralMap.id α) = f :=
ext fun _a => rfl
@[simp]
theorem id_comp (f : SpectralMap α β) : (SpectralMap.id β).comp f = f :=
ext fun _a => rfl
@[simp]
theorem cancel_right {g₁ g₂ : SpectralMap β γ} {f : SpectralMap α β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
⟨fun h => ext <| hf.forall.2 <| DFunLike.ext_iff.1 h,
fun a => of_eq (congrFun (congrArg comp a) f)⟩
@[simp]
theorem cancel_left {g : SpectralMap β γ} {f₁ f₂ : SpectralMap α β} (hg : Injective g) :
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
⟨fun h => ext fun a => hg <| by rw [← comp_apply, h, comp_apply], congr_arg _⟩
end SpectralMap
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.