list objects with algebraic structure
play

List Objects with Algebraic Structure Marcelo Fiore and Philip - PowerPoint PPT Presentation

List Objects with Algebraic Structure Marcelo Fiore and Philip Saville University of Cambridge Computer Laboratory 6th September 2017 1 / 26 A unifying framework for many diverse examples of list objects with algebraic structure 2 / 26


  1. List objects are initial algebras Definition An algebra for a functor F : C → C is a pair ( A , α : FA → A ). 12 / 26

  2. List objects are initial algebras Definition An algebra for a functor F : C → C is a pair ( A , α : FA → A ). Lemma If ( C , ⊗ , I ) is a monoidal category with finite coproducts (0 , +) and ω -colimits, both preserved by all ( − ) ⊗ P for P ∈ C , then the initial � � I + X ⊗ ( − ) algebra of the functor is a list object on X. 12 / 26

  3. List objects are initial algebras Definition An algebra for a functor F : C → C is a pair ( A , α : FA → A ). Lemma If ( C , ⊗ , I ) is a monoidal category with finite coproducts (0 , +) and ω -colimits, both preserved by all ( − ) ⊗ P for P ∈ C , then the initial � � I + X ⊗ ( − ) algebra of the functor is a list object on X. Remark This result relies on a general theory of parametrised initial algebras . 12 / 26

  4. The story so far 13 / 26

  5. The story so far list objects 13 / 26

  6. The story so far list objects ◮ well-understood datatype 13 / 26

  7. The story so far list objects ◮ well-understood datatype ◮ are free monoids 13 / 26

  8. The story so far list objects ◮ well-understood datatype ◮ are free monoids ◮ described by µ A . ( I + X ⊗ A ). 13 / 26

  9. Rest of this talk list objects T -list objects � (new work) ◮ well-understood datatype ◮ are free monoids ◮ extends datatype of lists ◮ described by ◮ are free T -monoids ◮ described by µ A . ( I + X ⊗ A ). µ A . T ( I + X ⊗ A ). 13 / 26

  10. Rest of this talk list objects T -list objects � (new work) ◮ well-understood datatype ◮ are free monoids ◮ extends datatype of lists ◮ described by ◮ are free T -monoids ◮ described by µ A . ( I + X ⊗ A ). µ A . T ( I + X ⊗ A ). ...and instantiate this for applications 13 / 26

  11. Compatible algebraic structure 14 / 26

  12. Compatible algebraic structure Definition A monad on a category C is a functor T : C → C equipped with a multiplication µ : T 2 → T and a unit η : Id C → T satisfying associativity and unit laws. 14 / 26

  13. Compatible algebraic structure Definition A monad on a category C is a functor T : C → C equipped with a multiplication µ : T 2 → T and a unit η : Id C → T satisfying associativity and unit laws. Definition An algebra for a monad ( T , µ, η ) is a pair ( A , α : TA → A ) satisfying unit and associativity laws. 14 / 26

  14. Compatible algebraic structure Definition A monad on a category C is a functor T : C → C equipped with a multiplication µ : T 2 → T and a unit η : Id C → T satisfying associativity and unit laws. Definition An algebra for a monad ( T , µ, η ) is a pair ( A , α : TA → A ) satisfying unit and associativity laws. Definition A strong monad T is a monad on a monoidal category ( ⊗ , I ) that is equipped with a natural transformation st A , B : T ( A ) ⊗ B → T ( A ⊗ B ) satisfying coherence laws. 14 / 26

  15. List objects with algebraic structure 15 / 26

  16. T -list objects 15 / 26

  17. T -list objects Let ( T , st ) be a strong monad on a monoidal category ( ⊗ , I ). A T-list object M ( X ) on X consists of I M ( X ) X ⊗ M ( X ) cons nil 15 / 26

  18. T -list objects Let ( T , st ) be a strong monad on a monoidal category ( ⊗ , I ). A T-list object M ( X ) on X consists of T ( M ( X )) τ I M ( X ) X ⊗ M ( X ) cons nil 15 / 26

  19. T -list objects Let ( T , st ) be a strong monad on a monoidal category ( ⊗ , I ). A T-list object M ( X ) on X consists of T ( M ( X )) τ I M ( X ) X ⊗ M ( X ) cons nil such that for every structure TA α P A X ⊗ A n c 15 / 26

  20. T -list objects Let ( T , st ) be a strong monad on a monoidal category ( ⊗ , I ). A T-list object M ( X ) on X consists of T ( M ( X )) τ I M ( X ) X ⊗ M ( X ) cons nil such that for every structure TA α P A X ⊗ A n c there exists a unique mediating map it ( n , c , α ) : M ( X ) ⊗ P → A 15 / 26

  21. T -list objects such that nil ⊗ P cons ⊗ P I ⊗ P M ( X ) ⊗ P X ⊗ M ( X ) ⊗ P ∼ = it ( n , c ,α ) X ⊗ it ( n , c ,α ) P A X ⊗ A n c and st M ( X ) , P T ( it ( n , c ,α )) � � T M ( X ) ⊗ P T ( M ( X ) ⊗ P ) TA τ ⊗ P α M ( X ) ⊗ P A it ( n , c ,α ) 16 / 26

  22. T -list objects Remark Every list object is a T -list object. If every ( − ) ⊗ P has a right adjoint, the iterator it ( n , c , α ) is a T -algebra homomorphism. 16 / 26

  23. Natural numbers in Cpo , revisited Flat natural numbers , Lazy natural numbers , Strict natural µ A . (1 + A ): µ A . (1 + A ) ⊥ : numbers , µ A . A ⊥ : · · · · · · · · · 0 1 2 3 · · · s 2 ( ⊥ ) 1 1 ⊥ s ( ⊥ ) 0 0 ⊥ ⊥ 17 / 26

  24. Natural numbers in Cpo as T -list objects on the unit Flat natural numbers , Lazy natural numbers , Strict natural µ A . (1 + A ): µ A . (1 + A ) ⊥ : numbers , µ A . A ⊥ : · · · · · · · · · 0 1 2 3 · · · s 2 ( ⊥ ) 1 1 ⊥ s ( ⊥ ) 0 0 ⊥ ⊥ 17 / 26

  25. Natural numbers in Cpo as T -list objects on the unit Flat natural numbers , Lazy natural numbers , Strict natural µ A . (1 + A ): µ A . (1 + A ) ⊥ : numbers , µ A . A ⊥ : · · · · · · · · · 0 1 2 3 · · · s 2 ( ⊥ ) 1 1 ⊥ s ( ⊥ ) 0 0 ⊥ ⊥ T -list object with ( × , 1) structure and monad T = Id 17 / 26

  26. Natural numbers in Cpo as T -list objects on the unit Flat natural numbers , Lazy natural numbers , Strict natural µ A . (1 + A ): µ A . (1 + A ) ⊥ : numbers , µ A . A ⊥ : · · · · · · · · · 0 1 2 3 · · · s 2 ( ⊥ ) 1 1 ⊥ s ( ⊥ ) 0 0 ⊥ ⊥ T -list object with T -list object with ( × , 1) structure ( × , 1) structure and monad T = Id and T := ( − ) ⊥ the lifting monad 17 / 26

  27. Natural numbers in Cpo as T -list objects on the unit Flat natural numbers , Lazy natural numbers , Strict natural µ A . (1 + A ): µ A . (1 + A ) ⊥ : numbers , µ A . A ⊥ : · · · · · · · · · 0 1 2 3 · · · s 2 ( ⊥ ) 1 1 ⊥ s ( ⊥ ) 0 0 ⊥ ⊥ T -list object with T -list object with T -list object with ( × , 1) structure ( × , 1) structure (+ , 0) structure and monad T = Id and T := ( − ) ⊥ the and T := ( − ) ⊥ the lifting monad lifting monad 17 / 26

  28. Monoids with compatible algebraic structure 18 / 26

  29. T -monoids 18 / 26

  30. T -monoids Let ( T , st ) be a strong monad on on a monoidal category ( ⊗ , I ). A � � T-monoid EM-monoid (Pir´ og) is a monoid I M M ⊗ M 18 / 26

  31. T -monoids Let ( T , st ) be a strong monad on on a monoidal category ( ⊗ , I ). A � � T-monoid EM-monoid (Pir´ og) is a monoid equipped with a T -algebra TM τ I M M ⊗ M 18 / 26

  32. T -monoids Let ( T , st ) be a strong monad on on a monoidal category ( ⊗ , I ). A � � T-monoid EM-monoid (Pir´ og) is a monoid equipped with a T -algebra TM τ I M M ⊗ M compatible in the sense that st C , C Tm T ( C ) ⊗ C T ( C ⊗ C ) TC c c ⊗ C C ⊗ C C m 18 / 26

  33. T -monoids Let ( T , st ) be a strong monad on on a monoidal category ( ⊗ , I ). A � � T-monoid EM-monoid (Pir´ og) is a monoid equipped with a T -algebra TM τ I M M ⊗ M compatible in the sense that st C , C Tm T ( C ) ⊗ C T ( C ⊗ C ) TC c c ⊗ C C ⊗ C C m Remark T -monoids generalise both monoids and T -algebras. 18 / 26

  34. T -monoids Remark In the context of abstract syntax, T is freely generated from some theory, and T -monoids are models of this theory. 19 / 26

  35. T -monoids Remark In the context of abstract syntax, T is freely generated from some theory, and T -monoids are models of this theory. Lemma For every monoid M the endofunctor T := M ⊗ ( − ) is a monad, � � and T-Mon ( C ) ≃ M / Mon ( C ) . 19 / 26

  36. T -monoids Remark In the context of abstract syntax, T is freely generated from some theory, and T -monoids are models of this theory. Lemma For every monoid M the endofunctor T := M ⊗ ( − ) is a monad, � � and T-Mon ( C ) ≃ M / Mon ( C ) . Example In particular, a T -monoid for the endofunctor T := S ⊗ ( − ) is precisely an algebraic operation with signature S in the sense of η Jaskelioff, and can be identified with a map S − → L ( S ) → M interpreting S inside M . 19 / 26

  37. T -monoids Remark In the context of abstract syntax, T is freely generated from some theory, and T -monoids are models of this theory. Lemma For every monoid M the endofunctor T := M ⊗ ( − ) is a monad, � � and T-Mon ( C ) ≃ M / Mon ( C ) . Example Set F , y (1) , • � � Thinking of a Lawvere theory as a monoid L M in , we can identify Lawvere theories extending L M with T -monoids for T := M • ( − ). 19 / 26

  38. T -list objects are free T -monoids 20 / 26

  39. T -list objects are free T -monoids For a strong monad ( T , st ) on a monoidal category ( ⊗ , I ), 20 / 26

  40. T -list objects are free T -monoids For a strong monad ( T , st ) on a monoidal category ( ⊗ , I ), Lemma 1. Every T-list object M ( X ) is a T-monoid. 20 / 26

  41. T -list objects are free T -monoids For a strong monad ( T , st ) on a monoidal category ( ⊗ , I ), Lemma 1. Every T-list object M ( X ) is a T-monoid. 2. This T -monoid is the free T -monoid on X , with universal map ∼ = X ⊗ nil → X ⊗ M ( X ) cons X − → X ⊗ I − − − − − → M ( X ) 20 / 26

  42. T -list objects are free T -monoids For a strong monad ( T , st ) on a monoidal category ( ⊗ , I ), Lemma 1. Every T-list object M ( X ) is a T-monoid. 2. This T -monoid is the free T -monoid on X , with universal map ∼ = X ⊗ nil → X ⊗ M ( X ) cons X − → X ⊗ I − − − − − → M ( X ) We can reason concretely about free T -monoids by reasoning about T -lists. 20 / 26

  43. T -list objects are initial algebras 21 / 26

  44. T -list objects are initial algebras For a strong monad ( T , st ) on a monoidal category ( ⊗ , I ), Lemma If every ( − ) ⊗ P preserves binary coproducts, and the initial algebra exists, then µ A . T ( I + X ⊗ A ) is a T-list object on X. 21 / 26

  45. Theorem Let T be a strong monad on a monoidal category ( C , I , ⊗ ) with binary coproducts (+) . If 1. for every P ∈ C , the endofunctor ( − ) ⊗ P preserves binary coproducts, and 2. for every X ∈ C , the initial algebra of T ( I + X ⊗ − ) exists Then C has all T-list objects and, thereby, the free T-monoid monad M T . 22 / 26

  46. Theorem Let T be a strong monad on a monoidal category ( C , I , ⊗ ) with binary coproducts (+) . If 1. for every P ∈ C , the endofunctor ( − ) ⊗ P preserves binary coproducts, and 2. for every X ∈ C , the initial algebra of T ( I + X ⊗ − ) exists Then C has all T-list objects and, thereby, the free T-monoid monad M T . Remark Thinking in terms of T -list objects makes the proof straightforward! 22 / 26

  47. Technical contribution 23 / 26

  48. Technical contribution µ A . ( I + X ⊗ A ) � list object � free monoid 23 / 26

  49. Technical contribution µ A . ( I + X ⊗ A ) � list object � free monoid T -list object 23 / 26

  50. Technical contribution µ A . ( I + X ⊗ A ) � list object � free monoid T -list object � free T -monoid 23 / 26

  51. Technical contribution µ A . ( I + X ⊗ A ) � list object � free monoid µ A . T ( I + X ⊗ A ) � T -list object � free T -monoid 23 / 26

  52. Technical contribution µ A . ( I + X ⊗ A ) � list object � free monoid µ A . T ( I + X ⊗ A ) � T -list object � free T -monoid Remark A natural extension: algebraic structure encapsulated by Lawvere theories or operads . This gives rise to a notion of near-semiring category , which underlies many of the applications. 23 / 26

  53. Applications 24 / 26

  54. Applications T -NNOs In a a monoidal category ( ⊗ , I ): NNO = list object on I T -NNO = T -list object on I In Cpo : gives rise to the flat- , lazy- and strict natural numbers. 24 / 26

  55. Applications Functional programming ◮ In the bicartesian closed setting: Jaskelioff’s monadic list transformer Lt ( T ) X := µ A . T (1 + X × A ) is just the free T -monoid monad. 24 / 26

  56. Applications Functional programming ◮ In the bicartesian closed setting: Jaskelioff’s monadic list transformer Lt ( T ) X := µ A . T (1 + X × A ) is just the free T -monoid monad. ◮ In the category of endofunctors over a cartesian category: the MonadPlus type class Mp ( F ) X := µ A . List ( X + FA ) of Rivas et al. is a List -list object. 24 / 26

  57. Applications Functional programming ◮ In the bicartesian closed setting: Jaskelioff’s monadic list transformer Lt ( T ) X := µ A . T (1 + X × A ) is just the free T -monoid monad. ◮ In the category of endofunctors over a cartesian category: the MonadPlus type class Mp ( F ) X := µ A . List ( X + FA ) of Rivas et al. is a List -list object. ◮ In the category of endofunctors over a cartesian category: the datatype Bun ( F ) X := µ A . (1 + X × A + F ( A ) × A + A × A ) is an instance of Spivey’s Bunch type class that is a T-list object for T the extension of the theory of monoids with a unary operator. 24 / 26

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend