A finiteness structure on resource terms

# A finiteness structure on resource terms

## Abstract

In our paper “Uniformity and the Taylor expansion of ordinary lambda-terms” (with Laurent Regnier), we studied a translation of lambda-terms as infinite linear combinations of resource lambda-terms, from a calculus similar to Boudol’s lambda-calculus with resources and based on ideas coming from differential linear logic and differential lambda-calculus. The good properties of this translation wrt. beta-reduction were guaranteed by a coherence relation on resource terms: normalization is “linear and stable” (in the sense of the coherence space semantics of linear logic) wrt. this coherence relation. Such coherence properties are lost when one considers non-deterministic or algebraic extensions of the lambda-calculus (the algebraic lambda-calculus is an extension of the lambda-calculus where terms can be linearly combined). We introduce a “finiteness structure” on resource terms which induces a linearly topologized vector space structure on terms and prevents the appearance of infinite coefficients during reduction, in typed settings.

## Introduction

Denotational semantics and linear logic. Denotational semantics consists in interpreting syntactical objects (programs, proofs) as points in abstract structures (typically, ordered sets with various completeness properties). In this process, the dynamical features of programs are lost, and abstract properties of programs, such as continuity, stability or sequentiality are expressed.

A program, or a proof, is normally a finite object, and its denotation is usually infinite, because it describes all the possible behaviors of the program when applied to all possible arguments. Semantics turns the potential infinity of program dynamics into the actually infinite static description of all its potential behaviors.

Linear logic (LL), which arose from investigations in denotational semantics, sheds a new light on this picture. Whilst being as expressive as intuitionistic logic, LL contains a purely linear fragment which is completely finite in the sense that, during reduction, the size of proofs strictly decreases. For allowing to define and manipulate potentially infinite pieces of proofs/programs, LL introduces new connectives: the exponentials.

Unlike its finite multiplicative-additive fragment, the exponential fragment of LL is strongly asymmetric:

• on one side, there is a promotion rule which allows to introduce the “” connective and makes a proof duplicable and erasable;

• and on the other side, there are the rules of contraction, weakening and dereliction which allow to duplicate, erase and access to promoted proofs. These rules introduce and allow to perform deductions on the “” connective, which is the linear dual of “”. Let use call these rules structural1.

The only infinite rule of LL is promotion. The potentially infinite duplicating power of contraction is not “located” in the contraction rule itself, but in the fact that, for being duplicable by contractions, a proof must be promoted first. This fact can be observed in denotational models but is not clear in the syntax because the structural rules have no other opponents but promotion2.

Differential linear logic The situation is quite different in differential LL (and, implicitly, in differential lambda-calculus and its variants), a system that we introduced recently (see [ER03, ER06b, EL09]). In this system, the “” rules have exact dual rules: there is a cocontraction, a coweakening and a codereliction rules. These rules are logical versions of standard mathematical operations used in elementary differential calculus, whence the name of the system.

So in differential LL we have structural and costructural rules and these rules interact in a completely symmetric and finite way, just as in the multiplicative and additive fragment. Promotion remains apart, as the only truly infinite rule of logic. This fact, which in LL could be observed only in denotational models, can be expressed syntactically in differential LL by means of the Taylor expansion of promotion rules.

Resource lambda-calculus. This operation is more easily understood in the lambda-calculus (see [Tra08] for the connection between lambda-terms and nets in differential LL). Roughly speaking, the ordinary lambda-calculus correspond to the fragment of LL which contains the multiplicative, structural and promotion rules. But we can also consider a lambda-calculus corresponding to the multiplicative, structural and costructural rules: the resource calculus that we introduced in [ER08]. Similar calculi already existed in the literature, such as Boudol’s calculi with multiplicities [Bou93] or with resources [BCL99], and also Kfoury’s calculi [Kfo00], introduced with different motivations and with different semantic backgrounds. The intuition behind our calculus with resources is as follows.

The first thing to say is that types should be thought of as (topological) vector spaces and not as domains. Consider then a term which should be seen as a function from to . Then imagine that it makes sense to compute the -the derivative of at the point of the vector space : it is a function , separately linear in each of its argument, and symmetric in the sense that for any permutation and any tuple . In our resource calculus, we have an application construction which represents this operation. Given a term (of type if we are in a typed setting) and a finite number of terms (of type ), we can “apply” to the multiset (the multiset whose elements are , taking multiplicities into account) and we denote with this operation. We take benefit of the intrinsic commutativity of multisets for implementing the symmetry of the -th derivative. The other constructions of this calculus are standard: we have variables and abstractions . Redexes are terms of the shape and can have several free occurrences in , which are all linear. When reducing this redex, one does not duplicate . Instead, one splits it into as many pieces as there are occurrences of in , and since all these occurrences are linear, all these pieces should contain exactly one term. We do that in all possible ways and take the sum of all possible results. When the number of free occurrences of in and the size of do not coincide, the result of this operation is .

For this to make sense, one must have the possibility of adding terms, and this is compatible with the idea that types are vector spaces.

Taylor expansion. Taylor expansion consists in replacing the ordinary application of lambda-calculus with this differential application of the resource calculus. If and are terms, then the standard Taylor formula should be

 (M)N=∞∑n=01n!M(n)(0)(nN,…,N)

This leads to the idea of writing any term as an infinite linear combination of resource terms (with rational coefficients): if and are such sums, we should have

 ((M)N)∗=∞∑n=01n!⟨M∗⟩(N∗)n (1)

where the power has to be understood in the sense of multiset concatenation, extented to linear combinations of multisets by linearity. Using the fact that all the constructions of the resource calculus should be linear (that is, should distribute over arbitrary linear combinations), formula (1) leads to a definition of as a linear combination of resource terms: where each is a positive rational number ( is the set of resource terms): this is the Taylor expansion of .

Taylor expansion looks like denotational semantics: we have transformed a finite program with a rich, potentially infinite, dynamics into an infinite set (linear combination to be more precise) of more elementary things, the resource terms. The difference wrt. denotational semantics is that these terms have still a dynamics, but this dynamics is completely finite because they belong to the promotion-free fragment of differential linear logic: all terms of our resource calculus, even the non typeable ones, are trivially strongly normalizing. But of course there is no uniform bound on the length of the reductions of the resource terms appearing in the Taylor expansion of a term.

Content. The present article is a contribution to a programme which consists in considering infinite linear combinations of resource terms as generalized lambda-terms. The first point to understand is how beta-reduction can be applied to such infinite linear combinations without introducing infinite coefficients. We initiated this programme in [ER08], defining a binary symmetric, but not reflexive, coherence relation on resource terms (such a coherence relation has also been defined for differential interaction nets in [PT09a]) and showing that, if two terms and are coherent and distinct, then their normal forms are disjoint (and hence can be summed). So a first idea is to consider cliques as generalized lambda-terms, and this is sound because the resource terms appearing in the Taylor expansion of a lambda-term are pairwise coherent.

But if we allow linear combinations in the lambda-calculus (as in the differential lambda-calculus for instance, and we speak then of algebraic lambda-calculus3), then we cannot expect Taylor expansions to be cliques for that coherence relation. Instead, we equip the set of resource terms with a finiteness structure (in the sense of [Ehr05]) which is defined in such a way that for any “finitary” linear combination of resource lambda-terms, the sum always makes sense, whatever be the choices of such that beta-reduces to in the resource lambda-calculus. We prove a soundness theorem, showing that the Taylor expansion of an algebraic lambda-terms is always finitary. This cannot hold however for the untyped algebraic lambda-calculus because we know that this calculus leads to unbounded coefficients during beta-reduction (think of where and is the Turing fixpoint combinator). So we prove our soundness result for second-order typeable algebraic lambda-terms, by a method similar to Girard’s proof of strong normalization of system F in Krivine’s very elegant presentation [Kri93]. The method consists in associating with any type a finiteness space (and hence a linearly topologized vector space) whose underlying set (web) is a set of resource terms.

## 1 The resource lambda-calculus

### 1.1 The calculus

The syntax of our resource calculus is defined as follows. One defines first the set of simple terms and the set of simple poly-terms.

• If is a variable then ;

• if and is a variable then ;

• if and then ;

• if then the multiset which consists of the s, denoted in a multiplicative way as , is an element of . The empty simple poly-term is accordingly denoted as .

We define the size of a simple term and the size of a simple poly-term by induction as follows:

• .

#### Extended syntax.

Given a rig (semi-ring) and a set , we denote by the set of all formal finite linear combinations of elements of with coefficients in : it is the free -module generated by . If and , denotes the coefficient of in . We also define as the set of all (not necessarily finite) linear combinations of elements of with coefficients in ; we use the same notations as for the elements of and we use to denote both modules, to deal with constructions which are applicable in both settings.

The semi-rings that we consider are

• with , so that and ;

• , and then is the set of all finite multisets of elements of . Given and we write when ;

• a field , and then is the -vector space generated by and is also a vector space.

Let , we set . Given moreover , we set . Last, given , we define as . In that formula, remember that is the multiset made of . This formula expresses that we consider multiset concatenation as a product, and so, when extended to linear combinations, a distributivity law must hold.

In particular, given and , we set . When , we set (this sum always makes sense, and we require to give a meaning to ). For (that is ), we set .

So all the constructions of the syntax can be applied to arbitrary linear combinations of simple terms, giving rise to combinations of simple terms.

#### Differential substitution

Given and , and given a variable , we define the differential substitution as if the number of free occurrences of in is different from , and as otherwise, where , are the occurrences of in and is the group of permutations on .

Given and and pairwise distinct variables which do not occur free in the ’s, we define more generally the parallel differential substitution : the definition is similar (the sum is indexed by tuples where is a permutation on the free occurrences of in ).

This operation must be extended by linearity. Given and , we set

 ∂x(a,A)=∑s∈Δ,S∈Δ!asAS∂x(s,S)∈R⟨Δ⟩(∞)

and we define similarly . It is not obvious at first sight that this sum is well defined in the infinite case. This results from Lemma 6 (see below).

#### The reduction relations

Given two sets and and a relation , we define a relation as follows: we say that if there are such that and .

The one step reduction relations and are defined as follows.

• never holds;

• if with ;

• if, for some , and ;

• in one of the following situations

• and ;

• and ;

• and .

###### Lemma 1

Let and . If , then, for any , one has .

The proof is straightforward (simple case inspection).

Let and . These are reflexive reduction relations on and respectively. More explicitly, we have if one can write and with for , and similarly for .

Finally we denote with and respectively the transitive closures of these relations.

###### Lemma 2

Let and is a variable which occurs free exactly once in . If then and if then .

###### Lemma 3

If then . If then .

These two lemmas are proved by straightforward inductions.

The reduction relation on has good properties: it is strongly normalizing, confluent (see [ER03, Vau05, PT09b]). Given , we denote by the unique normal form of , which is an element of .

#### Examples of reduction

Of course , but if the identity is applied to a multiset of size , the result is : and (where is the multiset which contains twice the variable ; this notation is compatible with the distributivity laws of 1.1.1).

Similarly, the term contains occurrences of (it is sensible to say that it is of degree in ). So if the size of is . And we have . As a last example we have .

#### An order relation on simple terms and poly-terms.

Let us define an order relation on simple terms. Given , we write if there exists such that and . Given , we use and . We define similarly an order relation on poly-terms and introduce similar notations: , and .

###### Lemma 4

For any , the set is finite.

Proof. By Lemma 1 and König’s lemma.

### 1.2 Two technical lemmas

###### Lemma 5

Let be a variable and which do not contain free the variable and let . Let , , be a variable. Let be such that . Then one of the the two following cases arises:

• either with , and

• or for some .

Proof. By induction on . Let be such that and . Consider the first reduction step of this reduction. Four cases are possible, because of the particular shape of .

First case: the reduction occurs in . That is for some and the reduction splits in . Since , one can find some with such that . Since , the inductive hypothesis applies and so there are two cases.

• Either we have with , and and we conclude because .

• Or with such that . Since and , we have . But by Lemma 3 and hence there exists such that . Hence we have by Lemma 2 and we conclude by transitivity.

The second case, where the reduction occurs in is similar.

Third case: the reduction occurs in . That is and the reduction splits in . Since , one can find some such that . Since , the inductive hypothesis applies and so there are two cases.

• Either with , and and we conclude because .

• Or for some . We conclude by Lemma 2 because .

Last case: the reduction splits in and we conclude immediately that there exists such that .

###### Lemma 6

Let . There are only finitely many pairs such that .

Proof. (Sketch) The intuition is clear and can easily be formalized. For building , one must choose some , and then pairwise disjoint4 sub-terms of . Then is obtained by replacing these sub-terms by in , and . There are only finitely many ways of choosing such a tuple .

## 2 Finiteness spaces

We recall some basic material on finiteness spaces. Given a set and a collection of subsets of , we define

 F⊥={e′⊆I∣∀e∈F e∩e′ is finite}.

A finiteness space is a pair where is a set (the web of ) and satisfies (the other inclusion being always true). The following properties follow immediately from this definition: if is finite then ; if and then ; if then .

Vector space. Let be a field. Given , let (the support of ). We set . This set is a -vector space, addition and scalar multiplication being defined pointwise.

Topology. Given , let : this is a linear subspace of . A subset of is open if, for all there exists such that . This defines a topology for which one checks easily that addition and scalar multiplication are continuous ( being equipped with the discrete topology). Actually is a linearly topologized vector space in the sense of [Lef42]: the topology is generated by neighborhoods of which are linear subspaces (for instance, the we introduced above). This topology is Hausdorff: for any , if one cant find a (linear) neighborhood of which does not contain . In particular, the specialization ordering is discrete (this is not a topology “à la Scott”).

Convergence and completeness. A net of if a family of elements indexed by a directed set . Such a net converges to if, for any open linear subspace of there is such that . If this holds, is unique ( is Hausdorff). A net is Cauchy if for any open linear subspace of , there exists such that . Using crucially the fact that , one can prove that any Cauchy net converges ( is complete).

## 3 The basic finiteness structure

We set

 N1 = {↑s∣s∈Δ}⊥ = {e⊆Δ∣∀s∈Δe∩↑s is finite}.

One defines similarly as . This defines finiteness structures on and . We consider therefore as a finiteness space that we simply denote as . To get a better grasp of the topology of the vector space , we must make a first observation. We express everything for for notational convenience, but obviously what we do can be transposed to without any difficulty.

###### Lemma 7

A subset of belongs to iff there are finitely many elements such that

 e′⊆↑s1∪⋯∪↑sn=↑{s1,…,sn}.

Proof. The “if” part is trivial, let us check the “only if” part. The only property of the order relation on simple terms that we need is the fact that each set is finite (Lemma 4).

Assume that there exists such that never holds. The set cannot be empty, so let . Since is finite, we cannot have . So let . Again, being finite, we cannot have . In that way, we construct an infinite sequence of elements of such that for each , ; in particular, the ’s are pairwise distinct, but we can say better: let and assume that . Then and this is impossible. Let us set . For any , it follows from the disjointness of the sets that has at most one element and is therefore finite, so that . But has an infinite intersection with (namely ), and this contradicts our hypothesis that .

Therefore the topology of is generated by the basic neighborhoods , where is an arbitrary finite family of elements of . Observe that these ’s can be assumed to be minimal in . An element of is minimal for the order relation we have defined iff is normal, or reduces only to . A typical non-normal minimal term is , where and are distinct variables.

The main purpose of these definitions is to give meaning to a normalization function on vectors. Consider indeed an arbitrary linear combinations of resource lambda-terms, . We would like to set . But there could perfectly exist normal elements such that, for infinitely many , and . If this is the case, we cannot normalize because infinite sums are not allowed in which is an arbitrary field5. As a typical example of this situation, consider All the terms of this sum reduce to the same term and hence is not defined.

###### Proposition 8

The map given by is well defined, linear and continuous from the topological vector space to itself.

Proof. Given , we have . So, since , for any , there are only finitely many such that . So the sum above makes sense, it can be written

All the elements of being minimal, this set obviously belongs to .

The map defined in that way is obviously linear, we must just check that it is continuous at but this is easy; indeed, if is a basic neighborhood of then, by definition of , if satisfies , this means that for each , and hence for no we can have . Therefore .

We can also extend the reduction relation to in a completely “free6” way. Indeed let . If one writes with and with the sole restriction (for this sum to make sense at all) that for each there are only finitely ’s such that and if, for each , one chooses arbitrarily such that , then the sum always makes sense, and belongs to (these facts result from the very definition of ). In that case we write , and we denote by the transitive closure of .

###### Proposition 9

The relation is confluent on .

Proof. (Sketch) Use the confluence of on and the following observation: given two finite families and of elements of such that , one can find a family of elements of such that and .

One has to be aware that this “reduction” relation has strange properties and can hardly be expected to normalize in a standard sense. For instance if and where are distinct, then and the reduction can go on after that. See [Vau07, Vau08] for more explanations. It makes sense nevertheless to define the associated equivalence relation (the symmetric closure of ) that we denote as .

###### Proposition 10

Let be such that . Then .

Proof. It suffices to show that and this is easy because .

The converse implication does not hold because reducing an element to can require an infinite number of steps. But one can always exhibit sequences with (in the sense of the topology of ).

Remark: It is not difficult to see that, given a finiteness space , the topological space is metrizable (ie. its topology can be defined by a distance) iff there exists an increasing sequence of elements of such that . It is also interesting to observe that, when interpreting linear logic in finiteness spaces (see [Ehr05]), one builds quite easily spaces which have not this property: for instance the interpretation of (the formula being interpreted by the finiteness space ) is not metrizable.

So the space is metrizable: choose an enumeration of and, given , define if , and where is the least integer such that . This distance generates the topology we have defined, but presenting this space as a metric space would be unnatural, because there is (apparently) no canonical choice of such a distance (it depends on a completely arbitrary enumeration of ).

A last interesting observation is that the subspace of spanned by the normal resource term is linearly compact7, so that can be seen as a projection onto a linearly compact subspace.

### 3.1 Dealing with free variables

The finiteness space allows to give meaning to normalization as shown by Proposition 8, but we would also like to deal with elements of (or of ) as if they were lambda-terms. However, nothing prevents an element of of containing infinitely many free variables. The set can even be the set of all variables: take for the set of all variables itself! It would be hard to define -reduction if we have to deal with such objects.

Fortunately the solution to this problem is quite easy. Let be the set of all subsets of such that, for each finite set of variables, there are only finitely many elements of such that .

###### Lemma 11

.

Proof. The inclusion “” is straightforward. So let . Towards a contradiction, assume that is infinite and let be a repetition-free enumeration of this set of variables. Let . Choose such that . Since is finite, we can find such that . Choose such that , choose such that … In that way we define a sequence of element of and a sequence of variables such that iff (take ). Then is an element of . Indeed, if is a finite set of variables, contains only a finite number of ’s and hence there can be only finitely many ’s such that . But is infinite since , whence the contradiction.

This is another instance of a general proof scheme used several times in [Ehr05] and generalized by Tasson and Vaux (see [Tas09]).

We arrive to the final definition of our basic finiteness space: we set and therefore we have so that is actually a finiteness space.

## 4 Interpreting types

With any type (of system F, see Section 5.1), we want to associate a finiteness space whose web will be a subset of . The construction is based on the definition of saturated sets in [Kri93], so we shall call our finiteness spaces saturated as well.

Let be the collection of all subsets of which are of the shape where is a variable and .

### 4.1 Saturated finiteness space

A -finiteness space is a finiteness space such that . One says that such a space is saturated if and, whenever , one has (using the notations introduced in 1.1.1 and 1.1.2) the implication

 ⟨⟨⟨∂x(g,e!)⟩e1!⟩⋯⟩en!∈F(X) ⇒⟨⟨⟨⟨λxg⟩e!⟩e1!⟩⋯⟩en!∈F(X). (2)

Then one simply says that is a saturated finiteness space.

Given two -finiteness spaces and , we construct a new one, denoted as .

The web is the collection of all such that

 ∀e∈F(X)⟨t⟩e!∈F(Y).

Then we define as the collection of all such that

 ∀e∈F(X)⟨g⟩e!∈F(Y),

that is

 ∀e∈F(X),∀f′∈F(Y)⊥⟨g⟩e!∩f′