Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - fix: add missing no_index around OfNat.ofNat #8317

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 47 additions & 19 deletions Mathlib/Algebra/Order/Floor.lean
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,9 @@ theorem floor_add_one (ha : 0 ≤ a) : ⌊a + 1⌋₊ = ⌊a⌋₊ + 1 := by
rw [←cast_one, floor_add_nat ha 1]
#align nat.floor_add_one Nat.floor_add_one

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

@[simp]
Expand All @@ -476,9 +477,10 @@ theorem floor_sub_nat [Sub α] [OrderedSub α] [ExistsAddOfLE α] (a : α) (n :
theorem floor_sub_one [Sub α] [OrderedSub α] [ExistsAddOfLE α] (a : α) : ⌊a - 1⌋₊ = ⌊a⌋₊ - 1 := by
exact_mod_cast floor_sub_nat a 1

-- See note [no_index around OfNat.ofNat]
@[simp]
theorem floor_sub_ofNat [Sub α] [OrderedSub α] [ExistsAddOfLE α] (a : α) (n : ℕ) [n.AtLeastTwo] :
⌊a - OfNat.ofNat n⌋₊ = ⌊a⌋₊ - OfNat.ofNat n :=
⌊a - (no_index (OfNat.ofNat n))⌋₊ = ⌊a⌋₊ - OfNat.ofNat n :=
floor_sub_nat a n

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

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

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

-- See note [no_index around OfNat.ofNat]
theorem floor_div_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] :
⌊a / OfNat.ofNat n⌋₊ = ⌊a⌋₊ / OfNat.ofNat n :=
⌊a / (no_index (OfNat.ofNat n))⌋₊ = ⌊a⌋₊ / OfNat.ofNat n :=
floor_div_nat a n

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

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

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

-- See note [no_index around OfNat.ofNat]
@[simp]
theorem floor_add_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] :
⌊a + OfNat.ofNat n⌋ = ⌊a⌋ + OfNat.ofNat n :=
⌊a + (no_index (OfNat.ofNat n))⌋ = ⌊a⌋ + OfNat.ofNat n :=
floor_add_nat a n

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

-- See note [no_index around OfNat.ofNat]
@[simp]
theorem floor_ofNat_add (n : ℕ) [n.AtLeastTwo] (a : α) :
⌊OfNat.ofNat n + a⌋ = OfNat.ofNat n + ⌊a⌋ :=
(no_index (OfNat.ofNat n)) + a⌋ = OfNat.ofNat n + ⌊a⌋ :=
floor_nat_add n a

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

@[simp] theorem floor_sub_one (a : α) : ⌊a - 1⌋ = ⌊a⌋ - 1 := by exact_mod_cast floor_sub_nat a 1

-- See note [no_index around OfNat.ofNat]
@[simp]
theorem floor_sub_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] :
⌊a - OfNat.ofNat n⌋ = ⌊a⌋ - OfNat.ofNat n :=
⌊a - (no_index (OfNat.ofNat n))⌋ = ⌊a⌋ - OfNat.ofNat n :=
floor_sub_nat a n

theorem abs_sub_lt_one_of_floor_eq_floor {α : Type*} [LinearOrderedCommRing α] [FloorRing α]
Expand Down Expand Up @@ -883,8 +892,10 @@ theorem fract_add_nat (a : α) (m : ℕ) : fract (a + m) = fract a := by
@[simp]
theorem fract_add_one (a : α) : fract (a + 1) = fract a := by exact_mod_cast fract_add_nat a 1

-- See note [no_index around OfNat.ofNat]
@[simp]
theorem fract_add_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] : fract (a + OfNat.ofNat n) = fract a :=
theorem fract_add_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] :
fract (a + (no_index (OfNat.ofNat n))) = fract a :=
fract_add_nat a n

@[simp]
Expand All @@ -897,8 +908,10 @@ theorem fract_nat_add (n : ℕ) (a : α) : fract (↑n + a) = fract a := by rw [
@[simp]
theorem fract_one_add (a : α) : fract (1 + a) = fract a := by exact_mod_cast fract_nat_add 1 a

-- See note [no_index around OfNat.ofNat]
@[simp]
theorem fract_ofNat_add (n : ℕ) [n.AtLeastTwo] (a : α) : fract (OfNat.ofNat n + a) = fract a :=
theorem fract_ofNat_add (n : ℕ) [n.AtLeastTwo] (a : α) :
fract ((no_index (OfNat.ofNat n)) + a) = fract a :=
fract_nat_add n a

@[simp]
Expand All @@ -916,8 +929,10 @@ theorem fract_sub_nat (a : α) (n : ℕ) : fract (a - n) = fract a := by
@[simp]
theorem fract_sub_one (a : α) : fract (a - 1) = fract a := by exact_mod_cast fract_sub_nat a 1

-- See note [no_index around OfNat.ofNat]
@[simp]
theorem fract_sub_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] : fract (a - OfNat.ofNat n) = fract a :=
theorem fract_sub_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] :
fract (a - (no_index (OfNat.ofNat n))) = fract a :=
fract_sub_nat a n

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

-- See note [no_index around OfNat.ofNat]
@[simp]
theorem fract_ofNat (n : ℕ) [n.AtLeastTwo] : fract (OfNat.ofNat n : α) = 0 := fract_natCast n
theorem fract_ofNat (n : ℕ) [n.AtLeastTwo] :
fract ((no_index (OfNat.ofNat n)) : α) = 0 :=
fract_natCast n

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

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

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

-- See note [no_index around OfNat.ofNat]
@[simp]
theorem ceil_add_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] : ⌈a + OfNat.ofNat n⌉ = ⌈a⌉ + OfNat.ofNat n :=
theorem ceil_add_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] :
⌈a + (no_index (OfNat.ofNat n))⌉ = ⌈a⌉ + OfNat.ofNat n :=
ceil_add_nat a n

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

-- See note [no_index around OfNat.ofNat]
@[simp]
theorem ceil_sub_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] : ⌈a - OfNat.ofNat n⌉ = ⌈a⌉ - OfNat.ofNat n :=
theorem ceil_sub_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] :
⌈a - (no_index (OfNat.ofNat n))⌉ = ⌈a⌉ - OfNat.ofNat n :=
ceil_sub_nat a n

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

-- See note [no_index around OfNat.ofNat]
@[simp]
theorem round_ofNat (n : ℕ) [n.AtLeastTwo] : round (OfNat.ofNat n : α) = n := round_natCast n
theorem round_ofNat (n : ℕ) [n.AtLeastTwo] : round (no_index (OfNat.ofNat n : α)) = n :=
round_natCast n

@[simp]
theorem round_intCast (n : ℤ) : round (n : α) = n := by simp [round]
Expand Down Expand Up @@ -1474,19 +1499,21 @@ theorem round_add_nat (x : α) (y : ℕ) : round (x + y) = round x + y := by
exact_mod_cast round_add_int x y
#align round_add_nat round_add_nat

-- See note [no_index around OfNat.ofNat]
@[simp]
theorem round_add_ofNat (x : α) (n : ℕ) [n.AtLeastTwo] :
round (x + OfNat.ofNat n) = round x + OfNat.ofNat n :=
round (x + (no_index (OfNat.ofNat n))) = round x + OfNat.ofNat n :=
round_add_nat x n

@[simp]
theorem round_sub_nat (x : α) (y : ℕ) : round (x - y) = round x - y := by
exact_mod_cast round_sub_int x y
#align round_sub_nat round_sub_nat

-- See note [no_index around OfNat.ofNat]
@[simp]
theorem round_sub_ofNat (x : α) (n : ℕ) [n.AtLeastTwo] :
round (x - OfNat.ofNat n) = round x - OfNat.ofNat n :=
round (x - (no_index (OfNat.ofNat n))) = round x - OfNat.ofNat n :=
round_sub_nat x n

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

-- See note [no_index around OfNat.ofNat]
@[simp]
theorem round_ofNat_add (n : ℕ) [n.AtLeastTwo] (x : α) :
round (OfNat.ofNat n + x) = OfNat.ofNat n + round x :=
round ((no_index (OfNat.ofNat n)) + x) = OfNat.ofNat n + round x :=
round_nat_add x n

theorem abs_sub_round_eq_min (x : α) : |x - round x| = min (fract x) (1 - fract x) := by
Expand Down
4 changes: 3 additions & 1 deletion Mathlib/Data/Real/ENatENNReal.lean
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ theorem toENNReal_coe (n : ℕ) : ((n : ℕ∞) : ℝ≥0∞) = n :=
rfl
#align enat.coe_ennreal_coe ENat.toENNReal_coe

-- See note [no_index around OfNat.ofNat]
@[simp, norm_cast]
theorem toENNReal_ofNat (n : ℕ) [n.AtLeastTwo] : ((OfNat.ofNat n : ℕ∞) : ℝ≥0∞) = OfNat.ofNat n :=
theorem toENNReal_ofNat (n : ℕ) [n.AtLeastTwo] :
((no_index (OfNat.ofNat n : ℕ∞)) : ℝ≥0∞) = OfNat.ofNat n :=
rfl

@[simp, norm_cast]
Expand Down
5 changes: 4 additions & 1 deletion Mathlib/Data/Real/Hyperreal.lean
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ theorem coe_add (x y : ℝ) : ↑(x + y) = (x + y : ℝ*) :=
#noalign hyperreal.coe_bit0
#noalign hyperreal.coe_bit1

-- See note [no_index around OfNat.ofNat]
@[simp, norm_cast]
theorem coe_ofNat (n : ℕ) [n.AtLeastTwo] : ((OfNat.ofNat n : ℝ) : ℝ*) = OfNat.ofNat n := rfl
theorem coe_ofNat (n : ℕ) [n.AtLeastTwo] :
((no_index (OfNat.ofNat n : ℝ)) : ℝ*) = OfNat.ofNat n :=
rfl

@[simp, norm_cast]
theorem coe_mul (x y : ℝ) : ↑(x * y) = (x * y : ℝ*) :=
Expand Down
3 changes: 2 additions & 1 deletion Mathlib/GroupTheory/Subsemigroup/Center.lean
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M := by simp [
theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M :=
(Nat.commute_cast · _)

-- See note [no_index around OfNat.ofNat]
@[simp]
theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] :
OfNat.ofNat n ∈ Set.center M :=
(no_index (OfNat.ofNat n)) ∈ Set.center M :=
natCast_mem_center M n

@[simp]
Expand Down
6 changes: 4 additions & 2 deletions Mathlib/Order/Filter/Germ.lean
Original file line number Diff line number Diff line change
Expand Up @@ -448,14 +448,16 @@ theorem coe_nat [NatCast M] (n : ℕ) : ((fun _ ↦ n : α → M) : Germ l M) =
@[simp, norm_cast]
theorem const_nat [NatCast M] (n : ℕ) : ((n : M) : Germ l M) = n := rfl

-- See note [no_index around OfNat.ofNat]
@[simp, norm_cast]
theorem coe_ofNat [NatCast M] (n : ℕ) [n.AtLeastTwo] :
((OfNat.ofNat n : α → M) : Germ l M) = OfNat.ofNat n :=
((no_index (OfNat.ofNat n : α → M)) : Germ l M) = OfNat.ofNat n :=
rfl

-- See note [no_index around OfNat.ofNat]
@[simp, norm_cast]
theorem const_ofNat [NatCast M] (n : ℕ) [n.AtLeastTwo] :
((OfNat.ofNat n : M) : Germ l M) = OfNat.ofNat n :=
((no_index (OfNat.ofNat n : M)) : Germ l M) = OfNat.ofNat n :=
rfl

instance intCast [IntCast M] : IntCast (Germ l M) where
Expand Down
4 changes: 3 additions & 1 deletion Mathlib/SetTheory/Cardinal/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1766,8 +1766,10 @@ theorem toNat_cast (n : ℕ) : Cardinal.toNat n = n := by
exact (Classical.choose_spec (lt_aleph0.1 (nat_lt_aleph0 n))).symm
#align cardinal.to_nat_cast Cardinal.toNat_cast

-- See note [no_index around OfNat.ofNat]
@[simp]
theorem toNat_ofNat (n : ℕ) [n.AtLeastTwo] : Cardinal.toNat (OfNat.ofNat n) = OfNat.ofNat n :=
theorem toNat_ofNat (n : ℕ) [n.AtLeastTwo] :
Cardinal.toNat (no_index (OfNat.ofNat n)) = OfNat.ofNat n :=
toNat_cast n

/-- `toNat` has a right-inverse: coercion. -/
Expand Down