Skip to content

Commit 83e7fe4

Browse files
committed
feat(CategoryTheory): use push attribute for CategoryTheory.inv. (leanprover-community#33820)
In this PR a few lemmas about isomorphisms are tagged `@[push]` or `@[push ←]`. The directionality of lemmas should be that the `inv` constant is pushed away from the head of the expression. Some annotations are terminal, for instance, the ones for `inv (inv f) = f`, or `inv (e.hom) = e.inv` and `inv (e.inv) = e.hom`. Running `push inv` thus normalizes inverses of expressions, though the form obtained is not necessarily the same as the simp normal form (simp normal forms in the library tend to "pull" the inverses outwards, while the push lemmas here are pushing them inwards). These annotations will serve as building blocks for a simproc that cancels an isomorphism with its inverse within arbitrary nested expressions (functor compositions, whiskering in monoidal categories, natural isomorphisms of multifunctors, etc.). See leanprover-community#33822 for the implementation of the simproc, and how it uses the annotations introduced here.
1 parent 344975b commit 83e7fe4

6 files changed

Lines changed: 16 additions & 16 deletions

File tree

Mathlib/CategoryTheory/Bicategory/Basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def whiskerLeftIso (f : a ⟶ b) {g h : b ⟶ c} (η : g ≅ h) : f ≫ g ≅ f
231231
instance whiskerLeft_isIso (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h) [IsIso η] : IsIso (f ◁ η) :=
232232
(whiskerLeftIso f (asIso η)).isIso_hom
233233

234-
@[simp]
234+
@[simp, push]
235235
theorem inv_whiskerLeft (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h) [IsIso η] :
236236
inv (f ◁ η) = f ◁ inv η := by
237237
apply IsIso.inv_eq_of_hom_inv_id
@@ -246,7 +246,7 @@ def whiskerRightIso {f g : a ⟶ b} (η : f ≅ g) (h : b ⟶ c) : f ≫ h ≅ g
246246
instance whiskerRight_isIso {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c) [IsIso η] : IsIso (η ▷ h) :=
247247
(whiskerRightIso (asIso η) h).isIso_hom
248248

249-
@[simp]
249+
@[simp, push]
250250
theorem inv_whiskerRight {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c) [IsIso η] :
251251
inv (η ▷ h) = inv η ▷ h := by
252252
apply IsIso.inv_eq_of_hom_inv_id

Mathlib/CategoryTheory/Comma/Basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,12 @@ instance [IsIso e] : IsIso e.left :=
180180
instance [IsIso e] : IsIso e.right :=
181181
(Comma.snd L R).map_isIso e
182182

183-
@[simp]
183+
@[simp, push ←]
184184
lemma inv_left [IsIso e] : (inv e).left = inv e.left := by
185185
apply IsIso.eq_inv_of_hom_inv_id
186186
rw [← Comma.comp_left, IsIso.hom_inv_id, id_left]
187187

188-
@[simp]
188+
@[simp, push ←]
189189
lemma inv_right [IsIso e] : (inv e).right = inv e.right := by
190190
apply IsIso.eq_inv_of_hom_inv_id
191191
rw [← Comma.comp_right, IsIso.hom_inv_id, id_right]

Mathlib/CategoryTheory/Iso.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,22 +358,22 @@ theorem inv_id : inv (𝟙 X) = 𝟙 X := by
358358
apply inv_eq_of_hom_inv_id
359359
simp
360360

361-
@[simp, reassoc]
361+
@[simp, reassoc, push]
362362
theorem inv_comp [IsIso f] [IsIso h] : inv (f ≫ h) = inv h ≫ inv f := by
363363
apply inv_eq_of_hom_inv_id
364364
simp
365365

366-
@[simp]
366+
@[simp, push]
367367
theorem inv_inv [IsIso f] : inv (inv f) = f := by
368368
apply inv_eq_of_hom_inv_id
369369
simp
370370

371-
@[simp]
371+
@[simp, push]
372372
theorem Iso.inv_inv (f : X ≅ Y) : inv f.inv = f.hom := by
373373
apply inv_eq_of_hom_inv_id
374374
simp
375375

376-
@[simp]
376+
@[simp, push]
377377
theorem Iso.inv_hom (f : X ≅ Y) : inv f.hom = f.inv := by
378378
apply inv_eq_of_hom_inv_id
379379
simp
@@ -561,7 +561,7 @@ theorem mapIso_refl (F : C ⥤ D) (X : C) : F.mapIso (Iso.refl X) = Iso.refl (F.
561561
instance map_isIso (F : C ⥤ D) (f : X ⟶ Y) [IsIso f] : IsIso (F.map f) :=
562562
(F.mapIso (asIso f)).isIso_hom
563563

564-
@[simp]
564+
@[simp, push ←]
565565
theorem map_inv (F : C ⥤ D) {X Y : C} (f : X ⟶ Y) [IsIso f] : F.map (inv f) = inv (F.map f) := by
566566
apply eq_inv_of_hom_inv_id
567567
simp [← F.map_comp]

Mathlib/CategoryTheory/Monoidal/Category.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def whiskerLeftIso (X : C) {Y Z : C} (f : Y ≅ Z) : X ⊗ Y ≅ X ⊗ Z where
357357
instance whiskerLeft_isIso (X : C) {Y Z : C} (f : Y ⟶ Z) [IsIso f] : IsIso (X ◁ f) :=
358358
(whiskerLeftIso X (asIso f)).isIso_hom
359359

360-
@[simp]
360+
@[simp, push]
361361
theorem inv_whiskerLeft (X : C) {Y Z : C} (f : Y ⟶ Z) [IsIso f] :
362362
inv (X ◁ f) = X ◁ inv f := by
363363
cat_disch
@@ -385,7 +385,7 @@ def whiskerRightIso {X Y : C} (f : X ≅ Y) (Z : C) : X ⊗ Z ≅ Y ⊗ Z where
385385
instance whiskerRight_isIso {X Y : C} (f : X ⟶ Y) (Z : C) [IsIso f] : IsIso (f ▷ Z) :=
386386
(whiskerRightIso (asIso f) Z).isIso_hom
387387

388-
@[simp]
388+
@[simp, push]
389389
theorem inv_whiskerRight {X Y : C} (f : X ⟶ Y) (Z : C) [IsIso f] :
390390
inv (f ▷ Z) = inv f ▷ Z := by
391391
cat_disch
@@ -429,7 +429,7 @@ theorem tensorIso_def' {X Y X' Y' : C} (f : X ≅ Y) (g : X' ≅ Y') :
429429
instance tensor_isIso {W X Y Z : C} (f : W ⟶ X) [IsIso f] (g : Y ⟶ Z) [IsIso g] : IsIso (f ⊗ₘ g) :=
430430
(asIso f ⊗ᵢ asIso g).isIso_hom
431431

432-
@[simp]
432+
@[simp, push]
433433
theorem inv_tensor {W X Y Z : C} (f : W ⟶ X) [IsIso f] (g : Y ⟶ Z) [IsIso g] :
434434
inv (f ⊗ₘ g) = inv f ⊗ₘ inv g := by
435435
simp [tensorHom_def, whisker_exchange]

Mathlib/CategoryTheory/NatIso.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ theorem naturality_2' (α : F ⟶ G) (f : X ⟶ Y) {_ : IsIso (α.app Y)} :
176176
instance isIso_app_of_isIso (α : F ⟶ G) [IsIso α] (X) : IsIso (α.app X) :=
177177
⟨⟨(inv α).app X, ⟨by grind, by grind⟩⟩⟩
178178

179-
@[simp]
180-
theorem isIso_inv_app (α : F ⟶ G) {_ : IsIso α} (X) : (inv α).app X = inv (α.app X) := by cat_disch
179+
@[simp, push ←]
180+
theorem isIso_inv_app (α : F ⟶ G) [IsIso α] (X) : (inv α).app X = inv (α.app X) := by cat_disch
181181

182182
@[simp]
183183
theorem inv_map_inv_app (F : C ⥤ D ⥤ E) {X Y : C} (e : X ≅ Y) (Z : D) :

Mathlib/CategoryTheory/Opposites.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ theorem isIso_unop_iff {X Y : Cᵒᵖ} (f : X ⟶ Y) : IsIso f.unop ↔ IsIso f
174174
instance isIso_unop {X Y : Cᵒᵖ} (f : X ⟶ Y) [IsIso f] : IsIso f.unop :=
175175
(isIso_unop_iff _).2 inferInstance
176176

177-
@[simp]
177+
@[simp, push ←]
178178
theorem op_inv {X Y : C} (f : X ⟶ Y) [IsIso f] : (inv f).op = inv f.op := by
179179
apply IsIso.eq_inv_of_hom_inv_id
180180
rw [← op_comp, IsIso.inv_hom_id, op_id]
181181

182-
@[simp]
182+
@[simp, push ←]
183183
theorem unop_inv {X Y : Cᵒᵖ} (f : X ⟶ Y) [IsIso f] : (inv f).unop = inv f.unop := by
184184
apply IsIso.eq_inv_of_hom_inv_id
185185
rw [← unop_comp, IsIso.inv_hom_id, unop_id]

0 commit comments

Comments
 (0)