Call-by-name is dual to call-by-value
P. Wadler
Abstract:Gentzen’s sequent calculus for classical logic shows great symmetry: for example, the rule introducing ∧ on the left of a sequent is mirror symmetric to the introduction rule for the dual operator ∨ on the right of a sequent. A consequence of this casual observation is that when Γ ` ∆ is a theorem over operators {∨,∧,¬}, then so is ∆ ` Γ, where Σ reverses the order of formulas in Σ, and exchanges each instance of A ∧B (C ∨D) in a formula of Σ with B ∨ A (D ∧ C). This symmetry of rules means that the duality of theorems is also a duality of proof structures. When introducing implication (→), the duality of theorems can be recovered by a translation (say, A → B ≡ ¬A ∨ B), but the duality of proofs is naively lost. By instead adding a logically redundant coimplication ←, that duality is restored. A classical Curry-Howard correspondence then dualizes application and λ-abstraction over expression variables, which implement→, with co-application and co-λ-abstraction over continuation variables, which implement ←. The proof syntax and programming language we recover is Filinski’s symmetric λ-calculus [3], augmented with a certain facility in naming continuations found in λμ-calculus [17]. The dual calculus of [18] lacks λ, encoding it instead using primitive operators—in particular, using computationally redundant sharing. It is from such nonlinearity that confluence is lost in normalization of classical proofs, which is why call-by-name and call-by-value translations are used to restore it. Interpreted from a linear logic perspective, this encoding unnecessarily requires two copies of every procedure calling context, because the dual calculus lacks the computational power of . Further, the call-by-value and call-by-name encodings of λ and @ are not isomorphic, nor do they have duals. The symmetric λ-calculus invites no such complication or redundancy, and its call-by-name and call-by-value CPS translations are dual. Using a direct-style translation that we introduced in [14], where the administrative redexes of CPS translation are eliminated and re∗Supported by NSF Grants CDA-9806718, CCR-0228951, and the Tyson Foundation. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. CW04, January 17, Venice, Italy. Copyright 2004 ACM 1-58113-756-7/03/0008 ...$5.00. placed by a boxing strategy, dual CBN and CBV proofnets are recovered. These proofnets elaborate the dual, confluent proof structures with explicit sharing, and identify explicitly the coroutined alternation in evaluation of expressions and continuations. The language is then built from four kinds of pairing (with complementary unpairing): of two expressions (a product), two continuations (a coproduct), a continuation and expression (application context), and an expression and continuation (co-application context).