an introduction to call-by-push-value
TRANSCRIPT
![Page 1: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/1.jpg)
An introduction to call-by-push-value calculus
H Koba
![Page 2: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/2.jpg)
Overview of this talk• (1) Introduction• CbPV• Embedding CbV and CbN strategy in the same system
• (2) Semantics• CbV, CbN’s semantics using monads• CbPV’s semantics, using EM adjunction
![Page 3: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/3.jpg)
Introduction• Types and
terms• [Levy, 2016]
(p. 3)
![Page 4: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/4.jpg)
Introduction• Computations with
side effects• [Levy, 2016]
(p. 8)• Behavior of
constructs depends on the evaluation strategy• CbV, CbN, …
![Page 5: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/5.jpg)
Introduction• CbV strategy
[Levy, 2016](p.7)• Arguments are
evaluated before substitution
![Page 6: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/6.jpg)
Introduction• CbN strategy
[Levy, 2016](p.6)• Substitutions
occur before evaluating arguments
![Page 7: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/7.jpg)
Introduction• How can we handle them in a single calculus?• Need to control evaluation order• Call-by-push-value calculus• distinction between “values” and “computations”
• Values: what do not need evaluation• Computations: what need evaluation
![Page 8: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/8.jpg)
Introduction
• Call-by-push-value calculus [Levy, 2016] (p. 30)• Computation types are underlined
![Page 9: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/9.jpg)
Introduction• [Levy, 2016] (p. 32)• return and to• like Haskell’s return
and >>=• thunk and force• No counterparts in
Haskell
![Page 10: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/10.jpg)
Introduction• [Levy, 2016] (p. 37)• Embedding of CbV to
CbPV• In function
application, N is evaluated first
![Page 11: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/11.jpg)
Introduction• [Levy, 2016] (p. 38)• Embedding of CbN to
CbPV• In function
application, evaluation of N is delayed (until the thunk is evaluated)
![Page 12: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/12.jpg)
Summary• We have a calculus call-by-push-value• We have embeddings of CbV and CbN to CbPV
![Page 13: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/13.jpg)
Semantics• (Denotational) semantics of pure typed lambda calculus is CCC (like
Sets)• Types -> objects, terms -> arrows
• , • Semantics of is
• What about non-pure computations?• Use monads to define denotational semantics• CbV and CbN need different categories
• CbV -> Kl(T), CbN -> EM(T)
![Page 14: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/14.jpg)
Semantics• CbV’s semantics: Kl(T)• Due to Moggi (1988)
• Figure from [Levy, 2016] (p. 15)• Types -> objects in Kl(T) =
objects in C• Terms -> arrows in Kl(T) =
Kleisli arrows
![Page 15: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/15.jpg)
Semantics• CbN’s semantics: EM(T)• Eilenberg-Moore category
• Figure from [Levy, 2016] (p. 29)• Types -> objects in EM(T) =
EM algebras• Terms -> An arrow (in C) for
some EM algebra
![Page 16: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/16.jpg)
Semantics• CbPV’s semantics: The adjunction • Value -> object in C• Computation -> object in EM(T) (Eilenberg-Moore algebra)• Embedding of CbV and CbN preserves semantics:• Recall in CbV becomes in CbPV• This is isomorphic to !
• is a limit, so it is preserved by (right adjoint of )
![Page 17: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/17.jpg)
Semantics• and are adjoint functors• Recall: ([Levy, 2016] (p. 30))
![Page 18: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/18.jpg)
Summary• Embedding of CbV and CbN preserves semantics• Monad is decomposed into adjunction
![Page 19: An introduction to call-by-push-value](https://reader033.vdocuments.net/reader033/viewer/2022051707/58eea8431a28abe25c8b4689/html5/thumbnails/19.jpg)
References• [Levy, 2016] P.B.Levy, A tutorial on call-by-push-value (2016)
https://www.cs.bham.ac.uk/~pbl/papers/cbpvefftt.pdf • It describes denotational semantics of CbV and CbN first, then introduces
CbPV using them.
• [Levy, 1999] P.B.Levy. Call-By-Push-Value: A Subsuming Paradigm (Extended Abstract) (1999)• [Moggi, 1988] E. Moggi, Computational lambda-calculus and monads
(1988)