analysis.complex.upper_half_plane.basicMathlib.Analysis.Complex.UpperHalfPlane.Basic

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)

(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)

(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)

(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)

(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)

(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)

(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)

(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)

(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)

(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
@@ -201,11 +201,11 @@ theorem linear_ne_zero (cd : Fin 2 → ℝ) (z : ℍ) (h : cd ≠ 0) : (cd 0 : 
   have : cd 0 = 0 :=
     by
     -- we will need this twice
-    apply_fun Complex.im at h 
+    apply_fun Complex.im at h
     simpa only [z.im_ne_zero, Complex.add_im, add_zero, coe_im, MulZeroClass.zero_mul, or_false_iff,
       Complex.ofReal_im, Complex.zero_im, Complex.mul_im, mul_eq_zero] using h
   simp only [this, MulZeroClass.zero_mul, Complex.ofReal_zero, zero_add, Complex.ofReal_eq_zero] at
-    h 
+    h
   ext i
   fin_cases i <;> assumption
 #align upper_half_plane.linear_ne_zero UpperHalfPlane.linear_ne_zero
@@ -217,15 +217,15 @@ theorem denom_ne_zero (g : GL(2, ℝ)⁺) (z : ℍ) : denom g z ≠ 0 :=
   intro H
   have DET := (mem_GL_pos _).1 g.prop
   have hz := z.prop
-  simp only [general_linear_group.coe_det_apply] at DET 
+  simp only [general_linear_group.coe_det_apply] at DET
   have H1 : (↑ₘg 1 0 : ℝ) = 0 ∨ z.im = 0 := by simpa using congr_arg Complex.im H
   cases H1
   · simp only [H1, Complex.ofReal_zero, denom, coe_fn_eq_coe, MulZeroClass.zero_mul, zero_add,
-      Complex.ofReal_eq_zero] at H 
-    rw [← coe_coe, Matrix.det_fin_two (↑g : Matrix (Fin 2) (Fin 2) ℝ)] at DET 
-    simp only [coe_coe, H, H1, MulZeroClass.mul_zero, sub_zero, lt_self_iff_false] at DET 
+      Complex.ofReal_eq_zero] at H
+    rw [← coe_coe, Matrix.det_fin_two (↑g : Matrix (Fin 2) (Fin 2) ℝ)] at DET
+    simp only [coe_coe, H, H1, MulZeroClass.mul_zero, sub_zero, lt_self_iff_false] at DET
     exact DET
-  · change z.im > 0 at hz 
+  · change z.im > 0 at hz
     linarith
 #align upper_half_plane.denom_ne_zero UpperHalfPlane.denom_ne_zero
 -/
Diff
@@ -323,63 +323,63 @@ instance SLAction {R : Type _} [CommRing R] [Algebra R ℝ] : MulAction SL(2, R)
 instance : Coe SL(2, ℤ) GL(2, ℝ)⁺ :=
   ⟨fun g => ((g : SL(2, ℝ)) : GL(2, ℝ)⁺)⟩
 
-#print UpperHalfPlane.SLOnGLPos /-
-instance SLOnGLPos : SMul SL(2, ℤ) GL(2, ℝ)⁺ :=
+#print UpperHalfPlane.ModularGroup.SLOnGLPos /-
+instance UpperHalfPlane.ModularGroup.SLOnGLPos : SMul SL(2, ℤ) GL(2, ℝ)⁺ :=
   ⟨fun s g => s * g⟩
-#align upper_half_plane.SL_on_GL_pos UpperHalfPlane.SLOnGLPos
+#align upper_half_plane.SL_on_GL_pos UpperHalfPlane.ModularGroup.SLOnGLPos
 -/
 
-#print UpperHalfPlane.SLOnGLPos_smul_apply /-
-theorem SLOnGLPos_smul_apply (s : SL(2, ℤ)) (g : GL(2, ℝ)⁺) (z : ℍ) :
+#print UpperHalfPlane.ModularGroup.SLOnGLPos_smul_apply /-
+theorem UpperHalfPlane.ModularGroup.SLOnGLPos_smul_apply (s : SL(2, ℤ)) (g : GL(2, ℝ)⁺) (z : ℍ) :
     (s • g) • z = ((s : GL(2, ℝ)⁺) * g) • z :=
   rfl
-#align upper_half_plane.SL_on_GL_pos_smul_apply UpperHalfPlane.SLOnGLPos_smul_apply
+#align upper_half_plane.SL_on_GL_pos_smul_apply UpperHalfPlane.ModularGroup.SLOnGLPos_smul_apply
 -/
 
-#print UpperHalfPlane.SL_to_GL_tower /-
-instance SL_to_GL_tower : IsScalarTower SL(2, ℤ) GL(2, ℝ)⁺ ℍ
+#print UpperHalfPlane.ModularGroup.SL_to_GL_tower /-
+instance UpperHalfPlane.ModularGroup.SL_to_GL_tower : IsScalarTower SL(2, ℤ) GL(2, ℝ)⁺ ℍ
     where smul_assoc := by intro s g z; simp only [SL_on_GL_pos_smul_apply, coe_coe];
     apply mul_smul'
-#align upper_half_plane.SL_to_GL_tower UpperHalfPlane.SL_to_GL_tower
+#align upper_half_plane.SL_to_GL_tower UpperHalfPlane.ModularGroup.SL_to_GL_tower
 -/
 
-#print UpperHalfPlane.subgroupGLPos /-
-instance subgroupGLPos : SMul Γ GL(2, ℝ)⁺ :=
+#print UpperHalfPlane.ModularGroup.subgroupGLPos /-
+instance UpperHalfPlane.ModularGroup.subgroupGLPos : SMul Γ GL(2, ℝ)⁺ :=
   ⟨fun s g => s * g⟩
-#align upper_half_plane.subgroup_GL_pos UpperHalfPlane.subgroupGLPos
+#align upper_half_plane.subgroup_GL_pos UpperHalfPlane.ModularGroup.subgroupGLPos
 -/
 
-#print UpperHalfPlane.subgroup_on_glpos_smul_apply /-
-theorem subgroup_on_glpos_smul_apply (s : Γ) (g : GL(2, ℝ)⁺) (z : ℍ) :
+#print UpperHalfPlane.ModularGroup.subgroup_on_glpos_smul_apply /-
+theorem UpperHalfPlane.ModularGroup.subgroup_on_glpos_smul_apply (s : Γ) (g : GL(2, ℝ)⁺) (z : ℍ) :
     (s • g) • z = ((s : GL(2, ℝ)⁺) * g) • z :=
   rfl
-#align upper_half_plane.subgroup_on_GL_pos_smul_apply UpperHalfPlane.subgroup_on_glpos_smul_apply
+#align upper_half_plane.subgroup_on_GL_pos_smul_apply UpperHalfPlane.ModularGroup.subgroup_on_glpos_smul_apply
 -/
 
-#print UpperHalfPlane.subgroup_on_glpos /-
-instance subgroup_on_glpos : IsScalarTower Γ GL(2, ℝ)⁺ ℍ
+#print UpperHalfPlane.ModularGroup.subgroup_on_glpos /-
+instance UpperHalfPlane.ModularGroup.subgroup_on_glpos : IsScalarTower Γ GL(2, ℝ)⁺ ℍ
     where smul_assoc := by intro s g z; simp only [subgroup_on_GL_pos_smul_apply, coe_coe];
     apply mul_smul'
-#align upper_half_plane.subgroup_on_GL_pos UpperHalfPlane.subgroup_on_glpos
+#align upper_half_plane.subgroup_on_GL_pos UpperHalfPlane.ModularGroup.subgroup_on_glpos
 -/
 
-#print UpperHalfPlane.subgroupSL /-
-instance subgroupSL : SMul Γ SL(2, ℤ) :=
+#print UpperHalfPlane.ModularGroup.subgroupSL /-
+instance UpperHalfPlane.ModularGroup.subgroupSL : SMul Γ SL(2, ℤ) :=
   ⟨fun s g => s * g⟩
-#align upper_half_plane.subgroup_SL UpperHalfPlane.subgroupSL
+#align upper_half_plane.subgroup_SL UpperHalfPlane.ModularGroup.subgroupSL
 -/
 
-#print UpperHalfPlane.subgroup_on_SL_apply /-
-theorem subgroup_on_SL_apply (s : Γ) (g : SL(2, ℤ)) (z : ℍ) :
+#print UpperHalfPlane.ModularGroup.subgroup_on_SL_apply /-
+theorem UpperHalfPlane.ModularGroup.subgroup_on_SL_apply (s : Γ) (g : SL(2, ℤ)) (z : ℍ) :
     (s • g) • z = ((s : SL(2, ℤ)) * g) • z :=
   rfl
-#align upper_half_plane.subgroup_on_SL_apply UpperHalfPlane.subgroup_on_SL_apply
+#align upper_half_plane.subgroup_on_SL_apply UpperHalfPlane.ModularGroup.subgroup_on_SL_apply
 -/
 
-#print UpperHalfPlane.subgroup_to_SL_tower /-
-instance subgroup_to_SL_tower : IsScalarTower Γ SL(2, ℤ) ℍ
+#print UpperHalfPlane.ModularGroup.subgroup_to_SL_tower /-
+instance UpperHalfPlane.ModularGroup.subgroup_to_SL_tower : IsScalarTower Γ SL(2, ℤ) ℍ
     where smul_assoc s g z := by rw [subgroup_on_SL_apply]; apply MulAction.hMul_smul
-#align upper_half_plane.subgroup_to_SL_tower UpperHalfPlane.subgroup_to_SL_tower
+#align upper_half_plane.subgroup_to_SL_tower UpperHalfPlane.ModularGroup.subgroup_to_SL_tower
 -/
 
 end ModularScalarTowers
@@ -439,31 +439,32 @@ section SLModularAction
 
 variable (g : SL(2, ℤ)) (z : ℍ) (Γ : Subgroup SL(2, ℤ))
 
-#print UpperHalfPlane.sl_moeb /-
+#print UpperHalfPlane.ModularGroup.sl_moeb /-
 @[simp]
-theorem sl_moeb (A : SL(2, ℤ)) (z : ℍ) : A • z = (A : GL(2, ℝ)⁺) • z :=
+theorem UpperHalfPlane.ModularGroup.sl_moeb (A : SL(2, ℤ)) (z : ℍ) : A • z = (A : GL(2, ℝ)⁺) • z :=
   rfl
-#align upper_half_plane.sl_moeb UpperHalfPlane.sl_moeb
+#align upper_half_plane.sl_moeb UpperHalfPlane.ModularGroup.sl_moeb
 -/
 
-#print UpperHalfPlane.subgroup_moeb /-
-theorem subgroup_moeb (A : Γ) (z : ℍ) : A • z = (A : GL(2, ℝ)⁺) • z :=
+#print UpperHalfPlane.ModularGroup.subgroup_moeb /-
+theorem UpperHalfPlane.ModularGroup.subgroup_moeb (A : Γ) (z : ℍ) : A • z = (A : GL(2, ℝ)⁺) • z :=
   rfl
-#align upper_half_plane.subgroup_moeb UpperHalfPlane.subgroup_moeb
+#align upper_half_plane.subgroup_moeb UpperHalfPlane.ModularGroup.subgroup_moeb
 -/
 
-#print UpperHalfPlane.subgroup_to_sl_moeb /-
+#print UpperHalfPlane.ModularGroup.subgroup_to_sl_moeb /-
 @[simp]
-theorem subgroup_to_sl_moeb (A : Γ) (z : ℍ) : A • z = (A : SL(2, ℤ)) • z :=
+theorem UpperHalfPlane.ModularGroup.subgroup_to_sl_moeb (A : Γ) (z : ℍ) :
+    A • z = (A : SL(2, ℤ)) • z :=
   rfl
-#align upper_half_plane.subgroup_to_sl_moeb UpperHalfPlane.subgroup_to_sl_moeb
+#align upper_half_plane.subgroup_to_sl_moeb UpperHalfPlane.ModularGroup.subgroup_to_sl_moeb
 -/
 
-#print UpperHalfPlane.SL_neg_smul /-
+#print UpperHalfPlane.ModularGroup.SL_neg_smul /-
 @[simp]
-theorem SL_neg_smul (g : SL(2, ℤ)) (z : ℍ) : -g • z = g • z := by
+theorem UpperHalfPlane.ModularGroup.SL_neg_smul (g : SL(2, ℤ)) (z : ℍ) : -g • z = g • z := by
   simp only [coe_GL_pos_neg, sl_moeb, coe_coe, coe_int_neg, neg_smul]
-#align upper_half_plane.SL_neg_smul UpperHalfPlane.SL_neg_smul
+#align upper_half_plane.SL_neg_smul UpperHalfPlane.ModularGroup.SL_neg_smul
 -/
 
 #print UpperHalfPlane.c_mul_im_sq_le_normSq_denom /-
@@ -478,20 +479,20 @@ theorem c_mul_im_sq_le_normSq_denom (z : ℍ) (g : SL(2, ℝ)) :
 #align upper_half_plane.c_mul_im_sq_le_norm_sq_denom UpperHalfPlane.c_mul_im_sq_le_normSq_denom
 -/
 
-#print UpperHalfPlane.SpecialLinearGroup.im_smul_eq_div_normSq /-
-theorem SpecialLinearGroup.im_smul_eq_div_normSq : (g • z).im = z.im / Complex.normSq (denom g z) :=
+#print UpperHalfPlane.ModularGroup.im_smul_eq_div_normSq /-
+theorem ModularGroup.im_smul_eq_div_normSq : (g • z).im = z.im / Complex.normSq (denom g z) :=
   by
   convert im_smul_eq_div_norm_sq g z
   simp only [coe_coe, general_linear_group.coe_det_apply, coe_GL_pos_coe_GL_coe_matrix,
     Int.coe_castRingHom, (g : SL(2, ℝ)).Prop, one_mul]
-#align upper_half_plane.special_linear_group.im_smul_eq_div_norm_sq UpperHalfPlane.SpecialLinearGroup.im_smul_eq_div_normSq
+#align upper_half_plane.special_linear_group.im_smul_eq_div_norm_sq UpperHalfPlane.ModularGroup.im_smul_eq_div_normSq
 -/
 
-#print UpperHalfPlane.denom_apply /-
-theorem denom_apply (g : SL(2, ℤ)) (z : ℍ) :
+#print UpperHalfPlane.ModularGroup.denom_apply /-
+theorem UpperHalfPlane.ModularGroup.denom_apply (g : SL(2, ℤ)) (z : ℍ) :
     denom g z = (↑g : Matrix (Fin 2) (Fin 2) ℤ) 1 0 * z + (↑g : Matrix (Fin 2) (Fin 2) ℤ) 1 1 := by
   simp
-#align upper_half_plane.denom_apply UpperHalfPlane.denom_apply
+#align upper_half_plane.denom_apply UpperHalfPlane.ModularGroup.denom_apply
 -/
 
 end SLModularAction
Diff
@@ -3,12 +3,12 @@ Copyright (c) 2021 Alex Kontorovich and Heather Macbeth and Marc Masdeu. All rig
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alex Kontorovich, Heather Macbeth, Marc Masdeu
 -/
-import Mathbin.Data.Fintype.Parity
-import Mathbin.LinearAlgebra.Matrix.SpecialLinearGroup
-import Mathbin.Analysis.Complex.Basic
-import Mathbin.GroupTheory.GroupAction.Defs
-import Mathbin.LinearAlgebra.Matrix.GeneralLinearGroup
-import Mathbin.Tactic.LinearCombination
+import Data.Fintype.Parity
+import LinearAlgebra.Matrix.SpecialLinearGroup
+import Analysis.Complex.Basic
+import GroupTheory.GroupAction.Defs
+import LinearAlgebra.Matrix.GeneralLinearGroup
+import Tactic.LinearCombination
 
 #align_import analysis.complex.upper_half_plane.basic from "leanprover-community/mathlib"@"9240e8be927a0955b9a82c6c85ef499ee3a626b8"
 
Diff
@@ -281,7 +281,7 @@ theorem denom_cocycle (x y : GL(2, ℝ)⁺) (z : ℍ) :
   by
   change _ = (_ * (_ / _) + _) * _
   field_simp [denom_ne_zero, -denom, -Num]
-  simp only [Matrix.mul, dot_product, Fin.sum_univ_succ, denom, Num, coe_coe, Subgroup.coe_mul,
+  simp only [HMul.hMul, dot_product, Fin.sum_univ_succ, denom, Num, coe_coe, Subgroup.coe_mul,
     general_linear_group.coe_mul, Fintype.univ_ofSubsingleton, Fin.mk_zero, Finset.sum_singleton,
     Fin.succ_zero_eq_one', Complex.ofReal_add, Complex.ofReal_mul]
   ring
@@ -295,7 +295,7 @@ theorem mul_smul' (x y : GL(2, ℝ)⁺) (z : ℍ) : smulAux (x * y) z = smulAux
   change _ / _ = (_ * (_ / _) + _) * _
   rw [denom_cocycle]
   field_simp [denom_ne_zero, -denom, -Num]
-  simp only [Matrix.mul, dot_product, Fin.sum_univ_succ, Num, denom, coe_coe, Subgroup.coe_mul,
+  simp only [HMul.hMul, dot_product, Fin.sum_univ_succ, Num, denom, coe_coe, Subgroup.coe_mul,
     general_linear_group.coe_mul, Fintype.univ_ofSubsingleton, Fin.mk_zero, Finset.sum_singleton,
     Fin.succ_zero_eq_one', Complex.ofReal_add, Complex.ofReal_mul]
   ring
@@ -308,7 +308,7 @@ instance : MulAction GL(2, ℝ)⁺ ℍ where
   one_smul z := by
     ext1; change _ / _ = _
     simp [coeFn_coe_base']
-  mul_smul := mul_smul'
+  hMul_smul := mul_smul'
 
 section ModularScalarTowers
 
@@ -378,7 +378,7 @@ theorem subgroup_on_SL_apply (s : Γ) (g : SL(2, ℤ)) (z : ℍ) :
 
 #print UpperHalfPlane.subgroup_to_SL_tower /-
 instance subgroup_to_SL_tower : IsScalarTower Γ SL(2, ℤ) ℍ
-    where smul_assoc s g z := by rw [subgroup_on_SL_apply]; apply MulAction.mul_smul
+    where smul_assoc s g z := by rw [subgroup_on_SL_apply]; apply MulAction.hMul_smul
 #align upper_half_plane.subgroup_to_SL_tower UpperHalfPlane.subgroup_to_SL_tower
 -/
 
@@ -503,7 +503,7 @@ instance posRealAction : MulAction { x : ℝ // 0 < x } ℍ
     where
   smul x z := mk ((x : ℝ) • z) <| by simpa using mul_pos x.2 z.2
   one_smul z := Subtype.ext <| one_smul _ _
-  mul_smul x y z := Subtype.ext <| mul_smul (x : ℝ) y (z : ℂ)
+  hMul_smul x y z := Subtype.ext <| mul_smul (x : ℝ) y (z : ℂ)
 #align upper_half_plane.pos_real_action UpperHalfPlane.posRealAction
 -/
 
Diff
@@ -356,11 +356,11 @@ theorem subgroup_on_glpos_smul_apply (s : Γ) (g : GL(2, ℝ)⁺) (z : ℍ) :
 #align upper_half_plane.subgroup_on_GL_pos_smul_apply UpperHalfPlane.subgroup_on_glpos_smul_apply
 -/
 
-#print UpperHalfPlane.subgroup_on_gLPos /-
-instance subgroup_on_gLPos : IsScalarTower Γ GL(2, ℝ)⁺ ℍ
+#print UpperHalfPlane.subgroup_on_glpos /-
+instance subgroup_on_glpos : IsScalarTower Γ GL(2, ℝ)⁺ ℍ
     where smul_assoc := by intro s g z; simp only [subgroup_on_GL_pos_smul_apply, coe_coe];
     apply mul_smul'
-#align upper_half_plane.subgroup_on_GL_pos UpperHalfPlane.subgroup_on_gLPos
+#align upper_half_plane.subgroup_on_GL_pos UpperHalfPlane.subgroup_on_glpos
 -/
 
 #print UpperHalfPlane.subgroupSL /-
Diff
@@ -283,7 +283,7 @@ theorem denom_cocycle (x y : GL(2, ℝ)⁺) (z : ℍ) :
   field_simp [denom_ne_zero, -denom, -Num]
   simp only [Matrix.mul, dot_product, Fin.sum_univ_succ, denom, Num, coe_coe, Subgroup.coe_mul,
     general_linear_group.coe_mul, Fintype.univ_ofSubsingleton, Fin.mk_zero, Finset.sum_singleton,
-    Fin.succ_zero_eq_one, Complex.ofReal_add, Complex.ofReal_mul]
+    Fin.succ_zero_eq_one', Complex.ofReal_add, Complex.ofReal_mul]
   ring
 #align upper_half_plane.denom_cocycle UpperHalfPlane.denom_cocycle
 -/
@@ -297,7 +297,7 @@ theorem mul_smul' (x y : GL(2, ℝ)⁺) (z : ℍ) : smulAux (x * y) z = smulAux
   field_simp [denom_ne_zero, -denom, -Num]
   simp only [Matrix.mul, dot_product, Fin.sum_univ_succ, Num, denom, coe_coe, Subgroup.coe_mul,
     general_linear_group.coe_mul, Fintype.univ_ofSubsingleton, Fin.mk_zero, Finset.sum_singleton,
-    Fin.succ_zero_eq_one, Complex.ofReal_add, Complex.ofReal_mul]
+    Fin.succ_zero_eq_one', Complex.ofReal_add, Complex.ofReal_mul]
   ring
 #align upper_half_plane.mul_smul' UpperHalfPlane.mul_smul'
 -/
Diff
@@ -2,11 +2,6 @@
 Copyright (c) 2021 Alex Kontorovich and Heather Macbeth and Marc Masdeu. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alex Kontorovich, Heather Macbeth, Marc Masdeu
-
-! This file was ported from Lean 3 source module analysis.complex.upper_half_plane.basic
-! leanprover-community/mathlib commit 9240e8be927a0955b9a82c6c85ef499ee3a626b8
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Data.Fintype.Parity
 import Mathbin.LinearAlgebra.Matrix.SpecialLinearGroup
@@ -15,6 +10,8 @@ import Mathbin.GroupTheory.GroupAction.Defs
 import Mathbin.LinearAlgebra.Matrix.GeneralLinearGroup
 import Mathbin.Tactic.LinearCombination
 
+#align_import analysis.complex.upper_half_plane.basic from "leanprover-community/mathlib"@"9240e8be927a0955b9a82c6c85ef499ee3a626b8"
+
 /-!
 # The upper half plane and its automorphisms
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alex Kontorovich, Heather Macbeth, Marc Masdeu
 
 ! This file was ported from Lean 3 source module analysis.complex.upper_half_plane.basic
-! leanprover-community/mathlib commit 34d3797325d202bd7250431275bb871133cdb611
+! leanprover-community/mathlib commit 9240e8be927a0955b9a82c6c85ef499ee3a626b8
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -18,6 +18,9 @@ import Mathbin.Tactic.LinearCombination
 /-!
 # The upper half plane and its automorphisms
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 This file defines `upper_half_plane` to be the upper half plane in `ℂ`.
 
 We furthermore equip it with the structure of an `GL_pos 2 ℝ` action by
Diff
@@ -50,12 +50,14 @@ local notation "GL(" n ", " R ")" "⁺" => Matrix.GLPos (Fin n) R
 
 /- ./././Mathport/Syntax/Translate/Command.lean:43:9: unsupported derive handler λ α,
 has_coe[has_coe] α exprℂ() -/
+#print UpperHalfPlane /-
 /-- The open upper half plane -/
 def UpperHalfPlane :=
   { point : ℂ // 0 < point.im }
 deriving «./././Mathport/Syntax/Translate/Command.lean:43:9: unsupported derive handler λ α,
   has_coe[has_coe] α exprℂ()»
 #align upper_half_plane UpperHalfPlane
+-/
 
 scoped[UpperHalfPlane] notation "ℍ" => UpperHalfPlane
 
@@ -64,96 +66,135 @@ namespace UpperHalfPlane
 instance : Inhabited ℍ :=
   ⟨⟨Complex.I, by simp⟩⟩
 
+#print UpperHalfPlane.canLift /-
 instance canLift : CanLift ℂ ℍ coe fun z => 0 < z.im :=
   Subtype.canLift fun z => 0 < z.im
 #align upper_half_plane.can_lift UpperHalfPlane.canLift
+-/
 
+#print UpperHalfPlane.im /-
 /-- Imaginary part -/
 def im (z : ℍ) :=
   (z : ℂ).im
 #align upper_half_plane.im UpperHalfPlane.im
+-/
 
+#print UpperHalfPlane.re /-
 /-- Real part -/
 def re (z : ℍ) :=
   (z : ℂ).re
 #align upper_half_plane.re UpperHalfPlane.re
+-/
 
+#print UpperHalfPlane.mk /-
 /-- Constructor for `upper_half_plane`. It is useful if `⟨z, h⟩` makes Lean use a wrong
 typeclass instance. -/
 def mk (z : ℂ) (h : 0 < z.im) : ℍ :=
   ⟨z, h⟩
 #align upper_half_plane.mk UpperHalfPlane.mk
+-/
 
+#print UpperHalfPlane.coe_im /-
 @[simp]
 theorem coe_im (z : ℍ) : (z : ℂ).im = z.im :=
   rfl
 #align upper_half_plane.coe_im UpperHalfPlane.coe_im
+-/
 
+#print UpperHalfPlane.coe_re /-
 @[simp]
 theorem coe_re (z : ℍ) : (z : ℂ).re = z.re :=
   rfl
 #align upper_half_plane.coe_re UpperHalfPlane.coe_re
+-/
 
+#print UpperHalfPlane.mk_re /-
 @[simp]
 theorem mk_re (z : ℂ) (h : 0 < z.im) : (mk z h).re = z.re :=
   rfl
 #align upper_half_plane.mk_re UpperHalfPlane.mk_re
+-/
 
+#print UpperHalfPlane.mk_im /-
 @[simp]
 theorem mk_im (z : ℂ) (h : 0 < z.im) : (mk z h).im = z.im :=
   rfl
 #align upper_half_plane.mk_im UpperHalfPlane.mk_im
+-/
 
+#print UpperHalfPlane.coe_mk /-
 @[simp]
 theorem coe_mk (z : ℂ) (h : 0 < z.im) : (mk z h : ℂ) = z :=
   rfl
 #align upper_half_plane.coe_mk UpperHalfPlane.coe_mk
+-/
 
+#print UpperHalfPlane.mk_coe /-
 @[simp]
 theorem mk_coe (z : ℍ) (h : 0 < (z : ℂ).im := z.2) : mk z h = z :=
   Subtype.eta z h
 #align upper_half_plane.mk_coe UpperHalfPlane.mk_coe
+-/
 
+#print UpperHalfPlane.re_add_im /-
 theorem re_add_im (z : ℍ) : (z.re + z.im * Complex.I : ℂ) = z :=
   Complex.re_add_im z
 #align upper_half_plane.re_add_im UpperHalfPlane.re_add_im
+-/
 
+#print UpperHalfPlane.im_pos /-
 theorem im_pos (z : ℍ) : 0 < z.im :=
   z.2
 #align upper_half_plane.im_pos UpperHalfPlane.im_pos
+-/
 
+#print UpperHalfPlane.im_ne_zero /-
 theorem im_ne_zero (z : ℍ) : z.im ≠ 0 :=
   z.im_pos.ne'
 #align upper_half_plane.im_ne_zero UpperHalfPlane.im_ne_zero
+-/
 
+#print UpperHalfPlane.ne_zero /-
 theorem ne_zero (z : ℍ) : (z : ℂ) ≠ 0 :=
   mt (congr_arg Complex.im) z.im_ne_zero
 #align upper_half_plane.ne_zero UpperHalfPlane.ne_zero
+-/
 
+#print UpperHalfPlane.normSq_pos /-
 theorem normSq_pos (z : ℍ) : 0 < Complex.normSq (z : ℂ) := by rw [Complex.normSq_pos];
   exact z.ne_zero
 #align upper_half_plane.norm_sq_pos UpperHalfPlane.normSq_pos
+-/
 
+#print UpperHalfPlane.normSq_ne_zero /-
 theorem normSq_ne_zero (z : ℍ) : Complex.normSq (z : ℂ) ≠ 0 :=
   (normSq_pos z).ne'
 #align upper_half_plane.norm_sq_ne_zero UpperHalfPlane.normSq_ne_zero
+-/
 
+#print UpperHalfPlane.im_inv_neg_coe_pos /-
 theorem im_inv_neg_coe_pos (z : ℍ) : 0 < (-z : ℂ)⁻¹.im := by
   simpa using div_pos z.property (norm_sq_pos z)
 #align upper_half_plane.im_inv_neg_coe_pos UpperHalfPlane.im_inv_neg_coe_pos
+-/
 
+#print UpperHalfPlane.num /-
 /-- Numerator of the formula for a fractional linear transformation -/
 @[simp]
 def num (g : GL(2, ℝ)⁺) (z : ℍ) : ℂ :=
   (↑ₘg 0 0 : ℝ) * z + (↑ₘg 0 1 : ℝ)
 #align upper_half_plane.num UpperHalfPlane.num
+-/
 
+#print UpperHalfPlane.denom /-
 /-- Denominator of the formula for a fractional linear transformation -/
 @[simp]
 def denom (g : GL(2, ℝ)⁺) (z : ℍ) : ℂ :=
   (↑ₘg 1 0 : ℝ) * z + (↑ₘg 1 1 : ℝ)
 #align upper_half_plane.denom UpperHalfPlane.denom
+-/
 
+#print UpperHalfPlane.linear_ne_zero /-
 theorem linear_ne_zero (cd : Fin 2 → ℝ) (z : ℍ) (h : cd ≠ 0) : (cd 0 : ℂ) * z + cd 1 ≠ 0 :=
   by
   contrapose! h
@@ -168,7 +209,9 @@ theorem linear_ne_zero (cd : Fin 2 → ℝ) (z : ℍ) (h : cd ≠ 0) : (cd 0 : 
   ext i
   fin_cases i <;> assumption
 #align upper_half_plane.linear_ne_zero UpperHalfPlane.linear_ne_zero
+-/
 
+#print UpperHalfPlane.denom_ne_zero /-
 theorem denom_ne_zero (g : GL(2, ℝ)⁺) (z : ℍ) : denom g z ≠ 0 :=
   by
   intro H
@@ -185,20 +228,28 @@ theorem denom_ne_zero (g : GL(2, ℝ)⁺) (z : ℍ) : denom g z ≠ 0 :=
   · change z.im > 0 at hz 
     linarith
 #align upper_half_plane.denom_ne_zero UpperHalfPlane.denom_ne_zero
+-/
 
+#print UpperHalfPlane.normSq_denom_pos /-
 theorem normSq_denom_pos (g : GL(2, ℝ)⁺) (z : ℍ) : 0 < Complex.normSq (denom g z) :=
   Complex.normSq_pos.mpr (denom_ne_zero g z)
 #align upper_half_plane.norm_sq_denom_pos UpperHalfPlane.normSq_denom_pos
+-/
 
+#print UpperHalfPlane.normSq_denom_ne_zero /-
 theorem normSq_denom_ne_zero (g : GL(2, ℝ)⁺) (z : ℍ) : Complex.normSq (denom g z) ≠ 0 :=
   ne_of_gt (normSq_denom_pos g z)
 #align upper_half_plane.norm_sq_denom_ne_zero UpperHalfPlane.normSq_denom_ne_zero
+-/
 
+#print UpperHalfPlane.smulAux' /-
 /-- Fractional linear transformation, also known as the Moebius transformation -/
 def smulAux' (g : GL(2, ℝ)⁺) (z : ℍ) : ℂ :=
   num g z / denom g z
 #align upper_half_plane.smul_aux' UpperHalfPlane.smulAux'
+-/
 
+#print UpperHalfPlane.smulAux'_im /-
 theorem smulAux'_im (g : GL(2, ℝ)⁺) (z : ℍ) :
     (smulAux' g z).im = det ↑ₘg * z.im / (denom g z).normSq :=
   by
@@ -209,7 +260,9 @@ theorem smulAux'_im (g : GL(2, ℝ)⁺) (z : ℍ) :
   rw [Matrix.det_fin_two ↑ₘg]
   ring
 #align upper_half_plane.smul_aux'_im UpperHalfPlane.smulAux'_im
+-/
 
+#print UpperHalfPlane.smulAux /-
 /-- Fractional linear transformation, also known as the Moebius transformation -/
 def smulAux (g : GL(2, ℝ)⁺) (z : ℍ) : ℍ :=
   ⟨smulAux' g z, by
@@ -220,7 +273,9 @@ def smulAux (g : GL(2, ℝ)⁺) (z : ℍ) : ℍ :=
     simp only [general_linear_group.coe_det_apply, coe_coe]
     ring⟩
 #align upper_half_plane.smul_aux UpperHalfPlane.smulAux
+-/
 
+#print UpperHalfPlane.denom_cocycle /-
 theorem denom_cocycle (x y : GL(2, ℝ)⁺) (z : ℍ) :
     denom (x * y) z = denom x (smulAux y z) * denom y z :=
   by
@@ -231,7 +286,9 @@ theorem denom_cocycle (x y : GL(2, ℝ)⁺) (z : ℍ) :
     Fin.succ_zero_eq_one, Complex.ofReal_add, Complex.ofReal_mul]
   ring
 #align upper_half_plane.denom_cocycle UpperHalfPlane.denom_cocycle
+-/
 
+#print UpperHalfPlane.mul_smul' /-
 theorem mul_smul' (x y : GL(2, ℝ)⁺) (z : ℍ) : smulAux (x * y) z = smulAux x (smulAux y z) :=
   by
   ext1
@@ -243,6 +300,7 @@ theorem mul_smul' (x y : GL(2, ℝ)⁺) (z : ℍ) : smulAux (x * y) z = smulAux
     Fin.succ_zero_eq_one, Complex.ofReal_add, Complex.ofReal_mul]
   ring
 #align upper_half_plane.mul_smul' UpperHalfPlane.mul_smul'
+-/
 
 /-- The action of ` GL_pos 2 ℝ` on the upper half-plane by fractional linear transformations. -/
 instance : MulAction GL(2, ℝ)⁺ ℍ where
@@ -256,56 +314,77 @@ section ModularScalarTowers
 
 variable (Γ : Subgroup (SpecialLinearGroup (Fin 2) ℤ))
 
-instance sLAction {R : Type _} [CommRing R] [Algebra R ℝ] : MulAction SL(2, R) ℍ :=
+#print UpperHalfPlane.SLAction /-
+instance SLAction {R : Type _} [CommRing R] [Algebra R ℝ] : MulAction SL(2, R) ℍ :=
   MulAction.compHom ℍ <| SpecialLinearGroup.toGLPos.comp <| map (algebraMap R ℝ)
-#align upper_half_plane.SL_action UpperHalfPlane.sLAction
+#align upper_half_plane.SL_action UpperHalfPlane.SLAction
+-/
 
 instance : Coe SL(2, ℤ) GL(2, ℝ)⁺ :=
   ⟨fun g => ((g : SL(2, ℝ)) : GL(2, ℝ)⁺)⟩
 
-instance sLOnGLPos : SMul SL(2, ℤ) GL(2, ℝ)⁺ :=
+#print UpperHalfPlane.SLOnGLPos /-
+instance SLOnGLPos : SMul SL(2, ℤ) GL(2, ℝ)⁺ :=
   ⟨fun s g => s * g⟩
-#align upper_half_plane.SL_on_GL_pos UpperHalfPlane.sLOnGLPos
+#align upper_half_plane.SL_on_GL_pos UpperHalfPlane.SLOnGLPos
+-/
 
-theorem sLOnGLPos_smul_apply (s : SL(2, ℤ)) (g : GL(2, ℝ)⁺) (z : ℍ) :
+#print UpperHalfPlane.SLOnGLPos_smul_apply /-
+theorem SLOnGLPos_smul_apply (s : SL(2, ℤ)) (g : GL(2, ℝ)⁺) (z : ℍ) :
     (s • g) • z = ((s : GL(2, ℝ)⁺) * g) • z :=
   rfl
-#align upper_half_plane.SL_on_GL_pos_smul_apply UpperHalfPlane.sLOnGLPos_smul_apply
+#align upper_half_plane.SL_on_GL_pos_smul_apply UpperHalfPlane.SLOnGLPos_smul_apply
+-/
 
+#print UpperHalfPlane.SL_to_GL_tower /-
 instance SL_to_GL_tower : IsScalarTower SL(2, ℤ) GL(2, ℝ)⁺ ℍ
     where smul_assoc := by intro s g z; simp only [SL_on_GL_pos_smul_apply, coe_coe];
     apply mul_smul'
 #align upper_half_plane.SL_to_GL_tower UpperHalfPlane.SL_to_GL_tower
+-/
 
+#print UpperHalfPlane.subgroupGLPos /-
 instance subgroupGLPos : SMul Γ GL(2, ℝ)⁺ :=
   ⟨fun s g => s * g⟩
 #align upper_half_plane.subgroup_GL_pos UpperHalfPlane.subgroupGLPos
+-/
 
-theorem subgroup_on_gLPos_smul_apply (s : Γ) (g : GL(2, ℝ)⁺) (z : ℍ) :
+#print UpperHalfPlane.subgroup_on_glpos_smul_apply /-
+theorem subgroup_on_glpos_smul_apply (s : Γ) (g : GL(2, ℝ)⁺) (z : ℍ) :
     (s • g) • z = ((s : GL(2, ℝ)⁺) * g) • z :=
   rfl
-#align upper_half_plane.subgroup_on_GL_pos_smul_apply UpperHalfPlane.subgroup_on_gLPos_smul_apply
+#align upper_half_plane.subgroup_on_GL_pos_smul_apply UpperHalfPlane.subgroup_on_glpos_smul_apply
+-/
 
+#print UpperHalfPlane.subgroup_on_gLPos /-
 instance subgroup_on_gLPos : IsScalarTower Γ GL(2, ℝ)⁺ ℍ
     where smul_assoc := by intro s g z; simp only [subgroup_on_GL_pos_smul_apply, coe_coe];
     apply mul_smul'
 #align upper_half_plane.subgroup_on_GL_pos UpperHalfPlane.subgroup_on_gLPos
+-/
 
+#print UpperHalfPlane.subgroupSL /-
 instance subgroupSL : SMul Γ SL(2, ℤ) :=
   ⟨fun s g => s * g⟩
 #align upper_half_plane.subgroup_SL UpperHalfPlane.subgroupSL
+-/
 
+#print UpperHalfPlane.subgroup_on_SL_apply /-
 theorem subgroup_on_SL_apply (s : Γ) (g : SL(2, ℤ)) (z : ℍ) :
     (s • g) • z = ((s : SL(2, ℤ)) * g) • z :=
   rfl
 #align upper_half_plane.subgroup_on_SL_apply UpperHalfPlane.subgroup_on_SL_apply
+-/
 
+#print UpperHalfPlane.subgroup_to_SL_tower /-
 instance subgroup_to_SL_tower : IsScalarTower Γ SL(2, ℤ) ℍ
     where smul_assoc s g z := by rw [subgroup_on_SL_apply]; apply MulAction.mul_smul
 #align upper_half_plane.subgroup_to_SL_tower UpperHalfPlane.subgroup_to_SL_tower
+-/
 
 end ModularScalarTowers
 
+#print UpperHalfPlane.specialLinearGroup_apply /-
 theorem specialLinearGroup_apply {R : Type _} [CommRing R] [Algebra R ℝ] (g : SL(2, R)) (z : ℍ) :
     g • z =
       mk
@@ -314,26 +393,36 @@ theorem specialLinearGroup_apply {R : Type _} [CommRing R] [Algebra R ℝ] (g :
         (g • z).property :=
   rfl
 #align upper_half_plane.special_linear_group_apply UpperHalfPlane.specialLinearGroup_apply
+-/
 
+#print UpperHalfPlane.coe_smul /-
 @[simp]
 theorem coe_smul (g : GL(2, ℝ)⁺) (z : ℍ) : ↑(g • z) = num g z / denom g z :=
   rfl
 #align upper_half_plane.coe_smul UpperHalfPlane.coe_smul
+-/
 
+#print UpperHalfPlane.re_smul /-
 @[simp]
 theorem re_smul (g : GL(2, ℝ)⁺) (z : ℍ) : (g • z).re = (num g z / denom g z).re :=
   rfl
 #align upper_half_plane.re_smul UpperHalfPlane.re_smul
+-/
 
+#print UpperHalfPlane.im_smul /-
 theorem im_smul (g : GL(2, ℝ)⁺) (z : ℍ) : (g • z).im = (num g z / denom g z).im :=
   rfl
 #align upper_half_plane.im_smul UpperHalfPlane.im_smul
+-/
 
+#print UpperHalfPlane.im_smul_eq_div_normSq /-
 theorem im_smul_eq_div_normSq (g : GL(2, ℝ)⁺) (z : ℍ) :
     (g • z).im = det ↑ₘg * z.im / Complex.normSq (denom g z) :=
   smulAux'_im g z
 #align upper_half_plane.im_smul_eq_div_norm_sq UpperHalfPlane.im_smul_eq_div_normSq
+-/
 
+#print UpperHalfPlane.neg_smul /-
 @[simp]
 theorem neg_smul (g : GL(2, ℝ)⁺) (z : ℍ) : -g • z = g • z :=
   by
@@ -344,30 +433,40 @@ theorem neg_smul (g : GL(2, ℝ)⁺) (z : ℍ) : -g • z = g • z :=
     Pi.neg_apply]
   ring_nf
 #align upper_half_plane.neg_smul UpperHalfPlane.neg_smul
+-/
 
 section SLModularAction
 
 variable (g : SL(2, ℤ)) (z : ℍ) (Γ : Subgroup SL(2, ℤ))
 
+#print UpperHalfPlane.sl_moeb /-
 @[simp]
 theorem sl_moeb (A : SL(2, ℤ)) (z : ℍ) : A • z = (A : GL(2, ℝ)⁺) • z :=
   rfl
 #align upper_half_plane.sl_moeb UpperHalfPlane.sl_moeb
+-/
 
+#print UpperHalfPlane.subgroup_moeb /-
 theorem subgroup_moeb (A : Γ) (z : ℍ) : A • z = (A : GL(2, ℝ)⁺) • z :=
   rfl
 #align upper_half_plane.subgroup_moeb UpperHalfPlane.subgroup_moeb
+-/
 
+#print UpperHalfPlane.subgroup_to_sl_moeb /-
 @[simp]
 theorem subgroup_to_sl_moeb (A : Γ) (z : ℍ) : A • z = (A : SL(2, ℤ)) • z :=
   rfl
 #align upper_half_plane.subgroup_to_sl_moeb UpperHalfPlane.subgroup_to_sl_moeb
+-/
 
+#print UpperHalfPlane.SL_neg_smul /-
 @[simp]
 theorem SL_neg_smul (g : SL(2, ℤ)) (z : ℍ) : -g • z = g • z := by
   simp only [coe_GL_pos_neg, sl_moeb, coe_coe, coe_int_neg, neg_smul]
 #align upper_half_plane.SL_neg_smul UpperHalfPlane.SL_neg_smul
+-/
 
+#print UpperHalfPlane.c_mul_im_sq_le_normSq_denom /-
 theorem c_mul_im_sq_le_normSq_denom (z : ℍ) (g : SL(2, ℝ)) :
     ((↑ₘg 1 0 : ℝ) * z.im) ^ 2 ≤ Complex.normSq (denom g z) :=
   by
@@ -377,46 +476,59 @@ theorem c_mul_im_sq_le_normSq_denom (z : ℍ) (g : SL(2, ℝ)) :
     (c * z.im) ^ 2 ≤ (c * z.im) ^ 2 + (c * z.re + d) ^ 2 := by nlinarith
     _ = Complex.normSq (denom g z) := by simp [Complex.normSq] <;> ring
 #align upper_half_plane.c_mul_im_sq_le_norm_sq_denom UpperHalfPlane.c_mul_im_sq_le_normSq_denom
+-/
 
+#print UpperHalfPlane.SpecialLinearGroup.im_smul_eq_div_normSq /-
 theorem SpecialLinearGroup.im_smul_eq_div_normSq : (g • z).im = z.im / Complex.normSq (denom g z) :=
   by
   convert im_smul_eq_div_norm_sq g z
   simp only [coe_coe, general_linear_group.coe_det_apply, coe_GL_pos_coe_GL_coe_matrix,
     Int.coe_castRingHom, (g : SL(2, ℝ)).Prop, one_mul]
 #align upper_half_plane.special_linear_group.im_smul_eq_div_norm_sq UpperHalfPlane.SpecialLinearGroup.im_smul_eq_div_normSq
+-/
 
+#print UpperHalfPlane.denom_apply /-
 theorem denom_apply (g : SL(2, ℤ)) (z : ℍ) :
     denom g z = (↑g : Matrix (Fin 2) (Fin 2) ℤ) 1 0 * z + (↑g : Matrix (Fin 2) (Fin 2) ℤ) 1 1 := by
   simp
 #align upper_half_plane.denom_apply UpperHalfPlane.denom_apply
+-/
 
 end SLModularAction
 
 section PosRealAction
 
+#print UpperHalfPlane.posRealAction /-
 instance posRealAction : MulAction { x : ℝ // 0 < x } ℍ
     where
   smul x z := mk ((x : ℝ) • z) <| by simpa using mul_pos x.2 z.2
   one_smul z := Subtype.ext <| one_smul _ _
   mul_smul x y z := Subtype.ext <| mul_smul (x : ℝ) y (z : ℂ)
 #align upper_half_plane.pos_real_action UpperHalfPlane.posRealAction
+-/
 
 variable (x : { x : ℝ // 0 < x }) (z : ℍ)
 
+#print UpperHalfPlane.coe_pos_real_smul /-
 @[simp]
 theorem coe_pos_real_smul : ↑(x • z) = (x : ℝ) • (z : ℂ) :=
   rfl
 #align upper_half_plane.coe_pos_real_smul UpperHalfPlane.coe_pos_real_smul
+-/
 
+#print UpperHalfPlane.pos_real_im /-
 @[simp]
 theorem pos_real_im : (x • z).im = x * z.im :=
   Complex.smul_im _ _
 #align upper_half_plane.pos_real_im UpperHalfPlane.pos_real_im
+-/
 
+#print UpperHalfPlane.pos_real_re /-
 @[simp]
 theorem pos_real_re : (x • z).re = x * z.re :=
   Complex.smul_re _ _
 #align upper_half_plane.pos_real_re UpperHalfPlane.pos_real_re
+-/
 
 end PosRealAction
 
@@ -430,41 +542,54 @@ instance : AddAction ℝ ℍ
 
 variable (x : ℝ) (z : ℍ)
 
+#print UpperHalfPlane.coe_vadd /-
 @[simp]
 theorem coe_vadd : ↑(x +ᵥ z) = (x + z : ℂ) :=
   rfl
 #align upper_half_plane.coe_vadd UpperHalfPlane.coe_vadd
+-/
 
+#print UpperHalfPlane.vadd_re /-
 @[simp]
 theorem vadd_re : (x +ᵥ z).re = x + z.re :=
   rfl
 #align upper_half_plane.vadd_re UpperHalfPlane.vadd_re
+-/
 
+#print UpperHalfPlane.vadd_im /-
 @[simp]
 theorem vadd_im : (x +ᵥ z).im = z.im :=
   zero_add _
 #align upper_half_plane.vadd_im UpperHalfPlane.vadd_im
+-/
 
 end RealAddAction
 
+#print UpperHalfPlane.modular_S_smul /-
 /- these next few lemmas are *not* flagged `@simp` because of the constructors on the RHS;
 instead we use the versions with coercions to `ℂ` as simp lemmas instead. -/
-theorem modular_s_smul (z : ℍ) : ModularGroup.S • z = mk (-z : ℂ)⁻¹ z.im_inv_neg_coe_pos := by
+theorem modular_S_smul (z : ℍ) : ModularGroup.S • z = mk (-z : ℂ)⁻¹ z.im_inv_neg_coe_pos := by
   rw [special_linear_group_apply]; simp [ModularGroup.S, neg_div, inv_neg]
-#align upper_half_plane.modular_S_smul UpperHalfPlane.modular_s_smul
+#align upper_half_plane.modular_S_smul UpperHalfPlane.modular_S_smul
+-/
 
-theorem modular_t_zpow_smul (z : ℍ) (n : ℤ) : ModularGroup.T ^ n • z = (n : ℝ) +ᵥ z :=
+#print UpperHalfPlane.modular_T_zpow_smul /-
+theorem modular_T_zpow_smul (z : ℍ) (n : ℤ) : ModularGroup.T ^ n • z = (n : ℝ) +ᵥ z :=
   by
   rw [← Subtype.coe_inj, coe_vadd, add_comm, special_linear_group_apply, coe_mk,
     ModularGroup.coe_T_zpow]
   simp only [of_apply, cons_val_zero, algebraMap.coe_one, Complex.ofReal_one, one_mul, cons_val_one,
     head_cons, algebraMap.coe_zero, MulZeroClass.zero_mul, zero_add, div_one]
-#align upper_half_plane.modular_T_zpow_smul UpperHalfPlane.modular_t_zpow_smul
+#align upper_half_plane.modular_T_zpow_smul UpperHalfPlane.modular_T_zpow_smul
+-/
 
-theorem modular_t_smul (z : ℍ) : ModularGroup.T • z = (1 : ℝ) +ᵥ z := by
+#print UpperHalfPlane.modular_T_smul /-
+theorem modular_T_smul (z : ℍ) : ModularGroup.T • z = (1 : ℝ) +ᵥ z := by
   simpa only [algebraMap.coe_one] using modular_T_zpow_smul z 1
-#align upper_half_plane.modular_T_smul UpperHalfPlane.modular_t_smul
+#align upper_half_plane.modular_T_smul UpperHalfPlane.modular_T_smul
+-/
 
+#print UpperHalfPlane.exists_SL2_smul_eq_of_apply_zero_one_eq_zero /-
 theorem exists_SL2_smul_eq_of_apply_zero_one_eq_zero (g : SL(2, ℝ)) (hc : ↑ₘ[ℝ] g 1 0 = 0) :
     ∃ (u : { x : ℝ // 0 < x }) (v : ℝ), ((· • ·) g : ℍ → ℍ) = (fun z => v +ᵥ z) ∘ fun z => u • z :=
   by
@@ -475,7 +600,9 @@ theorem exists_SL2_smul_eq_of_apply_zero_one_eq_zero (g : SL(2, ℝ)) (hc : ↑
     simpa [add_mul]
   ring
 #align upper_half_plane.exists_SL2_smul_eq_of_apply_zero_one_eq_zero UpperHalfPlane.exists_SL2_smul_eq_of_apply_zero_one_eq_zero
+-/
 
+#print UpperHalfPlane.exists_SL2_smul_eq_of_apply_zero_one_ne_zero /-
 theorem exists_SL2_smul_eq_of_apply_zero_one_ne_zero (g : SL(2, ℝ)) (hc : ↑ₘ[ℝ] g 1 0 ≠ 0) :
     ∃ (u : { x : ℝ // 0 < x }) (v w : ℝ),
       ((· • ·) g : ℍ → ℍ) =
@@ -500,6 +627,7 @@ theorem exists_SL2_smul_eq_of_apply_zero_one_ne_zero (g : SL(2, ℝ)) (hc : ↑
   field_simp
   linear_combination (-(z * ↑c ^ 2) - ↑c * ↑d) * h
 #align upper_half_plane.exists_SL2_smul_eq_of_apply_zero_one_ne_zero UpperHalfPlane.exists_SL2_smul_eq_of_apply_zero_one_ne_zero
+-/
 
 end UpperHalfPlane
 
Diff
@@ -42,13 +42,10 @@ attribute [-instance] Matrix.SpecialLinearGroup.hasCoeToFun
 
 attribute [-instance] Matrix.GeneralLinearGroup.hasCoeToFun
 
--- mathport name: «expr↑ₘ »
 local prefix:1024 "↑ₘ" => @coe _ (Matrix (Fin 2) (Fin 2) _) _
 
--- mathport name: «expr↑ₘ[ ]»
 local notation:1024 "↑ₘ[" R "]" => @coe _ (Matrix (Fin 2) (Fin 2) R) _
 
--- mathport name: «exprGL( , )⁺»
 local notation "GL(" n ", " R ")" "⁺" => Matrix.GLPos (Fin n) R
 
 /- ./././Mathport/Syntax/Translate/Command.lean:43:9: unsupported derive handler λ α,
@@ -60,7 +57,6 @@ deriving «./././Mathport/Syntax/Translate/Command.lean:43:9: unsupported derive
   has_coe[has_coe] α exprℂ()»
 #align upper_half_plane UpperHalfPlane
 
--- mathport name: upper_half_plane
 scoped[UpperHalfPlane] notation "ℍ" => UpperHalfPlane
 
 namespace UpperHalfPlane
Diff
@@ -380,7 +380,6 @@ theorem c_mul_im_sq_le_normSq_denom (z : ℍ) (g : SL(2, ℝ)) :
   calc
     (c * z.im) ^ 2 ≤ (c * z.im) ^ 2 + (c * z.re + d) ^ 2 := by nlinarith
     _ = Complex.normSq (denom g z) := by simp [Complex.normSq] <;> ring
-    
 #align upper_half_plane.c_mul_im_sq_le_norm_sq_denom UpperHalfPlane.c_mul_im_sq_le_normSq_denom
 
 theorem SpecialLinearGroup.im_smul_eq_div_normSq : (g • z).im = z.im / Complex.normSq (denom g z) :=
Diff
@@ -51,12 +51,12 @@ local notation:1024 "↑ₘ[" R "]" => @coe _ (Matrix (Fin 2) (Fin 2) R) _
 -- mathport name: «exprGL( , )⁺»
 local notation "GL(" n ", " R ")" "⁺" => Matrix.GLPos (Fin n) R
 
-/- ./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler λ α,
+/- ./././Mathport/Syntax/Translate/Command.lean:43:9: unsupported derive handler λ α,
 has_coe[has_coe] α exprℂ() -/
 /-- The open upper half plane -/
 def UpperHalfPlane :=
   { point : ℂ // 0 < point.im }
-deriving «./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler λ α,
+deriving «./././Mathport/Syntax/Translate/Command.lean:43:9: unsupported derive handler λ α,
   has_coe[has_coe] α exprℂ()»
 #align upper_half_plane UpperHalfPlane
 
@@ -164,7 +164,7 @@ theorem linear_ne_zero (cd : Fin 2 → ℝ) (z : ℍ) (h : cd ≠ 0) : (cd 0 : 
   have : cd 0 = 0 :=
     by
     -- we will need this twice
-    apply_fun Complex.im  at h 
+    apply_fun Complex.im at h 
     simpa only [z.im_ne_zero, Complex.add_im, add_zero, coe_im, MulZeroClass.zero_mul, or_false_iff,
       Complex.ofReal_im, Complex.zero_im, Complex.mul_im, mul_eq_zero] using h
   simp only [this, MulZeroClass.zero_mul, Complex.ofReal_zero, zero_add, Complex.ofReal_eq_zero] at
@@ -218,7 +218,8 @@ theorem smulAux'_im (g : GL(2, ℝ)⁺) (z : ℍ) :
 def smulAux (g : GL(2, ℝ)⁺) (z : ℍ) : ℍ :=
   ⟨smulAux' g z, by
     rw [smul_aux'_im]
-    convert mul_pos ((mem_GL_pos _).1 g.prop)
+    convert
+      mul_pos ((mem_GL_pos _).1 g.prop)
         (div_pos z.im_pos (complex.norm_sq_pos.mpr (denom_ne_zero g z)))
     simp only [general_linear_group.coe_det_apply, coe_coe]
     ring⟩
Diff
@@ -55,8 +55,8 @@ local notation "GL(" n ", " R ")" "⁺" => Matrix.GLPos (Fin n) R
 has_coe[has_coe] α exprℂ() -/
 /-- The open upper half plane -/
 def UpperHalfPlane :=
-  { point : ℂ // 0 < point.im }deriving
-  «./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler λ α,
+  { point : ℂ // 0 < point.im }
+deriving «./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler λ α,
   has_coe[has_coe] α exprℂ()»
 #align upper_half_plane UpperHalfPlane
 
@@ -164,11 +164,11 @@ theorem linear_ne_zero (cd : Fin 2 → ℝ) (z : ℍ) (h : cd ≠ 0) : (cd 0 : 
   have : cd 0 = 0 :=
     by
     -- we will need this twice
-    apply_fun Complex.im  at h
+    apply_fun Complex.im  at h 
     simpa only [z.im_ne_zero, Complex.add_im, add_zero, coe_im, MulZeroClass.zero_mul, or_false_iff,
       Complex.ofReal_im, Complex.zero_im, Complex.mul_im, mul_eq_zero] using h
   simp only [this, MulZeroClass.zero_mul, Complex.ofReal_zero, zero_add, Complex.ofReal_eq_zero] at
-    h
+    h 
   ext i
   fin_cases i <;> assumption
 #align upper_half_plane.linear_ne_zero UpperHalfPlane.linear_ne_zero
@@ -178,15 +178,15 @@ theorem denom_ne_zero (g : GL(2, ℝ)⁺) (z : ℍ) : denom g z ≠ 0 :=
   intro H
   have DET := (mem_GL_pos _).1 g.prop
   have hz := z.prop
-  simp only [general_linear_group.coe_det_apply] at DET
+  simp only [general_linear_group.coe_det_apply] at DET 
   have H1 : (↑ₘg 1 0 : ℝ) = 0 ∨ z.im = 0 := by simpa using congr_arg Complex.im H
   cases H1
   · simp only [H1, Complex.ofReal_zero, denom, coe_fn_eq_coe, MulZeroClass.zero_mul, zero_add,
-      Complex.ofReal_eq_zero] at H
-    rw [← coe_coe, Matrix.det_fin_two (↑g : Matrix (Fin 2) (Fin 2) ℝ)] at DET
-    simp only [coe_coe, H, H1, MulZeroClass.mul_zero, sub_zero, lt_self_iff_false] at DET
+      Complex.ofReal_eq_zero] at H 
+    rw [← coe_coe, Matrix.det_fin_two (↑g : Matrix (Fin 2) (Fin 2) ℝ)] at DET 
+    simp only [coe_coe, H, H1, MulZeroClass.mul_zero, sub_zero, lt_self_iff_false] at DET 
     exact DET
-  · change z.im > 0 at hz
+  · change z.im > 0 at hz 
     linarith
 #align upper_half_plane.denom_ne_zero UpperHalfPlane.denom_ne_zero
 
@@ -470,7 +470,7 @@ theorem modular_t_smul (z : ℍ) : ModularGroup.T • z = (1 : ℝ) +ᵥ z := by
 #align upper_half_plane.modular_T_smul UpperHalfPlane.modular_t_smul
 
 theorem exists_SL2_smul_eq_of_apply_zero_one_eq_zero (g : SL(2, ℝ)) (hc : ↑ₘ[ℝ] g 1 0 = 0) :
-    ∃ (u : { x : ℝ // 0 < x })(v : ℝ), ((· • ·) g : ℍ → ℍ) = (fun z => v +ᵥ z) ∘ fun z => u • z :=
+    ∃ (u : { x : ℝ // 0 < x }) (v : ℝ), ((· • ·) g : ℍ → ℍ) = (fun z => v +ᵥ z) ∘ fun z => u • z :=
   by
   obtain ⟨a, b, ha, rfl⟩ := g.fin_two_exists_eq_mk_of_apply_zero_one_eq_zero hc
   refine' ⟨⟨_, mul_self_pos.mpr ha⟩, b * a, _⟩
@@ -481,7 +481,7 @@ theorem exists_SL2_smul_eq_of_apply_zero_one_eq_zero (g : SL(2, ℝ)) (hc : ↑
 #align upper_half_plane.exists_SL2_smul_eq_of_apply_zero_one_eq_zero UpperHalfPlane.exists_SL2_smul_eq_of_apply_zero_one_eq_zero
 
 theorem exists_SL2_smul_eq_of_apply_zero_one_ne_zero (g : SL(2, ℝ)) (hc : ↑ₘ[ℝ] g 1 0 ≠ 0) :
-    ∃ (u : { x : ℝ // 0 < x })(v w : ℝ),
+    ∃ (u : { x : ℝ // 0 < x }) (v w : ℝ),
       ((· • ·) g : ℍ → ℍ) =
         ((· +ᵥ ·) w : ℍ → ℍ) ∘
           ((· • ·) ModularGroup.S : ℍ → ℍ) ∘ ((· +ᵥ ·) v : ℍ → ℍ) ∘ ((· • ·) u : ℍ → ℍ) :=
Diff
@@ -32,7 +32,7 @@ noncomputable section
 
 open Matrix Matrix.SpecialLinearGroup
 
-open Classical BigOperators MatrixGroups
+open scoped Classical BigOperators MatrixGroups
 
 attribute [local instance] Fintype.card_fin_even
 
Diff
@@ -134,9 +134,7 @@ theorem ne_zero (z : ℍ) : (z : ℂ) ≠ 0 :=
   mt (congr_arg Complex.im) z.im_ne_zero
 #align upper_half_plane.ne_zero UpperHalfPlane.ne_zero
 
-theorem normSq_pos (z : ℍ) : 0 < Complex.normSq (z : ℂ) :=
-  by
-  rw [Complex.normSq_pos]
+theorem normSq_pos (z : ℍ) : 0 < Complex.normSq (z : ℂ) := by rw [Complex.normSq_pos];
   exact z.ne_zero
 #align upper_half_plane.norm_sq_pos UpperHalfPlane.normSq_pos
 
@@ -253,8 +251,7 @@ theorem mul_smul' (x y : GL(2, ℝ)⁺) (z : ℍ) : smulAux (x * y) z = smulAux
 instance : MulAction GL(2, ℝ)⁺ ℍ where
   smul := smulAux
   one_smul z := by
-    ext1
-    change _ / _ = _
+    ext1; change _ / _ = _
     simp [coeFn_coe_base']
   mul_smul := mul_smul'
 
@@ -279,9 +276,7 @@ theorem sLOnGLPos_smul_apply (s : SL(2, ℤ)) (g : GL(2, ℝ)⁺) (z : ℍ) :
 #align upper_half_plane.SL_on_GL_pos_smul_apply UpperHalfPlane.sLOnGLPos_smul_apply
 
 instance SL_to_GL_tower : IsScalarTower SL(2, ℤ) GL(2, ℝ)⁺ ℍ
-    where smul_assoc := by
-    intro s g z
-    simp only [SL_on_GL_pos_smul_apply, coe_coe]
+    where smul_assoc := by intro s g z; simp only [SL_on_GL_pos_smul_apply, coe_coe];
     apply mul_smul'
 #align upper_half_plane.SL_to_GL_tower UpperHalfPlane.SL_to_GL_tower
 
@@ -295,9 +290,7 @@ theorem subgroup_on_gLPos_smul_apply (s : Γ) (g : GL(2, ℝ)⁺) (z : ℍ) :
 #align upper_half_plane.subgroup_on_GL_pos_smul_apply UpperHalfPlane.subgroup_on_gLPos_smul_apply
 
 instance subgroup_on_gLPos : IsScalarTower Γ GL(2, ℝ)⁺ ℍ
-    where smul_assoc := by
-    intro s g z
-    simp only [subgroup_on_GL_pos_smul_apply, coe_coe]
+    where smul_assoc := by intro s g z; simp only [subgroup_on_GL_pos_smul_apply, coe_coe];
     apply mul_smul'
 #align upper_half_plane.subgroup_on_GL_pos UpperHalfPlane.subgroup_on_gLPos
 
@@ -311,9 +304,7 @@ theorem subgroup_on_SL_apply (s : Γ) (g : SL(2, ℤ)) (z : ℍ) :
 #align upper_half_plane.subgroup_on_SL_apply UpperHalfPlane.subgroup_on_SL_apply
 
 instance subgroup_to_SL_tower : IsScalarTower Γ SL(2, ℤ) ℍ
-    where smul_assoc s g z := by
-    rw [subgroup_on_SL_apply]
-    apply MulAction.mul_smul
+    where smul_assoc s g z := by rw [subgroup_on_SL_apply]; apply MulAction.mul_smul
 #align upper_half_plane.subgroup_to_SL_tower UpperHalfPlane.subgroup_to_SL_tower
 
 end ModularScalarTowers
@@ -462,10 +453,8 @@ end RealAddAction
 
 /- these next few lemmas are *not* flagged `@simp` because of the constructors on the RHS;
 instead we use the versions with coercions to `ℂ` as simp lemmas instead. -/
-theorem modular_s_smul (z : ℍ) : ModularGroup.S • z = mk (-z : ℂ)⁻¹ z.im_inv_neg_coe_pos :=
-  by
-  rw [special_linear_group_apply]
-  simp [ModularGroup.S, neg_div, inv_neg]
+theorem modular_s_smul (z : ℍ) : ModularGroup.S • z = mk (-z : ℂ)⁻¹ z.im_inv_neg_coe_pos := by
+  rw [special_linear_group_apply]; simp [ModularGroup.S, neg_div, inv_neg]
 #align upper_half_plane.modular_S_smul UpperHalfPlane.modular_s_smul
 
 theorem modular_t_zpow_smul (z : ℍ) (n : ℤ) : ModularGroup.T ^ n • z = (n : ℝ) +ᵥ z :=
@@ -485,11 +474,8 @@ theorem exists_SL2_smul_eq_of_apply_zero_one_eq_zero (g : SL(2, ℝ)) (hc : ↑
   by
   obtain ⟨a, b, ha, rfl⟩ := g.fin_two_exists_eq_mk_of_apply_zero_one_eq_zero hc
   refine' ⟨⟨_, mul_self_pos.mpr ha⟩, b * a, _⟩
-  ext1 ⟨z, hz⟩
-  ext1
-  suffices ↑a * z * a + b * a = b * a + a * a * z
-    by
-    rw [special_linear_group_apply]
+  ext1 ⟨z, hz⟩; ext1
+  suffices ↑a * z * a + b * a = b * a + a * a * z by rw [special_linear_group_apply];
     simpa [add_mul]
   ring
 #align upper_half_plane.exists_SL2_smul_eq_of_apply_zero_one_eq_zero UpperHalfPlane.exists_SL2_smul_eq_of_apply_zero_one_eq_zero
@@ -502,28 +488,19 @@ theorem exists_SL2_smul_eq_of_apply_zero_one_ne_zero (g : SL(2, ℝ)) (hc : ↑
   by
   have h_denom := denom_ne_zero g
   induction' g using Matrix.SpecialLinearGroup.fin_two_induction with a b c d h
-  replace hc : c ≠ 0
-  · simpa using hc
+  replace hc : c ≠ 0; · simpa using hc
   refine' ⟨⟨_, mul_self_pos.mpr hc⟩, c * d, a / c, _⟩
-  ext1 ⟨z, hz⟩
-  ext1
+  ext1 ⟨z, hz⟩; ext1
   suffices (↑a * z + b) / (↑c * z + d) = a / c - (c * d + ↑c * ↑c * z)⁻¹
     by
     rw [special_linear_group_apply]
     simpa only [inv_neg, modular_S_smul, Subtype.coe_mk, coe_vadd, Complex.ofReal_mul,
       coe_pos_real_smul, Complex.real_smul, Function.comp_apply, Complex.ofReal_div]
-  replace hc : (c : ℂ) ≠ 0
-  · norm_cast
-    assumption
-  replace h_denom : ↑c * z + d ≠ 0
-  · simpa using h_denom ⟨z, hz⟩
-  have h_aux : (c : ℂ) * d + ↑c * ↑c * z ≠ 0 :=
-    by
-    rw [mul_assoc, ← mul_add, add_comm]
+  replace hc : (c : ℂ) ≠ 0; · norm_cast; assumption
+  replace h_denom : ↑c * z + d ≠ 0; · simpa using h_denom ⟨z, hz⟩
+  have h_aux : (c : ℂ) * d + ↑c * ↑c * z ≠ 0 := by rw [mul_assoc, ← mul_add, add_comm];
     exact mul_ne_zero hc h_denom
-  replace h : (a * d - b * c : ℂ) = (1 : ℂ)
-  · norm_cast
-    assumption
+  replace h : (a * d - b * c : ℂ) = (1 : ℂ); · norm_cast; assumption
   field_simp
   linear_combination (-(z * ↑c ^ 2) - ↑c * ↑d) * h
 #align upper_half_plane.exists_SL2_smul_eq_of_apply_zero_one_ne_zero UpperHalfPlane.exists_SL2_smul_eq_of_apply_zero_one_ne_zero
Diff
@@ -49,7 +49,7 @@ local prefix:1024 "↑ₘ" => @coe _ (Matrix (Fin 2) (Fin 2) _) _
 local notation:1024 "↑ₘ[" R "]" => @coe _ (Matrix (Fin 2) (Fin 2) R) _
 
 -- mathport name: «exprGL( , )⁺»
-local notation "GL(" n ", " R ")" "⁺" => Matrix.gLPos (Fin n) R
+local notation "GL(" n ", " R ")" "⁺" => Matrix.GLPos (Fin n) R
 
 /- ./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler λ α,
 has_coe[has_coe] α exprℂ() -/
Diff
@@ -462,21 +462,21 @@ end RealAddAction
 
 /- these next few lemmas are *not* flagged `@simp` because of the constructors on the RHS;
 instead we use the versions with coercions to `ℂ` as simp lemmas instead. -/
-theorem modular_s_smul (z : ℍ) : ModularGroup.s • z = mk (-z : ℂ)⁻¹ z.im_inv_neg_coe_pos :=
+theorem modular_s_smul (z : ℍ) : ModularGroup.S • z = mk (-z : ℂ)⁻¹ z.im_inv_neg_coe_pos :=
   by
   rw [special_linear_group_apply]
-  simp [ModularGroup.s, neg_div, inv_neg]
+  simp [ModularGroup.S, neg_div, inv_neg]
 #align upper_half_plane.modular_S_smul UpperHalfPlane.modular_s_smul
 
-theorem modular_t_zpow_smul (z : ℍ) (n : ℤ) : ModularGroup.t ^ n • z = (n : ℝ) +ᵥ z :=
+theorem modular_t_zpow_smul (z : ℍ) (n : ℤ) : ModularGroup.T ^ n • z = (n : ℝ) +ᵥ z :=
   by
   rw [← Subtype.coe_inj, coe_vadd, add_comm, special_linear_group_apply, coe_mk,
-    ModularGroup.coe_t_zpow]
+    ModularGroup.coe_T_zpow]
   simp only [of_apply, cons_val_zero, algebraMap.coe_one, Complex.ofReal_one, one_mul, cons_val_one,
     head_cons, algebraMap.coe_zero, MulZeroClass.zero_mul, zero_add, div_one]
 #align upper_half_plane.modular_T_zpow_smul UpperHalfPlane.modular_t_zpow_smul
 
-theorem modular_t_smul (z : ℍ) : ModularGroup.t • z = (1 : ℝ) +ᵥ z := by
+theorem modular_t_smul (z : ℍ) : ModularGroup.T • z = (1 : ℝ) +ᵥ z := by
   simpa only [algebraMap.coe_one] using modular_T_zpow_smul z 1
 #align upper_half_plane.modular_T_smul UpperHalfPlane.modular_t_smul
 
@@ -498,7 +498,7 @@ theorem exists_SL2_smul_eq_of_apply_zero_one_ne_zero (g : SL(2, ℝ)) (hc : ↑
     ∃ (u : { x : ℝ // 0 < x })(v w : ℝ),
       ((· • ·) g : ℍ → ℍ) =
         ((· +ᵥ ·) w : ℍ → ℍ) ∘
-          ((· • ·) ModularGroup.s : ℍ → ℍ) ∘ ((· +ᵥ ·) v : ℍ → ℍ) ∘ ((· • ·) u : ℍ → ℍ) :=
+          ((· • ·) ModularGroup.S : ℍ → ℍ) ∘ ((· +ᵥ ·) v : ℍ → ℍ) ∘ ((· • ·) u : ℍ → ℍ) :=
   by
   have h_denom := denom_ne_zero g
   induction' g using Matrix.SpecialLinearGroup.fin_two_induction with a b c d h
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alex Kontorovich, Heather Macbeth, Marc Masdeu
 
 ! This file was ported from Lean 3 source module analysis.complex.upper_half_plane.basic
-! leanprover-community/mathlib commit f06058e64b7e8397234455038f3f8aec83aaba5a
+! leanprover-community/mathlib commit 34d3797325d202bd7250431275bb871133cdb611
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -460,13 +460,26 @@ theorem vadd_im : (x +ᵥ z).im = z.im :=
 
 end RealAddAction
 
-@[simp]
+/- these next few lemmas are *not* flagged `@simp` because of the constructors on the RHS;
+instead we use the versions with coercions to `ℂ` as simp lemmas instead. -/
 theorem modular_s_smul (z : ℍ) : ModularGroup.s • z = mk (-z : ℂ)⁻¹ z.im_inv_neg_coe_pos :=
   by
   rw [special_linear_group_apply]
   simp [ModularGroup.s, neg_div, inv_neg]
 #align upper_half_plane.modular_S_smul UpperHalfPlane.modular_s_smul
 
+theorem modular_t_zpow_smul (z : ℍ) (n : ℤ) : ModularGroup.t ^ n • z = (n : ℝ) +ᵥ z :=
+  by
+  rw [← Subtype.coe_inj, coe_vadd, add_comm, special_linear_group_apply, coe_mk,
+    ModularGroup.coe_t_zpow]
+  simp only [of_apply, cons_val_zero, algebraMap.coe_one, Complex.ofReal_one, one_mul, cons_val_one,
+    head_cons, algebraMap.coe_zero, MulZeroClass.zero_mul, zero_add, div_one]
+#align upper_half_plane.modular_T_zpow_smul UpperHalfPlane.modular_t_zpow_smul
+
+theorem modular_t_smul (z : ℍ) : ModularGroup.t • z = (1 : ℝ) +ᵥ z := by
+  simpa only [algebraMap.coe_one] using modular_T_zpow_smul z 1
+#align upper_half_plane.modular_T_smul UpperHalfPlane.modular_t_smul
+
 theorem exists_SL2_smul_eq_of_apply_zero_one_eq_zero (g : SL(2, ℝ)) (hc : ↑ₘ[ℝ] g 1 0 = 0) :
     ∃ (u : { x : ℝ // 0 < x })(v : ℝ), ((· • ·) g : ℍ → ℍ) = (fun z => v +ᵥ z) ∘ fun z => u • z :=
   by
@@ -497,7 +510,8 @@ theorem exists_SL2_smul_eq_of_apply_zero_one_ne_zero (g : SL(2, ℝ)) (hc : ↑
   suffices (↑a * z + b) / (↑c * z + d) = a / c - (c * d + ↑c * ↑c * z)⁻¹
     by
     rw [special_linear_group_apply]
-    simpa [-neg_add_rev, inv_neg, ← sub_eq_add_neg]
+    simpa only [inv_neg, modular_S_smul, Subtype.coe_mk, coe_vadd, Complex.ofReal_mul,
+      coe_pos_real_smul, Complex.real_smul, Function.comp_apply, Complex.ofReal_div]
   replace hc : (c : ℂ) ≠ 0
   · norm_cast
     assumption
Diff
@@ -220,8 +220,7 @@ theorem smulAux'_im (g : GL(2, ℝ)⁺) (z : ℍ) :
 def smulAux (g : GL(2, ℝ)⁺) (z : ℍ) : ℍ :=
   ⟨smulAux' g z, by
     rw [smul_aux'_im]
-    convert
-      mul_pos ((mem_GL_pos _).1 g.prop)
+    convert mul_pos ((mem_GL_pos _).1 g.prop)
         (div_pos z.im_pos (complex.norm_sq_pos.mpr (denom_ne_zero g z)))
     simp only [general_linear_group.coe_det_apply, coe_coe]
     ring⟩
Diff
@@ -167,9 +167,10 @@ theorem linear_ne_zero (cd : Fin 2 → ℝ) (z : ℍ) (h : cd ≠ 0) : (cd 0 : 
     by
     -- we will need this twice
     apply_fun Complex.im  at h
-    simpa only [z.im_ne_zero, Complex.add_im, add_zero, coe_im, zero_mul, or_false_iff,
+    simpa only [z.im_ne_zero, Complex.add_im, add_zero, coe_im, MulZeroClass.zero_mul, or_false_iff,
       Complex.ofReal_im, Complex.zero_im, Complex.mul_im, mul_eq_zero] using h
-  simp only [this, zero_mul, Complex.ofReal_zero, zero_add, Complex.ofReal_eq_zero] at h
+  simp only [this, MulZeroClass.zero_mul, Complex.ofReal_zero, zero_add, Complex.ofReal_eq_zero] at
+    h
   ext i
   fin_cases i <;> assumption
 #align upper_half_plane.linear_ne_zero UpperHalfPlane.linear_ne_zero
@@ -182,10 +183,10 @@ theorem denom_ne_zero (g : GL(2, ℝ)⁺) (z : ℍ) : denom g z ≠ 0 :=
   simp only [general_linear_group.coe_det_apply] at DET
   have H1 : (↑ₘg 1 0 : ℝ) = 0 ∨ z.im = 0 := by simpa using congr_arg Complex.im H
   cases H1
-  · simp only [H1, Complex.ofReal_zero, denom, coe_fn_eq_coe, zero_mul, zero_add,
+  · simp only [H1, Complex.ofReal_zero, denom, coe_fn_eq_coe, MulZeroClass.zero_mul, zero_add,
       Complex.ofReal_eq_zero] at H
     rw [← coe_coe, Matrix.det_fin_two (↑g : Matrix (Fin 2) (Fin 2) ℝ)] at DET
-    simp only [coe_coe, H, H1, mul_zero, sub_zero, lt_self_iff_false] at DET
+    simp only [coe_coe, H, H1, MulZeroClass.mul_zero, sub_zero, lt_self_iff_false] at DET
     exact DET
   · change z.im > 0 at hz
     linarith
Diff
@@ -66,7 +66,7 @@ scoped[UpperHalfPlane] notation "ℍ" => UpperHalfPlane
 namespace UpperHalfPlane
 
 instance : Inhabited ℍ :=
-  ⟨⟨Complex.i, by simp⟩⟩
+  ⟨⟨Complex.I, by simp⟩⟩
 
 instance canLift : CanLift ℂ ℍ coe fun z => 0 < z.im :=
   Subtype.canLift fun z => 0 < z.im
@@ -118,7 +118,7 @@ theorem mk_coe (z : ℍ) (h : 0 < (z : ℂ).im := z.2) : mk z h = z :=
   Subtype.eta z h
 #align upper_half_plane.mk_coe UpperHalfPlane.mk_coe
 
-theorem re_add_im (z : ℍ) : (z.re + z.im * Complex.i : ℂ) = z :=
+theorem re_add_im (z : ℍ) : (z.re + z.im * Complex.I : ℂ) = z :=
   Complex.re_add_im z
 #align upper_half_plane.re_add_im UpperHalfPlane.re_add_im
 
@@ -168,8 +168,8 @@ theorem linear_ne_zero (cd : Fin 2 → ℝ) (z : ℍ) (h : cd ≠ 0) : (cd 0 : 
     -- we will need this twice
     apply_fun Complex.im  at h
     simpa only [z.im_ne_zero, Complex.add_im, add_zero, coe_im, zero_mul, or_false_iff,
-      Complex.of_real_im, Complex.zero_im, Complex.mul_im, mul_eq_zero] using h
-  simp only [this, zero_mul, Complex.of_real_zero, zero_add, Complex.of_real_eq_zero] at h
+      Complex.ofReal_im, Complex.zero_im, Complex.mul_im, mul_eq_zero] using h
+  simp only [this, zero_mul, Complex.ofReal_zero, zero_add, Complex.ofReal_eq_zero] at h
   ext i
   fin_cases i <;> assumption
 #align upper_half_plane.linear_ne_zero UpperHalfPlane.linear_ne_zero
@@ -182,8 +182,8 @@ theorem denom_ne_zero (g : GL(2, ℝ)⁺) (z : ℍ) : denom g z ≠ 0 :=
   simp only [general_linear_group.coe_det_apply] at DET
   have H1 : (↑ₘg 1 0 : ℝ) = 0 ∨ z.im = 0 := by simpa using congr_arg Complex.im H
   cases H1
-  · simp only [H1, Complex.of_real_zero, denom, coe_fn_eq_coe, zero_mul, zero_add,
-      Complex.of_real_eq_zero] at H
+  · simp only [H1, Complex.ofReal_zero, denom, coe_fn_eq_coe, zero_mul, zero_add,
+      Complex.ofReal_eq_zero] at H
     rw [← coe_coe, Matrix.det_fin_two (↑g : Matrix (Fin 2) (Fin 2) ℝ)] at DET
     simp only [coe_coe, H, H1, mul_zero, sub_zero, lt_self_iff_false] at DET
     exact DET
@@ -233,7 +233,7 @@ theorem denom_cocycle (x y : GL(2, ℝ)⁺) (z : ℍ) :
   field_simp [denom_ne_zero, -denom, -Num]
   simp only [Matrix.mul, dot_product, Fin.sum_univ_succ, denom, Num, coe_coe, Subgroup.coe_mul,
     general_linear_group.coe_mul, Fintype.univ_ofSubsingleton, Fin.mk_zero, Finset.sum_singleton,
-    Fin.succ_zero_eq_one, Complex.of_real_add, Complex.of_real_mul]
+    Fin.succ_zero_eq_one, Complex.ofReal_add, Complex.ofReal_mul]
   ring
 #align upper_half_plane.denom_cocycle UpperHalfPlane.denom_cocycle
 
@@ -245,7 +245,7 @@ theorem mul_smul' (x y : GL(2, ℝ)⁺) (z : ℍ) : smulAux (x * y) z = smulAux
   field_simp [denom_ne_zero, -denom, -Num]
   simp only [Matrix.mul, dot_product, Fin.sum_univ_succ, Num, denom, coe_coe, Subgroup.coe_mul,
     general_linear_group.coe_mul, Fintype.univ_ofSubsingleton, Fin.mk_zero, Finset.sum_singleton,
-    Fin.succ_zero_eq_one, Complex.of_real_add, Complex.of_real_mul]
+    Fin.succ_zero_eq_one, Complex.ofReal_add, Complex.ofReal_mul]
   ring
 #align upper_half_plane.mul_smul' UpperHalfPlane.mul_smul'
 
@@ -352,7 +352,7 @@ theorem neg_smul (g : GL(2, ℝ)⁺) (z : ℍ) : -g • z = g • z :=
   ext1
   change _ / _ = _ / _
   field_simp [denom_ne_zero, -denom, -Num]
-  simp only [Num, denom, coe_coe, Complex.of_real_neg, neg_mul, GL_pos.coe_neg_GL, Units.val_neg,
+  simp only [Num, denom, coe_coe, Complex.ofReal_neg, neg_mul, GL_pos.coe_neg_GL, Units.val_neg,
     Pi.neg_apply]
   ring_nf
 #align upper_half_plane.neg_smul UpperHalfPlane.neg_smul
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alex Kontorovich, Heather Macbeth, Marc Masdeu
 
 ! This file was ported from Lean 3 source module analysis.complex.upper_half_plane.basic
-! leanprover-community/mathlib commit ae690b0c236e488a0043f6faa8ce3546e7f2f9c5
+! leanprover-community/mathlib commit f06058e64b7e8397234455038f3f8aec83aaba5a
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -13,6 +13,7 @@ import Mathbin.LinearAlgebra.Matrix.SpecialLinearGroup
 import Mathbin.Analysis.Complex.Basic
 import Mathbin.GroupTheory.GroupAction.Defs
 import Mathbin.LinearAlgebra.Matrix.GeneralLinearGroup
+import Mathbin.Tactic.LinearCombination
 
 /-!
 # The upper half plane and its automorphisms
@@ -35,13 +36,18 @@ open Classical BigOperators MatrixGroups
 
 attribute [local instance] Fintype.card_fin_even
 
-/- Disable this instances as it is not the simp-normal form, and having them disabled ensures
+/- Disable these instances as they are not the simp-normal form, and having them disabled ensures
 we state lemmas in this file without spurious `coe_fn` terms. -/
 attribute [-instance] Matrix.SpecialLinearGroup.hasCoeToFun
 
+attribute [-instance] Matrix.GeneralLinearGroup.hasCoeToFun
+
 -- mathport name: «expr↑ₘ »
 local prefix:1024 "↑ₘ" => @coe _ (Matrix (Fin 2) (Fin 2) _) _
 
+-- mathport name: «expr↑ₘ[ ]»
+local notation:1024 "↑ₘ[" R "]" => @coe _ (Matrix (Fin 2) (Fin 2) R) _
+
 -- mathport name: «exprGL( , )⁺»
 local notation "GL(" n ", " R ")" "⁺" => Matrix.gLPos (Fin n) R
 
@@ -138,6 +144,10 @@ theorem normSq_ne_zero (z : ℍ) : Complex.normSq (z : ℂ) ≠ 0 :=
   (normSq_pos z).ne'
 #align upper_half_plane.norm_sq_ne_zero UpperHalfPlane.normSq_ne_zero
 
+theorem im_inv_neg_coe_pos (z : ℍ) : 0 < (-z : ℂ)⁻¹.im := by
+  simpa using div_pos z.property (norm_sq_pos z)
+#align upper_half_plane.im_inv_neg_coe_pos UpperHalfPlane.im_inv_neg_coe_pos
+
 /-- Numerator of the formula for a fractional linear transformation -/
 @[simp]
 def num (g : GL(2, ℝ)⁺) (z : ℍ) : ℂ :=
@@ -308,6 +318,15 @@ instance subgroup_to_SL_tower : IsScalarTower Γ SL(2, ℤ) ℍ
 
 end ModularScalarTowers
 
+theorem specialLinearGroup_apply {R : Type _} [CommRing R] [Algebra R ℝ] (g : SL(2, R)) (z : ℍ) :
+    g • z =
+      mk
+        ((((↑(↑ₘ[R] g 0 0) : ℝ) : ℂ) * z + ((↑(↑ₘ[R] g 0 1) : ℝ) : ℂ)) /
+          (((↑(↑ₘ[R] g 1 0) : ℝ) : ℂ) * z + ((↑(↑ₘ[R] g 1 1) : ℝ) : ℂ)))
+        (g • z).property :=
+  rfl
+#align upper_half_plane.special_linear_group_apply UpperHalfPlane.specialLinearGroup_apply
+
 @[simp]
 theorem coe_smul (g : GL(2, ℝ)⁺) (z : ℍ) : ↑(g • z) = num g z / denom g z :=
   rfl
@@ -441,5 +460,59 @@ theorem vadd_im : (x +ᵥ z).im = z.im :=
 
 end RealAddAction
 
+@[simp]
+theorem modular_s_smul (z : ℍ) : ModularGroup.s • z = mk (-z : ℂ)⁻¹ z.im_inv_neg_coe_pos :=
+  by
+  rw [special_linear_group_apply]
+  simp [ModularGroup.s, neg_div, inv_neg]
+#align upper_half_plane.modular_S_smul UpperHalfPlane.modular_s_smul
+
+theorem exists_SL2_smul_eq_of_apply_zero_one_eq_zero (g : SL(2, ℝ)) (hc : ↑ₘ[ℝ] g 1 0 = 0) :
+    ∃ (u : { x : ℝ // 0 < x })(v : ℝ), ((· • ·) g : ℍ → ℍ) = (fun z => v +ᵥ z) ∘ fun z => u • z :=
+  by
+  obtain ⟨a, b, ha, rfl⟩ := g.fin_two_exists_eq_mk_of_apply_zero_one_eq_zero hc
+  refine' ⟨⟨_, mul_self_pos.mpr ha⟩, b * a, _⟩
+  ext1 ⟨z, hz⟩
+  ext1
+  suffices ↑a * z * a + b * a = b * a + a * a * z
+    by
+    rw [special_linear_group_apply]
+    simpa [add_mul]
+  ring
+#align upper_half_plane.exists_SL2_smul_eq_of_apply_zero_one_eq_zero UpperHalfPlane.exists_SL2_smul_eq_of_apply_zero_one_eq_zero
+
+theorem exists_SL2_smul_eq_of_apply_zero_one_ne_zero (g : SL(2, ℝ)) (hc : ↑ₘ[ℝ] g 1 0 ≠ 0) :
+    ∃ (u : { x : ℝ // 0 < x })(v w : ℝ),
+      ((· • ·) g : ℍ → ℍ) =
+        ((· +ᵥ ·) w : ℍ → ℍ) ∘
+          ((· • ·) ModularGroup.s : ℍ → ℍ) ∘ ((· +ᵥ ·) v : ℍ → ℍ) ∘ ((· • ·) u : ℍ → ℍ) :=
+  by
+  have h_denom := denom_ne_zero g
+  induction' g using Matrix.SpecialLinearGroup.fin_two_induction with a b c d h
+  replace hc : c ≠ 0
+  · simpa using hc
+  refine' ⟨⟨_, mul_self_pos.mpr hc⟩, c * d, a / c, _⟩
+  ext1 ⟨z, hz⟩
+  ext1
+  suffices (↑a * z + b) / (↑c * z + d) = a / c - (c * d + ↑c * ↑c * z)⁻¹
+    by
+    rw [special_linear_group_apply]
+    simpa [-neg_add_rev, inv_neg, ← sub_eq_add_neg]
+  replace hc : (c : ℂ) ≠ 0
+  · norm_cast
+    assumption
+  replace h_denom : ↑c * z + d ≠ 0
+  · simpa using h_denom ⟨z, hz⟩
+  have h_aux : (c : ℂ) * d + ↑c * ↑c * z ≠ 0 :=
+    by
+    rw [mul_assoc, ← mul_add, add_comm]
+    exact mul_ne_zero hc h_denom
+  replace h : (a * d - b * c : ℂ) = (1 : ℂ)
+  · norm_cast
+    assumption
+  field_simp
+  linear_combination (-(z * ↑c ^ 2) - ↑c * ↑d) * h
+#align upper_half_plane.exists_SL2_smul_eq_of_apply_zero_one_ne_zero UpperHalfPlane.exists_SL2_smul_eq_of_apply_zero_one_ne_zero
+
 end UpperHalfPlane
 

Changes in mathlib4

mathlib3
mathlib4
feat(Complex/UpperHalfPlane): add vertical strips (#12443)

We define the vertical strips that are needed for proving Eisenstein series are modular forms #10377 . We also add the definition of sqrt{-1} as an elements of the upper half plane. Note that this is no longer needed for the modular forms PRs but its good to have.

Sorry about the typo in the PR name, its not my day!

Co-authored-by: Chris Birkbeck <c.birkbeck@uea.ac.uk>

Diff
@@ -137,6 +137,18 @@ theorem ne_zero (z : ℍ) : (z : ℂ) ≠ 0 :=
   mt (congr_arg Complex.im) z.im_ne_zero
 #align upper_half_plane.ne_zero UpperHalfPlane.ne_zero
 
+/-- Define I := √-1 as an element on the upper half plane. -/
+def I : ℍ := ⟨Complex.I, by simp⟩
+
+@[simp]
+lemma I_im : I.im = 1 := rfl
+
+@[simp]
+lemma I_re : I.re = 0 := rfl
+
+@[simp, norm_cast]
+lemma coe_I : I = Complex.I := rfl
+
 end UpperHalfPlane
 
 namespace Mathlib.Meta.Positivity
chore: remove autoImplicit from more files (#11798)

and reduce its scope in a few other instances. Mostly in CategoryTheory and Data this time; some Combinatorics also.

Co-authored-by: Richard Osborn <richardosborn@mac.com>

Diff
@@ -301,14 +301,13 @@ def coe' : SL(2, ℤ) → GL(2, ℝ)⁺ := fun g => ((g : SL(2, ℝ)) : GL(2, 
 instance : Coe SL(2, ℤ) GL(2, ℝ)⁺ :=
   ⟨coe'⟩
 
-set_option autoImplicit true in
 @[simp]
-theorem coe'_apply_complex : (Units.val <| Subtype.val <| coe' g) i j = (Subtype.val g i j : ℂ) :=
+theorem coe'_apply_complex {g : SL(2, ℤ)} {i j : Fin 2} :
+    (Units.val <| Subtype.val <| coe' g) i j = (Subtype.val g i j : ℂ) :=
   rfl
 
-set_option autoImplicit true in
 @[simp]
-theorem det_coe' : det (Units.val <| Subtype.val <| coe' g) = 1 := by
+theorem det_coe' {g : SL(2, ℤ)} : det (Units.val <| Subtype.val <| coe' g) = 1 := by
   simp only [SpecialLinearGroup.coe_GLPos_coe_GL_coe_matrix, SpecialLinearGroup.det_coe, coe']
 
 instance SLOnGLPos : SMul SL(2, ℤ) GL(2, ℝ)⁺ :=
chore: move Mathlib to v4.7.0-rc1 (#11162)

This is a very large PR, but it has been reviewed piecemeal already in PRs to the bump/v4.7.0 branch as we update to intermediate nightlies.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: damiano <adomani@gmail.com>

Diff
@@ -230,6 +230,10 @@ def smulAux' (g : GL(2, ℝ)⁺) (z : ℍ) : ℂ :=
   num g z / denom g z
 #align upper_half_plane.smul_aux' UpperHalfPlane.smulAux'
 
+-- Adaptation note: after v4.7.0-rc1, there is a performance problem in `field_simp`.
+-- (Part of the code was ignoring the `maxDischargeDepth` setting: now that we have to increase it,
+-- other paths becomes slow.)
+set_option maxHeartbeats 400000 in
 theorem smulAux'_im (g : GL(2, ℝ)⁺) (z : ℍ) :
     (smulAux' g z).im = det ↑ₘg * z.im / Complex.normSq (denom g z) := by
   rw [smulAux', Complex.div_im]
style: homogenise porting notes (#11145)

Homogenises porting notes via capitalisation and addition of whitespace.

It makes the following changes:

  • converts "--porting note" into "-- Porting note";
  • converts "porting note" into "Porting note".
Diff
@@ -234,7 +234,7 @@ theorem smulAux'_im (g : GL(2, ℝ)⁺) (z : ℍ) :
     (smulAux' g z).im = det ↑ₘg * z.im / Complex.normSq (denom g z) := by
   rw [smulAux', Complex.div_im]
   field_simp [smulAux', num, denom]
-  -- porting note: the local notation still didn't work here
+  -- Porting note: the local notation still didn't work here
   rw [Matrix.det_fin_two ((g : GL (Fin 2) ℝ) : Matrix (Fin 2) (Fin 2) ℝ)]
   ring
 #align upper_half_plane.smul_aux'_im UpperHalfPlane.smulAux'_im
chore: prepare Lean version bump with explicit simp (#10999)

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

Diff
@@ -394,7 +394,7 @@ theorem c_mul_im_sq_le_normSq_denom (z : ℍ) (g : SL(2, ℝ)) :
   let d := (↑ₘg 1 1 : ℝ)
   calc
     (c * z.im) ^ 2 ≤ (c * z.im) ^ 2 + (c * z.re + d) ^ 2 := by nlinarith
-    _ = Complex.normSq (denom g z) := by dsimp [denom, Complex.normSq]; ring
+    _ = Complex.normSq (denom g z) := by dsimp [c, d, denom, Complex.normSq]; ring
 #align upper_half_plane.c_mul_im_sq_le_norm_sq_denom UpperHalfPlane.c_mul_im_sq_le_normSq_denom
 
 @[simp]
chore: remove stream-of-consciousness uses of have, replace and suffices (#10640)

No changes to tactic file, it's just boring fixes throughout the library.

This follows on from #6964.

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -535,19 +535,19 @@ theorem exists_SL2_smul_eq_of_apply_zero_one_ne_zero (g : SL(2, ℝ)) (hc : ↑
         (w +ᵥ ·) ∘ (ModularGroup.S • · : ℍ → ℍ) ∘ (v +ᵥ · : ℍ → ℍ) ∘ (u • · : ℍ → ℍ) := by
   have h_denom := denom_ne_zero g
   induction' g using Matrix.SpecialLinearGroup.fin_two_induction with a b c d h
-  replace hc : c ≠ 0; · simpa using hc
+  replace hc : c ≠ 0 := by simpa using hc
   refine' ⟨⟨_, mul_self_pos.mpr hc⟩, c * d, a / c, _⟩
   ext1 ⟨z, hz⟩; ext1
   suffices (↑a * z + b) / (↑c * z + d) = a / c - (c * d + ↑c * ↑c * z)⁻¹ by
     -- Porting note: golfed broken proof
     simpa only [modular_S_smul, inv_neg, Function.comp_apply, coe_vadd, Complex.ofReal_mul,
       coe_pos_real_smul, Complex.real_smul, Complex.ofReal_div, coe_mk]
-  replace hc : (c : ℂ) ≠ 0; · norm_cast
-  replace h_denom : ↑c * z + d ≠ 0; · simpa using h_denom ⟨z, hz⟩
+  replace hc : (c : ℂ) ≠ 0 := by norm_cast
+  replace h_denom : ↑c * z + d ≠ 0 := by simpa using h_denom ⟨z, hz⟩
   have h_aux : (c : ℂ) * d + ↑c * ↑c * z ≠ 0 := by
     rw [mul_assoc, ← mul_add, add_comm]
     exact mul_ne_zero hc h_denom
-  replace h : (a * d - b * c : ℂ) = (1 : ℂ); · norm_cast
+  replace h : (a * d - b * c : ℂ) = (1 : ℂ) := by norm_cast
   field_simp
   linear_combination (-(z * (c:ℂ) ^ 2) - c * d) * h
 #align upper_half_plane.exists_SL2_smul_eq_of_apply_zero_one_ne_zero UpperHalfPlane.exists_SL2_smul_eq_of_apply_zero_one_ne_zero
refactor : add namespace UpperHalfPlane.ModularGroup (#7885)

Rename some definitions and theorems about $SL(2, ℤ)$ in Analysis/Complex/UpperHalfPlane/Basic.lean to place them in the namespace UpperHalfPlane.ModularGroup, in order to avoid the confusion with definitions and theorems about $SL(2, ℝ)$. For example, UpperHalfPlane.det_coe' is renamed to UpperHalfPlane.ModularGroup.det_coe', because we will have UpperHalfPlane.SL2R.det_coe'.

Co-authored-by: Johan Commelin <johan@commelin.net>

Diff
@@ -282,12 +282,15 @@ instance : MulAction GL(2, ℝ)⁺ ℍ where
 
 section ModularScalarTowers
 
-variable (Γ : Subgroup (SpecialLinearGroup (Fin 2) ℤ))
-
 instance SLAction {R : Type*} [CommRing R] [Algebra R ℝ] : MulAction SL(2, R) ℍ :=
   MulAction.compHom ℍ <| SpecialLinearGroup.toGLPos.comp <| map (algebraMap R ℝ)
 #align upper_half_plane.SL_action UpperHalfPlane.SLAction
 
+namespace ModularGroup
+
+variable (Γ : Subgroup (SpecialLinearGroup (Fin 2) ℤ))
+
+/-- Canonical embedding of `SL(2, ℤ)` into `GL(2, ℝ)⁺`. -/
 @[coe]
 def coe' : SL(2, ℤ) → GL(2, ℝ)⁺ := fun g => ((g : SL(2, ℝ)) : GL(2, ℝ)⁺)
 
@@ -306,50 +309,52 @@ theorem det_coe' : det (Units.val <| Subtype.val <| coe' g) = 1 := by
 
 instance SLOnGLPos : SMul SL(2, ℤ) GL(2, ℝ)⁺ :=
   ⟨fun s g => s * g⟩
-#align upper_half_plane.SL_on_GL_pos UpperHalfPlane.SLOnGLPos
+#align upper_half_plane.SL_on_GL_pos UpperHalfPlane.ModularGroup.SLOnGLPos
 
 theorem SLOnGLPos_smul_apply (s : SL(2, ℤ)) (g : GL(2, ℝ)⁺) (z : ℍ) :
     (s • g) • z = ((s : GL(2, ℝ)⁺) * g) • z :=
   rfl
-#align upper_half_plane.SL_on_GL_pos_smul_apply UpperHalfPlane.SLOnGLPos_smul_apply
+#align upper_half_plane.SL_on_GL_pos_smul_apply UpperHalfPlane.ModularGroup.SLOnGLPos_smul_apply
 
 instance SL_to_GL_tower : IsScalarTower SL(2, ℤ) GL(2, ℝ)⁺ ℍ where
   smul_assoc := by
     intro s g z
     simp only [SLOnGLPos_smul_apply]
     apply mul_smul'
-#align upper_half_plane.SL_to_GL_tower UpperHalfPlane.SL_to_GL_tower
+#align upper_half_plane.SL_to_GL_tower UpperHalfPlane.ModularGroup.SL_to_GL_tower
 
 instance subgroupGLPos : SMul Γ GL(2, ℝ)⁺ :=
   ⟨fun s g => s * g⟩
-#align upper_half_plane.subgroup_GL_pos UpperHalfPlane.subgroupGLPos
+#align upper_half_plane.subgroup_GL_pos UpperHalfPlane.ModularGroup.subgroupGLPos
 
 theorem subgroup_on_glpos_smul_apply (s : Γ) (g : GL(2, ℝ)⁺) (z : ℍ) :
     (s • g) • z = ((s : GL(2, ℝ)⁺) * g) • z :=
   rfl
-#align upper_half_plane.subgroup_on_GL_pos_smul_apply UpperHalfPlane.subgroup_on_glpos_smul_apply
+#align upper_half_plane.subgroup_on_GL_pos_smul_apply UpperHalfPlane.ModularGroup.subgroup_on_glpos_smul_apply
 
 instance subgroup_on_glpos : IsScalarTower Γ GL(2, ℝ)⁺ ℍ where
   smul_assoc := by
     intro s g z
     simp only [subgroup_on_glpos_smul_apply]
     apply mul_smul'
-#align upper_half_plane.subgroup_on_GL_pos UpperHalfPlane.subgroup_on_glpos
+#align upper_half_plane.subgroup_on_GL_pos UpperHalfPlane.ModularGroup.subgroup_on_glpos
 
 instance subgroupSL : SMul Γ SL(2, ℤ) :=
   ⟨fun s g => s * g⟩
-#align upper_half_plane.subgroup_SL UpperHalfPlane.subgroupSL
+#align upper_half_plane.subgroup_SL UpperHalfPlane.ModularGroup.subgroupSL
 
 theorem subgroup_on_SL_apply (s : Γ) (g : SL(2, ℤ)) (z : ℍ) :
     (s • g) • z = ((s : SL(2, ℤ)) * g) • z :=
   rfl
-#align upper_half_plane.subgroup_on_SL_apply UpperHalfPlane.subgroup_on_SL_apply
+#align upper_half_plane.subgroup_on_SL_apply UpperHalfPlane.ModularGroup.subgroup_on_SL_apply
 
 instance subgroup_to_SL_tower : IsScalarTower Γ SL(2, ℤ) ℍ where
   smul_assoc s g z := by
     rw [subgroup_on_SL_apply]
     apply MulAction.mul_smul
-#align upper_half_plane.subgroup_to_SL_tower UpperHalfPlane.subgroup_to_SL_tower
+#align upper_half_plane.subgroup_to_SL_tower UpperHalfPlane.ModularGroup.subgroup_to_SL_tower
+
+end ModularGroup
 
 end ModularScalarTowers
 
@@ -383,6 +388,15 @@ theorem im_smul_eq_div_normSq (g : GL(2, ℝ)⁺) (z : ℍ) :
   smulAux'_im g z
 #align upper_half_plane.im_smul_eq_div_norm_sq UpperHalfPlane.im_smul_eq_div_normSq
 
+theorem c_mul_im_sq_le_normSq_denom (z : ℍ) (g : SL(2, ℝ)) :
+    ((↑ₘg 1 0 : ℝ) * z.im) ^ 2 ≤ Complex.normSq (denom g z) := by
+  let c := (↑ₘg 1 0 : ℝ)
+  let d := (↑ₘg 1 1 : ℝ)
+  calc
+    (c * z.im) ^ 2 ≤ (c * z.im) ^ 2 + (c * z.re + d) ^ 2 := by nlinarith
+    _ = Complex.normSq (denom g z) := by dsimp [denom, Complex.normSq]; ring
+#align upper_half_plane.c_mul_im_sq_le_norm_sq_denom UpperHalfPlane.c_mul_im_sq_le_normSq_denom
+
 @[simp]
 theorem neg_smul (g : GL(2, ℝ)⁺) (z : ℍ) : -g • z = g • z := by
   ext1
@@ -394,47 +408,42 @@ theorem neg_smul (g : GL(2, ℝ)⁺) (z : ℍ) : -g • z = g • z := by
 
 section SLModularAction
 
+namespace ModularGroup
+
 variable (g : SL(2, ℤ)) (z : ℍ) (Γ : Subgroup SL(2, ℤ))
 
 @[simp]
 theorem sl_moeb (A : SL(2, ℤ)) (z : ℍ) : A • z = (A : GL(2, ℝ)⁺) • z :=
   rfl
-#align upper_half_plane.sl_moeb UpperHalfPlane.sl_moeb
+#align upper_half_plane.sl_moeb UpperHalfPlane.ModularGroup.sl_moeb
 
 theorem subgroup_moeb (A : Γ) (z : ℍ) : A • z = (A : GL(2, ℝ)⁺) • z :=
   rfl
-#align upper_half_plane.subgroup_moeb UpperHalfPlane.subgroup_moeb
+#align upper_half_plane.subgroup_moeb UpperHalfPlane.ModularGroup.subgroup_moeb
 
 @[simp]
 theorem subgroup_to_sl_moeb (A : Γ) (z : ℍ) : A • z = (A : SL(2, ℤ)) • z :=
   rfl
-#align upper_half_plane.subgroup_to_sl_moeb UpperHalfPlane.subgroup_to_sl_moeb
+#align upper_half_plane.subgroup_to_sl_moeb UpperHalfPlane.ModularGroup.subgroup_to_sl_moeb
 
 @[simp high]
 theorem SL_neg_smul (g : SL(2, ℤ)) (z : ℍ) : -g • z = g • z := by
   simp only [coe_GLPos_neg, sl_moeb, coe_int_neg, neg_smul, coe']
-#align upper_half_plane.SL_neg_smul UpperHalfPlane.SL_neg_smul
+#align upper_half_plane.SL_neg_smul UpperHalfPlane.ModularGroup.SL_neg_smul
 
-theorem c_mul_im_sq_le_normSq_denom (z : ℍ) (g : SL(2, ℝ)) :
-    ((↑ₘg 1 0 : ℝ) * z.im) ^ 2 ≤ Complex.normSq (denom g z) := by
-  let c := (↑ₘg 1 0 : ℝ)
-  let d := (↑ₘg 1 1 : ℝ)
-  calc
-    (c * z.im) ^ 2 ≤ (c * z.im) ^ 2 + (c * z.re + d) ^ 2 := by nlinarith
-    _ = Complex.normSq (denom g z) := by dsimp [denom, Complex.normSq]; ring
-#align upper_half_plane.c_mul_im_sq_le_norm_sq_denom UpperHalfPlane.c_mul_im_sq_le_normSq_denom
-
-nonrec theorem SpecialLinearGroup.im_smul_eq_div_normSq :
+nonrec theorem im_smul_eq_div_normSq :
     (g • z).im = z.im / Complex.normSq (denom g z) := by
   convert im_smul_eq_div_normSq g z
   simp only [GeneralLinearGroup.val_det_apply, coe_GLPos_coe_GL_coe_matrix,
     Int.coe_castRingHom, (g : SL(2, ℝ)).prop, one_mul, coe']
-#align upper_half_plane.special_linear_group.im_smul_eq_div_norm_sq UpperHalfPlane.SpecialLinearGroup.im_smul_eq_div_normSq
+#align upper_half_plane.special_linear_group.im_smul_eq_div_norm_sq UpperHalfPlane.ModularGroup.im_smul_eq_div_normSq
 
 theorem denom_apply (g : SL(2, ℤ)) (z : ℍ) :
     denom g z = (↑g : Matrix (Fin 2) (Fin 2) ℤ) 1 0 * z + (↑g : Matrix (Fin 2) (Fin 2) ℤ) 1 1 := by
   simp [denom, coe']
-#align upper_half_plane.denom_apply UpperHalfPlane.denom_apply
+#align upper_half_plane.denom_apply UpperHalfPlane.ModularGroup.denom_apply
+
+end ModularGroup
 
 end SLModularAction
 
chore: remove Fintype.card_fin_even (#10273)

This instance was meant to apply to even literal numbers. Because Lean 4 no longer uses bit0/bit1 for literals, it no longer serves that purpose. Instead, a specific instance for Fin 2 is added.

Diff
@@ -32,8 +32,6 @@ open Matrix Matrix.SpecialLinearGroup
 
 open scoped Classical BigOperators MatrixGroups
 
-attribute [local instance] Fintype.card_fin_even
-
 /- Disable these instances as they are not the simp-normal form, and having them disabled ensures
 we state lemmas in this file without spurious `coe_fn` terms. -/
 attribute [-instance] Matrix.SpecialLinearGroup.instCoeFun
@@ -385,9 +383,6 @@ theorem im_smul_eq_div_normSq (g : GL(2, ℝ)⁺) (z : ℍ) :
   smulAux'_im g z
 #align upper_half_plane.im_smul_eq_div_norm_sq UpperHalfPlane.im_smul_eq_div_normSq
 
--- Porting note FIXME: this instance isn't being found, but is needed here.
-instance : Fact (Even (Fintype.card (Fin 2))) := ⟨Nat.even_iff.mpr rfl⟩
-
 @[simp]
 theorem neg_smul (g : GL(2, ℝ)⁺) (z : ℍ) : -g • z = g • z := by
   ext1
chore: cleanup TODOs around leanprover/lean4#3060 (#10198)

Mathlib is now using v4.6.0-rc1, which includes the fix in leanprover/lean4#3060

Diff
@@ -148,26 +148,20 @@ open Lean Meta Qq
 /-- Extension for the `positivity` tactic: `UpperHalfPlane.im`. -/
 @[positivity UpperHalfPlane.im _]
 def evalUpperHalfPlaneIm : PositivityExt where eval {u α} _zα _pα e := do
-  -- TODO: can't merge the `match`es without lean4#3060
-  match u with
-  | 0 => match α, e with
-    | ~q(ℝ), ~q(UpperHalfPlane.im $a) =>
-      assertInstancesCommute
-      pure (.positive q(@UpperHalfPlane.im_pos $a))
-    | _, _ => throwError "not UpperHalfPlane.im"
-  | _ => throwError "not UpperHalfPlane.im"
+  match u, α, e with
+  | 0, ~q(ℝ), ~q(UpperHalfPlane.im $a) =>
+    assertInstancesCommute
+    pure (.positive q(@UpperHalfPlane.im_pos $a))
+  | _, _, _ => throwError "not UpperHalfPlane.im"
 
 /-- Extension for the `positivity` tactic: `UpperHalfPlane.coe`. -/
 @[positivity UpperHalfPlane.coe _]
 def evalUpperHalfPlaneCoe : PositivityExt where eval {u α} _zα _pα e := do
-  -- TODO: can't merge the `match`es without lean4#3060
-  match u with
-  | 0 => match α, e with
-    | ~q(ℂ), ~q(UpperHalfPlane.coe $a) =>
-      assertInstancesCommute
-      pure (.nonzero q(@UpperHalfPlane.ne_zero $a))
-    | _, _ => throwError "not UpperHalfPlane.coe"
-  | _ => throwError "not UpperHalfPlane.coe"
+  match u, α, e with
+  | 0, ~q(ℂ), ~q(UpperHalfPlane.coe $a) =>
+    assertInstancesCommute
+    pure (.nonzero q(@UpperHalfPlane.ne_zero $a))
+  | _, _, _ => throwError "not UpperHalfPlane.coe"
 
 end Mathlib.Meta.Positivity
 
doc: @[inherit_doc] on notations (#9942)

Make all the notations that unambiguously should inherit the docstring of their definition actually inherit it.

Also write a few docstrings by hand. I only wrote the ones I was competent to write and which I was sure of. Some docstrings come from mathlib3 as they were lost during the early port.

This PR is only intended as a first pass There are many more docstrings to add.

Diff
@@ -50,7 +50,7 @@ def UpperHalfPlane :=
   { point : ℂ // 0 < point.im }
 #align upper_half_plane UpperHalfPlane
 
-scoped[UpperHalfPlane] notation "ℍ" => UpperHalfPlane
+@[inherit_doc] scoped[UpperHalfPlane] notation "ℍ" => UpperHalfPlane
 
 open UpperHalfPlane
 
feat(UpperHalfPlane): add positivity extensions (#9545)
Diff
@@ -139,6 +139,40 @@ theorem ne_zero (z : ℍ) : (z : ℂ) ≠ 0 :=
   mt (congr_arg Complex.im) z.im_ne_zero
 #align upper_half_plane.ne_zero UpperHalfPlane.ne_zero
 
+end UpperHalfPlane
+
+namespace Mathlib.Meta.Positivity
+
+open Lean Meta Qq
+
+/-- Extension for the `positivity` tactic: `UpperHalfPlane.im`. -/
+@[positivity UpperHalfPlane.im _]
+def evalUpperHalfPlaneIm : PositivityExt where eval {u α} _zα _pα e := do
+  -- TODO: can't merge the `match`es without lean4#3060
+  match u with
+  | 0 => match α, e with
+    | ~q(ℝ), ~q(UpperHalfPlane.im $a) =>
+      assertInstancesCommute
+      pure (.positive q(@UpperHalfPlane.im_pos $a))
+    | _, _ => throwError "not UpperHalfPlane.im"
+  | _ => throwError "not UpperHalfPlane.im"
+
+/-- Extension for the `positivity` tactic: `UpperHalfPlane.coe`. -/
+@[positivity UpperHalfPlane.coe _]
+def evalUpperHalfPlaneCoe : PositivityExt where eval {u α} _zα _pα e := do
+  -- TODO: can't merge the `match`es without lean4#3060
+  match u with
+  | 0 => match α, e with
+    | ~q(ℂ), ~q(UpperHalfPlane.coe $a) =>
+      assertInstancesCommute
+      pure (.nonzero q(@UpperHalfPlane.ne_zero $a))
+    | _, _ => throwError "not UpperHalfPlane.coe"
+  | _ => throwError "not UpperHalfPlane.coe"
+
+end Mathlib.Meta.Positivity
+
+namespace UpperHalfPlane
+
 theorem normSq_pos (z : ℍ) : 0 < Complex.normSq (z : ℂ) := by
   rw [Complex.normSq_pos]; exact z.ne_zero
 #align upper_half_plane.norm_sq_pos UpperHalfPlane.normSq_pos
chore: Replace (· op ·) a by (a op ·) (#8843)

I used the regex \(\(· (.) ·\) (.)\), replacing with ($2 $1 ·).

Diff
@@ -487,8 +487,7 @@ theorem modular_T_smul (z : ℍ) : ModularGroup.T • z = (1 : ℝ) +ᵥ z := by
 #align upper_half_plane.modular_T_smul UpperHalfPlane.modular_T_smul
 
 theorem exists_SL2_smul_eq_of_apply_zero_one_eq_zero (g : SL(2, ℝ)) (hc : ↑ₘ[ℝ] g 1 0 = 0) :
-    ∃ (u : { x : ℝ // 0 < x }) (v : ℝ),
-      ((· • ·) g : ℍ → ℍ) = (fun z => v +ᵥ z) ∘ fun z => u • z := by
+    ∃ (u : { x : ℝ // 0 < x }) (v : ℝ), (g • · : ℍ → ℍ) = (v +ᵥ ·) ∘ (u • ·) := by
   obtain ⟨a, b, ha, rfl⟩ := g.fin_two_exists_eq_mk_of_apply_zero_one_eq_zero hc
   refine' ⟨⟨_, mul_self_pos.mpr ha⟩, b * a, _⟩
   ext1 ⟨z, hz⟩; ext1
@@ -500,9 +499,8 @@ theorem exists_SL2_smul_eq_of_apply_zero_one_eq_zero (g : SL(2, ℝ)) (hc : ↑
 
 theorem exists_SL2_smul_eq_of_apply_zero_one_ne_zero (g : SL(2, ℝ)) (hc : ↑ₘ[ℝ] g 1 0 ≠ 0) :
     ∃ (u : { x : ℝ // 0 < x }) (v w : ℝ),
-      ((· • ·) g : ℍ → ℍ) =
-        ((· +ᵥ ·) w : ℍ → ℍ) ∘
-          ((· • ·) ModularGroup.S : ℍ → ℍ) ∘ ((· +ᵥ ·) v : ℍ → ℍ) ∘ ((· • ·) u : ℍ → ℍ) := by
+      (g • · : ℍ → ℍ) =
+        (w +ᵥ ·) ∘ (ModularGroup.S • · : ℍ → ℍ) ∘ (v +ᵥ · : ℍ → ℍ) ∘ (u • · : ℍ → ℍ) := by
   have h_denom := denom_ne_zero g
   induction' g using Matrix.SpecialLinearGroup.fin_two_induction with a b c d h
   replace hc : c ≠ 0; · simpa using hc
fix: simps config for Units (#6514)
Diff
@@ -180,7 +180,7 @@ theorem denom_ne_zero (g : GL(2, ℝ)⁺) (z : ℍ) : denom g z ≠ 0 := by
   intro H
   have DET := (mem_glpos _).1 g.prop
   have hz := z.prop
-  simp only [GeneralLinearGroup.det_apply_val] at DET
+  simp only [GeneralLinearGroup.val_det_apply] at DET
   have H1 : (↑ₘg 1 0 : ℝ) = 0 ∨ z.im = 0 := by simpa [num, denom] using congr_arg Complex.im H
   cases' H1 with H1
   · simp only [H1, Complex.ofReal_zero, denom, zero_mul, zero_add,
@@ -219,7 +219,7 @@ def smulAux (g : GL(2, ℝ)⁺) (z : ℍ) : ℍ :=
     rw [smulAux'_im]
     convert mul_pos ((mem_glpos _).1 g.prop)
         (div_pos z.im_pos (Complex.normSq_pos.mpr (denom_ne_zero g z))) using 1
-    simp only [GeneralLinearGroup.det_apply_val]
+    simp only [GeneralLinearGroup.val_det_apply]
     ring
 #align upper_half_plane.smul_aux UpperHalfPlane.smulAux
 
@@ -404,7 +404,7 @@ theorem c_mul_im_sq_le_normSq_denom (z : ℍ) (g : SL(2, ℝ)) :
 nonrec theorem SpecialLinearGroup.im_smul_eq_div_normSq :
     (g • z).im = z.im / Complex.normSq (denom g z) := by
   convert im_smul_eq_div_normSq g z
-  simp only [GeneralLinearGroup.det_apply_val, coe_GLPos_coe_GL_coe_matrix,
+  simp only [GeneralLinearGroup.val_det_apply, coe_GLPos_coe_GL_coe_matrix,
     Int.coe_castRingHom, (g : SL(2, ℝ)).prop, one_mul, coe']
 #align upper_half_plane.special_linear_group.im_smul_eq_div_norm_sq UpperHalfPlane.SpecialLinearGroup.im_smul_eq_div_normSq
 
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
@@ -168,9 +168,9 @@ theorem linear_ne_zero (cd : Fin 2 → ℝ) (z : ℍ) (h : cd ≠ 0) : (cd 0 : 
   have : cd 0 = 0 := by
     -- we will need this twice
     apply_fun Complex.im at h
-    simpa only [z.im_ne_zero, Complex.add_im, add_zero, coe_im, MulZeroClass.zero_mul, or_false_iff,
+    simpa only [z.im_ne_zero, Complex.add_im, add_zero, coe_im, zero_mul, or_false_iff,
       Complex.ofReal_im, Complex.zero_im, Complex.mul_im, mul_eq_zero] using h
-  simp only [this, MulZeroClass.zero_mul, Complex.ofReal_zero, zero_add, Complex.ofReal_eq_zero]
+  simp only [this, zero_mul, Complex.ofReal_zero, zero_add, Complex.ofReal_eq_zero]
     at h
   ext i
   fin_cases i <;> assumption
@@ -183,10 +183,10 @@ theorem denom_ne_zero (g : GL(2, ℝ)⁺) (z : ℍ) : denom g z ≠ 0 := by
   simp only [GeneralLinearGroup.det_apply_val] at DET
   have H1 : (↑ₘg 1 0 : ℝ) = 0 ∨ z.im = 0 := by simpa [num, denom] using congr_arg Complex.im H
   cases' H1 with H1
-  · simp only [H1, Complex.ofReal_zero, denom, MulZeroClass.zero_mul, zero_add,
+  · simp only [H1, Complex.ofReal_zero, denom, zero_mul, zero_add,
       Complex.ofReal_eq_zero] at H
     rw [Matrix.det_fin_two (↑ₘg : Matrix (Fin 2) (Fin 2) ℝ)] at DET
-    simp only [H, H1, MulZeroClass.mul_zero, sub_zero, lt_self_iff_false] at DET
+    simp only [H, H1, mul_zero, sub_zero, lt_self_iff_false] at DET
   · change z.im > 0 at hz
     linarith
 #align upper_half_plane.denom_ne_zero UpperHalfPlane.denom_ne_zero
@@ -479,7 +479,7 @@ theorem modular_T_zpow_smul (z : ℍ) (n : ℤ) : ModularGroup.T ^ n • z = (n
   -- Porting note: added `coeToGL` and merged `rw` and `simp`
   simp [coeToGL, ModularGroup.coe_T_zpow,
     of_apply, cons_val_zero, algebraMap.coe_one, Complex.ofReal_one, one_mul, cons_val_one,
-    head_cons, algebraMap.coe_zero, MulZeroClass.zero_mul, zero_add, div_one]
+    head_cons, algebraMap.coe_zero, zero_mul, zero_add, div_one]
 #align upper_half_plane.modular_T_zpow_smul UpperHalfPlane.modular_T_zpow_smul
 
 theorem modular_T_smul (z : ℍ) : ModularGroup.T • z = (1 : ℝ) +ᵥ z := by
refactor(Data/Matrix): Eliminate notation in favor of HMul (#6487)

The main difficulty here is that * has a slightly difference precedence to . notably around smul and neg.

The other annoyance is that ↑U ⬝ A ⬝ ↑U⁻¹ : Matrix m m 𝔸 now has to be written U.val * A * (U⁻¹).val in order to typecheck.

A downside of this change to consider: if you have a goal of A * (B * C) = (A * B) * C, mul_assoc now gives the illusion of matching, when in fact Matrix.mul_assoc is needed. Previously the distinct symbol made it easy to avoid this mistake.

On the flipside, there is now no need to rewrite by Matrix.mul_eq_mul all the time (indeed, the lemma is now removed).

Diff
@@ -227,7 +227,7 @@ theorem denom_cocycle (x y : GL(2, ℝ)⁺) (z : ℍ) :
     denom (x * y) z = denom x (smulAux y z) * denom y z := by
   change _ = (_ * (_ / _) + _) * _
   field_simp [denom_ne_zero]
-  simp only [Matrix.mul, dotProduct, Fin.sum_univ_succ, denom, num, Subgroup.coe_mul,
+  simp only [Matrix.mul_apply, dotProduct, Fin.sum_univ_succ, denom, num, Subgroup.coe_mul,
     GeneralLinearGroup.coe_mul, Fintype.univ_ofSubsingleton, Fin.mk_zero, Finset.sum_singleton,
     Fin.succ_zero_eq_one, Complex.ofReal_add, Complex.ofReal_mul]
   ring
@@ -239,7 +239,7 @@ theorem mul_smul' (x y : GL(2, ℝ)⁺) (z : ℍ) : smulAux (x * y) z = smulAux
   change _ / _ = (_ * (_ / _) + _) / _
   rw [denom_cocycle]
   field_simp [denom_ne_zero]
-  simp only [Matrix.mul, dotProduct, Fin.sum_univ_succ, num, denom, Subgroup.coe_mul,
+  simp only [Matrix.mul_apply, dotProduct, Fin.sum_univ_succ, num, denom, Subgroup.coe_mul,
     GeneralLinearGroup.coe_mul, Fintype.univ_ofSubsingleton, Fin.mk_zero, Finset.sum_singleton,
     Fin.succ_zero_eq_one, Complex.ofReal_add, Complex.ofReal_mul]
   ring
fix: disable autoImplicit globally (#6528)

Autoimplicits are highly controversial and also defeat the performance-improving work in #6474.

The intent of this PR is to make autoImplicit opt-in on a per-file basis, by disabling it in the lakefile and enabling it again with set_option autoImplicit true in the few files that rely on it.

That also keeps this PR small, as opposed to attempting to "fix" files to not need it any more.

I claim that many of the uses of autoImplicit in these files are accidental; situations such as:

  • Assuming variables are in scope, but pasting the lemma in the wrong section
  • Pasting in a lemma from a scratch file without checking to see if the variable names are consistent with the rest of the file
  • Making a copy-paste error between lemmas and forgetting to add an explicit arguments.

Having set_option autoImplicit false as the default prevents these types of mistake being made in the 90% of files where autoImplicits are not used at all, and causes them to be caught by CI during review.

I think there were various points during the port where we encouraged porters to delete the universes u v lines; I think having autoparams for universe variables only would cover a lot of the cases we actually use them, while avoiding any real shortcomings.

A Zulip poll (after combining overlapping votes accordingly) was in favor of this change with 5:5:18 as the no:dontcare:yes vote ratio.

While this PR was being reviewed, a handful of files gained some more likely-accidental autoImplicits. In these places, set_option autoImplicit true has been placed locally within a section, rather than at the top of the file.

Diff
@@ -268,10 +268,12 @@ def coe' : SL(2, ℤ) → GL(2, ℝ)⁺ := fun g => ((g : SL(2, ℝ)) : GL(2, 
 instance : Coe SL(2, ℤ) GL(2, ℝ)⁺ :=
   ⟨coe'⟩
 
+set_option autoImplicit true in
 @[simp]
 theorem coe'_apply_complex : (Units.val <| Subtype.val <| coe' g) i j = (Subtype.val g i j : ℂ) :=
   rfl
 
+set_option autoImplicit true in
 @[simp]
 theorem det_coe' : det (Units.val <| Subtype.val <| coe' g) = 1 := by
   simp only [SpecialLinearGroup.coe_GLPos_coe_GL_coe_matrix, SpecialLinearGroup.det_coe, coe']
fix: replace SMul.smul use in UpperHalfPlane (#6353)
Diff
@@ -262,16 +262,26 @@ instance SLAction {R : Type*} [CommRing R] [Algebra R ℝ] : MulAction SL(2, R)
   MulAction.compHom ℍ <| SpecialLinearGroup.toGLPos.comp <| map (algebraMap R ℝ)
 #align upper_half_plane.SL_action UpperHalfPlane.SLAction
 
+@[coe]
+def coe' : SL(2, ℤ) → GL(2, ℝ)⁺ := fun g => ((g : SL(2, ℝ)) : GL(2, ℝ)⁺)
+
 instance : Coe SL(2, ℤ) GL(2, ℝ)⁺ :=
-  ⟨fun g => ((g : SL(2, ℝ)) : GL(2, ℝ)⁺)⟩
+  ⟨coe'⟩
+
+@[simp]
+theorem coe'_apply_complex : (Units.val <| Subtype.val <| coe' g) i j = (Subtype.val g i j : ℂ) :=
+  rfl
+
+@[simp]
+theorem det_coe' : det (Units.val <| Subtype.val <| coe' g) = 1 := by
+  simp only [SpecialLinearGroup.coe_GLPos_coe_GL_coe_matrix, SpecialLinearGroup.det_coe, coe']
 
 instance SLOnGLPos : SMul SL(2, ℤ) GL(2, ℝ)⁺ :=
   ⟨fun s g => s * g⟩
 #align upper_half_plane.SL_on_GL_pos UpperHalfPlane.SLOnGLPos
 
--- Porting note: writing the `SMul.smul` explicitly is terrible. Needs a fix
 theorem SLOnGLPos_smul_apply (s : SL(2, ℤ)) (g : GL(2, ℝ)⁺) (z : ℍ) :
-    (s • g) • z = SMul.smul ((s : GL(2, ℝ)⁺) * g) z :=
+    (s • g) • z = ((s : GL(2, ℝ)⁺) * g) • z :=
   rfl
 #align upper_half_plane.SL_on_GL_pos_smul_apply UpperHalfPlane.SLOnGLPos_smul_apply
 
@@ -286,9 +296,8 @@ instance subgroupGLPos : SMul Γ GL(2, ℝ)⁺ :=
   ⟨fun s g => s * g⟩
 #align upper_half_plane.subgroup_GL_pos UpperHalfPlane.subgroupGLPos
 
--- Porting note: writing the `SMul.smul` explicitly is terrible. Needs a fix
 theorem subgroup_on_glpos_smul_apply (s : Γ) (g : GL(2, ℝ)⁺) (z : ℍ) :
-    (s • g) • z = SMul.smul ((s : GL(2, ℝ)⁺) * g) z :=
+    (s • g) • z = ((s : GL(2, ℝ)⁺) * g) • z :=
   rfl
 #align upper_half_plane.subgroup_on_GL_pos_smul_apply UpperHalfPlane.subgroup_on_glpos_smul_apply
 
@@ -362,14 +371,12 @@ section SLModularAction
 
 variable (g : SL(2, ℤ)) (z : ℍ) (Γ : Subgroup SL(2, ℤ))
 
--- Porting note: writing the `SMul.smul` explicitly is terrible. Needs a fix
 @[simp]
-theorem sl_moeb (A : SL(2, ℤ)) (z : ℍ) : A • z = SMul.smul (A : GL(2, ℝ)⁺) z :=
+theorem sl_moeb (A : SL(2, ℤ)) (z : ℍ) : A • z = (A : GL(2, ℝ)⁺) • z :=
   rfl
 #align upper_half_plane.sl_moeb UpperHalfPlane.sl_moeb
 
--- Porting note: writing the `SMul.smul` explicitly is terrible. Needs a fix
-theorem subgroup_moeb (A : Γ) (z : ℍ) : A • z = SMul.smul (A : GL(2, ℝ)⁺) z :=
+theorem subgroup_moeb (A : Γ) (z : ℍ) : A • z = (A : GL(2, ℝ)⁺) • z :=
   rfl
 #align upper_half_plane.subgroup_moeb UpperHalfPlane.subgroup_moeb
 
@@ -378,10 +385,9 @@ theorem subgroup_to_sl_moeb (A : Γ) (z : ℍ) : A • z = (A : SL(2, ℤ)) •
   rfl
 #align upper_half_plane.subgroup_to_sl_moeb UpperHalfPlane.subgroup_to_sl_moeb
 
--- @[simp] Failed simpNF linter, probably due to the `SMul.smul` hack
+@[simp high]
 theorem SL_neg_smul (g : SL(2, ℤ)) (z : ℍ) : -g • z = g • z := by
-  simp only [coe_GLPos_neg, sl_moeb, coe_int_neg, neg_smul]
-  apply neg_smul -- Porting note: should be unneeded once `SMul.smul` hack is fixed
+  simp only [coe_GLPos_neg, sl_moeb, coe_int_neg, neg_smul, coe']
 #align upper_half_plane.SL_neg_smul UpperHalfPlane.SL_neg_smul
 
 theorem c_mul_im_sq_le_normSq_denom (z : ℍ) (g : SL(2, ℝ)) :
@@ -397,12 +403,12 @@ nonrec theorem SpecialLinearGroup.im_smul_eq_div_normSq :
     (g • z).im = z.im / Complex.normSq (denom g z) := by
   convert im_smul_eq_div_normSq g z
   simp only [GeneralLinearGroup.det_apply_val, coe_GLPos_coe_GL_coe_matrix,
-    Int.coe_castRingHom, (g : SL(2, ℝ)).prop, one_mul]
+    Int.coe_castRingHom, (g : SL(2, ℝ)).prop, one_mul, coe']
 #align upper_half_plane.special_linear_group.im_smul_eq_div_norm_sq UpperHalfPlane.SpecialLinearGroup.im_smul_eq_div_normSq
 
 theorem denom_apply (g : SL(2, ℤ)) (z : ℍ) :
     denom g z = (↑g : Matrix (Fin 2) (Fin 2) ℤ) 1 0 * z + (↑g : Matrix (Fin 2) (Fin 2) ℤ) 1 1 := by
-  simp [denom]
+  simp [denom, coe']
 #align upper_half_plane.denom_apply UpperHalfPlane.denom_apply
 
 end SLModularAction
chore: tidy various files (#6393)
Diff
@@ -40,7 +40,6 @@ attribute [-instance] Matrix.SpecialLinearGroup.instCoeFun
 attribute [-instance] Matrix.GeneralLinearGroup.instCoeFun
 
 local notation "GL(" n ", " R ")" "⁺" => Matrix.GLPos (Fin n) R
--- TODO: these don't seem to work yet
 local notation:1024 "↑ₘ" A:1024 =>
   (((A : GL(2, ℝ)⁺) : GL (Fin 2) ℝ) : Matrix (Fin 2) (Fin 2) _)
 local notation:1024 "↑ₘ[" R "]" A:1024 =>
@@ -88,7 +87,7 @@ def re (z : ℍ) :=
 theorem ext' {a b : ℍ} (hre : a.re = b.re) (him : a.im = b.im) : a = b :=
   ext <| Complex.ext hre him
 
-/-- Constructor for `upper_half_plane`. It is useful if `⟨z, h⟩` makes Lean use a wrong
+/-- Constructor for `UpperHalfPlane`. It is useful if `⟨z, h⟩` makes Lean use a wrong
 typeclass instance. -/
 def mk (z : ℂ) (h : 0 < z.im) : ℍ :=
   ⟨z, h⟩
@@ -293,12 +292,12 @@ theorem subgroup_on_glpos_smul_apply (s : Γ) (g : GL(2, ℝ)⁺) (z : ℍ) :
   rfl
 #align upper_half_plane.subgroup_on_GL_pos_smul_apply UpperHalfPlane.subgroup_on_glpos_smul_apply
 
-instance subgroup_on_gLPos : IsScalarTower Γ GL(2, ℝ)⁺ ℍ where
+instance subgroup_on_glpos : IsScalarTower Γ GL(2, ℝ)⁺ ℍ where
   smul_assoc := by
     intro s g z
     simp only [subgroup_on_glpos_smul_apply]
     apply mul_smul'
-#align upper_half_plane.subgroup_on_GL_pos UpperHalfPlane.subgroup_on_gLPos
+#align upper_half_plane.subgroup_on_GL_pos UpperHalfPlane.subgroup_on_glpos
 
 instance subgroupSL : SMul Γ SL(2, ℤ) :=
   ⟨fun s g => s * g⟩
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
@@ -259,7 +259,7 @@ section ModularScalarTowers
 
 variable (Γ : Subgroup (SpecialLinearGroup (Fin 2) ℤ))
 
-instance SLAction {R : Type _} [CommRing R] [Algebra R ℝ] : MulAction SL(2, R) ℍ :=
+instance SLAction {R : Type*} [CommRing R] [Algebra R ℝ] : MulAction SL(2, R) ℍ :=
   MulAction.compHom ℍ <| SpecialLinearGroup.toGLPos.comp <| map (algebraMap R ℝ)
 #align upper_half_plane.SL_action UpperHalfPlane.SLAction
 
@@ -319,7 +319,7 @@ end ModularScalarTowers
 
 -- Porting note: in the statement, we used to have coercions `↑· : ℝ`
 -- rather than `algebraMap R ℝ ·`.
-theorem specialLinearGroup_apply {R : Type _} [CommRing R] [Algebra R ℝ] (g : SL(2, R)) (z : ℍ) :
+theorem specialLinearGroup_apply {R : Type*} [CommRing R] [Algebra R ℝ] (g : SL(2, R)) (z : ℍ) :
     g • z =
       mk
         (((algebraMap R ℝ (↑ₘ[R] g 0 0) : ℂ) * z + (algebraMap R ℝ (↑ₘ[R] g 0 1) : ℂ)) /
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
@@ -2,11 +2,6 @@
 Copyright (c) 2021 Alex Kontorovich and Heather Macbeth and Marc Masdeu. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alex Kontorovich, Heather Macbeth, Marc Masdeu
-
-! This file was ported from Lean 3 source module analysis.complex.upper_half_plane.basic
-! leanprover-community/mathlib commit 34d3797325d202bd7250431275bb871133cdb611
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Data.Fintype.Parity
 import Mathlib.LinearAlgebra.Matrix.SpecialLinearGroup
@@ -15,6 +10,8 @@ import Mathlib.GroupTheory.GroupAction.Defs
 import Mathlib.LinearAlgebra.Matrix.GeneralLinearGroup
 import Mathlib.Tactic.LinearCombination
 
+#align_import analysis.complex.upper_half_plane.basic from "leanprover-community/mathlib"@"34d3797325d202bd7250431275bb871133cdb611"
+
 /-!
 # The upper half plane and its automorphisms
 
chore: fix grammar in docs (#5668)
Diff
@@ -20,7 +20,7 @@ import Mathlib.Tactic.LinearCombination
 
 This file defines `UpperHalfPlane` to be the upper half plane in `ℂ`.
 
-We furthermore equip it with the structure of an `GLPos 2 ℝ` action by
+We furthermore equip it with the structure of a `GLPos 2 ℝ` action by
 fractional linear transformations.
 
 We define the notation `ℍ` for the upper half plane available in the locale
feat: port Analysis.Complex.UpperHalfPlane.Manifold (#5658)

Also define UpperHalfPlane.coe so that type synonym doesn't leak through API.

Diff
@@ -58,17 +58,21 @@ scoped[UpperHalfPlane] notation "ℍ" => UpperHalfPlane
 
 open UpperHalfPlane
 
--- Porting note: added to replace `deriving`
-instance : CoeOut ℍ ℂ := inferInstanceAs (CoeOut { point : ℂ // 0 < point.im } ℂ)
-
 namespace UpperHalfPlane
 
-@[ext]
-theorem ext {a b : ℍ} (h : (a : ℂ) = b) : a = b := Subtype.ext h
+/-- Canonical embedding of the upper half-plane into `ℂ`. -/
+@[coe] protected def coe (z : ℍ) : ℂ := z.1
+
+-- Porting note: added to replace `deriving`
+instance : CoeOut ℍ ℂ := ⟨UpperHalfPlane.coe⟩
 
 instance : Inhabited ℍ :=
   ⟨⟨Complex.I, by simp⟩⟩
 
+@[ext] theorem ext {a b : ℍ} (h : (a : ℂ) = b) : a = b := Subtype.eq h
+
+@[simp, norm_cast] theorem ext_iff {a b : ℍ} : (a : ℂ) = b ↔ a = b := Subtype.coe_inj
+
 instance canLift : CanLift ℂ ℍ ((↑) : ℍ → ℂ) fun z => 0 < z.im :=
   Subtype.canLift fun (z : ℂ) => 0 < z.im
 #align upper_half_plane.can_lift UpperHalfPlane.canLift
@@ -83,6 +87,10 @@ def re (z : ℍ) :=
   (z : ℂ).re
 #align upper_half_plane.re UpperHalfPlane.re
 
+/-- Extensionality lemma in terms of `UpperHalfPlane.re` and `UpperHalfPlane.im`. -/
+theorem ext' {a b : ℍ} (hre : a.re = b.re) (him : a.im = b.im) : a = b :=
+  ext <| Complex.ext hre him
+
 /-- Constructor for `upper_half_plane`. It is useful if `⟨z, h⟩` makes Lean use a wrong
 typeclass instance. -/
 def mk (z : ℂ) (h : 0 < z.im) : ℍ :=
@@ -116,7 +124,7 @@ theorem coe_mk (z : ℂ) (h : 0 < z.im) : (mk z h : ℂ) = z :=
 
 @[simp]
 theorem mk_coe (z : ℍ) (h : 0 < (z : ℂ).im := z.2) : mk z h = z :=
-  Subtype.eta z h
+  rfl
 #align upper_half_plane.mk_coe UpperHalfPlane.mk_coe
 
 theorem re_add_im (z : ℍ) : (z.re + z.im * Complex.I : ℂ) = z :=
@@ -211,12 +219,12 @@ theorem smulAux'_im (g : GL(2, ℝ)⁺) (z : ℍ) :
 
 /-- Fractional linear transformation, also known as the Moebius transformation -/
 def smulAux (g : GL(2, ℝ)⁺) (z : ℍ) : ℍ :=
-  ⟨smulAux' g z, by
+  mk (smulAux' g z) <| by
     rw [smulAux'_im]
     convert mul_pos ((mem_glpos _).1 g.prop)
         (div_pos z.im_pos (Complex.normSq_pos.mpr (denom_ne_zero g z))) using 1
     simp only [GeneralLinearGroup.det_apply_val]
-    ring⟩
+    ring
 #align upper_half_plane.smul_aux UpperHalfPlane.smulAux
 
 theorem denom_cocycle (x y : GL(2, ℝ)⁺) (z : ℍ) :
@@ -389,8 +397,7 @@ theorem c_mul_im_sq_le_normSq_denom (z : ℍ) (g : SL(2, ℝ)) :
     _ = Complex.normSq (denom g z) := by dsimp [denom, Complex.normSq]; ring
 #align upper_half_plane.c_mul_im_sq_le_norm_sq_denom UpperHalfPlane.c_mul_im_sq_le_normSq_denom
 
-nonrec
-theorem SpecialLinearGroup.im_smul_eq_div_normSq :
+nonrec theorem SpecialLinearGroup.im_smul_eq_div_normSq :
     (g • z).im = z.im / Complex.normSq (denom g z) := by
   convert im_smul_eq_div_normSq g z
   simp only [GeneralLinearGroup.det_apply_val, coe_GLPos_coe_GL_coe_matrix,
@@ -464,7 +471,7 @@ theorem modular_S_smul (z : ℍ) : ModularGroup.S • z = mk (-z : ℂ)⁻¹ z.i
 #align upper_half_plane.modular_S_smul UpperHalfPlane.modular_S_smul
 
 theorem modular_T_zpow_smul (z : ℍ) (n : ℤ) : ModularGroup.T ^ n • z = (n : ℝ) +ᵥ z := by
-  rw [← Subtype.coe_inj, coe_vadd, add_comm, specialLinearGroup_apply, coe_mk]
+  rw [← ext_iff, coe_vadd, add_comm, specialLinearGroup_apply, coe_mk]
   -- Porting note: added `coeToGL` and merged `rw` and `simp`
   simp [coeToGL, ModularGroup.coe_T_zpow,
     of_apply, cons_val_zero, algebraMap.coe_one, Complex.ofReal_one, one_mul, cons_val_one,
feat: port Analysis.Complex.UpperHalfPlane.Basic (#4335)

Co-authored-by: Jireh Loreaux <loreaujy@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Johan Commelin <johan@commelin.net>

Dependencies 12 + 775

776 files ported (98.5%)
341001 lines ported (98.4%)
Show graph

The unported dependencies are

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