Use correct order for left- and right identity

Define and use helpers left- and right identity
This commit is contained in:
Frederik Hanghøj Iversen 2018-03-21 11:46:36 +01:00
parent 71d9acff9a
commit 4beb48e066
11 changed files with 65 additions and 61 deletions

View file

@ -47,7 +47,7 @@ module _ ( ' : Level) where
isAssociative : IsAssociative isAssociative : IsAssociative
isAssociative {f = F} {G} {H} = assc {F = F} {G = G} {H = H} isAssociative {f = F} {G} {H} = assc {F = F} {G = G} {H = H}
ident : IsIdentity identity ident : IsIdentity identity
ident = ident-r , ident-l ident = ident-l , ident-r
-- NB! `ArrowsAreSets RawCat` is *not* provable. The type of functors, -- NB! `ArrowsAreSets RawCat` is *not* provable. The type of functors,
-- however, form a groupoid! Therefore there is no (1-)category of -- however, form a groupoid! Therefore there is no (1-)category of
@ -244,7 +244,7 @@ module CatExponential { : Level} ( 𝔻 : Category ) where
fmap {c} {c} (𝟙 (object ) {c}) ≡⟨⟩ fmap {c} {c} (𝟙 (object ) {c}) ≡⟨⟩
fmap {c} {c} (idN F , 𝟙 ) ≡⟨⟩ fmap {c} {c} (idN F , 𝟙 ) ≡⟨⟩
𝔻 [ identityTrans F C F.fmap (𝟙 )] ≡⟨⟩ 𝔻 [ identityTrans F C F.fmap (𝟙 )] ≡⟨⟩
𝔻 [ 𝟙 𝔻 F.fmap (𝟙 )] ≡⟨ proj₂ 𝔻.isIdentity 𝔻 [ 𝟙 𝔻 F.fmap (𝟙 )] ≡⟨ 𝔻.leftIdentity
F.fmap (𝟙 ) ≡⟨ F.isIdentity F.fmap (𝟙 ) ≡⟨ F.isIdentity
𝟙 𝔻 𝟙 𝔻
where where

View file

@ -55,7 +55,7 @@ module _ {a b : Level} ( : Category a b) where
ident-l = refl ident-l = refl
isIdentity : IsIdentity 𝟙 isIdentity : IsIdentity 𝟙
isIdentity = ident-r , ident-l isIdentity = ident-l , ident-r
open Univalence isIdentity open Univalence isIdentity

View file

@ -45,18 +45,18 @@ module Fun {c c' d d' : Level} ( : Category c c') (𝔻 : C
eq-r : C (𝔻 [ f' C identityTrans A C ]) f' C eq-r : C (𝔻 [ f' C identityTrans A C ]) f' C
eq-r C = begin eq-r C = begin
𝔻 [ f' C identityTrans A C ] ≡⟨⟩ 𝔻 [ f' C identityTrans A C ] ≡⟨⟩
𝔻 [ f' C 𝔻.𝟙 ] ≡⟨ proj₁ 𝔻.isIdentity 𝔻 [ f' C 𝔻.𝟙 ] ≡⟨ 𝔻.rightIdentity
f' C f' C
eq-l : C (𝔻 [ identityTrans B C f' C ]) f' C eq-l : C (𝔻 [ identityTrans B C f' C ]) f' C
eq-l C = proj₂ 𝔻.isIdentity eq-l C = 𝔻.leftIdentity
ident-r : (NT[_∘_] {A} {A} {B} f (NT.identity A)) f ident-r : (NT[_∘_] {A} {A} {B} f (NT.identity A)) f
ident-r = lemSig allNatural _ _ (funExt eq-r) ident-r = lemSig allNatural _ _ (funExt eq-r)
ident-l : (NT[_∘_] {A} {B} {B} (NT.identity B) f) f ident-l : (NT[_∘_] {A} {B} {B} (NT.identity B) f) f
ident-l = lemSig allNatural _ _ (funExt eq-l) ident-l = lemSig allNatural _ _ (funExt eq-l)
isIdentity isIdentity
: (NT[_∘_] {A} {A} {B} f (NT.identity A)) f : (NT[_∘_] {A} {B} {B} (NT.identity B) f) f
× (NT[_∘_] {A} {B} {B} (NT.identity B) f) f × (NT[_∘_] {A} {A} {B} f (NT.identity A)) f
isIdentity = ident-r , ident-l isIdentity = ident-l , ident-r
-- Functor categories. Objects are functors, arrows are natural transformations. -- Functor categories. Objects are functors, arrows are natural transformations.
RawFun : RawCategory (c c' d d') (c c' d') RawFun : RawCategory (c c' d d') (c c' d')
RawFun = record RawFun = record

View file

@ -76,9 +76,9 @@ module _ {A B : Set} {S : Subset (A × B)} (ab : A × B) where
(a , b) S (a , b) S
equi = backwards Cubical.FromStdLib., isequiv equi = backwards Cubical.FromStdLib., isequiv
ident-l : (Σ[ a' A ] (a , a') Diag A × (a' , b) S) ident-r : (Σ[ a' A ] (a , a') Diag A × (a' , b) S)
(a , b) S (a , b) S
ident-l = equivToPath equi ident-r = equivToPath equi
module _ where module _ where
private private
@ -110,9 +110,9 @@ module _ {A B : Set} {S : Subset (A × B)} (ab : A × B) where
ab S ab S
equi = backwards Cubical.FromStdLib., isequiv equi = backwards Cubical.FromStdLib., isequiv
ident-r : (Σ[ b' B ] (a , b') S × (b' , b) Diag B) ident-l : (Σ[ b' B ] (a , b') S × (b' , b) Diag B)
ab S ab S
ident-r = equivToPath equi ident-l = equivToPath equi
module _ {A B C D : Set} {S : Subset (A × B)} {R : Subset (B × C)} {Q : Subset (C × D)} (ad : A × D) where module _ {A B C D : Set} {S : Subset (A × B)} {R : Subset (B × C)} {Q : Subset (C × D)} (ad : A × D) where
private private

View file

@ -287,39 +287,35 @@ module _ { : Level} where
open Category 𝓢 open Category 𝓢
open import Cubical.Sigma open import Cubical.Sigma
module _ (0A 0B : Object) where module _ (hA hB : Object) where
open Σ hA renaming (proj₁ to A ; proj₂ to sA)
open Σ hB renaming (proj₁ to B ; proj₂ to sB)
private private
A : Set productObject : Object
A = proj₁ 0A productObject = (A × B) , sigPresSet sA λ _ sB
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 module _ {X A B : Set } (f : X A) (g : X B) where
_&&&_ : (X A × B) _&&&_ : (X A × B)
_&&&_ x = f x , g x _&&&_ 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
rawProduct : RawProduct 𝓢 0A 0B module _ (hX : Object) where
RawProduct.object rawProduct = 0A×0B open Σ hX renaming (proj₁ to X)
module _ (f : X A ) (g : X B) where
ump : proj₁ Function.∘′ (f &&& g) f × proj₂ Function.∘′ (f &&& g) g
proj₁ ump = refl
proj₂ ump = refl
rawProduct : RawProduct 𝓢 hA hB
RawProduct.object rawProduct = productObject
RawProduct.proj₁ rawProduct = Data.Product.proj₁ RawProduct.proj₁ rawProduct = Data.Product.proj₁
RawProduct.proj₂ rawProduct = Data.Product.proj₂ RawProduct.proj₂ rawProduct = Data.Product.proj₂
isProduct : IsProduct 𝓢 _ _ rawProduct isProduct : IsProduct 𝓢 _ _ rawProduct
IsProduct.ump isProduct {X = X} f g IsProduct.ump isProduct {X = hX} f g
= (f &&& g) , lem {0X = X} f g = (f &&& g) , ump hX f g
product : Product 𝓢 0A 0B product : Product 𝓢 hA hB
Product.raw product = rawProduct Product.raw product = rawProduct
Product.isProduct product = isProduct Product.isProduct product = isProduct
@ -346,7 +342,7 @@ module _ {a b : Level} ( : Category a b) where
; fmap = [_∘_] ; fmap = [_∘_]
} }
; isFunctor = record ; isFunctor = record
{ isIdentity = funExt λ _ proj₂ isIdentity { isIdentity = funExt λ _ leftIdentity
; isDistributive = funExt λ x sym isAssociative ; isDistributive = funExt λ x sym isAssociative
} }
} }
@ -359,7 +355,7 @@ module _ {a b : Level} ( : Category a b) where
; fmap = λ f g [ g f ] ; fmap = λ f g [ g f ]
} }
; isFunctor = record ; isFunctor = record
{ isIdentity = funExt λ x proj₁ isIdentity { isIdentity = funExt λ x rightIdentity
; isDistributive = funExt λ x isAssociative ; isDistributive = funExt λ x isAssociative
} }
} }

View file

@ -96,7 +96,7 @@ record RawCategory (a b : Level) : Set (lsuc (a ⊔ b)) where
IsIdentity : ({A : Object} Arrow A A) Set (a b) IsIdentity : ({A : Object} Arrow A A) Set (a b)
IsIdentity id = {A B : Object} {f : Arrow A B} IsIdentity id = {A B : Object} {f : Arrow A B}
f id f × id f f id f f × f id f
ArrowsAreSets : Set (a b) ArrowsAreSets : Set (a b)
ArrowsAreSets = {A B : Object} isSet (Arrow A B) ArrowsAreSets = {A B : Object} isSet (Arrow A B)
@ -166,29 +166,37 @@ record IsCategory {a b : Level} ( : RawCategory a b) : Set (lsuc
field field
univalent : Univalent univalent : Univalent
leftIdentity : {A B : Object} {f : Arrow A B} 𝟙 f f
leftIdentity {A} {B} {f} = fst (isIdentity {A = A} {B} {f})
-- leftIdentity {A} {B} {f} = snd (isIdentity {A = A} {B} {f})
rightIdentity : {A B : Object} {f : Arrow A B} f 𝟙 f
rightIdentity {A} {B} {f} = snd (isIdentity {A = A} {B} {f})
-- rightIdentity {A} {B} {f} = fst (isIdentity {A = A} {B} {f})
-- Some common lemmas about categories. -- Some common lemmas about categories.
module _ {A B : Object} {X : Object} (f : Arrow A B) where module _ {A B : Object} {X : Object} (f : Arrow A B) where
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
g₀ ≡⟨ sym (fst isIdentity) g₀ ≡⟨ sym rightIdentity
g₀ 𝟙 ≡⟨ cong (_∘_ g₀) (sym right-inv) g₀ 𝟙 ≡⟨ cong (_∘_ g₀) (sym right-inv)
g₀ (f f-) ≡⟨ isAssociative g₀ (f f-) ≡⟨ isAssociative
(g₀ f) f- ≡⟨ cong (λ φ φ f-) eq (g₀ f) f- ≡⟨ cong (λ φ φ f-) eq
(g₁ f) f- ≡⟨ sym isAssociative (g₁ f) f- ≡⟨ sym isAssociative
g₁ (f f-) ≡⟨ cong (_∘_ g₁) right-inv g₁ (f f-) ≡⟨ cong (_∘_ g₁) right-inv
g₁ 𝟙 ≡⟨ fst isIdentity g₁ 𝟙 ≡⟨ rightIdentity
g₁ g₁
iso-is-mono : Isomorphism f Monomorphism {X = X} f iso-is-mono : Isomorphism f Monomorphism {X = X} f
iso-is-mono (f- , (left-inv , right-inv)) g₀ g₁ eq = iso-is-mono (f- , (left-inv , right-inv)) g₀ g₁ eq =
begin begin
g₀ ≡⟨ sym (snd isIdentity) g₀ ≡⟨ sym leftIdentity
𝟙 g₀ ≡⟨ cong (λ φ φ g₀) (sym left-inv) 𝟙 g₀ ≡⟨ cong (λ φ φ g₀) (sym left-inv)
(f- f) g₀ ≡⟨ sym isAssociative (f- f) g₀ ≡⟨ sym isAssociative
f- (f g₀) ≡⟨ cong (_∘_ f-) eq f- (f g₀) ≡⟨ cong (_∘_ f-) eq
f- (f g₁) ≡⟨ isAssociative f- (f g₁) ≡⟨ isAssociative
(f- f) g₁ ≡⟨ cong (λ φ φ g₁) left-inv (f- f) g₁ ≡⟨ cong (λ φ φ g₁) left-inv
𝟙 g₁ ≡⟨ snd isIdentity 𝟙 g₁ ≡⟨ leftIdentity
g₁ g₁
iso-is-epi-mono : Isomorphism f Epimorphism {X = X} f × Monomorphism {X = X} f iso-is-epi-mono : Isomorphism f Epimorphism {X = X} f × Monomorphism {X = X} f
@ -201,7 +209,7 @@ record IsCategory {a b : Level} ( : RawCategory a b) : Set (lsuc
module Propositionality {a b : Level} ( : RawCategory a b) where module Propositionality {a b : Level} ( : RawCategory a b) where
open RawCategory open RawCategory
module _ ( : IsCategory ) where module _ ( : IsCategory ) where
open IsCategory using (isAssociative ; arrowsAreSets ; isIdentity ; Univalent) open IsCategory using (isAssociative ; arrowsAreSets ; Univalent ; leftIdentity ; rightIdentity)
open import Cubical.NType open import Cubical.NType
open import Cubical.NType.Properties open import Cubical.NType.Properties
@ -233,11 +241,11 @@ module Propositionality {a b : Level} ( : RawCategory a b) where
open Cubical.NType.Properties open Cubical.NType.Properties
geq : g g' geq : g g'
geq = begin geq = begin
g ≡⟨ sym (fst isIdentity) g ≡⟨ sym rightIdentity
g 𝟙 ≡⟨ cong (λ φ g φ) (sym ε') g 𝟙 ≡⟨ cong (λ φ g φ) (sym ε')
g (f g') ≡⟨ isAssociative g (f g') ≡⟨ isAssociative
(g f) g' ≡⟨ cong (λ φ φ g') η (g f) g' ≡⟨ cong (λ φ φ g') η
𝟙 g' ≡⟨ snd isIdentity 𝟙 g' ≡⟨ leftIdentity
g' g'
propUnivalent : isProp Univalent propUnivalent : isProp Univalent

View file

@ -124,7 +124,7 @@ module _ {a b : Level} ( : Category a b) where
bind (f >>> (pure >>> bind 𝟙)) bind (f >>> (pure >>> bind 𝟙))
≡⟨ cong (λ φ bind (f >>> φ)) (isNatural _) ≡⟨ cong (λ φ bind (f >>> φ)) (isNatural _)
bind (f >>> 𝟙) bind (f >>> 𝟙)
≡⟨ cong bind (proj₂ .isIdentity) ≡⟨ cong bind .leftIdentity
bind f bind f
forthRawEq : forthRaw (backRaw m) K.Monad.raw m forthRawEq : forthRaw (backRaw m) K.Monad.raw m
@ -155,7 +155,7 @@ module _ {a b : Level} ( : Category a b) where
KM.bind 𝟙 ≡⟨⟩ KM.bind 𝟙 ≡⟨⟩
bind 𝟙 ≡⟨⟩ bind 𝟙 ≡⟨⟩
joinT X Rfmap 𝟙 ≡⟨ cong (λ φ _ φ) R.isIdentity joinT X Rfmap 𝟙 ≡⟨ cong (λ φ _ φ) R.isIdentity
joinT X 𝟙 ≡⟨ proj₁ .isIdentity joinT X 𝟙 ≡⟨ .rightIdentity
joinT X joinT X
fmapEq : {A B} KM.fmap {A} {B} Rfmap fmapEq : {A B} KM.fmap {A} {B} Rfmap
@ -167,7 +167,7 @@ module _ {a b : Level} ( : Category a b) where
Rfmap (f >>> pureT B) >>> joinT B ≡⟨ cong (λ φ φ >>> joinT B) R.isDistributive Rfmap (f >>> pureT B) >>> joinT B ≡⟨ cong (λ φ φ >>> joinT B) R.isDistributive
Rfmap f >>> Rfmap (pureT B) >>> joinT B ≡⟨ .isAssociative Rfmap f >>> Rfmap (pureT B) >>> joinT B ≡⟨ .isAssociative
joinT B Rfmap (pureT B) Rfmap f ≡⟨ cong (λ φ φ Rfmap f) (proj₂ isInverse) joinT B Rfmap (pureT B) Rfmap f ≡⟨ cong (λ φ φ Rfmap f) (proj₂ isInverse)
𝟙 Rfmap f ≡⟨ proj₂ .isIdentity 𝟙 Rfmap f ≡⟨ .leftIdentity
Rfmap f Rfmap f
) )
@ -192,7 +192,7 @@ module _ {a b : Level} ( : Category a b) where
M.RawMonad.joinT (backRaw (forth m)) X ≡⟨⟩ M.RawMonad.joinT (backRaw (forth m)) X ≡⟨⟩
KM.join ≡⟨⟩ KM.join ≡⟨⟩
joinT X Rfmap 𝟙 ≡⟨ cong (λ φ joinT X φ) R.isIdentity joinT X Rfmap 𝟙 ≡⟨ cong (λ φ joinT X φ) R.isIdentity
joinT X 𝟙 ≡⟨ proj₁ .isIdentity joinT X 𝟙 ≡⟨ .rightIdentity
joinT X ) joinT X )
joinNTEq : (λ i NaturalTransformation F[ Req i Req i ] (Req i)) joinNTEq : (λ i NaturalTransformation F[ Req i Req i ] (Req i))

View file

@ -104,7 +104,7 @@ record IsMonad (raw : RawMonad) : Set where
isFunctorR : IsFunctor rawR isFunctorR : IsFunctor rawR
IsFunctor.isIdentity isFunctorR = begin IsFunctor.isIdentity isFunctorR = begin
bind (pure 𝟙) ≡⟨ cong bind (proj₁ .isIdentity) bind (pure 𝟙) ≡⟨ cong bind (.rightIdentity)
bind pure ≡⟨ isIdentity bind pure ≡⟨ isIdentity
𝟙 𝟙
@ -156,9 +156,9 @@ record IsMonad (raw : RawMonad) : Set where
bind (bind (f >>> pure) >>> (pure >>> bind 𝟙)) bind (bind (f >>> pure) >>> (pure >>> bind 𝟙))
≡⟨ cong (λ φ bind (bind (f >>> pure) >>> φ)) (isNatural _) ≡⟨ cong (λ φ bind (bind (f >>> pure) >>> φ)) (isNatural _)
bind (bind (f >>> pure) >>> 𝟙) bind (bind (f >>> pure) >>> 𝟙)
≡⟨ cong bind (proj₂ .isIdentity) ≡⟨ cong bind .leftIdentity
bind (bind (f >>> pure)) bind (bind (f >>> pure))
≡⟨ cong bind (sym (proj₁ .isIdentity)) ≡⟨ cong bind (sym .rightIdentity)
bind (𝟙 >>> bind (f >>> pure)) ≡⟨⟩ bind (𝟙 >>> bind (f >>> pure)) ≡⟨⟩
bind (𝟙 >=> (f >>> pure)) bind (𝟙 >=> (f >>> pure))
≡⟨ sym (isDistributive _ _) ≡⟨ sym (isDistributive _ _)
@ -186,10 +186,10 @@ record IsMonad (raw : RawMonad) : Set where
bind (join >>> (pure >>> bind 𝟙)) bind (join >>> (pure >>> bind 𝟙))
≡⟨ cong (λ φ bind (join >>> φ)) (isNatural _) ≡⟨ cong (λ φ bind (join >>> φ)) (isNatural _)
bind (join >>> 𝟙) bind (join >>> 𝟙)
≡⟨ cong bind (proj₂ .isIdentity) ≡⟨ cong bind .leftIdentity
bind join ≡⟨⟩ bind join ≡⟨⟩
bind (bind 𝟙) bind (bind 𝟙)
≡⟨ cong bind (sym (proj₁ .isIdentity)) ≡⟨ cong bind (sym .rightIdentity)
bind (𝟙 >>> bind 𝟙) ≡⟨⟩ bind (𝟙 >>> bind 𝟙) ≡⟨⟩
bind (𝟙 >=> 𝟙) ≡⟨ sym (isDistributive _ _) bind (𝟙 >=> 𝟙) ≡⟨ sym (isDistributive _ _)
bind 𝟙 >>> bind 𝟙 ≡⟨⟩ bind 𝟙 >>> bind 𝟙 ≡⟨⟩
@ -212,7 +212,7 @@ record IsMonad (raw : RawMonad) : Set where
bind (pure >>> (pure >>> bind 𝟙)) bind (pure >>> (pure >>> bind 𝟙))
≡⟨ cong (λ φ bind (pure >>> φ)) (isNatural _) ≡⟨ cong (λ φ bind (pure >>> φ)) (isNatural _)
bind (pure >>> 𝟙) bind (pure >>> 𝟙)
≡⟨ cong bind (proj₂ .isIdentity) ≡⟨ cong bind .leftIdentity
bind pure ≡⟨ isIdentity bind pure ≡⟨ isIdentity
𝟙 𝟙

View file

@ -75,7 +75,7 @@ record IsMonad (raw : RawMonad) : Set where
joinT Y (R.fmap f pureT X) ≡⟨ cong (λ φ joinT Y φ) (sym (pureN f)) joinT Y (R.fmap f pureT X) ≡⟨ cong (λ φ joinT Y φ) (sym (pureN f))
joinT Y (pureT (R.omap Y) f) ≡⟨ .isAssociative joinT Y (pureT (R.omap Y) f) ≡⟨ .isAssociative
joinT Y pureT (R.omap Y) f ≡⟨ cong (λ φ φ f) (proj₁ isInverse) joinT Y pureT (R.omap Y) f ≡⟨ cong (λ φ φ f) (proj₁ isInverse)
𝟙 f ≡⟨ proj₂ .isIdentity 𝟙 f ≡⟨ .leftIdentity
f f
isDistributive : IsDistributive isDistributive : IsDistributive

View file

@ -72,8 +72,8 @@ module NaturalTransformation {c c' d d' : Level}
identityNatural : (F : Functor 𝔻) Natural F F (identityTrans F) identityNatural : (F : Functor 𝔻) Natural F F (identityTrans F)
identityNatural F {A = A} {B = B} f = begin identityNatural F {A = A} {B = B} f = begin
𝔻 [ identityTrans F B F→ f ] ≡⟨⟩ 𝔻 [ identityTrans F B F→ f ] ≡⟨⟩
𝔻 [ 𝟙 𝔻 F→ f ] ≡⟨ proj₂ 𝔻.isIdentity 𝔻 [ 𝟙 𝔻 F→ f ] ≡⟨ 𝔻.leftIdentity
F→ f ≡⟨ sym (proj₁ 𝔻.isIdentity) F→ f ≡⟨ sym 𝔻.rightIdentity
𝔻 [ F→ f 𝟙 𝔻 ] ≡⟨⟩ 𝔻 [ F→ f 𝟙 𝔻 ] ≡⟨⟩
𝔻 [ F→ f identityTrans F A ] 𝔻 [ F→ f identityTrans F A ]
where where

View file

@ -54,7 +54,7 @@ module _ { : Level} { : Category } where
isIdentity {c} = lemSig (naturalIsProp {F = presheaf c} {presheaf c}) _ _ eq isIdentity {c} = lemSig (naturalIsProp {F = presheaf c} {presheaf c}) _ _ eq
where where
eq : (λ C x [ .𝟙 x ]) identityTrans (presheaf c) eq : (λ C x [ .𝟙 x ]) identityTrans (presheaf c)
eq = funExt λ A funExt λ B proj₂ .isIdentity eq = funExt λ A funExt λ B .leftIdentity
isDistributive : IsDistributive isDistributive : IsDistributive
isDistributive {A} {B} {C} {f = f} {g} isDistributive {A} {B} {C} {f = f} {g}