Restructure products

This commit is contained in:
Frederik Hanghøj Iversen 2018-03-08 10:20:29 +01:00
parent b61749bb91
commit fae492a1e3
3 changed files with 63 additions and 63 deletions

View file

@ -151,16 +151,17 @@ module _ { ' : Level} (unprovable : IsCategory (RawCat ')) where
private
module P = CatProduct 𝔻
instance
isProduct : IsProduct Cat P.proj₁ P.proj₂
isProduct = P.isProduct
rawProduct : RawProduct { = Cat} 𝔻
RawProduct.obj rawProduct = P.obj
RawProduct.proj₁ rawProduct = P.proj₁
RawProduct.proj₂ rawProduct = P.proj₂
isProduct : IsProduct Cat rawProduct
IsProduct.isProduct isProduct = P.isProduct
product : Product { = Cat} 𝔻
product = record
{ obj = P.obj
; proj₁ = P.proj₁
; proj₂ = P.proj₂
}
Product.raw product = rawProduct
Product.isProduct product = isProduct
instance
hasProducts : HasProducts Cat

View file

@ -64,17 +64,17 @@ module _ { : Level} 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
rawProduct : RawProduct { = 𝓢} 0A 0B
RawProduct.obj rawProduct = 0A×0B
RawProduct.proj₁ rawProduct = Data.Product.proj₁
RawProduct.proj₂ rawProduct = Data.Product.proj₂
isProduct : IsProduct 𝓢 rawProduct
IsProduct.isProduct 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}}
}
Product.raw product = rawProduct
Product.isProduct product = isProduct
instance
SetsHasProducts : HasProducts 𝓢

View file

@ -2,61 +2,60 @@ module Cat.Category.Product where
open import Agda.Primitive
open import Cubical
open import Data.Product as P hiding (_×_)
open import Data.Product as P hiding (_×_ ; proj₁ ; proj₂)
open import Cat.Category
open import Cat.Category hiding (module Propositionality)
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₁ P.× [ π₂ x ] x₂)
module _ {a b : Level} where
record RawProduct { : Category a b} (A B : Object ) : Set (a b) where
no-eta-equality
field
obj : Object
proj₁ : [ obj , A ]
proj₂ : [ obj , B ]
-- Tip from Andrea; Consider this style for efficiency:
-- record IsProduct {a b : Level} ( : Category a b)
-- {A B obj : Object } (π₁ : Arrow obj A) (π₂ : Arrow obj B) : Set (a ⊔ b) where
-- field
-- issProduct : ∀ {X : Object } (x₁ : [ X , A ]) (x₂ : [ X , B ])
-- → ∃![ x ] ( [ π₁ ∘ x ] ≡ x₁ P.× [ π₂ ∘ x ] ≡ x₂)
record IsProduct ( : Category a b) {A B : Object } (raw : RawProduct { = } A B) : Set (a b) where
open RawProduct raw public
field
isProduct : {X : Object } (x₁ : [ X , A ]) (x₂ : [ X , B ])
∃![ x ] ( [ proj₁ x ] x₁ P.× [ proj₂ x ] x₂)
-- open IsProduct
-- | Arrow product
_P[_×_] : {X} (π₁ : [ X , A ]) (π₂ : [ X , B ])
[ X , obj ]
_P[_×_] π₁ π₂ = P.proj₁ (isProduct π₁ π₂)
-- TODO `isProp (Product ...)`
-- TODO `isProp (HasProducts ...)`
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₂
record Product { : Category a b} (A B : Object ) : Set (a b) where
field
raw : RawProduct { = } A B
isProduct : IsProduct {A} {B} raw
-- | Arrow product
_P[_×_] : {X} (π₁ : [ X , A ]) (π₂ : [ X , B ])
[ X , obj ]
_P[_×_] π₁ π₂ = proj₁ (isProduct π₁ π₂)
open IsProduct isProduct public
record HasProducts { ' : Level} ( : Category ') : Set ( ') where
field
product : (A B : Object ) Product { = } A B
record HasProducts ( : Category a b) : Set (a b) where
field
product : (A B : Object ) Product { = } A B
open Product hiding (obj)
module _ (A B : Object ) where
open Product (product A B)
_×_ : Object
_×_ = obj
module _ (A B : Object ) where
open Product (product A B)
_×_ : Object
_×_ = obj
-- | Parallel product of arrows
--
-- The product mentioned in awodey in Def 6.1 is not the regular product of
-- arrows. It's a "parallel" product
module _ {A A' B B' : Object } where
open Product
open Product (product A B) hiding (_P[_×_]) renaming (proj₁ to fst ; proj₂ to snd)
_|×|_ : [ A , A' ] [ B , B' ] [ A × B , A' × B' ]
a |×| b = product A' B'
P[ [ a fst ]
× [ b snd ]
]
-- | Parallel product of arrows
--
-- The product mentioned in awodey in Def 6.1 is not the regular product of
-- arrows. It's a "parallel" product
module _ {A A' B B' : Object } where
open Product (product A B) hiding (_P[_×_]) renaming (proj₁ to fst ; proj₂ to snd)
_|×|_ : [ A , A' ] [ B , B' ] [ A × B , A' × B' ]
a |×| b = product A' B'
P[ [ a fst ]
× [ b snd ]
]
module Propositionality where
-- TODO `isProp (Product ...)`
-- TODO `isProp (HasProducts ...)`