15-317 Constructive Logic
Lecture 24: A Taste of Linear Logic
Linear logic is the logic of precious resources: hypotheses may neither be
duplicated nor discarded in the course of a proof. At the end of the day,
every resource must be used exactly once. Earlier, we saw that the notion
of hypothesis-as-resource may be fruitfully employed in logic programming
to encode certain kinds of state transitions. We began class today by
reviewing the program that decomposes a list and then rebuilds a
list([X|Xs]) ⊸ elem(X) ⊗ list(Xs).
In the notation of linear logic, we see that the encoding uses two
list() ⊸ perm().
elem(X) ⊗ perm(Xs) ⊸ perm([X|Xs]).
We reviewed the intuitionistic linear sequent calculus right and
left rules for both connectives, showing how their interpretation matches
our intuition: we must sometimes partition our resources in order to
achieve our goals, and the init rule tells us we cannot discard any
- linear implication A ⊸ B, pronounced "A lolli
B", which represents the ability to consume a resource
A and replace it with a resource B.
- simultaneous conjunction A ⊗ B, pronounced "A
tensor B", which represents the simultaneous possession of a
resource A and a resource B.
We also recalled a modification of the above program to make it return a
permutation of a sub-list. To accomplish this, we explicitly permit
ourselves to discard elements using the empty resource 1.
elem(X) ⊸ 1.
The left and right rules for 1 are nullary versions of those for
Then we saw another linear logic connective, A & B, pronounced
"A with B", and its unit, ⊤, "top". The
right rule is strikingly similar to that for A ⊗ B, except
that it does not split the resources! This is accounted for in the left
rules, though, which only give you one of A or B, not both.
(Connectives whose rules split the context, such as ⊗ and ⊸
above, are called multiplicative. Connectives whose rules do not
split the context, like &, are called additive.)
This "alternative conjunction" or "internal choice"
represents the ability to have either resource, but not simultaneously
both. As a characteristic example, we considered the vending machine
which, given a dollar, offers you your choice of Coke or Sprite:
$1 ⊸ coke & sprite.
We also considered a vending machine offering a limited time promotion,
where each Coke comes with a pack of gum. We modelled the customer's
indifference about this gum by using the consumptive unit ⊤ to eat
up the undesired resource in the proof of:
($1 ⊸ coke ⊗ gum) ===> ($1 ⊸ coke ⊗
Given a notion of "internal choice", it is natural to wonder
if there is a corresponding "external choice". In linear logic,
there is: the connective A ⊕ B, pronounced "A plus
B", representing either an A resource or a B resource,
but you don't know which. The rules are very similar to the rules for
ordinary disjunction from intuitionistic logic. This external choice can
be used to model a Las Vegas gambling machine that sometimes gives you an
all-expenses paid vacation to the Grand Caymans and somtimes just gives you
$1 ⊸ coke ⊕ vacation.
Finally, we saw the unrestricted modality, !A, pronounced "bang
A" or "of course A", which represents as many A
resources as you'd like, possibly none at all. To interpret this
connective, we introduced a second context to hold unrestricted hypotheses.
In addition to the appropriate right and left rules, we posit a
"copy" rule which lets a proof proceed by copying an unrestricted
hypothesis to the linear context. In fact, we have implicitly made use of
this context already: the rules of a logic program may be applied over and
over again as long as their preconditions match the current state, and a
rule may be used not at all in the execution of a program. Thus, the rules
themselves are represented as unrestricted hypotheses.
To tie it all together, we worked through an extended example modelling a
delicious brunch menu using the tasty and versatile connectives of linear
logic. If only restaurateurs knew of such things!
- Reading: lp:12-linear.pdf
(Notes from an earlier course on Logic Programming)
- Brunch menu example: menu.pdf
- Key concepts:
- Linear hypotheses as precious resources
- Unrestricted hypotheses for unlimited use
- Internal vs. external choice
- Multiplicative vs. additive resource management
- Modelling monetary transactions using linear logic
- Previous lecture: Imperative Logic Programming
- Next lecture: ??