Skip to content

Commit 6513764

Browse files
eric-wiesertimotree3
authored andcommitted
fix: add missing no_index around OfNat.ofNat (#8317)
Co-authored-by: timotree3 <[email protected]> Co-authored-by: timotree3 <[email protected]>
1 parent d8402ff commit 6513764

File tree

6 files changed

+63
-25
lines changed

6 files changed

+63
-25
lines changed

Mathlib/Algebra/Order/Floor.lean

+47-19
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,9 @@ theorem floor_add_one (ha : 0 ≤ a) : ⌊a + 1⌋₊ = ⌊a⌋₊ + 1 := by
456456
rw [← cast_one, floor_add_nat ha 1]
457457
#align nat.floor_add_one Nat.floor_add_one
458458

459+
-- See note [no_index around OfNat.ofNat]
459460
theorem floor_add_ofNat (ha : 0 ≤ a) (n : ℕ) [n.AtLeastTwo] :
460-
⌊a + OfNat.ofNat n⌋₊ = ⌊a⌋₊ + OfNat.ofNat n :=
461+
⌊a + (no_index (OfNat.ofNat n))⌋₊ = ⌊a⌋₊ + OfNat.ofNat n :=
461462
floor_add_nat ha n
462463

463464
@[simp]
@@ -476,9 +477,10 @@ theorem floor_sub_nat [Sub α] [OrderedSub α] [ExistsAddOfLE α] (a : α) (n :
476477
theorem floor_sub_one [Sub α] [OrderedSub α] [ExistsAddOfLE α] (a : α) : ⌊a - 1⌋₊ = ⌊a⌋₊ - 1 :=
477478
mod_cast floor_sub_nat a 1
478479

480+
-- See note [no_index around OfNat.ofNat]
479481
@[simp]
480482
theorem floor_sub_ofNat [Sub α] [OrderedSub α] [ExistsAddOfLE α] (a : α) (n : ℕ) [n.AtLeastTwo] :
481-
⌊a - OfNat.ofNat n⌋₊ = ⌊a⌋₊ - OfNat.ofNat n :=
483+
⌊a - (no_index (OfNat.ofNat n))⌋₊ = ⌊a⌋₊ - OfNat.ofNat n :=
482484
floor_sub_nat a n
483485

484486
theorem ceil_add_nat (ha : 0 ≤ a) (n : ℕ) : ⌈a + n⌉₊ = ⌈a⌉₊ + n :=
@@ -496,8 +498,9 @@ theorem ceil_add_one (ha : 0 ≤ a) : ⌈a + 1⌉₊ = ⌈a⌉₊ + 1 := by
496498
rw [cast_one.symm, ceil_add_nat ha 1]
497499
#align nat.ceil_add_one Nat.ceil_add_one
498500

501+
-- See note [no_index around OfNat.ofNat]
499502
theorem ceil_add_ofNat (ha : 0 ≤ a) (n : ℕ) [n.AtLeastTwo] :
500-
⌈a + OfNat.ofNat n⌉₊ = ⌈a⌉₊ + OfNat.ofNat n :=
503+
⌈a + (no_index (OfNat.ofNat n))⌉₊ = ⌈a⌉₊ + OfNat.ofNat n :=
501504
ceil_add_nat ha n
502505

503506
theorem ceil_lt_add_one (ha : 0 ≤ a) : (⌈a⌉₊ : α) < a + 1 :=
@@ -543,8 +546,9 @@ theorem floor_div_nat (a : α) (n : ℕ) : ⌊a / n⌋₊ = ⌊a⌋₊ / n := by
543546
· exact cast_pos.2 hn
544547
#align nat.floor_div_nat Nat.floor_div_nat
545548

549+
-- See note [no_index around OfNat.ofNat]
546550
theorem floor_div_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] :
547-
⌊a / OfNat.ofNat n⌋₊ = ⌊a⌋₊ / OfNat.ofNat n :=
551+
⌊a / (no_index (OfNat.ofNat n))⌋₊ = ⌊a⌋₊ / OfNat.ofNat n :=
548552
floor_div_nat a n
549553

550554
/-- Natural division is the floor of field division. -/
@@ -738,7 +742,9 @@ theorem floor_zero : ⌊(0 : α)⌋ = 0 := by rw [← cast_zero, floor_intCast]
738742
theorem floor_one : ⌊(1 : α)⌋ = 1 := by rw [← cast_one, floor_intCast]
739743
#align int.floor_one Int.floor_one
740744

741-
@[simp] theorem floor_ofNat (n : ℕ) [n.AtLeastTwo] : ⌊(OfNat.ofNat n : α)⌋ = n := floor_natCast n
745+
-- See note [no_index around OfNat.ofNat]
746+
@[simp] theorem floor_ofNat (n : ℕ) [n.AtLeastTwo] : ⌊(no_index (OfNat.ofNat n : α))⌋ = n :=
747+
floor_natCast n
742748

743749
@[mono]
744750
theorem floor_mono : Monotone (floor : α → ℤ) :=
@@ -786,19 +792,21 @@ theorem floor_int_add (z : ℤ) (a : α) : ⌊↑z + a⌋ = z + ⌊a⌋ := by
786792
theorem floor_add_nat (a : α) (n : ℕ) : ⌊a + n⌋ = ⌊a⌋ + n := by rw [← Int.cast_ofNat, floor_add_int]
787793
#align int.floor_add_nat Int.floor_add_nat
788794

795+
-- See note [no_index around OfNat.ofNat]
789796
@[simp]
790797
theorem floor_add_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] :
791-
⌊a + OfNat.ofNat n⌋ = ⌊a⌋ + OfNat.ofNat n :=
798+
⌊a + (no_index (OfNat.ofNat n))⌋ = ⌊a⌋ + OfNat.ofNat n :=
792799
floor_add_nat a n
793800

794801
@[simp]
795802
theorem floor_nat_add (n : ℕ) (a : α) : ⌊↑n + a⌋ = n + ⌊a⌋ := by
796803
rw [← Int.cast_ofNat, floor_int_add]
797804
#align int.floor_nat_add Int.floor_nat_add
798805

806+
-- See note [no_index around OfNat.ofNat]
799807
@[simp]
800808
theorem floor_ofNat_add (n : ℕ) [n.AtLeastTwo] (a : α) :
801-
⌊OfNat.ofNat n + a⌋ = OfNat.ofNat n + ⌊a⌋ :=
809+
(no_index (OfNat.ofNat n)) + a⌋ = OfNat.ofNat n + ⌊a⌋ :=
802810
floor_nat_add n a
803811

804812
@[simp]
@@ -812,9 +820,10 @@ theorem floor_sub_nat (a : α) (n : ℕ) : ⌊a - n⌋ = ⌊a⌋ - n := by rw [
812820

813821
@[simp] theorem floor_sub_one (a : α) : ⌊a - 1⌋ = ⌊a⌋ - 1 := mod_cast floor_sub_nat a 1
814822

823+
-- See note [no_index around OfNat.ofNat]
815824
@[simp]
816825
theorem floor_sub_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] :
817-
⌊a - OfNat.ofNat n⌋ = ⌊a⌋ - OfNat.ofNat n :=
826+
⌊a - (no_index (OfNat.ofNat n))⌋ = ⌊a⌋ - OfNat.ofNat n :=
818827
floor_sub_nat a n
819828

820829
theorem abs_sub_lt_one_of_floor_eq_floor {α : Type*} [LinearOrderedCommRing α] [FloorRing α]
@@ -883,8 +892,10 @@ theorem fract_add_nat (a : α) (m : ℕ) : fract (a + m) = fract a := by
883892
@[simp]
884893
theorem fract_add_one (a : α) : fract (a + 1) = fract a := mod_cast fract_add_nat a 1
885894

895+
-- See note [no_index around OfNat.ofNat]
886896
@[simp]
887-
theorem fract_add_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] : fract (a + OfNat.ofNat n) = fract a :=
897+
theorem fract_add_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] :
898+
fract (a + (no_index (OfNat.ofNat n))) = fract a :=
888899
fract_add_nat a n
889900

890901
@[simp]
@@ -897,8 +908,10 @@ theorem fract_nat_add (n : ℕ) (a : α) : fract (↑n + a) = fract a := by rw [
897908
@[simp]
898909
theorem fract_one_add (a : α) : fract (1 + a) = fract a := mod_cast fract_nat_add 1 a
899910

911+
-- See note [no_index around OfNat.ofNat]
900912
@[simp]
901-
theorem fract_ofNat_add (n : ℕ) [n.AtLeastTwo] (a : α) : fract (OfNat.ofNat n + a) = fract a :=
913+
theorem fract_ofNat_add (n : ℕ) [n.AtLeastTwo] (a : α) :
914+
fract ((no_index (OfNat.ofNat n)) + a) = fract a :=
902915
fract_nat_add n a
903916

904917
@[simp]
@@ -916,8 +929,10 @@ theorem fract_sub_nat (a : α) (n : ℕ) : fract (a - n) = fract a := by
916929
@[simp]
917930
theorem fract_sub_one (a : α) : fract (a - 1) = fract a := mod_cast fract_sub_nat a 1
918931

932+
-- See note [no_index around OfNat.ofNat]
919933
@[simp]
920-
theorem fract_sub_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] : fract (a - OfNat.ofNat n) = fract a :=
934+
theorem fract_sub_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] :
935+
fract (a - (no_index (OfNat.ofNat n))) = fract a :=
921936
fract_sub_nat a n
922937

923938
-- Was a duplicate lemma under a bad name
@@ -985,8 +1000,11 @@ theorem fract_intCast (z : ℤ) : fract (z : α) = 0 := by
9851000
theorem fract_natCast (n : ℕ) : fract (n : α) = 0 := by simp [fract]
9861001
#align int.fract_nat_cast Int.fract_natCast
9871002

1003+
-- See note [no_index around OfNat.ofNat]
9881004
@[simp]
989-
theorem fract_ofNat (n : ℕ) [n.AtLeastTwo] : fract (OfNat.ofNat n : α) = 0 := fract_natCast n
1005+
theorem fract_ofNat (n : ℕ) [n.AtLeastTwo] :
1006+
fract ((no_index (OfNat.ofNat n)) : α) = 0 :=
1007+
fract_natCast n
9901008

9911009
-- porting note: simp can prove this
9921010
-- @[simp]
@@ -1213,8 +1231,9 @@ theorem ceil_natCast (n : ℕ) : ⌈(n : α)⌉ = n :=
12131231
eq_of_forall_ge_iff fun a => by rw [ceil_le, ← cast_ofNat, cast_le]
12141232
#align int.ceil_nat_cast Int.ceil_natCast
12151233

1234+
-- See note [no_index around OfNat.ofNat]
12161235
@[simp]
1217-
theorem ceil_ofNat (n : ℕ) [n.AtLeastTwo] : ⌈(OfNat.ofNat n : α)⌉ = n := ceil_natCast n
1236+
theorem ceil_ofNat (n : ℕ) [n.AtLeastTwo] : ⌈(no_index (OfNat.ofNat n : α))⌉ = n := ceil_natCast n
12181237

12191238
theorem ceil_mono : Monotone (ceil : α → ℤ) :=
12201239
gc_ceil_coe.monotone_l
@@ -1238,8 +1257,10 @@ theorem ceil_add_one (a : α) : ⌈a + 1⌉ = ⌈a⌉ + 1 := by
12381257
rw [← ceil_add_int a (1 : ℤ), cast_one]
12391258
#align int.ceil_add_one Int.ceil_add_one
12401259

1260+
-- See note [no_index around OfNat.ofNat]
12411261
@[simp]
1242-
theorem ceil_add_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] : ⌈a + OfNat.ofNat n⌉ = ⌈a⌉ + OfNat.ofNat n :=
1262+
theorem ceil_add_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] :
1263+
⌈a + (no_index (OfNat.ofNat n))⌉ = ⌈a⌉ + OfNat.ofNat n :=
12431264
ceil_add_nat a n
12441265

12451266
@[simp]
@@ -1258,8 +1279,10 @@ theorem ceil_sub_one (a : α) : ⌈a - 1⌉ = ⌈a⌉ - 1 := by
12581279
rw [eq_sub_iff_add_eq, ← ceil_add_one, sub_add_cancel]
12591280
#align int.ceil_sub_one Int.ceil_sub_one
12601281

1282+
-- See note [no_index around OfNat.ofNat]
12611283
@[simp]
1262-
theorem ceil_sub_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] : ⌈a - OfNat.ofNat n⌉ = ⌈a⌉ - OfNat.ofNat n :=
1284+
theorem ceil_sub_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] :
1285+
⌈a - (no_index (OfNat.ofNat n))⌉ = ⌈a⌉ - OfNat.ofNat n :=
12631286
ceil_sub_nat a n
12641287

12651288
theorem ceil_lt_add_one (a : α) : (⌈a⌉ : α) < a + 1 := by
@@ -1438,8 +1461,10 @@ theorem round_one : round (1 : α) = 1 := by simp [round]
14381461
theorem round_natCast (n : ℕ) : round (n : α) = n := by simp [round]
14391462
#align round_nat_cast round_natCast
14401463

1464+
-- See note [no_index around OfNat.ofNat]
14411465
@[simp]
1442-
theorem round_ofNat (n : ℕ) [n.AtLeastTwo] : round (OfNat.ofNat n : α) = n := round_natCast n
1466+
theorem round_ofNat (n : ℕ) [n.AtLeastTwo] : round (no_index (OfNat.ofNat n : α)) = n :=
1467+
round_natCast n
14431468

14441469
@[simp]
14451470
theorem round_intCast (n : ℤ) : round (n : α) = n := by simp [round]
@@ -1474,19 +1499,21 @@ theorem round_add_nat (x : α) (y : ℕ) : round (x + y) = round x + y :=
14741499
mod_cast round_add_int x y
14751500
#align round_add_nat round_add_nat
14761501

1502+
-- See note [no_index around OfNat.ofNat]
14771503
@[simp]
14781504
theorem round_add_ofNat (x : α) (n : ℕ) [n.AtLeastTwo] :
1479-
round (x + OfNat.ofNat n) = round x + OfNat.ofNat n :=
1505+
round (x + (no_index (OfNat.ofNat n))) = round x + OfNat.ofNat n :=
14801506
round_add_nat x n
14811507

14821508
@[simp]
14831509
theorem round_sub_nat (x : α) (y : ℕ) : round (x - y) = round x - y :=
14841510
mod_cast round_sub_int x y
14851511
#align round_sub_nat round_sub_nat
14861512

1513+
-- See note [no_index around OfNat.ofNat]
14871514
@[simp]
14881515
theorem round_sub_ofNat (x : α) (n : ℕ) [n.AtLeastTwo] :
1489-
round (x - OfNat.ofNat n) = round x - OfNat.ofNat n :=
1516+
round (x - (no_index (OfNat.ofNat n))) = round x - OfNat.ofNat n :=
14901517
round_sub_nat x n
14911518

14921519
@[simp]
@@ -1499,9 +1526,10 @@ theorem round_nat_add (x : α) (y : ℕ) : round ((y : α) + x) = y + round x :=
14991526
rw [add_comm, round_add_nat, add_comm]
15001527
#align round_nat_add round_nat_add
15011528

1529+
-- See note [no_index around OfNat.ofNat]
15021530
@[simp]
15031531
theorem round_ofNat_add (n : ℕ) [n.AtLeastTwo] (x : α) :
1504-
round (OfNat.ofNat n + x) = OfNat.ofNat n + round x :=
1532+
round ((no_index (OfNat.ofNat n)) + x) = OfNat.ofNat n + round x :=
15051533
round_nat_add x n
15061534

15071535
theorem abs_sub_round_eq_min (x : α) : |x - round x| = min (fract x) (1 - fract x) := by

Mathlib/Data/Real/ENatENNReal.lean

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ theorem toENNReal_coe (n : ℕ) : ((n : ℕ∞) : ℝ≥0∞) = n :=
5656
rfl
5757
#align enat.coe_ennreal_coe ENat.toENNReal_coe
5858

59+
-- See note [no_index around OfNat.ofNat]
5960
@[simp, norm_cast]
60-
theorem toENNReal_ofNat (n : ℕ) [n.AtLeastTwo] : ((OfNat.ofNat n : ℕ∞) : ℝ≥0∞) = OfNat.ofNat n :=
61+
theorem toENNReal_ofNat (n : ℕ) [n.AtLeastTwo] :
62+
((no_index (OfNat.ofNat n : ℕ∞)) : ℝ≥0∞) = OfNat.ofNat n :=
6163
rfl
6264

6365
@[simp, norm_cast]

Mathlib/Data/Real/Hyperreal.lean

+4-1
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ theorem coe_add (x y : ℝ) : ↑(x + y) = (x + y : ℝ*) :=
8989
#noalign hyperreal.coe_bit0
9090
#noalign hyperreal.coe_bit1
9191

92+
-- See note [no_index around OfNat.ofNat]
9293
@[simp, norm_cast]
93-
theorem coe_ofNat (n : ℕ) [n.AtLeastTwo] : ((OfNat.ofNat n : ℝ) : ℝ*) = OfNat.ofNat n := rfl
94+
theorem coe_ofNat (n : ℕ) [n.AtLeastTwo] :
95+
((no_index (OfNat.ofNat n : ℝ)) : ℝ*) = OfNat.ofNat n :=
96+
rfl
9497

9598
@[simp, norm_cast]
9699
theorem coe_mul (x y : ℝ) : ↑(x * y) = (x * y : ℝ*) :=

Mathlib/GroupTheory/Subsemigroup/Center.lean

+2-1
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,10 @@ theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.cent
185185
| zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero]
186186
| succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one]
187187

188+
-- See note [no_index around OfNat.ofNat]
188189
@[simp]
189190
theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] :
190-
OfNat.ofNat n ∈ Set.center M :=
191+
(no_index (OfNat.ofNat n)) ∈ Set.center M :=
191192
natCast_mem_center M n
192193

193194
@[simp]

Mathlib/Order/Filter/Germ.lean

+4-2
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,16 @@ theorem coe_nat [NatCast M] (n : ℕ) : ((fun _ ↦ n : α → M) : Germ l M) =
457457
@[simp, norm_cast]
458458
theorem const_nat [NatCast M] (n : ℕ) : ((n : M) : Germ l M) = n := rfl
459459

460+
-- See note [no_index around OfNat.ofNat]
460461
@[simp, norm_cast]
461462
theorem coe_ofNat [NatCast M] (n : ℕ) [n.AtLeastTwo] :
462-
((OfNat.ofNat n : α → M) : Germ l M) = OfNat.ofNat n :=
463+
((no_index (OfNat.ofNat n : α → M)) : Germ l M) = OfNat.ofNat n :=
463464
rfl
464465

466+
-- See note [no_index around OfNat.ofNat]
465467
@[simp, norm_cast]
466468
theorem const_ofNat [NatCast M] (n : ℕ) [n.AtLeastTwo] :
467-
((OfNat.ofNat n : M) : Germ l M) = OfNat.ofNat n :=
469+
((no_index (OfNat.ofNat n : M)) : Germ l M) = OfNat.ofNat n :=
468470
rfl
469471

470472
instance intCast [IntCast M] : IntCast (Germ l M) where

Mathlib/SetTheory/Cardinal/Basic.lean

+3-1
Original file line numberDiff line numberDiff line change
@@ -1757,8 +1757,10 @@ theorem toNat_cast (n : ℕ) : Cardinal.toNat n = n := by
17571757
exact (Classical.choose_spec (lt_aleph0.1 (nat_lt_aleph0 n))).symm
17581758
#align cardinal.to_nat_cast Cardinal.toNat_cast
17591759

1760+
-- See note [no_index around OfNat.ofNat]
17601761
@[simp]
1761-
theorem toNat_ofNat (n : ℕ) [n.AtLeastTwo] : Cardinal.toNat (OfNat.ofNat n) = OfNat.ofNat n :=
1762+
theorem toNat_ofNat (n : ℕ) [n.AtLeastTwo] :
1763+
Cardinal.toNat (no_index (OfNat.ofNat n)) = OfNat.ofNat n :=
17621764
toNat_cast n
17631765

17641766
/-- `toNat` has a right-inverse: coercion. -/

0 commit comments

Comments
 (0)