Call-by-push-value (CBPV) is a generalisation to call-by-name (CBN) and call-by-value (CPV). This programming language paradigm is based on the slogan "a value is, a program does" and is equipped with a type theory, operational semantics, and denotational models. A calculus for CBPV was first presented in Paul Blain Levy's PhD thesis. This note summerises parts of the thesis.
In CBPV we distinguish between computations and values. Hence there are two disjoint kinds of types: a computation has a computation type, and a value has a value type.
The syntax of types and terms are given in FigureĀ 1. We omit the ground types and values (e.g. booleans) and prospone the discussion in RemarkĀ B.
Types
Terms
Once we get to the semantics and equational theory, we will see that the let-bindings are essentially syntax sugars for lambda application (e.g. is equivalent to ). Nonetheless, the intuition behind the other terms are explained as follows. Notice the a value is, a computation does principle.
Suppose there is an operand-stack of values and tags.
Observe that only a value can be pushed or popped. However, we can "freeze" a computation into a value; this value is called the thunk of . Later, when desired, this thunk can be forced (i.e. executed).
We can extend value types with ground types by adding the unit type and sum type for some countable index . For instance, we can define .
The only term of type is , and by an abuse of notation, terms of are simply denoted for . We call these terms ground values.
Since we have two kinds of types, the judgments in the calculus are
and the type system is given in FigureĀ 2.
We present a big-step semantics that can reduce all closed computation to a terminal computation. Intuitively, a terminal computation cannot proceed if the operand-stack is empty.
A closed computation is terminal if it is in the form
Let denote the set of closed computation of type , and denote the set of terminal computations. The big-step semantics presented in FigureĀ 3 defines a (total) function from to .
Based on the big-step semantics, we can derive an equational theory and recover laws such as the -reduction and -conversion. Formally, we define new judgments
to express judgmental equalities. However, we adopt the following conventions.
The laws are grouped into - and -laws in FigureĀ 4, and sequencing laws in FigureĀ 5.
todocbv and semantics for cbv
The most important difference between CBV and CPBV is that is a value in CBV whereas in CPBV its a computation. Thus is translated to in CBPV.
notice that