topology.metric_space.dilationMathlib.Topology.MetricSpace.Dilation

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -358,7 +358,7 @@ 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 
+  · push_neg at h
     rcases h with ⟨x, y, hne⟩
     refine' (ratio_unique hne.1 hne.2 _).symm
     simp
@@ -406,8 +406,8 @@ theorem ratio_comp' {g : Dilation β γ} {f : Dilation α β}
   by
   rcases hne with ⟨x, y, hα⟩
   have hgf := (edist_eq (g.comp f) x y).symm
-  simp only [dist_eq, coe_comp, ← mul_assoc, mul_eq_mul_right_iff] at hgf 
-  rw [edist_eq, edist_eq, ← mul_assoc, ENNReal.mul_eq_mul_right hα.1 hα.2] at hgf 
+  simp only [dist_eq, coe_comp, ← mul_assoc, mul_eq_mul_right_iff] at hgf
+  rw [edist_eq, edist_eq, ← mul_assoc, ENNReal.mul_eq_mul_right hα.1 hα.2] at hgf
   rwa [← ENNReal.coe_inj, ENNReal.coe_mul]
 #align dilation.comp_ratio Dilation.ratio_comp'
 -/
Diff
@@ -204,7 +204,7 @@ theorem edist_eq [DilationClass F α β] (f : F) (x y : α) :
 @[simp]
 theorem nndist_eq {α β F : Type _} [PseudoMetricSpace α] [PseudoMetricSpace β] [DilationClass F α β]
     (f : F) (x y : α) : nndist (f x) (f y) = ratio f * nndist x y := by
-  simp only [← ENNReal.coe_eq_coe, ← edist_nndist, ENNReal.coe_mul, edist_eq]
+  simp only [← ENNReal.coe_inj, ← edist_nndist, ENNReal.coe_mul, edist_eq]
 #align dilation.nndist_eq Dilation.nndist_eq
 -/
 
@@ -221,7 +221,7 @@ theorem dist_eq {α β F : Type _} [PseudoMetricSpace α] [PseudoMetricSpace β]
 `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_eq_coe] using edist_eq f x y
+  simpa only [hr, ENNReal.mul_eq_mul_right h₀ htop, ENNReal.coe_inj] using edist_eq f x y
 #align dilation.ratio_unique Dilation.ratio_unique
 -/
 
@@ -408,7 +408,7 @@ theorem ratio_comp' {g : Dilation β γ} {f : Dilation α β}
   have hgf := (edist_eq (g.comp f) x y).symm
   simp only [dist_eq, coe_comp, ← mul_assoc, mul_eq_mul_right_iff] at hgf 
   rw [edist_eq, edist_eq, ← mul_assoc, ENNReal.mul_eq_mul_right hα.1 hα.2] at hgf 
-  rwa [← ENNReal.coe_eq_coe, ENNReal.coe_mul]
+  rwa [← ENNReal.coe_inj, ENNReal.coe_mul]
 #align dilation.comp_ratio Dilation.ratio_comp'
 -/
 
Diff
@@ -72,7 +72,7 @@ structure Dilation where
 You should extend this typeclass when you extend `dilation`.
 -/
 class DilationClass (F : Type _) (α β : outParam <| Type _) [PseudoEMetricSpace α]
-    [PseudoEMetricSpace β] extends FunLike F α fun _ => β where
+    [PseudoEMetricSpace β] extends DFunLike F α fun _ => β where
   edist_eq' : ∀ f : F, ∃ r : ℝ≥0, r ≠ 0 ∧ ∀ x y : α, edist (f x) (f y) = r * edist x y
 #align dilation_class DilationClass
 -/
@@ -97,7 +97,7 @@ instance toDilationClass : DilationClass (Dilation α β) α β
 -/
 
 instance : CoeFun (Dilation α β) fun _ => α → β :=
-  FunLike.hasCoeToFun
+  DFunLike.hasCoeToFun
 
 #print Dilation.toFun_eq_coe /-
 @[simp]
@@ -115,26 +115,26 @@ theorem coe_mk (f : α → β) (h) : ⇑(⟨f, h⟩ : Dilation α β) = f :=
 
 #print Dilation.congr_fun /-
 theorem congr_fun {f g : Dilation α β} (h : f = g) (x : α) : f x = g x :=
-  FunLike.congr_fun h x
+  DFunLike.congr_fun h x
 #align dilation.congr_fun Dilation.congr_fun
 -/
 
 #print Dilation.congr_arg /-
 theorem congr_arg (f : Dilation α β) {x y : α} (h : x = y) : f x = f y :=
-  FunLike.congr_arg f h
+  DFunLike.congr_arg f h
 #align dilation.congr_arg Dilation.congr_arg
 -/
 
 #print Dilation.ext /-
 @[ext]
 theorem ext {f g : Dilation α β} (h : ∀ x, f x = g x) : f = g :=
-  FunLike.ext f g h
+  DFunLike.ext f g h
 #align dilation.ext Dilation.ext
 -/
 
 #print Dilation.ext_iff /-
 theorem ext_iff {f g : Dilation α β} : f = g ↔ ∀ x, f x = g x :=
-  FunLike.ext_iff
+  DFunLike.ext_iff
 #align dilation.ext_iff Dilation.ext_iff
 -/
 
@@ -158,7 +158,7 @@ protected def copy (f : Dilation α β) (f' : α → β) (h : f' = ⇑f) : Dilat
 
 #print Dilation.copy_eq_self /-
 theorem copy_eq_self (f : Dilation α β) {f' : α → β} (h : f' = f) : f.copy f' h = f :=
-  FunLike.ext' h
+  DFunLike.ext' h
 #align dilation.copy_eq_self Dilation.copy_eq_self
 -/
 
Diff
@@ -4,8 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Dilations of emetric and metric spaces
 Authors: Hanting Zhang
 -/
-import Mathbin.Topology.MetricSpace.Antilipschitz
-import Mathbin.Data.FunLike.Basic
+import Topology.MetricSpace.Antilipschitz
+import Data.FunLike.Basic
 
 #align_import topology.metric_space.dilation from "leanprover-community/mathlib"@"30faa0c3618ce1472bf6305ae0e3fa56affa3f95"
 
Diff
@@ -353,8 +353,8 @@ theorem coe_id : ⇑(Dilation.id α) = id :=
 #align dilation.coe_id Dilation.coe_id
 -/
 
-#print Dilation.id_ratio /-
-theorem id_ratio : ratio (Dilation.id α) = 1 :=
+#print Dilation.ratio_id /-
+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]
@@ -362,7 +362,7 @@ theorem id_ratio : ratio (Dilation.id α) = 1 :=
     rcases h with ⟨x, y, hne⟩
     refine' (ratio_unique hne.1 hne.2 _).symm
     simp
-#align dilation.id_ratio Dilation.id_ratio
+#align dilation.id_ratio Dilation.ratio_id
 -/
 
 #print Dilation.comp /-
@@ -396,12 +396,12 @@ theorem comp_apply (g : Dilation β γ) (f : Dilation α β) (x : α) : (g.comp
 #align dilation.comp_apply Dilation.comp_apply
 -/
 
-#print Dilation.comp_ratio /-
+#print Dilation.ratio_comp' /-
 /-- Ratio of the composition `g.comp f` of two dilations is the product of their ratios. We assume
 that the domain `α` of `f` is nontrivial, otherwise `ratio f = ratio (g.comp f) = 1` but `ratio g`
 may have any value. -/
 @[simp]
-theorem comp_ratio {g : Dilation β γ} {f : Dilation α β}
+theorem ratio_comp' {g : Dilation β γ} {f : Dilation α β}
     (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α⟩
@@ -409,7 +409,7 @@ theorem comp_ratio {g : Dilation β γ} {f : Dilation α β}
   simp only [dist_eq, coe_comp, ← mul_assoc, mul_eq_mul_right_iff] at hgf 
   rw [edist_eq, edist_eq, ← mul_assoc, ENNReal.mul_eq_mul_right hα.1 hα.2] at hgf 
   rwa [← ENNReal.coe_eq_coe, ENNReal.coe_mul]
-#align dilation.comp_ratio Dilation.comp_ratio
+#align dilation.comp_ratio Dilation.ratio_comp'
 -/
 
 #print Dilation.comp_id /-
Diff
@@ -3,15 +3,12 @@ Copyright (c) 2022 Hanting Zhang. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Dilations of emetric and metric spaces
 Authors: Hanting Zhang
-
-! This file was ported from Lean 3 source module topology.metric_space.dilation
-! leanprover-community/mathlib commit 30faa0c3618ce1472bf6305ae0e3fa56affa3f95
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Topology.MetricSpace.Antilipschitz
 import Mathbin.Data.FunLike.Basic
 
+#align_import topology.metric_space.dilation from "leanprover-community/mathlib"@"30faa0c3618ce1472bf6305ae0e3fa56affa3f95"
+
 /-!
 # Dilations
 
Diff
@@ -5,7 +5,7 @@ Dilations of emetric and metric spaces
 Authors: Hanting Zhang
 
 ! This file was ported from Lean 3 source module topology.metric_space.dilation
-! leanprover-community/mathlib commit 93f880918cb51905fd51b76add8273cbc27718ab
+! leanprover-community/mathlib commit 30faa0c3618ce1472bf6305ae0e3fa56affa3f95
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -15,6 +15,9 @@ import Mathbin.Data.FunLike.Basic
 /-!
 # Dilations
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 We define dilations, i.e., maps between emetric spaces that satisfy
 `edist (f x) (f y) = r * edist x y` for some `r ∉ {0, ∞}`.
 
Diff
@@ -59,12 +59,15 @@ section Defs
 
 variable (α : Type _) (β : Type _) [PseudoEMetricSpace α] [PseudoEMetricSpace β]
 
+#print Dilation /-
 /-- 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 (to_fun x) (to_fun y) = r * edist x y
 #align dilation Dilation
+-/
 
+#print DilationClass /-
 /-- `dilation_class F α β r` states that `F` is a type of `r`-dilations.
 You should extend this typeclass when you extend `dilation`.
 -/
@@ -72,6 +75,7 @@ class DilationClass (F : Type _) (α β : outParam <| Type _) [PseudoEMetricSpac
     [PseudoEMetricSpace β] extends FunLike F α fun _ => β where
   edist_eq' : ∀ f : F, ∃ r : ℝ≥0, r ≠ 0 ∧ ∀ x y : α, edist (f x) (f y) = r * edist x y
 #align dilation_class DilationClass
+-/
 
 end Defs
 
@@ -83,48 +87,65 @@ section Setup
 
 variable [PseudoEMetricSpace α] [PseudoEMetricSpace β]
 
+#print Dilation.toDilationClass /-
 instance toDilationClass : DilationClass (Dilation α β) α β
     where
   coe := toFun
   coe_injective' f g h := by cases f <;> cases g <;> congr
   edist_eq' f := edist_eq' f
 #align dilation.to_dilation_class Dilation.toDilationClass
+-/
 
 instance : CoeFun (Dilation α β) fun _ => α → β :=
   FunLike.hasCoeToFun
 
+#print Dilation.toFun_eq_coe /-
 @[simp]
 theorem toFun_eq_coe {f : Dilation α β} : f.toFun = (f : α → β) :=
   rfl
 #align dilation.to_fun_eq_coe Dilation.toFun_eq_coe
+-/
 
+#print Dilation.coe_mk /-
 @[simp]
 theorem coe_mk (f : α → β) (h) : ⇑(⟨f, h⟩ : Dilation α β) = f :=
   rfl
 #align dilation.coe_mk Dilation.coe_mk
+-/
 
+#print Dilation.congr_fun /-
 theorem congr_fun {f g : Dilation α β} (h : f = g) (x : α) : f x = g x :=
   FunLike.congr_fun h x
 #align dilation.congr_fun Dilation.congr_fun
+-/
 
+#print Dilation.congr_arg /-
 theorem congr_arg (f : Dilation α β) {x y : α} (h : x = y) : f x = f y :=
   FunLike.congr_arg f h
 #align dilation.congr_arg Dilation.congr_arg
+-/
 
+#print Dilation.ext /-
 @[ext]
 theorem ext {f g : Dilation α β} (h : ∀ x, f x = g x) : f = g :=
   FunLike.ext f g h
 #align dilation.ext Dilation.ext
+-/
 
+#print Dilation.ext_iff /-
 theorem ext_iff {f g : Dilation α β} : f = g ↔ ∀ x, f x = g x :=
   FunLike.ext_iff
 #align dilation.ext_iff Dilation.ext_iff
+-/
 
+#print Dilation.mk_coe /-
 @[simp]
 theorem mk_coe (f : Dilation α β) (h) : Dilation.mk f h = f :=
   ext fun _ => rfl
 #align dilation.mk_coe Dilation.mk_coe
+-/
 
+#print Dilation.copy /-
 /-- Copy of a `dilation` with a new `to_fun` equal to the old one. Useful to fix definitional
 equalities. -/
 @[simps (config := { fullyApplied := false })]
@@ -133,28 +154,38 @@ protected def copy (f : Dilation α β) (f' : α → β) (h : f' = ⇑f) : Dilat
   toFun := f'
   edist_eq' := h.symm ▸ f.edist_eq'
 #align dilation.copy Dilation.copy
+-/
 
+#print Dilation.copy_eq_self /-
 theorem copy_eq_self (f : Dilation α β) {f' : α → β} (h : f' = f) : f.copy f' h = f :=
   FunLike.ext' h
 #align dilation.copy_eq_self Dilation.copy_eq_self
+-/
 
+#print Dilation.ratio /-
 /-- 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).some
 #align dilation.ratio Dilation.ratio
+-/
 
+#print Dilation.ratio_ne_zero /-
 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
 #align dilation.ratio_ne_zero Dilation.ratio_ne_zero
+-/
 
+#print Dilation.ratio_pos /-
 theorem ratio_pos [DilationClass F α β] (f : F) : 0 < ratio f :=
   (ratio_ne_zero f).bot_lt
 #align dilation.ratio_pos Dilation.ratio_pos
+-/
 
+#print Dilation.edist_eq /-
 @[simp]
 theorem edist_eq [DilationClass F α β] (f : F) (x y : α) :
     edist (f x) (f y) = ratio f * edist x y :=
@@ -167,26 +198,34 @@ theorem edist_eq [DilationClass F α β] (f : F) (x y : α) :
     · simp [hr, h, hne]
   exact (DilationClass.edist_eq' f).choose_spec.2 x y
 #align dilation.edist_eq Dilation.edist_eq
+-/
 
+#print Dilation.nndist_eq /-
 @[simp]
 theorem nndist_eq {α β F : Type _} [PseudoMetricSpace α] [PseudoMetricSpace β] [DilationClass F α β]
     (f : F) (x y : α) : nndist (f x) (f y) = ratio f * nndist x y := by
   simp only [← ENNReal.coe_eq_coe, ← edist_nndist, ENNReal.coe_mul, edist_eq]
 #align dilation.nndist_eq Dilation.nndist_eq
+-/
 
+#print Dilation.dist_eq /-
 @[simp]
 theorem dist_eq {α β F : Type _} [PseudoMetricSpace α] [PseudoMetricSpace β] [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]
 #align dilation.dist_eq Dilation.dist_eq
+-/
 
+#print Dilation.ratio_unique /-
 /-- 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_eq_coe] using edist_eq f x y
 #align dilation.ratio_unique Dilation.ratio_unique
+-/
 
+#print Dilation.ratio_unique_of_nndist_ne_zero /-
 /-- 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 β]
@@ -195,7 +234,9 @@ theorem ratio_unique_of_nndist_ne_zero {α β F : Type _} [PseudoMetricSpace α]
   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])
 #align dilation.ratio_unique_of_nndist_ne_zero Dilation.ratio_unique_of_nndist_ne_zero
+-/
 
+#print Dilation.ratio_unique_of_dist_ne_zero /-
 /-- 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 β]
@@ -204,9 +245,11 @@ theorem ratio_unique_of_dist_ne_zero {α β} {F : Type _} [PseudoMetricSpace α]
   ratio_unique_of_nndist_ne_zero (NNReal.coe_ne_zero.1 hxy) <|
     NNReal.eq <| by rw [coe_nndist, hr, NNReal.coe_mul, coe_nndist]
 #align dilation.ratio_unique_of_dist_ne_zero Dilation.ratio_unique_of_dist_ne_zero
+-/
 
+#print Dilation.mkOfNNDistEq /-
 /-- Alternative `dilation` constructor when the distance hypothesis is over `nndist` -/
-def mkOfNndistEq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α → β)
+def mkOfNNDistEq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α → β)
     (h : ∃ r : ℝ≥0, r ≠ 0 ∧ ∀ x y : α, nndist (f x) (f y) = r * nndist x y) : Dilation α β
     where
   toFun := f
@@ -214,39 +257,50 @@ def mkOfNndistEq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α 
     rcases h with ⟨r, hne, h⟩
     refine' ⟨r, hne, fun x y => _⟩
     rw [edist_nndist, edist_nndist, ← ENNReal.coe_mul, h x y]
-#align dilation.mk_of_nndist_eq Dilation.mkOfNndistEq
+#align dilation.mk_of_nndist_eq Dilation.mkOfNNDistEq
+-/
 
+#print Dilation.coe_mkOfNNDistEq /-
 @[simp]
-theorem coe_mkOfNndistEq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α → β) (h) :
-    ⇑(mkOfNndistEq f h : Dilation α β) = f :=
+theorem coe_mkOfNNDistEq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α → β) (h) :
+    ⇑(mkOfNNDistEq f h : Dilation α β) = f :=
   rfl
-#align dilation.coe_mk_of_nndist_eq Dilation.coe_mkOfNndistEq
+#align dilation.coe_mk_of_nndist_eq Dilation.coe_mkOfNNDistEq
+-/
 
+#print Dilation.mk_coe_of_nndist_eq /-
 @[simp]
 theorem mk_coe_of_nndist_eq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : Dilation α β)
-    (h) : Dilation.mkOfNndistEq f h = f :=
+    (h) : Dilation.mkOfNNDistEq f h = f :=
   ext fun _ => rfl
 #align dilation.mk_coe_of_nndist_eq Dilation.mk_coe_of_nndist_eq
+-/
 
+#print Dilation.mkOfDistEq /-
 /-- 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) : Dilation α β :=
-  mkOfNndistEq f <|
+  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]⟩
 #align dilation.mk_of_dist_eq Dilation.mkOfDistEq
+-/
 
+#print Dilation.coe_mkOfDistEq /-
 @[simp]
 theorem coe_mkOfDistEq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α → β) (h) :
     ⇑(mkOfDistEq f h : Dilation α β) = f :=
   rfl
 #align dilation.coe_mk_of_dist_eq Dilation.coe_mkOfDistEq
+-/
 
+#print Dilation.mk_coe_of_dist_eq /-
 @[simp]
 theorem mk_coe_of_dist_eq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : Dilation α β) (h) :
     Dilation.mkOfDistEq f h = f :=
   ext fun _ => rfl
 #align dilation.mk_coe_of_dist_eq Dilation.mk_coe_of_dist_eq
+-/
 
 end Setup
 
@@ -258,37 +312,48 @@ variable [DilationClass F α β] [DilationClass G β γ]
 
 variable (f : F) (g : G) {x y z : α} {s : Set α}
 
+#print Dilation.lipschitz /-
 theorem lipschitz : LipschitzWith (ratio f) (f : α → β) := fun x y => (edist_eq f x y).le
 #align dilation.lipschitz Dilation.lipschitz
+-/
 
+#print Dilation.antilipschitz /-
 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
 #align dilation.antilipschitz Dilation.antilipschitz
+-/
 
+#print Dilation.injective /-
 /-- A dilation from an emetric space is injective -/
 protected theorem injective {α : Type _} [EMetricSpace α] [DilationClass F α β] (f : F) :
     Injective f :=
   (antilipschitz f).Injective
 #align dilation.injective Dilation.injective
+-/
 
+#print Dilation.id /-
 /-- The identity is a dilation -/
 protected def id (α) [PseudoEMetricSpace α] : Dilation α α
     where
   toFun := id
   edist_eq' := ⟨1, one_ne_zero, fun x y => by simp only [id.def, ENNReal.coe_one, one_mul]⟩
 #align dilation.id Dilation.id
+-/
 
 instance : Inhabited (Dilation α α) :=
   ⟨Dilation.id α⟩
 
+#print Dilation.coe_id /-
 @[simp, protected]
 theorem coe_id : ⇑(Dilation.id α) = id :=
   rfl
 #align dilation.coe_id Dilation.coe_id
+-/
 
+#print Dilation.id_ratio /-
 theorem id_ratio : ratio (Dilation.id α) = 1 :=
   by
   by_cases h : ∀ x y : α, edist x y = 0 ∨ edist x y = ∞
@@ -298,7 +363,9 @@ theorem id_ratio : ratio (Dilation.id α) = 1 :=
     refine' (ratio_unique hne.1 hne.2 _).symm
     simp
 #align dilation.id_ratio Dilation.id_ratio
+-/
 
+#print Dilation.comp /-
 /-- The composition of dilations is a dilation -/
 def comp (g : Dilation β γ) (f : Dilation α β) : Dilation α γ
     where
@@ -307,21 +374,29 @@ def comp (g : Dilation β γ) (f : Dilation α β) : Dilation α γ
     ⟨ratio g * ratio f, mul_ne_zero (ratio_ne_zero g) (ratio_ne_zero f), fun x y => by
       simp only [edist_eq, ENNReal.coe_mul]; ring⟩
 #align dilation.comp Dilation.comp
+-/
 
+#print Dilation.comp_assoc /-
 theorem comp_assoc {δ : Type _} [PseudoEMetricSpace δ] (f : Dilation α β) (g : Dilation β γ)
     (h : Dilation γ δ) : (h.comp g).comp f = h.comp (g.comp f) :=
   rfl
 #align dilation.comp_assoc Dilation.comp_assoc
+-/
 
+#print Dilation.coe_comp /-
 @[simp]
 theorem coe_comp (g : Dilation β γ) (f : Dilation α β) : (g.comp f : α → γ) = g ∘ f :=
   rfl
 #align dilation.coe_comp Dilation.coe_comp
+-/
 
+#print Dilation.comp_apply /-
 theorem comp_apply (g : Dilation β γ) (f : Dilation α β) (x : α) : (g.comp f : α → γ) x = g (f x) :=
   rfl
 #align dilation.comp_apply Dilation.comp_apply
+-/
 
+#print Dilation.comp_ratio /-
 /-- Ratio of the composition `g.comp f` of two dilations is the product of their ratios. We assume
 that the domain `α` of `f` is nontrivial, otherwise `ratio f = ratio (g.comp f) = 1` but `ratio g`
 may have any value. -/
@@ -335,16 +410,21 @@ theorem comp_ratio {g : Dilation β γ} {f : Dilation α β}
   rw [edist_eq, edist_eq, ← mul_assoc, ENNReal.mul_eq_mul_right hα.1 hα.2] at hgf 
   rwa [← ENNReal.coe_eq_coe, ENNReal.coe_mul]
 #align dilation.comp_ratio Dilation.comp_ratio
+-/
 
+#print Dilation.comp_id /-
 @[simp]
 theorem comp_id (f : Dilation α β) : f.comp (Dilation.id α) = f :=
   ext fun x => rfl
 #align dilation.comp_id Dilation.comp_id
+-/
 
+#print Dilation.id_comp /-
 @[simp]
 theorem id_comp (f : Dilation α β) : (Dilation.id β).comp f = f :=
   ext fun x => rfl
 #align dilation.id_comp Dilation.id_comp
+-/
 
 instance : Monoid (Dilation α α) where
   one := Dilation.id α
@@ -353,49 +433,68 @@ instance : Monoid (Dilation α α) where
   one_mul := id_comp
   mul_assoc f g h := comp_assoc _ _ _
 
+#print Dilation.one_def /-
 theorem one_def : (1 : Dilation α α) = Dilation.id α :=
   rfl
 #align dilation.one_def Dilation.one_def
+-/
 
+#print Dilation.mul_def /-
 theorem mul_def (f g : Dilation α α) : f * g = f.comp g :=
   rfl
 #align dilation.mul_def Dilation.mul_def
+-/
 
+#print Dilation.coe_one /-
 @[simp]
 theorem coe_one : ⇑(1 : Dilation α α) = id :=
   rfl
 #align dilation.coe_one Dilation.coe_one
+-/
 
+#print Dilation.coe_mul /-
 @[simp]
 theorem coe_mul (f g : Dilation α α) : ⇑(f * g) = f ∘ g :=
   rfl
 #align dilation.coe_mul Dilation.coe_mul
+-/
 
+#print Dilation.cancel_right /-
 theorem cancel_right {g₁ g₂ : Dilation β γ} {f : Dilation α β} (hf : Surjective f) :
     g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
   ⟨fun h => Dilation.ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
 #align dilation.cancel_right Dilation.cancel_right
+-/
 
+#print Dilation.cancel_left /-
 theorem cancel_left {g : Dilation β γ} {f₁ f₂ : Dilation α β} (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⟩
 #align dilation.cancel_left Dilation.cancel_left
+-/
 
+#print Dilation.uniformInducing /-
 /-- A dilation from a metric space is a uniform inducing map -/
 protected theorem uniformInducing : UniformInducing (f : α → β) :=
   (antilipschitz f).UniformInducing (lipschitz f).UniformContinuous
 #align dilation.uniform_inducing Dilation.uniformInducing
+-/
 
+#print Dilation.tendsto_nhds_iff /-
 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
 #align dilation.tendsto_nhds_iff Dilation.tendsto_nhds_iff
+-/
 
+#print Dilation.toContinuous /-
 /-- A dilation is continuous. -/
-theorem to_continuous : Continuous (f : α → β) :=
+theorem toContinuous : Continuous (f : α → β) :=
   (lipschitz f).Continuous
-#align dilation.to_continuous Dilation.to_continuous
+#align dilation.to_continuous Dilation.toContinuous
+-/
 
+#print Dilation.ediam_image /-
 /-- 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
@@ -404,34 +503,45 @@ theorem ediam_image (s : Set α) : EMetric.diam ((f : α → β) '' s) = ratio f
   rw [div_eq_mul_inv, mul_comm, ← ENNReal.coe_inv]
   exacts [(antilipschitz f).le_mul_ediam_image s, ratio_ne_zero f]
 #align dilation.ediam_image Dilation.ediam_image
+-/
 
+#print Dilation.ediam_range /-
 /-- 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
 #align dilation.ediam_range Dilation.ediam_range
+-/
 
+#print Dilation.mapsTo_emetric_ball /-
 /-- 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
 #align dilation.maps_to_emetric_ball Dilation.mapsTo_emetric_ball
+-/
 
+#print Dilation.mapsTo_emetric_closedBall /-
 /-- 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')) :=
   fun y hy => (edist_eq f y x).trans_le <| mul_le_mul_left' hy _
 #align dilation.maps_to_emetric_closed_ball Dilation.mapsTo_emetric_closedBall
+-/
 
+#print Dilation.comp_continuousOn_iff /-
 theorem comp_continuousOn_iff {γ} [TopologicalSpace γ] {g : γ → α} {s : Set γ} :
     ContinuousOn ((f : α → β) ∘ g) s ↔ ContinuousOn g s :=
   (Dilation.uniformInducing f).Inducing.continuousOn_iff.symm
 #align dilation.comp_continuous_on_iff Dilation.comp_continuousOn_iff
+-/
 
+#print Dilation.comp_continuous_iff /-
 theorem comp_continuous_iff {γ} [TopologicalSpace γ] {g : γ → α} :
     Continuous ((f : α → β) ∘ g) ↔ Continuous g :=
   (Dilation.uniformInducing f).Inducing.continuous_iff.symm
 #align dilation.comp_continuous_iff Dilation.comp_continuous_iff
+-/
 
 end PseudoEmetricDilation
 
@@ -440,23 +550,29 @@ section EmetricDilation
 
 variable [EMetricSpace α]
 
+#print Dilation.uniformEmbedding /-
 /-- 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
 #align dilation.uniform_embedding Dilation.uniformEmbedding
+-/
 
+#print Dilation.embedding /-
 /-- A dilation from a metric space is an embedding -/
 protected theorem embedding [PseudoEMetricSpace β] [DilationClass F α β] (f : F) :
     Embedding (f : α → β) :=
   (Dilation.uniformEmbedding f).Embedding
 #align dilation.embedding Dilation.embedding
+-/
 
+#print Dilation.closedEmbedding /-
 /-- 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
 #align dilation.closed_embedding Dilation.closedEmbedding
+-/
 
 end EmetricDilation
 
@@ -465,32 +581,42 @@ section PseudoMetricDilation
 
 variable [PseudoMetricSpace α] [PseudoMetricSpace β] [DilationClass F α β] (f : F)
 
+#print Dilation.diam_image /-
 /-- 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]
 #align dilation.diam_image Dilation.diam_image
+-/
 
+#print Dilation.diam_range /-
 theorem diam_range : Metric.diam (range (f : α → β)) = ratio f * Metric.diam (univ : Set α) := by
   rw [← image_univ, diam_image]
 #align dilation.diam_range Dilation.diam_range
+-/
 
+#print Dilation.mapsTo_ball /-
 /-- 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
 #align dilation.maps_to_ball Dilation.mapsTo_ball
+-/
 
+#print Dilation.mapsTo_sphere /-
 /-- 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
 #align dilation.maps_to_sphere Dilation.mapsTo_sphere
+-/
 
+#print Dilation.mapsTo_closedBall /-
 /-- 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 _)
 #align dilation.maps_to_closed_ball Dilation.mapsTo_closedBall
+-/
 
 end PseudoMetricDilation
 

Changes in mathlib4

mathlib3
mathlib4
chore: avoid id.def (adaptation for nightly-2024-03-27) (#11829)

Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com>

Diff
@@ -301,7 +301,7 @@ protected theorem injective {α : Type*} [EMetricSpace α] [FunLike F α β]  [D
 /-- 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.def, ENNReal.coe_one, one_mul]⟩
+  edist_eq' := ⟨1, one_ne_zero, fun x y => by simp only [id, ENNReal.coe_one, one_mul]⟩
 #align dilation.id Dilation.id
 
 instance : Inhabited (α →ᵈ α) :=
chore(*): remove empty lines between variable statements (#11418)

Empty lines were removed by executing the following Python script twice

import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
Diff
@@ -265,9 +265,7 @@ 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`. -/
feat: Make the coercion ℝ≥0 → ℝ≥0∞ commute defeqly with nsmul and pow (#10225)

by tweaking the definition of the AddMonoid and MonoidWithZero instances for WithTop. Also unprotect ENNReal.coe_injective and rename ENNReal.coe_eq_coe → ENNReal.coe_inj.

From LeanAPAP

Diff
@@ -1,7 +1,6 @@
 /-
 Copyright (c) 2022 Hanting Zhang. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
-Dilations of emetric and metric spaces
 Authors: Hanting Zhang
 -/
 import Mathlib.Topology.MetricSpace.Antilipschitz
@@ -184,7 +183,7 @@ theorem edist_eq [DilationClass F α β] (f : F) (x y : α) :
 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_eq_coe, ← edist_nndist, ENNReal.coe_mul, edist_eq]
+  simp only [← ENNReal.coe_inj, ← edist_nndist, ENNReal.coe_mul, edist_eq]
 #align dilation.nndist_eq Dilation.nndist_eq
 
 @[simp]
@@ -198,7 +197,7 @@ theorem dist_eq {α β F : Type*} [PseudoMetricSpace α] [PseudoMetricSpace β]
 `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_eq_coe] using edist_eq f x y
+  simpa only [hr, ENNReal.mul_eq_mul_right h₀ htop, ENNReal.coe_inj] using edist_eq f x y
 #align dilation.ratio_unique Dilation.ratio_unique
 
 /-- The `ratio` is equal to the distance ratio for any two points
@@ -357,7 +356,7 @@ theorem ratio_comp' {g : β →ᵈ γ} {f : α →ᵈ β}
   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_eq_coe, ENNReal.coe_mul]
+  rwa [← ENNReal.coe_inj, ENNReal.coe_mul]
 #align dilation.comp_ratio Dilation.ratio_comp'
 
 @[simp]
doc: fix typos (#10296)

Fixed minor typos.

Diff
@@ -22,7 +22,7 @@ injective. The value `r = ∞` is not allowed because this way we can define `Di
 not `Dilation.ratio f : ℝ≥0∞`. Also, we do not often need maps sending distinct points to points at
 infinite distance.
 
-## Main defintions
+## 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.
@@ -34,7 +34,7 @@ infinite distance.
 ## 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 choosen to match the Wikipedia name.
+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
refactor(Data/FunLike): use unbundled inheritance from FunLike (#8386)

The FunLike hierarchy is very big and gets scanned through each time we need a coercion (via the CoeFun instance). It looks like unbundled inheritance suits Lean 4 better here. The only class that still extends FunLike is EquivLike, since that has a custom coe_injective' field that is easier to implement. All other classes should take FunLike or EquivLike as a parameter.

Zulip thread

Important changes

Previously, morphism classes would be Type-valued and extend FunLike:

/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
  extends FunLike F A B :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))

After this PR, they should be Prop-valued and take FunLike as a parameter:

/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
  [FunLike F A B] : Prop :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))

(Note that A B stay marked as outParam even though they are not purely required to be so due to the FunLike parameter already filling them in. This is required to see through type synonyms, which is important in the category theory library. Also, I think keeping them as outParam is slightly faster.)

Similarly, MyEquivClass should take EquivLike as a parameter.

As a result, every mention of [MyHomClass F A B] should become [FunLike F A B] [MyHomClass F A B].

Remaining issues

Slower (failing) search

While overall this gives some great speedups, there are some cases that are noticeably slower. In particular, a failing application of a lemma such as map_mul is more expensive. This is due to suboptimal processing of arguments. For example:

variable [FunLike F M N] [Mul M] [Mul N] (f : F) (x : M) (y : M)

theorem map_mul [MulHomClass F M N] : f (x * y) = f x * f y

example [AddHomClass F A B] : f (x * y) = f x * f y := map_mul f _ _

Before this PR, applying map_mul f gives the goals [Mul ?M] [Mul ?N] [MulHomClass F ?M ?N]. Since M and N are out_params, [MulHomClass F ?M ?N] is synthesized first, supplies values for ?M and ?N and then the Mul M and Mul N instances can be found.

After this PR, the goals become [FunLike F ?M ?N] [Mul ?M] [Mul ?N] [MulHomClass F ?M ?N]. Now [FunLike F ?M ?N] is synthesized first, supplies values for ?M and ?N and then the Mul M and Mul N instances can be found, before trying MulHomClass F M N which fails. Since the Mul hierarchy is very big, this can be slow to fail, especially when there is no such Mul instance.

A long-term but harder to achieve solution would be to specify the order in which instance goals get solved. For example, we'd like to change the arguments to map_mul to look like [FunLike F M N] [Mul M] [Mul N] [highPriority <| MulHomClass F M N] because MulHomClass fails or succeeds much faster than the others.

As a consequence, the simpNF linter is much slower since by design it tries and fails to apply many map_ lemmas. The same issue occurs a few times in existing calls to simp [map_mul], where map_mul is tried "too soon" and fails. Thanks to the speedup of leanprover/lean4#2478 the impact is very limited, only in files that already were close to the timeout.

simp not firing sometimes

This affects map_smulₛₗ and related definitions. For simp lemmas Lean apparently uses a slightly different mechanism to find instances, so that rw can find every argument to map_smulₛₗ successfully but simp can't: leanprover/lean4#3701.

Missing instances due to unification failing

Especially in the category theory library, we might sometimes have a type A which is also accessible as a synonym (Bundled A hA).1. Instance synthesis doesn't always work if we have f : A →* B but x * y : (Bundled A hA).1 or vice versa. This seems to be mostly fixed by keeping A B as outParams in MulHomClass F A B. (Presumably because Lean will do a definitional check A =?= (Bundled A hA).1 instead of using the syntax in the discrimination tree.)

Workaround for issues

The timeouts can be worked around for now by specifying which map_mul we mean, either as map_mul f for some explicit f, or as e.g. MonoidHomClass.map_mul.

map_smulₛₗ not firing as simp lemma can be worked around by going back to the pre-FunLike situation and making LinearMap.map_smulₛₗ a simp lemma instead of the generic map_smulₛₗ. Writing simp [map_smulₛₗ _] also works.

Co-authored-by: Matthew Ballard <matt@mrb.email> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Scott Morrison <scott@tqft.net> Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>

Diff
@@ -72,8 +72,8 @@ 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*) (α β : outParam <| Type*) [PseudoEMetricSpace α]
-    [PseudoEMetricSpace β] extends DFunLike F α fun _ => β where
+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
 #align dilation_class DilationClass
 
@@ -87,9 +87,11 @@ section Setup
 
 variable [PseudoEMetricSpace α] [PseudoEMetricSpace β]
 
-instance toDilationClass : DilationClass (α →ᵈ β) α β where
+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
 #align dilation.to_dilation_class Dilation.toDilationClass
 
@@ -140,6 +142,8 @@ theorem copy_eq_self (f : α →ᵈ β) {f' : α → β} (h : f' = f) : f.copy f
   DFunLike.ext' h
 #align dilation.copy_eq_self Dilation.copy_eq_self
 
+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 :=
@@ -177,14 +181,16 @@ theorem edist_eq [DilationClass F α β] (f : F) (x y : α) :
 #align dilation.edist_eq Dilation.edist_eq
 
 @[simp]
-theorem nndist_eq {α β F : Type*} [PseudoMetricSpace α] [PseudoMetricSpace β] [DilationClass F α β]
-    (f : F) (x y : α) : nndist (f x) (f y) = ratio f * nndist x y := by
+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_eq_coe, ← edist_nndist, ENNReal.coe_mul, edist_eq]
 #align dilation.nndist_eq Dilation.nndist_eq
 
 @[simp]
-theorem dist_eq {α β F : Type*} [PseudoMetricSpace α] [PseudoMetricSpace β] [DilationClass F α β]
-    (f : F) (x y : α) : dist (f x) (f y) = ratio f * dist x y := by
+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]
 #align dilation.dist_eq Dilation.dist_eq
 
@@ -198,7 +204,7 @@ theorem ratio_unique [DilationClass F α β] {f : F} {x y : α} {r : ℝ≥0} (h
 /-- 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 β]
-    [DilationClass F α β] {f : F} {x y : α} {r : ℝ≥0} (hxy : nndist x y ≠ 0)
+    [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])
@@ -207,7 +213,7 @@ theorem ratio_unique_of_nndist_ne_zero {α β F : Type*} [PseudoMetricSpace α]
 /-- 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 β]
-    [DilationClass F α β] {f : F} {x y : α} {r : ℝ≥0} (hxy : dist x y ≠ 0)
+    [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]
@@ -261,7 +267,7 @@ section PseudoEmetricDilation
 
 variable [PseudoEMetricSpace α] [PseudoEMetricSpace β] [PseudoEMetricSpace γ]
 
-variable [DilationClass F α β] [DilationClass G β γ]
+variable [FunLike F α β] [DilationClass F α β] [FunLike G β γ] [DilationClass G β γ]
 
 variable (f : F) (g : G) {x y z : α} {s : Set α}
 
@@ -289,7 +295,8 @@ theorem antilipschitz : AntilipschitzWith (ratio f)⁻¹ (f : α → β) := fun
 #align dilation.antilipschitz Dilation.antilipschitz
 
 /-- A dilation from an emetric space is injective -/
-protected theorem injective {α : Type*} [EMetricSpace α] [DilationClass F α β] (f : F) :
+protected theorem injective {α : Type*} [EMetricSpace α] [FunLike F α β]  [DilationClass F α β]
+    (f : F) :
     Injective f :=
   (antilipschitz f).injective
 #align dilation.injective Dilation.injective
@@ -474,6 +481,7 @@ 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) :
@@ -508,7 +516,7 @@ theorem ratio_comp [MetricSpace α] [Nontrivial α] [PseudoEMetricSpace β]
 
 section PseudoMetricDilation
 
-variable [PseudoMetricSpace α] [PseudoMetricSpace β] [DilationClass F α β] (f : F)
+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
feat: link Dilation to Isometry and Homeomorph (#9980)
Diff
@@ -4,8 +4,9 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Dilations of emetric and metric spaces
 Authors: Hanting Zhang
 -/
-import Mathlib.Topology.MetricSpace.Lipschitz
 import Mathlib.Topology.MetricSpace.Antilipschitz
+import Mathlib.Topology.MetricSpace.Isometry
+import Mathlib.Topology.MetricSpace.Lipschitz
 import Mathlib.Data.FunLike.Basic
 
 #align_import topology.metric_space.dilation from "leanprover-community/mathlib"@"93f880918cb51905fd51b76add8273cbc27718ab"
@@ -264,6 +265,20 @@ variable [DilationClass F α β] [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
 #align dilation.lipschitz Dilation.lipschitz
 
chore: reduce imports (#9830)

This uses the improved shake script from #9772 to reduce imports across mathlib. The corresponding noshake.json file has been added to #9772.

Co-authored-by: Mario Carneiro <di.gama@gmail.com>

Diff
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Dilations of emetric and metric spaces
 Authors: Hanting Zhang
 -/
+import Mathlib.Topology.MetricSpace.Lipschitz
 import Mathlib.Topology.MetricSpace.Antilipschitz
 import Mathlib.Data.FunLike.Basic
 
chore(*): rename FunLike to DFunLike (#9785)

This prepares for the introduction of a non-dependent synonym of FunLike, which helps a lot with keeping #8386 readable.

This is entirely search-and-replace in 680197f combined with manual fixes in 4145626, e900597 and b8428f8. The commands that generated this change:

sed -i 's/\bFunLike\b/DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoFunLike\b/toDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/import Mathlib.Data.DFunLike/import Mathlib.Data.FunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bHom_FunLike\b/Hom_DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean     
sed -i 's/\binstFunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bfunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoo many metavariables to apply `fun_like.has_coe_to_fun`/too many metavariables to apply `DFunLike.hasCoeToFun`/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean

Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>

Diff
@@ -71,7 +71,7 @@ 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*) (α β : outParam <| Type*) [PseudoEMetricSpace α]
-    [PseudoEMetricSpace β] extends FunLike F α fun _ => β where
+    [PseudoEMetricSpace β] extends DFunLike F α fun _ => β where
   edist_eq' : ∀ f : F, ∃ r : ℝ≥0, r ≠ 0 ∧ ∀ x y : α, edist (f x) (f y) = r * edist x y
 #align dilation_class DilationClass
 
@@ -92,7 +92,7 @@ instance toDilationClass : DilationClass (α →ᵈ β) α β where
 #align dilation.to_dilation_class Dilation.toDilationClass
 
 instance : CoeFun (α →ᵈ β) fun _ => α → β :=
-  FunLike.hasCoeToFun
+  DFunLike.hasCoeToFun
 
 @[simp]
 theorem toFun_eq_coe {f : α →ᵈ β} : f.toFun = (f : α → β) :=
@@ -105,20 +105,20 @@ theorem coe_mk (f : α → β) (h) : ⇑(⟨f, h⟩ : α →ᵈ β) = f :=
 #align dilation.coe_mk Dilation.coe_mk
 
 theorem congr_fun {f g : α →ᵈ β} (h : f = g) (x : α) : f x = g x :=
-  FunLike.congr_fun h x
+  DFunLike.congr_fun h x
 #align dilation.congr_fun Dilation.congr_fun
 
 theorem congr_arg (f : α →ᵈ β) {x y : α} (h : x = y) : f x = f y :=
-  FunLike.congr_arg f h
+  DFunLike.congr_arg f h
 #align dilation.congr_arg Dilation.congr_arg
 
 @[ext]
 theorem ext {f g : α →ᵈ β} (h : ∀ x, f x = g x) : f = g :=
-  FunLike.ext f g h
+  DFunLike.ext f g h
 #align dilation.ext Dilation.ext
 
 theorem ext_iff {f g : α →ᵈ β} : f = g ↔ ∀ x, f x = g x :=
-  FunLike.ext_iff
+  DFunLike.ext_iff
 #align dilation.ext_iff Dilation.ext_iff
 
 @[simp]
@@ -135,7 +135,7 @@ protected def copy (f : α →ᵈ β) (f' : α → β) (h : f' = ⇑f) : α →
 #align dilation.copy Dilation.copy
 
 theorem copy_eq_self (f : α →ᵈ β) {f' : α → β} (h : f' = f) : f.copy f' h = f :=
-  FunLike.ext' h
+  DFunLike.ext' h
 #align dilation.copy_eq_self Dilation.copy_eq_self
 
 /-- The ratio of a dilation `f`. If the ratio is undefined (i.e., the distance between any two
chore(*): drop $/<| before fun (#9361)

Subset of #9319

Diff
@@ -150,7 +150,7 @@ theorem ratio_of_trivial [DilationClass F α β] (f : F)
 
 @[nontriviality]
 theorem ratio_of_subsingleton [Subsingleton α] [DilationClass F α β] (f : F) : ratio f = 1 :=
-  if_pos <| fun x y ↦ by simp [Subsingleton.elim x y]
+  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
refactor: get rid of comap norm atTop (#8262)

Co-authored-by: Jireh Loreaux <loreaujy@gmail.com>

Diff
@@ -52,7 +52,7 @@ needed.
 
 noncomputable section
 
-open Function Set
+open Function Set Bornology
 
 open scoped Topology ENNReal NNReal Classical
 
@@ -521,6 +521,13 @@ theorem mapsTo_closedBall (x : α) (r' : ℝ) :
   fun y hy => (dist_eq f y x).trans_le <| mul_le_mul_of_nonneg_left hy (NNReal.coe_nonneg _)
 #align dilation.maps_to_closed_ball Dilation.mapsTo_closedBall
 
+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
chore: replace exact_mod_cast tactic with mod_cast elaborator where possible (#8404)

We still have the exact_mod_cast tactic, used in a few places, which somehow (?) works a little bit harder to prevent the expected type influencing the elaboration of the term. I would like to get to the bottom of this, and it will be easier once the only usages of exact_mod_cast are the ones that don't work using the term elaborator by itself.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -268,7 +268,7 @@ theorem lipschitz : LipschitzWith (ratio f) (f : α → β) := fun x y => (edist
 
 theorem antilipschitz : AntilipschitzWith (ratio f)⁻¹ (f : α → β) := fun x y => by
   have hr : ratio f ≠ 0 := ratio_ne_zero f
-  exact_mod_cast
+  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
 #align dilation.antilipschitz Dilation.antilipschitz
 
style: shorten simps configurations (#8296)

Use .asFn and .lemmasOnly as simps configuration options.

For reference, these are defined here:

https://github.com/leanprover-community/mathlib4/blob/4055c8b471380825f07416b12cb0cf266da44d84/Mathlib/Tactic/Simps/Basic.lean#L843-L851

Diff
@@ -128,7 +128,7 @@ theorem mk_coe (f : α →ᵈ β) (h) : Dilation.mk f h = f :=
 
 /-- Copy of a `Dilation` with a new `toFun` equal to the old one. Useful to fix definitional
 equalities. -/
-@[simps (config := { fullyApplied := false })]
+@[simps (config := .asFn)]
 protected def copy (f : α →ᵈ β) (f' : α → β) (h : f' = ⇑f) : α →ᵈ β where
   toFun := f'
   edist_eq' := h.symm ▸ f.edist_eq'
chore: @[simp] cancel_(right|left) (#6300)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -389,11 +389,13 @@ def ratioHom : (α →ᵈ α) →* ℝ≥0 := ⟨⟨ratio, ratio_one⟩, ratio_m
 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 (ext_iff.1 h), fun h => h ▸ rfl⟩
 #align dilation.cancel_right Dilation.cancel_right
 
+@[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⟩
chore: drop MulZeroClass. in mul_zero/zero_mul (#6682)

Search&replace MulZeroClass.mul_zero -> mul_zero, MulZeroClass.zero_mul -> zero_mul.

These were introduced by Mathport, as the full name of mul_zero is actually MulZeroClass.mul_zero (it's exported with the short name).

Diff
@@ -169,7 +169,7 @@ theorem edist_eq [DilationClass F α β] (f : F) (x y : α) :
   · 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, MulZeroClass.mul_zero]
+    · simp only [hr, h, mul_zero]
     · simp [hr, h, hne]
   exact (DilationClass.edist_eq' f).choose_spec.2 x y
 #align dilation.edist_eq Dilation.edist_eq
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -58,7 +58,7 @@ open scoped Topology ENNReal NNReal Classical
 
 section Defs
 
-variable (α : Type _) (β : Type _) [PseudoEMetricSpace α] [PseudoEMetricSpace β]
+variable (α : Type*) (β : Type*) [PseudoEMetricSpace α] [PseudoEMetricSpace β]
 
 /-- A dilation is a map that uniformly scales the edistance between any two points. -/
 structure Dilation where
@@ -70,7 +70,7 @@ 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 _) (α β : outParam <| Type _) [PseudoEMetricSpace α]
+class DilationClass (F : Type*) (α β : outParam <| Type*) [PseudoEMetricSpace α]
     [PseudoEMetricSpace β] extends FunLike F α fun _ => β where
   edist_eq' : ∀ f : F, ∃ r : ℝ≥0, r ≠ 0 ∧ ∀ x y : α, edist (f x) (f y) = r * edist x y
 #align dilation_class DilationClass
@@ -79,7 +79,7 @@ end Defs
 
 namespace Dilation
 
-variable {α : Type _} {β : Type _} {γ : Type _} {F : Type _} {G : Type _}
+variable {α : Type*} {β : Type*} {γ : Type*} {F : Type*} {G : Type*}
 
 section Setup
 
@@ -175,13 +175,13 @@ theorem edist_eq [DilationClass F α β] (f : F) (x y : α) :
 #align dilation.edist_eq Dilation.edist_eq
 
 @[simp]
-theorem nndist_eq {α β F : Type _} [PseudoMetricSpace α] [PseudoMetricSpace β] [DilationClass F α β]
+theorem nndist_eq {α β F : Type*} [PseudoMetricSpace α] [PseudoMetricSpace β] [DilationClass F α β]
     (f : F) (x y : α) : nndist (f x) (f y) = ratio f * nndist x y := by
   simp only [← ENNReal.coe_eq_coe, ← edist_nndist, ENNReal.coe_mul, edist_eq]
 #align dilation.nndist_eq Dilation.nndist_eq
 
 @[simp]
-theorem dist_eq {α β F : Type _} [PseudoMetricSpace α] [PseudoMetricSpace β] [DilationClass F α β]
+theorem dist_eq {α β F : Type*} [PseudoMetricSpace α] [PseudoMetricSpace β] [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]
 #align dilation.dist_eq Dilation.dist_eq
@@ -195,7 +195,7 @@ theorem ratio_unique [DilationClass F α β] {f : F} {x y : α} {r : ℝ≥0} (h
 
 /-- 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 β]
+theorem ratio_unique_of_nndist_ne_zero {α β F : Type*} [PseudoMetricSpace α] [PseudoMetricSpace β]
     [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)
@@ -204,7 +204,7 @@ theorem ratio_unique_of_nndist_ne_zero {α β F : Type _} [PseudoMetricSpace α]
 
 /-- 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 β]
+theorem ratio_unique_of_dist_ne_zero {α β} {F : Type*} [PseudoMetricSpace α] [PseudoMetricSpace β]
     [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) <|
@@ -273,7 +273,7 @@ theorem antilipschitz : AntilipschitzWith (ratio f)⁻¹ (f : α → β) := fun
 #align dilation.antilipschitz Dilation.antilipschitz
 
 /-- A dilation from an emetric space is injective -/
-protected theorem injective {α : Type _} [EMetricSpace α] [DilationClass F α β] (f : F) :
+protected theorem injective {α : Type*} [EMetricSpace α] [DilationClass F α β] (f : F) :
     Injective f :=
   (antilipschitz f).injective
 #align dilation.injective Dilation.injective
@@ -308,7 +308,7 @@ def comp (g : β →ᵈ γ) (f : α →ᵈ β) : α →ᵈ γ where
     fun x y => by simp_rw [Function.comp, edist_eq, ENNReal.coe_mul, mul_assoc]⟩
 #align dilation.comp Dilation.comp
 
-theorem comp_assoc {δ : Type _} [PseudoEMetricSpace δ] (f : α →ᵈ β) (g : β →ᵈ γ)
+theorem comp_assoc {δ : Type*} [PseudoEMetricSpace δ] (f : α →ᵈ β) (g : β →ᵈ γ)
     (h : γ →ᵈ δ) : (h.comp g).comp f = h.comp (g.comp f) :=
   rfl
 #align dilation.comp_assoc Dilation.comp_assoc
@@ -404,7 +404,7 @@ protected theorem uniformInducing : UniformInducing (f : α → β) :=
   (antilipschitz f).uniformInducing (lipschitz f).uniformContinuous
 #align dilation.uniform_inducing Dilation.uniformInducing
 
-theorem tendsto_nhds_iff {ι : Type _} {g : ι → α} {a : Filter ι} {b : α} :
+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
 #align dilation.tendsto_nhds_iff Dilation.tendsto_nhds_iff
chore: fix grammar mistakes (#6121)
Diff
@@ -325,7 +325,7 @@ theorem comp_apply (g : β →ᵈ γ) (f : α →ᵈ β) (x : α) : (g.comp f :
 -- 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 by any number. This
+`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 : α →ᵈ β}
refactor: add notation for Dilation _ _, extend API (#5753)
  • add notation X →ᵈ Y for Dilation X Y;
  • add Dilation.ratio_of_trivial, Dilation.ratio_of_subsingleton;
  • rename Dilation.id_ratio to Dilation.ratio_id;
  • rename Dilation.comp_ratio to Dilation.ratio_comp', add Dilation.ratio_comp with TC assumptions instead of an explicit hypothesis;
  • add Dilation.ratio_mul, Dilation.ratio_one, Dilation.ratioHom, and Dilation.ratio_pow.
Diff
@@ -25,6 +25,10 @@ infinite distance.
 * `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"
@@ -37,7 +41,7 @@ needed.
 ## TODO
 
 - Introduce dilation equivs.
-- Refactor the `isometry` API to match the `*HomClass` API below.
+- Refactor the `Isometry` API to match the `*HomClass` API below.
 
 ## References
 
@@ -62,6 +66,8 @@ structure Dilation where
   edist_eq' : ∃ r : ℝ≥0, r ≠ 0 ∧ ∀ x y : α, edist (toFun x) (toFun y) = r * edist x y
 #align dilation Dilation
 
+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 _) (α β : outParam <| Type _) [PseudoEMetricSpace α]
@@ -79,56 +85,56 @@ section Setup
 
 variable [PseudoEMetricSpace α] [PseudoEMetricSpace β]
 
-instance toDilationClass : DilationClass (Dilation α β) α β where
+instance toDilationClass : DilationClass (α →ᵈ β) α β where
   coe := toFun
   coe_injective' f g h := by cases f; cases g; congr
   edist_eq' f := edist_eq' f
 #align dilation.to_dilation_class Dilation.toDilationClass
 
-instance : CoeFun (Dilation α β) fun _ => α → β :=
+instance : CoeFun (α →ᵈ β) fun _ => α → β :=
   FunLike.hasCoeToFun
 
 @[simp]
-theorem toFun_eq_coe {f : Dilation α β} : f.toFun = (f : α → β) :=
+theorem toFun_eq_coe {f : α →ᵈ β} : f.toFun = (f : α → β) :=
   rfl
 #align dilation.to_fun_eq_coe Dilation.toFun_eq_coe
 
 @[simp]
-theorem coe_mk (f : α → β) (h) : ⇑(⟨f, h⟩ : Dilation α β) = f :=
+theorem coe_mk (f : α → β) (h) : ⇑(⟨f, h⟩ : α →ᵈ β) = f :=
   rfl
 #align dilation.coe_mk Dilation.coe_mk
 
-theorem congr_fun {f g : Dilation α β} (h : f = g) (x : α) : f x = g x :=
+theorem congr_fun {f g : α →ᵈ β} (h : f = g) (x : α) : f x = g x :=
   FunLike.congr_fun h x
 #align dilation.congr_fun Dilation.congr_fun
 
-theorem congr_arg (f : Dilation α β) {x y : α} (h : x = y) : f x = f y :=
+theorem congr_arg (f : α →ᵈ β) {x y : α} (h : x = y) : f x = f y :=
   FunLike.congr_arg f h
 #align dilation.congr_arg Dilation.congr_arg
 
 @[ext]
-theorem ext {f g : Dilation α β} (h : ∀ x, f x = g x) : f = g :=
+theorem ext {f g : α →ᵈ β} (h : ∀ x, f x = g x) : f = g :=
   FunLike.ext f g h
 #align dilation.ext Dilation.ext
 
-theorem ext_iff {f g : Dilation α β} : f = g ↔ ∀ x, f x = g x :=
+theorem ext_iff {f g : α →ᵈ β} : f = g ↔ ∀ x, f x = g x :=
   FunLike.ext_iff
 #align dilation.ext_iff Dilation.ext_iff
 
 @[simp]
-theorem mk_coe (f : Dilation α β) (h) : Dilation.mk f h = f :=
+theorem mk_coe (f : α →ᵈ β) (h) : Dilation.mk f h = f :=
   ext fun _ => rfl
 #align dilation.mk_coe Dilation.mk_coe
 
 /-- Copy of a `Dilation` with a new `toFun` equal to the old one. Useful to fix definitional
 equalities. -/
 @[simps (config := { fullyApplied := false })]
-protected def copy (f : Dilation α β) (f' : α → β) (h : f' = ⇑f) : Dilation α β where
+protected def copy (f : α →ᵈ β) (f' : α → β) (h : f' = ⇑f) : α →ᵈ β where
   toFun := f'
   edist_eq' := h.symm ▸ f.edist_eq'
 #align dilation.copy Dilation.copy
 
-theorem copy_eq_self (f : Dilation α β) {f' : α → β} (h : f' = f) : f.copy f' h = f :=
+theorem copy_eq_self (f : α →ᵈ β) {f' : α → β} (h : f' = f) : f.copy f' h = f :=
   FunLike.ext' h
 #align dilation.copy_eq_self Dilation.copy_eq_self
 
@@ -138,6 +144,14 @@ 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
 #align dilation.ratio Dilation.ratio
 
+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
@@ -199,7 +213,7 @@ theorem ratio_unique_of_dist_ne_zero {α β} {F : Type _} [PseudoMetricSpace α]
 
 /-- 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) : Dilation α β where
+    (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⟩
@@ -209,19 +223,19 @@ def mkOfNNDistEq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α 
 
 @[simp]
 theorem coe_mkOfNNDistEq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α → β) (h) :
-    ⇑(mkOfNNDistEq f h : Dilation α β) = f :=
+    ⇑(mkOfNNDistEq f h : α →ᵈ β) = f :=
   rfl
 #align dilation.coe_mk_of_nndist_eq Dilation.coe_mkOfNNDistEq
 
 @[simp]
-theorem mk_coe_of_nndist_eq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : Dilation α β)
+theorem mk_coe_of_nndist_eq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α →ᵈ β)
     (h) : Dilation.mkOfNNDistEq f h = f :=
   ext fun _ => rfl
 #align dilation.mk_coe_of_nndist_eq Dilation.mk_coe_of_nndist_eq
 
 /-- 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) : Dilation α β :=
+    (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]⟩
@@ -229,12 +243,12 @@ def mkOfDistEq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α →
 
 @[simp]
 theorem coe_mkOfDistEq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α → β) (h) :
-    ⇑(mkOfDistEq f h : Dilation α β) = f :=
+    ⇑(mkOfDistEq f h : α →ᵈ β) = f :=
   rfl
 #align dilation.coe_mk_of_dist_eq Dilation.coe_mkOfDistEq
 
 @[simp]
-theorem mk_coe_of_dist_eq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : Dilation α β) (h) :
+theorem mk_coe_of_dist_eq {α β} [PseudoMetricSpace α] [PseudoMetricSpace β] (f : α →ᵈ β) (h) :
     Dilation.mkOfDistEq f h = f :=
   ext fun _ => rfl
 #align dilation.mk_coe_of_dist_eq Dilation.mk_coe_of_dist_eq
@@ -265,12 +279,12 @@ protected theorem injective {α : Type _} [EMetricSpace α] [DilationClass F α
 #align dilation.injective Dilation.injective
 
 /-- The identity is a dilation -/
-protected def id (α) [PseudoEMetricSpace α] : Dilation α α where
+protected def id (α) [PseudoEMetricSpace α] : α →ᵈ α where
   toFun := id
   edist_eq' := ⟨1, one_ne_zero, fun x y => by simp only [id.def, ENNReal.coe_one, one_mul]⟩
 #align dilation.id Dilation.id
 
-instance : Inhabited (Dilation α α) :=
+instance : Inhabited (α →ᵈ α) :=
   ⟨Dilation.id α⟩
 
 @[simp] -- Porting note: Removed `@[protected]`
@@ -278,90 +292,109 @@ theorem coe_id : ⇑(Dilation.id α) = id :=
   rfl
 #align dilation.coe_id Dilation.coe_id
 
-theorem id_ratio : ratio (Dilation.id α) = 1 := by
+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
-#align dilation.id_ratio Dilation.id_ratio
+#align dilation.id_ratio Dilation.ratio_id
 
 /-- The composition of dilations is a dilation -/
-def comp (g : Dilation β γ) (f : Dilation α β) : Dilation α γ where
+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]⟩
 #align dilation.comp Dilation.comp
 
-theorem comp_assoc {δ : Type _} [PseudoEMetricSpace δ] (f : Dilation α β) (g : Dilation β γ)
-    (h : Dilation γ δ) : (h.comp g).comp f = h.comp (g.comp f) :=
+theorem comp_assoc {δ : Type _} [PseudoEMetricSpace δ] (f : α →ᵈ β) (g : β →ᵈ γ)
+    (h : γ →ᵈ δ) : (h.comp g).comp f = h.comp (g.comp f) :=
   rfl
 #align dilation.comp_assoc Dilation.comp_assoc
 
 @[simp]
-theorem coe_comp (g : Dilation β γ) (f : Dilation α β) : (g.comp f : α → γ) = g ∘ f :=
+theorem coe_comp (g : β →ᵈ γ) (f : α →ᵈ β) : (g.comp f : α → γ) = g ∘ f :=
   rfl
 #align dilation.coe_comp Dilation.coe_comp
 
-theorem comp_apply (g : Dilation β γ) (f : Dilation α β) (x : α) : (g.comp f : α → γ) x = g (f x) :=
+theorem comp_apply (g : β →ᵈ γ) (f : α →ᵈ β) (x : α) : (g.comp f : α → γ) x = g (f x) :=
   rfl
 #align dilation.comp_apply Dilation.comp_apply
 
+-- 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 the domain `α` of `f` is nontrivial, otherwise `ratio f = ratio (g.comp f) = 1` but `ratio g`
-may have any value. -/
-@[simp]
-theorem comp_ratio {g : Dilation β γ} {f : Dilation α β}
+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 by 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_eq_coe, ENNReal.coe_mul]
-#align dilation.comp_ratio Dilation.comp_ratio
+#align dilation.comp_ratio Dilation.ratio_comp'
 
 @[simp]
-theorem comp_id (f : Dilation α β) : f.comp (Dilation.id α) = f :=
+theorem comp_id (f : α →ᵈ β) : f.comp (Dilation.id α) = f :=
   ext fun _ => rfl
 #align dilation.comp_id Dilation.comp_id
 
 @[simp]
-theorem id_comp (f : Dilation α β) : (Dilation.id β).comp f = f :=
+theorem id_comp (f : α →ᵈ β) : (Dilation.id β).comp f = f :=
   ext fun _ => rfl
 #align dilation.id_comp Dilation.id_comp
 
-instance : Monoid (Dilation α α) where
+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 α α) = Dilation.id α :=
+theorem one_def : (1 : α →ᵈ α) = Dilation.id α :=
   rfl
 #align dilation.one_def Dilation.one_def
 
-theorem mul_def (f g : Dilation α α) : f * g = f.comp g :=
+theorem mul_def (f g : α →ᵈ α) : f * g = f.comp g :=
   rfl
 #align dilation.mul_def Dilation.mul_def
 
 @[simp]
-theorem coe_one : ⇑(1 : Dilation α α) = id :=
+theorem coe_one : ⇑(1 : α →ᵈ α) = id :=
   rfl
 #align dilation.coe_one Dilation.coe_one
 
 @[simp]
-theorem coe_mul (f g : Dilation α α) : ⇑(f * g) = f ∘ g :=
+theorem coe_mul (f g : α →ᵈ α) : ⇑(f * g) = f ∘ g :=
   rfl
 #align dilation.coe_mul Dilation.coe_mul
 
-theorem cancel_right {g₁ g₂ : Dilation β γ} {f : Dilation α β} (hf : Surjective f) :
+@[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 _ _
+
+theorem cancel_right {g₁ g₂ : β →ᵈ γ} {f : α →ᵈ β} (hf : Surjective f) :
     g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
   ⟨fun h => Dilation.ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩
 #align dilation.cancel_right Dilation.cancel_right
 
-theorem cancel_left {g : Dilation β γ} {f₁ f₂ : Dilation α β} (hg : Injective g) :
+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⟩
 #align dilation.cancel_left Dilation.cancel_left
@@ -444,6 +477,17 @@ protected theorem closedEmbedding [CompleteSpace α] [EMetricSpace β] [Dilation
 
 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 β] [DilationClass F α β] (f : F)
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -3,15 +3,12 @@ Copyright (c) 2022 Hanting Zhang. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Dilations of emetric and metric spaces
 Authors: Hanting Zhang
-
-! This file was ported from Lean 3 source module topology.metric_space.dilation
-! leanprover-community/mathlib commit 93f880918cb51905fd51b76add8273cbc27718ab
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Topology.MetricSpace.Antilipschitz
 import Mathlib.Data.FunLike.Basic
 
+#align_import topology.metric_space.dilation from "leanprover-community/mathlib"@"93f880918cb51905fd51b76add8273cbc27718ab"
+
 /-!
 # Dilations
 
feat: port Topology.MetricSpace.Dilation (#5442)

Dependencies 10 + 491

492 files ported (98.0%)
216345 lines ported (97.6%)
Show graph

The unported dependencies are

The following 1 dependencies have changed in mathlib3 since they were ported, which may complicate porting this file