Setoid.Categories.NaturalTransformation¶
Natural transformations between minimal functors¶
This is the Setoid.Categories.NaturalTransformation module of the Agda Universal Algebra Library.
A natural transformation is the third rung of the basic category-theory ladder, after
Category and Functor, and it
is the notion category theory was invented to make precise. Where a functor F : š ā¶ š
translates one mathematical world into another, a natural transformation compares two such
translations F, G : š ā¶ š: it assigns to every object A of š a š-morphism
component A : Fā A ā¶ Gā A, in a way that is uniform in A.
Uniformity is the entire content of the definition. The components must not be ad-hoc
choices made object by object; they must commute with every morphism of š, which the
natural field states as the famous naturality square: for each
f : A ā¶ B in š,
component A
Fā A āāāāāāāāāāāāāāāā Gā A
ā ā
Fā f ā ā Gā f
ā ā
Fā B āāāāāāāāāāāāāāāā Gā B
component B
both ways around the square are the same š-morphism ā component B ā Fā f equals
Gā f ā component A ā up to the target category's hom-equality _ā_. Intuitively:
first translate by F and then convert to G, or convert first and then translate by
G; naturality says it cannot matter. A family of maps with this property is exactly
what a working mathematician means by a construction that "requires no arbitrary
choices."
The library has already met this notion twice, componentwise:
- A signature morphism
Ļ : šā ā šāinduces the familyā¦ Ļ ā§ A : ⨠šā ā© A ⶠ⨠šā ā© Aof Setoid.Signatures.Functor, whose naturality square (naturality) commutes byrefl;reductprecomposes this family into an algebra's structure map. - An adjunction carries two natural families, its
unitandcounit(Setoid.Categories.Adjunction), each with its naturality square recorded as a field.
This record packages the pattern once, so that constructions which consume a natural
transformation whole ā the Monad record of M4-5e is the
inaugural consumer ā can take one argument instead of a component family and a square.
Where a componentwise rendering already is the canonical form (the Adjunction fields,
the ā¦_ā§ family), it stays canonical; this record is the bundled view, not a
replacement. (Adjunction derives unitNT / counitNT views for free.)
As with the rest of the layer (ADR-006), the record is minimal and self-contained ā no
agda-categories dependency ā and every law is stated against the target category's
hom-equality field _ā_, so categories with pointwise hom-setoids (the algebra
categories Alg) prove naturality pointwise, with no
function extensionality.
The record¶
A NaturalTransformation F G consists of the component family and its naturality
square. The components live in the target category š, and so does the equality in
which the square commutes.
record NaturalTransformation {š : Category o ā e} {š : Category oā² āā² eā²} (F G : Functor š š) : Type (o ā ā ā āā² ā eā²) where open Category š renaming ( Obj to šā ; Hom to š[_,_] ) open Category š renaming ( Hom to š[_,_] ; _ā_ to _āį“°_ ; _ā_ to _āį“°_ ) open Functor F renaming ( Fā to Fā ; Fā to Fā ) open Functor G renaming ( Fā to Gā ; Fā to Gā ) field -- One š-morphism per š-object: the A-th component Fā A ā¶ Gā A. component : (A : šā) ā š[ Fā A , Gā A ] -- The naturality square: the components commute with the image of -- every š-morphism, in the hom-equality of š. natural : {A B : šā} (f : š[ A , B ]) ā component B āį“° Fā f āį“° Gā f āį“° component A
A small dictionary for readers coming from the classical literature: what is written
Ī· : F ā¹ G with components Ī·_A and square Ī·_B ā F f = G f ā Ī·_A appears here as
Ī· : NaturalTransformation F G with component Ī· A and natural Ī· f. Vertical and
horizontal composition of natural transformations are not defined yet; per the
library's two-consumer rule they will be added when a second construction needs them
(the Monad laws below need only the components, which is
also why the monad laws there are stated componentwise).