Skip to content

Commit f52e271

Browse files
committed
chore: ofNat lemmas for Complex.normSq and abs (#7975)
Having `_ofNat` lemmas is important for confluence given that for both `normSq` and `abs`, the `_ofReal` lemma is `@[simp]` and so is `ofReal_ofNat`. We already have lemmas for 0 and 1 from the bundled classes for both functions, so I'm only adding lemmas for the `AtLeastTwo` case here.
1 parent 8903aac commit f52e271

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

Mathlib/Analysis/Complex/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ theorem norm_rat (r : ℚ) : ‖(r : ℂ)‖ = |(r : ℝ)| := by
158158

159159
@[simp 1100]
160160
theorem norm_nat (n : ℕ) : ‖(n : ℂ)‖ = n :=
161-
abs_of_nat _
161+
abs_natCast _
162162
#align complex.norm_nat Complex.norm_nat
163163

164164
@[simp 1100]

Mathlib/Data/Complex/Basic.lean

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,11 @@ theorem normSq_one : normSq 1 = 1 :=
638638
normSq.map_one
639639
#align complex.norm_sq_one Complex.normSq_one
640640

641+
@[simp]
642+
theorem normSq_ofNat (n : ℕ) [n.AtLeastTwo] :
643+
normSq (no_index (OfNat.ofNat n : ℂ)) = OfNat.ofNat n * OfNat.ofNat n := by
644+
simp [normSq]
645+
641646
@[simp]
642647
theorem normSq_I : normSq I = 1 := by simp [normSq]
643648
set_option linter.uppercaseLean3 false in
@@ -990,11 +995,13 @@ nonrec theorem abs_of_nonneg {r : ℝ} (h : 0 ≤ r) : Complex.abs r = r :=
990995
(Complex.abs_ofReal _).trans (abs_of_nonneg h)
991996
#align complex.abs_of_nonneg Complex.abs_of_nonneg
992997

993-
theorem abs_of_nat (n : ℕ) : Complex.abs n = n :=
994-
calc
995-
Complex.abs n = Complex.abs (n : ℝ) := by rw [ofReal_nat_cast]
996-
_ = _ := Complex.abs_of_nonneg (Nat.cast_nonneg n)
997-
#align complex.abs_of_nat Complex.abs_of_nat
998+
theorem abs_natCast (n : ℕ) : Complex.abs n = n := Complex.abs_of_nonneg (Nat.cast_nonneg n)
999+
#align complex.abs_of_nat Complex.abs_natCast
1000+
1001+
@[simp]
1002+
theorem abs_ofNat (n : ℕ) [n.AtLeastTwo] :
1003+
Complex.abs (no_index (OfNat.ofNat n : ℂ)) = OfNat.ofNat n :=
1004+
abs_natCast n
9981005

9991006
theorem mul_self_abs (z : ℂ) : Complex.abs z * Complex.abs z = normSq z :=
10001007
Real.mul_self_sqrt (normSq_nonneg _)
@@ -1019,11 +1026,7 @@ theorem abs_I : Complex.abs I = 1 := by simp [Complex.abs]
10191026
set_option linter.uppercaseLean3 false in
10201027
#align complex.abs_I Complex.abs_I
10211028

1022-
@[simp]
1023-
theorem abs_two : Complex.abs 2 = 2 :=
1024-
calc
1025-
Complex.abs 2 = Complex.abs (2 : ℝ) := rfl
1026-
_ = (2 : ℝ) := Complex.abs_of_nonneg (by norm_num)
1029+
theorem abs_two : Complex.abs 2 = 2 := abs_ofNat 2
10271030
#align complex.abs_two Complex.abs_two
10281031

10291032
@[simp]

Mathlib/NumberTheory/LSeries.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ theorem zeta_LSeriesSummable_iff_one_lt_re {z : ℂ} : LSeriesSummable ζ z ↔
117117
· simp [h0]
118118
simp only [cast_zero, natCoe_apply, zeta_apply, succ_ne_zero, if_false, cast_succ, one_div,
119119
Complex.norm_eq_abs, map_inv₀, Complex.abs_cpow_real, inv_inj, zero_add]
120-
rw [← cast_one, ← cast_add, Complex.abs_of_nat, cast_add, cast_one]
120+
rw [← cast_one, ← cast_add, Complex.abs_natCast, cast_add, cast_one]
121121
#align nat.arithmetic_function.zeta_l_series_summable_iff_one_lt_re Nat.ArithmeticFunction.zeta_LSeriesSummable_iff_one_lt_re
122122

123123
@[simp]

0 commit comments

Comments
 (0)