Clean-up in the category of categories

This commit is contained in:
Frederik Hanghøj Iversen 2018-03-08 11:54:13 +01:00
parent d01514cbdb
commit 52297d9073

View file

@ -4,9 +4,11 @@
module Cat.Categories.Cat where module Cat.Categories.Cat where
open import Agda.Primitive open import Agda.Primitive
open import Cubical
open import Data.Product renaming (proj₁ to fst ; proj₂ to snd) open import Data.Product renaming (proj₁ to fst ; proj₂ to snd)
open import Cubical
open import Cubical.Sigma
open import Cat.Category open import Cat.Category
open import Cat.Category.Functor open import Cat.Category.Functor
open import Cat.Category.Product open import Cat.Category.Product
@ -46,21 +48,30 @@ module _ ( ' : Level) where
isAssociative {f = F} {G} {H} = assc {F = F} {G = G} {H = H} isAssociative {f = F} {G} {H} = assc {F = F} {G = G} {H = H}
ident : IsIdentity identity ident : IsIdentity identity
ident = ident-r , ident-l ident = ident-r , ident-l
-- NB! `ArrowsAreSets RawCat` is *not* provable. The type of functors, -- NB! `ArrowsAreSets RawCat` is *not* provable. The type of functors,
-- however, form a groupoid! Therefore there is no (1-)category of -- however, form a groupoid! Therefore there is no (1-)category of
-- categories. There does, however, exist a 2-category of 1-categories. -- categories. There does, however, exist a 2-category of 1-categories.
--
-- Because of the note above there is not category of categories. -- Because of this there is no category of categories.
Cat : (unprovable : IsCategory RawCat) Category (lsuc ( ')) ( ') Cat : (unprovable : IsCategory RawCat) Category (lsuc ( ')) ( ')
Category.raw (Cat _) = RawCat Category.raw (Cat _) = RawCat
Category.isCategory (Cat unprovable) = unprovable Category.isCategory (Cat unprovable) = unprovable
-- Category.raw Cat _ = RawCat
-- Category.isCategory Cat unprovable = unprovable
-- The following to some extend depends on the category of categories being a -- | In the following we will pretend there is a category of categories when
-- category. In some places it may not actually be needed, however. -- e.g. talking about it being cartesian closed. It still makes sense to
-- construct these things even though that category does not exist.
--
-- If the notion of a category is later generalized to work on different
-- homotopy levels, then the proof that the category of categories is cartesian
-- closed will follow immediately from these constructions.
-- | the category of categories have products.
module CatProduct { ' : Level} ( 𝔻 : Category ') where module CatProduct { ' : Level} ( 𝔻 : Category ') where
private private
module = Category
module 𝔻 = Category 𝔻
Obj = Object × Object 𝔻 Obj = Object × Object 𝔻
Arr : Obj Obj Set ' Arr : Obj Obj Set '
Arr (c , d) (c' , d') = [ c , c' ] × 𝔻 [ d , d' ] Arr (c , d) (c' , d') = [ c , c' ] × 𝔻 [ d , d' ]
@ -80,9 +91,6 @@ module CatProduct { ' : Level} ( 𝔻 : Category ') where
RawCategory._∘_ rawProduct = _∘_ RawCategory._∘_ rawProduct = _∘_
open RawCategory rawProduct open RawCategory rawProduct
module = Category
module 𝔻 = Category 𝔻
open import Cubical.Sigma
arrowsAreSets : ArrowsAreSets arrowsAreSets : ArrowsAreSets
arrowsAreSets = setSig {sA = .arrowsAreSets} {sB = λ x 𝔻.arrowsAreSets} arrowsAreSets = setSig {sA = .arrowsAreSets} {sB = λ x 𝔻.arrowsAreSets}
isIdentity : IsIdentity 𝟙' isIdentity : IsIdentity 𝟙'
@ -97,24 +105,28 @@ module CatProduct { ' : Level} ( 𝔻 : Category ') where
IsCategory.arrowsAreSets isCategory = arrowsAreSets IsCategory.arrowsAreSets isCategory = arrowsAreSets
IsCategory.univalent isCategory = univalent IsCategory.univalent isCategory = univalent
obj : Category ' object : Category '
Category.raw obj = rawProduct Category.raw object = rawProduct
proj₁ : Functor obj proj₁ : Functor object
proj₁ = record proj₁ = record
{ raw = record { omap = fst ; fmap = fst } { raw = record
; isFunctor = record { isIdentity = refl ; isDistributive = refl } { omap = fst ; fmap = fst }
; isFunctor = record
{ isIdentity = refl ; isDistributive = refl }
} }
proj₂ : Functor obj 𝔻 proj₂ : Functor object 𝔻
proj₂ = record proj₂ = record
{ raw = record { omap = snd ; fmap = snd } { raw = record
; isFunctor = record { isIdentity = refl ; isDistributive = refl } { omap = snd ; fmap = snd }
; isFunctor = record
{ isIdentity = refl ; isDistributive = refl }
} }
module _ {X : Category '} (x₁ : Functor X ) (x₂ : Functor X 𝔻) where module _ {X : Category '} (x₁ : Functor X ) (x₂ : Functor X 𝔻) where
private private
x : Functor X obj x : Functor X object
x = record x = record
{ raw = record { raw = record
{ omap = λ x x₁.omap x , x₂.omap x { omap = λ x x₁.omap x , x₂.omap x
@ -150,7 +162,7 @@ module _ { ' : Level} (unprovable : IsCategory (RawCat ')) where
module P = CatProduct 𝔻 module P = CatProduct 𝔻
rawProduct : RawProduct Cat 𝔻 rawProduct : RawProduct Cat 𝔻
RawProduct.object rawProduct = P.obj RawProduct.object rawProduct = P.object
RawProduct.proj₁ rawProduct = P.proj₁ RawProduct.proj₁ rawProduct = P.proj₁
RawProduct.proj₂ rawProduct = P.proj₂ RawProduct.proj₂ rawProduct = P.proj₂
@ -165,24 +177,23 @@ module _ { ' : Level} (unprovable : IsCategory (RawCat ')) where
hasProducts : HasProducts Cat hasProducts : HasProducts Cat
hasProducts = record { product = product } hasProducts = record { product = product }
-- Basically proves that `Cat ` is cartesian closed. -- | The category of categories have expoentntials - and because it has products
-- it is therefory also cartesian closed.
module CatExponential { : Level} ( 𝔻 : Category ) where module CatExponential { : Level} ( 𝔻 : Category ) where
private private
open Data.Product open Data.Product
open import Cat.Categories.Fun open import Cat.Categories.Fun
module = Category module = Category
module 𝔻 = Category 𝔻 module 𝔻 = Category 𝔻
Category = Category Category = Category
open Fun 𝔻 renaming (identity to idN) open Fun 𝔻 renaming (identity to idN)
private
omap : Functor 𝔻 × Object Object 𝔻
omap (F , A) = F.omap A
where
module F = Functor F
prodObj : Category omap : Functor 𝔻 × Object Object 𝔻
prodObj = Fun omap (F , A) = Functor.omap F A
-- The exponential object
object : Category
object = Fun
module _ {dom cod : Functor 𝔻 × Object } where module _ {dom cod : Functor 𝔻 × Object } where
private private
@ -215,15 +226,10 @@ module CatExponential { : Level} ( 𝔻 : Category ) where
l = 𝔻 [ θB F.fmap f ] l = 𝔻 [ θB F.fmap f ]
r : 𝔻 [ F.omap A , G.omap B ] r : 𝔻 [ F.omap A , G.omap B ]
r = 𝔻 [ G.fmap f θA ] r = 𝔻 [ G.fmap f θA ]
-- There are two choices at this point,
-- but I suppose the whole point is that
-- by `θNat f` we have `l ≡ r`
-- lem : 𝔻 [ θ B ∘ F .fmap f ] ≡ 𝔻 [ G .fmap f ∘ θ A ]
-- lem = θNat f
result : 𝔻 [ F.omap A , G.omap B ] result : 𝔻 [ F.omap A , G.omap B ]
result = l result = l
open CatProduct renaming (obj to _×p_) using () open CatProduct renaming (object to _⊗_) using ()
module _ {c : Functor 𝔻 × Object } where module _ {c : Functor 𝔻 × Object } where
private private
@ -234,7 +240,7 @@ module CatExponential { : Level} ( 𝔻 : Category ) where
ident : fmap {c} {c} (NT.identity F , 𝟙 {A = proj₂ c}) 𝟙 𝔻 ident : fmap {c} {c} (NT.identity F , 𝟙 {A = proj₂ c}) 𝟙 𝔻
ident = begin ident = begin
fmap {c} {c} (𝟙 (prodObj ×p ) {c}) ≡⟨⟩ fmap {c} {c} (𝟙 (object ) {c}) ≡⟨⟩
fmap {c} {c} (idN F , 𝟙 ) ≡⟨⟩ fmap {c} {c} (idN F , 𝟙 ) ≡⟨⟩
𝔻 [ identityTrans F C F.fmap (𝟙 )] ≡⟨⟩ 𝔻 [ identityTrans F C F.fmap (𝟙 )] ≡⟨⟩
𝔻 [ 𝟙 𝔻 F.fmap (𝟙 )] ≡⟨ proj₂ 𝔻.isIdentity 𝔻 [ 𝟙 𝔻 F.fmap (𝟙 )] ≡⟨ proj₂ 𝔻.isIdentity
@ -254,8 +260,6 @@ module CatExponential { : Level} ( 𝔻 : Category ) where
module F = Functor F module F = Functor F
module G = Functor G module G = Functor G
module H = Functor H module H = Functor H
-- Not entirely clear what this is at this point:
_P⊕_ = Category._∘_ (prodObj ×p ) {F×A} {G×B} {H×C}
module _ module _
-- NaturalTransformation F G × .Arrow A B -- NaturalTransformation F G × .Arrow A B
@ -305,7 +309,7 @@ module CatExponential { : Level} ( 𝔻 : Category ) where
≡⟨ cong (λ φ 𝔻 [ 𝔻 [ η C G.fmap g ] φ ]) (sym (θNat f)) ≡⟨ cong (λ φ 𝔻 [ 𝔻 [ η C G.fmap g ] φ ]) (sym (θNat f))
𝔻 [ 𝔻 [ η C G.fmap g ] 𝔻 [ θ B F.fmap f ] ] 𝔻 [ 𝔻 [ η C G.fmap g ] 𝔻 [ θ B F.fmap f ] ]
eval : Functor (CatProduct.obj prodObj ) 𝔻 eval : Functor (CatProduct.object object ) 𝔻
eval = record eval = record
{ raw = record { raw = record
{ omap = omap { omap = omap
@ -317,14 +321,12 @@ module CatExponential { : Level} ( 𝔻 : Category ) where
} }
} }
module _ (𝔸 : Category ) (F : Functor (𝔸 ×p ) 𝔻) where module _ (𝔸 : Category ) (F : Functor (𝔸 ) 𝔻) where
-- open HasProducts (hasProducts {} {} unprovable) renaming (_|×|_ to parallelProduct)
postulate postulate
parallelProduct parallelProduct
: Functor 𝔸 prodObj Functor : Functor 𝔸 object Functor
Functor (𝔸 ×p ) (prodObj ×p ) Functor (𝔸 ) (object )
transpose : Functor 𝔸 prodObj transpose : Functor 𝔸 object
eq : F[ eval (parallelProduct transpose (identity {C = })) ] F eq : F[ eval (parallelProduct transpose (identity {C = })) ] F
-- eq : F[ :eval: ∘ {!!} ] ≡ F -- eq : F[ :eval: ∘ {!!} ] ≡ F
-- eq : Cat [ :eval: ∘ (HasProducts._|×|_ hasProducts transpose (𝟙 Cat {o = })) ] ≡ F -- eq : Cat [ :eval: ∘ (HasProducts._|×|_ hasProducts transpose (𝟙 Cat {o = })) ] ≡ F
@ -339,39 +341,30 @@ module CatExponential { : Level} ( 𝔻 : Category ) where
-- :eval: (parallelProduct F~ (𝟙 Cat {o = }))] F) catTranspose = -- :eval: (parallelProduct F~ (𝟙 Cat {o = }))] F) catTranspose =
-- transpose , eq -- transpose , eq
-- We don't care about filling out the holes below since they are anyways hidden
-- behind an unprovable statement.
module _ ( : Level) (unprovable : IsCategory (RawCat )) where module _ ( : Level) (unprovable : IsCategory (RawCat )) where
private private
Cat : Category (lsuc ( )) ( ) Cat : Category (lsuc ( )) ( )
Cat = Cat unprovable Cat = Cat unprovable
module _ ( 𝔻 : Category ) where
open CatExponential 𝔻 using (prodObj ; eval)
-- Putting in the type annotation causes Agda to loop indefinitely.
-- eval' : Functor (CatProduct.obj prodObj ) 𝔻
-- Likewise, using it below also results in this.
eval' : _
eval' = eval
-- private
-- -- module _ ( 𝔻 : Category ) where
-- postulate :isExponential: : IsExponential Cat 𝔻 prodObj :eval:
-- -- :isExponential: : IsExponential Cat 𝔻 :obj: :eval:
-- -- :isExponential: = {!catTranspose!}
-- -- where
-- -- open HasProducts (hasProducts {} {} unprovable) using (_|×|_)
-- -- :isExponential: = λ 𝔸 F → transpose 𝔸 F , eq' 𝔸 F
-- -- :exponent: : Exponential (Cat ) A B module _ ( 𝔻 : Category ) where
module CatExp = CatExponential 𝔻
_⊗_ = CatProduct.object
-- Filling the hole causes Agda to loop indefinitely.
eval : Functor (CatExp.object ) 𝔻
eval = {!CatExp.eval!}
isExponential : IsExponential Cat 𝔻 CatExp.object eval
isExponential = {!CatExp.isExponential!}
exponent : Exponential Cat 𝔻 exponent : Exponential Cat 𝔻
exponent = record exponent = record
{ obj = prodObj { obj = CatExp.object
; eval = {!evalll'!} ; eval = eval
; isExponential = {!:isExponential:!} ; isExponential = isExponential
} }
where
open HasProducts (hasProducts unprovable) renaming (_×_ to _×p_)
open import Cat.Categories.Fun
open Fun
-- _×p_ = CatProduct.obj -- prodObj
-- eval' : Functor CatP.obj 𝔻
hasExponentials : HasExponentials Cat hasExponentials : HasExponentials Cat
hasExponentials = record { exponent = exponent } hasExponentials = record { exponent = exponent }