2018-02-07 19:19:17 +00:00
|
|
|
|
{-# OPTIONS --cubical #-}
|
2018-02-05 13:59:53 +00:00
|
|
|
|
module Cat.Category.Functor where
|
2018-01-08 21:54:53 +00:00
|
|
|
|
|
|
|
|
|
open import Agda.Primitive
|
|
|
|
|
open import Cubical
|
|
|
|
|
open import Function
|
|
|
|
|
|
|
|
|
|
open import Cat.Category
|
|
|
|
|
|
2018-02-23 11:41:15 +00:00
|
|
|
|
open Category hiding (_∘_ ; raw ; IsIdentity)
|
2018-01-30 15:23:36 +00:00
|
|
|
|
|
2018-02-06 13:24:34 +00:00
|
|
|
|
module _ {ℓc ℓc' ℓd ℓd'}
|
|
|
|
|
(ℂ : Category ℓc ℓc')
|
|
|
|
|
(𝔻 : Category ℓd ℓd')
|
|
|
|
|
where
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
ℓ = ℓc ⊔ ℓc' ⊔ ℓd ⊔ ℓd'
|
|
|
|
|
𝓤 = Set ℓ
|
|
|
|
|
|
2018-03-05 09:28:16 +00:00
|
|
|
|
Omap = Object ℂ → Object 𝔻
|
|
|
|
|
Fmap : Omap → Set _
|
|
|
|
|
Fmap omap = ∀ {A B}
|
|
|
|
|
→ ℂ [ A , B ] → 𝔻 [ omap A , omap B ]
|
2018-02-06 13:24:34 +00:00
|
|
|
|
record RawFunctor : 𝓤 where
|
|
|
|
|
field
|
|
|
|
|
func* : Object ℂ → Object 𝔻
|
|
|
|
|
func→ : ∀ {A B} → ℂ [ A , B ] → 𝔻 [ func* A , func* B ]
|
|
|
|
|
|
2018-02-23 11:41:15 +00:00
|
|
|
|
IsIdentity : Set _
|
|
|
|
|
IsIdentity = {A : Object ℂ} → func→ (𝟙 ℂ {A}) ≡ 𝟙 𝔻 {func* A}
|
|
|
|
|
|
|
|
|
|
IsDistributive : Set _
|
|
|
|
|
IsDistributive = {A B C : Object ℂ} {f : ℂ [ A , B ]} {g : ℂ [ B , C ]}
|
|
|
|
|
→ func→ (ℂ [ g ∘ f ]) ≡ 𝔻 [ func→ g ∘ func→ f ]
|
|
|
|
|
|
2018-03-05 09:28:16 +00:00
|
|
|
|
-- | Equality principle for raw functors
|
|
|
|
|
--
|
|
|
|
|
-- The type of `func→` depend on the value of `func*`. We can wrap this up
|
|
|
|
|
-- into an equality principle for this type like is done for e.g. `Σ` using
|
|
|
|
|
-- `pathJ`.
|
|
|
|
|
module _ {x y : RawFunctor} where
|
|
|
|
|
open RawFunctor
|
|
|
|
|
private
|
|
|
|
|
P : (omap : Omap) → (eq : func* x ≡ omap) → Set _
|
|
|
|
|
P y eq = (fmap' : Fmap y) → (λ i → Fmap (eq i))
|
|
|
|
|
[ func→ x ≡ fmap' ]
|
|
|
|
|
module _
|
|
|
|
|
(eq : (λ i → Omap) [ func* x ≡ func* y ])
|
|
|
|
|
(kk : P (func* x) refl)
|
|
|
|
|
where
|
|
|
|
|
private
|
|
|
|
|
p : P (func* y) eq
|
|
|
|
|
p = pathJ P kk (func* y) eq
|
|
|
|
|
eq→ : (λ i → Fmap (eq i)) [ func→ x ≡ func→ y ]
|
|
|
|
|
eq→ = p (func→ y)
|
|
|
|
|
RawFunctor≡ : x ≡ y
|
|
|
|
|
func* (RawFunctor≡ i) = eq i
|
|
|
|
|
func→ (RawFunctor≡ i) = eq→ i
|
|
|
|
|
|
2018-02-06 13:24:34 +00:00
|
|
|
|
record IsFunctor (F : RawFunctor) : 𝓤 where
|
2018-02-23 11:21:16 +00:00
|
|
|
|
open RawFunctor F public
|
2018-01-30 15:23:36 +00:00
|
|
|
|
field
|
2018-03-07 14:23:07 +00:00
|
|
|
|
-- TODO Really ought to be preserves identity or something like this.
|
2018-02-23 11:53:35 +00:00
|
|
|
|
isIdentity : IsIdentity
|
|
|
|
|
isDistributive : IsDistributive
|
2018-01-30 15:23:36 +00:00
|
|
|
|
|
|
|
|
|
record Functor : Set (ℓc ⊔ ℓc' ⊔ ℓd ⊔ ℓd') where
|
|
|
|
|
field
|
2018-02-06 13:24:34 +00:00
|
|
|
|
raw : RawFunctor
|
|
|
|
|
{{isFunctor}} : IsFunctor raw
|
|
|
|
|
|
2018-02-23 11:21:16 +00:00
|
|
|
|
open IsFunctor isFunctor public
|
2018-02-06 13:24:34 +00:00
|
|
|
|
|
2018-01-25 11:11:50 +00:00
|
|
|
|
open Functor
|
|
|
|
|
|
2018-02-28 18:03:11 +00:00
|
|
|
|
EndoFunctor : ∀ {ℓa ℓb} (ℂ : Category ℓa ℓb) → Set _
|
|
|
|
|
EndoFunctor ℂ = Functor ℂ ℂ
|
|
|
|
|
|
2018-02-06 13:24:34 +00:00
|
|
|
|
module _
|
|
|
|
|
{ℓa ℓb : Level}
|
|
|
|
|
{ℂ 𝔻 : Category ℓa ℓb}
|
2018-02-23 09:36:59 +00:00
|
|
|
|
(F : RawFunctor ℂ 𝔻)
|
2018-02-06 13:24:34 +00:00
|
|
|
|
where
|
|
|
|
|
private
|
2018-02-23 15:41:17 +00:00
|
|
|
|
module 𝔻 = Category 𝔻
|
2018-02-06 13:24:34 +00:00
|
|
|
|
|
2018-02-20 13:08:47 +00:00
|
|
|
|
propIsFunctor : isProp (IsFunctor _ _ F)
|
|
|
|
|
propIsFunctor isF0 isF1 i = record
|
2018-02-23 11:51:44 +00:00
|
|
|
|
{ isIdentity = 𝔻.arrowsAreSets _ _ isF0.isIdentity isF1.isIdentity i
|
2018-02-23 11:53:35 +00:00
|
|
|
|
; isDistributive = 𝔻.arrowsAreSets _ _ isF0.isDistributive isF1.isDistributive i
|
2018-02-06 13:24:34 +00:00
|
|
|
|
}
|
|
|
|
|
where
|
|
|
|
|
module isF0 = IsFunctor isF0
|
|
|
|
|
module isF1 = IsFunctor isF1
|
|
|
|
|
|
2018-02-09 11:09:59 +00:00
|
|
|
|
-- Alternate version of above where `F` is indexed by an interval
|
2018-02-06 13:24:34 +00:00
|
|
|
|
module _
|
|
|
|
|
{ℓa ℓb : Level}
|
|
|
|
|
{ℂ 𝔻 : Category ℓa ℓb}
|
|
|
|
|
{F : I → RawFunctor ℂ 𝔻}
|
|
|
|
|
where
|
|
|
|
|
private
|
2018-02-23 15:41:17 +00:00
|
|
|
|
module 𝔻 = Category 𝔻
|
2018-02-06 13:24:34 +00:00
|
|
|
|
IsProp' : {ℓ : Level} (A : I → Set ℓ) → Set ℓ
|
|
|
|
|
IsProp' A = (a0 : A i0) (a1 : A i1) → A [ a0 ≡ a1 ]
|
2018-01-30 15:23:36 +00:00
|
|
|
|
|
2018-02-07 19:19:17 +00:00
|
|
|
|
IsFunctorIsProp' : IsProp' λ i → IsFunctor _ _ (F i)
|
|
|
|
|
IsFunctorIsProp' isF0 isF1 = lemPropF {B = IsFunctor ℂ 𝔻}
|
2018-02-23 09:36:59 +00:00
|
|
|
|
(\ F → propIsFunctor F) (\ i → F i)
|
2018-02-07 19:19:17 +00:00
|
|
|
|
where
|
2018-02-16 10:36:44 +00:00
|
|
|
|
open import Cubical.NType.Properties using (lemPropF)
|
2018-01-30 15:23:36 +00:00
|
|
|
|
|
2018-02-06 13:24:34 +00:00
|
|
|
|
module _ {ℓ ℓ' : Level} {ℂ 𝔻 : Category ℓ ℓ'} where
|
2018-01-25 11:11:50 +00:00
|
|
|
|
Functor≡ : {F G : Functor ℂ 𝔻}
|
2018-03-05 09:28:16 +00:00
|
|
|
|
→ raw F ≡ raw G
|
|
|
|
|
→ F ≡ G
|
2018-03-05 16:10:41 +00:00
|
|
|
|
raw (Functor≡ eq i) = eq i
|
|
|
|
|
isFunctor (Functor≡ {F} {G} eq i)
|
2018-03-05 09:28:16 +00:00
|
|
|
|
= res i
|
|
|
|
|
where
|
|
|
|
|
res : (λ i → IsFunctor ℂ 𝔻 (eq i)) [ isFunctor F ≡ isFunctor G ]
|
|
|
|
|
res = IsFunctorIsProp' (isFunctor F) (isFunctor G)
|
|
|
|
|
|
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-02-06 13:24:34 +00:00
|
|
|
|
F* = func* F
|
|
|
|
|
F→ = func→ F
|
|
|
|
|
G* = func* G
|
|
|
|
|
G→ = func→ G
|
2018-02-05 11:21:39 +00:00
|
|
|
|
module _ {a0 a1 a2 : Object A} {α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 ⟩
|
2018-02-23 11:53:35 +00:00
|
|
|
|
F→ (G→ (A [ α1 ∘ α0 ])) ≡⟨ cong F→ (isDistributive G) ⟩
|
|
|
|
|
F→ (B [ G→ α1 ∘ G→ α0 ]) ≡⟨ isDistributive F ⟩
|
2018-01-30 17:26:11 +00:00
|
|
|
|
C [ (F→ ∘ G→) α1 ∘ (F→ ∘ G→) α0 ] ∎
|
2018-01-08 21:54:53 +00:00
|
|
|
|
|
2018-02-06 13:24:34 +00:00
|
|
|
|
_∘fr_ : RawFunctor A C
|
|
|
|
|
RawFunctor.func* _∘fr_ = F* ∘ G*
|
|
|
|
|
RawFunctor.func→ _∘fr_ = F→ ∘ G→
|
|
|
|
|
instance
|
|
|
|
|
isFunctor' : IsFunctor A C _∘fr_
|
|
|
|
|
isFunctor' = record
|
2018-02-23 11:49:41 +00:00
|
|
|
|
{ isIdentity = begin
|
2018-02-05 11:21:39 +00:00
|
|
|
|
(F→ ∘ G→) (𝟙 A) ≡⟨ refl ⟩
|
2018-02-23 11:49:41 +00:00
|
|
|
|
F→ (G→ (𝟙 A)) ≡⟨ cong F→ (isIdentity G)⟩
|
|
|
|
|
F→ (𝟙 B) ≡⟨ isIdentity F ⟩
|
2018-02-05 11:21:39 +00:00
|
|
|
|
𝟙 C ∎
|
2018-02-23 11:53:35 +00:00
|
|
|
|
; isDistributive = dist
|
2018-01-30 15:23:36 +00:00
|
|
|
|
}
|
2018-02-06 13:24:34 +00:00
|
|
|
|
|
2018-02-24 11:55:08 +00:00
|
|
|
|
F[_∘_] : Functor A C
|
2018-02-24 11:52:16 +00:00
|
|
|
|
raw F[_∘_] = _∘fr_
|
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
|
2018-02-06 13:24:34 +00:00
|
|
|
|
{ raw = record
|
|
|
|
|
{ func* = λ x → x
|
|
|
|
|
; func→ = λ x → x
|
|
|
|
|
}
|
2018-01-30 15:23:36 +00:00
|
|
|
|
; isFunctor = record
|
2018-02-23 11:49:41 +00:00
|
|
|
|
{ isIdentity = refl
|
2018-02-23 11:53:35 +00:00
|
|
|
|
; isDistributive = refl
|
2018-01-30 15:23:36 +00:00
|
|
|
|
}
|
2018-01-15 15:13:23 +00:00
|
|
|
|
}
|