Skip to content

Commit c148e3f

Browse files
committed
chore: golf (#3473)
- Golf `TopologicalGroup.toUniformSpace`. - Slightly golf `GroupSeminorm.toSeminormedGroup`
1 parent 7392084 commit c148e3f

File tree

2 files changed

+14
-48
lines changed

2 files changed

+14
-48
lines changed

Mathlib/Analysis/Normed/Group/Basic.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,14 @@ creates bad definitional equalities (e.g., it does not take into account a possi
303303
and the pseudometric space structure from the seminorm properties. Note that in most cases this
304304
instance creates bad definitional equalities (e.g., it does not take into account a possibly
305305
existing `UniformSpace` instance on `E`)."]
306-
def GroupSeminorm.toSeminormedGroup [Group E] (f : GroupSeminorm E) : SeminormedGroup E
307-
where
306+
def GroupSeminorm.toSeminormedGroup [Group E] (f : GroupSeminorm E) : SeminormedGroup E where
308307
dist x y := f (x / y)
309308
norm := f
310309
dist_eq x y := rfl
311310
dist_self x := by simp only [div_self', map_one_eq_zero]
312311
dist_triangle := le_map_div_add_map_div f
313312
dist_comm := map_div_rev f
314-
edist_dist := fun x y => (ENNReal.ofReal_eq_coe_nnreal (map_nonneg f (x / y))).symm
313+
edist_dist x y := by exact ENNReal.coe_nnreal_eq _
315314
-- porting note: how did `mathlib3` solve this automatically?
316315
#align group_seminorm.to_seminormed_group GroupSeminorm.toSeminormedGroup
317316
#align add_group_seminorm.to_seminormed_add_group AddGroupSeminorm.toSeminormedAddGroup

Mathlib/Topology/Algebra/UniformGroup.lean

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -556,53 +556,20 @@ Warning: in general the right and left uniformities do not coincide and so one d
556556
`UniformAddGroup` structure. Two important special cases where they _do_ coincide are for
557557
commutative additive groups (see `comm_topologicalAddGroup_is_uniform`) and for compact
558558
additive groups (see `topologicalAddGroup_is_uniform_of_compactSpace`)."]
559-
def TopologicalGroup.toUniformSpace : UniformSpace G
560-
where
559+
def TopologicalGroup.toUniformSpace : UniformSpace G where
561560
uniformity := comap (fun p : G × G => p.2 / p.1) (𝓝 1)
562-
refl := by
563-
refine' map_le_iff_le_comap.1 (le_trans _ (pure_le_nhds 1));
564-
simp (config := { contextual := true }) [Set.subset_def]
561+
refl := (Tendsto.mono_right (by simp) (pure_le_nhds _)).le_comap
565562
symm :=
566-
by
567-
suffices
568-
Tendsto (fun p : G × G => (p.2 / p.1)⁻¹) (comap (fun p : G × G => p.2 / p.1) (𝓝 1)) (𝓝 1⁻¹)
569-
by simpa [tendsto_comap_iff]
570-
exact tendsto_id.inv.comp tendsto_comap
571-
comp := by
572-
intro D H
573-
rw [mem_lift'_sets]
574-
· rcases H with ⟨U, U_nhds, U_sub⟩
575-
rcases exists_nhds_one_split U_nhds with ⟨V, ⟨V_nhds, V_sum⟩⟩
576-
exists (fun p : G × G => p.2 / p.1) ⁻¹' V
577-
have H :
578-
(fun p : G × G => p.2 / p.1) ⁻¹' V ∈ comap (fun p : G × G => p.2 / p.1) (𝓝 (1 : G)) := by
579-
exists V, V_nhds
580-
exists H
581-
have comp_rel_sub :
582-
compRel ((fun p : G × G => p.2 / p.1) ⁻¹' V) ((fun p => p.2 / p.1) ⁻¹' V) ⊆
583-
(fun p : G × G => p.2 / p.1) ⁻¹' U :=
584-
by
585-
intro p p_comp_rel
586-
rcases p_comp_rel with ⟨z, ⟨Hz1, Hz2⟩⟩
587-
simpa using V_sum _ Hz2 _ Hz1
588-
exact Set.Subset.trans comp_rel_sub U_sub
589-
· exact monotone_id.compRel monotone_id
590-
isOpen_uniformity := by
591-
intro S
592-
let S' x := { p : G × G | p.1 = x → p.2 ∈ S }
593-
show IsOpen S ↔ ∀ x : G, x ∈ S → S' x ∈ comap (fun p : G × G => p.2 / p.1) (𝓝 (1 : G))
594-
rw [isOpen_iff_mem_nhds]
595-
refine' forall₂_congr fun a ha => _
596-
rw [← nhds_translation_div, mem_comap, mem_comap]
597-
refine exists_congr fun t => (and_congr_right fun _ => ?_)
598-
-- Porting note: was
599-
--refine' exists₂_congr fun t ht => _
600-
show (fun y : G => y / a) ⁻¹' t ⊆ S ↔ (fun p : G × G => p.snd / p.fst) ⁻¹' t ⊆ S' a
601-
constructor
602-
· rintro h ⟨x, y⟩ hx rfl
603-
exact h hx
604-
· rintro h x hx
605-
exact @h (a, x) hx rfl
563+
have : Tendsto (fun p : G × G ↦ (p.2 / p.1)⁻¹) (comap (fun p : G × G ↦ p.2 / p.1) (𝓝 1))
564+
(𝓝 1⁻¹) := tendsto_id.inv.comp tendsto_comap
565+
by simpa [tendsto_comap_iff]
566+
comp := Tendsto.le_comap <| fun U H ↦ by
567+
rcases exists_nhds_one_split H with ⟨V, V_nhds, V_mul⟩
568+
refine mem_map.2 (mem_of_superset (mem_lift' <| preimage_mem_comap V_nhds) ?_)
569+
rintro ⟨x, y⟩ ⟨z, hz₁, hz₂⟩
570+
simpa using V_mul _ hz₂ _ hz₁
571+
isOpen_uniformity S := by
572+
simp only [isOpen_iff_mem_nhds, ← mem_comap_prod_mk, comap_comap, (· ∘ ·), nhds_translation_div]
606573
#align topological_group.to_uniform_space TopologicalGroup.toUniformSpace
607574
#align topological_add_group.to_uniform_space TopologicalAddGroup.toUniformSpace
608575

0 commit comments

Comments
 (0)