arXiv is now an independent nonprofit! Learn more
License: CC BY 4.0
arXiv:1809.02659v4 [cs.LO] 14 Jul 2020

Sep. 11, 2018Jul. 15, 2020

Revisiting Call-by-value Böhm trees
in light of their Taylor expansion

Emma Kerinec Address: Université de Lyon, ENS de Lyon, Université Claude Bernard Lyon 1, LIP Email address: emma.kerinec@ens-lyon.fr , Giulio Manzonetto Address: LIPN, UMR 7030, Université Paris 13, Sorbonne Paris Cité, F-93430, Villetaneuse, France Email address: giulio.manzonetto@univ-paris13.fr and Michele Pagani Address: CNRS, IRIF, Université de Paris, F-75205 Paris, France Email address: pagani@irif.fr
Abstract.

The call-by-value λ\lambda-calculus can be endowed with permutation rules, arising from linear logic proof-nets, having the advantage of unblocking some redexes that otherwise get stuck during the reduction. We show that such an extension allows to define a satisfying notion of Böhm(-like) tree and a theory of program approximation in the call-by-value setting. We prove that all λ\lambda-terms having the same Böhm tree are observationally equivalent, and characterize those Böhm-like trees arising as actual Böhm trees of λ\lambda-terms.

We also compare this approach with Ehrhard’s theory of program approximation based on the Taylor expansion of λ\lambda-terms, translating each λ\lambda-term into a possibly infinite set of so-called resource terms. We provide sufficient and necessary conditions for a set of resource terms in order to be the Taylor expansion of a λ\lambda-term. Finally, we show that the normal form of the Taylor expansion of a λ\lambda-term can be computed by performing a normalized Taylor expansion of its Böhm tree. From this it follows that two λ\lambda-terms have the same Böhm tree if and only if the normal forms of their Taylor expansions coincide.

Key words and phrases: 
Lambda calculus, call-by-value, Böhm trees, differential linear logic, Taylor expansion, program approximation
lmcs-doi: Volume 16, Issue 3, Paper 6

We are honoured to dedicate this article to Corrado Böhm, whose brilliant pioneering work has been an inspiration to us all.

Introduction

In 1968, Corrado Böhm published a separability theorem – known as the Böhm Theorem – which is nowadays universally recognized as a fundamental theorem in λ\lambda-calculus [Bö68]. Inspired by this result, Barendregt in 1977 proposed the definition of “Böhm tree of a λ\lambda-term” [Bar77], a notion which played for decades a prominent role in the theory of program approximation. The Böhm tree of a λ\lambda-term MM represents the evaluation of MM as a possibly infinite labelled tree coinductively, but effectively, constructed by collecting the stable amounts of information coming out of the computation. Equating all λ\lambda-terms having the same Böhm tree is a necessary, although non sufficient, step in the quest for fully abstract models of λ\lambda-calculus.

In 2003, Ehrhard and Regnier, motivated by insights from Linear Logic, introduced the notion of “Taylor expansion of a λ\lambda-term” as an alternative way of approximating λ\lambda-terms [ER03]. The Taylor expansion translates a λ\lambda-term MM as a possibly infinite set11 1 In its original definition, the Taylor expansion is a power series of multi-linear terms taking coefficients in the semiring of non-negative rational numbers. Following [MP11, Ehr12, BHP13], in this paper we abuse language and call “Taylor expansion” the support (underlying set) of the actual Taylor expansion. This is done for good reasons, as we are interested in the usual observational equivalences between λ\lambda-terms that overlook such coefficients. of multi-linear terms, each approximating a finite part of the behaviour of MM. These terms populate a resource calculus [Tra09] where λ\lambda-calculus application is replaced by the application of a term to a bag of resources that cannot be erased, or duplicated and must be consumed during the reduction. The advantage of the Taylor expansion is that it exposes the amount of resources needed by a λ\lambda-term to produce (a finite part of) a value, a quantitative information that does not appear in its Böhm tree. The relationship between these two notions of program approximation has been investigated in [ER06], where the authors show that the Taylor expansion can actually be seen as a resource sensitive version of Böhm trees by demonstrating that the normal form of the Taylor expansion of MM is actually equal to the Taylor expansion of its Böhm tree.

The notions of Böhm tree and Taylor expansion have been first developed in the setting of call-by-name (CbN) λ\lambda-calculus [Bar84]. However many modern functional programming languages, like OCaml, adopt a call-by-value (CbV) reduction strategy — a redex of shape (λx.M)N(\lambda x.M)N is only contracted when NN is a value, namely a variable or a λ\lambda-abstraction. The call-by-value λ\lambda-calculus λv\lambda_{v} has been defined by Plotkin in 1975 [Plo75], but its theory of program approximation is still unsatisfactory and constitutes an ongoing line of research [Ehr12, CG14, MRP19]. For instance, it is unclear what should be the Böhm tree of a λ\lambda-term because of the possible presence of β\beta-redexes that get stuck (waiting for a value) in the reduction. A paradigmatic example of this situation is the λ\lambda-term M=(λy.Δ)(xx)ΔM=(\lambda y.\Delta)(xx)\Delta, where Δ=λz.zz\Delta=\lambda z.zz (see [PRDR99, AG17]). This term is a call-by-value normal form because the argument xxxx, which is not a value, blocks the evaluation (while one would expect MM to behave as the divergent term Ω=ΔΔ\Omega=\Delta\Delta). A significant advance in reducing the number of stuck redexes has been made in [CG14] where Carraro and Guerrieri, inspired by Regnier’s work in the call-by-name setting [Reg94], introduce permutations rules (σ)(\sigma) naturally arising from the translation of λ\lambda-terms into Linear Logic proof-nets. Using σ\sigma-rules, the λ\lambda-term MM above rewrites in (λy.ΔΔ)(xx)(\lambda y.\Delta\Delta)(xx) which in its turn rewrites to itself, thus giving rise to an infinite reduction sequence, as desired. In [GPR17], Guerrieri et al. show that this extended calculus λvσ\lambda^{\sigma}_{v} still enjoys nice properties like confluence and standardization, and that adding the σ\sigma-rules preserves the operational semantics of Plotkin’s CbV λ\lambda-calculus as well as the observational equivalence.

In the present paper we show that σ\sigma-rules actually open the way to provide a meaningful notion of call-by-value Böhm trees (Definition 2.1). Rather than giving a coinductive definition, which turns out to be more complicated than expected, we follow [AC98] and provide an appropriate notion of approximants, namely λ\lambda-terms possibly containing a constant \bot, that are in normal form w.r.t. the reduction rules of λvσ\lambda^{\sigma}_{v} (i.e., the σ\sigma-rules and the restriction of (β)(\beta) to values). In this context, \bot represents the undefined value and this intuition is reflected in the definition of a preorder \sqsubseteq between approximants which is generated by V\bot\sqsubseteq V, for all approximated values VV. The next step is to associate with every λ\lambda-term MM the set 𝒜(M)\mathcal{A}(M) of its approximants and verify that they enjoy the following properties: (i)(i) the “external shape” of an approximant of MM is stable under reduction (Lemma 7); (ii)(ii) two interconvertible λ\lambda-terms share the same set of approximants (cf., Lemma 8); (iii)(iii) the set of approximants of MM is directed (Lemma 9). Once this preliminary work is accomplished, it is possible to define the Böhm tree of MM as the supremum of 𝒜(M)\mathcal{A}(M), the result being a possibly infinite labelled tree BT(M)\mathrm{BT}(M), as expected.

More generally, it is possible to define the notion of (CbV) “Böhm-like” trees as those labelled trees that can be obtained by arbitrary superpositions of (compatible) approximants. The Böhm-like trees corresponding to CbV Böhm trees of λ\lambda-terms have specific properties, that are due to the fact that λ\lambda-calculus constitutes a model of computation. Indeed, since every λ\lambda-term MM is finite, BT(M)\mathrm{BT}(M) can only contain a finite number of free variables and, since MM represents a program, the tree BT(M)\mathrm{BT}(M) must be computable. In Theorem 12 we demonstrate that these conditions are actually sufficient, thus providing a characterization.

To show that our notion of Böhm tree is actually meaningful, we prove that all λ\lambda-terms having the same Böhm tree are operationally indistinguishable (Theorem 31) and we investigate the relationship between Böhm trees and Taylor expansion in the call-by-value setting. Indeed, as explained by Ehrhard in [Ehr12], the CbV analogues of resource calculus and of Taylor expansion are unproblematic to define, because they are driven by solid intuitions coming from Linear Logic: rather than using the CbN translation AB=!ABA\to B=\oc A\multimap B of intuitionistic arrow, it is enough to exploit Girard’s so-called “boring” translation, which transforms ABA\to B in !(AB)\oc(A\multimap B) and is suitable for CbV. Following [BHP13], we define a coherence relation \coh between resource terms and prove that a set of such terms corresponds to the Taylor expansion of a λ\lambda-term if and only if it is an infinite clique having finite height. Subsequently, we focus on the dynamic aspects of the Taylor expansion by studying its normal form, that can always be calculated since the resource calculus enjoys strong normalization.

In [CG14], Carraro and Guerrieri propose to extend the CbV resource calculus with σ\sigma-rules to obtain a more refined normal form of the Taylor expansion 𝒯(M)\mathscr{T}(M) of a λ\lambda-term MM — this allows to mimic the σ\sigma-reductions occurring in MM at the level of its resource approximants. Even with this shrewdness, it turns out that the normal form of 𝒯(M)\mathscr{T}(M) is different from the normal form of 𝒯(BT(M))\mathscr{T}(\mathrm{BT}(M)), the latter containing approximants that are not normal, but whose normal form is however empty (they disappear along the reduction). Although the result from [ER06] does not hold verbatim in CbV, we show that it is possible to define the normalized Taylor expansion 𝒯()\mathscr{T}^{\circ}(-) of a Böhm tree and prove in Theorem 26 that the normal form of 𝒯(M)\mathscr{T}(M) coincide with 𝒯(BT(M))\mathscr{T}^{\circ}(\mathrm{BT}(M)), which is the main result of the paper. An interesting consequence, among others, is that all denotational models satisfying the Taylor expansion (e.g., the one in [CG14]) equate all λ\lambda-terms having the same Böhm tree.

Related works

To our knowledge, in the literature no notion of CbV Böhm tree appears22 2 Even Paolini’s separability result in [Pao01] for CbV λ\lambda-calculus does not rely on Böhm trees.. However, there have been attempts to develop syntactic bisimulation equivalences and theories of program approximation arising from denotational models. Lassen [Las05] coinductively defines a bisimulation equating all λ\lambda-terms having (recursively) the same “eager normal form”, but he mentions that no obvious tree representations of the equivalence classes are at hand. In [RDRP04], Ronchi della Rocca and Paolini study a filter model of CbV λ\lambda-calculus and, in order to prove an Approximation Theorem, they need to define sets of upper and lower approximants of a λ\lambda-term. By admission of the authors [Roc18], these notions are not satisfactory because they correspond to an “over” (resp. “under”) approximation of its behaviour.

We end this section by recalling that most of the results we prove in this paper are the CbV analogues of results well-known in CbN and contained in [Bar84, Ch. 10] (for Böhm trees), in [BHP13] (for Taylor expansion) and  [ER06] (for the relationship between the two notions).

General notations. We denote by Nature{\rm Nature} the set of all natural numbers. Given a set XX we denote by 𝒫(X)\mathscr{P}(X) its powerset and by 𝒫f(X)\mathscr{P}_{\mathrm{f}}(X) the set of all finite subsets of XX.

1. Call-By-Value λ\lambda-Calculus

The call-by-value λ\lambda-calculus λv\lambda_{v}, introduced by Plotkin in [Plo75], is a λ\lambda-calculus endowed with a reduction relation that allows the contraction of a redex (λx.M)N(\lambda x.M)N only when the argument NN is a value, namely when NN is a variable or an abstraction. In this section we briefly review its syntax and operational semantics. By extending its reduction with permutation rules σ\sigma, we obtain the calculus λvσ\lambda^{\sigma}_{v} introduced in [CG14], that will be our main subject of study.

1.1. Its syntax and operational semantics.

For the λ\lambda-calculus we mainly use the notions and notations from [Bar84]. We consider fixed a denumerable set 𝕍\mathbb{V} of variables.

{defi}

The set Λ\Lambda of λ\lambda-terms and the set Val\mathrm{Val} of values are defined through the following grammars (where OPENx𝕍)x\in\mathbb{V}):

(Λ)M,N,P,Q::=V|MN(Val)U,V::=x|λx.M\begin{array}[]{lrl}(\Lambda)&M,N,P,Q::=&V\mid MN\\ (\mathrm{Val})&U,V::=&x\mid\lambda x.M\\ \end{array}

As usual, we assume that application associates to the left and has higher precedence than λ\lambda-abstraction. For instance, λxyz.xyz=λx.(λy.(λz.((xy)z)))\lambda xyz.xyz=\lambda x.(\lambda y.(\lambda z.((xy)z))). Given x1,,xn𝕍x_{1},\dots,x_{n}\in\mathbb{V}, we let λx.M\lambda\vec{x}.M stand for λx1λxn.M\lambda x_{1}\dots\lambda x_{n}.M. Finally, we write MNnMN^{\sim n} for MNNMN\cdots N (nn times).

The set FV(M)\mathrm{FV}(M) of free variables of MM and the α\alpha-conversion are defined as in [Bar84, §2.1]. A λ\lambda-term MM is called closed, or a combinator, whenever FV(M)=\mathrm{FV}(M)=\emptyset. The set of all combinators is denoted by Λo\Lambda^{o}. From now on, λ\lambda-terms are considered up to α\alpha-conversion, whence the symbol == represents syntactic equality possibly up to renaming of bound variables.

{defi}

Concerning specific combinators, we define:

𝙸=λx.x,Δ=λx.xx,Ω=ΔΔ,𝙱=λfgx.f(gx),𝙺=λxy.x,𝙵=λxy.y,𝚉=λf.(λy.f(λz.yyz))(λy.f(λz.yyz)),𝙺=𝚉𝙺.\begin{array}[]{lcllcllcl}\mathtt{I}&=&\lambda x.x,&\Delta&=&\lambda x.xx,&\Omega&=&\Delta\Delta,\\ \mathtt{B}&=&\lambda fgx.f(gx),&\mathtt{K}&=&\lambda xy.x,&\mathtt{F}&=&\lambda xy.y,\\ \mathtt{Z}&=&\lx@intercol\lambda f.(\lambda y.f(\lambda z.yyz))(\lambda y.f(\lambda z.yyz)),\hfil\lx@intercol&\mathtt{K}^{*}&=&\mathtt{ZK}.\\ \end{array}

where 𝙸\mathtt{I} is the identity, Ω\Omega is the paradigmatic looping combinator, 𝙱\mathtt{B} is the composition operator, 𝙺\mathtt{K} and 𝙵\mathtt{F} are the first and second projection (respectively), 𝚉\mathtt{Z} is Plotkin’s recursion operator, and 𝙺\mathtt{K}^{*} is a λ\lambda-term producing an increasing amount of external abstractions.

Given M,NΛM,N\in\Lambda and x𝕍x\in\mathbb{V} we denote by M[x:=N]M{[}x:=N] the λ\lambda-term obtained by substituting NN for every free occurrence of xx in MM, subject to the usual proviso of renaming bound variables in MM to avoid capture of free variables in NN.

Remark 1.

It is easy to check that the set Val\mathrm{Val} is closed under substitution of values for free variables, namely U,VValU,V\in\mathrm{Val} and x𝕍x\in\mathbb{V} entail V[x:=U]ValV{[}x:=U]\in\mathrm{Val}.

A context is a λ\lambda-term possibly containing occurrences of a distinguished algebraic variable, called hole and denoted by \llparenthesis-\rrparenthesis. In the present paper we consider – without loss of generality for our purposes – contexts having a single occurrence of \llparenthesis-\rrparenthesis.

{defi}

A (single-hole) context CC\llparenthesis-\rrparenthesis is generated by the simplified grammar:

C::=CMMC|λx.C(for MΛ)\qquad C::=\llparenthesis-\rrparenthesis\mid CM\mid MC\mid\lambda x.C\qquad\textrm{(for $M\in\Lambda$)}

A context CC\llparenthesis-\rrparenthesis is called a head context if it has shape (λx1xn.)V1Vm(\lambda x_{1}\dots x_{n}.\llparenthesis-\rrparenthesis)V_{1}\cdots V_{m} for ViValV_{i}\in\mathrm{Val}.

Given MΛM\in\Lambda, we write CMC\llparenthesis M\rrparenthesis for the λ\lambda-term obtained by replacing MM for the hole \llparenthesis-\rrparenthesis in CC\llparenthesis-\rrparenthesis, possibly with capture of free variables.

We consider a CbV λ\lambda-calculus λvσ\lambda^{\sigma}_{v} endowed with the following notions of reductions. The βv\beta_{v}-reduction is the standard one, from [Plo75], while the σ\sigma-reductions have been introduced in [Reg94, CG14] and are inspired by the translation of λ\lambda-calculus into linear logic proof-nets.

{defi}

The βv\beta_{v}-reduction βv\to_{\beta_{v}} is the contextual closure of the following rule:

(βv)(λx.M)VM[x:=V] whenever VVal(\beta_{v})\qquad(\lambda x.M)V\to M{[}x:=V]\textrm{ whenever }V\in\mathrm{Val}

The σ\sigma-reductions σ1\to_{\sigma_{1}}, σ3\to_{\sigma_{3}} are the contextual closures of the following rules (for VValV\in\mathrm{Val}):

(σ1)(λx.M)NP(λx.MP)Nwith xFV(P)(σ3)V((λx.M)N)(λx.VM)Nwith xFV(V)\begin{array}[]{lll}(\sigma_{1})&(\lambda x.M)NP\to(\lambda x.MP)N&\textrm{with }x\notin\mathrm{FV}(P)\\ (\sigma_{3})&V((\lambda x.M)N)\to(\lambda x.VM)N&\textrm{with }x\notin\mathrm{FV}(V)\\ \end{array}

We also set σ=σ1σ3\to_{\sigma}\ =\ \to_{\sigma_{1}}\cup\to_{\sigma_{3}} and 𝗏=βvσ\to_{\mathsf{v}}\ =\ \to_{\beta_{v}}\cup\to_{\sigma}.

The λ\lambda-term at the left side of the arrow in the rule (βv)(\beta_{v}) (resp. (σ1)(\sigma_{1}), (σ3)(\sigma_{3})) is called βv\beta_{v}- (resp. σ1\sigma_{1}-, σ3\sigma_{3}-) redex, while the λ\lambda-term at the right side is the corresponding contractum. Notice that the condition for contracting a σ1\sigma_{1}- (resp. σ3\sigma_{3}-) redex can always be satisfied by performing appropriate α\alpha-conversions.

Each reduction relation 𝖱\to_{\mathsf{R}} generates the corresponding multistep relation 𝖱\twoheadrightarrow_{\mathsf{R}} by taking its transitive and reflexive closure, and conversion relation =𝖱=_{\mathsf{R}} by taking its transitive, reflexive and symmetric closure. Moreover, we say that a λ\lambda-term MM is in 𝖱\mathsf{R}-normal form (𝖱\mathsf{R}-nf, for short) if there is no NΛN\in\Lambda such that M𝖱NM\to_{\mathsf{R}}N. We say that MM has an 𝖱\mathsf{R}-normal form whenever M𝖱NM\twoheadrightarrow_{\mathsf{R}}N for some NN in 𝖱\mathsf{R}-nf, and in this case we denote NN by nf𝖱(M)\mathrm{nf}_{\mathsf{R}}(M).

{exa}
  1. (1)

    𝙸xβvx\mathtt{I}x\to_{\beta_{v}}x, while 𝙸(xy)\mathtt{I}(xy) is a 𝗏\mathsf{v}-normal form.

  2. (2)

    ΩβvΩ\Omega\to_{\beta_{v}}\Omega, whence Ω\Omega is a looping combinator in the CbV setting as well.

  3. (3)

    𝙸(Δ(xx))\mathtt{I}(\Delta(xx)) is a βv\beta_{v}-nf, but contains a σ3\sigma_{3}-redex, indeed 𝙸(Δ(xx))σ3(λz.𝙸(zz))(xx)\mathtt{I}(\Delta(xx))\to_{\sigma_{3}}(\lambda z.\mathtt{I}(zz))(xx).

  4. (4)

    For all values VV, we have 𝚉V=𝗏V(λx.𝚉Vx)\mathtt{Z}V=_{\mathsf{v}}V(\lambda x.\mathtt{Z}Vx) with xFV(V)x\notin\mathrm{FV}(V). So we get:

  5. (5)

    𝙺=𝚉𝙺=𝗏𝙺(λy.𝙺y)=𝗏λx0x1.𝙺x1=𝗏λx0x1x2.𝙺x2=𝗏=𝗏λx0xn.𝙺xn\mathtt{K}^{*}=\mathtt{ZK}=_{\mathsf{v}}\mathtt{K}(\lambda y.\mathtt{K}^{*}y)=_{\mathsf{v}}\lambda x_{0}x_{1}.\mathtt{K}^{*}x_{1}=_{\mathsf{v}}\lambda x_{0}x_{1}x_{2}.\mathtt{K}^{*}x_{2}=_{\mathsf{v}}\cdots=_{\mathsf{v}}\lambda x_{0}\dots x_{n}.\mathtt{K}^{*}x_{n}.

  6. (6)

    Let Ξ=𝚉N\Xi=\mathtt{Z}N for N=λf.(λy1.f𝙸)(zz)N=\lambda f.(\lambda y_{1}.f\mathtt{I})(zz), then we have:

    Ξ=𝗏N(λw.Ξw)by 𝚉V=𝗏V(λw.𝚉Vw)=𝗏(λy1.(λw.Ξw)𝙸)(zz)by (βv)=𝗏(λy1.Ξ𝙸)(zz)by (βv)=𝗏(λy1.((λy2.Ξ𝙸)(zz))𝙸)(zz)by (βv)=𝗏(λy1.((λy2.Ξ𝙸𝙸)(zz)))(zz)by (σ1)=𝗏(λy1.((λy2.((λy3.Ξ𝙸𝙸𝙸)(zz)))(zz)))(zz)=\begin{array}[]{lcll}\Xi&=_{\mathsf{v}}&N(\lambda w.\Xi w)&\textrm{by }\mathtt{Z}V=_{\mathsf{v}}V(\lambda w.\mathtt{Z}Vw)\\ &=_{\mathsf{v}}&(\lambda y_{1}.(\lambda w.\Xi w)\mathtt{I})(zz)&\textrm{by }(\beta_{v})\\ &=_{\mathsf{v}}&(\lambda y_{1}.\Xi\mathtt{I})(zz)&\textrm{by }(\beta_{v})\\ &=_{\mathsf{v}}&(\lambda y_{1}.((\lambda y_{2}.\Xi\mathtt{I})(zz))\mathtt{I})(zz)&\textrm{by }(\beta_{v})\\ &=_{\mathsf{v}}&(\lambda y_{1}.((\lambda y_{2}.\Xi\mathtt{I}\mathtt{I})(zz)))(zz)&\textrm{by ($\sigma_{1}$)}\\ &=_{\mathsf{v}}&(\lambda y_{1}.((\lambda y_{2}.((\lambda y_{3}.\Xi\mathtt{I}\mathtt{I}\mathtt{I})(zz)))(zz)))(zz)&=\ \cdots\\ \end{array}
  7. (7)

    𝚉𝙱=𝗏𝙱(λz.𝚉𝙱z)=𝗏λgx.(λz.𝚉𝙱z)(gx)=𝗏λgx.(λfy.(λz.𝚉𝙱z)(fy))(gx)=𝗏\mathtt{ZB}=_{\mathsf{v}}\mathtt{B}(\lambda z.\mathtt{ZB}z)=_{\mathsf{v}}\lambda gx.(\lambda z.\mathtt{ZB}z)(gx)=_{\mathsf{v}}\lambda gx.(\lambda fy.(\lambda z.\mathtt{ZB}z)(fy))(gx)=_{\mathsf{v}}\cdots

The next lemma was already used implicitly in [GPR17].

Lemma 2.

A λ\lambda-term MM is in 𝗏\mathsf{v}-normal form if and only if MM is a GG-term generated by the following grammar (for k0k\geq 0):

G::=H|RH::=xλx.GxHG1GkR::=(λx.G)(yHG1Gk)\begin{array}[]{lcll}G&::=&H\mid R\\ H&::=&x\mid\lambda x.G\mid xHG_{1}\cdots G_{k}\\ R&::=&(\lambda x.G)(yHG_{1}\cdots G_{k})\\ \end{array}
Proof 1.1.

()(\Rightarrow) Assume that MM is in 𝗏\mathsf{v}-nf and proceed by structural induction. Recall that every λ\lambda-term MM can be uniquely written as λx1xm.MN1Nn\lambda x_{1}\dots x_{m}.M^{\prime}N_{1}\cdots N_{n} where m,n0m,n\geq 0 and either M=xM^{\prime}=x or M=(λx.P)QM^{\prime}=(\lambda x.P)Q. Moreover, the λ\lambda-terms M,N1,,NnM^{\prime},N_{1},\dots,N_{n} must be in 𝗏\mathsf{v}-nf’s since MM is 𝗏\mathsf{v}-nf. Now, if m>0m>0 then MM is of the form λx.P\lambda x.P with PP in 𝗏\mathsf{v}-nf and the result follows from the induction hypothesis. Hence, we assume m=0m=0 and split into cases depending on MM^{\prime}:

  • M=xM^{\prime}=x for some x𝕍x\in\mathbb{V}. If n=0n=0 then we are done since xx is an HH-term. If n>0n>0 then M=xN1NnM=xN_{1}\cdots N_{n} where all the NiN_{i}’s are GG-terms by induction hypothesis. Moreover, N1N_{1} cannot be an RR-term for otherwise MM would have a σ3\sigma_{3}-redex. Whence, N1N_{1} must be an HH-term and MM is of the form xHG1GkxHG_{1}\cdots G_{k} for k=n1k=n-1.

  • M=(λx.P)QM^{\prime}=(\lambda x.P)Q for some variable xx and λ\lambda-terms P,QP,Q in 𝗏\mathsf{v}-nf. In this case we must have n=0n=0 because MM cannot have a σ1\sigma_{1}-redex. By induction hypothesis, P,QP,Q are GG-terms, but QQ cannot be an RR-term or a value for otherwise MM would have a σ3\sigma_{3}- or a βv\beta_{v}-redex, respectively. We conclude that the only possibility for the shape of QQ is yHG1GkyHG_{1}\cdots G_{k}, whence MM must be an RR-term.

()(\Leftarrow) By induction on the grammar generating MM. The only interesting cases are the following.

  • M=xHG1GkM=xHG_{1}\cdots G_{k} could have a σ3\sigma_{3}-redex if H=(λy.P)QH=(\lambda y.P)Q, but this is impossible by definition of an HH-term. As H,G1,,GkH,G_{1},\dots,G_{k} are in 𝗏\mathsf{v}-nf by induction hypothesis, so must be MM.

  • M=(λx.G)(yHG1Gk)M=(\lambda x.G)(yHG_{1}\cdots G_{k}) where G,H,G1,,GkG,H,G_{1},\dots,G_{k} are in 𝗏\mathsf{v}-nf by induction hypothesis. In the previous item we established that yHG1GkyHG_{1}\cdots G_{k} is in 𝗏\mathsf{v}-nf. Thus, MM could only have a βv\beta_{v}-redex if yHG1GkValyHG_{1}\cdots G_{k}\in\mathrm{Val}, but this is not the case by definition of Val\mathrm{Val}.

Intuitively, in the grammar above, GG stands for “general” normal form, RR for “redex-like” normal form and HH for “head” normal form. The following properties are well-established.

Proposition 3 (Properties of reductions [Plo75, CG14]).
  1. (1)

    The σ\sigma-reduction is confluent and strongly normalizing.

  2. (2)

    The βv\beta_{v}- and 𝗏\mathsf{v}-reductions are confluent.

Lambda terms are classified into valuables, potentially valuable and non-potentially valuable, depending on their capability of producing a value in a suitable environment.

{defi}

A λ\lambda-term MM is valuable if MβvVM\twoheadrightarrow_{\beta_{v}}V for some VValV\in\mathrm{Val}. A λ\lambda-term MM is potentially valuable if there exists a head context33 3 Equivalently, MM is potentially valuable if there is a substitution ϑ:𝕍Val\vartheta:\mathbb{V}\to\mathrm{Val} such that ϑ(M)\vartheta(M) is valuable. C=(λx1xn.)V1VnC\llparenthesis-\rrparenthesis=(\lambda x_{1}\dots x_{n}.\llparenthesis-\rrparenthesis)V_{1}\cdots V_{n}, where FV(M)={x1,,xn}\mathrm{FV}(M)=\{x_{1},\dots,x_{n}\}, such that CMC\llparenthesis M\rrparenthesis is valuable.

It is easy to check that MM valuable entails MM potentially valuable and that, for MΛoM\in\Lambda^{o}, the two notions coincide. As shown in [GPR17], a λ\lambda-term MM is valuable (resp. potentially valuable) if and only if M𝗏VM\twoheadrightarrow_{\mathsf{v}}V (resp. CM𝗏VC\llparenthesis M\rrparenthesis\twoheadrightarrow_{\mathsf{v}}V) for some VValV\in\mathrm{Val}. As a consequence, the calculus λvσ\lambda^{\sigma}_{v} can be used as a tool for studying the operational semantics of the original calculus λv\lambda_{v}.

In [Plo75], Plotkin defines an observational equivalence analogous to the following one.

{defi}

The observational equivalence \equiv is defined as follows (for M,NΛM,N\in\Lambda):

MNC.CM,CNΛo[VVal.CMβvVUVal.CNβvU]\begin{array}[]{c}M\equiv N\\ \iff\\ \forall C\llparenthesis-\rrparenthesis\,.\,C\llparenthesis M\rrparenthesis,C\llparenthesis N\rrparenthesis\in\Lambda^{o}\ [\ \exists V\in\mathrm{Val}\,.\,C\llparenthesis M\rrparenthesis\twoheadrightarrow_{\beta_{v}}V\iff\exists U\in\mathrm{Val}\,.\,C\llparenthesis N\rrparenthesis\twoheadrightarrow_{\beta_{v}}U\ ]\end{array}

For example, we have 𝙸λxy.xy\mathtt{I}\equiv\lambda xy.xy and ΞΩ\Xi\equiv\Omega (see Example 1.1(6)), while Ωλx.Ω\Omega\not\equiv\lambda x.\Omega.

Remark 4.

It is well known that, in order to check whether MNM\equiv N holds, it is enough to consider head contexts (cf. [Ong97, Pao08]). In other words, MNM\not\equiv N if and only if there exists a head context CC\llparenthesis-\rrparenthesis such that CMC\llparenthesis M\rrparenthesis is valuable, while CNC\llparenthesis N\rrparenthesis is not.

2. Call-by-value Böhm Trees

In the call-by-name setting there are several equivalent ways of defining Böhm trees. The most famous definition is coinductive44 4 See also Definition 10.1.3 of [Bar84], marked by Barendregt as ‘informal’ because at the time the coinduction principle was not as well-understood as today.  [Las99], while the formal one in Barendregt’s book exploits the notion of “effective Böhm-like trees” which is not easy to handle in practice. The definition given in Amadio and Curien’s book [AC98, Def. 2.3.3] is formal, does not require coinductive techniques and, as it turns out, generalizes nicely to the CbV setting. The idea is to first define the set 𝒜(M)\mathcal{A}(M) of approximants of a λ\lambda-term MM, then show that it is directed w.r.t. some preorder \sqsubseteq and, finally, define the Böhm tree of MM as the supremum of 𝒜(M)\mathcal{A}(M).

2.1. Böhm trees and approximants

Let Λ\Lambda_{\bot} be the set of λ\lambda-terms possibly containing a constant \bot, representing the undefined value, and let \sqsubseteq be the context-closed preorder on Λ\Lambda_{\bot} generated by setting, for all x𝕍x\in\mathbb{V} and MΛM\in\Lambda_{\bot}:

x,λx.M.\bot\sqsubseteq x,\qquad\qquad\qquad\qquad\qquad\bot\sqsubseteq\lambda x.M.

Notice that, by design, \bot can only be used to approximate values, not λ\lambda-terms like Ω\Omega.

The reduction 𝗏\to_{\mathsf{v}} from Definition 1.1 generalizes to terms in Λ\Lambda_{\bot} in the obvious way, namely by considering a set Val\mathrm{Val}_{\bot} of values generated by the grammar (for MΛM\in\Lambda_{\bot}):

(Val)U,V::=xλx.M\begin{array}[]{lrl}(\mathrm{Val}_{\bot})&U,V\ ::=&\bot\mid x\mid\lambda x.M\\ \end{array}

For example, the βv\beta_{v}-reduction is extended by setting for all M,VΛM,V\in\Lambda_{\bot}:

(βv)(λx.M)VM[x:=V] whenever VVal(\beta_{v})\qquad(\lambda x.M)V\to M{[}x:=V]\textrm{ whenever }V\in\mathrm{Val}_{\bot}

Similarly, for the σ\sigma-rules. A \bot-context CC\llparenthesis-\rrparenthesis is a context possibly containing some occurrences of \bot. We use for \bot-contexts the same notations introduced for contexts in Section 1.1.

Given M,NΛM,N\in\Lambda_{\bot} compatible55 5 Recall that M,NM,N are compatible if there exists ZZ such that MZM\sqsubseteq Z and NZN\sqsubseteq Z. w.r.t. \sqsubseteq, we denote their least upper bound by MNM\sqcup N.

{defi}
  1. (1)

    The set 𝒜\mathcal{A} of approximants contains the terms AΛA\in\Lambda_{\bot} generated by the grammar (for k0k\geq 0):

    A::=B|CB::=xλx.AxBA1AkC::=(λx.A)(yBA1Ak)\begin{array}[]{lcl}A&::=&B\mid C\\ B&::=&x\mid\lambda x.A\mid\bot\mid xBA_{1}\cdots A_{k}\\ C&::=&(\lambda x.A)(yBA_{1}\cdots A_{k})\end{array}
  2. (2)

    The set of free variables FV()\mathrm{FV}(-) is extended to approximants by setting FV()=\mathrm{FV}(\bot)=\emptyset.

  3. (3)

    Given MΛM\in\Lambda, the set of approximants of MM is defined as follows:

    𝒜(M)={A𝒜NΛ,M𝗏N and AN}.\mathcal{A}(M)=\{A\in\mathcal{A}\mid\exists N\in\Lambda,M\twoheadrightarrow_{\mathsf{v}}N\textrm{ and }A\sqsubseteq N\}.
{exa}
  1. (1)

    𝒜(𝙸)={,λx.,λx.x}\mathcal{A}(\mathtt{I})=\{\bot,\lambda x.\bot,\lambda x.x\}.

  2. (2)

    𝒜(Ω)=𝒜(Ξ)=\mathcal{A}(\Omega)=\mathcal{A}(\Xi)=\emptyset and 𝒜(λx.Ω)={}\mathcal{A}(\lambda x.\Omega)=\{\bot\}.

  3. (3)

    𝒜(𝙸(Δ(xx)))={(λz.(λy.Y)(zZ))(xX)Y{y,}Z{z,}X{x,}}\mathcal{A}(\mathtt{I}(\Delta(xx)))=\{(\lambda z.(\lambda y.Y)(zZ))(xX)\mid Y\in\{y,\bot\}\ \land\ Z\in\{z,\bot\}\ \land\ X\in\{x,\bot\}\}.
    Notice that neither (λz.)(xx)(\lambda z.\bot)(xx) nor (λz.)(x)(\lambda z.\bot)(x\bot) belong to this set, because 𝙸(zz)\bot\not\sqsubseteq\mathtt{I}(zz).

  4. (4)

    𝒜(𝚉)=nNature{λf.f(λz0.f(λz1.f(λzn.fZn)Z1)Z0)i.Zi{zi,}}{}\mathcal{A}(\mathtt{Z})=\bigcup_{n\in{\rm Nature}}\{\lambda f.f(\lambda z_{0}.f(\lambda z_{1}.f\cdots(\lambda z_{n}.f\bot\,Z_{n})\cdots Z_{1})Z_{0})\mid\forall i\,.\,Z_{i}\in\{z_{i},\bot\}\}\cup\{\bot\}.

  5. (5)

    𝒜(𝙺)={λx1xn.n0}\mathcal{A}(\mathtt{K}^{*})=\{\lambda x_{1}\dots x_{n}.\bot\mid n\geq 0\}.

  6. (6)

    The set of approximants of 𝚉𝙱\mathtt{ZB} is particularly interesting to calculate:

    𝒜(𝚉𝙱)={λf0x0.((λfn1xn1.(λfn.)(fn1Xn1)))(f0X0)n>0,i.Xi{xi,}}{,λf0.}.\begin{array}[]{r@{~}l}\mathcal{A}(\mathtt{ZB})=&\{\lambda f_{0}x_{0}.(\cdots(\lambda f_{n-1}x_{n-1}.(\lambda f_{n}.\bot)(f_{n-1}X_{n-1}))\cdots)(f_{0}X_{0})\mid n>0,\forall i\,.\,X_{i}\in\{x_{i},\bot\}\}\\ \cup&\{\bot,\lambda f_{0}.\bot\}.\\ \end{array}
Lemma 5.

Every M𝒜M\in\mathcal{A} is in normal form with respect to the extended 𝗏\mathsf{v}-reduction.

Proof 2.1.

By a simple case analysis (analogous to the proof of Lemma 2).

The following lemmas show that the “external shape” of an approximant is stable under 𝗏\mathsf{v}-reduction. For instance, if A=(λx.A0)(yBA1Ak)MA=(\lambda x.A_{0})(yBA_{1}\cdots A_{k})\sqsubseteq M then all approximants A𝒜(M)A^{\prime}\in\mathcal{A}(M) have shape (λx.A0)(yBA1Ak)(\lambda x.A^{\prime}_{0})(yB^{\prime}A^{\prime}_{1}\cdots A^{\prime}_{k}) for some B,A0,,Ak𝒜B^{\prime},A^{\prime}_{0},\dots,A^{\prime}_{k}\in\mathcal{A}.

Lemma 6.

Let CC\llparenthesis-\rrparenthesis be a (single-hole) \bot-context and VValV\in\mathrm{Val}. Then C𝒜C\llparenthesis\bot\rrparenthesis\in\mathcal{A} and CV𝗏NC\llparenthesis V\rrparenthesis\to_{\mathsf{v}}N entails that there exists a value VV^{\prime} such that V𝗏VV\to_{\mathsf{v}}V^{\prime} and N=CVN=C\llparenthesis V^{\prime}\rrparenthesis.

Proof 2.2.

Let A=C𝒜A=C\llparenthesis\bot\rrparenthesis\in\mathcal{A}. By Lemma 5, AA cannot have any 𝗏\mathsf{v}-redex. Clearly, substituting VV for an occurrence of \bot in AA does not create any new βv\beta_{v}-redex, so if CVβvNC\llparenthesis V\rrparenthesis\to_{\beta_{v}}N then the contracted redex must occur in VV. As VV is a value, it can only 𝗏\mathsf{v}-reduce to a value VV^{\prime}.

It is slightly trickier to check by induction on CC\llparenthesis-\rrparenthesis that such an operation does not introduce any σ\sigma-redex. The only interesting case is C=(λx.A)(xCA1Ak)C\llparenthesis\bot\rrparenthesis=(\lambda x.A^{\prime})(xC^{\prime}\llparenthesis\bot\rrparenthesis A_{1}\cdots A_{k}) where CC^{\prime}\llparenthesis\bot\rrparenthesis is a BB-term. Indeed, since xValx\in\mathrm{Val}, xCVxC^{\prime}\llparenthesis V\rrparenthesis would be a σ3\sigma_{3}-redex for CV=(λy.P)QC^{\prime}\llparenthesis V\rrparenthesis=(\lambda y.P)Q but this is impossible since CC^{\prime}\llparenthesis\bot\rrparenthesis is a BB-term and BB-terms cannot have this shape.

The case C=xCA1AkC\llparenthesis\bot\rrparenthesis=xC^{\prime}\llparenthesis\bot\rrparenthesis A_{1}\cdots A_{k} is analogous.

Lemma 7.

For MΛM\in\Lambda and A𝒜A\in\mathcal{A}, AMA\sqsubseteq M and M𝗏NM\to_{\mathsf{v}}N entails ANA\sqsubseteq N.

Proof 2.3.

If AMA\sqsubseteq M then MM can be obtained from AA by substituting each occurrence of \bot for the appropriate subterm of MM, and such subterm must be a value. Hence, the redex contracted in M𝗏NM\to_{\mathsf{v}}N must occur in a subterm VV of MM corresponding to an occurrence66 6 An occurrence of a subterm NN in a λ\lambda-term MM is a (single-hole) context CC\llparenthesis-\rrparenthesis such that M=CNM=C\llparenthesis N\rrparenthesis. CC\llparenthesis-\rrparenthesis of \bot in AA. So we have C=AC\llparenthesis\bot\rrparenthesis=A and CV𝗏NC\llparenthesis V\rrparenthesis\to_{\mathsf{v}}N^{\prime} implies, by Lemma 6, that N=CVN^{\prime}=C\llparenthesis V^{\prime}\rrparenthesis for a VV^{\prime} such that V𝗏VV\to_{\mathsf{v}}V^{\prime}. So we conclude that A=CNA=C\llparenthesis\bot\rrparenthesis\sqsubseteq N, as desired.

Lemma 8.

For M,NΛM,N\in\Lambda, M𝗏NM\to_{\mathsf{v}}N entails 𝒜(M)=𝒜(N)\mathcal{A}(M)=\mathcal{A}(N).

Proof 2.4.

Straightforward from Definition 2.1(3) and Lemma 7.

Proposition 9.

For all MΛM\in\Lambda, the set 𝒜(M)\mathcal{A}(M) is either empty or an ideal (i.e. non-empty, directed and downward closed) w.r.t. \sqsubseteq.

Proof 2.5.

Assume 𝒜(M)\mathcal{A}(M) is non-empty. We check the remaining two conditions:

  • To show that 𝒜(M)\mathcal{A}(M) is directed, we need to prove that every A1,A2𝒜(M)A_{1},A_{2}\in\mathcal{A}(M) have an upper bound A3𝒜(M)A_{3}\in\mathcal{A}(M).

    We proceed by induction on A1A_{1}. In case A1=A_{1}=\bot (resp. A2=A_{2}=\bot) simply take A3=A2A_{3}=A_{2} (resp. A3=A1A_{3}=A_{1}). Let us assume that A1,A2A_{1},A_{2}\neq\bot.

    Case A1=xA_{1}=x, then A3=A2=xA_{3}=A_{2}=x.

    Case A1=xB1A11A1kA_{1}=xB_{1}A^{1}_{1}\cdots A^{1}_{k}. In this case we must have M𝗏N1M\twoheadrightarrow_{\mathsf{v}}N_{1} for N1=xN0NkN_{1}=xN^{\prime}_{0}\cdots N^{\prime}_{k} with B1N0B_{1}\sqsubseteq N^{\prime}_{0} and Ai1NiA^{1}_{i}\sqsubseteq N^{\prime}_{i} for all ii such that 1ik1\leq i\leq k. As A2𝒜(M)A_{2}\in\mathcal{A}(M), there exists a λ\lambda-term N2N_{2} such that M𝗏N2M\twoheadrightarrow_{\mathsf{v}}N_{2} and A2N2A_{2}\sqsubseteq N_{2}. By Proposition 3(2) (confluence), N1N_{1} and N2N_{2} have a common reduct NN. Since A1N1A_{1}\sqsubseteq N_{1}, by Lemma 7 we get A1NA_{1}\sqsubseteq N thus N=xN0NkN=xN_{0}\cdots N_{k}. By Lemma 7 again, A2NA_{2}\sqsubseteq N whence A2=xB2A21A2kA_{2}=xB_{2}A^{2}_{1}\cdots A^{2}_{k} for some approximants B2N0B_{2}\sqsubseteq N_{0} and Ai2NiA^{2}_{i}\sqsubseteq N_{i} for 1ik1\leq i\leq k. Now, by definition, B1,B2𝒜(N0)B_{1},B_{2}\in\mathcal{A}(N_{0}) and Ai1,Ai2𝒜(Ni)A^{1}_{i},A^{2}_{i}\in\mathcal{A}(N_{i}) for 1ik1\leq i\leq k. By induction hypothesis, there exists B3𝒜(N0),Ai3𝒜(Ni)B_{3}\in\mathcal{A}(N_{0}),A^{3}_{i}\in\mathcal{A}(N_{i}) such that B1B3B2B_{1}\sqsubseteq B_{3}\sqsupseteq B_{2} and Ai1Ai3Ai2A^{1}_{i}\sqsubseteq A^{3}_{i}\sqsupseteq A^{2}_{i} from which it follows that the upper bound xB3A31A3kxB_{3}A^{3}_{1}\cdots A^{3}_{k} of A1,A2A_{1},A_{2} belongs to 𝒜(xN0Nk)\mathcal{A}(xN_{0}\cdots N_{k}). By Lemma 8, we conclude that xB3A13Ak3𝒜(M)xB_{3}A^{3}_{1}\cdots A^{3}_{k}\in\mathcal{A}(M), as desired.

    Case A1=(λx.A1)(yB1A11Ak1)A_{1}=(\lambda x.A^{\prime}_{1})(yB_{1}A^{1}_{1}\cdots A^{1}_{k}). In this case we must have M𝗏N1M\twoheadrightarrow_{\mathsf{v}}N_{1} for N1=(λx.M)(yM0Mk)N_{1}=(\lambda x.M^{\prime})(yM_{0}\cdots M_{k}) with A1MA^{\prime}_{1}\sqsubseteq M^{\prime}, B1M0B_{1}\sqsubseteq M_{0} and Ai1MiA^{1}_{i}\sqsubseteq M_{i} for all ii such that 1ik1\leq i\leq k. Reasoning as above, A2𝒜(M)A_{2}\in\mathcal{A}(M) implies there exists a λ\lambda-term N2N_{2} such that M𝗏N2M\twoheadrightarrow_{\mathsf{v}}N_{2} and A2N2A_{2}\sqsubseteq N_{2}. By Proposition 3(2), N1N_{1} and N2N_{2} have a common reduct NN. Since A1N1A_{1}\sqsubseteq N_{1}, by Lemma 7 we get A1NA_{1}\sqsubseteq N thus N=(λx.N)(yN0Nk)N=(\lambda x.N^{\prime})(yN_{0}\cdots N_{k}). By Lemma 7 again, A2NA_{2}\sqsubseteq N whence A2=(λx.A2)(yB2A12Ak2)A_{2}=(\lambda x.A^{\prime}_{2})(yB_{2}A^{2}_{1}\cdots A^{2}_{k}) where A2NA^{\prime}_{2}\sqsubseteq N^{\prime}, B2N0B_{2}\sqsubseteq N_{0} and Ai2NiA^{2}_{i}\sqsubseteq N_{i} for 1ik1\leq i\leq k. By induction hypothesis we get A3𝒜(N)A^{\prime}_{3}\in\mathcal{A}(N^{\prime}) such that A1A3A2A^{\prime}_{1}\sqsubseteq A^{\prime}_{3}\sqsupseteq A^{\prime}_{2}, B3𝒜(N0)B_{3}\in\mathcal{A}(N_{0}) such that B1B3B2B_{1}\sqsubseteq B_{3}\sqsupseteq B_{2} and Ai3𝒜(Ni)A^{3}_{i}\in\mathcal{A}(N_{i}) such that Ai1Ai3Ai2A^{1}_{i}\sqsubseteq A^{3}_{i}\sqsupseteq A^{2}_{i} for 1ik1\leq i\leq k. It follows that the upper bound (λx.A3)(yB3A13Ak3)(\lambda x.A^{\prime}_{3})(yB_{3}A^{3}_{1}\cdots A^{3}_{k}) of A1,A2A_{1},A_{2} belongs to 𝒜((λx.N)(yN0Nk))\mathcal{A}((\lambda x.N^{\prime})(yN_{0}\cdots N_{k})). By Lemma 8, we conclude that (λx.A3)(yB3A13Ak3)𝒜(M)(\lambda x.A^{\prime}_{3})(yB_{3}A^{3}_{1}\cdots A^{3}_{k})\in\mathcal{A}(M).

    All other cases follow from Lemma 7, confluence of 𝗏\to_{\mathsf{v}} and the induction hypothesis.

  • To prove that 𝒜(M)\mathcal{A}(M) is downward closed, we need to show that for all A1,A2𝒜A_{1},A_{2}\in\mathcal{A}, if A1A2𝒜(M)A_{1}\sqsubseteq A_{2}\in\mathcal{A}(M) then A1𝒜(M)A_{1}\in\mathcal{A}(M), but this follows directly from its definition.

As a consequence, whenever 𝒜(M)\mathcal{A}(M)\neq\emptyset, we can actually define the Böhm tree of a λ\lambda-term MM as the supremum of its approximants in 𝒜(M)\mathcal{A}(M).

{defi}
  1. (1)

    Let MΛ.M\in\Lambda. The (call-by-value) Böhm tree of MM, in symbols BT(M)\mathrm{BT}(M), is defined as follows (where we assume that =\bigsqcup\emptyset=\emptyset):

    BT(M)=𝒜(M)\mathrm{BT}(M)=\bigsqcup\mathcal{A}(M)

    Therefore, the resulting structure is a possibly infinite labelled tree TT.

  2. (2)

    More generally, every 𝒳𝒜\mathcal{X}\subseteq\mathcal{A} directed and downward closed determines a so-called Böhm-like tree T=𝒳T=\bigsqcup\mathcal{X}.

  3. (3)

    Given a Böhm-like tree TT, we set FV(T)=FV(𝒳)=A𝒳FV(A)\mathrm{FV}(T)=\mathrm{FV}(\mathcal{X})=\bigcup_{A\in\mathcal{X}}\mathrm{FV}(A).

The difference between the Böhm tree of a λ\lambda-term MM and a Böhm-like tree TT is that the former must be ‘‘computable77 7 The formal meaning of “computable” will be discussed in the rest of the section.” since it is λ\lambda-definable, while the latter can be arbitrary. In particular, any Böhm tree BT(M)\mathrm{BT}(M) is a Böhm-like tree but the converse does not hold.

Remark 10.
  1. (1)

    Notice that 𝒜(M)=𝒜(N)\mathcal{A}(M)=\mathcal{A}(N) if and only if BT(M)=BT(N)\mathrm{BT}(M)=\mathrm{BT}(N).

  2. (2)

    The supremum 𝒳\bigsqcup\mathcal{X} in Definition 2.1(2) (and a fortiori 𝒜(M)\bigsqcup\mathcal{A}(M), in (1)) belongs to the larger set 𝒳\mathscr{X} generated by taking the grammar in Definition 2.1(1) coinductively, whose elements are ordered by \sqsubseteq extended to infinite terms. However, 𝒳\mathscr{X} contains terms like

    (λy1.(λy2.(λy3.)(yy))(yy))(yy)𝒳(\lambda y_{1}.(\lambda y_{2}.(\lambda y_{3}.\cdots)(yy))(yy))(yy)\in\mathscr{X}

    that are not “Böhm-like” as they cannot be obtained as the supremum of a directed subset 𝒳𝒜\mathcal{X}\subseteq\mathcal{A}.

  3. (3)

    FV(BT(M))FV(M)\mathrm{FV}(\mathrm{BT}(M))\subseteq\mathrm{FV}(M) and the inclusion can be strict: FV(BT(λx.Ωy))=FV()=\mathrm{FV}(\mathrm{BT}(\lambda x.\Omega y))=\mathrm{FV}(\bot)=\emptyset.

The Böhm-like trees defined above as the supremum of a set of approximants can be represented as actual trees. Indeed, any Böhm-like tree TT can be depicted using the following “building blocks”.

  • If T=T=\bot we actually draw a node labelled \bot.

  • If T=λx.TT=\lambda x.T^{\prime} we use an abstraction node labelled “λx\lambda x”:

    λx\lambda xTT^{\prime}
  • If T=xT1TkT=xT_{1}\cdots T_{k}, we use an application node labelled by “@@”:

    @@xT1Tkx\quad T_{1}\quad\cdots\quad T_{k}
  • If T=(λx.T0)(yT1Tk)T=(\lambda x.T_{0})(yT_{1}\cdots T_{k}) we combine the application and abstraction nodes as imagined:

    @@λx\lambda xT0T_{0}@@yT1Tky\quad T_{1}\quad\cdots\quad T_{k}

Notice that the tree T1T_{1} in the last two cases need to respect the shape of the corresponding approximant (Definition 2.1(1)) for otherwise TT would not be the supremum of an ideal.

{exa}

Notable examples of Böhm trees of λ\lambda-terms are given in Figure 1. Interestingly, the λ\lambda-term Ξ\Xi from Example 1.1(6) satisfying

Ξ=𝗏(λy1.((λy2.((λyn.Ξ𝙸n)(zz)))(zz)))(zz)\Xi=_{\mathsf{v}}(\lambda y_{1}.((\lambda y_{2}.(\cdots(\lambda y_{n}.\Xi\mathtt{I}^{\sim n})(zz)\cdots))(zz)))(zz) (1)

is such that BT(Ξ)=\mathrm{BT}(\Xi)=\bot. Indeed, substituting \bot for a λyn.Ξ𝙸n\lambda y_{n}.\Xi\mathtt{I}^{\sim n} in (1) never gives an approximant belonging to 𝒜\mathcal{A} (cf. the grammar of Definition 2.1(1)).

BT(Ω)\mathrm{BT}(\Omega)\shortparallel\emptysetBT(λx.Ω)\mathrm{BT}(\lambda x.\Omega)\shortparallel\botBT(𝚉)\mathrm{BT}(\mathtt{Z})\shortparallelλf\lambda f@@ffλz0\lambda z_{0}@@ffλz1\lambda z_{1}z0z_{0}@@ffλz2\lambda z_{2}z1z_{1}BT(𝙸(zz))\mathrm{BT}(\mathtt{I}(zz))\shortparallel@@λx\lambda xxx@@zzzzBT(𝙺)\mathrm{BT}(\mathtt{\mathtt{K}^{*}})\shortparallelλx0\lambda x_{0}λx1\lambda x_{1}λx2\lambda x_{2}λx3\lambda x_{3}BT(𝚉𝙱)\mathrm{BT}(\mathtt{ZB})\shortparallelλf0\lambda f_{0}λx0\lambda x_{0}@@@@f0f_{0}x0x_{0}λf1\lambda f_{1}λx1\lambda x_{1}@@@@f1f_{1}x1x_{1}λf2\lambda f_{2}λx2\lambda x_{2}
Figure 1. Examples of CbV Böhm trees.
Proposition 11.

For M,NΛM,N\in\Lambda, if M=𝗏NM=_{\mathsf{v}}N then BT(M)=BT(N)\mathrm{BT}(M)=\mathrm{BT}(N).

Proof 2.6.

By Proposition 3(2) (i.e. confluence of 𝗏\to_{\mathsf{v}}), M=𝗏NM=_{\mathsf{v}}N if and only if there exists a λ\lambda-term PP such that M𝗏PM\twoheadrightarrow_{\mathsf{v}}P and N𝗏PN\twoheadrightarrow_{\mathsf{v}}P. By an iterated application of Lemma 8 we get 𝒜(M)=𝒜(P)=𝒜(N)\mathcal{A}(M)=\mathcal{A}(P)=\mathcal{A}(N), so we conclude BT(M)=BT(N)\mathrm{BT}(M)=\mathrm{BT}(N).

Theorem 12 below provides a characterization of those Böhm-like trees arising as the Böhm tree of some λ\lambda-term, in the spirit of [Bar84, Thm. 10.1.23]. To achieve this result, it will be convenient to consider a tree as a set of sequences closed under prefix.

We denote by Nature{\rm Nature}^{*} the set of finite sequences of natural numbers. Given n1,,nkNaturen_{1},\dots,n_{k}\in{\rm Nature}, the corresponding sequence σNature\sigma\in{\rm Nature}^{*} of length kk is represented by σ=n1,,nk\sigma=\langle n_{1},\dots,n_{k}\rangle. In particular, \langle\rangle represents the empty sequence of length 0. Given σNature\sigma\in{\rm Nature}^{*} as above and nNaturen\in{\rm Nature}, we write n::σn::\sigma for the sequence n,n1,,nk\langle n,n_{1},\dots,n_{k}\rangle and σ;n\sigma;n for the sequence n1,,nk,n\langle n_{1},\dots,n_{k},n\rangle.

Given a tree TT, the sequence i::σi::\sigma possibly determines a subtree that can be found going through the (i+1)(i+1)-th children of TT (if it exists) and then following the path σ\sigma. Of course this is only the case if i::σi::\sigma actually belongs to the domain of the tree. The following definition formalizes this intuitive idea in the particular case of syntax trees of approximants.

{defi}

Let σNature,A𝒜\sigma\in{\rm Nature}^{*},A\in\mathcal{A}. The subterm of AA at σ\sigma, written AσA_{\sigma}, is defined by:

A=A(λx.A)σ={Aτif σ=0::τ,otherwise,σ=(xA0Ak)σ={(Ai1)τif 1ik+1 and σ=i::τ,otherwise,((λx.A)(yA0Ak))σ={Aτif σ=0::0::τ,(Ai1)τif 1ik+1 and σ=1::i::τ,otherwise.\begin{array}[]{lrcl}A_{\langle\rangle}=A&(\lambda x.A)_{\sigma}&=&\begin{cases}A_{\tau}&\textrm{if }\sigma=0::\tau,\\ \uparrow&\textrm{otherwise},\end{cases}\\ \\ \bot_{\sigma}=\ \uparrow&(xA_{0}\cdots A_{k})_{\sigma}&=&\begin{cases}(A_{i-1})_{\tau}&\textrm{if $1\leq i\leq k+1$ and }\sigma=i::\tau,\\ \uparrow&\textrm{otherwise},\end{cases}\\ \\ &((\lambda x.A^{\prime})(yA_{0}\cdots A_{k}))_{\sigma}&=&\begin{cases}A^{\prime}_{\tau}&\textrm{if }\sigma=0::0::\tau,\\ (A_{i-1})_{\tau}&\textrm{if $1\leq i\leq k+1$ and }\sigma=1::i::\tau,\\ \uparrow&\textrm{otherwise.}\end{cases}\\ \end{array}

As a matter of notation, given an approximant AA^{\prime}, a subset 𝒳𝒜\mathcal{X}\subseteq\mathcal{A} and a sequence σNature\sigma\in{\rm Nature}^{*}, we write Aσ𝒳A\exists A_{\sigma}\simeq_{\mathcal{X}}A^{\prime} whenever there exists A𝒳A\in\mathcal{X} such that AσA_{\sigma} is defined and Aσ=AA_{\sigma}=A^{\prime}.

Theorem 12.

Let 𝒳𝒜\mathcal{X}\subseteq\mathcal{A} be a set of approximants. There exists MΛM\in\Lambda such that 𝒜(M)=𝒳\mathcal{A}(M)=\mathcal{X} if and only if the following three conditions hold:

  1. (1)

    𝒳\mathcal{X} is directed and downward closed w.r.t. \sqsubseteq,

  2. (2)

    𝒳\mathcal{X} is r.e. (after coding),

  3. (3)

    FV(𝒳)\mathrm{FV}(\mathcal{X}) is finite.

Proof 2.7 (Proof sketch).

()(\Rightarrow) Let MΛM\in\Lambda be such that 𝒳=𝒜(M)\mathcal{X}=\mathcal{A}(M), then (1) is satisfied by Proposition 9 and (3) by Remark 10. Concerning (2), let us fix an effective bijective encoding #:ΛNature\#:\Lambda_{\bot}\to{\rm Nature}. Then the set {#AA𝒳}\{\#A\mid A\in\mathcal{X}\} is r.e. because it is semi-decidable to determine if M𝗏NM\twoheadrightarrow_{\mathsf{v}}N (just enumerate all 𝗏\mathsf{v}-reducts of MM and check whether NN is one of them), the set {#AA𝒜}\{\#A\mid A\in\mathcal{A}\} and the relation \sqsubseteq restricted to 𝒜×Λ\mathcal{A}\times\Lambda are decidable.

()(\Leftarrow) Assume that 𝒳\mathcal{X} is a set of approximants satisfying the conditions (1-3).

If 𝒳=\mathcal{X}=\emptyset then we can simply take M=ΩM=\Omega since 𝒜(Ω)=\mathcal{A}(\Omega)=\emptyset.

If 𝒳\mathcal{X} is non-empty then it is an ideal. Since 𝒳\mathcal{X} is r.e., if A𝒜A^{\prime}\in\mathcal{A} and σNature\sigma\in{\rm Nature}^{*} are effectively given then the condition Aσ𝒳A\exists A_{\sigma}\simeq_{\mathcal{X}}A^{\prime} is semi-decidable and a witness 𝙰\mathtt{A} can be computed. Let σ\ulcorner\sigma\urcorner be the numeral associated with σ\sigma under an effective encoding and A\ulcorner A\urcorner be the quote of AA as defined by Mogensen88 8 This encoding is particularly convenient because it is effective, defined on open terms by exploiting the fact that FV(M)=FV(M)\mathrm{FV}(\ulcorner M\urcorner)=\mathrm{FV}(M) and works in the CbV setting as well (easy to check). See also [BDS13, §6.1] for a nice treatment. in [Mog92], using a fresh variable zbFV(𝒳)z_{b}\notin\mathrm{FV}(\mathcal{X}) to represent the \bot. (Such variable always exists because FV(𝒳)\mathrm{FV}(\mathcal{X}) is finite.) The CbV λ\lambda-calculus being Turing-complete, as shown by Paolini in [Pao01], there exists a λ\lambda-term P𝒳P_{\mathcal{X}} satisfying:

P𝒳σA=𝗏{𝙰 if Aσ𝒳A holds,not potentially valuable otherwise.P_{\mathcal{X}}\ulcorner\sigma\urcorner\ulcorner A^{\prime}\urcorner=_{\mathsf{v}}\begin{cases}\ulcorner\mathtt{A}\urcorner&\textrm{ if $\exists A_{\sigma}\simeq_{\mathcal{X}}A^{\prime}$ holds},\\ \textrm{not potentially valuable}&\textrm{ otherwise.}\\ \end{cases}

for some witness 𝙰\mathtt{A}. Recall that there exists an evaluator 𝙴Λo\mathtt{E}\in\Lambda^{o} such that 𝙴M=𝗏M\mathtt{E}\ulcorner M\urcorner=_{\mathsf{v}}M for all λ\lambda-terms MM. Using the λ\lambda-terms 𝙴,P𝒳\mathtt{E},P_{\mathcal{X}} so-defined and the recursion operator 𝚉\mathtt{Z}, it is possible to define a λ\lambda-term FF (also depending on 𝒳\mathcal{X}) satisfying the following recursive equations:

Fσ=𝗏{xif Aσ𝒳x,λx.Fσ;0if Aσ𝒳λx.A1,x(Fσ;1)(Fσ;k+1)if Aσ𝒳xA0Ak,(λx.Fσ;0;0)(y(Fσ;1;1)(Fσ;1;k+1))if Aσ𝒳(λx.A)(yA0Ak),not valuableotherwise.F\,\ulcorner\sigma\urcorner=_{\mathsf{v}}\!\!\begin{cases}x&\textrm{if }\exists A_{\sigma}\simeq_{\mathcal{X}}x,\\ \lambda x.F\,\ulcorner\sigma;0\urcorner&\textrm{if }\exists A_{\sigma}\simeq_{\mathcal{X}}\lambda x.A_{1},\\ x(F\,\ulcorner\sigma;1\urcorner)\cdots(F\,\ulcorner\sigma;k+1\urcorner)&\textrm{if }\exists A_{\sigma}\simeq_{\mathcal{X}}xA_{0}\cdots A_{k},\\ \big(\lambda x.F\ulcorner\sigma;0;0\urcorner\big)\big(y(F\ulcorner\sigma;1;1\urcorner)\cdots(F\ulcorner\sigma;1;k+1\urcorner)\big)&\textrm{if }\exists A_{\sigma}\simeq_{\mathcal{X}}(\lambda x.A)(yA_{0}\cdots A_{k}),\\ \textrm{not valuable}&\textrm{otherwise.}\\ \end{cases}

The fact that 𝒳\mathcal{X} is directed guarantees that, for a given sequence σ\sigma, exactly one of the cases above is applicable. It is now easy to check that 𝒜(F)=𝒳\mathcal{A}(F\,\ulcorner\langle\rangle\urcorner)=\mathcal{X}.

3. Call-By-Value Taylor Expansion

The (call-by-name) resource calculus λr\lambda_{r} has been introduced by Tranquilli in his thesis [Tra09], and its promotion-free fragment is the target language of Ehrhard and Regnier’s Taylor expansion [ER06]. Both the resource calculus and the notion of Taylor expansion have been adapted to the CbV setting by Ehrhard [Ehr12], using Girard’s second translation of intuitionistic arrow in linear logic. Carraro and Guerrieri added to CbV λr\lambda_{r} the analogous of the σ\sigma-rules and studied the denotational and operational properties of the resulting language λrσ{\lambda^{\sigma}_{r}} in [CG14].

3.1. Its syntax and operational semantics.

We briefly recall here the definition of the call-by-value resource calculus λrσ{\lambda^{\sigma}_{r}} from [CG14], and introduce some notations.

{defi}

The sets Valr\mathrm{Val}^{r} of resource values, Λs\Lambda^{s} of simple terms and Λr\Lambda^{r} of resource terms are generated by the following grammars (for k0k\geq 0):

(Valr)u,v::=x|λx.tresource values(Λs)s,t::=st|[v1,,vk]simple terms(Λr)e::=v|sresource terms\begin{array}[]{llcll}(\mathrm{Val}^{r})&u,v&::=&x\mid\lambda x.t&\textrm{resource values}\\ (\Lambda^{s})&s,t&::=&st\mid{[}v_{1},\dots,v_{k}{]}&\textrm{simple terms}\\ (\Lambda^{r})&e&::=&v\mid s&\textrm{resource terms}\\ \end{array}

The notions of α\alpha-conversion and free variable are inherited from λvσ\lambda^{\sigma}_{v}. In particular, given eΛre\in\Lambda^{r}, FV(e)\mathrm{FV}(e) denotes the set of free variables of ee. The size of a resource term ee is defined in the obvious way, while the height 𝗁𝗍(e)\mathsf{ht}(e) of ee is the height of its syntax tree:

𝗁𝗍(x)=0,𝗁𝗍(λx.t)=𝗁𝗍(t)+1,𝗁𝗍(st)=max{𝗁𝗍(s),𝗁𝗍(t)}+1,𝗁𝗍([v1,,vk])=max{𝗁𝗍(vi)ik}+1.\begin{array}[]{lcl}\mathsf{ht}(x)&=&0,\\ \mathsf{ht}(\lambda x.t)&=&\mathsf{ht}(t)+1,\\ \mathsf{ht}(st)&=&\max\{\mathsf{ht}(s),\mathsf{ht}(t)\}+1,\\ \mathsf{ht}({[}v_{1},\dots,v_{k}{]})&=&\max\{\mathsf{ht}(v_{i})\mid i\leq k\}+1.\\ \end{array}

Resource values are analogous to the values of λvσ\lambda^{\sigma}_{v}, namely variables and λ\lambda-abstractions. Simple terms of shape [v1,,vn]{[}v_{1},\dots,v_{n}{]} are called bags and represent finite multisets of linear resources — this means that every viv_{i} must be used exactly once along the reduction. Indeed, when a singleton bag [λx.t]{[}\lambda x.t{]} is applied to a bag [v1,,vn]{[}v_{1},\dots,v_{n}{]} of resource values, each viv_{i} is substituted for exactly one free occurrence of xx in tt. Such an occurrence is chosen non-deterministically, and all possibilities are taken into account — this is expressed by a set-theoretical union of resource terms (see Example 3.1 below). In case there is a mismatch between the cardinality of the bag and the number of occurrences of xx in tt, the reduction relation “raises an exception” and the result of the computation is the empty set \emptyset.

Whence, we need to introduce some notations concerning sets of resource terms.

{nota}

Sets of resource values, simple terms and resource terms are denoted by:

𝒰,𝒱𝒫(Valr),𝒮,𝒯𝒫(Λs),𝒫(Λr),\mathcal{U},\mathcal{V}\in\mathscr{P}(\mathrm{Val}^{r}),\quad\mathcal{S},\mathcal{T}\in\mathscr{P}(\Lambda^{s}),\quad\mathcal{E}\in\mathscr{P}(\Lambda^{r}),

To simplify the subsequent definitions, given 𝒮,𝒯𝒫(Λs)\mathcal{S,T}\in\mathscr{P}(\Lambda^{s}) and 𝒱1,,𝒱k𝒫(Valr)\mathcal{V}_{1},\dots,\mathcal{V}_{k}\in\mathscr{P}(\mathrm{Val}^{r}) we fix the following notations (as a syntactic sugar, not as actual syntax):

λx.𝒯={λx.tt𝒯}𝒫(Valr),𝒮𝒯={sts𝒮,t𝒯}𝒫(Λs),[𝒱1,,𝒱k]={[v1,,vk]v1𝒱1,,vk𝒱k}𝒫(Λs).\begin{array}[]{ccl}\lambda x.\mathcal{T}&=&\{\lambda x.t\mid t\in\mathcal{T}\}\in\mathscr{P}(\mathrm{Val}^{r}),\\ \mathcal{S\,T}&=&\{st\mid s\in\mathcal{S},t\in\mathcal{T}\}\in\mathscr{P}(\Lambda^{s}),\\ {[}\mathcal{V}_{1},\dots,\mathcal{V}_{k}{]}&=&\{{[}v_{1},\dots,v_{k}{]}\mid v_{1}\in\mathcal{V}_{1},\dots,v_{k}\in\mathcal{V}_{k}\}\in\mathscr{P}(\Lambda^{s}).\\ \end{array}

Indeed all constructors of λrσ{\lambda^{\sigma}_{r}} are multi-linear, so we get λx.=𝒯=𝒮=[,𝒱1,,𝒱k]=\lambda x.\emptyset=\emptyset\mathcal{T}=\mathcal{S}\emptyset=[\emptyset,\mathcal{V}_{1},\dots,\mathcal{V}_{k}]=\emptyset.

These notations are used in a crucial way, e.g., in Definition 3.1(2).

{defi}

Let eΛre\in\Lambda^{r} and x𝕍x\in\mathbb{V}.

  1. (1)

    Define the degree of xx in ee, written degx(e)\mathrm{deg}_{x}(e), as the number of free occurrences of the variable xx in the resource term ee.

  2. (2)

    Let eΛre\in\Lambda^{r}, v1,,vnValrv_{1},\dots,v_{n}\in\mathrm{Val}^{r} and x𝕍x\in\mathbb{V}. The linear substitution of v1,,vnv_{1},\dots,v_{n} for xx in ee, denoted by ex:=[v1,,vn]𝒫f(Λr)e\langle x:=[v_{1},\dots,v_{n}]\rangle\in\mathscr{P}_{\mathrm{f}}(\Lambda^{r}), is defined as follows:

    ex:=[v1,,vn]={{e[x1:=vσ(1),,xn:=vσ(n)]σ𝔖n},if degx(e)=n,,otherwise.e\langle x:=[v_{1},\dots,v_{n}]\rangle=\begin{cases}\big\{e[x_{1}:=v_{\sigma(1)},\dots,x_{n}:=v_{\sigma(n)}]\mid\sigma\in\mathfrak{S}_{n}\big\},&\textrm{if }\mathrm{deg}_{x}(e)=n,\\ \emptyset,&\textrm{otherwise.}\end{cases}

    where 𝔖n\mathfrak{S}_{n} is the group of permutations over {1,,n}\{1,\dots,n\} and x1,,xnx_{1},\dots,x_{n} is an enumeration of the free occurrences of xx in ee, so that e[xi:=vσ(i)]e{[}x_{i}:=v_{\sigma(i)}] denotes the resource term obtained from ee by replacing the ii-th free occurrence of xx in ee with the resource value vσ(i)v_{\sigma(i)}.

The definitions above open the way to introduce the following notions of reduction for λrσ{\lambda^{\sigma}_{r}}, mimicking the corresponding reductions of λvσ\lambda^{\sigma}_{v} (cf. Definition 1.1).

{defi}
  1. (1)

    The βr\beta_{r}-reduction is a relation βrΛr×𝒫f(Λr)\to_{\beta_{r}}\,\subseteq\Lambda^{r}\times\mathscr{P}_{\mathrm{f}}(\Lambda^{r}) defined by the following rule (for v1,,vnValrv_{1},\dots,v_{n}\in\mathrm{Val}^{r}):

    (βr)[λx.t][v1,,vk]tx:=[v1,,vn].(\beta_{r})\quad[\lambda x.t][v_{1},\dots,v_{k}]\to t\langle x:=[v_{1},\dots,v_{n}]\rangle.

    Similarly, the 00-reduction 0Λr×𝒫f(Λr)\to_{0}\,\subseteq\Lambda^{r}\times\mathscr{P}_{\mathrm{f}}(\Lambda^{r}) is defined by the rule:

    (0)[v1,,vn]t, when n1.(0)\quad[v_{1},\dots,v_{n}]\,t\to\emptyset,\quad\textrm{ when }n\neq 1.\qquad

    The σ\sigma-reductions σ1,σ3Λr×Λr\to_{\sigma_{1}},\to_{\sigma_{3}}\,\subseteq\Lambda^{r}\times\Lambda^{r} are defined by the rules:

    (σ1)[λx.t]s1s2[λx.ts2]s1,if xFV(s1),(σ3)[v]([λx.t]s)[λx.[v]t]s,if xFV(v) and vValr.\begin{array}[]{lll}(\sigma_{1})&[\lambda x.t]s_{1}s_{2}\to[\lambda x.ts_{2}]s_{1},&\textrm{if }x\notin\mathrm{FV}(s_{1}),\\ (\sigma_{3})&[v]([\lambda x.t]s)\to[\lambda x.[v]t]s,&\textrm{if }x\notin\mathrm{FV}(v)\textrm{ and }v\in\mathrm{Val}^{r}.\\ \end{array}
  2. (2)

    The relation 𝗋𝒫f(Λr)×𝒫f(Λr)\to_{\mathsf{r}}\ \subseteq\mathscr{P}_{\mathrm{f}}(\Lambda^{r})\times\mathscr{P}_{\mathrm{f}}(\Lambda^{r}) is the contextual closure of the rules above, i.e. 𝗋\to_{\mathsf{r}} is the smallest relation including (βr),(0),(σ1),(σ3)(\beta_{r}),(0),(\sigma_{1}),(\sigma_{3}) and satisfying the rules in Figure 2.

    t𝗋𝒯λx.t𝗋λx.𝒯s𝗋𝒮st𝗋𝒮tt𝗋𝒯st𝗋s𝒯v0𝗋𝒱0[v0,v1,,vk]𝗋[𝒱0,v1,,vk]e𝗋1e2{e}2𝗋12\begin{array}[]{c}\hskip 10.0pt\lambda x.t\to_{\mathsf{r}}\lambda x.\mathcal{T}t\to_{\mathsf{r}}\mathcal{T}\qquad s\,t\to_{\mathsf{r}}\mathcal{S}\,ts\to_{\mathsf{r}}\mathcal{S}\qquad s\,t\to_{\mathsf{r}}s\,\mathcal{T}t\to_{\mathsf{r}}\mathcal{T}\qquad{[}v_{0},v_{1},\dots,v_{k}{]}\to_{\mathsf{r}}{[}\mathcal{V}_{0},v_{1},\dots,v_{k}{]}v_{0}\to_{\mathsf{r}}\mathcal{V}_{0}\\[8.61108pt] \{e\}\cup\mathcal{E}_{2}\to_{\mathsf{r}}\mathcal{E}_{1}\cup\mathcal{E}_{2}\lx@proof@logical@and e\to_{\mathsf{r}}\mathcal{E}_{1}e\notin\mathcal{E}_{2}\\ \end{array}
    Figure 2. Contextual rules for 𝗋𝒫f(Λr)×𝒫f(Λr)\to_{\mathsf{r}}\ \subseteq\mathscr{P}_{\mathrm{f}}(\Lambda^{r})\times\mathscr{P}_{\mathrm{f}}(\Lambda^{r}).
  3. (3)

    The transitive and reflexive closure of 𝗋\to_{\mathsf{r}} is denoted by 𝗋\twoheadrightarrow_{\mathsf{r}}, as usual.

{exa}

We provide some examples of reductions:

  1. (1)

    [λx.[x][x]][λy.[y],z]βr{[λy.[y]][z],[z][λy.[y]]}βr{[z],[z][λy.[y]]}{[}\lambda x.{[}x{]}{[}x{]}{]}{[}\lambda y.{[}y{]},z{]}\to_{\beta_{r}}\{{[}\lambda y.{[}y{]}{]}{[}z{]},{[}z{]}{[}\lambda y.{[}y{]}{]}\}\to_{\beta_{r}}\{{[}z{]},{[}z{]}{[}\lambda y.{[}y{]}{]}\}.

  2. (2)

    [λx.[x,x]][λy.[y],z]βr{[λy.[y],z],[z,λy.[y]]}={[λy.[y],z]{[}\lambda x.{[}x,x{]}{]}{[}\lambda y.{[}y{]},z{]}\to_{\beta_{r}}\{{[}\lambda y.{[}y{]},z{]},{[}z,\lambda y.{[}y{]}{]}\}=\{{[}\lambda y.{[}y{]},z{]}}.

  3. (3)

    [λy.[λx.[x,x][y]]]([z][w])[𝙸,w]σ1[λy.[λx.[x,x][y]][𝙸,w]]([z][w])βr{[λy.[𝙸,w][y]]([z][w])}{[}\lambda y.{[}\lambda x.{[}x,x{]}{[}y{]}{]}{]}({[}z{]}{[}w{]}){[}\mathtt{I},w{]}\to_{\sigma_{1}}{[}\lambda y.{[}\lambda x.{[}x,x{]}{[}y{]}{]}{[}\mathtt{I},w{]}{]}({[}z{]}{[}w{]})\to_{\beta_{r}}\{{[}\lambda y.{[}\mathtt{I},w{]}{[}y{]}{]}({[}z{]}{[}w{]})\} 0\to_{0}\emptyset. Note that (σ1)(\sigma_{1}) is used to unblock an otherwise stuck βr\beta_{r}-redex.

  4. (4)

    [𝙸]([λx.[λy.[x][y]]][z][w])βr{[λx.[λy.[x][y]]][z][w]}βr{[λy.[z][y]][w]}βr{[z][w]}{[}\mathtt{I}{]}({[}\lambda x.{[}\lambda y.{[}x{]}{[}y{]}{]}{]}{[}z{]}{[}w{]})\to_{\beta_{r}}\{{[}\lambda x.{[}\lambda y.{[}x{]}{[}y{]}{]}{]}{[}z{]}{[}w{]}\}\to_{\beta_{r}}\{{[}\lambda y.{[}z{]}{[}y{]}{]}{[}w{]}\}\to_{\beta_{r}}\{{[}z{]}{[}w{]}\}.

  5. (5)

    [𝙸]([λx.[λy.[x][y]]][z][w])σ3[λx.[𝙸][λy.[x][y]]][z][w]σ1[λx.[𝙸][λy.[x][y]][w]][z]βr{[𝙸][λy.[z][y]][w]}βr{[λy.[z][y]][w]}βr{[z][w]}{[}\mathtt{I}{]}({[}\lambda x.{[}\lambda y.{[}x{]}{[}y{]}{]}{]}{[}z{]}{[}w{]})\to_{\sigma_{3}}{[}\lambda x.{[}\mathtt{I}{]}{[}\lambda y.{[}x{]}{[}y{]}{]}{]}{[}z{]}{[}w{]}\to_{\sigma_{1}}{[}\lambda x.{[}\mathtt{I}{]}{[}\lambda y.{[}x{]}{[}y{]}{]}{[}w{]}{]}{[}z{]}\to_{\beta_{r}}\{{[}\mathtt{I}{]}{[}\lambda y.{[}z{]}{[}y{]}{]}{[}w{]}\}\to_{\beta_{r}}\{{[}\lambda y.{[}z{]}{[}y{]}{]}{[}w{]}\}\to_{\beta_{r}}\{{[}z{]}{[}w{]}\}.

Remark that (4) and (5) constitute two different reduction sequences originating from the same simple term.

As shown in [CG14], this notion of reduction enjoys the following properties.

Proposition 13.

The reduction 𝗋\to_{\mathsf{r}} is confluent and strongly normalizing.

Note that strong normalization is straightforward to prove — indeed, a 00-reduction annihilates the whole term, σ\sigma-rules are strongly normalizing (cf. Proposition 3(1)) and contracting a βr\beta_{r}-redex in a resource term ee produces a set of resource terms whose size is strictly smaller than ee because no duplication is involved and a λ\lambda-abstraction is erased.

As a consequence of Proposition 13, the 𝗋\mathsf{r}-normal form of 𝒫f(Λr)\mathcal{E}\in\mathscr{P}_{\mathrm{f}}(\Lambda^{r}) always exists and is denoted by nf𝗋()\mathrm{nf}_{\mathsf{r}}(\mathcal{E}), i.e. 𝗋nf𝗋()𝒫f(Λr)\mathcal{E}\twoheadrightarrow_{\mathsf{r}}\mathrm{nf}_{\mathsf{r}}(\mathcal{E})\in\mathscr{P}_{\mathrm{f}}(\Lambda^{r}) and there is no \mathcal{E}^{\prime} such that nf𝗋()𝗋\mathrm{nf}_{\mathsf{r}}(\mathcal{E})\to_{\mathsf{r}}\mathcal{E}^{\prime}. Simple terms in 𝗋\mathsf{r}-nf are called “resource approximants” because their role is similar to the one played by finite approximants of Böhm trees, except that they approximate the normal form of the Taylor expansion. They admit the following syntactic characterization.

{defi}

A resource approximant aΛsa\in\Lambda^{s} is a simple term generated by the following grammar (for k,n0k,n\geq 0, where [xn]{[}x^{n}{]} is the bag [x,,x]{[}x,\dots,x{]} having nn occurrences of xx):

a::=b|cb::=[xn][λx.a1,,λx.an][x]ba1akc::=[λx.a]([y]ba1ak)\begin{array}[]{lcl}a&::=&b\mid c\\ b&::=&{[}x^{n}{]}\mid{[}\lambda x.a_{1},\dots,\lambda x.a_{n}{]}\mid{[}x{]}ba_{1}\cdots a_{k}\\ c&::=&{[}\lambda x.a{]}({[}y{]}ba_{1}\cdots a_{k})\\ \end{array}

It is easy to check that resource approximants are 𝗋\mathsf{r}-normal forms.

{exa}

The following are examples of resource approximants:

  1. (1)

    [λx.[x],λx.[x,x],λx.[x,x,x]]{[}\lambda x.{[}x{]},\lambda x.{[}x,x{]},\lambda x.{[}x,x,x{]}{]} and [λx.[x][x,x],λx.[x][x,x,x]]{[}\lambda x.{[}x{]}{[}x,x{]},\lambda x.{[}x{]}{[}x,x,x{]}{]} belong to the Taylor expansion of some λ\lambda-term (as we will see in Example 3.2).

  2. (2)

    [λx.[x,x,x],λx.[y,y,y]]{[}\lambda x.{[}x,x,x{]},\lambda x.{[}y,y,y{]}{]} does not, as will be shown in Proposition 19.

3.2. Characterizing the Taylor Expansion of a λ\lambda-Term

We recall the definition of the Taylor expansion of a λ\lambda-term in the CbV setting, following [Ehr12, CG14]. Such a Taylor expansion translates a λ\lambda-term MM into an infinite set99 9 This set can be thought of as the support of the actual Taylor expansion, which is an infinite formal linear combination of simple terms taking coefficients in the semiring of non-negative rational numbers. of simple terms. Subsequently, we characterize those sets of resource terms arising as a Taylor expansion of some MΛM\in\Lambda.

{defi}

The Taylor expansion 𝒯(M)Λs\mathscr{T}(M)\subseteq\Lambda^{s} of a λ\lambda-term MM is an infinite set of simple terms defined by induction as follows:

𝒯(x)={[xn]n0}, where [xn]=[x,,x] (n times),𝒯(λx.N)={[λx.t1,,λx.tn]n0,in,ti𝒯(N)},𝒯(PQ)={sts𝒯(P),t𝒯(Q)}.\begin{array}[]{lcl}\mathscr{T}(x)&=&\{{[}x^{n}{]}\mid n\geq 0\},\textrm{ where }[x^{n}]=[x,\dots,x]\textrm{ ($n$ times)},\\ \mathscr{T}(\lambda x.N)&=&\{{[}\lambda x.t_{1},\dots,\lambda x.t_{n}{]}\mid n\geq 0,\forall i\leq n,\ t_{i}\in\mathscr{T}(N)\},\\ \mathscr{T}(PQ)&=&\{st\mid s\in\mathscr{T}(P),\ t\in\mathscr{T}(Q)\}.\\ \end{array}

From the definition above, we get the following easy properties.

Remark 14.
  1. (1)

    []𝒯(V)[]\in\mathscr{T}(V) if and only if VValV\in\mathrm{Val}.

  2. (2)

    Every occurrence of a βrσ\beta_{r}\sigma-redex in t𝒯(M)t\in\mathscr{T}(M) arises from some 𝗏\mathsf{v}-redex in MM.

  3. (3)

    By exploiting Notation 3.1, we can rewrite the Taylor expansion of an application or an abstraction as follows:

    𝒯(PQ)=𝒯(P)𝒯(Q),𝒯(λx.N)=nNature{[λx.𝒯(N),,λx.𝒯(N)n times]}.\begin{array}[]{lcl}\mathscr{T}(PQ)&=&\mathscr{T}(P)\mathscr{T}(Q),\\ \mathscr{T}(\lambda x.N)&=&\bigcup_{n\in{\rm Nature}}\{{[}\underbrace{\lambda x.\mathscr{T}(N),\dots,\lambda x.\mathscr{T}(N)}_{n\textrm{ times}}{]}\}.\\ \end{array}
{exa}

We calculate the Taylor expansion of some λ\lambda-terms.

  1. (1)

    𝒯(𝙸)={[λx.[xn1],,λx.[xnk]]k0,ik,ni0}\mathscr{T}(\mathtt{I})=\{{[}\lambda x.{[}x^{n_{1}}{]},\dots,\lambda x.{[}x^{n_{k}}{]}{]}\mid k\geq 0,\forall i\leq k,n_{i}\geq 0\},

  2. (2)

    𝒯(Δ)={[λx.[xn1][xm1],,λx.[xnk][xmk]]k0,ik,mi,ni0}\mathscr{T}(\Delta)=\{{[}\lambda x.{[}x^{n_{1}}{]}{[}x^{m_{1}}{]},\dots,\lambda x.{[}x^{n_{k}}{]}{[}x^{m_{k}}{]}{]}\mid k\geq 0,\forall i\leq k,m_{i},n_{i}\geq 0\},

  3. (3)

    𝒯(Δ𝙸)={sts𝒯(Δ),t𝒯(𝙸)}\mathscr{T}(\Delta\mathtt{I})=\{st\mid s\in\mathscr{T}(\Delta),t\in\mathscr{T}(\mathtt{I})\},

  4. (4)

    𝒯(Ω)={sts,t𝒯(Δ)}\mathscr{T}(\Omega)=\{st\mid s,t\in\mathscr{T}(\Delta)\},

  5. (5)

    𝒯(λz.yyz)={[λz.[y1][ym1][zn1],,λz.[yk][ymk][znk]]k0,ik,i,mi,ni0}\mathscr{T}(\lambda z.yyz)=\{{[}\lambda z.{[}y^{\ell_{1}}{]}{[}y^{m_{1}}{]}{[}z^{n_{1}}{]},\dots,\lambda z.{[}y^{\ell_{k}}{]}{[}y^{m_{k}}{]}{[}z^{n_{k}}{]}{]}\mid k\geq 0,\forall i\leq k,\ell_{i},m_{i},n_{i}\geq 0\},

  6. (6)

    𝒯(λy.f(λz.yyz))={[λy.[fn1]t1,,λy.[fnk]tk]k0,ik,ni0,ti𝒯(λz.yyz)}\mathscr{T}(\lambda y.f(\lambda z.yyz))=\{{[}\lambda y.{[}f^{n_{1}}{]}t_{1},\dots,\lambda y.{[}f^{n_{k}}{]}t_{k}{]}\mid k\geq 0,\forall i\leq k,n_{i}\geq 0,t_{i}\in\mathscr{T}(\lambda z.yyz)\},

  7. (7)

    𝒯(𝚉)={[λf.s1t1,,λf.sktk]k0,ik,si,ti𝒯(λy.f(λz.yyz))}\mathscr{T}(\mathtt{Z})=\{{[}\lambda f.s_{1}t_{1},\dots,\lambda f.s_{k}t_{k}{]}\mid k\geq 0,\forall i\leq k,s_{i},t_{i}\in\mathscr{T}(\lambda y.f(\lambda z.yyz))\}.

These examples naturally brings to formulate the next remark and lemma.

Remark 15.

An element tt belonging to the Taylor expansion of a λ\lambda-term MM in 𝗏\mathsf{v}-nf might not be in 𝗋\mathsf{r}-nf, due to the possible presence of 00-redexes. For an example, consider [λx.[x,x][x,x],λx.[x][x,x,x]]𝒯(Δ){[}\lambda x.{[}x,x{]}{[}x,x{]},\lambda x.{[}x{]}{[}x,x,x{]}{]}\in\mathscr{T}(\Delta). Notice that, since the reduction does not modify the cardinality of a bag, a more refined definition of Taylor expansion eliminating all 0-redexes is possible by substituting the application case with the following:

𝒯(VM0Mk)={[v]t0tk[v]𝒯(V),i.(0ik)ti𝒯(Mi)}\mathscr{T}(VM_{0}\cdots M_{k})=\{{[}v{]}t_{0}\cdots t_{k}\mid{[}v{]}\in\mathscr{T}(V),\forall i\,.\,(0\leq i\leq k)\ t_{i}\in\mathscr{T}(M_{i})\}

We prefer to keep Ehrhard’s original notion because it has a simpler inductive definition.

The following statement concerning the Taylor expansion of λ\lambda-terms in 𝗏\mathsf{v}-nf does hold.

Lemma 16.

For MΛM\in\Lambda, the following are equivalent:

  1. (1)

    MM is in 𝗏\mathsf{v}-normal form,

  2. (2)

    every t𝒯(M)t\in\mathscr{T}(M) is in βrσ\beta_{r}\sigma-normal form.

Proof 3.1.

(1 \Rightarrow 2) Using Lemma 2, we proceed by induction on the normal structure of MM.

If M=xM=x then t𝒯(M)t\in\mathscr{T}(M) entails t=[x,,x]t=[x,\dots,x] which is in 𝗏\mathsf{v}-nf.

If M=λx.GM=\lambda x.G then t𝒯(M)t\in\mathscr{T}(M) implies that t=[λx.t1,,λx.tn]t=[\lambda x.t_{1},\dots,\lambda x.t_{n}] where ti𝒯(G)t_{i}\in\mathscr{T}(G) for all ini\leq n. By the induction hypothesis each tit_{i} is in βrσ\beta_{r}\sigma-nf, hence, so is tt.

If M=xHG1GkM=xHG_{1}\cdots G_{k} then t𝒯(M)t\in\mathscr{T}(M) entails t=[xn]st1tkt={[}x^{n}{]}st_{1}\cdots t_{k} for some n0n\geq 0, s𝒯(H)s\in\mathscr{T}(H) and ti𝒯(Gi)t_{i}\in\mathscr{T}(G_{i}) (1ik1\leq i\leq k). By induction hypothesis s,t1,,tks,t_{1},\dots,t_{k} are in βrσ\beta_{r}\sigma-nf, so tt is in βr\beta_{r}-nf. Concerning σ\sigma-rules, tt could have a σ3\sigma_{3}-redex in case s=[λx.s]ts=[\lambda x.s^{\prime}]t^{\prime} but this is impossible since s𝒯(H)s\in\mathscr{T}(H) and HH cannot have shape (λx.P)Q(\lambda x.P)Q.

If M=(λx.G)(yHG1Gk)M=(\lambda x.G)(yHG_{1}\cdots G_{k}) and t𝒯(M)t\in\mathscr{T}(M) then t=[λx.s1,,λx.sn]tt=[\lambda x.s_{1},\dots,\lambda x.s_{n}]t^{\prime} for some n0n\geq 0, si𝒯(G)s_{i}\in\mathscr{T}(G), 1in1\leq i\leq n, and t𝒯(yHG1Gk)t^{\prime}\in\mathscr{T}(yHG_{1}\cdots G_{k}). By induction hypothesis, the resource terms s1,,sns_{1},\dots,s_{n} and tt^{\prime} are in βrσ\beta_{r}\sigma-nf. In principle, when n=1n=1, the simple term tt might have the shape either of a βr\beta_{r}-redex or of a σ3\sigma_{3}-redex. Both cases are impossible since t𝒯(yHG1Gk)t^{\prime}\in\mathscr{T}(yHG_{1}\cdots G_{k}) entails t=[ym]st1tkt^{\prime}=[y^{m}]st_{1}\cdots t_{k} which is neither a resource value nor a simple term of shape [λz.s]s[\lambda z.s]s^{\prime}. We conclude that tt is in βrσ\beta_{r}\sigma-nf.

(2 \Rightarrow 1) We prove the contrapositive. Assume that MM is not in 𝗏\mathsf{v}-nf, then either MM itself is a β𝗏\beta_{\mathsf{v}}- or σ\sigma-redex, or it contains one as a subterm. Let us analyze first the former case.

  1. (β𝗏)(\beta_{\mathsf{v}})

    If M=(λx.N)VM=(\lambda x.N)V for VValV\in\mathrm{Val} then, by Remark 14(1), the βr\beta_{r}-redex [λx.s][][\lambda x.s][] belongs to 𝒯(M)\mathscr{T}(M) for every s𝒯(N)s\in\mathscr{T}(N).

  2. (σ1)(\sigma_{1})

    If M=(λx.N)PQM=(\lambda x.N)PQ then for all s𝒯(N),t1𝒯(P),t2𝒯(Q)s\in\mathscr{T}(N),t_{1}\in\mathscr{T}(P),t_{2}\in\mathscr{T}(Q) we have [λx.s]t1t2𝒯(M)[\lambda x.s]t_{1}t_{2}\in\mathscr{T}(M) and this simple term is a σ1\sigma_{1}-redex.

  3. (σ3)(\sigma_{3})

    If M=V((λx.P)Q)M=V((\lambda x.P)Q) for VValV\in\mathrm{Val} then for all [v]𝒯(V),s𝒯(P)[v]\in\mathscr{T}(V),s\in\mathscr{T}(P) and t𝒯(Q)t^{\prime}\in\mathscr{T}(Q) we have [v]([λx.s]t)𝒯(M)[v]([\lambda x.s]t^{\prime})\in\mathscr{T}(M) and this resource term is a σ2\sigma_{2}-redex.

Otherwise M=CMM=C\llparenthesis M^{\prime}\rrparenthesis where CC is a context and MM^{\prime} is a 𝗏\mathsf{v}-redex having one of the shapes above; in this case there is t𝒯(M)t\in\mathscr{T}(M) containing a βrσ\beta_{r}\sigma-redex t𝒯(M)t^{\prime}\in\mathscr{T}(M^{\prime}) as a subterm.

The rest of the section is devoted to provide a characterization of all sets of simple terms that arise as the Taylor expansion of some λ\lambda-term MM.

{defi}
  1. (1)

    The height of a non-empty set Λr\mathcal{E}\subseteq{\Lambda^{r}}, written 𝗁𝗍()\mathsf{ht}(\mathcal{E}), is the maximal height of its elements, if it exists, and in this case we say that \mathcal{E} has finite height. Otherwise, we define 𝗁𝗍()=0\mathsf{ht}(\mathcal{E})=\aleph_{0} and we say that \mathcal{E} has infinite height.

  2. (2)

    Define a coherence relation Λr×Λr\coh\ \subseteq\Lambda^{r}\times\Lambda^{r} as the smallest relation satisfying:

    xxstλx.sλx.tvivj(i,jn)[v1,,vk][vk+1,,vn]s1s2t1t2s1t1s2t2x\coh x\phantom{x\coh x}\qquad\lambda x.s\coh\lambda x.ts\coh t\qquad{[}v_{1},\dots,v_{k}{]}\coh{[}v_{k+1},\dots,v_{n}{]}\lx@proof@logical@and v_{i}\coh v_{j}(\forall i,j\leq n)\qquad s_{1}t_{1}\coh s_{2}t_{2}\lx@proof@logical@and s_{1}\coh s_{2}t_{1}\coh t_{2}
  3. (3)

    A subset Λr\mathcal{E}\subseteq{\Lambda^{r}} is a clique whenever eee\coh e^{\prime} holds for all e,ee,e^{\prime}\in\mathcal{E}.

  4. (4)

    A clique \mathcal{E} is maximal if, for every eΛre\in\Lambda^{r}, {e}\mathcal{E}\cup\{e\} is a clique entails ee\in\mathcal{E}.

The coherence relation above is inspired by Ehrhard’s work in the call-by-name setting [ER08]. Note that \coh is symmetric, but neither reflexive as [x,y]�̸[x,y]{[}x,y{]}\not\coh{[}x,y{]} nor transitive since [x][][y][x]\coh[]\coh[y] but [x]�̸[y][x]\not\coh[y].

{exa}

Notice that all sets in Example 3.2 are maximal cliques of finite height. For instance, 𝗁𝗍(𝒯(𝙸))=3\mathsf{ht}(\mathscr{T}(\mathtt{I}))=3 and by following the rules in Definition 3.2(2) we have utu\coh t for all t𝒯(𝙸)t\in\mathscr{T}(\mathtt{I}) if and only if either u=[]u={[}{]} or u=[xn]u={[}x^{n}{]} for some nNaturen\in{\rm Nature} if and only if u𝒯(𝙸)u\in\mathscr{T}(\mathtt{I}). Therefore 𝒯(𝙸)\mathscr{T}(\mathtt{I}) is maximal.

The rest of the section is devoted to proving that these two properties actually characterize those sets that the Taylor expansions of λ\lambda-terms (Proposition 19).

We may now characterize resource approximants (Definition 3.1).

Lemma 17.

Let tΛst\in\Lambda^{s} be such that ttt\coh t. Then tt is in 𝗋\mathsf{r}-nf iff tt is a resource approximant.

Proof 3.2.

Notice that ttt\coh t guarantees that all terms in each bag occurring in tt have similar shape. The proof of the absence of βr\beta_{r}- and σ\sigma- redexes, is analogous to the one of Lemma 2. The bags occurring in [x]ba1ak{[}x{]}ba_{1}\cdots a_{k} and [λx.a]([y]ba1ak){[}\lambda x.a{]}({[}y{]}ba_{1}\cdots a_{k}) must be singleton multisets, for otherwise we would have some 00-redexes.

This lemma follows easily from Definition 3.2(1) and Remark 14(3).

Lemma 18.

For N,P,QΛN,P,Q\in\Lambda, we have:

  1. (1)

    𝗁𝗍(𝒯(λx.N))=𝗁𝗍(𝒯(N))+2\mathsf{ht}(\mathscr{T}(\lambda x.N))=\mathsf{ht}(\mathscr{T}(N))+2.

  2. (2)

    𝗁𝗍(𝒯(PQ))=𝗁𝗍(𝒯(P)𝒯(Q))+1\mathsf{ht}(\mathscr{T}(PQ))=\mathsf{ht}(\mathscr{T}(P)\cup\mathscr{T}(Q))+1,

Proof 3.3.

(1) Indeed, we have:

𝗁𝗍(𝒯(λx.N))=max{𝗁𝗍([λx.t1,,λx.tn])n0,in,ti𝒯(N)},=max{max{𝗁𝗍(λx.t1),,𝗁𝗍(λx.tn)}+1n0,in,ti𝒯(N)},=max{max{𝗁𝗍(t1),,𝗁𝗍(tn)}+2n0,in,ti𝒯(N)},=max{𝗁𝗍(t)+2t𝒯(N)}=𝗁𝗍(𝒯(N))+2.\begin{array}[]{lcl}\mathsf{ht}(\mathscr{T}(\lambda x.N))&=&\max\{\mathsf{ht}({[}\lambda x.t_{1},\dots,\lambda x.t_{n}{]})\mid n\geq 0,\forall i\leq n,\ t_{i}\in\mathscr{T}(N)\},\\ &=&\max\{\max{\{\mathsf{ht}(\lambda x.t_{1}),\dots,\mathsf{ht}(\lambda x.t_{n})\}}+1\mid n\geq 0,\forall i\leq n,\ t_{i}\in\mathscr{T}(N)\},\\ &=&\max\{\max{\{\mathsf{ht}(t_{1}),\dots,\mathsf{ht}(t_{n})\}}+2\mid n\geq 0,\forall i\leq n,\ t_{i}\in\mathscr{T}(N)\},\\ &=&\max\{\mathsf{ht}(t)+2\mid t\in\mathscr{T}(N)\}=\mathsf{ht}(\mathscr{T}(N))+2.\\ \end{array}

(2) This case is analogous but simpler, and we omit it.

The next proposition gives a characterization of those sets of simple terms corresponding to the Taylor expansion of some λ\lambda-terms and constitutes the main result of the section.

Proposition 19.

For Λs\mathcal{E}\subseteq\Lambda^{s}, the following are equivalent:

  1. (1)

    \mathcal{E} is a maximal clique having finite height,

  2. (2)

    There exists MΛM\in\Lambda such that =𝒯(M)\mathcal{E}=\mathscr{T}(M).

Proof 3.4.

(1 \Rightarrow 2) As \mathcal{E} maximal entails \mathcal{E}\neq\emptyset, we can proceed by induction on h=𝗁𝗍()h=\mathsf{ht}(\mathcal{E}).

The case h=0h=0 is vacuous because no simple term has height 00.

If h=1h=1 then tt\in\mathcal{E} implies t=[x1,,xn]t={[}x_{1},\dots,x_{n}{]} since variables are the only resource terms of height 00. Now, ttt\coh t holds since \mathcal{E} is a clique so the xix_{i}’s must be pairwise coherent with each other, but xixjx_{i}\coh x_{j} holds if and only if xi=xjx_{i}=x_{j} whence t=[xi,,xi]t={[}x_{i},\dots,x_{i}{]} for some index ii. From this, and the fact that \mathcal{E} is maximal, we conclude =𝒯(xi)\mathcal{E}=\mathscr{T}(x_{i}).

Assume h>1h>1 and split into cases depending on the form of tt\in\mathcal{E}.

  • Case t=[λx.s1,,λx.sk]t={[}\lambda x.s_{1},\dots,\lambda x.s_{k}{]}. Since 𝗁𝗍()>1\mathsf{ht}(\mathcal{E})>1 we can assume wlog that t[]t\neq{[}{]}, namely k>0k>0. Moreover, since \mathcal{E} is a clique, all tt^{\prime}\in\mathcal{E} must have shape t=[λx.sk+1,,λx.sn]t^{\prime}={[}\lambda x.s_{k+1},\dots,\lambda x.s_{n}{]} for some nn with sisjs_{i}\coh s_{j} for all i,jni,j\leq n. It follows that the set 𝒮={s[λx.s]}\mathcal{S}=\{s\mid{[}\lambda x.s{]}\in\mathcal{E}\} is a maximal clique, because \mathcal{E} is maximal, and has height h2h-2 since 𝗁𝗍([λx.s])=𝗁𝗍(s)+2\mathsf{ht}({[}\lambda x.s{]})=\mathsf{ht}(s)+2. Moreover, ={[λx.s1,,λx.sk]k0,ik.si𝒮}\mathcal{E}=\{{[}\lambda x.s_{1},\dots,\lambda x.s_{k}{]}\mid k\geq 0,\forall i\leq k\ .\ s_{i}\in\mathcal{S}\}. By induction hypothesis there exists NΛN\in\Lambda such that 𝒮=𝒯(N)\mathcal{S}=\mathscr{T}(N), so we get =𝒯(λx.N)\mathcal{E}=\mathscr{T}(\lambda x.N).

  • Otherwise, if t=s1s2t=s_{1}s_{2} then all tt^{\prime}\in\mathcal{E} must be of the form t=s1s2t^{\prime}=s^{\prime}_{1}s^{\prime}_{2} with s1s1s_{1}\coh s^{\prime}_{1} and s2s2s_{2}\coh s^{\prime}_{2}. So, the set \mathcal{E} can be written as =𝒮1𝒮2\mathcal{E}=\mathcal{S}_{1}\mathcal{S}_{2} where 𝒮1={tts2}\mathcal{S}_{1}=\{t\mid ts_{2}\in\mathcal{E}\} and 𝒮2={ts1t}\mathcal{S}_{2}=\{t\mid s_{1}t\in\mathcal{E}\}. As \mathcal{E} is a maximal clique, the sets 𝒮1,𝒮2\mathcal{S}_{1},\mathcal{S}_{2} are independent from the choice of s2,s1s_{2},s_{1} (resp.), and they are maximal cliques themselves. Moreover, 𝗁𝗍()=𝗁𝗍(𝒮1𝒮2)+1\mathsf{ht}(\mathcal{E})=\mathsf{ht}(\mathcal{S}_{1}\cup\mathcal{S}_{2})+1, whence the heights of 𝒮1,𝒮2\mathcal{S}_{1},\mathcal{S}_{2} are strictly smaller than hh. By the induction hypothesis, there exists P,QΛP,Q\in\Lambda such that 𝒮1=𝒯(P)\mathcal{S}_{1}=\mathscr{T}(P) and 𝒮2=𝒯(Q)\mathcal{S}_{2}=\mathscr{T}(Q), from which it follows =𝒯(PQ)\mathcal{E}=\mathscr{T}(PQ).

(2 \Rightarrow 1) We proceed by induction on the structure of MM.

If M=xM=x then t,t𝒯(M)t,t^{\prime}\in\mathscr{T}(M) entails t=[xk]t=[x^{k}] and t=[xn]t^{\prime}={[}x^{n}{]} for some k,n0k,n\geq 0, whence 𝒯(x)\mathscr{T}(x) is a clique of height 1. It is moreover maximal because it contains [xi]{[}x^{i}{]} for all i0i\geq 0.

If M=λx.NM=\lambda x.N then t,t𝒯(M)t,t^{\prime}\in\mathscr{T}(M) entails t=[λx.t1,,λx.tk]t=[\lambda x.t_{1},\dots,\lambda x.t_{k}] and t=[λx.tk+1,,λx.tn]t^{\prime}=[\lambda x.t_{k+1},\dots,\lambda x.t_{n}] with ti𝒯(N)t_{i}\in\mathscr{T}(N) for all ini\leq n. By induction hypothesis 𝒯(N)\mathscr{T}(N) is a maximal clique of finite height hNatureh\in{\rm Nature}, in particular titjt_{i}\coh t_{j} for all i,jni,j\leq n which entails ttt\coh t^{\prime}. The maximality of 𝒯(M)\mathscr{T}(M) follows from that of 𝒯(N)\mathscr{T}(N) and, by Lemma 18(1), 𝗁𝗍(𝒯(M))\mathsf{ht}(\mathscr{T}(M)) has finite height h+2h+2.

If M=PQM=PQ then t,t𝒯(M)t,t^{\prime}\in\mathscr{T}(M) entails t=s1t1t=s_{1}t_{1} and t=s2t2t^{\prime}=s_{2}t_{2} for s1,s2𝒯(P)s_{1},s_{2}\in\mathscr{T}(P) and t1,t2𝒯(Q)t_{1},t_{2}\in\mathscr{T}(Q). By induction hypothesis, s1s2s_{1}\coh s_{2} and t1t2t_{1}\coh t_{2} hold and thus ttt\coh t^{\prime}. Also in this case, the maximality of 𝒯(M)\mathscr{T}(M) follows from the same property of 𝒯(P),𝒯(Q)\mathscr{T}(P),\mathscr{T}(Q). Finally, by induction hypothesis, 𝗁𝗍(𝒯(P))=h1\mathsf{ht}(\mathscr{T}(P))=h_{1} and 𝗁𝗍(𝒯(Q))=h2\mathsf{ht}(\mathscr{T}(Q))=h_{2} for h1,h2Natureh_{1},h_{2}\in{\rm Nature} then 𝗁𝗍(𝒯(M))=max{h1,h2}+1\mathsf{ht}(\mathscr{T}(M))=\max\{h_{1},h_{2}\}+1 by Lemma 18(2), and this concludes the proof.

4. Computing the Normal Form of the Taylor expansion, and Beyond

The Taylor expansion, as defined in Section 3.2, is a static operation translating a λ\lambda-term into an infinite set of simple terms. However, we have seen in Proposition 13 that the reduction 𝗋\to_{\mathsf{r}} is confluent and strongly normalizing. Whence, it is possible to define the normal form of an arbitrary set of resource terms as follows.

{defi}

The 𝗋\mathsf{r}-normal form is extended element-wise to any subset Λr\mathcal{E}\subseteq{\Lambda^{r}} by setting NF()=enf𝗋(e)\mathrm{NF}(\mathcal{E})=\bigcup_{e\in\mathcal{E}}\ \mathrm{nf}_{\mathsf{r}}(e). In particular, NF(Λs)\mathrm{NF}(\Lambda^{s}) (resp. NF(Λr)\mathrm{NF}(\Lambda^{r}), NF(Valr)\mathrm{NF}(\mathrm{Val}^{r})) represents the set of all simple terms (resp. resource terms, resource values) in 𝗋\mathsf{r}-nf generated by the grammar in Definition 3.1. Moreover, NF(𝒯(M))\mathrm{NF}(\mathscr{T}(M)) is a well-defined subset of NF(Λs)\mathrm{NF}(\Lambda^{s}) for every MΛM\in\Lambda (it can possibly be the empty set, thought).

{exa}

We calculate the 𝗋\mathsf{r}-normal form of the Taylor expansions from Example 3.2:

  1. (1)

    NF(𝒯(𝙸))=𝒯(𝙸)={[λx.[xn1],,λx.[xnk]]k0,ik,ni0}\mathrm{NF}(\mathscr{T}(\mathtt{I}))=\mathscr{T}(\mathtt{I})=\{{[}\lambda x.{[}x^{n_{1}}{]},\dots,\lambda x.{[}x^{n_{k}}{]}{]}\mid k\geq 0,\forall i\leq k,n_{i}\geq 0\},

  2. (2)

    NF(𝒯(Δ))={[λx.[x][xm1],,λx.[x][xmk]]k0,ik,mi0}\mathrm{NF}(\mathscr{T}(\Delta))=\{{[}\lambda x.{[}x{]}{[}x^{m_{1}}{]},\dots,\lambda x.{[}x{]}{[}x^{m_{k}}{]}{]}\mid k\geq 0,\forall i\leq k,m_{i}\geq 0\},

  3. (3)

    NF(𝒯(Δ𝙸))=NF(𝒯(𝙸))\mathrm{NF}(\mathscr{T}(\Delta\mathtt{I}))=\mathrm{NF}(\mathscr{T}(\mathtt{I})),

  4. (4)

    NF(𝒯(Ω))=\mathrm{NF}(\mathscr{T}(\Omega))=\emptyset, from this it follows:

  5. (5)

    NF(𝒯(λx.Ω))={[]}\mathrm{NF}(\mathscr{T}(\lambda x.\Omega))=\{[]\}, moreover, for 𝙰=(λz.(λy.y)(zz))(xx)\mathtt{A}=(\lambda z.(\lambda y.y)(zz))(xx), we obtain:

  6. (6)

    NF(𝒯(𝙰))={[λz.[[λy.[y1]]([z][zm1])]([x][xn1]),,λz.[[λy.[yk]]([z][zmk])]([x][xnk])]k0,ik,i,mi,ni0}\mathrm{NF}(\mathscr{T}(\mathtt{A}))=\{{[}\lambda z.{[}{[}\lambda y.{[}y^{\ell_{1}}{]}{]}({[}z{]}{[}z^{m_{1}}{]}){]}{({[}x{]}{[}x^{n_{1}}{]})},\dots,\lambda z.{[}{[}\lambda y.{[}y^{\ell_{k}}{]}{]}({[}z{]}{[}z^{m_{k}}{]}){]}{({[}x{]}{[}x^{n_{k}}{]})}{]}\mid{}\hskip 75.0ptk\geq 0,\forall i\leq k,\ell_{i},m_{i},n_{i}\geq 0\}.

On the one hand, it is not difficult to calculate the normal forms of the Taylor expansions of 𝙸,Δ\mathtt{I},\Delta and 𝙰\mathtt{A}. (As shown in Lemma 16, it is enough to perform some 00-reductions.) Similarly, it is not difficult to check that NF(𝒯(Ω))\mathrm{NF}(\mathscr{T}(\Omega)) is empty, once realized that no term t𝒯(Ω)t\in\mathscr{T}(\Omega) can survive through the reduction. On the other hand, it is more complicated to compute the normal forms of 𝒯(𝚉)\mathscr{T}(\mathtt{Z}), and hence 𝒯(𝚉𝙱)\mathscr{T}(\mathtt{ZB}), without having a result connecting such normal forms with the 𝗏\mathsf{v}-reductions of the corresponding λ\lambda-terms. The rest of the section is devoted to study such a relationship. We start with some technical lemmas.

Lemma 20 (Substitution Lemma).

Let MΛM\in\Lambda, VValV\in\mathrm{Val} and x𝕍x\in\mathbb{V}. Then we have:

𝒯(M[x:=V])=t𝒯(M)[v1,,vn]𝒯(V)tx:=[v1,,vn].\mathscr{T}(M{[}x:=V])=\bigcup_{t\in\mathscr{T}(M)}\bigcup_{[v_{1},\dots,v_{n}]\in\mathscr{T}(V)}t\langle x:=[v_{1},\dots,v_{n}]\rangle.
Proof 4.1.

Straightforward induction on the structure of MM.

Lemma 21.

Let M,NΛM,N\in\Lambda be such that M𝗏NM\to_{\mathsf{v}}N. Then:

  1. (1)

    for all t𝒯(M)t\in\mathscr{T}(M), there exists 𝒯𝒯(N)\mathcal{T}\subseteq\mathscr{T}(N) such that t𝗋𝒯t\twoheadrightarrow_{\mathsf{r}}\mathcal{T},

  2. (2)

    for all t𝒯(N)t^{\prime}\in\mathscr{T}(N) such that t↛0t^{\prime}\not\to_{0}\emptyset, there exist t𝒯(M)t\in\mathscr{T}(M) and 𝒯𝒫f(Λs)\mathcal{T}\in\mathscr{P}_{\mathrm{f}}(\Lambda^{s}) satisfying t𝗋{t}𝒯t\twoheadrightarrow_{\mathsf{r}}\{t^{\prime}\}\cup\mathcal{T}. Moreover such a tt is unique.

Proof 4.2.

We check that both (1) and (2) hold by induction on a derivation of M𝗏NM\to_{\mathsf{v}}N, splitting into cases depending on the kind of redex is reduced.

(βv)(\beta_{v}):

If M=(λx.Q)VM=(\lambda x.Q)V and N=Q[x:=V]N=Q{[}x:=V] then items (1) and (2) follow by Lemma 20.

(σ1)(\sigma_{1}):

If M=(λx.M)PQM=(\lambda x.M^{\prime})PQ and N=(λx.MQ)PN=(\lambda x.M^{\prime}Q)P then

𝒯(M)={[λx.t1,,λx.tn]s1s2n0,ti𝒯(M),s1𝒯(P),s2𝒯(Q)},𝒯(N)={[λx.t1s1,,λx.tnsn]sn0,ti𝒯(M),si𝒯(Q),s𝒯(P)}.\begin{array}[]{lcl}\mathscr{T}(M)&=&\{{[}\lambda x.t_{1},\dots,\lambda x.t_{n}{]}s_{1}s_{2}\mid n\geq 0,t_{i}\in\mathscr{T}(M^{\prime}),s_{1}\in\mathscr{T}(P),s_{2}\in\mathscr{T}(Q)\},\\ \mathscr{T}(N)&=&\{{[}\lambda x.t^{\prime}_{1}s^{\prime}_{1},\dots,\lambda x.t^{\prime}_{n}s^{\prime}_{n}{]}s\mid n\geq 0,t^{\prime}_{i}\in\mathscr{T}(M^{\prime}),s^{\prime}_{i}\in\mathscr{T}(Q),s\in\mathscr{T}(P)\}.\\ \end{array}

For n1n\neq 1, we have [λx.t1,,λx.tn]s1s20𝒯(N){[}\lambda x.t_{1},\dots,\lambda x.t_{n}{]}s_{1}s_{2}\to_{0}\emptyset\subseteq\mathscr{T}(N). For n=1n=1, we get [λx.t1]s1s2σ1[λx.t1s2]s1{[}\lambda x.t_{1}{]}s_{1}s_{2}\to_{\sigma_{1}}{[}\lambda x.t_{1}s_{2}{]}s_{1} for t1𝒯(M)t_{1}\in\mathscr{T}(M^{\prime}), s1𝒯(P)s_{1}\in\mathscr{T}(P) and s2𝒯(Q)s_{2}\in\mathscr{T}(Q), whence [λx.t1s2]s1𝒯(N){[}\lambda x.t_{1}s_{2}{]}s_{1}\in\mathscr{T}(N) and (1) holds. Concerning (2), note that [λx.t1s1,,λx.tnsn]s↛0{[}\lambda x.t^{\prime}_{1}s^{\prime}_{1},\dots,\lambda x.t^{\prime}_{n}s^{\prime}_{n}{]}s\not\to_{0}\emptyset entails n=1n=1. Moreover, 𝒯(M)[λx.t1]ss1σ1[λx.t1s1]s\mathscr{T}(M)\ni{[}\lambda x.t^{\prime}_{1}{]}ss^{\prime}_{1}\to_{\sigma_{1}}{[}\lambda x.t^{\prime}_{1}s^{\prime}_{1}{]}s since t1𝒯(M),s1𝒯(Q),s𝒯(P)t^{\prime}_{1}\in\mathscr{T}(M^{\prime}),s^{\prime}_{1}\in\mathscr{T}(Q),s\in\mathscr{T}(P).

(σ3)(\sigma_{3}):

If M=V((λx.P)Q)M=V((\lambda x.P)Q) for VValV\in\mathrm{Val} and N=(λx.VP)QN=(\lambda x.VP)Q then

𝒯(M)={[v1,,vn]([λx.s1,,λx.sm]s)n0,[v1,,vn]𝒯(V),im,si𝒯(P),s𝒯(Q)},\begin{array}[]{ll}\mathscr{T}(M)=\{{[}v_{1},\dots,v_{n}{]}({[}\lambda x.s_{1},\dots,\lambda x.s_{m}{]}s)\mid&n\geq 0,{[}v_{1},\dots,v_{n}{]}\in\mathscr{T}(V),\\ &i\leq m,\ s_{i}\in\mathscr{T}(P),s\in\mathscr{T}(Q)\},\\ \end{array}
𝒯(N)={[λx.[v11,,v1k1]s1,,λx.[vn1,,vnkn]sn]sn0,in,si𝒯(P),s𝒯(Q),[vi1,,viki]𝒯(V)},\begin{array}[]{ll}\mathscr{T}(N)=\{{[}\lambda x.{[}v_{11},\dots,v_{1k_{1}}{]}s_{1},\dots,\lambda x.{[}v_{n1},\dots,v_{nk_{n}}{]}s_{n}{]}s\mid&n\geq 0,\ i\leq n,\\ &s_{i}\in\mathscr{T}(P),s\in\mathscr{T}(Q),\\ &{[}v_{i1},\dots,v_{ik_{i}}{]}\in\mathscr{T}(V)\},\\ \end{array}

For m1m\neq 1 n1n\neq 1, we have [v1,,vn]([λx.s1,,λx.sm]s)0𝒯(N){[}v_{1},\dots,v_{n}{]}({[}\lambda x.s_{1},\dots,\lambda x.s_{m}{]}s)\to_{0}\emptyset\subseteq\mathscr{T}(N). For m=n=1m=n=1, we get [v1]([λx.s1]s)σ3[λx.[v1]s1]s𝒯(N){[}v_{1}{]}({[}\lambda x.s_{1}{]}s)\to_{\sigma_{3}}{[}\lambda x.{[}v_{1}{]}s_{1}{]}s\in\mathscr{T}(N), so (1) holds. Similarly, we have that [λx.[v11,,v1k1]s1,,λx.[vn1,,vnkn]sn]s0{[}\lambda x.{[}v_{11},\dots,v_{1k_{1}}{]}s_{1},\dots,\lambda x.{[}v_{n1},\dots,v_{nk_{n}}{]}s_{n}{]}s\to_{0}\emptyset whenever n1n\neq 1 or ki1k_{i}\neq 1. For n=k1=1n=k_{1}=1, we get 𝒯(M)[v11]([λx.s1]s)σ3[λx.[v11]s1]s\mathscr{T}(M)\ni{[}v_{11}{]}({[}\lambda x.s_{1}{]}s)\to_{\sigma_{3}}{[}\lambda x.{[}v_{11}{]}s_{1}{]}s which proves (2).

In the cases above it is easy to check that tt is actually unique. The contextual cases follow straightforwardly from the induction hypothesis.

As a consequence, we obtain the analogue of Proposition 11 for Taylor expansions.

Corollary 22.

For M,NΛM,N\in\Lambda, M=𝗏NM=_{\mathsf{v}}N entails NF(𝒯(M))=NF(𝒯(N))\mathrm{NF}(\mathscr{T}(M))=\mathrm{NF}(\mathscr{T}(N)).

Proof 4.3.

It is enough to prove NF(𝒯(M))=NF(𝒯(N))\mathrm{NF}(\mathscr{T}(M))=\mathrm{NF}(\mathscr{T}(N)) for MM and NN such that M𝗏NM\to_{\mathsf{v}}N, indeed the general result follows by confluence of 𝗏\mathsf{v}-reduction. We show the two inclusions.

()(\subseteq) Consider tNF(𝒯(M))t\in\mathrm{NF}(\mathscr{T}(M)), then there exists t0𝒯(M)t_{0}\in\mathscr{T}(M) and 𝒯𝒫f(Λs)\mathcal{T}\in\mathscr{P}_{\mathrm{f}}(\Lambda^{s}) such that t0𝗋{t}𝒯t_{0}\twoheadrightarrow_{\mathsf{r}}\{t\}\cup\mathcal{T}. Since λrσ{\lambda^{\sigma}_{r}} is strongly normalizing (Proposition 13), we assume wlog 𝒯\mathcal{T} in 𝗋\mathsf{r}-nf. By Lemma 21(1), we have t0𝗋𝒯0𝒯(N)t_{0}\twoheadrightarrow_{\mathsf{r}}\mathcal{T}_{0}\subseteq{\mathscr{T}(N)} so by confluence of r\to_{r} we get 𝒯0𝗋{t}𝒯\mathcal{T}_{0}\twoheadrightarrow_{\mathsf{r}}\{t\}\cup\mathcal{T} which entails tNF(𝒯(N))t\in\mathrm{NF}(\mathscr{T}(N)) because tt is in 𝗋\mathsf{r}-nf.

()(\supseteq) If tNF(𝒯(N))t\in\mathrm{NF}(\mathscr{T}(N)) then there are s𝒯(N)s\in\mathscr{T}(N) and 𝒯𝒫f(Λs)\mathcal{T}\in\mathscr{P}_{\mathrm{f}}(\Lambda^{s}) such that s𝗋{t}𝒯s\twoheadrightarrow_{\mathsf{r}}\{t\}\cup\mathcal{T}. By Lemma 21(2), there exists s0𝒯(M)s_{0}\in\mathscr{T}(M) and 𝒮𝒫f(Λs)\mathcal{S}\in\mathscr{P}_{\mathrm{f}}(\Lambda^{s}) satisfying s0𝗋{s}𝒮s_{0}\twoheadrightarrow_{\mathsf{r}}\{s\}\cup\mathcal{S}. Composing the two reductions we get s0𝗋{t}𝒮𝒯s_{0}\twoheadrightarrow_{\mathsf{r}}\{t\}\cup\mathcal{S}\cup\mathcal{T}, thus tNF(𝒯(M))t\in\mathrm{NF}(\mathscr{T}(M)) as well.

We now prove a Context Lemma for Taylor expansions in the spirit of [Bar84, Cor. 14.3.20] (namely, the Context Lemma for CbN Böhm trees). For the sake of simplicity, in the next lemma we consider head contexts but the same reasoning works for arbitrary contexts.

Lemma 23 (Context Lemma for Taylor expansions).

Let M,NΛM,N\in\Lambda. If NF(𝒯(M))=NF(𝒯(N))\mathrm{NF}(\mathscr{T}(M))=\mathrm{NF}(\mathscr{T}(N)) then, for all head contexts CC\llparenthesis-\rrparenthesis, we have NF(𝒯(CM))=NF(𝒯(CN))\mathrm{NF}(\mathscr{T}(C\llparenthesis M\rrparenthesis))=\mathrm{NF}(\mathscr{T}(C\llparenthesis N\rrparenthesis)).

Proof 4.4.

Consider C=(λx1xn.)V1VkC\llparenthesis-\rrparenthesis=(\lambda x_{1}\dots x_{n}.\llparenthesis-\rrparenthesis)V_{1}\cdots V_{k} for n,k0n,k\geq 0. Let us take tNF(𝒯(CM))t\in\mathrm{NF}(\mathscr{T}(C\llparenthesis M\rrparenthesis)) and prove that tt belongs to NF(𝒯(CN))\mathrm{NF}(\mathscr{T}(C\llparenthesis N\rrparenthesis)), the other inclusion being symmetrical. Then there exists t0𝒯(CM)t_{0}\in\mathscr{T}(C\llparenthesis M\rrparenthesis) and 𝒯𝒫f(NF(Λs))\mathcal{T}\in\mathscr{P}_{\mathrm{f}}(\mathrm{NF}(\Lambda^{s})) such that t0𝗋{t}𝒯t_{0}\twoheadrightarrow_{\mathsf{r}}\{t\}\cup\mathcal{T}. By definition of CC\llparenthesis-\rrparenthesis and 𝒯()\mathscr{T}(-), t0t_{0} must have the following shape:

t0=[λx1.[[λxn.s]]][v11,,v1n1][vk1,,vknk]t_{0}={[}\lambda x_{1}.{[}\cdots{[}\lambda x_{n}.s{]}\cdots{]}{]}{[}v_{11},\dots,v_{1n_{1}}{]}\cdots{[}v_{k1},\dots,v_{kn_{k}}{]}

where s𝒯(M)s\in\mathscr{T}(M), [vi1,,vini]𝒯(Vi){[}v_{i1},\dots,v_{in_{i}}{]}\in\mathscr{T}(V_{i}) where 1ik1\leq i\leq k and ni=degxi(s)n_{i}=\deg_{x_{i}}(s) for otherwise t00t_{0}\to_{0}\emptyset, which is impossible. By confluence and strong normalization of 𝗋\to_{\mathsf{r}} (Proposition 13), the reduction t0𝗋{t}𝒯t_{0}\twoheadrightarrow_{\mathsf{r}}\{t\}\cup\mathcal{T} factorizes as t0𝗋𝒯0𝗋{t}𝒯t_{0}\twoheadrightarrow_{\mathsf{r}}\mathcal{T}_{0}\twoheadrightarrow_{\mathsf{r}}\{t\}\cup\mathcal{T} where

𝒯0=[λx1.[[λxn.nf𝗋(s)]]][v11,,v1n1][vk1,,vknk]\mathcal{T}_{0}={[}\lambda x_{1}.{[}\cdots{[}\lambda x_{n}.\mathrm{nf}_{\mathsf{r}}(s){]}\cdots{]}{]}{[}v_{11},\dots,v_{1n_{1}}{]}\cdots{[}v_{k1},\dots,v_{kn_{k}}{]}

and nf𝗋(s)𝒫f(NF(𝒯(M)))\mathrm{nf}_{\mathsf{r}}(s)\in\mathscr{P}_{\mathrm{f}}(\mathrm{NF}(\mathscr{T}(M))). By hypothesis nf𝗋(s)𝒫f(NF(𝒯(N)))\mathrm{nf}_{\mathsf{r}}(s)\in\mathscr{P}_{\mathrm{f}}(\mathrm{NF}(\mathscr{T}(N))), therefore there are 𝒮1𝒫f(𝒯(N))\mathcal{S}_{1}\in\mathscr{P}_{\mathrm{f}}(\mathscr{T}(N)) such that 𝒮1𝗋nf𝗋(s)𝒮\mathcal{S}_{1}\twoheadrightarrow_{\mathsf{r}}\mathrm{nf}_{\mathsf{r}}(s)\cup\mathcal{S}^{\prime}, for some 𝒮\mathcal{S}^{\prime}, and 𝒮0𝒯(CN)\mathcal{S}_{0}\subseteq\mathscr{T}(C\llparenthesis N\rrparenthesis) of shape

𝒮0=[λx1.[[λxn.𝒮1]]][v11,,v1n1][vk1,,vknk]\mathcal{S}_{0}={[}\lambda x_{1}.{[}\cdots{[}\lambda x_{n}.\mathcal{S}_{1}{]}\cdots{]}{]}{[}v_{11},\dots,v_{1n_{1}}{]}\cdots{[}v_{k1},\dots,v_{kn_{k}}{]}

so we conclude, for some 𝒮′′\mathcal{S}^{\prime\prime}, that 𝒮0𝗋𝒯0𝒮′′𝗋{t}𝒯nf𝗋(𝒮′′)NF(𝒯(CN))\mathcal{S}_{0}\twoheadrightarrow_{\mathsf{r}}\mathcal{T}_{0}\cup\mathcal{S}^{\prime\prime}\twoheadrightarrow_{\mathsf{r}}\{t\}\cup\mathcal{T}\cup\mathrm{nf}_{\mathsf{r}}(\mathcal{S}^{\prime\prime})\subseteq\mathrm{NF}(\mathscr{T}(C\llparenthesis N\rrparenthesis)).

4.1. Taylor expanding Böhm trees.

The Taylor expansion can be extended to elements of Λ\Lambda_{\bot} by adding 𝒯()={[]}\mathscr{T}(\bot)=\{{[}{]}\} to the rules of Definition 3.2. However, the resulting translation of an approximant AA produces a set of resource terms that are not necessarily in 𝗋\mathsf{r}-normal form because of the presence of (0)(0)-redexes (as already discussed in Remark 15). Luckily, it is possible to slightly modify such a definition by performing an “on the flight” normalization and obtain directly the normalized Taylor expansion of a Böhm tree.

{defi}
  1. (1)

    Let A𝒜A\in\mathcal{A}. The normalized Taylor expansion of AA, in symbols 𝒯(A)\mathscr{T}^{\circ}(A), is defined by structural induction following the grammar of Definition 2.1(1):

    𝒯(x)={[xn]n0},𝒯(λx.A)={[λx.t1,,λx.tn]n0,ik.ti𝒯(A)},𝒯()={[]},𝒯(xBA1Ak)={[x]t0tnt0𝒯(B),1ik.ti𝒯(Ai)},𝒯((λx.A)(yBA1Ak))={[λx.s]ts𝒯(A),t𝒯(yBA1Ak)}.\begin{array}[]{rcl}\mathscr{T}^{\circ}(x)&=&\{{[}x^{n}{]}\mid n\geq 0\},\\[4.30554pt] \mathscr{T}^{\circ}(\lambda x.A^{\prime})&=&\{[\lambda x.t_{1},\dots,\lambda x.t_{n}]\mid n\geq 0,\forall i\leq k\ .\ t_{i}\in\mathscr{T}^{\circ}(A^{\prime})\},\\[4.30554pt] \mathscr{T}^{\circ}(\bot)&=&\{{[}{]}\},\\[4.30554pt] \mathscr{T}^{\circ}(xBA_{1}\cdots A_{k})&=&\{[x]t_{0}\cdots t_{n}\mid t_{0}\in\mathscr{T}^{\circ}(B),\forall 1\leq i\leq k\ .\ t_{i}\in\mathscr{T}^{\circ}(A_{i})\},\\[4.30554pt] \mathscr{T}^{\circ}((\lambda x.A^{\prime})(yBA_{1}\cdots A_{k}))&=&\{{[}\lambda x.s{]}t\mid s\in\mathscr{T}^{\circ}(A^{\prime}),\ t\in\mathscr{T}^{\circ}(yBA_{1}\cdots A_{k})\}.\\ \end{array}
  2. (2)

    The normalized Taylor expansion of BT(M)\mathrm{BT}(M), written 𝒯(BT(M))\mathscr{T}^{\circ}(\mathrm{BT}(M)), is defined by setting:

    𝒯(BT(M))=A𝒜(M)𝒯(A)\mathscr{T}^{\circ}(\mathrm{BT}(M))=\bigcup_{A\in\mathcal{A}(M)}\mathscr{T}^{\circ}(A)
{exa}
  1. (1)

    Recall from Example 2.1(1) that 𝒜(𝙸)={,λx.,λx.x}\mathcal{A}(\mathtt{I})=\{\bot,\lambda x.\bot,\lambda x.x\}, therefore

    𝒯(𝒜(𝙸))={[]}{[(λx.[])k]k0}{[λx.[xn1],,λx.[xnk]]k,n1,,nk0}\mathscr{T}^{\circ}(\mathcal{A}(\mathtt{I}))=\{{[}{]}\}\cup\{{[}(\lambda x.{[}{]})^{k}{]}\mid k\geq 0\}\cup\{{[}\lambda x.{[}x^{n_{1}}{]},\dots,\lambda x.{[}x^{n_{k}}{]}{]}\mid k,n_{1},\dots,n_{k}\geq 0\}

    By Example 4(1) this is equal to NF(𝒯(𝙸))\mathrm{NF}(\mathscr{T}(\mathtt{I})).

  2. (2)

    Since 𝒜(Ω)=\mathcal{A}(\Omega)=\emptyset we have 𝒯(𝒜(Ω))==NF(𝒯(Ω))\mathscr{T}^{\circ}(\mathcal{A}(\Omega))=\emptyset=\mathrm{NF}(\mathscr{T}(\Omega)).

  3. (3)

    Also, 𝒜(Δ)={,λx.,λx.xx}\mathcal{A}(\Delta)=\{\bot,\lambda x.\bot,\lambda x.xx\}, so that

    𝒯(𝒜(Δ))={[]}{[(λx.[])k]k0}{[λx.[x][xn1],,λx.[x][xnk]]k,n1,,nk0}\mathscr{T}^{\circ}(\mathcal{A}(\Delta))=\{{[}{]}\}\cup\{{[}(\lambda x.{[}{]})^{k}{]}\mid k\geq 0\}\cup\{{[}\lambda x.{[}x{]}{[}x^{n_{1}}{]},\dots,\lambda x.{[}x{]}{[}x^{n_{k}}{]}{]}\mid k,n_{1},\dots,n_{k}\geq 0\}

    By Example 4(2) this is equal to NF(𝒯(Δ))\mathrm{NF}(\mathscr{T}(\Delta)).

  4. (4)

    Finally, Examples 2.1(3) and 4(3) and the above item (1) give us 𝒯(𝒜(Δ𝙸))=𝒯(𝒜(𝙸))=NF(𝒯(𝙸))=NF(𝒯(Δ𝙸))\mathscr{T}^{\circ}(\mathcal{A}(\Delta\mathtt{I}))=\mathscr{T}^{\circ}(\mathcal{A}(\mathtt{I}))=\mathrm{NF}(\mathscr{T}(\mathtt{I}))=\mathrm{NF}(\mathscr{T}(\Delta\mathtt{I})).

The rest of the section is devoted to generalizing the above example, proving that the normal form of the Taylor expansion of any λ\lambda-term MM is equal to the normalized Taylor expansion of the Böhm tree of MM (Theorem 26). On the one side, this link is extremely useful to compute NF(𝒯(M))\mathrm{NF}(\mathscr{T}(M)) because the Böhm trees have the advantage of hiding the explicit amounts of resources that can become verbose and difficult to handle. On the other side, this allow to transfer results from the Taylor expansions to Böhm trees, Lemma 30 being a paradigmatic example.

Lemma 24.

Let MΛM\in\Lambda.

  1. (1)

    If t𝒯(M)t\in\mathscr{T}(M) and t𝗋{t1}𝒯1t\to_{\mathsf{r}}\{t_{1}\}\cup\mathcal{T}_{1}, then there exists NΛN\in\Lambda and 𝒯2𝒫f(Λs)\mathcal{T}_{2}\in\mathscr{P}_{\mathrm{f}}(\Lambda^{s}), such that M𝗏NM\to_{\mathsf{v}}N and {t1}𝒯1𝗋𝒯2𝒯(N)\{t_{1}\}\cup\mathcal{T}_{1}\twoheadrightarrow_{\mathsf{r}}\mathcal{T}_{2}\subseteq\mathscr{T}(N).

  2. (2)

    If tNF(𝒯(M))t\in\mathrm{NF}(\mathscr{T}(M)) then there exists MM^{\prime} such that M𝗏MM\twoheadrightarrow_{\mathsf{v}}M^{\prime} and t𝒯(M)t\in\mathscr{T}(M^{\prime}).

  3. (3)

    If t,s𝒯(M)t,s\in\mathscr{T}(M) then NF(t)NF(s)\mathrm{NF}(t)\cap\mathrm{NF}(s)\neq\emptyset entails t=st=s.

  4. (4)

    If t𝒯(M)NF(Λs)t\in\mathscr{T}(M)\cap\mathrm{NF}(\Lambda^{s}) then there exists A𝒜A\in\mathcal{A} such that AMA\sqsubseteq M and t𝒯(A)t\in\mathscr{T}^{\circ}(A).

Proof 4.5.

(1) Note that t𝗋{t1}𝒯1t\to_{\mathsf{r}}\{t_{1}\}\cup\mathcal{T}_{1} by contracting an 𝗋\mathsf{r}-redex arising from an occurrence of a 𝗏\mathsf{v}-redex in MM, so M𝗏NM\to_{\mathsf{v}}N where NN is obtained by contracting such a redex occurrence. By Lemma 21(1) and confluence of 𝗋\to_{\mathsf{r}}, there exists 𝒯2𝒯(N)\mathcal{T}_{2}\subseteq\mathscr{T}(N) such that t𝗋{t1}𝒯1𝗋𝒯2t\twoheadrightarrow_{\mathsf{r}}\{t_{1}\}\cup\mathcal{T}_{1}\twoheadrightarrow_{\mathsf{r}}\mathcal{T}_{2}.

(2) Assume that tNF(𝒯(M))t\in\mathrm{NF}(\mathscr{T}(M)), then there are t0𝒯(M)t_{0}\in\mathscr{T}(M) and 𝒯𝒫f(Λs)\mathcal{T}\in\mathscr{P}_{\mathrm{f}}(\Lambda^{s}) such that t0𝗋{t}𝒯t_{0}\twoheadrightarrow_{\mathsf{r}}\{t\}\cup\mathcal{T}. Since 𝗋\to_{\mathsf{r}} is strongly normalizing, we can assume 𝒯NF(Λs)\mathcal{T}\subseteq\mathrm{NF}(\Lambda^{s}) and choose such a reduction to have maximal length nn. We proceed by induction on nn to show that the λ\lambda-term MM^{\prime} exists. If n=0n=0 then t0t_{0} is in 𝗋\mathsf{r}-nf so just take t0=tt_{0}=t, 𝒯=\mathcal{T}=\emptyset and M=MM=M^{\prime}. Otherwise n>0n>0 and t0𝗋{t1}𝒯1𝗋{t}𝒯t_{0}\to_{\mathsf{r}}\{t_{1}\}\cup\mathcal{T}_{1}\twoheadrightarrow_{\mathsf{r}}\{t\}\cup\mathcal{T} where the second reduction is strictly shorter. By (1) and confluence there exists NN such that M𝗏NM\to_{\mathsf{v}}N and {t1}𝒯1𝗋𝒯2𝗋{t}𝒯\{t_{1}\}\cup\mathcal{T}_{1}\twoheadrightarrow_{\mathsf{r}}\mathcal{T}_{2}\twoheadrightarrow_{\mathsf{r}}\{t\}\cup\mathcal{T} for some 𝒯2𝒯(N)\mathcal{T}_{2}\subseteq\mathscr{T}(N). So, there are t2𝒯2t_{2}\in\mathcal{T}_{2} and 𝒯𝒫f(Λs)\mathcal{T}^{\prime}\in\mathscr{P}_{\mathrm{f}}(\Lambda^{s}) such that t2𝗋{t}𝒯NF(𝒯(M))t_{2}\twoheadrightarrow_{\mathsf{r}}\{t\}\cup\mathcal{T}^{\prime}\subseteq\mathrm{NF}(\mathscr{T}(M)) so we conclude by applying the induction hypothesis to this reduction shorter than nn.

(3) Assume t0NF(t)NF(𝒯(M))t_{0}\in\mathrm{NF}(t)\subseteq\mathrm{NF}(\mathscr{T}(M)). By (2) there is a reduction M𝗏M1𝗏𝗏MkM\to_{\mathsf{v}}M_{1}\to_{\mathsf{v}}\cdots\to_{\mathsf{v}}M_{k} such that t0𝒯(Mk)t_{0}\in\mathscr{T}(M_{k}). By an iterated application of Lemma 21(2), we get that tt is the unique element in 𝒯(M)\mathscr{T}(M) generating t0t_{0}. Therefore, t0NF(s)t_{0}\in\mathrm{NF}(s) entails s=ts=t.

(4) By structural induction on the normal structure of tt (characterized in Lemma 17: notice that ttt\coh t by Proposition 19).

If t=[]t={[}{]} then MValM\in\mathrm{Val} and there are two subcases: either M=xM=x, or M=λx.MM=\lambda x.M^{\prime} so we simply take A=A=\bot. Similarly, if t=[x,,x]t={[}x,\dots,x{]} (n>0n>0 occurrences) then M=A=x.M=A=x.

If t=[λx.a1,,λx.an]t={[}\lambda x.a_{1},\dots,\lambda x.a_{n}{]} with n>0n>0 then M=λx.MM=\lambda x.M^{\prime} and ai𝒯(M)a_{i}\in\mathscr{T}(M^{\prime}) for ini\leq n. By induction hypothesis, there are approximants AiMA_{i}\sqsubseteq M^{\prime} such that ai𝒯(Ai)a_{i}\in\mathscr{T}^{\circ}(A_{i}). Then we set A=λx.AA=\lambda x.A^{\prime} for A=A1AnA^{\prime}=A_{1}\sqcup\cdots\sqcup A_{n} which exists because the AiA_{i}’s are pairwise compatible.

If t=[x]ba1akt={[}x{]}ba_{1}\cdots a_{k} then M=xM0MkM=xM_{0}\cdots M_{k} and b𝒯(M0)b\in\mathscr{T}(M_{0}) and aj𝒯(Mi)a_{j}\in\mathscr{T}(M_{i}) for 1jk1\leq j\leq k. By induction hypothesis, there are A0,,AkA_{0},\dots,A_{k} such that AiMiA_{i}\sqsubseteq M_{i} for all ii (0ik0\leq i\leq k), b𝒯(A0)b\in\mathscr{T}^{\circ}(A_{0}) and aj𝒯(Aj)a_{j}\in\mathscr{T}^{\circ}(A_{j}) for 1jk1\leq j\leq k. Moreover b𝒯(A0)b\in\mathscr{T}^{\circ}(A_{0}) entails that A0A_{0} is a BB-term from the grammar in Lemma 2, therefore we may take A=xA0Ak𝒜A=xA_{0}\cdots A_{k}\in\mathcal{A}.

Finally, if t=[λx.a]([y]ba1ak)t={[}\lambda x.a{]}({[}y{]}ba_{1}\cdots a_{k}) then M=(λx.M)(yM0Mk)M=(\lambda x.M^{\prime})(yM_{0}\cdots M_{k}) with a𝒯(M)a\in\mathscr{T}(M^{\prime}) and [y]ba1ak𝒯(yM0Mk){[}y{]}ba_{1}\cdots a_{k}\in\mathscr{T}(yM_{0}\cdots M_{k}). Reasoning as in the previous case, we get yA0Ak𝒜yA_{0}\cdots A_{k}\in\mathcal{A} such that [y]ba1ak𝒯(yA0Ak){[}y{]}ba_{1}\cdots a_{k}\in\mathscr{T}^{\circ}(yA_{0}\cdots A_{k}). Moreover, by induction hypothesis, there is AMA^{\prime}\sqsubseteq M^{\prime} such that a𝒯(A)a\in\mathscr{T}^{\circ}(A^{\prime}). We conclude by taking A=(λx.A)(yA0Ak)A=(\lambda x.A^{\prime})(yA_{0}\cdots A_{k}).

Lemma 25.

Let MΛM\in\Lambda and A𝒜A\in\mathcal{A}.

  1. (1)

    If AMA\sqsubseteq M then 𝒯(A)NF(𝒯(M))\mathscr{T}^{\circ}(A)\subseteq\mathrm{NF}(\mathscr{T}(M)).

  2. (2)

    If 𝒯(A)𝒯(BT(M))\mathscr{T}^{\circ}(A)\subseteq\mathscr{T}^{\circ}(\mathrm{BT}(M)) then A𝒜(M)A\in\mathcal{A}(M).

Proof 4.6.

(1) If A=A=\bot then MValM\in\mathrm{Val} and 𝒯()={[]}𝒯(M)NF(Λr)\mathscr{T}^{\circ}(\bot)=\{[]\}\subseteq\mathscr{T}(M)\cap\mathrm{NF}(\Lambda^{r}).

Otherwise, it follows by induction on AA exploiting the fact that all simple terms in 𝒯(A)\mathscr{T}^{\circ}(A) belong to 𝒯(M)\mathscr{T}(M) and are already in 𝗋\mathsf{r}-nf.

(2) We proceed by structural induction on AA, the case A=A=\bot being trivial.

  • If A=xA=x then 𝒯(x)={[xn]n0}𝒯(BT(M))\mathscr{T}^{\circ}(x)=\{[x^{n}]\mid n\geq 0\}\subseteq\mathscr{T}^{\circ}(\mathrm{BT}(M)) entails M𝗏xM\twoheadrightarrow_{\mathsf{v}}x and we are done.

  • If A=λx.AA=\lambda x.A^{\prime} then 𝒯(λx.A)={[λx.t1,,λx.tn]n0,ik.ti𝒯(A)}\mathscr{T}^{\circ}(\lambda x.A^{\prime})=\{[\lambda x.t_{1},\dots,\lambda x.t_{n}]\mid n\geq 0,\forall i\leq k\ .\ t_{i}\in\mathscr{T}^{\circ}(A^{\prime})\}. So, 𝒯(λx.A)𝒯(BT(M))\mathscr{T}^{\circ}(\lambda x.A^{\prime})\subseteq\mathscr{T}^{\circ}(\mathrm{BT}(M)) implies that M𝗏λx.MM\twoheadrightarrow_{\mathsf{v}}\lambda x.M^{\prime} for some MM^{\prime} such that 𝒯(A)𝒯(BT(M))\mathscr{T}^{\circ}(A^{\prime})\subseteq\mathscr{T}^{\circ}(\mathrm{BT}(M^{\prime})). By induction hypothesis, we get A𝒜(M)A^{\prime}\in\mathcal{A}(M^{\prime}) and λx.A𝒜(λx.M)\lambda x.A^{\prime}\in\mathcal{A}(\lambda x.M^{\prime}). By Lemma 8 we obtain λx.A𝒜(M)\lambda x.A^{\prime}\in\mathcal{A}(M) as desired.

  • If A=A=\bot, then 𝒯(A)={[]}𝒯(BT(M))\mathscr{T}^{\circ}(A)=\{{[}{]}\}\subseteq\mathscr{T}^{\circ}(\mathrm{BT}(M)) entails M𝗏VM\twoheadrightarrow_{\mathsf{v}}V for some value VV, therefore we get 𝒜(V)\bot\in\mathcal{A}(V) and we conclude by Lemma 8.

  • If A=xBA1AkA=xBA^{\prime}_{1}\cdots A^{\prime}_{k} then 𝒯(A)={[x]t0tnt0𝒯(B),1ik.ti𝒯(Ai)}\mathscr{T}^{\circ}(A)=\{[x]t_{0}\cdots t_{n}\mid t_{0}\in\mathscr{T}^{\circ}(B),\forall 1\leq i\leq k\ .\ t_{i}\in\mathscr{T}^{\circ}(A^{\prime}_{i})\}. In this case, we must have M𝗏xM0MkM\twoheadrightarrow_{\mathsf{v}}xM_{0}\cdots M_{k} with 𝒯(B)𝒯(BT(M0))\mathscr{T}^{\circ}(B)\subseteq\mathscr{T}^{\circ}(\mathrm{BT}(M_{0})) and 𝒯(Ai)𝒯(BT(Mi))\mathscr{T}^{\circ}(A^{\prime}_{i})\subseteq\mathscr{T}^{\circ}(\mathrm{BT}(M_{i})) for 1ik1\leq i\leq k. By induction hypothesis B𝒜(M0)B\in\mathcal{A}(M_{0}) and Ai𝒜(Mi)A^{\prime}_{i}\in\mathcal{A}(M_{i}) i{1,,k}\forall i\in\{1,\dots,k\}, thus xBA1Ak𝒜(xM0Mk)=𝒜(M)xBA^{\prime}_{1}\cdots A^{\prime}_{k}\in\mathcal{A}(xM_{0}\cdots M_{k})=\mathcal{A}(M) by Lemma 8.

  • If A=(λx.A)(yBA1Ak)A=(\lambda x.A^{\prime})(yBA^{\prime}_{1}\cdots A^{\prime}_{k}), then 𝒯(A)={[λx.s]ts𝒯(A),t𝒯(yBA1Ak)}\mathscr{T}^{\circ}(A)=\{{[}\lambda x.s{]}t\mid s\in\mathscr{T}^{\circ}(A^{\prime}),\ t\in\mathscr{T}^{\circ}(yBA^{\prime}_{1}\cdots A^{\prime}_{k})\}. In this case we get M𝗏(λx.M)(yM0Mk)M\twoheadrightarrow_{\mathsf{v}}(\lambda x.M^{\prime})(yM_{0}\cdots M_{k}) with 𝒯(A)𝒯(BT(M))\mathscr{T}^{\circ}(A^{\prime})\subseteq\mathscr{T}^{\circ}(\mathrm{BT}(M^{\prime})) and 𝒯(yBA1Ak)𝒯(BT(yM0Mk))\mathscr{T}^{\circ}(yBA^{\prime}_{1}\cdots A^{\prime}_{k})\subseteq\mathscr{T}^{\circ}(\mathrm{BT}(yM_{0}\cdots M_{k})). By applying the induction hypothesis, we obtain A𝒜((λx.M)(yM0Mk))A\in\mathcal{A}((\lambda x.M^{\prime})(yM_{0}\cdots M_{k})) and once again we conclude by Lemma 8.

The following constitutes the main result of the section, relating Böhm trees and Taylor expansion in the spirit of [ER06].

Theorem 26.

For all MΛM\in\Lambda, we have 𝒯(BT(M))=NF(𝒯(M))\mathscr{T}^{\circ}(\mathrm{BT}(M))=\mathrm{NF}(\mathscr{T}(M)).

Proof 4.7.

()(\subseteq) Take t𝒯(BT(M))t\in\mathscr{T}^{\circ}(\mathrm{BT}(M)), then there exists an approximant A𝒜(M)A^{\prime}\in\mathcal{A}(M) such that t𝒯(A)t\in\mathscr{T}^{\circ}(A^{\prime}). As A𝒜(M)A^{\prime}\in\mathcal{A}(M), there is MΛM^{\prime}\in\Lambda such that M𝗏MM\twoheadrightarrow_{\mathsf{v}}M^{\prime} and AMA^{\prime}\sqsubseteq M^{\prime}. We can therefore apply Lemma 25(1) to conclude that tNF(𝒯(M))t\in\mathrm{NF}(\mathscr{T}(M^{\prime})), which is equal to NF(𝒯(M))\mathrm{NF}(\mathscr{T}(M)) by Lemma 22.

()(\supseteq) Assume tNF(𝒯(M))t\in\mathrm{NF}(\mathscr{T}(M)). By Lemma 24(2) there exists MΛM^{\prime}\in\Lambda such that M𝗏MM\twoheadrightarrow_{\mathsf{v}}M^{\prime} and t𝒯(M)t\in\mathscr{T}(M^{\prime}). By Lemma 24(4), there is AMA\sqsubseteq M^{\prime} such that t𝒯(A)t\in\mathscr{T}^{\circ}(A). By the conditions above we have A𝒜(M)A\in\mathcal{A}(M), so we conclude that t𝒯(BT(M))t\in\mathscr{T}^{\circ}(\mathrm{BT}(M)).

4.2. Consequences of the main theorem

The rest of the section is devoted to present some interesting consequences of Theorem 26.

Corollary 27.

For M,NΛM,N\in\Lambda, the following are equivalent:

  1. (1)

    BT(M)=BT(N)\mathrm{BT}(M)=\mathrm{BT}(N),

  2. (2)

    NF(𝒯(M))=NF(𝒯(N))\mathrm{NF}(\mathscr{T}(M))=\mathrm{NF}(\mathscr{T}(N)).

Proof 4.8.

(12)(1\Rightarrow 2) If M,NM,N have the same Böhm tree, we can apply Theorem 26 to get

NF(𝒯(M))=𝒯(BT(M))=𝒯(BT(N))=NF(𝒯(N)).\mathrm{NF}(\mathscr{T}(M))=\mathscr{T}^{\circ}(\mathrm{BT}(M))=\mathscr{T}^{\circ}(\mathrm{BT}(N))=\mathrm{NF}(\mathscr{T}(N)).

(12)(1\Leftarrow 2) We assume NF(𝒯(M))=NF(𝒯(N))\mathrm{NF}(\mathscr{T}(M))=\mathrm{NF}(\mathscr{T}(N)) and start showing 𝒜(M)𝒜(N)\mathcal{A}(M)\subseteq\mathcal{A}(N). Take any A𝒜(M)A\in\mathcal{A}(M), by definition we have 𝒯(A)𝒯(BT(M))\mathscr{T}^{\circ}(A)\subseteq\mathscr{T}^{\circ}(\mathrm{BT}(M)), so Lemma 25(2) entails ABT(N)A\in\mathrm{BT}(N). The converse inclusion being symmetrical, we get 𝒜(M)=𝒜(N)\mathcal{A}(M)=\mathcal{A}(N) which in its turn entails BT(M)=BT(N)\mathrm{BT}(M)=\mathrm{BT}(N) by Remark 10.

Carraro and Guerrieri showed in [CG14] that the relational model 𝒰\mathscr{U} of CbV λ\lambda-calculus and resource calculus introduced by Ehrhard in [Ehr12] satisfies the σ\sigma-rules, so it is actually a model of both λvσ\lambda^{\sigma}_{v} and λrσ\lambda_{r}^{\sigma}. They also prove that 𝒰\mathscr{U} satisfies the Taylor expansion in the following technical sense (where \llbracket-\rrbracket represents the interpretation function in 𝒰\mathscr{U}):

M=t𝒯(M)t\llbracket M\rrbracket=\bigcup_{t\in\mathscr{T}(M)}\llbracket t\rrbracket (2)

As a consequence, we get that the theory of the model 𝒰\mathscr{U} is included in the theory equating all λ\lambda-terms having the same Böhm trees. We conjecture that the two theories coincide.

Theorem 28.

For M,NΛM,N\in\Lambda, we have:

BT(M)=BT(N)M=N.\mathrm{BT}(M)=\mathrm{BT}(N)\ \Rightarrow\ \llbracket M\rrbracket=\llbracket N\rrbracket.
Proof 4.9.

Indeed, we have the following chain of equalities:

M=t𝒯(M)t,by (2),=tNF(𝒯(M))t,as t=snf𝗋(t)s,=t𝒯(BT(M))t,by Theorem 26,=t𝒯(BT(N))t,as BT(M)=BT(N),=tNF(𝒯(N))t,by Theorem 26,=t𝒯(N)t,as t=snf𝗋(t)s,=N,by (2).\begin{array}[]{rll}\llbracket M\rrbracket=&\bigcup_{t\in\mathscr{T}(M)}\llbracket t\rrbracket,&\textrm{by \eqref{eq:CarGue},}\\ =&\bigcup_{t\in\mathrm{NF}(\mathscr{T}(M))}\llbracket t\rrbracket,&\textrm{as }\llbracket t\rrbracket=\bigcup_{s\in\mathrm{nf}_{\mathsf{r}}(t)}\llbracket s\rrbracket,\\ =&\bigcup_{t\in\mathscr{T}^{\circ}(\mathrm{BT}(M))}\llbracket t\rrbracket,&\textrm{by Theorem~\ref{thm:T_commutes_with_BT}},\\ =&\bigcup_{t\in\mathscr{T}^{\circ}(\mathrm{BT}(N))}\llbracket t\rrbracket,&\textrm{as }\mathrm{BT}(M)=\mathrm{BT}(N),\\ =&\bigcup_{t\in\mathrm{NF}(\mathscr{T}(N))}\llbracket t\rrbracket,&\textrm{by Theorem~\ref{thm:T_commutes_with_BT}},\\ =&\bigcup_{t\in{\mathscr{T}(N)}}\llbracket t\rrbracket,&\textrm{as }\llbracket t\rrbracket=\bigcup_{s\in\mathrm{nf}_{\mathsf{r}}(t)}\llbracket s\rrbracket,\\ =&\llbracket N\rrbracket,&\textrm{by \eqref{eq:CarGue}.}\\ \end{array}

This concludes the proof.

In the paper [CG14], the authors also prove that M\llbracket M\rrbracket\neq\emptyset exactly when MM is potentially valuable (Definition 1.1). From this result, we obtain easily the lemma below.

Theorem 29.

For MΛM\in\Lambda, the following are equivalent:

  1. (1)

    MM is potentially valuable,

  2. (2)

    BT(M)\mathrm{BT}(M)\neq\bot.

Proof 4.10.

It is easy to check that all resource approximants tt have non-empty interpretation in 𝒰\mathscr{U}, i.e. tNF(Λs)t\in\mathrm{NF}(\Lambda^{s}) entails t\llbracket t\rrbracket\neq\emptyset. Therefore we have the following chain of equivalences:

M potentially valuableM,by [CG14, Thm. 24],tNF(𝒯(M)),tby (2),s𝒯(BT(M)),sby Theorem 26,A𝒜(M),A\begin{array}[]{rll}M\textrm{ potentially valuable}\iff&\llbracket M\rrbracket\neq\emptyset,&\textrm{by \cite[cite]{[\@@bibref{}{CarraroG14}{}{}, Thm.~24]},}\\ \iff&\exists t\in\mathrm{NF}(\mathscr{T}(M)),\llbracket t\rrbracket\neq\emptyset&\textrm{by \eqref{eq:CarGue},}\\ \iff&\exists s\in\mathscr{T}^{\circ}(\mathrm{BT}(M)),\llbracket s\rrbracket\neq\emptyset&\textrm{by Theorem~\ref{thm:T_commutes_with_BT}},\\ \iff&\exists A\in\mathcal{A}(M),A\neq\bot\\ \end{array}

This is equivalent to say that BT(M)\mathrm{BT}(M)\neq\bot.

After this short, but fruitful, semantical digression we conclude proving that all λ\lambda-terms having the same Böhm tree are indistinguishable from an observational point of view. As in the CbN setting, also in CbV this result follows from the Context Lemma for Böhm trees. The classical proof of this lemma in CbN is obtained by developing an interesting, but complicated, theory of syntactic continuity (see [Bar84, §14.3] and [AC98, §2.4]). Here we bypass this problem completely, and obtain such a result as a corollary of the Context Lemma for Taylor expansions by applying Theorem 26.

Lemma 30 (Context Lemma for Böhm trees).

Let M,NΛM,N\in\Lambda. If BT(M)=BT(N)\mathrm{BT}(M)=\mathrm{BT}(N) then, for all head contexts CC\llparenthesis-\rrparenthesis, we have BT(CM)=BT(CN)\mathrm{BT}(C\llparenthesis M\rrparenthesis)=\mathrm{BT}(C\llparenthesis N\rrparenthesis).

Proof 4.11.

It follows from the Context Lemma for Taylor expansions (Lemma 23) by applying Theorem 26 and Corollary 27.

As mentioned in the discussion before Lemma 23, both the statement and the proof generalize to arbitrary contexts. Thanks to Remark 4, we only need head contexts in order to prove the following theorem stating that the Böhm tree model defined in this paper is adequate for Plotkin’s CbV λ\lambda-calculus.

Theorem 31.

Let M,NΛM,N\in\Lambda. If BT(M)=BT(N)\mathrm{BT}(M)=\mathrm{BT}(N) then MNM\equiv N.

Proof 4.12.

Assume, by the way of contradiction, that BT(M)=BT(N)\mathrm{BT}(M)=\mathrm{BT}(N) but MNM\not\equiv N. Then, there exists a head context CC\llparenthesis-\rrparenthesis such that CM,CNΛoC\llparenthesis M\rrparenthesis,C\llparenthesis N\rrparenthesis\in\Lambda^{o} and, say, CMC\llparenthesis M\rrparenthesis is valuable while CNC\llparenthesis N\rrparenthesis is not. Since they are closed λ\lambda-terms, this is equivalent to say that CMC\llparenthesis M\rrparenthesis is potentially valuable while CNC\llparenthesis N\rrparenthesis is not. By Theorem 29, BT(CM)\mathrm{BT}(C\llparenthesis M\rrparenthesis)\neq\bot and BT(CN)=\mathrm{BT}(C\llparenthesis N\rrparenthesis)=\bot. As a consequence, we obtain BT(CM)BT(CN)\mathrm{BT}(C\llparenthesis M\rrparenthesis)\neq\mathrm{BT}(C\llparenthesis N\rrparenthesis) thus contradicting the Context Lemma for Böhm trees (Lemma 30).

Notice that the converse implication does not hold — for instance it is easy to check that Δ(yy)yy(yy)\Delta(yy)\equiv yy(yy) holds, but the two λ\lambda-terms have different Böhm trees.

5. Conclusions

Inspired by the work of Ehrhard [Ehr12], Carraro and Guerrieri [CG14], we proposed a notion of Böhm tree for Plotkin’s call-by-value λ\lambda-calculus λv\lambda_{v}, having a strong mathematical background rooted in Linear Logic. We proved that CbV Böhm trees provide a syntactic model of λv\lambda_{v} which is adequate (in the sense expressed by Theorem 31) but not fully abstract — there are operationally indistinguishable λ\lambda-terms having different Böhm trees. The situation looks similar in call-by-name where one needs to consider Böhm trees up to possibly infinite η\eta-expansions to capture the λ\lambda-theory \mathcal{H}^{*} and obtain a fully abstract model [Bar84, Cor. 19.2.10]. Developing a notion of extensionality for CbV Böhm trees is certainly interesting, as it might help to describe the equational theory of some extensional denotational model, and a necessary step towards full abstraction. Contrary to what happens in call-by-name, this will not be enough to achieve full abstraction as shown by the counterexample Δ(yy)yy(yy)\Delta(yy)\equiv yy(yy) but BT(Δ(yy))BT(yy(yy))\mathrm{BT}(\Delta(yy))\neq\mathrm{BT}(yy(yy)), where extensionality plays no role. The second and third authors, together with Ronchi Della Rocca, recently introduced in [MRP19] a new class of adequate models of λvσ\lambda^{\sigma}_{v} and showed that they validate not only =𝗏=_{\mathsf{v}} but also some II-reductions (in the sense of λI\lambda I-calculus [Bar84, Ch. 9]) preserving the operational semantics of λ\lambda-terms. Finding a precise characterization of those II-redexes that can be safely contracted in the construction of a CbV Böhm tree is a crucial open problem that can lead to full abstraction.

Acknowledgment

The authors wish to acknowledge fruitful discussions with Giulio Guerrieri, Luca Paolini and Simona Ronchi della Rocca.

References

  • [AC98] Roberto Amadio and Pierre-Louis Curien. Domains and Lambda Calculi. Cambridge tracts in theoretical computer science. Cambridge University Press, 1998.
  • [AG17] Beniamino Accattoli and Giulio Guerrieri. Implementing open call-by-value (extended version). CoRR, abs/1701.08186, 2017.
  • [Bar77] Henk P. Barendregt. The type free lambda calculus. In Jon Barwise, editor, Handbook of Mathematical Logic, volume 90 of Studies in Logic and the Foundations of Mathematics, pages 1091 – 1132. Elsevier, 1977.
  • [Bar84] Henk P. Barendregt. The lambda-calculus, its syntax and semantics. Number 103 in Studies in Logic and the Foundations of Mathematics. North-Holland, second edition, 1984.
  • [BDS13] Henk P. Barendregt, Wil Dekkers, and Richard Statman. Lambda Calculus with Types. Perspectives in logic. Cambridge University Press, 2013.
  • [BHP13] Pierre Boudes, Fanny He, and Michele Pagani. A characterization of the Taylor expansion of lambda-terms. In Simona Ronchi Della Rocca, editor, Computer Science Logic 2013 (CSL 2013), CSL 2013, September 2-5, 2013, Torino, Italy, volume 23 of LIPIcs, pages 101–115. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2013.
  • [Bö68] Corrado Böhm. Alcune proprietà delle forme β\beta-η\eta-normali nel λ\lambda-KK-calcolo. INAC, 696:1–19, 1968.
  • [CG14] Alberto Carraro and Giulio Guerrieri. A Semantical and Operational Account of Call-by-Value Solvability. In Anca Muscholl, editor, Foundations of Software Science and Computation Structures, volume 8412 of Lecture Notes in Computer Science, pages 103–118. Springer-Verlag, 2014.
  • [Ehr12] Thomas Ehrhard. Collapsing non-idempotent intersection types. In P. Cégielski and A. Durand, editors, Computer Science Logic (CSL’12), 21st Annual Conference of the EACSL, CSL 2012, volume 16 of LIPIcs, pages 259–273. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2012.
  • [ER03] Thomas Ehrhard and Laurent Regnier. The differential lambda-calculus. Theor. Comput. Sci., 309(1-3):1–41, 2003.
  • [ER06] Thomas Ehrhard and Laurent Regnier. Böhm trees, Krivine’s machine and the Taylor expansion of lambda-terms. In Arnold Beckmann, Ulrich Berger, Benedikt Löwe, and John V. Tucker, editors, Logical Approaches to Computational Barriers, Second Conference on Computability in Europe, CiE 2006, Swansea, UK, June 30-July 5, 2006, Proceedings, volume 3988 of Lecture Notes in Computer Science, pages 186–197. Springer, 2006.
  • [ER08] Thomas Ehrhard and Laurent Regnier. Uniformity and the Taylor expansion of ordinary lambda-terms. Theor. Comput. Sci., 403(2-3):347–372, 2008.
  • [GPR17] Giulio Guerrieri, Luca Paolini, and Simona Ronchi Della Rocca. Standardization and conservativity of a refined call-by-value lambda-calculus. Logical Methods in Computer Science, 13(4), 2017.
  • [Las99] Søren B. Lassen. Bisimulation in untyped lambda calculus: Böhm trees and bisimulation up to context. Electr. Notes Theor. Comput. Sci., 20:346–374, 1999.
  • [Las05] Søren B. Lassen. Eager normal form bisimulation. In 20th IEEE Symposium on Logic in Computer Science (LICS 2005), 26-29 June 2005, Chicago, IL, USA, Proceedings, pages 345–354. IEEE Computer Society, 2005.
  • [Mog92] Torben Æ. Mogensen. Efficient self-interpretations in lambda calculus. J. Funct. Program., 2(3):345–363, 1992.
  • [MP11] Giulio Manzonetto and Michele Pagani. Böhm’s theorem for resource lambda calculus through Taylor expansion. In C.-H. Luke Ong, editor, Typed Lambda Calculi and Applications - 10th International Conference, TLCA 2011, Novi Sad, Serbia, June 1-3, 2011. Proceedings, volume 6690 of Lecture Notes in Computer Science, pages 153–168. Springer, 2011.
  • [MRP19] Giulio Manzonetto, Simona Ronchi Della Rocca, and Michele Pagani. New semantical insights into call-by-value λ\lambda-calculus. Fundam. Inform., 170(1-3):241–265, 2019.
  • [Ong97] Luke Ong. Lambda calculus, 1997. Lecture Notes.
  • [Pao01] Luca Paolini. Call-by-value separability and computability. In Antonio Restivo, Simona Ronchi Della Rocca, and Luca Roversi, editors, Theoretical Computer Science, 7th Italian Conference, ICTCS 2001, volume 2202 of Lecture Notes in Computer Science, pages 74–89. Springer, 2001.
  • [Pao08] Luca Paolini. Parametric λ\lambda-theories. Theoretical Computer Science, 398(1):51 – 62, 2008.
  • [Plo75] Gordon D. Plotkin. Call-by-name, call-by-value and the lambda-calculus. Theor. Comput. Sci., 1(2):125–159, 1975.
  • [PRDR99] Luca Paolini and Simona Ronchi Della Rocca. Call-by-value solvability. ITA, 33(6):507–534, 1999.
  • [RDRP04] Simona Ronchi Della Rocca and Luca Paolini. The Parametric λ\lambda-Calculus: a Metamodel for Computation. EATCS Series. Springer, Berlin, 2004.
  • [Reg94] Laurent Regnier. Une équivalence sur les lambda-termes. Theoretical Computer Science, 126:281–292, 1994.
  • [Roc18] Simona Ronchi Della Rocca. Personal communication, 2018.
  • [Tra09] P. Tranquilli. Nets Between Determinism and Nondeterminism. PhD thesis, Univ. Paris 7 and Univ. Roma 3, 2009.