A semantical and operational account of call-by-value solvability Alberto Carraro1,2 and Giulio Guerrieri2 1 DAIS, Università Ca’ Foscari Venezia, [email protected] 2 PPS, Univ Paris Diderot, Sorbonne Paris Cité [email protected] Abstract. In Plotkin’s call-by-value lambda-calculus, solvable terms are characterized syntactically by means of call-by-name reductions and there is no neat semantical characterization of such terms. Preserving confluence, we extend Plotkin’s original reduction without adding extra syntactical constructors, and we get a call-by-value operational characterization of solvable terms. Moreover, we give a semantical characterization of solvable terms in a relational model, based on Linear Logic, satisfying the Taylor expansion formula. As a technical tool, we also use a resource-sensitive calculus (with tests) in which the elements of the model are definable. Keywords: (resource) call-by-value lambda calculus, tests, potential valuability, solvability, relational semantics, weak and stratified reductions 1 Introduction In the theory of ordinary (i.e. untyped call-by-name) λ-calculus, the notion of solvability plays a crucial role. A λ-term M is solvable if there is a head context H such that HLM M β λx.x = I (the identity); M is unsolvable if it is not solvable. Solvability (see [1]) underlies the fundamental notions of approximants, Böhmtrees and separability; moreover, it is possible to encode partial recursive functions in λ-calculus in such a way that undefinedness is represented by unsolvable λterms ([1, Ch. 8]). Enforcing the idea of unsolvable-as-meaningless, it is consistent to equate all unsolvable λ-terms (but not all λ-terms having no β-normal form, [1, Ch. 16]). A fundamental theorem for ordinary λ-calculus (see [2,3]) states that for every λ-term M the following are equivalent: (1) M is solvable; (2) the head reduction of M terminates; (3) the semantics of M in the Scott’s model D∞ is not the least element. Equivalence (1)⇔(2) (resp. (1)⇔(3)) gives a semantical (resp. syntactical or operational ) characterization of solvability in ordinary λ-calculus. The most common parameter passing policy for programming languages is call-by-value (CBV). Plotkin [4] introduced the λv -calculus in order to grasp the CBV paradigm in a pure λ-calculus setting. The λv -calculus (without constants) has the same syntax as ordinary λ-calculus but its βv -reduction rule allows the contraction of a β-redex only if the argument is a λ-value, i.e. a variable or an abstraction. As argued in [5], a good CBV λ-calculus should enjoy an internal operational characterization (i.e. by using CBV reduction rules) of CBV-solvability. 2 A. Carraro, G. Guerrieri This is not the case for Plotkin’s λv -calculus and the weakness of βv -reduction is widely recognized and accepted. Following [6,7], a λ-term M is λv -solvable if there is a head context H such that HLM M βv I. Let ∆ = λx.xx: there is no head context sending (via βv -reduction) N = (λy.∆)(xI)∆ to I, thus N is λv -unsolvable and hence it should be divergent, whereas it is βv -normal. An operational characterization of λv -solvability has been provided in [6,7] but through a call-by-name reduction; this result is improved in [8] where the characterization is built upon strong normalization of the (call-by-name) lazy β-reduction. There are many proposals of alternative CBV λ-calculi (see [9,10,11,12,5]) extending Plotkin’s one by using explicit substitutions (constructors of the form let...in). In particular, Accattoli and Paolini [5] introduced recently the λvsub -calculus where the reduction rule acts at a distance by extending the notion of βv -redex (with explicit substitutions). In this setting they give an internal operational characterization of solvability and this characterization lifts to Herbelin and Zimmermann’s λCBV -calculus, another CBV λ-calculus with explicit substitutions introduced in [9] (without rules acting at a distance but with commutation rules for explicit substitutions). Paolini and Ronchi Della Rocca [6,7] made major contributions to the study of CBV-solvability through denotational semantics. In [6] they showed an intersection type system that characterizes λv -potentially valuable 3 (Thm. 6.4) and λv -solvable λ-terms (Thm. 6.5). We quote from [6, p. 28]: “The type assignment system presented here is strongly related to the system presented in [13] for reasoning on the denotational semantics of the [Plotkin’s] λv -calculus. [. . . ] The two systems have the same typability power”. It is not shown whether this type system is “legal” (see [7, Def. 10.1.5]), which is substantially a sufficient condition to turn the type system into a filter model (i.e. a true domain model). In [7, Ch. 12] the same authors exhibit two models, V (§ 12.1) and VV (§ 12.2), both built from intersection type systems. The model V comes from a legal type system and it is shown to be isomorphic to the one of [13]. All and only λv -potentially valuable λ-terms have non trivial interpretation in V, but V gives only a partial semantical characterization of λv -solvable λ-terms (Thm. 12.1.19). The model VV characterizes observational equivalence (Thm. 12.2.14) but it is not a filter model. Recently, Ehrhard [14] used a relational model of the λv -calculus, based on Linear Logic, to show that if the semantics of a λ-term M is not empty, then M is strongly normalizing for the lazy βv -reduction (which does not reduce under abstractions); the converse is false (the aforesaid λ-term N is a counterexample). The starting points of our work are [6,5,14]. We introduce the λσv -calculus, a CBV λ-calculus having the same syntax as ordinary (and hence Plotkin’s CBV) λ-calculus (there are no explicit substitutions) and extending the βv -reduction by adding two reduction rules, σ1 and σ3 . For the λσv -calculus we give a semantical and an internal operational characterization of solvability and potential valuability. We use the relational model of [14], which can also be seen as a model of ordinary 3 Following [6,7], a λ-term is λv -potentially valuable if there is a substitution sending it (via βv ) into a λ-value. This notion is important for a CBV λ-calculus because if we want to manipulate some subterms, we need first to transform them into λ-values. A semantical and operational account of call-by-value solvability 3 λ-calculus (unlike the model V of [7]) and satisfies a version of the Taylor formula (see [14]). We also introduce a resource-sensitive calculus with tests in which the elements of the relational model are definable: this is a promising tool to face the CBV full abstraction problem, along the lines of [15]. Our λσv -calculus springs from Girard’s call-by-value “boring” translation v (·) of λ-calculus into Intuitionistic Multiplicative Exponential Linear Logic (IMELL) proof-nets, identified by (A ⇒ B)v = !Av ( !B v (see [16]). The images of a σ1 - or σ3 -redex and its contractum under (·)v are equal modulo some specified “immediate” steps of cut-elimination. Our σ-rules are related to (but partly different from) Regnier’s σ-reduction defined in [17,18] for the ordinary λ-calculus. Moreover, σ1 and σ3 correspond respectively to the commutation rules let app and (a generalization of) let let in λCBV -calculus (see [9,5]). In some sense, they can be seen as a finer (and local) decomposition of the reduction rules acting at a distance in λvsub -calculus (it is possible to simulate λvsub - and λCBV -calculus in our λσv -calculus), but the absence of explicit substitutions in λσv -calculus prevents from lifting the internal operational characterization of CBV-solvability from λvsub - or λCBV -calculus to our λσv -calculus. Outline. In §2 we introduce our λσv -calculus. Then, §3, §4 and §5 are devoted to the technical notions which are necessary in order to state our main results: in §3 we present two sub-reductions in the λσv -calculus, called w- and s-reduction; in §4 and §5 we present a resource-sensitive version of the λσv -calculus and the relational model of the (resource) λσv -calculus. In §6 we state and prove our main theorems: the semantical (via the relational model) and syntactical (via w- and s-reductions) characterization of potential valuability and solvability; they say also that weak and strong normalizations coincide for both w- and s-reductions. 2 A CBV lambda-calculus with sigma-like-reductions In this section we introduce λσv , our version of CBV λ-calculus. The syntax of λσv is the same as the one of ordinary λ-calculus. Given a countable set of variables (denoted by x, y, z, . . . ), the language of λσv is defined by the following grammar: (Λv ) (Λ) V, U ::= x | λx.M M, N, L ::= V | M N λ-values λ-terms All λ-terms are considered up to α-conversion. The set of free variables of a λ-term M is denoted by fv(M ). Given pairwise distinct variables x1 , . . . , xn , we denote by M {V1 /x1 , . . . , Vn /xn } the λ-term obtained by the capture-avoiding simultaneous substitution of each free occurrence of xi in the λ-term M by the λ-value Vi (for 1 ≤ i ≤ n). Notice that, for all λ-values V, V1 , . . . , Vn and pairwise distinct variables x1 , . . . , xn , V {V1 /x1 , . . . , Vn /xn } is a λ-value. Contexts (with exactly one hole) are defined as usual via the grammar: C ::= L·M | λx.C | CM | M C . We use CLM M for the λ-term obtained by the capture-allowing substitution of the λ-term M for L·M in the context C. 4 A. Carraro, G. Guerrieri Definition 1. We define the following binary relations from Λ to Λ: (λx.M )V 7→βv M {V /x} (λx.M )N L 7→σ1 (λx.M L)N V ((λx.L)N ) 7→σ3 (λx.V L)N with V ∈ Λv with x ∈ 6 fv(L) with x ∈ 6 fv(V ) and V ∈ Λv For R ∈ {βv , σ1 , σ3 }, if M 7→R M 0 then M is called R-redex. We set 7→σ = 7→σ1 ∪ 7→σ3 and 7→v = 7→βv ∪ 7→σ . The side conditions on 7→σ in Def. 1 can be always fulfilled by α-renaming. Notation. Let 7→R ⊆ Λ × Λ. We use →R (called R-reduction) for the closure of 7 R under all contexts; we denote by R (resp. →+ → R ) the reflexive-transitive (resp. transitive) closure of →R . Let M be a λ-term: M is R-normal if there is no λ-term N such that M →R N ; M is R-normalizable if there is a R-normal λterm N such that M R N ; M is strongly R-normalizing if there is no sequence (Ni )i∈N such that M = N0 and Ni →R Ni+1 for every i ∈ N. Notice that, for any λ-value V , if V →v M , then M is a λ-value. The λσv -calculus is the set Λ of λ-terms endowed with the v-reduction →v . The set Λ endowed with →βv is Plotkin’s CBV λ-calculus ([4]) without constants. Informally, σ-rules unblock βv -redexes which are hidden by the “hypersequential structure” of λ-terms. This approach is alternative to the one in [5] where hidden βv -redexes are reduced thanks to a rule acting at a distance. Example. N = (λy.∆)(xI)∆ →σ1 (λy.∆∆)(xI) →βv (λy.∆∆)(xI) →βv . . . is the only possible v-reduction path from N : N is not v-normalizable but βv -normal. 2.1 Confluence of our CBV lambda-calculus Our goal here is to prove that the v-reduction is confluent. Proof at p. 16 Proposition 2. The reduction →σ is strongly normalizing. Proof. First, we define two sizes s(M ) and #M by induction on the λ-term M : s(x) = 2; #x = 1; s(λx.M ) = s(M ) + 1; #λx.M = #M + s(M ); s(M N ) = s(M ) + s(N ). #M N = #M + #N + 2s(M )s(N ) − 1. It is sufficient to show that if N →σ N 0 then s(N ) = s(N 0 ) and #N > #N 0 . t u Proof at p. 16 See Remarks 41 and 42 at p. 18 Proposition 3. The reduction →σ is (not strongly) confluent. Proof. By Newman’s Lemma and Prop. 2, it is sufficient to show that →σ is locally confluent. The proof of local confluence is by induction on M . The λ-term Ξ = (λx.x0 ) (λy.y 0 I)(zI) (z 0 I) is an objection to strong confluence of →σ . t u Lemma 4 (Hindley–Rosen, [1, p. 64]). Let →1 , →2 ⊆ X 2 (for any set X). If they are both confluent and they commute, i.e. if t 1 u1 and t 2 u2 then there exists s such that u1 2 s and u2 1 s, then →1 ∪ →2 is confluent. A semantical and operational account of call-by-value solvability Proof at p. 17 5 Lemma 5. Let M, M 0 ∈ Λ, V, V 0 , V1 , . . . , Vm ∈ Λv and R ∈ {βv , σ, v}. (i) If V →R V 0 then M {V /x} R M {V 0 /x}. (ii) If M →R M 0 then M {V1 /x1 , . . . , Vm /xm } →R M 0 {V1 /x1 , . . . , Vm /xm }. Lemma 6. The reductions →βv and →σ commute. Proof at p. 18 Proof. It suffices to prove that if M →σ N1 and M →βv N2 then there is L s.t. N2 σ L and N1 →βv L. The proof of this statement is by induction on M . t u By Lemmas 4 and 6, Prop. 3 and confluence of →βv (see [4]), we conclude: Theorem 7. The reduction →v is (not strongly) confluent. The λ-term Ξ (see proof of Prop. 3) is an objection to strong confluence of →v . If in the definition of 7→σ3 (Def. 1) we replace the λ-value V with any λ-term M then →σ and →v are not (locally) confluent: consider (λx.x0 )(zI) (λy.y 0 )(z 0 I) . 3 See Remarks 41 and 42 at p. 18 See Remark 43 at p. 18 Weak and stratified CBV reductions In this section we introduce two sub-reductions of →v : weak (or w-)reduction and stratified (or s-)reduction. We will show in §6 that they give an operational characterization of potential valuability and solvability: they are the “CBV counterpart” of head reduction for ordinary λ-calculus. Whereas head reduction is strictly deterministic (any λ-term has at most one head redex), a λ-term might have several (overlapping) w- or s-redexes. Anyway, both w- and s-reductions are confluent (Prop. 10) and for them weak and strong normalization coincide (Thm. 24 and 25). We have gathered our definition of w- and s-reductions from [5]. Definition 8. Weak and stratified contexts (denoted respectively by W and S) are contexts defined via the grammar: W ::= L·M | WM | M W | (λx.W)M S ::= W | λx.S | SM Notation. Let 7→R ⊆ Λ × Λ: we use →w[R] (resp. →s[R] ) for the closure under weak (resp. stratified) contexts of 7→R . We set w = w[v] and s = s[v]; for instance, →w = →w[v] (called w-reduction) and →s = →s[v] (called s-reduction). Note that →w ( →s ( →v . In weak contexts, if the hole is under an abstraction then this abstraction is the left-hand side of an application. Stratified contexts never contain the hole under an abstraction which is in the right-hand side of some application, unless the abstraction is the left-hand side of an application. Example. Let Ω = ∆∆: one has Ω →w Ω →w . . . , λy.Ω →s λy.Ω →s . . . , and x(λy.Ω) →v x(λy.Ω) →v . . . , whereas λy.Ω (resp. x(λy.Ω)) is w-(resp. s-)normal. We will now prove that the w- and s-reductions are confluent. Lemma 9. (i) The reductions →w[βv ] and →s[βv ] are strongly confluent. (ii) The reductions →w[σ] and →s[σ] are confluent. (iii) The reductions →w[βv ] and →w[σ] (resp. →s[βv ] and →s[σ] ) commute. By Lemmas 4 and 9 we can conclude: Proposition 10. The reductions →w and →s are (not strongly) confluent. The λ-term Ξ (see p. 4) is an objection to strong confluence of →w and →s . Proof at p. 19 6 3.1 A. Carraro, G. Guerrieri Characterization of w- and s-normal forms Our goal here is to characterize w- and s-normal forms. Having no explicit substitutions, our characterization appears more concise than the one in [5]. Definition 11. We define the subsets anf , snf and wnf of Λ as follows: (anf ) (wnf ) (snf ) Anf ::= xV | xAnf | Anf Wnf Wnf ::= V | (λx.Wnf )Anf | Anf Snf ::= x | λx.Snf | (λx.Snf )Anf | Anf A β-redex is a λ-term of shape (λx.M )L. Notice that anf ( snf ( wnf and if N ∈ anf then N has a free “head variable” and it is neither a value nor a β-redex. Proof at p. 20 Proposition 12. Let M be a λ-term. (i) M is w-normal iff M ∈ wnf . (ii) M is s-normal iff M ∈ snf . (iii) M is w-(resp. s-)normal and is neither a value nor a β-redex iff M ∈ anf . 4 A resource CBV lambda-calculus We now introduce the resource λσv -calculus, a valuable tool to prove some parts of our main results. It is an extension of the resource CBV λ-calculus introduced in [14, §5.2]. Its syntax is defined by the following grammar (the same as in [14]): (rΛv ) (rΛt ) (rΛ) u, v ::= x | λx.t s, t ::= st | [v1 , . . . , vk ] e, f ::= v | t (k ≥ 0) resource values resource terms expressions A resource term like [v1 , . . . , vk ] is a multiset of resource values (called bag). The resource-version of the βv -rule makes use of linear substitution, which requires to enrich the syntax of the calculus with finite sets of resource terms. Notation. Since the set Pf (A) of all finite subsets of a set A is the free module 2hAi generated by A over the boolean semiring {0, 1} with 1 + 1 = 1, we will use algebraic notations for operations on its elements (+ for set unions, 0 for the empty set), as done in [15,14]. We denote by degx (e) the number of free occurrences of the variable x in the expression e. Given e ∈ rΛ, v1 , . . . , vk ∈ rΛv andP an enumeration of the free occurrences of variable x in e, if degx (e) = k then by f ∈Sk e{vf (1) /x1 , . . . , vf (k) /xk } we mean the sum of all expressions obtained by substituting vf (i) for the i-th free occurrence of x in e, as f varies over all elements of the set Sk of permutations of {1, . . . , k}. Finally, the linear substitution of [v1 , . . . , vk ] for x in e is (P 1 k f ∈Sk e{vf (1) /x , . . . , vf (k) /x } if degx (e) = k eh[v1 , . . . , vk ]/xi = 0 otherwise A semantical and operational account of call-by-value solvability 7 Notice that, for n ∈ {v, t}, if e ∈ rΛn then eh[v1 , . . . , vk ]/xi ∈ 2hrΛn i. Resource contexts (with exactly one hole) are defined via the grammar: R ::= L·M | Rt | tR | [λx.R, v1 , . . . , vk ] (k ≥ 0) Let R be a resource context. We use RLtM for the resource term obtained by the capture-allowing substitution of the resource term Pn Pn t for the hole L·M in R. If T = i=1 ti (with t1 , . . . , tn ∈ rΛt ), then RLTM = i=1 RLti M ∈ 2hrΛt i (see also [14, §5.2] and [15, §2.1]). For example, RL0M = 0 and [λx.[x]L[y][z] + [z][y]M, y] = [λx.[x]([y][z]), y] + [λx.[x]([z][y]), y]. Definition 13. We define the following binary relations from rΛt to 2hrΛt i: [λx.t]ss0 7→σ1 [λx.ts0 ]s [λx.t][v1 , . . . , vk ] 7→βv th[v1 , . . . , vk ]/xi [v1 , . . . , vn ]t 7→0 0 if n 6= 1 if x ∈ / fv(s0 ) [v]([λx.t]s) 7→σ3 [λx.[v]t]s if x ∈ / fv(v) We set 7→v = 7→βv ∪ 7→σ1 ∪ 7→σ3 ∪ 7→0 . According to the convention of §2, →v ⊆ rΛt ×2hrΛt i is the reduction obtained by resource-contextual closure of 7→v . The resource λσv -calculus consists of the language rΛt and the reduction →v : it is the resource CBV λ-calculus of [14] plus the σ1 - and σ3 -rules. As a technical we extend →v to a binary relation on 2hrΛt i by Pn simplification, P n linearity, i.e. ( i=1 ti ) + S →v ( i=1 Ti ) + S iff ti →v Ti for every i = 1, . . . , n (n ≥ 1). With this extension we can concisely state the following theorem: Theorem 14. Reduction →v on 2hrΛt i is strongly normalizing and confluent. We omit the proof of Thm. 14. Strong normalization is evident (see [14] for a proof for the resource-contextual closure of 7→βv ∪ 7→0 ). The proof of local confluence for the resource λσv -calculus is analogous to the one for v-reduction on λ-terms (see §2). Finally, confluence is obtained by Newman’s Lemma. 5 A relational model of (resource) CBV lambda-calculus In this section we present a relational model for both the λσv -calculus and the resource λσv -calculus. This model is to be found in the category Rel of sets and relations (i.e. Rel(X, Y ) = P(X × Y )). In Rel identities are diagonal relations and composition of morphisms is the standard composition of relations. This category has a symmetric monoidal structure given by 1 = {1} (arbitrary singleton set) and X ⊗ Y = X × Y . This symmetric monoidal category is closed, with X ( Y = X × Y , and ∗-autonomous with dualizing object ⊥ = 1. Category Rel is cartesian, with X & Y = ({1} × X) ∪ ({2} × Y ), and has an exponential functor ! defined by !X = Mf (X) (the set of finite multisets on X) and !f = {([α1 , . . . , αn ], [β1 , . . . , βn ]) : n ≥ 0, (αi , βi ) ∈ f ∀ 1 ≤ i ≤ n} for f ∈ Rel(X, Y ). All this structure makes Rel a new-Seely category and hence a categorical model of Linear Logic (LL). For more details we refer the reader to [19,14]. The model. We build inductively a family of sets (UnS)n∈N given by U0 = ∅ and Un+1 = Mf (Un ) × Mf (Un ). Finally, we set U = n∈N Un . Notice that Un ( Un+1 for all n ∈ N, and U = Mf (U ) × Mf (U ) = !U ( !U . 8 A. Carraro, G. Guerrieri 5.1 Interpreting the CBV lambda-calculus Using the fact that Rel has the structure of a LL model, we can give a concrete interpretation of λ-terms as morphisms from Mf (U )n to Mf (U ) in Rel (where Mf (U )n is the n-fold set-theoretic power of Mf (U )). This semantics can also be described by type judgements (see [14]). With a ] b we indicate the union of the multisets a and b (accounting for repetitions); if ~a and ~b are two finite sequences (of the same length) of multisets, ~a ] ~b is their component-wise union. Definition 15. For every λ-term M and repetition-free list ~x ⊇ fv(M ), we define, by induction on M , its interpretation JM K~x ⊆ Mf (U )n × Mf (U ) (where n is the length of ~x), as follows: Jxi K~x = {(~a, ai ) : ai ∈ Mf (U ), aj = [ ] for all 1 ≤ j ≤ n with j 6= i} Uk Uk Jλy.N K~x = {( i=1 ~ai , i=1 [(bi , ci )]) : k ≥ 0, ∀i = 1, . . . , k. ((~ai , bi ), ci ) ∈ JN K~x,y } JM N K~x = {(~a0 ] ~a1 , c) : ∃ b ∈ Mf (U ). (~a0 , [(b, c)]) ∈ JM K~x , (~a1 , b) ∈ JN K~x } . Notation. Hereafter, whenever we write JM K~x we suppose that ~x is a repetitionfree list of variables containing fv(M ). Moreover, we will sometimes silently use the fact that JM K~x,y = {((~a, [ ]), b) : (~a, b) ∈ JM K~x } whenever y 6∈ ~x. Proof at p. 21 Theorem 16 (soundness). Let M, N ∈ Λ. If M →v N , then JM K~x = JN K~x . 5.2 Interpreting the resource CBV lambda-calculus In addition to the structure mentioned above, Rel is additive, and more precisely its hom-sets are enriched over the category of complete lattices, with set-theoretic union as join operation. The category Rel is a weak differential LL model (see [14]). Using this structure we can give the concrete interpretation of expressions as morphisms from Mf (U )n to Mf (U ) in Rel. Definition 17. For every expression e and repetition-free list ~x ⊇ fv(e), we define, by induction on e, its interpretation JeK~x ⊆ Mf (U )n × Mf (U ) (where n is the length of ~x), as follows: Jxi K~x = {(~a, [α]) : α ∈ U, ai = [α], aj = [ ] for all 1 ≤ j ≤ n with j 6= i} Jλz.tK~x = {(~a, [(b, c)]) : ((~a, b), c) ∈ JtK~y,z } JstK~x = {(~a0 ] ~a1 , c) : ∃b ∈ Mf (U ). (~a0 , [(b, c)]) ∈ JsK~x , (~a1 , b) ∈ JtK~x } Uk Uk J[v1 , . . . , vk ]K~x = {( i=1 ~ai , i=1 bi ) : k ≥ 0, ∀i = 1, . . . , k. (~ai , bi ) ∈ Jvi K~x } . Pn Sn Finally, sums of expressions are interpreted by setting J i=1 ei K~x = i=1 Jei K~x . Notation. As for λ-terms, whenever we write JeK~x we suppose that ~x is a repetition-free list of variables containing fv(e), and similarly for the sums. Note that J[ ]K~x = {([ ]n , [ ])} ⊆ Mf (U )n × Mf (U ), where [ ]n = ([ ], . . . , [ ]). | {z } n times A semantical and operational account of call-by-value solvability Proof at p. 21 9 Theorem 18 (soundness). Let S, T ∈ 2hrΛt i. If S →v T, then JSK~x = JTK~x . The following notion of CBV Taylor expansion has been introduced in [14]. Definition 19 ([14], Taylor expansion). Given a λ-term M , we inductively define a set T (M ) of resource terms, called the Taylor expansion of M , as follows: n times n T (x) = {[x ] : n ≥ 0} n z }| { where [x ] = [x, . . . , x] T (λx.M ) = {[λx.t1 , . . . , λx.tn ] : n ≥ 0, ∀i. ti ∈ T (M )} T (M N ) = {st : s ∈ T (M ), t ∈ T (N )} . Theorem 20 ([14]). Let M be a λ-term. Then JM K~x = S x t∈T (M ) JtK~ . Thm. 20 shows the semantical connection between λ-terms and their Taylor expansion. In the next section (§6) it will be applied in Thm. 39.1, which is in turn a fundamental part of one of our main results Thm. 24. Definition 21. For every expression e we define by induction the set strat(e) of multisets of resource values that occur in e in stratified position, as follows: Sn strat(x) = ∅; strat([v1 , . . . , vn ]) = {[v1 , . . . , vn ]} ∪ i=1 strat(vi ) (n ≥ 0); strat(st) = strat(s); strat(λx.t) = strat(t) . We set Strat = {t ∈ rΛt : [ ] ∈ / strat(t)}, whose elements are called stratified resource terms. A stratified resource term t does not contain any [ ] in stratified position, i.e. every occurrence of [ ] in t is a subterm of some subterm of t in argument position. For instance: [x][ ], [x]([λz.[ ]][ ]) ∈ Strat but [ ], [ ][z], [λz.[ ][x, y]] ∈ / Strat. Stratified resource terms are not closed under v-reduction. For example, the stratified resource term [λx.[x]][λy.[ ]] v-reduces to the non-stratified [λy.[ ]]. Definition 22 (stratified Taylor expansion). Given a λ-term M , we define its stratified Taylor expansion Ts (M ) = {t ∈ T (M ) : if t v T, then T ⊆ Strat}. Example. The λ-term M = (λxy.x)Ω is neither w- nor s-normalizable and every resource term in T (M ) v-reduces to 0. Instead the non-s-normalizable (but w-normal) λ-term N = (λxy.Ω)(zz 0 ) has infinitely many resource terms in T (N ) that do not v-reduce to 0, like t = [λx.[ ]]([z][z 0 ]) for example. However t 6∈ Ts (N ) and Ts (N ) contains only resource terms that v-reduce to 0, because all resource terms in T (N ) not v-reducing to 0 contain at least one [ ] in stratified position. The semantical connection between λ-terms and their stratified Taylor expansion is illustrated in one of our main results, Thm. 25. In particular, Thm. 39.2 is the step in which it is proved that the interpretation of Ts (M ) actually witnesses the strong s-normalization of M . Intuitively, if t ∈ Ts (M ) then the v-normal form Pn of t is a sum i=1 ti (n ≥ 0) of stratified resource terms, each of which does not contain [ ] in stratified position: a subterm [ ] inside a ti does not “hide” a non-s-normalizable λ-term N such that M = SLN M. So, by Lemma 38.ii one can prove that if t 6= 0 then M is strongly s-normalizing. 10 6 A. Carraro, G. Guerrieri The main theorems In this section we will present our main results: the semantical and internal operational characterization of potential valuability (Thm. 24) and solvability (Thm. 25) for the λσv -calculus. See §1 for a overview of these notions. Definition 23 (Potential valuability, solvability). Let M be a λ-term: – M is potentially valuable if there exist variables x1 , . . . , xm and λ-values V, V1 , . . . , Vm (with m ≥ 0) such that M {V1 /x1 , . . . , Vm /xm } v V ; – M is solvable if there exist variables x1 , . . . , xm and λ-terms N1 , . . . , Nn (for some n, m ≥ 0) such that (λx1 . . . xm .M )N1 · · · Nn v I. We state now the two main theorems. In particular, Thm. 24 says that w-normalizability (i.e. potential valuability) plays a role analogous to that of head-normalizability for many call-by-name models, like Scott’s D∞ . Theorem 24. Let M be a λ-term with ~x ⊇ fv(M ). The following are equivalent: (i) M is w-normalizable; (iii) JM K~x 6= ∅; (ii) M is potentially valuable; (iv) M is strongly w-normalizing. Theorem 25. Let M be a λ-term with ~x ⊇ fv(M ). The following are equivalent: S (i) M is s-normalizable; (iii) t∈Ts (M ) JtK~x 6= ∅; (ii) M is solvable; (iv) M is strongly s-normalizing. An immediate corollary of Thm. 24 and 25 is that every solvable (i.e. snormalizable) λ-term is also potentially valuable (i.e. w-normalizable). The proofs of Thm. 24 and 25 are divided into parts, which are detailed separately in the next subsections, due to the different techniques used for each one of them. The splitting of the two proofs follows the same pattern. The implications (i) ⇒ (ii) of both theorems are proved in §6.1 by purely syntactical means. The implication (ii) ⇒ (iii) of Thm. 24 is shown in §6.2 using the resource λσv -calculus of §4; for this implication of Thm. 25 we use an extension of the resource λσv calculus presented in §6.3. The implication (iii) ⇒ (iv) of both theorems is proved in §6.4 using simulations of w- and s-reductions in λσv -calculus by the v-reduction of the resource λσv -calculus. Finally, (iv) ⇒ (i) are trivial in both cases. 6.1 From weak and stratified normalization to solvability and potential valuability Our goal here is to prove the implication (i) ⇒ (ii) of Thm. 24 and 25. Our approach is largely inspired by [6,7,5]. For every n ∈ N, we set on = λxn . . . x0 .x0 . Notice that o0 = I and on is a closed value for any n ∈ N. Moreover, on V 7→βv on−1 for any n > 0 and V ∈ Λv . Proof at p. 21 Lemma 26. Let M ∈ wnf with fv(M ) ⊆ {x1 , . . . , xm } and let j ∈ N. Then there exists h > 0 such that for all n1 , . . . , nm ≥ j + h there exists a λ-term N such that M {on1 /x1 , . . . , onm /xm } v λx.N and λx.N is closed. A semantical and operational account of call-by-value solvability Proof at p. 22 11 Lemma 27. Let M ∈ snf with fv(M ) ⊆ {x1 , . . . , xm } and let j ∈ N. Then there exist h, k ∈ N such that for all n1 , . . . , nm+k ≥ j + h there exists n ≥ j such that M {on1 /x1 , . . . , onm /xm }onm+1 . . . onm+k v on . Theorem 28. Let M be a λ-term. 1. [(i)⇒(ii) of Thm. 24] If M is w-normalizable then M is potentially valuable. 2. [(i)⇒(ii) of Thm. 25] If M is s-normalizable then M is solvable. Proof. For point 1 (resp. 2), hypothesis means that there is a w-(resp. s-)normal form M 0 such that M w M 0 (resp. M s M 0 ), moreover M 0 ∈ wnf (resp. M 0 ∈ snf ) by Prop. 12. Let fv(M ) = {x1 , . . . , xm } and thus fv(M 0 ) ⊆ {x1 , . . . , xm }. 1. By Lemma 26 (taking j = 0) there exists h > 0 such that: M 0 {oh /x1 , . . . , oh /xm } v λx.N , for some closed λ-value λx.N . One has M {oh/x1 , . . . , oh/xm } v M 0 {oh/x1 , . . . , oh/xm } by Lemma 5.ii, so that M is potentially valuable because λx.N is a closed λ-value. 2. By Lemma 27 (taking j = 0), there exist h, k, n ∈ N such that: (M 0 {oh /x1 , . . . , oh /xm })oh . . . oh v on (oh is applied k times). We conclude h that M is solvable because if we set H = (λx1 . . . xm .L·M) o . . oh} I| .{z . . }I , then | .{z m+k times n times HLM M v HLM 0 M v (M 0 {oh /x1 , . . . , oh /xm })oh . . . oh I . . . I v on I . . . I v I. 6.2 t u From potential valuability to non-emptyness The following theorem proves the implication (ii) ⇒ (iii) of Thm. 24. Theorem 29. Let M be a λ-term with ~x ⊇ fv(M ). If M is potentially valuable, then JM K~x 6= ∅. Proof. If M is potentially valuable (see Def. 23) there exist variables x1 , . . . , xm and λ-values V, V1 , . . . , Vm (for some m ≥ 0) s.t. M {V1 /x1 , . . . , Vm /xm } v V . Since variables are λ-values, we can suppose without loss of generality that Sm ~x = (x1 , . . . , xm ) ⊇ fv(M ). Let ~y = fv(V ) ∪ i=1 fv(Vi ). One can prove by induction on M that See Lemma 48 at p. 24 Um JM {V1 /x1 , . . . , Vm /xm }K~y = ( i=1 ~ai , c) : ∃ b1 , . . . , bm ∈ Mf (U ) : ((b1 , . . . , bm ), c) ∈ JM K~x , (~ai , bi ) ∈ JVi K~y for all 1 ≤ i ≤ m . Since JV K~y 6= ∅ (this can be proved by simple inspection), by Thm. 16 we obtain that JM {V1 /x1 , . . . , Vm /xm }K~y 6= ∅ also holds, so that JM K~x 6= ∅. t u 6.3 From solvability to non-emptyness of stratified Taylor expansion The implication (ii) ⇒ (iii) of Thm. 25 seems much more difficult to prove. To accomplish this task we introduce the resource λσv -calculus with tests, a CBV See Lemma 47 at p. 23 12 A. Carraro, G. Guerrieri version of the resource calculus with tests defined in [15]. In this syntax all elements of the relational model are definable (see Def. 34). The language extends that of resource λσv -calculus (see §4, p. 6) as follows: (rΛv ) (rΛt ) (rΛτ ) u, v ::= x | λx.t s, t ::= t ∗ p | st | [v1 , . . . , vk ] p, q ::= τ [t1 , . . . , tk ] (k ≥ 0) (k ≥ 0) resource values resource terms tests Note the overloaded use of rΛv and rΛt , which now (and until Lemma 36) indicate larger sets than those introduced in §4. We will use this extension to prove Lemma 36 (whose statement concerns only resource terms without tests). Tests are – formally – multisets of resource terms, the “τ ” being a tag for distinguishing them from bags of values. Intuitively, they are constructions which can produce either success, represented by τ [ ], or failure, represented by 0. Notation. We set ε = τ [ ] and τ [t1 , . . . , tk ] k τ [tk+1 , . . . , tn ] = τ [t1 , . . . , tn ] (k ≤ n). The test p k q represents the (must-)parallel composition of p and q (i.e., p k q succeeds iff both p and q succeed). The composition is parallel in the sense that the order of evaluation is inessential (remember that they are multisets). The binary operator ∗ allows to build a resource term out of a resource term and a test: intuitively, the resource term t ∗ p may be thought of as something that outputs the result of t only if p succeeds. Dually, the “cork construction” τ [t] may be thought of as a check that tests whether or not t v-reduces to [ ]. Resource, test-resource and test-test contexts (with exactly one hole), denoted resp. by R, Q and P, are defined by mutual induction via the grammar (k ≥ 0): R ::= L·M | Rt | tR | t ∗ Q | [λx.R, v1 , . . . , vk ] Q ::= τ [R, t1 , . . . , tk ] (test-resource c.); (resource contexts); P ::= L·M k τ [t1 , . . . , tk ] (test-test c.). Let t, t1 , . . . , tn ∈ rΛ (resp. p, p1 , . . . , pn ∈ rΛτ ). We use QLtM (resp. PLpM) for the test obtained by the capture-allowing substitution of t (resp. the hole P p) for P L·MPin Q (resp. P); similarly for RLtM (see p. 7). As usual, RL t M = i i i RLti M, P P P QL i ti M = i QLti M and PL i pi M = i PLpi M. E.g., t ∗ 0 = t ∗ QL0M = RL0M = 0. t Definition 30. The operational semantics of the resource λσv -calculus with tests extends the set of rules listed in Def. 13 with the following ones: t(s ∗ p) 7→τ1 ts ∗ p τ [t ∗ p] 7→τ4 τ([t] k p (t ∗ p)s 7→τ2 ts ∗ p τ [[v1 , . . . , vn ]] 7→τ5 ε if n = 0 (t ∗ p) ∗ q 7→τ3 t ∗ (p k q) 0 otherwise S5 t t τ We set 7→vτ = 7→v ∪ ( i=1 7→τi ) ⊆ (rΛ × 2hrΛ i) ∪ (rΛ × 2hrΛτ i). Then, according to the convention of §2, →vτ ⊆ rΛτ × 2hrΛτ i is the reduction obtained by test-contextual closure4 of 7→vτ . The resource λσv -calculus with tests consists of the language rΛτ and the reduction →vτ . 4 This means that, for every p ∈ rΛτ and p0 ∈ 2hrΛτ i, if p →vτ p0 then either there exist a test-test context P, q ∈ rΛτ and q 0 ∈ 2hrΛτ i such that p = PLqM, p0 = PLq 0 M and q 7→τi q 0 with i ∈ {4, 5}; or there exist a test-resource context Q, tS∈ rΛt and t0 ∈ 2hrΛt i such that p = QLtM, p0 = QLt0 M and t 7→vτ 0 t0 with 7→vτ 0 = 7→v ∪ ( 3i=1 7→τi ). A semantical and operational account of call-by-value solvability 13 τ As a technical Pnsimplification, we Pnextend →vτ to a binary relation on 2hrΛ i by linearity, i.e., ( i=1 qi )+P →vτ ( i=1 Qi )+P iff qi →vτ Qi for every i = 1, . . . , n (n ≥ 1). With this extension we can concisely state the following theorem: Theorem 31. Reduction →vτ on 2hrΛτ i is strongly normalizing and confluent. Definition 32. For every test p and repetition-free list ~x ⊇ fv(p), we define the interpretation JpK~x ⊆ Mf (U )n × 1 of p, where n is the length of ~x, by mutual induction with Def. 17 as follows: JεK~x = {([ ]n , 1)} Jτ [t]K~x = {(~a, 1) : (~a, [ ]) ∈ JtK~x } Jp k qK~x = {(~a ] ~b, 1) : (~a, 1) ∈ JpK~x , (~b, 1) ∈ JqK~x } Jt ∗ pK~x = {(~a ] ~b, c) : (~a, c) ∈ JtK~x , (~b, 1) ∈ JpK~x }. Finally, sums of tests are interpreted by setting J Pn i=1 pi K~x = Sn x. i=1 Jpi K~ Theorem 33 (soundness). Let P, Q ∈ 2hrΛτ i. If P →vτ Q, then JPK~x = JQK~x . Proof at p. 25 A key tool to connect the semantics with the vτ -reduction is the following transformation of elements of Mf (U ) into resource terms and test contexts. The role of this transformation is made clear in Lemma 35, used to prove Lemma 36. Definition 34. Let c = [(a1 , b1 ), . . . , (an , bn )] ∈ Mf (U ) (n ≥ 0). We define: – the closed resource term c− = [λy1 .b1− ∗a1+ L[y1m1 ]M, . . . , λyn .bn− ∗an+ L[ynmn ]M], where mi is the cardinality of the multiset ai (for i = 1, . . . , n); – the test-resource context c+ = τ [[λx.[ ]∗ kni=1 τ [[λy.[ ] ∗ bi + L[y ki ]M]([x]ai − )]]L·M], where ki is the cardinality if the multiset bi (for i = 1, . . . , n). Notation. For any a ∈ Mf (U ), #a indicates its cardinality. For ~a = (a1 , . . . , an ) ∈ Mf (U )n and t ∈ rΛt , we write th~a− /~xi as a shorthand for tha1− /x1 i · · · han− /xn i. Lemma 35. Let (~a, b) ∈ Mf (U )n × Mf (U ), k = #b and t ∈ rΛt with ~x ⊇ fv(t). Then (~a, b) ∈ JtK~x iff τ [[λy.[ ] ∗ b+ L[y k ]M](th~a− /~xi)] vτ ε. Lemma 36. Let s and t be v-normal resource terms without tests (i.e., generated by the grammar on §4, p. 6). If s ∈ Strat and t 6∈ Strat, then JsK~x ∩ JtK~x = ∅. Proof. Let (~a, b) ∈ Mf (U )n × Mf (U ) and QL·M = τ [[λy.[ ] ∗ b+ L[y k ]M](L·Mh~a− /~xi)], with k = #b. One can prove by induction on the v-normal resource terms (without tests) that: either QLtM vτ ε and QLsM vτ 0; or QLsM vτ ε and QLtM vτ 0; or QLsM vτ 0 and QLtM vτ 0. Hence, by Lemma 35, (~a, b) 6∈ JsK~x ∩ JtK~x . t u Hereafter, when we will mention resource terms, we will refer to the ones without test (i.e., generated by the grammar on §4, p. 6). The following theorem proves the implication (ii) ⇒ (iii) of Thm. 25. Theorem 37. Let M be a λ-term and let ~x ⊇ fv(M ). If M is solvable, then S x 6= ∅. t∈Ts (M ) JtK~ Proof at p. 26 14 A. Carraro, G. Guerrieri Proof. If M is solvable then there exists a context C = (λx1 . . .Sxm .L·M)N1 · · · Nn (for some n, m ≥ 0) such that CLM M v I. By Thm. 16 and 20, t∈T (CLM M) JtK~x = S S JCLM MK~x = JIK~x = t∈T (I) JtK~x . Using Lemma 36 we infer that t∈Ts (CLM M) JtK~x = S S JtK . Therefore t∈Ts (CLM M) JtK~x = 6 ∅ because it is easy to check that St∈Ts (I) ~x S JtK 6 = ∅. By Thm. 18 and 14, ~ x x 6= ∅ implies that there is a t∈Ts (I) t∈Ts (CLM M) JtK~ resource term in Ts (CLM M) that v-reduces to a non-zero v-normal form. Now all resource terms in Ts (CLM M) are of the shape RLsM for some s ∈ Ts (M ) (because the hole of C is in stratified position), so that if all resource terms in Ts (M ) v-reduced to 0, then all resource terms in Ts (CLM M) would v-reduce to 0. Thus, there is t ∈ Ts (M ) that v-reduces to a v-normal form T 6= 0. It is easy to prove that Jt0 K~x = 6 ∅ for every v-normal form t0 , hence JtK~x = JTK~x = 6 ∅ by Thm. 18. t u 6.4 From non-emptyness to strong normalization Our goal here is to prove the implication (iii) ⇒ (iv) of Thm. 24 and 25. Proof at p. 27 Lemma 38. Let M, M 0 be λ-terms. (i) If M →w M 0 and t ∈ T (M ), then there exists T ⊆ T (M 0 ) such that t →v T. (ii) If M →s M 0 and s ∈ Ts (M ), then there exists S ⊆ Ts (M 0 ) such that s →+ v S. Lemma 38.i is false if we replace the hypothesis M →w M 0 with M →s M 0 . For instance, take M = λx.Ω: then [ ] ∈ T (M ) and M →s M , but [ ] is v-normal. Theorem 39. Let M be a λ-term and let ~x ⊇ fv(M ). 1. [(iii)⇒(iv) of Thm. 24] IfSJM K~x 6= ∅ then M is strongly w-normalizing. 2. [(iii)⇒(iv) of Thm. 25] If t∈Ts (M ) JtK~x 6= ∅, then M is strongly s-normalizing. S Proof. Let (~a, b) ∈ JM K~x (resp. (~a, b) ∈ t∈Ts (M ) JtK~x ). By Thm. 20 (resp. Then) there exists t ∈ T (M ) (resp. t ∈ Ts (M )) such that (~a, b) ∈ JtK~x . If M →w M 0 (resp. M →s M 0 ), then by Lemma 38.i (resp. Lemma 38.ii) there exists T ⊆ T (M 0 ) (resp. T ⊆ Ts (M 0 )) such that t →+ a, b) ∈ JTK~x , hence v T. According to Thm. 18, (~ T 6= ∅ and so there exists t0 ∈ T such that (~a, b) ∈ Jt0 K~x . Therefore, if there was an infinite reduction M →w M1 →w M2 →w . . . (resp. M →s M1 →s M2 →s . . . ) + + then there would also be a an infinite reduction t →+ v T1 →v T2 →v . . . , which is impossible by Thm. 14. t u Conclusions and future work Our approach, that exploits the validity of the Taylor formula for a resource CBV λ-calculus, makes use of purely combinatorial proofs, rather than more standard approaches based on reducibility or some specific machines. The interesting feature of this approach is that it can be used for many different calculi always using a similar relational model and a suitable resource calculus. We think that using the ordinary syntax of λ-calculus with our reduction will allow to develop a reasonable theory of CBV Böhm trees, never defined before (Paolini’s separability result in [20] for λv -calculus does not use Böhm trees), together with connections between equivalence of Böhm trees and observational A semantical and operational account of call-by-value solvability 15 equivalence. A future challenge is that of finding other fully abstract denotational models, in view of Paolini and Ronchi Della Rocca’s proof of absence of fully abstract filter models (see [7, Thm. 12.1.25]) built from legal type systems. Another direction is relating two equivalence relations on λ-terms, the one generated by our σ-rules and the one induced by Girard’s CBV “boring” translation (·)v of λ-calculus into IMELL proof-nets (along the lines of [17,18,21]). References 1. Barendregt, H.P.: The Lambda Calculus: Its Syntax and Semantics. North-Holland, Amsterdam (1984) 2. Barendregt, H.: Solvability in lambda-calculi. J. Symb. Logic 75(3) (1975) 191–231 3. Wadsworth, C.: The Relation Between Computational and Denotational Properties for Scott’s D∞ -Models of the λ-Calculus. SIAM J. Comput. 5(3) (1976) 488–521 4. Plotkin, G.: Call-by-Name, Call-by-Value and the λ-Calculus. Theor. Comput. Sci. 1(2) (1975) 125–159 5. Accattoli, B., Paolini, L.: Call-by-Value Solvability, Revisited. In: FLOPS. (2012) 4–16 6. Paolini, L., Ronchi Della Rocca, S.: Call-by-value Solvability. ITA 33(6) (1999) 507–534 7. Paolini, L., Ronchi della Rocca, S.: The Parametric λ-calculus: a Metamodel for Computation. Texts in Theoretical Computer Science. Springer, Berlin (2004) 8. Paolini, L., Pimentel, E., Ronchi Della Rocca, S.: Strong Normalization from an unusual point of view. Theor. Comput. Sci. 412(20) (2011) 1903–1915 9. Herbelin, H., Zimmermann, S.: An operational account of Call-by-Value Minimal and Classical λ-calculus in ”Natural Deduction” form. In: TLCA. (2009) 142–156 10. Hofmann, M.: Sound and Complete Axiomatisations of Call-by-Value Control Operators. Mathematical Structures in Computer Science 5(4) (1995) 461–482 11. Moggi, E.: Computational Lambda-Calculus and Monads. In: LICS. (1989) 14–23 12. Dyckhoff, R., Lengrand, S.: Call-by-Value lambda-calculus and LJQ. J. Log. Comput. 17(6) (2007) 1109–1134 13. Egidi, L., Honsell, F., Ronchi Della Rocca, S.: Operational, denotational and logical descriptions: a case study. Fundamenta Informaticæ 16(2) (1992) 149–169 14. Ehrhard, T.: Collapsing non-idempotent intersection types. In: CSL. (2012) 259–273 15. Bucciarelli, A., Carraro, A., Ehrhard, T., Manzonetto, G.: Full Abstraction for the Resource Lambda Calculus with Tests, through Taylor Expansion. Logical Methods in Computer Science 8(4) (2012) 16. Girard, J.: Linear Logic. Theor. Comput. Sci. 50(1) (1987) 1–102 17. Regnier, L.: Lambda calcul et réseaux. PhD thesis, Université Paris 7 (1992) 18. Regnier, L.: Une équivalence sur les lambda-termes. Theor. Comput. Sci. 126(2) (1994) 281–292 19. Melliès, P.: Categorical semantics of Linear Logic. In: Interactive models of computation and program behaviour. Volume 27 of Panoramas et Synthèses. Société Mathématique de France (2009) 1–196 20. Paolini, L.: Call-by-Value Separability and Computability. In: ICTCS. (2001) 74–89 21. Accattoli, B., Kesner, D.: The Permutative λ-Calculus. In: LPAR. (2012) 23–36 16 A. Carraro, G. Guerrieri A Technical appendix A.1 Stated at p. 4 Proofs and remarks of Section 2 Proposition 2. The reduction →σ is strongly normalizing. Proof. First we define two sizes s(M ) and #M by induction on the λ-term M : – #x = 1; – s(x) = 2; – #λx.M = #M + s(M ); – s(λx.M ) = s(M ) + 1; – #M N = #M + #N + 2s(M )s(N ) − 1. – s(M N ) = s(M ) + s(N ). Notice that s(N ) ≥ 2 and #N ≥ 1 for any λ-term N . In order to prove that σ-reduction is strongly normalizing, it suffices to show that if M →σ M 0 then s(M ) = s(M 0 ) and #M > #M 0 . We proceed by induction on the definition of M →σ M 0 . If M 7→σ1 M 0 then M = (λx.M0 )N L and M 0 = (λx.M0 L)N , hence #M = #M0 + #L + #N + s(M0 ) + 2 s(N ) + 2 s(L) + 2 s(M0 )s(N ) + 2 s(M0 )s(L) + 2 s(L)s(N ) − 2 0 #M = #M0 + #L + #N + s(M0 ) + 2 s(N ) + s(L) + 2 s(M0 )s(N ) + 2 s(M0 )s(L) + 2 s(L)s(N ) − 2 so #M = #M 0 +s(L) > #M 0 . Moreover s(M ) = s(M0 )+s(L)+s(N )+1 = s(M 0 ). If M 7→σ3 M 0 then M = V ((λxL)N ) and M 0 = (λx.V L)N , hence #M = #V + #L + #N + 2 s(V ) + 2 s(N ) + s(L) + 2 s(V )s(N ) + 2 s(V )s(L) + 2 s(L)s(N ) − 2 #M 0 = #V + #L + #N + s(V ) + 2 s(N ) + s(L) + 2 s(V )s(N ) + 2 s(V )s(L) + 2 s(L)s(N ) − 2 so #M = #M 0 + s(V ) > #M 0 . Moreover s(M ) = s(V ) + s(L) + s(N ) + 1 = s(M 0 ). If M = λx.N and M 0 = λx.N 0 with N →σ N 0 , then #M = #N + s(N ) and #M 0 = #N 0 + s(N 0 ); by induction hypothesis, #N > #N 0 and s(N ) = s(N 0 ), hence #M > #N 0 + s(N ) = #M 0 and s(M ) = s(N ) + 1 = s(M 0 ). If M = LN and M 0 = L0 N (resp. M = N L and M 0 = N L0 ) with L →σ L0 , then #M = #L + #N + 2 s(L)s(N ) − 1 and #M 0 = #L0 + #N + 2 s(L0 )s(N ) − 1; by induction hypothesis, #L > #L0 and s(L) = s(L0 ), hence #M > #L + #N + 2 s(L0 )s(N ) − 1 = #M 0 and s(M ) = s(L) + s(N ) = s(M 0 ). t u Stated at p. 4 Proposition 3. The reduction →σ is confluent. Proof. By Newman’s lemma and Prop. 2, it suffices to show that →σ is locally confluent: if M →σ N1 and M →σ N2 then there is M 0 s.t. N1 σ M 0 and N2 σ M 0 . We proceed by induction on M , the only interesting cases are: – if M = (λx.M0 ) (λy.L)N L0 with M →σ1 (λx.M0 L0 ) (λy.L)N = N1 and M →σ3 (λy.(λx.M0 )L)N L0 = N2 , then N2 →σ1 (λy.(λx.M0 )LL0 )N →σ1 (λy.(λx.M0 L0 )L)N = M 0 and N1 →σ3 M 0 ; A semantical and operational account of call-by-value solvability 17 – if M = V (λx.L)((λx0 .L0 )N) with M →σ3 V (λx0 .(λx.L)L0 )N =N1 and M →σ3 (λx.V L) (λx0 .L0 )N = N2 , then N1 →σ3 λx0 .V ((λx.L)L0 ) N →σ3 (λx0 .(λx.V L)L0 )N = M 0 and N2 →σ3 M 0 . t u Lemma 5. Let M, M 0 ∈ Λ, V, V 0 , V1 , . . . , Vm ∈ Λv and R ∈ {βv , σ, v}. (i) If V →R V 0 then M {V /x} R M {V 0 /x}. (ii) If M →R M 0 then M {V1 /x1 , . . . , Vm /xm } →R M 0 {V1 /x1 , . . . , Vm /xm }. Proof. For R = βv , the proofs of (i) and (ii) are in [4]. For R = v, the proof of (i) (resp. (ii)) is a consequence of the property (i) (resp. (ii)) for both →βv and →σ , since →v = →βv ∪ →σ . Let us prove (i) and (ii) for R = σ. (i) The proof is by induction on the λ-term M . If M = x, then M {V /x} = V and M {V 0 /x} = V 0 , so M {V /x} σ M {V 0 /x} by hypothesis. If M = y = 6 x, then M {V /x} = y = M {V 0 /x}, then M {V /x} σ M {V 0 /x} by reflexivity of σ . If M = λy.N for some λ-term N , then we can suppose without loss of generality that y ∈ / fv(V ) ∪ {x}, so M {V /x} = λy.N {V /x} and M {V 0 /x} = 0 λy.N {V /x}; by induction hypothesis, N {V /x} σ N {V 0 /x} and therefore M {V /x} σ M {V 0 /x}. If M = LN for some λ-terms L and N , then M {V /x} = L{V /x}N {V /x} and M {V 0/x} = L{V 0/x}N {V 0/x}; L{V /x} σ L{V 0 /x} and N {V /x} σ N {V 0 /x} by induction hypothesis, thus M {V /x} σ L{V 0 /x}N {V /x} σ M {V 0 /x}. (ii) The proof is by induction on the definition of M →σ M 0 . For any λ-term N we set N ∗ = N {V1 /x1 , . . . , Vm /xm }. If M 7→σ1 M 0 then M = (λy.M0 )N L and M 0 = (λy.M / fv(L); 0 L)N with y ∈ Sm we can suppose without loss of generality that y ∈ / i=1 (fv(Vi ) ∪ {xi }), so 0∗ M ∗ = (λy.M0∗ )N ∗ L∗ and MS = (λy.M0∗ L∗ )N ∗ , hence M ∗ →σ1 M 0∗ since m y∈ / (fv(L) \ {x1 , . . . , xm }) ∪ i=1 fv(Vi ) = fv(L∗ ). If M 7→σ3 M 0 then M = V ((λy.L)N ) and M 0 = (λy.V / fv(V ); Sm L)N with y ∈ we can suppose without loss of generality that y ∈ / i=1 (fv(Vi ) ∪ {xi }), thus 0∗ ∗ ∗ ∗ M ∗ = V ∗ ((λy.L∗ )N ∗ ) and M , so M ∗ →σ3 M 0∗ since Sm = (λy.V L )N ∗ y∈ / (fv(V ) \ {x1 , . . . , xm }) ∪ i=1 fv(Vi ) = fv(V ). If M = λy.N and M 0 = λy.NS0 with N →σ N 0 then we can suppose without m loss of generality that y ∈ / i=1 (fv(Vi ) ∪ {xi }), hence M ∗ = λy.N ∗ and M 0∗ = λy.N 0∗ ; by induction hypothesis, N ∗ →σ N 0∗ and so M ∗ →σ M 0∗ . If M = LN and M 0 = L0 N (resp. M = N L and M 0 = N L0 ) with L →σ L0 , then M ∗ = L∗ N ∗ and M 0∗ = L0∗ N ∗ (resp. M ∗ = N ∗ L∗ and M 0∗ = N ∗ L0∗ ); by induction hypothesis, L∗ →σ L0∗ , so M ∗ →σ M 0∗ . t u Lemma 40. Let →1 , →2 ⊆ X 2 (for any set X) be such that if t →1 u1 and t →2 u2 then there is v ∈ X such that u2 1 v and u1 →2 v. Then they commute (i.e. if t 1 u1 and t 2 u2 then there is s ∈ X such that u1 2 s and u2 1 s). Proof. For every t, u ∈ X, → ⊆ X 2 and n ∈ N, we write t →n u if there exist v0 , . . . , vn ∈ X such that t = v0 , u = vn and vi → vi+1 for all 0 ≤ i ≤ n. We prove Stated at p. 5 18 A. Carraro, G. Guerrieri the following stronger statement, in order to apply the right induction hypothesis: 0 0 m 0 if t 1 u1 and t →m 2 u2 then there exists t ∈ X such that u2 1 t and u1 →2 t . n Let t →1 u1 : the proof is by induction on (m, n) with the lexicographical order on N2 . If m = 0 or n = 0, we conclude easily. Let m, n > 0: there exist u01 , u02 ∈ X such that t →1 u01 , t →2 u02 , u01 →n−1 u1 1 0 0 and u02 →m−1 u . By hypothesis, there is v ∈ X such that u → v and u 2 2 1 v. 1 2 2 By induction hypothesis applied to u02 , there is v 0 ∈ X such that u2 1 v 0 and 0 0 m v m−1 v 0 ; thus u01 →m 2 v , so there exists s ∈ X such that v 1 s and u1 →2 s 2 0 by applying the induction hypothesis to u1 , therefore u2 1 s. t u Stated at p. 5 Lemma 6. The reductions →βv and →σ commute. Proof. By lemma 40, it suffices to prove that if M →σ N1 and M →βv N2 then there is L such that N2 σ L and N1 →βv L. The proof of this property is by induction on M . The only interesting cases are: – if M = (λx.N )V L0 with M →σ1 (λx.N L0 )V = N1 and M →βv N {V /x}L0 = N2 , then N1 →βv N2 since x ∈ / fv(L0 ). – if M = U ((λx.N )V ) with M →σ3 (λx.U N )V = N1 and M →βv U (N {V /x}) = N2 , then N1 →βv N2 since x ∈ / fv(U ). – if M = (λy.N 0 ) (λx.N )V L0 with M →σ1 (λy.N 0 L0 )(λx.N )V = N1 and M →βv (λy.N 0 )N {V /x}L0 = N2 , then N1 →βv (λy.N 0 L0 )N {V /x} = L and N2 →σ1 L. – if M = (λx.N )V with M →σ N1 = (λx.N )V 0 (resp. N1 = (λx.N 0 )V ), M →βv N {V /x} = N2 and V →σ V 0 (resp. N →σ N 0 ), then we conclude by Lemma 5.i (resp. 5.ii). t u Remark 41. The reductions →σ and →v are not strongly confluent. For in0 0 0 stance take N = zI, L = z I and M = (λx.x ) (λy.y I)N L: one has M →σ1 (λx.x0 L) (λy.y 0 I)N = N3 and M →σ3 λy.(λx.x0 )(y 0 I) N L = N1 (with N1 6= N3 ) but for i ∈ {1, 3} the only v-redex in Ni is the σi -redex Ni itself; therefore N1 →σ1 λy.(λx.x0 )(y 0 I)L N 6= λy.(λx.x0 L)(y 0 I) N σ3 ← N3 . Remark 42. If we define a Tait–Martin-Löf parallel reduction →ρ of →v in the obvious way, then →ρ is not strongly confluent. For instance, take M = (λx.L) (λy.N )((λz.N 0 )N 00 ) L0 , M1 = (λx.LL0 ) (λy.N )((λz.N 0 )N 00 ) and M2 = (λy.(λx.L)N )((λz.N 0 )N 00 ) L0 : then M →ρ M1 and M →ρ M2 but there is no λ-term M 0 such that M1 →ρ M 0 ρ ← M2 . Informally, →ρ is not able to reduce in one step several “subsequent” σ1 -redexes created by one σ3 -step. Therefore, we cannot adapt the Tait–Martin-Löf technique in a natural way in order to prove that →v is confluent. Remark 43. If in definition of 7→σ3 (Def. 1) we replace the λ-value V with any λ-term M then →σ and →v are not (locally) confluent. For instance, take Ni = (zi )I for i ∈ {1, 2} and M = (λx1 .y1 )N1 (λx2 .y2 )N2 : one would have M →σ3 (λx2 .(λx1 .y1 )N1 y2 )N2 = L1 and M →σ1 λx1 .y1 ((λx2 .y2 )N2 ) N1 = L3 (with L1 = 6 L3 ) but the only v-redex in L1 (resp. L3 ) is the σ1 -redex (λx1 .y1 )N1 y2 (resp. σ3 -redex y1 ((λx2 .y2 )N )); so L → λx .(λx .y y )N 1 σ1 2 1 1 2 1 N2 = N12 and 2 L3 →σ3 λx1 .(λx2 .y1 y2 )N2 N1 = N21 , with N12 6= N21 and N12 , N21 v-normal. A semantical and operational account of call-by-value solvability A.2 19 Proofs and remarks of Section 3 Lemma 44. Let M, M 0 ∈ Λ, V1 , . . . , Vm ∈ Λv and R ∈ {w[βv ], w[σ], s[βv ], s[σ]}. If M →R M 0 then M {V1 /x1 , . . . , Vm /xm } →R M 0 {V1 /x1 , . . . , Vm /xm }. Proof. All the proofs are by induction on the definition of M →R M 0 . For R ∈ {w[σ], s[σ]}, the proof is analogous to that one for Lemma 5.ii. For R = w[βv ] (for any λ-term N we set N ∗ = N {V1 /x1 , . . . , Vm /xm }): – If M 7→βv M 0 then M = (λy.N )V and M 0 = S N {V /y}, moreover we can m suppose without loss of generality that y ∈ / i=1 (fv(Vi ) ∪ {xi }); hence, ∗ ∗ ∗ ∗ ∗ 0∗ M = (λy.N )V →βv N {V /y} = M (since V ∗ is a value). – If M = LN and M 0 = L0 N (resp. M = N L and M 0 = N L0 ) with L →w[βv ] L0 , then M ∗ = L∗ N ∗ and M 0∗ = L0∗ N ∗ (resp. M ∗ = N ∗ L∗ and M 0∗ = N ∗ L0∗ ); by induction hypothesis, L∗ →w[βv ] L0∗ , so M ∗ →w[βv ] M 0∗ . – If M = (λy.N )L and M 0 = (λy.N 0 )L withSN →w[βv ] N 0 , moreover we can m suppose without loss of generality that y ∈ / i=1 (fv(Vi ) ∪ {xi }); hence, M ∗ = ∗ ∗ 0∗ 0∗ ∗ (λy.N )L and M = (λy.N )L ; by induction hypothesis, N ∗ →w[βv ] N 0∗ and thus M ∗ →w[βv ] M 0∗ . For R = s[βv ] (for any λ-term N we set N ∗ = N {V1 /x1 , . . . , Vm /xm }): – If M →w[βv ] M 0 then we have just proved that M ∗ →w[βv ] M 0∗ and so M ∗ →s[βv ] M 0∗ (since →w[βv ] ⊆ →s[βv ] ). – If M = LN and M 0 = L0 N (resp. M = λy.L and M 0 = λy.L0 ) with L →s[βv ] L0 , then M ∗ = L∗ N ∗ and M 0∗ = L0∗ N ∗ (resp. M ∗ S = λy.L∗ and m 0∗ 0∗ M = λy.L , by supposing without loss of generality that y ∈ / i=1 (fv(Vi ) ∪ ∗ 0∗ ∗ {xi })); by induction hypothesis, L →s[βv ] L , so M →s[βv ] M 0∗ . t u Remark 45. There are no λ-values V and V 0 such that V →w V 0 . For R ∈ {s[βv ], s[σ]}, if V →R V 0 then V = λz.N , V 0 = λz.N 0 and N →R N 0 . Remark 46. For R ∈ {s[βv ], s[σ]}, the analogous of Lemma 5.i does not hold: V →R V 0 does not imply M {V /x} R M {V 0 /x}. For instance, take M = yx: by Remark 45, for any λ-value V , M {V /x} = yV is R-normal. Lemma 9. (i) The reductions →w[βv ] and →s[βv ] are strongly confluent. (ii) The reductions →w[σ] and →s[σ] are confluent. (iii) The reductions →w[βv ] and →w[σ] (resp. →s[βv ] and →s[σ] ) commute. Proof. (i) Let R ∈ {w[βv ], s[βv ]}. We prove by induction on M ∈ Λ that if M →R N1 and M →R N2 then there is M 0 ∈ Λ such that N1 →R M 0 and N2 →R M 0 . The only interesting case is when M = (λx.N )V with M →R N {V /x} = N1 , M →R (λx.N 0 )V = N2 and N →R N 0 : N2 →R N 0 {V /x} and, by Lemma 44, N1 →R N 0 {V /x}. Stated at p. 5 20 A. Carraro, G. Guerrieri (ii) By Newman’s lemma and Prop. 2 (since →w[σ] , →s[σ] ⊆ →σ ), it suffices to show that →w[σ] and →s[σ] are locally confluent. The proof that →w[σ] and →s[σ] are locally confluent are analogous to that one for the local confluence of →σ seen in Prop. 3. (iii) The proof is analogous to that one for Lemma 6 (in particular, we use Lemma 40). The only notable difference is that here there is not a case where, for R ∈ {w, s}, M = (λx.N )V , M →R[βv ] N {V /x} = N2 and M →R[σ] (λxN )V 0 = N1 with V →R[σ] V 0 (see Remarks 45 and 46). t u Notice that every s-normal forms is also a w-normal form, since →w ⊆ →s . Obviously, every βv -redex is also a β-redex (a λ-term of the form (λx.M )N ). Stated at p. 6 Proposition 12. Let M be a λ-term. (i) M is w-normal iff M ∈ wnf . (ii) M is s-normal iff M ∈ snf . (iii) M is w-(resp. s-)normal and is neither a value nor a β-redex iff M ∈ anf . Proof. ⇒: We prove simultaneously the left-to-right part of the three statements, by induction on the λ-term M . If M is a λ-value then M ∈ wnf . Furthermore, if M is a variable then M ∈ snf ; if M = λx.N is s-normal (for some λ-term N ) then N is s-normal, hence N ∈ snf by induction hypothesis, and so M ∈ snf . If M is not a λ-value then M = M1 M2 for some λ-terms M1 and M2 . By simple inspection of the definition of →w (resp. →s ), the fact that M is w-(resp. s-)normal implies that M1 is w-(resp. s-)normal and M2 is w-normal, moreover M1 is not a β-redex (otherwise M would be a σ1 -redex) and M is neither a βv - nor a σ3 -redex. There are only three cases: 1. M1 is not a value: by induction hypothesis M1 ∈ anf and M2 ∈ wnf , therefore M ∈ anf wnf ⊆ anf . 2. M1 = λx.N : then M2 is neither a β-redex (otherwise M would be a σ3 -redex) nor a value (otherwise M would be a βv -redex), so M2 ∈ anf by induction hypothesis. Moreover, the fact that M1 is w-(resp. s-)normal entails that N is w-(resp. s-)normal and thus N ∈ wnf (resp. N ∈ snf ), by induction hypothesis. Hence M ∈ anf . 3. M1 is a variable: if M2 is a value then M ∈ anf ; if M2 is not a value then M2 is not a β-redex (otherwise M would be a σ3 -redex) and thus M2 ∈ anf by induction hypothesis, therefore M ∈ anf . ⇐: The proof right-to-left part of the statement (i) (resp. (ii)) is by induction on M ∈ wnf (resp. M ∈ snf ). The right-to-left part of the statement (iii) is an immediate consequence of (i) and (ii), since anf ⊆ snf ⊆ wnf and if M ∈ anf then M is neither a value nor a β-redex. t u A semantical and operational account of call-by-value solvability A.3 Stated at p. 8 21 Proofs of Section 5 Theorem 16 (soundness). Let M, N ∈ Λ. If M →v N , then JM K~x = JN K~x . Proof. For soundness w.r.t. the βv -rule we refer to [14] (see also Lemma 48). Regarding the σ-rules we have: J(λy.M )N LK~x = {(~a0 ] ~a1 ] ~a2 , c) : ∃b ∈ Mf (U ). ∃d ∈ Mf (U ). ((~a1 , d), [(b, c)]) ∈ JM K~x,y , (~a0 , b) ∈ JLK~x , (~a2 , d) ∈ JN K~x } = J(λy.M L)N K~x which validates the rule σ1 , and JV ((λy.L)N )K~x = {(~a0 ] ~a1 ] ~a2 , c) : ∃b ∈ Mf (U ). ∃d ∈ Mf (U ). (~a0 , [(b, c)]) ∈ JV K~x , ((~a1 , d), b) ∈ JLK~x,y , (~a2 , d) ∈ JN K~x } = J(λy.V L)N K~x which validates the rule σ3 . Finally it is easy to check that the interpretation is contextual. t u Theorem 18 (soundness). Let S, T ∈ 2hrΛt i. If S →v T, then JSK~x = JTK~x . Stated at p. 9 Proof. For soundness w.r.t. the βv -rule and 0-rule, we refer to [14]. Regarding the σ-rules we have: J[λy.t]ss0 K~x = {(~a0 ] ~a1 ] ~a2 , c) : ∃b ∈ Mf (U ). ∃d ∈ Mf (U ). ((~a1 , d), [(b, c)]) ∈ JtK~x,y , (~a0 , b) ∈ Js0 K~x , (~a2 , d) ∈ JsK~x } = J[λy.ts0 ]sK~x which validates the rule σ1 , and J[v]([λy.t]s)K~x = {(~a0 ] ~a1 ] ~a2 , c) : ∃b ∈ Mf (U ). ∃d ∈ Mf (U ). (~a0 , [(b, c)]) ∈ JvK~x , ((~a1 , d), b) ∈ JtK~x,y , (~a2 , d) ∈ JsK~x } = J[λy.[v]t]sK~x which validates the rule σ3 . Finally it is easy to check that the interpretation is contextual. t u A.4 Proofs of Subsection 6.1 Lemma 26. Let M be a λ-term with fv(M ) ⊆ {x1 , . . . , xm } and let j ∈ N. – If M ∈ anf then there exists h ∈ N∗ such that for all n1 , . . . , nm ≥ j + h one has M {on1 /x1 , . . . , onm /xm } v ok for some k ≥ j. – If M ∈ wnf then there is h ∈ N∗ such that for all n1 , . . . , nm ≥ j + h one has M {on1 /x1 , . . . , onm /xm } v λx.N for some λ-term N s.t. λx.N is closed. Stated at p. 10 22 A. Carraro, G. Guerrieri Proof. By mutual induction on M ∈ anf and M ∈ wnf . Notice that if M ∈ anf then fv(M ) 6= ∅ and thus m > 0. If M = xV for some variable x and λ-value V , then x = xi for some 1 ≤ i ≤ m. Let n1 , . . . , nm ≥ j + 1. One has M {on1 /x1 , . . . , onm /xm } = oni V {on1 /x1 , . . . , onm /xm } →v oni −1 (since V {on1 /x1 , . . . , onm /xm } is a λvalue) where ni − 1 ≥ j. Hence we conclude by taking h = 1 and k = ni − 1. If M = xN for some variable x and N ∈ anf , then x = xi for some 1 ≤ i ≤ m. By induction hypothesis there exists h ∈ N∗ such that for all n1 , . . . , nm ≥ j + h one has N {on1 /x1 , . . . , onm /xm } v ok for some k ≥ j. Hence for all n1 , . . . , nm ≥ j + h one has M {on1 /x1 , . . . , onm /xm } v oni ok →v oni −1 where ni − 1 ≥ j + h − 1 ≥ j. If M = N 0 N 00 for some N 0 ∈ anf and N 00 ∈ wnf , then by induction hypothesis there are h0 , h00 ∈ N∗ s.t. for all n01 , . . . , n0m ≥ j + 1 + h0 and n001 , . . . , n00m ≥ j + h00 0 0 00 00 one has N 0 {on1 /x1 , . . . , onm /xm } v ok and N 00 {on1 /x1 , . . . , onm /xm } v λx.L for some k ≥ j +1 and λ-term L such that λx.L is closed. Let h = max{h0 +1, h00 }: for all n1 , . . . , nm ≥ j + h one has N {on1 /x1 , . . . , onm /xm } v ok λx.L →v ok−1 where k − 1 ≥ j. If M is a variable then M = xi for some 1 ≤ i ≤ m, hence for all n1 , . . . , nm ≥ j + 1 one has M {on1 /x1 , . . . , onm /xm } = oni which is a closed abstraction. If M = λx.N for some λ-term N , then we can suppose without loss of generality that x 6= xi for any 1 ≤ i ≤ m, so M {on1 /x1 , . . . , onm /xm } = λx.N {on1 /x1 , . . . , onm /xm } which is closed because the oni ’s are closed and fv(N ) ⊆ {x, x1 , . . . , xn }. If M = (λx.N 0 )N 00 for some λ-terms N 0 ∈ wnf and N 00 ∈ anf then we can suppose without loss of generality that x 6= xi for any 1 ≤ i ≤ m, moreover fv(N 0 ) ⊆ {x, x1 , . . . , xm }. By induction hypothesis, there exist h0 , h00 ∈ N∗ such that for all n0 , n01 , . . . , n0m ≥ j + h0 and n001 , . . . , n00m ≥ j + h0 + h00 one has 0 0 0 00 00 N 0 {on /x, on1 /x1 . . . , onm /xm } v λxL and N 00 {on1 /x1 , . . . , onm /xm } v ok for some k ≥ j + h0 and λ-term L s.t. λx.L is closed. If h = h0 + h00 then, for all n1 , . . . , nm ≥ j +h, M {on1/x1 , . . . , onm/xm } v (λx.N 0 {on1/x1 , . . . , onm/xm })ok →v N 0 {ok /x, on1 /x1 . . . , onm /xm } v λx.L. t u Stated at p. 11 Lemma 27. Let M ∈ snf with fv(M ) ⊆ {x1 , . . . , xm } and let j ∈ N. Then there exist h, k ∈ N such that for all n1 , . . . , nm+k ≥ j + h there exists n ≥ j such that M {on1 /x1 , . . . , onm /xm }onm+1 . . . onm+k v on . Proof. By induction on M ∈ snf . If M is a variable then M = xi with 1 ≤ i ≤ m, so M {on1 /x1 , . . . , onm /xm } = ni o where ni ≥ j, hence we conclude by taking h = 0 = k. If M = λx.N for some N ∈ snf then we can suppose without loss of generality that x 6= xi for any 1 ≤ i ≤ m, moreover fv(N ) ⊆ {x, x1 , . . . , xm }. By induction hypothesis, there exist h, k 0 ∈ N such that for all n0 , n1 , . . . , nm+k ≥ j +h one has A semantical and operational account of call-by-value solvability 23 0 (N {on /x, on1 /x1 . . . , onm /xm })onm+1 . . . onm+k0 v on for some n ≥ j. Hence 0 (M {on1 /x1 , . . . , onm /xm })on onm+1 . . . onm+k0 = 0 (λxN {on1 /x1 , . . . , onm /xm })on onm+1 . . . onm+k0 →v 0 (N {on /x, on1 /x1 . . . , onm /xm })onm+1 . . . onm+k0 v on where n ≥ j, thus we conclude by taking k = k 0 + 1. If M = (λx.N 0 )N 00 for some λ-terms N 0 ∈ snf and N 00 ∈ anf then we can suppose without loss of generality that x 6= xi for any 1 ≤ i ≤ m, moreover fv(N 0 ) ⊆ {x, x1 , . . . , xm }. By induction hypothesis, there exist h0 , k ∈ N such that for all n0 , n01 , . . . , n0m+k ≥ j + h0 one has 0 0 0 0 0 (N 0 {on /x, on1 /x1 . . . , onm /xm })onm+1 . . . onm+k v on for some n ≥ j. By lemma 26 there exists h00 ∈ N∗ such that for all n001 , . . . , n00m ≥ 00 00 00 j + h0 + h00 one has N 00 {on1 /x1 , . . . , onm /xm } v on for some n00 ≥ j + h0 . Let h = h0 + h00 : for all n1 , . . . , nm+k0 ≥ j + h one has (where n ≥ j) (M {on1 /x1 , . . . , onm /xm })onm+1 . . . onm+k v 00 (λxN 0 {on1 /x1 , . . . , onm /xm })on onm+1 . . . onm+k →v 00 (N 0 {on /x, on1 /x1 . . . , onm /xm })onm+1 . . . onm+k v on If M ∈ anf then there exists h ∈ N∗ such that for all n1 , . . . , nm ≥ j + h one has M {on1 /x1 , . . . , onm /xm } v on for some n ≥ j by lemma 26, thus we conclude by taking k = 0. t u A.5 Proofs of Subsection 6.2 The two following lemmas are used in the proof of Thm. 29 at p. 11. Lemma 47. Let V be a λ-value and ~x = (x1 , . . . , xn ) ⊇ fv(V ) (with n ∈ N). (i) For every ((a1 , . . . , an ), [ ]) ∈ JV K~x one has ai = [ ] for any 1 ≤ i ≤ n; 1 1 1 m m m (ii) For any Um m i ∈ N, if ((a1 , . . . , an ), a0 ), . . . , ((a1 , . . . , an ), a0 ) ∈ JV K~x and aj = i=1 aj for any 0 ≤ j ≤ n, then ((a1 , . . . , an ), a0 ) ∈ JV K~x (in particular, ([ ]n , [ ]) ∈ JV K~x ). Proof. We prove simultaneously points (i) and (ii) by simple inspection. – If V is a variable then V = xk for some 1 ≤ k ≤ n, thus ((a1 , . . . , an ), [ ]) ∈ m JV K~x entails aj = [ ] for any 1 ≤ j ≤ n. If ((a11 , . . . , a1n ), a10 ), . . . , ((am , . . . , am n ), a0 ) ∈ 1U m i i i ak (and so a0 = i=1 a0 = Jxk K~x then, for every 1 ≤ i ≤ m, one has U Uma0 = m i i i i=1 ak = ak ) and aj = [ ] (and so aj = i=1 aj = [ ]) for any 1 ≤ j ≤ n with j 6= k, therefore ((a1 , . . . , an ), a0 ) = (([ ], . . . , ak , . . . , [ ]), ak ) ∈ Jxk K~x = JV K~x . 24 A. Carraro, G. Guerrieri Up – If V = λy.N for some λ-term N then JV K~x = {( k=1 d~k , [(b1 , c1 ), . . . , (bp , cp )]) : p ≥ 0, ∀k = 1, . . . , p. ((d~k , bk ), ck ) ∈ JN K~x,y }. If ((a1 , . . . , an ), [ ]) ∈ JV K~x then m m p = 0 and so aj = [ ] for any 1 ≤ j ≤ n. If ((a11 , . . . , a1n ), a10 ), . . . , ((am 1 , . . . , an ), a0 ) ∈ i i i i JV K~x then, for any 1 ≤ i ≤ m, there exist pi ∈ N, b1 , . . . , bpi , c1 , . . . , cpi ∈ Mf (U ) and (ai1,1 , . . . , ain,1 ), . . . , (ai1,pi , . . . , ain,pi ) ∈ Mf (U )n such that ai0 = Upi [(bi1 , ci1 ), . . . , (bipi , cipi )], aij = k=1 aij,k for any 1 ≤ j ≤ n and ((ai1,k , . . . , ain,k , bik ), cik ) ∈ Um JN K for any 1 ≤ i ≤ m and 1 ≤ k ≤ pi ; since aj = i=1 aij = Um ~x,yUpi U U U m m pi i i i i i=1 k=1 aj,k for any 1 ≤ j ≤ n and a0 = i=1 a0 = i=1 k=1 [(bk , ck )], one has ((a1 , . . . , an ), a0 ) ∈ Jλy.N K~x = JV K~x . t u Lemma 48. Let M be a λ-term, let ~x = (x1 , . . . , xm ) and ~y = (y1 , . . . , yn ) be two finite sequences of pairwise distinct variables Sm such that fv(M ) ⊆ {x1 , . . . , xm , y1 , . . . , yn }. If V1 , . . . , Vm are λ-values such that i=1 fv(Vi ) ⊆ {y1 , . . . , yn }, then Um JM {V1 /x1 , . . . , Vm /xm }K~y = ( i=0 ~ai , c) : ∃ b1 , . . . , bm ∈ Mf (U ). ((~a0 , b1 , . . . , bm ), c) ∈ JM K~y,~x and (~ai , bi ) ∈ JVi K~y for all 1 ≤ i ≤ m (1) Proof. By induction on M . Let us denote by S the set in the right-hand side of relation (1), and by N ∗ the λ-term N {V1 /x1 , . . . , Vm /xm }, for any λ-term N . If M = xi for some 1 ≤ i ≤ m, then JM ∗ K~y = JVi K~y = S by Lemma 47 and since Jxi K~y,~x = {(([ ]n , [ ], . . . , c, . . . , [ ]), c) : c ∈ Mf (U )}. If M is a variable different from all xi ’s, then M = yj for some 1 ≤ j ≤ n, hence JM ∗ K~y = Jyj K~y = {(([ ], . . . , c, . . . , [ ]), c) : c ∈ Mf (U )} = S by Lemma 47 and since Jyj K~y,~x = {(([ ], . . . , c, . . . , [ ], [ ]m ), c) : c ∈ Mf (U )}. If M = λzN for some λ-term N then fv(N ) ⊆ {x1 , . . . , xm , y1 , . . . , yn , z} and we can suppose without loss of generality that z ∈ / {x1 , . . . , xm , y1 , . . . , yn }, so Uk JM ∗ K~y = Jλz.N ∗ K~y = ( j=1 ~aj , [(d1 , c1 ), . . . , (dk , ck )]) : k ≥ 0, ((~aj , dj ), cj ) ∈ JN ∗ K~y,z for all 1 ≤ j ≤ k . (2) By induction hypothesis, for every 1 ≤ j ≤ k, ((~aj , dj ), cj ) ∈ JN ∗ K~y,z if and only if there exist bj1 , . . . , bjm ∈ Mf (U ) and ~aj0 , . . . , ~ajm ∈ Mf (U )n such that ~aj = Um j ai , ((~aj0 , dj , bj1 , . . . , bjm ), cj ) ∈ JN K~y,z,~x and ((~aji , [ ]), bji ) ∈ JVi K~y,z (which i=0 ~ is equivalent to (~aji , bji ) ∈ JVi K~y because z ∈ / fv(Vi )) for any 1 ≤ i ≤ m; let Uk Uk Um j 1 1 k k c = [(d , c ), . . . , (d , c )], ~ai = j=1 ~ai and bi = j=1 bji : one has i=0 ~ai = Um U k Uk aji = j=1 ~aj , ((~a0 , b1 , . . . , bm ), c) ∈ Jλz.N K~y,~x and, by Lemma 47, i=0 j=1 ~ (~ai , bi ) ∈ JVi K~y for all 1 ≤ i ≤ m. Therefore, according to relation (2), JM ∗ K~y = S. If M = N L then fv(N ), fv(L) ⊆ {y1 , . . . , yn } and JM ∗ K~y = JN ∗ L∗ K~y = {(a~0 ] a~00 , c) | ∃ b ∈ Mf (U ) : (a~0 , [(b, c)]) ∈ JN ∗ K~y and (a~00 , b) ∈ JL∗ K~y }. (3) By induction hypothesis, (a~0 , [(b, c)]) ∈ JN ∗ K~y iff there exist b01 , . . . , b0m ∈ Mf (U ) Um and a~00 , . . . , a~0m ∈ Mf (U )n such that a0 = i=0 a~0i , ((a~00 , b01 , . . . , b0m ), [(b, c)]) ∈ A semantical and operational account of call-by-value solvability 25 JN K~y,~x and (a~0i , b0i ) ∈ JVi K~y for all 1 ≤ i ≤ m; and (a~00 , b) ∈ JL∗ K~y iff there Um exist b001 , . . . , b00m ∈ Mf (U ) and a~000 , . . . , a~00m ∈ Mf (U )n such that a00 = i=0 a~00i , ((a~000 , b001 , . . . , b00m ), b) ∈ JLK~y,~x and (a~00i , b00i ) ∈ JVi K~y for all 1 ≤ i ≤ m; let ~ai = a~0i ] a~00i Um Um and bi = b0i ] b00i : one has i=0 ~ai = i=0 a~0i ] a~00i = ~a0 ] ~a00 , ((~a0 , b1 , . . . , bm ), c) ∈ JN LK~y and, by Lemma 47, (~ai , bi ) ∈ JVi K~y for all 1 ≤ i ≤ m. Therefore, according to relation (3), JM ∗ K~y = S. t u A.6 Proofs of Subsection 6.3 Theorem 33 (soundness). Let P, Q ∈ 2hrΛτ i. If P →vτ Q, then JPK~x = JQK~x . Proof. By Thm. 18 it suffices to prove that the τi -rules are sound. For example Jt(s ∗ p)K~x = {(~a0 ] ~a1 ] ~a2 , c) : ∃b ∈ Mf (U ). (~a0 , [(b, c)]) ∈ JtK~x , (~a1 , b) ∈ JsK~x , (~a2 , 1) ∈ JpK~x } = Jts ∗ pK~x If n > 0, then Jτ [[v1 , . . . , vn ]]K~x = {(~a, 1) : (~a, [ ]) ∈ J[v1 , . . . , vn ]K~x } = ∅ because the interpretation of a non-empty bag of values which does not reduce to 0 never contains an element like (~a, [ ]). Instead Jτ [[ ]]K~x = {(~a, 1) : (~a, [ ]) ∈ {([ ]n , [ ])}} = JεK~x This shows that the interpretation is invariant w.r.t. the rules 7→τ1 and 7→τ5 . The other τi -rules are proved similarly. t u Lemma 49. Let p be a closed test. Then: (i) either p vτ ε or p vτ 0; (ii) JpK 6= ∅ iff p vτ ε. Proof. (i) It suffices to show that for every closed resource term t, either τ [t] vτ ε or τ [t] vτ 0. As the rτ λσv -calculus is strongly normalizing, Pk we have that t vτ i=1 si , where each si is a closed normal form. If k = 0 then τ [t] vτ 0 since τ [0] = 0. Otherwise for each si there are two possibilities: – si = [v1 , . . . , vm ] with vj not a variable. Then τ [si ] reduces either to ε or to 0, depending on the value of m. 0 0 – si = τ [[v1 , . . . , vm ] ∗ ([v10 , . . . , vm 0 ] k q)] with vj , vl not a variable. Then 0 0 si →vτ τ [[v1 , . . . , vm ]] k ([v1 , . . . , vm0 ] k q) that, using the induction hypothesis, can only reduce Pk to 0 or ε. We conclude since τ [t] vτ i=1 τ [si ], and this latter expression reduces to a finite (possibly empty) sum of ε’s, which is thus equal to 0 or ε. (ii) By the soundness of the model (Thm. 33) and item (i). t u Stated at p. 13 26 A. Carraro, G. Guerrieri The set U admits a well-founded ordering via the notion of rank of an element α ∈ U : the rank of α, notation rk(α), is the smallest n ∈ N such that α ∈ Un . The rank of a multiset b ∈ Mf (U ), denoted by rk(b), is the greatest among the ranks of its elements, if it is non-empty; the empty multiset has rank 0. Lemma 50. Let a ∈ Mf (U ). Then: (i) Ja− K = {(1, a)}, (ii) Ja+ L[xn ]MKx = {(a, 1)}, where n = #a. Proof. The points (i) and (ii) are proved simultaneously by induction on rk(a). We write IH(i) and IH(ii) for the induction hypotheses concerning (i) and (ii), respectively. If rk(a) = 0 then a = [ ], hence Ja− K = J[ ]K = {[ ]} and Ja+ L[x0 ]MKx = Jτ [[λy.[ ] ∗ ε][ ]]Kx = JεKx = {([ ], 1)}. This proves the base cases for (i) and (ii). For the inductive step, suppose rk(a) > 0 and #a = r, so that a = [(b1 , c1 ), . . . , (br , cr )]. We prove (i). By definition Ja− K = J[λy1 .c1 − ∗ b1 + L[y1m1 ]M, . . . , λyr .cr − ∗ br + L[yrmr ]M]K. So we have (1, a0 ) ∈ Ja− K iff a0 = [(b01 , c01 ), . . . , (b0r , c0r )] and for all 1 ≤ j ≤ r m m (b0j , c0j ) ∈ Jcj − ∗ bj + L[yj j ]MK, i.e., (1, c0j ) ∈ Jcj − K and (b0j , 1) ∈ Jbj + L[yj j ]MKyj . By 0 0 0 IH(i) and IH(ii) we have cj = cj and bj = bj . Therefore a = a. We prove (ii). By definition a+ L[xr ]M = τ [[λz.[ ]∗ kri=1 τ [[λy.[ ] ∗ ci + L[y ki ]M]([z]bi − )]][xr ]], where ki = #ci for all 1 ≤ i ≤ r. Hence, a+ L[xr ]M vτ kri=1 τ [[λy.[ ] ∗ ci + L[y ki ]M]([x]bi − )]. Using IH(i) and IH(ii) we have that Jbi − K = {(1, bi )} and Jci + L[y ki ]MKy = {(ci , 1)} and therefore Jτ [[λy.[ ] ∗ ci + L[y ki ]M]([x]bi − )]Kx = {([(bi , ci )], 1)}, for each i = 1, . . . , r. In conclusion Ja+ L[xr ]MKx = {([(b1 , c1 ), . . . , (br , cr )], 1)}. t u Lemma 51. Let b ∈ Mf (U ) and let t be a resource term with fv(t) ⊆ ~x. Then Jb+ LtMK~x = {(~a, 1) : (~a, b) ∈ JtK~x }. t u Proof. By induction on the structure of t. Lemma 52. Let ~a ∈ Mf (U )n and let p be a test with fv(p) ⊆ ~x. Then Jph~a− /~xiK 6= ∅ iff (~a, 1) ∈ JpK~x . t u Proof. By induction on the structure of p. Lemma 53. Let b ∈ Mf (U ) and let #b = n. If s is a resource term with fv(s) ⊆ ~x, then Jb+ LsMK~x 6= ∅ iff Jτ [[λy.[ ] ∗ b+ L[y n ]M]s]K~x 6= ∅. t u Proof. By induction on the rank of b. Stated at p. 13 Lemma 35. Let (~a, b) ∈ Mf (U )n × Mf (U ), #b = r and let t be a resource term. Then (~a, b) ∈ JtK~x iff τ [[λy.[ ] ∗ b+ L[y r ]M](th~a− /~xi)] vτ ε. Proof. We have the following chain of equivalences: (~a, b) ∈ JtK~x ⇔ (~a, 1) ∈ Jb+ LtMK~x , by Lemma 51 ⇔ Jb+ LtMh~a− /~xiK 6= ∅, by Lemma 52 ⇔ Jb+ Lth~a− /~xiMK 6= ∅, since fv(b+ L·M) = ∅ ⇔ Jτ [[λy.[ ] ∗ b+ L[y r ]M](th~a− /~xi)]K 6= ∅, by Lemma 53 ⇔ τ [[λy.[ ] ∗ b+ L[y r ]M](th~a− /~xi)] vτ ε, by Lemma 49 t u A semantical and operational account of call-by-value solvability A.7 27 Proofs of Subsection 6.4 Lemma 54. Let M ∈ Λ, V ∈ Λv , t ∈ T (M ) and v1 , . . . , vm ∈ T (V ). For every f ∈ Sm , if degx (t) = m then t{vf (1) /x1 , . . . , vf (m) /xm } ∈ T (N {V /x}). t u Proof. See Lemma 16 in [14]. The following lemma is a generalization of Lemma 18 in [14]. Lemma 38. Let M, M 0 be λ-terms. 0 Stated at p. 14 0 (i) If M →w M and t ∈ T (M ), then there exists T ⊆ T (M ) such that t →v T. (ii) If M →s M 0 and s ∈ Ts (M ), then there exists S ⊆ Ts (M 0 ) such that s →+ v S. Proof (of Lemma 38.i). By induction on the definition of M →w M 0 . If M = (λx.N )V →w N {V /x} = M 0 then t = [λx.t1 , . . . , λx.tn ][v1 , . . . , vm ] for some n, m ∈ N, with ti ∈ T (N ) and vj ∈ T (V ) for all 1 ≤ i ≤ n and 1 ≤ j ≤ m. 0 If n 6= 1, or n = 1 but degx (t1 ) 6= m, then t → n = 1 and Pv 0 ⊆ Ts (M ). Otherwise, degx (t1 ) = m, so t = [λx.t1 ][v1, . . . , vm ] →v f ∈Smt1 {vf (1) /x1 , . . . , vf (m) /xm } = T. By Lemma 54, T ⊆ T (M 0 ). If M = (λx.M0 )N L →w (λx.M0 L)N = M 0 , then t = [λx.t1 , . . . , λx.tn ]s1 s2 for some s1 ∈ T (N ), s2 ∈ T (L) and n ∈ N, with ti ∈ T (M0 ) for all 1 ≤ i ≤ n. If n 6= 1 then t →v 0 ⊆ T (M 0 ), otherwise t = [λx.t1 ]s1 s2 →v [λx.t1 s2 ]s1 ⊆ T (M 0 ). If M = V ((λx.L)N ) →w (λx.V L)N = M 0 , then t = [v1 , . . . , vn ]([λx.t1 , . . . , λx.tn ]s) for some s ∈ T (N ) and n, m ∈ N, with vi ∈ T (V ) and tj ∈ T (L) for all 1 ≤ i ≤ n and 1 ≤ j ≤ m. If n 6= 1 or m 6= 1 then t →v 0 ⊆ T (M 0 ), otherwise t = [v1 ]([λx.t1 ]s0 ) →v [λx.v1 t1 ]s0 ⊆ T (M 0 ). If M = M0 M1 →w M00 M1 = M 0 with M0 →w M00 , then t = s0 s1 where si ∈ T (Mi ) for i ∈ {1, 2}. By induction hypothesis, there exists T0 ⊆ T (M00 ) such that s0 →v T0 . Therefore t →v T0 s1 ⊆ T (M 0 ). The case where M = M0 M1 →w M0 M10 = M 0 with M1 →w M10 is perfectly similar to the previous one. If M = (λx.L)N →w (λx.L0 )N = M 0 with L →w L0 , then t = [λx.t1 , . . . , λx.tn ]s for some s ∈ T (N ) and n ∈ N, with ti ∈ T (L) for all 1 ≤ i ≤ n. If n 6= 1 then t →v 0 ⊆ T (M 0 ). Otherwise t = [λx.t1 ]s and, by induction hypothesis, there exists L ⊆ T (L0 ) such that t1 →v L. Hence t →v (λx.L)s ⊆ T (M 0 ). t u Proof (of Lemma 38.ii). By induction on the definition of M →s M 0 . If M →w M 0 then there exists T ⊆ T (M 0 ) such that t →v T, by Lemma 38.i. Since t ∈ Ts (M ), for every T0 if T →∗v T0 then T0 ⊆ Strat. Therefore T ⊆ Ts (M 0 ). If M = M0 M1 →s M00 M1 = M 0 with M0 →s M00 , then t = s0 s1 where s0 ∈ Ts (M0 ) and s1 ∈ T (M1 ). By induction hypothesis, there exists S0 ⊆ Ts (M00 ) + 0 0 such that s0 →+ v S0 , thus t →v S0 s1 ⊆ T (M ). Since t ∈ Ts (M ), for every T if ∗ 0 0 0 S0 s1 →v T then T ⊆ Strat. Therefore S0 s1 ⊆ Ts (M ). If M = λx.L →s λx.L0 = M 0 with L →s L0 , then t = [λx.t1 , . . . , λx.tn ] for some n ≥ 1 with ti ∈ Ts (L) for all 1 ≤ i ≤ n. By induction hypothesis, + for all 1 ≤ i ≤ n there exists Li ⊆ Ts (L0 ) such that ti →+ v Li . So, t →v + + 0 [λx.L1 , λx.t2 , . . . , λx.tn ] →v . . . →v [λx.L1 , . . . , λx.Ln ] ⊆ T (M ). Since t ∈ Ts (M ), for every T0 if [λx.L1 , . . . , λx.Ln ] →∗v T0 then T0 ⊆ Strat. Therefore [λx.L1 , . . . , λx.Ln ] ⊆ Ts (M 0 ). t u
© Copyright 2026 Paperzz