-
Notifications
You must be signed in to change notification settings - Fork 68
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
+Commutative monads #402
+Commutative monads #402
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{-# OPTIONS --without-K --safe #-} | ||
|
||
open import Level | ||
open import Data.Product using (_,_) | ||
|
||
open import Categories.Category | ||
open import Categories.Category.Monoidal | ||
open import Categories.Monad | ||
open import Categories.Monad.Strong | ||
open import Categories.Category.Monoidal.Symmetric | ||
open import Categories.Functor using (Functor; Endofunctor; _∘F_) renaming (id to idF) | ||
|
||
open import Categories.NaturalTransformation using (NaturalTransformation) | ||
|
||
module Categories.Monad.Commutative {o ℓ e} {C : Category o ℓ e} {V : Monoidal C} (S : Symmetric V) (SM : StrongMonad S) where | ||
|
||
private | ||
module M = StrongMonad.M SM | ||
module τ = StrongMonad.strengthen SM | ||
module τ' = StrongMonad.strengthen' SM | ||
|
||
open NaturalTransformation | ||
open Category C | ||
open Monoidal V | ||
|
||
open NaturalTransformation M.η using (η) | ||
open NaturalTransformation M.μ renaming (η to μ) | ||
|
||
open M using (F) | ||
open Functor F | ||
|
||
record Commutative : Set (o ⊔ ℓ ⊔ e) where | ||
field | ||
commutativity : {A B : Obj} → μ (A ⊗₀ B) ∘ F₁ (τ'.η (A , B)) ∘ τ.η (F₀ A , B) | ||
≈ μ (A ⊗₀ B) ∘ F₁ (τ.η (A , B)) ∘ τ'.η (A , F₀ B) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,27 +14,51 @@ open import Data.Product using (_,_) | |
open import Categories.Category | ||
open import Categories.Functor renaming (id to idF) | ||
open import Categories.Category.Monoidal | ||
open import Categories.Category.Monoidal.Symmetric | ||
open import Categories.Category.Monoidal.Braided | ||
|
||
open import Categories.Category.Product | ||
open import Categories.Category.Product.Properties | ||
open import Categories.NaturalTransformation hiding (id) | ||
open import Categories.NaturalTransformation.NaturalIsomorphism renaming (associator to ∘-assoc) | ||
open import Categories.Monad | ||
|
||
private | ||
variable | ||
o ℓ e : Level | ||
|
||
record Strength {C : Category o ℓ e} (V : Monoidal C) (M : Monad C) : Set (o ⊔ ℓ ⊔ e) where | ||
record Strength {C : Category o ℓ e} {V : Monoidal C} (S : Symmetric V) (M : Monad C) : Set (o ⊔ ℓ ⊔ e) where | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it the case that there are different concepts of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that was too crude. We can have left-strong monads over non-symmetric V. |
||
open Category C | ||
open Monoidal V | ||
|
||
private | ||
module M = Monad M | ||
|
||
open M using (F) | ||
open NaturalTransformation M.η using (η) | ||
open NaturalTransformation M.μ renaming (η to μ) | ||
open Functor F | ||
open Symmetric S using (braided) | ||
open NaturalIsomorphism using (F⇐G; F⇒G) | ||
|
||
private | ||
γ = Braided.braiding.F⇒G braided | ||
γ⁻¹ = Braided.braiding.F⇐G braided | ||
|
||
field | ||
strengthen : NaturalTransformation (⊗ ∘F (idF ⁂ F)) (F ∘F ⊗) | ||
|
||
module strengthen = NaturalTransformation strengthen | ||
-- dual strength | ||
strengthen' : NaturalTransformation (⊗ ∘F (F ⁂ idF)) (F ∘F ⊗) | ||
strengthen' = (F ∘ˡ γ⁻¹) ∘ᵥ F⇒G (∘-assoc Swap ⊗ F) ∘ᵥ (strengthen ∘ʳ Swap) ∘ᵥ | ||
F⇐G (∘-assoc Swap (idF ⁂ F) ⊗) ∘ᵥ | ||
(⊗ ∘ˡ F⇒G (SwapFG≅FGSwap C C F idF)) ∘ᵥ | ||
F⇒G (∘-assoc (F ⁂ idF) Swap ⊗) ∘ᵥ | ||
(γ ∘ʳ (F ⁂ idF)) | ||
|
||
module strengthen = NaturalTransformation strengthen | ||
module strengthen' = NaturalTransformation strengthen' | ||
|
||
private | ||
module t = strengthen | ||
|
||
|
@@ -48,12 +72,12 @@ record Strength {C : Category o ℓ e} (V : Monoidal C) (M : Monad C) : Set (o | |
≈ t.η (A , B) ∘ id ⊗₁ μ B | ||
-- consecutive applications of strength commute (i.e. strength is associative) | ||
strength-assoc : {A B C : Obj} → F₁ associator.from ∘ t.η (A ⊗₀ B , C) | ||
≈ t.η (A , B ⊗₀ C) ∘ id ⊗₁ t.η (B , C) ∘ associator.from | ||
≈ t.η (A , B ⊗₀ C) ∘ id ⊗₁ t.η (B , C) ∘ associator.from | ||
|
||
record StrongMonad {C : Category o ℓ e} (V : Monoidal C) : Set (o ⊔ ℓ ⊔ e) where | ||
record StrongMonad {C : Category o ℓ e} {V : Monoidal C} (S : Symmetric V) : Set (o ⊔ ℓ ⊔ e) where | ||
field | ||
M : Monad C | ||
strength : Strength V M | ||
strength : Strength S M | ||
|
||
module M = Monad M | ||
open Strength strength public |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if
Commutative
should be a simple property rather than arecord
? There are certainly times where a one-field record is much nicer (both to help Agda with inference, and to get a nice projector name), I'm not sure here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copycatted /src/Categories/Monad/Idempotent.agda
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which was the right thing to do. I didn't think of asking the question about that one - such are the vagaries of code reviews done by humans, you don't catch everything every time.