The stack calculus
DD. Kesner and P. Viana (Eds.): LSFA 2012EPTCS 113, 2013, pp. 93–108, doi:10.4204/EPTCS.113.10 c (cid:13)
A. Carraro, T. Ehrhard, A. SalibraThis work is licensed under theCreative Commons Attribution License.
The stack calculus
Alberto Carraro
PPS, Universit´e Denis Diderot Paris, France [email protected]
Thomas Ehrhard
PPS, Universit´e Denis Diderot Paris, France [email protected]
Antonino Salibra
DAIS, Universit`a Ca’ Foscari Venezia, Italia [email protected]
We introduce a functional calculus with simple syntax and operational semantics in which the calculiintroduced so far in the Curry–Howard correspondence for Classical Logic can be faithfully encoded.Our calculus enjoys confluence without any restriction. Its type system enforces strong normalizationof expressions and it is a sound and complete system for full implicational Classical Logic. Wegive a very simple denotational semantics which allows easy calculations of the interpretation ofexpressions.
The Curry–Howard correspondence [16] was first designed as the isomorphism between natural deduc-tion for minimal Intuitionistic Logic [28] and the simply typed l -calculus, and for a long time no onethought this isomorphism could be extended to Classical Logic, until Griffin [14] proposed that naturaldeduction for Classical Logic could be viewed as a type system for a l -calculus extended with a con-trol operator C , introduced by Felleisen in his l C -calculus [10]. There are also other operators thatcorrespond to logical axioms that, once added to minimal Intuitionistic Logic, give proof systems ofdifferent power, from minimal to full implicational Classical Logic. Felleisen’s C , corresponding to the Double-Negation Elimination law , gives full implicational Classical Logic; less powerful operators are K (a.k.a. call / cc ), typable with Peirce’s law , and A (a.k.a. abort ) typable with the Ex-Falso Quodlibetlaw . On the programming side, this classification corresponds to the different expressive power of theoperators as control primitives. Ariola and Herbelin [1] survey and classify these logical systems andintroduce a refinement of l C -calculus which aims at resolving a mismatch between the operational andproof-theoretical interpretation of Felleisen’s l C -reduction theory.Another extension of the l -calculus is Parigot’s lm -calculus [27] which introduces a Natural Deduc-tion with multiple conclusions. This system implements minimal Classical Logic and it is able to encodethe primitive call / cc ; Ariola and Herbelin [1] extend it to cover full Classical Logic and compare theirsystem with Felleisen’s l C -calculus: similar studies are made by De Groote [7]. The correspondencebetween classical principles and functional control operators is further stressed by De Groote’s extensionof l -calculus with raise/handle primitives [8]. While the untyped version of lm -calculus enjoys con-fluence, its extensional version is only confluent on closed terms via the addition of a rewrite rule thatdestroys the strong normalization of typable terms [6].Gentzen’s sequent calculus LK [11] is put in correspondence with a reduction system by Urban [32];the type system of Curien–Herbelin’s ¯ lm ˜ m -calculus [3] corresponds to its implicational fragment. Thesetwo approaches are compared in detail by Lengrand [24]. These calculi highlight the duality betweencall-by-value and call-by-name cut-elimination (or evaluation): confluence is not achievable without4 Thestack calculuschoosing one of the two strategies. Other computational interpretations of Classical sequent calculusare Girard’s LC [13] and the translations of Classical Logic in Linear Logic [5], based upon linear dualdecomposition of classical implication.In this paper we introduce the stack calculus . The idea of this calculus comes from a synthesis ofKrivine’s extension of the l -calculus with stacks and call / cc [18] with Parigot’s lm -calculus. It alsobears similarities with the call-by-name variant of ¯ lm ˜ m -calculus. In Krivine’s Classical Realizability[18] classical implication is associated to a stack constructor, while in lm -calculus (as in l C -calculus)the arrow-type is introduced by an intuitionistic l -abstraction: the role of the m -abstraction is to make itclassical by “merging together” many intuitionistic arrows. The m -abstraction can then be thought of as afunctional abstraction over lists of inputs , corresponding to a list of consecutive l -abstractions. This ideais used in the design of L ¨ow–Streicher’s CPS ¥ -calculus [25] which is an infinitary version of l -calculusthat allows only infinite abstractions and infinite applications.The stack calculus is a finitary functional language in which stacks are first-class entities, and manyof the previously-mentioned calculi can be faithfully translated. The stack calculus enjoys confluencewithout any restriction, also in its extensional version. We type the stack calculus with a propositionallanguage with implication and falsity, to be associated to stack construction and empty stack, respec-tively. As a consequence one obtains a sound and complete system for full implicational Classical Logic.In our case the realizability interpretation of types `a la Krivine matches perfectly the logical meaningof the arrow in the type system: proofs of soundness and strong normalization of the calculus are bothgiven by particular realizability interpretations. The simplicity of the stack calculus, which does notuse at the same time l - and m -abstractions allows an easy encoding of control primitives like call / cc , label / resume , raise / catch .Many researchers contributed to the study of proof semantics of Classical Logic. From Girard [13], toReus and Streicher [29], to Selinger [30] who gives a general presentation in terms of control categories .It is also very interesting the work by Laurent and Regnier [23] which shows in detail how to extract acontrol category out of a categorical model of Multiplicative Additive Linear Logic (MALL).Inspired by Laurent and Regnier’s work [23] we give a minimal framework in which the stack cal-culus can be soundly interpreted. The absence of the l -abstraction, allows us to focus on the minimalstructure required to interpret Laurent’s Polarized Linear Logic [21] and to use it to interpret the stackcalculus. The simplicity of the framework gives an easy calculation of the semantics of expressions. The stack calculus has three syntactic categories: terms that are in functional position, stacks that arein argument position and represent streams of arguments, processes that are terms applied to stacks.The basis for the definition of the stack calculus language is a countably infinite set of stack variables ,ranged over by the initial small letters a , b , g , . . . of the greek alphabet. The language is then given bythe following grammar: p , v :: = a | nil | M (cid:5) p | cdr ( p ) stacks M , N :: = ma . P | car ( p ) terms P , Q :: = M ⋆ p processesWe use letters E , E ′ to range over expressions which are either stacks, terms or processes. We denote by S p , S s , S t , and S e the sets of all processes, stacks, terms, and expressions respectively. The operator m is.Carraro, T.Ehrhard, A.Salibra 95a binder. An occurrence of a variable a in an expression E is bound if it is under the scope of a ma ; theset FV ( E ) of free variables is made of those variables having a non-bound occurrence in E . Stacks represent lists of terms: nil is the empty stack. A stack M (cid:5) · · · (cid:5) M k (cid:5) nil , stands for a finite list whilea stack M (cid:5) · · · (cid:5) M k (cid:5) a stands for a non-terminated list that can be further extended. Terms are entities that wait for a stack to compute. A term ma . P is the m -abstraction of a in P . Processes result from the application M ⋆ p of a term M to a stack p . This application, unlike in l -calculus, has to be thought as exhaustive and gives rise to an evolving entity that does not have anyoutcome.Application has precedence over m -abstraction and the stack constructor has precedence over appli-cation, so that the term ma . M ⋆ N (cid:5) p unambiguously abbreviates ma . ( M ⋆ ( N (cid:5) p )) . As usual, the calculusinvolves a substitution operator. By E { p / a } we denote the (capture-avoiding) substitution of the stack p for all free occurrences of a in E . The symbol ‘ ≡ ’ stands for syntactic equality, while ‘: = ’ stands fordefinitional equality. Lemma 1 (Substitution Lemma) . For E ∈ S e , p , v ∈ S s , a FV ( v ) and a b we haveE { p / a }{ v / b } ≡ E { v / b }{ p { v / b } / a } . Definition 2.
The reduction rules of the stack calculus are the following ones: ( m ) ( ma . P ) ⋆ p → m P { p / a } ( car ) car ( M (cid:5) p ) → car M ( cdr ) cdr ( M (cid:5) p ) → cdr p Adding the following rules we obtain the extensional stack calculus: ( h ) ma . M ⋆ a → h M if a FV ( M )( h ) car ( p ) (cid:5) cdr ( p ) → h p We simply write → s for the contextual closure of the relation ( → m ∪ → car ∪ → cdr ) . Moreover wewrite → h for the contextual closure of the relation ( → h ∪ → h ) and finally we set → s h = ( → s ∪ → h ) .For example, if I : = ma . car ( a ) ⋆ cdr ( a ) , then I ⋆ I (cid:5) nil → s I ⋆ nil → s car ( nil ) ⋆ cdr ( nil ) and the reductiondoes not proceed further. If w : = ma . car ( a ) ⋆ a , then w ⋆ w (cid:5) nil → s w ⋆ w (cid:5) nil ; this is an example of anon-normalizing process. The stack calculus enjoys confluence, even in its extensional version, as thefollowing theorems state. Theorem 3.
The → s -reduction is Church-Rosser. Theorem 4.
The → s h -reduction is Church-Rosser. We observe that Theorem 4 holds despite the non left-linearity of the reduction rules of the exten-sional stack calculus. In other calculi, like the l -calculus with surjective pairing, the interaction of theextensionality rule with the projection rules breaks the Church-Rosser property for the calculus [17]. Many calculi have been introduced so far to extend the Curry–Howard correspondence to classical logic[14, 27, 8, 32, 3]. Since we cannot attempt to report a comparison with the stack calculus for each oneof them, so we choose probably the best known, i.e. Parigot’s lm -calculus. In this section we show how lm -calculus can be faithfully encoded into the stack calculus (in the precise sense of the forthcomingTheorem 6).6 Thestack calculusThe basis for the definition of the lm -calculus language are two (disjoint) sets l Var and m Var of l -variables and m -variables (a.k.a. names ), respectively. The names, ranged over by a , b , g , . . . , are aretaken from m Var and the usual variables, taken in l Var, are ranged over by x , y , z , . . . . The expressionsbelonging to the language of lm -calculus are often divided into two categories, terms and named terms ,produced by the following grammar: s , t :: = x | l x . t | st | ma . p terms p , q :: = [ a ] t named termsWe use letters e , e ′ to range over expressions which are either terms or named terms. We denote by L t , L p , and L e the sets of all terms, named terms and expressions, respectively.We briefly recall the operational semantics of lm -calculus. In addition to the usual capture-freesubstitution e { t / x } of a term t for a variable x in e , lm -calculus uses the renaming e { b / a } of a with b in e and the structural substitution e { s / ∗ a } that replaces all named subterms [ a ] t of e with the namedterm [ a ] ts : for example ( l y . mb . [ a ] z ) { l x . x / ∗ a } ≡ l y . mb . [ a ] z ( l x . x ) (see [27]). Note that we adopt herethe notations of David and Py [6] instead of Parigot’s original ones. The reduction relation characterizingthe lm -calculus is given by the contextual closure of the following rewrite rules: ( b ) ( l x . t ) s → b t { s / x } logical reduction ( r ) [ b ]( ma . p ) → r p { b / a } renaming ( m ) ( ma . p ) s → m ma . p { s / ∗ a } structural reduction ( q ) ma . [ a ] t → q t if a FN ( t ) The reduction → bmrq was proved to enjoy the Church-Rosser property by Parigot [27]. The extensional lm -calculus is obtained by adding the contextual closure of the following reduction rules: ( h ) l x . tx → h t if x FV ( t )( n ) ma . p → n l x . ma . p { x / ∗ a } if x FV ( p ) We are now going to translate lm -expressions into expressions of the stack calculus (stack-expressions,for short). A minor technical detail for the translation is the need of regarding all l -variables and allnames as stack variables. Definition 5.
Define a mapping ( · ) ◦ : L e → S e by induction as follows:x ◦ = mb . car ( x ) ⋆ b ( l x . t ) ◦ = m x . t ◦ ⋆ cdr ( x )( ts ) ◦ = mb . t ◦ ⋆ s ◦ (cid:5) b b FV ( t ◦ ) ∪ FV ( s ◦ )([ a ] t ) ◦ = t ◦ ⋆ a ( ma . p ) ◦ = ma . p ◦ The translation of Definition 5 preserves the convertibility of expressions and in this sense providesan embedding of lm -calculus into the stack calculus. Theorem 6.
Let e , e ′ ∈ L e .(i) If e → bmrq e ′ , then e ◦ and ( e ′ ) ◦ have a common reduct in the stack calculus.(ii) If e → bmrqhn e ′ , then e ◦ and ( e ′ ) ◦ have a common reduct in the extensional stack calculus. Note that the extensional lm -calculus does not enjoy a full Church-Rosser theorem, as witnessed bythe following counterexample [6]: [ g ] y hr և [ b ] l x . ( ma . [ g ] y ) x → m [ b ] l x . ma . [ g ] y .However these kinds of situations do not arise in the stack calculus (by Theorem 4): in this case forexample we have ([ g ] y ) ◦ ։ s car ( y ) ⋆ g s h և ([ b ] l x . ma . [ g ] y ) ◦ .For example ( l x . x ) ◦ = m x . car ( x ) ⋆ cdr ( x ) and ( call / cc ) ◦ = ma . car ( a ) ⋆ ( mb . car ( b ) ⋆ cdr ( a )) (cid:5) cdr ( a ) ,where call / cc ≡ l f . ma . [ a ]( f ( l x . md . [ a ] x )) ..Carraro, T.Ehrhard, A.Salibra 97 We are now going to look at the stack calculus in the light of the Curry–Howard isomorphism. Since thestack calculus can encode calculi with control features (such as lm -calculus), it can be given a deductivesystem of full classical implicational propositional logic ( {→ , ⊥} -fragment).The type system has judgements that come in three forms: p : A ⊢ D , ⊢ M : A | D , and ⊢ P | D , where asusual greek capital letters D , D ′ are used to denote contexts , that is sets of assumptions { a : A , . . . , a n : A n } (also abbreviated by ~ a : ~ A ). In a judgement like ⊢ M : A | D , the vertical bar separates the context D fromthe active formula A ; Theorem 9 can sharpen its role via a comparison with judgements in typed lm -calculus. ⊢ M : A | D p : B ⊢ D [ → i ] M (cid:5) p : A → B ⊢ D a : A ∈ D [ ax ] a : A ⊢ D p : A → B ⊢ D [ → e l ] cdr ( p ) : B ⊢ Dp : A → B ⊢ D [ → e r ] ⊢ car ( p ) : A | D ⊢ P | D , a : A [ m , a ] ⊢ ma . P : A | D ⊢ M : A | D p : A ⊢ D [ cut ] ⊢ M ⋆ p | D [ ⊥ i ] nil : ⊥ ⊢ D Fig 2:
Typed stack calculus - propositional {→ , ⊥} -fragment.The choice for the forms of the judgements is justified by the forthcoming Theorem 9, where itwill appear that the role of contexts is analogous to that of name contexts (i.e. right contexts) in typed lm -calculus (see Figure 3).It is very well-known that by restricting Gentzen’s sequent calculus LK [11] to manage at most oneformula on the right-hand side of sequents one gets the intuitionistic sequent calculus. On the otherhand, the symmetric restriction (which, by symmetry, is well behaved with respect to cut elimination) isnot so popular. One can find an explicit study of the induced system in Czermak [4]. In [22] Laurentstudies a slight variation of Czermak’s system, that he calls LD , and explores the logical duality between LD and its symmetrical calculus LJ . The existence of these two symmetrical (and equivalent, viaduality) systems has its roots in the dual “decomposition” of LK into Danos et. al’s [5] LKQ and
LKT systems, corresponding to call-by-value and call-by-name evaluation of classical proofs, respectively.Both systems are as powerful as LK , and LKT can be encoded into LD , in which the stoup disappears,since there is at most one formula on the left-hand side of sequents. There is a close relationship between LD , LKT and the stack calculus, but indeed while the first two are formulated as a sequent calculus (i.e.,with introduction rules only) the latter has elimination rules. One can translate both
LKT and LD intothe stack calculus (and viceversa), somewhat as Gentzen’s LK can be translated into Prawitz’s naturaldecuction [28] (and viceversa) but the translations are not mere inclusions.The judgements in stack calculus have the following intuitive logical interpretation, in terms of theclassical (boolean) notion of semantic entailment “ (cid:15) ”. For those of the form p : A ⊢ b : B , . . . , b n : B n ,read “ ¬ B , . . . , ¬ B n (cid:15) ¬ A ”; for those of the form ⊢ M : A | b : B , . . . , b n : B n , read “ ¬ B , . . . , ¬ B n (cid:15) A ”;for those of the form ⊢ P | b : B , . . . , b n : B n , read “ ¬ B , . . . , ¬ B n (cid:15) ⊥ ”. The above indications will berestated and proved precisely in Theorem 17.We now show that the reduction rules specified in Section 2 are indeed reduction rules for the proofsof the typed system.8 Thestack calculus Lemma 7 (Typed substitution lemma) . Suppose p : B ⊢ D .(i) If v : A ⊢ b : B , D , then v { p / b } : A ⊢ D (ii) if ⊢ M : A | b : B , D , then ⊢ M { p / b } : A | D (iii) if ⊢ P | b : B , D , then ⊢ P { p / b } | D . Using Lemma 7, we can prove that the reduction of a typed term preserves the type.
Theorem 8.
For all p , p ′ ∈ S s , all P , P ′ ∈ S p and M , M ′ ∈ S t we have that(i) if ⊢ P | D and P → s h P ′ , then ⊢ P ′ | D (ii) if p : A ⊢ D and p → s h p ′ , then p ′ : A ⊢ D (iii) if ⊢ M : A | D and M → s h M ′ , then ⊢ M ′ : A | D . Another way to type the stack calculus is to choose a language with negation, conjunction and falsity,to be associated to abstraction, stack construction and empty stack, respectively. This approach mirrorsthe one used by Lafont et al. [19] to type the l -calculus with explicit pair constructor and projections.The result is an intuitionistic proof system that can be seen as the target of a CPS translation that embedsClassical Logic into a fragment of Intuitionistic Logic via a mapping that transforms the types but not theproofs; this can be done by two translations ( · ) + and ( · ) − from {→ , ⊥} -formulas into {∧ , ¬ , ⊥} -formulasas follows: ⊥ + = ¬⊥ and a + = a , for every atom a ; ( A → B ) + = A − ∧ B + ; A − = ¬ A + . One obtains a“rule-per-rule” correspondence: under this point of view, the stack calculus is the target-language of aCPS translation from itself that alters the types but not the proofs, while the translation of Lafont et al.does change also the terms. The lm -calculus is endowed with a type system that is a sound and complete Natural Deduction systemfor purely implicational classical logic.The type system has judgements that come in two forms: G ⊢ lm t : A | D and G ⊢ lm p | D . On theleft-hand side, G represents a context ~ x : ~ A of assumptions for the free l -variables, while on the right-andside, D represents a context ~ a : ~ B of assumptions for the free names. G , x : A ⊢ lm t : B | D [ → i , x ] G ⊢ lm l x . t : A → B | D G ⊢ lm t : A → B | D G ⊢ lm s : A | D [ → e ] G ⊢ lm ts : B | DG ⊢ lm t : A | D [ ⊥ i ] G ⊢ lm [ a ] t | a : A , D G ⊢ lm p | b : B , D [ ⊥ e , b ] G ⊢ lm mb . p : B | D x : A ∈ G [ ax ] G ⊢ lm x : A | D Fig. 3:
Typed lm -calculus - propositional {→} -fragment.Given a context G = x : A , . . . , x n : A n and a sequence of formulas ~ C = C , . . . , C n we write G → ~ C asan abbreviation for x : A → C , . . . , x n : A n → C n . Theorem 9. (i) If G ⊢ lm t : B | D , then for all sequences ~ C of formulas we have ⊢ t ◦ : B | G → ~ C , D .(ii) If G ⊢ lm p | D , then for all sequences ~ C of formulas we have ⊢ p ◦ | G → ~ C , D . From Theorem 9 results clearly that when the l -variables are looked at as stack variables, they areendowed with a stream type of which only the type of the head is uniquely determined.Finally we observe that the empty stack nil does not appear in the translations of lm -terms. It isneeded if we want to translate the so-called lm -top calculus [1]: in fact one can naturally set ([ top ] t ) ◦ = t ◦ ⋆ nil ..Carraro, T.Ehrhard, A.Salibra 99 In this section we set up a framework which is the analogue of Krivine’s Classical Realizability [18].Krivine’s idea is to interpret implicational formulas at the same time as sets of stacks and sets of terms ofhis modified l -calculus obtaining, respectively, falsehood and truth values for the formulas. This methodhas many applications, among which the extraction of programs realizing mathematical theorems in thecontext of relevant logical theories such as Zermelo–Frenkel Set Theory and Analysis [18]. We willapply particular instances of realizability interpretation in Sections 4 and 3.3 to prove soundness andstrong normalization of our typed calculus.Let T ⊆ S t and ⊆ S s be given sets of terms and stacks, respectively, such that nil ∈ andif M ∈ T and p ∈ , then M (cid:5) p ∈ and cdr ( p ) ∈ .We define three binary relations ≻ s , ≻ t , ≻ p on S s , S t and S p , respectively, as the smallest reflexiverelations satisfying the following conditions: • ≻ s is transitive; • if M ∈ T , p ∈ and v ≻ s M (cid:5) p , then car ( v ) ≻ t M and cdr ( v ) ≻ s p ; • if p ∈ , then ( ma . P ) ⋆ p ≻ p P { p / a } ; • if M ′ ≻ t M , then M ′ ⋆ p ≻ p M ⋆ p .Moreover we let ≻ e = ≻ p ∪ ≻ s ∪ ≻ t and we say that a set X ⊆ S e is saturated if E ∈ X and E ′ ≻ e E imply E ′ ∈ X . For X ⊆ S e , we let P s ( X ) denote the family of all saturated subsets of X . Definition 10.
A triple ( | = , T , ) of sets is a realizability triple if | = ⊆ S p , T ⊆ S t , ⊆ S s are all saturated. Definition 11 (Realizability relation) . Let ( | = , T , ) be a realizability triple. We define a binary relation (cid:13) ⊆ T × P s ( ) as M (cid:13) X iff ∀ p ∈ X . M ⋆ p ∈ | = . If M (cid:13) X , we say that M realizes X , or that M is a realizer of X ; the set of realizers of X is rea ( X ) = { M ∈ T : M (cid:13) X } . We define the following binary operation on P ( S s ) as follows: X ⇒ Y = { v ∈ : ∃ M ∈ rea ( X ) . ∃ p ∈ Y . v ≻ s M (cid:5) p } .We indicate by At the set of all atomic formulas, which includes ⊥ and a countable set of atoms.We indicate by Fm the set of all formulas built from At with the connective → . We use the followingconventions: letters A , B , C , . . . range over Fm , and F , G , H , . . . range over At . We let arrows associate tothe right, so that A → B → C ≡ A → ( B → C ) . Every formula is of the form B → · · · → B n → G , where G is atomic. As usual the negation is defined as ¬ A : = A → ⊥ .Let R = ( | = , T , ) be a realizability triple. An atomic R -interpretation is a function I : At → P s ( ) such that I ( ⊥ ) = . Then I extends uniquely to a map k·k I : Fm → P ( S s ) by setting k A → B k I = k A k I ⇒ k B k I . The set k A k I is called the falsehood value of the formula A under I . The truth value | A | I of a formula A under I is given by | A | I = rea ( k A k I ) . Proposition 12.
For every formula A, k A k I ∈ P s ( ) and | A | I ∈ P s ( T ) .Proof. By induction on the structure of formulas. For falsehood values is suffices to observe that P s ( ) is closed under the ⇒ operation. For truth values, use the fact that M ′ ≻ t M implies M ′ ⋆ p ≻ p M ⋆ p andthe saturation of | = .If ~ p = p , . . . , p n and ~ B = B , . . . , B n are sequences, we write ~ p ∈ k ~ B k I as an abbreviation for p ∈ k B k I , . . . , p n ∈ k B n k I . The next theorem is the stack calculus analogue of Krivine’s AdequacyTheorem [18], which shows that realizability is compatible with deduction in classical logic. It is anessential tool that will be used to obtain, in a uniform way, both soundness and strong normalization ofthe typed calculus.00 Thestack calculus Theorem 13 (Adequacy theorem) . Let R = ( | = , T , ) be a realizability triple and let I be an R -interpretation. If ~ p ∈ k ~ B k I then(i) If v : A ⊢ ~ a : ~ B, then v { ~ p /~ a } ∈ k A k I ;(ii) If ⊢ M : A | ~ a : ~ B, then M { ~ p /~ a } ∈ | A | I ;(iii) If ⊢ P | ~ a : ~ B, then P { ~ p /~ a } ∈ | = . One proves all items simultaneously proceeding by induction on the depth of type derivations.
We are now going to prove that the typed stack calculus is strongly normalizing. We prove this fact byadapting the reducibility candidates technique to our setting. It becomes a sort of instance of Krivine’sadequacy theorem in the context of Classical Realizability. We let SN e ⊆ S e be the set of all stronglynormalizing expressions of the stack calculus (w.r.t. → s h -reduction); SN t , SN p , SN s denote the sets allstrongly normalizing terms, processes and stacks, respectively. Proposition 14. S = ( SN p , SN t , SN s ) is a realizability triple. The proof of Proposition 14 consists in showing that if E ′ ≻ e E and E ∈ SN p (resp. E ∈ SN t , E ∈ SN s ), then also E ′ ∈ SN p (resp. E ′ ∈ SN t , E ′ ∈ SN s ). One can proceed by induction on the definitionof ≻ e . The main point of such a proof is when we consider the case in which P ≡ M ⋆ p ∈ SN p and P ′ ≡ M ′ ⋆ p with M ′ ≻ t M because there there exist v and p ′ such that v ≻ s M (cid:5) p ′ and M ′ ≡ car ( v ) . Hereone can show that if M ′ ⋆ p has an infinite reduction path, then M ⋆ p has an infinite reduction path too.Note that it is crucial that for the terms M ′ ≡ ma . ( mb . b [ ] ⋆ b ) ⋆ ( mg . a [ ] ⋆ a ) (cid:5) nil and M ≡ ma . nil [ ] ⋆ nil we have M ′ t M . In fact, setting p ≡ ( md . d [ ] ⋆ d ) (cid:5) nil , we obtain that M ⋆ p is strongly normalizingbut M ′ ⋆ p is not strongly normalizing.Let A be a formula. We define its arity ar ( A ) by induction setting ar ( G ) = ar ( A → B ) = + ar ( B ) . It is convenient sometimes to use abbreviations p [ n ) : = cdr ( · · · cdr ( p ) · · · ) ( n times) and p [ n ] : = car ( p [ n )) , in order to make some expressions more readable. Theorem 15 (Strong normalization) . Let M ∈ S t , p ∈ S s and P ∈ S p .(i) If there exist D , A such that p : A ⊢ D , then p ∈ SN s ;(ii) If there exist D , A such that ⊢ M : A | D , then M ∈ SN t ;(iii) If there exist D such that ⊢ P | D , then P ∈ SN p .Proof. Let D = ~ a : ~ B , where ~ a = a , . . . , a n and ~ B = B , . . . , B n . Let I be the S -interpretation sending ev-ery atom to SN s and set p i : = a i [ ] (cid:5) . . . (cid:5) a i [ ar ( B i ) − ] (cid:5) a i [ ar ( B i )) , for each i = , . . . , n and ~ p = p , . . . , p n .An easy induction on the arity of formulas shows that ~ p ∈ k ~ B k I . By Theorem 13 (i),(ii),(iii) respectivelywe get that(i) v { ~ p /~ a } ∈ k A k I ⊆ SN s , (ii) M { ~ p /~ a } ∈ | A | I ⊆ SN t and (iii) P { ~ p /~ a } ∈ SN p .Finally in each of the above cases we have E { ~ p /~ a } ։ h E and since E { ~ p /~ a } is strongly normalizing,then so is E ..Carraro, T.Ehrhard, A.Salibra 101 The present section provides soundness and completeness proofs of the stack calculus for the two-valuedsemantics of classical propositional logic. We find interesting to report the full completeness proof,which resembles very much a completeness proof for a tableaux calculus [31]. In fact, as in a tableauxsystem there are labeled formulas (with true and false labels), in the stack calculus we have terms andstacks which play, respectively, the role of proofs and counter-proofs, exactly in the spirit of Krivine’sClassical Realizability.It is easy matter to check that B = ( /0 , S t , S s ) is a realizability triple. For every formula A and B -interpretation I we have | A | I = ( S t if k A k I = /0/0 otherwiseThe induced function | · | I maps formulas into elements of the two-element boolean algebra { S t , /0 } ,where the ordering is set-inclusion and the operators are ∪ , ∩ and complement. In other words S t represents “true” and /0 represents “false”. The truth values behave as expected w.r.t. negation: | A | I = /0 ⇔ |¬ A | I = S t . Definition 16.
Let F be a set of formulas and let A be a formula. We say that F semantically entails A,notation F (cid:15) A, if for every atomic B -interpretation I we have that T B ∈ F | B | I ⊆ | A | I . Theorem 17 (Soundness) . (i) If ⊢ M : A | ~ b : ~ B is provable (where FV ( M ) ⊆ ~ b ), then ¬ B , . . . , ¬ B n (cid:15) A.(ii) If p : A ⊢ ~ b : ~ B is provable (where FV ( p ) ⊆ ~ b ), then ¬ B , . . . , ¬ B n (cid:15) ¬ A.(iii) If ⊢ P | ~ b : ~ B is provable (where FV ( P ) ⊆ ~ b ), then ¬ B , . . . , ¬ B n (cid:15) ⊥ .Proof. (i) Let I be a B -interpretation. By Theorem 13 (Adequacy) if for all i ∈ [ , n ] k B i k I = /0, then M { ~ p /~ a } ∈ | A | I , i.e., | A | I = /0. Since k B i k I = /0 ⇔ | B i | I = /0 ⇔ |¬ B i | I = S t , we conclude that everyderivable judgement ⊢ M : A | ~ b : ~ B has the following property: for every I , if |¬ B i | I = S t for all i ∈ [ , n ] , then | A | I = S t . This means, by definition, that ¬ B , . . . , ¬ B n (cid:15) A .(ii),(iii) Similar to (i), again applying Theorem 13.The main goal of the rest of the section is to prove that every classical tautology is the type of someterm of the stack-calculus. The proof is supported by some auxiliary definitions and lemmas. Definition 18.
Let A be a formula. We define its terminal tmn ( A ) by induction setting tmn ( G ) = Gand tmn ( A → B ) = tmn ( B ) . We also define its premisses pr ( A ) by induction setting pr ( G ) = /0 and pr ( A → B ) = { A } ∪ pr ( B ) . Definition 19.
Let F be a set of formulas. We define three sets tmn ( F ) = { tmn ( A ) : A ∈ F } , pr ( F ) = S A ∈ F pr ( A ) , and prt ( F ) = { A ∈ pr ( F ) : tmn ( A ) ∈ ( tmn ( F ) ∪ {⊥} ) } . Definition 20.
A set F of formulas is saturated if for every formula A ∈ prt ( F ) we have pr ( A ) ∩ F = /0 . It will turn out that, by applying an iterative process, it is possible to construct saturated sets offormulas starting from finite sets of formulas which cannot be proved by a sequent of the stack calculus.The forthcoming Lemmas 21 and 22 are the fundamental ingredients for such construction. We write − : A | − : ~ B to express the fact that there are no variables ~ b and no term M such that ⊢ M : A | ~ b : ~ B .02 Thestack calculus Lemma 21.
Let F = { B , . . . , B n } be a finite set of formulas and suppose − : B | − : B , . . . , − : B n .Then prt ( F ) ∩ At = /0 .Proof. We prove the contrapositive statement. Supposing A ∈ prt ( F ) ∩ At , we distinguish two possiblecases: (1) and (2). We write ~ b : ~ B for the context b : B , . . . , b n : B n . Let e be a fresh variable.(1) There exist some j , k ∈ [ , n ] such that B j = C ′ → · · · → C ′ i → · · · → C ′ m ′ → G ′ , B k = C ′′ → · · · → C ′′ m ′′ → G ′′ , and C ′ i = G ′′ = A . Then ⊢ mb . ( me . b j [ i − ] ⋆ e [ m ′′ )) ⋆ b k : B | ~ b : ~ B .(2) There exist some j ∈ [ , n ] such that B j = C ′ → · · · → C ′ i → · · · → C ′ m ′ → G ′ , and C ′ i = ⊥ = A . Then ⊢ mb . ( me . b j [ i − ] ⋆ nil ) ⋆ b k : B | ~ b : ~ B . Lemma 22.
Let F = { B , . . . , B n } be a finite set of formulas and suppose − : B | − : B , . . . , − : B n .Then for every A ∈ prt ( F ) there exists a formula C ∈ pr ( A ) such that − : B | − : B , . . . , − : B n , − : C.Proof.
We prove the contrapositive statement. To this end, suppose A ∈ prt ( F ) is a formula that isa counterexample to the conclusion of the statement. First note that pr ( A ) = /0, otherwise A ∈ At , incontradiction with Lemma 21. Therefore A = C → · · · → C m → G , with m ≥
1. We write ~ b : ~ B for thecontext b : B , . . . , b n : B n .By our assumption for every i = , . . . , m ( m ≥
1) there exist M i , g i such that ⊢ M i : B | ~ b : ~ B , g i : C i and thus we derive ⊢ mg i . M i ⋆ b : C i | b : B ,~ b : ~ B for each i = , . . . , m . Moreover, since A ∈ prt ( F ) ,there are two cases:(1) there exist some k , h ∈ [ , n ] such that B h = C ′ → · · · → C ′ j → · · · → C ′ m ′ → G ′ , B k = C ′′ → · · · → C ′′ m ′′ → G ′′ , A = C ′ j , and G = G ′′ .(2) G = ⊥ and there exist some h ∈ [ , n ] such that B h = C ′ → · · · → C ′ j → · · · → C ′ m ′ → G ′ and A = C ′ j .Let e be a fresh variable. In both cases (1) and (2) there exists a stack p such that p : G ⊢ e : B k isderivable, where p is either nil or e [ ar ( B k )) .Let g , . . . , g m , d be fresh variables and let v : = ( mg . M ⋆ b ) (cid:5) . . . (cid:5) ( mg m . M m ⋆ b ) (cid:5) p . Then we finallyderive ⊢ mb . ( md . ( me . d [ j − ] ⋆ v ) ⋆ b k ) ⋆ b h : B | ~ b : ~ B .The complexity of a formula A is the total number of implications and atomic sub-formulas occurringin A . The formulas of complexity one are exactly the atomic ones. Lemma 23.
Let F be a saturated set of formulas. Then there exists a B -interpretation I such that | A | I = /0 , for all A ∈ F .Proof. The case in which F = /0 is trivial, so for the rest of the proof we assume F = /0. We define a B -interpretation I as follows: I ( G ) = ( /0 if G ∈ tmn ( F ) S t otherwiseWe now prove that | A | I = /0, for all A ∈ F . The proof is by induction on the complexity of formulas.Suppose A ∈ At . If A = ⊥ the result is obvious; otherwise, since A ∈ tmn ( F ) , we have | A | I = /0.Suppose A = C → · · · → C m → G (with m ≥ | C | I = · · · = | C m | I = S t ; (2) | G | I = /0..Carraro, T.Ehrhard, A.Salibra 103The items (1) and (2) together yield | A | I = /0.(1) For C i ∈ pr ( A ) we distinguish two cases.Suppose C i prt ( F ) . Then tmn ( C i ) is not a terminal of a formula in F . By definition of I we have | tmn ( C i ) | I = S t . We conclude observing that | C i | I ⊇ | tmn ( C i ) | I = S t .Suppose C i ∈ prt ( F ) . Then, by saturation of F , C i = C ′ → · · · → C ′ m ′ → G ′ (with m ′ ≥
1) and thereexists j ∈ [ , m ′ ] such that C ′ j ∈ F . Since C ′ j has strictly lower complexity than A , by inductionhypothesis | C ′ j | I = /0. This implies | C i | I = S t .(2) Since G ∈ tmn ( F ) ∪ {⊥} , evidently | G | I = /0 by the definition of the interpretation | · | I .Next we give the second main theorem of this section, concerning completeness. The idea of itsproof is the counter-model construction , typical of Smullyan’s analytic tableaux [31]. Theorem 24 (Completeness) . Let A be a formula and let ~ B be a sequence of formulas. If ¬ B , . . . , ¬ B n (cid:15) A, then there exist M and ~ b such that ⊢ M : A | ~ b : ~ B is provable.Proof.
We proceed to prove the contrapositive statement. Suppose − : A | − : ~ B . Then we can constructa saturated set F of formulas containing { A , B , . . . , B n } as F : = S n ≥ F n , where the family { F n } n ≥ isinductively defined as follows: • F : = { A , B , . . . , B n } ; • If prt ( F n ) = /0, then we define F n + : = F n . If prt ( F n ) = { C , . . . , C k } 6 = /0, by Lemma 22 foreach C i there exists a formula D i ∈ pr ( C i ) such that − : A | − : B , . . . , − : B n , − : D i . Let Y n = { D , . . . , D k } , where each D i is the leftmost premiss of C i having the property that − : A | − : B , . . . , − : B n , − : D i . Then we define F n + : = F n ∪ Y n .By construction F is a saturated set of formulas containing { A , B , . . . , B n } . Finally applying Lemma 23we obtain some I such that | B | I = · · · = | B n | I = | A | I = /0, meaning that ¬ B , . . . , ¬ B n A .Of course Theorem 24 implies that every classical propositional tautology (of the {→ , ⊥} -fragment)is provable by the type derivation of a term. In the present section we sketch the definition of a Krivine machine that executes the terms of stackcalculus. Similar machines have been defined by de Groote [9], Laurent [20], Reus and Streicher [29]for the lm -calculus. Using this machine we show how to encode control mechanisms like label/resume and raise/handle in the stack calculus.In order to define the states of the machine, we need the following mutually inductive definitions.A stack closure is a pair p = ( p , e ) consisting of a stack p and an environment e ; a term closure is apair m = ( M , e ) consisting of a stack p and an environment e ; an environment is a partial function (withfinite domain) from the set of stack variables to the set of stack closures. We write e [ a p ] for theenvironment e ′ which assumes the same values as e except at most on a , where e ′ ( a ) = p .A state is a pair h m , p i and the machine consists of the following (deterministic) transitions betweenstates: h ( N , e ) , p i −→ h ( p ′ [ n ] , e ′ ) , p i if a [ n ] is the ։ car , cdr -normal form of N and e ( a ) = ( p ′ , e ′ ) h ( N , e ) , p i −→ h ( M , e ′ ) , ( p , e ′ ) i if ma . M ⋆ p is the ։ car , cdr -normal form of N and e ′ = e [ a p ]
04 Thestack calculusWe let − ։ be the reflexive and transitive closure of the relation −→ . Consider a state h ( M , e ) , p i . Theclosure p is the current context of evaluation of M ; the next state may discard p and restore a contextappeared in the past. The environment e is the current state of the memory: it takes into account all sideeffects caused by the previous stages of computation. The term M is said to be in execution position andit is the current program acting on p evaluated in e . A computation is a sequence of states sequentiallyrelated by the transition rules.To explain how the stack calculus achieves the control of the execution flow, we define label/resumeand raise/handle instructions and show that the machine soundly executes them. We set lab e { M } : = mb . ( me . M ⋆ b ) ⋆ ( md . d [ ] ⋆ b ) (cid:5) b with b FV ( M ) res e { M } : = mg . e [ ] ⋆ N (cid:5) g with e , g FV ( M ) throw e { M } : = mg . e [ ] ⋆ M (cid:5) nil with e , g FV ( M ) try e { M } catch { N } : = mb . ( me . M ⋆ b ) ⋆ ( md . N ⋆ d [ ] (cid:5) b ) (cid:5) nil with b ( FV ( M ) ∪ FV ( N )) , d FV ( N ) We now discuss briefly and informally how the machine executes the above instructions.Suppose to start the machine in a state S = h ( lab e { M } , e ) , p i . If no term res e { N } ever reaches theexecution position, then the computation starting at S is equivalent to that starting at S ′ = h ( M , e ) , p i .Otherwise S − ։ n h ( mg . e [ ] ⋆ N (cid:5) g , e n ) , p n i− ։ h ( N , e n + ) , p n + i , and we notice that the computationstarting at h ( res e { N } , e n ) , p n i is equivalent to that starting at h ( N , e n + ) , p n + i .Suppose to start the machine in a state S = h ( try e { M } catch { N } , e ) , p i . If no term throw e { M ′ } ever reaches the execution position, then the computation starting at S is equivalent to that starting at S ′ = h ( M , e ) , p i . Otherwise S − ։ n h ( mg . e [ ] ⋆ M ′ (cid:5) nil , e n ) , p n i− ։ h ( N , e n + ) , ( d [ ] (cid:5) b , e n + ) i and wecan see that the exception handler N goes on with the computation, and the value M ′ returned by theexception is at use of N , since it is stored in the in the current environment e n + in a cell that is presentin the current evaluation context.We conclude remarking that all the above constructions can be typed by derived rules. Informallyone may assert that Theorem 17 and Theorem 8, together, ensure that the execution of well-typed termalways ensures that all the “resume” and “raise” instructions are always handled correctly. Girard’s correlation spaces [13] are (one of) the first denotational models of Classical Logic: they refinecoherence spaces [12] with some additional structure. Intuitively, these richer objects come with theinformation required to interpret structural rules (weakening and contraction) on the right-hand side ofsequents in classical sequent calculus. Girard’s construction hints that Classical Logic may be encodedinto Linear Logic, a result achieved by Danos et al. [5] via a dual linear decomposition of classicalimplication. In [29] the authors interpret the lm -calculus in the Cartesian closed category of “negateddomains”, i.e. the full subcategory of CPO determined by the objects of the form R A , where A is apredomain and R is some fixed domains of “responses”. The category of negated domains is a particular category of continuations [19] and categories of continuations are complete [15] for the lm -calculus, inthe sense that every equational theory for lm -calculus is given by the kernel relation of the interpreta-tion in some category of continuations. Selinger [30] gives a general presentation in terms of controlcategories , which are easily seen to subsume categories of continuations. However via a categoricalstructure theorem he also shows that every control category is equivalent to a category of continuations.This structure theorem implies the soundness and completeness of the categorical interpretation of the lm -calculus with respect to a natural CPS semantics..Carraro, T.Ehrhard, A.Salibra 105In brief, a control category is a Cartesian closed category ( C , N , ⊤ , ⇒ ) which is also a symmet-ric premonoidal category ( C , O , ⊥ ) . The binoidal functor O distributes over N and there is a naturalisomorphism s A , B , C : B A O C → ( B O C ) A in A , B and C satisfying some coherence conditions. Selingerdistinguishes a subcategory C ♯ of C , called the focus of C , which have the same objects as C but fewerarrows. On C ♯ the functor O restricts to a coproduct. It is very important to remark that in any controlcategory C there exists an isomorphism j : C ( ⊤ , B O A ) ∼ = C ♯ ( ⊥ A , B ) natural in central B (see [30] forthe details). If C is a control category we map falsity to the object ⊥ and set | A → B | = ⊥ | A | O | B | ; acontext D = ~ a : ~ A is mapped to | D | = | A | O · · · O | A n | . Then the judgements are interpreted as morphisms J p : A ⊢ D K : | A | → | D | , J ⊢ M : A | D K : ⊥ | A | → | D | and J ⊢ P | D K : ⊤ → | D | , using the coproduct struc-ture and the isomorphism j . The above intepretation is sound , in the sense that it is invariant under → s h -reduction of expressions.Very interesting is the work of Laurent and Regnier [23] which shows in detail how to extract acontrol category out of a categorical model of MALL. This constribution gives a general frameworkunder which falls the correlation spaces model construction by Girard and at the same time constitutesthe categorical counterpart of Danos–Joinet–Schellinx’s [5] call-by-name encoding of Classical logicinto Linear Logic.A ∗ -autonomous category is a symmetric monoidal category with two monoidal structures ( C , ⊗ , ) and ( C , O , ⊥ ) possessing a dualizing endofunctor ( · ) ⊥ which maps f : A → B to f ⊥ : B ⊥ → A ⊥ .Let C be a ∗ -autonomous category. When the forgetful functor from the category Mon O ( C ) (of O -monoids and O -monoid morphisms) to the category C has a right adjoint, then C is a Lafont category .We recall that the co-Kleisli category K C of a monoidal category C via a comonad ( ! , d , e ) has thesame objects as C and K C ( A , B ) = C ( ! A , B ) ; the composition of morphisms is defined using the monadstructure (see [26]).One of the main results of [23] is that if C is a ∗ -autonomous Lafont category withfinite products, then then the co-Kleisli category K C ′ of the full-subcategory C ′ of C whose objects arethe O -monoids is a control category. Inspired by Laurent and Regnier’s work [23] we give a minimal framework in which the stack calculuscan be soundly interpreted. The absence of the l -abstraction, allows us to focus on the minimal structurerequired to interpret Laurent’s Polarized Linear Logic [21] and to use it to interpret the stack calculus.Let C be a ∗ -autonomous category. We denote by r A : A → A O ⊥ , l A : A → ⊥ O A , a , g and t theusual natural isomorphisms related to the monoidal structure of ( C , O , ⊥ ) .A linear category is a symmetric monoidal category together with a symmetric monoidal comonad (( ! , m ) , d , e ) such that there are monoidal natural transformations with components e A : ! A → and d A : ! A → ! A ⊗ ! A which are coalgebra morphisms and make each free !-coalgebra a commutative ⊗ -comonoid ( ! A , d A , e A ) ; moreover d A : ! A → !! A is a comonoid morphism, for every object A .In the sequel we let C be a ∗ -autonomous linear category, so that by duality we can turn the abovedefinition in terms of a monad (( ? , m ) , d , e ) , ?-algebras and O -monoids. In this case there are monoidalnatural transformations with components w A : ⊥ → ? A and c A :? A O ? A → ? A which are ?-algebra mor-phisms and make each free ?-algebra a commutative O -monoid ( ? A , c A , w A ) ; d A :?? A → ? A is a monoidmorphism, for every object A . Under these hypotheses all ?-algebras A , being retract of a the free al-gebra ? A , have a multiplication c A , and a unit w A (see [26] for further details). The category C ? ofEilenberg-Moore algebras is symmetric monoidal, with (co)tensor product of ( A , alg A ) , ( B , alg B ) givenby ( A O B , ( alg A O alg B ) ◦ m ) and unit given by ( ⊥ , m ) . The ∗ -autonomous structure of C yields a natu-ral isomorphism L : C ( , B O A ) → C ( A ⊥ , B ) that we will use to interpret abstraction (a natural retraction06 Thestack calculus C ( , B O A ) ⊳ C ( A ⊥ , B ) would suffice anyway).Starting from a valuation that associates ?-algebras to atomic types and the object ⊥ to falsity, thearrow-types are mapped as follows: | A → B | = ? | A | ⊥ O | B | . Given a context D = ~ a : ~ A we set | D | = | A | O · · · O | A n | . Note that all types are interpreted by ?-algebras. Then the type judgements with assump-tions D can be easily interpreted as morphisms with target | D | ; for example J nil : ⊥ ⊢ D K : ⊥ → | D | isthe unit of the monoid | D | . We describe such interpretation for the particular case of the untyped stackcalculus, for which we need a ?-algebra U of C together with two ?-algebra morphisms La :? U ⊥ O U → U and Ap : U → ? U ⊥ O U satisfying Ap ◦ La = id ? U ⊥ O U and a ?-algebra morphism J : U → ⊥ (needed forthe stack nil ). We write U n for the n -fold O -product of U . Such product inherits a ?-algebra structure alg U n defined using the algebra alg U and the monoidality of the monad; as a consequence it also inheritsa multiplication c U n and a unit w U n . We also define i jn : U ∼ = ⊥ j − O U O ⊥ n − j w U j − O id U O w Un − j −−−−−−−−−−−→ U n .For all expressions E with FV ( E ) ⊆ ~ a we define the interpretation J M K ~ a : U ⊥ → U n , J p K ~ a : U → U n and J P K ~ a : → U n as follows ( n = ♯~ a ): J a i K ~ a = i jn J M (cid:5) p K ~ a = [ alg U n ◦ ? J M K ~ a , J p K ~ a ] ◦ Ap J cdr ( p ) K ~ a = J p K ~ a ◦ La ◦ ( w U ⊥ O id U ) ◦ r U J nil K ~ a = w U n ◦ J J car ( p ) K ~ a = J p K ~ a ◦ La ◦ ( e U ⊥ O w U ) ◦ l U ⊥ J mb . P K ~ a = L ( J P K ~ a , b ) J M ⋆ p K ~ a = [ id U n , J p K ~ a ] ◦ L − ( J M K ~ a ) Note that the denotations of stacks are ?-algebra morphisms and it is not difficult to verify thatthe above interpretation is invariant under → s -reduction. To see that check before that J E { p / b } K ~ a =[ id ~ a , J p K ~ a ] ◦ J E K ~ a , b . The category Rel of sets and relations is a ∗ -autonomous linear category that satisfiesall our requirements [26]. If S is a set, we denote by M f ( S ) ( w ) the set of all the N -indexed sequences s = ( a , a , . . . ) of multisets over S such that a i = [] holds for all but a finite number of indices i ∈ N . Theset M f ( S ) ( w ) is a simple example of ?-algebra of Rel . For s = ( a , a , . . . ) and t = ( b , b , . . . ) , we define s + t = ( a ⊎ b , a ⊎ b , . . . ) and ∗ = ([] , [] , . . . ) . Then the relations w = { ( , ∗ ) } and c = { (( s , t ) , s + t ) : s , t ∈ M f ( S ) ( w ) } make ( M f ( S ) ( w ) , c , w ) a O -monoid in Rel . The operation + on M f ( S ) ( w ) can alsobe extended componentwise to ( M f ( S ) ( w ) ) k (whose elements are ranged over by ~ s ,~ t , . . . ) transferringthereby the monoid structure. In order to model the untyped calculus we need a O -monoid U of togetherwith two relations La ⊆ ( M f ( U ) × U ) × U and Ap ⊆ U × ( M f ( U ) × U ) satisfying Ap ◦ La = id M f ( U ) × U and a relation J ⊆ U × { } . In the category Rel lives one such object D = ( D , Ap , La ) that has alreadybeen encountered many times in the literature (see for example [2]) as a model of the ordinary l -calculus(as well as of some of its extensions). The object is constructed as union D = S n ∈ N D n of a family ofsets ( D n ) n ∈ N defined by D = /0 and D n + = M f ( D n ) ( w ) . Given s = ( a , a , a , . . . ) ∈ D and a ∈ M f ( D ) ,we write a :: s for the element ( a , a , a , a , . . . ) ∈ D . Since D = M f ( D ) ( w ) , as previously observed ithas a standard monoid structure and we can set La = { (( a , s ) , a :: s ) : a ∈ M f ( D ) , s ∈ D } and Ap = { ( a :: s , ( a , s )) : a ∈ M f ( D ) , s ∈ D } satisfying the desired equation; as a matter of fact also the equationLa ◦ Ap = id U holds and the interpretation of expressions is invariant under → s h -reduction. Finally J = { ( ∗ , ) } .The isomorphism L : C ( , U O U ) → C ( U ⊥ , U ) is trivially given by L ( f ) = { ( a , b ) : ( , ( b , a )) ∈ f } .The interpretation is concretely defined as follows: J a i K ~ a = { ( s , ( ∗ , .., s , .., ∗ )) : s ∈ D } ; J cdr ( p ) K ~ a = { ( s ,~ t ) : ([] :: s ,~ t ) ∈ J p K ~ a } ; J car ( p ) K ~ a = { ( s ,~ t ) : ([ s ] :: ∗ ,~ t ) ∈ J p K ~ a } ; J mb . P K ~ a = { ( s ,~ t ) : ( , ( ~ t , s )) ∈ J P K ~ a , b } ; J M (cid:5) p K ~ a = { ([ s , .., s k ] :: s , S ki = ~ t i ) : k ≥ , ∀ i = , .., k . ( s i ,~ t i ) ∈ J M K ~ a , ( s ,~ t ) ∈ J p K ~ a } ; J M ⋆ p K ~ a = { ( ,~ t + ~ t ′ ) : ∃ s ∈ D . ( s ,~ t ) ∈ J M K ~ a , ( s ,~ t ′ ) ∈ J p K ~ a } ; J nil K ~ a = { ( ∗ , ( ∗ , .., ∗ )) } . .Carraro, T.Ehrhard, A.Salibra 107For example for the stack calculus version of call / cc we have J ma . a [ ] ⋆ ( mb . b [ ] ⋆ a [ )) (cid:5) a [ ) K = { [[[ s ] :: ∗ , .., [ s k ] :: ∗ ] :: s ] :: ( S ki = s i ) : k ≥ , s , .., s k ∈ D } . We introduced the stack calculus, a finitary functional calculus with simple syntax and rewrite rulesin which the calculi introduced so far in the Curry–Howard correspondence for classical logic can befaithfully encoded; instead of exhibiting comparisons with all the existing formalisms, we just showedhow Parigot’s lm -calculus can be translated into our calculus. We proved that the untyped stack cal-culus enjoys confluence, and that types enforce strong normalization. The typed fragment is a soundand complete system for full implicational Classical Logic. The type system that Lafont et al. [19] usefor the l -calculus with pairs may be used to type stack expressions within the {∧ , ¬ , ⊥} -fragment ofIntuitionistic Logic: under this point of view, the stack calculus is the target-language of a CPS trans-lation from itself that alters the types but not the expressions of the calculus. In the classically-typedsystem ( {→ , ⊥} -fragment of Classical Logic) the arrow type corresponds to the stack constructor; forthis reason the realizability interpretation of types `a la Krivine matches perfectly the logical meaning ofthe arrow in the type system. The proofs of soundness and strong normalization of the calculus are bothgiven by particular realizability interpretations. We defined a Krivine machine that executes the termsof stack calculus. We showed how to encode control mechanisms like label/resume and raise/handle inthe stack calculus which are soundly executed by our machine. This approach seems to be simpler thanthe extension of ML with exceptions studied in De Groote [8]. Inspired by Laurent and Regnier’s work[23], we give a simple categorical framework to interpret the expressions of both typed and untyped stackcalculus. We show how, in the case of a relational semantics, this famework allows a simple calculationof the interpretation of expressions. References [1] Z.M. Ariola & H. Herbelin (2003):
Minimal classical logic and control operators . In: ICALP, pp. 871–885,doi: .[2] A. Bucciarelli, T. Ehrhard & G. Manzonetto (2007):
Not Enough Points Is Enough . In: CSL, LNCS 4646,pp. 298–312, doi: .[3] P.-L Curien & H. Herbelin (2000):
The duality of computation . In: ACMSIGPLANInternationalConferenceonFunctionalProgramming, pp. 233–243, doi: .[4] J. Czermak (1977):
A Remark on Gentzen’s Calculus of Sequents . Notre Dame Journal of Formal Logic18(3), pp. 471–474, doi: .[5] V. Danos, J.-B. Joinet & H. Schellinx (1995):
LKQ and LKT: Sequent calculi for second order logic basedupon dual linear decompositions of classical implication . In J.-Y. Girard, Y. Lafont & L. Regnier, editors:Advancesinlinearlogic, LondonMath.SocietyLectureNoteSeries 222.[6] R. David & W. Py (2001): lm -Calculus and B¨ohm’s Theorem . J. Symb. Log. 66(1), pp. 407–413, doi: .[7] P. De Groote (1994): On the relation between the lm -calculus and the syntactic theory of sequential control .In: LPAR, pp. 31–43, doi: .[8] P. De Groote (1995): A Simple Calculus of Exception Handling . In: TLCA, pp. 201–215.[9] P. De Groote (1998):
An environment machine for the lm -calculus . Math. Struct. Comp. Sci. 8(6), pp.637–669, doi: .
08 Thestack calculus [10] M. Felleisen & R. Hieb (1992):
The Revised Report on the Syntactic Theories of Sequential Control andState . Theor.Comput.Sci. 103, pp. 235–271, doi: .[11] G. Gentzen (1935):
Investigations into logical deduction .[12] J.-Y. Girard (1986):
The system F of variable types, fifteen years later . Theor.Comput.Sci. 45, pp. 159–192,doi: .[13] J.-Y. Girard (1991):
A new constructive logic: Classical Logic . Math.Struct.inComp.Sci.1(3), pp. 255–296,doi: .[14] T. Griffin (1990):
A Formulae-as-Types Notion of Control . In: POPL, pp. 47–58, doi: .[15] M. Hofmann & T. Streicher (1997):
Continuation Models are Universal for lambda-mu-Calculus . In: LICS,pp. 387–395, doi: .[16] W.A. Howard (1980):
The formulae-as-types notion of construction . In J.R. Hindley & J.P. Seldin, editors:ToH.B.Curry: EssaysonCombinatoryLogic,LambdaCalculusandFormalism, pp. 479–490.[17] J.W. Klop & R.C. de Vrijer (1989):
Unique normal forms for lambda calculus with surjective pairing . Infor-mationandComputation2, pp. 97–113, doi: .[18] J.-L. Krivine (2001):
Typed lambda-calculus in classical Zermelo-Frænkel set theory . Arch. Math. Log.40(3), pp. 189–205, doi: .[19] Y. Lafont, B. Reus & T. Streicher (1993):
Continuations Semantics or Expressing Implication by Negation .Technical Report 9321, Ludwig-Maximilians-Universitat, Munchen. Technical Report.[20] O. Laurent (2003):
Krivine’s abstract machine and the lambda mu-calculus (an overview) . Unpublished.[21] O. Laurent (2003):
Polarized proof-nets and lambda-mu calculus . Theor.Comput.Sci. 290(1), pp. 161–188,doi: .[22] O. Laurent (2011):
Intuitionistic Dual-intuitionistic Nets . J.Log.Comput.21(4), pp. 561–587, doi: .[23] O. Laurent & L. Regnier (2003):
About Translations of Classical Logic into Polarized Linear Logic . In:LICS, pp. 11–20, doi: .[24] S. Lengrand (2003):
Call-by-value, call-by-name, and strong normalization for the classical sequent calcu-lus . Elec.NotesinTheor.Comp.Sci. 86, doi: . WRS.[25] T. Low & T. Streicher (2006):
Universality Results for Models in Locally Boolean Domains . In: CSL, pp.456–470, doi: .[26] P.-A. Melli`es:
Categorical semantics of linear logic . Available at . Panoramas et Synth`eses 27, Soci´et´e Math´ematique de France, 2009.[27] M. Parigot (1992): lm -calculus: An Algorithmic Interpretation of Classical Natural Deduction . In: LPAR,pp. 190–201, doi: .[28] D. Prawitz (1965): Natural Deduction - a proof theoretical study . Almqvist & Wiksell, Stokholm.[29] B. Reus & T. Streicher (1998):
Classical Logic, Continuation Semantics and Abstract Machines . J. Funct.Program.8(6), pp. 543–572, doi: .[30] P. Selinger (2001):
Control categories and duality: on the categorical semantics of the lambda-mu calculus .Math.Struct.inComp.Sci. 11, pp. 207–260, doi: .[31] R. Smullyan (1968):
First-order logic . Springer-Verlag, New York, doi: .[32] C. Urban (2000):