Module docstring
{"# Basic properties of metric spaces, and instances.
"}
{"# Basic properties of metric spaces, and instances.
"}
MetricSpace.instT0Space
instance
: T0Space γ
instance (priority := 100) _root_.MetricSpace.instT0Space : T0Space γ where
t0 _ _ h := eq_of_dist_eq_zero <| Metric.inseparable_iff.1 h
Metric.isUniformEmbedding_iff'
theorem
[PseudoMetricSpace β] {f : γ → β} :
IsUniformEmbedding 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 < δ
/-- 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 isUniformEmbedding_iff' [PseudoMetricSpace β] {f : γ → β} :
IsUniformEmbeddingIsUniformEmbedding 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 [isUniformEmbedding_iff_isUniformInducing, isUniformInducing_iff, uniformContinuous_iff]
MetricSpace.ofT0PseudoMetricSpace
abbrev
(α : Type*) [PseudoMetricSpace α] [T0Space α] : MetricSpace α
/-- 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
MetricSpace.toEMetricSpace
instance
: EMetricSpace γ
/-- A metric space induces an emetric space -/
instance (priority := 100) _root_.MetricSpace.toEMetricSpace : EMetricSpace γ :=
.ofT0PseudoEMetricSpace γ
Metric.isClosed_of_pairwise_le_dist
theorem
{s : Set γ} {ε : ℝ} (hε : 0 < ε) (hs : s.Pairwise fun x y => ε ≤ dist x y) : IsClosed s
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
Metric.isClosedEmbedding_of_pairwise_le_dist
theorem
{α : Type*} [TopologicalSpace α] [DiscreteTopology α] {ε : ℝ} (hε : 0 < ε) {f : α → γ}
(hf : Pairwise fun x y => ε ≤ dist (f x) (f y)) : IsClosedEmbedding f
theorem isClosedEmbedding_of_pairwise_le_dist {α : Type*} [TopologicalSpace α] [DiscreteTopology α]
{ε : ℝ} (hε : 0 < ε) {f : α → γ} (hf : Pairwise fun x y => ε ≤ dist (f x) (f y)) :
IsClosedEmbedding f :=
isClosedEmbedding_of_spaced_out (dist_mem_uniformity hε) <| by simpa using hf
Metric.isUniformEmbedding_bot_of_pairwise_le_dist
theorem
{β : Type*} {ε : ℝ} (hε : 0 < ε) {f : β → α} (hf : Pairwise fun x y => ε ≤ dist (f x) (f y)) :
@IsUniformEmbedding _ _ ⊥ (by infer_instance) f
/-- 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 isUniformEmbedding_bot_of_pairwise_le_dist {β : Type*} {ε : ℝ} (hε : 0 < ε) {f : β → α}
(hf : Pairwise fun x y => ε ≤ dist (f x) (f y)) :
@IsUniformEmbedding _ _ ⊥ (by infer_instance) f :=
isUniformEmbedding_of_spaced_out (dist_mem_uniformity hε) <| by simpa using hf
EMetricSpace.toMetricSpaceOfDist
abbrev
{α : Type u} [EMetricSpace α] (dist : α → α → ℝ) (edist_ne_top : ∀ x y : α, edist x y ≠ ⊤)
(h : ∀ x y, dist x y = ENNReal.toReal (edist x y)) : MetricSpace α
/-- 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 : α, edistedist x y ≠ ⊤) (h : ∀ x y, dist x y = ENNReal.toReal (edist x y)) :
MetricSpace α :=
@MetricSpace.ofT0PseudoMetricSpace _
(PseudoEMetricSpace.toPseudoMetricSpaceOfDist dist edist_ne_top h) _
EMetricSpace.toMetricSpace
definition
{α : Type u} [EMetricSpace α] (h : ∀ x y : α, edist x y ≠ ⊤) : MetricSpace α
/-- 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 : α, edistedist x y ≠ ⊤) :
MetricSpace α :=
EMetricSpace.toMetricSpaceOfDist (fun x y => ENNReal.toReal (edist x y)) h fun _ _ => rfl
MetricSpace.induced
abbrev
{γ β} (f : γ → β) (hf : Function.Injective f) (m : MetricSpace β) : MetricSpace γ
/-- 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) }
IsUniformEmbedding.comapMetricSpace
abbrev
{α β} [UniformSpace α] [m : MetricSpace β] (f : α → β) (h : IsUniformEmbedding f) : MetricSpace α
/-- 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 IsUniformEmbedding.comapMetricSpace {α β} [UniformSpace α] [m : MetricSpace β] (f : α → β)
(h : IsUniformEmbedding f) : MetricSpace α :=
.replaceUniformity (.induced f h.injective m) h.comap_uniformity.symm
Topology.IsEmbedding.comapMetricSpace
abbrev
{α β} [TopologicalSpace α] [m : MetricSpace β] (f : α → β) (h : IsEmbedding f) : MetricSpace α
/-- 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 Topology.IsEmbedding.comapMetricSpace {α β} [TopologicalSpace α] [m : MetricSpace β]
(f : α → β) (h : IsEmbedding f) : MetricSpace α :=
.replaceTopology (.induced f h.injective m) h.eq_induced
Subtype.metricSpace
instance
{α : Type*} {p : α → Prop} [MetricSpace α] : MetricSpace (Subtype p)
instance Subtype.metricSpace {α : Type*} {p : α → Prop} [MetricSpace α] :
MetricSpace (Subtype p) :=
.induced Subtype.val Subtype.coe_injective ‹_›
MulOpposite.instMetricSpace
instance
{α : Type*} [MetricSpace α] : MetricSpace αᵐᵒᵖ
@[to_additive]
instance MulOpposite.instMetricSpace {α : Type*} [MetricSpace α] : MetricSpace αᵐᵒᵖ :=
MetricSpace.induced MulOpposite.unop MulOpposite.unop_injective ‹_›
Real.metricSpace
instance
: MetricSpace ℝ
/-- Instantiate the reals as a metric space. -/
instance Real.metricSpace : MetricSpace ℝ := .ofT0PseudoMetricSpace ℝ
instMetricSpaceNNReal
instance
: MetricSpace ℝ≥0
instance : MetricSpace ℝ≥0 :=
Subtype.metricSpace
instMetricSpaceULift
instance
[MetricSpace β] : MetricSpace (ULift β)
instance [MetricSpace β] : MetricSpace (ULift β) :=
MetricSpace.induced ULift.down ULift.down_injective ‹_›
Prod.metricSpaceMax
instance
[MetricSpace β] : MetricSpace (γ × β)
instance Prod.metricSpaceMax [MetricSpace β] : MetricSpace (γ × β) :=
.ofT0PseudoMetricSpace _
metricSpacePi
instance
: MetricSpace (∀ b, π b)
/-- A finite product of metric spaces is a metric space, with the sup distance. -/
instance metricSpacePi : MetricSpace (∀ b, π b) := .ofT0PseudoMetricSpace _
Metric.secondCountable_of_countable_discretization
theorem
{α : Type u} [PseudoMetricSpace α]
(H : ∀ ε > (0 : ℝ), ∃ (β : Type*) (_ : Encodable β) (F : α → β), ∀ x y, F x = F y → dist x y ≤ ε) :
SecondCountableTopology α
/-- 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} [PseudoMetricSpace α]
(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⟩
SeparationQuotient.instDist
instance
{α : Type u} [PseudoMetricSpace α] : Dist (SeparationQuotient α)
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]
SeparationQuotient.dist_mk
theorem
{α : Type u} [PseudoMetricSpace α] (p q : α) : dist (mk p) (mk q) = dist p q
theorem SeparationQuotient.dist_mk {α : Type u} [PseudoMetricSpace α] (p q : α) :
dist (mk p) (mk q) = dist p q :=
rfl
SeparationQuotient.instMetricSpace
instance
{α : Type u} [PseudoMetricSpace α] : MetricSpace (SeparationQuotient α)
instance SeparationQuotient.instMetricSpace {α : Type u} [PseudoMetricSpace α] :
MetricSpace (SeparationQuotient α) :=
EMetricSpace.toMetricSpaceOfDist dist (surjective_mk.forall₂.2 edist_ne_top) <|
surjective_mk.forall₂.2 dist_edist