Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit d292fd7

Browse files
refactor(topology/metric_space/basic): add pseudo_metric (#6716)
This is the natural continuation of #6694: we introduce here `pseudo_metric_space`. Note that I didn't do anything fancy, I only generalize the results that work out of the box for pseudometric spaces (quite a lot indeed). It's possible that there is some duplicate code, especially in the section about products.
1 parent 3936f5f commit d292fd7

File tree

7 files changed

+541
-430
lines changed

7 files changed

+541
-430
lines changed

src/geometry/euclidean/basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ lemma dist_square_eq_dist_orthogonal_projection_square_add_dist_orthogonal_proje
726726
dist p1 (orthogonal_projection s p2) * dist p1 (orthogonal_projection s p2) +
727727
dist p2 (orthogonal_projection s p2) * dist p2 (orthogonal_projection s p2) :=
728728
begin
729-
rw [metric_space.dist_comm p2 _, dist_eq_norm_vsub V p1 _, dist_eq_norm_vsub V p1 _,
729+
rw [pseudo_metric_space.dist_comm p2 _, dist_eq_norm_vsub V p1 _, dist_eq_norm_vsub V p1 _,
730730
dist_eq_norm_vsub V _ p2, ← vsub_add_vsub_cancel p1 (orthogonal_projection s p2) p2,
731731
norm_add_square_eq_norm_square_add_norm_square_iff_real_inner_eq_zero],
732732
exact submodule.inner_right_of_mem_orthogonal

src/geometry/euclidean/triangle.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ include V
295295
lemma dist_square_eq_dist_square_add_dist_square_iff_angle_eq_pi_div_two (p1 p2 p3 : P) :
296296
dist p1 p3 * dist p1 p3 = dist p1 p2 * dist p1 p2 + dist p3 p2 * dist p3 p2 ↔
297297
∠ p1 p2 p3 = π / 2 :=
298-
by erw [metric_space.dist_comm p3 p2, dist_eq_norm_vsub V p1 p3, dist_eq_norm_vsub V p1 p2,
298+
by erw [pseudo_metric_space.dist_comm p3 p2, dist_eq_norm_vsub V p1 p3, dist_eq_norm_vsub V p1 p2,
299299
dist_eq_norm_vsub V p2 p3,
300300
←norm_sub_square_eq_norm_square_add_norm_square_iff_angle_eq_pi_div_two,
301301
vsub_sub_vsub_cancel_right p1, ←neg_vsub_eq_vsub_rev p2 p3, norm_neg]

src/topology/metric_space/basic.lean

Lines changed: 502 additions & 304 deletions
Large diffs are not rendered by default.

src/topology/metric_space/emetric_space.lean

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ namespace, while notions associated to metric spaces are mostly in the root name
106106
variables [pseudo_emetric_space α]
107107

108108
@[priority 100] -- see Note [lower instance priority]
109-
instance pseudoe_emetric_space.to_uniform_space' : uniform_space α :=
109+
instance pseudo_emetric_space.to_uniform_space' : uniform_space α :=
110110
pseudo_emetric_space.to_uniform_space
111111

112112
export pseudo_emetric_space (edist_self edist_comm edist_triangle)
@@ -362,7 +362,7 @@ This is useful if one wants to construct a pseudoemetric space with a
362362
specified uniformity. See Note [forgetful inheritance] explaining why having definitionally
363363
the right uniformity is often important.
364364
-/
365-
def pseudoemetric_space.replace_uniformity {α} [U : uniform_space α] (m : pseudo_emetric_space α)
365+
def pseudo_emetric_space.replace_uniformity {α} [U : uniform_space α] (m : pseudo_emetric_space α)
366366
(H : @uniformity _ U = @uniformity _ pseudo_emetric_space.to_uniform_space) :
367367
pseudo_emetric_space α :=
368368
{ edist := @edist _ m.to_has_edist,
@@ -372,8 +372,7 @@ def pseudoemetric_space.replace_uniformity {α} [U : uniform_space α] (m : pseu
372372
to_uniform_space := U,
373373
uniformity_edist := H.trans (@pseudo_emetric_space.uniformity_edist α _) }
374374

375-
/-- The extended pseudometric induced by an injective function taking values in a
376-
pseudoemetric space. -/
375+
/-- The extended pseudometric induced by a function taking values in a pseudoemetric space. -/
377376
def pseudo_emetric_space.induced {α β} (f : α → β)
378377
(m : pseudo_emetric_space β) : pseudo_emetric_space α :=
379378
{ edist := λ x y, edist (f x) (f y),
@@ -403,7 +402,7 @@ theorem subtype.edist_eq {p : α → Prop} (x y : subtype p) : edist x y = edist
403402
/-- The product of two pseudoemetric spaces, with the max distance, is an extended
404403
pseudometric spaces. We make sure that the uniform structure thus constructed is the one
405404
corresponding to the product of uniform spaces, to avoid diamond problems. -/
406-
instance prod.pseudoemetric_space_max [pseudo_emetric_space β] : pseudo_emetric_space (α × β) :=
405+
instance prod.pseudo_emetric_space_max [pseudo_emetric_space β] : pseudo_emetric_space (α × β) :=
407406
{ edist := λ x y, max (edist x.1 y.1) (edist x.2 y.2),
408407
edist_self := λ x, by simp,
409408
edist_comm := λ x y, by simp [edist_comm],
@@ -432,7 +431,8 @@ a pseudoemetric space.
432431
This construction would also work for infinite products, but it would not give rise
433432
to the product topology. Hence, we only formalize it in the good situation of finitely many
434433
spaces. -/
435-
instance pseudoemetric_space_pi [∀b, pseudo_emetric_space (π b)] : pseudo_emetric_space (Πb, π b) :=
434+
instance pseudo_emetric_space_pi [∀b, pseudo_emetric_space (π b)] :
435+
pseudo_emetric_space (Πb, π b) :=
436436
{ edist := λ f g, finset.sup univ (λb, edist (f b) (g b)),
437437
edist_self := assume f, bot_unique $ finset.sup_le $ by simp,
438438
edist_comm := assume f g, by unfold edist; congr; funext a; exact edist_comm _ _,
@@ -452,11 +452,11 @@ instance pseudoemetric_space_pi [∀b, pseudo_emetric_space (π b)] : pseudo_eme
452452
simp [set.ext_iff, εpos]
453453
end }
454454

455-
lemma pseudoedist_pi_def [Π b, pseudo_emetric_space (π b)] (f g : Π b, π b) :
455+
lemma pseudo_edist_pi_def [Π b, pseudo_emetric_space (π b)] (f g : Π b, π b) :
456456
edist f g = finset.sup univ (λb, edist (f b) (g b)) := rfl
457457

458458
@[priority 1100]
459-
lemma pseudoedist_pi_const [nonempty β] (a b : α) :
459+
lemma pseudo_edist_pi_const [nonempty β] (a b : α) :
460460
edist (λ x : β, a) (λ _, b) = edist a b := finset.sup_const univ_nonempty (edist a b)
461461

462462
end pi
@@ -907,6 +907,17 @@ instance to_separated : separated_space γ :=
907907
separated_def.2 $ λ x y h, eq_of_forall_edist_le $
908908
λ ε ε0, le_of_lt (h _ (edist_mem_uniformity ε0))
909909

910+
/-- If a `pseudo_emetric_space` is separated, then it is an `emetric_space`. -/
911+
def emetric_of_t2_pseudo_emetric_space {α : Type*} [pseudo_emetric_space α]
912+
(h : separated_space α) : emetric_space α :=
913+
{ eq_of_edist_eq_zero := λ x y hdist,
914+
begin
915+
refine separated_def.1 h x y (λ s hs, _),
916+
obtain ⟨ε, hε, H⟩ := mem_uniformity_edist.1 hs,
917+
exact H (show edist x y < ε, by rwa [hdist])
918+
end
919+
..‹pseudo_emetric_space α› }
920+
910921
/-- Auxiliary function to replace the uniformity on an emetric space with
911922
a uniformity which is equal to the original one, but maybe not defeq.
912923
This is useful if one wants to construct an emetric space with a
@@ -958,7 +969,7 @@ instance prod.emetric_space_max [emetric_space β] : emetric_space (γ × β) :=
958969
have B : x.snd = y.snd := edist_le_zero.1 h₂,
959970
exact prod.ext_iff.2 ⟨A, B⟩
960971
end,
961-
..prod.pseudoemetric_space_max }
972+
..prod.pseudo_emetric_space_max }
962973

963974
lemma prod.edist_eq [emetric_space β] (x y : α × β) :
964975
edist x y = max (edist x.1 y.1) (edist x.2 y.2) :=
@@ -985,7 +996,7 @@ instance emetric_space_pi [∀b, emetric_space (π b)] : emetric_space (Πb, π
985996
simp only [finset.sup_le_iff] at eq1,
986997
exact (funext $ assume b, edist_le_zero.1 $ eq1 b $ mem_univ b),
987998
end,
988-
..pseudoemetric_space_pi }
999+
..pseudo_emetric_space_pi }
9891000

9901001
lemma edist_pi_def [Π b, emetric_space (π b)] (f g : Π b, π b) :
9911002
edist f g = finset.sup univ (λb, edist (f b) (g b)) := rfl

src/topology/metric_space/gluing.lean

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ Gluing metric spaces
55
Authors: Sébastien Gouëzel
66
-/
77
import topology.metric_space.isometry
8-
import topology.metric_space.premetric_space
98

109
/-!
1110
# Metric space gluing
@@ -52,7 +51,7 @@ noncomputable theory
5251
universes u v w
5352
variables {α : Type u} {β : Type v} {γ : Type w}
5453

55-
open function set premetric
54+
open function set
5655
open_locale uniformity
5756

5857
namespace metric
@@ -325,26 +324,26 @@ section gluing
325324
variables [nonempty γ] [metric_space γ] [metric_space α] [metric_space β]
326325
{Φ : γ → α} {Ψ : γ → β} {ε : ℝ}
327326
open sum (inl inr)
328-
local attribute [instance] premetric.dist_setoid
327+
local attribute [instance] pseudo_metric.dist_setoid
329328

330-
def glue_premetric (hΦ : isometry Φ) (hΨ : isometry Ψ) : premetric_space (α ⊕ β) :=
329+
def glue_premetric (hΦ : isometry Φ) (hΨ : isometry Ψ) : pseudo_metric_space (α ⊕ β) :=
331330
{ dist := glue_dist Φ Ψ 0,
332331
dist_self := glue_dist_self Φ Ψ 0,
333332
dist_comm := glue_dist_comm Φ Ψ 0,
334333
dist_triangle := glue_dist_triangle Φ Ψ 0 $ λp q, by rw [hΦ.dist_eq, hΨ.dist_eq]; simp }
335334

336335
def glue_space (hΦ : isometry Φ) (hΨ : isometry Ψ) : Type* :=
337-
@metric_quot _ (glue_premetric hΦ hΨ)
336+
@pseudo_metric_quot _ (glue_premetric hΦ hΨ)
338337

339338
instance metric_space_glue_space (hΦ : isometry Φ) (hΨ : isometry Ψ) :
340339
metric_space (glue_space hΦ hΨ) :=
341-
@premetric.metric_space_quot _ (glue_premetric hΦ hΨ)
340+
@metric_space_quot _ (glue_premetric hΦ hΨ)
342341

343342
def to_glue_l (hΦ : isometry Φ) (hΨ : isometry Ψ) (x : α) : glue_space hΦ hΨ :=
344-
by letI : premetric_space (α ⊕ β) := glue_premetric hΦ hΨ; exact ⟦inl x⟧
343+
by letI : pseudo_metric_space (α ⊕ β) := glue_premetric hΦ hΨ; exact ⟦inl x⟧
345344

346345
def to_glue_r (hΦ : isometry Φ) (hΨ : isometry Ψ) (y : β) : glue_space hΦ hΨ :=
347-
by letI : premetric_space (α ⊕ β) := glue_premetric hΦ hΨ; exact ⟦inr y⟧
346+
by letI : pseudo_metric_space (α ⊕ β) := glue_premetric hΦ hΨ; exact ⟦inr y⟧
348347

349348
instance inhabited_left (hΦ : isometry Φ) (hΨ : isometry Ψ) [inhabited α] :
350349
inhabited (glue_space hΦ hΨ) :=
@@ -357,7 +356,7 @@ instance inhabited_right (hΦ : isometry Φ) (hΨ : isometry Ψ) [inhabited β]
357356
lemma to_glue_commute (hΦ : isometry Φ) (hΨ : isometry Ψ) :
358357
(to_glue_l hΦ hΨ) ∘ Φ = (to_glue_r hΦ hΨ) ∘ Ψ :=
359358
begin
360-
letI : premetric_space (α ⊕ β) := glue_premetric hΦ hΨ,
359+
letI : pseudo_metric_space (α ⊕ β) := glue_premetric hΦ hΨ,
361360
funext,
362361
simp only [comp, to_glue_l, to_glue_r, quotient.eq],
363362
exact glue_dist_glued_points Φ Ψ 0 x
@@ -413,7 +412,7 @@ end
413412

414413
/-- Premetric space structure on Σn, X n.-/
415414
def inductive_premetric (I : ∀n, isometry (f n)) :
416-
premetric_space (Σn, X n) :=
415+
pseudo_metric_space (Σn, X n) :=
417416
{ dist := inductive_limit_dist f,
418417
dist_self := λx, by simp [dist, inductive_limit_dist],
419418
dist_comm := λx y, begin
@@ -440,20 +439,20 @@ def inductive_premetric (I : ∀n, isometry (f n)) :
440439
inductive_limit_dist_eq_dist I y z m hy hz]
441440
end }
442441

443-
local attribute [instance] inductive_premetric premetric.dist_setoid
442+
local attribute [instance] inductive_premetric pseudo_metric.dist_setoid
444443

445444
/-- The type giving the inductive limit in a metric space context. -/
446445
def inductive_limit (I : ∀n, isometry (f n)) : Type* :=
447-
@metric_quot _ (inductive_premetric I)
446+
@pseudo_metric_quot _ (inductive_premetric I)
448447

449448
/-- Metric space structure on the inductive limit. -/
450449
instance metric_space_inductive_limit (I : ∀n, isometry (f n)) :
451450
metric_space (inductive_limit I) :=
452-
@premetric.metric_space_quot _ (inductive_premetric I)
451+
@metric_space_quot _ (inductive_premetric I)
453452

454453
/-- Mapping each `X n` to the inductive limit. -/
455454
def to_inductive_limit (I : ∀n, isometry (f n)) (n : ℕ) (x : X n) : metric.inductive_limit I :=
456-
by letI : premetric_space (Σn, X n) := inductive_premetric I; exact ⟦sigma.mk n x⟧
455+
by letI : pseudo_metric_space (Σn, X n) := inductive_premetric I; exact ⟦sigma.mk n x⟧
457456

458457
instance (I : ∀ n, isometry (f n)) [inhabited (X 0)] : inhabited (inductive_limit I) :=
459458
⟨to_inductive_limit _ 0 (default _)⟩

src/topology/metric_space/gromov_hausdorff_realized.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,17 +418,17 @@ let ⟨Z1, Z2⟩ := classical.some_spec (exists_minimizer α β) in Z2 g hg
418418
/-- With the optimal candidate, construct a premetric space structure on α ⊕ β, on which the
419419
predistance is given by the candidate. Then, we will identify points at 0 predistance
420420
to obtain a genuine metric space -/
421-
def premetric_optimal_GH_dist : premetric_space (α ⊕ β) :=
421+
def premetric_optimal_GH_dist : pseudo_metric_space (α ⊕ β) :=
422422
{ dist := λp q, optimal_GH_dist α β (p, q),
423423
dist_self := λx, candidates_refl (optimal_GH_dist_mem_candidates_b α β),
424424
dist_comm := λx y, candidates_symm (optimal_GH_dist_mem_candidates_b α β),
425425
dist_triangle := λx y z, candidates_triangle (optimal_GH_dist_mem_candidates_b α β) }
426426

427-
local attribute [instance] premetric_optimal_GH_dist premetric.dist_setoid
427+
local attribute [instance] premetric_optimal_GH_dist pseudo_metric.dist_setoid
428428

429429
/-- A metric space which realizes the optimal coupling between α and β -/
430430
@[derive [metric_space]] definition optimal_GH_coupling : Type* :=
431-
premetric.metric_quot (α ⊕ β)
431+
pseudo_metric_quot (α ⊕ β)
432432

433433
/-- Injection of α in the optimal coupling between α and β -/
434434
def optimal_GH_injl (x : α) : optimal_GH_coupling α β := ⟦inl x⟧

src/topology/metric_space/premetric_space.lean

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)