lipn.univ-paris13.frgmanzonetto/papers/gg18.pdf · submitted to: tlla/linearity 2018 c g. guerrieri...

21
Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License. The Bang Calculus and the Two Girard’s Translations 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, into LL proof-nets. Following [17], we can claim that, via these translations, LL proof-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 for LL. Indeed, LL can 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 for LL proofs, boxes (introducing the

Upload: others

Post on 25-Sep-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

Submitted to:TLLA/Linearity 2018

c© G. Guerrieri & G. ManzonettoThis work is licensed under theCreative Commons Attribution License.

The Bang Calculus and the Two Girard’s Translations

Giulio GuerrieriDipartimento di Informatica – Scienza e Ingegneria (DISI), Universita di Bologna, Bologna, Italy

[email protected]

Giulio ManzonettoLIPN, UMR 7030, Universite Paris 13, Sorbonne Paris Cite, F-93430, Villetaneuse, France

[email protected]

We study the two Girard’s translations of intuitionistic implication into linear logic by exploiting thebang calculus, a paradigmatic functional language with an explicit box-operator that allows both thecall-by-name and call-by-value λ -calculi to be encoded in. We investigate how the bang calculussubsumes 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 anargument each time it is used. On the contrary, a CbV discipline evaluates an argument just once and recallsits value each time it is used. CbN and CbV λ -calculi are usually defined by means of operational rulesgiving rise to two different rewriting systems on the same set of λ -terms: in CbN there is no restriction onfiring a β -redex, whereas in CbV a β -redex can be fired only when the argument is a value, i.e. a variableor 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. ForCbV, 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 conceptssuch as separability, solvability, Bohm trees, classification of λ -theories, full-abstraction, etc., this is notthe case for CbV λ -calculus [25], in the sense that concerning the CbV counterpart of these theoreticalnotions 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, gamesemantics, 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 solvedsince both CbN and CbV λ -calculi can be faithfully translated, via two different translations, into LLproof-nets. Following [17], we can claim that, via these translations, LL proof-nets “subsume” the CbNand CbV paradigms, in the sense that both operational and denotational semantics for those paradigmscan be seen as arising, via these translations, from similar semantics for LL.

Indeed, LL can be understood as a refinement of intuitionistic logic (and hence λ -calculus) in whichresource management is made explicit thanks to the introduction of a new pair of dual connectives:the exponentials “!” and “?”. In proof-nets, the standard syntax for LL proofs, boxes (introducing the

Page 2: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

2 The Bang Calculus and the Two Girard’s Translations

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) orcan enter other boxes. The categorical counterpart of this refinement is well known: it is the notion of acartesian ∗-autonomous1 category, equipped with a comonad endowed with a strong monoidal structure.Every instance of such a kind of structure yields a denotational model of LL.

In his seminal article [15], Girard proposes a standard translation of intuitionistic logic (and hencesimply typed λ -calculus) in multiplicative-exponential LL proof-nets whose semantic counterpart iswell known: the Kleisli category of the exponential comonad “!” is cartesian closed thanks to the strongmonoidal structure of “!”. This translation (·)N maps the intuitionistic implication A⇒ B to the LL formula!AN ( BN. In [15] Girard proposes also another translation (·)V that he calls “boring”: it maps the theintuitionistic implication A⇒ B to the LL formula !(AV ( BV) (or equivalently !AV ( !BV). Since theuntyped λ -calculus can be seen as simply typed with only one ground type o satisfying the recursiveidentity o = o⇒ o, the two Girard’s translations (·)N and (·)V decompose this identity into o = !o ( oand o = !(o ( o) (or equivalently, o = !o ( !o), respectively. At the λ -term level, these two translationsdiffer only by the way they use logical exponential rules (i.e. box and dereliction), whereas they usemultiplicative and structural (i.e. contraction and weakening) ingredients in the same way. Because ofthis difference, the translation (·)N encodes the CbN λ -calculus into LL proof-nets (in the sense thatCbN evaluation→β is simulated by cut-elimination via (·)N), while (·)V encodes the CbV λ -calculusinto LL proof-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), thetranslation (·)N puts the argument of every application into a box (see [7, 27, 16]); on the other hand, thetranslation (·)V puts only values into boxes (see [2]) since in CbV λ -calculus values are the only duplicableand discardable λ -terms. Thus, as deeply studied in [20], the two Girard’s logical translations explain thetwo different evaluation mechanisms, bringing them into the scope of the Curry-Howard isomorphism.

The syntax of multiplicative-exponential LL proof-nets is extremely expressive and powerful, but it istoo general and sophisticated for the computational purpose of representing purely functional programs.For instance, simulation of β -reduction on LL proof-nets passes through intermediate states/proof-netsthat cannot be expressed as λ -terms, since LL proof-nets have many spurious cuts with axioms that haveno counterpart on λ -terms. More in general, LL proof-nets are manipulated in their graphical form, andwhile 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 tointernalize the insights coming from LL in a λ -like syntax. The idea is to enrich the λ -calculus with explicitboxes marking the “values” of the calculus, i.e. the terms that can be freely duplicated and discarded: sucha linear λ -calculus subsumes both CbN and CbV λ -calculi, via suitable translations. This, of course, hasbeen done quite early in the history of LL by 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 beingfreely (and implicitly) available for the latter and forbidden for the former. This distinction complicatesthe 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 thesame time the conceptual simplicity of λ -calculus (without any distinction between linear and non-linearvariables) and the operational expressiveness of LL proof-nets: the bang calculus. It is a variant of theλ -calculus which is “linear” in the sense that the exponential rules of LL (box and dereliction) are partof the syntax, so as to subsume CbN and CbV λ -calculi via two translations (·)n and (·)v, respectively,

1Actually the full symmetry of such a category is not really essential as far as the λ -calculus is concerned, it is however quitenatural from the LL viewpoint: LL restores the classical involutivity of negation in a constructive setting.

Page 3: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

G. Guerrieri & G. Manzonetto 3

from the set Λ of λ -terms to the set !Λ of terms of the bang calculus (see §3). These two translations aredeeply related to Girard’s encodings (·)N and (·)V of CbN and CbV λ -calculi into LL proof-nets. Indeed,Girard’s translations (·)N and (·)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-exponential LL proof-nets. Thus,the bang calculus internalizes the two Girard’s translations in a λ -like calculus instead of LL proof-nets.It subsumes both CbN and CbV λ -calculi in the same rewriting system and denotational model, so that itmay be a general setting to compare CbN and CbV. The bang calculus can be seen as a metalanguagewhere the choice of CbN or CbV evaluation depends on the way the term is built up. If we consider thesyntax of the λ -calculus as a programming language, issues like CbN versus CbV evaluations affect theway 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 theimplicative fragment of Paul Levy’s Call-By-Push-Value calculus [17, 18]. Interestingly, his work wasnot motivated by an investigation of the two Girard’s translations. This link is not casual, since it holdseven 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 (·)n and (·)v from the λ -calculusto 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

Λ 3 t β //

(·)n

s ∈ Λ

(·)n

!Λ 3 tn b // sn ∈ !Λ

Λ 3 t βv //

(·)v

s ∈ Λ

(·)v

!Λ 3 tv b // sv ∈ !Λ

commute in the two ways: starting from the β -reduction step→β for the CbN λ -calculus (on theleft) or the βv-reduction step →β v for the CbV λ -calculus (on the right), and starting from theb-reduction step→b of the bang calculus.2

2. From a semantic viewpoint, we show in §4 that the every LL-based model U of the bang calculus(as categorically defined in [14]) provides a model for both CbN and CbV λ -calculi (in [14] this wasdone only for the special case of relational semantics). Moreover, given a λ -term t, we investigatethe relation between its interpretations |t|n in CbN (resp. |t|v in CbV) and the interpretation J·K of itstranslation tn (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 ofthe diagram below on the right (for CbV). We conjecture that there still exists a relationship in CbVbetween |t|v and JtvK, but it should be more sophisticated than in CbN.

Λ 3 t |·|n //(·)n ((

|t|n = JtnK ∈U

tn ∈ !ΛJ·K

44Λ 3 t |·|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) thesyntax 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.

Page 4: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

4 The Bang Calculus and the Two Girard’s Translations

Terms: T,S,R ::= x | λxT | 〈T 〉S | derT | T ! (set: !Λ)

Contexts: C ::= L·M | λxC | 〈C〉T | 〈T 〉C | derC | C! (set: !ΛC)

Ground contexts: G ::= L·M | λxG | 〈G〉T | 〈T 〉G | derG (set: !ΛG)

Root-steps: 〈λxT 〉S! 7→` TS/x der(T !) 7→d T 7→b := 7→` ∪ 7→d

r-reduction: T →r S ⇔ ∃C ∈ !ΛC, ∃T ′,S′∈ !Λ : T = CLT ′M, S = CLS′M, T ′ 7→r S′

rg-reduction: T →rg S ⇔ ∃G ∈ !ΛG, ∃T ′,S′∈ !Λ : T = GLT ′M, S = GLS′M, T ′ 7→r S′

Figure 1: The bang calculus: its syntax and its reduction rules, where r ∈ `,d,b.

Preliminaries and notations. Let→r and→r′ be binary relations on a set X .The composition of→r and→r′ is denoted by→r→r′ or→r ·→r′ . The transpose of→r is denoted by r←.

The reflexive-transitive (resp. reflexive) closure of→r is denoted by→∗r (resp.→=r ). The r-equivalence 'r is the

reflexive-transitive and symmetric closure of→r.Let t ∈ X : t is r-normal if there is no term s such that t→r s; t is r-normalizable if there is a r-normal term s

such that t→∗r s, and we then say that s is a r-normal form of t.The relation→r is confluent if ∗r← ·→∗r ⊆→∗r ·∗r←; it is quasi-storngly confluent if r← ·→r ⊆ (→r · r←)∪=.

From confluence it follows that: t 'r s iff t→∗r r ∗r← s for some term r; and any r-normalizable term has a uniquer-normal form. Clearly, quasi-strong confluence implies confluence.

2 Syntax and reduction rules of the bang calculus

The syntax and operational semantics of the bang calculus are defined in Fig. 1.Terms are built up from a countably infinite set V ar of variables (denoted by x,y,z, . . . ). Terms

of the form T ! (resp. λxT ; 〈T 〉S; derT ) are called or boxes (resp. abstractions; (linear) applications;derelictions). The set of boxes is denoted by !Λ!. The set of free variables of a term T , denoted by fv(T ),is defined as expected, λ being the only binding constructor. All terms are considered up to α-conversion.Given T,S ∈ !Λ and a variable x, TS/x denotes the term obtained by the capture-avoiding substitutionof S (and not S!) for each free occurrence of x in T : so, T !S/x= (TS/x)! ∈ !Λ!.

Contexts C and ground contexts G (both with exactly one hole L·M) are defined in Fig. 1. All groundcontexts are contexts but the converse fails: L·M! is a non-ground context. We write CLT M for the termobtained by the capture-allowing substitution of the term T for the hole L·M in the context C.

Reductions in the bang calculus are defined in Fig. 1 as follows: given a root-step rule 7→r⊆ !Λ× !Λ,we define the r-reduction→r (resp. rg-reduction→rg) as the closure of 7→r under contexts (resp. groundcontexts). Note that→rg (→r as !ΛG ( !ΛC: the only difference between→r and→rg is that the latterdoes not reduce under ! (but both reduce under λ ). The root-steps used in the bang calculus are 7→` and 7→d

and 7→b := 7→`∪ 7→d. From the definitions in Fig. 1 it follows that→b=→` ∪→d and→bg =→`g∪→dg .Intuitively, the basic idea behind the root-steps 7→` and 7→d is that the box-constructor ! marks the

only terms that can be erased and duplicated. When the argument of a constructor der is a box T !, theroot-step 7→d opens the box, i.e. accesses its content T , destroying its status of availability at will (but T ,in turn, might be a box). The root-step 7→` says that a β -like redex 〈λxT 〉S can be fired only when itsargument is a box, i.e. S = R!: if it so, the content R of the box S replaces any free occurrence of x in T .Example 1. Let ∆ := λx〈x〉x! and ∆′ := λx〈der(x!)〉x!. Then, ∆′→dg ∆ and 〈∆〉∆!→`g 〈∆〉∆!→`g . . . and〈der(∆′!)〉∆′!→dg 〈∆′〉∆′!→`g 〈der(∆′!)〉∆′!→dg . . . Note that (〈∆〉∆!)! is bg-normal but not b-normalizable.

The bang (resp. ground bang) calculus is the set !Λ endowed with the reduction→b (resp.→bg).

Page 5: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

G. Guerrieri & G. Manzonetto 5

varx⇒` xT ⇒` S

λ

λxT ⇒` λxS

T ⇒` S!

T !⇒` S!

T ⇒` Sder

derT ⇒` derS

T ⇒` S R⇒` Q@

〈T 〉R⇒` 〈S〉QT ⇒` S R⇒` Q

`〈λxT 〉R!⇒` SQ/x

Figure 2: Parallel `-reduction.

Quasi-strong confluence of bg-reduction and confluence of b-reduction. To prove the confluenceof→b (Prop. 4.2), first we show that→` is confluent (Lemma 3.4). The latter is proved by a standardadaptation of Tait–Martin-Lof technique — as improved by Takahashi [29] — based on parallel reduction.For this purpose, we introduce parallel `-reduction, denoted by⇒`, a binary relation on !Λ defined bythe rules in Fig. 2. Intuitively,⇒` reduces simultaneously a number of `-redexes existing in a term. It isimmediate to check that⇒` is reflexive and→`⊆⇒`⊆→∗` , whence⇒∗` =→∗` .

For any term T , we denote by T ∗ the term obtained by reducing all `-redexes in T simultaneously.Formally, T ∗ is defined by induction on T ∈ !Λ as follows:

x∗ := x (λxT )∗ := λxT ∗ (T !)∗ := (T ∗)! (derT )∗ := der(T ∗)

(〈T 〉S)∗ := 〈T ∗〉S∗ if T 6= λxR or S /∈ !Λ! (〈λxT 〉S!)∗ := T ∗S∗/x

Lemma 2 (Development). Let Proof p. 17T,S ∈ !Λ. If T ⇒` S, then S⇒` T ∗.

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- and dg-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. →`g is quasi-strongly confluent: `g← ·→`g⊆ (→`g · `g←)∪=.

2. →dg and→d are quasi-strongly confluent (separately).

3. →dg and→`g strongly commute: dg← ·→`g⊆→`g ·dg← .→d quasi-strongly commutes over→`: d← ·→` ⊆→` · ∗d← .→d and→` commute: ∗d← ·→∗` ⊆→∗` · ∗d← .

4. →` is confluent: ∗`← ·→∗` ⊆→∗` · ∗`← .

Proposition 4 (Quasi-strong confluence of→bg and confluence of→b). Proof p. 20

1. The reduction→bg is quasi-strongly confluent, i.e. bg← ·→bg⊆ (→bg ·bg←)∪= .

2. The reduction→b is 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 both call-by-name(CbN i.e. ordinary, [4]) and Plotkin’s call-by-value (CbV, [25]) λ -calculi can be embedded.3 Syntax andreduction rules of CbN and CbV λ -calculi are in Fig. 3: β reduction→β (resp. β v-reduction→β v) isthe 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 therestriction of→β allowing to fire a β -redex (λxT )S only when S is a λ -value, i.e. variable or abstraction.Ground β -(resp. β v-)reduction→βg

(resp.→β vg) 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.

Page 6: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

6 The Bang Calculus and the Two Girard’s Translations

λ -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: (λxt)S 7→β tS/x (CbN) (λxt)v 7→β v tv/x (CbV)

r-reduction: t→r s ⇔ ∃C ∈ ΛC, ∃ t ′,s′∈ Λ : t = CLt ′M, s = CLs′M, t ′ 7→r s′

βg-reduction: t→βgs ⇔ ∃N ∈ ΛN, ∃ t ′,s′∈ Λ : t = NLt ′M, s = NLs′M, t ′ 7→β s′

βvg -reduction: t→β v

gs ⇔ ∃V ∈ ΛV, ∃ t ′,s′∈ Λ : t = VLt ′M, s = VLs′M, t ′ 7→β v s′

Figure 3: The CbN and CbV λ -calculi: their syntax and reduction rules, where r ∈ β ,β 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);

• →β vg

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 and CbV 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 := 〈tn〉sn!

xv := x! (λx t)v := (λx tv)! (ts)v := 〈der tv〉sv .

Example 5. Let Ω := (λxxx)λxxx, the typical diverging λ -term for CbN and CbV λ -calculi: one hasΩn = 〈∆〉∆! and Ωv = 〈der(∆′!)〉∆′!, which are not bg- nor b-normalizable (∆ and ∆′ are defined in Ex. 1).

For any λ -term t, tn and tv are just different decorations of t by means of the monadic operators ! andder (the latter does not occur in tn). Note that the translation (·)n puts the argument of any applicationinto 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 (·)v into boxes, as they are the only λ -terms duplicableor discardable in CbV λ -calculus.

Lemma 6 (Substitution). Let t,s be λ -terms and x be a variable.

1. One has that tnsn/x= (ts/x)n.

2. If s is such that sv = R! for some R ∈ !Λ, then tvR/x= (ts/x)v.

Proof. The proofs of both points are by induction on the λ -term t.

1. • Variable: If t is a variable then there are two subcases. If t := x then tn = x, so tnsn/x=sn = (ts/x)n. Otherwise t := y 6= x and then tn = y, hence tnr/x= y = (ts/x)n.• Abstraction: If t := λyr then tn = λyrn and we can suppose without loss of generality

that y /∈ fv(s)∪x. By i.h., rnsn/x = (rs/x)n and hence tnsn/x = λy(rnsn/x) =λy(rs/x)n = (ts/x)n.

Page 7: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

G. Guerrieri & G. Manzonetto 7

• Application: If t := RQ, then tn = 〈rn〉qn!. By i.h., rnsn/x = (rs/x)n and qnsn/x =(qs/x)n. So, tnsn/x= 〈rnsn/x〉(qnsn/x)! = 〈(rs/x)n〉((qs/x)n)! = (ts/x)n.

2. • Variable: If t is a variable then there are two subcases. If t := x then tv = x!, so tvR/x=R! = sv = (ts/x)v. Otherwise t := y 6= x and then tv = y!, hence tvR/x= y! = (ts/x)v.• Application: If t := pq then tv = 〈der pv〉qv. By i.h., pvR/x = (ps/x)v and qvR/x =(qs/x)v. So, tvR/x= 〈der(pvR/x)〉qvR/x= 〈der(ps/xv)〉(qs/x)v = (ts/x)v.• Abstraction: If t := λyq then tv=(λyqv)! and we can suppose without loss of generality

that y /∈ fv(s)∪x. By i.h., qvR/x = (qs/x)v, and thus tvR/x = (λy(qvR/x))! =(λy(qs/x)v)! = (ts/x)v.

Note that the hypothesis about s in Lemma 6.2 is fulfilled if and only if s is a λ -value.Remark 7 (CbV translation is `-normal). It is immediate to prove by induction on t ∈Λ that tv is `-normal,so if tv→d S0→` S then the only `-redex in S0 has been created by the step tv→d S0 and is absent in tv.

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 issound and complete: said differently, the target of the CbN (resp. CbV) translation into the bang calculusis a conservative extension 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→β t ′ then tn→` t ′n (and tn→b t ′n);Completeness: Conversely, if tn→b S then tn→` S = t ′n and t→β t ′ for some λ -term t ′.

2. Conservative extension of ground CbN λ -calculus:Soundness: If t→βg

t ′ then tn→`g t ′n (and tn→bg t ′n);Completeness: Conversely, if tn→bg S then tn→`g S = t ′n and t→βg

t ′ for some λ -term t ′.

3. Conservative extension of CbV λ -calculus:Soundness: If t→β v t ′ then tv→d→` t ′v (and hence tv→b→b t ′v);Completeness: Conversely, if tv→d→` S then S = t ′v and t→β v t ′ for some λ -term t ′.

4. Conservative extension of ground CbV λ -calculus:Soundness: If t→β v

gt ′ then tv→dg→`g t ′v (and hence tv→bg→bg t ′v);

Completeness: Conversely, if tv→dg→`g S then S = t ′v and t→β vg

t ′ for some λ -term t ′.

Proof. 1. Soundness: We prove by induction on the λ -term t that if t →β t ′ then tn →` t ′n. Bydefinition of t→β t ′, there are the following cases:

• Root-step, i.e. t := (λxr)s 7→β Rs/x=: t ′: by Lemma 6.1, tn = 〈λxrn〉sn! 7→` rnsn/x= t ′n.• Abstraction, i.e. t := λxr→β λxr′ =: t ′ with r→β r′: by i.h., rn→` r′n, thus tn = λxrn→`

λxr′n = t ′n.• Application left, i.e. t := rs→β r′s =: t ′ with r→β r′: by i.h. rn→` r′n, so tn = 〈rn〉sn!→`

〈r′n〉sn! = t ′n.• Application right, i.e. t := sr→β sr′=: t ′ with r→β r′: analogous to the previous case.

Completeness: First, observe that tn→b s entails tn→` s since der does not occur in tn, hence tn isd-normal. We prove by induction on the λ -term t that if tn→` S then S = t ′n and t→β t ′ for someλ -term t ′. According to the definition of tn→` S, there are the following cases:

Page 8: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

8 The Bang Calculus and the Two Girard’s Translations

• Root-step, i.e. tn := 〈λxrn〉qn! 7→` rnqn/x =: S: by Lemma 6.1 S = (rq/x)n, so t =(λxr)q 7→β rq/x=: t ′ where t ′v = S.

• Abstraction, i.e. tn := λxrn→` λxS′ =: S with rn→` S′: by i.h., there is a λ -term r′ such thatr′n = S′ and r→β r′, thus t = λxr→β λxr′ =: t ′ where t ′n = λxr′n = S.

• Application left, i.e. tn := 〈rn〉qn!→` 〈S′〉qn! =: S with rn→` S′: analogously to above.

• Application right, i.e. tn := 〈qn〉rn!→` 〈qn〉S′!=: S with rn→` S′: by i.h., there is a λ -term r′

such that r′n = S′ and r→β r′, so t = qr→β qr′ =: t ′ with t ′n = 〈qn〉r′n!= S.

2. Since 7→β is simulated by 7→` and vice-versa (see the root-cases above), Thm. 8.2 is provedanalogously to the proof of Thm. 8.1 (→`g replaces→`, and→βg

replaces→β ), with the differencethat, by definition,→βg

and→`g do not give rise to the case Application right.

3. Soundness: We prove by induction on the λ -term t that if t→β v t ′ then tv→d→` t ′v. According tothe definition of T →β v T ′, there are the following cases:

• Root-step, i.e. t := (λxr)v 7→β v rv/x =: t ′ where v is a λ -value, i.e. a variable or anabstraction: then vv = S! for some S ∈ !Λ, hence tv = 〈der(λxrv)!〉vv →dg 〈λxrv〉vv 7→`

rvS/x= t ′v by Lemma 6.2 (recall that→dg⊆→d).

• Abstraction, i.e. t := λxr →β v λxr′ =: t ′ with r →β v r′: by i.h., rv →d→` r′v; thereforetv = (λxrv)!→d→` (λxr′v)! = t ′v.

• Application left, i.e. t := rs→β v r′s =: t ′ with r →β v r′: by i.h. rv →d→` r′v; thereforetv = 〈derrv〉sv→d→` 〈derr′v〉sv = T ′v.

• Application right, i.e. t := sr→β v sr′=: t ′ with r→β v r′: analogous to the previous case.

Completeness: We prove by induction on S0 ∈ !Λ that if tv→d S0→` S then S = t ′v and t→β v t ′

for some λ -term t ′. According to the definition of S0→` S, there are the following cases:

• Root-step, i.e. S0 := 〈λxR〉Q! 7→` RQ/x =: S. According to Rmk. 7, necessarily tv =〈der(λxR)!〉Q! and hence t =(λxr0)v for some λ -term r0 and some λ -value v such that rv0 =Rand vv = Q!. Notice that tv→dg S0. Let t ′ := r0v/x: then, t 7→β v t ′ and t ′v = rv0Q/x= Saccording to Lemma 6.2.

• Abstraction, i.e. S0 := λxR0→` λxR′ =: S with R0→` R′. This case is impossible because,according to Rmk. 7, necessarily tv = λxR for some `-normal R ∈ !Λ such that R→d R0, butthere is no λ -term t such that tv is an abstraction.

• Dereliction, i.e. S0 := derR0→` derR′ =: S with R0→` R′. This case is impossible because,according to Rmk. 7, necessarily tv = derR for some `-normal R ∈ !Λ such that R→d R0, butthere is no λ -term t such that tv is a dereliction.

• Application left, i.e. S0 := 〈R0〉R1→` 〈R′〉R1 =: S with R0→` R′. By Rmk. 7, tv = 〈derP〉R1for some `-normal P ∈ !Λ such that derP→d R0, and thus R0 = derP0 where P→d P0 (indeedP = R!

0 is impossible because P is `-normal), and hence R′ = derP′ with P0→` P′. So, t = qq1for some λ -terms q and q1 such that qv = P and qv1 = R1 with qv→d P0→` P′. By i.h., P′= q′v

and q→β v q′ for some λ -term q′. Let t ′ := q′q1: then, t = qq1→β v t ′ and t ′v = 〈derq′v〉qv1 = S.

• Application right, i.e. S0 := 〈R1〉R0→` 〈R1〉R′ =: S with R0→` R′. By Rmk. 7, necessarilytv = 〈derP1〉R for some `-normal R,P1 ∈ !Λ such that derP1 = R1 and R→d R0. So, t = q1Qfor some λ -terms q1 and q such that qv1 = P1 and qv = R with qv→d R0→` R′. By i.h., R′= q′v

and q→β v q′ for some λ -term q′. Let t ′ := q1q′: then, t = q1q→β v t ′ and t ′v = 〈derqv1〉q′v = S.

Page 9: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

G. Guerrieri & G. Manzonetto 9

target of CbN translation into !Λ: T,S ::= x | 〈T 〉S! | λxT (set: !Λn)

target of CbV translation into !Λ: M,N ::=U ! | 〈derM〉N | 〈U〉M (set: !Λv) U ::= x | λxM (set: !Λvv).

Figure 4: Targets of CbN and CbV translations into the bang calculus.

• Box, i.e. S0 := R!0→` R′! =: S with R0→` R′. According to Rmk. 7, necessarily tv = R! for

some `-normal R ∈ !Λ such that R→d R0. So, t = λxq (since tv is a box and xv is d-normal)for some λ -term q such that R = λxqv, and hence there are P0,P′ ∈ !Λ such that R0 = λxP0and R′ = λxP′ with qv→d P0→` P′. By i.h., P′ = q′v and q→β v q′ for some λ -term q′. Lett ′ := λxq′: then, t = λxq→β v t ′ and t ′v = (λxq′v)! = S.

4. Since 7→β v is simulated by→dg 7→` and vice-versa (see the root-cases above), Thm. 8.4 is provedanalogously to the proof of Thm. 8.3 (replace→` with→`g , and→d with→dg , as well as→β v

with→β vg), with the difference that→β v

gdoes not give rise to the case Abstraction (in the soundness

proof) and Box (in the completeness proof).

So, the bang calculus can simulate β - and β v-reductions via (·)n and (·)v and, conversely, `-reductionsin the targets of (·)n and (·)v correspond to β - and β v-reductions. Also, these simulations are:

• modular, in the sense that ground β -reduction (including head β -reduction and weak head β -reduction) is simulated by ground `-reduction, and vice-versa (Thm. 8.2); ground β v-reduction(including head β v-reduction) is simulated by ground d- and `-reductions, and vice-versa (Thm. 8.4);

• quantitative sensitive, meaning that one step of (ground) β -reduction corresponds exactly, via (·)n,to one step of (ground) `-reduction, and vice-versa; one step of (ground) β v-reduction correspondsexactly, via (·)v, to one step of (ground) `-reduction, and vice-versa.

According to the definition of CbN translation (·)n, the target of (·)n into the bang calculus can becharacterized syntactically: it is the subset !Λn of !Λ defined in Fig. 4. This means that tn ∈ !Λn for anyt ∈ Λ, and conversely, for any T ∈ !Λn, T n = t for some t ∈ Λ. Note that in !Λn the constructor der doesnot occur and hence reductions→` and→`g coincide with→b and→bg , respectively, in !Λn.

So, Thm. 8.1-2 says that !Λn endowed with the reduction→` (resp. →`g ) — which coincides with→b

(resp. →bg) in !Λn — is isomorphic to 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 '` sn iff tn 'b sn.

2. CbN normal forms: t is (ground) β -normal iff tn is (ground) `-normal iff tn is (ground) b-normal.

Proof. 1. If t 'β s then t→∗β

r ∗β← s for some r ∈ Λ, as→β is confluent. By Thm. 8.1 (soundness),

tn→∗` rn ∗`← sn; so, tn '` sn and tn 'b Sn since→`⊆→b.Conversely, if tn 'b sn then tn→∗b R ∗b← sn for some R ∈ !Λ, since→b is confluent (Prop. 4.2). ByThm. 8.1 (completeness), t→∗

βq ∗

β← s for some λ -term q such that qn = R, and therefore t 'β s.

2. Immediate consequence of Thm. 8.1-2.

The correspondence between CbV λ -calculus and bang calculus is slightly more delicate: CbVtranslation (·)v gives a sound and complete embedding of→β v into→d→` (and similarly for their groundvariants), but it is not complete with respect to generic →b. Indeed, Ex. 1 and Ex. 5 have shown that

Page 10: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

10 The Bang Calculus and the Two Girard’s Translations

(λxxx)v = ∆′!→d ∆!, where ∆! is b-normal and there is no λ -term t such that tv = ∆!. Note that λxxx isβ v-normal but (λxxx)v = ∆′! is not b-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 asound and complete way with respect to b-equivalence (see Cor. 12 below). The proof requires a fineanalysis of CbV translation (·)v. First, we define two subsets !Λv and !Λv

v of !Λ, see Fig. 4.

Remark 10 (Image of CbV translation). If t ∈ Λ then tv ∈ !Λv (proof by induction on t ∈ Λ). In particular,for any v ∈ Λv, vv =U ! for some U ∈ !Λv

v . Note that ∆! ∈ !Λv but there is no λ -term t such that tv = ∆!.

We have just shown that (·)v is not surjective in !Λv. Anyway, it can be shown (Lemma 11.3) that !Λv

is the set of terms in !Λ reachable by b-reduction from CbV translations of λ -terms (i.e. for any t ∈ Λ,if tv→∗b S then S ∈ !Λv) and b-equivalence in !Λv preserves βv-equivalence (Cor. 12). To prove that, wedefine a forgetful translation (·)† : !Λv∪ !Λv

v → Λ transforming terms M ∈ !Λv and U ∈ !Λvv into λ -terms:

(U !)† :=U† (〈derM〉N)† := M†N† (〈U〉M)† :=U†M† ; x† := x (λxM)† := λxM†.

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: MU/x ∈ !Λv with (MU/x)† = M†U†/x, for any M ∈ !Λv and U ∈ !Λvv .

3. b-reduction vs. β v-reduction: For any M ∈ !Λv and T ∈ !Λ, if M→b T then T ∈ !Λv and M†→=β v T †.

Rmk. 10 and Lemma 11.3 mean that !Λv is the set of terms in !Λ reachable by b-reduction from CbVtranslations of λ -terms (i.e. for any t ∈ Λ, if tv→∗b S then S ∈ !Λv). We can conclude:

Corollary 12 (Preservation of CbV equational theory). Let t,s ∈ Λ. One has t 'β v s iff tv 'b sv.

Proof. If t 'β v s then t→∗β v r ∗

β v← s for some r ∈ Λ, as→β v is confluent; by Thm. 8.3, tv→∗b rv ∗b← sv,since→`⊆→b and→d⊆→b; therefore, tv 'b sv. Conversely, if tv 'b sv then tv→∗b R ∗b← sv for someR ∈ !Λ, since→b is confluent (Prop. 4.2); by Rmk. 10, tv,sv ∈ !Λv; so, R ∈ !Λv and T v†→∗

β v R† ∗β v← sv†

by Lemma 11.3, hence t = tv† 'β v sv† = s by Lemma 11.1.

So, Cor. 12 says that CbV translation (·)v — even if it is a sound but not complete embedding ofβ v-reduction into b-reduction — is a sound and complete embedding of β v-equivalence into b-equivalence.

A final remark on the good rewriting properties of the bang calculus: the embeddings of CbN andCbV λ -calculi into the bang calculus are finer than the ones into the linear calculus λlin introduced in [20].For instance, in λlin it is impossible to define a fragment isomorphic to CbN λ -calculus; also, the CbVtranslation of the λ -calculus into λlin is sound but not complete, and equates more than β v-equivalence.Moreover, the bang calculus can be modularly extended with other reduction rules and/or syntacticconstructs so that our CbV translation embeds the extensions of CbV λ -calculus studied in [3] into thecorresponding 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 adenotational model of LL. We recall the basic definitions and notations, see [21, 13, 14] for more details.

Page 11: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

G. Guerrieri & G. Manzonetto 11

Linear logic based denotational semantics of bang calculus. A denotational model of LL is given by:

• A ∗-autonomous category, namely a symmetric monoidal closed category (L ,⊗,1,λ ,ρ,α,σ) witha dualizing object⊥. We use X (Y for the linear exponential object, ev ∈L ((X ( Y )⊗X ,Y ) forthe evaluation morphism and cur for the linear curryfication map L (Z⊗X ,Y )→L (Z,X ( Y ).We use X⊥ for the object X (⊥ of L (the linear negation of X). This operation ( )⊥ is a functorL op→L . The category L is cartesian with terminal object >, product &, projections pri. By∗-autonomy, L is cocartesian with initial object 0, coproduct ⊕ and injections ini.

• A functor ! : L →L which is:

– a comonad with counit derX ∈L (!X ,X) (dereliction) and comultiplication digX ∈L (!X , !!X)(digging), and

– a strong symmetric monoidal functor—with Seely isos m0 ∈L (1, !>) and m2X ,Y ∈L (!X⊗

!Y, !(X &Y ))—from the symmetric monoidal category (L ,&,>) to the symmetric monoidalcategory (L ,⊗,1), satisfying an additional coherence condition with respect to dig.

In order that L is also a denotational model of the bang calculus we need a further assumption:

we assume that the unique morphism in L (0,>) is an iso (to simplify, assume just 0 =>). (1)

From (1) it follows that for any two objects X and Y there is a morphism 0X ,Y := i t ∈L (X ,Y ) where tis the unique morphism X →> and i is the unique morphism 0→ Y . It turns out that this specific zeromorphism satisfies the identities f 0X ,Y = 0X ,Z = 0Y,Zg for all f ∈L (Y,Z) and g∈L (X ,Y ) . Assumption(1) is satisfied by many models of LL, like relational model [6], finiteness spaces [10], Scott model [12],(hyper-)coherence [15, 9] and probabilistic coherence spaces [8], all models based on Indexed LL [6].

A model of the bang calculus is any object U of L satisfying the identity U ∼= !U & (!U ( U )(we assume this iso to be an equality). Note that this entails both !U C U and !U ( U C U .

Given a term T and a repetition-free list of variables ~x = (x1, . . . ,xn) which contains all the freevariables of T , we can define a morphism JT K~x ∈L ((!U )⊗n,U ), the denotational semantics (or inter-pretation) of T (where (!U )⊗k :=

⊗ki=1 !U ). The definition is by induction on T ∈ !Λ:

• JxiK~x := w⊗i−1U ⊗ derU ⊗w⊗n−i

U where wU ∈L (!U ,1) is the weakening and we keep implicit themonoidality isos 1⊗U 'U ,

• JλySK~x := 〈0(!U )⊗n,!U ,cur (JSK~x,y)〉, where we assume without loss of generality y /∈ x1, . . . ,xn,

• J〈S〉RK~x := ev (pr2 JSK~x⊗pr1 JRK~x) c, where c ∈L ((!U )⊗n,(!U )⊗n⊗ (!U )⊗n) is the contraction,

• JS!K~x := 〈(JSK~x)!,0(!U )⊗n,!U (U 〉, for (JSK~x)

! = !(JSK~x)h where h ∈L ((!U )⊗n, !((!U )⊗n)) is thecoalgebra structure map of (!U )⊗n (see [13]),

• JderSK~x := derU pr1 JSK~x .

Theorem 13 (Invariance, [14]). Let T,S ∈ !Λ and~x be a repetition-free list of variables which containsall free variables of T and S. If T 'b S then JT K~x = JSK~x.

The proof of Thm. 13 uses crucially the fact that JR!K~x is a coalgebra morphism, see [13].The general notion of denotational model for the bang calculus presented here and obtained from any

denotational model L of LL satisfying the assumption (1) above is a particular case of Moggi’s semanticsof computations based on monads [22, 23], if one keeps in mind that the functor “!” defines a strongmonad on the Kleisli category L! of L .

Page 12: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

12 The Bang Calculus and the Two Girard’s Translations

Call-by-name. A model of the CbN λ -calculus is a reflexive object in a cartesian closed category. Thecategory L being ∗-autonomous, its Kleisli L! over the comonad (!,dig,der) is cartesian closed. The cate-gory L! (whose objects are the same as L and morphisms are given by L!(A,B) =L (!A,B)) has compo-sition f g defined as f !g dig and identities A given by derA. In L!, products A&B are preserved, with pro-jections πi := pri der!(A&B) (i ∈ 1,2); the exponential object A⇒ B is !A ( B (this is the semantic coun-terpart of Girard’s CbN translation) and has an evaluation morphism Ev = ev(der!A(B⊗ id!A)(m

2)−1 ∈L (!((!A ( B)&!A),B). This defines an exponentiation since for all f ∈L (!(C &A),B) there is a uniquemorphism Λ( f ) = cur( f m2) ∈L (!C, !A ( B) satisfying Ev 〈Λ( f ),A〉= f .

The identity U = !U & (!U ( U ) entails !U (U CU in L via lam := 〈0!U (U ,!U , id!U (U 〉 ∈L (!U (U ,U ) and app := pr2 ∈L (U , !U (U ), since app lam= id!U (U . So, U is a reflexive ob-ject (i.e. !U (U CU ) in L! via appn := der!U (U !app ∈L!(U , !U (U ) and lamn := derU !lam ∈L!(!U ( U ,U ), since appn lamn = !U ( U . Therefore, the interpretation of a λ -term t can bedefined as usual as a morphism |t|n~x ∈L!(U k,U ), with~x = (x1, . . . ,xk) such that fv(t)⊆ x1, . . . ,xk:

|xi|n~x := πki , |λy t|n~x := lamn Λ(|t|n~x,y), |ts|n~x := Ev 〈appn |t|n~x , |s|

n~x〉.

Summing up, the object U provides both a model of the bang calculus and a model of the CbN λ -calculus. The relation between the two is elegant: the semantics |t|n in the CbN model of the λ -calculus of aλ -term t decomposes into the semantics J·K in the model of the bang calculus of the CbN translation tn of t.Theorem 14 (Factorization of any CbN semantics). For every λ -term t, JtnK~x = |t|n~x (up to Seely’s isos).

Proof. Below we use ∼= to transform a morphism f ∈L ((!U )⊗k,U ) into a morphism g ∈L!(U k,U )using Seely’s isos (where U k :=

˘ki=1 U ). We proceed by induction on t ∈ Λ.

• If t := xi then tn = xi, so we have JtnK~x = JxiK~x = w⊗i−1U ⊗ derU ⊗w⊗k−i

U∼= prk

i derU k = |xi|n~x .• If t := λys then tn = λysn.

JλysnK~x = 〈0(!U )⊗k,!U ,cur (JsnK~x,y)〉∼= 〈0(!U )⊗k,!U ,cur(|s|n~x,ym

2)〉= derU !(〈0(!U )⊗k,!U ,cur(|s|n~x,ym

2)〉)digU k

= derU !〈0!U (U ,!U , id!U (U 〉 !cur(|s|n~x,ym2)digU k

= (derU !lam)Λ(|s|n~x,y) = |λys|n~x

• If t := sr then tn = 〈sn〉(rn)!.

J〈sn〉(rn)!K~x = ev((pr2 JsnK~x)⊗ (pr1 J(rn)!K~x))c

= ev((pr2 JsnK~x)⊗ (pr1 〈(JrnK~x)!,0

(!U )⊗k,!U (U 〉))c

= ev((pr2 JsnK~x)⊗ (JrnK~x)!)c

∼= ev((app |s|n~x)⊗ (!|r|n~x digU k))c

= ev(der!U (U !(app |s|n~x)digU k)⊗ (!|r|n~x digU k))c

= ev(der!U (U ⊗ id!U )(!(app |s|n~x)⊗ !|r|n~x)(digU k⊗digU k)c

= ev(der!U (U ⊗ id!U )m2!〈app |s|n~x , |r|n~x〉digU k

= Ev 〈der!U (U !(app |s|n~x)digU k , |r|n~x〉= Ev 〈der!U (U !app !|s|n~x digU k , |r|n~x〉= Ev 〈(der!U (U !app) |s|n~x , |r|

n~x〉= |sr|n~x

Page 13: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

G. Guerrieri & G. Manzonetto 13

Thm. 14 is a powerful result: it says not only that every LL based model of the bang calculus is alsoa model of the CbN λ -calculus, but also that the CbN semantics of any λ -term in such a model alwaysnaturally factorizes into the CbN translation of the λ -term and its semantics in the bang calculus.

Call-by-value. Following [26, 11], models of the CbV λ -calculus can be defined using Girard’s “boring”CbV translation of the intuitionistic implication into LL. It is enough to find an object X in L satisfying!X ( !X C X (or equivalently, !(X ( X) C X).4 This is the case for our object U (the model ofthe bang calculus) since !U ( U C U and !U C U entail !U ( !U C U (by the variance of!U ( ) via the morphisms lamv = 〈0!U (!U ,!U ,cur(〈ev,0(!U (!U )⊗!U ,U 〉)〉 ∈L (!U ( !U ,U ) andappv = cur(pr1 ev)pr2 ∈L (U , !U ( !U ). As in [11], we can then define the interpretation of a λ -termt as a morphism |t|v~x ∈L ((!U )⊗k, !U ), with~x = (x1, . . . ,xk) such that fv(t)⊆ x1, . . . ,xk:

|xi|v~x = w⊗i−1U ⊗ id!U ⊗w⊗k−i

U , |λy t|v~x = (lamv cur(|t|v~x,y))!, |ts|v~x = ev((appv |t|v~x)⊗ (|s|v~x))c .

We now have two possible ways of interpreting the CbV λ -calculus in our model U : either by translatinga λ -term t into tv ∈ !Λ and then compute JtvK, or by computing directly |t|v. It is natural to wonder whetherthe two interpretations JtvK and |t|v are related, and in what way. In [14] the authors conjectured that, atleast in the case of a particular relational model U satisfying U = !U ∪ (!U ×U ) = !U & (!U ( U ),the two interpretations coincide. We show that the situation is actually more complicated than expected.

The relational model U introduced in [14] admits the following concrete description as a type system.The set U of types and the set !U of finite multisets over U are defined by mutual induction as follows:

(set: U ) α,β ,γ ::= a | a ( α (set: !U ) a,b,c ::= [α1, . . . ,αk] for any k ≥ 0. (2)

Environments Γ are functions from variables to !U whose support supp(Γ) = x | Γ(x) 6= [] is finite. Wewrite x1 : a1, . . . ,xn : an for the environment Γ satisfying Γ(xi) = ai and Γ(y) = [ ] for y /∈~x. The multisetunion a+b is extended to environments pointwise, namely (Γ+∆)(x) = Γ(x)+∆(x).

On the one hand, the relational model U for the CbV λ -calculus inteprets a λ -term t using | · |v, whichgives |t|v~x = (Γ,β ) | Γ `v t :β where `v is the type system below (note that if Γ `v t : β then β ∈ !U ):

axx : a `v x : a

Γ `v t : [a(b] ∆ `v s : aapp

Γ+∆ `v ts : b

(Γi,y : ai `v t : bi)1≤i≤k k ≥ 0lam

∑ki=1 Γi `v λy t : [a1(b1, . . . ,ak(bk]

On the other hand, the relational model U for the bang calculus interprets a term T ∈ !Λ using J·K,which gives JT K~x = (Γ,β ) | Γ `! T : β where `! is the type system defined as follows:

ax!x : [α] `! x : α

Γ `! T : a(β ∆ `! S : a@

Γ+∆ `! 〈T 〉S : β

(Γi `! T : βi)1≤i≤k k ≥ 0!

∑ki=1 Γi `! T ! : [β1, . . . ,βk]

Γ `! T : [α]der

Γ `! derT : α

Γ,x : a `! T : βλ

Γ `! λxT : a ( β

In U (seen as the relational model for the bang calculus) what is the interpretation JtvK~x of the CbVtranslation tv of a λ -term t? Easy calculations show that in the type system `! the rules below — the onesneeded to interpret terms of the form tv for some λ -term t — can be derived:

axx : a `! x! : a

Γ `! tv : [a(β ] ∆ `! sv : aapp

Γ+∆ `! 〈der tv〉sv : β

(Γi,y : ai `! tv : βi)1≤i≤k k ≥ 0lam

∑ki=1 Γi `! (λy tv)! : [a1(β1, . . . ,ak(βk]

(3)

4This approach is compatible with other notions of model such as Moggi’s one [22, 23], since the functor “!” defines a strongmonad on the Kleisli category L!. The reflexive object !X ( !X C X (or equivalently, !(X ( X)C X) is the CbV version in Lof the reflexive object X ⇒ X C X in a cartesian closed category, in accordance with Girard’s CbV decomposition of the arrow.

Page 14: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

14 The Bang Calculus and the Two Girard’s Translations

Intuitively, the type system `v is obtained from the restriction of `! to the image of (·)v by substitutingarbitrary types β with multisets b of types. So, given a λ -term t, the two interpretations |t|v~x and JtvK~x canbe different: for α ∈U r !U (e.g. take α = []( [ ]), one has [([a(α]+a)(α]∈ J(λxxx)vKr |λxxx|v.

Proposition 15 (Relational semantics for CbV). In the relational model U , |t|v~x ⊆ JtvK~x for any λ -term t,with~x = (x1, . . . ,xk) such that fv(t)⊆ x1, . . . ,xk. There exists a closed λ -term s such that |s|v 6= JsvK.

Proof. We have just shown that |s|v 6= JsvK for s = λxxx. To prove that |t|v~x ⊆ JtvK~x, it is enough to show,by induction on t ∈ Λ, that x1 :a1, . . . ,xn :ak `! tv :β is derivable whenever x1 :a1, . . . ,xk :ak `v t :β is.

If t is a variable, then t = xi for some 1 ≤ i ≤ k, and tv = x!i . All the derivations for t in the type

system `v are of the formax

xi : a `v xi : a for any a ∈ !U , and in the type system `!, according to (3),ax

x : a `! x! : a is derivable.If t = sr, then tv = 〈der sv〉rv and all the type derivations for t in the type system `v are of the form

Γ `v s : [a(b] ∆ `v r : aapp

Γ+∆ `v sr : bfor any a,b ∈ !U .

By i.h., Γ `! sv : [a(β ] and ∆ `! sv : a are derivable in the type system `!, hence the following derivationis derivable in the type system `!, according to (3) since !U ⊆U

Γ `! sv : [a(b] ∆ `! rv : aapp

Γ+∆ `! 〈der sv〉rv : b .

If t = λys, then tv = (λysv)! and all the type derivations for t in the type system `v are of the form

(Γi,y : ai `v s : bi)1≤i≤k k ≥ 0lam

∑ki=1 Γi `v λy s : [a1(b1, . . . ,ak(bk]

for any a1,b1, . . . ,ak,bk ∈ !U .

By i.h., Γi,y : ai `! sv : bi is derivable in the type system `! for all 1≤ i≤ k, hence the following derivationis derivable in the type system `!, according to (3) since !U ⊆U

(Γi,y : ai `! sv : bi)1≤i≤k k ≥ 0lam

∑ki=1 Γi `! (λy sv)! : [a1(b1, . . . ,ak(bk] .

The example above of |s|v 6= JsvK shows also that in general neither JtvK~x = 〈|t|v,0〉~x nor pr1JtvK~x = |t|v~xhold in relational semantics.5 We conjecture that, for any λ -term t, |t|v~x can be obtained from JtvK~xby iterating the application of pr1 to J·K along the structure of t, but how to express this formally andcategorically for a generic model U of the bang calculus? Usually in these situations one defines a logicalrelation between the two interpretations, but this is complicated by the fact that we are in the untypedsetting so there is no type hierarchy to base our induction. We plan to investigate whether the (syntactic)logical relations introduced by Pitts in [24] can give an inspiration to define semantic logical relations inthe untyped setting. Another source of inspiration might be the study of other concrete LL based modelsof the CbV λ -calculus, such as Scott domains and coherent semantics [26, 11].

5Relational semantics interprets terms in the object U — defined in (2), where a ( α denotes the ordered pair (a,α)— ofthe category Rel of sets and relations. The cartesian product & is the disjoint union, with the empty set as terminal and initialobject >= 0, so that the zero morphism 0X ,Y for any objects X and Y is the empty relation and the projection pri is the obviousselection. Therefore, in relational semantics, 〈|t|v~x,0〉= |t|

v~x and pr1JtvK~x = JtvK~x for any λ -term t.

Page 15: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

G. Guerrieri & G. Manzonetto 15

References[1] S. Abramsky (1993): Computational Interpretations of Linear Logic. TCS 111(1&2), pp. 3–57.[2] B. Accattoli (2015): Proof nets and the call-by-value λ -calculus. TCS 606, pp. 2–24.[3] B. Accattoli & G. Guerrieri (2016): Open Call-by-Value. In: APLAS 2016, pp. 206–226.[4] H. P. Barendregt (1984): The Lambda Calculus: Its Syntax and Semantics, Studies in Logic and the Foundation

of Mathematics 103. North-Holland, Amsterdam.[5] P. N. Benton & P. Wadler (1996): Linear Logic, Monads and the Lambda Calculus. In: LICS’96, pp. 420–431.[6] A. Bucciarelli & T. Ehrhard (2001): On phase semantics and denotational semantics: the exponentials. Annals

of Pure and Applied Logic 109(3), pp. 205–241.[7] V. Danos (1990): La Logique Lineaire applique a l’etude de divers processus de normalisation (principalement

du λ -calcul). Ph.D. thesis, Universite Paris 7.[8] V. Danos & T. Ehrhard (2011): Probabilistic coherence spaces as a model of higher-order probabilistic

computation. Information and Computation 152(1), pp. 111–137.[9] T. Ehrhard (1993): Hypercoherences: A Strongly Stable Model of Linear Logic. Mathematical Structures in

Computer Science 3(4), pp. 365–385.[10] T. Ehrhard (2005): Finiteness spaces. Mathematical Structures in Computer Science 15(4), pp. 615–646.[11] T. Ehrhard (2012): Collapsing non-idempotent intersection types. In: CSL 2012, pp. 259–273.[12] T. Ehrhard (2012): The Scott model of linear logic is the extensional collapse of its relational model. Theor.

Comput. Sci. 424, pp. 20–45.[13] T. Ehrhard (2016): Call-By-Push-Value from a Linear Logic point of view. In: ESOP 2016, pp. 202–228.[14] T. Ehrhard & G. Guerrieri (2016): The Bang Calculus: an untyped lambda-calculus generalizing call-by-name

and call-by-value. In: PPDP’16, ACM, pp. 174–187.[15] J.-Y. Girard (1987): Linear Logic. Theoretical Computer Science 50(1), pp. 1–102.[16] O. Laurent (2003): Polarized proof-nets and λ µ-calculus. Theoretical Computer Science 290(1), pp. 161–188.[17] P. B. Levy (1999): Call-by-Push-Value: A Subsuming Paradigm. In: TLCA’99, pp. 228–242.[18] P. B. Levy (2006): Call-by-push-value: Decomposing call-by-value and call-by-name. Higher-Order and

Symbolic Computation 19(4), pp. 377–414.[19] P. Lincoln & J. C. Mitchell (1992): Operational aspects of linear lambda calculus. In: Proceedings of the

Seventh Annual Symposium on Logic in Computer Science (LICS ’92), IEEE Computer Society, pp. 235–246.[20] J. Maraist, M. Odersky, D. N. Turner & P. Wadler (1999): Call-by-name, Call-by-value, Call-by-need and the

Linear lambda Calculus. Theoretical Computer Science 228(1-2), pp. 175–210.[21] P.-A. Mellies (2009): Categorical semantics of linear logic. In: Interactive models of computation and

program behaviour, Panoramas et Syntheses 27, Societe Mathematique de France.[22] E. Moggi (1989): Computational Lambda-Calculus and Monads. In: Proc. of the Fourth Annual Symposium

on Logic in Computer Science (LICS ’89), pp. 14–23.[23] E. Moggi (1991): Notions of Computation and Monads. Inf. Comput. 93(1), pp. 55–92.[24] A. M. Pitts (1993): Computational Adequacy via ”Mixed” Inductive Definitions. In: MFPS’93, pp. 72–82.[25] G. D. Plotkin (1975): Call-by-name, call-by-value and the λ -calculus. TCS 1(2), pp. 125–159.[26] A. Pravato, S. Ronchi Della Rocca & L. Roversi (1999): The call-by-value λ -calculus: a semantic investigation.

Mathematical Structures in Computer Science 9(5), pp. 617–650.[27] L. Regnier (1992): Lambda calcul et reseaux. Ph.D. thesis, Universite Paris 7.[28] S. Ronchi Della Rocca & L. Roversi (1997): Lambda Calculus and Intuitionistic Linear Logic. Studia Logica

59(3), pp. 417–448.[29] M. Takahashi (1995): Parallel Reductions in lambda-Calculus. Inf. Comput. 118(1), pp. 120–127.

Page 16: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

16 The Bang Calculus and the Two Girard’s Translations

A Technical appendix: omitted proofs

The enumeration of propositions, theorems, lemmas already stated in the body of the article is unchanged.

A.1 Omitted proofs and remarks of Section 2

Let n ∈ N and T,S1, . . . ,Sn ∈ !Λ and x1, . . . ,xn ∈ V ar. The substitution of S1, . . . ,Sn for x1, . . . ,xn in T isthe term TS1/x1, . . . ,Sn/xn defined by induction on T ∈ !Λ as follows:

xiS1/x1, . . . ,Sn/xn := Si for all 1≤ i≤ n

yS1/x1, . . . ,Sn/xn := y with y /∈ x1, . . . ,xn(λyT )S1/x1, . . . ,Sn/xn := λyTS1/x1, . . . ,Sn/xn with y /∈

n⋃i=1

fv(Si)∪xi

(〈T 〉R)S1/x1, . . . ,Sn/xn := 〈TS1/x1, . . . ,Sn/xn〉RS1/x1, . . . ,Sn/xn(T !)S1/x1, . . . ,Sn/xn := (TS1/x1, . . . ,Sn/xn)!

(derT )S1/x1, . . . ,Sn/xn := der(TS1/x1, . . . ,Sn/xn)

Lemma 16 (Composition of substitution). Let T,S,R ∈ !Λ and x,y ∈ V ar. If y /∈ fv(R)∪ x thenTS/yR/x= TR/xSR/x/y.

Proof. By straightforward induction on T ∈ !Λ.

Remark 17 (Reflexive-transitive closure of parallel `-reduction). It is immediate to check that ⇒` isreflexive and→`⊆⇒`⊆→∗` , whence⇒∗` =→∗` .

Lemma 18 (Substitution Lemma for parallel `-reduction). Let T,S,R,Q ∈ !Λ and x ∈ V ar. If T ⇒` Sand R⇒` Q, then TR/x⇒` SQ/x.

Proof. By induction on the derivation of T ⇒` S. Let us consider its last rule r.If r = var, then there are two sub-cases:

• either T = S = y 6= x and then TR/x= y = SQ/x, therefore TR/x⇒` SQ/x by applyingthe rule var;

• or T = x = S and then TR/x= R⇒` Q = SQ/x by hypothesis.

If r = !, then T = T ′!⇒` S′! = S with T ′⇒` S′. By induction hypothesis, T ′R/x⇒` S′R/x andhence S = Q!⇒` (R∗)! = T ∗ (apply the rule !).

The cases where r = λ and r = der are analogous to the previous one.If r = `, then T = 〈λyT1〉T !

2 ⇒` S1S2/y = S with T1 ⇒` S1 and T2 ⇒` S2 as conclusions ofsub-derivations. We can suppose without loss of generality that y /∈ fv(R)∪ x. By induction hy-pothesis, T1R/x ⇒` S1R/x and T2R/x ⇒` S2R/x, so TR/x = 〈λyT1R/x〉(T2R/x)!⇒`

S1R/xS2R/x/y= S1S2/yR/x= SR/x by applying the rule ` and Lemma 16.Finally, if r = @, then there are two subcases:

• either T = 〈R〉Q and S = 〈R′〉Q′ with R⇒` R′, Q⇒` Q′, and R 6= λxP or Q /∈ !Λ!; by inductionhypothesis, R′⇒` R∗ and Q′⇒` Q∗, therefore S = 〈R′〉Q′⇒` 〈R∗〉Q∗ = T ∗ (apply the rule @);

• or T = 〈λxR〉T ! and S = 〈λxQ〉S! with R⇒` Q and T !⇒` S!; by induction hypothesis, Q⇒` R∗

and S!⇒` T !∗, hence S = 〈λxQ〉S!⇒` R∗T !∗/x= T ∗ by applying the rule `.

Page 17: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

G. Guerrieri & G. Manzonetto 17

For any term T , we denote by T ∗ the term obtained by reducing all `-redexes in T simultaneously.Formally, T ∗ is defined by induction on T ∈ !Λ as follows:

x∗ := x (λxT )∗ := λxT ∗ (T !)∗ := (T ∗)! (derT )∗ := der(T ∗)

(〈T 〉S)∗ := 〈T ∗〉S∗ if T 6= λxR or S /∈ !Λ! (〈λxT 〉S!)∗ := T ∗S∗/x

Lemma 2 (Development). Let See p. 5T,S ∈ !Λ. If T ⇒` S, then S⇒` T ∗.

Proof. By induction on the derivation of T ⇒` S. Let us consider its last rule r.If r = var, then T = x = S and T ∗ = x, thus S⇒` T ∗ (apply the rule var).If r = !, then T = R! ⇒` Q! = S with R⇒` Q as premise. By induction hypothesis, Q⇒` R∗ and

hence S = Q!⇒` (R∗)! = T ∗ (apply the rule !).The cases where r = λ and r = der are analogous to the previous one.If r = `, then T = 〈λxR〉T !

1 ⇒` QS1/x = S with R⇒` Q and T1 ⇒` S1 as conclusions of sub-derivations. By induction hypothesis, Q⇒` R∗ and S1⇒` T ∗1 , hence S = QS1/x⇒` R∗T ∗1 /x= T ∗,according to Lemma 18.

Finally, if r = @, then there are two subcases:

• either T = 〈R〉Q⇒` 〈R′〉Q′ = S with R⇒` R′ and Q⇒` Q′ as premises, and R 6= λxP or Q /∈ !Λ!;by i.h., R′⇒` R∗ and Q′⇒` Q∗, therefore S = 〈R′〉Q′⇒` 〈R∗〉Q∗ = T ∗ (apply the rule @);

• or T = 〈λxR〉T !1 ⇒` 〈λxQ〉S!

1 = S with R⇒` Q and T1⇒` S1 as conclusions of sub-derivations;by i.h., Q⇒` R∗ and S1⇒` T ∗1 , so S = 〈λxQ〉S!

1⇒` R∗T ∗1 /x= T ∗ (apply the rule `).

Lemma 2 is the key ingredient to prove the confluence of→` (Lemma 3.4), indeed it entails that⇒`,and hence→∗` by Rmk. 17, are strongly confluent.

Lemma 19 (Substitution Lemma for reductions). Let T,T ′,R ∈ !Λ, x ∈ V ar.

1. For any r ∈ `,d,b, `g,dg,bg, if T →r T ′ then TR/x→r T ′R/x.

2. For any r ∈ `,d,b, if T →r T ′ then RT/x→∗r RT ′/x.

Proof. 1. By induction on T ∈ !Λ.First, let us consider the cases where r ∈ `g,dg,bg. T cannot be a box because boxes are r-normal.Therefore, there are only the following cases:

• Root-step, i.e. T 7→r T ′ where r ∈ `,d,b. Since 7→b= 7→d ∪ 7→`, there are only two subcasesto consider:

– T := der(T ′!) 7→d T ′, so TR/x= der(T ′R/x!)→d T ′R/x.– T := 〈λyQ〉S! 7→` QS/y=: T ′ and we can suppose without loss of generality that y /∈

fv(R)∪x. Note that S!R/x=(SR/x)! ∈ !Λ!, so TR/x= 〈λyQR/x〉(SR/x)!

→` QR/xSR/x/y= QS/yR/x= T ′R/x.• Dereliction, i.e. T := derS→r derS′ =: T ′ with S→r S′: by induction hypothesis, SR/x→r

S′R/x and hence TR/x= der(SR/x)→r der(S′R/x) = T ′R/x.• Abstraction, i.e. T := λyS→r λyS′ =: T ′ with S→r S′: we can suppose without loss of gener-

ality that y /∈ fv(R)∪x. By i.h., SR/x→r S′R/x and hence TR/x= λy(SR/x)→r

λy(S′R/x) = T ′R/x.• Application Right, i.e. T := 〈Q〉S→r 〈Q〉S′ =: T ′ with S→r S′. By i.h., SR/x→r S′R/x

and hence TR/x= 〈QR/x〉(SR/x)→r 〈QR/x〉(S′R/x) = T ′R/x.

Page 18: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

18 The Bang Calculus and the Two Girard’s Translations

• Application Left, i.e. T := 〈S〉Q→r 〈S′〉Q =: T ′ with S→r S′: analogous to the previous case.

Now, let us consider the case where r ∈ `, !,b. The poof is perfectly analogous to the one above,the only novelty is a new case:

• Box, i.e. T := S!→r S′! =: T ′ with S→r S′: by induction hypothesis, S′R/x →r S′R/xand hence TR/x= (SR/x)!→r (S′R/x)! = T ′R/x.

2. Concerning r = `, from T →` T ′ it follows that T ⇒` T ′ by Remark 17. According to Lemma 18(since R⇒` R by reflexivity of ⇒`), RT/x ⇒` RT ′/x and hence RT/x →∗` RT ′/x byRemark 17 again.

Concerning r = d, the proof is by straightforward induction on R ∈ !Λ.

Concerning r = b, we have just proved that RT ′/x →∗` RT ′/x and RT/x →∗d RT ′/x,therefore we are done because→b=→` ∪→d.

The next lemma lists a series of properties of `-, `g-, d- and dg-reductions that will be used to provestrong confluence of→bg and confluence of→b (Prop. 4).

Lemma 3 (Basic properties of reductions).See p. 5

1. →`g is strongly confluent (i.e. `g← ·→`g ⊆ (→`g · `g←)∪=).

2. →dg and→d are strongly confluent (separately).

3. →dg and→`g strongly commute (i.e. dg← ·→`g ⊆→`g ·dg←).

→d quasi-strongly commutes over→` (i.e. d← ·→` ⊆→` · ∗d←).

→d and→` commute (i.e. ∗d← ·→∗` ⊆→∗` · ∗d←).

4. →` is confluent.

Proof. 1. Let T,T1,T2 ∈ !Λ be such that T1 `g← T →`g T2 and T1 6= T2: we prove by induction onT ∈ !Λ that T1→`g T ′ `g← T2 for some T ′ ∈ !Λ. Since→`g does not reduce under !, there are onlythe following cases:

• Root-step for T →`g T1 and non-root-step for T →`g T2, i.e. T := 〈λxS〉R! 7→` SR/x=: T1and T 67→` T2. Note that R! is `g-normal since→`g does not reduce under !, hence the factthat T →`g T2 via a non-root-step implies that T2 := 〈λxQ〉R! and S→`g Q. By Lemma 19.1,T1→`g QR/x `g← T2.• Dereliction for both T →`g T1 and T →`g T2, i.e. T1 := derS1 `g← T →`g derS2 =: T2 with

T := derS and S1 `g← S→`g S2. By induction hypothesis, there exists S′ ∈ !Λ such thatS1→`g S′ `g← S2, whence T1→`g derS′ `g← T2.• Abstraction for both T →`g T1 and T →`g T2, i.e. T1 := λxS1 `g← T →`g λxS2 =: T2 with

T := λxS and S1 `g← S→`g S2: analogous to the previous case.• Application left for both T →`g T1 and T →`g T2, i.e. T1 := 〈S1〉R `g← T →`g 〈S2〉R =: T2

with T := 〈S〉R and S1 `g← S→`g S2. By induction hypothesis, there exists S′ ∈ !Λ such thatS1→`g S′ `g← S2, whence T1→`g 〈S′〉R `g← T2.• Application right for both T →`g T1 and T →`g T2, i.e. T1 := 〈R〉S1 `g← T →`g 〈R〉S2 =: T2

with T := 〈R〉S and S1 `g← S→`g S2: analogous to the previous case.• Application left for T →`g T1 and Application Right T →`g T2, i.e. T := 〈S〉R and T1 :=〈S′〉R `g← T →`g 〈S〉R′ =: T2 with S→`g S′ and R→`g R′. Then, T1→`g 〈S′〉R′ `g← T2.

Page 19: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

G. Guerrieri & G. Manzonetto 19

2. We prove that→d is strongly confluent; the proof of strong confluence of→dg is analogous (andwithout the cases box and root-step). Let T,T1,T2 ∈ !Λ be such that T1 d← T →d T2 and T1 6= T2:we prove by induction on T ∈ !Λ that T1→d T ′ d← T2 for some T ′ ∈ !Λ. Cases:

• Root-step for T →d T1 and non-Root-step for T →d T2, i.e. T := der(T !1 ) 7→d T1 and T →d

der(S!) =: T2 with T1→d S. Then, T1→d Sd← T2.• Dereliction for both T →d T1 and T →d T2, i.e. T := derS and T1 := derS1 d← T →d derS2 =:

T2 with S1 d← S→d S2. By induction hypothesis, there exists S′ ∈ !Λ such that S1→d S′ d← S2,whence T1→d derS′ d← T2.• Abstraction for both T→d T1 and T→d T2, i.e. T := λxS and T1 := λxS1 d←T→d λxS2 =: T2

with S1 d← S→d S2: analogous to the previous case.• Box for both T →d T1 and T →d T2, i.e. T1 := S!

1 d← T →d S!2 =: T2 with T := S! and

S1 d← S→d S2: analogous to the previous case.• Application Left for both T →d T1 and T →d T2, i.e. T := 〈S〉R and T1 := 〈S1〉R d← T →d

〈S2〉R =: T2 with S1 d← S→d S2. By induction hypothesis, there exists S′ ∈ !Λ such thatS1→d S′ d← S2, whence T1→d 〈S′〉Rd← T2.• Application Right for both T →d T1 and T →d T2, i.e. T := 〈R〉S and T1 := 〈R〉S1 d← T →d

〈R〉S2 =: T2 with S1 d← S→d S2: analogous to the previous case.• Application Left for T →d T1 and Application Right for T →d T2, i.e. T := 〈S〉R and T1 :=〈S′〉Rd← T →d 〈S〉R′ =: T2 with S→d S′ and R→d R′. Then, T1→d 〈S′〉R′ d← T2.

3. First we show that→`g and→dg strongly commute. Let T,T1,T2 ∈ !Λ be such that T1 dg← T →`g T2:we prove by induction on T ∈ !Λ that there exists T ′ ∈ !Λ such that T1→`g T ′ dg← T2. Since→`g

and→dg do not reduce under !, the only interesting case is the following:

• Root-step for T →`g T2 and non-Root-step for T →dg T1, i.e. T := 〈λxS〉R! 7→`g SR/x=: T2and T →dg 〈λxS′〉R! =: T1 with S→dg S′ (recall that R! is dg-normal, so T →dg T1 impliesS→dg S′ by necessity). By Lemma 19.1, T1→`g S′R/xdg← T2.

The other cases are analogous to the ones in the proof of Lemma 3.1 not involving root-steps,paying attention that now the induction hypothesis is different.

Now we show that→d quasi-strongly commutes over→`, i.e. d← ·→` ⊆→` · ∗d← . This impliesthat→` and→d commute. Let T,T1,T2 ∈ !Λ be such that T1 d← T →` T2: we prove by inductionon T ∈ !Λ that T1→` T ′ ∗d← T2 for some T ′ ∈ !Λ. The only interesting cases are the following:

• Root-step for T →d T1 and non-Root-step for T →` T2, i.e. T := der(T !1 ) 7→d T1 and T →`

der(T ′!) =: T2 with T1→` T ′. Then, T1→` T ′ d← T2.• Root-step for T →` T2 and non-Root-step for T →d T1. There are two subcases:

– T := 〈λxS〉R!→d 〈λxS′〉R! =: T1 and T 7→` SR/x =: T2 with S→d S′. Then, T1→`

S′R/xd← T2 by Lemma 19.1.– T := 〈λxS〉R!→d 〈λxS〉R′! =: T1 and T 7→` SR/x =: T2 with R→d R′. Then, T1→`

SR′/x ∗d← T2 according to Lemma 19.2.

The other cases are analogous to the ones in the proof of Lemma 3.2 not involving root-steps,paying attention that now the inductive hypothesis is different.

4. Lemma 2 entails that⇒` is strongly confluent: indeed, if S `⇐ T ⇒` R then S⇒` T ∗ `⇐ R. There-fore,⇒` is confluent, that is⇒∗` is strongly confluent. But⇒∗` =→∗` according to Rmk. 17. So,→`

is confluent.

Page 20: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

20 The Bang Calculus and the Two Girard’s Translations

Proposition 4 (Strong confluence of→bg and confluence of→b).See p. 5

1. The reduction→bg is strongly confluent, i.e. bg← ·→bg⊆ (→bg ·bg←)∪= .

2. The reduction→b is confluent: ∗b← ·→∗b ⊆→∗b · ∗b← .

Proof.

1. Since→dg and→`g are strongly confluent (Lemmas 3.1-2) and strongly commute (Lemma 3.3), itfollows immediately that→dg ∪→`g is strongly confluent, where by definition→bg =→dg ∪→`g .

2. Since→d and→` are confluent (Lemmas 3.2 and 3.4) and commute (Lemma 3.3),→d ∪→` isconfluent by Hindley-Rosen Lemma [4, Lemma 3.3.5], where by definition→b=→d ∪→`.

A.2 Omitted proofs and remarks of Section 3

Lemma 11 (Properties of the forgetful translation (·)†).See p. 10

1. (·)† is a right-inverse of (·)v: For every t ∈ Λ, one has tv† = t.

2. (·)† preserves substitution: MU/x ∈ !Λv with (MU/x)† = M†U†/x, and U ′U/x ∈ !Λvv

with (U ′U/x)† =U ′†U†/x, for any M ∈ !Λv and U,U ′ ∈ !Λvv .

3. (·)† maps b-reduction into β v-reduction: For any M ∈ !Λv, U ∈ !Λvv and T,S ∈ !Λ, if M→b T then

T ∈ !Λv and M†→=β v T †; if U →b S then S ∈ !Λv

v and U†→=β v S†.

Proof. Statements of Lemmas 11.2-3 proved here are slightly stronger than in p. 10, to get the right i.h.

1. Proof by induction on t ∈ Λ. Cases:

• Variable, i.e. t := x, then tv = x! and hence tv† = x = t.• Abstraction, i.e. t := λxs for some s ∈ Λ, then tv = (λxsv)!. By i.h., sv† = s and hence

tv† = λxsv† = λxs = t.• Application, i.e. t := sr with s,r ∈ Λ, then tv= 〈dersv〉rv. By i.h., sv† = s and Rv† = R, so

tv†= sv†rv† = sr = t.

2. Proof by mutual induction on M ∈ !Λv and U ′ ∈ !Λvv . Cases:

• Variable, i.e. U ′ := y. There are two subcases:– either y = x and then U ′U/x = U ∈ !Λv

v and U ′† = x, hence (U ′U/x)† = U† =U ′†U†/x;

– or y 6= x and then U ′U/x= y ∈ !Λvv and U ′† = y, thus (U ′U/x)† = y =U ′†U†/x.

• Abstraction, i.e. U ′ := λyN. We can suppose without loss of generality that y /∈ fv(U)∪x,hence U ′U/x= λyNU/x ∈ !Λv

v (since NU/x ∈ !Λvv by i.h.) and U ′† = λyN†. By i.h.,

(NU/x)† = N†U†/x. So, (U ′U/x)† = λy(NU/x)† = λyN†U†/x=U ′†U†/x.• Box, i.e. M :=U ′!. Then, MU/x= (U ′U/x)! ∈ !Λv (since U ′U/x ∈ !Λv

v by i.h.) andM† = U ′†. By i.h., (U ′U/x)† = U ′†U†/x. Therefore, (MU/x)† = (U ′U/x)† =U ′†U†/x= M†U†/x.• Application without top-level dereliction, i.e. M := 〈U ′〉N. So, MU/x= 〈U ′U/x〉NU/x∈ !Λv (as U ′U/x ∈ !Λv

v and NU/x ∈ !Λv by i.h.) and M† =U ′†N†. By i.h., (U ′U/x)† =U ′†U†/x and (NU/x)† = N†U†/x. Therefore, (MU/x)† = (U ′U/x)†(NU/x)†

=U ′†U†/xN†U†/x= M†U†/x.

Page 21: lipn.univ-paris13.frgmanzonetto/papers/GG18.pdf · Submitted to: TLLA/Linearity 2018 c G. Guerrieri & G. Manzonetto This work is licensed under the Creative Commons Attribution License

G. Guerrieri & G. Manzonetto 21

• Application with top-level dereliction, i.e. M := 〈derN〉L. Then, M† = N†L† and MU/x=〈derNU/x〉LU/x ∈ !Λv (since NU/x,LU/x ∈ !Λv). By induction hypothesis,(NU/x)† = N†U†/x and (LU/x)† = L†U†/x. Therefore,

(MU/x)† = (NU/x)†(LU/x)† = N†U†/xL†U†/x= M†U†/x.

3. Proof by mutual induction on M ∈ !Λv and U ∈ !Λvv . Since there is neither M = derR nor U = derR,

there are only the following cases:

• Root-step, i.e. M 7→b T . As 7→b= 7→d ∪ 7→`, there are two cases to consider. The case M 7→d Tis impossible since there is no M = derR ∈ !Λv. It remains only one case for the root-step:M := 〈λxN〉U ! 7→` NU/x=: T . Notice that U† is λ -value, i.e. a variable or an abstraction.Then, by Lemma 11.2, T ∈ !Λv and M† = (λxN†)U† 7→β v N†U†/x= (NU/x)† = T †.• Box, i.e. M := U ! →b S! =: T with U →b S. By i.h., S ∈ !Λv

v and U† →=β v S†. Hence,

M† =U†→=β v S† = T †.

• Application left, i.e. M := 〈R〉N→b 〈R′〉N =: T with R→b R′. There are three subcases:– either R := der(U !) 7→d U =: R′, and then T = 〈U〉N ∈ !Λv with M† = (der(U !))†N† =

U†N† = T † (in particular, M†→=β v T †);

– or R := derL→b derS =: R′ with L→b S, and then S ∈ !Λv with L†→=β v S† by i.h., so

T = 〈derS〉R ∈ !Λv and M† = L†N†→=β v S†N† = T †;

– or R := U →b S =: R′ with U →b S, and then S ∈ !Λvv and U† →=

β v S† by i.h., thusT = 〈S〉N ∈ !Λv and M† =U†N†→β v S†N† = T †.

• Application right, i.e. M := 〈R〉N→b 〈R〉S =: T where N→b S and either R :=U or R := derL.By i.h., S ∈ !Λv and N† →=

β v S†. Therefore, either T = 〈U〉S ∈ !Λv and M† = U†N† →=β v

U†S† = T †, or T = 〈derL〉S ∈ !Λv and M† = L†N†→=β v L†S† = T †.

• Abstraction, i.e. U := λxN →b λxR =: S with N →b R. By i.h., R ∈ !Λv and N† →=β v R†.

Hence, S ∈ !Λvv and U† = λxN†→=

β v λxR† = S†.