From 8022ed349d8c4259cb52700d68091216d41b340f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20Hangh=C3=B8j=20Iversen?= Date: Mon, 5 Feb 2018 12:21:39 +0100 Subject: [PATCH 1/9] "re-delegate" projections in new module `Category` --- src/Cat/Categories/Fun.agda | 12 +++--- src/Cat/Categories/Sets.agda | 12 +++--- src/Cat/Category.agda | 69 ++++++++++++++++++-------------- src/Cat/Category/Free.agda | 12 +++--- src/Cat/Category/Properties.agda | 2 +- src/Cat/CwF.agda | 14 +++---- src/Cat/Functor.agda | 26 ++++++------ 7 files changed, 77 insertions(+), 70 deletions(-) diff --git a/src/Cat/Categories/Fun.agda b/src/Cat/Categories/Fun.agda index 3778cdb..6719ac6 100644 --- a/src/Cat/Categories/Fun.agda +++ b/src/Cat/Categories/Fun.agda @@ -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→ diff --git a/src/Cat/Categories/Sets.agda b/src/Cat/Categories/Sets.agda index e9c93bd..259ec44 100644 --- a/src/Cat/Categories/Sets.agda +++ b/src/Cat/Categories/Sets.agda @@ -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 diff --git a/src/Cat/Category.agda b/src/Cat/Category.agda index 4154dce..bdb632c 100644 --- a/src/Cat/Category.agda +++ b/src/Cat/Category.agda @@ -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 diff --git a/src/Cat/Category/Free.agda b/src/Cat/Category/Free.agda index 1225aa3..c8732d1 100644 --- a/src/Cat/Category/Free.agda +++ b/src/Cat/Category/Free.agda @@ -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} diff --git a/src/Cat/Category/Properties.agda b/src/Cat/Category/Properties.agda index 20631e4..2477447 100644 --- a/src/Cat/Category/Properties.agda +++ b/src/Cat/Category/Properties.agda @@ -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) diff --git a/src/Cat/CwF.agda b/src/Cat/CwF.agda index 9313885..c3099ca 100644 --- a/src/Cat/CwF.agda +++ b/src/Cat/CwF.agda @@ -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 ] diff --git a/src/Cat/Functor.agda b/src/Cat/Functor.agda index e88238d..890801b 100644 --- a/src/Cat/Functor.agda +++ b/src/Cat/Functor.agda @@ -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 } } From 20dc9d26acfba4da7fe6bcbcff77f55e53a2f70c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20Hangh=C3=B8j=20Iversen?= Date: Mon, 5 Feb 2018 14:08:30 +0100 Subject: [PATCH 2/9] Move product, exponential and cart closed to own file --- src/Cat.agda | 5 +++ src/Cat/CartesianClosed.agda | 12 ++++++ src/Cat/Categories/Sets.agda | 1 + src/Cat/Category.agda | 77 ------------------------------------ src/Cat/Exponential.agda | 39 ++++++++++++++++++ src/Cat/Product.agda | 50 +++++++++++++++++++++++ 6 files changed, 107 insertions(+), 77 deletions(-) create mode 100644 src/Cat/CartesianClosed.agda create mode 100644 src/Cat/Exponential.agda create mode 100644 src/Cat/Product.agda diff --git a/src/Cat.agda b/src/Cat.agda index 4cb7bb8..edf98de 100644 --- a/src/Cat.agda +++ b/src/Cat.agda @@ -3,10 +3,15 @@ module Cat where import Cat.Category import Cat.Functor import Cat.CwF +import Cat.CartesianClosed +import Cat.Exponential +import Cat.Product + import Cat.Category.Pathy import Cat.Category.Bij import Cat.Category.Free import Cat.Category.Properties + import Cat.Categories.Sets -- import Cat.Categories.Cat import Cat.Categories.Rel diff --git a/src/Cat/CartesianClosed.agda b/src/Cat/CartesianClosed.agda new file mode 100644 index 0000000..e00fd0d --- /dev/null +++ b/src/Cat/CartesianClosed.agda @@ -0,0 +1,12 @@ +module Cat.CartesianClosed where + +open import Agda.Primitive + +open import Cat.Category +open import Cat.Product +open import Cat.Exponential + +record CartesianClosed {ℓ ℓ' : Level} (ℂ : Category ℓ ℓ') : Set (ℓ ⊔ ℓ') where + field + {{hasProducts}} : HasProducts ℂ + {{hasExponentials}} : HasExponentials ℂ diff --git a/src/Cat/Categories/Sets.agda b/src/Cat/Categories/Sets.agda index 259ec44..1bc747d 100644 --- a/src/Cat/Categories/Sets.agda +++ b/src/Cat/Categories/Sets.agda @@ -8,6 +8,7 @@ import Function open import Cat.Category open import Cat.Functor +open import Cat.Product open Category module _ {ℓ : Level} where diff --git a/src/Cat/Category.agda b/src/Cat/Category.agda index bdb632c..036a3e4 100644 --- a/src/Cat/Category.agda +++ b/src/Cat/Category.agda @@ -136,49 +136,6 @@ module Category {ℓa ℓb : Level} (ℂ : Category ℓa ℓb) where open Category using ( Object ; _[_,_] ; _[_∘_]) --- open RawCategory - -module _ {ℓ ℓ' : Level} (ℂ : Category ℓ ℓ') {A B obj : Object ℂ} where - IsProduct : (π₁ : ℂ [ obj , A ]) (π₂ : ℂ [ obj , B ]) → Set (ℓ ⊔ ℓ') - IsProduct π₁ π₂ - = ∀ {X : Object ℂ} (x₁ : ℂ [ X , A ]) (x₂ : ℂ [ X , B ]) - → ∃![ x ] (ℂ [ π₁ ∘ x ] ≡ x₁ × ℂ [ π₂ ∘ x ] ≡ x₂) - --- Tip from Andrea; Consider this style for efficiency: --- record IsProduct {ℓ ℓ' : Level} (ℂ : Category {ℓ} {ℓ'}) --- {A B obj : Object ℂ} (π₁ : Arrow ℂ obj A) (π₂ : Arrow ℂ obj B) : Set (ℓ ⊔ ℓ') where --- field --- isProduct : ∀ {X : ℂ .Object} (x₁ : ℂ .Arrow X A) (x₂ : ℂ .Arrow X B) --- → ∃![ x ] (ℂ ._⊕_ π₁ x ≡ x₁ × ℂ. _⊕_ π₂ x ≡ x₂) - -record Product {ℓ ℓ' : Level} {ℂ : Category ℓ ℓ'} (A B : Object ℂ) : Set (ℓ ⊔ ℓ') where - no-eta-equality - field - obj : Object ℂ - proj₁ : ℂ [ obj , A ] - proj₂ : ℂ [ obj , B ] - {{isProduct}} : IsProduct ℂ proj₁ proj₂ - - arrowProduct : ∀ {X} → (π₁ : ℂ [ X , A ]) (π₂ : ℂ [ X , B ]) - → ℂ [ X , obj ] - arrowProduct π₁ π₂ = fst (isProduct π₁ π₂) - -record HasProducts {ℓ ℓ' : Level} (ℂ : Category ℓ ℓ') : Set (ℓ ⊔ ℓ') where - field - product : ∀ (A B : Object ℂ) → Product {ℂ = ℂ} A B - - open Product - - 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' : 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₁ ]) - (ℂ [ b ∘ (product A B) .proj₂ ]) - module _ {ℓa ℓb : Level} (ℂ : Category ℓa ℓb) where private open Category ℂ @@ -212,40 +169,6 @@ module _ {ℓa ℓb : Level} (ℂ : Category ℓa ℓb) where -- assoc (Opposite-is-involution i) = {!!} -- ident (Opposite-is-involution i) = {!!} -module _ {ℓ ℓ'} (ℂ : Category ℓ ℓ') {{hasProducts : HasProducts ℂ}} where - open HasProducts hasProducts - open Product hiding (obj) - private - _×p_ : (A B : Object ℂ) → Object ℂ - _×p_ A B = Product.obj (product A B) - - 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 : 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 : 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 : Object ℂ) → Exponential ℂ A B - -record CartesianClosed {ℓ ℓ' : Level} (ℂ : Category ℓ ℓ') : Set (ℓ ⊔ ℓ') where - field - {{hasProducts}} : HasProducts ℂ - {{hasExponentials}} : HasExponentials ℂ - module _ {ℓa ℓb : Level} (ℂ : Category ℓa ℓb) where unique = isContr diff --git a/src/Cat/Exponential.agda b/src/Cat/Exponential.agda new file mode 100644 index 0000000..df70399 --- /dev/null +++ b/src/Cat/Exponential.agda @@ -0,0 +1,39 @@ +module Cat.Exponential where + +open import Agda.Primitive +open import Data.Product +open import Cubical + +open import Cat.Category +open import Cat.Product + +open Category + +module _ {ℓ ℓ'} (ℂ : Category ℓ ℓ') {{hasProducts : HasProducts ℂ}} where + open HasProducts hasProducts + open Product hiding (obj) + private + _×p_ : (A B : Object ℂ) → Object ℂ + _×p_ A B = Product.obj (product A B) + + 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 : 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 : Object ℂ) → ℂ [ A ×p B , C ] → ℂ [ A , obj ] + transpose A f = proj₁ (isExponential A f) + +record HasExponentials {ℓ ℓ' : Level} (ℂ : Category ℓ ℓ') {{_ : HasProducts ℂ}} : Set (ℓ ⊔ ℓ') where + field + exponent : (A B : Object ℂ) → Exponential ℂ A B diff --git a/src/Cat/Product.agda b/src/Cat/Product.agda new file mode 100644 index 0000000..f50c36d --- /dev/null +++ b/src/Cat/Product.agda @@ -0,0 +1,50 @@ +module Cat.Product where + +open import Agda.Primitive +open import Data.Product +open import Cubical + +open import Cat.Category + +open Category + +module _ {ℓ ℓ' : Level} (ℂ : Category ℓ ℓ') {A B obj : Object ℂ} where + IsProduct : (π₁ : ℂ [ obj , A ]) (π₂ : ℂ [ obj , B ]) → Set (ℓ ⊔ ℓ') + IsProduct π₁ π₂ + = ∀ {X : Object ℂ} (x₁ : ℂ [ X , A ]) (x₂ : ℂ [ X , B ]) + → ∃![ x ] (ℂ [ π₁ ∘ x ] ≡ x₁ × ℂ [ π₂ ∘ x ] ≡ x₂) + +-- Tip from Andrea; Consider this style for efficiency: +-- record IsProduct {ℓ ℓ' : Level} (ℂ : Category {ℓ} {ℓ'}) +-- {A B obj : Object ℂ} (π₁ : Arrow ℂ obj A) (π₂ : Arrow ℂ obj B) : Set (ℓ ⊔ ℓ') where +-- field +-- isProduct : ∀ {X : ℂ .Object} (x₁ : ℂ .Arrow X A) (x₂ : ℂ .Arrow X B) +-- → ∃![ x ] (ℂ ._⊕_ π₁ x ≡ x₁ × ℂ. _⊕_ π₂ x ≡ x₂) + +record Product {ℓ ℓ' : Level} {ℂ : Category ℓ ℓ'} (A B : Object ℂ) : Set (ℓ ⊔ ℓ') where + no-eta-equality + field + obj : Object ℂ + proj₁ : ℂ [ obj , A ] + proj₂ : ℂ [ obj , B ] + {{isProduct}} : IsProduct ℂ proj₁ proj₂ + + arrowProduct : ∀ {X} → (π₁ : ℂ [ X , A ]) (π₂ : ℂ [ X , B ]) + → ℂ [ X , obj ] + arrowProduct π₁ π₂ = proj₁ (isProduct π₁ π₂) + +record HasProducts {ℓ ℓ' : Level} (ℂ : Category ℓ ℓ') : Set (ℓ ⊔ ℓ') where + field + product : ∀ (A B : Object ℂ) → Product {ℂ = ℂ} A B + + open Product + + 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' : 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₁ ]) + (ℂ [ b ∘ (product A B) .proj₂ ]) From 83ccde62e9ad91ca33f6e55af46dabf9fe614952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20Hangh=C3=B8j=20Iversen?= Date: Mon, 5 Feb 2018 14:47:15 +0100 Subject: [PATCH 3/9] Use co-patterns --- src/Cat/Categories/Cube.agda | 19 +++++---- src/Cat/Categories/Fam.agda | 6 +-- src/Cat/Categories/Fun.agda | 6 +-- src/Cat/Categories/Sets.agda | 27 ++++++------ src/Cat/Category.agda | 83 +++++++++++++++++++++--------------- 5 files changed, 77 insertions(+), 64 deletions(-) diff --git a/src/Cat/Categories/Cube.agda b/src/Cat/Categories/Cube.agda index ec1a145..ee0eccc 100644 --- a/src/Cat/Categories/Cube.agda +++ b/src/Cat/Categories/Cube.agda @@ -65,15 +65,16 @@ module _ {ℓ ℓ' : Level} (Ns : Set ℓ) where Hom = Σ Hom' rules + module Raw = RawCategory -- The category of names and substitutions Rawℂ : RawCategory ℓ ℓ -- ℓo (lsuc lzero ⊔ ℓo) - Rawℂ = record - { Object = FiniteDecidableSubset - -- { Object = Ns → Bool - ; Arrow = Hom - ; 𝟙 = λ { {o} → inj₁ , λ { (i , ii) (j , jj) eq → Σ≡ eq {!refl!} } } - ; _∘_ = {!!} - } - postulate RawIsCategoryℂ : IsCategory Rawℂ + Raw.Object Rawℂ = FiniteDecidableSubset + Raw.Arrow Rawℂ = Hom + Raw.𝟙 Rawℂ {o} = inj₁ , λ { (i , ii) (j , jj) eq → Σ≡ eq {!refl!} } + Raw._∘_ Rawℂ = {!!} + + postulate IsCategoryℂ : IsCategory Rawℂ + ℂ : Category ℓ ℓ - ℂ = Rawℂ , RawIsCategoryℂ + raw ℂ = Rawℂ + isCategory ℂ = IsCategoryℂ diff --git a/src/Cat/Categories/Fam.agda b/src/Cat/Categories/Fam.agda index 9fac2bf..600cabb 100644 --- a/src/Cat/Categories/Fam.agda +++ b/src/Cat/Categories/Fam.agda @@ -46,9 +46,9 @@ module _ (ℓa ℓb : Level) where isCategory = record { assoc = λ {A} {B} {C} {D} {f} {g} {h} → assoc {D = D} {f} {g} {h} ; ident = λ {A} {B} {f} → ident {A} {B} {f = f} - ; arrow-is-set = ? - ; univalent = ? + ; arrow-is-set = {!!} + ; univalent = {!!} } Fam : Category (lsuc (ℓa ⊔ ℓb)) (ℓa ⊔ ℓb) - Fam = RawFam , isCategory + Category.raw Fam = RawFam diff --git a/src/Cat/Categories/Fun.agda b/src/Cat/Categories/Fun.agda index 6719ac6..c14823a 100644 --- a/src/Cat/Categories/Fun.agda +++ b/src/Cat/Categories/Fun.agda @@ -110,12 +110,12 @@ module _ {ℓc ℓc' ℓd ℓd' : Level} {ℂ : Category ℓc ℓc'} {𝔻 : Cat :isCategory: = record { assoc = λ {A B C D} → :assoc: {A} {B} {C} {D} ; ident = λ {A B} → :ident: {A} {B} - ; arrow-is-set = ? - ; univalent = ? + ; arrow-is-set = {!!} + ; univalent = {!!} } Fun : Category (ℓc ⊔ ℓc' ⊔ ℓd ⊔ ℓd') (ℓc ⊔ ℓc' ⊔ ℓd') - Fun = RawFun , :isCategory: + raw Fun = RawFun module _ {ℓ ℓ' : Level} (ℂ : Category ℓ ℓ') where open import Cat.Categories.Sets diff --git a/src/Cat/Categories/Sets.agda b/src/Cat/Categories/Sets.agda index 1bc747d..e9a8b87 100644 --- a/src/Cat/Categories/Sets.agda +++ b/src/Cat/Categories/Sets.agda @@ -1,4 +1,4 @@ -{-# OPTIONS --allow-unsolved-metas #-} +{-# OPTIONS --allow-unsolved-metas --cubical #-} module Cat.Categories.Sets where open import Cubical @@ -13,23 +13,22 @@ open Category module _ {ℓ : Level} where SetsRaw : RawCategory (lsuc ℓ) ℓ - SetsRaw = record - { Object = Set ℓ - ; Arrow = λ T U → T → U - ; 𝟙 = Function.id - ; _∘_ = Function._∘′_ - } + RawCategory.Object SetsRaw = Set ℓ + RawCategory.Arrow SetsRaw = λ T U → T → U + RawCategory.𝟙 SetsRaw = Function.id + RawCategory._∘_ SetsRaw = Function._∘′_ + open IsCategory SetsIsCategory : IsCategory SetsRaw - SetsIsCategory = record - { assoc = refl - ; ident = funExt (λ _ → refl) , funExt (λ _ → refl) - ; arrow-is-set = {!!} - ; univalent = {!!} - } + assoc SetsIsCategory = refl + proj₁ (ident SetsIsCategory) = funExt λ _ → refl + proj₂ (ident SetsIsCategory) = funExt λ _ → refl + arrow-is-set SetsIsCategory = {!!} + univalent SetsIsCategory = {!!} Sets : Category (lsuc ℓ) ℓ - Sets = SetsRaw , SetsIsCategory + raw Sets = SetsRaw + isCategory Sets = SetsIsCategory private module _ {X A B : Set ℓ} (f : X → A) (g : X → B) where diff --git a/src/Cat/Category.agda b/src/Cat/Category.agda index 036a3e4..5c7eb41 100644 --- a/src/Cat/Category.agda +++ b/src/Cat/Category.agda @@ -109,12 +109,10 @@ module _ {ℓa} {ℓb} {ℂ : RawCategory ℓa ℓb} where module x = IsCategory x module y = IsCategory y -Category : (ℓa ℓb : Level) → Set (lsuc (ℓa ⊔ ℓb)) -Category ℓa ℓb = Σ (RawCategory ℓa ℓb) IsCategory - -module Category {ℓa ℓb : Level} (ℂ : Category ℓa ℓb) where - raw = fst ℂ - isCategory = snd ℂ +record Category (ℓa ℓb : Level) : Set (lsuc (ℓa ⊔ ℓb)) where + field + raw : RawCategory ℓa ℓb + {{isCategory}} : IsCategory raw private module ℂ = RawCategory raw @@ -134,42 +132,57 @@ module Category {ℓa ℓb : Level} (ℂ : Category ℓa ℓb) where _[_∘_] : {A B C : Object} → (g : ℂ.Arrow B C) → (f : ℂ.Arrow A B) → ℂ.Arrow A C _[_∘_] = ℂ._∘_ -open Category using ( Object ; _[_,_] ; _[_∘_]) module _ {ℓa ℓb : Level} (ℂ : Category ℓa ℓb) where private open Category ℂ - module ℂ = RawCategory (ℂ .fst) - OpRaw : RawCategory ℓa ℓb - OpRaw = record - { Object = ℂ.Object - ; Arrow = Function.flip ℂ.Arrow - ; 𝟙 = ℂ.𝟙 - ; _∘_ = Function.flip (ℂ._∘_) - } - open IsCategory isCategory - OpIsCategory : IsCategory OpRaw - OpIsCategory = record - { assoc = sym assoc - ; ident = swap ident - ; arrow-is-set = {!!} - ; univalent = {!!} - } - Opposite : Category ℓa ℓb - Opposite = OpRaw , OpIsCategory --- A consequence of no-eta-equality; `Opposite-is-involution` is no longer --- definitional - i.e.; you must match on the fields: --- --- Opposite-is-involution : ∀ {ℓ ℓ'} → {C : Category {ℓ} {ℓ'}} → Opposite (Opposite C) ≡ C --- Object (Opposite-is-involution {C = C} i) = Object C --- Arrow (Opposite-is-involution i) = {!!} --- 𝟙 (Opposite-is-involution i) = {!!} --- _⊕_ (Opposite-is-involution i) = {!!} --- assoc (Opposite-is-involution i) = {!!} --- ident (Opposite-is-involution i) = {!!} + OpRaw : RawCategory ℓa ℓb + RawCategory.Object OpRaw = Object + RawCategory.Arrow OpRaw = Function.flip Arrow + RawCategory.𝟙 OpRaw = 𝟙 + RawCategory._∘_ OpRaw = Function.flip _∘_ + + open IsCategory isCategory + + OpIsCategory : IsCategory OpRaw + IsCategory.assoc OpIsCategory = sym assoc + IsCategory.ident OpIsCategory = swap ident + IsCategory.arrow-is-set OpIsCategory = {!!} + IsCategory.univalent OpIsCategory = {!!} + + Opposite : Category ℓa ℓb + raw Opposite = OpRaw + Category.isCategory Opposite = OpIsCategory + +-- As demonstrated here a side-effect of having no-eta-equality on constructors +-- means that we need to pick things apart to show that things are indeed +-- definitionally equal. I.e; a thing that would normally be provable in one +-- line now takes more than 20!! +module _ {ℓa ℓb : Level} {ℂ : Category ℓa ℓb} where + private + open RawCategory + module C = Category ℂ + rawOp : Category.raw (Opposite (Opposite ℂ)) ≡ Category.raw ℂ + Object (rawOp _) = C.Object + Arrow (rawOp _) = C.Arrow + 𝟙 (rawOp _) = C.𝟙 + _∘_ (rawOp _) = C._∘_ + open Category + open IsCategory + module IsCat = IsCategory (ℂ .isCategory) + rawIsCat : (i : I) → IsCategory (rawOp i) + assoc (rawIsCat i) = IsCat.assoc + ident (rawIsCat i) = IsCat.ident + arrow-is-set (rawIsCat i) = IsCat.arrow-is-set + univalent (rawIsCat i) = IsCat.univalent + + Opposite-is-involution : Opposite (Opposite ℂ) ≡ ℂ + raw (Opposite-is-involution i) = rawOp 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) From e8215b2c051062c6301abc9b3f6ec67106259758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20Hangh=C3=B8j=20Iversen?= Date: Mon, 5 Feb 2018 14:59:53 +0100 Subject: [PATCH 4/9] Move product, exponential, ... --- src/Cat.agda | 8 ++++---- src/Cat/Categories/Cube.agda | 2 +- src/Cat/Categories/Fun.agda | 2 +- src/Cat/Categories/Sets.agda | 4 ++-- src/Cat/{ => Category}/CartesianClosed.agda | 6 +++--- src/Cat/{ => Category}/Exponential.agda | 4 ++-- src/Cat/{ => Category}/Functor.agda | 2 +- src/Cat/{ => Category}/Product.agda | 2 +- src/Cat/Category/Properties.agda | 3 +-- src/Cat/CwF.agda | 2 +- 10 files changed, 17 insertions(+), 18 deletions(-) rename src/Cat/{ => Category}/CartesianClosed.agda (68%) rename src/Cat/{ => Category}/Exponential.agda (95%) rename src/Cat/{ => Category}/Functor.agda (99%) rename src/Cat/{ => Category}/Product.agda (98%) diff --git a/src/Cat.agda b/src/Cat.agda index edf98de..c452d26 100644 --- a/src/Cat.agda +++ b/src/Cat.agda @@ -1,12 +1,12 @@ module Cat where import Cat.Category -import Cat.Functor import Cat.CwF -import Cat.CartesianClosed -import Cat.Exponential -import Cat.Product +import Cat.Category.Functor +import Cat.Category.Product +import Cat.Category.Exponential +import Cat.Category.CartesianClosed import Cat.Category.Pathy import Cat.Category.Bij import Cat.Category.Free diff --git a/src/Cat/Categories/Cube.agda b/src/Cat/Categories/Cube.agda index ee0eccc..fdee75e 100644 --- a/src/Cat/Categories/Cube.agda +++ b/src/Cat/Categories/Cube.agda @@ -13,7 +13,7 @@ open import Relation.Nullary open import Relation.Nullary.Decidable open import Cat.Category -open import Cat.Functor +open import Cat.Category.Functor open import Cat.Equality open Equality.Data.Product diff --git a/src/Cat/Categories/Fun.agda b/src/Cat/Categories/Fun.agda index c14823a..50acaaa 100644 --- a/src/Cat/Categories/Fun.agda +++ b/src/Cat/Categories/Fun.agda @@ -7,7 +7,7 @@ open import Function open import Data.Product open import Cat.Category -open import Cat.Functor +open import Cat.Category.Functor module _ {ℓc ℓc' ℓd ℓd' : Level} {ℂ : Category ℓc ℓc'} {𝔻 : Category ℓd ℓd'} where open Category hiding ( _∘_ ; Arrow ) diff --git a/src/Cat/Categories/Sets.agda b/src/Cat/Categories/Sets.agda index e9a8b87..e13fa0c 100644 --- a/src/Cat/Categories/Sets.agda +++ b/src/Cat/Categories/Sets.agda @@ -7,8 +7,8 @@ open import Data.Product import Function open import Cat.Category -open import Cat.Functor -open import Cat.Product +open import Cat.Category.Functor +open import Cat.Category.Product open Category module _ {ℓ : Level} where diff --git a/src/Cat/CartesianClosed.agda b/src/Cat/Category/CartesianClosed.agda similarity index 68% rename from src/Cat/CartesianClosed.agda rename to src/Cat/Category/CartesianClosed.agda index e00fd0d..ba477c9 100644 --- a/src/Cat/CartesianClosed.agda +++ b/src/Cat/Category/CartesianClosed.agda @@ -1,10 +1,10 @@ -module Cat.CartesianClosed where +module Cat.Category.CartesianClosed where open import Agda.Primitive open import Cat.Category -open import Cat.Product -open import Cat.Exponential +open import Cat.Category.Product +open import Cat.Category.Exponential record CartesianClosed {ℓ ℓ' : Level} (ℂ : Category ℓ ℓ') : Set (ℓ ⊔ ℓ') where field diff --git a/src/Cat/Exponential.agda b/src/Cat/Category/Exponential.agda similarity index 95% rename from src/Cat/Exponential.agda rename to src/Cat/Category/Exponential.agda index df70399..5865da0 100644 --- a/src/Cat/Exponential.agda +++ b/src/Cat/Category/Exponential.agda @@ -1,11 +1,11 @@ -module Cat.Exponential where +module Cat.Category.Exponential where open import Agda.Primitive open import Data.Product open import Cubical open import Cat.Category -open import Cat.Product +open import Cat.Category.Product open Category diff --git a/src/Cat/Functor.agda b/src/Cat/Category/Functor.agda similarity index 99% rename from src/Cat/Functor.agda rename to src/Cat/Category/Functor.agda index 890801b..912557e 100644 --- a/src/Cat/Functor.agda +++ b/src/Cat/Category/Functor.agda @@ -1,4 +1,4 @@ -module Cat.Functor where +module Cat.Category.Functor where open import Agda.Primitive open import Cubical diff --git a/src/Cat/Product.agda b/src/Cat/Category/Product.agda similarity index 98% rename from src/Cat/Product.agda rename to src/Cat/Category/Product.agda index f50c36d..cbc42b5 100644 --- a/src/Cat/Product.agda +++ b/src/Cat/Category/Product.agda @@ -1,4 +1,4 @@ -module Cat.Product where +module Cat.Category.Product where open import Agda.Primitive open import Data.Product diff --git a/src/Cat/Category/Properties.agda b/src/Cat/Category/Properties.agda index 2477447..9b678a5 100644 --- a/src/Cat/Category/Properties.agda +++ b/src/Cat/Category/Properties.agda @@ -7,7 +7,7 @@ open import Data.Product open import Cubical open import Cat.Category -open import Cat.Functor +open import Cat.Category.Functor open import Cat.Categories.Sets open import Cat.Equality open Equality.Data.Product @@ -51,7 +51,6 @@ epi-mono-is-not-iso f = open import Cat.Category open Category -open import Cat.Functor open Functor -- module _ {ℓ : Level} {ℂ : Category ℓ ℓ} diff --git a/src/Cat/CwF.agda b/src/Cat/CwF.agda index c3099ca..44e725e 100644 --- a/src/Cat/CwF.agda +++ b/src/Cat/CwF.agda @@ -4,7 +4,7 @@ open import Agda.Primitive open import Data.Product open import Cat.Category -open import Cat.Functor +open import Cat.Category.Functor open import Cat.Categories.Fam open Category From e8ac6786ff2caac25599f130aed5ff6d65a1014d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20Hangh=C3=B8j=20Iversen?= Date: Mon, 5 Feb 2018 16:35:33 +0100 Subject: [PATCH 5/9] Changes to the category of categories --- src/Cat/Categories/Cat.agda | 223 +++++++++++++++++------------- src/Cat/Category.agda | 4 +- src/Cat/Category/Exponential.agda | 2 +- src/Cat/Category/Product.agda | 34 +++-- src/Cat/Category/Properties.agda | 2 +- 5 files changed, 154 insertions(+), 111 deletions(-) diff --git a/src/Cat/Categories/Cat.agda b/src/Cat/Categories/Cat.agda index 0fe0056..1ec9acb 100644 --- a/src/Cat/Categories/Cat.agda +++ b/src/Cat/Categories/Cat.agda @@ -9,7 +9,9 @@ open import Function open import Data.Product renaming (proj₁ to fst ; proj₂ to snd) open import Cat.Category -open import Cat.Functor +open import Cat.Category.Functor +open import Cat.Category.Product +open import Cat.Category.Exponential open import Cat.Equality open Equality.Data.Product @@ -26,12 +28,12 @@ module _ (ℓ ℓ' : Level) where eq* : func* (H ∘f (G ∘f F)) ≡ func* ((H ∘f G) ∘f F) eq* = refl eq→ : PathP - (λ i → {A B : 𝔸 .Object} → 𝔸 [ A , B ] → 𝔻 [ eq* i A , eq* i B ]) + (λ i → {A B : Object 𝔸} → 𝔸 [ A , B ] → 𝔻 [ eq* i A , eq* i B ]) (func→ (H ∘f (G ∘f F))) (func→ ((H ∘f G) ∘f F)) eq→ = refl postulate eqI - : (λ i → ∀ {A : 𝔸 .Object} → eq→ i (𝔸 .𝟙 {A}) ≡ 𝔻 .𝟙 {eq* i A}) + : (λ i → ∀ {A : Object 𝔸} → eq→ i (𝟙 𝔸 {A}) ≡ 𝟙 𝔻 {eq* i A}) [ (H ∘f (G ∘f F)) .isFunctor .ident ≡ ((H ∘f G) ∘f F) .isFunctor .ident ] @@ -58,12 +60,12 @@ module _ (ℓ ℓ' : Level) where eq→ = refl postulate eqI-r - : (λ i → {c : ℂ .Object} → (λ _ → 𝔻 [ func* F c , func* F c ]) - [ func→ F (ℂ .𝟙) ≡ 𝔻 .𝟙 ]) + : (λ i → {c : Object ℂ} → (λ _ → 𝔻 [ func* F c , func* F c ]) + [ func→ F (𝟙 ℂ) ≡ 𝟙 𝔻 ]) [(F ∘f identity) .isFunctor .ident ≡ F .isFunctor .ident ] eqD-r : PathP (λ i → - {A B C : ℂ .Object} {f : ℂ .Arrow A B} {g : ℂ .Arrow B C} → + {A B C : Object ℂ} {f : ℂ [ A , B ]} {g : ℂ [ B , C ]} → eq→ i (ℂ [ g ∘ f ]) ≡ 𝔻 [ eq→ i g ∘ eq→ i f ]) ((F ∘f identity) .isFunctor .distrib) (F .isFunctor .distrib) ident-r : F ∘f identity ≡ F @@ -73,40 +75,50 @@ module _ (ℓ ℓ' : Level) where postulate eq* : (identity ∘f F) .func* ≡ F .func* eq→ : PathP - (λ i → {x y : Object ℂ} → ℂ .Arrow x y → 𝔻 .Arrow (eq* i x) (eq* i y)) + (λ i → {x y : Object ℂ} → ℂ [ x , y ] → 𝔻 [ eq* i x , eq* i y ]) ((identity ∘f F) .func→) (F .func→) - eqI : (λ i → ∀ {A : ℂ .Object} → eq→ i (ℂ .𝟙 {A}) ≡ 𝔻 .𝟙 {eq* i A}) + eqI : (λ i → ∀ {A : Object ℂ} → eq→ i (𝟙 ℂ {A}) ≡ 𝟙 𝔻 {eq* i A}) [ ((identity ∘f F) .isFunctor .ident) ≡ (F .isFunctor .ident) ] - eqD : PathP (λ i → {A B C : ℂ .Object} {f : ℂ .Arrow A B} {g : ℂ .Arrow B C} + eqD : PathP (λ i → {A B C : Object ℂ} {f : ℂ [ A , B ]} {g : ℂ [ B , C ]} → eq→ i (ℂ [ g ∘ f ]) ≡ 𝔻 [ eq→ i g ∘ eq→ i f ]) ((identity ∘f F) .isFunctor .distrib) (F .isFunctor .distrib) -- (λ z → eq* i z) (eq→ i) ident-l : identity ∘f F ≡ F ident-l = Functor≡ eq* eq→ λ i → record { ident = eqI i ; distrib = eqD i } - Cat : Category (lsuc (ℓ ⊔ ℓ')) (ℓ ⊔ ℓ') - Cat = - record - { Object = Category ℓ ℓ' - ; Arrow = Functor - ; 𝟙 = identity - ; _∘_ = _∘f_ - -- What gives here? Why can I not name the variables directly? - ; isCategory = record - { assoc = λ {_ _ _ _ F G H} → assc {F = F} {G = G} {H = H} - ; ident = ident-r , ident-l + RawCat : RawCategory (lsuc (ℓ ⊔ ℓ')) (ℓ ⊔ ℓ') + RawCat = + record + { Object = Category ℓ ℓ' + ; Arrow = Functor + ; 𝟙 = identity + ; _∘_ = _∘f_ + -- What gives here? Why can I not name the variables directly? + -- ; isCategory = record + -- { assoc = λ {_ _ _ _ F G H} → assc {F = F} {G = G} {H = H} + -- ; ident = ident-r , ident-l + -- } } - } + open IsCategory + instance + :isCategory: : IsCategory RawCat + assoc :isCategory: {f = F} {G} {H} = assc {F = F} {G = G} {H = H} + ident :isCategory: = ident-r , ident-l + arrow-is-set :isCategory: = {!!} + univalent :isCategory: = {!!} + + Cat : Category (lsuc (ℓ ⊔ ℓ')) (ℓ ⊔ ℓ') + raw Cat = RawCat module _ {ℓ ℓ' : Level} where module _ (ℂ 𝔻 : Category ℓ ℓ') where private Catt = Cat ℓ ℓ' - :Object: = ℂ .Object × 𝔻 .Object + :Object: = Object ℂ × Object 𝔻 :Arrow: : :Object: → :Object: → Set ℓ' :Arrow: (c , d) (c' , d') = Arrow ℂ c c' × Arrow 𝔻 d d' :𝟙: : {o : :Object:} → :Arrow: o o - :𝟙: = ℂ .𝟙 , 𝔻 .𝟙 + :𝟙: = 𝟙 ℂ , 𝟙 𝔻 _:⊕:_ : {a b c : :Object:} → :Arrow: b c → @@ -114,25 +126,35 @@ module _ {ℓ ℓ' : Level} where :Arrow: a c _:⊕:_ = λ { (bc∈C , bc∈D) (ab∈C , ab∈D) → ℂ [ bc∈C ∘ ab∈C ] , 𝔻 [ bc∈D ∘ ab∈D ]} + :rawProduct: : RawCategory ℓ ℓ' + RawCategory.Object :rawProduct: = :Object: + RawCategory.Arrow :rawProduct: = :Arrow: + RawCategory.𝟙 :rawProduct: = :𝟙: + RawCategory._∘_ :rawProduct: = _:⊕:_ + + module C = IsCategory (ℂ .isCategory) + module D = IsCategory (𝔻 .isCategory) + postulate + issSet : {A B : RawCategory.Object :rawProduct:} → isSet (RawCategory.Arrow :rawProduct: A B) instance - :isCategory: : IsCategory :Object: :Arrow: :𝟙: _:⊕:_ - :isCategory: = record - { assoc = Σ≡ C.assoc D.assoc - ; ident + :isCategory: : IsCategory :rawProduct: + -- :isCategory: = record + -- { assoc = Σ≡ C.assoc D.assoc + -- ; ident + -- = Σ≡ (fst C.ident) (fst D.ident) + -- , Σ≡ (snd C.ident) (snd D.ident) + -- ; arrow-is-set = issSet + -- ; univalent = {!!} + -- } + IsCategory.assoc :isCategory: = Σ≡ C.assoc D.assoc + IsCategory.ident :isCategory: = Σ≡ (fst C.ident) (fst D.ident) , Σ≡ (snd C.ident) (snd D.ident) - } - where - open module C = IsCategory (ℂ .isCategory) - open module D = IsCategory (𝔻 .isCategory) + IsCategory.arrow-is-set :isCategory: = issSet + IsCategory.univalent :isCategory: = {!!} :product: : Category ℓ ℓ' - :product: = record - { Object = :Object: - ; Arrow = :Arrow: - ; 𝟙 = :𝟙: - ; _∘_ = _:⊕:_ - } + raw :product: = :rawProduct: proj₁ : Catt [ :product: , ℂ ] proj₁ = record { func* = fst ; func→ = fst ; isFunctor = record { ident = refl ; distrib = refl } } @@ -143,28 +165,32 @@ module _ {ℓ ℓ' : Level} where module _ {X : Object Catt} (x₁ : Catt [ X , ℂ ]) (x₂ : Catt [ X , 𝔻 ]) where open Functor - x : Functor X :product: - x = record - { func* = λ x → x₁ .func* x , x₂ .func* x - ; func→ = λ x → func→ x₁ x , func→ x₂ x - ; isFunctor = record - { ident = Σ≡ x₁.ident x₂.ident - ; distrib = Σ≡ x₁.distrib x₂.distrib - } - } - where - open module x₁ = IsFunctor (x₁ .isFunctor) - open module x₂ = IsFunctor (x₂ .isFunctor) + postulate x : Functor X :product: + -- x = record + -- { func* = λ x → x₁ .func* x , x₂ .func* x + -- ; func→ = λ x → func→ x₁ x , func→ x₂ x + -- ; isFunctor = record + -- { ident = Σ≡ x₁.ident x₂.ident + -- ; distrib = Σ≡ x₁.distrib x₂.distrib + -- } + -- } + -- where + -- open module x₁ = IsFunctor (x₁ .isFunctor) + -- open module x₂ = IsFunctor (x₂ .isFunctor) - isUniqL : Catt [ proj₁ ∘ x ] ≡ x₁ - isUniqL = Functor≡ eq* eq→ eqIsF -- Functor≡ refl refl λ i → record { ident = refl i ; distrib = refl i } - where - eq* : (Catt [ proj₁ ∘ x ]) .func* ≡ x₁ .func* - eq* = refl - eq→ : (λ i → {A : X .Object} {B : X .Object} → X [ A , B ] → ℂ [ eq* i A , eq* i B ]) - [ (Catt [ proj₁ ∘ x ]) .func→ ≡ x₁ .func→ ] - eq→ = refl - postulate eqIsF : (Catt [ proj₁ ∘ x ]) .isFunctor ≡ x₁ .isFunctor + -- Turned into postulate after: + -- > commit e8215b2c051062c6301abc9b3f6ec67106259758 (HEAD -> dev, github/dev) + -- > Author: Frederik Hanghøj Iversen + -- > Date: Mon Feb 5 14:59:53 2018 +0100 + postulate isUniqL : Catt [ proj₁ ∘ x ] ≡ x₁ + -- isUniqL = Functor≡ eq* eq→ {!!} + -- where + -- eq* : (Catt [ proj₁ ∘ x ]) .func* ≡ x₁ .func* + -- eq* = {!refl!} + -- eq→ : (λ i → {A : Object X} {B : Object X} → X [ A , B ] → ℂ [ eq* i A , eq* i B ]) + -- [ (Catt [ proj₁ ∘ x ]) .func→ ≡ x₁ .func→ ] + -- eq→ = refl + -- postulate eqIsF : (Catt [ proj₁ ∘ x ]) .isFunctor ≡ x₁ .isFunctor -- eqIsF = IsFunctor≡ {!refl!} {!!} postulate isUniqR : Catt [ proj₂ ∘ x ] ≡ x₂ @@ -202,55 +228,55 @@ module _ (ℓ : Level) where Catℓ = Cat ℓ ℓ module _ (ℂ 𝔻 : Category ℓ ℓ) where private - :obj: : Cat ℓ ℓ .Object + :obj: : Object (Cat ℓ ℓ) :obj: = Fun {ℂ = ℂ} {𝔻 = 𝔻} - :func*: : Functor ℂ 𝔻 × ℂ .Object → 𝔻 .Object + :func*: : Functor ℂ 𝔻 × Object ℂ → Object 𝔻 :func*: (F , A) = F .func* A - module _ {dom cod : Functor ℂ 𝔻 × ℂ .Object} where + module _ {dom cod : Functor ℂ 𝔻 × Object ℂ} where private F : Functor ℂ 𝔻 F = proj₁ dom - A : ℂ .Object + A : Object ℂ A = proj₂ dom G : Functor ℂ 𝔻 G = proj₁ cod - B : ℂ .Object + B : Object ℂ B = proj₂ cod - :func→: : (pobj : NaturalTransformation F G × ℂ .Arrow A B) - → 𝔻 .Arrow (F .func* A) (G .func* B) + :func→: : (pobj : NaturalTransformation F G × ℂ [ A , B ]) + → 𝔻 [ F .func* A , G .func* B ] :func→: ((θ , θNat) , f) = result where - θA : 𝔻 .Arrow (F .func* A) (G .func* A) + θA : 𝔻 [ F .func* A , G .func* A ] θA = θ A - θB : 𝔻 .Arrow (F .func* B) (G .func* B) + θB : 𝔻 [ F .func* B , G .func* B ] θB = θ B - F→f : 𝔻 .Arrow (F .func* A) (F .func* B) + F→f : 𝔻 [ F .func* A , F .func* B ] F→f = F .func→ f - G→f : 𝔻 .Arrow (G .func* A) (G .func* B) + G→f : 𝔻 [ G .func* A , G .func* B ] G→f = G .func→ f - l : 𝔻 .Arrow (F .func* A) (G .func* B) + l : 𝔻 [ F .func* A , G .func* B ] l = 𝔻 [ θB ∘ F→f ] - r : 𝔻 .Arrow (F .func* A) (G .func* B) + r : 𝔻 [ F .func* A , G .func* B ] r = 𝔻 [ G→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 .func→ f ] ≡ 𝔻 [ G .func→ f ∘ θ A ] -- lem = θNat f - result : 𝔻 .Arrow (F .func* A) (G .func* B) + result : 𝔻 [ F .func* A , G .func* B ] result = l _×p_ = product - module _ {c : Functor ℂ 𝔻 × ℂ .Object} where + module _ {c : Functor ℂ 𝔻 × Object ℂ} where private F : Functor ℂ 𝔻 F = proj₁ c - C : ℂ .Object + C : Object ℂ C = proj₂ c -- NaturalTransformation F G × ℂ .Arrow A B @@ -259,19 +285,19 @@ module _ (ℓ : Level) where -- where -- open module 𝔻 = IsCategory (𝔻 .isCategory) -- Unfortunately the equational version has some ambigous arguments. - :ident: : :func→: {c} {c} (identityNat F , ℂ .𝟙 {o = proj₂ c}) ≡ 𝔻 .𝟙 + :ident: : :func→: {c} {c} (identityNat F , 𝟙 ℂ {o = proj₂ c}) ≡ 𝟙 𝔻 :ident: = begin - :func→: {c} {c} ((:obj: ×p ℂ) .Product.obj .𝟙 {c}) ≡⟨⟩ - :func→: {c} {c} (identityNat F , ℂ .𝟙) ≡⟨⟩ - 𝔻 [ identityTrans F C ∘ F .func→ (ℂ .𝟙)] ≡⟨⟩ - 𝔻 [ 𝔻 .𝟙 ∘ F .func→ (ℂ .𝟙)] ≡⟨ proj₂ 𝔻.ident ⟩ - F .func→ (ℂ .𝟙) ≡⟨ F.ident ⟩ - 𝔻 .𝟙 ∎ + :func→: {c} {c} (𝟙 (Product.obj (:obj: ×p ℂ)) {c}) ≡⟨⟩ + :func→: {c} {c} (identityNat F , 𝟙 ℂ) ≡⟨⟩ + 𝔻 [ identityTrans F C ∘ F .func→ (𝟙 ℂ)] ≡⟨⟩ + 𝔻 [ 𝟙 𝔻 ∘ F .func→ (𝟙 ℂ)] ≡⟨ proj₂ 𝔻.ident ⟩ + F .func→ (𝟙 ℂ) ≡⟨ F.ident ⟩ + 𝟙 𝔻 ∎ where open module 𝔻 = IsCategory (𝔻 .isCategory) open module F = IsFunctor (F .isFunctor) - module _ {F×A G×B H×C : Functor ℂ 𝔻 × ℂ .Object} where + module _ {F×A G×B H×C : Functor ℂ 𝔻 × Object ℂ} where F = F×A .proj₁ A = F×A .proj₂ G = G×B .proj₁ @@ -279,27 +305,27 @@ module _ (ℓ : Level) where H = H×C .proj₁ C = H×C .proj₂ -- Not entirely clear what this is at this point: - _P⊕_ = (:obj: ×p ℂ) .Product.obj .Category._∘_ {F×A} {G×B} {H×C} + _P⊕_ = Category._∘_ (Product.obj (:obj: ×p ℂ)) {F×A} {G×B} {H×C} module _ -- NaturalTransformation F G × ℂ .Arrow A B - {θ×f : NaturalTransformation F G × ℂ .Arrow A B} - {η×g : NaturalTransformation G H × ℂ .Arrow B C} where + {θ×f : NaturalTransformation F G × ℂ [ A , B ]} + {η×g : NaturalTransformation G H × ℂ [ B , C ]} where private θ : Transformation F G θ = proj₁ (proj₁ θ×f) θNat : Natural F G θ θNat = proj₂ (proj₁ θ×f) - f : ℂ .Arrow A B + f : ℂ [ A , B ] f = proj₂ θ×f η : Transformation G H η = proj₁ (proj₁ η×g) ηNat : Natural G H η ηNat = proj₂ (proj₁ η×g) - g : ℂ .Arrow B C + g : ℂ [ B , C ] g = proj₂ η×g ηθNT : NaturalTransformation F H - ηθNT = Fun .Category._∘_ {F} {G} {H} (η , ηNat) (θ , θNat) + ηθNT = Category._∘_ Fun {F} {G} {H} (η , ηNat) (θ , θNat) ηθ = proj₁ ηθNT ηθNat = proj₂ ηθNT @@ -341,17 +367,28 @@ module _ (ℓ : Level) where } module _ (𝔸 : Category ℓ ℓ) (F : Functor ((𝔸 ×p ℂ) .Product.obj) 𝔻) where - open HasProducts (hasProducts {ℓ} {ℓ}) using (parallelProduct) + open HasProducts (hasProducts {ℓ} {ℓ}) renaming (_|×|_ to parallelProduct) postulate transpose : Functor 𝔸 :obj: - eq : Catℓ [ :eval: ∘ (parallelProduct transpose (Catℓ .𝟙 {o = ℂ})) ] ≡ F + eq : Catℓ [ :eval: ∘ (parallelProduct transpose (𝟙 Catℓ {o = ℂ})) ] ≡ F + -- eq : Catℓ [ :eval: ∘ (HasProducts._|×|_ hasProducts transpose (𝟙 Catℓ {o = ℂ})) ] ≡ F + -- eq' : (Catℓ [ :eval: ∘ + -- (record { product = product } HasProducts.|×| transpose) + -- (𝟙 Catℓ) + -- ]) + -- ≡ F - catTranspose : ∃![ F~ ] (Catℓ [ :eval: ∘ (parallelProduct F~ (Catℓ .𝟙 {o = ℂ}))] ≡ F ) - catTranspose = transpose , eq + -- For some reason after `e8215b2c051062c6301abc9b3f6ec67106259758` + -- `catTranspose` makes Agda hang. catTranspose : ∃![ F~ ] (Catℓ [ + -- :eval: ∘ (parallelProduct F~ (𝟙 Catℓ {o = ℂ}))] ≡ F) catTranspose = + -- transpose , eq :isExponential: : IsExponential Catℓ ℂ 𝔻 :obj: :eval: - :isExponential: = catTranspose + :isExponential: = {!catTranspose!} + where + open HasProducts (hasProducts {ℓ} {ℓ}) using (_|×|_) + -- :isExponential: = λ 𝔸 F → transpose 𝔸 F , eq' 𝔸 F -- :exponent: : Exponential (Cat ℓ ℓ) A B :exponent: : Exponential Catℓ ℂ 𝔻 diff --git a/src/Cat/Category.agda b/src/Cat/Category.agda index 5c7eb41..6af9764 100644 --- a/src/Cat/Category.agda +++ b/src/Cat/Category.agda @@ -76,8 +76,10 @@ record IsCategory {ℓa ℓb : Level} (ℂ : RawCategory ℓa ℓb) : Set (lsuc -- 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 : {A B : Object} → isEquiv (A ≡ B) (A ≅ B) (id-to-iso A B) + univalent : Univalent module _ {A B : Object} where Epimorphism : {X : Object } → (f : Arrow A B) → Set ℓb diff --git a/src/Cat/Category/Exponential.agda b/src/Cat/Category/Exponential.agda index 5865da0..137e501 100644 --- a/src/Cat/Category/Exponential.agda +++ b/src/Cat/Category/Exponential.agda @@ -19,7 +19,7 @@ module _ {ℓ ℓ'} (ℂ : Category ℓ ℓ') {{hasProducts : HasProducts ℂ}} 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) + → ∃![ f~ ] (ℂ [ eval ∘ f~ |×| Category.𝟙 ℂ ] ≡ f) record Exponential : Set (ℓ ⊔ ℓ') where field diff --git a/src/Cat/Category/Product.agda b/src/Cat/Category/Product.agda index cbc42b5..5eca0e0 100644 --- a/src/Cat/Category/Product.agda +++ b/src/Cat/Category/Product.agda @@ -1,8 +1,8 @@ module Cat.Category.Product where open import Agda.Primitive -open import Data.Product open import Cubical +open import Data.Product as P hiding (_×_) open import Cat.Category @@ -12,14 +12,16 @@ module _ {ℓ ℓ' : Level} (ℂ : Category ℓ ℓ') {A B obj : Object ℂ} whe IsProduct : (π₁ : ℂ [ obj , A ]) (π₂ : ℂ [ obj , B ]) → Set (ℓ ⊔ ℓ') IsProduct π₁ π₂ = ∀ {X : Object ℂ} (x₁ : ℂ [ X , A ]) (x₂ : ℂ [ X , B ]) - → ∃![ x ] (ℂ [ π₁ ∘ x ] ≡ x₁ × ℂ [ π₂ ∘ x ] ≡ x₂) + → ∃![ x ] (ℂ [ π₁ ∘ x ] ≡ x₁ P.× ℂ [ π₂ ∘ x ] ≡ x₂) -- Tip from Andrea; Consider this style for efficiency: --- record IsProduct {ℓ ℓ' : Level} (ℂ : Category {ℓ} {ℓ'}) --- {A B obj : Object ℂ} (π₁ : Arrow ℂ obj A) (π₂ : Arrow ℂ obj B) : Set (ℓ ⊔ ℓ') where +-- record IsProduct {ℓa ℓb : Level} (ℂ : Category ℓa ℓb) +-- {A B obj : Object ℂ} (π₁ : Arrow ℂ obj A) (π₂ : Arrow ℂ obj B) : Set (ℓa ⊔ ℓb) where -- field --- isProduct : ∀ {X : ℂ .Object} (x₁ : ℂ .Arrow X A) (x₂ : ℂ .Arrow X B) --- → ∃![ x ] (ℂ ._⊕_ π₁ x ≡ x₁ × ℂ. _⊕_ π₂ x ≡ x₂) +-- issProduct : ∀ {X : Object ℂ} (x₁ : ℂ [ X , A ]) (x₂ : ℂ [ X , B ]) +-- → ∃![ x ] (ℂ [ π₁ ∘ x ] ≡ x₁ P.× ℂ [ π₂ ∘ x ] ≡ x₂) + +-- open IsProduct record Product {ℓ ℓ' : Level} {ℂ : Category ℓ ℓ'} (A B : Object ℂ) : Set (ℓ ⊔ ℓ') where no-eta-equality @@ -29,9 +31,9 @@ record Product {ℓ ℓ' : Level} {ℂ : Category ℓ ℓ'} (A B : Object ℂ) : proj₂ : ℂ [ obj , B ] {{isProduct}} : IsProduct ℂ proj₁ proj₂ - arrowProduct : ∀ {X} → (π₁ : ℂ [ X , A ]) (π₂ : ℂ [ X , B ]) + _P[_×_] : ∀ {X} → (π₁ : ℂ [ X , A ]) (π₂ : ℂ [ X , B ]) → ℂ [ X , obj ] - arrowProduct π₁ π₂ = proj₁ (isProduct π₁ π₂) + _P[_×_] π₁ π₂ = proj₁ (isProduct π₁ π₂) record HasProducts {ℓ ℓ' : Level} (ℂ : Category ℓ ℓ') : Set (ℓ ⊔ ℓ') where field @@ -39,12 +41,14 @@ record HasProducts {ℓ ℓ' : Level} (ℂ : Category ℓ ℓ') : Set (ℓ ⊔ open Product - objectProduct : (A B : Object ℂ) → Object ℂ - objectProduct A B = Product.obj (product A B) + _×_ : (A B : Object ℂ) → Object ℂ + 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' : 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₁ ]) - (ℂ [ b ∘ (product A B) .proj₂ ]) + _|×|_ : {A A' B B' : Object ℂ} → ℂ [ A , A' ] → ℂ [ B , B' ] + → ℂ [ A × B , A' × B' ] + _|×|_ {A = A} {A' = A'} {B = B} {B' = B'} a b + = product A' B' + P[ ℂ [ a ∘ (product A B) .proj₁ ] + × ℂ [ b ∘ (product A B) .proj₂ ] + ] diff --git a/src/Cat/Category/Properties.agda b/src/Cat/Category/Properties.agda index 9b678a5..a656b4c 100644 --- a/src/Cat/Category/Properties.agda +++ b/src/Cat/Category/Properties.agda @@ -60,7 +60,7 @@ open Functor -- open import Cat.Categories.Fun -- open import Cat.Categories.Sets -- -- module Cat = Cat.Categories.Cat --- open Exponential +-- open import Cat.Category.Exponential -- private -- Catℓ = Cat ℓ ℓ -- prshf = presheaf {ℂ = ℂ} From 0688f5c37231b6bc7564d626abe3882dddf41ac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20Hangh=C3=B8j=20Iversen?= Date: Tue, 6 Feb 2018 10:34:43 +0100 Subject: [PATCH 6/9] Rename arrowIsSet --- src/Cat/Categories/Fam.agda | 2 +- src/Cat/Categories/Fun.agda | 2 +- src/Cat/Categories/Rel.agda | 2 +- src/Cat/Categories/Sets.agda | 2 +- src/Cat/Category.agda | 25 +++++++++++++------------ src/Cat/Category/Free.agda | 2 +- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/Cat/Categories/Fam.agda b/src/Cat/Categories/Fam.agda index 600cabb..83f19b0 100644 --- a/src/Cat/Categories/Fam.agda +++ b/src/Cat/Categories/Fam.agda @@ -46,7 +46,7 @@ module _ (ℓa ℓb : Level) where isCategory = record { assoc = λ {A} {B} {C} {D} {f} {g} {h} → assoc {D = D} {f} {g} {h} ; ident = λ {A} {B} {f} → ident {A} {B} {f = f} - ; arrow-is-set = {!!} + ; arrowIsSet = {!!} ; univalent = {!!} } diff --git a/src/Cat/Categories/Fun.agda b/src/Cat/Categories/Fun.agda index 50acaaa..26e71b1 100644 --- a/src/Cat/Categories/Fun.agda +++ b/src/Cat/Categories/Fun.agda @@ -110,7 +110,7 @@ module _ {ℓc ℓc' ℓd ℓd' : Level} {ℂ : Category ℓc ℓc'} {𝔻 : Cat :isCategory: = record { assoc = λ {A B C D} → :assoc: {A} {B} {C} {D} ; ident = λ {A B} → :ident: {A} {B} - ; arrow-is-set = {!!} + ; arrowIsSet = {!!} ; univalent = {!!} } diff --git a/src/Cat/Categories/Rel.agda b/src/Cat/Categories/Rel.agda index d58b35c..8a93274 100644 --- a/src/Cat/Categories/Rel.agda +++ b/src/Cat/Categories/Rel.agda @@ -166,6 +166,6 @@ RawIsCategoryRel : IsCategory RawRel RawIsCategoryRel = record { assoc = funExt is-assoc ; ident = funExt ident-l , funExt ident-r - ; arrow-is-set = {!!} + ; arrowIsSet = {!!} ; univalent = {!!} } diff --git a/src/Cat/Categories/Sets.agda b/src/Cat/Categories/Sets.agda index e13fa0c..aade6d0 100644 --- a/src/Cat/Categories/Sets.agda +++ b/src/Cat/Categories/Sets.agda @@ -23,7 +23,7 @@ module _ {ℓ : Level} where assoc SetsIsCategory = refl proj₁ (ident SetsIsCategory) = funExt λ _ → refl proj₂ (ident SetsIsCategory) = funExt λ _ → refl - arrow-is-set SetsIsCategory = {!!} + arrowIsSet SetsIsCategory = {!!} univalent SetsIsCategory = {!!} Sets : Category (lsuc ℓ) ℓ diff --git a/src/Cat/Category.agda b/src/Cat/Category.agda index 6af9764..5cd7c5b 100644 --- a/src/Cat/Category.agda +++ b/src/Cat/Category.agda @@ -11,7 +11,7 @@ open import Data.Product renaming ) open import Data.Empty import Function -open import Cubical +open import Cubical hiding (isSet) open import Cubical.GradLemma using ( propIsEquiv ) ∃! : ∀ {a b} {A : Set a} @@ -23,6 +23,9 @@ open import Cubical.GradLemma using ( propIsEquiv ) syntax ∃!-syntax (λ x → B) = ∃![ x ] B +IsSet : {ℓ : Level} (A : Set ℓ) → Set ℓ +IsSet A = {x y : A} → (p q : x ≡ y) → p ≡ q + record RawCategory (ℓ ℓ' : Level) : Set (lsuc (ℓ' ⊔ ℓ)) where -- adding no-eta-equality can speed up type-checking. -- ONLY IF you define your categories with copatterns though. @@ -59,7 +62,7 @@ record IsCategory {ℓa ℓb : Level} (ℂ : RawCategory ℓa ℓb) : Set (lsuc → h ∘ (g ∘ f) ≡ (h ∘ g) ∘ f ident : {A B : Object} {f : Arrow A B} → f ∘ 𝟙 ≡ f × 𝟙 ∘ f ≡ f - arrow-is-set : ∀ {A B : Object} → isSet (Arrow A B) + arrowIsSet : ∀ {A B : Object} → IsSet (Arrow A B) Isomorphism : ∀ {A B} → (f : Arrow A B) → Set ℓb Isomorphism {A} {B} f = Σ[ g ∈ Arrow B A ] g ∘ f ≡ 𝟙 × f ∘ g ≡ 𝟙 @@ -73,7 +76,6 @@ record IsCategory {ℓa ℓb : Level} (ℂ : RawCategory ℓa ℓb) : Set (lsuc 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) @@ -93,16 +95,15 @@ module _ {ℓa} {ℓb} {ℂ : RawCategory ℓa ℓb} where -- This lemma will be useful to prove the equality of two categories. IsCategory-is-prop : isProp (IsCategory ℂ) IsCategory-is-prop x y i = record - { assoc = x.arrow-is-set _ _ x.assoc y.assoc i + { assoc = x.arrowIsSet x.assoc y.assoc i ; ident = - ( x.arrow-is-set _ _ (fst x.ident) (fst y.ident) i - , x.arrow-is-set _ _ (snd x.ident) (snd y.ident) i + ( x.arrowIsSet (fst x.ident) (fst y.ident) i + , x.arrowIsSet (snd x.ident) (snd y.ident) i ) - -- ; arrow-is-set = {!λ x₁ y₁ p q → x.arrow-is-set _ _ p q!} - ; arrow-is-set = λ _ _ p q → + ; arrowIsSet = λ p q → let - golden : x.arrow-is-set _ _ p q ≡ y.arrow-is-set _ _ p q - golden = λ j k l → {!!} + golden : x.arrowIsSet p q ≡ y.arrowIsSet p q + golden = {!!} in golden i ; univalent = λ y₁ → {!!} @@ -150,7 +151,7 @@ module _ {ℓa ℓb : Level} (ℂ : Category ℓa ℓb) where OpIsCategory : IsCategory OpRaw IsCategory.assoc OpIsCategory = sym assoc IsCategory.ident OpIsCategory = swap ident - IsCategory.arrow-is-set OpIsCategory = {!!} + IsCategory.arrowIsSet OpIsCategory = arrowIsSet IsCategory.univalent OpIsCategory = {!!} Opposite : Category ℓa ℓb @@ -176,7 +177,7 @@ module _ {ℓa ℓb : Level} {ℂ : Category ℓa ℓb} where rawIsCat : (i : I) → IsCategory (rawOp i) assoc (rawIsCat i) = IsCat.assoc ident (rawIsCat i) = IsCat.ident - arrow-is-set (rawIsCat i) = IsCat.arrow-is-set + arrowIsSet (rawIsCat i) = IsCat.arrowIsSet univalent (rawIsCat i) = IsCat.univalent Opposite-is-involution : Opposite (Opposite ℂ) ≡ ℂ diff --git a/src/Cat/Category/Free.agda b/src/Cat/Category/Free.agda index c8732d1..44ad12e 100644 --- a/src/Cat/Category/Free.agda +++ b/src/Cat/Category/Free.agda @@ -37,6 +37,6 @@ module _ {ℓ ℓ' : Level} (ℂ : Category ℓ ℓ') where RawIsCategoryFree = record { assoc = p-assoc ; ident = ident-r , ident-l - ; arrow-is-set = {!!} + ; arrowIsSet = {!!} ; univalent = {!!} } From 9f1e82168fc80bff4aa1d764dcaf2c106344e42d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20Hangh=C3=B8j=20Iversen?= Date: Tue, 6 Feb 2018 10:35:52 +0100 Subject: [PATCH 7/9] Move the free category --- src/Cat.agda | 2 +- src/Cat/{Category => Categories}/Free.agda | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/Cat/{Category => Categories}/Free.agda (97%) diff --git a/src/Cat.agda b/src/Cat.agda index c452d26..f7c744e 100644 --- a/src/Cat.agda +++ b/src/Cat.agda @@ -9,11 +9,11 @@ import Cat.Category.Exponential import Cat.Category.CartesianClosed import Cat.Category.Pathy import Cat.Category.Bij -import Cat.Category.Free import Cat.Category.Properties import Cat.Categories.Sets -- import Cat.Categories.Cat import Cat.Categories.Rel +import Cat.Categories.Free import Cat.Categories.Fun import Cat.Categories.Cube diff --git a/src/Cat/Category/Free.agda b/src/Cat/Categories/Free.agda similarity index 97% rename from src/Cat/Category/Free.agda rename to src/Cat/Categories/Free.agda index 44ad12e..71dec95 100644 --- a/src/Cat/Category/Free.agda +++ b/src/Cat/Categories/Free.agda @@ -1,5 +1,5 @@ {-# OPTIONS --allow-unsolved-metas #-} -module Cat.Category.Free where +module Cat.Categories.Free where open import Agda.Primitive open import Cubical hiding (Path) From a27292dd53d93cb23863cc35854a365f0e57d631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20Hangh=C3=B8j=20Iversen?= Date: Tue, 6 Feb 2018 11:27:22 +0100 Subject: [PATCH 8/9] Stuff about the free category --- src/Cat/Categories/Free.agda | 66 +++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/src/Cat/Categories/Free.agda b/src/Cat/Categories/Free.agda index 71dec95..16b37c0 100644 --- a/src/Cat/Categories/Free.agda +++ b/src/Cat/Categories/Free.agda @@ -2,41 +2,61 @@ module Cat.Categories.Free where open import Agda.Primitive -open import Cubical hiding (Path) +open import Cubical hiding (Path ; isSet ; empty) open import Data.Product -open import Cat.Category as C +open import Cat.Category + +open IsCategory +open Category + +-- data Path {ℓ : Level} {A : Set ℓ} : (a b : A) → Set ℓ where +-- emptyPath : {a : A} → Path a a +-- concatenate : {a b c : A} → Path a b → Path b c → Path a b module _ {ℓ ℓ' : Level} (ℂ : Category ℓ ℓ') where - private - open module ℂ = Category ℂ + module ℂ = Category ℂ - postulate - 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 + -- 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 - 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 : ℂ.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 ℓ ℓ' + module _ {A B C D : Object ℂ} where + 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-assoc {r} {q} {p} = {!!} + module _ {A B : Object ℂ} {p : Path A B} where + -- postulate + -- ident-r : concatenate {A} {A} {B} p (lift 𝟙) ≡ p + -- ident-l : concatenate {A} {B} {B} (lift 𝟙) p ≡ p + module _ {A B : Object ℂ} where + isSet : IsSet (Path A B) + isSet = {!!} + RawFree : RawCategory ℓ (ℓ ⊔ ℓ') RawFree = record - { Object = ℂ.Object + { Object = Object ℂ ; Arrow = Path - ; 𝟙 = λ {o} → emptyPath o - ; _∘_ = λ {a b c} → concatenate {a} {b} {c} + ; 𝟙 = λ {o} → {!lift 𝟙!} + ; _∘_ = λ {a b c} → {!concatenate {a} {b} {c}!} } RawIsCategoryFree : IsCategory RawFree RawIsCategoryFree = record - { assoc = p-assoc - ; ident = ident-r , ident-l + { assoc = {!p-assoc!} + ; ident = {!ident-r , ident-l!} ; arrowIsSet = {!!} ; univalent = {!!} } From 9349b3755011e984e23019fa75948e449d27615d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20Hangh=C3=B8j=20Iversen?= Date: Tue, 6 Feb 2018 14:24:34 +0100 Subject: [PATCH 9/9] Refactor Functor - only in module Functor --- src/Cat/Categories/Fun.agda | 36 +++++---- src/Cat/Categories/Sets.agda | 12 ++- src/Cat/Category.agda | 8 +- src/Cat/Category/Functor.agda | 143 +++++++++++++++++++++++----------- src/Cat/CwF.agda | 6 +- 5 files changed, 133 insertions(+), 72 deletions(-) diff --git a/src/Cat/Categories/Fun.agda b/src/Cat/Categories/Fun.agda index 26e71b1..e60a118 100644 --- a/src/Cat/Categories/Fun.agda +++ b/src/Cat/Categories/Fun.agda @@ -14,15 +14,18 @@ module _ {ℓc ℓc' ℓd ℓd' : Level} {ℂ : Category ℓc ℓc'} {𝔻 : Cat open Functor module _ (F G : Functor ℂ 𝔻) where + private + module F = Functor F + module G = Functor G -- 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 ℂ} → (f : ℂ [ A , B ]) - → 𝔻 [ θ B ∘ F .func→ f ] ≡ 𝔻 [ G .func→ f ∘ θ A ] + → 𝔻 [ θ B ∘ F.func→ f ] ≡ 𝔻 [ G.func→ f ∘ θ A ] NaturalTransformation : Set (ℓc ⊔ ℓc' ⊔ ℓd') NaturalTransformation = Σ Transformation Natural @@ -30,13 +33,12 @@ module _ {ℓc ℓc' ℓd ℓd' : Level} {ℂ : Category ℓc ℓc'} {𝔻 : Cat -- NaturalTranformation : Set (ℓc ⊔ (ℓc' ⊔ ℓd')) -- NaturalTranformation = ∀ (θ : Transformation) {A B : ℂ .Object} → (f : ℂ .Arrow A B) → 𝔻 ._⊕_ (θ B) (F .func→ f) ≡ 𝔻 ._⊕_ (G .func→ f) (θ A) - module _ {F G : Functor ℂ 𝔻} where - NaturalTransformation≡ : {α β : NaturalTransformation F G} + NaturalTransformation≡ : {α β : NaturalTransformation} → (eq₁ : α .proj₁ ≡ β .proj₁) → (eq₂ : PathP (λ i → {A B : Object ℂ} (f : ℂ [ A , B ]) - → 𝔻 [ eq₁ i B ∘ F .func→ f ] - ≡ 𝔻 [ G .func→ f ∘ eq₁ i A ]) + → 𝔻 [ eq₁ i B ∘ F.func→ f ] + ≡ 𝔻 [ G.func→ f ∘ eq₁ i A ]) (α .proj₂) (β .proj₂)) → α ≡ β NaturalTransformation≡ eq₁ eq₂ i = eq₁ i , eq₂ i @@ -52,7 +54,8 @@ module _ {ℓc ℓc' ℓd ℓd' : Level} {ℂ : Category ℓc ℓc'} {𝔻 : Cat 𝔻 [ F→ f ∘ 𝟙 𝔻 ] ≡⟨⟩ 𝔻 [ F→ f ∘ identityTrans F A ] ∎ where - F→ = F .func→ + module F = Functor F + F→ = F.func→ module 𝔻 = IsCategory (isCategory 𝔻) identityNat : (F : Functor ℂ 𝔻) → NaturalTransformation F F @@ -60,20 +63,23 @@ module _ {ℓc ℓc' ℓd ℓd' : Level} {ℂ : Category ℓc ℓc'} {𝔻 : Cat module _ {F G H : Functor ℂ 𝔻} where private + module F = Functor F + module G = Functor G + module H = Functor H _∘nt_ : Transformation G H → Transformation F G → Transformation F H (θ ∘nt η) C = 𝔻 [ θ C ∘ η C ] NatComp _:⊕:_ : NaturalTransformation G H → NaturalTransformation F G → NaturalTransformation F H proj₁ ((θ , _) :⊕: (η , _)) = θ ∘nt η proj₂ ((θ , θNat) :⊕: (η , ηNat)) {A} {B} f = begin - 𝔻 [ (θ ∘nt η) B ∘ F .func→ f ] ≡⟨⟩ - 𝔻 [ 𝔻 [ θ B ∘ η B ] ∘ F .func→ f ] ≡⟨ sym assoc ⟩ - 𝔻 [ θ B ∘ 𝔻 [ η B ∘ F .func→ f ] ] ≡⟨ cong (λ φ → 𝔻 [ θ B ∘ φ ]) (ηNat f) ⟩ - 𝔻 [ θ B ∘ 𝔻 [ G .func→ f ∘ η A ] ] ≡⟨ assoc ⟩ - 𝔻 [ 𝔻 [ θ B ∘ G .func→ f ] ∘ η A ] ≡⟨ cong (λ φ → 𝔻 [ φ ∘ η A ]) (θNat f) ⟩ - 𝔻 [ 𝔻 [ H .func→ f ∘ θ A ] ∘ η A ] ≡⟨ sym assoc ⟩ - 𝔻 [ H .func→ f ∘ 𝔻 [ θ A ∘ η A ] ] ≡⟨⟩ - 𝔻 [ H .func→ f ∘ (θ ∘nt η) A ] ∎ + 𝔻 [ (θ ∘nt η) B ∘ F.func→ f ] ≡⟨⟩ + 𝔻 [ 𝔻 [ θ B ∘ η B ] ∘ F.func→ f ] ≡⟨ sym assoc ⟩ + 𝔻 [ θ B ∘ 𝔻 [ η B ∘ F.func→ f ] ] ≡⟨ cong (λ φ → 𝔻 [ θ B ∘ φ ]) (ηNat f) ⟩ + 𝔻 [ θ B ∘ 𝔻 [ G.func→ f ∘ η A ] ] ≡⟨ assoc ⟩ + 𝔻 [ 𝔻 [ θ B ∘ G.func→ f ] ∘ η A ] ≡⟨ cong (λ φ → 𝔻 [ φ ∘ η A ]) (θNat f) ⟩ + 𝔻 [ 𝔻 [ H.func→ f ∘ θ A ] ∘ η A ] ≡⟨ sym assoc ⟩ + 𝔻 [ H.func→ f ∘ 𝔻 [ θ A ∘ η A ] ] ≡⟨⟩ + 𝔻 [ H.func→ f ∘ (θ ∘nt η) A ] ∎ where open IsCategory (isCategory 𝔻) diff --git a/src/Cat/Categories/Sets.agda b/src/Cat/Categories/Sets.agda index aade6d0..5263aa1 100644 --- a/src/Cat/Categories/Sets.agda +++ b/src/Cat/Categories/Sets.agda @@ -56,8 +56,10 @@ Representable {ℓ' = ℓ'} ℂ = Functor ℂ (Sets {ℓ'}) -- The "co-yoneda" embedding. representable : ∀ {ℓ ℓ'} {ℂ : Category ℓ ℓ'} → Category.Object ℂ → Representable ℂ representable {ℂ = ℂ} A = record - { func* = λ B → ℂ [ A , B ] - ; func→ = ℂ [_∘_] + { raw = record + { func* = λ B → ℂ [ A , B ] + ; func→ = ℂ [_∘_] + } ; isFunctor = record { ident = funExt λ _ → proj₂ ident ; distrib = funExt λ x → sym assoc @@ -73,8 +75,10 @@ Presheaf {ℓ' = ℓ'} ℂ = Functor (Opposite ℂ) (Sets {ℓ'}) -- Alternate name: `yoneda` presheaf : {ℓ ℓ' : Level} {ℂ : Category ℓ ℓ'} → Category.Object (Opposite ℂ) → Presheaf ℂ presheaf {ℂ = ℂ} B = record - { func* = λ A → ℂ [ A , B ] - ; func→ = λ f g → ℂ [ g ∘ f ] + { raw = record + { func* = λ A → ℂ [ A , B ] + ; func→ = λ f g → ℂ [ g ∘ f ] + } ; isFunctor = record { ident = funExt λ x → proj₁ ident ; distrib = funExt λ x → assoc diff --git a/src/Cat/Category.agda b/src/Cat/Category.agda index 5cd7c5b..168b2fc 100644 --- a/src/Cat/Category.agda +++ b/src/Cat/Category.agda @@ -53,10 +53,6 @@ record RawCategory (ℓ ℓ' : Level) : Set (lsuc (ℓ' ⊔ ℓ)) where -- (univalent). record IsCategory {ℓa ℓb : Level} (ℂ : RawCategory ℓa ℓb) : Set (lsuc (ℓa ⊔ ℓb)) where 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 assoc : {A B C D : Object} { f : Arrow A B } { g : Arrow B C } { h : Arrow C D } → h ∘ (g ∘ f) ≡ (h ∘ g) ∘ f @@ -100,9 +96,9 @@ module _ {ℓa} {ℓb} {ℂ : RawCategory ℓa ℓb} where ( x.arrowIsSet (fst x.ident) (fst y.ident) i , x.arrowIsSet (snd x.ident) (snd y.ident) i ) - ; arrowIsSet = λ p q → + ; arrowIsSet = λ p q → let - golden : x.arrowIsSet p q ≡ y.arrowIsSet p q + golden : x.arrowIsSet p q ≡ y.arrowIsSet p q golden = {!!} in golden i diff --git a/src/Cat/Category/Functor.agda b/src/Cat/Category/Functor.agda index 912557e..8097071 100644 --- a/src/Cat/Category/Functor.agda +++ b/src/Cat/Category/Functor.agda @@ -6,61 +6,110 @@ open import Function open import Cat.Category -open Category hiding (_∘_) +open Category hiding (_∘_ ; raw) -module _ {ℓc ℓc' ℓd ℓd'} (ℂ : Category ℓc ℓc') (𝔻 : Category ℓd ℓd') where - record IsFunctor - (func* : Object ℂ → Object 𝔻) - (func→ : {A B : Object ℂ} → ℂ [ A , B ] → 𝔻 [ func* A , func* B ]) - : Set (ℓc ⊔ ℓc' ⊔ ℓd ⊔ ℓd') where +module _ {ℓc ℓc' ℓd ℓd'} + (ℂ : Category ℓc ℓc') + (𝔻 : Category ℓ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 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 ]} → func→ (ℂ [ g ∘ f ]) ≡ 𝔻 [ func→ g ∘ func→ f ] record Functor : Set (ℓc ⊔ ℓc' ⊔ ℓd ⊔ ℓd') where field - func* : Object ℂ → Object 𝔻 - func→ : ∀ {A B} → ℂ [ A , B ] → 𝔻 [ func* A , func* B ] - {{isFunctor}} : IsFunctor func* func→ + raw : RawFunctor + {{isFunctor}} : IsFunctor raw + + private + module R = RawFunctor raw + + func* : Object ℂ → Object 𝔻 + func* = R.func* + + func→ : ∀ {A B} → ℂ [ A , B ] → 𝔻 [ func* A , func* B ] + func→ = R.func→ open IsFunctor 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 - - 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 ℂ 𝔻} - → (eq* : F .func* ≡ G .func*) + → (eq* : func* F ≡ func* G) → (eq→ : (λ i → ∀ {x y} → ℂ [ x , y ] → 𝔻 [ eq* i x , eq* i y ]) - [ F .func→ ≡ G .func→ ]) - -- → (eqIsF : PathP (λ i → IsFunctor ℂ 𝔻 (eq* i) (eq→ i)) (F .isFunctor) (G .isFunctor)) - → (eqIsFunctor : (λ i → IsFunctor ℂ 𝔻 (eq* i) (eq→ i)) [ F .isFunctor ≡ G .isFunctor ]) + [ func→ F ≡ func→ 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 private - F* = F .func* - F→ = F .func→ - G* = G .func* - G→ = G .func→ + F* = func* F + F→ = func→ F + G* = func* G + G→ = func→ G 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 ] @@ -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 ⟩ C [ (F→ ∘ G→) α1 ∘ (F→ ∘ G→) α0 ] ∎ - _∘f_ : Functor A C - _∘f_ = - record - { func* = F* ∘ G* - ; func→ = F→ ∘ G→ - ; isFunctor = record + _∘fr_ : RawFunctor A C + RawFunctor.func* _∘fr_ = F* ∘ G* + RawFunctor.func→ _∘fr_ = F→ ∘ G→ + instance + isFunctor' : IsFunctor A C _∘fr_ + isFunctor' = record { ident = begin (F→ ∘ G→) (𝟙 A) ≡⟨ refl ⟩ 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 ∎ ; distrib = dist } - } + + _∘f_ : Functor A C + raw _∘f_ = _∘fr_ -- The identity functor identity : ∀ {ℓ ℓ'} → {C : Category ℓ ℓ'} → Functor C C identity = record - { func* = λ x → x - ; func→ = λ x → x + { raw = record + { func* = λ x → x + ; func→ = λ x → x + } ; isFunctor = record { ident = refl ; distrib = refl diff --git a/src/Cat/CwF.agda b/src/Cat/CwF.agda index 44e725e..5735ac3 100644 --- a/src/Cat/CwF.agda +++ b/src/Cat/CwF.agda @@ -25,8 +25,10 @@ module _ {ℓa ℓb : Level} where T : Functor (Opposite ℂ) (Fam ℓa ℓb) -- Empty context [] : Terminal ℂ + private + module T = Functor T Type : (Γ : Object ℂ) → Set ℓa - Type Γ = proj₁ (T .func* Γ) + Type Γ = proj₁ (T.func* Γ) module _ {Γ : Object ℂ} {A : Type Γ} where @@ -35,7 +37,7 @@ module _ {ℓa ℓb : Level} where (λ f → {x : proj₁ (func* T B)} → proj₂ (func* T B) x → proj₂ (func* T A) (f x)) - k = T .func→ γ + k = T.func→ γ k₁ : proj₁ (func* T B) → proj₁ (func* T A) k₁ = proj₁ k k₂ : ({x : proj₁ (func* T B)} →