Refactor Functor - only in module Functor
This commit is contained in:
parent
a27292dd53
commit
9349b37550
|
@ -14,6 +14,9 @@ module _ {ℓc ℓc' ℓd ℓd' : Level} {ℂ : Category ℓc ℓc'} {𝔻 : Cat
|
||||||
open Functor
|
open Functor
|
||||||
|
|
||||||
module _ (F G : Functor ℂ 𝔻) where
|
module _ (F G : Functor ℂ 𝔻) where
|
||||||
|
private
|
||||||
|
module F = Functor F
|
||||||
|
module G = Functor G
|
||||||
-- What do you call a non-natural tranformation?
|
-- What do you call a non-natural tranformation?
|
||||||
Transformation : Set (ℓc ⊔ ℓd')
|
Transformation : Set (ℓc ⊔ ℓd')
|
||||||
Transformation = (C : Object ℂ) → 𝔻 [ F.func* C , G.func* C ]
|
Transformation = (C : Object ℂ) → 𝔻 [ F.func* C , G.func* C ]
|
||||||
|
@ -30,8 +33,7 @@ module _ {ℓc ℓc' ℓd ℓd' : Level} {ℂ : Category ℓc ℓc'} {𝔻 : Cat
|
||||||
-- NaturalTranformation : Set (ℓc ⊔ (ℓc' ⊔ ℓd'))
|
-- NaturalTranformation : Set (ℓc ⊔ (ℓc' ⊔ ℓd'))
|
||||||
-- NaturalTranformation = ∀ (θ : Transformation) {A B : ℂ .Object} → (f : ℂ .Arrow A B) → 𝔻 ._⊕_ (θ B) (F .func→ f) ≡ 𝔻 ._⊕_ (G .func→ f) (θ A)
|
-- NaturalTranformation = ∀ (θ : Transformation) {A B : ℂ .Object} → (f : ℂ .Arrow A B) → 𝔻 ._⊕_ (θ B) (F .func→ f) ≡ 𝔻 ._⊕_ (G .func→ f) (θ A)
|
||||||
|
|
||||||
module _ {F G : Functor ℂ 𝔻} where
|
NaturalTransformation≡ : {α β : NaturalTransformation}
|
||||||
NaturalTransformation≡ : {α β : NaturalTransformation F G}
|
|
||||||
→ (eq₁ : α .proj₁ ≡ β .proj₁)
|
→ (eq₁ : α .proj₁ ≡ β .proj₁)
|
||||||
→ (eq₂ : PathP
|
→ (eq₂ : PathP
|
||||||
(λ i → {A B : Object ℂ} (f : ℂ [ A , B ])
|
(λ i → {A B : Object ℂ} (f : ℂ [ A , B ])
|
||||||
|
@ -52,6 +54,7 @@ module _ {ℓc ℓc' ℓd ℓd' : Level} {ℂ : Category ℓc ℓc'} {𝔻 : Cat
|
||||||
𝔻 [ F→ f ∘ 𝟙 𝔻 ] ≡⟨⟩
|
𝔻 [ F→ f ∘ 𝟙 𝔻 ] ≡⟨⟩
|
||||||
𝔻 [ F→ f ∘ identityTrans F A ] ∎
|
𝔻 [ F→ f ∘ identityTrans F A ] ∎
|
||||||
where
|
where
|
||||||
|
module F = Functor F
|
||||||
F→ = F.func→
|
F→ = F.func→
|
||||||
module 𝔻 = IsCategory (isCategory 𝔻)
|
module 𝔻 = IsCategory (isCategory 𝔻)
|
||||||
|
|
||||||
|
@ -60,6 +63,9 @@ module _ {ℓc ℓc' ℓd ℓd' : Level} {ℂ : Category ℓc ℓc'} {𝔻 : Cat
|
||||||
|
|
||||||
module _ {F G H : Functor ℂ 𝔻} where
|
module _ {F G H : Functor ℂ 𝔻} where
|
||||||
private
|
private
|
||||||
|
module F = Functor F
|
||||||
|
module G = Functor G
|
||||||
|
module H = Functor H
|
||||||
_∘nt_ : Transformation G H → Transformation F G → Transformation F H
|
_∘nt_ : Transformation G H → Transformation F G → Transformation F H
|
||||||
(θ ∘nt η) C = 𝔻 [ θ C ∘ η C ]
|
(θ ∘nt η) C = 𝔻 [ θ C ∘ η C ]
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,10 @@ Representable {ℓ' = ℓ'} ℂ = Functor ℂ (Sets {ℓ'})
|
||||||
-- The "co-yoneda" embedding.
|
-- The "co-yoneda" embedding.
|
||||||
representable : ∀ {ℓ ℓ'} {ℂ : Category ℓ ℓ'} → Category.Object ℂ → Representable ℂ
|
representable : ∀ {ℓ ℓ'} {ℂ : Category ℓ ℓ'} → Category.Object ℂ → Representable ℂ
|
||||||
representable {ℂ = ℂ} A = record
|
representable {ℂ = ℂ} A = record
|
||||||
|
{ raw = record
|
||||||
{ func* = λ B → ℂ [ A , B ]
|
{ func* = λ B → ℂ [ A , B ]
|
||||||
; func→ = ℂ [_∘_]
|
; func→ = ℂ [_∘_]
|
||||||
|
}
|
||||||
; isFunctor = record
|
; isFunctor = record
|
||||||
{ ident = funExt λ _ → proj₂ ident
|
{ ident = funExt λ _ → proj₂ ident
|
||||||
; distrib = funExt λ x → sym assoc
|
; distrib = funExt λ x → sym assoc
|
||||||
|
@ -73,8 +75,10 @@ Presheaf {ℓ' = ℓ'} ℂ = Functor (Opposite ℂ) (Sets {ℓ'})
|
||||||
-- Alternate name: `yoneda`
|
-- Alternate name: `yoneda`
|
||||||
presheaf : {ℓ ℓ' : Level} {ℂ : Category ℓ ℓ'} → Category.Object (Opposite ℂ) → Presheaf ℂ
|
presheaf : {ℓ ℓ' : Level} {ℂ : Category ℓ ℓ'} → Category.Object (Opposite ℂ) → Presheaf ℂ
|
||||||
presheaf {ℂ = ℂ} B = record
|
presheaf {ℂ = ℂ} B = record
|
||||||
|
{ raw = record
|
||||||
{ func* = λ A → ℂ [ A , B ]
|
{ func* = λ A → ℂ [ A , B ]
|
||||||
; func→ = λ f g → ℂ [ g ∘ f ]
|
; func→ = λ f g → ℂ [ g ∘ f ]
|
||||||
|
}
|
||||||
; isFunctor = record
|
; isFunctor = record
|
||||||
{ ident = funExt λ x → proj₁ ident
|
{ ident = funExt λ x → proj₁ ident
|
||||||
; distrib = funExt λ x → assoc
|
; distrib = funExt λ x → assoc
|
||||||
|
|
|
@ -53,10 +53,6 @@ record RawCategory (ℓ ℓ' : Level) : Set (lsuc (ℓ' ⊔ ℓ)) where
|
||||||
-- (univalent).
|
-- (univalent).
|
||||||
record IsCategory {ℓa ℓb : Level} (ℂ : RawCategory ℓa ℓb) : Set (lsuc (ℓa ⊔ ℓb)) where
|
record IsCategory {ℓa ℓb : Level} (ℂ : RawCategory ℓa ℓb) : Set (lsuc (ℓa ⊔ ℓb)) where
|
||||||
open RawCategory ℂ
|
open RawCategory ℂ
|
||||||
-- (Object : Set ℓ)
|
|
||||||
-- (Arrow : Object → Object → Set ℓ')
|
|
||||||
-- (𝟙 : {o : Object} → Arrow o o)
|
|
||||||
-- (_∘_ : { a b c : Object } → Arrow b c → Arrow a b → Arrow a c)
|
|
||||||
field
|
field
|
||||||
assoc : {A B C D : Object} { f : Arrow A B } { g : Arrow B C } { h : Arrow C D }
|
assoc : {A B C D : Object} { f : Arrow A B } { g : Arrow B C } { h : Arrow C D }
|
||||||
→ h ∘ (g ∘ f) ≡ (h ∘ g) ∘ f
|
→ h ∘ (g ∘ f) ≡ (h ∘ g) ∘ f
|
||||||
|
|
|
@ -6,61 +6,110 @@ open import Function
|
||||||
|
|
||||||
open import Cat.Category
|
open import Cat.Category
|
||||||
|
|
||||||
open Category hiding (_∘_)
|
open Category hiding (_∘_ ; raw)
|
||||||
|
|
||||||
module _ {ℓc ℓc' ℓd ℓd'} (ℂ : Category ℓc ℓc') (𝔻 : Category ℓd ℓd') where
|
module _ {ℓc ℓc' ℓd ℓd'}
|
||||||
record IsFunctor
|
(ℂ : Category ℓc ℓc')
|
||||||
(func* : Object ℂ → Object 𝔻)
|
(𝔻 : Category ℓd ℓd')
|
||||||
(func→ : {A B : Object ℂ} → ℂ [ A , B ] → 𝔻 [ func* A , func* B ])
|
where
|
||||||
: Set (ℓc ⊔ ℓc' ⊔ ℓd ⊔ ℓd') where
|
|
||||||
|
private
|
||||||
|
ℓ = ℓc ⊔ ℓc' ⊔ ℓd ⊔ ℓd'
|
||||||
|
𝓤 = Set ℓ
|
||||||
|
|
||||||
|
record RawFunctor : 𝓤 where
|
||||||
|
field
|
||||||
|
func* : Object ℂ → Object 𝔻
|
||||||
|
func→ : ∀ {A B} → ℂ [ A , B ] → 𝔻 [ func* A , func* B ]
|
||||||
|
|
||||||
|
record IsFunctor (F : RawFunctor) : 𝓤 where
|
||||||
|
open RawFunctor F
|
||||||
field
|
field
|
||||||
ident : {c : Object ℂ} → func→ (𝟙 ℂ {c}) ≡ 𝟙 𝔻 {func* c}
|
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
|
|
||||||
distrib : {A B C : Object ℂ} {f : ℂ [ A , B ]} {g : ℂ [ B , C ]}
|
distrib : {A B C : Object ℂ} {f : ℂ [ A , B ]} {g : ℂ [ B , C ]}
|
||||||
→ func→ (ℂ [ g ∘ f ]) ≡ 𝔻 [ func→ g ∘ func→ f ]
|
→ func→ (ℂ [ g ∘ f ]) ≡ 𝔻 [ func→ g ∘ func→ f ]
|
||||||
|
|
||||||
record Functor : Set (ℓc ⊔ ℓc' ⊔ ℓd ⊔ ℓd') where
|
record Functor : Set (ℓc ⊔ ℓc' ⊔ ℓd ⊔ ℓd') where
|
||||||
field
|
field
|
||||||
|
raw : RawFunctor
|
||||||
|
{{isFunctor}} : IsFunctor raw
|
||||||
|
|
||||||
|
private
|
||||||
|
module R = RawFunctor raw
|
||||||
|
|
||||||
func* : Object ℂ → Object 𝔻
|
func* : Object ℂ → Object 𝔻
|
||||||
|
func* = R.func*
|
||||||
|
|
||||||
func→ : ∀ {A B} → ℂ [ A , B ] → 𝔻 [ func* A , func* B ]
|
func→ : ∀ {A B} → ℂ [ A , B ] → 𝔻 [ func* A , func* B ]
|
||||||
{{isFunctor}} : IsFunctor func* func→
|
func→ = R.func→
|
||||||
|
|
||||||
open IsFunctor
|
open IsFunctor
|
||||||
open Functor
|
open Functor
|
||||||
|
|
||||||
|
-- TODO: Is `IsFunctor` a proposition?
|
||||||
|
module _
|
||||||
|
{ℓa ℓb : Level}
|
||||||
|
{ℂ 𝔻 : Category ℓa ℓb}
|
||||||
|
{F : RawFunctor ℂ 𝔻}
|
||||||
|
where
|
||||||
|
private
|
||||||
|
module 𝔻 = IsCategory (isCategory 𝔻)
|
||||||
|
|
||||||
|
-- isProp : Set ℓ
|
||||||
|
-- isProp = (x y : A) → x ≡ y
|
||||||
|
|
||||||
|
IsFunctorIsProp : isProp (IsFunctor _ _ F)
|
||||||
|
IsFunctorIsProp isF0 isF1 i = record
|
||||||
|
{ ident = 𝔻.arrowIsSet isF0.ident isF1.ident i
|
||||||
|
; distrib = 𝔻.arrowIsSet isF0.distrib isF1.distrib i
|
||||||
|
}
|
||||||
|
where
|
||||||
|
module isF0 = IsFunctor isF0
|
||||||
|
module isF1 = IsFunctor isF1
|
||||||
|
|
||||||
|
-- Alternate version of above where `F` is a path in
|
||||||
|
module _
|
||||||
|
{ℓa ℓb : Level}
|
||||||
|
{ℂ 𝔻 : Category ℓa ℓb}
|
||||||
|
{F : I → RawFunctor ℂ 𝔻}
|
||||||
|
where
|
||||||
|
private
|
||||||
|
module 𝔻 = IsCategory (isCategory 𝔻)
|
||||||
|
IsProp' : {ℓ : Level} (A : I → Set ℓ) → Set ℓ
|
||||||
|
IsProp' A = (a0 : A i0) (a1 : A i1) → A [ a0 ≡ a1 ]
|
||||||
|
|
||||||
|
postulate IsFunctorIsProp' : IsProp' λ i → IsFunctor _ _ (F i)
|
||||||
|
-- IsFunctorIsProp' isF0 isF1 i = record
|
||||||
|
-- { ident = {!𝔻.arrowIsSet {!isF0.ident!} {!isF1.ident!} i!}
|
||||||
|
-- ; distrib = {!𝔻.arrowIsSet {!isF0.distrib!} {!isF1.distrib!} i!}
|
||||||
|
-- }
|
||||||
|
-- where
|
||||||
|
-- module isF0 = IsFunctor isF0
|
||||||
|
-- module isF1 = IsFunctor isF1
|
||||||
|
|
||||||
module _ {ℓ ℓ' : Level} {ℂ 𝔻 : Category ℓ ℓ'} where
|
module _ {ℓ ℓ' : Level} {ℂ 𝔻 : Category ℓ ℓ'} where
|
||||||
|
|
||||||
IsFunctor≡
|
|
||||||
: {func* : Object ℂ → Object 𝔻}
|
|
||||||
{func→ : {A B : Object ℂ} → ℂ [ A , B ] → 𝔻 [ 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 }
|
|
||||||
|
|
||||||
Functor≡ : {F G : Functor ℂ 𝔻}
|
Functor≡ : {F G : Functor ℂ 𝔻}
|
||||||
→ (eq* : F .func* ≡ G .func*)
|
→ (eq* : func* F ≡ func* G)
|
||||||
→ (eq→ : (λ i → ∀ {x y} → ℂ [ x , y ] → 𝔻 [ eq* i x , eq* i y ])
|
→ (eq→ : (λ i → ∀ {x y} → ℂ [ x , y ] → 𝔻 [ eq* i x , eq* i y ])
|
||||||
[ F .func→ ≡ G .func→ ])
|
[ func→ F ≡ func→ G ])
|
||||||
-- → (eqIsF : PathP (λ i → IsFunctor ℂ 𝔻 (eq* i) (eq→ i)) (F .isFunctor) (G .isFunctor))
|
|
||||||
→ (eqIsFunctor : (λ i → IsFunctor ℂ 𝔻 (eq* i) (eq→ i)) [ F .isFunctor ≡ G .isFunctor ])
|
|
||||||
→ F ≡ G
|
→ F ≡ G
|
||||||
Functor≡ eq* eq→ eqIsFunctor i = record { func* = eq* i ; func→ = eq→ i ; isFunctor = eqIsFunctor i }
|
Functor≡ {F} {G} eq* eq→ i = record
|
||||||
|
{ raw = eqR i
|
||||||
|
; isFunctor = f i
|
||||||
|
}
|
||||||
|
where
|
||||||
|
eqR : raw F ≡ raw G
|
||||||
|
eqR i = record { func* = eq* i ; func→ = eq→ i }
|
||||||
|
postulate T : isSet (IsFunctor _ _ (raw F))
|
||||||
|
f : (λ i → IsFunctor ℂ 𝔻 (eqR i)) [ isFunctor F ≡ isFunctor G ]
|
||||||
|
f = IsFunctorIsProp' (isFunctor F) (isFunctor G)
|
||||||
|
|
||||||
module _ {ℓ ℓ' : Level} {A B C : Category ℓ ℓ'} (F : Functor B C) (G : Functor A B) where
|
module _ {ℓ ℓ' : Level} {A B C : Category ℓ ℓ'} (F : Functor B C) (G : Functor A B) where
|
||||||
private
|
private
|
||||||
F* = F .func*
|
F* = func* F
|
||||||
F→ = F .func→
|
F→ = func→ F
|
||||||
G* = G .func*
|
G* = func* G
|
||||||
G→ = G .func→
|
G→ = func→ G
|
||||||
module _ {a0 a1 a2 : Object A} {α0 : A [ a0 , a1 ]} {α1 : A [ a1 , a2 ]} where
|
module _ {a0 a1 a2 : Object A} {α0 : A [ a0 , a1 ]} {α1 : A [ a1 , a2 ]} where
|
||||||
|
|
||||||
dist : (F→ ∘ G→) (A [ α1 ∘ α0 ]) ≡ C [ (F→ ∘ G→) α1 ∘ (F→ ∘ G→) α0 ]
|
dist : (F→ ∘ G→) (A [ α1 ∘ α0 ]) ≡ C [ (F→ ∘ G→) α1 ∘ (F→ ∘ G→) α0 ]
|
||||||
|
@ -70,12 +119,12 @@ module _ {ℓ ℓ' : Level} {A B C : Category ℓ ℓ'} (F : Functor B C) (G : F
|
||||||
F→ (B [ G→ α1 ∘ G→ α0 ]) ≡⟨ F .isFunctor .distrib ⟩
|
F→ (B [ G→ α1 ∘ G→ α0 ]) ≡⟨ F .isFunctor .distrib ⟩
|
||||||
C [ (F→ ∘ G→) α1 ∘ (F→ ∘ G→) α0 ] ∎
|
C [ (F→ ∘ G→) α1 ∘ (F→ ∘ G→) α0 ] ∎
|
||||||
|
|
||||||
_∘f_ : Functor A C
|
_∘fr_ : RawFunctor A C
|
||||||
_∘f_ =
|
RawFunctor.func* _∘fr_ = F* ∘ G*
|
||||||
record
|
RawFunctor.func→ _∘fr_ = F→ ∘ G→
|
||||||
{ func* = F* ∘ G*
|
instance
|
||||||
; func→ = F→ ∘ G→
|
isFunctor' : IsFunctor A C _∘fr_
|
||||||
; isFunctor = record
|
isFunctor' = record
|
||||||
{ ident = begin
|
{ ident = begin
|
||||||
(F→ ∘ G→) (𝟙 A) ≡⟨ refl ⟩
|
(F→ ∘ G→) (𝟙 A) ≡⟨ refl ⟩
|
||||||
F→ (G→ (𝟙 A)) ≡⟨ cong F→ (G .isFunctor .ident)⟩
|
F→ (G→ (𝟙 A)) ≡⟨ cong F→ (G .isFunctor .ident)⟩
|
||||||
|
@ -83,13 +132,17 @@ module _ {ℓ ℓ' : Level} {A B C : Category ℓ ℓ'} (F : Functor B C) (G : F
|
||||||
𝟙 C ∎
|
𝟙 C ∎
|
||||||
; distrib = dist
|
; distrib = dist
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
_∘f_ : Functor A C
|
||||||
|
raw _∘f_ = _∘fr_
|
||||||
|
|
||||||
-- The identity functor
|
-- The identity functor
|
||||||
identity : ∀ {ℓ ℓ'} → {C : Category ℓ ℓ'} → Functor C C
|
identity : ∀ {ℓ ℓ'} → {C : Category ℓ ℓ'} → Functor C C
|
||||||
identity = record
|
identity = record
|
||||||
|
{ raw = record
|
||||||
{ func* = λ x → x
|
{ func* = λ x → x
|
||||||
; func→ = λ x → x
|
; func→ = λ x → x
|
||||||
|
}
|
||||||
; isFunctor = record
|
; isFunctor = record
|
||||||
{ ident = refl
|
{ ident = refl
|
||||||
; distrib = refl
|
; distrib = refl
|
||||||
|
|
|
@ -25,6 +25,8 @@ module _ {ℓa ℓb : Level} where
|
||||||
T : Functor (Opposite ℂ) (Fam ℓa ℓb)
|
T : Functor (Opposite ℂ) (Fam ℓa ℓb)
|
||||||
-- Empty context
|
-- Empty context
|
||||||
[] : Terminal ℂ
|
[] : Terminal ℂ
|
||||||
|
private
|
||||||
|
module T = Functor T
|
||||||
Type : (Γ : Object ℂ) → Set ℓa
|
Type : (Γ : Object ℂ) → Set ℓa
|
||||||
Type Γ = proj₁ (T.func* Γ)
|
Type Γ = proj₁ (T.func* Γ)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue