Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Call-by-push-value
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Intermediate language}} In [[programming language theory]], '''call-by-push-value''' (CBPV) is an [[intermediate language]] that embeds the [[call-by-value]] (CBV) and [[call-by-name]] (CBN) [[evaluation strategy|evaluation strategies]]. CBPV is structured as a polarized [[λ-calculus]] with two main types, "values" (+) and "computations" (-).<ref name="Kavvos2020">{{cite journal |last1=Kavvos |first1=G. A. |last2=Morehouse |first2=Edward |last3=Licata |first3=Daniel R. |last4=Danner |first4=Norman |title=Recurrence extraction for functional programs through call-by-push-value |journal=Proceedings of the ACM on Programming Languages |date=January 2020 |volume=4 |issue=POPL |pages=1–31 |doi=10.1145/3371083 |url=https://dl.acm.org/doi/pdf/10.1145/3371083 |language=en |issn=2475-1421|arxiv=1911.04588 }}</ref> Restrictions on interactions between the two types enforce a controlled order of evaluation, similar to [[Monad (functional programming)|monad]]s or [[continuation passing style|CPS]]. The calculus can embed computational effects, such as nontermination, mutable state, or nondeterminism. There are natural semantics-preserving translations from CBV and CBN into CBPV. This means that giving a CBPV semantics and proving its properties implicitly establishes CBV and CBN semantics and properties as well. Paul Blain Levy formulated and developed CBPV in several papers and his doctoral thesis.<ref name="Levy99">{{Cite conference |last=Blain Levy |first=Paul |date=April 1999 |title=Call-by-Push-Value: A Subsuming Paradigm |conference=Typed Lambda Calculi and Applications, 4th International Conference, TLCA'99, L'Aquila, Italy |series=Lecture Notes in Computer Science |volume=1581 |pages=228–242|url=https://www.cs.bham.ac.uk/~pbl/papers/tlca99.pdf}}</ref><ref name="Levy2003">{{cite book |last1=Levy |first1=Paul Blain |title=Call-by-push-value: a functional/imperative synthesis |date=2003 |publisher=Kluwer Academic Publishers |location=Dordrecht ; Boston |isbn=978-1-4020-1730-8|url=https://www.cs.bham.ac.uk/~pbl/papers/thesisqmwphd.pdf}}</ref><ref name="Levy2022">{{cite journal |last1=Levy |first1=Paul Blain |title=Call-by-push-value |journal=ACM SIGLOG News |date=April 2022 |volume=9 |issue=2 |pages=7–29 |doi=10.1145/3537668.3537670}}</ref> == Definition == The CBPV paradigm is based on the slogan "a value is, a computation does". One complication in the presentation is distinguishing type variables ranging over value types from those ranging over computation types. This article follows Levy in using underlines to denote computations, so <math>B</math> is an (arbitrary) value type but <math>\underline{B}</math> is a computation type.<ref name="Levy2022"/> Some authors use other conventions, such as distinct sets of letters.<ref>{{cite journal |last1=Pédrot |first1=Pierre-Marie |last2=Tabareau |first2=Nicolas |title=The fire triangle: how to mix substitution, dependent elimination, and effects |journal=Proceedings of the ACM on Programming Languages |date=January 2020 |volume=4 |issue=POPL |pages=1–28 |doi=10.1145/3371126}}</ref> The exact set of constructs varies by author and desired use for the calculus, but the following constructs are typical:<ref name="Levy99"/><ref name="Levy2022"/> * Lambdas <code>λx.M</code> are computations of type <math>A \to \underline{B}</math>, where <math>x : A</math> and <math>M : \underline{B}</math>. A lambda application <code>F V</code> or <code>V'F</code> is a computation of type <math>\underline{B}</math>, where <math>V : A</math> and <math>F : A \to \underline{B}</math>. The let-binding construct <code>let { x_1 = V_1; ... }. M</code> binds values <code>x_1</code> to values <code>V_1</code>, of matching types <math>A_1</math>, inside a computation <code>M</code> : <math>\underline{B}</math>. * A thunk <code>thunk M</code> is a value of type <math>U \underline{A}</math> constructed from a computation <code>M</code> of type <math>\underline{A}</math>. Forcing a thunk is a computation, <code>force X</code> : <math>\underline{A}</math> for a thunk <code>X</code> : <math>U \underline{A}</math>. * It is also possible to wrap a value <code>V</code> of type <math>A</math> as a computation <code>return V</code> : <math>F A</math>. Such a computation can be used inside another computation as <code>M to x. N</code> : <math>\underline{B}</math>, where <code>M</code> : <math>F A</math>, and <code>N</code> : <math>\underline{B}</math> is a computation. * Values can also include [[algebraic data type]]s constructed from a tag and zero or more sub-values, while computations include a deconstructing pattern-match <code>match V as { (1,...) in M_1, ... }</code>. Depending on presentation, ADTs may be limited to binary sums and products, Booleans only, or be omitted altogether. A program is a closed computation of type <math>F A</math>, where <math>A</math> is a ground ADT type.<ref name="Levy2022"/> === Complex values === Expressions such as <code>not true : bool</code> make sense denotationally. But, following the rules above, <code>not</code> can only be encoded using pattern-matching, which would make it a computation, and therefore the overall expression must also be a computation, giving <code>not true : F bool</code>. Similarly, there is no way to obtain <code>1</code> from <code>(1,2)</code> without constructing a computation. When modelling CBPV in the equational or [[category theory]], such constructs are indispensable. Levy therefore defines an extended IR, "CBPV with complex values". This IR extends let-binding to bind values within a value expression, and also to pattern-match a value with each clause returning a value expression.<ref name="Levy2003"/> Besides modelling, such constructs also make writing programs in CBPV more natural.<ref name="Levy99"/> Complex values complicate the operational semantics, in particular requiring an arbitrary decision of when to evaluate the complex value. Such a decision has no semantic significance because evaluating complex values has no side effects. Also, it is possible to syntactically convert any computation or closed expression to one of the same type and denotation without complex values.<ref name="Levy2003"/> Therefore, many presentations omit complex values.<ref name="Levy2022"/> == Translation == The CBV translation produces CBPV values for each expression. A CBV function <code>λx.M</code> : <math>A \to_v B</math> is translated to <code>thunk λx.M<sup>v</sup></code> : <math>U (A^v \to F B^v)</math>. A CBV application <code>M N</code> : <math>A</math> is translated to a computation <code>M<sup>v</sup> to f in N<sup>v</sup> to x in x'(force f)</code> of type <math>F A</math>, making the order of evaluation explicit. A pattern match <code>match V as { (1,...) in M_1, ... }</code> is translated as <code>V<sup>v</sup> to z in match z as { (1,...) in M_1<sup>v</sup>, ... }</code>. Values are wrapped with <code>return</code> when necessary, but otherwise remain unmodified.<ref name="Levy99"/> In some translations, sequencing may be required, such as translating <code>inl M</code> to <code>M to x. return inl x</code>.<ref name="Levy2022"/> The CBN translation produces CBPV computations for each expression. A CBN function <code>λx.M</code> : <math>A \to B</math> translates unaltered, <code>λx.M<sup>N</sup></code> : <math>(U A^n) \to X^n</math>. A CBN application <code>M N</code> : <math>C</math> is translated to a computation <code>M<sup>v</sup> (thunk N<sup>v</sup>)</code> of type <math>C^n</math>. A pattern match <code>match V as { (1,...) in M_1, ... }</code> is translated similarly to CBN as <code>V<sup>n</sup> to z in match z as { (1,...) in M_1<sup>n</sup>, ... }</code>. ADT values are wrapped with <code>return</code>, but <code>force</code> and <code>thunk</code> are also necessary on internal structure. Levy's translation assumes that <code>M = force (thunk M)</code>, which does indeed hold.<ref name="Levy99"/> It is also possible to extend CBPV to model call-by-need, by introducing a <code>M need x. N</code> construct that allows visible sharing. This construct has semantics similar to <code>M name x. N = (λy.N[x ↦ (force y)])(thunk M)</code>, except that with the <code>need</code> construct, the thunk of <code>M</code> is evaluated at most once.<ref>{{cite book |last1=McDermott |first1=Dylan |last2=Mycroft |first2=Alan |chapter=Extended Call-by-Push-Value: Reasoning About Effectful Programs and Evaluation Order |title=Programming Languages and Systems |date=2019 |pages=235–262 |doi=10.1007/978-3-030-17184-1_9 |isbn=978-3-030-17184-1 |publisher=Springer International Publishing |language=en}}</ref> == Modifications == Some authors have noted that CBPV can be simplified, by removing either the U type constructor (thunks)<ref name="Egger2014">{{cite journal |last1=Egger |first1=J. |last2=Mogelberg |first2=R. E. |last3=Simpson |first3=A. |title=The enriched effect calculus: syntax and semantics |journal=Journal of Logic and Computation |date=1 June 2014 |volume=24 |issue=3 |pages=615–654 |doi=10.1093/logcom/exs025 |url=https://www.pure.ed.ac.uk/ws/portalfiles/portal/12289301/eec.pdf}}</ref> or the F type constructor (computations returning values).<ref name="Ehrhard2016">{{cite book |last1=Ehrhard |first1=Thomas |chapter=Call-By-Push-Value from a Linear Logic Point of View |title=Programming Languages and Systems |series=Lecture Notes in Computer Science |date=2016 |volume=9632 |pages=202–228 |doi=10.1007/978-3-662-49498-1_9|doi-access=free|isbn=978-3-662-49497-4 }}</ref> Egger and Mogelberg justify omitting U on the grounds of streamlined syntax and avoiding the clutter of inferable conversions from computations to values. This choice makes computation types a subset of value types, and it is then natural to expand function types to a full function space between values. They term their calculus the "Enriched Effects Calculus". This modified calculus is equivalent to a superset of CBPV via a bidirectional semantics-preserving translation.<ref name="Egger2014"/> Ehrhard in contrast omits the F type constructor, making values a subset of computations. Ehrhard renames computations to "general types" to better reflect their semantics. This modified calculus, the "half-polarized lambda calculus", has close connections to linear logic.<ref name="Ehrhard2016"/><ref>{{cite book |last1=Chouquet |first1=Jules |last2=Tasson |first2=Christine |title=Taylor expansion for Call-By-Push-Value |date=2020 |publisher=Schloss Dagstuhl – Leibniz-Zentrum für Informatik |series=Leibniz International Proceedings in Informatics |volume=152 |pages=16:1–16:16 |doi=10.4230/LIPIcs.CSL.2020.16 |doi-access=free |isbn=978-3-95977-132-0 |url=https://hal.science/hal-02318600/document}}</ref> It can be translated bidirectionally to a subset of a fully-polarized variant of CBPV.<ref>{{citation |last1=Ehrhard |first1=Thomas |title=A Call-By-Push-Value FPC and its interpretation in Linear Logic |date=July 2015 |url=https://hal.science/hal-01176033/document}}</ref> == See also == * [[Programming Computable Functions]] == References == {{reflist}} [[Category:Lambda calculus]] [[Category:Programming language semantics]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Citation
(
edit
)
Template:Cite book
(
edit
)
Template:Cite conference
(
edit
)
Template:Cite journal
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)