Skip to content

Commit e731cb8

Browse files
committed
chore: deprecate Nat.cast_eq_ofNat (#20168)
This lemma is malformed; the `n` on the RHS must be a raw literal, but the one on the left is not. Correcting the statement results in `Nat.cast_ofNat` which already exists.
1 parent 112e2af commit e731cb8

File tree

7 files changed

+12
-10
lines changed

7 files changed

+12
-10
lines changed

Mathlib/Algebra/Polynomial/Basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,8 @@ theorem coeff_ofNat_zero (a : ℕ) [a.AtLeastTwo] :
678678
@[simp]
679679
theorem coeff_ofNat_succ (a n : ℕ) [h : a.AtLeastTwo] :
680680
coeff (no_index (OfNat.ofNat a : R[X])) (n + 1) = 0 := by
681-
rw [← Nat.cast_eq_ofNat]
682-
simp
681+
rw [← Nat.cast_ofNat]
682+
simp [-Nat.cast_ofNat]
683683

684684
theorem C_mul_X_pow_eq_monomial : ∀ {n : ℕ}, C a * X ^ n = monomial n a
685685
| 0 => mul_one _

Mathlib/Algebra/Ring/Subsemiring/Defs.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ theorem natCast_mem [AddSubmonoidWithOneClass S R] (n : ℕ) : (n : R) ∈ s :=
3333
@[aesop safe apply (rule_sets := [SetLike])]
3434
lemma ofNat_mem [AddSubmonoidWithOneClass S R] (s : S) (n : ℕ) [n.AtLeastTwo] :
3535
no_index (OfNat.ofNat n) ∈ s := by
36-
rw [← Nat.cast_eq_ofNat]; exact natCast_mem s n
36+
rw [← Nat.cast_ofNat]; exact natCast_mem s n
3737

3838
instance (priority := 74) AddSubmonoidWithOneClass.toAddMonoidWithOne
3939
[AddSubmonoidWithOneClass S R] : AddMonoidWithOne s :=

Mathlib/Analysis/SpecialFunctions/Trigonometric/EulerSineProd.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ theorem sin_pi_mul_eq (z : ℂ) (n : ℕ) :
219219
dsimp only [C]
220220
rw [integral_cos_pow_eq, aux', integral_sin_pow, sin_zero, sin_pi, pow_succ',
221221
zero_mul, zero_mul, zero_mul, sub_zero, zero_div,
222-
zero_add, ← mul_assoc, ← mul_assoc, mul_comm (1 / 2 : ℝ) _, Nat.cast_mul, Nat.cast_eq_ofNat]
222+
zero_add, ← mul_assoc, ← mul_assoc, mul_comm (1 / 2 : ℝ) _, Nat.cast_mul, Nat.cast_ofNat]
223223
rw [this]
224224
change
225225
π * z * A * B / C =

Mathlib/Data/Nat/Cast/Defs.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Some discussion is [on Zulip here](https://leanprover.zulipchat.com/#narrow/stre
6868
@[simp, norm_cast] theorem Nat.cast_ofNat {n : ℕ} [NatCast R] [Nat.AtLeastTwo n] :
6969
(Nat.cast (no_index (OfNat.ofNat n)) : R) = OfNat.ofNat n := rfl
7070

71+
@[deprecated Nat.cast_ofNat (since := "2024-12-22")]
7172
theorem Nat.cast_eq_ofNat {n : ℕ} [NatCast R] [Nat.AtLeastTwo n] :
7273
(Nat.cast n : R) = OfNat.ofNat n :=
7374
rfl

Mathlib/FieldTheory/CardinalEmb.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ instance (i : ι) : Algebra.IsSeparable (E⟮<i⟯) (E⟮<i⟯⟮b (φ i)⟯) :=
210210

211211
open Field in
212212
theorem two_le_deg (i : ι) : 2 ≤ #(X i) := by
213-
rw [← Nat.cast_eq_ofNat, ← toNat_le_iff_le_of_lt_aleph0 (nat_lt_aleph0 _) (deg_lt_aleph0 i),
213+
rw [← Nat.cast_ofNat, ← toNat_le_iff_le_of_lt_aleph0 (nat_lt_aleph0 _) (deg_lt_aleph0 i),
214214
toNat_natCast, ← Nat.card, ← finSepDegree, finSepDegree_eq_finrank_of_isSeparable, Nat.succ_le]
215215
by_contra!
216216
obtain ⟨x, hx⟩ := finrank_adjoin_simple_eq_one_iff.mp (this.antisymm Module.finrank_pos)

Mathlib/LinearAlgebra/Reflection.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ lemma reflection_reflection_iterate
385385
| succ n ih =>
386386
have hz : ∀ z : M, f y • g x • z = 22 • z := by
387387
intro z
388-
rw [smul_smul, hgxfy, smul_smul, ← Nat.cast_smul_eq_nsmul R (2 * 2), Nat.cast_eq_ofNat]
388+
rw [smul_smul, hgxfy, smul_smul, ← Nat.cast_smul_eq_nsmul R (2 * 2), show 2 * 2 = 4 from rfl,
389+
Nat.cast_ofNat]
389390
simp only [iterate_succ', comp_apply, ih, two_smul, smul_sub, smul_add, map_add,
390391
LinearEquiv.trans_apply, reflection_apply_self, map_neg, reflection_apply, neg_sub, map_sub,
391392
map_nsmul, map_smul, smul_neg, hz, add_smul]

Mathlib/Tactic/NoncommRing.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ namespace Mathlib.Tactic.NoncommRing
2323
section nat_lit_mul
2424
variable {R : Type*} [NonAssocSemiring R] (r : R) (n : ℕ)
2525

26-
lemma nat_lit_mul_eq_nsmul [n.AtLeastTwo] : no_index (OfNat.ofNat n) * r = n • r := by
27-
simp only [nsmul_eq_mul, Nat.cast_eq_ofNat]
28-
lemma mul_nat_lit_eq_nsmul [n.AtLeastTwo] : r * no_index (OfNat.ofNat n) = n • r := by
29-
simp only [nsmul_eq_mul', Nat.cast_eq_ofNat]
26+
lemma nat_lit_mul_eq_nsmul [n.AtLeastTwo] : no_index (OfNat.ofNat n) * r = OfNat.ofNat n • r := by
27+
simp only [nsmul_eq_mul, Nat.cast_ofNat]
28+
lemma mul_nat_lit_eq_nsmul [n.AtLeastTwo] : r * no_index (OfNat.ofNat n) = OfNat.ofNat n • r := by
29+
simp only [nsmul_eq_mul', Nat.cast_ofNat]
3030

3131
end nat_lit_mul
3232

0 commit comments

Comments
 (0)