scispace - formally typeset
Open AccessProceedings ArticleDOI

Explicit substitutions

Reads0
Chats0
TLDR
The λ&sgr;-calculus is a refinement of the λ-Calculus where substitutions are manipulated explicitly, and provides a setting for studying the theory of substitutions, with pleasant mathematical properties.
Abstract
The ls-calculus is a refinement of the l-calculus where substitutions are manipulated explicitly. The ls-calculus provides a setting for studying the theory of substitutions, with pleasant mathematical properties. It is also a useful bridge between the classical l-calculus and concrete implementations.

read more

Content maybe subject to copyright    Report

Explicit Substitutions
M. Abadi
L. Cardelli
P.-L. Curien
J.-J. L´evy
September 18, 1996
Abstract
The λσ-calculus is a refinement of the λ-calculus where substitu-
tions are manipulated explicitly. The λσ-calculus provides a setting
for studying the theory of s ubstitutions, with pleasant mathematical
properties. It is also a useful bridge between the classical λ-calculus
and concrete implementations.
Digital Equipment Corporation, Systems Research Center.
Ecole Normale Sup´erieure; part of this work was completed while at Digital Equipment
Corporation, Systems Research Center.
INRIA Rocquencourt; part of this work was completed while at Digital Equipment
Corporation, Systems Research Center and Paris Research Laboratory.
1

1 Introduction
Substitution is the ´eminence grise of the λ-calculus. The classical β rule,
(λx.a)b
β
a{b/x}
uses substitution crucially though informally. Here a and b denote two
terms, and a{b/x} represents the term a where all free occurrences of x are
replaced with b. This substitution does not belong in the calculus proper,
but rather in an informal meta-level. Similar situations arise in dealing with
all binding constructs, fr om universal quantifiers to type abstractions.
A naive reading of the β rule suggests that the substitution of b for
x should happen at once, when the rule is applied. In implementations,
substitutions invariably happen in a more controlled way. This is due to
practical considerations, relevant in the implementation of both logics and
programming languages. The term a{b/x} may contain many copies of b
(for instance, if a = xxxx); without sophisticated structure-sharing mecha-
nisms [15], perf orming sub stitutions immediately causes a size exp losion.
Therefore, in practice, substitutions are delayed and explicitly recorded;
the application of s ubstitutions is independent, an d not coupled with th e
β rule. The correspondence between the theory and its implementations
becomes highly nontrivial, and the correctness of the implementations can
be compromised.
In th is paper we study the λσ-calculus, a refinement of the λ-calculus [1]
where substitutions are manipulated explicitly. Substitutions have syntactic
representations, and if a is a term and s is a substitution then the term a[s]
represents a with the substitution s. We can now express a β rule with
delayed su bstitution, called Be ta:
(λx.a)b
Beta
a[(b/x) · id]
where (b/x) · id is syntax for the substitution that replaces x with b and
affects no other variable (“· represents extension and id the identity substi-
tution). Of course, additional rules are needed to distribute the substitution
later on.
The λσ-calculus is a suitable setting for s tudying the theory of substi-
tutions, where we can express and prove desirable mathematical pr operties.
For example, the calculus is Church-Rosser and is a conservative extension
of the λ-calculus. Moreover, the λσ-calculus is strongly connected with the
1

categorical understanding of the λ-calculus, where a substitution is inter-
preted as a composition [5].
We propose the λσ-calculus as a step in closing the gap between the
classical λ-calculus and concrete implementations. The calculus is a vehi-
cle in designing, un derstanding, verifying, and comparing implementations
of the λ-calculus, from interpreters to machines. Other applications are
in the analysis of typechecking algorithms for higher-order languages and,
potentially, in the m echanization of logical systems.
When one considers weak reduction strategies, th e treatment of substi-
tutions can remain quite simple—and then our approach may seem overly
general. Weak reduction strategies do not compute in the scope of λ’s.
Then, there arise neither nested substitutions nor substitutions in the scope
of λ’s. All substitutions are at the top level, as simple environments. An
ancestor of the λσ-calculus, the λρ-calculus, suffices in this setting [5].
However, strong reduction strategies are useful in general, both in log-
ics and in the typechecking of higher-order programming languages. In fact,
strong reduction strategies are useful in all situations where symbolic match-
ing has to be conducted in the scope of binders. Thus, a general treatment
of substitutions is required, where substitutions may occur at the top level
and deep inside terms.
In some respects, the λσ-calculus resembles the calculi of combinators,
including those of categorical combinators [4]. The λσ-calculus and the
combinator calculi all give full formal accounts of the process of computation,
without suffering from unpleasant complications in the (informal) handling
of variables. They all make it easy to derive machines for the λ-calculus
and to show the correctness of these machines. ¿From our perspective, the
advantage of the λσ-calculus over combinator calculi is that it remains closer
to the original λ-calculus.
There are actually several versions of the calculus of substitutions. We
start out by discussing an untyped calculus. The main value of the untyped
calculus is for studying evaluation method s . We give reduction rules that
extend those of the classical λ-calculus and investigate th eir confluence. We
concentrate on a presentation that relies on De Bruijn’s numb ering for vari-
ables [2], and briefly discuss presentations with more traditional variable
names.
Then we proceed to consider typ ed calculi of su bstitutions, in De Bruijn
notation. We discuss typing rules for a first-order system and for a higher-
order system; we prove some of their central properties. The typing rules
2

are meant to s erve in designing typechecking algorithms. In particular, their
study has been of help for both soundness and efficiency in the design of the
Quest typechecking algorithm [3].
We postpone discussion of the untyped calculi to section 3 and of the
typed calculi to sections 4 and 5. We now proceed with a general technical
overview.
2 Overview
The technical details of the λσ-calculus can be quite intricate, and hence a
gentle informal introduction seems in order. We start with a brief review of
De Bruijn notation, since most of our calculi rely on it. Then we preview
untyped, first-order, and second-order calculi of substitutions.
2.1 De Bruijn notation
In De Bruijn notation, variable occurrences are replaced with positive in-
tegers (called De Bruijn indices); binding occurrences of variables become
unnecessary. The positive integer n refers to the variable bound by the n-th
surrounding λ binder, for example:
λx.λy.xy becomes λλ2 1
In first-order typed systems, the binder types must be preserved, for exam-
ple:
λx:A.λy:B.xy becomes λA.λB. 2 1
In second-order systems, typ e variables too are replaced with De Bruijn
indices:
ΛA.λx:A.x becomes Λλ1.1
Although De Bruijn notation is unreadable, it leads to simple formal sys-
tems. Therefore, we use indices in inference rules, but variable names in
examples.
Classical β reduction and substitution must be adapted for De Bruijn
notation. In order to reduce (λa)b, it does not suffice to substitute b into
a in the appropriate places. If there are occurrences of 2, 3, 4, . . . in a,
these become “one off,” since one of the λ binders surroun ding a has been
3

removed. Hence, all the remaining free indices in a must be decremented;
the desired effect is obtained with an infinite substitution:
(λx.a)b
β
a{b/x} becomes (λa)b
β
a{b/1, 1/2, 2/3, . . .}
When p ushing this substitution inside a, we may come across a λ term
(λc){b/1, 1/2, 2/3, . . .}. In th is case, we must be careful to avoid replacing
the occurrences of 1 in c with b, since these occurrences correspond to a
bound variable and the substitution shou ld not affect them. Hence, we
must “shift” the sub stitution. Thus, we may try:
(λc){b/1, 1/2, 2/3, . . .}
?
= λc{1/1, b/2, 2/3, 3/4, . . .}
But this is not yet correct: now b has an additional surroun ding binder, and
we must prevent capture of free indices of b. Suppose b contains the index
1, for example. We do not want the λ of (λc) to capture this index. Hence
we must “lift” all the indices of b:
(λc){b/1, 1/2, 2/3, . . .} = λc{1/1, b{2/1, 3/2, . . .}/2, 2/3, . . .}
This informal introduction to De Bruijn notation should suffice to give
the flavor of things to come.
2.2 An untyped calculus
We shall study a simple set of algebraic operators that perform all these
index manipulations—without . . .’s, even though we treat infinite sub s ti-
tutions that replace all indexes. If s represents the infinite substitution
{a
1
/1, a
2
/2, a
3
/3, . . . }, we write a[s] for a with the substitution s . A term
of the form a[s] is called a closure. The change from { }’s to [ ]’s emph asizes
that the substitution is no longer a meta-level operation.
The syntax of the untyped λσ-calculus is:
Terms a ::= 1 | ab | λa | a[s]
Substitutions s ::= id | | a · s | s t
This syntax corresponds to the index manipulations described in the
previous section, as follows:
id is the identity substitution {1/1, 2/2, . . .}, which we may write
{i/i}.
4

Citations
More filters
Book

Types and Programming Languages

TL;DR: This text provides a comprehensive introduction both to type systems in computer science and to the basic theory of programming languages, with a variety of approaches to modeling the features of object-oriented languages.
Journal ArticleDOI

Conditional rewriting logic as a unified model of concurrency

TL;DR: Maude as discussed by the authors is a programming language whose modules are rewriting logic theories, which is defined and given denotational and operational semantics, and it provides a simple unification of concurrent programming with functional and object-oriented programming and supports high level declarative programming of concurrent systems.
Proceedings ArticleDOI

The chemical abstract machine

TL;DR: A new kind of abstract machine based on the chemical metaphor used in the Γ language of Banâtre & al. is introduced, which shows how to extract a higher-order concurrent λ-calculus out of the basic concepts of the chemical abstract machine.
Journal ArticleDOI

The chemical abstract machine

TL;DR: A new kind of abstract machine based on the chemical metaphor used in the Γ language of Banâtre and Le Metayer is introduced, using the operational semantics of the TCCS and CCS process calculi and of the fragment of Milner, Parrow and Walker's Calculus of Mobile Processes used by Milner to encode the lambda-calculus.
Book

Combinatory reduction systems

TL;DR: This proof is a direct generalization of Aczel's original proof, which is close to the well-known confluence proof for λ-calculus by Tait and Martin-Lof and gives an outline of a short proof of confluence.
References
More filters
Book

The Lambda Calculus. Its Syntax and Semantics

TL;DR: In this article, the Lambda-Calculus has been studied as a theory of composition and reduction, and the theory of reduction has been used to construct models of Lambda Theories.
Book

Intuitionistic type theory

TL;DR: These lectures were given in Padova and Munich later in the same year as part of the meeting on Konstruktive Mengenlehre und Typentheorie which was organized in Munich by Prof. Helmut Schwichtenberg.
Journal ArticleDOI

Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem

TL;DR: In this paper, a notational system for lambda calculus is developed, where occurrences of variables are indicated by integers giving the "distance" to the binding λ instead of a name attached to that λ. This convention is known to cause considerable trouble in cases of substitution.
Book ChapterDOI

Equations and rewrite rules: a survey

TL;DR: The problem of "solving" equations, the problem of proving termination of sets of rewrite rules, and the decidability and complexity of word problems and of combinations of equational theories are discussed.
Book

Combinatory reduction systems

TL;DR: This proof is a direct generalization of Aczel's original proof, which is close to the well-known confluence proof for λ-calculus by Tait and Martin-Lof and gives an outline of a short proof of confluence.
Frequently Asked Questions (15)
Q1. What are the contributions in "Explicit substitutions" ?

The λσ-calculus provides a setting for studying the theory of substitutions, with pleasant mathematical properties. Ecole Normale Supérieure ; part of this work was completed while at Digital Equipment Corporation, Systems Research Center. INRIA Rocquencourt ; part of this work was completed while at Digital Equipment Corporation, Systems Research Center and Paris Research Laboratory. 

If s represents the infinite substitution {a1/1, a2/2, a3/3, . . .}, the authors write a[s] for a with the substitution s. A term of the form a[s] is called a closure. 

In order to typecheck a term a[s], the basic strategy is to analyze simpler and simpler components of a while accumulating more and more complex substitutions in s. 

all the remaining free indices in a must be decremented; the desired effect is obtained with an infinite substitution:(λx.a)b →β a{b/x} becomes (λa)b →β a{b/1, 1/2, 2/3, . . . 

The inference rules = s′ t = t′s ◦ t = s′ ◦ t′can be removed, and the inference rule for the closure operator can be restricted tos = s′1[s] = 1[s′] 

The calculus is a vehicle in designing, understanding, verifying, and comparing implementations of the λ-calculus, from interpreters to machines. 

Other applications are in the analysis of typechecking algorithms for higher-order languages and, potentially, in the mechanization of logical systems. 

¿From their perspective, the advantage of the λσ-calculus over combinator calculi is that it remains closer to the original λ-calculus. 

An alternative (but heavy) solution would be to have separate index sets for ordinary term variables and for type variables, and to manipulate separate term and type environments as well. 

The theory S2 is formulated with equivalence judgments, for example judgments of the form E ` a ∼ b : A. This judgment means that in the environment E the terms a and b both have type A and are equivalent. 

In their setting, weak head normal forms are defined as follows:Definition 3.7 A weak head normal form (whnf for short) is a λσ term of the form λa or na1 · · · am. 

(The precise relation between environment lengths, and substitutions sizes, as defined in section 2, obeys the invariant: if E ` s substp and | s | = (m,n) then p = m + | E | − n ≥ 0.) 

For the typed first-order λσ-calculus, the syntax becomes:Types A ::= K |A → B Environments E ::= nil |A,E Terms a ::= 1 | ab |λA.a | a[s] 

The first-order λσ-calculus has the following syntax:Types A ::= K |A → B Environments E ::= nil |A,E Terms a ::= 1 | ab |λA.a | a[s] 

The rule for application takes this into account; a substitution is applied to B to “unshift” its indices:E ` b : A → B E ` a : AE ` b(a) : B[a:A · id ]The B[a:A · id ] part is reminiscent of the rule found in calculi for dependent types, and this is the correct technique for the version of such calculi with explicit substitutions.