"re-delegate" projections in new module Category

This commit is contained in:
Frederik Hanghøj Iversen 2018-02-05 12:21:39 +01:00
parent 22a9a71870
commit 8022ed349d
7 changed files with 77 additions and 70 deletions

View file

@ -16,11 +16,11 @@ module _ {c c' d d' : Level} { : Category c c'} {𝔻 : Cat
module _ (F G : Functor 𝔻) where
-- What do you call a non-natural tranformation?
Transformation : Set (c d')
Transformation = (C : .Object) 𝔻 [ F .func* C , G .func* C ]
Transformation = (C : Object ) 𝔻 [ F .func* C , G .func* C ]
Natural : Transformation Set (c (c' d'))
Natural θ
= {A B : .Object}
= {A B : Object }
(f : [ A , B ])
𝔻 [ θ B F .func→ f ] 𝔻 [ G .func→ f θ A ]
@ -34,7 +34,7 @@ module _ {c c' d d' : Level} { : Category c c'} {𝔻 : Cat
NaturalTransformation≡ : {α β : NaturalTransformation F G}
(eq₁ : α .proj₁ β .proj₁)
(eq₂ : PathP
(λ i {A B : .Object} (f : [ A , B ])
(λ i {A B : Object } (f : [ A , B ])
𝔻 [ eq₁ i B F .func→ f ]
𝔻 [ G .func→ f eq₁ i A ])
(α .proj₂) (β .proj₂))
@ -42,14 +42,14 @@ module _ {c c' d d' : Level} { : Category c c'} {𝔻 : Cat
NaturalTransformation≡ eq₁ eq₂ i = eq₁ i , eq₂ i
identityTrans : (F : Functor 𝔻) Transformation F F
identityTrans F C = 𝔻 .𝟙
identityTrans F C = 𝟙 𝔻
identityNatural : (F : Functor 𝔻) Natural F F (identityTrans F)
identityNatural F {A = A} {B = B} f = begin
𝔻 [ identityTrans F B F→ f ] ≡⟨⟩
𝔻 [ 𝔻 .𝟙 F→ f ] ≡⟨ proj₂ 𝔻.ident
𝔻 [ 𝟙 𝔻 F→ f ] ≡⟨ proj₂ 𝔻.ident
F→ f ≡⟨ sym (proj₁ 𝔻.ident)
𝔻 [ F→ f 𝔻 .𝟙 ] ≡⟨⟩
𝔻 [ F→ f 𝟙 𝔻 ] ≡⟨⟩
𝔻 [ F→ f identityTrans F A ]
where
F→ = F .func→

View file

@ -39,10 +39,10 @@ module _ { : Level} where
proj₁ lem = refl
proj₂ lem = refl
instance
isProduct : {A B : Sets .Object} IsProduct Sets {A} {B} proj₁ proj₂
isProduct : {A B : Object Sets} IsProduct Sets {A} {B} proj₁ proj₂
isProduct f g = f &&& g , lem f g
product : (A B : Sets .Object) Product { = Sets} A B
product : (A B : Object Sets) Product { = Sets} A B
product A B = record { obj = A × B ; proj₁ = proj₁ ; proj₂ = proj₂ ; isProduct = isProduct }
instance
@ -56,8 +56,8 @@ Representable {' = '} = Functor (Sets {'})
-- The "co-yoneda" embedding.
representable : { '} { : Category '} Category.Object Representable
representable { = } A = record
{ func* = λ B .Arrow A B
; func→ = ._∘_
{ func* = λ B [ A , B ]
; func→ = [_∘_]
; isFunctor = record
{ ident = funExt λ _ proj₂ ident
; distrib = funExt λ x sym assoc
@ -73,8 +73,8 @@ Presheaf {' = '} = Functor (Opposite ) (Sets {'})
-- Alternate name: `yoneda`
presheaf : { ' : Level} { : Category '} Category.Object (Opposite ) Presheaf
presheaf { = } B = record
{ func* = λ A .Arrow A B
; func→ = λ f g ._∘_ g f
{ func* = λ A [ A , B ]
; func→ = λ f g [ g f ]
; isFunctor = record
{ ident = funExt λ x proj₁ ident
; distrib = funExt λ x assoc

View file

@ -114,27 +114,34 @@ Category a b = Σ (RawCategory a b) IsCategory
module Category {a b : Level} ( : Category a b) where
raw = fst
open RawCategory raw public
isCategory = snd
open RawCategory
private
module = RawCategory raw
-- _∈_ : ∀ {a b} ( : Category a b) → ( .fst .Object → Set b) → Set (a ⊔ b)
-- A ∈ =
Object : Set a
Object = .Object
Obj : {a b} Category a b Set a
Obj = .fst .Object
Arrow = .Arrow
_[_,_] : { '} ( : Category ') (A : Obj ) (B : Obj ) Set '
[ A , B ] = .fst .Arrow A B
𝟙 = .𝟙
_[_∘_] : { '} ( : Category ') {A B C : Obj } (g : [ B , C ]) (f : [ A , B ]) [ A , C ]
[ g f ] = .fst ._∘_ g f
_∘_ = ._∘_
module _ { ' : Level} ( : Category ') {A B obj : Obj } where
_[_,_] : (A : Object) (B : Object) Set b
_[_,_] = .Arrow
_[_∘_] : {A B C : Object} (g : .Arrow B C) (f : .Arrow A B) .Arrow A C
_[_∘_] = ._∘_
open Category using ( Object ; _[_,_] ; _[_∘_])
-- open RawCategory
module _ { ' : Level} ( : Category ') {A B obj : Object } where
IsProduct : (π₁ : [ obj , A ]) (π₂ : [ obj , B ]) Set ( ')
IsProduct π₁ π₂
= {X : Obj } (x₁ : [ X , A ]) (x₂ : [ X , B ])
= {X : Object } (x₁ : [ X , A ]) (x₂ : [ X , B ])
∃![ x ] ( [ π₁ x ] x₁ × [ π₂ x ] x₂)
-- Tip from Andrea; Consider this style for efficiency:
@ -144,10 +151,10 @@ module _ { ' : Level} ( : Category ') {A B obj : Obj } where
-- isProduct : ∀ {X : .Object} (x₁ : .Arrow X A) (x₂ : .Arrow X B)
-- → ∃![ x ] ( ._⊕_ π₁ x ≡ x₁ × . _⊕_ π₂ x ≡ x₂)
record Product { ' : Level} { : Category '} (A B : Obj ) : Set ( ') where
record Product { ' : Level} { : Category '} (A B : Object ) : Set ( ') where
no-eta-equality
field
obj : Obj
obj : Object
proj₁ : [ obj , A ]
proj₂ : [ obj , B ]
{{isProduct}} : IsProduct proj₁ proj₂
@ -158,15 +165,15 @@ record Product { ' : Level} { : Category '} (A B : Obj ) : Se
record HasProducts { ' : Level} ( : Category ') : Set ( ') where
field
product : (A B : Obj ) Product { = } A B
product : (A B : Object ) Product { = } A B
open Product
objectProduct : (A B : Obj ) Obj
objectProduct : (A B : Object ) Object
objectProduct A B = Product.obj (product A B)
-- The product mentioned in awodey in Def 6.1 is not the regular product of arrows.
-- It's a "parallel" product
parallelProduct : {A A' B B' : Obj } [ A , A' ] [ B , B' ]
parallelProduct : {A A' B B' : Object } [ A , A' ] [ B , B' ]
[ objectProduct A B , objectProduct A' B' ]
parallelProduct {A = A} {A' = A'} {B = B} {B' = B'} a b = arrowProduct (product A' B')
( [ a (product A B) .proj₁ ])
@ -209,30 +216,30 @@ module _ { '} ( : Category ') {{hasProducts : HasProducts }}
open HasProducts hasProducts
open Product hiding (obj)
private
_×p_ : (A B : Obj ) Obj
_×p_ : (A B : Object ) Object
_×p_ A B = Product.obj (product A B)
module _ (B C : Obj ) where
IsExponential : (Cᴮ : Obj ) [ Cᴮ ×p B , C ] Set ( ')
IsExponential Cᴮ eval = (A : Obj ) (f : [ A ×p B , C ])
∃![ f~ ] ( [ eval parallelProduct f~ (Category.raw .𝟙)] f)
module _ (B C : Object ) where
IsExponential : (Cᴮ : Object ) [ Cᴮ ×p B , C ] Set ( ')
IsExponential Cᴮ eval = (A : Object ) (f : [ A ×p B , C ])
∃![ f~ ] ( [ eval parallelProduct f~ (Category.𝟙 )] f)
record Exponential : Set ( ') where
field
-- obj ≡ Cᴮ
obj : Obj
obj : Object
eval : [ obj ×p B , C ]
{{isExponential}} : IsExponential obj eval
-- If I make this an instance-argument then the instance resolution
-- algorithm goes into an infinite loop. Why?
exponentialsHaveProducts : HasProducts
exponentialsHaveProducts = hasProducts
transpose : (A : Obj ) [ A ×p B , C ] [ A , obj ]
transpose : (A : Object ) [ A ×p B , C ] [ A , obj ]
transpose A f = fst (isExponential A f)
record HasExponentials { ' : Level} ( : Category ') {{_ : HasProducts }} : Set ( ') where
field
exponent : (A B : Obj ) Exponential A B
exponent : (A B : Object ) Exponential A B
record CartesianClosed { ' : Level} ( : Category ') : Set ( ') where
field
@ -242,15 +249,15 @@ record CartesianClosed { ' : Level} ( : Category ') : Set (
module _ {a b : Level} ( : Category a b) where
unique = isContr
IsInitial : Obj Set (a b)
IsInitial I = {X : Obj } unique ( [ I , X ])
IsInitial : Object Set (a b)
IsInitial I = {X : Object } unique ( [ I , X ])
IsTerminal : Obj Set (a b)
IsTerminal : Object Set (a b)
-- ∃![ ? ] ?
IsTerminal T = {X : Obj } unique ( [ X , T ])
IsTerminal T = {X : Object } unique ( [ X , T ])
Initial : Set (a b)
Initial = Σ (Obj ) IsInitial
Initial = Σ (Object ) IsInitial
Terminal : Set (a b)
Terminal = Σ (Obj ) IsTerminal
Terminal = Σ (Object ) IsTerminal

View file

@ -12,23 +12,23 @@ module _ { ' : Level} ( : Category ') where
open module = Category
postulate
Path : ( a b : Obj ) Set '
emptyPath : (o : Obj ) Path o o
concatenate : {a b c : Obj } Path b c Path a b Path a c
Path : (a b : .Object) Set '
emptyPath : (o : .Object) Path o o
concatenate : {a b c : .Object} Path b c Path a b Path a c
private
module _ {A B C D : Obj } {r : Path A B} {q : Path B C} {p : Path C D} where
module _ {A B C D : .Object} {r : Path A B} {q : Path B C} {p : Path C D} where
postulate
p-assoc : concatenate {A} {C} {D} p (concatenate {A} {B} {C} q r)
concatenate {A} {B} {D} (concatenate {B} {C} {D} p q) r
module _ {A B : Obj } {p : Path A B} where
module _ {A B : .Object} {p : Path A B} where
postulate
ident-r : concatenate {A} {A} {B} p (emptyPath A) p
ident-l : concatenate {A} {B} {B} (emptyPath B) p p
RawFree : RawCategory '
RawFree = record
{ Object = Obj
{ Object = .Object
; Arrow = Path
; 𝟙 = λ {o} emptyPath o
; _∘_ = λ {a b c} concatenate {a} {b} {c}

View file

@ -12,7 +12,7 @@ open import Cat.Categories.Sets
open import Cat.Equality
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 IsCategory (isCategory)

View file

@ -17,20 +17,20 @@ module _ {a b : Level} where
-- "A base category"
: Category a b
-- It's objects are called contexts
Contexts = .Object
Contexts = Object
-- It's arrows are called substitutions
Substitutions = .Arrow
Substitutions = Arrow
field
-- A functor T
T : Functor (Opposite ) (Fam a b)
-- Empty context
[] : Terminal
Type : (Γ : .Object) Set a
Type : (Γ : Object ) Set a
Type Γ = proj₁ (T .func* Γ)
module _ {Γ : .Object} {A : Type Γ} where
module _ {Γ : Object } {A : Type Γ} where
module _ {A B : .Object} {γ : [ A , B ]} where
module _ {A B : Object } {γ : [ A , B ]} where
k : Σ (proj₁ (func* T B) proj₁ (func* T A))
(λ f
{x : proj₁ (func* T B)}
@ -44,8 +44,8 @@ module _ {a b : Level} where
record ContextComprehension : Set (a b) where
field
Γ&A : .Object
proj1 : .Arrow Γ&A Γ
Γ&A : Object
proj1 : [ Γ&A , Γ ]
-- proj2 : ????
-- if γ : [ A , B ]

View file

@ -10,20 +10,20 @@ open Category hiding (_∘_)
module _ {c c' d d'} ( : Category c c') (𝔻 : Category d d') where
record IsFunctor
(func* : Obj Obj 𝔻)
(func→ : {A B : Obj } [ A , B ] 𝔻 [ func* A , func* B ])
(func* : Object Object 𝔻)
(func→ : {A B : Object } [ A , B ] 𝔻 [ func* A , func* B ])
: Set (c c' d d') where
field
ident : {c : Obj } 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 ]
record Functor : Set (c c' d d') where
field
func* : .Object 𝔻 .Object
func* : Object Object 𝔻
func→ : {A B} [ A , B ] 𝔻 [ func* A , func* B ]
{{isFunctor}} : IsFunctor func* func→
@ -33,11 +33,11 @@ open Functor
module _ { ' : Level} { 𝔻 : Category '} where
IsFunctor≡
: {func* : .Object 𝔻 .Object}
{func→ : {A B : .Object} .Arrow A B 𝔻 .Arrow (func* A) (func* B)}
: {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})
: (λ i {A} func→ (𝟙 {A}) 𝟙 𝔻 {func* A})
[ F .ident G .ident ])
(eqD :
(λ i {A B C} {f : [ A , B ]} {g : [ B , C ]}
@ -61,7 +61,7 @@ module _ { ' : Level} {A B C : Category '} (F : Functor B C) (G : F
F→ = F .func→
G* = G .func*
G→ = G .func→
module _ {a0 a1 a2 : A .Object} {α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 = begin
@ -77,10 +77,10 @@ module _ { ' : Level} {A B C : Category '} (F : Functor B C) (G : F
; func→ = F→ G→
; isFunctor = record
{ ident = begin
(F→ G→) (A .𝟙) ≡⟨ refl
F→ (G→ (A .𝟙)) ≡⟨ cong F→ (G .isFunctor .ident)
F→ (B .𝟙) ≡⟨ F .isFunctor .ident
C .𝟙
(F→ G→) (𝟙 A) ≡⟨ refl
F→ (G→ (𝟙 A)) ≡⟨ cong F→ (G .isFunctor .ident)
F→ (𝟙 B) ≡⟨ F .isFunctor .ident
𝟙 C
; distrib = dist
}
}