Skip to content

Commit 18978c9

Browse files
committed
chore(UnitDisc): review API (leanprover-community#33639)
- Define a `Star` instance instead of `UnitDisc.conj`. - Move the notation from the `_root_.UnitDisc` scope to `Complex.UnitDisc`. - Define `casesOn`. - Add `inst` to instance names. Cherry-picked from leanprover-community#33368
1 parent a3dd48d commit 18978c9

1 file changed

Lines changed: 77 additions & 39 deletions

File tree

β€ŽMathlib/Analysis/Complex/UnitDisc/Basic.leanβ€Ž

Lines changed: 77 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,17 @@ introduce some basic operations on this disc.
1919
@[expose] public section
2020

2121
open Set Function Metric Filter
22-
open scoped Topology
22+
open scoped ComplexConjugate Topology
2323

2424
noncomputable section
2525

26-
local notation "conj'" => starRingEnd β„‚
27-
2826
namespace Complex
2927

3028
/-- The complex unit disc, denoted as `𝔻` withinin the Complex namespace -/
3129
def UnitDisc : Type :=
3230
ball (0 : β„‚) 1 deriving TopologicalSpace
3331

34-
@[inherit_doc] scoped[UnitDisc] notation "𝔻" => Complex.UnitDisc
32+
@[inherit_doc] scoped[Complex.UnitDisc] notation "𝔻" => Complex.UnitDisc
3533
open UnitDisc
3634

3735
namespace UnitDisc
@@ -45,6 +43,7 @@ instance instIsCancelMulZero : IsCancelMulZero UnitDisc := by unfold UnitDisc; i
4543
instance instHasDistribNeg : HasDistribNeg UnitDisc := by unfold UnitDisc; infer_instance
4644
instance instCoe : Coe UnitDisc β„‚ := ⟨UnitDisc.coe⟩
4745

46+
@[ext]
4847
theorem coe_injective : Injective ((↑) : 𝔻 β†’ β„‚) :=
4948
Subtype.coe_injective
5049

@@ -63,9 +62,13 @@ theorem norm_lt_one (z : 𝔻) : β€–(z : β„‚)β€– < 1 :=
6362
theorem norm_ne_one (z : 𝔻) : β€–(z : β„‚)β€– β‰  1 :=
6463
z.norm_lt_one.ne
6564

65+
theorem sq_norm_lt_one (z : 𝔻) : β€–(z : β„‚)β€– ^ 2 < 1 := by
66+
rw [sq_lt_one_iff_abs_lt_one, abs_norm]
67+
exact z.norm_lt_one
68+
6669
theorem normSq_lt_one (z : 𝔻) : normSq z < 1 := by
67-
convert (Real.sqrt_lt' one_pos).1 z.norm_lt_one
68-
exact (one_pow 2).symm
70+
rw [← Complex.norm_mul_self_eq_normSq, ← sq]
71+
exact z.sq_norm_lt_one
6972

7073
theorem coe_ne_one (z : 𝔻) : (z : β„‚) β‰  1 :=
7174
ne_of_apply_ne (β€–Β·β€–) <| by simp [z.norm_ne_one]
@@ -80,11 +83,25 @@ theorem one_add_coe_ne_zero (z : 𝔻) : (1 + z : β„‚) β‰  0 :=
8083
theorem coe_mul (z w : 𝔻) : ↑(z * w) = (z * w : β„‚) :=
8184
rfl
8285

86+
@[simp, norm_cast]
87+
theorem coe_neg (z : 𝔻) : ↑(-z) = (-z : β„‚) := rfl
88+
8389
/-- A constructor that assumes `β€–zβ€– < 1` instead of `dist z 0 < 1` and returns an element
8490
of `𝔻` instead of `β†₯Metric.ball (0 : β„‚) 1`. -/
8591
def mk (z : β„‚) (hz : β€–zβ€– < 1) : 𝔻 :=
8692
⟨z, mem_ball_zero_iff.2 hz⟩
8793

94+
/-- A cases eliminator that makes `cases z` use `UnitDisc.mk` instead of `Subtype.mk`. -/
95+
@[elab_as_elim, cases_eliminator]
96+
protected def casesOn {motive : 𝔻 β†’ Sort*} (mk : βˆ€ z hz, motive (.mk z hz)) (z : 𝔻) :
97+
motive z :=
98+
mk z z.norm_lt_one
99+
100+
@[simp]
101+
theorem casesOn_mk {motive : 𝔻 β†’ Sort*} (mk' : βˆ€ z hz, motive (.mk z hz)) {z : β„‚} (hz : β€–zβ€– < 1) :
102+
(mk z hz).casesOn mk' = mk' z hz :=
103+
rfl
104+
88105
@[simp]
89106
theorem coe_mk (z : β„‚) (hz : β€–zβ€– < 1) : (mk z hz : β„‚) = z :=
90107
rfl
@@ -111,39 +128,42 @@ theorem coe_eq_zero {z : 𝔻} : (z : β„‚) = 0 ↔ z = 0 :=
111128
instance : Inhabited 𝔻 :=
112129
⟨0⟩
113130

114-
instance circleAction : MulAction Circle 𝔻 :=
131+
instance instMulActionCircle : MulAction Circle 𝔻 :=
115132
mulActionSphereBall
116133

117-
instance isScalarTower_circle_circle : IsScalarTower Circle Circle 𝔻 :=
134+
instance instIsScalarTower_circle_circle : IsScalarTower Circle Circle 𝔻 :=
118135
isScalarTower_sphere_sphere_ball
119136

120-
instance isScalarTower_circle : IsScalarTower Circle 𝔻 𝔻 :=
137+
instance instIsScalarTower_circle : IsScalarTower Circle 𝔻 𝔻 :=
121138
isScalarTower_sphere_ball_ball
122139

123-
instance instSMulCommClass_circle : SMulCommClass Circle 𝔻 𝔻 :=
140+
instance instSMulCommClass_circle_left : SMulCommClass Circle 𝔻 𝔻 :=
124141
instSMulCommClass_sphere_ball_ball
125142

126-
instance instSMulCommClass_circle' : SMulCommClass 𝔻 Circle 𝔻 :=
143+
instance instSMulCommClass_circle_right : SMulCommClass 𝔻 Circle 𝔻 :=
127144
SMulCommClass.symm _ _ _
128145

129146
@[simp, norm_cast]
130-
theorem coe_smul_circle (z : Circle) (w : 𝔻) : ↑(z β€’ w) = (z * w : β„‚) :=
147+
theorem coe_circle_smul (z : Circle) (w : 𝔻) : ↑(z β€’ w) = (z * w : β„‚) :=
131148
rfl
132149

133-
instance closedBallAction : MulAction (closedBall (0 : β„‚) 1) 𝔻 :=
150+
@[deprecated (since := "2026-01-06")]
151+
alias coe_smul_circle := coe_circle_smul
152+
153+
instance instMulActionClosedBall : MulAction (closedBall (0 : β„‚) 1) 𝔻 :=
134154
mulActionClosedBallBall
135155

136-
instance isScalarTower_closedBall_closedBall :
156+
instance instIsScalarTower_closedBall_closedBall :
137157
IsScalarTower (closedBall (0 : β„‚) 1) (closedBall (0 : β„‚) 1) 𝔻 :=
138158
isScalarTower_closedBall_closedBall_ball
139159

140-
instance isScalarTower_closedBall : IsScalarTower (closedBall (0 : β„‚) 1) 𝔻 𝔻 :=
160+
instance instIsScalarTower_closedBall : IsScalarTower (closedBall (0 : β„‚) 1) 𝔻 𝔻 :=
141161
isScalarTower_closedBall_ball_ball
142162

143-
instance instSMulCommClass_closedBall : SMulCommClass (closedBall (0 : β„‚) 1) 𝔻 𝔻 :=
163+
instance instSMulCommClass_closedBall_left : SMulCommClass (closedBall (0 : β„‚) 1) 𝔻 𝔻 :=
144164
⟨fun _ _ _ => Subtype.ext <| mul_left_comm _ _ _⟩
145165

146-
instance instSMulCommClass_closedBall' : SMulCommClass 𝔻 (closedBall (0 : β„‚) 1) 𝔻 :=
166+
instance instSMulCommClass_closedBall_right : SMulCommClass 𝔻 (closedBall (0 : β„‚) 1) 𝔻 :=
147167
SMulCommClass.symm _ _ _
148168

149169
instance instSMulCommClass_circle_closedBall : SMulCommClass Circle (closedBall (0 : β„‚) 1) 𝔻 :=
@@ -153,9 +173,12 @@ instance instSMulCommClass_closedBall_circle : SMulCommClass (closedBall (0 :
153173
SMulCommClass.symm _ _ _
154174

155175
@[simp, norm_cast]
156-
theorem coe_smul_closedBall (z : closedBall (0 : β„‚) 1) (w : 𝔻) : ↑(z β€’ w) = (z * w : β„‚) :=
176+
theorem coe_closedBall_smul (z : closedBall (0 : β„‚) 1) (w : 𝔻) : ↑(z β€’ w) = (z * w : β„‚) :=
157177
rfl
158178

179+
@[deprecated (since := "2026-01-06")]
180+
alias coe_smul_closedBall := coe_closedBall_smul
181+
159182
instance : Pow UnitDisc β„•+ where
160183
pow z n := ⟨z ^ (n : β„•), by simp [pow_lt_one_iff_of_nonneg, z.norm_lt_one]⟩
161184

@@ -207,36 +230,51 @@ theorem im_neg (z : 𝔻) : (-z).im = -z.im :=
207230
rfl
208231

209232
/-- Conjugate point of the unit disc. -/
210-
def conj (z : 𝔻) : 𝔻 :=
211-
mk (conj' ↑z) <| (norm_conj z).symm β–Έ z.norm_lt_one
233+
instance : Star 𝔻 where
234+
star z := mk (conj z) <| (norm_conj z).symm β–Έ z.norm_lt_one
212235

213-
@[simp]
214-
theorem coe_conj (z : 𝔻) : (z.conj : β„‚) = conj' ↑z :=
215-
rfl
236+
/-- Conjugate point of the unit disc. Deprecated, use `star` instead. -/
237+
@[deprecated star (since := "2026-01-06")]
238+
protected def Β«conjΒ» (z : 𝔻) := star z
216239

217-
@[simp]
218-
theorem conj_zero : conj 0 = 0 :=
219-
coe_injective (map_zero conj')
240+
@[simp] theorem coe_star (z : 𝔻) : (↑(star z) : β„‚) = conj ↑z := rfl
220241

221-
@[simp]
222-
theorem conj_conj (z : 𝔻) : conj (conj z) = z :=
223-
coe_injective <| Complex.conj_conj (z : β„‚)
242+
@[deprecated (since := "2026-01-06")]
243+
alias coe_conj := coe_star
224244

225245
@[simp]
226-
theorem conj_neg (z : 𝔻) : (-z).conj = -z.conj :=
227-
rfl
246+
protected theorem star_eq_zero {z : 𝔻} : star z = 0 ↔ z = 0 := by
247+
simp [← coe_eq_zero]
228248

229249
@[simp]
230-
theorem re_conj (z : 𝔻) : z.conj.re = z.re :=
231-
rfl
250+
protected theorem star_zero : star (0 : 𝔻) = 0 := by simp
232251

233-
@[simp]
234-
theorem im_conj (z : 𝔻) : z.conj.im = -z.im :=
235-
rfl
252+
instance : InvolutiveStar 𝔻 where
253+
star_involutive z := by ext; simp
236254

237-
@[simp]
238-
theorem conj_mul (z w : 𝔻) : (z * w).conj = z.conj * w.conj :=
239-
Subtype.ext <| map_mul _ _ _
255+
@[deprecated star_star (since := "2026-01-06")]
256+
theorem conj_conj (z : 𝔻) : star (star z) = z := star_star z
257+
258+
@[simp] protected theorem star_neg (z : 𝔻) : star (-z) = -(star z) := rfl
259+
260+
@[deprecated (since := "2026-01-06")]
261+
alias conj_neg := UnitDisc.star_neg
262+
263+
@[simp] protected theorem re_star (z : 𝔻) : (star z).re = z.re := rfl
264+
265+
@[deprecated (since := "2026-01-06")]
266+
alias re_conj := UnitDisc.re_star
267+
268+
@[simp] protected theorem im_star (z : 𝔻) : (star z).im = -z.im := rfl
269+
270+
@[deprecated (since := "2026-01-06")] alias im_conj := UnitDisc.im_star
271+
272+
instance : StarMul 𝔻 where
273+
star_mul z w := coe_injective <| by simp [mul_comm]
274+
275+
@[deprecated star_mul' (since := "2026-01-06")]
276+
theorem conj_mul (z w : 𝔻) : star (z * w) = star z * star w :=
277+
star_mul' z w
240278

241279
end UnitDisc
242280

0 commit comments

Comments
Β (0)