Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Universal Objects are Isomorphic #80

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
102 changes: 88 additions & 14 deletions src/CoLimits/CoProduct.lidr
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,112 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
> module CoLimits.CoProduct
>
> import Basic.Category
> import Basic.Isomorphism
>
> %access public export
> %default total
> %auto_implicits off
>
> record CommutingMorphism
> (cat : Category)
> (a : obj cat) (b : obj cat) (carrier : obj cat) (c : obj cat)
> (inl : mor cat a carrier) (inr : mor cat b carrier)
> (f : mor cat a c) (g : mor cat b c)
> (l : obj cat) (r : obj cat) (carrier : obj cat) (c : obj cat)
> (inl : mor cat l carrier) (inr : mor cat r carrier)
> (f : mor cat l c) (g : mor cat r c)
> where
> constructor MkCommutingMorphism
> challenger : mor cat carrier c
> commutativityLeft : compose cat a carrier c inl challenger = f
> commutativityRight : compose cat b carrier c inr challenger = g
> commutativityLeft : compose cat l carrier c inl challenger = f
> commutativityRight : compose cat r carrier c inr challenger = g
>
> record CoProduct
> (cat : Category)
> (a : obj cat) (b : obj cat)
> (l : obj cat) (r : obj cat)
> where
> constructor MkCoProduct
> carrier: obj cat
> inl: mor cat a carrier
> inr: mor cat b carrier
> inl: mor cat l carrier
> inr: mor cat r carrier
> exists:
> (c : obj cat)
> -> (f : mor cat a c)
> -> (g : mor cat b c)
> -> CommutingMorphism cat a b carrier c inl inr f g
> -> (f : mor cat l c)
> -> (g : mor cat r c)
> -> CommutingMorphism cat l r carrier c inl inr f g
> unique:
> (c : obj cat)
> -> (f : mor cat a c)
> -> (g : mor cat b c)
> -> (h : CommutingMorphism cat a b carrier c inl inr f g)
> -> (f : mor cat l c)
> -> (g : mor cat r c)
> -> (h : CommutingMorphism cat l r carrier c inl inr f g)
> -> challenger h = challenger (exists c f g)
>
> coProductMorphism :
> (cat : Category)
> -> (l, r : obj cat)
> -> (a, b : CoProduct cat l r)
> -> CommutingMorphism
> cat
> l r (carrier a) (carrier b)
> (inl a) (inr a)
> (inl b) (inr b)
> coProductMorphism cat l r a b = exists a (carrier b) (inl b) (inr b)
>
> composeCoProductMorphisms :
> (cat : Category)
> -> (l, r : obj cat)
> -> (a, b : CoProduct cat l r)
> -> CommutingMorphism
> cat
> l r (carrier a) (carrier a)
> (inl a) (inr a)
> (inl a) (inr a)
> composeCoProductMorphisms cat l r a b =
> let
> mor = coProductMorphism cat l r a b
> inv = coProductMorphism cat l r b a
> in
> MkCommutingMorphism
> (compose cat (carrier a) (carrier b) (carrier a)
> (challenger mor) (challenger inv))
> (rewrite associativity cat l (carrier a) (carrier b) (carrier a)
> (inl a) (challenger mor) (challenger inv) in
> rewrite commutativityLeft mor in
> rewrite commutativityLeft inv in Refl)
> (rewrite associativity cat r (carrier a) (carrier b) (carrier a)
> (inr a) (challenger mor) (challenger inv) in
> rewrite commutativityRight mor in
> rewrite commutativityRight inv in Refl)
>
> idCommutingMorphism :
> (cat : Category)
> -> (l, r : obj cat)
> -> (a : CoProduct cat l r)
> -> CommutingMorphism
> cat
> l r (carrier a) (carrier a)
> (inl a) (inr a)
> (inl a) (inr a)
> idCommutingMorphism cat l r a = MkCommutingMorphism
> (identity cat (carrier a))
> (rightIdentity cat l (carrier a) (inl a))
> (rightIdentity cat r (carrier a) (inr a))
>
> coProductsAreIsomorphic :
> (cat : Category)
> -> (l, r : obj cat)
> -> (a, b : CoProduct cat l r)
> -> Isomorphic cat (carrier a) (carrier b)
> coProductsAreIsomorphic cat l r a b =
> let
> mor = coProductMorphism cat l r a b
> inv = coProductMorphism cat l r b a
> in
> buildIsomorphic
> (challenger mor)
> (challenger inv)
> (rewrite unique a (carrier a) (inl a) (inr a)
> (composeCoProductMorphisms cat l r a b) in
> rewrite unique a (carrier a) (inl a) (inr a)
> (idCommutingMorphism cat l r a) in Refl)
> (rewrite unique b (carrier b) (inl b) (inr b)
> (composeCoProductMorphisms cat l r b a) in
> rewrite unique b (carrier b) (inl b) (inr b)
> (idCommutingMorphism cat l r b) in Refl)
14 changes: 14 additions & 0 deletions src/Dual/DualCategory.lidr
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,17 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
> (idFunctor (dualCategory $ dualCategory cat))
> (\_ => Refl)
> (\_, _, _ => Refl))
>
> dualPreservesIsomorphic :
> Isomorphic (dualCategory cat) a b
> -> Isomorphic cat a b
> dualPreservesIsomorphic
> (MkIsomorphic
> morphism
> (MkIsomorphism inverse
> (MkInverseMorphisms lawLeft lawRight))) =
> MkIsomorphic
> inverse
> (MkIsomorphism
> morphism
> (MkInverseMorphisms lawLeft lawRight))
7 changes: 7 additions & 0 deletions src/Limits/Product.lidr
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
> module Limits.Product
>
> import Basic.Category
> import Basic.Isomorphism
> import public CoLimits.CoProduct
> import public Dual.DualCategory
>
Expand All @@ -30,3 +31,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
>
> Product : (cat : Category) -> (a : obj cat) -> (b : obj cat) -> Type
> Product cat a b = CoProduct (dualCategory cat) a b
>
> productsAreIsomorphic :
> (a, b : Product cat l r)
> -> Isomorphic cat (carrier a) (carrier b)
> productsAreIsomorphic {cat} {l} {r} a b =
> dualPreservesIsomorphic (coProductsAreIsomorphic (dualCategory cat) l r a b)
7 changes: 7 additions & 0 deletions src/Limits/TerminalObject.lidr
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
> import Basic.Category
> import public CoLimits.InitialObject
> import public Dual.DualCategory
> import Basic.Isomorphism
>
> %access public export
> %default total
>
> TerminalObject : Category -> Type
> TerminalObject cat = InitialObject (dualCategory cat)
>
> terminalObjectsAreIsomorphic :
> (a, b : TerminalObject cat)
> -> Isomorphic cat (carrier a) (carrier b)
> terminalObjectsAreIsomorphic {cat} a b =
> dualPreservesIsomorphic (initialObjectsAreIsomorphic (dualCategory cat) a b)