nLab lambda-mu-calculus

Contents

Introduction

Similar to how simply typed lambda-calculus gives a computational interpretation of intuitionistic logic, lambda-mu calculus gives an computational interpretation of classical logic, the excluded middle and double negation. It is an extension of lambda-calculus with “continuation” capturing and passing.

The idea is that for the law of excluded middle one must prove A∨¬AA \vee \neg A. The a proof of ¬A\neg A is usually thought of as a A→⊥A \to \bot, where it takes in an element of AA and returns an element of the empty type ⊥\bot, which should be impossible. Instead to prove the LEM, it creates an element of A→⊥A \to \bot that is really is a continuation that “jumps” somewhere else in the program, so it has a return type of ⊥\bot as in that it never returns. Where it jumps to gets provided an element of AA, as the other half of the LEM. It can be though of that whenever an element f:A→⊥f : A \to \bot is used with an element a:Aa : A as faf a it can take that aa and insert it as inl(a)inl(a) for A∨¬AA \vee \neg A.

Definition

Here is simply typed from Michel Parigot. Terms in regular lambda calculus are usually generated by variables, function application, and lambda abstraction.

term=var|termterm|λvar.termterm = var | term \quad term | \lambda var . term

here varvar is a countable set of variables.

var=x|y|z|…var = x | y | z | \dots

Instead terms are extended by giving them to a continuation or capturing a continuation.

term=var|termterm|λvar.term|[covar]term|μcovar.termterm = var | term \quad term | \lambda var . term | [covar] term | \mu covar . term

The covariables represent continuations and are also a countable set of names.

covar=α|β|γ|…covar = \alpha | \beta | \gamma | \dots

The usuall rules of lambda calculus

Γ,a:A⊢b:BΓ⊢λa.b:A→B\frac{\Gamma, a : A \vdash b : B}{\Gamma \vdash \lambda a . b : A \to B}

are instead extended to where judgments add an extra context Δ\Delta

Γ;Δ⊢t:T\Gamma; \Delta \vdash t : T

The context Γ\Gamma is the usual context of variables.

Γ=a:A,b:B,c:C,…\Gamma = a : A, b : B, c : C, \dots

But in contrast the Δ\Delta is a context of covariables, where α:A\alpha : A represents a continuation that takes in type AA.

Δ=α:A,β:B,γ:C,…\Delta = \alpha : A, \beta : B, \gamma : C, \dots

The usual lambda calculus rules stay the same by simply ignoring Δ\Delta. For example lambda abstraction is the same.

Γ,a:A;Δ⊢b:BΓ;Δ⊢λa.b:A→B\frac{\Gamma, a : A; \Delta \vdash b : B}{\Gamma ; \Delta \vdash \lambda a . b : A \to B}

But the calculus has some additional rules added. For example given a an element t:At : A and a continuation α:A\alpha : A one can pass tt into α\alpha and it will jump somewhere else in the program giving [α]t:⊥[\alpha]t : \bot.

Γ;Δ,α:A⊢t:AΓ;Δ,α:A⊢[α]t:⊥\frac{\Gamma; \Delta, \alpha : A\vdash t : A}{\Gamma; \Delta, \alpha : A \vdash [\alpha] t : \bot}

Additionally one can capture a continuation

Γ;Δ,α:A⊢t:AΓ;Δ⊢μα.t:A\frac{\Gamma; \Delta, \alpha : A\vdash t : A}{\Gamma; \Delta \vdash \mu \alpha . t : A}

The continuation passing is represented with some additional judgmental equalities. Regular lambda calculus has betabeta-reduction and η\eta-reduction.

(λx.t)s≡t[s/x](\lambda x . t)s \equiv t[s/x]
(λx.(fx)≡f(\lambda x . (f x) \equiv f

the lambda-mu calculus also has the following judgmental equalities.

If tt is passed to a continuation α\alpha that is immediately captured then it’s the same as just using aa

μα.[α]t≡t\mu \alpha . [\alpha]t \equiv t

If tt is captured by β\beta that then immediately goes into α\alpha then tt might as well just pass anything it passed into β\beta directly into α\alpha

μα.[α]t≡t[α/β]\mu \alpha . [\alpha]t \equiv t[\alpha / \beta]

If alphaalpha returns a function from tt and is then applied to ss then one can instead apply ss to anywhere something is passed into α\alpha.

(μα.t)s≡μα.t[[α](ns)/[α]n](\mu \alpha . t) s \equiv \mu \alpha . t[[\alpha](n s)/[\alpha]n]

Examples

Double negation

We want to prove ((A→⊥)→⊥)→A((A \to \bot) \to \bot) \to A for any AA. So we can say We are given an h:((A→⊥)→⊥)h : ((A \to \bot) \to \bot) and want to get a term of AA. We can give hh a “fake” A→⊥A \to \bot by using a capture.

k=λx.[α]xk = \lambda x . [\alpha] x
Γ;Δ,α:A⊢λx.[α]x:A→⊥\Gamma; \Delta, \alpha : A \vdash \lambda x . [\alpha] x : A \to \bot

So kk will take an AA and pass upwards to wherever α\alpha is captured by a μ\mu.

Applying hh to kk will yield a ⊥\bot.

Γ,h:((A→⊥)→⊥);Δ,α:A⊢h(λx.[α]x):⊥\Gamma, h: ((A \to \bot) \to \bot); \Delta, \alpha : A \vdash h (\lambda x . [\alpha] x) : \bot

Now we can simply capture the AA that kk is throwing up with a μ\mu abstraction.

Γ,h:((A→⊥)→⊥);Δ⊢μα.h(λx.[α]x):A\Gamma, h: ((A \to \bot) \to \bot); \Delta \vdash \mu \alpha . h (\lambda x . [\alpha] x) : A

Then do a regular lambda abstraction.

Γ;Δ⊢λh.μα.h(λx.[α]x):((A→⊥)→⊥)→A\Gamma; \Delta \vdash \lambda h . \mu \alpha . h (\lambda x . [\alpha] x) : ((A \to \bot) \to \bot) \to A

The intuition here is that any h:((A→⊥)→⊥)h : ((A \to \bot) \to \bot) to use its input argument A→⊥A \to \bot must give that A→⊥A \to \bot a value of AA to get ⊥\bot, but we pass that AA into the continuation α\alpha that jumps back up and can then provde that AA for the output.

Law of excluded middle

Intuitionistic logic can already prove ¬¬(A∨¬A)\neg \neg ( A \vee \neg A) so using double negation we can already get LEM. But there is a nicer way of proving it.

Let’s say we have

λx.[α](inlx)):(A→⊥)\lambda x . [\alpha] (inl x)) : (A \to \bot)

we can then insert that onto the right side of the sum

inr(λx.[α](inlx)):A∨(A→⊥)inr(\lambda x . [\alpha] (inl x)) : A \vee (A \to \bot)

and then capture the α\alpha

μα.inr(λx.[α](inlx)):A∨(A→⊥)\mu \alpha . inr(\lambda x . [\alpha] (inl x)) : A \vee (A \to \bot)

The intuition here is that anything that uses the LEM must match both sides of the sum. So it first provides the right side A→⊥A \to \bot as a continuation, so when the proof uses that by passing an AA into it, it jumps back and uses that AA on the left side. Thus providing A∨(A→⊥)A \vee (A \to \bot).

References

https://doi.org/10.1007%2FBFb0013061

Last revised on November 15, 2026 at 07:20:33. See the history of this page for a list of all contributions to it.