Skip to content

Commit 424cfe2

Browse files
Merge pull request #462 from agda/naturaltransformations-end
The set of natural transformations between two functors is an end
2 parents 38b96b2 + f6b517b commit 424cfe2

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{-# OPTIONS --without-K --safe #-}
2+
3+
open import Categories.Category using (Category)
4+
open import Categories.Functor using (Functor)
5+
6+
open import Level
7+
8+
module Categories.Diagram.End.Instance.NaturalTransformations
9+
{o ℓ e o′ ℓ′ e′}
10+
{C : Category o ℓ e}
11+
{D : Category o′ (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) (o ⊔ e′)}
12+
(F G : Functor C D)
13+
where
14+
15+
open import Categories.Category.Construction.Functors using (Functors)
16+
open import Categories.Diagram.End using (End)
17+
open import Categories.Diagram.Wedge using (Wedge)
18+
open import Categories.Functor.Bifunctor using (reduce-×)
19+
open import Categories.Functor.Hom using (Hom[_][-,-]; Hom[_][_,_])
20+
open import Categories.Morphism.Reasoning D
21+
open import Categories.NaturalTransformation using (NaturalTransformation)
22+
23+
open import Function.Bundles using (Func; _⟨$⟩_)
24+
25+
private
26+
module F = Functor F
27+
module G = Functor G
28+
29+
open Category C using (id)
30+
open Category D hiding (id)
31+
open HomReasoning
32+
open NaturalTransformation
33+
open Wedge
34+
35+
-- For appropriately sized categories, the set of natural
36+
-- transformations from F to G forms the end ∫ₓ F x ⇒ G x
37+
-- This is Theorem 1.4.1 of Coend calculus
38+
39+
naturalTransformations : End (reduce-× Hom[ D ][-,-] F.op G)
40+
naturalTransformations = record
41+
{ wedge = record
42+
{ E = Hom[ Functors C D ][ F , G ]
43+
; dinatural = record
44+
{ α = λ X record
45+
{ to = λ nt η nt X
46+
; cong = λ eq eq
47+
}
48+
; commute = λ {X Y} f {nt} begin
49+
G.₁ f ∘ η nt X ∘ F.₁ id ≈⟨ refl⟩∘⟨ elimʳ F.identity ⟩
50+
G.₁ f ∘ η nt X ≈⟨ sym-commute nt f ⟩
51+
η nt Y ∘ F.₁ f ≈⟨ pushˡ (introˡ G.identity) ⟩
52+
G.₁ id ∘ η nt Y ∘ F.₁ f ∎
53+
; op-commute = λ {X Y} f {nt} begin
54+
G.₁ id ∘ η nt Y ∘ F.₁ f ≈⟨ pullˡ (elimˡ G.identity) ⟩
55+
η nt Y ∘ F.₁ f ≈⟨ commute nt f ⟩
56+
G.₁ f ∘ η nt X ≈⟨ refl⟩∘⟨ introʳ F.identity ⟩
57+
G.₁ f ∘ η nt X ∘ F.₁ id ∎
58+
}
59+
}
60+
; factor = λ W record
61+
{ to = λ e record
62+
{ η = λ X dinatural.α W X ⟨$⟩ e
63+
; commute = λ {X Y} f begin
64+
(dinatural.α W Y ⟨$⟩ e) ∘ F.₁ f ≈⟨ pushˡ (introˡ G.identity) ⟩
65+
G.₁ id ∘ (dinatural.α W Y ⟨$⟩ e) ∘ F.₁ f ≈⟨ dinatural.op-commute W f ⟩
66+
G.₁ f ∘ (dinatural.α W X ⟨$⟩ e) ∘ F.₁ id ≈⟨ refl⟩∘⟨ elimʳ F.identity ⟩
67+
G.₁ f ∘ (dinatural.α W X ⟨$⟩ e) ∎
68+
; sym-commute = λ {X Y} f begin
69+
G.₁ f ∘ (dinatural.α W X ⟨$⟩ e) ≈⟨ refl⟩∘⟨ introʳ F.identity ⟩
70+
G.₁ f ∘ (dinatural.α W X ⟨$⟩ e) ∘ F.₁ id ≈⟨ dinatural.commute W f ⟩
71+
G.₁ id ∘ (dinatural.α W Y ⟨$⟩ e) ∘ F.₁ f ≈⟨ pullˡ (elimˡ G.identity) ⟩
72+
(dinatural.α W Y ⟨$⟩ e) ∘ F.₁ f ∎
73+
}
74+
; cong = λ eq Func.cong (dinatural.α W _) eq
75+
}
76+
; universal = Equiv.refl
77+
; unique = λ eq Equiv.sym eq
78+
}

0 commit comments

Comments
 (0)