Submitted to:
TLLA/Linearity 2018
c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License.
Giulio Guerrieri
Dipartimento di Informatica – Scienza e Ingegneria (DISI), Universit`a di Bologna, Bologna, Italy [email protected]
Giulio Manzonetto
LIPN, UMR 7030, Universit´e Paris 13, Sorbonne Paris Cit´e, F-93430, Villetaneuse, France [email protected]
We study the two Girard’s translations of intuitionistic implication into linear logic by exploiting the bang calculus, a paradigmatic functional language with an explicit box-operator that allows both the call-by-name and call-by-valueλ-calculi to be encoded in. We investigate how the bang calculus subsumes both call-by-name and call-by-valueλ-calculi from a syntactic and a semantic viewpoint.
1 Introduction
Theλ-calculus is a simple framework formalizing many features of functional programming languages.
For instance, theλ-calculus can be endowed with two different evaluation mechanisms, call-by-name (CbN) and call-by-value (CbV), which have quite different properties. A CbN discipline re-evaluates an argument each time it is used. On the contrary, a CbV discipline evaluates an argument just once and recalls its value each time it is used. CbN and CbVλ-calculi are usually defined by means of operational rules giving rise to two different rewriting systems on the same set ofλ-terms: in CbN there is no restriction on firing aβ-redex, whereas in CbV aβ-redex can be fired only when the argument is a value,i.e. a variable or an abstraction. The standard categorical setting for describing denotational models of theλ-calculus, cartesian closed categories, provides models which are adequate for CbN, but typically not for CbV. For CbV, the introduction of an additional computational monad (in the sense of Moggi [22, 23]) is necessary.
While CbNλ-calculus [4] has a rich and refined semantic and syntactic theory featuring advanced concepts such as separability, solvability, B¨ohm trees, classification ofλ-theories, full-abstraction,etc., this is not the case for CbVλ-calculus [25], in the sense that concerning the CbV counterpart of these theoretical notions there are only partial and not satisfactory results (or they do not exist at all!).
Quoting from [17], “the existence of two separate paradigms is troubling” for at least two reasons:
• it makes each language appear arbitrary (whereas a unified language might be more canonical);
• each time we create a new style of semantics,e.g.Scott semantics, operational semantics, game semantics, continuation semantics,etc., we always need to do it twice — once for each paradigm.
Girard’s Linear Logic (LL, [15]) provides a unifying setting where this discrepancy could be solved since both CbN and CbVλ-calculi can be faithfully translated, via two different translations, intoLL proof-nets. Following [17], we can claim that, via these translations,LLproof-nets “subsume” the CbN and CbV paradigms, in the sense that both operational and denotational semantics for those paradigms can be seen as arising, via these translations, from similar semantics forLL.
Indeed,LLcan be understood as a refinement of intuitionistic logic (and henceλ-calculus) in which resource management is made explicit thanks to the introduction of a new pair of dual connectives:
the exponentials “!” and “?”. In proof-nets, the standard syntax forLLproofs,boxes(introducing the
modality “!”) mark the sub-proofs available at will: during cut-elimination, such boxes can be erased (by weakening rules), can be duplicated (by contraction rules), can be opened (by dereliction rules) or can enter other boxes. The categorical counterpart of this refinement is well known: it is the notion of a cartesian∗-autonomous1category, equipped with a comonad endowed with a strong monoidal structure.
Every instance of such a kind of structure yields a denotational model ofLL.
In his seminal article [15], Girard proposes a standard translation of intuitionistic logic (and hence simply typed λ-calculus) in multiplicative-exponentialLL proof-nets whose semantic counterpart is well known: the Kleisli category of the exponential comonad “!” is cartesian closed thanks to the strong monoidal structure of “!”. This translation(·)Nmaps the intuitionistic implicationA⇒Bto theLLformula
!AN(BN. In [15] Girard proposes also another translation(·)V that he calls “boring”: it maps the the intuitionistic implicationA⇒Bto theLLformula !(AV(BV)(or equivalently !AV(!BV). Since the untypedλ-calculus can be seen as simply typed with only one ground typeosatisfying the recursive identityo=o⇒o, the two Girard’s translations(·)Nand(·)Vdecompose this identity intoo=!o(o ando=!(o(o)(or equivalently,o=!o(!o), respectively. At theλ-term level, these two translations differ only by the way they use logical exponential rules (i.e. box and dereliction), whereas they use multiplicative and structural (i.e. contraction and weakening) ingredients in the same way. Because of this difference, the translation(·)N encodes the CbNλ-calculus into LLproof-nets (in the sense that CbN evaluation→β is simulated by cut-elimination via(·)N), while(·)V encodes the CbVλ-calculus intoLLproof-nets (CbV evaluation→βv is simulated by cut-elimination via(·)V). Indeed, since in CbN λ-calculus there is no restriction on firing aβ-redex (its argument can be freely copied or erased), the translation(·)Nputs the argument of every application into a box (see [7, 27, 16]); on the other hand, the translation(·)Vputs only values into boxes (see [2]) since in CbVλ-calculus values are the only duplicable and discardableλ-terms. Thus, as deeply studied in [20], the two Girard’s logical translations explain the two different evaluation mechanisms, bringing them into the scope of the Curry-Howard isomorphism.
The syntax of multiplicative-exponentialLLproof-nets is extremely expressive and powerful, but it is too general and sophisticated for the computational purpose of representing purely functional programs.
For instance, simulation ofβ-reduction onLLproof-nets passes through intermediate states/proof-nets that cannot be expressed asλ-terms, sinceLLproof-nets have many spurious cuts with axioms that have no counterpart onλ-terms. More in general,LLproof-nets are manipulated in their graphical form, and while this is a handy formalism for intuitions, it is far from practical for formal reasoning.
From the analysis of Girard’s translations it seems worthwhile to extend the syntax of theλ-calculus to internalize the insights coming fromLLin aλ-like syntax. The idea is to enrich theλ-calculus with explicit boxesmarking the “values” of the calculus,i.e.the terms that can be freely duplicated and discarded: such alinearλ-calculus subsumes both CbN and CbVλ-calculi, via suitable translations. This, of course, has been done quite early in the history ofLLby defining various linearλ-calculi, such as [19, 1, 5, 28, 20].
All these calculi require a clear distinction between linear and non-linear variables, structural rules being freely (and implicitly) available for the latter and forbidden for the former. This distinction complicates the formalism and is actually useless as far as we are interested in subsumingλ-calculi.
Inspired by Ehrhard [13], in [14] it has been introduced an intermediate formalism enjoying at the same time the conceptual simplicity ofλ-calculus (without any distinction between linear and non-linear variables) and the operational expressiveness ofLLproof-nets: thebang calculus. It is a variant of the λ-calculus which is “linear” in the sense that the exponential rules ofLL(box and dereliction) are part of the syntax, so as to subsume CbN and CbVλ-calculi via two translations(·)nand(·)v, respectively,
1Actually the full symmetry of such a category is not really essential as far as theλ-calculus is concerned, it is however quite natural from theLLviewpoint:LLrestores the classical involutivity of negation in a constructive setting.
from the setΛofλ-terms to the set !Λof terms of the bang calculus (see§3). These two translations are deeply related to Girard’s encodings(·)Nand(·)V of CbN and CbVλ-calculi intoLLproof-nets. Indeed, Girard’s translations(·)Nand(·)V decompose in such a way that the following diagrams commute:
Λ (·)N //
(·)n
))
LL
!Λ
(·)◦
55 Λ (·)V //
(·)v
))
LL
!Λ
(·)◦
55
where(·)◦is a natural translation of the bang calculus into multiplicative-exponentialLLproof-nets. Thus, the bang calculusinternalizesthe two Girard’s translations in aλ-like calculus instead ofLLproof-nets.
It subsumes both CbN and CbVλ-calculi in thesamerewriting system and denotational model, so that it may be a general setting to compare CbN and CbV. The bang calculus can be seen as a metalanguage where the choice of CbN or CbV evaluation depends on the way the term is built up. If we consider the syntax of theλ-calculus as a programming language, issues like CbN versus CbV evaluations affect the way theλ-calculus is translated in this metalanguage, but does not affect the metalanguage itself.
It turns out that this bang calculus was already known in the literature: it is an untyped version of the implicative fragment of Paul Levy’s Call-By-Push-Value calculus [17, 18]. Interestingly, his work was not motivated by an investigation of the two Girard’s translations. This link is not casual, since it holds even when the bang calculus is extended to a PCF-like system, as shown by Ehrhard [13].
The aim of our paper is to further investigate the way the bang calculus subsumes CbN and CbV λ-calculi, refining and extending some results already obtained in [14].
1. From a syntactic viewpoint, we show in§3 that the bang calculus subsumes in the same rewriting sys- tem both CbN and CbVλ-calculi, in the sense that the translations(·)nand(·)vfrom theλ-calculus to the bang calculus are sound and complete with respect toβ-reduction andβv-reduction, respec- tively (in [14] only soundness was proven, and in a less elegant way). In other words, the diagrams
Λ3t β //
(·)n
s∈Λ
(·)n
!Λ3tn b //sn∈!Λ
Λ3t βv //
(·)v
s∈Λ
(·)v
!Λ3tv b //sv∈!Λ
commute in the two ways: starting from theβ-reduction step→βfor the CbNλ-calculus (on the left) or theβv-reduction step→βv for the CbVλ-calculus (on the right), and starting from the b-reduction step→bof the bang calculus.2
2. From a semantic viewpoint, we show in§4 that theeveryLL-based modelU of the bang calculus (as categorically defined in [14]) provides a model for both CbN and CbVλ-calculi (in [14] this was done only for the special case of relational semantics). Moreover, given aλ-termt, we investigate the relation between its interpretations|t|nin CbN (resp.|t|vin CbV) and the interpretationJ·Kof its translationtn(resp.tv) into the bang calculus. We prove that the diagram below on the left (for CbN) commutes, whereas we give a counterexample (in the relational semantics) to the commutation of the diagram below on the right (for CbV). We conjecture that there still exists a relationship in CbV between|t|vandJtvK, but it should be more sophisticated than in CbN.
Λ3t |·|n //
(·)n ((
|t|n=JtnK∈U tn∈!Λ
J·K 44 Λ3t |·|v //
(·)v ((
|t|v=JtvK∈U tv∈!Λ
J·K 44
In order to achieve these results in a clearer and simpler way, we have slightly modified (see§2) the syntax and operational semantics of the bang calculus with respect to its original formulation in [14].
2Actually, for the CbVλ-calculus the diagram is slightly more complex, as we will see in§3, but the essence does not change.
Terms: T,S,R::=x|λx T | hTiS|derT |T! (set: !Λ) Contexts: C::=L·M|λxC| hCiT | hTiC|derC|C! (set: !ΛC) Ground contexts: G::=L·M|λxG| hGiT | hTiG|derG (set: !ΛG)
Root-steps: hλx TiS!7→`T{S/x} der(T!)7→dT 7→b:=7→`∪ 7→d r-reduction: T →rS ⇔ ∃C∈!ΛC,∃T0,S0∈!Λ:T =CLT0M,S=CLS0M,T07→rS0 rg-reduction: T →rgS ⇔ ∃G∈!ΛG,∃T0,S0∈!Λ:T =GLT0M,S=GLS0M,T07→rS0
Figure 1: The bang calculus: its syntax and its reduction rules, wherer∈ {`,d,b}.
Preliminaries and notations. Let→rand→r0 be binary relations on a setX.
The composition of→rand→r0 is denoted by→r→r0 or→r· →r0. The transpose of→r is denoted by r←.
The reflexive-transitive (resp. reflexive) closure of→ris denoted by→∗r (resp.→=r ). Ther-equivalence'ris the reflexive-transitive and symmetric closure of→r.
Lett∈X:tisr-normalif there is no termssuch thatt→rs;tisr-normalizableif there is ar-normal terms such thatt→∗r s, and we then say thatsis ar-normal form of t.
The relation→risconfluentif∗r← · →∗r ⊆ →∗r·∗r←; it isquasi-storngly confluentifr← · →r⊆ (→r·r←)∪=.
From confluence it follows that:t'rsifft→∗rr∗r←sfor some termr; and anyr-normalizable term has aunique r-normal form. Clearly, quasi-strong confluence implies confluence.
2 Syntax and reduction rules of the bang calculus
The syntax and operational semantics of thebang calculusare defined in Fig. 1.
Terms are built up from a countably infinite set Varof variables(denoted byx,y,z, . . .). Terms of the formT! (resp.λx T;hTiS; derT) are called orboxes(resp.abstractions;(linear) applications;
derelictions). The set of boxes is denoted by !Λ!. The set of free variables of a termT, denoted byfv(T), is defined as expected,λ being the only binding constructor. All terms are considered up toα-conversion.
GivenT,S∈!Λand a variablex,T{S/x}denotes the term obtained by thecapture-avoiding substitution ofS(and notS!) for each free occurrence ofxinT: so,T!{S/x}= (T{S/x})!∈!Λ!.
ContextsCandground contextsG(both with exactly one holeL·M) are defined in Fig. 1. All ground contexts are contexts but the converse fails: L·M
!is a non-ground context. We writeCLTMfor the term obtained by the capture-allowing substitution of the termT for the holeL·Min the contextC.
Reductions in the bang calculus are defined in Fig. 1 as follows: given aroot-steprule7→r⊆!Λ×!Λ, we define ther-reduction→r(resp.rg-reduction→rg) as the closure of7→runder contexts (resp. ground contexts). Note that→rg(→r as !ΛG(!ΛC: the only difference between→rand→rg is that the latter does not reduce under ! (but both reduce underλ). The root-steps used in the bang calculus are7→`and7→d and7→b:=7→`∪ 7→d. From the definitions in Fig. 1 it follows that→b=→`∪ →dand→bg=→`g∪ →dg.
Intuitively, the basic idea behind the root-steps7→` and7→dis that the box-constructor ! marks the only terms that can be erased and duplicated. When the argument of a constructor der is a boxT!, the root-step7→dopens the box,i.e.accesses its contentT, destroying its status of availability at will (butT, in turn, might be a box). The root-step7→`says that aβ-like redexhλx TiScan be fired only when its argument is a box,i.e. S=R!: if it so, the contentRof the boxSreplaces any free occurrence ofxinT. Example1. Let∆:=λxhxix!and∆0:=λxhder(x!)ix!. Then,∆0→dg∆andh∆i∆!→`gh∆i∆!→`g. . . and hder(∆0!)i∆0!→dgh∆0i∆0!→`ghder(∆0!)i∆0!→dg. . . Note that(h∆i∆!)!isbg-normal but notb-normalizable.
Thebang(resp.ground bang)calculusis the set !Λendowed with the reduction→b(resp.→bg).
x⇒`x var
T⇒`S λ λx T ⇒`λx S
T⇒`S
! T!⇒`S!
T⇒`S derT⇒`derSder
T⇒`S R⇒`Q hTiR⇒`hSiQ @
T⇒`S R⇒`Q
` hλx TiR!⇒`S{Q/x}
Figure 2: Parallel`-reduction.
Quasi-strong confluence ofbg-reduction and confluence ofb-reduction. To prove the confluence of→b(Prop. 4.2), first we show that→`is confluent (Lemma 3.4). The latter is proved by a standard adaptation of Tait–Martin-L¨of technique — as improved by Takahashi [29] — based on parallel reduction.
For this purpose, we introduceparallel`-reduction, denoted by⇒`, a binary relation on !Λdefined by the rules in Fig. 2. Intuitively,⇒`reduces simultaneously a number of`-redexes existing in a term. It is immediate to check that⇒`is reflexive and→`⊆ ⇒`⊆ →∗`, whence⇒∗`=→∗`.
For any termT, we denote byT∗the term obtained by reducingall`-redexes inT simultaneously.
Formally,T∗is defined by induction onT ∈!Λas follows:
x∗:=x (λx T)∗:=λx T∗ (T!)∗:= (T∗)! (derT)∗:=der(T∗) (hTiS)∗:=hT∗iS∗ifT 6=λx RorS∈/!Λ! (hλx TiS!)∗:=T∗{S∗/x}
Lemma 2(Development). LetT,S∈!Λ. If T ⇒`S, then S⇒`T∗. Proof p. 17
Lemma 2 is the key ingredient to prove the confluence of→`(Lemma 3.4 below).
The next lemma lists a series of good rewriting properties of`-,`g-,d- anddg-reductions that will be used to prove quasi-strong confluence of→bg and confluence of→b(Prop. 4 below).
Lemma 3(Basic properties of reductions). Proof p. 18
1. →`gis quasi-strongly confluent: `g← · →`g⊆(→`g·`g←)∪=.
2. →dgand→dare quasi-strongly confluent (separately).
3. →dgand→`g strongly commute: dg← · →`g⊆ →`g·dg←.
→dquasi-strongly commutes over→`: d← · →`⊆ →`·∗d←.
→dand→`commute: ∗d← · →∗` ⊆ →∗`·∗d←. 4. →`is confluent: ∗`← · →∗` ⊆ →∗`·∗`←.
Proposition 4(Quasi-strong confluence of→bgand confluence of→b). Proof p. 20
1. The reduction→bgis quasi-strongly confluent, i.e. bg← · →bg⊆(→bg·bg←)∪=. 2. The reduction→bis confluent: ∗b← · →∗b⊆ →∗b·∗b←.
3 The bang calculus with respect to CbN and CbV λ -calculi, syntactically
One of the interests of the bang calculus is that it is a general framework where bothcall-by-name (CbNi.e.ordinary, [4]) and Plotkin’scall-by-value(CbV, [25])λ-calculi can be embedded.3 Syntax and reduction rules of CbN and CbVλ-calculi are in Fig. 3: β reduction→β (resp.βv-reduction→βv) is the reduction for the CbN (resp. CbV)λ-calculus. CbN and CbVλ-calculi share the same term syntax (the setΛofλ-terms of CbV and CbNλ-calculi can be seen as a subset of !Λ), whereas→βv is just the restriction of→β allowing to fire aβ-redex(λx T)Sonly whenSis aλ-value,i.e.variable or abstraction.
Groundβ-(resp.βv-)reduction→βg (resp.→βv
g) is an interesting restriction ofβ-(resp.βv-)reduction:
3Here, with CbN or CbVλ-calculus we refer to the whole calculus and its general reduction rules, not only to CbN or CbV (deterministic) evaluation strategy in theλ-calculus.
λ-terms: t,s,r::=v|ts (set:Λ)
λ-values: v::=x|λx t (set:Λv)
λ-contexts: C::=L·M|λxC|Ct|tC (set:ΛC) CbN groundλ-contexts: N::=L·M|λxN|Nt (set:ΛN) CbV groundλ-contexts: V::=L·M|Vt|tV (set:ΛV) Root-steps: (λx t)S7→βt{S/x}(CbN) (λx t)v7→βvt{v/x}(CbV)
r-reduction: t→rs ⇔ ∃C∈ΛC,∃t0,s0∈Λ:t=CLt0M,s=CLs0M,t07→rs0 βg-reduction: t→βgs ⇔ ∃N∈ΛN,∃t0,s0∈Λ:t=NLt0M,s=NLs0M,t07→βs0 βgv-reduction: t→βgvs ⇔ ∃V∈ΛV,∃t0,s0∈Λ:t=VLt0M,s=VLs0M,t07→βvs0
Figure 3: The CbN and CbVλ-calculi: their syntax and reduction rules, wherer∈ {β,βv}.
• →βgcontains headβ-reduction and weak headβ-reduction, two well-known evaluation strategies for CbNλ-calculus (both reduce theβ-redex in head position, the latter does not reduce underλ’s);
• →βv
g contains (weak) headβv-reduction (aka left reduction in [25, p. 136]), the well-known evalua- tion strategy for CbVλ-calculus firing the leftmost-outermostβv-redex (if any) not underλ’s.
CbN and CbV translations into the bang calculus. CbN andCbV translations are two functions (·)n:Λ→!Λand(·)v:Λ→!Λ, respectively, translatingλ-terms into terms of the bang calculus:
xn:=x (λx t)n:=λx tn (ts)n:=htnisn!
xv:=x! (λx t)v:= (λx tv)! (ts)v:=hdertvisv.
Example5. LetΩ:= (λx xx)λx xx, the typical divergingλ-term for CbN and CbVλ-calculi: one has Ωn=h∆i∆!andΩv=hder(∆0!)i∆0!, which are notbg- norb-normalizable (∆and∆0 are defined in Ex. 1).
For anyλ-termt,tnandtvare just different decorations oftby means of the monadic operators ! and der (the latter does not occur intn). Note that the translation(·)nputs the argument of any application into a box: in CbNλ-calculus anyλ-term is duplicable or discardable. On the other hand, onlyλ-values (i.e.abstractions and variables) are translated by(·)vinto boxes, as they are the onlyλ-terms duplicable or discardable in CbVλ-calculus.
Lemma 6(Substitution). Let t,s beλ-terms and x be a variable.
1. One has that tn{sn/x}= (t{s/x})n.
2. If s is such that sv=R!for some R∈!Λ, then tv{R/x}= (t{s/x})v. Proof. The proofs of both points are by induction on theλ-termt.
1. • Variable: Iftis a variable then there are two subcases. Ift:=xthentn=x, sotn{sn/x}= sn= (t{s/x})n. Otherwiset:=y6=xand thentn=y, hencetn{r/x}=y= (t{s/x})n.
• Abstraction: If t:=λy r then tn=λy rn and we can suppose without loss of generality thaty∈/fv(s)∪ {x}. Byi.h.,rn{sn/x}= (r{s/x})nand hencetn{sn/x}=λy(rn{sn/x}) = λy(r{s/x})n= (t{s/x})n.
• Application: Ift:=RQ, thentn=hrniqn!. Byi.h.,rn{sn/x}= (r{s/x})nandqn{sn/x}= (q{s/x})n. So,tn{sn/x}=hrn{sn/x}i(qn{sn/x})!=h(r{s/x})ni((q{s/x})n)!= (t{s/x})n. 2. • Variable: Iftis a variable then there are two subcases. Ift:=xthentv=x!, sotv{R/x}=
R!=sv= (t{s/x})v. Otherwiset:=y6=xand thentv=y!, hencetv{R/x}=y!= (t{s/x})v.
• Application: Ift:=pqthentv=hderpviqv. Byi.h., pv{R/x}= (p{s/x})vandqv{R/x}= (q{s/x})v. So,tv{R/x}=hder(pv{R/x})iqv{R/x}=hder(p{s/x}v)i(q{s/x})v= (t{s/x})v.
• Abstraction: Ift:=λy qthentv= (λy qv)! and we can suppose without loss of generality thaty∈/fv(s)∪ {x}. Byi.h.,qv{R/x}= (q{s/x})v, and thustv{R/x}= (λy(qv{R/x}))!= (λy(q{s/x})v)!= (t{s/x})v.
Note that the hypothesis aboutsin Lemma 6.2 is fulfilled if and only ifsis aλ-value.
Remark7 (CbV translation is`-normal). It is immediate to prove by induction ont∈Λthattvis`-normal, so iftv→dS0→`Sthen the only`-redex inS0has been created by the steptv→dS0and is absent intv. Simulating CbN and CbV reductions into the bang calculus. We can now show that the CbN trans- lation(·)n(resp. CbV translation(·)v) from the CbN (resp. CbV)λ-calculus into the bang calculus is soundandcomplete: said differently, the target of the CbN (resp. CbV) translation into the bang calculus is aconservativeextension of the CbN (resp. CbV)λ-calculus.
Theorem 8(Simulation of CbN and CbVλ-calculi). Let t be aλ-term.
1. Conservative extension of CbNλ-calculus:
Soundness:If t→βt0 then tn→`t0n(and tn→bt0n);
Completeness:Conversely, if tn→bS then tn→`S=t0nand t→βt0for someλ-term t0. 2. Conservative extension of ground CbNλ-calculus:
Soundness:If t→βgt0then tn→`gt0n(and tn→bgt0n);
Completeness:Conversely, if tn→bgS then tn→`gS=t0nand t→βgt0for someλ-term t0. 3. Conservative extension of CbVλ-calculus:
Soundness:If t→βvt0then tv→d→`t0v(and hence tv→b→bt0v);
Completeness:Conversely, if tv→d→`S then S=t0vand t→βvt0for someλ-term t0. 4. Conservative extension of ground CbVλ-calculus:
Soundness:If t→βv
gt0then tv→dg→`gt0v(and hence tv→bg→bgt0v);
Completeness:Conversely, if tv→dg→`gS then S=t0vand t→βv
g t0for someλ-term t0.
Proof. 1. Soundness: We prove by induction on the λ-termt that ift →β t0 thentn→`t0n. By definition oft→βt0, there are the following cases:
• Root-step,i.e. t:= (λxr)s7→βR{s/x}=:t0: by Lemma 6.1,tn=hλxrnisn!7→`rn{sn/x}=t0n.
• Abstraction,i.e. t:=λx r→βλx r0=:t0withr→β r0: byi.h.,rn→`r0n, thustn=λx rn→` λx r0n=t0n.
• Application left,i.e. t:=rs→β r0s=:t0 withr→β r0: byi.h. rn→`r0n, sotn=hrnisn!→` hr0nisn!=t0n.
• Application right,i.e. t:=sr→βsr0=:t0withr→βr0: analogous to the previous case.
Completeness:First, observe thattn→bsentailstn→`ssince der does not occur intn, hencetnis d-normal. We prove by induction on theλ-termtthat iftn→`SthenS=t0nandt→βt0for some λ-termt0. According to the definition oftn→`S, there are the following cases:
• Root-step, i.e. tn:=hλx rniqn!7→`rn{qn/x}=:S: by Lemma 6.1S= (r{q/x})n, sot= (λx r)q7→βr{q/x}=:t0wheret0v=S.
• Abstraction,i.e. tn:=λx rn→`λx S0=:Swithrn→`S0: byi.h., there is aλ-termr0such that r0n=S0andr→βr0, thust=λx r→βλx r0=:t0wheret0n=λx r0n=S.
• Application left,i.e. tn:=hrniqn!→`hS0iqn!=:Swithrn→`S0: analogously to above.
• Application right,i.e. tn:=hqnirn!→`hqniS0!=:Swithrn→`S0: byi.h., there is aλ-termr0 such thatr0n=S0andr→β r0, sot=qr→βqr0=:t0witht0n=hqnir0n!=S.
2. Since 7→β is simulated by 7→` and vice-versa (see the root-cases above), Thm. 8.2 is proved analogously to the proof of Thm. 8.1 (→`g replaces→`, and→βgreplaces→β), with the difference that, by definition,→β
gand→`g do not give rise to the caseApplication right.
3. Soundness:We prove by induction on theλ-termtthat ift→βvt0thentv→d→`t0v. According to the definition ofT →βvT0, there are the following cases:
• Root-step, i.e. t := (λx r)v7→βv r{v/x}=:t0 wherev is aλ-value, i.e. a variable or an abstraction: then vv =S! for someS∈!Λ, hence tv =hder(λx rv)!ivv→dg hλx rvivv7→` rv{S/x}=t0vby Lemma 6.2 (recall that→dg⊆ →d).
• Abstraction, i.e. t:=λx r→βv λx r0=:t0 with r→βv r0: by i.h., rv →d→`r0v; therefore tv= (λx rv)!→d→`(λx r0v)!=t0v.
• Application left, i.e. t :=rs→βv r0s=:t0 with r→βv r0: by i.h. rv →d→`r0v; therefore tv=hderrvisv→d→`hderr0visv=T0v.
• Application right,i.e. t:=sr→βvsr0=:t0withr→βvr0: analogous to the previous case.
Completeness: We prove by induction onS0∈!Λthat iftv→dS0→`SthenS=t0vandt→βvt0 for someλ-termt0. According to the definition ofS0→`S, there are the following cases:
• Root-step, i.e. S0:=hλx RiQ!7→` R{Q/x}=:S. According to Rmk. 7, necessarily tv= hder(λx R)!iQ!and hencet= (λx r0)vfor someλ-termr0and someλ-valuevsuch thatrv0=R andvv=Q!. Notice thattv→dgS0. Lett0:=r0{v/x}: then,t7→βvt0andt0v=rv0{Q/x}=S according to Lemma 6.2.
• Abstraction,i.e. S0:=λx R0→`λx R0=:SwithR0→`R0. This case is impossible because, according to Rmk. 7, necessarilytv=λx Rfor some`-normalR∈!Λsuch thatR→dR0, but there is noλ-termtsuch thattvis an abstraction.
• Dereliction,i.e. S0:=derR0→`derR0=:SwithR0→`R0. This case is impossible because, according to Rmk. 7, necessarilytv=derRfor some`-normalR∈!Λsuch thatR→dR0, but there is noλ-termtsuch thattvis a dereliction.
• Application left,i.e. S0:=hR0iR1→`hR0iR1=:SwithR0→`R0. By Rmk. 7,tv=hderPiR1 for some`-normalP∈!Λsuch that derP→dR0, and thusR0=derP0whereP→dP0(indeed P=R!0is impossible becausePis`-normal), and henceR0=derP0withP0→`P0. So,t=qq1 for someλ-termsqandq1such thatqv=Pandqv1=R1withqv→dP0→`P0. Byi.h.,P0=q0v andq→βvq0for someλ-termq0. Lett0:=q0q1: then,t=qq1→βvt0andt0v=hderq0viqv1=S.
• Application right,i.e. S0:=hR1iR0→`hR1iR0=:SwithR0→`R0. By Rmk. 7, necessarily tv=hderP1iRfor some`-normalR,P1∈!Λsuch that derP1=R1andR→dR0. So,t=q1Q for someλ-termsq1andqsuch thatqv1=P1andqv=Rwithqv→dR0→`R0. Byi.h.,R0=q0v andq→βvq0for someλ-termq0. Lett0:=q1q0: then,t=q1q→βvt0andt0v=hderqv1iq0v=S.
target of CbN translation into!Λ: T,S::=x| hTiS!|λx T (set: !Λn)
target of CbV translation into!Λ: M,N::=U!| hderMiN| hUiM (set: !Λv) U::=x|λx M (set: !Λvv).
Figure 4: Targets of CbN and CbV translations into the bang calculus.
• Box,i.e. S0:=R!0→`R0!=:SwithR0→`R0. According to Rmk. 7, necessarilytv=R!for some`-normalR∈!Λsuch thatR→dR0. So,t=λx q(sincetvis a box andxvisd-normal) for someλ-termqsuch thatR=λx qv, and hence there areP0,P0∈!Λsuch thatR0=λx P0 andR0=λx P0withqv→dP0→`P0. Byi.h.,P0=q0vandq→βvq0for someλ-termq0. Let t0:=λx q0: then,t=λx q→βvt0andt0v= (λx q0v)!=S.
4. Since7→βv is simulated by→dg7→`and vice-versa (see the root-cases above), Thm. 8.4 is proved analogously to the proof of Thm. 8.3 (replace→`with→`g, and→dwith→dg, as well as→βv
with→βv
g), with the difference that→βv
g does not give rise to the caseAbstraction(in the soundness proof) andBox(in the completeness proof).
So, the bang calculus can simulateβ- andβv-reductions via(·)nand(·)vand, conversely,`-reductions in the targets of(·)nand(·)vcorrespond toβ- andβv-reductions. Also, these simulations are:
• modular, in the sense that ground β-reduction (including head β-reduction and weak headβ- reduction) is simulated byground `-reduction, and vice-versa (Thm. 8.2);ground βv-reduction (including headβv-reduction) is simulated bygroundd- and`-reductions, and vice-versa (Thm. 8.4);
• quantitative sensitive, meaning thatone stepof (ground)β-reduction corresponds exactly, via(·)n, toone stepof (ground)`-reduction, and vice-versa;one stepof (ground)βv-reduction corresponds exactly, via(·)v, toone stepof (ground)`-reduction, and vice-versa.
According to the definition of CbN translation(·)n, the target of(·)ninto the bang calculus can be characterized syntactically: it is the subset !Λnof !Λdefined in Fig. 4. This means thattn∈!Λnfor any t∈Λ, and conversely, for anyT ∈!Λn,Tn=tfor somet∈Λ. Note that in !Λnthe constructor der does not occur and hence reductions→`and→`gcoincide with→band→bg, respectively, in !Λn.
So, Thm. 8.1-2 says that !Λnendowed with the reduction→`(resp.→`g) — which coincides with→b (resp.→bg) in !Λn— isisomorphicto CbN (resp. ground CbN)λ-calculus. In particular:
Corollary 9(Preservations with respect to CbNλ-calculus). Let t,s∈Λ.
1. CbN equational theory:t'βs iff tn'`sniff tn'bsn.
2. CbN normal forms:t is (ground)β-normal iff tnis (ground)`-normal iff tnis (ground)b-normal.
Proof. 1. Ift'βsthent→∗
βr∗
β←sfor somer∈Λ, as→β is confluent. By Thm. 8.1 (soundness), tn→∗` rn∗`←sn; so,tn'`snandtn'bSnsince→`⊆ →b.
Conversely, iftn'bsnthentn→∗bR∗b←snfor someR∈!Λ, since→bis confluent (Prop. 4.2). By Thm. 8.1 (completeness),t→∗βq∗β←sfor someλ-termqsuch thatqn=R, and thereforet'β s.
2. Immediate consequence of Thm. 8.1-2.
The correspondence between CbV λ-calculus and bang calculus is slightly more delicate: CbV translation(·)vgives a sound and complete embedding of→βvinto→d→`(and similarly for their ground variants), but it is not complete with respect to generic→b. Indeed, Ex. 1 and Ex. 5 have shown that
(λx xx)v=∆0!→d∆!, where∆!isb-normal and there is noλ-termtsuch thattv=∆!. Note thatλx xxis βv-normal but(λx xx)v=∆0!is notb-normal: in CbV the analogous of Cor. 9.2 does not hold for(·)v.
Actually, an analogous of Cor. 9.1 for CbV holds: CbV translation preservesβv-equivalence in a sound and complete way with respect tob-equivalence (see Cor. 12 below). The proof requires a fine analysis of CbV translation(·)v. First, we define two subsets !Λvand !Λvv of !Λ, see Fig. 4.
Remark10 (Image of CbV translation). Ift∈Λthentv∈!Λv(proof by induction ont∈Λ). In particular, for anyv∈Λv,vv=U!for someU∈!Λvv. Note that∆!∈!Λvbut there is noλ-termtsuch thattv=∆!.
We have just shown that(·)vis not surjective in !Λv. Anyway, it can be shown (Lemma 11.3) that !Λv is the set of terms in !Λreachable byb-reduction from CbV translations ofλ-terms (i.e.for anyt∈Λ, iftv→∗bSthenS∈!Λv) andb-equivalence in !Λvpreservesβv-equivalence (Cor. 12). To prove that, we define a forgetful translation(·)†: !Λv∪!Λvv→Λtransforming termsM∈!ΛvandU∈!Λvv intoλ-terms:
(U!)†:=U† (hderMiN)†:=M†N† (hUiM)†:=U†M†; x†:=x (λx M)†:=λx M†. Lemma 11(Properties of the forgetful translation(·)†).
Proof p. 20
1. (·)†is a right-inverse of(·)v:For every t∈Λ, one has tv†=t.
2. Substitution:M{U/x} ∈!Λvwith(M{U/x})†=M†{U†/x}, for any M∈!Λvand U∈!Λvv. 3. b-reduction vs.βv-reduction:For any M∈!Λvand T∈!Λ, if M→bT then T ∈!Λvand M†→=
βvT†. Rmk. 10 and Lemma 11.3 mean that !Λvis the set of terms in !Λreachable byb-reduction from CbV translations ofλ-terms (i.e.for anyt∈Λ, iftv→∗bSthenS∈!Λv). We can conclude:
Corollary 12(Preservation of CbV equational theory). Let t,s∈Λ. One has t 'βvs iff tv'bsv. Proof. Ift'βvsthent→∗
βvr∗
βv←sfor somer∈Λ, as→βvis confluent; by Thm. 8.3,tv→∗brv∗b←sv, since→`⊆ →band→d⊆ →b; therefore,tv'bsv. Conversely, iftv'bsvthentv→∗bR∗b←svfor some R∈!Λ, since→bis confluent (Prop. 4.2); by Rmk. 10,tv,sv∈!Λv; so,R∈!ΛvandTv†→∗βvR†∗βv←sv†
by Lemma 11.3, hencet=tv†'βvsv†=sby Lemma 11.1.
So, Cor. 12 says that CbV translation (·)v— even if it is a sound but not complete embedding of βv-reduction intob-reduction — is a sound and complete embedding ofβv-equivalence intob-equivalence.
A final remark on the good rewriting properties of the bang calculus: the embeddings of CbN and CbVλ-calculi into the bang calculus arefinerthan the ones into the linear calculusλlinintroduced in [20].
For instance, inλlinit is impossible to define a fragment isomorphic to CbNλ-calculus; also, the CbV translation of theλ-calculus intoλlinis sound but not complete, and equates more thanβv-equivalence.
Moreover, the bang calculus can be modularly extended with other reduction rules and/or syntactic constructs so that our CbV translation embeds the extensions of CbVλ-calculus studied in [3] into the corresponding extended version of the bang calculus, with results analogous to those presented here.
4 The bang calculus with respect to CbN and CbV λ -calculi, semantically
The denotational models of the bang calculus we are interested in this paper are those induced by a denotational model ofLL. We recall the basic definitions and notations, see [21, 13, 14] for more details.