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-30 18:19:16 +00:00
|
|
|
|
open Category hiding (_∘_)
|
2018-01-30 15:23:36 +00:00
|
|
|
|
|
|
|
|
|
module _ {ℓc ℓc' ℓd ℓd'} (ℂ : Category ℓc ℓc') (𝔻 : Category ℓd ℓd') where
|
|
|
|
|
record IsFunctor
|
|
|
|
|
(func* : ℂ .Object → 𝔻 .Object)
|
2018-01-30 17:26:11 +00:00
|
|
|
|
(func→ : {A B : ℂ .Object} → ℂ [ A , B ] → 𝔻 [ func* A , func* B ])
|
|
|
|
|
: Set (ℓc ⊔ ℓc' ⊔ ℓd ⊔ ℓd') where
|
2018-01-30 15:23:36 +00:00
|
|
|
|
field
|
|
|
|
|
ident : { c : ℂ .Object } → func→ (ℂ .𝟙 {c}) ≡ 𝔻 .𝟙 {func* c}
|
|
|
|
|
-- 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-30 17:26:11 +00:00
|
|
|
|
distrib : {A B C : ℂ .Object} {f : ℂ [ A , B ]} {g : ℂ [ B , C ]}
|
|
|
|
|
→ func→ (ℂ [ g ∘ f ]) ≡ 𝔻 [ func→ g ∘ func→ f ]
|
2018-01-30 15:23:36 +00:00
|
|
|
|
|
|
|
|
|
record Functor : Set (ℓc ⊔ ℓc' ⊔ ℓd ⊔ ℓd') where
|
|
|
|
|
field
|
|
|
|
|
func* : ℂ .Object → 𝔻 .Object
|
2018-01-30 17:26:11 +00:00
|
|
|
|
func→ : ∀ {A B} → ℂ [ A , B ] → 𝔻 [ func* A , func* B ]
|
2018-01-30 15:23:36 +00:00
|
|
|
|
{{isFunctor}} : IsFunctor func* func→
|
2018-01-08 21:54:53 +00:00
|
|
|
|
|
2018-01-30 15:23:36 +00:00
|
|
|
|
open IsFunctor
|
2018-01-25 11:11:50 +00:00
|
|
|
|
open Functor
|
|
|
|
|
|
|
|
|
|
module _ {ℓ ℓ' : Level} {ℂ 𝔻 : Category ℓ ℓ'} where
|
2018-01-30 15:23:36 +00:00
|
|
|
|
|
2018-01-30 21:41:18 +00:00
|
|
|
|
IsFunctor≡
|
|
|
|
|
: {func* : ℂ .Object → 𝔻 .Object}
|
|
|
|
|
{func→ : {A B : ℂ .Object} → ℂ .Arrow A B → 𝔻 .Arrow (func* A) (func* B)}
|
|
|
|
|
{F G : IsFunctor ℂ 𝔻 func* func→}
|
|
|
|
|
→ (eqI
|
|
|
|
|
: (λ i → ∀ {A} → func→ (ℂ .𝟙 {A}) ≡ 𝔻 .𝟙 {func* A})
|
|
|
|
|
[ F .ident ≡ G .ident ])
|
|
|
|
|
→ (eqD :
|
|
|
|
|
(λ i → ∀ {A B C} {f : ℂ [ A , B ]} {g : ℂ [ B , C ]}
|
|
|
|
|
→ func→ (ℂ [ g ∘ f ]) ≡ 𝔻 [ func→ g ∘ func→ f ])
|
|
|
|
|
[ F .distrib ≡ G .distrib ])
|
|
|
|
|
→ (λ _ → IsFunctor ℂ 𝔻 (λ i → func* i) func→) [ F ≡ G ]
|
|
|
|
|
IsFunctor≡ eqI eqD i = record { ident = eqI i ; distrib = eqD i }
|
2018-01-30 15:23:36 +00:00
|
|
|
|
|
2018-01-25 11:11:50 +00:00
|
|
|
|
Functor≡ : {F G : Functor ℂ 𝔻}
|
|
|
|
|
→ (eq* : F .func* ≡ G .func*)
|
2018-01-31 13:39:54 +00:00
|
|
|
|
→ (eq→ : (λ i → ∀ {x y} → ℂ [ x , y ] → 𝔻 [ eq* i x , eq* i y ])
|
|
|
|
|
[ F .func→ ≡ G .func→ ])
|
2018-01-30 15:23:36 +00:00
|
|
|
|
-- → (eqIsF : PathP (λ i → IsFunctor ℂ 𝔻 (eq* i) (eq→ i)) (F .isFunctor) (G .isFunctor))
|
2018-01-30 21:41:18 +00:00
|
|
|
|
→ (eqIsFunctor : (λ i → IsFunctor ℂ 𝔻 (eq* i) (eq→ i)) [ F .isFunctor ≡ G .isFunctor ])
|
2018-01-25 11:11:50 +00:00
|
|
|
|
→ F ≡ G
|
2018-01-30 21:41:18 +00:00
|
|
|
|
Functor≡ eq* eq→ eqIsFunctor i = record { func* = eq* i ; func→ = eq→ i ; isFunctor = eqIsFunctor i }
|
2018-01-25 11:11:50 +00:00
|
|
|
|
|
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→
|
2018-01-30 17:26:11 +00:00
|
|
|
|
module _ {a0 a1 a2 : A .Object} {α0 : A [ a0 , a1 ]} {α1 : A [ a1 , a2 ]} where
|
2018-01-08 21:54:53 +00:00
|
|
|
|
|
2018-01-30 17:26:11 +00:00
|
|
|
|
dist : (F→ ∘ G→) (A [ α1 ∘ α0 ]) ≡ C [ (F→ ∘ G→) α1 ∘ (F→ ∘ G→) α0 ]
|
2018-01-08 21:54:53 +00:00
|
|
|
|
dist = begin
|
2018-01-30 17:26:11 +00:00
|
|
|
|
(F→ ∘ G→) (A [ α1 ∘ α0 ]) ≡⟨ refl ⟩
|
|
|
|
|
F→ (G→ (A [ α1 ∘ α0 ])) ≡⟨ cong F→ (G .isFunctor .distrib)⟩
|
|
|
|
|
F→ (B [ G→ α1 ∘ G→ α0 ]) ≡⟨ F .isFunctor .distrib ⟩
|
|
|
|
|
C [ (F→ ∘ G→) α1 ∘ (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→
|
2018-01-30 15:23:36 +00:00
|
|
|
|
; isFunctor = record
|
|
|
|
|
{ ident = begin
|
|
|
|
|
(F→ ∘ G→) (A .𝟙) ≡⟨ refl ⟩
|
|
|
|
|
F→ (G→ (A .𝟙)) ≡⟨ cong F→ (G .isFunctor .ident)⟩
|
|
|
|
|
F→ (B .𝟙) ≡⟨ F .isFunctor .ident ⟩
|
|
|
|
|
C .𝟙 ∎
|
|
|
|
|
; distrib = dist
|
|
|
|
|
}
|
2018-01-08 21:54:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-- 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
|
2018-01-30 15:23:36 +00:00
|
|
|
|
; isFunctor = record
|
|
|
|
|
{ ident = refl
|
|
|
|
|
; distrib = refl
|
|
|
|
|
}
|
2018-01-15 15:13:23 +00:00
|
|
|
|
}
|