2018-01-08 21:54:53 +00:00
|
|
|
|
module Cat.Functor where
|
|
|
|
|
|
|
|
|
|
open import Agda.Primitive
|
|
|
|
|
open import Cubical
|
|
|
|
|
open import Function
|
|
|
|
|
|
|
|
|
|
open import Cat.Category
|
|
|
|
|
|
2018-01-21 00:11:08 +00:00
|
|
|
|
record Functor {ℓc ℓc' ℓd ℓd'} (C : Category ℓc ℓc') (D : Category ℓd ℓd')
|
2018-01-08 21:54:53 +00:00
|
|
|
|
: Set (ℓc ⊔ ℓc' ⊔ ℓd ⊔ ℓd') where
|
2018-01-22 10:35:37 +00:00
|
|
|
|
open Category
|
2018-01-08 21:54:53 +00:00
|
|
|
|
field
|
2018-01-22 10:35:37 +00:00
|
|
|
|
func* : C .Object → D .Object
|
|
|
|
|
func→ : {dom cod : C .Object} → C .Arrow dom cod → D .Arrow (func* dom) (func* cod)
|
|
|
|
|
ident : { c : C .Object } → func→ (C .𝟙 {c}) ≡ D .𝟙 {func* c}
|
2018-01-08 21:54:53 +00:00
|
|
|
|
-- TODO: Avoid use of ugly explicit arguments somehow.
|
|
|
|
|
-- This guy managed to do it:
|
|
|
|
|
-- https://github.com/copumpkin/categories/blob/master/Categories/Functor/Core.agda
|
2018-01-22 10:35:37 +00:00
|
|
|
|
distrib : { c c' c'' : C .Object} {a : C .Arrow c c'} {a' : C .Arrow c' c''}
|
|
|
|
|
→ func→ (C ._⊕_ a' a) ≡ D ._⊕_ (func→ a') (func→ a)
|
2018-01-08 21:54:53 +00:00
|
|
|
|
|
2018-01-25 11:11:50 +00:00
|
|
|
|
open Functor
|
|
|
|
|
open Category
|
|
|
|
|
|
|
|
|
|
module _ {ℓ ℓ' : Level} {ℂ 𝔻 : Category ℓ ℓ'} where
|
|
|
|
|
private
|
|
|
|
|
_ℂ⊕_ = ℂ ._⊕_
|
|
|
|
|
Functor≡ : {F G : Functor ℂ 𝔻}
|
|
|
|
|
→ (eq* : F .func* ≡ G .func*)
|
|
|
|
|
→ (eq→ : PathP (λ i → ∀ {x y} → ℂ .Arrow x y → 𝔻 .Arrow (eq* i x) (eq* i y))
|
2018-01-25 11:44:47 +00:00
|
|
|
|
(F .func→) (G .func→))
|
2018-01-25 11:11:50 +00:00
|
|
|
|
→ (eqI : PathP (λ i → ∀ {A : ℂ .Object} → eq→ i (ℂ .𝟙 {A}) ≡ 𝔻 .𝟙 {eq* i A})
|
2018-01-25 11:44:47 +00:00
|
|
|
|
(ident F) (ident G))
|
2018-01-25 11:11:50 +00:00
|
|
|
|
→ (eqD : PathP (λ i → {A B C : ℂ .Object} {f : ℂ .Arrow A B} {g : ℂ .Arrow B C}
|
2018-01-25 11:44:47 +00:00
|
|
|
|
→ eq→ i (ℂ ._⊕_ g f) ≡ 𝔻 ._⊕_ (eq→ i g) (eq→ i f))
|
|
|
|
|
(distrib F) (distrib G))
|
2018-01-25 11:11:50 +00:00
|
|
|
|
→ F ≡ G
|
|
|
|
|
Functor≡ eq* eq→ eqI eqD i = record { func* = eq* i ; func→ = eq→ i ; ident = eqI i ; distrib = eqD i }
|
|
|
|
|
|
2018-01-21 00:11:08 +00:00
|
|
|
|
module _ {ℓ ℓ' : Level} {A B C : Category ℓ ℓ'} (F : Functor B C) (G : Functor A B) where
|
2018-01-08 21:54:53 +00:00
|
|
|
|
private
|
2018-01-21 14:19:15 +00:00
|
|
|
|
F* = F .func*
|
|
|
|
|
F→ = F .func→
|
|
|
|
|
G* = G .func*
|
|
|
|
|
G→ = G .func→
|
|
|
|
|
_A⊕_ = A ._⊕_
|
|
|
|
|
_B⊕_ = B ._⊕_
|
|
|
|
|
_C⊕_ = C ._⊕_
|
|
|
|
|
module _ {a0 a1 a2 : A .Object} {α0 : A .Arrow a0 a1} {α1 : A .Arrow a1 a2} where
|
2018-01-08 21:54:53 +00:00
|
|
|
|
|
2018-01-21 14:19:15 +00:00
|
|
|
|
dist : (F→ ∘ G→) (α1 A⊕ α0) ≡ (F→ ∘ G→) α1 C⊕ (F→ ∘ G→) α0
|
2018-01-08 21:54:53 +00:00
|
|
|
|
dist = begin
|
2018-01-21 14:19:15 +00:00
|
|
|
|
(F→ ∘ G→) (α1 A⊕ α0) ≡⟨ refl ⟩
|
|
|
|
|
F→ (G→ (α1 A⊕ α0)) ≡⟨ cong F→ (G .distrib)⟩
|
|
|
|
|
F→ ((G→ α1) B⊕ (G→ α0)) ≡⟨ F .distrib ⟩
|
|
|
|
|
(F→ ∘ G→) α1 C⊕ (F→ ∘ G→) α0 ∎
|
2018-01-08 21:54:53 +00:00
|
|
|
|
|
2018-01-21 14:21:50 +00:00
|
|
|
|
_∘f_ : Functor A C
|
|
|
|
|
_∘f_ =
|
2018-01-08 21:54:53 +00:00
|
|
|
|
record
|
|
|
|
|
{ func* = F* ∘ G*
|
|
|
|
|
; func→ = F→ ∘ G→
|
|
|
|
|
; ident = begin
|
2018-01-21 14:19:15 +00:00
|
|
|
|
(F→ ∘ G→) (A .𝟙) ≡⟨ refl ⟩
|
|
|
|
|
F→ (G→ (A .𝟙)) ≡⟨ cong F→ (G .ident)⟩
|
|
|
|
|
F→ (B .𝟙) ≡⟨ F .ident ⟩
|
|
|
|
|
C .𝟙 ∎
|
2018-01-08 21:54:53 +00:00
|
|
|
|
; distrib = dist
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-- The identity functor
|
2018-01-21 00:11:08 +00:00
|
|
|
|
identity : ∀ {ℓ ℓ'} → {C : Category ℓ ℓ'} → Functor C C
|
2018-01-15 15:13:23 +00:00
|
|
|
|
identity = record
|
|
|
|
|
{ func* = λ x → x
|
|
|
|
|
; func→ = λ x → x
|
|
|
|
|
; ident = refl
|
|
|
|
|
; distrib = refl
|
|
|
|
|
}
|