Skip to content

Commit 3bf06ae

Browse files
committed
feat: when simps is used on inst names, omit the name (#25125)
When `@[simps]` is used on ```lean namespace Foo @[simps] instance : Group Foo := ... end Foo ``` this now generates the names `Foo.mul_def`, `Foo.inv_def`, etc. If `Foo` has `simps` projections, these will be used as `Foo.mul_proj`, `Foo.inv_proj` (respecting prefixes as usual). This introduces `@[simps (nameStem := "")]` to opt into the behavior explicitly, and `@[simps (nameStem := "instGroup")]` to opt out. Note that this does not deprecate the old auto-generated names, as in practice it is tricky to exhaustively list them all, and adding support to `simps` to generate them does not seem worth the effort. It's perhaps worth noting that we didn't need this feature as much in Lean 3, as there the instances were called `instance mul : mul X` instead of `instance instMul : Mul X`, and so we got `theorem mul_mul` instead of `theorem instMul_mul`.
1 parent 478adcb commit 3bf06ae

File tree

26 files changed

+139
-93
lines changed

26 files changed

+139
-93
lines changed

Mathlib/Algebra/BigOperators/Fin.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ theorem finSigmaFinEquiv_apply {m : ℕ} {n : Fin m → ℕ} (k : (i : Fin m) ×
626626
rcases k with ⟨⟨iv, hi⟩, j⟩
627627
rw [finSigmaFinEquiv]
628628
unfold finSumFinEquiv
629-
simp only [Equiv.coe_fn_mk, Equiv.sigmaCongrLeft, Equiv.coe_fn_symm_mk, Equiv.instTrans_trans,
629+
simp only [Equiv.coe_fn_mk, Equiv.sigmaCongrLeft, Equiv.coe_fn_symm_mk, Equiv.trans_def,
630630
Equiv.trans_apply, finCongr_apply, Fin.coe_cast]
631631
conv =>
632632
enter [1,1,3]

Mathlib/Algebra/Category/Ring/Adjunctions.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def monoidAlgebra (R : CommRingCat.{max u v}) : CommMonCat.{v} ⥤ Under R where
8787
map f := Under.homMk (CommRingCat.ofHom <| MonoidAlgebra.mapDomainRingHom R f.hom)
8888
map_comp f g := by ext : 2; apply MonoidAlgebra.ringHom_ext <;> intro <;> simp
8989

90-
@[simps]
90+
@[simps (nameStem := "commMon")]
9191
instance : HasForget₂ CommRingCat CommMonCat where
9292
forget₂ := { obj M := .of M, map f := CommMonCat.ofHom f.hom }
9393
forget_comp := rfl

Mathlib/Algebra/Homology/TotalComplexShift.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ variable (x y : ℤ) [K.HasTotal (up ℤ)]
7777
instance : ((shiftFunctor₁ C x).obj K).HasTotal (up ℤ) := fun n =>
7878
hasCoproduct_of_equiv_of_iso (K.toGradedObject.mapObjFun (π (up ℤ) (up ℤ) (up ℤ)) (n + x)) _
7979
{ toFun := fun ⟨⟨a, b⟩, h⟩ => ⟨⟨a + x, b⟩, by
80-
simp only [Set.mem_preimage, instTotalComplexShape_π, Set.mem_singleton_iff] at h ⊢
80+
simp only [Set.mem_preimage, π_def, Set.mem_singleton_iff] at h ⊢
8181
omega⟩
8282
invFun := fun ⟨⟨a, b⟩, h⟩ => ⟨(a - x, b), by
83-
simp only [Set.mem_preimage, instTotalComplexShape_π, Set.mem_singleton_iff] at h ⊢
83+
simp only [Set.mem_preimage, π_def, Set.mem_singleton_iff] at h ⊢
8484
omega⟩
8585
left_inv := by
8686
rintro ⟨⟨a, b⟩, h⟩
@@ -99,10 +99,10 @@ instance : ((shiftFunctor₁ C x).obj K).HasTotal (up ℤ) := fun n =>
9999
instance : ((shiftFunctor₂ C y).obj K).HasTotal (up ℤ) := fun n =>
100100
hasCoproduct_of_equiv_of_iso (K.toGradedObject.mapObjFun (π (up ℤ) (up ℤ) (up ℤ)) (n + y)) _
101101
{ toFun := fun ⟨⟨a, b⟩, h⟩ => ⟨⟨a, b + y⟩, by
102-
simp only [Set.mem_preimage, instTotalComplexShape_π, Set.mem_singleton_iff] at h ⊢
102+
simp only [Set.mem_preimage, π_def, Set.mem_singleton_iff] at h ⊢
103103
omega⟩
104104
invFun := fun ⟨⟨a, b⟩, h⟩ => ⟨(a, b - y), by
105-
simp only [Set.mem_preimage, instTotalComplexShape_π, Set.mem_singleton_iff] at h ⊢
105+
simp only [Set.mem_preimage, π_def, Set.mem_singleton_iff] at h ⊢
106106
omega⟩
107107
left_inv _ := by simp
108108
right_inv _ := by simp }

Mathlib/Algebra/Quaternion.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,9 +1212,9 @@ instance instInv : Inv ℍ[R] :=
12121212
instance instGroupWithZero : GroupWithZero ℍ[R] :=
12131213
{ Quaternion.instNontrivial with
12141214
inv := Inv.inv
1215-
inv_zero := by rw [instInv_inv, star_zero, smul_zero]
1215+
inv_zero := by rw [inv_def, star_zero, smul_zero]
12161216
mul_inv_cancel := fun a ha => by
1217-
rw [instInv_inv, Algebra.mul_smul_comm (normSq a)⁻¹ a (star a), self_mul_star, smul_coe,
1217+
rw [inv_def, Algebra.mul_smul_comm (normSq a)⁻¹ a (star a), self_mul_star, smul_coe,
12181218
inv_mul_cancel₀ (normSq_ne_zero.2 ha), coe_one] }
12191219

12201220
@[norm_cast, simp]

Mathlib/AlgebraicGeometry/ResidueField.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ instance {X : Scheme.{u}} (x : X) : IsPreimmersion (X.fromSpecResidueField x) :=
227227
@[simps] noncomputable
228228
instance (x : X) : (Spec (X.residueField x)).Over X := ⟨X.fromSpecResidueField x⟩
229229

230-
@[simps! over] noncomputable
230+
noncomputable
231231
instance (x : X) : (Spec (X.residueField x)).CanonicallyOver X where
232232

233233
@[reassoc (attr := simp)]

Mathlib/AlgebraicGeometry/Stalk.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ noncomputable def Scheme.fromSpecStalk (X : Scheme) (x : X) :
6868
@[simps over] noncomputable
6969
instance (X : Scheme.{u}) (x : X) : (Spec (X.presheaf.stalk x)).Over X := ⟨X.fromSpecStalk x⟩
7070

71-
@[simps! over] noncomputable
71+
noncomputable
7272
instance (X : Scheme.{u}) (x : X) : (Spec (X.presheaf.stalk x)).CanonicallyOver X where
7373

7474
@[simp]

Mathlib/AlgebraicTopology/SimplicialObject/Basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,13 +516,13 @@ end SimplicialObject
516516
def CosimplicialObject :=
517517
SimplexCategory ⥤ C
518518

519+
namespace CosimplicialObject
520+
519521
@[simps!]
520522
instance : Category (CosimplicialObject C) := by
521523
dsimp only [CosimplicialObject]
522524
infer_instance
523525

524-
namespace CosimplicialObject
525-
526526
/-- `X ^⦋n⦌` denotes the `n`th-term of the cosimplicial object X -/
527527
scoped[Simplicial]
528528
notation3:1000 X " ^⦋" n "⦌" =>

Mathlib/CategoryTheory/Bicategory/NaturalTransformation/Oplax.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def vcomp : StrongTrans F H :=
275275
/-- `CategoryStruct` on `OplaxFunctor B C` where the (1-)morphisms are given by strong
276276
transformations. -/
277277
@[simps! id_app id_naturality comp_app comp_naturality]
278-
scoped instance : CategoryStruct (OplaxFunctor B C) where
278+
scoped instance OplaxFunctor.instCategoryStruct : CategoryStruct (OplaxFunctor B C) where
279279
Hom := StrongTrans
280280
id := StrongTrans.id
281281
comp := StrongTrans.vcomp

Mathlib/CategoryTheory/Comma/Over/OverClass.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ instance : OverClass X X := ⟨𝟙 _⟩
7272

7373
instance : IsIso (S ↘ S) := inferInstanceAs (IsIso (𝟙 S))
7474

75+
namespace CanonicallyOverClass
7576
-- This cannot be a simp lemma be cause it loops with `comp_over`.
7677
@[simps -isSimp]
7778
instance (priority := 900) [CanonicallyOverClass X Y] [OverClass Y S] : OverClass X S :=
7879
⟨X ↘ Y ≫ Y ↘ S⟩
80+
end CanonicallyOverClass
7981

8082
/-- Given `OverClass X S` and `OverClass Y S` and `f : X ⟶ Y`,
8183
`HomIsOver f S` is the typeclass asserting `f` commutes with the structure morphisms. -/

Mathlib/CategoryTheory/Comma/StructuredArrow/Final.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private lemma final_of_final_costructuredArrowToOver_small (L : A ⥤ T) (R : B
5353
Final.colimitIso _ _
5454
_ ≅ colimit G := (colimitIsoColimitGrothendieck (𝟭 T) G).symm
5555
convert Iso.isIso_hom i
56-
simp only [Iso.instTransIso_trans, comp_obj, grothendieckProj_obj, Grothendieck.pre_obj_base,
56+
simp only [Iso.trans_def, comp_obj, grothendieckProj_obj, Grothendieck.pre_obj_base,
5757
Grothendieck.pre_obj_fiber, Iso.trans_assoc, Iso.trans_hom, Iso.symm_hom, i]
5858
rw [← Iso.inv_comp_eq, Iso.eq_inv_comp]
5959
apply colimit.hom_ext (fun _ => by simp)

0 commit comments

Comments
 (0)