The areas / V13. General topology
Mathlib.Topology.MetricSpace.Defs
38 declarations and 2 deprecated aliases. Mathlib docs · Source
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.
Main definitions
MetricSpace α: A pseudometric space with the guaranteedist x y = 0 → x = y.MetricSpace.ofDistTopology: Construct a metric space from a compatible topology and distance.MetricSpace.replaceUniformity,MetricSpace.replaceTopology,MetricSpace.replaceBornology: Tools to construct a metric space on a type with a pre-existing uniformity, topology, or bornology in such a way that the definitional equalities for these structures are preserved; these are essential to avoid type class synthesis issues.
Main results
dist_eq_zero,dist_pos,eq_of_forall_dist_le,eq_of_nnDist_eq_zero: core characterizations of equality via distance.
Implementation notes
A lot of elementary properties don't require eq_of_dist_eq_zero, hence are stated and proven
for PseudoMetricSpaces in Mathlib/Topology/MetricSpace/Pseudo/Defs.lean.
Tags
metric, pseudometric space, dist
Additive, Multiplicative
The distance on those type synonyms is inherited without change.
Order dual
The distance on this type synonym is inherited without change.
def MetricSpace.ctorIdx E1 #
{α : Type u} → MetricSpace α → ℕ
class MetricSpace E3 #
Type u → Type u
A metric space is a type endowed with a ℝ-valued distance dist satisfying
dist x y = 0 ↔ x = y, commutativity dist x y = dist y x, and the triangle inequality
dist x z ≤ dist x y + dist y z.
See pseudometric spaces (PseudoMetricSpace) for the similar class with the dist x y = 0 ↔ x = y
assumption weakened to dist x x = 0.
Any metric space is a T1 topological space and a uniform space (see TopologicalSpace, T1Space,
UniformSpace), where the topology and uniformity come from the metric.
We make the uniformity/topology part of the data instead of deriving it from the metric.
This e.g. ensures that we do not get a diamond when doing
[MetricSpace α] [MetricSpace β] : TopologicalSpace (α × β):
The product metric and product topology agree, but not definitionally so.
See Note [forgetful inheritance].
instance MetricSpace.toPseudoMetricSpace E0 #
{α : Type u} → [self : MetricSpace α] → PseudoMetricSpace α
ctor MetricSpace.mk E0 #
{α : Type u} → [toPseudoMetricSpace : PseudoMetricSpace α] → (∀ {x y : α}, dist x y = 0 → x = y) → MetricSpace α
theorem MetricSpace.ext E1 #
∀ {α : Type u_2} {m m' : MetricSpace α}, m.toDist = m'.toDist → m = m'
Two metric space structures with the same distance coincide.
theorem MetricSpace.ext_iff E0 #
∀ {α : Type u_2} {m m' : MetricSpace α}, m = m' ↔ m.toDist = m'.toDist
def MetricSpace.ofDistTopology E3 #
{α : Type u} →
[inst : TopologicalSpace α] →
(dist : α → α → ℝ) →
(∀ (x : α), dist x x = 0) →
(∀ (x y : α), dist x y = dist y x) →
(∀ (x y z : α), dist x z ≤ dist x y + dist y z) →
(∀ (s : Set α), IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, ∀ (y : α), dist x y < ε → y ∈ s) →
(∀ (x y : α), dist x y = 0 → x = y) → MetricSpace α
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.
theorem dist_eq_zero E3 #
∀ {γ : Type w} [inst : MetricSpace γ] {x y : γ}, dist x y = 0 ↔ x = y
theorem zero_eq_dist E0 #
∀ {γ : Type w} [inst : MetricSpace γ] {x y : γ}, 0 = dist x y ↔ x = y
theorem dist_ne_zero E1 #
∀ {γ : Type w} [inst : MetricSpace γ] {x y : γ}, dist x y ≠ 0 ↔ x ≠ y
theorem dist_le_zero E0 #
∀ {γ : Type w} [inst : MetricSpace γ] {x y : γ}, dist x y ≤ 0 ↔ x = y
theorem dist_pos E3 #
∀ {γ : Type w} [inst : MetricSpace γ] {x y : γ}, 0 < dist x y ↔ x ≠ y
theorem nnDist_eq_zero E0 #
∀ {γ : Type w} [inst : MetricSpace γ] {x y : γ}, nnDist x y = 0 ↔ x = y
Characterize the equality of points as the vanishing of the nonnegative distance
theorem zero_eq_nnDist E0 #
∀ {γ : Type w} [inst : MetricSpace γ] {x y : γ}, 0 = nnDist x y ↔ x = y
theorem Metric.closedBall_zero E0 #
∀ {γ : Type w} [inst : MetricSpace γ] {x : γ}, Metric.closedBall x 0 = {x}
theorem Metric.sphere_zero E0 #
∀ {γ : Type w} [inst : MetricSpace γ] {x : γ}, Metric.sphere x 0 = {x}
theorem Metric.subsingleton_closedBall E1 #
∀ {γ : Type w} [inst : MetricSpace γ] (x : γ) {r : ℝ}, r ≤ 0 → (Metric.closedBall x r).Subsingleton
theorem Metric.subsingleton_sphere E1 #
∀ {γ : Type w} [inst : MetricSpace γ] (x : γ) {r : ℝ}, r ≤ 0 → (Metric.sphere x r).Subsingleton
abbrev MetricSpace.replaceUniformity E3 #
{γ : Type u_2} → [U : UniformSpace γ] → (m : MetricSpace γ) → uniformity γ = uniformity γ → MetricSpace γ
Build a new metric space from an old one where the bundled uniform structure is provably (but typically non-definitionally) equal to some given uniform structure. See Note [forgetful inheritance]. See Note [reducible non-instances].
theorem MetricSpace.replaceUniformity_eq E0 #
∀ {γ : Type u_2} [U : UniformSpace γ] (m : MetricSpace γ) (H : uniformity γ = uniformity γ), m.replaceUniformity H = m
abbrev MetricSpace.replaceTopology E3 #
{γ : Type u_2} →
[U : TopologicalSpace γ] →
(m : MetricSpace γ) → U = PseudoMetricSpace.toUniformSpace.toTopologicalSpace → MetricSpace γ
Build a new metric space from an old one where the bundled topological structure is provably (but typically non-definitionally) equal to some given topological structure. See Note [forgetful inheritance]. See Note [reducible non-instances].
theorem MetricSpace.replaceTopology_eq E0 #
∀ {γ : Type u_2} [U : TopologicalSpace γ] (m : MetricSpace γ)
(H : U = PseudoMetricSpace.toUniformSpace.toTopologicalSpace), m.replaceTopology H = m
abbrev MetricSpace.replaceBornology E3 #
{α : Type u_2} →
[B : Bornology α] →
(m : MetricSpace α) → (∀ (s : Set α), Bornology.IsBounded s ↔ Bornology.IsBounded s) → MetricSpace α
Build a new metric space from an old one where the bundled bornology structure is provably (but typically non-definitionally) equal to some given bornology structure. See Note [forgetful inheritance]. See Note [reducible non-instances].
theorem MetricSpace.replaceBornology_eq E0 #
∀ {α : Type u_2} [m : MetricSpace α] [B : Bornology α]
(H : ∀ (s : Set α), Bornology.IsBounded s ↔ Bornology.IsBounded s), m.replaceBornology H = m
instance instMetricSpaceEmpty E0 #
MetricSpace Empty
instance instMetricSpacePUnit E0 #
MetricSpace PUnit.{u + 1}
instance instDistAdditive E0 #
{X : Type u_1} → [Dist X] → Dist (Additive X)
instance instDistMultiplicative E0 #
{X : Type u_1} → [Dist X] → Dist (Multiplicative X)
theorem dist_ofMul E0 #
∀ {X : Type u_1} [inst : Dist X] (a b : X), dist (Additive.ofMul a) (Additive.ofMul b) = dist a b
theorem dist_ofAdd E0 #
∀ {X : Type u_1} [inst : Dist X] (a b : X), dist (Multiplicative.ofAdd a) (Multiplicative.ofAdd b) = dist a b
theorem dist_toMul E0 #
∀ {X : Type u_1} [inst : Dist X] (a b : Additive X), dist (Additive.toMul a) (Additive.toMul b) = dist a b
theorem dist_toAdd E0 #
∀ {X : Type u_1} [inst : Dist X] (a b : Multiplicative X),
dist (Multiplicative.toAdd a) (Multiplicative.toAdd b) = dist a b
instance instMetricSpaceAdditive E0 #
{X : Type u_1} → [MetricSpace X] → MetricSpace (Additive X)
instance instMetricSpaceMultiplicative E0 #
{X : Type u_1} → [MetricSpace X] → MetricSpace (Multiplicative X)
instance instDistOrderDual E0 #
{X : Type u_1} → [Dist X] → Dist Xᵒᵈ
theorem dist_toDual E0 #
∀ {X : Type u_1} [inst : Dist X] (a b : X), dist (OrderDual.toDual a) (OrderDual.toDual b) = dist a b
theorem dist_ofDual E0 #
∀ {X : Type u_1} [inst : Dist X] (a b : Xᵒᵈ), dist (OrderDual.ofDual a) (OrderDual.ofDual b) = dist a b
instance instMetricSpaceOrderDual E0 #
{X : Type u_1} → [MetricSpace X] → MetricSpace Xᵒᵈ
Deprecated aliases
| Name | New name | Since |
|---|---|---|
nndist_eq_zero | nnDist_eq_zero | 2026-11-07 |
zero_eq_nndist | zero_eq_nnDist | 2026-11-07 |