Abstract 1 Introduction 2 Preliminaries 3 Ohana trees 4 A resource calculus with memory 5 Taylor approximation for Ohana trees 6 Conclusions and future work References

Ohana Trees and Taylor Expansion
for the λI-Calculus

Rémy Cerda ORCID Université Paris Cité, CNRS, IRIF, F-75013, Paris, France Giulio Manzonetto ORCID Université Paris Cité, CNRS, IRIF, F-75013, Paris, France Alexis Saurin Université Paris Cité, CNRS, IRIF, F-75013, Paris, France
INRIA π3, Paris, France
Abstract

Although the λ𝖨-calculus is a natural fragment of the λ-calculus, obtained by forbidding the erasure, its equational theories did not receive much attention. The reason is that all proper denotational models studied in the literature equate all non-normalizable λ𝖨-terms, whence the associated theory is not very informative. The goal of this paper is to introduce a previously unknown theory of the λ𝖨-calculus, induced by a notion of evaluation trees that we call “Ohana trees”. The Ohana tree of a λ𝖨-term is an annotated version of its Böhm tree, remembering all free variables that are hidden within its meaningless subtrees, or pushed into infinity along its infinite branches.

We develop the associated theories of program approximation: the first approach – more classic – is based on finite trees and continuity, the second adapts Ehrhard and Regnier’s Taylor expansion. We then prove a Commutation Theorem stating that the normal form of the Taylor expansion of a λ𝖨-term coincides with the Taylor expansion of its Ohana tree. As a corollary, we obtain that the equality induced by Ohana trees is compatible with abstraction and application. We conclude by discussing the cases of Lévy-Longo and Berarducci trees, and generalizations to the full λ-calculus.

Keywords and phrases:
λ-calculus, program approximation, Taylor expansion, λI-calculus, persistent free variables, Böhm trees, Ohana trees
Funding:
Rémy Cerda: Partially funded by the ANR project RECIPROG ANR-21-CE48-019.
Alexis Saurin: Partially funded by the ANR project RECIPROG ANR-21-CE48-019.
Copyright and License:
[Uncaptioned image] © Rémy Cerda, Giulio Manzonetto, and Alexis Saurin; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Rewrite systems
; Theory of computation Lambda calculus ; Theory of computation Denotational semantics
Related Version:
Version hosted on arXiv, with additional proofs in an appendix: https://arxiv.org/abs/2505.06193 [11]
Acknowledgements:
We wish to thank Thomas Ehrhard, Paul-André Melliès, Lorenzo Tortora de Falco and Lionel Vaux Auclair for interesting discussions. We also thank the anonymous reviewers for the many valuable corrections they suggested.
Editors:
Maribel Fernández

1 Introduction

In the pioneering article “The calculi of lambda-conversion” [13] Alonzo Church introduced the λ-calculus together with its fragment without weakening, called the λ𝖨-calculus, where each abstraction must bind at least one occurrence of a variable. Historically, the λ𝖨-calculus has proven to be a useful framework for establishing results such as the finiteness of developments and standardization, which were successfully proven for the full λ-calculus only decades later. Despite that, in the last forty years there are no groundbreaking advances in its study.

The study of models and theories of λ-calculus flourished in the 1970s [4] and remained central in theoretical computer science for decades [5]. Although the equational theories of λ-calculus, called λ-theories, form a complete lattice of cardinality 20 [33], only a handful are of interest to computer scientists. Most articles focus on λ-theories generated through some notion of “evaluation tree” of a λ-term, which means that two λ-terms are equated in the theory exactly when their evaluation trees coincide. The definitions of evaluation trees present in the literature follow the same pattern: they collect in a possibly infinite tree all stable portions of the output coming out from the computation, and replace the subterms that are considered meaningless by a constant , representing the lack of information. By modifying the notions of “stable” and “meaningless”, one obtains Böhm trees [3], possibly endowed with some form of extensionality [42, 27], Lévy-Longo trees [31, 32] and Berarducci trees [7]. In the modern language of infinitary term rewriting systems, these trees can be seen as the transfinite normal forms of infinitary λ-calculi [22, 14]. Another popular method for defining λ-theories is via observational equivalences [37]: two λ-terms are equivalent if they display the same behaviour whenever plugged in any context. For instance, the theory of Scott’s 𝒟 model [41] captures the maximal consistent observational equivalence [26, 47].

Since the λ-calculus is a conservative extension of the λ𝖨-calculus, every theory of the former is also a theory of the latter, namely a λ𝖨-theory, while the converse does not hold. A typical example is the λ𝖨-theory 𝖨 generated by equating all λ𝖨-terms that are not β-normalizing. The maximal consistent observational equivalence 𝖨η is similar, except for the fact that it is extensional. Note that equating all λ-terms without a β-normal form gives rise to an inconsistent λ-theory, but in the context of λ𝖨-calculus it is consistent and arises naturally: all “proper” denotational models of the λ𝖨-calculus induce either 𝖨 or 𝖨η [25]. This is somewhat disappointing, since models and theories are most valuable when they capture non-trivial operational properties of programs, and normalization is relatively elementary in this setting. In this paper we are going to introduce a new (proper) λ𝖨-theory, induced by a notion of evaluation trees inspired by Böhm trees, but explicitly designed for λ𝖨-terms.

Böhm trees and Taylor expansion for the λ𝖨-calculus

An important feature of Böhm trees is that, because of their coinductive nature, they are capable of pushing some subterms into infinity. Consider for instance a λ𝖨-term M satisfying

Mxfβf(Mxf)βf(f(Mxf))βf(f(f(Mxf)))βfn(Mxf)β

then the Böhm tree of Mxf is the “limit” of this infinite reduction: fω=f(f(f())). Observe that x is “persistent” in the sense that it is never erased along any finite reduction, but is forgotten at the limit. We say that x is pushed into infinity in the Böhm tree of Mxf. To some extent, also the variable f is pushed into infinity, but it occurs infinitely often in fω. The variable x can also disappear because it is hidden behind a meaningless term like Ω. For instance, the Böhm tree of the λ𝖨-term N=Ωx is just and we say that x is left behind.

As a consequence there are λ𝖨-terms, like λxf.M and λxy.y(Ωx), whose Böhm tree is not a λ𝖨-tree [4, Def. 10.1.26] since the variable x is abstracted, but does not appear in the tree. This shows that Böhm trees are not well-suited for the λ𝖨-calculus, and the question of whether other notions of trees can model λ𝖨-terms in a more faithful way naturally arises.

In this paper we introduce a notion of Böhm trees keeping tracks of the variables persistently occurring along each possibly infinite path, or left behind a meaningless subterm. We call them Ohana trees as they remember all the variables present in the terms generating them, even if these variables are never actually used in their evaluations. This is obtained by simply annotating such variables on the branches of the Böhm tree, and on its -nodes, but bares interesting consequences: since Ohana trees are invariant under β-conversion, showing that two terms have distinct Ohana trees becomes a way of separating them modulo =β.

Once the coinductive definition of Ohana trees is given (Definition 10), we develop the corresponding theory of program approximation based on finite trees. Perhaps surprisingly, in the finite approximants, the only variable annotations that are actually required are those on the constant , as all other labels can be reconstructed when taking their supremum. Our main result in this setting is the Approximation Theorem 20 stating that the Ohana tree of a λ𝖨-term is uniquely determined by the (directed) set of all its finite approximants.

Inspired by quantitative semantics of linear logics, Ehrhard and Regnier proposed a theory of program approximation for regular λ-terms based on Taylor expansion  [19, 21]. A λ-term is approximated by a possibly infinite power-series of programs living in a completely linear resource calculus, where no resource can be duplicated or erased along the computation. This theory is linked to Böhm trees by a Commutation Theorem [20] stating that the normal form of the Taylor expansion of a λ-term is equal to the Taylor expansion of its Böhm tree.

The second part of our paper is devoted to explore the question of whether it is possible to define a Taylor expansion for the λ𝖨-calculus capturing the Ohana tree equality. In Section 4 we design a λ𝖨-resource calculus with memory, mixing linear and non-linear features. Our terms are either applied to non-empty bags (finite multiset) of non-duplicable resources, or to an empty bag 1X annotated with a set X of variables (the non-linear parts of the terms). The reduction of a resource term t preserves its free variables fv(t): if the reduction is valid then t consumes all its linear resources and each variable is recorded in some labels, otherwise an exception is thrown and t reduces to an empty program 𝟎X, where X=fv(t).

First we prove that the resource calculus so-obtained is confluent and strongly normalizing, then we use it as the target language of a Taylor expansion with memory, capable of approximating both λ𝖨-terms and Ohana trees. Our main result is that the Commutation Theorem from [20] extends to this setting: the normal form of the Taylor expansion with memory of a λ𝖨-term always exists and is equal to the Taylor expansion with memory of its Ohana tree (Theorem 38). As consequences (Corollaries 44 and 45), we obtain that: 1) The equality induced on λ𝖨-terms by Ohana trees coincides with the equality induced by the normalized Taylor expansion with memory; 2) The equality induced by Ohana trees is compatible with application and abstraction, in the sense of the λ𝖨-calculus, and it is therefore a λ𝖨-theory. We consider this work a first step in a broader line of research, which we discuss further in the conclusion of the paper. In particular, we aim to extend our formalism to the full λ-calculus and explore its applicability to other kinds of trees.

Related works

On the syntactic side, the λ𝖨-calculus can be translated into MELL proofnets without weakening studied in [15, 16]. Our Ohana trees can be presented as labelled Böhm trees, and therefore share similarities with Melliès”s (infinitary) λ-terms “with boundaries”, whose branches are annotated by booleans [36]. However, our labels are describing additional points occurring at transfinite positions, a phenomenon reminiscent of the non-monotonic pre-fixed point construction defined in [6]. They can also be seen as an instances of the transfinite terms considered in [30], but simpler, because no reduction is performed at transfinite positions. Thus, Ohana trees should correspond to normal forms of an infinitary labelled λ𝖨-calculus, just like Böhm trees are the normal forms of the infinitary λ-calculus [29]. We wonder whether a clever translation of the λ𝖨-calculus into the process calculus in [17] would allow us to retrieve the Ohana trees and the associated Taylor expansion, in which case our Commutation Theorem might become an instance of their general construction.

Concerning denotational semantics, certain relevant intersection type systems [44, 24, 1] can be used to represent models of the λ𝖨-calculus, as they describe reflexive objects in the smcc of cpos and strict functions [28]. In [25], the authors show that the model introduced in [18] is fully abstract for the λ𝖨-theory 𝖨η. The results in [16] suggest that the relational semantics, endowed with the comonad of finite non-empty multisets, contains models whose theory is either 𝖨 or 𝖨η. No filter model or relational graph model can induce the Ohana tree equality, since they equate all λ-terms having the same Böhm tree [40, 8]. However, the relational model defined in [9] using the comonad of finite multisets with possibly infinite coefficients, gives hope since it separates Mxf from Myf, and Ωx from Ωy, when xy. This category appears to be the most promising for finding models capturing Ohana trees.

2 Preliminaries

We recall some basic notions and results concerning the λ-calculus, and its fragment without weakening known as the λ𝖨-calculus. For more information, we refer to Barendregt’s book [4].

2.1 The λ-calculus, in a nutshell

Let us fix an infinite set 𝒱 of variables. The set Λ of λ-terms is defined by induction

ΛM,Nxλx.MMN(for x𝒱)

We use parentheses when needed. We assume that application associates on the left, and has higher precedence than abstraction. E.g., λx.λy.λz.xyz stands for λx.(λy.(λz.(xy)z)). We write λx1xn.M or even λx.M for λx1.λxn.M, and Nn(M) for N(N(N(M))), where N occurs n times. In particular, when n=0, we get λx.M=Nn(M)=M.

The set fv(M) of free variables of M is defined as usual, and we say that M is closed whenever fv(M)=. Hereafter, λ-terms are considered modulo α-conversion (see [4, §2.1]).

Example 1.

The λ-terms below are used throughout the paper to construct examples:

𝖨λx.x,𝖪λxy.x,𝖥λxy.y,𝖡λfgx.f(g(x)),𝖣λx.xx,Ω𝖣𝖣.

The λ-term 𝖨 is the identity, 𝖪,𝖥 are the projections, 𝖡 is the composition, 𝖣 is the diagonal and Ω a looping term. The pairing of M,N is encoded as [M,N]λx.xMN, for x fresh.

The β-reduction β is generated by the rule (λx.M)NM[N/x], where (λx.M)N is called a β-redex and M[N/x] stands for the capture-free substitution of N for all free occurrences of x in M. We let β (resp. =β) be the reflexive-transitive (and symmetric) closure of β. We say that M is in β-normal form (β-nf) if M does not contain any β-redex, and that M has a β-nf if MβN, for some N in β-nf. Since β is confluent, such N must be unique.

 Remark 2.

Any λ-term M can be written in one of the following forms: either M=λx.yM1Mk, in which case M is called a head normal form (hnf) and y its head variable; or M=λx.(λy.P)QM1Mk, where (λy.P)Q is referred to as its head redex.

The head reduction h is the restriction of β obtained by contracting the head redex.

Definition 3.

A λ-term Y is a fixed-point combinator (fpc) if it satisfies Yx=βx(Yx).

Notice that we do not require that fixed-point combinators are closed λ-terms. We recall Curry’s combinator 𝖸 and define, for all l𝒱, Polonsky’s Θl and Klop’s l [35]:

𝖣fλx.f(xx),𝖸λf.𝖣f𝖣f,𝖵λvlf.f(vvlf),Θl𝖵𝖵l,lλe.𝖡𝖸𝖡el. (1)

It is easy to check that 𝖸 and Θl are fpcs. Regarding the Bible l, which owes its name to its distinctive spelling, we get lx=β𝖡𝖸𝖡xl=β𝖸(𝖡x)l=β𝖡x(𝖸(𝖡x))l=βx(𝖸(𝖡x)l)=βx(lx). Note that the variable l remains in a passive position along the reduction of l (and of Θl), therefore N:=l[N/l] (resp. ΘN:=Θl[N/l]) remains a fpc, for all NΛ.

Although fpcs Y are not β-normalizable, they differ from Ω since they produce increasing stable amounts of information along reduction: Yβλf.fY1βλf.fn(Yn)β. Barendregt introduced a notion of “evaluation tree” to capture this infinitary behaviour [3].

Definition 4.

The Böhm tree BT(M) of a λ-term M is coinductively defined as follows.

  1. 1.

    If M has a hnf, that is Mhλx1xn.yM1Mk, then

  2. 2.

    BT(M), otherwise. The constant represents the absolute lack of information.

Example 5.

Using the terms from Example 1 and (1), let us construct some Böhm trees.

  1. (i)

    If M has a β-normal form N then, up to isomorphism, BT(M)=N. E.g., BT(𝖣𝖨)=𝖨.

  2. (ii)

    Since Ω and 𝖸𝖪 have no hnf, we get BT(Ω)=BT(𝖸𝖪)=.

  3. (iii)

    If Y is an fpc, then BT(Y)=λf.f(f(f())). Thus, BT(𝖸)=BT(l)=BT(Θl).

  4. (iv)

    Using the fpc 𝖸, one can define λ-terms 𝖤x,𝖮x satisfying 𝖤x=β[Ω,[Ωx,𝖤x]] and 𝖮x=β[Ωx,[Ω,𝖮x]]. These two λ-terms both construct a “stream” [M1,[M2,[M3,[]]]], but the former places Ωx at even positions and Ω at odd ones, while the latter does the converse. This difference is however forgotten in their Böhm trees:

    BT(𝖤x)=BT(𝖮x)=[,[,[,[,[]]]]] (inline depiction of a tree)
  5. (v)

    Check that, given 𝖱=λylx.x(y(xl)), we have BT(𝖸𝖱l)=λx0.x0(λx1.x1(λx2.x2())).

The Böhm tree equality induces an equivalence on λ-terms: M=N iff BT(M)=BT(N). As shown in [31, 48], is a λ-theory because it contains =β and is compatible with abstraction and application: M=M entails λx.M=λx.M, MN=MN and NM=NM.

2.2 The λ𝖨-calculus

The set Λ𝖨 of λ𝖨-terms is the subset of Λ consisting of those λ-terms in which every abstraction binds at least one occurrence of the abstracted variable. Note that β induces a reduction on Λ𝖨 since MΛ𝖨 and MβN entail NΛ𝖨. In other words, the property of being a λ𝖨-term is preserved by β. Similarly, the λ𝖨-calculus inherits from λ-calculus all the notions previously defined like head reduction, Böhm trees, etc. For convenience, we consider an alternative definition of Λ𝖨 simultaneously defining λ𝖨-terms and their sets of free variables.

Definition 6.
  1. (i)

    For all X𝒱, Λ𝖨(X) is defined as the smallest subset of Λ such that:

    xΛ𝖨({x})MΛ𝖨(X)xXλx.MΛ𝖨(X{x})MΛ𝖨(X)NΛ𝖨(Y)MNΛ𝖨(XY)
  2. (ii)

    Finally, the set of all λ𝖨-terms is given by the disjoint union Λ𝖨=X𝒱Λ𝖨(X).

 Remark 7.
  1. (i)

    Note that MΛ𝖨(X) means that M is a λ𝖨-term such that fv(M)=X. As a consequence, if MΛ𝖨(X) then the set X must be finite.

  2. (ii)

    Each set Λ𝖨(X) is closed under β-conversion.

  3. (iii)

    Our examples 𝖨,𝖡,𝖣,Ω,𝖸,l,Θl,𝖤x,𝖮x,𝖸𝖱l are λ𝖨-terms, while 𝖪,𝖥,𝖸𝖪Λ𝖨.

Definition 8.

A λ𝖨-theory 𝒯 is given by an equivalence =𝒯Λ𝖨2 containing β-conversion and compatible with application and abstraction. In the context of λ𝖨-calculus, the compatibility with abstraction becomes: M=𝒯M and xfv(M)fv(M) imply λx.M=𝒯λx.M.

The only subtlety in the definition above stands in the side condition on the compatibility with abstraction. However, this small difference has significant consequences: e.g., the theory axiomatized by equating all terms without a β-nf is consistent as a λ𝖨-theory, but inconsistent as a λ-theory. The following theorem collects the main properties of the λ𝖨-calculus.

Theorem 9.
  1. (i)

    Every computable numerical function is λ𝖨-definable [4, Thm. 9.2.16].

  2. (ii)

    Strong and weak β-normalization coincide for the λ𝖨-calculus [4, Thm. 11.3.4].

  3. (iii)

    Every λ-theory is also a λ𝖨-theory, while the converse does not hold.

By (iii), Böhm trees induce a λ𝖨-theory, but we argue that this theory does not respect the spirit of Λ𝖨. E.g., the variable l is never erased along the reduction of, say, l, but it disappears in its Böhm tree. Using the terminology of [4], one says that l is pushed to infinity in BT(l). This shows that the Böhm tree of the λ𝖨-term λl.lΛ𝖨 is not a λ𝖨-tree: the outer λ-abstraction “λl” does not bind any free occurrence of l in BT(l)=λf.f(f(f())).

3 Ohana trees

Figure 1: Examples of Ohana trees of λ𝖨-terms.

We have seen that Böhm trees are not well-suited for representing λ𝖨-terms faithfully, because variables that are never erased along the reduction are forgotten (i.e., pushed into infinity). We now introduce a notion of evaluation tree that records all variables that are pushed along each path, ensuring that none are forgotten, whether they remain in passive position or not.

3.1 The coinductive definition

For every finite set X𝒱, written Xf𝒱, we introduce a constant X representing any looping MΛ𝖨(X). Intuitively, the Ohana tree of a λ𝖨-term M is obtained from BT(M) by annotating each subtree (also ) with the free variables of the λ-term that generated it.

Definition 10.

The Ohana tree of a term MΛ𝖨(X) is coinductively defined as follows:

  1. (i)

    If Mhλx1xn.yM1Mk with yX{x}, MiΛ𝖨(Xi) (for 1ik), then

  2. (ii)

    OT(M)X, otherwise. Recall that X=fv(M), since MΛ𝖨(X).

We sometimes use an inline presentation of Ohana trees, by introducing application symbols annotated with the sets Xi, as in λx1xn.yX1T1XkTk.

Example 11.
  1. (i)

    OT(𝖨)=λx.x, OT(𝖣)=λx.x{x}x, OT(𝖡)=λfgx.f{g,x}(g{x}x).

  2. (ii)

    OT(Ω)=OT(λy.Ωy)=, OT(Ωx)={x}. More generally: OT(Ωx)={x1,,xn}.

  3. (iii)

    OT(𝖸)=λf.f{f}(f{f}(f{f}())). In fact, it is easy to check that for all closed fpcs YΛ𝖨, we have OT(Y)=OT(𝖸)BT(𝖸).

  4. (iv)

    In OT(l) the variable l which is pushed into infinity becomes visible: OT(l)=OT(Θl)=λf.f{f,l}(f{f,l}(f{f,l}())). Thus OT(l)OT(Θx) when xl.

Other examples of Ohana trees are depicted in Figure 1. Note that the Ohana trees of 𝖤x and 𝖮x are now distinguished. The interest of 𝖸𝖱l is that it pushes into infinity an increasing amount of variables:

𝖸𝖱l=βλx0.x0((𝖸𝖱)(x0l))=βλx0.x0(λx1.x1((𝖸𝖱)(x1(x0l))))=β

So – at the limit – infinitely many variables are pushed into infinity (but only l is free).

 Remark 12.

If MΛ𝖨 has a β-nf N, then there is an isomorphism OT(M)N. In fact, since N is finite, it is possible to reconstruct all the labels in OT(M).

We are going to show that Ohana trees are invariant under β-reduction (Prop. 19 plus Thm. 20), and that the equality induced on λ𝖨-terms is a λ𝖨-theory (Corollary 45).

3.2 The associated approximation theory

We introduce a theory of program approximation that captures Ohana trees, by adapting the well-established approach originally developed for Böhm trees [31, 48] (see also [4, Ch. 14]). We start by defining the approximants with memory, corresponding to finite Ohana trees.

Definition 13.
  1. (i)

    The set of approximants with memory is 𝒜𝗆Xf𝒱𝒜𝗆(X), where 𝒜𝗆(X) is defined by (for Ai𝒜𝗆(Xi), XiX, yX{x} and xi=1kXi):

    𝒜𝗆(X)AXλx1xn.yA1Ak
  2. (ii)

    We define 𝒜𝗆2 as the least partial order closed under the following rules:

    A𝒜𝗆(X)XAAiAiAi,Ai𝒜𝗆(Xi)for all 1ikx{y}(i=1kXi)λx1xn.yA1Akλx1xn.yA1Ak

Each (𝒜𝗆(X),) is a pointed poset (partially ordered set) with bottom element X, while the poset (𝒜𝗆,) is not pointed because it has countably many minimal elements. Note that we do not annotate the application symbols in A𝒜𝗆 with the sets of variables Xi, since the labels in its -nodes carry enough information to reconstruct the finite Ohana tree associated with A.

Lemma 14.

There is a bijection between 𝒜𝗆 and the set of finite Ohana trees of λ𝖨-terms.

We now give the recipe to compute the set of approximants with memory of a λ𝖨-term.

Definition 15.
  1. (i)

    The direct approximant of MΛ𝖨(X) is given by:

    ω𝗆(M){λx1xn.yω𝗆(M1)ω𝗆(Mk),if M=λx1xn.yM1Mk,X,otherwise.
  2. (ii)

    The set App𝗆(M) of approximants with memory of MΛ𝖨 is defined by:

    App𝗆(M){A𝒜𝗆NΛ𝖨.MβN and Aω𝗆(N)}
 Remark 16.

For all MΛ𝖨(X), we have ω𝗆(M)𝒜𝗆(X) and App𝗆(M)𝒜𝗆(X).

Example 17.
  1. (i)

    App𝗆(𝖣)={,λx.x{x},𝖣}, App𝗆(Ω)={}.

  2. (ii)

    App𝗆(𝖸)={}{λf.fn({f})n}.

  3. (iii)

    App𝗆(l)={{l}}{λf.fn({f,l})n}.

  4. (iv)

    App𝗆(𝖸𝖱l)={{l},λx0.x0({x0,l}),λx0.x0(λx1.x1({x0,x1,l})),}.

Lemma 18.
  1. (i)

    For every M,NΛ𝖨, MβN entails ω𝗆(M)ω𝗆(N).

  2. (ii)

    For all MΛ𝖨(X), App𝗆(M) is an ideal of the poset (𝒜𝗆(X),). More precisely:

    1. (a)

      non-emptiness: XApp𝗆(M);

    2. (b)

      downward closure: AApp𝗆(M) and AA imply AApp𝗆(M);

    3. (c)

      directedness: A1,A2App𝗆(M),A3App𝗆(M) such that A1A3A2.

Proof.
  1. (i)

    By an easy induction on the structure of MΛ𝖨(X), using Remarks 2 and 7.

  2. (ii)

    (a) and (b) are trivial. For (c), define by setting: XA=AX=A, xx=x, if A1,A1 and A2,A2 are compatible, then (λx.A1)(λx.A1)=λx.(A1A1) and A1A2A1A2=(A1A1)(A2A2). Check that A3=A1A2 is their supremum.

The next result shows that β-convertible terms share the same the set of approximants.

Proposition 19.

Let M,NΛ𝖨(X). If MβN, then App𝗆(M)=App𝗆(N).

Proof.

By confluence of β, using Lemma 18(i).

Theorem 20.

There is a bijection 𝒜() between the set of Ohana trees and the set of approximants of λ𝖨-terms satisfying 𝒜(OT(M))=App𝗆(M), for all MΛ𝖨.

Proof.

From OT(M) to App𝗆(M). Let OT(M) be the set of all finite subtrees of OT(M), where each truncated subtree T is replaced by fv(T). By Lemma 14, OT(M)App𝗆(M).

From App𝗆(M) to OT(M). For every finite path σ in OT(M), there is an AApp𝗆(M) representing OT(M) along σ. Conclude since OT(M) is the supremum of all such σ.

4 A resource calculus with memory

In this section we introduce the λ𝖨-resource calculus refining the (finite) resource calculus [19], best known as the target language of Ehrhard and Regnier’s Taylor expansion [21]. So, the resource calculus is not meant to be a stand-alone language, but rather another theory of approximations for the λ-calculus. Before going further, we recall its main properties.

We consider here the promotion-free fragment of the resource calculus introduced in [39]. Its syntax is similar to the λ-calculus, except for the applications that are of shape st¯, where t¯=[t1,,tn] is a multiset of resources called bag. The resources populating t¯ are linear as they cannot be erased or copied by s, they must be used exactly once along the reduction. When contracting a term of the form s=(λx.s)[t1,,tn] there are two possibilities.

  1. 1.

    If the number of occurrences of x in s is exactly n, then each occurrence is substituted by a different ti. Since the elements in the bag are unordered, there is no canonical bijection between the resources and the occurrences of x. The solution consists in collecting all possibilities in a formal sum of terms, the sum representing an inner-choice operator.

  2. 2.

    If there is a mismatch between the number of occurrences and the amount of resources, then s reduces to the empty-sum, 𝟎. From a programming-language perspective, this can be thought of as a program terminating abruptly after throwing an uncaught exception.

The first-class citizens of the resource calculus are therefore finite sums of resource terms, that are needed to ensure the (strong) confluence of reductions. Another important property is strong normalization, that follows from the fact that no resource can be duplicated.

4.1 λ𝖨-resource expressions and λ𝖨-resource sums

Our version of the resource calculus is extended with labels representing the memory of free variables that were present in the λ𝖨-term they approximate. Just like in Definition 13(i) we endowed the constant with a finite set X of variables, here we annotate:

  • the empty bag 1 of resource terms, since an empty bag of approximants of M should remember the free variables of M;

  • the empty sum 𝟎 of resource terms. Indeed, if a resource term vanishes during reduction because of the mismatch described above, its free variables should be remembered.

Definition 21.
  1. (i)

    For all Xf𝒱, the sets Δ𝖨(X) and !Δ𝖨(X) are defined by induction:

    xΔ𝖨({x})sΔ𝖨(X)xXλx.sΔ𝖨(X{x})sΔ𝖨(X)t¯!Δ𝖨(Y)st¯Δ𝖨(XY)
    1X!Δ𝖨(X)t0Δ𝖨(X)tnΔ𝖨(X)[t0,,tn]!Δ𝖨(X)
  2. (ii)

    The set Δ𝖨 of λ𝖨-resource terms and the set !Δ𝖨 of bags are given by:

    Δ𝖨Xf𝒱Δ𝖨(X)and!Δ𝖨Xf𝒱!Δ𝖨(X).

As a matter of notation, we let (!)Δ𝖨 denote either Δ𝖨 or !Δ𝖨, indistinctly but coherently. We call resource expressions generic elements s,t(!)Δ𝖨. We denote the union of two bags t¯,u¯!Δ𝖨(X) multiplicatively by t¯u¯, whose neutral element is the empty bag, 1X.

 Remark 22.
  1. (i)

    In every λ𝖨-resource term of the form λx.s, the variable x must occur freely in s: it may appear in the undecorated underlying term, or in the “memory” X decorating 1X. Therefore, it makes sense to define fv(s)X whenever s(!)Δ𝖨(X).

  2. (ii)

    Each set !Δ𝖨(X) is isomorphic to the monoid of multisets of elements of Δ𝖨(X). Notice that !Δ𝖨 is not the set of all bags of elements of Δ𝖨, just its subset of bags whose elements have the same free variables (and so inductively in the subterms).

Example 23.
  1. (i)

    The identity 𝖨 belongs to Δ𝖨, whereas the projections do not: 𝖪,𝖥Δ𝖨.

  2. (ii)

    Note that λxy.x1Δ𝖨 since yfv(x1), but λxy.x1{y}Δ𝖨 because y{y}.

  3. (iii)

    The terms 𝖣0=λx.x1{x} and 𝖣n+1=λx.x[x,,x], where the bag contains n+1 occurrences of x, are λ𝖨-resource terms. By Remark 22(ii), we obtain:

  4. (iv)

    [x,y]!Δ𝖨, while [x,x[x],x[λy.y,λy.y[y]],(λy.y)[x],λy.y1{x}]!Δ𝖨({x})!Δ𝖨.

We consider resource expressions up to α-equivalence, under the proviso that abstractions bind linear occurrences of variables as well as occurrences in the memory of empty bags. For instance, λxyz.x1{x}1{x,y,z} and λxyz.x1{x}1{x,y,z} are considered α-equivalent.

Definition 24.

For all Xf𝒱, the set [(!)Δ𝖨(X)] of sums of λ𝖨-resource terms (“resource sums”, for short) is defined as the -semimodule of finitely supported formal sums of expressions in (!)Δ𝖨(X), with coefficients in . Explicitly, it can be presented as:

[(!)Δ𝖨(X)]𝐬,𝐭𝟎Xrr+𝐬(for r(!)Δ𝖨(X))

quotiented by associativity and commutativity of +, as well as neutrality of 𝟎X.

Note that (!)Δ𝖨(X)[(!)Δ𝖨(X)], that is, resource expressions are assimilated to the corresponding one-element sum. The constructors of the calculus are extended to resource sums by (bi)linearity, i.e. for sΔ𝖨(X), 𝐬[Δ𝖨(X)], t¯!Δ𝖨(Y), 𝐭¯[!Δ𝖨(Y)], uΔ𝖨(Y) and 𝐮[Δ𝖨(Y)], we have:

(s+𝐬)t¯st¯+𝐬t¯,𝟎Xt¯𝟎XY,λx.(s+𝐬)λx.s+λx.𝐬,λx.0X𝟎X{x},s(t¯+𝐭¯)st¯+s𝐭¯,s𝟎Y𝟎XY,[u+𝐮]t¯[u]t¯+[𝐮]t¯,[𝟎Y]t¯𝟎Y.

Therefore, if 𝟎X occurs in s not as a summand but as a proper subterm, then s=𝟎fv(s).

4.2 Memory substitution and resource substitution

While the usual finite resource calculus is completely linear, the variables we store in the memory of 1X and 𝟎X are not. The memory X remembers the variables present in X not their amounts, this is the reason why it is modelled as a set, not as a multiset. This consideration leads us to define two kinds of substitutions.

The (non-linear) memory substitution of a set Yf𝒱 for a variable x in a λ𝖨-resource term s does not interact with the linear occurrences of x in s (i.e., they remain unchanged), it just replaces the “memory” of x in the empty bags with the content of Y.

Definition 25.
  1. (i)

    For all X,Yf𝒱 and x𝒱, define

    X{Y/x}{X{x}Y,if xX,X,otherwise.
  2. (ii)

    Given s(!)Δ𝖨(X), the memory substitution of x by Yf𝒱 in s is the resource term s{Y/x} defined as follows (for xy and, in the abstraction case, yY):

    x{Y/x} x, 1X{Y/x} 1X{Y/x}, (st¯){Y/x} (s{Y/x})(t¯{Y/x}),
    y{Y/x} y, (λy.s){Y/x} λy.s{Y/x}, ([s]t¯){Y/x} [s{Y/x}](t¯{Y/x}).

We now define the resource substitution of a bag u¯ for x in s, whose effect is twofold. 1) It non-deterministically replaces each linear occurrence of x with a resource from the bag (as usual). 2) It applies the memory substitution of x by fv(u¯) to the resulting sum of terms.

Definition 26.

Given s(!)Δ𝖨(X), x𝒱 and u¯!Δ𝖨(Y), the resource substitution of x by u¯ in s is the resource sum su¯/x[(!)Δ𝖨(X{Y/x})] defined as follows:

xu¯/x {u,if u¯=[u],𝟎Y,otherwise, (st¯)u¯/x u¯=v¯w¯(sv¯/x)(t¯w¯/x),
yu¯/x {y,if u¯=1Y,𝟎{y},otherwise, 1Xu¯/x {1X{Y/x},if u¯=1Y,𝟎X{Y/x},otherwise,
(λy.s)u¯/x λy.su¯/x, ([s]t¯)u¯/x u¯=v¯w¯[sv¯/x](t¯w¯/x).

with xy and in the abstraction case yY. We extend it to sums in [(!)Δ𝖨(X)] by setting:

𝟎Xu¯/x 𝟎X{Y/x} (s+𝐬)u¯/x su¯/x+𝐬u¯/x
s𝟎Y/x 𝟎X{Y/x} s(u¯+𝐮¯)/x su¯/x+s𝐮¯/x.

It is easy to verify that the definition above does indeed define a resource sum in [(!)Δ𝖨(X{Y/x})], and that it is stable under the quotients of Definition 24.

Definition 27.

The linear degree degx(s) of x𝒱 in some s(!)Δ𝖨 is defined by:

degx(x) 1, degx(λy.s) degx(s), wlog. xy, degx(1X) 0,
degx(y) 0, degx(st¯) degx(s)+degx(t¯), degx([s]t¯) degx(s)+degx(t¯).

The next lemma is not strictly needed, but helps understanding resource substitution.

Lemma 28.

Consider s(!)Δ𝖨(X), x𝒱 and u¯!Δ𝖨(Y), and write ndegx(s). Then

su¯/x={σ𝔖(n)s[uσ(1)/x(1),,uσ(n)/x(n)]{Y/x},if the cardinality of u¯ is n,𝟎X{Y/x},otherwise,

where: 𝔖(n) is the set of permutations of {1,,n}; u1,,un is any enumeration of the elements in u¯; x(1),,x(n) enumerate the occurrences of x in s; and s[uσ(1)/x(1),,uσ(n)/x(n)] is the λ𝖨-resource term obtained by substituting each element uσ(i) for the occurrence x(i).

Proof.

Straightforward induction on s.

The next Substitution Lemma concerns the commutation of resource substitutions, and is the analogous of [4, Lemma 2.1.16]. Notice that the assumptions on the substituted variables are stronger than in the usual resource calculus [21, Lemma 2], where only xY is required.

Lemma 29.

Given s(!)Δ𝖨(X), u¯!Δ𝖨(Y), v¯!Δ𝖨(Z), and xXZ, yXY,

su¯/xv¯/y=v¯=v¯v¯′′sv¯/yu¯v¯′′/y/x.
Proof.

By structural induction on s, using Lemma 28 in order to apply the induction hypothesis only to those subterms where the hypotheses are actually satisfied.

4.3 The operational semantics

We finally endow resource expressions and resource sums with a notion of reduction 𝗋.

Definition 30.
  1. (i)

    For each Xf𝒱, define the resource reduction as a relation between λ𝖨-resource terms and resource sums, i.e. 𝗋(!)Δ𝖨(X)×[(!)Δ𝖨(X)]:

    (λx.s)t¯𝗋st¯/xmissings𝗋𝐬λx.s𝗋λx.𝐬s𝗋𝐬st¯𝗋𝐬t¯t¯𝗋𝐭¯st¯𝗋s𝐭¯s𝗋𝐬[s]t¯𝗋[𝐬]t¯
  2. (ii)

    We extend the reduction relation 𝗋 to resource sums [(!)Δ𝖨(X)]×[(!)Δ𝖨(X)], and simultaneously introduce its reflexive closure 𝗋?, as follows:

    s𝗋𝐬𝐭𝗋?𝐭s+𝐭𝗋𝐬+𝐭𝐭𝗋𝐭𝐭𝗋?𝐭𝐭𝗋?𝐭
  3. (iii)

    We denote by 𝗋 the reflexive and transitive closure of the relation 𝗋 given in (ii).

Observe that 𝗋 is well-defined because fv((λx.s)t¯)=fv(st¯/x). Indeed fv((λx.s)t¯)=fv(s){x}fv(t¯) with xfv(s), whence fv(st¯/x)=fv(s){fv(t¯)/x}=fv(s){x}fv(t¯).

Example 31.

We use the resource λ𝖨-terms 𝖨 and 𝖣n from Example 23.

  1. (i)

    𝖣0[z]𝗋(x1{x})[z]/x=(x[z]/x)(1{z})+(x1{z}/x)(1{x}[z]/x)=z1{z}+𝟎{z}=z1{z}. Similarly, 𝖣0[𝖨]𝗋𝖨1𝟎.

  2. (ii)

    (λx.𝖣𝟢[x])[z] has two redexes. Contracting the outermost first gives (λx.𝖣𝟢[x])[z]𝗋𝖣𝟢[z]𝗋z1{z}. Contracting the innermost (λx.𝖣𝟢[x])[z]𝗋(λx.x1{x})[z]𝗋z1{z}.

  3. (iii)

    𝖣1[𝖨,𝖨]𝗋𝖨[𝖨]+𝖨[𝖨]𝗋𝖨+𝖨[𝖨]𝗋𝖨+𝖨=2.𝖨. Thus, sums can arise from single terms.

We show that 𝗋 enjoys the properties of strong confluence and strong normalisation.

Theorem 32.
  1. (i)

    The reduction 𝗋 is strongly normalising.

  2. (ii)

    𝗋 is strongly confluent in the following sense: for all 𝐬,𝐭1,𝐭2[(!)Δ𝖨(X)] such that 𝐬𝗋𝐭1 and 𝐬𝗋𝐭2, there exists 𝐮[(!)Δ𝖨(X)] such that 𝐭1𝗋?𝐮 and 𝐭2𝗋?𝐮.

Proof.
  1. (i)

    The size 𝗌𝗂𝗓𝖾(s) of a resource expression s(!)Δ𝖨 is defined by structural induction as usual, with base cases 𝗌𝗂𝗓𝖾(x)=1 and 𝗌𝗂𝗓𝖾(1X)=0, so that 𝗌𝗂𝗓𝖾(1Xt¯)=𝗌𝗂𝗓𝖾(t¯). The sum-size of a resource sum 𝐬 is the finite multiset defined by 𝗌𝗌𝗂𝗓𝖾(𝟎X)=[] and 𝗌𝗌𝗂𝗓𝖾(s+𝐭)=[𝗌𝗂𝗓𝖾(s)]𝗌𝗌𝗂𝗓𝖾(𝐭). Sum-sizes are well-ordered by the usual well-founded ordering on finite multisets over (see [43, §A.6]).

    Now, assume that 𝐬𝗋𝐬. Since the contraction of a redex suppresses an abstraction and there is no duplication, we get 𝗌𝗌𝗂𝗓𝖾(𝐬)𝗌𝗌𝗂𝗓𝖾(𝐬). Conclude since is well-founded.

  2. (ii)

    The sequence of lemmas leading to the result follows a well-trodden path in the resource calculus [46, 10]. It is sufficient to check that they generalize to our setting.

By (ii) above every 𝐬[(!)Δ𝖨(X)] has a unique r-normal form which is denoted nf(𝐬).

5 Taylor approximation for Ohana trees

In its original formulation, Ehrhard and Regnier’s Taylor expansion translates a λ-term as a power series of iterated derivatives [20]. We now introduce a qualitative Taylor expansion [34] specifically designed for the λ𝖨-calculus, having as target the λ𝖨-resource calculus.

5.1 The Taylor approximation

Intuitively, a qualitative Taylor expansion should associate each term MΛ𝖨(X) with a set of resource approximants 𝒯𝗆(M)Δ𝖨(X). Therefore the codomain of 𝒯𝗆() should be Xf𝒱2Δ𝖨(X), and what we actually define is 𝒯𝗆(M)(X,𝒯𝗆(M)) with 𝒯𝗆(M)Δ𝖨(X). Notice that, whereas all previous constructions of disjoint unions Xf𝒱 were formed from genuinely disjoint sets, this is no longer the case here, as 2Δ𝖨(X), for all X.

Notation 33.
  1. (i)

    For Xf𝒱 and 𝒳2Δ𝖨(X), we write fv(X,𝒳)X.

  2. (ii)

    We let denote the order relation on Xf𝒱2Δ𝖨(X) such that (X,𝒳)(Y,𝒴) whenever X=Y and 𝒳𝒴. We write for the corresponding least upper bounds.

  3. (iii)

    We write s(X,𝒳) to mean that s𝒳.

  4. (iv)

    Given 𝒳2Δ𝖨(X), 𝒴2!Δ𝖨(Y){} and xX, we write:

    λx.(X,𝒳)(X{x},{λx.s|s𝒳}),(X,𝒳)𝒴(XY,{st¯|s𝒳,t¯𝒴}).
Definition 34.
  1. (i)

    The Taylor expansion 𝒯𝗆(M)Xf𝒱2Δ𝖨(X) of a λ𝖨-term M, is defined together with 𝒯𝗆!(M)!Δ𝖨(fv(M)) by mutual induction:

    𝒯𝗆(x)({x},{x}),𝒯𝗆(λx.M)λx.𝒯𝗆(M),𝒯𝗆(MN)𝒯𝗆(M)𝒯𝗆!(N),
    𝒯𝗆!(M){1fv(M)}{[t0,,tn]|n,t0,,tn𝒯𝗆(M)}.
  2. (ii)

    The above definition is extended to Ohana trees by setting, for all MΛ𝖨,

    𝒯𝗆(OT(M))AApp𝗆(M)𝒯𝗆(A),together with {𝒯𝗆(X)(X,),𝒯𝗆!(X){1X}.
 Remark 35.

For all M, we have fv(𝒯𝗆(M))=fv(M). Similarly, fv(𝒯𝗆(OT(M)))=fv(M), due to Remark 16 and the way we ordered Xf𝒱2Δ𝖨(X).

Example 36.
  1. (i)

    𝒯𝗆(𝖨)=(,{𝖨}), 𝒯𝗆(𝖣)=(,{𝖣n|n}).

  2. (ii)

    𝒯𝗆(OT(𝖸f))=({f},𝒳𝖸f) and 𝒯𝗆(OT(lf))=({f,l},𝒳lf), where the sets of approximants can be described as the smallest (in fact, unique) subsets of Δ𝖨 such that:

    𝒳𝖸f ={f1{f}}{f[t0,,tn]|n,t0,,tn𝒳𝖸f},
    𝒳lf ={f1{f,l}}{f[t0,,tn]|n,t0,,tn𝒳lf}.

We now describe how resource reduction acts on Taylor expansions, i.e. on potentially infinite sets of resource expressions.

Notation 37.
  1. (i)

    Given 𝐬[(!)Δ𝖨(X)], we denote by |𝐬|Xf𝒱2Δ𝖨(X) its support, defined by |𝟎X|(X,) and |s+𝐭|(X,{s})|𝐭|. Notice that s|𝐭| whenever s bears a non-zero coefficient in 𝐭 (i.e. 𝐭=s+𝐭, for some 𝐭).

  2. (ii)

    Given 𝒳2(!)Δ𝖨(X), we write nf(X,𝒳)s𝒳|nf(s)|. Notice that fv(nf(X,𝒳))=X, and that nf(X,𝒳)=(X,) if and only if s𝗋𝟎X, for all s𝒳.

This allows us to state the following theorem, adapting [20, Theorem 2].

Theorem 38 (Commutation).

For all MΛ𝖨, nf(𝒯𝗆(M))=𝒯𝗆(OT(M)).

We outline a proof in the following sequence of lemmas, similar to the one in [2]; alternatively, the variants of [20, 21], [38] and [10, 12] could also be adapted.

Lemma 39.

For all resource sums 𝐬 such that |𝐬|𝒯𝗆(M), there exists a reduction MβN such that |nf(𝐬)|𝒯𝗆(N).

Proof.

By induction on the length of the longest reduction 𝐬𝗋nf(𝐬). If it is 0, take NM. Otherwise, the longest reduction is 𝐬=t+𝐮𝗋𝐭+𝐮𝗋nf(𝐬). By firing all redexes in M and 𝐮 at the same position as the redex fired in t𝗋𝐭 (formally we do this by induction on this reduction), we obtain MβM and 𝐮𝗋𝐮 such that |𝐭+𝐮|𝒯𝗆(M). By confluence, 𝐭+𝐮𝗋nf(𝐬). We conclude by induction on this (shorter) reduction.

Lemma 40.

If t𝒯𝗆(N) is in 𝗋-nf, then there exists AApp𝗆(N) such that t𝒯𝗆(A).

Proof.

By induction on t. An 𝗋-nf is also a hnf, hence t=λx.yt¯1t¯k and N=λx.yN1Nk. For 1ik, t¯i𝒯𝗆!(Ni). If t¯i=1fv(Ni) define Aifv(Ni). If t¯i=[ti1,,tin], each tij is in 𝗋-nf, by induction there is AijApp𝗆(Ni), tij𝒯𝗆(Aij). Define Aij=1nAijApp𝗆(Ni). Finally, Aλx.yA1AkApp𝗆(N) and t𝒯𝗆(A).

Lemma 41 (Monotonicity of 𝒯𝗆()).
  1. (i)

    𝒯𝗆(A)𝒯𝗆(A) if and only if AA.

  2. (ii)

    For all NΛ𝖨, we have 𝒯𝗆(ω𝗆(N))𝒯𝗆(N).

Proof.

Immediate inductions (i) on A and A, and (ii) on the head structure of N.

Lemma 42 (Simulation of β).

If MβN, then 𝒯𝗆(N)=s𝒯𝗆(M)|𝐭s| for resource sums 𝐭s[Δ𝖨(fv(M))] such that s𝒯𝗆(M),s𝗋𝐭s.

Proof.

One first shows by induction on P that for all P,QΛ𝖨 and xfv(P), 𝒯𝗆(P[Q/x])=s𝒯𝗆(P)t¯𝒯𝗆!(Q)|st¯/x|. Then the proof is an induction on MβN, using the previous equality in the base case. See the details of a similar proof in [12, Lemmas 4.1 and 4.2].

Lemma 43.

If A𝒜𝗆 then all s𝒯𝗆(A) are in 𝗋-nf.

Proof.

Immediate induction on A.

Everything is now in place to prove the Commutation Theorem 38.

Proof of Theorem 38.

By Remark 35, fv(nf(𝒯𝗆(M)))=fv(M)=fv(𝒯𝗆(OT(M))). Thus, it is sufficient to prove that, for tΔ𝖨(fv(M)): tnf(𝒯𝗆(M)) if and only if t𝒯𝗆(OT(M)).

Take tnf(𝒯𝗆(M)), i.e. t|nf(s)| for some s𝒯𝗆(M). Then, by Lemma 39, there exists a reduction MβN such that |nf(s)|𝒯𝗆(N). Hence t𝒯𝗆(N) and t is in 𝗋-nf: Lemma 40 ensures that t𝒯𝗆(A) for some AApp𝗆(N)=App𝗆(M) (by Proposition 19). This means exactly that t𝒯𝗆(OT(M)).

Conversely, take t𝒯𝗆(OT(M)), i.e. t𝒯𝗆(A) for some AApp𝗆(M). By definition there is a reduction MβN such that Aω𝗆(N). By Lemma 41, t𝒯𝗆(A)𝒯𝗆(ω𝗆(N))𝒯𝗆(N). By iterated applications of Lemma 42, there is an s𝒯𝗆(M) such that s𝗋𝐭s and t|𝐭s|. By Lemma 43, t is in 𝗋-nf, therefore t|nf(s)|nf(𝒯𝗆(M)).

5.2 The λ𝖨-theory of Ohana trees

Consider the equivalence 𝒪 on Λ𝖨, defined by M=𝒪N if and only if OT(M)=OT(N). Thanks to Theorem 38, we are now able to show that this equivalence is a λ𝖨-theory.

Corollary 44.

For M,NΛ𝖨, M=𝒪N if and only if nf(𝒯𝗆(M))=nf(𝒯𝗆(N)).

Proof.

() Immediate by Theorem 38. () Take M,N such that nf(𝒯𝗆(M))=nf(𝒯𝗆(N)). By Theorem 20, it is sufficient to prove App𝗆(M)=App𝗆(N). Take AApp𝗆(M). If A=X, then AApp𝗆(N) is trivial since App𝗆(N) is downward closed. Otherwise, by hypothesis and Theorem 38, 𝒯𝗆(A)BApp𝗆(N)𝒯𝗆(B). There is a BApp𝗆(N) such that [[A]]𝗋𝒯𝗆(B), where [[A]]𝗋𝒯𝗆(A) is defined by

[[x]]𝗋x,[[λx.yA1Ak]]𝗋λx.y[[A1]]𝗋![[Ak]]𝗋!,[[A]]𝗋!{1X,if A=X,[[[A]]𝗋],otherwise.

By induction on A, one shows that [[A]]𝗋𝒯𝗆(B) implies AB, hence AApp𝗆(N) by downward-closure (Lemma 18(ii)). This shows that App𝗆(M)App𝗆(N). The converse inclusion is symmetric.

Corollary 45.

𝒪 is a λ𝖨-theory.

Proof.

The relation =𝒪 is clearly an equivalence. By Propositions 19 and 20, for all M,NΛ𝖨, M=βN entails M=𝒪N.

For compatibility with abstraction, take M=𝒪N and xfv(M)fv(N). By Corollary 44, we get nf(𝒯𝗆(λx.M))=λx.nf(𝒯𝗆(M))=λx.nf(𝒯𝗆(N))=nf(𝒯𝗆(λx.N)).

For compatibility with application, by Theorem 32 observe that for all M,NΛ𝖨, nf(𝒯𝗆(MN))=nf(𝒯𝗆(M)𝒯𝗆!(N))=nf(nf(𝒯𝗆(M))nf(𝒯𝗆!(N))), where nf(𝒯𝗆!(N)) is defined by adapting Notation 37 to sets of resource bags. Therefore, nf(𝒯𝗆(M))=nf(𝒯𝗆(M)) and nf(𝒯𝗆(N))=nf(𝒯𝗆(N)) imply nf(𝒯𝗆(MN))=nf(𝒯𝗆(MN)), and we can conclude the proof by Corollary 44.

6 Conclusions and future work

In this paper we introduced the Ohana trees for the λ𝖨-calculus, together with two theories of program approximations: the former based on finite trees, the latter on resource approximants and Taylor expansion. Our pioneering results look encouraging, so we believe that this approach deserves further investigations.

6.1 Further work on the λ𝖨-calculus

The Ohana trees introduced in Definition 10 are an adaptation of Böhm trees, since they regard as meaningless the terms without hnf. By considering as meaningless the subset of zero-terms111I.e., terms without an hnf that never reduce to an abstraction. one obtains Lévy-Longo trees [31, 32], and by taking mute terms222Also called root active, mute terms have the property that all their reducts can reduce to a redex. as meaningless one obtains Berarducci trees [7]. Our definition of Ohana trees can be readily adapted to both settings by appropriately modifying the notion of meaningless. Preliminary investigations indicate that all our results extend seamlessly to the Lévy-Longo version. Regarding the Berarducci version, the direct approximants can be generalized without any issues (except for the fact that an oracle is needed, see [45]). We are currently studying whether the corresponding λ𝖨-resource calculus and Taylor expansion could also be designed.

Our investigation of memory trees started from semantical considerations. The relational model with infinite multiplicities , defined in [9], distinguishes Ω from Ωx, and 𝖸 from l, just like our memory trees. Unlike our memory trees, it equates λx.x(Ωy)(Ωz) and λx.x(Ωz)(Ωy), thus the induced theory is different from memory trees equality (=𝒪).

Finding a denotational model whose theory captures exactly the Ohana tree equality would reinforce our belief that they are a natural notion of trees for the λ𝖨-calculus.

Problem 46.

Is there a denotational model of Λ𝖨 whose theory is exactly 𝒪?

As pointed out by one of the referees, our Definition 6 of λ𝖨-terms can most likely be recast in the framework of abstract syntax with binding [23]: just as Λ() can be described as a canonical presheaf over (a skeleton of) the category of finite sets and functions, Λ𝖨() would be a presheaf over the category of finite sets and surjections (intuitively, considering only surjective renamings of variables prevents any weakening). Similarly, (!)Δ𝖨() would appear as a presheaf over the same category. One could then wonder whether all our work can be presented “over” finite sets and surjections; in particular, would our Taylor expansion act naturally with respect to these presheaf constructions? There is hope that it is the case, given that we followed the inductive structures of both λ𝖨-terms and λ𝖨-resource terms, which may pave the way towards building (presheaf) models answering to Problem 46.

We believe that finding a denotational model and studying its categorical properties are important steps towards a deeper mathematical understanding of our Taylor expansion. In particular, it is currently unclear whether our resource calculus stands on a solid notion of differentiation, as it is the case for the usual resource calculus [19], or if it is an ad hoc adaptation.

Problem 47.

Is the λ𝖨-resource calculus representing some notion of derivative?

We now discuss more speculative extensions, going beyond the setting of λ𝖨-calculus.

6.2 What about the full λ-calculus?

We have seen that the model from [9] distinguishes some meaningless terms having different free variables, but equates some λ𝖨-terms having different Ohana trees. Characterizing its theory seems a very natural question that has been completely overlooked in the literature.

Problem 48.

Is there an operational characterization of the λ-theory induced by ?

The fact that is a model of the full λ-calculus witnesses the existence of consistent λ-theories that remember variables that are pushed into infinity in the Böhm tree semantics. It is then natural to wonder whether it makes sense to extend the definition of Ohana trees to arbitrary λ-terms. The idea is to consider the set of permanent free variables of MΛ:

pfv(M)={xNΛ.MβN implies xfv(N)}

Intuitively, pfv(M) is the set of free variables of M that are never erased along a reduction.

Definition 49.

The Ohana tree of a λ-term M can be then defined by setting:

  • OT(M)=λx.ypfv(M1)OT(M1)pfv(Mk)OT(Mk), if Mhλx1xn.yM1Mk;

  • pfv(M), otherwise.

For MΛ𝖨 the definition above is equivalent to Definition 10, since pfv(M)=fv(M). For an arbitrary MΛ, one needs an oracle to compute pfv(M), but an oracle is already needed to determine whether M has an hnf, therefore the logical complexity does not increase.

Preliminary investigations show that the above notion of Ohana tree remains invariant by β. The key property which is exploited to prove this result is that pfv(λx.yM1Mk)={y}pfv(M1)pfv(Mk). The main problem of Definition 49 is that the equality induced on λ-terms is not a λ-theory because it is not compatible with application. The following counterexample exploits the fact that, in general, pfv(MN)pfv(M)pfv(N). Define:

𝖶=λxy.yxy,M=λz.𝖶(zv1v2)𝖶,N=λz.𝖶(zv2v1)𝖶, for v1,v2𝒱.

We have Mhλz.(λy.y(zv1v2)y)𝖶hM and Nhλz.(λy.y(zv2v1)y)𝖶hN, whence OT(M)=OT(N)={v1,v2}. By applying these terms to 𝖪, we obtain M𝖪β𝖶v1𝖶 and N𝖪β𝖶v2𝖶, therefore OT(M𝖪)={v1}{v2}=OT(N𝖪). We conclude that the equality induced on Λ is not a λ-theory, because it is not compositional. This counterexample is particularly strong because it shows that this is independent from the fact that Ohana trees are generalizations of Böhm trees and not, say, Berarducci trees. Indeed, the M,N constructed above have the same Böhm tree, Lévy-Longo tree and Berarducci tree.

A natural question is whether Ohana trees can be used as a meaningful notion of observation, in the sense of Morris’s observational equivalences [37].

Problem 50.

Is there a denotational model inducing the following λ-theory?

MNC[].OT(C[M])=OT(C[N])

where C[] denotes a λ-calculus context (namely, a λ-term containing a hole []), and C[M] the λ-term obtained by replacing M for the hole [] in C[], possibly with capture of free variables.

References

  • [1] Sandra Alves and Mário Florido. Structural rules and algebraic properties of intersection types. In Helmut Seidl, Zhiming Liu, and Corina S. Pasareanu, editors, Theoretical Aspects of Computing - ICTAC 2022 - 19th International Colloquium, Tbilisi, Georgia, September 27-29, 2022, Proceedings, volume 13572 of Lecture Notes in Computer Science, pages 60–77. Springer, 2022. doi:10.1007/978-3-031-17715-6_6.
  • [2] Davide Barbarossa and Giulio Manzonetto. Taylor subsumes Scott, Berry, Kahn and Plotkin. Proceedings of the ACM on Programming Languages, 4(POPL):1–23, 2019. doi:10.1145/3371069.
  • [3] Henk 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. North-Holland, Amsterdam, 1977.
  • [4] Henk Barendregt. The lambda calculus - its syntax and semantics, volume 103 of Studies in logic and the foundations of mathematics. North-Holland, 1984.
  • [5] Henk Barendregt and Giulio Manzonetto. A Lambda Calculus Satellite. College Publications, 2022. URL: https://www.collegepublications.co.uk/logic/mlf/?00035.
  • [6] Stefano Berardi and Ugo de’Liguoro. Non-monotonic pre-fix points and learning. Fundam. Informaticae, 150(3-4):259–280, 2017. doi:10.3233/FI-2017-1470.
  • [7] Alessandro Berarducci. Infinite λ-calculus and non-sensible models. In Marcel Dekker, editor, Logic and Algebra, volume 180, pages 339–377, New York, 1996. Presented to the conference in honour of Roberto Magari, Pontignano 1994.
  • [8] Flavien Breuvart, Giulio Manzonetto, and Domenico Ruoppolo. Relational graph models at work. Log. Methods Comput. Sci., 14(3), 2018. doi:10.23638/LMCS-14(3:2)2018.
  • [9] Alberto Carraro, Thomas Ehrhard, and Antonino Salibra. Exponentials with infinite multiplicities. In Anuj Dawar and Helmut Veith, editors, Computer Science Logic, 24th International Workshop, CSL 2010, 19th Annual Conference of the EACSL, Brno, Czech Republic, August 23-27, 2010. Proceedings, volume 6247 of Lecture Notes in Computer Science, pages 170–184. Springer, 2010. doi:10.1007/978-3-642-15205-4_16.
  • [10] Rémy Cerda. Taylor Approximation and Infinitary λ-Calculi. Phd thesis, Aix-Marseille Université, 2024. URL: https://hal.science/tel-04664728.
  • [11] Rémy Cerda, Giulio Manzonetto, and Alexis Saurin. Ohana trees and Taylor expansion for the λI-calculus. No variable gets left behind or forgotten!, 2025. Version of this paper with additional proofs in an appendix. arXiv:2505.06193.
  • [12] Rémy Cerda and Lionel Vaux Auclair. Finitary simulation of infinitary β-reduction via Taylor expansion, and applications. Logical Methods in Computer Science, 19, 2023. doi:10.46298/lmcs-19(4:34)2023.
  • [13] Alonzo Church. The calculi of lambda conversion. Princeton University Press, 1941.
  • [14] Lukasz Czajka. A new coinductive confluence proof for infinitary lambda calculus. Log. Methods Comput. Sci., 16(1), 2020. doi:10.23638/LMCS-16(1:31)2020.
  • [15] Daniel de Carvalho and Lorenzo Tortora de Falco. The relational model is injective for multiplicative exponential linear logic (without weakenings). Ann. Pure Appl. Log., 163(9):1210–1236, 2012. doi:10.1016/J.APAL.2012.01.004.
  • [16] Daniel de Carvalho and Lorenzo Tortora de Falco. A semantic account of strong normalization in linear logic. Inf. Comput., 248:104–129, 2016. doi:10.1016/J.IC.2015.12.010.
  • [17] Aloÿs Dufour and Damiano Mazza. Böhm and Taylor for all! In Jakob Rehof, editor, 9th International Conference on Formal Structures for Computation and Deduction, FSCD 2024, July 10-13, 2024, Tallinn, Estonia, volume 299 of LIPIcs, pages 29:1–29:20. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2024. doi:10.4230/LIPICS.FSCD.2024.29.
  • [18] Lavinia Egidi, Furio Honsell, and Simona Ronchi Della Rocca. Operational, denotational and logical descriptions: a case study. Fundam. Informaticae, 16(1):149–169, 1992.
  • [19] Thomas Ehrhard and Laurent Regnier. The differential lambda-calculus. Theor. Comput. Sci., 309(1-3):1–41, 2003. doi:10.1016/S0304-3975(03)00392-X.
  • [20] 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 (CiE 2006), pages 186–197, 2006. doi:10.1007/11780342_20.
  • [21] Thomas Ehrhard and Laurent Regnier. Uniformity and the Taylor expansion of ordinary lambda-terms. Theoretical Computer Science, 403(2):347–372, 2008. doi:10.1016/j.tcs.2008.06.001.
  • [22] Jörg Endrullis, Dimitri Hendriks, and Jan Willem Klop. Highlights in infinitary rewriting and lambda calculus. Theor. Comput. Sci., 464:48–71, 2012. doi:10.1016/J.TCS.2012.08.018.
  • [23] Marcelo Fiore, Gordon Plotkin, and Daniele Turi. Abstract syntax and variable binding. In 14th Symposium on Logic in Computer Science, 1999. doi:10.1109/lics.1999.782615.
  • [24] Silvia Ghilezan. Strong normalization and typability with intersection types. Notre Dame J. Formal Log., 37(1):44–52, 1996. doi:10.1305/NDJFL/1040067315.
  • [25] Furio Honsell and Marina Lenisa. Some results on the full abstraction problem for restricted lambda calculi. In Andrzej M. Borzyszkowski and Stefan Sokolowski, editors, Mathematical Foundations of Computer Science 1993, 18th International Symposium, MFCS’93, Gdansk, Poland, August 30 - September 3, 1993, Proceedings, volume 711 of Lecture Notes in Computer Science, pages 84–104. Springer, 1993. doi:10.1007/3-540-57182-5_6.
  • [26] J. Martin E. Hyland. A syntactic characterization of the equality in some models for the λ-calculus. Journal London Mathematical Society (2), 12(3):361–370, 1975.
  • [27] Benedetto Intrigila, Giulio Manzonetto, and Andrew Polonsky. Degrees of extensionality in the theory of Böhm trees and Sallé’s conjecture. Log. Methods Comput. Sci., 15(1), 2019. doi:10.23638/LMCS-15(1:6)2019.
  • [28] Bart Jacobs. Semantics of lambda-I and of other substructure lambda calculi. In Marc Bezem and Jan Friso Groote, editors, Typed Lambda Calculi and Applications, International Conference on Typed Lambda Calculi and Applications, TLCA ’93, Utrecht, The Netherlands, March 16-18, 1993, Proceedings, volume 664 of Lecture Notes in Computer Science, pages 195–208. Springer, 1993. doi:10.1007/BFB0037107.
  • [29] Richard Kennaway, Jan Willem Klop, M. Ronan Sleep, and Fer-Jan de Vries. Infinitary lambda calculi and Böhm models. In Jieh Hsiang, editor, Rewriting Techniques and Applications, 6th International Conference, RTA-95, Kaiserslautern, Germany, April 5-7, 1995, Proceedings, volume 914 of Lecture Notes in Computer Science, pages 257–270. Springer, 1995. doi:10.1007/3-540-59200-8_62.
  • [30] Jeroen Ketema, Stefan Blom, Takahito Aoto, and Jakob Grue Simonsen. Rewriting Transfinite Terms, pages 129–144. Lulu Press Inc, United States, 2009.
  • [31] Jean-Jacques Lévy. An algebraic interpretation of the λβK-calculus; and an application of a labelled λ-calculus. Theor. Comput. Sci., 2(1):97–114, 1976. doi:10.1016/0304-3975(76)90009-8.
  • [32] Giuseppe Longo. Set-theoretical models of λ-calculus: theories, expansions, isomorphisms. Annals of Pure and Applied Logic, 24(2):153–188, 1983. doi:10.1016/0168-0072(83)90030-1.
  • [33] Stefania Lusin and Antonino Salibra. The lattice of lambda theories. J. Log. Comput., 14(3):373–394, 2004. doi:10.1093/LOGCOM/14.3.373.
  • [34] 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. doi:10.1007/978-3-642-21691-6_14.
  • [35] Giulio Manzonetto, Andrew Polonsky, Alexis Saurin, and Jakob Grue Simonsen. The fixed point property and a technique to harness double fixed point combinators. J. Log. Comput., 29(5):831–880, 2019. doi:10.1093/LOGCOM/EXZ013.
  • [36] Paul-André Melliès. Higher-order parity automata. In 32nd Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2017, Reykjavik, Iceland, June 20-23, 2017, pages 1–12. IEEE Computer Society, 2017. doi:10.1109/LICS.2017.8005077.
  • [37] James Hiram Morris. Lambda calculus models of programming languages. Phd thesis, Massachusetts Institute of Technology (MIT), 1968.
  • [38] Federico Olimpieri and Lionel Vaux Auclair. On the Taylor expansion of λ-terms and the groupoid structure of their rigid approximants. Logical Methods in Computer Science, 18, 2022. doi:10.46298/lmcs-18(1:1)2022.
  • [39] Michele Pagani and Paolo Tranquilli. Parallel reduction in resource lambda-calculus. In Zhenjiang Hu, editor, Programming Languages and Systems, 7th Asian Symposium, APLAS 2009, Seoul, Korea, December 14-16, 2009. Proceedings, volume 5904 of Lecture Notes in Computer Science, pages 226–242. Springer, 2009. doi:10.1007/978-3-642-10672-9_17.
  • [40] Simona Ronchi Della Rocca. Characterization theorems for a filter lambda model. Inf. Control., 54(3):201–216, 1982. doi:10.1016/S0019-9958(82)80022-3.
  • [41] Dana S. Scott. Continuous lattices. In Lawvere, editor, Toposes, Algebraic Geometry and Logic, volume 274 of Lecture Notes in Mathematics, pages 97–136. Springer, 1972.
  • [42] Paula Severi and Fer-Jan de Vries. The infinitary lambda calculus of the infinite η-Böhm trees. Math. Struct. Comput. Sci., 27(5):681–733, 2017. doi:10.1017/S096012951500033X.
  • [43] Terese. Term Rewriting Systems, volume 55 of Cambridge Tracts in Theoretical Computer Science. Cambridge University Press, 2003.
  • [44] Steffen van Bakel. Complete restrictions of the intersection type discipline. Theor. Comput. Sci., 102(1):135–163, 1992. doi:10.1016/0304-3975(92)90297-S.
  • [45] Steffen van Bakel, Franco Barbanera, Mariangiola Dezani-Ciancaglini, and Fer-Jan de Vries. Intersection types for lambda-trees. Theor. Comput. Sci., 272(1-2):3–40, 2002. doi:10.1016/S0304-3975(00)00346-7.
  • [46] Lionel Vaux. Normalizing the Taylor expansion of non-deterministic λ-terms, via parallel reduction of resource vectors. Logical Methods in Computer Science, 15, 2019. doi:10.23638/LMCS-15(3:9)2019.
  • [47] Christopher P. Wadsworth. The relation between computational and denotational properties for Scott’s 𝒟-models of the lambda-calculus. SIAM J. Comput., 5(3):488–521, 1976. doi:10.1137/0205036.
  • [48] Christopher P. Wadsworth. Approximate reduction and lambda calculus models. SIAM J. Comput., 7(3):337–356, 1978. doi:10.1137/0207028.