Modules over Monads & their Algebras og 1 , Nicolas Wu 2 , and - - PowerPoint PPT Presentation

modules over monads their algebras
SMART_READER_LITE
LIVE PREVIEW

Modules over Monads & their Algebras og 1 , Nicolas Wu 2 , and - - PowerPoint PPT Presentation

Modules over Monads & their Algebras og 1 , Nicolas Wu 2 , and Jeremy Gibbons 1 Maciej Pir 1 University of Oxford 2 University of Bristol CALCO2015, Nijmegen Part 1 (out of 3) Straight to the definition... Modules over monads Let M =


slide-1
SLIDE 1

Modules over Monads & their Algebras

Maciej Pir´

  • g1, Nicolas Wu2, and Jeremy Gibbons1

1University of Oxford 2University of Bristol

CALCO2015, Nijmegen

slide-2
SLIDE 2

Part 1 (out of 3) Straight to the definition...

slide-3
SLIDE 3

Modules over monads Let M = M, η, µ be a monad on a category C . A (right) module over M is a pair S, − → µ , where S : C → C is an endofunctor − → µ : SM → S is a natural transformation s.t.t.f.d.c. SMM SM SM S

Sµ − → µ − → µ M − → µ

S SM S

Sη − → µ id

slide-4
SLIDE 4

Modules over monads

  • S. Mac Lane (page 170)
  • E. Dubuc (‘Kan Extensions in...’, 1970)
  • J. Ad´

amek, S. Milius, J. Velebil (‘On Rational Monads and...’, 2002)

  • r (using a slightly generalised definition)
  • R. Street (‘The Formal Theory of...’, 1972)
  • A. Hirschowitz and M. Maggesi (‘Modules over Monads and...’,

2007 & 2010)

slide-5
SLIDE 5

Examples Let M = M, η, µ be a monad on a category C .

  • ‘Right regular representation’:

M, µ : M → M

  • For an endofunctor G : C → C :

GM, Gµ : GMM → GM

  • For a monad morphism m : M → T:

T, TM

Tm

− − → TT

µT

− − → T

  • In a CCC, over the state monad (– × V )V for a fixed V :

– × V , evalA : (A × V )V × V → A × V

slide-6
SLIDE 6

Part 2 (out of 3) General theory of modules

slide-7
SLIDE 7

Morphisms between modules For brevity, we denote a module S, − → µ over M, η, µ as M, S, leaving the natural transformations implicit. A morphism between M, S and M′, S′ is a pair m, s, where m : M → M′ is a monad morphism s : S → S′ is a natural transformation s.t.t.f.d.c. SM S S′M′ S′

− → µ s sm − → µ ′

slide-8
SLIDE 8

Category of modules We define the category of modules as:

  • Objects: modules M, S
  • Morhpsims: module morphisms m, s

We denote this category Mod.

slide-9
SLIDE 9

Algebras for modules An algebra for M, S is a triple A, f , g s.t.

  • 1. f : MA → A is an Eilenberg–Moore M-algebra,
  • 2. g : SA → A is an S-algebra,
  • 3. t.f.d.c.

SMA SA SA A

Sf g − → µA g

A morphism between A, f , g and B, f ′, g′ is a morphism h : A → B that is both an S-algebra and an M-algebra

  • homomorphism. The category of algebras for M, S is called

ModAlg(M, S)

slide-10
SLIDE 10

The forgetful functor U : ModAlg(M, S) → C UA, f , g = A Uh = h Theorem If S∗A = µX.SX + A exists for all A (i.e. S admits an algebraically-free monad), then U has a left adjoint F. FA = MS∗A, f , g, where f = MMS∗A

µM

S∗A

− − − → MS∗A g = SMS∗A

− → µS∗A

− − − → SS∗A

consA

− − − → S∗A

ηM

S∗A

− − − → MS∗A Fh = MS∗h

slide-11
SLIDE 11

The induced monad The induced monad UF = MS∗ can be seen as a generalisation of

  • E. Moggi’s resumption monad M(GM)∗ for an endofunctor G.

(Recall from the examples that GM is a module over M.) Also: M. Hyland, G. Plotkin, and J. Power’s proof that Moggi’s monad is a monad works in this case as well.

slide-12
SLIDE 12

Theorem The adjunction F ⊣ U is strictly monadic. This entails that ModAlg(M, S) ∼ = Alg(MS∗)

slide-13
SLIDE 13

The RRR functor We define the right regular representation functor ∆ : Mnd → Mod: ∆M = M, M where − → µ = µ ∆m = m, m

slide-14
SLIDE 14

The universal property The monad MS∗ is the free object in Mnd generated by S with respect to ∆. More precisely: for a monad T, a module M, S, and a module morphism m, f : M, S → ∆T, there exists a unique monad morphism k : MS∗ → T s.t.t.f.d.c. M MS∗ S∗ S T

MηS∗ ηMS∗ emb m k f

slide-15
SLIDE 15

There’s more...

  • Modules and adjunctions
  • Distributive laws and liftings
slide-16
SLIDE 16

Part 3 (out of 3) Computations in context

slide-17
SLIDE 17

Running computations in context

  • In a CCC, over the state monad (– × V )V for a fixed V :

– × V , evalA : (A × V )V × V → A × V

  • In a CCC, over the reader monad –V for a fixed V :

– × V , λf , x.fx, x : AV × V → A × V

  • Adjoint monad–comonad situation η, ε : W ⊣ M:

WM, WM

WMη

− − − → WMMW

W µW

− − − − → WMW

εW

− − → W

  • T. Uustalu: ‘Stateful runners are monad morphisms to the state

monad.’ For a monad morphism m : M → T: T, TM

Tm

− − → TT

µT

− − → T

slide-18
SLIDE 18

Combinators Let T X be the set of all SKI-terms with variables from X. Let NX be the set of all normalised SKI-terms. N + C{⊥}, NT + C{⊥}

CBN

− − − → N + C{⊥}

slide-19
SLIDE 19

Modules and adjoints Paraphrasing a result by Dubuc (1970): Let L : C → D and R : D → C be functors s.t. L ⊣ R, and let H : D → C be any functor. Then, HL, HLRL HεR − − − → HL is a module over RL. Moreover, every module arises in this way.

slide-20
SLIDE 20

The continuation monad C C C ⇑ κ

G G RanG G

RanGG – right Kan extension along itself (RanGG)G – the codensity monad of G G, κ : (RanGG)G → G – a left module over the codensity monad

slide-21
SLIDE 21

Conclusions

slide-22
SLIDE 22

Conclusions

  • Theory of modules is non-problematic.
  • The resumption monad M(GM)∗ generalises to GS∗.
  • Running computations in context??
slide-23
SLIDE 23

Thanks!