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
open import Agda.Primitive
open import Cubical
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.Functor
open import Cat.Category.Product
@ -46,21 +48,30 @@ module _ ( ' : Level) where
isAssociative {f = F} {G} {H} = assc {F = F} {G = G} {H = H}
ident : IsIdentity identity
ident = ident-r , ident-l
-- NB! `ArrowsAreSets RawCat` is *not* provable. The type of functors,
-- however, form a groupoid! Therefore there is no (1-)category of
-- categories. There does, however, exist a 2-category of 1-categories.
-- Because of the note above there is not category of categories.
-- NB! `ArrowsAreSets RawCat` is *not* provable. The type of functors,
-- however, form a groupoid! Therefore there is no (1-)category of
-- categories. There does, however, exist a 2-category of 1-categories.
--
-- Because of this there is no category of categories.
Cat : (unprovable : IsCategory RawCat) Category (lsuc ( ')) ( ')
Category.raw (Cat _) = RawCat
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
-- category. In some places it may not actually be needed, however.
-- | In the following we will pretend there is a category of categories when
-- 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
private
module = Category
module 𝔻 = Category 𝔻
Obj = Object × Object 𝔻
Arr : Obj Obj Set '
Arr (c , d) (c' , d') = [ c , c' ] × 𝔻 [ d , d' ]
@ -80,9 +91,6 @@ module CatProduct { ' : Level} ( 𝔻 : Category ') where
RawCategory._∘_ rawProduct = _∘_
open RawCategory rawProduct
module = Category
module 𝔻 = Category 𝔻
open import Cubical.Sigma
arrowsAreSets : ArrowsAreSets
arrowsAreSets = setSig {sA = .arrowsAreSets} {sB = λ x 𝔻.arrowsAreSets}
isIdentity : IsIdentity 𝟙'
@ -97,31 +105,35 @@ module CatProduct { ' : Level} ( 𝔻 : Category ') where
IsCategory.arrowsAreSets isCategory = arrowsAreSets
IsCategory.univalent isCategory = univalent
obj : Category '
Category.raw obj = rawProduct
object : Category '
Category.raw object = rawProduct
proj₁ : Functor obj
proj₁ : Functor object
proj₁ = record
{ raw = record { omap = fst ; fmap = fst }
; isFunctor = record { isIdentity = refl ; isDistributive = refl }
{ raw = record
{ omap = fst ; fmap = fst }
; isFunctor = record
{ isIdentity = refl ; isDistributive = refl }
}
proj₂ : Functor obj 𝔻
proj₂ : Functor object 𝔻
proj₂ = record
{ raw = record { omap = snd ; fmap = snd }
; isFunctor = record { isIdentity = refl ; isDistributive = refl }
{ raw = record
{ omap = snd ; fmap = snd }
; isFunctor = record
{ isIdentity = refl ; isDistributive = refl }
}
module _ {X : Category '} (x₁ : Functor X ) (x₂ : Functor X 𝔻) where
private
x : Functor X obj
x : Functor X object
x = record
{ raw = record
{ omap = λ x x₁.omap x , x₂.omap x
; fmap = λ x x₁.fmap x , x₂.fmap x
}
; isFunctor = record
{ isIdentity = Σ≡ x₁.isIdentity x₂.isIdentity
{ isIdentity = Σ≡ x₁.isIdentity x₂.isIdentity
; isDistributive = Σ≡ x₁.isDistributive x₂.isDistributive
}
}
@ -150,7 +162,7 @@ module _ { ' : Level} (unprovable : IsCategory (RawCat ')) where
module P = CatProduct 𝔻
rawProduct : RawProduct Cat 𝔻
RawProduct.object rawProduct = P.obj
RawProduct.object rawProduct = P.object
RawProduct.proj₁ rawProduct = P.proj₁
RawProduct.proj₂ rawProduct = P.proj₂
@ -165,24 +177,23 @@ module _ { ' : Level} (unprovable : IsCategory (RawCat ')) where
hasProducts : HasProducts Cat
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
private
open Data.Product
open import Cat.Categories.Fun
module = Category
module 𝔻 = Category 𝔻
Category = Category
open Fun 𝔻 renaming (identity to idN)
Category = Category
open Fun 𝔻 renaming (identity to idN)
private
omap : Functor 𝔻 × Object Object 𝔻
omap (F , A) = F.omap A
where
module F = Functor F
omap (F , A) = Functor.omap F A
prodObj : Category
prodObj = Fun
-- The exponential object
object : Category
object = Fun
module _ {dom cod : Functor 𝔻 × Object } where
private
@ -215,15 +226,10 @@ module CatExponential { : Level} ( 𝔻 : Category ) where
l = 𝔻 [ θB F.fmap f ]
r : 𝔻 [ F.omap A , G.omap B ]
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 = l
open CatProduct renaming (obj to _×p_) using ()
open CatProduct renaming (object to _⊗_) using ()
module _ {c : Functor 𝔻 × Object } where
private
@ -234,7 +240,7 @@ module CatExponential { : Level} ( 𝔻 : Category ) where
ident : fmap {c} {c} (NT.identity F , 𝟙 {A = proj₂ c}) 𝟙 𝔻
ident = begin
fmap {c} {c} (𝟙 (prodObj ×p ) {c}) ≡⟨⟩
fmap {c} {c} (𝟙 (object ) {c}) ≡⟨⟩
fmap {c} {c} (idN F , 𝟙 ) ≡⟨⟩
𝔻 [ identityTrans F C F.fmap (𝟙 )] ≡⟨⟩
𝔻 [ 𝟙 𝔻 F.fmap (𝟙 )] ≡⟨ proj₂ 𝔻.isIdentity
@ -254,8 +260,6 @@ module CatExponential { : Level} ( 𝔻 : Category ) where
module F = Functor F
module G = Functor G
module H = Functor H
-- Not entirely clear what this is at this point:
_P⊕_ = Category._∘_ (prodObj ×p ) {F×A} {G×B} {H×C}
module _
-- NaturalTransformation F G × .Arrow A B
@ -305,7 +309,7 @@ module CatExponential { : Level} ( 𝔻 : Category ) where
≡⟨ cong (λ φ 𝔻 [ 𝔻 [ η C G.fmap g ] φ ]) (sym (θNat f))
𝔻 [ 𝔻 [ η C G.fmap g ] 𝔻 [ θ B F.fmap f ] ]
eval : Functor (CatProduct.obj prodObj ) 𝔻
eval : Functor (CatProduct.object object ) 𝔻
eval = record
{ raw = record
{ omap = omap
@ -317,14 +321,12 @@ module CatExponential { : Level} ( 𝔻 : Category ) where
}
}
module _ (𝔸 : Category ) (F : Functor (𝔸 ×p ) 𝔻) where
-- open HasProducts (hasProducts {} {} unprovable) renaming (_|×|_ to parallelProduct)
module _ (𝔸 : Category ) (F : Functor (𝔸 ) 𝔻) where
postulate
parallelProduct
: Functor 𝔸 prodObj Functor
Functor (𝔸 ×p ) (prodObj ×p )
transpose : Functor 𝔸 prodObj
: Functor 𝔸 object Functor
Functor (𝔸 ) (object )
transpose : Functor 𝔸 object
eq : F[ eval (parallelProduct transpose (identity {C = })) ] F
-- eq : F[ :eval: ∘ {!!} ] ≡ 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 =
-- 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
private
Cat : Category (lsuc ( )) ( )
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
exponent : Exponential Cat 𝔻
exponent = record
{ obj = prodObj
; eval = {!evalll'!}
; 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 𝔻
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 = record
{ obj = CatExp.object
; eval = eval
; isExponential = isExponential
}
hasExponentials : HasExponentials Cat
hasExponentials = record { exponent = exponent }