Skip to content

Commit 53b9fb3

Browse files
committed
chore(Fin): fix some @[simp] lemmas (#23967)
Some `@[simps]`-generated lemmas use wrong RHS. Also, one lemma was incorrectly named.
1 parent 595daf8 commit 53b9fb3

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

Mathlib/Algebra/BigOperators/Fin.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ theorem sum_const [AddCommMonoid α] (n : ℕ) (x : α) : ∑ _i : Fin n, x = n
155155
@[to_additive]
156156
theorem prod_Ioi_zero {M : Type*} [CommMonoid M] {n : ℕ} {v : Fin n.succ → M} :
157157
∏ i ∈ Ioi 0, v i = ∏ j : Fin n, v j.succ := by
158-
rw [Ioi_zero_eq_map, Finset.prod_map, val_succEmb]
158+
rw [Ioi_zero_eq_map, Finset.prod_map, coe_succEmb]
159159

160160
@[to_additive]
161161
theorem prod_Ioi_succ {M : Type*} [CommMonoid M] {n : ℕ} (i : Fin n) (v : Fin n.succ → M) :
162162
∏ j ∈ Ioi i.succ, v j = ∏ j ∈ Ioi i, v j.succ := by
163-
rw [Ioi_succ, Finset.prod_map, val_succEmb]
163+
rw [Ioi_succ, Finset.prod_map, coe_succEmb]
164164

165165
@[to_additive]
166166
theorem prod_congr' {M : Type*} [CommMonoid M] {a b : ℕ} (f : Fin b → M) (h : a = b) :

Mathlib/Data/Fin/Basic.lean

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,11 @@ def succEmb (n : ℕ) : Fin n ↪ Fin (n + 1) where
442442
inj' := succ_injective _
443443

444444
@[simp]
445-
theorem val_succEmb : ⇑(succEmb n) = Fin.succ := rfl
445+
theorem coe_succEmb : ⇑(succEmb n) = Fin.succ :=
446+
rfl
447+
448+
@[deprecated (since := "2025-04-12")]
449+
alias val_succEmb := coe_succEmb
446450

447451
@[simp]
448452
theorem exists_succ_eq {x : Fin (n + 1)} : (∃ y, Fin.succ y = x) ↔ x ≠ 0 :=
@@ -497,7 +501,7 @@ lemma castAdd_injective (m n : ℕ) : Injective (@Fin.castAdd m n) := castLE_inj
497501
lemma castSucc_injective (n : ℕ) : Injective (@Fin.castSucc n) := castAdd_injective _ _
498502

499503
/-- `Fin.castLE` as an `Embedding`, `castLEEmb h i` embeds `i` into a larger `Fin` type. -/
500-
@[simps! apply]
504+
@[simps apply]
501505
def castLEEmb (h : n ≤ m) : Fin n ↪ Fin m where
502506
toFun := castLE h
503507
inj' := castLE_injective _
@@ -596,15 +600,20 @@ theorem cast_eq_cast (h : n = m) : (Fin.cast h : Fin n → Fin m) = _root_.cast
596600

597601
/-- `Fin.castAdd` as an `Embedding`, `castAddEmb m i` embeds `i : Fin n` in `Fin (n+m)`.
598602
See also `Fin.natAddEmb` and `Fin.addNatEmb`. -/
599-
@[simps! apply]
600603
def castAddEmb (m) : Fin n ↪ Fin (n + m) := castLEEmb (le_add_right n m)
601604

605+
@[simp]
606+
lemma coe_castAddEmb (m) : (castAddEmb m : Fin n → Fin (n + m)) = castAdd m := rfl
607+
608+
lemma castAddEmb_apply (m) (i : Fin n) : castAddEmb m i = castAdd m i := rfl
609+
602610
/-- `Fin.castSucc` as an `Embedding`, `castSuccEmb i` embeds `i : Fin n` in `Fin (n+1)`. -/
603-
@[simps! apply]
604611
def castSuccEmb : Fin n ↪ Fin (n + 1) := castAddEmb _
605612

606613
@[simp, norm_cast] lemma coe_castSuccEmb : (castSuccEmb : Fin n → Fin (n + 1)) = Fin.castSucc := rfl
607614

615+
lemma castSuccEmb_apply (i : Fin n) : castSuccEmb i = i.castSucc := rfl
616+
608617
theorem castSucc_le_succ {n} (i : Fin n) : i.castSucc ≤ i.succ := Nat.le_succ i
609618

610619
@[simp] theorem castSucc_le_castSucc_iff {a b : Fin n} : castSucc a ≤ castSucc b ↔ a ≤ b := .rfl

Mathlib/RingTheory/Idempotents.lean

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,9 @@ lemma CompleteOrthogonalIdempotents.lift_of_isNilpotent_ker_aux
310310
refine ⟨_, (equiv (finSuccEquiv n)).mpr
311311
(CompleteOrthogonalIdempotents.option (h₁.embedding (Fin.succEmb _))), funext fun i ↦ ?_⟩
312312
have (i) : f (e' i) = e i := congr_fun h₂ i
313-
obtain ⟨_ | i, rfl⟩ := (finSuccEquiv n).symm.surjective i
314-
· simp only [Fin.val_succEmb, Function.comp_apply, finSuccEquiv_symm_none, finSuccEquiv_zero,
315-
Option.elim_none, map_sub, map_one, map_sum, this, ← he.complete, sub_eq_iff_eq_add,
316-
Fin.sum_univ_succ]
317-
· simp [this]
313+
cases i using Fin.cases with
314+
| zero => simp [this, Fin.sum_univ_succ, ← he.complete]
315+
| succ i => simp [this]
318316

319317
/-- A system of complete orthogonal idempotents lift along nil ideals. -/
320318
lemma CompleteOrthogonalIdempotents.lift_of_isNilpotent_ker

0 commit comments

Comments
 (0)