diff options
Diffstat (limited to 'Functor/Monoidal/Construction')
| -rw-r--r-- | Functor/Monoidal/Construction/ListOf.agda | 213 |
1 files changed, 213 insertions, 0 deletions
diff --git a/Functor/Monoidal/Construction/ListOf.agda b/Functor/Monoidal/Construction/ListOf.agda new file mode 100644 index 0000000..476939e --- /dev/null +++ b/Functor/Monoidal/Construction/ListOf.agda @@ -0,0 +1,213 @@ +{-# OPTIONS --without-K --safe #-} + +open import Categories.Category using (Category) +open import Categories.Category.Cocartesian.Bundle using (CocartesianCategory) +open import Categories.Category.Construction.Monoids using (Monoids) +open import Categories.Category.Monoidal.Bundle using (MonoidalCategory) +open import Categories.Functor using (Functor) renaming (_βF_ to _β_) +open import Level using (Level) + +module Functor.Monoidal.Construction.ListOf + {o β e : Level} + {π : CocartesianCategory o β e} + {S : MonoidalCategory o β e} + (let module π = CocartesianCategory π) + (let module S = MonoidalCategory S) + (G : Functor π.U S.U) + (M : Functor S.U (Monoids S.monoidal)) + where + +import Categories.Category.Monoidal.Reasoning as β-Reasoning +import Categories.Category.Monoidal.Utilities as β-Util +import Categories.Morphism.Reasoning as β-Reasoning +import Categories.Object.Monoid as MonoidObject + +open import Categories.Category.Cocartesian using (module CocartesianMonoidal) +open import Categories.Category.Product using (_β_) +open import Categories.Functor.Monoidal using (MonoidalFunctor; IsMonoidalFunctor) +open import Categories.Functor.Properties using ([_]-resp-square; [_]-resp-β) +open import Categories.Morphism using (_β
_) +open import Categories.NaturalTransformation using (NaturalTransformation; ntHelper) +open import Data.Product using (_,_) + +module G = Functor G +module M = Functor M +module π-M = CocartesianMonoidal π.U π.cocartesian + +open π using (β₯; -+-; _+_; _+β_; iβ; iβ; injectβ; injectβ) +module +-assoc {n} {m} {o} = _β
_ (π.+-assoc {n} {m} {o}) +module +-Ξ» {n} = _β
_ (π-M.β₯+Aβ
A {n}) +module +-Ο {n} = _β
_ (π-M.A+β₯β
A {n}) + +module _ where + + open π + open β-Reasoning U + open β-Reasoning π-M.+-monoidal + + module _ {n m o : Obj} where + + private + + +-Ξ± : (n + m) + o π.β n + (m + o) + +-Ξ± = +-assoc.to {n} {m} {o} + + +-Ξ±βiβ : +-Ξ± β iβ β iβ β iβ + +-Ξ±βiβ = injectβ + + +-Ξ±βiββiβ : (+-Ξ± β iβ) β iβ β iβ + +-Ξ±βiββiβ = injectβ β©ββ¨refl β injectβ + + +-Ξ±βiββiβ : (+-Ξ± β iβ) β iβ β iβ β iβ + +-Ξ±βiββiβ = injectβ β©ββ¨refl β injectβ + + module _ {n : Obj} where + + +-Οβiβ : +-Ο.from {n} β iβ β id + +-Οβiβ = injectβ + + +-Ξ»βiβ : +-Ξ».from {n} β iβ β id + +-Ξ»βiβ = injectβ + +open S +open Functor +open MonoidalFunctor +open MonoidObject S.monoidal using (Monoid; Monoidβ) +open Monoid renaming (assoc to ΞΌ-assoc; identityΛ‘ toΒ ΞΌ-identityΛ‘; identityΚ³ to ΞΌ-identityΚ³) +open Monoidβ + +Forget : Functor (Monoids monoidal) U +Forget .Fβ = Carrier +Forget .Fβ = arr +Forget .identity = Equiv.refl +Forget .homomorphism = Equiv.refl +Forget .F-resp-β x = x + +π-MC : MonoidalCategory o β e +π-MC = record { monoidal = π-M.+-monoidal } + +List : Functor U U +List = Forget β M + +module List = Functor List + +ListβG : Functor π.U U +ListβG = List β G + +module LG = Functor ListβG + +[] : {A : Obj} β unit β List.β A +[] {A} = Ξ· (M.β A) + +++ : {A : Obj} β List.β A ββ List.β A β List.β A +++ {A} = ΞΌ (M.β A) + +++β : {A B : Obj} (f : A β B) β List.β f β ++ β ++ β List.β f ββ List.β f +++β f = preserves-ΞΌ (M.β f) + +[]β : {A B : Obj} (f : A β B) β List.β f β [] β [] +[]β f = preserves-Ξ· (M.β f) + +++-β : {n m : π.Obj} β LG.β n ββ LG.β m β LG.β (n + m) +++-β = ++ β LG.β iβ ββ LG.β iβ + +open β-Reasoning U +open β-Reasoning monoidal + +module _ {n nβ² m mβ² : π.Obj} (f : n π.β nβ²) (g : m π.β mβ²) where + + LG[+ββiβ] : LG.β (f +β g) β LG.β iβ β LG.β iβ β LG.β f + LG[+ββiβ] = [ ListβG ]-resp-square injectβ + + LG[+ββiβ] : LG.β (f +β g) β LG.β iβ β LG.β iβ β LG.β g + LG[+ββiβ] = [ ListβG ]-resp-square injectβ + + ++-β-commute : ++-β β LG.β f ββ LG.β g β LG.β (f +β g) β ++-β + ++-β-commute = begin + (++ β LG.β iβ ββ LG.β iβ) β LG.β f ββ LG.β g ββ¨ pushΚ³ (parallel LG[+ββiβ] LG[+ββiβ]) β¨ + ++ β (LG.β (f +β g) ββ LG.β (f +β g)) β (LG.β iβ ββ LG.β iβ) ββ¨ extendΚ³ (++β (G.β (f +β g))) β¨ + LG.β (f +β g) β ++ β LG.β iβ ββ LG.β iβ β + +open β-Util.Shorthands monoidal + +++-homo : NaturalTransformation (β β (ListβG β ListβG)) (ListβG βΒ -+-) +++-homo = ntHelper record + { Ξ· = Ξ» (n , m) β ++-β {n} {m} + ; commute = Ξ» { {n , m} {nβ² , mβ²} (f , g) β ++-β-commute f g } + } + +Ξ±-++-β + : {n m o : π.Obj} + β LG.β (+-assoc.to {n} {m} {o}) + β (++ β LG.β iβ ββ LG.β iβ) + β (++ β LG.β iβ ββ LG.β iβ) ββ id + β (++ β LG.β iβ ββ LG.β iβ) + β id ββ (++ β LG.β iβ ββ LG.β iβ) + β Ξ±β +Ξ±-++-β {n} {m} {o} = begin + LG.β +-Ξ± β (++ β LG.β iβ ββ LG.β iβ) β (++ β LG.β iβ ββ LG.β iβ) ββ id ββ¨ reflβ©ββ¨ pullΚ³ mergeβΚ³ β© + LG.β +-Ξ± β ++ β (LG.β iβ β ++ β LG.β iβ ββ LG.β iβ) ββ LG.β iβ ββ¨ extendΚ³ (++β (G.β +-Ξ±)) β© + ++ β LG.β +-Ξ± ββ LG.β +-Ξ± β (LG.β iβ β ++ β LG.β iβ ββ LG.β iβ) ββ LG.β iβ ββ¨ reflβ©ββ¨ β-distrib-over-β β¨ + ++ β (LG.β +-Ξ± β LG.β iβ β ++ β LG.β iβ ββ LG.β iβ) ββ (LG.β +-Ξ± β LG.β iβ) ββ¨ reflβ©ββ¨ pullΛ‘ (Equiv.sym LG.homomorphism) β©ββ¨ [ ListβG ]-resp-square +-Ξ±βiβ β© + ++ β (LG.β (+-Ξ± π.β iβ) β ++ β LG.β iβ ββ LG.β iβ) ββ (LG.β iβ β LG.β iβ) ββ¨ reflβ©ββ¨ extendΚ³ (++β (G.β (+-Ξ± π.β iβ))) β©ββ¨refl β© + ++ β (++ β LG.β (+-Ξ± π.β iβ) ββ LG.β (+-Ξ± π.β iβ) β _) ββ (LG.β iβ β LG.β iβ) ββ¨ reflβ©ββ¨ (reflβ©ββ¨ β-distrib-over-β) β©ββ¨refl β¨ + ++ β (++ β _ ββ (LG.β (+-Ξ± π.β iβ) β LG.β iβ)) ββ (LG.β iβ β LG.β iβ) ββ¨ reflβ©ββ¨ (reflβ©ββ¨ [ ListβG ]-resp-β +-Ξ±βiββiβ β©ββ¨ [ ListβG ]-resp-square +-Ξ±βiββiβ) β©ββ¨refl β© + ++ β (++ β LG.β iβ ββ (LG.β iβ β LG.β iβ)) ββ (LG.β iβ β LG.β iβ) ββ¨ reflβ©ββ¨ splitβΛ‘ β© + ++ β ++ ββ id β (LG.β iβ ββ (LG.β iβ β LG.β iβ)) ββ (LG.β iβ β LG.β iβ) ββ¨ extendΚ³ (ΞΌ-assoc (M.β (G.β (n + (m + o))))) β© + ++ β (id ββ ++ β Ξ±β) β (LG.β iβ ββ (LG.β iβ β LG.β iβ)) ββ (LG.β iβ β LG.β iβ) ββ¨ reflβ©ββ¨ assoc β© + ++ β id ββ ++ β Ξ±β β (LG.β iβ ββ (LG.β iβ β LG.β iβ)) ββ (LG.β iβ β LG.β iβ) ββ¨ reflβ©ββ¨ reflβ©ββ¨ assoc-commute-from β© + ++ β id ββ ++ β LG.β iβ ββ ((LG.β iβ β LG.β iβ) ββ (LG.β iβ β LG.β iβ)) β Ξ±β ββ¨ reflβ©ββ¨ pullΛ‘ mergeβΛ‘ β© + ++ β LG.β iβ ββ (++ β (LG.β iβ β LG.β iβ) ββ (LG.β iβ β LG.β iβ)) β Ξ±β ββ¨ reflβ©ββ¨ reflβ©ββ¨ (reflβ©ββ¨ β-distrib-over-β) β©ββ¨refl β© + ++ β LG.β iβ ββ (++ β LG.β iβ ββ LG.β iβ β LG.β iβ ββ LG.β iβ) β Ξ±β ββ¨ reflβ©ββ¨ reflβ©ββ¨ (extendΚ³ (++β (G.β iβ))) β©ββ¨refl β¨ + ++ β LG.β iβ ββ (LG.β iβ β ++ β LG.β iβ ββ LG.β iβ) β Ξ±β ββ¨ pushΚ³ (pushΛ‘ splitβΚ³) β© + (++ β LG.β iβ ββ LG.β iβ) β id ββ (++ β LG.β iβ ββ LG.β iβ) β Ξ±β β + where + +-Ξ± : (n + m) + o π.β n + (m + o) + +-Ξ± = +-assoc.to {n} {m} {o} + + +module _ {n : π.Obj} where + + ++-[]Κ³ : {A B : Obj} (f : A β B) β ++ β List.β f ββ [] β List.β f β Οβ + ++-[]Κ³ {A} {B} f = begin + ++ β List.β f ββ [] ββ¨ reflβ©ββ¨ serializeββ β© + ++ β id ββ [] β List.β f ββ id ββ¨ pullΛ‘ (Equiv.sym (ΞΌ-identityΚ³Β (M.β B))) β© + Οβ β List.β f ββ id ββ¨ unitorΚ³-commute-from β© + List.β f β Οβ β + + ++-[]Λ‘ : {A B : Obj} (f : A β B) β ++ β [] ββ List.β f β List.β f β Ξ»β + ++-[]Λ‘ {A} {B} f = begin + ++ β [] ββ List.β f ββ¨ reflβ©ββ¨ serializeββ β© + ++ β [] ββ id β id ββ List.β f ββ¨ pullΛ‘ (Equiv.sym (ΞΌ-identityΛ‘Β (M.β B))) β© + Ξ»β β id ββ List.β f ββ¨ unitorΛ‘-commute-from β© + List.β f β Ξ»β β + + ++-β-Ξ» + : LG.β +-Ξ».from β (++ β LG.β (iβ {β₯} {n}) ββ LG.β iβ) β [] ββ id + β Ξ»β + ++-β-Ξ» = begin + LG.β +-Ξ».from β (++ β LG.β iβ ββ LG.β iβ) β [] ββ id ββ¨ reflβ©ββ¨ pullΚ³ mergeβΚ³ β© + LG.β +-Ξ».from β ++ β (LG.β iβ β []) ββ LG.β iβ ββ¨ reflβ©ββ¨ reflβ©ββ¨ []β (G.β iβ) β©ββ¨refl β© + LG.β +-Ξ».from β ++ β [] ββ LG.β iβ ββ¨ reflβ©ββ¨ ++-[]Λ‘ (G.β iβ) β© + LG.β +-Ξ».from β LG.β iβ β Ξ»β ββ¨ cancelΛ‘ ([ ListβG ]-resp-β +-Ξ»βiβ β LG.identity) β© + Ξ»β β + + ++-β-Ο + : LG.β +-Ο.from β (++ β LG.β (iβ {n}) ββ LG.β iβ) β id ββ [] + β Οβ + ++-β-Ο = begin + LG.β +-Ο.from β (++ β LG.β iβ ββ LG.β iβ) β id ββ [] ββ¨ reflβ©ββ¨ pullΚ³ mergeβΚ³ β© + LG.β +-Ο.from β ++ β LG.β iβ ββ (LG.β iβ β []) ββ¨ reflβ©ββ¨ reflβ©ββ¨ reflβ©ββ¨ []β (G.β iβ) β© + LG.β +-Ο.from β ++ β LG.β iβ ββ [] ββ¨ reflβ©ββ¨ ++-[]Κ³ (G.β iβ) β© + LG.β +-Ο.from β LG.β iβ β Οβ ββ¨ cancelΛ‘ ([ ListβG ]-resp-β +-Οβiβ β LG.identity) β© + Οβ Β β + +open IsMonoidalFunctor + +ListOf,++,[] : MonoidalFunctor π-MC S +ListOf,++,[] .F = ListβG +ListOf,++,[] .isMonoidal .Ξ΅ = [] +ListOf,++,[] .isMonoidal .β-homo = ++-homo +ListOf,++,[] .isMonoidal .associativity = Ξ±-++-β +ListOf,++,[] .isMonoidal .unitaryΛ‘ = ++-β-Ξ» +ListOf,++,[] .isMonoidal .unitaryΚ³ = ++-β-Ο |
