Skip to content

Commit cdb6f72

Browse files
committed
feat(CategoryTheory/NatTrans): use to_dual (#33834)
This PR tags `NatTrans` with `to_dual`. The two functor arguments get swapped because the underlying `NatTrans.app` has its direction swapped. Translating the `naturality` field is slightly awkward. We need to define a constant `naturality'` (analogously to `Category.assoc')
1 parent 0fcc195 commit cdb6f72

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Mathlib/CategoryTheory/NatTrans.lean

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,25 @@ The field `app` provides the components of the natural transformation.
4848
4949
Naturality is expressed by `α.naturality`.
5050
-/
51-
@[ext]
51+
@[ext, to_dual self (reorder := F G)]
5252
structure NatTrans (F G : C ⥤ D) : Type max u₁ v₂ where
5353
/-- The component of a natural transformation. -/
54-
app : ∀ X : C, F.obj X ⟶ G.obj X
54+
app (X : C) : F.obj X ⟶ G.obj X
5555
/-- The naturality square for a given morphism. -/
56-
naturality : ∀ ⦃X Y : C⦄ (f : X ⟶ Y), F.map f ≫ app Y = app X ≫ G.map f := by cat_disch
56+
naturality ⦃X Y : C⦄ (f : X ⟶ Y) : F.map f ≫ app Y = app X ≫ G.map f := by cat_disch
57+
58+
set_option linter.translateOverwrite false in
59+
@[to_dual existing naturality]
60+
lemma NatTrans.naturality' {F G : C ⥤ D} (self : NatTrans G F) ⦃X Y : C⦄ (f : Y ⟶ X) :
61+
self.app Y ≫ F.map f = G.map f ≫ self.app X := (self.naturality f).symm
5762

5863
-- Rather arbitrarily, we say that the 'simpler' form is
5964
-- components of natural transformations moving earlier.
6065
attribute [reassoc (attr := simp)] NatTrans.naturality
6166

6267
attribute [grind _=_] NatTrans.naturality
6368

69+
@[to_dual self]
6470
theorem congr_app {F G : C ⥤ D} {α β : NatTrans F G} (h : α = β) (X : C) : α.app X = β.app X := by
6571
cat_disch
6672

@@ -83,11 +89,13 @@ section
8389
variable {F G H : C ⥤ D}
8490

8591
/-- `vcomp α β` is the vertical compositions of natural transformations. -/
92+
@[to_dual self (reorder := F H, α β)]
8693
def vcomp (α : NatTrans F G) (β : NatTrans G H) : NatTrans F H where
8794
app X := α.app X ≫ β.app X
8895

8996
-- functor_category will rewrite (vcomp α β) to (α ≫ β), so this is not a
9097
-- suitable simp lemma. We will declare the variant vcomp_app' there.
98+
@[to_dual self]
9199
theorem vcomp_app (α : NatTrans F G) (β : NatTrans G H) (X : C) :
92100
(vcomp α β).app X = α.app X ≫ β.app X := rfl
93101

0 commit comments

Comments
 (0)