In mathematical logic and computer science, the lambda-mu calculus is an extension of the lambda calculus introduced by Michel Parigot.1 It introduces two new operators: the μ operator (which is completely different both from the μ operator found in computability theory and from the μ operator of modal μ-calculus) and the bracket operator. Proof-theoretically, it provides a well-behaved formulation of classical natural deduction.
One of the main goals of this extended calculus is to be able to describe expressions corresponding to theorems in classical logic. According to the Curry–Howard isomorphism, lambda calculus on its own can express theorems in intuitionistic logic only, and several classical logical theorems can't be written at all. However with these new operators one is able to write terms that have, for example, the type of Peirce's law.
According to de Groote, the μ operator corresponds to Felleisen's undelimited control operator C and bracket corresponds to calling a captured continuation.2
Formal definition
The three forms of expressions in lambda calculus are as follows:
- A variable x.
- An abstraction λx. M, where x is any variable and M is any lambda expression.
- An application (M N), where M and N are any lambda expressions.
In addition to the traditional λ-variables, the lambda-mu calculus includes a distinct set of μ-variables, which can be understood as continuation variables. The set of terms is divided into unnamed (all traditional lambda expressions are of this kind) and named terms. The terms that are added by the lambda-mu calculus are of the form:
- [α]M is a named term, where α is a μ-variable and M is an unnamed term.
- (μ α. t) is an unnamed term, where α is a μ-variable and t is a named term.
Reduction
The basic reduction rules used in the lambda-mu calculus are the following:
- beta reduction
- structural reduction
- , where the substitutions are to be made for all subterms of of the form .
- renaming
- μη-reduction
- , if α does not occur freely in M
These rules cause the calculus to be confluent.
Typed lambda-mu calculus
The lambda-mu calculus can be typed. The basic theory of the typed lambda-mu calculus is to classical propositional logic as the simply typed lambda calculus is to intuitionistic propositional logic.3
Typed lambda-mu calculus can be presented in sequent calculus:3: Figure 6.2 The first 3 rules are the same as simply typed lambda calculus. The next 2 are new to the lambda-mu calculus.
Curry–Howard correspondence
Simply typed lambda calculus, by the Curry–Howard correspondence, corresponds to purely functional programs that can only redirect their inputs.
A sequent states that, within a program context , one can construct an object of type .
The rule states that, within a context that includes some , one can construct an object with type . This is obvious, by simply taking that same .
The lambda-introduction rule states that, if one can construct within a context of , then one can construct within a context of . This object is a function-object defined within the context of . It takes an object as input, and internally reproduces the context of , in which one then constructs . This is a form of closure.
The lambda-reduction rule is a reverse of the previous rule.
The typed lambda-mu calculus is similar to the simply typed lambda calculus, but it allows redirecing both the inputs and the outputs. The redirection of input is by lambda abstraction, or closure. The redirection of output is by mu abstraction, or call/cc, jumps, or control operators.
The negation symbol denotes duality. Whereas in the program context denotes an input from which an object with type appears, denotes an output for an object with type goes to.
denotes a computational process that does not return any value, because its value would be returned to an output in context.
The address abstraction rule closes an output from context. This corresponds to catch in call/cc.
The address application rule redirects the output of a process to the output in context. This corresponds to throw in call/cc.
The is a channel device. The address is a channel that values of type can be transmitted along, and represents transmittal of to , provided that is of type .3: 134
Examples
Peirce's law is the type of the following term:where we write for , in order to save space.
Intuitively, one can understand this construction as follows. The program opens an input context , and an output context . One way to satisfy the output requirement of is to construct something of type , and give it to . That something is . If takes this object without trying to use it, then it will return an object of type , which can then be given to . Alternatively, might attempt to use it by providing it with an object , which can then be given to without ever replying an object of type to .
The Łukasiewicz axiom is the type of the following term:The double-negation translation corresponds to continuation-passing style. That is, the double-negation translation turns every formula provable in classical propositional logic into a provable formula in intuitionistic propositional logic. This corresponds to converting a program with catch/throw into a purely functional program that uses continuation-passing.3: Sec. 6.4
For example, the double-negation translation of Peirce's law is the type of the following term:Compare these two, in parallel:The "jump to a different output" control behavior, as defined by , is translated into a pure lambda expression . Instead of allowing a jump to the address , one encodes the entire "the rest of the computation after the jumping to " as a single object, called the continuation object. This continuation object can then be called for as many times as one wants, as long as that continuation object remains in context.
Variations
Call-by-value lambda-mu calculus
To obtain call-by-value semantics, one must refine the beta reduction rule and add another form of structural reduction:4
- call-by-value beta reduction
- , where V is a value
- right structural reduction
- , where V is a value
This addition corresponds to the addition of an additional evaluation context former when moving from call-by-name to call-by-value evaluation.
De Groote's unstratified syntax
For a closer correspondence with conventional formalizations of control operators, the distinction between named and unnamed terms can be abolished, meaning that [α]M is of the same sort as other lambda-expressions and the body of μ-abstraction can also be any expression.2 Another variant in this vein is the Λμ-calculus.5
Symmetric lambda-mu calculus
One can consider a structural reduction rule symmetric to the original one:1
This, however, breaks confluence and the correspondence to control operators.
See also
See also
- Classical pure type systems for typed generalizations of lambda calculi with control
References
References
- Michel Parigot (1992). λμ-Calculus: An algorithmic interpretation of classical natural deduction. Lecture Notes in Computer Science. Vol. 624. pp. 190–201. doi:10.1007/BFb0013061. ISBN 3-540-55727-X.
- de Groote, Philippe (1994). "On the relation between the λμ-calculus and the syntactic theory of sequential control". In Pfenning, Frank (ed.). Logic Programming and Automated Reasoning, 5th International Conference, LPAR'94, Kiev, Ukraine, July 16–22, 1994, Proceedings. Lecture Notes in Computer Science. Vol. 822. Springer. pp. 31–43. doi:10.1007/3-540-58216-9_27. ISBN 978-3-540-58216-8.
- Sørensen, Morten Heine; Urzyczyn, Paweł (2006). "6. Classical logic and control operators". Lectures on the Curry-Howard isomorphism. Studies in logic and the foundations of mathematics. ScienceDirect (Online service) (1 ed.). Amsterdam Boston [MA]: Elsevier. ISBN 978-0-444-52077-7.
- Ong, C.-H. L.; Stewart, C. A. (1997-01-01). "A Curry-Howard foundation for functional computation with control". Proceedings of the 24th ACM SIGPLAN-SIGACT symposium on Principles of programming languages - POPL '97. New York, NY, USA: Association for Computing Machinery. pp. 215–227. doi:10.1145/263699.263722. ISBN 978-0-89791-853-4.
- Saurin, Alexis (2005). "Separation with Streams in the λμ-calculus". 20th IEEE Symposium on Logic in Computer Science (LICS 2005), 26–29 June 2005, Chicago, IL, USA, Proceedings. IEEE Computer Society. pp. 356–365. doi:10.1109/LICS.2005.48.