Linear $\beta$-reduction
Stefano Guerrini (LIPN, Institut Galil\'ee, Universit\'e Paris Nord, 13, Sorbonne Paris Cit\'e)

TL;DR
This paper introduces a comprehensive analysis of linear beta-reduction at a distance in lambda-calculus, clarifying its syntactic structure and properties, and extends strong normalization proofs to this setting.
Contribution
It provides a general notion of beta-reduction at a distance and linear reduction, along with their properties and relations, using a refined sigma-equivalence for better analysis.
Findings
Defined a general notion of beta-reduction at a distance
Analyzed relations and properties of linear reduction
Extended strong normalization proof to linear reduction in simply typed case
Abstract
Linear head reduction is a key tool for the analysis of reduction machines for lambda-calculus and for game semantics. Its definition requires a notion of redex at a distance named primary redex in the literature. Nevertheless, a clear and complete syntactic analysis of this rule is missing. We present here a general notion of beta-reduction at a distance and of linear reduction (i.e., not restricted to the head variable), and we analyse their relations and properties. This analysis rests on a variant of the so-called sigma-equivalence that is more suitable for the analysis of reduction machines, since the position along the spine of primary redexes is not permuted. We finally show that, in the simply typed case, the proof of strong normalisation of linear reduction can be obtained by a trivial tuning of Gandy's proof for strong normalisation of beta-reduction.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Linear -reduction††thanks: Partially supported by the Project ELICA (ref. ANR-14-CE25-0005), of
the ANR program “Fondements du numérique (DS0705) 2014”.
Stefano Guerrini
LIPN
Institut Galilée
Université Paris Nord 13
Sorbonne Paris Cité
Abstract
Linear head reduction is a key tool for the analysis of reduction machines for -calculus and for game semantics. Its definition requires a notion of redex at a distance named primary redex in the literature. Nevertheless, a clear and complete syntactic analysis of this rule is missing. We present here a general notion of -reduction at a distance and of linear reduction (i.e., not restricted to the head variable), and we analyse their relations and properties. This analysis rests on a variant of the so-called -equivalence that is more suitable for the analysis of reduction machines, since the position along the spine of primary redexes is not permuted. We finally show that, in the simply typed case, the proof of strong normalisation of linear reduction can be obtained by a trivial tuning of Gandy’s proof for strong normalisation of -reduction.
1 Introduction
Linear head reduction is a key tool for the analysis of reduction machines for -calculus and for game semantics. A detailed analysis of it, and more generally of a notion of reduction at a distance, has been given by Accattoli [2] in terms of proof nets and explicit substitutions. Linear head reduction is usually presented in terms of the so-called -equivalence introduced by Regnier in [9]. In the following, we introduce a variant of the -equivalence, which has the main advantage of leaving unchanged the order of primary redexes (a notion of -redex that will be discussed later). Such a new equivalence is more suitable for the analysis of abstract reduction machines based on linear head reduction, as for instance Danos and Regnier’s Pointer Abstract Machine (PAM) [4], which has been analysed in detail by the author and Pellitta in [6]. Indeed, most of the material that we shall present in this paper has been developed for formalising the results in [6].
The key tool of our approach is a notion of context which is indeed an implicit representation of environments mapping variables to their values. By means of these contexts, one can define a -reduction at a distance and its linearised version. Both of these reduction rules preserve -equivalence, and both of them are strongly normalising in the case of simply typed -calculus. However, the proof of strong normalisation is not at all evident. In fact, linear reduction does not erase any term, it just replaces one of the occurrences of a variable with a (larger) -term; in other words, the size of the reducing term always increases along the reduction. Surprisingly, this apparent difficulty can be trivially overcome by a small tuning of Gandy’s proof for strong normalisation of -reduction [5]. Just by changing a detail in the interpretation of variable occurrences—it suffices to increase by 1 their measure—we can adapt the measure used in Gandy’s proof to the case of linear reduction. Moreover, the new measure obtained in this way simultaneously proves strong normalisation of -reduction and of its linearised version.
As already remarked, linear reduction has been studied in detail by Accattoli [2] by means of linear logic proof nets. Such an approach has been inspired by the structural calculus introduced by Accattoli and Kesner [3], a calculus with explicit substitutions and reduction rules at a distance. In the present paper, our goal is to analyse linear reduction directly on -calculus, without introducing explicit substitutions or without going down to the low level analysis of reduction that can be achieved by means of proof nets. As we shall see later, such a goal is achieved by introducing a variant of -equivalence, named E-equivalence, which is more suitable for investigating reduction machines based on pointers, as for instance the PAM. Moreover, the proof of strong normalisation that we shall give is much simpler then the one based on reducibility candidates required in the case of proof nets. Recently, Pedrot and Saurin [8] have proposed a call-by-need variant of -calculus defined in terms of a notion of closure contexts. Such closure contexts correspond to the E-contexts introduced in the following by Definition 2, but extended to -calculus too. We remark that most of the material that we shall present below is a by-product of the study of the PAM started in [6], and that one of the further developments mentioned in [6] is the extension of the PAM to the -calculus; Pedrot and Saurin’s call-by-need closure contexts seem to be the right tool for formalising such an extension.
2 Preliminaries
The set of the -terms is defined by the abstract grammar , where and is a binder for the variable . The set of the free variables of a term is denoted by . The key computational step of -calculus is -contraction , where denotes that every free occurrence of the variable in is replaced by , provided that such a replacement does not cause any name clash of some free variable of ; otherwise, if this is not the case, one has to preliminarily apply a suitable sequence of variable renamings, or -rules, to . (The -congruence is the least congruence induced by the -rule , in which replaces all the free occurrences of in and does not occur in .) As usual, denotes the reflexive and transitive closure of the binary relation defined by the -rule, and denotes the corresponding equivalence (closing by symmetry also). Such notations will extend to the other rewriting rules that we shall see in the paper.
In order to avoid the bureaucratic problems connected to -congruence, we can assume to work modulo it, and that all the bound variables in the terms that we shall consider have the distinct names property (sometimes referred to as Baredrengt variable names convention). A term has the distinct names property if no free variable in it has the same name of a bound variable, and all the bound variables have distinct names. Remarkably, for every -term there is an -congruent one which has the distinct name property. In this way, no name clash can arise by replacing for in in the -reduction of . However, even if correct, the resulting term might not have the above distinct names property. In order to guarantee that preserves the distinct names property of , we can assume to replace each occurrence of with a fresh copy of , in which every bound variable has a fresh name which has not been already used in the term or in another copy of .
In the simply typed -calculus, every term has a type. The set of types is given by the abstract grammar , where the constant is the unique base type and any type is said a functional type. The set of the simply typed terms is the subset of whose terms respect the following typing rules:
(i) each variable has a given type ;
(ii) if the variable has type , and the term has type , then has type ;
(iii) if the term has type and has type , then has type .
We shall write or to denote that a term has type . The -rule preserves typing; namely, if and , then .
A reduction strategy is a set of rules specifying how to reduce a -term. Roughly speaking, given a reducible term , a reduction strategy is a function that selects the redex (or the redexes) of that must (or among which we can choose the redex to) be reduced at the next step. A reduction strategy defines a sub-rewriting system of -reduction and, in some cases, if some -reducible term contains no valid redex for the given reduction strategy, it introduces new normal forms.
2.1 Head reduction
Let us say that a -redex is in outermost head position111Usually this is simply referred to as head position. In the following we shall however present a larger notion of head position, in which a -redex may be in head position even if it is inside the body of a -redex in head position. According to such a new notion of head position, the redex reduced by the head reduction is the outermost -redex in head position. in when , and that head reduces to , written , by reducing its outermost head redex. A term is in head normal form when , which in general is not a -normal form, since may contain -redexes. Indeed, the -normal form of , if it exists, can be found by head reducing a term to its head normal form (if any) first, and then by recursively applying the head reduction strategy to every and to the subterms of their head normal forms.
2.2 Head contexts
As usual, a context is a term with a hole (a sort of dummy free variable occurring exactly once in the term) . Given any term , by we denote the term obtained by replacing the hole of the context with the term , without performing any variable renaming; therefore, when the hole is under the scope of a -abstraction binding the variable , any free occurrence of in is captured in , and becomes bound.
Definition 1** (H-context, head variable)**
A head context, or H-context, is a context whose hole appears in head position. More precisely, H-contexts are defined by the following grammar
[TABLE]
A head context of a term is any H-context s.t. , for some term , that we shall say to be in head position in . In particular, for every -term , there is a unique head context of (the maximal head context of ) and a unique variable (the head variable of ) s.t. . □
2.3 Spine
A spine -abstraction/application of a term is any -abstraction/application in head position in . The spine of , and of its head context , is the sequence of its spine -abstractions/applications ordered from the head variable of (the hole of ) to its root. A variable bound by a spine abstraction is a spine variable, while the right subterm of a spine application is a spine argument of . By and we denote the set of the spine variables of a term and of a H-context , respectively.
A H-context is a -context if its spine is formed of -abstractions only (equivalently, has no spine arguments). A H-context is a -context if its spine is formed of applications only (equivalently, has no spine variables).
3 -reduction at a distance
3.1 Environment contexts
Definition 2** (E-context)**
An environment context, or E-context, is a particular H-context in which spine -abstractions and spine applications are balanced. E-contexts are defined by the grammar
[TABLE]
□
An E-context contains an equal number of spine variables and of spine arguments. For every E-context , there is a unique pair s.t. , for some pair of E-contexts . Therefore, every E-context defines a unique bijection between its spine variables and its spine arguments. Such a correspondence can be formalised in terms of environments. An environment is an ordered sequence of variable substitutions (where is a term replacing the variable ). Given an environment , we define .
Definition 3
The environment associated to an E-context is inductively defined by
[TABLE]
□
According to the above definition, every pair of matching spine argument/variable corresponds to a substitution in . We remark that the order of the substitutions in an environment is relevant, since for , the occurrences of in the term are replaced by the term , while this is not the case for any occurrence of in a term with . In particular, the order of the spine variables in corresponds to the order in which they appear in , assuming to move from the inner head position to the root. In other words, precedes in iff the binder of is in the scope of the binder of .
Lemma 1
Let be an E-context. For every -term t, . □
3.2 Primary redexes and -contraction at a distance
Any pair of matching spine argument/variable in an E-environment is as a sort of redex at a distance.
Definition 4** (Primary -redex)**
A -redex at a distance is a term , where is an E-context. A primary -redex is a -redex at a distance occurring in a head position. □
As a particular case, for , any -redex is a -redex at a distance. -redexes at a distance can be reduced as usual -redexes, by defining the following generalisation at a distance of the -rule
[TABLE]
and by taking the -reduction as the closure by contexts of the above rule. The H-context of a -redex at a distance is an E-context. Then, every pair of matching spine argument/variable of an -context (and therefore every substitution in ) forms a primary redex. As a consequence, it is readily seen that for every E-context and every term . More generally, -reduction at a distance is sound w.r.t. the usual -reduction.
Proposition 1
Let , then . Moreover, is a normal form for iff it is a -normal form. □
4 Spine permutation equivalence of -terms
The head canonical E-contexts are a particular case of E-contexts in which every redex at a distance is also a -redex. Head canonical E-contexts are defined by the grammar , and any head canonical E-context has the shape An environment can be seen as the explicit representation of a head canonical E-context in which the order of the -redexes along the spine is the inverse of the substitution pairs in the environment
[TABLE]
Which corresponds to the inductive definition , and .
4.1 Surface E-equivalence
By Lemma 1, we have that , for every pair of E-contexts and s.t. . We can then define the following equivalence.
Definition 5** (Surface E-equivalence on E-contexts)**
The surface E-equivalence on E-contexts is the least equivalence defined by
[TABLE]
□
Such an equivalence captures exactly the equivalence classes of E-contexts , where is head canonical, as formally stated by the following lemma.
Lemma 2
For every E-context , there is a unique canonical E-context , which is also the unique normal form of the terminating rewriting system obtained by orienting the -equivalence rules of Definition 5 from the left to the right
[TABLE]
Moreover, , and therefore iff . □
Example 1
Let with and . The E-context is the unique canonical E-context -equivalent to . □
4.2 Canonical -terms
The E-equivalence can be extended to terms. In the corresponding head canonical forms, along the spine, one finds first all the unmatched spine abstractions, then the E-context formed of the primary redexes, and finally the unmatched spine arguments.
Definition 6** (Surface E-equivalence on terms)**
The surface E-equivalence on terms is the least equivalence defined by the E-equivalence rules on E-contexts of Definition 5, plus
[TABLE]
where is a -context, and are E-contexts. The equivalence naturally extends to H-contexts, by replacing for in the above equations. □
Definition 7** (head canonical -term)**
Let us say that is a head canonical H-context when
[TABLE]
where is a -context, is an -context, and is a head canonical E-context. The spine -abstractions of are the head -abstractions of , while the spine arguments of are the head arguments of . The -term is head canonical when its maximal head context is head canonical. □
Summing up, any head canonical -term has the shape
[TABLE]
and we can define , , , and .
Every H-context , and then every -term , has a unique E-equivalent head canonical form , or for terms. Moreover, as shown by Theorem 1 below, preserves the same relative positions of unmatched spine -abstractions, unmatched spine arguments, and primary redexes of . (A spine -abstraction/argument is unmatched when it is not involved in a primary redex.) More precisely, the -th head -abstraction of is the -th unmatched -abstraction on the spine of , the -th head argument of the head canonical form is the -th unmatched spine argument on the spine of , the -th primary redex of is the -th primary redex on the spine of .
Theorem 1
For any H-context , there is a unique head canonical context . More precisely,
for every H-context , there is a unique sequence of spine variables , a unique sequence of spine arguments , and a unique sequence of E-contexts s.t.
[TABLE]
that is
[TABLE] 2. 2.
there is a unique head canonical context , and is equal to
[TABLE]
that is
[TABLE]
where is the unique head canonical E-context equivalent to ; 3. 3.
the canonical context of is the unique normal form of the rewriting system obtained by orienting from the left to the right the surface E-equivalences on terms of Definition 6. Namely,
[TABLE]
plus the rules for E-contexts in Lemma 2.
□
4.3 E-equivalence
The surface E-equivalence permutes the arguments on the spine of a term without modifying them. The E-equivalence is obtained by recursively applying the surface E-equivalence to spine arguments too. If we denote by the -th head spine argument of the term (which corresponds to the -th spine argument in the head -context of its head canonical form) and by the spine argument of the -th primary redex of (which corresponds to the -th spine argument in the head canonical E-context of the head canonical form of ), we define as the least equivalence s.t. if , and , for or .
4.4 -equivalence
The -equivalence [9] is the least congruence induced by
[TABLE]
The rewriting system obtained by orienting the latter -equivalences from the left to the right is terminating—its head canonical forms are the same already defined for the E-equivalence—but is not confluent. Indeed, the -equivalence contains the E-equivalence, but it equates head canonical forms and s.t. the environments and are equivalent modulo the following permutation rule if and .
Example 2
Let us take the -term , where is the -context of Example 1. Its unique head E-canonical form is , which can be also obtained by applying the first -rule. However, since by applying the second -rule, too, the -term has two -equivalent canonical forms. □
Summing up, the E-equivalence is a variant of the -equivalence which equates less terms then the latter one. The definition of the -equivalence is simpler and more elegant, and has a direct and nice interpretation in terms of linear logic proof nets. However, the better rewriting properties of the E-equivalence—canonical form uniqueness and preservation of primary redexes relative positions—makes it more suitable for a finer analysis of reduction machines requiring a reduction at a distance based on -equivalence, as for instance the PAM. The -equivalence can be recovered from the E-equivalence by adding the following permutation equivalence of primary redexes
[TABLE]
if and , to the E-equivalence of E-contexts.
5 Linear head reduction
5.1 Linear reduction
Let be a redex s.t. the term contains at least one occurrence of . For any occurrence of in , we can take the context obtained by replacing such an occurrence of with . The following reduction rule where is a fresh copy of , is a linearised variant of the usual -rule in which, instead of removing the redex after replacing all the occurrences of the bound variable , the redex is kept and only one occurrence of is replaced by a fresh copy of the argument . Such a linear -reduction can be extended to be applied at a distance too. We obtain then the linear reduction rule (at a distance)
[TABLE]
where is a fresh copy of . When the term in does not contain any occurrence of , we can instead take the following garbage rule (which is just a degenerated case of -reduction at a distance)
[TABLE]
Given a -redex (at a distance), by iterating the linear -reduction (at a distance), we can eventually obtain a redex (at a distance) to which apply the garbage rule. Therefore, -reduction (at a distance) can be simulated by a sort of affine reduction which is the union of linear and garbage reduction.
Proposition 2
Let .
If , then . Moreover, there is s.t. . 2. 2.
If , then . Therefore, there is s.t. .
□
As a consequence of the above proposition, a term has a normal form for iff it has a -normal form; moreover, the two normal forms coincide. We also remark the second part of the first item of Proposition 2. This is a particular case of a more general property stating that garbage reductions can be always postponed; that is, for every , there is s.t. .
5.2 Linear head -rule
A particular case of linear reduction arises when the occurrence to be replaced is the head variable.
Definition 8** (Linear head reduction)**
The linear head reduction is the least reduction which contains the linear head -rule
[TABLE]
where is a fresh copy of , and which is closed by head contexts. □
Linear head reduction is strongly related to head -reduction, as shown by the following statements.
Proposition 3
Let . There is s.t. . □
Corollary 1
A term has a linear head normal form iff it has a head normal form. Moreover, let be the linear head normal form of .
The head normal form of is obtained by -reducing all the primary redexes in . 2. 2.
The head normal form of is the head normal form of , indeed.
□
6 Strong normalisation
All the rewriting systems defined above are strong normalising on simply typed -terms. The proof of strong normalisation is however not at all evident. In fact, since linear reduction does not erase the reducing redex—it just replaces the occurrence of a variable by a (larger) -term—the size of the reducing term increases at each step. Accattoli [2], in its analysis of proof nets linear reduction, proved strong normalisation by applying reducibility candidates. Here, we show that, surprisingly, the proof of strong normalisation of linear reduction is simpler then one might have thought, as it can be easily obtained by a trivial tuning of the proof of strong normalisation originally proposed by Gandy for -reduction [5]. In Gandy’s proof, each type is interpreted as a well-founded ordered set . In particular, any functional type is mapped into a set of increasing functions from to . A measure is then associated to every term by interpreting any as an element . Strong normalisation is a consequence of the fact that any -reduction sends to a lower element .
The original measure defined for the analysis of -reduction does not directly work for the case of linear reduction, since such a measure does not change along linear reduction (i.e., , when ). Indeed, Gandy’s measure just counts the number of -abstractions erased along a -reduction. However, by taking the successor of the usual interpretation of a variable occurrence, one obtains a new measure which counts the number of variable occurrences replaced by some -term. Such a new measure decreases along linear reduction, and allows to prove at the same time the strong normalisation of all the rewriting systems described in the present papers.
In the following, we shall follow the presentation of Gandy’s proof given by Miquel [7]. Let us interpret the base type as the strict partial order , and every functional type as the strict partial order of the increasing functions from the interpretation of to the interpretation of . Formally, for every type , let us inductively define by
[TABLE]
[TABLE]
with and . We define then the binary operation as
[TABLE]
for and . It is readily seen that , that , and that implies , for every and .
For every type , let us define and by
[TABLE]
for and . By induction, we can see that is increasing (that is, , for all s.t. ).
A valuation is a function associating an element of to every variable . Given a valuation , a variable , and a value , we shall denote by a new valuation s.t. , and , when .
Given a valuation , any typed -term can be interpreted as an element by application of the following inductive definition
[TABLE]
For every valuation , we can also define the measure , by .
Remark 1
The only difference w.r.t. the usual interpretation used in the proof of strong normalisation of -reduction is the interpretation of variables. Indeed, one usually takes (see [7]). With this choice, however, we would get when . □
Lemma 3
For every valuation , every , and every , we have that
; 2. 2.
if , then and .
□
By the previous lemma, and the fact that there is at least a valuation (for instance, the valuation defined by ), we can eventually get the strong normalisation result.
Theorem 2
The rewriting systems , , , , , and are strongly normalising. □
7 Conclusions
In the paper we have analysed linear -reduction in terms of a notion of evaluation context, and we have seen how a simple adaptation of the semantical proof of strong normalisation for the simply typed -calculus allows to prove the same result for the linear case. The proof is surprisingly simple and its idea might be adapted to prove strong normalisations of other -calculi in which the -rule is decomposed in more elementary steps, as for instance in the case of explicit substitution -calculi.
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1]
- 2[2] Beniamino Accattoli (2013): Linear Logic and Strong Normalization . In Femke van Raamsdonk, editor: 24th International Conference on Rewriting Techniques and Applications (RTA 2013) , LIP Ics 21, Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany, pp. 39–54, 10.4230/LIP Ics.RTA.2013.39 . · doi ↗
- 3[3] Beniamino Accattoli & Delia Kesner (2010): The Structural λ 𝜆 \lambda -Calculus . In Anuj Dawar & Helmut Veith, editors: Computer Science Logic , LNCS 6247, Springer Berlin Heidelberg, pp. 381–395, 10.1007/978-3-642-15205-4_30 . · doi ↗
- 4[4] Vincent Danos & Laurent Regnier (2004): Head Linear Reduction . Http://iml.univ-mrs.fr/ regnier/articles/pam.ps.gz.
- 5[5] R. O. Gandy (1980): Proofs of strong normalisation . In J. P. Seldin & J. R. Hindley, editors: To H. B. Curry: Essays in Combinatory Logic, Lambda Calculus, and Formalism , Academic Press, pp. 457–477.
- 6[6] Stefano Guerrini & Giulio Pellitta (2016): Dissecting the PAM . Submitted.
- 7[7] Alexandre Miquel: A combinatorial proof of strong normalisation for the simply typed -calculus . Unpublished draft.
- 8[8] Pierre-Marie Pédrot & Alexis Saurin (2016): Classical By-Need . In Peter Thiemann, editor: Programming Languages and Systems. 25th European Symposium on Programming, ESOP 2016 , LNCS 9632, Springer, pp. 616–643, 10.1007/978-3-662-49498-1_24 . · doi ↗
