Merge branch 'dev'

This commit is contained in:
Frederik Hanghøj Iversen 2018-02-21 14:06:24 +01:00
commit 6322ef92d5
12 changed files with 368 additions and 240 deletions

6
BACKLOG.md Normal file
View file

@ -0,0 +1,6 @@
Backlog
=======
Prove univalence for various categories
Prove postulates in `Cat.Wishlist`

17
CHANGELOG.md Normal file
View file

@ -0,0 +1,17 @@
Changelog
=========
Version 1.1.0
-------------
In this version categories have been refactored - there's now a notion of a raw
category, and a proper category which has the data (raw category) as well as
the laws.
Furthermore the type of arrows must be homotopy sets and they must satisfy univalence.
I've made a module `Cat.Wishlist` where I just postulate things that I hope to
implement upstream in `cubical`.
I have proven that `IsCategory` is a mere proposition.
I've also updated the category of sets to adhere to this new definition.

View file

@ -1,17 +1,29 @@
Description Description
=========== ===========
This project includes code as well as my masters thesis (currently just This project aims to formalize some parts of category theory using cubical agda
consisting of the proposal for the thesis). — an extension to agda permitting univalence. To learn more about this
[readthedocs](https://agda.readthedocs.io/en/latest/language/cubical.html).
This project draws a lot of inspiration from [the
HoTT-book](https://homotopytypetheory.org/book/).
Installation Installation
============ ============
You probably need a very recent version of the Agda compiler. At the time
of writing the solution has been tested with Agda version 2.6.0-5d84754.
Dependencies Dependencies
------------ ------------
To succesfully compile the following is needed:
* Agda version >= `707ce6042b6a3bdb26521f3fe8dfe5d8a8470a43`.
* [Agda Standard Library](https://github.com/agda/agda-stdlib)
* [Cubical](https://github.com/Saizan/cubical-demo/)
It's important to have the right version of these - but which one is the right
is in constant flux. It's most likely the newest one.
I've used git submodules to manage dependencies. Unfortunately Agda does not I've used git submodules to manage dependencies. Unfortunately Agda does not
allow specifying libraries to be used only as local dependencies. allow specifying libraries to be used only as local dependencies. So the
submodules are mostly used for documentation.
You can let Agda know about these libraries by appending them to your global You can let Agda know about these libraries by appending them to your global
libraries file like so: (NB!: There is a good reason this is not in a libraries file like so: (NB!: There is a good reason this is not in a

@ -1 +1 @@
Subproject commit 157497a5335ad0069c7aaffbc65932c40a28ee68 Subproject commit 87d28d7d753f73abd20665d7bbb88f9d72ed88aa

@ -1 +1 @@
Subproject commit 12c2c628e9e202f1698a4c32e0356d5ca8cb6151 Subproject commit 9bfbacbb30d4673332566f6e4a58fd04e3904106

View file

@ -8,55 +8,65 @@ open import Data.Product
open import Cat.Category open import Cat.Category
open IsCategory open IsCategory
open Category
-- data Path { : Level} {A : Set } : (a b : A) → Set where -- data Path { : Level} {A : Set } : (a b : A) → Set where
-- emptyPath : {a : A} → Path a a -- emptyPath : {a : A} → Path a a
-- concatenate : {a b c : A} → Path a b → Path b c → Path a b -- concatenate : {a b c : A} → Path a b → Path b c → Path a b
-- import Data.List
-- P : (a b : Object ) → Set (')
-- P = {!Data.List.List ?!}
-- Generalized paths:
data Path { ' : Level} {A : Set } (R : A A Set ') : (a b : A) Set ( ') where
empty : {a : A} Path R a a
cons : {a b c : A} R b c Path R a b Path R a c
concatenate _++_ : { '} {A : Set } {a b c : A} {R : A A Set '} Path R b c Path R a b Path R a c
concatenate empty p = p
concatenate (cons x q) p = cons x (concatenate q p)
_++_ = concatenate
singleton : {} {𝓤 : Set } {r} {R : 𝓤 𝓤 Set r} {A B : 𝓤} R A B Path R A B
singleton f = cons f empty
module _ { ' : Level} ( : Category ') where module _ { ' : Level} ( : Category ') where
module = Category module = Category
open Category
-- import Data.List
-- P : (a b : Object ) → Set (')
-- P = {!Data.List.List ?!}
-- Generalized paths:
-- data P { : Level} {A : Set } (R : A → A → Set ) : (a b : A) → Set where
-- e : {a : A} → P R a a
-- c : {a b c : A} → R a b → P R b c → P R a c
-- Path's are like lists with directions.
-- This implementation is specialized to categories.
data Path : (a b : Object ) Set ( ') where
empty : {A : Object } Path A A
cons : {A B C} [ B , C ] Path A B Path A C
concatenate : {A B C : Object } Path B C Path A B Path A C
concatenate empty p = p
concatenate (cons x q) p = cons x (concatenate q p)
private private
module _ {A B C D : Object } where p-assoc : {A B C D : Object} {r : Path Arrow A B} {q : Path Arrow B C} {p : Path Arrow C D}
p-assoc : {r : Path A B} {q : Path B C} {p : Path C D} concatenate p (concatenate q r) concatenate (concatenate p q) r p ++ (q ++ r) (p ++ q) ++ r
p-assoc {r} {q} {p} = {!!} p-assoc {r = r} {q} {empty} = refl
module _ {A B : Object } {p : Path A B} where p-assoc {A} {B} {C} {D} {r = r} {q} {cons x p} = begin
-- postulate cons x p ++ (q ++ r) ≡⟨ cong (cons x) lem
-- ident-r : concatenate {A} {A} {B} p (lift 𝟙) ≡ p cons x ((p ++ q) ++ r) ≡⟨⟩
-- ident-l : concatenate {A} {B} {B} (lift 𝟙) p ≡ p (cons x p ++ q) ++ r
module _ {A B : Object } where where
isSet : Cubical.isSet (Path A B) lem : p ++ (q ++ r) ((p ++ q) ++ r)
isSet = {!!} lem = p-assoc {r = r} {q} {p}
ident-r : {A} {B} {p : Path Arrow A B} concatenate p empty p
ident-r {p = empty} = refl
ident-r {p = cons x p} = cong (cons x) ident-r
ident-l : {A} {B} {p : Path Arrow A B} concatenate empty p p
ident-l = refl
module _ {A B : Object} where
isSet : Cubical.isSet (Path Arrow A B)
isSet a b p q = {!!}
RawFree : RawCategory ( ') RawFree : RawCategory ( ')
RawFree = record RawFree = record
{ Object = Object { Object = Object
; Arrow = Path ; Arrow = Path Arrow
; 𝟙 = λ {o} {!lift 𝟙!} ; 𝟙 = empty
; _∘_ = λ {a b c} {!concatenate {a} {b} {c}!} ; _∘_ = concatenate
} }
RawIsCategoryFree : IsCategory RawFree RawIsCategoryFree : IsCategory RawFree
RawIsCategoryFree = record RawIsCategoryFree = record
{ assoc = {!p-assoc!} { assoc = λ { {f = f} {g} {h} p-assoc {r = f} {g} {h}}
; ident = {!ident-r , ident-l!} ; ident = ident-r , ident-l
; arrowIsSet = {!!} ; arrowIsSet = {!!}
; univalent = {!!} ; univalent = {!!}
} }

View file

@ -9,6 +9,7 @@ import Cubical.GradLemma
module UIP = Cubical.GradLemma module UIP = Cubical.GradLemma
open import Cubical.Sigma open import Cubical.Sigma
open import Cubical.NType open import Cubical.NType
open import Cubical.NType.Properties
open import Data.Nat using (_≤_ ; z≤n ; s≤s) open import Data.Nat using (_≤_ ; z≤n ; s≤s)
module Nat = Data.Nat module Nat = Data.Nat
@ -20,7 +21,7 @@ open import Cat.Equality
open Equality.Data.Product open Equality.Data.Product
module _ {c c' d d' : Level} { : Category c c'} {𝔻 : Category d d'} where module _ {c c' d d' : Level} { : Category c c'} {𝔻 : Category d d'} where
open Category hiding ( _∘_ ; Arrow ) open Category using (Object ; 𝟙)
open Functor open Functor
module _ (F G : Functor 𝔻) where module _ (F G : Functor 𝔻) where
@ -69,7 +70,7 @@ module _ {c c' d d' : Level} { : Category c c'} {𝔻 : Cat
where where
module F = Functor F module F = Functor F
F→ = F.func→ F→ = F.func→
module 𝔻 = IsCategory (isCategory 𝔻) module 𝔻 = Category 𝔻
identityNat : (F : Functor 𝔻) NaturalTransformation F F identityNat : (F : Functor 𝔻) NaturalTransformation F F
identityNat F = identityTrans F , identityNatural F identityNat F = identityTrans F , identityNatural F
@ -94,13 +95,13 @@ module _ {c c' d d' : Level} { : Category c c'} {𝔻 : Cat
𝔻 [ H.func→ f 𝔻 [ θ A η A ] ] ≡⟨⟩ 𝔻 [ H.func→ f 𝔻 [ θ A η A ] ] ≡⟨⟩
𝔻 [ H.func→ f (θ ∘nt η) A ] 𝔻 [ H.func→ f (θ ∘nt η) A ]
where where
open IsCategory (isCategory 𝔻) open Category 𝔻
NatComp = _:⊕:_ NatComp = _:⊕:_
private private
module _ {F G : Functor 𝔻} where module _ {F G : Functor 𝔻} where
module 𝔻 = IsCategory (isCategory 𝔻) module 𝔻 = Category 𝔻
transformationIsSet : isSet (Transformation F G) transformationIsSet : isSet (Transformation F G)
transformationIsSet _ _ p q i j C = 𝔻.arrowIsSet _ _ (λ l p l C) (λ l q l C) i j transformationIsSet _ _ p q i j C = 𝔻.arrowIsSet _ _ (λ l p l C) (λ l q l C) i j
@ -125,18 +126,37 @@ module _ {c c' d d' : Level} { : Category c c'} {𝔻 : Cat
θ = proj₁ θ' θ = proj₁ θ'
η = proj₁ η' η = proj₁ η'
ζ = proj₁ ζ' ζ = proj₁ ζ'
θNat = proj₂ θ'
ηNat = proj₂ η'
ζNat = proj₂ ζ'
L : NaturalTransformation A D
L = (_:⊕:_ {A} {C} {D} ζ' (_:⊕:_ {A} {B} {C} η' θ'))
R : NaturalTransformation A D
R = (_:⊕:_ {A} {B} {D} (_:⊕:_ {B} {C} {D} ζ' η') θ')
_g⊕f_ = _:⊕:_ {A} {B} {C} _g⊕f_ = _:⊕:_ {A} {B} {C}
_h⊕g_ = _:⊕:_ {B} {C} {D} _h⊕g_ = _:⊕:_ {B} {C} {D}
:assoc: : (_:⊕:_ {A} {C} {D} ζ' (_:⊕:_ {A} {B} {C} η' θ')) (_:⊕:_ {A} {B} {D} (_:⊕:_ {B} {C} {D} ζ' η') θ') :assoc: : L R
:assoc: = Σ≡ (funExt (λ _ assoc)) {!!} :assoc: = lemSig (naturalIsProp {F = A} {D})
L R (funExt (λ x assoc))
where where
open IsCategory (isCategory 𝔻) open Category 𝔻
module _ {A B : Functor 𝔻} {f : NaturalTransformation A B} where module _ {A B : Functor 𝔻} {f : NaturalTransformation A B} where
private
allNatural = naturalIsProp {F = A} {B}
f' = proj₁ f
module 𝔻Data = Category 𝔻
eq-r : C (𝔻 [ f' C identityTrans A C ]) f' C
eq-r C = begin
𝔻 [ f' C identityTrans A C ] ≡⟨⟩
𝔻 [ f' C 𝔻Data.𝟙 ] ≡⟨ proj₁ (𝔻.ident {A} {B})
f' C
eq-l : C (𝔻 [ identityTrans B C f' C ]) f' C
eq-l C = proj₂ (𝔻.ident {A} {B})
ident-r : (_:⊕:_ {A} {A} {B} f (identityNat A)) f ident-r : (_:⊕:_ {A} {A} {B} f (identityNat A)) f
ident-r = {!!} ident-r = lemSig allNatural _ _ (funExt eq-r)
ident-l : (_:⊕:_ {A} {B} {B} (identityNat B) f) f ident-l : (_:⊕:_ {A} {B} {B} (identityNat B) f) f
ident-l = {!!} ident-l = lemSig allNatural _ _ (funExt eq-l)
:ident: :ident:
: (_:⊕:_ {A} {A} {B} f (identityNat A)) f : (_:⊕:_ {A} {A} {B} f (identityNat A)) f
× (_:⊕:_ {A} {B} {B} (identityNat B) f) f × (_:⊕:_ {A} {B} {B} (identityNat B) f) f
@ -161,7 +181,7 @@ module _ {c c' d d' : Level} { : Category c c'} {𝔻 : Cat
} }
Fun : Category (c c' d d') (c c' d') Fun : Category (c c' d d') (c c' d')
raw Fun = RawFun Category.raw Fun = RawFun
module _ { ' : Level} ( : Category ') where module _ { ' : Level} ( : Category ') where
open import Cat.Categories.Sets open import Cat.Categories.Sets

View file

@ -9,80 +9,113 @@ import Function
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
open Category
module _ ( : Level) where
private
open RawCategory
open IsCategory
open import Cubical.Univalence
open import Cubical.NType.Properties
open import Cubical.Universe
SetsRaw : RawCategory (lsuc )
Object SetsRaw = Cubical.Universe.0-Set
Arrow SetsRaw (T , _) (U , _) = T U
𝟙 SetsRaw = Function.id
_∘_ SetsRaw = Function._∘_
SetsIsCategory : IsCategory SetsRaw
assoc SetsIsCategory = refl
proj₁ (ident SetsIsCategory) = funExt λ _ refl
proj₂ (ident SetsIsCategory) = funExt λ _ refl
arrowIsSet SetsIsCategory {B = (_ , s)} = setPi λ _ s
univalent SetsIsCategory = {!!}
𝓢𝓮𝓽 Sets : Category (lsuc )
Category.raw 𝓢𝓮𝓽 = SetsRaw
Category.isCategory 𝓢𝓮𝓽 = SetsIsCategory
Sets = 𝓢𝓮𝓽
module _ { : Level} where module _ { : Level} where
SetsRaw : RawCategory (lsuc )
RawCategory.Object SetsRaw = Set
RawCategory.Arrow SetsRaw = λ T U T U
RawCategory.𝟙 SetsRaw = Function.id
RawCategory._∘_ SetsRaw = Function._∘_
open IsCategory
SetsIsCategory : IsCategory SetsRaw
assoc SetsIsCategory = refl
proj₁ (ident SetsIsCategory) = funExt λ _ refl
proj₂ (ident SetsIsCategory) = funExt λ _ refl
arrowIsSet SetsIsCategory = {!!}
univalent SetsIsCategory = {!!}
Sets : Category (lsuc )
raw Sets = SetsRaw
isCategory Sets = SetsIsCategory
private private
module _ {X A B : Set } (f : X A) (g : X B) where 𝓢 = 𝓢𝓮𝓽
_&&&_ : (X A × B) open Category 𝓢
_&&&_ x = f x , g x open import Cubical.Sigma
module _ {X A B : Set } (f : X A) (g : X B) where
lem : Sets [ proj₁ (f &&& g)] f × Sets [ proj₂ (f &&& g)] g
proj₁ lem = refl
proj₂ lem = refl
instance
isProduct : {A B : Object Sets} IsProduct Sets {A} {B} proj₁ proj₂
isProduct f g = f &&& g , lem f g
product : (A B : Object Sets) Product { = Sets} A B module _ (0A 0B : Object) where
product A B = record { obj = A × B ; proj₁ = proj₁ ; proj₂ = proj₂ ; isProduct = isProduct } private
A : Set
A = proj₁ 0A
sA : isSet A
sA = proj₂ 0A
B : Set
B = proj₁ 0B
sB : isSet B
sB = proj₂ 0B
0A×0B : Object
0A×0B = (A × B) , sigPresSet sA λ _ sB
module _ {X A B : Set } (f : X A) (g : X B) where
_&&&_ : (X A × B)
_&&&_ x = f x , g x
module _ {0X : Object} where
X = proj₁ 0X
module _ (f : X A ) (g : X B) where
lem : proj₁ Function.∘′ (f &&& g) f × proj₂ Function.∘′ (f &&& g) g
proj₁ lem = refl
proj₂ lem = refl
instance
isProduct : IsProduct 𝓢 {0A} {0B} {0A×0B} proj₁ proj₂
isProduct {X = X} f g = (f &&& g) , lem {0X = X} f g
product : Product { = 𝓢} 0A 0B
product = record
{ obj = 0A×0B
; proj₁ = Data.Product.proj₁
; proj₂ = Data.Product.proj₂
; isProduct = λ { {X} isProduct {X = X}}
}
instance instance
SetsHasProducts : HasProducts Sets SetsHasProducts : HasProducts 𝓢
SetsHasProducts = record { product = product } SetsHasProducts = record { product = product }
-- Covariant Presheaf module _ {a b : Level} where
Representable : { ' : Level} ( : Category ') Set ( lsuc ') module _ ( : Category a b) where
Representable {' = '} = Functor (Sets {'}) -- Covariant Presheaf
Representable : Set (a lsuc b)
Representable = Functor (𝓢𝓮𝓽 b)
-- The "co-yoneda" embedding. -- Contravariant Presheaf
representable : { '} { : Category '} Category.Object Representable Presheaf : Set (a lsuc b)
representable { = } A = record Presheaf = Functor (Opposite ) (𝓢𝓮𝓽 b)
{ raw = record
{ func* = λ B [ A , B ]
; func→ = [_∘_]
}
; isFunctor = record
{ ident = funExt λ _ proj₂ ident
; distrib = funExt λ x sym assoc
}
}
where
open IsCategory (isCategory )
-- Contravariant Presheaf -- The "co-yoneda" embedding.
Presheaf : { '} ( : Category ') Set ( lsuc ') representable : { : Category a b} Category.Object Representable
Presheaf {' = '} = Functor (Opposite ) (Sets {'}) representable { = } A = record
{ raw = record
-- Alternate name: `yoneda` { func* = λ B [ A , B ] , arrowIsSet
presheaf : { ' : Level} { : Category '} Category.Object (Opposite ) Presheaf ; func→ = [_∘_]
presheaf { = } B = record }
{ raw = record ; isFunctor = record
{ func* = λ A [ A , B ] { ident = funExt λ _ proj₂ ident
; func→ = λ f g [ g f ] ; distrib = funExt λ x sym assoc
} }
; isFunctor = record
{ ident = funExt λ x proj₁ ident
; distrib = funExt λ x assoc
} }
} where
where open Category
open IsCategory (isCategory )
-- Alternate name: `yoneda`
presheaf : { : Category a b} Category.Object (Opposite ) Presheaf
presheaf { = } B = record
{ raw = record
{ func* = λ A [ A , B ] , arrowIsSet
; func→ = λ f g [ g f ]
}
; isFunctor = record
{ ident = funExt λ x proj₁ ident
; distrib = funExt λ x assoc
}
}
where
open Category

View file

@ -14,6 +14,8 @@ import Function
open import Cubical open import Cubical
open import Cubical.NType.Properties using ( propIsEquiv ) open import Cubical.NType.Properties using ( propIsEquiv )
open import Cat.Wishlist
∃! : {a b} {A : Set a} ∃! : {a b} {A : Set a}
(A Set b) Set (a b) (A Set b) Set (a b)
∃! = ∃!≈ _≡_ ∃! = ∃!≈ _≡_
@ -23,64 +25,39 @@ open import Cubical.NType.Properties using ( propIsEquiv )
syntax ∃!-syntax (λ x B) = ∃![ x ] B syntax ∃!-syntax (λ x B) = ∃![ x ] B
-- This follows from [HoTT-book: §7.1.10] record RawCategory (a b : Level) : Set (lsuc (a b)) where
-- Andrea says the proof is in `cubical` but I can't find it.
postulate isSetIsProp : { : Level} {A : Set } isProp (isSet A)
record RawCategory ( ' : Level) : Set (lsuc (' )) where
-- adding no-eta-equality can speed up type-checking.
-- ONLY IF you define your categories with copatterns though.
no-eta-equality no-eta-equality
field field
-- Need something like: Object : Set a
-- Object : Σ (Set ) isGroupoid Arrow : Object Object Set b
Object : Set 𝟙 : {A : Object} Arrow A A
-- And:
-- Arrow : Object → Object → Σ (Set ') isSet
Arrow : Object Object Set '
𝟙 : {o : Object} Arrow o o
_∘_ : {A B C : Object} Arrow B C Arrow A B Arrow A C _∘_ : {A B C : Object} Arrow B C Arrow A B Arrow A C
infixl 10 _∘_ infixl 10 _∘_
domain : { a b : Object } Arrow a b Object domain : { a b : Object } Arrow a b Object
domain {a = a} _ = a domain {a = a} _ = a
codomain : { a b : Object } Arrow a b Object codomain : { a b : Object } Arrow a b Object
codomain {b = b} _ = b codomain {b = b} _ = b
-- Thierry: All projections must be `isProp`'s IsAssociative : Set (a b)
IsAssociative = {A B C D} {f : Arrow A B} {g : Arrow B C} {h : Arrow C D}
h (g f) (h g) f
-- According to definitions 9.1.1 and 9.1.6 in the HoTT book the IsIdentity : ({A : Object} Arrow A A) Set (a b)
-- arrows of a category form a set (arrow-is-set), and there is an IsIdentity id = {A B : Object} {f : Arrow A B}
-- equivalence between the equality of objects and isomorphisms f id f × id f f
-- (univalent).
record IsCategory {a b : Level} ( : RawCategory a b) : Set (lsuc (a b)) where IsInverseOf : {A B} (Arrow A B) (Arrow B A) Set b
open RawCategory IsInverseOf = λ f g g f 𝟙 × f g 𝟙
module Raw = RawCategory
field
assoc : {A B C D : Object} { f : Arrow A B } { g : Arrow B C } { h : Arrow C D }
h (g f) (h g) f
ident : {A B : Object} {f : Arrow A B}
f 𝟙 f × 𝟙 f f
arrowIsSet : {A B : Object} isSet (Arrow A B)
Isomorphism : {A B} (f : Arrow A B) Set b Isomorphism : {A B} (f : Arrow A B) Set b
Isomorphism {A} {B} f = Σ[ g Arrow B A ] g f 𝟙 × f g 𝟙 Isomorphism {A} {B} f = Σ[ g Arrow B A ] IsInverseOf f g
_≅_ : (A B : Object) Set b _≅_ : (A B : Object) Set b
_≅_ A B = Σ[ f Arrow A B ] (Isomorphism f) _≅_ A B = Σ[ f Arrow A B ] (Isomorphism f)
idIso : (A : Object) A A
idIso A = 𝟙 , (𝟙 , ident)
id-to-iso : (A B : Object) A B A B
id-to-iso A B eq = transp (\ i A eq i) (idIso A)
-- TODO: might want to implement isEquiv differently, there are 3
-- equivalent formulations in the book.
Univalent : Set (a b)
Univalent = {A B : Object} isEquiv (A B) (A B) (id-to-iso A B)
field
univalent : Univalent
module _ {A B : Object} where module _ {A B : Object} where
Epimorphism : {X : Object } (f : Arrow A B) Set b Epimorphism : {X : Object } (f : Arrow A B) Set b
Epimorphism {X} f = ( g₀ g₁ : Arrow B X ) g₀ f g₁ f g₀ g₁ Epimorphism {X} f = ( g₀ g₁ : Arrow B X ) g₀ f g₁ f g₀ g₁
@ -88,69 +65,137 @@ record IsCategory {a b : Level} ( : RawCategory a b) : Set (lsuc
Monomorphism : {X : Object} (f : Arrow A B) Set b Monomorphism : {X : Object} (f : Arrow A B) Set b
Monomorphism {X} f = ( g₀ g₁ : Arrow X A ) f g₀ f g₁ g₀ g₁ Monomorphism {X} f = ( g₀ g₁ : Arrow X A ) f g₀ f g₁ g₀ g₁
module _ {a} {b} { : RawCategory a b} where IsInitial : Object Set (a b)
-- TODO, provable by using arrow-is-set and that isProp (isEquiv _ _ _) IsInitial I = {X : Object} isContr (Arrow I X)
-- This lemma will be useful to prove the equality of two categories.
IsCategory-is-prop : isProp (IsCategory )
IsCategory-is-prop x y i = record
-- Why choose `x`'s `arrowIsSet`?
{ assoc = x.arrowIsSet _ _ x.assoc y.assoc i
; ident =
( x.arrowIsSet _ _ (fst x.ident) (fst y.ident) i
, x.arrowIsSet _ _ (snd x.ident) (snd y.ident) i
)
; arrowIsSet = isSetIsProp x.arrowIsSet y.arrowIsSet i
; univalent = {!!}
}
where
module x = IsCategory x
module y = IsCategory y
xuni : x.Univalent
xuni = x.univalent
yuni : y.Univalent
yuni = y.univalent
open RawCategory
T : I Set (a b)
T i = {A B : Object}
isEquiv (A B) (A x.≅ B)
(λ A≡B
transp
(λ j
Σ-syntax (Arrow A (A≡B j))
(λ f Σ-syntax (Arrow (A≡B j) A) (λ g g f 𝟙 × f g 𝟙)))
( 𝟙
, 𝟙
, x.arrowIsSet _ _ (fst x.ident) (fst y.ident) i
, x.arrowIsSet _ _ (snd x.ident) (snd y.ident) i
)
)
eqUni : T [ xuni yuni ]
eqUni = {!!}
IsTerminal : Object Set (a b)
IsTerminal T = {X : Object} isContr (Arrow X T)
Initial : Set (a b)
Initial = Σ Object IsInitial
Terminal : Set (a b)
Terminal = Σ Object IsTerminal
-- Univalence is indexed by a raw category as well as an identity proof.
module Univalence {a b : Level} ( : RawCategory a b) where
open RawCategory
module _ (ident : IsIdentity 𝟙) where
idIso : (A : Object) A A
idIso A = 𝟙 , (𝟙 , ident)
-- Lemma 9.1.4 in [HoTT]
id-to-iso : (A B : Object) A B A B
id-to-iso A B eq = transp (\ i A eq i) (idIso A)
-- TODO: might want to implement isEquiv
-- differently, there are 3
-- equivalent formulations in the book.
Univalent : Set (a b)
Univalent = {A B : Object} isEquiv (A B) (A B) (id-to-iso A B)
record IsCategory {a b : Level} ( : RawCategory a b) : Set (lsuc (a b)) where
open RawCategory
open Univalence public
field
assoc : IsAssociative
ident : IsIdentity 𝟙
arrowIsSet : {A B : Object} isSet (Arrow A B)
univalent : Univalent ident
-- `IsCategory` is a mere proposition.
module _ {a b : Level} {C : RawCategory a b} where
open RawCategory C
module _ ( : IsCategory C) where
open IsCategory
open import Cubical.NType
open import Cubical.NType.Properties
propIsAssociative : isProp IsAssociative
propIsAssociative x y i = arrowIsSet _ _ x y i
propIsIdentity : {f : {A} Arrow A A} isProp (IsIdentity f)
propIsIdentity a b i
= arrowIsSet _ _ (fst a) (fst b) i
, arrowIsSet _ _ (snd a) (snd b) i
propArrowIsSet : isProp ( {A B} isSet (Arrow A B))
propArrowIsSet a b i = isSetIsProp a b i
propIsInverseOf : {A B f g} isProp (IsInverseOf {A} {B} f g)
propIsInverseOf x y = λ i
let
h : fst x fst y
h = arrowIsSet _ _ (fst x) (fst y)
hh : snd x snd y
hh = arrowIsSet _ _ (snd x) (snd y)
in h i , hh i
module _ {A B : Object} {f : Arrow A B} where
isoIsProp : isProp (Isomorphism f)
isoIsProp a@(g , η , ε) a'@(g' , η' , ε') =
lemSig (λ g propIsInverseOf) a a' geq
where
open Cubical.NType.Properties
geq : g g'
geq = begin
g ≡⟨ sym (fst ident)
g 𝟙 ≡⟨ cong (λ φ g φ) (sym ε')
g (f g') ≡⟨ assoc
(g f) g' ≡⟨ cong (λ φ φ g') η
𝟙 g' ≡⟨ snd ident
g'
propUnivalent : isProp (Univalent ident)
propUnivalent a b i = propPi (λ iso propHasLevel ⟨-2⟩) a b i
private
module _ (x y : IsCategory C) where
module IC = IsCategory
module X = IsCategory x
module Y = IsCategory y
open Univalence C
-- In a few places I use the result of propositionality of the various
-- projections of `IsCategory` - I've arbitrarily chosed to use this
-- result from `x : IsCategory C`. I don't know which (if any) possibly
-- adverse effects this may have.
ident : (λ _ IsIdentity 𝟙) [ X.ident Y.ident ]
ident = propIsIdentity x X.ident Y.ident
done : x y
U : {a : IsIdentity 𝟙} (λ _ IsIdentity 𝟙) [ X.ident a ] (b : Univalent a) Set _
U eqwal bbb = (λ i Univalent (eqwal i)) [ X.univalent bbb ]
P : (y : IsIdentity 𝟙)
(λ _ IsIdentity 𝟙) [ X.ident y ] Set _
P y eq = (b' : Univalent y) U eq b'
helper : (b' : Univalent X.ident)
(λ _ Univalent X.ident) [ X.univalent b' ]
helper univ = propUnivalent x X.univalent univ
foo = pathJ P helper Y.ident ident
eqUni : U ident Y.univalent
eqUni = foo Y.univalent
IC.assoc (done i) = propIsAssociative x X.assoc Y.assoc i
IC.ident (done i) = ident i
IC.arrowIsSet (done i) = propArrowIsSet x X.arrowIsSet Y.arrowIsSet i
IC.univalent (done i) = eqUni i
propIsCategory : isProp (IsCategory C)
propIsCategory = done
record Category (a b : Level) : Set (lsuc (a b)) where record Category (a b : Level) : Set (lsuc (a b)) where
field field
raw : RawCategory a b raw : RawCategory a b
{{isCategory}} : IsCategory raw {{isCategory}} : IsCategory raw
private open RawCategory raw public
module = RawCategory raw open IsCategory isCategory public
Object : Set a
Object = .Object
Arrow = .Arrow
𝟙 = .𝟙
_∘_ = ._∘_
module _ {a b : Level} ( : Category a b) where
open Category
_[_,_] : (A : Object) (B : Object) Set b _[_,_] : (A : Object) (B : Object) Set b
_[_,_] = .Arrow _[_,_] = Arrow
_[_∘_] : {A B C : Object} (g : .Arrow B C) (f : .Arrow A B) .Arrow A C
_[_∘_] = ._∘_
_[_∘_] : {A B C : Object} (g : Arrow B C) (f : Arrow A B) Arrow A C
_[_∘_] = _∘_
module _ {a b : Level} ( : Category a b) where module _ {a b : Level} ( : Category a b) where
private private
@ -162,8 +207,6 @@ module _ {a b : Level} ( : Category a b) where
RawCategory.𝟙 OpRaw = 𝟙 RawCategory.𝟙 OpRaw = 𝟙
RawCategory._∘_ OpRaw = Function.flip _∘_ RawCategory._∘_ OpRaw = Function.flip _∘_
open IsCategory isCategory
OpIsCategory : IsCategory OpRaw OpIsCategory : IsCategory OpRaw
IsCategory.assoc OpIsCategory = sym assoc IsCategory.assoc OpIsCategory = sym assoc
IsCategory.ident OpIsCategory = swap ident IsCategory.ident OpIsCategory = swap ident
@ -199,20 +242,3 @@ module _ {a b : Level} { : Category a b} where
Opposite-is-involution : Opposite (Opposite ) Opposite-is-involution : Opposite (Opposite )
raw (Opposite-is-involution i) = rawOp i raw (Opposite-is-involution i) = rawOp i
isCategory (Opposite-is-involution i) = rawIsCat i isCategory (Opposite-is-involution i) = rawIsCat i
module _ {a b : Level} ( : Category a b) where
open Category
unique = isContr
IsInitial : Object Set (a b)
IsInitial I = {X : Object } unique ( [ I , X ])
IsTerminal : Object Set (a b)
-- ∃![ ? ] ?
IsTerminal T = {X : Object } unique ( [ X , T ])
Initial : Set (a b)
Initial = Σ (Object ) IsInitial
Terminal : Set (a b)
Terminal = Σ (Object ) IsTerminal

View file

@ -47,7 +47,6 @@ module _ {c c' d d'}
open IsFunctor open IsFunctor
open Functor open Functor
-- TODO: Is `IsFunctor` a proposition?
module _ module _
{a b : Level} {a b : Level}
{ 𝔻 : Category a b} { 𝔻 : Category a b}
@ -56,11 +55,8 @@ module _
private private
module 𝔻 = IsCategory (isCategory 𝔻) module 𝔻 = IsCategory (isCategory 𝔻)
-- isProp : Set propIsFunctor : isProp (IsFunctor _ _ F)
-- isProp = (x y : A) → x ≡ y propIsFunctor isF0 isF1 i = record
IsFunctorIsProp : isProp (IsFunctor _ _ F)
IsFunctorIsProp isF0 isF1 i = record
{ ident = 𝔻.arrowIsSet _ _ isF0.ident isF1.ident i { ident = 𝔻.arrowIsSet _ _ isF0.ident isF1.ident i
; distrib = 𝔻.arrowIsSet _ _ isF0.distrib isF1.distrib i ; distrib = 𝔻.arrowIsSet _ _ isF0.distrib isF1.distrib i
} }
@ -81,7 +77,7 @@ module _
IsFunctorIsProp' : IsProp' λ i IsFunctor _ _ (F i) IsFunctorIsProp' : IsProp' λ i IsFunctor _ _ (F i)
IsFunctorIsProp' isF0 isF1 = lemPropF {B = IsFunctor 𝔻} IsFunctorIsProp' isF0 isF1 = lemPropF {B = IsFunctor 𝔻}
(\ F IsFunctorIsProp {F = F}) (\ i F i) (\ F propIsFunctor {F = F}) (\ i F i)
where where
open import Cubical.NType.Properties using (lemPropF) open import Cubical.NType.Properties using (lemPropF)

View file

@ -14,7 +14,6 @@ open Equality.Data.Product
module _ { ' : Level} { : Category '} { A B : Category.Object } {X : Category.Object } (f : Category.Arrow A B) where module _ { ' : Level} { : Category '} { A B : Category.Object } {X : Category.Object } (f : Category.Arrow A B) where
open Category open Category
open IsCategory (isCategory)
iso-is-epi : Isomorphism f Epimorphism {X = X} f iso-is-epi : Isomorphism f Epimorphism {X = X} f
iso-is-epi (f- , left-inv , right-inv) g₀ g₁ eq = begin iso-is-epi (f- , left-inv , right-inv) g₀ g₁ eq = begin

View file

@ -1,6 +1,15 @@
module Cat.Wishlist where module Cat.Wishlist where
open import Level
open import Cubical.NType open import Cubical.NType
open import Data.Nat using (_≤_ ; z≤n ; s≤s) open import Data.Nat using (_≤_ ; z≤n ; s≤s)
postulate ntypeCommulative : { n m} {A : Set } n m HasLevel n ⟩₋₂ A HasLevel m ⟩₋₂ A postulate ntypeCommulative : { n m} {A : Set } n m HasLevel n ⟩₋₂ A HasLevel m ⟩₋₂ A
module _ { : Level} {A : Set } where
-- This is §7.1.10 in [HoTT]. Andrea says the proof is in `cubical` but I
-- can't find it.
postulate propHasLevel : n isProp (HasLevel n A)
isSetIsProp : isProp (isSet A)
isSetIsProp = propHasLevel (S (S ⟨-2⟩))