Skip to content

Commit

Permalink
chore(topology/metric_space/basic): golf an instance (#13664)
Browse files Browse the repository at this point in the history
Golf the proof of `prod.pseudo_metric_space_max` using
`pseudo_emetric_space.to_pseudo_metric_space_of_dist`.
  • Loading branch information
urkud committed Apr 25, 2022
1 parent 9101c48 commit 454b884
Showing 1 changed file with 10 additions and 30 deletions.
40 changes: 10 additions & 30 deletions src/topology/metric_space/basic.lean
Expand Up @@ -1395,25 +1395,11 @@ variables [pseudo_metric_space β]

noncomputable instance prod.pseudo_metric_space_max :
pseudo_metric_space (α × β) :=
{ dist := λ x y, max (dist x.1 y.1) (dist x.2 y.2),
dist_self := λ x, by simp,
dist_comm := λ x y, by simp [dist_comm],
dist_triangle := λ x y z, max_le
(le_trans (dist_triangle _ _ _) (add_le_add (le_max_left _ _) (le_max_left _ _)))
(le_trans (dist_triangle _ _ _) (add_le_add (le_max_right _ _) (le_max_right _ _))),
edist := λ x y, max (edist x.1 y.1) (edist x.2 y.2),
edist_dist := assume x y, begin
have : monotone ennreal.of_real := assume x y h, ennreal.of_real_le_of_real h,
rw [edist_dist, edist_dist, ← this.map_max]
end,
uniformity_dist := begin
refine uniformity_prod.trans _,
simp only [uniformity_basis_dist.eq_binfi, comap_infi],
rw ← infi_inf_eq, congr, funext,
rw ← infi_inf_eq, congr, funext,
simp [inf_principal, ext_iff, max_lt_iff]
end,
to_uniform_space := prod.uniform_space }
pseudo_emetric_space.to_pseudo_metric_space_of_dist
(λ x y : α × β, max (dist x.1 y.1) (dist x.2 y.2))
(λ x y, (max_lt (edist_lt_top _ _) (edist_lt_top _ _)).ne) $
λ x y, by rw [dist_edist, dist_edist, prod.edist_eq,
← ennreal.to_real_max (edist_ne_top _ _) (edist_ne_top _ _)]

lemma prod.dist_eq {x y : α × β} :
dist x y = max (dist x.1 y.1) (dist x.2 y.2) := rfl
Expand Down Expand Up @@ -1650,17 +1636,11 @@ begin
the uniformity is the same as the product uniformity, but we register nevertheless a nice formula
for the distance -/
refine pseudo_emetric_space.to_pseudo_metric_space_of_dist
(λf g, ((sup univ (λb, nndist (f b) (g b)) : ℝ≥0) : ℝ)) _ _,
show ∀ (x y : Π (b : β), π b), edist x y ≠ ⊤,
{ assume x y,
rw ← lt_top_iff_ne_top,
have : (⊥ : ℝ≥0∞) < ⊤ := ennreal.coe_lt_top,
simp [edist_pi_def, finset.sup_lt_iff this, edist_lt_top] },
show ∀ (x y : Π (b : β), π b), ↑(sup univ (λ (b : β), nndist (x b) (y b))) =
ennreal.to_real (sup univ (λ (b : β), edist (x b) (y b))),
{ assume x y,
simp only [edist_nndist],
norm_cast }
(λf g, ((sup univ (λb, nndist (f b) (g b)) : ℝ≥0) : ℝ)) (λ f g, _) (λ f g, _),
show edist f g ≠ ⊤,
from ne_of_lt ((finset.sup_lt_iff bot_lt_top).2 $ λ b hb, edist_lt_top _ _),
show ↑(sup univ (λ b, nndist (f b) (g b))) = (sup univ (λ b, edist (f b) (g b))).to_real,
by simp only [edist_nndist, ← ennreal.coe_finset_sup, ennreal.coe_to_real]
end

lemma nndist_pi_def (f g : Πb, π b) : nndist f g = sup univ (λb, nndist (f b) (g b)) :=
Expand Down

0 comments on commit 454b884

Please sign in to comment.