This paper introduces a confluent non-idempotent intersection type system for lambda-calculus that enables unique factorization of derivation spaces into garbage-free and garbage parts, improving understanding of resource usage.
Contribution
It presents a novel confluent intersection type system with proof term syntax, establishing a unique factorization of derivation spaces using a Grothendieck construction.
Findings
01
The system enjoys subject reduction and strong normalization.
02
Derivation spaces can be uniquely factorized into garbage-free and garbage parts.
03
A correspondence with lambda-calculus via simulation theorems is established.
Abstract
In typical non-idempotent intersection type systems, proof normalization is not confluent. In this paper we introduce a confluent non-idempotent intersection type system for the lambda-calculus. Typing derivations are presented using proof term syntax. The system enjoys good properties: subject reduction, strong normalization, and a very regular theory of residuals. A correspondence with the lambda-calculus is established by simulation theorems. The machinery of non-idempotent intersection types allows us to track the usage of resources required to obtain an answer. In particular, it induces a notion of garbage: a computation is garbage if it does not contribute to obtaining an answer. Using these notions, we show that the derivation space of a lambda-term may be factorized using a variant of the Grothendieck construction for semilattices. This means, in particular, that any derivation…
\begin{array}[]{c}{tensy\vbox{\hbox spread0.0pt{\hskip 0.0pt plus 0.0001fil\hbox{\kern 29.48183pt\hbox{$\displaystyle\penalty 1$}}\hskip 0.0pt plus 0.0001fil}\hbox{\hbox{\kern 0.0pt\vrule height=0.25002pt,depth=0.25002pt,width=58.96365pt\hbox{\kern 3.00003pt$\texttt{{var}}$}}}\hbox{\kern 0.0pt\hbox{$\displaystyle x:[\mathcal{A}]\vdash x^{\mathcal{A}}:\mathcal{A}$}}}}\end{array}\hskip 14.22636pt\begin{array}[]{c}{tensy\vbox{\hbox spread0.0pt{\hskip 0.0pt plus 0.0001fil\hbox{$\displaystyle\penalty 1\Gamma\oplus(x:\mathcal{M})\vdash t:\mathcal{B}$}\hskip 0.0pt plus 0.0001fil}\hbox{\hbox{\kern 0.0pt\vrule height=0.25002pt,depth=0.25002pt,width=74.60391pt\hbox{\kern 3.00003pt$\texttt{{lam}}$}}}\hbox{\kern 0.49995pt\hbox{$\displaystyle\Gamma\vdash\lambda^{\ell}x.t:\mathcal{M}\overset{\ell}{\to}\mathcal{B}$}}}}\end{array}
\begin{array}[]{c}{tensy\vbox{\hbox spread0.0pt{\hskip 0.0pt plus 0.0001fil\hbox{\kern 29.48183pt\hbox{$\displaystyle\penalty 1$}}\hskip 0.0pt plus 0.0001fil}\hbox{\hbox{\kern 0.0pt\vrule height=0.25002pt,depth=0.25002pt,width=58.96365pt\hbox{\kern 3.00003pt$\texttt{{var}}$}}}\hbox{\kern 0.0pt\hbox{$\displaystyle x:[\mathcal{A}]\vdash x^{\mathcal{A}}:\mathcal{A}$}}}}\end{array}\hskip 14.22636pt\begin{array}[]{c}{tensy\vbox{\hbox spread0.0pt{\hskip 0.0pt plus 0.0001fil\hbox{$\displaystyle\penalty 1\Gamma\oplus(x:\mathcal{M})\vdash t:\mathcal{B}$}\hskip 0.0pt plus 0.0001fil}\hbox{\hbox{\kern 0.0pt\vrule height=0.25002pt,depth=0.25002pt,width=74.60391pt\hbox{\kern 3.00003pt$\texttt{{lam}}$}}}\hbox{\kern 0.49995pt\hbox{$\displaystyle\Gamma\vdash\lambda^{\ell}x.t:\mathcal{M}\overset{\ell}{\to}\mathcal{B}$}}}}\end{array}
\begin{array}[]{c}{tensy\vbox{\hbox spread0.0pt{\hskip 0.0pt plus 0.0001fil\hbox{$\displaystyle\penalty 1\Gamma\vdash t:[\mathcal{B}_{1},\ldots,\mathcal{B}_{n}]\overset{\ell}{\to}\mathcal{A}\hskip 14.22636pt\left(\Delta_{i}\vdash s_{i}:\mathcal{B}_{i}\right)_{i=1}^{n}$}\hskip 0.0pt plus 0.0001fil}\hbox{\hbox{\kern 0.0pt\vrule height=0.25002pt,depth=0.25002pt,width=156.89214pt\hbox{\kern 3.00003pt$\texttt{{app}}$}}}\hbox{\kern 29.96257pt\hbox{$\displaystyle\Gamma+_{i=1}^{n}\Delta_{i}\vdash t[s_{1},\ldots,s_{n}]:\mathcal{A}$}}}}\end{array}
\begin{array}[]{c}{tensy\vbox{\hbox spread0.0pt{\hskip 0.0pt plus 0.0001fil\hbox{$\displaystyle\penalty 1\Gamma\vdash t:[\mathcal{B}_{1},\ldots,\mathcal{B}_{n}]\overset{\ell}{\to}\mathcal{A}\hskip 14.22636pt\left(\Delta_{i}\vdash s_{i}:\mathcal{B}_{i}\right)_{i=1}^{n}$}\hskip 0.0pt plus 0.0001fil}\hbox{\hbox{\kern 0.0pt\vrule height=0.25002pt,depth=0.25002pt,width=156.89214pt\hbox{\kern 3.00003pt$\texttt{{app}}$}}}\hbox{\kern 29.96257pt\hbox{$\displaystyle\Gamma+_{i=1}^{n}\Delta_{i}\vdash t[s_{1},\ldots,s_{n}]:\mathcal{A}$}}}}\end{array}
\begin{array}[]{rcll}x^{\mathcal{A}}\{x:=[s]\}&\overset{\mathrm{def}}{=}&s\\
y^{\mathcal{A}}\{x:=[]\}&\overset{\mathrm{def}}{=}&y^{\mathcal{A}}&\text{ if $x\neq y$}\\
(\lambda^{\ell}y.u)\{x:=\bar{s}\}&\overset{\mathrm{def}}{=}&\lambda^{\ell}y.u\{x:=\bar{s}\}&\text{ if $x\neq y$ and $y\not\in\mathsf{fv}({\bar{s}})$}\\
u_{0}[u_{j}]_{j=1}^{m}\{x:=\bar{s}\}&\overset{\mathrm{def}}{=}&u_{0}\{x:=\bar{s}_{0}\}[u_{j}\{x:=\bar{s}_{j}\}]_{j=1}^{m}\end{array}
\begin{array}[]{rcll}x^{\mathcal{A}}\{x:=[s]\}&\overset{\mathrm{def}}{=}&s\\
y^{\mathcal{A}}\{x:=[]\}&\overset{\mathrm{def}}{=}&y^{\mathcal{A}}&\text{ if $x\neq y$}\\
(\lambda^{\ell}y.u)\{x:=\bar{s}\}&\overset{\mathrm{def}}{=}&\lambda^{\ell}y.u\{x:=\bar{s}\}&\text{ if $x\neq y$ and $y\not\in\mathsf{fv}({\bar{s}})$}\\
u_{0}[u_{j}]_{j=1}^{m}\{x:=\bar{s}\}&\overset{\mathrm{def}}{=}&u_{0}\{x:=\bar{s}_{0}\}[u_{j}\{x:=\bar{s}_{j}\}]_{j=1}^{m}\end{array}
\begin{array}[]{rcll}\bar{v}_{1}+\bar{v}_{2}&=&(\sum_{i=0}^{n}\bar{u}_{i,1})+(\sum_{i=0}^{n}\bar{u}_{i,2})\\
&\approx&\sum_{i=0}^{n}\bar{u}_{i,1}+\bar{u}_{i,2}\\
&\approx&\sum_{i=0}^{n}\bar{u}_{i}&\text{by {\em i.h.} on each index $i=0..n$}\\
&=&\bar{u}\end{array}
\begin{array}[]{rcll}\bar{v}_{1}+\bar{v}_{2}&=&(\sum_{i=0}^{n}\bar{u}_{i,1})+(\sum_{i=0}^{n}\bar{u}_{i,2})\\
&\approx&\sum_{i=0}^{n}\bar{u}_{i,1}+\bar{u}_{i,2}\\
&\approx&\sum_{i=0}^{n}\bar{u}_{i}&\text{by {\em i.h.} on each index $i=0..n$}\\
&=&\bar{u}\end{array}
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.
Taxonomy
TopicsLogic, programming, and type systems · Logic, Reasoning, and Knowledge · Formal Methods in Verification
Full text
\AtAppendix
11institutetext:
Departamento de Computación, FCEyN, UBA, Argentina
IRIF, Université Paris 7, France
11email: [email protected]
22institutetext: Departamento de Computación, FCEyN, UBA, Argentina
(Extended Version)††thanks: Work partially supported by CONICET.
Pablo Barenbaum
11
Gonzalo Ciruelos
22
Abstract
In typical non-idempotent intersection type systems, proof normalization is not confluent.
In this paper we introduce a confluent non-idempotent intersection type system for the λ-calculus.
Typing derivations are presented using proof term syntax.
The system enjoys good properties: subject reduction, strong normalization,
and a very regular theory of residuals.
A correspondence with the λ-calculus is established by simulation theorems.
The machinery of non-idempotent intersection types allows us to track the usage of
resources required to obtain an answer.
In particular, it induces a notion of garbage: a computation is garbage
if it does not contribute to obtaining an answer.
Using these notions,
we show that the derivation space of a λ-term may be factorized using a
variant of the Grothendieck construction for semilattices.
This means, in particular, that any derivation in the λ-calculus can be
uniquely written as a garbage-free prefix followed by garbage.
Our goal in this paper is attempting to
understand the spaces of computations of programs.
Consider a hypothetical functional programming language
with arithmetic expressions and tuples.
All the possible computations starting from the tuple
(1+1,2∗3+1)
can be arranged to form its “space of computations”:
[TABLE]
In this case, the space of computations is quite easy to understand,
because the subexpressions (1+1) and (2∗3+1) cannot interact with each other.
Indeed, the space of computations of a tuple (A,B) can always be understood as
the product of the spaces of A and B.
In the general case, however, the space of computations of a program may have a
much more complex structure.
For example, it is not easy to characterize the space of computations of a function application f(A).
The difficulty is that f may use the value of A zero, one, or
possibly many times.
The quintessential functional programming language
is the pure λ-calculus.
Computations in the λ-calculus have been thoroughly
studied since its conception in the 1930s.
The well-known theorem by Church and Rosser [10]
states that β-reduction in the λ-calculus is confluent,
which means, in particular, that terminating programs have unique normal forms.
Another result by Curry and Feys [12]
states that computations in the
λ-calculus may be standardized,
meaning that they may be converted into a computation in canonical form.
A refinement of this theorem by Lévy [25]
asserts that the canonical computation thus obtained is equivalent to the
original one in a strong sense, namely that they are permutation equivalent.
In a series of papers [29, 30, 31, 32],
Melliès generalized many of these results to the abstract setting of axiomatic rewrite systems.
Let us discuss “spaces of computations” more precisely.
The derivation space of an object x in some rewriting system
is the set of all derivations, i.e. sequences of rewrite steps, starting from x.
In this paper, we will be interested in the pure λ-calculus,
and we will study finite derivations only.
In the λ-calculus,
a transitive relation between derivations may be defined, the prefix order.
A derivation ρ is a prefix of a derivation σ,
written ρ⊑σ,
whenever ρ performs less computational work than σ.
Formally, ρ⊑σ is defined to hold whenever the projectionρ/σ
is empty111The notion of projection defined by means of residuals
is the standard one, see e.g. [4, Chapter 12]
or [33, Section 8.7]..
For example, if K=λx.λy.x,
the derivation space of the term (λx.xx)(Kz)
can be depicted with the reduction graph below.
Derivations are directed paths in the reduction graph,
and ρ is a prefix of σ if there is a directed path from the
target of ρ to the target of σ.
For instance, SR2 is a prefix of RS′T′:
[TABLE]
Remark that ⊑ is reflexive and transitive but not antisymmetric,
i.e. it is a quasi-order but not an order.
For example RS′⊑SR1R2′⊑RS′
but RS′=SR1R2′.
Antisymmetry may be recovered as usual when in presence of a quasi-order,
by working modulo permutation equivalence:
two derivations ρ and σ
are said to be permutation equivalent,
written ρ≡σ, if ρ⊑σ
and σ⊑ρ.
Working modulo permutation equivalence is reasonable because Lévy’s
formulation of the
standardization theorem ensures that permutation equivalence is decidable.
Derivation spaces are known to exhibit various
regularities [25, 35, 24, 28, 26, 2].
In his PhD thesis, Lévy [25] showed that the derivation space of a term is
an upper semilattice: any two derivations ρ,σ from a term t
have a least upper boundρ⊔σ, defined as ρ(σ/ρ),
unique up to permutation equivalence.
On the other hand, the derivation space of a term t is not an easy structure to understand in general222Problem 2 in
the RTA List of Open Problems [13] poses
the open-ended question of investigating the properties of “spectra”, i.e. derivation spaces..
For example, relating the derivation space of an application ts
with the derivation spaces of t and s appears to be a hard problem.
Lévy also noted that the greatest lower bound of two derivations does
not necessarily exist, meaning that the derivation space of a term does not form a lattice in general.
Even when it forms a lattice, it may not necessarily be a distributive lattice, as observed for example by
Laneve [24].
In [29], Melliès showed that
derivation spaces in any rewriting system satisfying certain axioms
may be factorized using two spaces,
one of external and one of internal derivations.
The difficulty to understand derivation spaces is due to three pervasive phenomena
of interaction between computations.
The first phenomenon is duplication:
in the reduction graph of above, the step S duplicates the step R,
resulting in two copies of R: the steps R1 and R2.
In such situation, one says that R1 and R2 are residuals of R,
and, conversely, R is an ancestor of R1 and R2.
The second phenomenon is erasure:
in the diagram above, the step T erases the step R1′,
resulting in no copies of R1′.
The third phenomenon is creation:
in the diagram above, the step R2 creates the step T,
meaning that T is not a residual of a step that existed prior
to executing R2; that is, T has no ancestor.
These three interaction phenomena, especially duplication and erasure,
are intimately related with the management of resources.
In this work, we aim to explore the hypothesis that having an explicit
representation of resource management may provide insight on
the structure of derivation spaces.
There are many existing λ-calculi that deal with resource management explicitly [6, 15, 20, 21],
most of which draw inspiration from Girard’s Linear Logic [18].
Recently, calculi endowed with
non-idempotent intersection type systems,
have received some attention [14, 5, 7, 8, 19, 34, 22].
These type systems are able to statically capture non-trivial
dynamic properties of terms, particularly normalization,
while at the same time being amenable to elementary proof techniques by induction.
Intersection types were originally proposed by
Coppo and Dezani-Ciancaglini [11]
to study termination in the λ-calculus.
They are characterized by the presence of an intersection type constructor A∩B.
Non-idempotent intersection type systems are distinguished from their usual idempotent
counterparts by the fact that intersection
is not declared to be idempotent, i.e.A and A∩A are not equivalent types.
Rather, intersection behaves like a multiplicative connective in linear logic.
Arguments to functions are typed many times, typically once
per each time that the argument will be used.
Non-idempotent intersection types were originally formulated by
Gardner [17],
and later reintroduced by de Carvalho [9].
In this paper, we will use a non-idempotent intersection type system
based on system W of [8]
(called system H in [7]).
Let us recall its definition.
Terms are as usual in the λ-calculus (t::=x∣λx.t∣tt).
Types A,B,C,… are defined by the grammar:
[TABLE]
where α ranges over one of denumerably many base types,
and M represents a multiset of types.
Here [Ai]i=1n denotes the multiset A1,…,An
with their respective multiplicities.
A multiset [Ai]i=1n intuitively stands for the (non-idempotent) intersection A1∩…∩An.
The sum of multisetsM+N is defined as their union (adding multiplicities).
A typing contextΓ is a partial function mapping variables to multisets of types.
The domain of Γ is the set of variables x such that Γ(x) is defined.
We assume that typing contexts always have finite domain and hence they may be written as
x1:M1,…,xn:Mn.
The sum of contextsΓ+Δ is their pointwise sum,
i.e.(Γ+Δ)(x):=Γ(x)+Δ(x) if Γ(x) and Δ(x) are both defined,
(Γ+Δ)(x):=Γ(x) if Δ(x) is undefined,
and (Γ+Δ)(x):=Δ(x) if Γ(x) is undefined.
We write Γ+i=1nΔi to abbreviate Γ+Δ1+…+Δn.
The disjoint sum of contextsΓ⊕Δ stands for Γ+Δ, provided that
the domains of Γ and Δ are disjoint.
A typing judgment is a triple Γ⊢t:A,
representing the knowledge that the term t has type A in the context Γ.
Type assignment rules for system W are as follows.
Definition 1 (System W)
[TABLE]
Observe that the app rule has n+1 premises, where n≥0.
System W enjoys various properties, nicely summarized in [8].
There are two obstacles to adopting system W for studying derivation spaces.
The first obstacle is mostly a matter of presentation—typing derivations use a tree-like notation,
which is cumbersome. One would like to have an alternative notation based on proof terms.
For example, one may define proof terms for the typing rules above using the
syntax π::=xA∣λx.π∣π[π,…,π],
in such a way that xA encodes an application of the var axiom,
λx.π encodes an application of the lam rule to the typing derivation encoded by π,
and π1[π2,…,πn] encodes an application of the
app rule to the typing derivations encoded by π1,π2,…,πn.
For example, using this notation
λx.x[α,α]→β[xα,xα]
would represent the following typing derivation:
[TABLE]
The second obstacle is a major one for our purposes: proof normalization in this system is not confluent.
The reason is that applications take multiple arguments, and a β-reduction step must choose a way to
distribute these arguments among the occurrences of the formal parameters.
For instance, the following critical pair cannot be closed:
[TABLE]
The remainder of this paper is organized as follows:
•
In Sec. 2, we review some standard notions of order and rewriting theory.
•
In Sec. 3, we introduce a confluent calculus λ# based on system W.
The desirable properties of system W of [8] still hold in λ#.
Moreover, λ# is confluent.
We impose confluence forcibly, by decorating subtrees with distinct labels, so that
a β-reduction step may distribute the arguments in a unique way.
Derivation spaces in λ# have very regular structure,
namely they are distributive lattices.
•
In Sec. 4, we establish a correspondence between derivation spaces in the
λ-calculus and the λ#-calculus via simulation theorems,
which defines a morphism of upper semilattices.
•
In Sec. 5, we introduce the notion of a garbage derivation.
Roughly, a derivation in the λ-calculus is garbage if it maps to
an empty derivation in the λ#-calculus.
This gives rise to an orthogonal notion of garbage-free derivation.
The notion of garbage-free derivation is closely related
with the notions of needed step [33, Section 8.6],
typed occurrence of a redex [8],
and external derivation [29].
Using this notion of garbage we prove a factorization theorem
reminiscent of Melliès’ [29].
The upper semilattice of derivations of a term in the λ-calculus
is factorized using a variant of the Grothendieck construction.
Every derivation is uniquely decomposed as a garbage-free prefix followed by a garbage suffix.
Note. Proofs including a ♣ symbol are spelled out in detail in the appendix.
2 Preliminaries
We recall some standard definitions.
An upper semilattice is a poset (A,≤)
with a least element or bottom⊥∈A,
and such that for every two elements a,b∈A
there is a least upper bound or join(a∨b)∈A.
A lattice is an upper semilattice
with a greatest element or top⊤∈A,
and such that for every two elements a,b∈A
there is a greatest lower bound or meet(a∧b)∈A.
A lattice is distributive if ∧ distributes over ∨ and vice versa.
A morphism of upper semilattices
is given by a monotonic function f:A→B,
i.e.a≤b implies f(a)≤f(b),
preserving the bottom element, i.e.f(⊥)=⊥,
and joins, i.e.f(a∨b)=f(a)∨f(b) for all a,b∈A.
Similarly for morphisms of lattices.
Any poset (A,≤) forms a category whose objects are the elements of A
and morphisms are of the form a↪b for all a≤b.
The category of posets with monotonic functions is denoted by Poset.
In fact, we regard it as a 2-category: given morphisms f,g:A→B of posets,
we have that f≤g whenever f(a)≤g(a) for all a∈A.
An axiomatic rewrite system (cf. [28, Def. 2.1])
is given by a set of objects Obj, a set of steps Stp,
two functions src,tgt:Stp→Obj indicating the source and target of each step,
and a residual function(/) such that given any two steps R,S∈Stp
with the same source, yields a set of steps R/S such that src(R′)=tgt(S)
for all R′∈R/S.
Steps are ranged over by R,S,T,….
A step R′∈R/S is called a residual of R after S,
and R is called an ancestor of R′.
Steps are coinitial (resp. cofinal) if they have the same source (resp. target).
A derivation is a possibly empty sequence of composable steps R1…Rn.
Derivations are ranged over by ρ,σ,τ,….
The functions src and tgt are extended to derivations.
Composition of derivations is defined when tgt(ρ)=src(σ) and written ρσ.
Residuals after a derivation can be defined by
Rn∈R0/S1…Sn
if and only if there exist R1,…,Rn−1
such that Ri+1∈Ri/Si+1 for all 0≤i≤n−1.
Let M be a set of coinitial steps.
A development of M is a (possibly infinite) derivation R1…Rn…
such that for every index i there exists a step S∈M
such that Ri∈S/R1…Ri−1.
A development is complete if it is maximal.
An orthogonal axiomatic rewrite system (cf. [28, Sec. 2.3])
has four additional axioms333In [28],
Autoerasure is called Axiom A, Finite Residuals is called Axiom B, and Semantic Orthogonality is called PERM.
We follow the nomenclature of [1].:
Autoerasure.
R/R=∅ for all R∈Stp.
2. 2.
Finite Residuals.
The set R/S is finite for all coinitial R,S∈Stp.
3. 3.
Finite Developments.
If M is a set of coinitial steps,
all developments of M are finite.
4. 4.
Semantic Orthogonality.
Let R,S∈Stp be coinitial steps.
Then there exist a complete development ρ of R/S
and a complete development σ of S/R
such that ρ and σ are cofinal.
Moreover,
for every step T∈Stp such that T is coinitial to R,
the following equality between sets holds:
T/(Rσ)=T/(Sρ).
In [28], Melliès develops
the theory of orthogonal axiomatic rewrite systems.
A notion of projectionρ/σ may be defined between coinitial derivations,
essentially by setting ϵ/σ=defϵ
and Rρ′/σ=def(R/σ)(ρ′/(σ/R))
where, by abuse of notation, R/σ stands for a (canonical) complete development
of the set R/σ.
Using this notion, one may define
a transitive relation of prefix (ρ⊑σ),
a permutation equivalence relation (ρ≡σ),
and the join of derivations (ρ⊔σ).
Some of their properties are summed up in the figure
below:
Summary of properties of orthogonal axiomatic rewrite systems
[TABLE]
Let [ρ]={σ∣ρ≡σ}
denote the permutation equivalence class of ρ.
In an orthogonal axiomatic rewrite system,
the set D(x)={[ρ]∣src(ρ)=x}
forms an upper semilattice [28, Thm. 2.2,Thm. 2.3].
The order [ρ]⊑[σ] is declared to hold if
ρ⊑σ,
the join is [ρ]⊔[σ]=[ρ⊔σ],
and the bottom is ⊥=[ϵ].
The λ-calculus is an example of an orthogonal axiomatic rewrite system.
Our structures of interest are the semilattices of derivations of the λ-calculus,
written Dλ(t) for any given λ-term t.
As usual, β-reduction in the λ-calculus
is written t→βs
and defined by the contextual closure of the axiom (λx.t)s→βt{x:=s}.
3 The Distributive λ-Calculus
In this section we introduce the
distributive λ-calculus (λ#),
and we prove some basic results.
Terms of the λ#-calculus are typing derivations of a non-idempotent intersection type
system, written using proof term syntax.
The underlying type system is a variant of system W of [7, 8],
the main difference being that λ#
uses labels and a suitable invariant on terms,
to ensure that the formal parameters of all functions
are in 1–1 correspondence with the actual arguments that they receive.
Definition 2 (Syntax of the λ#-calculus)
Let L={ℓ,ℓ′,ℓ′′,…} be a denumerable set of labels.
The set of types is ranged over by A,B,C,…,
and defined inductively as follows:
[TABLE]
where α ranges over one of denumerably many base types,
and M represents a multiset of types.
In a type like αℓ and M→ℓA,
the label ℓ is called the external label.
The typing contexts are defined as in Sec. 1 for system W.
We write domΓ for the domain of Γ.
A type A is said to occur inside another type B,
written A⪯B, if A is a subformula of B.
This is extended to say that a type A occurs in a multiset [B1,…,Bn],
declaring that A⪯[B1,…,Bn] if A⪯Bi for some i=1..n,
and that a type A occurs in a typing context Γ,
declaring that A⪯Γ if A⪯Γ(x) for some x∈domΓ.
The set of
terms,
ranged over by t,s,u,…, is given by the grammar
t::=xA∣λℓx.t∣ttˉ,
where tˉ represents a (possibly empty) finite list of terms.
The notations [xi]i=1n, [x1,…,xn], and xˉ
all stand simultaneously for multisets and for lists of elements.
Note that there is no confusion since we only work with multisets of types,
and with lists of terms.
The concatenation of the lists xˉ,yˉ is denoted by xˉ+yˉ.
A sequence of n lists (xˉ1,…,xˉn) is a partition of xˉ
if xˉ1+…+xˉn is a permutation of xˉ.
The set of free variables of a term t
is written fv(t) and defined as expected.
We also write fv([ti]i=1n) for ∪i=1nfv(ti).
A context is a term C with an occurrence of a distinguished hole□.
We write C⟨t⟩ for the capturing substitution of □ by t.
Typing judgments are triples Γ⊢t:A representing the knowledge
that the term t has type A in the context Γ.
Type assignment rules are:
[TABLE]
[TABLE]
For example
⊢λ1x.x[α2,α3]→4β5[xα3,xα2]:[[α2,α3]→4β5,α2,α3]→1β5
is a derivable judgment (using integer labels).
Remark 1 (Unique typing)
Let Γ⊢t:A and Δ⊢t:B be derivable judgments.
Then Γ=Δ and A=B.
Moreover, the derivation trees coincide.
This can be checked by induction on t.
It means that λ# is an à la Church type system,
that is, types are an intrinsic property of the syntax of terms,
as opposed to an à la Curry type system like W, in which
types are extrinsic properties that a given term might or might not have.
To define a confluent rewriting rule,
we impose a further constraint on the syntax of terms, called correctness.
The λ#-calculus will be defined over the set of correct terms.
Definition 3 (Correct terms)
A multiset of types [A1,…,An] is sequential
if the external labels of Ai and Aj are different for all i=j.
A typing context Γ is sequential if Γ(x) is sequential for every x∈domΓ.
A term t is correct if it is typable and it verifies the following three conditions:
Uniquely labeled lambdas.
If λℓx.s and λℓ′y.u
are subterms of t at different positions, then ℓ and ℓ′
must be different labels.
2. 2.
Sequential contexts.
If s is a subterm of t and Γ⊢s:A
is derivable, then Γ must be sequential.
3. 3.
Sequential types.
If s is a subterm of t,
the judgment Γ⊢s:A is derivable,
and there exists a type such that
(M→ℓB⪯Γ)∨(M→ℓB⪯A),
then M must be sequential.
The set of correct terms is denoted by T#.
For example,
x[α1]→2β3[xα1] is a correct term,
λ1x.λ1y.yα2
is not a correct term since labels for lambdas are not unique,
and
λ1x.xα2→3[β4,β4]→5γ6 is not a correct term
since [β4,β4] is not sequential.
Substitution is defined explicitly below.
If t is typable,
Tx(t)
stands for the multiset
of types of the free occurrences of x in t.
If t1,…,tn are typable,
T([t1,…,tn]) stands for the multiset
of types of t1,…,tn.
For example,
Tx(x[α1]→2β3[xα1])=T([yα1,z[α1]→2β3])=[[α1]→2β3,α1].
To perform a substitution t{x:=[s1,…,sn]}
we will require that Tx(t)=T([s1,…,sn]).
Definition 4 (Substitution)
Let t and s1,…,sn be correct terms such that Tx(t)=T([s1,…,sn]).
The capture-avoiding substitution of x in t by sˉ=[s1,…,sn]
is denoted by t{x:=sˉ} and defined as follows:
[TABLE]
In the last case, (sˉ0,…,sˉm)
is a partition of sˉ
such that Tx(uj)=T(sˉj) for all j=0..m.
Remark 2
Substitution is type-directed: the arguments [s1,…,sn]
are propagated throughout the term
so that si reaches the free occurrence of x
that has the same type as si.
Note that the definition of substitution requires that Tx(t)=T([s1,…,sn]),
which means that the types of the terms s1,…,sn
are in 1–1 correspondence with the types of the free occurrences of x.
Moreover, since t is a correct term,
the multiset Tx(t) is sequential,
which implies in particular that each free occurrence of x has a different type.
Hence there is a unique correspondence matching the free occurrences of x
with the arguments s1,…,sn that respects their types.
As a consequence, in the definition of substitution for an application
u0[uj]j=1m{x:=sˉ}
there is essentially a unique way to split sˉ
into n+1 lists (sˉ0,sˉ1,…,sˉn)
in such a way that Tx(ui)=T(sˉi).
More precisely, if (sˉ0,sˉ1,…,sˉn)
and (uˉ0,uˉ1,…,uˉn)
are two partitions of sˉ with the stated property,
then sˉi is a permutation of uˉi for all i=0..n.
Using this argument, it is easy to check by induction on t
that the value of t{x:=sˉ} is uniquely determined and
does not depend on this choice.
For example,
(x[α1]→2β3[xα1]){x:=[y[α1]→2β3,zα1]}=y[α1]→2β3zα1
while, on the other hand,
(x[α1]→2β3[xα1]){x:=[yα1,z[α1]→2β3]}=z[α1]→2β3yα1.
The operation of substitution preserves term correctness and typability:
Lemma 1 (Subject Reduction)
If C⟨(λℓx.t)sˉ⟩ is a correct term
such that
the judgment Γ⊢C⟨(λℓx.t)sˉ⟩:A
is derivable, then C⟨t{x:=sˉ}⟩ is correct
and Γ⊢C⟨t{x:=sˉ}⟩:A
is derivable.
The λ#-calculus is the rewriting system whose objects
are the set of correct terms T#.
The rewrite relation →# is the closure under arbitrary contexts
of the rule (λℓx.t)sˉ→#t{x:=sˉ}.
Lem. 1 justifies that →# is well-defined, i.e. that
the right-hand side is a correct term.
The label of a step is the label ℓ decorating the contracted lambda.
We write tℓ#s whenever t→#s and the label of
the step is ℓ.
Example 1
Let I3=defλ3x.xα2
and I4=defλ4x.xα2.
The reduction graph of
the term
(λ1x.x[α2]→3α2[xα2])[I3,I4[zα2]] is:
[TABLE]
Note that numbers over arrows are the labels of the steps,
while R,R′,S,... are metalanguage names to refer to the steps.
Next, we state and prove some basic properties of λ#.
Proposition 1 (Strong Normalization)
There is no infinite reduction t0→#t1→#….
Proof
Observe that a reduction step
C⟨(λℓx.t)sˉ⟩→#C⟨t{x:=sˉ}⟩
decreases the number of lambdas in a term by exactly 1,
because substitution is linear, i.e. the term t{x:=[s1,…,sn]}
uses si exactly once for all i=1..n.
Note:
this is an adaptation of [8, Theorem 4.1].
The substitution operator may be extended to work on lists,
by defining
[ti]i=1n{x:=sˉ}=def[ti{x:=sˉi}]i=1n
where (sˉ1,…,sˉn) is a partition of sˉ
such that Tx(ti)=T(sˉi) for all i=1..n.
Lemma 2 (Substitution Lemma)
Let x=y and x∈fv(uˉ).
If (uˉ1,uˉ2) is a partition of uˉ
then
t{x:=sˉ}{y:=uˉ}=t{y:=uˉ1}{x:=sˉ{y:=uˉ2}},
provided that both sides of the equation are defined.
Note: there exists a list uˉ that makes the left-hand side defined
if and only if there exist lists uˉ1,uˉ2 that make the
right-hand side defined.
If t0ℓ1#t1
and t0ℓ2#t2
are different steps, then there exists a term t3∈T# such that
t1ℓ2#t3 and t2ℓ1#t3.
Proof
♣
By exhaustive case analysis of permutation diagrams.
Two representative cases are depicted below.
The proof uses the Substitution Lemma (Lem. 2).
[TABLE]
[TABLE]
As a consequence of
Prop. 2,
reduction is subcommutative,
i.e.(←#∘→#)⊆(→#=∘←#=)
where
←# denotes (→#)−1
and R= denotes the reflexive closure of R.
Moreover, it is well-known that subcommutativity implies confluence,
i.e.(←#∗∘→#∗)⊆(→#∗∘←#∗);
see [33, Prop. 1.1.10] for a proof of this fact.
Proposition 3 (Orthogonality)
λ# is an orthogonal axiomatic rewrite system.
Proof
Let R:t→#s and S:t→#u.
Define the set of residuals R/S as the set of steps starting
on u that have the same label as R.
Note that R/S is empty if R=S,
and it is a singleton if R=S, since terms are correct so their lambdas
are uniquely labeled.
Then it is immediate to observe that axioms Autoerasure and Finite Residuals hold.
The Finite Developments axiom
is a consequence of Strong Normalization (Prop. 1).
The Semantic Orthogonality axiom is a consequence of Permutation (Prop. 2).
For instance, in the reduction graph of Ex. 1,
ST/RS′=T′,
S⊔R=SR′,
and SR′T′≡RS′T′.
Observe that in Ex. 1 there is no
duplication or erasure of steps. This is a general phenomenon.
Indeed, Permutation (Prop. 2) ensures that all
non-trivial permutation diagrams are closed with exactly one step on each side.
Let us write D#(t) for the set of derivations of t in the λ#-calculus,
modulo permutation equivalence.
As a consequence of
Orthogonality (Prop. 3)
and axiomatic results [28],
the set D#(t) is an upper semilattice.
Actually, we show that moreover the space D#(t)
is a distributive lattice.
To prove this, let us start by mentioning
the property that we call Full Stability.
This is a strong version of stability in the sense of Lévy [26].
It means that steps are created in an essentially unique way.
In what follows, we write lab(R) for the label of a step,
and labs(R1…Rn)={lab(Ri)∣1≤i≤n} for the set of
labels of a derivation.
Lemma 3 (Full Stability)
Let ρ,σ be coinitial derivations
with disjoint labels, i.e.labs(ρ)∩labs(σ)=∅.
Let T1,T2,T3 be steps such that
T3=T1/(σ/ρ)=T2/(ρ/σ).
Then there is a step T0 such that T1=T0/ρ
and T2=T0/σ.
Proof
♣
The proof is easily reduced to a Basic Stability result:
a particular case of Full Stability when ρ and σ
consist of single steps.
Basic Stability is proved by exhaustive case analysis.
Proposition 4
D#(t) is a lattice.
Proof
♣
The missing components are the top and the meet.
The top element is given by ⊤:=[ρ] where ρ:t→#∗s
is a derivation to normal form, which exists by Strong Normalization (Prop. 1).
The meet of {[ρ],[σ]} is constructed using
Full Stability (Lem. 15).
If labs(ρ)∩labs(σ)=∅,
define (ρ⊓σ):=ϵ.
Otherwise, the stability result ensures that there is a step
R coinitial to ρ and σ
such that lab(R)∈labs(ρ)∩labs(σ).
Let R be one such step,
and, recursively, define
(ρ⊓σ):=R((ρ/R)⊓(σ/R)).
It can be checked that recursion terminates,
because labs(ρ/R)⊂labs(ρ) is a strict
inclusion.
Moreover, ρ⊓σ
is the greatest lower bound of {ρ,σ},
up to permutation equivalence.
For instance, in Ex. 1
we have that
ST⊓R=ϵ,
ST⊓RS′=S,
and ST⊓RS′T′=ST.
Proposition 5
There is a monomorphism of lattices D#(t)→P(X)
for some set X.
The lattice (P(X),⊆,∅,∪,X,∩) consists of the subsets of X, ordered by inclusion.
Proof
♣
The morphism is the function labs, mapping each derivation to its set of labels.
This means that a derivation in λ# is characterized, up to permutation equivalence,
by the set of labels of its steps.
Since P(X) is a distributive lattice, in particular we have:
Corollary 1
D#(t) is a distributive lattice.
4 Simulation of the λ-Calculus in the λ#-Calculus
In this section we establish a precise relationship between derivations in
the λ-calculus and derivations in λ#.
To begin, we need a way to relate λ-terms and correct terms (T#):
Definition 6 (Refinement)
A correct term t′∈T#refines a λ-term t,
written t′⋉t, according to the following inductive definition:
[TABLE]
A λ-term may have many refinements.
For example, the following terms refine (λx.xx)y:
[TABLE]
[TABLE]
The refinement relation establishes a relation of simulation between the λ-calculus and λ#.
Proposition 6 (Simulation)
Let t′⋉t. Then:
If t→βs, there exists s′
such that t′→#∗s′
and s′⋉s.
2. 2.
If t′→#s′, there exist s and s′′
such that
t→βs,
s′→#∗s′′,
and s′′⋉s.
Proof
♣
By case analysis. The proof is constructive.
Moreover, in item 1,
the derivation t′→#∗s′ is shown to be a multistep, i.e. the complete
development of a set {R1,…,Rn}.
The following example illustrates that a β-step in the λ-calculus may be simulated by zero,
one, or possibly many steps in λ#, depending on the refinement chosen.
Example 2
The following are simulations of the step x((λx.x)y)→βxy
using →#-steps:
[TABLE]
[TABLE]
The next result relates typability and normalization.
This is an adaptation of existing results from
non-idempotent intersection types, e.g. [8, Lemma 5.1].
Recall that a
head normal form is a term of the form
λx1.…λxn.yt1…tm.
Proposition 7 (Typability characterizes head normalization)
The following are equivalent:
There exists t′∈T# such that t′⋉t.
2. 2.
There exists a head normal form s such that t→β∗s.
Proof
♣
The implication (1⟹2)
relies on Simulation (Prop. 6).
The implication (2⟹1)
relies on the fact that head normal forms are typable,
plus an auxiliary result of Subject Expansion.
The first item of Simulation (Prop. 6)
ensures that every step t→βs can be simulated
in λ# starting from a term t′⋉t.
Actually, a finer relationship can be established between the
derivation spaces Dλ(t) and D#(t′).
For this, we introduce the notion of simulation residual.
Definition 7 (Simulation residuals)
Let t′⋉t and let R:t→βs be a step.
The constructive proof of Simulation (Prop. 6)
associates the →β-step R to a possibly empty set of →#-steps
{R1,…,Rn} all of which start from t′.
We write R/t′=def{R1,…,Rn},
and we call R1,…,Rn the simulation residuals of R after t′.
All the complete developments of R/t′ have a common target,
which we denote by t′/R,
called the simulation residual of t′ after R.
Recall that, by abuse of notation, R/t′ stands
for some complete development of the set R/t′.
By Simulation (Prop. 6),
the following diagram always holds given t′⋉t→βs:
If t′⋉t and ρ:t→β∗s is a derivation,
then ρ/t′ and t′/ρ are defined as follows by induction on ρ:
[TABLE]
It is then easy to check that ρ/t′:t′→#∗t′/ρ and t′/ρ⋉s, by induction on ρ.
Moreover, simulation residuals are well-defined modulo permutation equivalence:
Proposition 8 (Compatibility)
If ρ≡σ
and t⋉src(ρ)
then
ρ/t≡σ/t
and t/ρ=t/σ.
Proof
♣
By case analysis,
studying how permutation diagrams in the λ-calculus
are transported to permutation diagrams in λ#
via simulation.
The following result resembles the usual Cube Lemma [4, Lemma 12.2.6]:
Lemma 4 (Cube)
If t⋉src(ρ)=src(σ), then (ρ/σ)/(t/σ)≡(ρ/t)/(σ/t).
Proof
♣
By induction on ρ and σ,
relying on an auxiliary result, the Basic Cube Lemma,
when ρ and σ are single steps,
proved by exhaustive case analysis.
As a result,
(ρ⊔σ)/t=ρ(σ/ρ)/t=(ρ/t)((σ/ρ)/(t/ρ))≡(ρ/t)((σ/t)/(σ/ρ))=(ρ/t)⊔(σ/t).
Moreover, if ρ⊑σ
then ρτ≡σ for some τ.
So we have that ρ/t⊑(ρ/t)(τ/(t/ρ))=ρτ/t≡σ/t
by Compatibility (Prop. 8).
Hence we may formulate a stronger simulation result:
Corollary 2 (Algebraic Simulation)
Let t′⋉t.
Then the mapping Dλ(t)→D#(t′)
given by [ρ]↦[ρ/t′] is a morphism of upper
semilattices.
Example 4
Let I=λx.x
and Δ=(λ5x.xα2)[zα2]
and let y^=y[α2]→3[]→4β5.
The refinement t′:=(λ1x.y^[xα2][])[Δ]⋉(λx.yxx)(Iz)
induces a morphism between the upper semilattices represented by the following reduction graphs:
[TABLE]
For example
(R1⊔S)/t′=(R1S11S22)/t′=R1′S1′=R1′⊔S′=R1/t′⊔S/t′.
Note that the step S22 is erased by the simulation: S22/(y^[zα2][])=∅.
Intuitively, S22 is “garbage” with respect to the refinement y^[zα2][],
because it lies inside an untyped argument.
5 Factoring Derivation Spaces
In this section we prove that the upper semilattice Dλ(t)
may be factorized using a variant of the Grothendieck construction.
We start by formally defining the notion of garbage.
Definition 9 (Garbage)
Let t′⋉t.
A derivation ρ:t→β∗s is t′-garbage
if ρ/t′=ϵ.
The informal idea is that each refinement t′⋉t
specifies that some subterms of t are “useless”.
A subterm u is useless if it lies inside the argument
of an application s(...u...)
in such a way that the argument is not typed, i.e. the refinement is
of the form s′[]⋉s(...u...).
A single step R is t′-garbage if the pattern of the contracted
redex lies inside a useless subterm.
A sequence of steps R1R2…Rn
is t′-garbage if R1 is t′-garbage,
R2 is (t′/R1)-garbage,
…,
Ri is (t′/R1…Ri−1)-garbage,
…,
and so on.
Usually we say that ρ is just garbage, when t′ is clear from the context.
For instance, in Ex. 4,
S21 is garbage, since S21/(y^[Δ][])=ϵ.
Similarly, S22 is garbage, since S22/(y^[zα2][])=ϵ.
On the other hand, R1S21 is not garbage, since
R1S21/((λ1x.y^[xα2][])[Δ])=R1′=ϵ.
For each t′⋉t, the set of t′-garbage derivations forms an ideal of the upper semilattice Dλ(t).
More precisely:
Proposition 9 (Properties of garbage)
Let t′⋉t. Then:
If ρ is t′-garbage and σ⊑ρ, then σ is t′-garbage.
2. 2.
The composition ρσ is t′-garbage if and only if ρ is t′-garbage and σ is (t′/ρ)-garbage.
3. 3.
If ρ is t′-garbage then ρ/σ is (t′/σ)-garbage.
4. 4.
The join ρ⊔σ is t′-garbage if and only if ρ and σ are t′-garbage.
Our aim is to show that given ρ:t→β∗s and t′⋉t,
there is a unique way of decomposing ρ as στ,
where τ is t′-garbage and σ “has no t′-garbage”.
Garbage is well-defined modulo permutation equivalence,
i.e. given ρ≡σ, we have that ρ is garbage if and only if σ is garbage.
In contrast, it is not immediate to give a well-defined notion of “having no garbage”.
For example, in Ex. 4,
SR2 has no garbage steps, so it appears to have no garbage;
however, it is permutation equivalent to R1S11S22, which
does contain a garbage step (S22).
The following definition seems to capture the right notion of having no garbage:
Definition 10 (Garbage-free derivation)
Let t′⋉t. A derivation ρ:t→β∗s
is t′-garbage-free if
for any derivation σ
such that σ⊑ρ
and ρ/σ is (t′/σ)-garbage,
then ρ/σ=ϵ.
Again, we omit the t′ if clear from the context.
Going back to Ex. 4,
the derivation SR2 is not garbage-free,
because R1S11⊑SR2
and SR2/R1S11=S22 is garbage but non-empty.
Note that Def. 10
is defined in terms of the prefix order (⊑), so:
Remark 3
If ρ≡σ,
then ρ is t′-garbage-free if and only if σ is t′-garbage-free.
Next, we define an effective procedure (sieving)
to erase all the garbage from a derivation.
The idea is that if ρ:t→β⋆s is a derivation
in the λ-calculus and t′⋉t is any refinement,
we may constructively build a t′-garbage-free derivation (ρ⇓t′):t→β⋆u
by erasing all the t′-garbage from ρ.
Our goal will then be to show that ρ≡(ρ⇓t′)σ
where σ is garbage.
Definition 11 (Sieving)
Let t′⋉t and ρ:t→β⋆s.
A step R is coarse for (ρ,t′) if
R⊑ρ and R/t′=∅.
The sieve of ρ with respect to t′,
written ρ⇓t′,
is defined as follows.
•
If there are no coarse steps for (ρ,t′),
then (ρ⇓t′)=defϵ.
•
If there is a coarse step for (ρ,t′),
then (ρ⇓t′)=defR0((ρ/R0)⇓(t′/R0))
where R0 is the leftmost such step.
Lemma 5
The sieving operation ρ⇓t′ is well-defined.
Proof
♣
To see that recursion terminates, consider the measure M given by M(ρ,t′):=#labs(ρ/t′), and note that M(ρ,t′)>M(ρ/R0,t′/R0).
For example, in Ex. 4,
we have that
S⇓t′=S
and
SR2⇓t′=R1S11.
Proposition 10 (Properties of sieving)
Let t′⋉t and ρ:t→β∗s. Then:
ρ⇓t′ is t′-garbage-free and ρ⇓t′⊑ρ.
2. 2.
ρ/(ρ⇓t′) is (t′/(ρ⇓t′))-garbage.
3. 3.
ρ is t′-garbage if and only if ρ⇓t′=ϵ.
4. 4.
ρ is t′-garbage-free if and only if ρ⇓t′≡ρ.
Proof
♣
By induction on the length of ρ⇓t′, using various technical lemmas.
As a consequence of the definition of the sieving construction and its properties,
given any derivation ρ:t→β∗s
and any refinement t′⋉t,
we can always write ρ, modulo permutation equivalence, as of the form
ρ≡στ
in such a way that σ is garbage-free and τ is garbage.
To prove this take σ:=ρ⇓t′
and τ:=ρ/(ρ⇓t′),
and note that σ is garbage-free by item 1. of Prop. 10,
τ is garbage by item 2. of Prop. 10,
and ρ≡σ(ρ/σ)=στ
because σ⊑ρ by item 1. of Prop. 10.
In the following we give a stronger version of this result.
The Factorization theorem below (Thm. 5.1)
states that this decomposition is actually an isomorphism of upper semilattices.
This means, on one hand, that given any derivation ρ:t→β∗s
and any refinement t′⋉t
there is a unique way to factor ρ as of the form
ρ≡στ where σ is garbage-free
and τ is garbage.
On the other hand, it means that the decomposition
ρ↦(ρ⇓t′,ρ/(ρ⇓t′))
mapping each derivation to a of a garbage-free plus a garbage derivation
is functorial.
This means, essentially, that the set of pairs (σ,τ) such that σ is garbage-free
and τ is garbage can be given the structure of an upper semilattice
in such a way that:
•
If ρ↦(σ,τ)
and ρ′↦(σ′,τ′)
then ρ⊑ρ′⟺(σ,τ)≤(σ′,τ′).
•
If ρ↦(σ,τ)
and ρ′↦(σ′,τ′)
then (ρ⊔ρ′)↦(σ,τ)∨(σ′,τ′).
The upper semilattice structure of the set of pairs (σ,τ)
is given using a variant of the Grothendieck construction:
Definition 12 (Grothendieck construction for partially ordered sets)
Let A be a poset, and let B:A→Poset be a mapping associating
each object a∈A to a poset B(a).
Suppose moreover that B is a lax 2-functor.
More precisely, for each a≤b in A,
the function B(a↪b):B(a)→B(b)
is monotonic and such that:
B(a↪a)=idB(a) for all a∈A,
2. 2.
B((b↪c)∘(a↪b))≤B(b↪c)∘B(a↪b) for all a≤b≤c in A.
The Grothendieck construction∫AB
is defined as the poset
given by the set of objects
{(a,b)∣a∈A,b∈B(a)}
and such that (a,b)≤(a′,b′)
is declared to hold if and only if A≤a′ and B(a↪a′)(b)≤b′.
The following proposition states that garbage-free derivations form a finite lattice,
while garbage derivations form an upper semilattice.
Proposition 11 (Garbage-free and garbage semilattices)
Let t′⋉t.
The set
F=\{{[\rho]}\ |\ \mathsf{src}(\rho)=t\text{ and }\rho\text{ is t^{\prime}-garbage-free}\}
of t′-garbage-free derivations forms a finite lattice
F(t′,t)=(F,⊴,⊥,▽,⊤,△), with:
•
Partial order:{[\rho]}\unlhd{[\sigma]}\overset{\mathrm{def}}{\iff}\rho/\sigma\text{ is (t^{\prime}/\sigma)-garbage}.
•
Bottom:⊥:=[ϵ].
•
Join:[ρ]▽[σ]=def[(ρ⊔σ)⇓t′].
•
Top:⊤, defined as the join of all the [τ] such that τ is t′-garbage-free.
•
Meet:[ρ]△[σ],
defined as the join of all the [τ] such that [τ]⊴[ρ] and [τ]⊴[σ].
2. 2.
The set G=\{{[\rho]}\ |\ \mathsf{src}(\rho)=t\text{ and }\rho\text{ is t^{\prime}-garbage}\}
of t′-garbage derivations forms an upper semilattice G(t′,t)=(G,⊑,⊥,⊔),
with the structure inherited from Dλ(t).
Proof
♣
The proof relies on the properties of garbage and sieving (Prop. 9, Prop. 10).
Suppose that t′⋉t,
and let F=defF(t′,t) denote the lattice
of t′-garbage-free derivations.
Let G:F→Poset be the lax 2-functor
G([ρ])=defG(t′/ρ,tgt(ρ))
with the following action on morphisms:
[TABLE]
Using the previous proposition (Prop. 11)
it can be checked that G is indeed a lax 2-functor, and that
the Grothendieck construction ∫FG forms an upper semilattice. The join is given by
(a,b)∨(a′,b′)=(a▽a′,G(a↪a▽a′)(b)⊔G(a′↪a▽a′)(b′)).
Finally we can state the main theorem:
Theorem 5.1 (Factorization)
The following maps form an isomorphism of upper semilattices:
[TABLE]
Proof
♣
The proof consists in checking that both maps are morphisms of upper semilattices and
that they are mutual inverses, resorting to Prop. 9 and Prop. 10.
Example 5
Let t=(λx.yxx)(Iz)
and t′ be as in Ex. 4.
The upper semilattice Dλ(t) can be factorized as ∫FG
as follows. Here posets are represented by their Hasse diagrams:
[TABLE]
For example ([S],[ϵ])≤([R1S11],[S22])
because [S]⊴[R1S11], that is,
S/R1S11=S22 is garbage,
and
G([S]↪[R1S11])([ϵ])=[S/R1S11]=[S22]⊑[S22].
6 Conclusions
We have defined a calculus (λ#) based on
non-idempotent intersection types.
Its syntax and semantics are complex due to the presence of an admittedly ad hoc correctness invariant for terms,
enforced so that reduction is confluent.
In contrast, derivation spaces in this calculus turn out to be very simple structures:
they are representable as rings of sets (Prop. 5)
and as a consequence they are distributive lattices (Coro. 1).
Derivation spaces in the λ-calculus can be mapped to these
much simpler spaces using a strong notion of simulation (Coro. 2)
inspired by residual theory. Building on this, we showed how the derivation space of any typable λ-term
may be factorized as a “twisted product” of garbage-free and garbage derivations (Thm. 5.1).
We believe that this validates the (soft) hypothesis
that explicitly representing resource management can provide insight on the structure
of derivation spaces.
Related work.
The Factorization theorem (Thm. 5.1) is reminiscent
of Melliès’ abstract factorization result [29].
Given an axiomatic rewriting system fulfilling a number of axioms,
Melliès proves that every derivation can be uniquely
factorized as an external prefix followed by an internal suffix.
We conjecture that each refinement t′⋉t should provide
an instantiation of Melliès’ axioms, in such a way that our
t′-garbage-free/t′-garbage factorization coincides with his external/internal
factorization.
Melliès notes that any evaluation strategy that always selects external steps
is hypernormalizing. A similar result should hold for evaluation strategies that
always select non-garbage steps.
The notion of garbage-free derivation is closely related with the
notion of X-neededness [3].
A step R is X-needed
if every reduction to a term t∈X contracts a residual of R.
Recently, Kesner et al. [22] have related
typability in a non-idempotent intersection type system V
and weak-head neededness.
Using similar techniques, it should be possible to prove that
t′-garbage-free steps are X-needed,
where X={s∣s′⋉s}
and s′ is the →#-normal form of t′.
There are several resource calculi in the literature
which perhaps could play a similar role as λ# to recover factorization results akin to Thm. 5.1.
Kfoury [23] embeds the λ-calculus
in a linearλ-calculus that has no duplication nor erasure.
Ehrard and Regnier prove that the Taylor expansion of λ-terms [16]
commutes with normalization, similarly as in Algebraic Simulation (Coro. 2).
Mazza et al. [27] study a general framework for polyadic approximations,
corresponding roughly to the notion of refinement in this paper.
Acknowledgements.
To Eduardo Bonelli and Delia Kesner for introducing the first author to these topics.
To Luis Scoccola and the anonymous reviewers for helpful suggestions.
Appendix 0.A Appendix
This technical appendix includes the detailed proofs of the results stated in the main body
of the paper that have been marked with the ♣ symbol.
We are to prove that
if C⟨(λℓx.t)sˉ⟩ is correct
then C⟨t{x:=sˉ}⟩ is correct,
and, moreover, that their unique typings are under the same typing context
and have the same type.
We need a few auxiliary results:
Lemma 6
If sˉ is a permutation of uˉ, then t{x:=sˉ}=t{x:=uˉ}.
Proof
By induction on t.
Lemma 7
If t is correct, then any subterm of t is correct.
Proof
Note, by definition of correctness (Def. 3),
that if t is a correct abstraction t=λℓx.s then s is correct,
and if t is a correct application t=s[u1,…,un]
then s and u1,…,un are correct.
This allows us to conclude by induction on t.
Lemma 8 (Relevance)
If Γ⊢t:A
and x∈domΓ then x∈fv(t).
Proof
By induction on t.
Definition 13
Λ(t) stands for the multiset of labels decorating the lambdas of t:
[TABLE]
For example, Λ((λ1x.x[α2]→3α2)[λ3x.xα2])=[1,3].
Lemma 9
Let t,s1,…,sn be correct terms.
Then
Λ(t{x:=[si]i=1n})=Λ(t)+i=1nΛ(si).
Proof
By induction on t.
To prove Lem. 1, we first show that substitution preserves typing,
and then that it preserves correctness.
0.A.1.1 Substitution preserves typing
More precisely, let us show that
if Γ⊢C⟨(λℓx.t)sˉ⟩:A is derivable,
then Γ⊢C⟨t{x:=sˉ}⟩:A is derivable.
By induction on the context C.
Empty, C=□.
By induction on t.
1.1
Variable (same), t=xA, sˉ=[s].
We have that x:[A]⊢xA:A
and Δ⊢s:B are derivable,
so we are done.
2. 1.2
Variable (different), t=yA, y=x, sˉ=[].
We have that y:[A]⊢yA:A is derivable, so we are done.
3. 1.3
Abstraction, t=λℓy.u.
Let Γ⊕x:[Bi]i=1n⊢λℓx.u:M→ℓA
be derivable
and Δi⊢si:Bi be derivable for all i=1..n.
By inversion of the lam rule,
we have that Γ⊕y:M⊕x:[Bi]i=1n⊢u:A
is derivable, so by i.h.(Γ⊕y:M)+i=1nΔi⊢u{x:=[si]i=1n}:A is derivable.
Observe that y∈fv(si) so y∈domΔi by Lem. 8.
Hence the previous judgment can be written as
(Γ+i=1nΔi)⊕y:M⊢u{x:=[si]i=1n}:A.
Applying the lam rule we obtain
Γ+i=1nΔi⊢λℓy.u{x:=[si]i=1n}:M→ℓA
as required.
4. 1.4
Application, t=u[rj]j=1m.
Let Γ⊕x:[Bi]i=1n⊢u[rj]j=1m:A
be derivable
and Δi⊢si:Bi be derivable for all i=1..n.
By inversion of the app rule,
the multiset of types [Bi]i=1n
may be partitioned as [Bi]i=1n=∑j=0mMj,
and
the typing context Γ
may be partitioned as Γ=∑j=0mΓj
in such a way that
Γ0⊕x:M0⊢u:[Cj]j=1m→ℓA
is derivable
and
Γj⊕x:Mj⊢rj:Cj is derivable for all j=1..m.
Consider a partition (sˉ0,…,sˉj)
of the list sˉ
such that for every j=0..m we have T(sˉj)=Mj.
Observe that this partition exists since T(sˉ0+…+sˉj)=T(sˉ)=∑j=0mMj=[Bi]i=1n=Tx(t).
Moreover, let Θj=∑i:si∈sˉjΔi for all j=0..m.
By i.h. we have that
Γ0+Θ0⊢u{x:=sˉ0}:[Cj]j=1m→ℓA
is derivable
and
Γj+Θj⊢rj{x:=sˉj}:Cj
is derivable for all j=1..m.
Applying the app rule we obtain
that
∑j=0mΓj+∑j=0mΘj⊢u[rj]{x:=∑j=0msˉj}:A
is derivable.
By definition of
Γ0,…,Γm and
Θ0,…,Θm
this judgment equals
Γ+i=1nΔi⊢u[rj]{x:=∑j=0msˉj}:A.
By definition of sˉ0,…,sˉm
and Lem. 6
this in turn equals
Γ+i=1nΔi⊢u[rj]{x:=sˉ}:A,
as required.
2. 2.
Under an abstraction, C=λℓ′y.C′.
Straightforward by i.h..
3. 3.
Left of an application, C=C′uˉ.
Straightforward by i.h..
4. 4.
Right of an application, C=u[rˉ1,C′,rˉ2].
Straightforward by i.h..
0.A.1.2 Substitution preserves correctness
More precisely, let us show that
if C⟨(λℓx.t)sˉ⟩ is correct
then C⟨t{x:=sˉ}⟩ is correct.
By induction on C:
Empty, C=□.
Let sˉ=[s1,…,sn].
Observe that if (λℓx.t)[s1,…,sn] is correct then:
•
[c1] Γ⊕x:[Bi]i=1n⊢t:A and Δi⊢si:Bi are derivable for all i=1..n,
•
[c2] t,s1,…,sn are correct,
•
[c3] there are no free occurrences of x among s1,…,sn,
•
[c4] all the lambdas occurring in t,s1,…,sn have pairwise distinct labels,
•
[c5] Γ+i=1nΔi is a sequential context.
Condition [c1] holds by inversion of the typing rules,
condition [c2] holds by Lem. 7,
condition [c3] holds by Barendregt’s convention,
and conditions [c4] and [c5] hold because the source term is supposed to be correct.
By induction on t, we check that
if (λℓx.t)[s1,…,sn]
is correct, then
t{x:=sˉ} is correct.
1.1
Variable (same), t=xA, sˉ=[s].
Note that t{x:=sˉ}=s. Conclude by [c2].
2. 1.2
Variable (different), t=yA, sˉ=[] with x=y.
Note that t{x:=sˉ}=yA.
Conclude by [c2].
3. 1.3
Abstraction, t=λℓ′y.u.
Then A=M→ℓ′C and
by inversion Γ⊕y:M⊢u:C is derivable.
Note that (λℓx.u)sˉ is correct,
so by i.h.u{x:=sˉ} is correct.
The variable y does not occur free in sˉ,
so (Γ⊕y:M)+i=1nΔi=(Γ+i=1nΔi)⊕(y:M).
Let us check that λℓ′y.u{x:=sˉ} is correct:
1.3.1
Uniquely labeled lambdas.
Let ℓ1 and ℓ2 be two labels decorating different lambdas of
λℓ′y.u{x:=sˉ},
and let us show that ℓ1=ℓ2.
There are two subcases, depending on whether one of the labels
decorates the outermost lambda:
1.3.1.1
If ℓ1 or ℓ2 decorates the outermost lambda.
Suppose without loss of generality that ℓ1=ℓ′ is the label decorating the outermost lambda.
Then by Lem. 9,
there are two cases: either ℓ2 decorates a lambda of u,
or ℓ2 decorates a lambda of some term in the list sˉ.
If ℓ2 decorates a lambda of u, then ℓ1=ℓ2
since we knew that λℓ′y.u was a correct term by [c2].
If ℓ2 decorates a lambda of some term in the list sˉ, then ℓ1=ℓ2
by condition [c4].
2. 1.3.1.2
If ℓ1 and ℓ2 do not decorate the outermost lambda.
Then ℓ1 and ℓ2 decorate different lambdas of the term u{x:=sˉ},
and we conclude by i.h..
2. 1.3.2
Sequential contexts.
Let t′ be a subterm of λℓ′x.u{x:=sˉ}.
If t′ is a subterm of u{x:=sˉ}, we conclude by i.h..
Otherwise t′ is the whole term and the context is Γ+i=1nΔi,
which is sequential by hypothesis [c5].
3. 1.3.3
Sequential types.
Let t′ be a subterm of λℓ′x.u{x:=sˉ}.
If t′ is a subterm of u{x:=sˉ}, we conclude by i.h..
Otherwise t′ is the whole term. Then Γ+i=1nΔi⊢t′:A is derivable,
since we have already shown that substitution preserves typing.
Let N→ℓ′′D be
a type such that N→ℓ′′D⪯Γ+i=1nΔi or N→ℓ′′D⪯A,
and let us show that N is sequential.
In the first case, i.e. if N→ℓ′′D⪯Γ+i=1nΔi holds,
then either N→ℓ′′D⪯Γ or N→ℓ′′D⪯Δi for some i=1..n,
and we have that N is sequential because all the terms t,s1,…,sn are correct by [c2].
In the second case, i.e. if N→ℓ′′D⪯A holds,
then we have that N is sequential because t is correct by [c2].
4. 1.4
Application, t=urˉ.
Let rˉ=[r1,…,rm].
Note that (λℓx.u)sˉ0 is correct
and (λℓx.rj)sˉj is correct for all j=1..m,
which means that we may apply the i.h. in all these cases.
Let us show that u[rj]j=1m{x:=sˉ} is correct:
1.4.1
Uniquely labeled lambdas.
Let ℓ1 and ℓ2 be two labels decorating different lambdas of
u[rj]j=1m{x:=sˉ}, and let us show that ℓ1=ℓ2.
Observe that the term
u[rj]j=1m{x:=sˉ}=u{x:=sˉ0}[rj{x:=sˉj}]j=1m
has m+1 immediate subterms, namely
u{x:=sˉ0}
and rj{x:=sˉj} for each j=1..m.
We consider two subcases, depending on whether ℓ1 and ℓ2
decorate two lambdas in the same immediate subterm or in different immediate subterms.
1.4.1.1
The labels ℓ1 and ℓ2 decorate the same immediate subterm.
That is, ℓ1 and ℓ2 both decorate lambdas in u{x:=sˉ0}
or both decorate lambdas in some rj{x:=sˉj} for some j=1..m.
Then we conclude, since both u{x:=sˉ0} and
the rj{x:=sˉj} are correct by i.h..
2. 1.4.1.2
The labels ℓ1 and ℓ2 decorate different subterms.
Let r0:=u.
Then we have that
ℓ1 decorates a lambda in rj{x:=sˉj} for some j=0..m
and
ℓ2 decorates a lambda in rk{x:=sˉk} for some k=0..m, j=k.
By Lem. 9,
ℓ1 decorates a lambda in rj or a lambda in a term of the list sˉj,
and similarly
ℓ2 decorates a lambda in rk or a lambda in a term of the list sˉk.
This leaves four possibilities, which are all consequence of [c4].
2. 1.4.2
Sequential contexts.
Similar to item 1.3.2.
3. 1.4.3
Under an abstraction, C=λℓ′y.C′.
Note that Γ⊢λℓ′y.C′⟨t{x:=sˉ}⟩:M→ℓ′A is derivable.
Let us check the three conditions to see that λℓ′y.C′⟨t{x:=sˉ}⟩ is correct:
2.1
Uniquely labeled lambdas.
Any two lambdas in C′⟨t{x:=sˉ}⟩ have different labels by i.h..
We are left to check that ℓ′ does not decorate any lambda in C′⟨t{x:=sˉ}⟩.
Let ℓ1 be a label that decorates a lambda in C′⟨t{x:=sˉ}⟩.
Then we have that ℓ1 decorates a lambda in C′,
or it decorates a lambda in t{x:=sˉ}.
By what we proved in item 1
this in turn means that it decorates a lambda in t or a lambda in some of the terms of the list sˉ.
In any of these cases we have that ℓ1=ℓ′
since λℓ′y.C′⟨(λℓx.t)sˉ⟩ is correct.
2. 2.2
Sequential contexts.
Let t′ be a subterm of λℓ′y.C′⟨t{x:=sˉ}⟩
and let us check that its typing context is sequential.
If t′ is a subterm of C′⟨t{x:=sˉ}⟩ we conclude by i.h..
We are left to check the property for t′ being the whole term, i.e. that Γ is sequential.
By i.h., Γ⊕y:M is sequential, which implies that Γ is sequential.
3. 2.3
Sequential types.
Let t′ be a subterm of λℓ′y.C′⟨t{x:=sˉ}⟩
and let us check that, if N→ℓ′′C is any type occurring in the typing
context or in the type of t′, then N is sequential.
If t′ is a subterm of C′⟨t{x:=sˉ}⟩ we conclude by i.h..
We are left to check the property for t′ being the whole term.
If N→ℓ′′C⪯Γ,
then N→ℓ′′C⪯Γ⊕y:N
which is the type of C′⟨t{x:=sˉ}⟩,
so by i.h.N is sequential.
If N→ℓ′′C⪯M→ℓ′′A,
there are three subcases:
2.3.1
If N=M, then note that M is sequential
because Γ⊕y:M is the typing context of C′⟨t{x:=sˉ}⟩,
which is sequential by i.h..
2. 2.3.2
If N→ℓ′′C⪯B where B is one of the types of M,
then N→ℓ′′C⪯M→ℓ′′A which is the typing context
of C′⟨t{x:=sˉ}⟩,
and we conclude for this term has sequential types by i.h..
3. 2.3.3
If N→ℓ′′C⪯A,
note that A is the type of C′⟨t{x:=sˉ}⟩,
and we conclude for this term has sequential types by i.h..
3. 3.
Left of an application, C=C′uˉ.
Note that Γ⊢C′⟨t{x:=sˉ}⟩:[Bj]j=1m→ℓ′A
is derivable.
Moreover the list of arguments is of the form
uˉ=[u1,…,um] where all the uj are correct
and Δj⊢uj:Bj is derivable for all j=1..m.
Then Γ+j=1mΔj⊢C′⟨t{x:=sˉ}⟩[uj]j=1m:A
is derivable.
Let us check the three conditions to see that C′⟨t{x:=sˉ}⟩[uj]j=1m is correct:
3.1
Uniquely labeled lambdas.
Let ℓ1 and ℓ2 be two labels decorating different lambdas in C′⟨t{x:=sˉ}⟩[uj]j=1m.
There are three subcases.
3.1.1
If ℓ1 and ℓ2 both decorate lambdas in the subterm C′⟨t{x:=sˉ}⟩
then ℓ1=ℓ2 since C′⟨t{x:=sˉ}⟩ is correct by i.h..
2. 3.1.2
If ℓ1 and ℓ2 both decorate lambdas somewhere in [u1,…,um]
then ℓ1=ℓ2 since C′⟨t⟩[u1,…,um] is correct by hypothesis.
3. 3.1.3
If ℓ1 decorates a lambda in C′⟨t{x:=sˉ}⟩
and ℓ2 decorates a lambda in one of the terms uj for some j=1..m,
then note that ℓ1 must either decorate a lambda in C′ or a lambda in t{x:=sˉ}.
By what we proved in item 1
this in turn means that it decorates a lambda in t or a lambda in some of the terms of the list sˉ.
In any of these cases we have that ℓ1=ℓ2
since C′⟨(λℓx.t)sˉ⟩[uj]j=1m is correct by hypothesis.
2. 3.2
Sequential contexts.
Let t′ be a subterm of C′⟨t{x:=sˉ}⟩[uj]j=1m
and let us show that its typing context is sequential.
If t′ is a subterm of C′⟨t{x:=sˉ}⟩ we conclude by i.h..
If t′ is a subterm of one of the uj for some j=1..m, we conclude using that uj is correct by hypothesis.
It remains to check that the whole term is correct, i.e. that Γ+j=1mΔj is sequential.
Observe that Γ+j=1mΔj is also the typing context of
C′⟨(λℓx.t)sˉ⟩[uj]j=1m, which is correct by hypothesis.
3. 3.3
Sequential types.
Let t′ be a subterm of C′⟨t{x:=sˉ}⟩[uj]j=1m
and let us show if N→ℓ′C is a type
that occurs in the typing context or in the type of t′, then N is sequential.
If t′ is a subterm of C′⟨t{x:=sˉ}⟩ we conclude by i.h..
If t′ is a subterm of one of the uj for some j=1..m, we conclude using that uj is correct by hypothesis.
We are left to check the property for t′ being the whole term.
If N→ℓ′C⪯Γ+j=1mΔj,
we conclude by observing
that Γ+j=1mΔj is also the typing context of C′⟨(λℓx.t)sˉ⟩[uj]j=1m,
which is correct by hypothesis, so it has sequential types.
Similarly, if N→ℓ′C⪯A,
we conclude by observing
that A is also the type of C′⟨(λℓx.t)sˉ⟩[uj]j=1m.
4. 4.
Right of an application, C=u[rˉ1,C′,rˉ2].
Similar to item 3.
Let us prove that
t{x:=sˉ}{y:=uˉ}=t{y:=uˉ1}{x:=sˉ{y:=uˉ2}}
by induction on t.
The interesting case is the application.
Let t=r[r1,…,rn]. Then:
[TABLE]
Given that ∑i=0nsˉi is a permutation of sˉ,
by defining vˉ2:=∑i=0nuˉi,2,
the last term equals
(r{y:=uˉ0,1}[ri{y:=uˉi,1}]i=0n){x:=sˉ{y:=vˉ2}}.
Finally, by defining vˉ1:=∑i=0nuˉi,1,
we obtain
(r[r1,…,rn]){y:=vˉ1}{x:=sˉ{y:=vˉ2}}.
To conclude observe that vˉ1+vˉ2 is indeed a permutation of uˉ:
[TABLE]
where xˉ≈yˉ is the equivalence relation on lists that holds whenever xˉ is a permutation of yˉ.
Let us extend the operation of substitution to operate on contexts
by declaring that Tx(□)=[]
and □{x:=[]}=□.
We need two auxiliary lemmas:
Lemma 10 (Substitution lemma for contexts)
If both sides of the equation are defined
and (sˉ1,sˉ2) is a partition of sˉ
then
C⟨t⟩{x:=sˉ}=C{x:=s1ˉ}⟨t{x:=sˉ2}⟩.
Proof
The proof is similar to the Substitution Lemma, by induction on C.
Lemma 11 (Reduction inside a substitution)
Let 1≤i≤n and si→ℓsi′.
Then:
[TABLE]
.
Proof
Straightforward by induction on s.
The proof of Prop. 2 proceeds as follows.
Let R:t0ℓ#t1 and S:t0ℓ′#t2
be coinitial steps, and let us show that the diagram may be closed.
The step R is of the form
t0=C⟨(λℓx.t)sˉ⟩ℓ#C⟨t{x:=sˉ}⟩=t1.
Recall that R=S by hypothesis.
We proceed by induction on C.
Empty context, C=□.
Then
R:t0=(λℓx.t)sˉℓ#t{x:=sˉ}=t1.
There are two subcases, depending on whether the pattern of S is inside t
or inside sˉ:
where (sˉ1,sˉ2,sˉ3) and (sˉ1,sˉ4) are partitions of sˉ.
Note that (sˉ2,sˉ3) is a partition of sˉ4,
so it suffices to show that
r{y:=uˉ}{x:=sˉ4}=r{x:=sˉ2}{y:=uˉ{x:=sˉ3}}, which is an immediate consequence of the Substitution Lemma (Lem. 2).
2. 1.2
The pattern of S is inside sˉ.
In this case, sˉ=[sˉ1,C⟨(λℓ′y.r)uˉ⟩,sˉ2].
[TABLE]
The arrow of the bottom of the diagram exists as a consequence of Lem. 11.
2. 2.
Under an abstraction, C=λℓ′′y.C′.
Straightforward by i.h..
3. 3.
Left of an application, C=C′uˉ.
There are three subcases, depending on whether the redex S is
at the root, to the left of the application, or to the right of the application.
3.1
The pattern of S is at the root.
Then C′⟨(λℓ′x.t)sˉ⟩ must have a lambda at the root,
so it is of the form λℓ′y.C′′′⟨(λℓx.t)sˉ⟩.
Hence, the starting term is
(λℓ′y.C′′′⟨(λℓx.t)sˉ⟩)uˉ.
The symmetric case has already been studied in item 1.1.
2. 3.2
The pattern of S is inside C′. Straightforward by i.h..
3. 3.3
The pattern of S is inside uˉ.
It is immediate to close the diagram since the steps are at disjoint positions:
[TABLE]
4. 4.
Right of an application,
C=r[u1,…,ui−1,C′,ui+1,…,un].
There are four subcases, depending on whether the redex S is
at the root, to the left of the application (that is, inside r),
or to the right of the application (that is, either inside C′ or uj for some j).
4.1
The pattern of S is at the root.
Then r has a lambda at the root, i.e. it is of the form λℓ′y.u.
Hence the starting term is
(λℓ′y.u)[u1:i−1,C′⟨(λℓx.t)s⟩,ui+1:n].
The symmetric case has already been studied in item 1.2.
2. 4.2
The pattern of S is inside r.
The steps are disjoint, so it is immediate.
3. 4.3
The pattern of S is inside uj for some j=i.
The steps are disjoint, so it is immediate.
4. 4.4
The pattern of S is inside C′.
Straightforward by i.h..
0.A.4 Full Stability
In this section, we state and prove a strong version of Stability
in the sense of Lévy [26],
called Full Stability (Lem. 15).
This lemma is crucial in establishing that
D#(t) forms a distributive lattice (Prop. 4).
First we need a few auxiliary results:
Definition 14 (Alternative Substitution)
An alternative definition for capture-avoiding substitution,
written t{{x:=sˉ}},
may be defined as follows,
provided that
Tx(t)⊆T(sˉ)
and the multiset of types of sˉ=[s1,…,sm]
is sequential:
[TABLE]
Moreover,
[t1,…,tn]{{x:=sˉ}}
stands for [t1{{x:=sˉ}},…,tn{{x:=sˉ}}],
whenever each substitution ti{{x:=sˉ}} is well-defined.
Lemma 12
Let t,sˉ,uˉ be correct terms such that
Tx(t)=T(sˉ) and
suppose that sˉ is contained in uˉ,
i.e. there exists a list rˉ such that
(sˉ,rˉ) is a partition of uˉ.
Then t{x:=sˉ}=t{{x:=uˉ}}.
Proof
Straightforward by induction on t.
Lemma 13 (Creation)
If R creates S then it is according to
one of the following cases:
[crII]:
C⟨(λℓx.λℓ′y.t)sˉuˉ⟩→#C⟨(λℓ′y.t′)uˉ⟩→#C⟨t′{{y:=uˉ}}⟩, where
t′=t{{x:=sˉ}}.
3. 3.
[crIII]:
C1⟨(λℓx.C2⟨xAtˉ⟩)sˉ⟩→#C1⟨C2′⟨(λℓ′y.u)t′ˉ⟩⟩→#C1⟨C2′⟨u{{y:=t′ˉ}}⟩⟩,
where
[TABLE]
Proof
Let R:C⟨(λℓx.t)sˉ⟩→#C⟨t{{x:=sˉ}}⟩ be a step,
and let S:C⟨t{{x:=sˉ}}⟩→#p another step
such that R creates S.
The redex contracted by the step S is below a context C1,
so let C⟨t{{x:=sˉ}}⟩=C1⟨(λℓ′y.u)rˉ⟩,
where (λℓ′y.u)rˉ is the redex contracted by S.
We consider three cases, depending on the relative positions of the holes of C and C1,
namely they may be disjoint,
C may be a prefix of C1,
or C1 may be a prefix of C:
If the holes of C and C1 are disjoint.
Then there is a two-hole context C^ such that
C=C^⟨□,(λℓ′y.u)rˉ⟩ and C1=C^⟨t{{x:=sˉ}},□⟩.
So
C^⟨(λℓx.t)sˉ,(λℓ′y.u)rˉ⟩→#C^⟨t{{x:=sˉ}},(λℓ′y.u)rˉ⟩→#C^⟨t{{x:=sˉ}},u{{y:=r}}⟩.
Observe that S has an ancestor S0, contradicting the hypothesis that R creates S.
So this case is impossible.
2. 2.
If C is a prefix of C1.
Then there exists a context C2 such that C1=C⟨C2⟩,
and we have that
t{{x:=sˉ}}=C2⟨(λℓ′y.u)rˉ⟩.
We consider two subcases, depending on whether the position of the hole C2 lies
inside the term t, or it reaches a free occurrence of x in t
and “jumps” to one of the arguments in the list sˉ.
2.1
If the position of the hole of C2 lies in t.
More precisely, there is a context C2′ and a term t′ such that:
t=C2′⟨t′⟩,
C2=C2′{{x:=sˉ}},
and
(λℓ′y.u)rˉ=t′{{x:=sˉ}}.
We consider three further subcases for the term t′.
It cannot be an abstraction, so it may be a variable xA,
or an application.
Besides, if it is an application, the head may be a variable xA or an abstraction.
2.1.1
Variable, i.e.t′=xA.
Then the list sˉ may be split as sˉ=[s1ˉ,(λℓ′y.u)rˉ,s2ˉ],
and:
C⟨(λℓx.C2′⟨xA⟩)[s1ˉ,(λℓ′y.u)rˉ,s2ˉ]⟩→#C⟨C2⟨(λℓ′y.u)rˉ⟩⟩→#C⟨C2⟨u{{y:=rˉ}}⟩⟩.
Observe that S has an ancestor S0, contradicting the hypothesis that R creates S.
So this case is impossible.
2. 2.1.2
Application of a variable, i.e.t′=xAr′ˉ.
Given that
(λℓ′y.u)rˉ=t′{{x:=sˉ}},
we have rˉ=r′ˉ{{x:=sˉ}},
and the list sˉ may be split as sˉ=[s1ˉ,λℓ′y.u,s2ˉ].
Then
C⟨(λℓx.C2′⟨xAr′ˉ⟩)[s1ˉ,λℓ′y.u,s2ˉ]⟩→#C⟨C2⟨(λℓ′y.u)rˉ⟩⟩→#C⟨C2⟨u{{y:=rˉ}}⟩⟩,
and we are in the situation of [crIII].
3. 2.1.3
Application of an abstraction, i.e.t′=(λℓy.u′)r′ˉ.
Given that
(λℓ′y.u)rˉ=t′{{x:=sˉ}},
we have uˉ=u′ˉ{{x:=sˉ}}
and rˉ=r′ˉ{{x:=sˉ}}.
Then:
C⟨(λℓx.C2′⟨(λℓy.u′)r′ˉ⟩)sˉ⟩→#C⟨C2⟨(λℓy.u)rˉ⟩⟩→#C⟨C2⟨u{{z:=rˉ}}⟩⟩.
Then S has an ancestor S0, contradicting the hypothesis that R creates S.
So this case is impossible.
2. 2.2
If the position of the hole of C2 “jumps” through a free occurrence of x.
More precisely,
there exist C3, A, s1ˉ, s2ˉ, and C4
such that:
t=C3⟨xA⟩sˉ=[s1ˉ,C4⟨(λℓ′y.u)rˉ⟩,s2ˉ]
in such a way that T(C4⟨(λℓ′y.u)rˉ⟩)=Tx(xA),
and C2=C3{{x:=sˉ}}⟨C4⟩.
Then:
[TABLE]
Then S has an ancestor S0, contradicting the hypothesis that R creates S.
So this case is impossible.
3. 3.
If C1 is a prefix of C.
Then there exists a context C2 such that C=C1⟨C2⟩.
This means that C2⟨t{{x:=sˉ}}⟩=(λℓ′y.u)rˉ.
We consider three subcases, depending on whether C2 is empty,
or the hole of C2 lies to the left or to the right of the application.
3.1
Empty, C2=□.
Then C=C1 so C is a prefix of C1. We have already considered this case.
2. 3.2
Left, C2=C2′rˉ.
Then the step R is of the form
R:C1⟨C2′⟨(λℓx.t)sˉ⟩rˉ⟩→#C1⟨C2′⟨t{{x:=sˉ}}⟩rˉ⟩.
In particular we know that C2′⟨t{{x:=sˉ}}⟩=λℓ′y.u.
There are two cases, depending on whether C2′ is empty or non-empty.
3.2.1
Empty, C2′=□
Then we have that t{{x:=sˉ}}=λℓ′y.u.
We consider two further subcases, depending on whether t is an occurrence of the variable x.
3.2.1.1
If t=xA for some type A.
Then the list sˉ must be of the form [λℓ′y.u]
where the external label of A is precisely ℓ′.
Then
C1⟨(λℓx.xA)[λℓ′y.u]rˉ⟩→#C1⟨(λℓ′y.u)rˉ⟩→#C1⟨u{{y:=rˉ}}⟩,
and we are in the situation of [crI].
2. 3.2.1.2
If t=xA for any type A.
Then t must be an abstraction, namely t=λℓ′y.u′
where u′{{x:=sˉ}}=u.
Then
C1⟨(λℓx.λℓ′y.u′)sˉrˉ⟩→#C1⟨(λℓ′y.u′{{x:=sˉ}})rˉ⟩→#C1⟨u′{{x:=sˉ}}{{y:=rˉ}}⟩,
and we are in the situation of [crII].
2. 3.2.2
Non-empty, C2′=□
Then necessarily C2′ must be an abstraction, namely C2′=λℓ′y.C2′′.
Then:
[TABLE]
Then S has an ancestor S0, contradicting the hypothesis that R creates S.
So this case is impossible.
3. 3.3
Right, C2=(λℓ′y.u)[rˉ1,C2′,rˉ2].
Then:
[TABLE]
Then S has an ancestor S0, contradicting the hypothesis that R creates S.
So this case is impossible.
Lemma 14 (Basic Stability)
Let R=S.
If T3∈T1/(S/R)
and T3∈T2/(R/S)
then there exists a step T0 such that
T1∈T0/R
and
T2∈T0/S.
Proof
We prove an equivalent statement.
Namely,
we prove that if R,S are different coinitial steps such that
R creates a step T,
then R/S creates the step T/(S/R).
It is easy to see that these are equivalent since in λ# there is
no erasure or duplication.
Let R:C⟨(λℓx.t)sˉ⟩→#C⟨t{x:=sˉ}⟩,
let S=R be a step coinitial to R,
and suppose that R creates a step T.
By induction on the context C we argue that R/S creates T/(S/R).
Empty context, C=□.
Then R:(λℓx.t)sˉ→#t{{x:=sˉ}}.
There are two cases for S, depending on whether it is internal to t
or internal to one of the arguments of the list sˉ.
1.1
If S is internal to t.
Then t=C1⟨Σ⟩ where Σ is the redex contracted by S.
Let Σ′ denote the contractum of Σ. Then:
[TABLE]
By Creation (Lem. 13),
T must be created by [crIII],
since there are no applications surrounding the subterm contracted by R.
This means that C1⟨Σ⟩=C2⟨xAuˉ⟩
where, moreover, sˉ may be split as [sˉ1,λℓ′y.r,sˉ2]
in such a way that ℓ′ is the external label of A.
We consider three subcases, depending on whether the contexts
C1 and C2 are disjoint,
C1 is a prefix of C2,
or C2 is a prefix of C1.
1.1.1
If C1 and C2 are disjoint.
Then there is a two-hole context C^ such that
C^⟨□,xAuˉ⟩=C1 and C^⟨Σ,□⟩=C2.
Given any term, context, or list of terms X let us write X∗ to denote X{{x:=sˉ}}.
Then R/S creates T/(S/R):
[TABLE]
2. 1.1.2
If C1 is a prefix of C2.
Then C2=C1⟨C2′⟩ which means that Σ=C2′⟨xAuˉ⟩.
Recall that Σ is a redex, so let us write
Σ=(λℓ′′z.p)qˉ.
We consider two further subcases, depending on whether the hole of C2′
lies to the left or to the right of the application (observe that it cannot be at the root
since λℓ′′z.p is not a variable).
1.1.2.1
If the hole of C2′ lies to the left of (λℓ′′z.p)qˉ.
More precisely, we have that
C2′=(λℓ′′z.C2′′)qˉ and p=C2′′⟨xAuˉ⟩.
Given any term, context, or list of terms X let us write X∗ to denote X{{x:=sˉ}}.
Then R/S creates T/(S/R):
[TABLE]
2. 1.1.2.2
If the hole of C2′ lies to the right of (λℓ′′z.p)qˉ.
More precisely, we have that C2′=(λℓ′′z.p)[qˉ1,C2′′,qˉ2]
and qˉ=[qˉ1,C2′′⟨xAuˉ⟩,qˉ2].
Given any term, context, or list of terms X let us write X∗ to denote X{{x:=sˉ}}.
Moreover, since parameters are in 1–1 correspondence with arguments,
there is exactly one free occurrence of z in p whose type coincides with
the type of C2′′⟨xAuˉ⟩.
Let p=C3⟨zB⟩ where the hole of C3 marks the position
of such occurrence.
Then:
[TABLE]
Moreover, if we write C3′ for the context C3{{z:=qˉ}}:
[TABLE]
by the Substitution Lemma for contexts (Lem. 10).
Then:
[TABLE]
The labels of the steps T and T/(S/R) are both ℓ′,
which means that R/S creates T/(S/R).
3. 1.1.3
If C2 is a prefix of C1.
Then C1=C2⟨C1′⟩
which means xAuˉ=C1′⟨Σ⟩.
Since Σ is a redex, C1′ must be of the form xA[uˉ1,C1′′,uˉ2]
and uˉ=[uˉ1,C1′′⟨Σ⟩,uˉ2].
Given any term, context, or list of terms X let us write X∗ to denote X{{x:=sˉ}}.
Then: R/S creates T/(S/R):
[TABLE]
2. 1.2
If S is internal to sˉ.
Then sˉ=[sˉ1,C1⟨Σ⟩,sˉ2]
where Σ is the redex contracted by S.
Let Σ′ denote the contractum of Σ. Then:
[TABLE]
By Creation (Lem. 13), T must be created by
[crIII],
since there are no applications surrounding the subterm contracted by R.
This means that t=C2⟨xAuˉ⟩,
and there is a term in the list [sˉ1,C1⟨Σ⟩,sˉ2]
of the form λℓ′y.r
such that ℓ′ is also the external label of the type A.
There are two subcases, depending on whether such term is C1⟨Σ⟩
or a different term in the list [sˉ1,C1⟨Σ⟩,sˉ2].
1.2.1
If λℓ′y.r=C1⟨Σ⟩.
Note that C1 cannot be empty, since this would imply that λℓ′y.r=Σ;
however Σ is a redex, and in particular an application, so this cannot be the case.
Hence the context C1 must be non-empty, i.e.C1=λℓ′y.C1′ with r=C1′⟨Σ⟩.
Given any term, context, or list of terms X let us write X∗ to denote X{{x:=[sˉ1,sˉ2]}}.
Then R/S creates T/(S/R):
[TABLE]
2. 1.2.2
If λℓ′y.r=C1⟨Σ⟩.
Then λℓ′y.r
is either one of the terms in the list sˉ1
or one of the terms in the list sˉ2.
Given any term, context,
or list of terms X let X∗ denote X{{x:=[sˉ1,C1⟨Σ⟩sˉ2]}}
and let X† denote X{{x:=[sˉ1,C1⟨Σ′⟩sˉ2]}}.
Then R/S creates T/(S/R):
[TABLE]
2. 2.
Under an abstraction, C=λℓy.C′.
Straightforward by i.h..
3. 3.
Left of an application, C=C′uˉ.
Let Δ be the redex contracted by R, and let Δ′ denote its contractum.
The step R is of the form C′⟨Δ⟩uˉ→#C′⟨Δ′⟩uˉ.
We consider three subcases, according to Creation (Lem. 13), depending on whether
T is created by [crI], [crII], or [crIII].
3.1
[crI]
Then C′ is empty and Δ has the following particular shape:
Δ=(λℓx.xA)[λℓ′y.r].
The step S can be either internal to the subterm r,
or internal to one of the subterms in the list uˉ.
If S is internal to r, let r′ denote the term that results
from r after the step S.
Then:
[TABLE]
Note that R/S creates T/(S/R), as required.
If, on the other hand, S is internal to uˉ, the situation is similar.
2. 3.2
[crII]
Then C′ is empty and Δ has the following particular shape:
Δ=(λℓx.λℓ′y.r)sˉ.
The step S can be either internal to r, internal to sˉ,
or internal to uˉ.
If S is internal to r, let r′ denote the term that results
from r after the step S. Then:
[TABLE]
Note that R/S creates T/(S/R), as required.
If, on the other hand, S is internal to sˉ or uˉ, the situation is similar.
3. 3.3
[crIII]
Recall that the step R is of the form
R:C′⟨Δ⟩uˉ→#C′⟨Δ′⟩uˉ.
Since the step T is created by [crIII],
it does not take place at the root of C′[Δ′]uˉ,
but rather it is internal to C′[Δ′].
We consider three subcases, depending on whether the step S takes place
at the root, to the left of the application or to the right of the application.
3.3.1
If S takes place at the root.
Then C′⟨Δ⟩ is an abstraction,
so C′ cannot be empty, i.e. we have that C′=λℓ′y.C′′.
Moreover, since T is created by [crIII],
we have that Δ has the following specific shape:
Δ=(λℓx.C2⟨xArˉ⟩)sˉ
where sˉ=[sˉ1,λℓ′′z.p,sˉ2]
and such that ℓ′′ is the external label of A.
Given any term, context, or list of terms X let X∗ denote X{{x:=sˉ}}
and let X† denote X{{y:=uˉ}}.
Note also that by the Substitution lemma (Lem. 10) we have that
X†{{x:=sˉ†}}=X∗†.
Then R/S creates T/(S/R):
[TABLE]
2. 3.3.2
If S is internal to C′⟨Δ⟩.
Then it is straightforward by i.h..
3. 3.3.3
If S is internal to uˉ.
Then:
[TABLE]
It is immediate to note in this case that R/S creates T/(S/R),
since the two-step sequences RT and (R/S)(T/(S/R))
are both isomorphic to
C′⟨Δ⟩→#C′⟨Δ′⟩→#p, only going below different contexts.
4. 4.
Right of an application, C=u[rˉ1,C′,rˉ2].
Let Δ be the redex contracted by R, and let Δ′ denote its contractum.
The step R is of the form
u[rˉ1,C′⟨Δ⟩,rˉ2]→#u[rˉ1,C′⟨Δ′⟩,rˉ2].
We consider three subcases, depending on whether the step S takes place at the root,
to the left of the application, or to the right of the application.
4.1
If S takes place at the root.
Then u is an abstraction u=λℓ′y.u′.
Moreover, since parameters are in 1–1 correspondence with arguments,
there is a free occurrence of y in u′ whose type is also the type of
the argument C′⟨Δ⟩. Let us write u′ as u′=C1⟨yA⟩,
where the hole of C1 marks the position of such occurrence.
Given any term, context, or list of terms X let X∗ denote X{{x:=rˉ1,rˉ2}}.
Then:
[TABLE]
So R/S creates T/(S/R),
since the two-step sequences RT and (R/S)(T/(S/R))
are both isomorphic to C′⟨Δ⟩→#C′⟨Δ′⟩→#p,
only going below different contexts.
2. 4.2
If S is internal to the left of the application.
Then:
[TABLE]
Then since RT and (R/S)(T/(S/R))
are isomorphic, it is immediate to conclude,
similarly as in item 3.3.3 of this lemma.
3. 4.3
If S is internal to the right of the application.
We consider two further subcases, depending on whether S is
internal to the argument C′⟨Δ⟩, or otherwise.
4.3.1
If S is internal to the argument C′⟨Δ⟩.
Then it is straightforward by i.h..
2. 4.3.2
If S is not internal to the argument C′⟨Δ⟩.
Then it is either internal to rˉ1 or to rˉ2.
If it is internal to rˉ1, then:
[TABLE]
Then since RT and (R/S)(T/(S/R))
are isomorphic, it is immediate to conclude,
similarly as in item 3.3.3 of this lemma.
Lemma 15 (Full Stability)
Let ρ,σ be coinitial derivations
such that labs(ρ)∩labs(σ)=∅.
Let T1,T2,T3 be steps such that
T3=T1/(σ/ρ)=T2/(ρ/σ).
Then there is a step T0 such that T1=T0/ρ
and T2=T0/σ.
Proof
The proof of Full Stability (Lem. 15)
is straightforward using Basic Stability (Lem. 14).
Consider the diagram
formed by ρ=R1…Rn
and σ=S1…Sm.
By Permutation (Prop. 2)
the diagram can be tiled using squares, as in λ#
there is no erasure or duplication. Note that for all i=j we have
that Ri=Sj,
since labs(ρ) and labs(σ) are disjoint.
It suffices to apply Basic Stability n×m times, once for each tile.
Let [ρ] denote the permutation equivalence class of
a derivation ρ,
and let D#(t)={[ρ]∣src(ρ)=t}
be the set of →#-derivations
starting on t, modulo permutation equivalence.
We already know that (D#(t),⊑) is an upper
semilattice, where the order is given by
[ρ]⊑[σ]⟺defρ⊑σ,
the bottom is ⊥=[ϵ]
and the join is
[ρ]⊔[σ]=[ρ⊔σ].
Note that D#(t) has a top element:
given that λ# is strongly normalizing (Prop. 1),
consider a derivation ρ:t↠#∗s to normal form.
Then for any other derivation σ:t↠#∗u
we have that σ/ρ=ϵ, so it suffices to take
⊤=[ρ].
To see that D#(t) is a lattice for all t∈T#,
we are left to show that any two coinitial derivations ρ,σ
have a meetρ⊓σ
with respect to the prefix order ⊑,
and define [ρ]⊓[σ]=def[ρ⊓σ].
To this purpose, we prove various auxiliary results.
Definition 15
A step Rbelongs to a coinitial derivation ρ,
written R∈ρ,
if and only if
some residual of R is contracted along ρ.
More precisely,
R∈ρ
if there exist ρ1,R′,ρ2 such that
ρ=ρ1Rρ2 and R′∈R/ρ1,
We write R∈ρ
if it is not the case that R∈ρ.
Lemma 16 (Characterization of belonging)
Let R be a step and ρ a coinitial derivation
in λ#.
Then the following are equivalent:
R∈ρ,
2. 2.
R⊑ρ,
3. 3.
lab(R)∈labs(ρ).
Note: the hypothesis that R and ρ are coinitial is crucial.
In particular, (1) and (2) by definition only hold when R and ρ are coinitial,
while (3) might hold even if R and ρ are not coinitial.
Proof
(1⇒2)
Let ρ=ρ1Sσ2 where S is a residual of R.
Suppose moreover, without loss of generality,
that ρ1 is minimal, i.e. that R∈ρ1.
Since in λ# there is no duplication or erasure,
R/ρ1 is a singleton, so R/ρ1=S.
This means that R/ρ1Sρ2=∅,
so indeed R⊑ρ1Sρ2.
(2⇒3)
By induction on ρ.
If ρ is empty, the implication is vacuously true,
so let ρ=Sσ
and consider two subcases, depending on whether R=S.
If R=S, then indeed the first step of ρ=Rσ
has the same label as R.
On the other hand, if R=S,
since in λ# there is no duplication or erasure,
we have that R/S=R′,
where lab(R)=lab(R′).
Note that R⊑Sσ
so R/S=R′⊑σ.
By applying the i.h. we obtain that there must be a step in σ
whose label is lab(R)=lab(R′), and we are done.
(3⇒1)
By induction on ρ.
If ρ is empty, the implication is vacuously true,
so let ρ=Sσ
and consider two subcases, depending on whether lab(R)=lab(S).
If lab(R)=lab(S) then R and S must be the same step,
since terms are correct, which means that labels decorating lambdas are pairwise distinct.
Hence R∈ρ=Rσ.
On the other hand, if lab(R)=lab(S), then
R=S
so since in λ# there is no duplication or erasure
we have that R/S=R′,
where lab(R)=lab(R′).
By hypothesis, there is a step in the derivation ρ=Sσ whose label
is lab(R), and it is not S, so there must be at least one step in the
derivation σ whose label is lab(R)=lab(R′).
By i.h.R′∈σ
and then, since R′ is a residual of R,
we conclude that R∈Sσ,
as required.
It is immediate to note that,
when composing derivations ρ,σ,
the set of labels of ρσ
results from the union of the labels of ρ and σ:
Remark 4
labs(ρσ)=labs(ρ)∪labs(σ)
Indeed, a stronger results holds. Namely, the union is disjoint:
Lemma 17
labs(ρσ)=labs(ρ)⊎labs(σ)
Proof
Let ρ:t↠#s.
By induction on ρ we argue that the set of labels decorating the lambdas in s
is disjoint from labs(ρ).
The base case is immediate, so let ρ=Tτ.
The step T is of the form:
T:t=C⟨(λℓx.u)rˉ⟩→#C⟨u{x:=rˉ}⟩.
Hence the target of T has no lambdas decorated with the label ℓ.
Moreover, the derivation τ is of the form:
τ:C⟨u{x:=rˉ}⟩↠#s
and by i.h. the set of labels decorating the lambdas in s
is disjoint from labs(τ).
As a consequence,
the set of labels decorating the lambdas in s
is disjoint from both labs(τ)
and {ℓ}.
This completes the proof.
As an easy consequence:
Corollary 3
If ∣ρ∣ denotes the length of ρ,
then
∣ρ∣=#(labs(ρ)).
Lemma 18
Let ρ and σ be coinitial.
Then
labs(ρ/σ)=labs(ρ)∖labs(σ)
Proof
First we claim that labs(ρ/R)=labs(ρ)∖{lab(R)}.
By induction on ρ.
The base case is immediate, so let ρ=Sσ
and consider two subcases, depending on whether R=S.
If R=S,
then
labs(ρ/R)=labs(Rσ/R)=labs(σ)=labs(Rσ)∖{lab(R)}.
On the other hand if R=S,
then since
in λ# there is no duplication or erasure
we have that R/S=R′
where lab(R)=lab(R′)
and, similarly,
S/R=S′,
where lab(S)=lab(S′). Hence:
[TABLE]
which completes the claim.
To see that labs(ρ/σ)=labs(ρ)∖labs(σ)
for an arbitrary derivation σ,
proceed by induction on σ.
If σ is empty it is trivial, so
consider the case in which σ=Rτ.
[TABLE]
Proposition 12 (Prefixes as subsets)
Let ρ,σ be coinitial derivations in the distributive lambda-calculus.
Then
ρ⊑σ if and only if labs(ρ)⊆labs(σ).
Proof
By induction on ρ.
The base case is immediate since ϵ⊑σ
and ∅⊆labs(σ) both hold.
So let ρ=Tτ. First note that
the following equivalence holds:
[TABLE]
Indeed:
(⇒)
Suppose that Tτ⊑σ.
Then, on one hand, T⊑Tτ⊑σ.
On the other hand, projection is monotonic, so
τ=Tτ/T⊑σ/T.
(⇐)
Since τ⊑σ/T
we have that Tτ⊑T(σ/T)≡σ(T/σ)=σ
since T/σ=ϵ.
So we have that:
[TABLE]
To justify the very last equivalence, the (⇒) direction is immediate.
For the (⇐) direction,
the difficulty is ensuring that
labs(τ)⊆labs(σ)∖{lab(T)}
from the fact that
labs(Tτ)⊆labs(σ).
To see this it suffices to observe that by Lem. 17,
labs(Tτ)
is the disjoint union
labs(T)⊎labs(τ),
which means that
lab(T)∈labs(τ).
As an easy consequence:
Corollary 4 (Permutation equivalence in terms of labels)
Let ρ,σ be coinitial derivations in λ#.
Then
ρ≡σ if and only if labs(ρ)=labs(σ).
Lemma 19 (Projections are decreasing)
Let R∈ρ. Then ∣ρ∣=1+∣ρ/R∣.
Proof
Observe that R⊑ρ by Lem. 16.
So ρ≡R(ρ/R), which gives us that:
[TABLE]
The proof of Prop. 4 proceeds as follows.
If ρ and σ are derivations, we say that a step R
is a common (to ρ and σ) whenever R∈ρ and R∈σ.
Define ρ⊓σ as follows,
by induction on the length of ρ:
[TABLE]
In the second case of the definition, there might be more than one R
common to ρ and σ.
Any such step may be chosen and we make no further assumptions.
To see that this recursive construction is well-defined,
note that the length of ρ/R is lesser than the length of ρ
by the fact that projections are decreasing (Lem. 19).
To conclude the construction, we show that ρ⊓σ is an infimum, i.e. a greatest lower bound:
Lower bound.
Let us show that ρ⊓σ⊑ρ
by induction on the length of ρ.
There are two subcases, depending on whether
there is a step common to ρ and σ.
If there is no common step,
then ρ⊓σ=ϵ
trivially verifies ρ⊓σ⊑ρ.
On the other hand, if there is a common step, we have by definition that
ρ⊓σ=R((ρ/R)⊓(σ/R))
where R is common to ρ and σ.
Recall that projections are decreasing (Lem. 19)
so ∣ρ∣>∣ρ/R∣.
This allows us to apply the i.h. and conclude:
[TABLE]
Showing that ρ⊓σ⊑σ is symmetric,
by induction on the length of σ.
2. 2.
Greatest lower bound.
Let τ be a lower bound for {ρ,σ},
i.e.τ⊑ρ and τ⊑σ,
and let us show that τ⊑ρ⊓σ.
We proceed by induction on the length of ρ.
There are two subcases, depending on whether
there is a step common to ρ and σ.
If there is no common step,
we claim that τ must be empty.
Otherwise we would have that τ=Tτ′⊑ρ
so in particular T⊑ρ and T∈ρ by Lem. 16.
Similarly, T∈σ so
T is a step common to ρ and σ,
which is a contradiction.
We obtain that τ is empty,
so trivially τ=ϵ⊑ρ⊓σ.
On the other hand, if there is a common step, we have by definition that
ρ⊓σ=R((ρ/R)⊓(σ/R))
where R is common to ρ and σ.
Moreover, since τ⊑ρ and τ⊑σ,
by projecting along R we know that
τ/R⊑ρ/R and τ/R⊑σ/R.
So:
[TABLE]
Finally, observe that
the meet of {ρ,σ}
is unique modulo permutation equivalence,
since
if τ and τ′ both
have the universal property of being a greatest lower bound,
then τ⊑τ′
and τ′⊑τ.
0.A.6 Proof of Prop. 5 – The function labs is a morphism of lattices
We need the following auxiliary result:
Lemma 20 (Disjoint derivations)
Let ρ and σ be coinitial derivations in λ#.
The following are equivalent:
labs(ρ)∩labs(σ)=∅.
2. 2.
ρ⊓σ=ϵ.
3. 3.
There is no step common to ρ and σ.
In this case we say that ρ and σ are disjoint.
Proof
The implication (1⟹2) is immediate since if we suppose that ρ⊓σ is non-empty
then the first step of ρ⊓σ is a step T
such that T∈ρ and T∈σ.
By Lem. 16,
this means that lab(T)∈labs(ρ)∩labs(σ),
contradicting the fact that lab(T) and labs(ρ) are disjoint.
The implication
(2⟹3) is immediate by the definition of ρ⊓σ (defined in Prop. 4).
Let us check that the implication (3⟹1) holds.
By the contrapositive, suppose that labs(ρ) and labs(σ)
are not disjoint, and let us show that there is a step common to ρ and σ.
Since labs(ρ)∩labs(σ)=∅,
we know that the derivation ρ can be written as ρ=ρ1Rρ2
where lab(R)∈labs(σ).
Without loss of generality we may suppose
that R is the first step in ρ with that property,
i.e. that labs(ρ1)∩labs(σ)=∅.
Moreover, let us write σ as σ=σ1Sσ2
where lab(R)=lab(S).
Observe that the label of R does not appear anywhere along the sequence of steps ρ1,
i.e. that lab(R)∈labs(ρ1), as a consequence of the
fact that no labels are ever repeated in any sequence of steps (Lem. 17).
This implies that lab(S)∈labs(ρ1/σ1).
Indeed:
[TABLE]
This means that S is not erased by the derivation ρ1/σ1.
More precisely, S/(ρ1/σ1) is a singleton.
Symmetrically, R/(σ1/ρ1) is a singleton.
Moreover, lab(S/(ρ1/σ1))=lab(S)=lab(R)=lab(R/(σ1/ρ1))
so we have that S/(ρ1/σ1)=R/(σ1/ρ1).
The situation is the following, where labs(ρ1)∩labs(σ1)=∅:
[TABLE]
By Full stability (Lem. 15) this means that there exists a step T
such that T/ρ1=R and T/σ1=S.
Then T∈ρ1Rρ2=ρ
and also T∈σ1Sσ2=σ
so T is common to ρ and σ,
by which we conclude.
Let X be the set of labels of the steps involved in some derivation to normal form.
More precisely, let ρ0:t→#∗s be a derivation to normal form, which exists
by virtue of Strong Normalization (Prop. 1),
and let X=labs(ρ0).
Then we claim that:
[TABLE]
is a monomorphism of lattices.
Note that labs is well-defined
over permutation equivalence classes
since if ρ≡σ then
labs(ρ)=labs(σ)
by Coro. 4.
We are to show that labs is monotonic, that it preserves bottom, joins, top, and meets,
and finally that it is a monomorphism:
Monotonic, i.e.[ρ]⊑[σ]
implies labs(ρ)⊆labs(σ).
By Prop. 12.
2. 2.
Preserves top.
Recall that ⊤=[ρ0] where ρ0:t↠#∗s
is the derivation to normal form.
Note moreover that all derivations to normal form
are permutation equivalent in an orthogonal axiomatic rewrite system, so the choice
does not matter.
To conclude, observe that labs(ρ0)=X by definition of X,
and X is indeed the top element of P(X).
5. 5.
Preserves meets,
i.e.labs([ρ]⊓[σ])=labs(ρ)∩labs(σ).
We show the two inclusions:
5.1
(⊆)
It suffices to check that
labs(ρ⊓σ)⊆labs(ρ)
(the inclusion
labs(ρ⊓σ)⊆labs(σ)
is symmetric).
By induction on the length of ρ⊓σ.
If ρ⊓σ is empty it is immediate.
If it is non-empty,
ρ⊓σ=T(ρ/T⊓σ/T),
where T is a step common to ρ and σ.
Then since T is common to ρ and σ,
we have that lab(T)∈labs(ρ).
Moreover, by i.h.labs(ρ/T⊓σ/T)⊆labs(ρ/T).
So:
[TABLE]
2. 5.2
(⊇)
To show labs(ρ)∩labs(σ)⊆labs(ρ⊓σ),
we first prove the following claim:
Claim.labs(ρ/(ρ⊓σ))∩labs(σ/(ρ⊓σ)=∅.
Proof of the claim.
By Lem. 20 it suffices to show that
(ρ/(ρ⊓σ))⊓(σ/(ρ⊓σ))=ϵ.
By contradiction, suppose that there is a step T common to
the derivations
ρ/(ρ⊓σ) and σ/(ρ⊓σ).
Then the derivation (ρ⊓σ)T is a lower bound for {ρ,σ},
i.e.(ρ⊓σ)T⊑ρ
and
(ρ⊓σ)T⊑σ.
Since ρ⊓σ is the greatest lower bound for {ρ,σ},
we have that (ρ⊓σ)T⊑ρ⊓σ.
But this implies that T⊑ϵ, which is a contradiction.
End of claim.
Note that ρ⊓σ⊑ρ,
so we have that ρ≡(ρ⊓σ)(ρ/(ρ⊓σ)),
and this in turn implies that
labs(ρ)=labs((ρ⊓σ)(ρ/(ρ⊓σ)))
by Coro. 4.
Symmetrically,
labs(σ)=labs((ρ⊓σ)(σ/(ρ⊓σ))).
Then:
[TABLE]
6. 6.
Monomorphism.
It suffices to show that labs is injective.
Indeed,
suppose that labs([ρ])=labs([σ]).
By Coro. 4
we have that ρ≡σ,
so
[ρ]=[σ].
0.A.7.1 Item 1 of Prop. 6: simulation of →β with →#
Let t′⋉t and let t=C⟨(λx.p)q⟩→βC⟨p{x:=q}⟩=s.
We prove that there exists a term s′ such that
t′→#∗s′ and s′⋉s
by induction on C.
Empty context, C=□.
Then t=(λx.p)q→p{x:=q}=s
and t′ is of the form (λℓx.p′)[q1′,…,qn′].
We conclude by taking s′=p′{x:=[q1′,…,qn′]}, using Lem. 21.
2. 2.
Under an abstraction, C=λy.C′.
Immediate by i.h..
3. 3.
Left of an application, C=C′u.
Immediate by i.h..
4. 4.
Right of an application, C=uC′.
Then t=uC′⟨(λx.p)q⟩→βuC′⟨p{x:=q}⟩=s
and t′=u′[u1′,…,un′],
with u′⋉u
and ui′⋉C′⟨(λx.p)q⟩
for all i=1..n.
Applying the i.h. on ui′ for each i=1..n, we have:
[TABLE]
So we may conclude as follows:
[TABLE]
0.A.7.2 Item 2 of Prop. 6: simulation of →# with →β
Let t′⋉t and t′→#s′.
We prove that there exist terms s and s′′
such that
t→βs,
s′→#∗s′′,
and s′′⋉s
by induction on t′.
Moreover, s′→#∗s′′ is a multistep.
Variable t′=x. Impossible.
2. 2.
Abstraction, t′=λℓy.r′
Immediate by i.h..
3. 3.
Application, t′=u′[r1′,…,rn′]
Then t=ur
where u′⋉u
and ri′⋉r for all i=1..n.
There are three subcases,
depending on whether the step t′→#s′
takes place at the root,
inside u′,
or inside ri′ for some i=1..n,
3.1
Reduction at the root.
In this case u′=λℓx.s′.
Then by Lem. 21:
[TABLE]
2. 3.2
Reduction in u′.
Immediate by i.h..
3. 3.3
Reduction in ri′ for some i=1..n.
We have that ri′→#ri′′, so by i.h. there exist pi′ and p such that:
[TABLE]
For every j=1..n, j=i,
we have that rj′⋉r and
r→βp.
By item 1 of Simulation (Prop. 6),
which we have just proved, we have the following diagram:
[TABLE]
So:
[TABLE]
0.A.8 Proof of Prop. 7 – Typability characterizes head normalization
Before proving Prop. 7, we need a few auxiliary results.
Definition 16 (Head normal forms)
A λ-term t is a head normal form if it is of the form
t=λx1.…λxn.yt1…tm
where n≥0 and m≥0.
Note that y might be or not be among the variables x1,…,xn.
Similarly, a correct term t∈T# of λ# a head normal form
if it is of the form
t=λℓ1x1.…λℓnxn.yAtˉ1…tˉm
where n≥0 and m≥0.
Lemma 22
If t is a head normal form,
there exists t′∈T# such that t′⋉t.
Moreover t′ can be taken to be of the form
λℓ1x1.…λℓnxn.y[]→ℓ1′…[]→ℓm′αℓ′′[]…[].
Proof
Let t=λx1.…λxn.yt1…tm.
Let {ℓ1,…,ℓn,ℓ1′,…,ℓm′,ℓ′′}
be a set of n+m+1 pairwise distinct labels and let α be a base type.
Take t^{\prime}:=\lambda^{\ell_{1}}x_{1}.\ldots\lambda^{\ell_{n}}x_{n}.y^{[\,]\overset{\ell^{\prime}_{1}}{\to}\ldots[\,]\overset{\ell^{\prime}_{m}}{\to}\alpha^{\ell^{\prime\prime}}}\underbrace{[\,]\ldots[\,]}_{\text{m times}}.
Observe that t′ is correct and t′⋉t.
Lemma 23 (→#-normal forms refine head normal forms)
Let t′∈T# be a →#-normal form
and t′⋉t. Then t is a head normal form.
Proof
Observe, by induction on t′
that if t′∈T# is a →#-normal form, it must be
of the form
λℓ1x1.…λℓnxn.yAsˉ1…sˉm,
as it cannot have a subterm of the form (λℓ′z.u)rˉ.
Then λℓ1x1.…λℓnxn.yAsˉ1…sˉm⋉t.
So t is of the form λx1.…λxn.ys1…sn,
that is, t is a head normal form.
The following lemma is an adaptation of Subject Expansion in [8].
Lemma 24 (Subject Expansion)
If Γ⊢C⟨t{x:=sˉ}⟩:A is derivable,
then Γ⊢C⟨(λℓx.t)sˉ⟩:A is derivable.
Proof
The proof proceeds by induction on C,
and the base case by induction on t,
similar to the proof that substitution preserves typing in
the proof of Subject Reduction (Sec. 0.A.1.1).
Correctness is not necessarily preserved by →#-expansion.
We need a stronger invariant, strong sequentiality,
that will be shown to be preserved by expansion
under appropiate conditions:
Definition 17 (Subterms and free subterms)
The set of subtermssub(t) of a term t is formally defined as follows:
[TABLE]
The set of free subtermssub∘(t) of a term t is defined similarly,
except for the abstraction case, which requires that the subterm in question
do not include occurrences of bound variables:
[TABLE]
Definition 18 (Strong sequentiality)
A term t is strongly sequential
if it is correct and, moreover,
for every subterm s∈sub(t)
and any two free subterms s1,s2∈sub∘(s) lying at disjoint positions of s,
the types of s1 and s2 have different external labels.
Example 6
The following examples illustrate the notion of strong sequentiality:
The term t=(λ1x.yα2)[] is strongly sequential.
Note that t and yα2 have the same type, namely α2,
but they do not occur at disjoint positions.
2. 2.
The term t=(λ1x.xα2)[yα2] is strongly sequential.
Note that xα2 and yα2 both have type α2,
but they are not simultaneously free subterms of the same subterm of t.
3. 3.
The term t=λ1y.x[α2]→3[α2]→4β5[yα2][zα2]
is not strongly sequential,
since yα2 and zα2
have the same type and they are both free subterms of
x[α2]→3[α2]→4β5[yα2][zα2]∈sub(t).
Lemma 25 (Refinement of a substitution: decomposition)
If u′⋉t{x:=s}
and u′ is strongly sequential,
then u′ is of the form t′{x:=[si′]i=1n}.
Moreover, given a fresh label ℓ,
the term (λℓx.t′)[si′]i=1n is strongly sequential,
t′⋉t and si′⋉s for all i=1..n.
Proof
By induction on t.
Variable (same), t=x.
Then u′⋉s.
Let A be the type of u′.
Taking t′:=xA⋉x
we have that (λℓx.xA)[u′] is strongly sequential.
Regarding strong sequentiality,
observe that xA and u′ have the same type, but they are not
simultaneously the free subterms of any subterm of (λℓx.xA)[u′].
2. 2.
Variable (different), t=y=x.
Then u′⋉y, so u′ is of the form yA.
Taking t′:=yA we have that
(λℓx.yA)[] is strongly sequential.
3. 3.
Abstraction, t=λy.r.
Then u′⋉λy.r{x:=s}
so u′ is of the form λℓ′y.u′′
where u′′⋉r{x:=s}.
By i.h., u′′ is of the form r′{x:=[si′]i=1n}
where (λℓx.r′)[si′]i=1n is strongly sequential,
r′⋉r and si′⋉s for all i=1..n.
Taking t′:=λℓ′y.r′,
we have that
t′=λℓ′y.r′⋉λy.r=t.
Moreover, the term
(λℓx.t′)[si]i=1n=(λℓx.λℓ′y.r′)[si]i=1n
is strongly sequential.
Typability is a consequence of Subject Expansion (Lem. 24).
The remaining properties are:
3.1
Uniquely labeled lambdas.
The multiset of labels decorating the lambdas of
(λℓx.λℓ′y.r′)[si]i=1n
is given by
Λ((λℓx.λℓ′y.r′)[si]i=1n)=[ℓ,ℓ′]+Λ(r′)+i=1nΛ(si).
It suffices to check that this multiset has no repeats.
The label ℓ is assumed to be fresh, so it occurs only once.
By i.h., u′′=r′{x:=[si′]i=1n},
so using Lem. 9 we have
Λ(u′)=Λ(λℓ′y.u′)=[ℓ′]+Λ(u′′)=[ℓ′]+Λ(r′{x:=[si′]i=1n})=[ℓ′]+Λ(r′)+i=1nΛ(si′).
Moreover, the term u′=λℓ′y.u′′ is correct,
so this multiset has no repeats.
2. 3.2
Sequential contexts.
Let q be a subterm of (λℓx.λℓ′y.r′)[si′]i=1n.
If q is a subterm of r′ or a subterm of si′ for some i=1..n we conclude by i.h. since (λℓx.r′)[si′]i=1n is known to be correct.
Moreover, if Γ⊕x:M⊕y:N is the typing context for r′,
the typing contexts of
λℓ′y.r′ and λℓx.λℓ′y.r′
are respectively Γ⊕x:M and Γ, which are also sequential.
Finally, if Δi is the typing context for si′, for each i=1..n,
the typing context for (λℓx.r′)[si′]i=1n
is of the form Γ+i=1nΔi+y:N, and it is sequential by i.h..
Hence the typing context for the whole term is Γ+i=1nΔi, and it is sequential.
3. 3.3
Sequential types.
Let q be a subterm (λℓx.λℓ′y.r′)[si′]i=1n,
and let P→ℓ′′C be a type that occurs in the typing context
or the type of q.
As in the previous case, we have that
Γ⊕x:[Bi]i=1n⊕y:N⊢r′:A is derivable
and Δi⊢si′:Bi is derivable for all i=1..n.
Moreover, they are correct by i.h., so if q is a subterm of r′ or a subterm of some si′,
we are done.
There are three cases left for q:
3.3.1
Case q=λℓ′y.r′.
The typing context is Γ⊕x:[Bi]i=1n and the type N→ℓ′A.
2. 3.3.2
Case q=λℓx.λℓ′y.r′.
The typing context is Γ and the type [Bi]i=1n→ℓN→ℓ′A.
3. 3.3.3
Case q=(λℓx.λℓ′y.r′)[si]i=1n.
The typing context is Γ and the type N→ℓ′A.
In all three cases, if P→ℓ′′C occurs in the typing context
or the type of q, then P can be shown to be sequential using the i.h..
4. 3.4
Strong sequentiality.
Let q∈sub((λℓx.λℓ′y.r′)[si]i=1n)
be a subterm,
and let q1,q2∈sub∘(q) be free subterms lying at disjoint positions of q.
We argue that the types of q1 and q2 have different external labels.
Consider the following five possibilities for q1:
3.4.1
Case q1=(λℓx.λℓ′y.r′)[si]i=1n.
Impossible since q2 must be at a disjoint position.
2. 3.4.2
Case q1=λℓx.λℓ′y.r′.
Then the external label of the type of q1 is the label ℓ, which is fresh,
so it cannot coincide with the type of any other subterm.
3. 3.4.3
Case q1=λℓ′y.r′.
Then q2 must be a subterm of si for some i=1..n.
Note that q must be the whole term,
and n>0, so there is at least one free occurrence of x in λℓ′y.r′.
This means that q1∈sub∘(q), so this case is impossible.
4. 3.4.4
Case q1 is a subterm of r′.
If q2 is also a subterm of r′, we conclude since by i.h.(λℓx.r′)[si′]i=1n is strongly sequential.
Otherwise, q2 is a subterm of si for some i=1..n,
and we also conclude by i.h..
5. 3.4.5
Case q1 is a subterm of si for some i=1..n.
If q2 is a subterm of sj for some j=1..n,
we conclude since by i.h.(λℓx.r′)[si′]i=1n is strongly sequential.
If q2 is any other subterm, note that the symmetric case has already been considered
in one of the previous cases.
4. 4.
Application, t=rp.
Then u′⋉(rp){x:=s},
so it is of the form u0′[uj′]j=1m
where u0′⋉r{x:=s}
and uj′⋉p{x:=s} for all j=1..m.
By i.h. we have that u0′ is of the form
r′{x:=sˉ0}
and for all j=1..m the term uj′ is of the form
pj′{x:=sˉj},
where r′⋉r
and pj′⋉p for all j=1..m.
Moreover,
the length of the list sˉj is kj
and
sˉj=[si(j)]i=1kj for all j=0..m,
and we have that si(j)⋉s for all j=0..m,i=1..kj.
By i.h. we also know that
(λℓx.r′)sˉ0 is strongly sequential
and (λℓx.pj′)sˉj is strongly sequential for all j=1..m.
Let t′:=r′[pj′]j=1m,
let n:=∑j=0mkj,
and let [s1′,…,sn′]:=∑j=0msˉj.
Note that t′=r′[pj′]j=1m⋉rp=t
and si′⋉s for all i=1..n.
Moreover, we have to check that u′=t′{x:=[s1′,…,sn′]}.
To prove this,
note that t′{x:=[s1′,…,sn′]}=(r′[pj′]j=1m){x:=[s1′,…,sn′]}.
Suppose that the multiset T([s1′,…,sn′]) were sequential.
Then the list of terms [s1′,…,sn′] would be partitioned
as (uˉ0,…,uˉm)
where uˉj is a permutation of sˉj for all j=0..m,
and we would have indeed:
[TABLE]
To see that T([s1′,…,sn′]) is sequential,
note that for every i=j,
the terms si′ and sj′ are free subterms of u′
and they lie at disjoint positions of u′.
Since u′ is strongly sequential, the types of si′ and sj′
have different external labels. Hence T([s1′,…,sn′]) is sequential.
To conclude, we are left to check that (λℓx.t′)[s1′,…,sn′] is strongly sequential:
4.1
Uniquely labeled lambdas.
The multiset of labels decorating the lambdas of (λℓx.t′)[s1′,…,sn′]
is given by
Λ((λℓx.t′)[s1′,…,sn′])=[ℓ]+Λ(t′)+i=1nΛ(si′).
It suffices to check that this multiset has no repeats.
The label ℓ is assumed to be fresh, so it occurs only once.
We have already argued that
u′=t′{x:=[s1′,…,sn′]},
so using Lem. 9 we have
Λ(u′)=Λ(t′)+i=1nΛ(si′).
Moreover u′ is correct, so this multiset has no repeats.
2. 4.2
Sequential contexts.
Suppose that
Γ0⊕x:M0⊢r′:[Cj]j=1m→ℓ′A
is derivable,
Γj⊕x:Mj⊢pj′:Cj
is derivable for all j=1..m,
and Δi⊢si′:Bi is derivable for all i=1..n.
Note that ∑j=0mMj=[Bi]i=1n.
Let q be a subterm of
(λℓx.r′[pj′]j=1m)[s1′,…,sn′].
Consider four cases for q:
4.2.1
Case q=(λℓx.r′[pj′]j=1m)[s1′,…,sn′].
The typing context is ∑j=0mΓj+∑i=1nΔi.
By Subject Expansion (Lem. 24)
the typing context of (r′[pj′]j=1m){x:=[s1′,…,sn′]}=u′
is also ∑j=0mΓj+∑i=1nΔi
and u′ is correct by hypothesis.
So ∑j=0mΓj+∑i=1nΔi is sequential.
2. 4.2.2
Case q=λℓx.r′[pj′]j=1m.
The typing context is
∑j=0mΓj,
which is sequential because ∑j=0mΓj+∑i=1nΔi is sequential.
3. 4.2.3
Case q=r′[pj′]j=1m.
The typing context is
∑j=0mΓj⊕x:[Bi]i=1n,
which is sequential because ∑j=0mΓj is sequential
and, moreover, [Bi]i=1n=T([B1′,…,Bn′])
which we have already shown to be sequential.
4. 4.2.4
Otherwise.
Then q is a subterm of r′, a subterm of pj′ for some j=1..m,
or a subterm of some si′ for some i=1..n.
Then we conclude since by i.h.(λℓx.r′)sˉ0
and all the (λℓx.pj′)sˉj
are strongly sequential.
3. 4.3
Sequential types.
Let q be a subterm of (λℓx.r′[pj′]j=1m)[s1′,…,sn′].
We claim that if N→ℓ′′D occurs in the context or in the type of q,
then N is sequential.
The proof is similar as for subcase .
4. 4.4
Strong sequentiality.
Let q∈sub((λℓx.r′[pj′]j=1m)[s1′,…,sn′])
be a subterm,
and let q1,q2∈sub∘(q) be free subterms lying at disjoint positions of q.
We claim that the types of q1 and q2 have different external labels.
The proof is similar as for subcase .
Lemma 26 (Backwards Simulation)
Let t,s∈T be λ-terms and
let s′∈T# be a strongly sequential term such that
t→βs and s′⋉s.
Then there exists a strongly sequential term t′∈T# such that:
[TABLE]
Proof
Let t=C⟨(λx.u)r⟩→βC⟨u{x:=r}⟩=s.
The proof proceeds by induction on C.
Empty, C=□.
By Lem. 25 we have that s′
is of the form u′{x:=[r1′,…,rn′]}
where u′⋉u and ri′⋉r for all i=1..n.
Moreover, taking ℓ to be a fresh label, (λℓx.u′)[r1′,…,rn′]
is strongly sequential and
(λℓx.u′)[r1′,…,rn′]⋉(λx.u)r.
2. 2.
Under an abstraction, C=λx.C′.
Straightforward by i.h..
3. 3.
Left of an application, C=C′u
Straightforward by i.h..
4. 4.
Right of an application, C=uC′
Then t=ur→βup=s
where r→βp and s′⋉s.
Then s′ is of the form u′[p1′,…,pn′] where pi′⋉p for all i=1..n.
By i.h., for all i=1..n we have that there exist r1′,…,rn′ such that:
[TABLE]
Moreover, u′[ri′]i=1n is strongly sequential, which can be concluded
from the facts that u′[pi′]i=1n is strongly sequential by hypothesis,
ri′ is strongly sequential for all i=1..n by i.h.,
and ri′ and pi′ have the same types by Subject Expansion (Lem. 24).
To prove the equivalence (1⟺2) of Prop. 7, we claim that the following
three statements are equivalent:
There exists t′∈T# such that t′⋉t.
2. 1’.
There exists t′∈T# such that t′⋉t
and t′→#∗λℓ1x1.…λℓnxn.yA[]…[].
3. 2.
There exists a head normal form s such that t→β∗s.
Let us prove the chain of implications 1⟹2⟹1′⟹1:
•
(1⟹2)
Let t′⋉t.
By Strong Normalization (Prop. 1), reduce t′→#∗s′
to normal form.
We claim that there exists a term s such that t→β∗s and s′⋉s.
Observe that, since λ# is strongly normalizing (Prop. 1)
and finitely branching, König’s lemma ensures that there is a bound for the length of →#-derivations
going out from a term t′∈T#.
(Alternatively, according to the proof of Strong Normalization in Prop. 1,
the bound may be explicitly taken to be the number of lambdas in t′).
Call this bound the weight of t′.
We proceed by induction on the weight of t′.
If the derivation is empty, we are done by taking s:=t.
If the derivation is non-empty, it is of the form t′→#u′→#∗s′.
By Simulation (Prop. 6) there exist terms u and u′′
such that u′→#∗u′′⋉u
and t→βu. Since the λ#-calculus is
confluent (Prop. 2) and s′ is a normal form,
we have that u′′↠#s′.
Note that the weight of t′ is strictly larger than the weight of u′′,
so by i.h. there exists s such that u→β∗s
and s′⋉s:
[TABLE]
Finally, since s′ is a →#-normal form and s′⋉s,
Lem. 23
ensures that s is a head normal form, as required.
•
(1′⟹1) Obvious.
•
(2⟹1′)
Let t→β∗s be a derivation to head normal form.
We claim that there exists t′∈T# such that t′ is strongly sequential,
and the normal form of t′ is of the form λℓ1x1.…λℓnxn.yA[]…[].
By induction on the length of the derivation t→β∗s.
If the derivation is empty, t=s is a head normal form
and we conclude by Lem. 22, observing that the constructed term t′⋉t
is strongly sequential.
If the derivation is non-empty, conclude using the i.h. and Backwards Simulation (Lem. 26).
If ρ,σ are composable derivations and t′⋉src(ρ),
then:
t′/ρσ=(t′/ρ)/σ
2. 2.
ρσ/t′=(ρ/t′)(σ/(t′/ρ))
Proof
Straightforward by induction on ρ.
An n-hole context C′ is a term with n ocurrences of a hole □.
We extend refinement for contexts by setting □⋉□.
We write C⟨t1,…,tn⟩ for the capturing substitution of the
i-th occurrence of □ in C by ti for all i=1..n.
If R:t→βs is a step, we write C⟨R⟩
for the step C⟨R⟩:C⟨t⟩→βC⟨s⟩.
Note that in general a context C may be refined by an n-hole context,
for example a [math]-hole context, x[]→1α2[]⋉x(y□),
or a 2-hole context, x[α1,β2]→3γ4[□,□]⋉x□.
Lemma 28 (Simulation of contexts)
Let C′⋉C,
let t1′,…,tn′∈T# and t∈T
such that ti′⋉t′ for each i∈{1,…,n},
and C′⟨t1′,…,tn′⟩⋉C⟨t⟩.
Moreover, let R:t→βs.
Then C′⟨t1′,…,tn′⟩/C⟨R⟩=C′⟨t1/R,…,tn/R⟩,
and labs(C⟨R⟩/C′⟨t1′,…,tn′⟩)=∑i=1nlabs(R/ti′).
Proof
Straightforward by induction on C.
In the proof of the following lemma (Lem. 29),
sometimes we will use the previous lemma (Lem. 28) implicitly.
Lemma 29 (Basic Cube Lemma for simulation residuals)
Let R:t→βs and S:t→βu be coinitial steps,
and let t′∈T# be a correct term such that t′⋉t.
Then the following equality between sets of coinitial steps holds:
(R/t′)/(S/t′)=(R/S)/(t′/S).
Proof
If R=S then it is easy to see that the proposition holds, so we can assume that R=S.
Also, note that it is enough to see that labs((R/t′)/(S/t′))=labs(((R/S)/(t′/S)), as we will do that in some cases.
We proceed by induction on t.
Variable t=x. Impossible.
2. 2.
Abstraction, t=λx.u.
Immediate by i.h..
3. 3.
Application, t=pq.
Three cases, depending on the position of R.
3.1
If R is at the root.
Then t=(λx.r)q, and R:(λx.r)q→r{x:=q}.
Then S may be inside r or inside q. In any case,
the situation is:
[TABLE]
Note that (R/t′)/(S/t′) has only one element R1,
namely the step contracting the lambda labeled with ℓ.
Note that R/S also happens to have only one element,
R2:(λx.r∘)q∘→βr∘{x:=q∘}.
It is easy to see that R2/((λℓx.r′)qˉ)={R1}, as required.
2. 3.2
If R is in p.
We consider three subcases, depending on the position of S.
3.2.1
If S is at the root.
Then p=λx.C⟨(λy.u)v⟩ and
(for appropiate C∘,u∘,v∘):
[TABLE]
[TABLE]
Note that labs((R/t′)/(S/t′))={ℓ1,…,ℓn}.
Similarly, labs((R/S)/(t′/S))={ℓ1,…,ℓn},
as required.
2. 3.2.2
If S is in p.
Straightforward by i.h..
3. 3.2.3
If S is in q.
Straightforward since the steps are disjoint.
3. 3.3
If R is in q.
We consider three subcases, depending on the position of S.
3.3.1
If S is at the root. Then p=λx.s
and t=(λx.s)C⟨(λy.u)v⟩.
[TABLE]
[TABLE]
Note that R/S has as many elements as there are free occurrences
of x in s. In particular, S may erase or multiply R.
In turn s′ has a number of free occurrences of x,
more precisely n free occurrences of x,
i.e. the cardinality of the argument of the application.
By Lem. 28, each step in R/S,
when projected onto t′/S yields a set of labels {ℓi,1,…,ℓi,mi}.
So
labs((R/S)/(t′/S))=∑i=1n{ℓi,1,…,ℓi,mi}=labs((R/t′)/(S/t′))
as required.
2. 3.3.2
If S is in p.
Straightforward since the steps are disjoint.
3. 3.3.3
If S is in q.
Straightforward by i.h..
Lemma 30 (Simulation residual of a development)
Let M be a set of coinitial steps in the λ-calculus,
let ρ be a complete development of M,
and let t′∈T# be a correct term such that t′⋉src(ρ).
Then ρ/t′ is a complete development of M/t′.
Proof
Recall that developments are finite and the λ-calculus is finitely branching so,
by König’s lemma, the length of a development of a set M is bounded.
This bound is called the depth of M.
We proceed by induction on the depth of M.
Base case.
Immediate.
2. 2.
Induction.
Then M must be non-empty. Let M={R1,…,Rn,S} for some n≥0,
and let ρ be a complete development of M.
Without loss of generality, we may assume that ρ=Sρ′,
where ρ′ is a complete development of M′=M/S.
Note that the depth of M′ is strictly lesser than the depth of M.
By i.h., ρ′/(t′/S) is a complete development of
M′/(t′/S)=⋃i=1nt′/SRi/S.
By the Basic Cube Lemma (Lem. 29) this set is equal to
⋃i=1nS/t′Ri/t′.
Then (S/t′)(ρ′/(t′/S)) is a complete development of
M/t′=(R1/t′)∪…∪(Rn/t′)∪(S/t′).
To conclude, note that
ρ/t′=Sρ′/t′=(S/t′)(ρ′/(t′/S)) so we are done.
Lemma 31 (Compatibility for developments)
Let M be a set of coinitial steps,
and let ρ and σ be complete developments of M,
and let t′∈T# be a correct term such that t′⋉src(ρ).
Then ρ/t′≡σ/t′.
Proof
This is an immediate consequence of Lem. 30,
since ρ/t′ and σ/t′ are both complete developments of M/t′,
hence permutation equivalent.
The proof of Prop. 8
proceeds as follows. Let ρ≡σ be permutation equivalent derivations in the λ-calculus,
let t′∈T# be a correct term such that t′⋉src(ρ),
and let us show that:
t′/ρ=t′/σ
2. 2.
ρ/t′≡σ/t′
Recall that, in an orthogonal axiomatic rewrite system,
permutation equivalence may be defined as
the reflexive and transitive closure of the
permutation axiom
τ1Rστ2≡τ1Sρτ2,
where
τ1 and τ2 are arbitrary derivations,
σ is a complete development of S/R,
and ρ is a complete development of R/S.
For this definition of permutation equivalence, see for example [28, Def. 2.17],
and .
We prove each item separately:
For the first item, we proceed by induction on the derivation that ρ≡σ.
Reflexivity and transitivity are trivial, so we concentrate on the permutation axiom itself.
Let τ1Rστ2≡τ1Sρτ2,
where
τ1 and τ2 are arbitrary derivations,
σ is a complete development of S/R,
and ρ is a complete development of R/S,
and let us show that t′/τ1Rστ2=t′/τ1Sρτ2.
By Lem. 27 we have that:
[TABLE]
so, without loss of generality,
it suffices to show that for an arbitrary term s′∈T#,
we have s′/Rσ=s′/Sρ.
By definition of simulation residual, the derivations below have the indicated sources and targets:
[TABLE]
Moreover:
[TABLE]
So Rσ/s′ and Sρ/s′ are permutation equivalent.
In particular, they have the same target, so
s′/Rσ=s′/Sρ as required.
2. 2.
The proof of the second item is also by induction on the derivation that ρ≡σ.
Let τ1Rστ2≡τ1Sρτ2,
where
τ1 and τ2 are arbitrary derivations,
σ is a complete development of S/R,
and ρ is a complete development of R/S,
and let us show that τ1Rστ2/t′=τ1Sρτ2/t′.
By Lem. 27 we have that:
[TABLE]
where s′=t′/τ1,
u′=s′/τ1Rσ,
and
u′′=s′/τ1Sρ.
Similarly as before, we can prove that Rσ/s′≡Sρ/s′.
By item 1 of this proposition, we have u′=u′′,
so τ2/u′≡τ2/u′′,
which finishes the proof.
0.A.10 Proof of Lem. 4 – Cube Lemma for simulation residuals
Let ρ:t↠βs and σ:t↠βu be coinitial derivations,
and let t′∈T# be a correct term such that t′⋉t.
The statement of Lem. 4 claims that the following equivalence holds:
[TABLE]
Before proving Lem. 4,
we prove three auxiliary lemmas, all of which are particular cases of the main result.
Lemma 32
(R/t′)/(σ/t′)≡(R/σ)/(t′/σ).
Proof
By induction on σ:
Empty, σ=ϵ.
Immediate since R/t′=R/t′.
2. 2.
Non-empty, σ=Sσ′.
Then:
[TABLE]
Lemma 33
Let M be a set of coinitial steps in the λ-calculus.
Then (M/t′)/(S/t′) and (M/S)/(t′/S)
are equal as sets.
Let M be a set of coinitial steps in the λ-calculus,
and let M also stand for some (canonical) complete development of M.
Then (ρ/t′)/(M/t′)≡(ρ/M)/(t′/M).
Proof
By induction on ρ:
Empty, ρ=ϵ.
Immediate since ϵ=ϵ.
2. 2.
Non-empty, ρ=Rρ′.
Then:
[TABLE]
For the equality marked with (⋆), observe that
(t′/R)/(M/R)=t′/(R⊔M)
and
(t′/M)/(R/M)=t′/(M⊔R)
by definition.
Moreover R⊔M≡M⊔R,
so by Compatibility (Prop. 8),
(t′/R)/(M/R)=(t′/M)/(R/M).
Now the proof of Lem. 4 proceeds by induction on ρ:
Empty ρ=ϵ. Immediate since ϵ=ϵ.
2. 2.
Non-empty, ρ=Rρ′. Then:
[TABLE]
For the equality marked with (⋆), observe that
(t′/σ)/(R/σ)=t′/(σ⊔R)
and
(t′/R)/(σ/R)=t′/(R⊔σ)
by definition.
Moreover σ⊔R≡R⊔σ,
so by Compatibility (Prop. 8),
(t′/σ)/(R/σ)=(t′/R)/(σ/R).
Let σ⊑ρ.
Then στ≡ρ for some τ,
so σ/t′⊑(σ/t′)(τ/(t′/σ))=στ/t′≡ρ/t′
by Compatibility (Prop. 8).
2. 2.
Note that ρσ/t′=(ρ/t′)(σ/(t′/ρ)).
So ρσ/t′ is empty if and only if
ρ/t′ and σ/(t′/ρ) are empty.
3. 3.
Suppose that ρ/t′=ϵ.
Then (ρ/σ)/(t′/σ)=(ρ/t′)/(σ/t′)
by the Cube Lemma (Lem. 4).
4. 4.
By the Cube Lemma (Lem. 4):
(ρ⊔σ)/t′=ρ(σ/ρ)/t′=(ρ/t′)((σ/ρ)/(t′/ρ)≡(ρ/t′)((σ/t′)/(ρ/t′))=(ρ/t′)⊔(σ/t′).
So (ρ⊔σ)/t′ is empty if and only if
ρ/t′ and σ/t′ are empty.
Note that t′/R0⋉ρ/R0 by definition of simulation residual,
so the recursive call can be made.
To see that recursion is well-founded, consider the measure
given by M(ρ,t′)=#labs(ρ/t′).
Let R0 be a coarse step for (ρ,t′).
Observe that R0⊑ρ
so R0/t′⊑ρ/t′ by Coro. 2.
Then labs(R0/t′)⊆labs(ρ/t′) by Prop. 12.
So we have:
To prove Prop. 10 we first prove various auxiliary results.
Lemma 35 (The sieve is a prefix)
Let ρ:t→β∗s and t′⋉t.
Then ρ⇓t′⊑ρ.
Proof
By induction on the length of ρ⇓t′.
If there are no coarse steps for (ρ,t′),
then trivially ρ⇓t′=ϵ⊑ρ.
If there is a coarse step for (ρ,t′),
let R0 be the leftmost such step. Then:
[TABLE]
We also need the following technical lemma:
Lemma 36 (Refinement of a context)
The following are equivalent:
t′⋉C⟨s⟩,
2. 2.
t′ is of the form C′⟨s1′,…,sn′⟩,
where C′ is an n-hole context such that C′⋉C and
si′⋉s for all 1≤i≤n.
Note that n might be [math], in which case C′ is a term.
Moreover, in the implication (1⟹2),
the decomposition is unique,
i.e. the context C′,
the number of holes n≥0,
and the terms s1′,…,sn′
are the unique possible such objects.
Proof
Straightforward by induction on C.
Lemma 37 (Garbage only interacts with garbage)
The following hold:
Garbage only creates garbage.
Let R and S be composable steps in the λ-calculus,
and let t′⋉src(R).
If R creates S and R is t′-garbage,
then S is (t′/R)-garbage.
2. 2.
Garbage only duplicates garbage.
Let R and S be coinitial steps in the λ-calculus
and let t′⋉src(R).
If R duplicates S, i.e.#(S/R)>1,
and R is t′-garbage,
then S is (t′/R)-garbage.
Proof
We prove each item separately:
According to Lévy [25],
there are three creation cases in the λ-calculus.
We consider the three possibilities for R creating S:
1.1
Case I,
C⟨(λx.x)(λy.s)u⟩RβC⟨(λy.s)u⟩SβC⟨s{y:=u}⟩.
Then by Lem. 36,
the term t′ is of the form
C′⟨Δ1,…,Δn⟩
where C′ is an n-hole context such that C′⋉C⟨□u⟩
and Δi⋉(λx.x)(λy.s) for all 1≤i≤n.
Since R is garbage, we know that actually n=0.
So t′⋉C⟨□u⟩ and R/t′:t′↠#t′=t′/R in zero steps.
Hence t′⋉C⟨(λy.s)u⟩,
so by Lem. 36,
the term t′ can be written in a unique way as
C′′⟨Σ1,…,Σm⟩, where C′′ is an m-hole context
such that C′′⋉C⟨□u⟩ and Σi⋉λy.s for all 1≤i≤m.
Since the decomposition is unique and t′⋉C⟨□u⟩,
we conclude that m=0.
Hence S is (t′/R)-garbage.
2. 1.2
Case II,
C⟨(λx.λy.s)ur⟩RβC⟨(λy.s{x:=u})r⟩SβC⟨s{x:=u}{y:=r}⟩.
Then by Lem. 36,
the term t′ is of the form
C′⟨Δ1,…,Δn⟩
where C′ is an n-hole context such that C′⋉C⟨□r⟩
and Δi⋉(λx.λy.s)u for all 1≤i≤n.
Since R is garbage, we know that actually n=0.
So t′⋉C⟨□r⟩ and R/t′:t′↠#t′=t′/R
in zero steps. Hence t′⋉C⟨(λy.s{x:=u})r⟩,
so by Lem. 36, the term t′ can be written in a unique way as
C′′⟨Σ1,…,Σn⟩, where C′′ is an m-hole context such that
C′′⋉C⟨□r⟩ and Σi⋉λy.s{x:=u}
for all 1≤i≤m.
Since the decomposition is unique and t′⋉C⟨□r⟩,
we conclude that m=0.
Hence S is (t′/R)-garbage.
3. 1.3
Case III, C1⟨(λx.C2⟨xs⟩)(λy.u)⟩RβC1⟨C^2⟨(λy.u)s^⟩⟩SβC1⟨C^2⟨u{y:=s^}⟩⟩,
where
C^2=C2{x:=λy.u}
and
t^=t{x:=λy.u}.
Then by Lem. 36,
the term t′ is of the form C′⟨Δ1,…,Δn⟩
where C′ is an n-hole context such that C′⋉C1
and Δi⋉(λx.C2⟨xs⟩)(λy.u) for all 1≤i≤n.
Since R is garbage, we know that actually n=0.
So t′⋉C1 and R/t′:t′↠#t′=t′/R in zero steps.
Hence t′⋉C1⟨C^2⟨(λy.u)s^⟩⟩,
so by Lem. 36, the term t′ can be written in a unique way as
C′′⟨Σ1,…,Σm⟩, where C′′⋉C1 and
Σi⋉C^2⟨(λy.u)s^⟩ for all 1≤i≤m.
Since the decomposition is unique and t′⋉C1, we conclude that m=0.
Hence S is (t′/R)-garbage.
2. 2.
Since R duplicates S,
the redex contracted by S
lies inside the argument of R, that is,
the source term is of the form C1⟨(λx.t)C2⟨(λy.s)u⟩⟩
where the pattern of R is (λx.t)C2⟨(λy.s)u⟩,
and the pattern of S is (λy.s)u.
By Lem. 36,
the term t′ is of the form C′⟨Δ1,…,Δn⟩
where C′ is an n-hole context
such that C′⋉C and Δi⋉(λx.t)C2⟨(λy.s)u⟩ for all 1≤i≤n.
Since R is garbage, we know that n=0.
By Lem. 36,
the term t′ can be written as C′′⟨Σ1,…,Σm⟩
where C′′⋉C1⟨(λx.t)C2⟩
and Σi⋉(λy.s)u for all 1≤i≤m.
Note that t′⋉C1 so t′⋉C1⟨(λx.t)C2⟩,
as can be checked by induction on C1.
Since the decomposition is unique, this means that m=0,
and thus S is garbage.
Proposition 13 (Characterization of garbage)
Let ρ:t↠βs and t′⋉t.
The following are equivalent:
ρ⇓t′=ϵ.
2. 2.
There are no coarse steps for (ρ,t′).
3. 3.
The derivation ρ is t′-garbage.
Proof
It is immediate to check that items 1 and 2 are equivalent, by definition of sieving,
so let us prove 2⟹3 and 3⟹2:
•
(2⟹3)
We prove the contrapositive, namely that if ρ is not garbage,
there is a coarse step for (ρ,t′).
Suppose that ρ is not garbage, i.e.ρ/t′=ϵ.
Then by Prop. 9
we have that ρ can be written as ρ=ρ1Rρ2 where
all the steps in ρ1 are garbage and R is not garbage.
By the fact that garbage only creates garbage (Lem. 37)
the step R has an ancestor R0, i.e.R∈R0/ρ1.
Moreover, since garbage only duplicates garbage (Lem. 37)
we have that R0/ρ1=R.
Given that R is not garbage, we have that:
[TABLE]
Since (R0/t′)/(ρ1/t′)=∅, in particular,
R0/t′=∅, which means that R0 is not garbage.
Moreover, R0⊑ρ1Rρ2=ρ.
So R0 is coarse for (ρ,t′).
•
(3⟹2)
Let ρ be garbage, suppose that there is a coarse step R for (ρ,t′),
and let us derive a contradiction.
Since R is coarse for (ρ,t′),
we have that R⊑ρ,
so R/t′⊑ρ/t′ by Coro. 2.
But ρ/t′ is empty because ρ is t′-garbage,
that is, R/t′⊑σ/t′=ϵ,
which means that R is also t′-garbage.
This contradicts the fact that R is coarse for (ρ,t′).
Lemma 38 (The leftmost coarse step has at most one residual)
Let R0 be the leftmost coarse step for (ρ,t′),
and let σ⊑ρ.
Then #(R0/σ)≤1.
Proof
By induction on the length of σ. The base case is immediate.
For the inductive step, let σ=Sτ⊑ρ.
Then in particular S⊑ρ.
We consider two cases, depending on whether R0=S.
Equal, R0=S.
Then R0/σ=R0/R0τ=∅ and we are done.
2. 2.
Non-equal, R0=S.
First we argue that R0/S has exactly one residual R1∈R0/S.
To see this, we consider two further cases, depending on whether
S is t′-garbage or not:
2.1
If S is not t′-garbage.
Then S⊑ρ and S/t′=∅, so S is coarse for (ρ,t′).
Since R0 is the leftmost coarse step, this means that R is to the left of S.
So R0 has exactly one residual R1∈R0/S.
2. 2.2
If S is t′-garbage.
Let us write the term t as t=C⟨(λx.s)u⟩, where
(λx.s)u is the pattern of the redex S.
By Lem. 36
the term t′ is of the form t′=C′[Δ1,…,Δn],
where C′ is a many-hole context such that C′⋉C
and Δi⋉(λx.s)u for all 1≤i≤n.
We know that S is garbage, so n=0 and t′=C′ is actually
a [math]-hole context (i.e. a term).
On the other hand, R0 is coarse for (ρ,t′), so in particular
it is not t′-garbage.
This means that the pattern of the redex R0 cannot occur inside the argument u
of the redex S.
So S does not erase or duplicate R,
i.e.R0 has exactly one residual R1∈R0/S.
Now we have that R0/Sτ=R1/τ.
We are left to show that #(R0/Sτ)≤1.
Let us show that we may apply the i.h. on R1.
More precisely, observe that τ⊑ρ/S since Sτ⊑ρ.
To apply the i.h. it suffices to show that R1 is coarse for (ρ/S,t′/S).
Indeed, we may check the two conditions
for the definition that R1 is coarse for (ρ/S,t′/S).
2.1
Firstly, R1=R0/S⊑ρ/S holds, as a consequence of the fact that R0⊑ρ.
2. 2.2
Secondly, we may check that R1 is not (t′/S)-garbage.
To see this, i.e. that R1/(t′/S) is non-empty,
we check that labs(R1/(t′/S)) is non-empty.
[TABLE]
For the last step, note that labs(R0/t′) and labs(S/t′) are disjoint,
since R0=S.
Applying the i.h., we obtain that #(R0/Sτ)=#(R1/τ)≤1.
Lemma 39
Let R be a step, let ρ a coinitial derivation,
and let t′⋉src(R).
Suppose that R is not t′-garbage,
and that R/ρ1 is a singleton for every prefix ρ1⊑ρ.
Then R/ρ is not (t′/ρ)-garbage.
Proof
By induction on ρ.
The base case, when ρ=ϵ, is immediate
since we know that R is not garbage.
For the inductive step, suppose that ρ=Sσ.
We know that R/S is a singleton,
so let R1=R/S.
Note that
R1/(t′/S)=(R/S)/(t′/S)=(R/t′)/(S/t′) by Lem. 4.
We know that R/t′ is non-empty, because R is not garbage.
Moreover, labs(R/t′) and labs(S/t′) are disjoint
since R=S.
So #labs((R/t′)/(S/t′))=labs(R/t′) by Lem. 18.
This means that the set R1/(t′/S) is non-empty,
so R1 is not (t′/S)-garbage .
By i.h. we obtain that R1/σ is not ((t′/S)/σ)-garbage,
which means that
(R/Sσ)/(t′/Sσ)=∅,
i.e. that R/Sσ is not garbage, as required.
To be able to apply the i.h., observe that if σ1 is a prefix of σ,
then Sσ1 is a prefix of ρ,
so the fact that R has a single residual after Sσ1
implies that the step R1=R/S has a single residual after σ1.
Proposition 14 (Characterization of garbage-free derivations)
Let ρ:t↠βs and t′⋉t.
The following are equivalent:
ρ is t′-garbage-free.
2. 2.
ρ≡ρ⇓t′.
3. 3.
ρ≡σ⇓t′ for some derivation σ.
Proof
Let us prove 1⟹2⟹3⟹1:
•
(1⟹2)
Suppose that ρ is t′-garbage-free,
and let us show that ρ≡ρ⇓t′
by induction on the length of ρ⇓t′.
If there are no coarse steps for (ρ,t′),
By Prop. 13, any derivation with no coarse steps is garbage.
So ρ is t′-garbage.
Since ρ is garbage-free, this means that ρ=ϵ.
Hence ρ=ϵ=ρ⇓t′, as required.
If there exists a coarse step for (ρ,t′), let R0 be the leftmost such step.
Note that ρ≡R0(ρ/R0) since R0⊑ρ.
Moreover, we claim that ρ/R0 is (t′/R0)-garbage-free.
Let σ⊑ρ/R0 such that (ρ/R0)/σ is garbage
with respect to the term (t′/R0)/σ=t′/R0σ,
and let us show that (ρ/R0)/σ is empty.
Note that:
[TABLE]
Moreover, we know that the derivation ρ/R0σ=(ρ/R0)/σ is
(t′/R0σ)-garbage.
So, given that ρ is t′-garbage-free, we conclude that
ρ/R0σ=ϵ, that is (ρ/R0)/σ=ϵ,
which completes the proof of the claim that ρ/R0 is (t′/R0)-garbage-free.
We conclude as follows:
[TABLE]
•
(2⟹3) Obvious, taking σ:=ρ.
•
(3⟹1)
Let ρ≡σ⇓t′.
Let us show that ρ is garbage-free by induction on the length of σ⇓t′.
If there are no coarse steps for (σ,t′),
then ρ≡σ⇓t′=ϵ, which means that ρ=ϵ.
Observe that the empty derivation is trivially garbage-free.
If there exists a coarse step for (σ,t′),
let R0 be the leftmost such step.
Then ρ≡σ⇓t′=R0((σ/R0)⇓(t′/R0)).
To see that ρ is t′-garbage-free,
let τ⊑ρ such that ρ/τ is garbage,
and let us show that ρ/τ is empty.
We know that ρ/τ is of the following form (modulo permutation equivalence):
[TABLE]
That is, we know that the following derivation is (t′/τ)-garbage,
and it suffices to show that it is empty:
[TABLE]
Recall that, in general, AB is garbage if and only if A and B are garbage (Prop. 9).
Similarly, AB is empty if and only if A and B are empty.
So it suffices to prove the two following implications:
[TABLE]
Let us check that each implication holds:
–
(A)
Suppose that R0/τ is (t′/τ)-garbage,
and let us show that R0/τ is empty.
Knowing that the derivation R0/τ is garbage means that
(R0/τ)/(t′/τ)=∅.
Since R0 is the leftmost step coarse for (σ,t′),
by Lem. 38
we have that #(R0/τ)≤1.
If R0/τ is empty we are done, since this is what we wanted to prove.
The remaining possibility is that R0/τ be a singleton.
We argue that this case is impossible.
Note that for every prefix τ1⊑τ,
the set R0/τ1 is also a singleton,
since otherwise it would be empty, as a consequence of Lem. 38.
So we may apply Lem. 39 and conclude that,
since R0 is not t′-garbage
then R0/τ is not (t′/τ)-garbage.
This contradicts the hypothesis.
–
(B)
Suppose that ((σ/R0)⇓(t′/R0))/(τ/R0) is garbage
with respect to the term (t′/R0)/(τ/R0), and let us show that it is empty.
Since (σ/R0)⇓(t′/R0)
is a shorter derivation than σ⇓t′,
we may apply the i.h. we obtain that
(σ/R0)⇓(t′/R0) is (t′/R0)-garbage-free.
Moreover, the following holds:
[TABLE]
So, by definition of (σ/R0)⇓(t′/R0)
being garbage-free,
the fact that
the derivation
((σ/R0)⇓(t′/R0))/(τ/R0) is garbage
implies that it is empty, as required.
Lemma 40 (The projection after a sieve is garbage)
Let ρ:t↠βs and t′⋉t.
Then ρ/(ρ⇓t′) is (t′/(ρ⇓t′))-garbage.
Proof
By induction on the length of ρ⇓t′.
If there are no coarse steps for (ρ,t′),
then ρ⇓t′=ϵ.
Moreover, by Prop. 13, a derivation with no
coarse steps is garbage. So ρ/(ρ⇓t′)=ρ
is garbage, as required.
If there exists a coarse step for (ρ,t′),
let R0 be the leftmost such step,
and let σ=ρ/R0 and s′=t′/R0.
Then:
[TABLE]
By i.h., σ/(σ⇓s′) is (s′/(σ⇓s′))-garbage.
That is:
[TABLE]
Unfolding the definitions of σ and s′ we have
that:
[TABLE]
Equivalently:
[TABLE]
Finally, by definition of sieve,
[TABLE]
which means that ρ/(ρ⇓t′) is (t′/(ρ⇓t′))-garbage,
as required.
The proof of Prop. 10 is a consequence of the preceding results, namely:
**Proof that ρ⇓t′ is t′-garbage-free and ρ⇓t′⊑ρ.
**Note that ρ⇓t′ is t′-garbage-free by Prop. 14.
Moreover, ρ⇓t′⊑ρ by Lem. 35.
2. 2.
Observe that, given two permutation equivalent derivations ρ and σ,
a step R is coarse for (ρ,t′) if and only if R is coarse for (σ,t′),
since
(R⊑ρ)⟺(R/ρ=∅)⟺(R/σ=∅)⟺(R⊑σ).
Using this observation, the proof is straightforward by induction on the length of ρ⇓t′.
Lemma 42 (Sieving trailing garbage)
Let ρ and σ be composable derivations, and let t′⋉src(ρ).
If σ is (t′/ρ)-garbage, then ρσ⇓t′=ρ⇓t′.
Proof
By induction on the length of ρ⇓t′.
If there are no coarse steps for (ρ,t′),
then by Prop. 13,
the derivation ρ is t′-garbage,
so ρσ is t′-garbage by Prop. 9.
Resorting to Prop. 13
we obtain that ρσ⇓t′=ϵ=ρ⇓t′,
as required.
If there exists a coarse step for (ρ,t′),
let R0 be the leftmost such step.
Then since R0⊑ρ also R0⊑ρσ,
so R0 is a coarse step for (ρσ,t′).
In particular, since there exists at least one coarse step for (ρσ,t′),
let S0 be the leftmost such step.
We argue that R0=S0.
We consider two cases, depending on whether S0 is coarse for (ρ,t′):
If S0 is coarse for (ρ,t′).
Then R0 and S0 are both simultaneously
coarse for (ρ,t′) and for (ρσ,t′).
Note that R0 cannot be to the left of S0,
since then S0 would not be the leftmost coarse step for (ρσ,t′).
Symmetrically, S0 cannot be to the left of R0,
since then R0 would not be the leftmost coarse step for (ρ,t′).
Hence R0=S0 as claimed.
2. 2.
If S0 is not coarse for (ρ,t′).
We argue that this case is impossible.
Note that S0⊑ρσ but it is not the case that S0⊑ρ,
so S0/ρ is not empty.
Note also that S0/ρ⊑σ,
so by Coro. 2
we have that (S0/ρ)/(t′/ρ)⊑σ/(t′/ρ).
Moreover, σ/(t′/ρ)=ϵ is empty because σ is (t′/ρ)-garbage.
This means that (S0/ρ)/(t′/ρ)=ϵ.
Then we have the following chain of equalities:
[TABLE]
To justify the last step, start by noting that no residual of S0 is contracted along the derivation ρ.
Indeed, if S0 had a residual, then ρ=ρ1S1ρ2 where S1∈S0/ρ.
But recall that S0 is the leftmost coarse step for (ρσ,t′) and
ρ1⊑ρσ, so it has at most one residual (Lem. 38).
This means that S0/ρ1=S1, so S0/ρ=∅, which is a contradiction.
Given that no residuals of S0 are contracted along the derivation ρ,
we have that the sets labs(S0/t′) and labs(ρ/t′) are disjoint
which justifies the last step.
According to the chain of equalities above, we have that labs(S0/t′)=∅.
This means that S0 is t′-garbage.
This in turn contradicts the fact that S0 is coarse for (ρσ,t′),
confirming that this case is impossible.
We have just claimed that R0=S0. Then we conclude as follows:
The set F(t′,t) forms a finite lattice.
Let us check all the conditions:
1.1
Partial order.
First let us show that ⊴ is a partial order.
1.1.1
Reflexivity.
It is immediate that [ρ]⊴[ρ] holds since ρ/ρ=ϵ is garbage.
2. 1.1.2
Antisymmetry.
Let [ρ]⊴[σ]⊴[ρ].
This means that ρ/σ and σ/ρ are garbage.
Then:
[TABLE]
Since ρ≡σ we conclude that [ρ]=[σ],
as required.
3. 1.1.3
Transitivity.
Let [ρ]⊴[σ]⊴[τ]
and let us show that [ρ]⊴[τ].
Note that ρ/σ and σ/τ are garbage.
By the fact that the projection of garbage is garbage (Prop. 9)
the derivation (ρ/σ)/(σ/τ) is garbage.
The composition of garbage is also garbage (Prop. 9),
so (σ/τ)((ρ/σ)/(σ/τ)) is garbage.
In general the following holds:
[TABLE]
So since any prefix of a garbage derivation is garbage (Prop. 9)
we conclude that ρ/τ is garbage.
This means that [ρ]⊴[τ], as required.
2. 1.2
Finite.
Let us check that F(t′,t) is a finite lattice, i.e. that it has a finite number of elements.
Recall that F(t′,t) is the set of equivalence classes [ρ] where ρ
is t′-garbage-free.
On one hand, recall that the λ#-calculus is finitely branching and strongly normalizing (Prop. 1).
So by König’s lemma the set of →#-derivations starting from t′
is bounded in length. More precisely, there is a constant M such that
for any s′∈T# and any derivation ρ:t′→#∗s′
we have that the length ∣ρ∣ is bounded by M.
On the other hand, let F=\{\rho\ |\ \rho\text{ is t^{\prime}-garbage-free and }\rho\Downarrow t^{\prime}=\rho\}.
Consider the mapping φ:F(t′,t)→F
given by [ρ]↦ρ⇓t′, and note that:
•
φ does not depend on the choice of representative,
that is, if [ρ]=[σ] then φ([ρ])=ρ⇓t′=σ⇓t′=φ([σ]).
This is a consequence of Lem. 41.
•
φ is a well-defined function, that is φ([ρ])∈F.
This is because φ([ρ])=ρ⇓t′ is t′-garbage-free by Prop. 10.
Moreover, we have that φ([ρ])⇓t′=([ρ]⇓t′)⇓t′=[ρ]⇓t′=φ([ρ]),
which is also a consequence of Lem. 41,
and the fact that [ρ]⇓t′≡ρ (Prop. 10).
•
φ is injective. Indeed, suppose that φ([ρ])=φ([σ]),
that is, ρ⇓t′=σ⇓t′.
Then ρ≡ρ⇓t′=σ⇓t′≡σ
by Prop. 10 since ρ and σ are t′-garbage-free.
Hence [ρ]=[σ].
Since φ:F(t′,t)→F is injective, it suffices to show that F is finite
to conclude that F(t′,t) is finite.
Recall that the λ-calculus is finitely branching, so the number of derivations of a certain length
is finite. To show that F is finite, it suffices to show that the length of derivations in F is
bounded by some constant.
Let ρ be a derivation in F. We have that ρ=ρ⇓t′.
By construction of the sieve, none of the steps of ρ⇓t′ are garbage.
That is ρ=ρ⇓t′=R1…Rn where for all i we have that
Ri/(t′/R1…Ri−1)=∅.
So we have that the length of ρ/t′ is greater than the length of ρ
for all ρ∈F:
[TABLE]
As a consequence given any →β-derivation ρ∈F we have that ∣ρ∣≤∣ρ/t′∣≤M.
This concludes the proof that F(t′,t) is finite.
3. 1.3
Bottom element.
As the bottom element take ⊥(F(t′,t)):=[ϵ].
Observe that this is well-defined since ϵ is t′-garbage-free.
Moreover, let us show that ⊥(F(t′,t)) is the least element.
Let [ρ] be an arbitrary element of F(t′,t)
and let us check that ⊥(F(t′,t))⊴[ρ].
This is immediate since,
by definition, ⊥(F(t′,t))⊴[ρ]
if and only if ϵ/ρ is garbage.
But ϵ/ρ=ϵ is trivially garbage.
4. 1.4
Join.
Let [ρ],[σ] be arbitrary elements of F(t′,t),
and let us check that [ρ]▽[σ] is the join.
First observe that [ρ]▽[σ] is well-defined
i.e. that (ρ⊔σ)⇓t′ is t′-garbage-free,
which is an immediate consequence of Prop. 14.
Moreover, it is indeed the least upper bound of {[ρ],[σ]}:
1.4.1
Upper bound.
Let us show that [ρ]⊴[ρ]▽[σ]; the proof for [σ] is symmetrical.
We must show that ρ/((ρ⊔σ)⇓t′) is garbage.
Note that ρ⊑ρ⊔σ,
so in particular ρ/((ρ⊔σ)⇓t′)⊑(ρ⊔σ)/((ρ⊔σ)⇓t′).
Given that any prefix of a garbage derivation is garbage (Prop. 9),
it suffices to show that (ρ⊔σ)/((ρ⊔σ)⇓t′) is garbage.
This is a straightforward consequence of the fact that projecting after a sieve is garbage (Lem. 40).
2. 1.4.2
Least upper bound.
Let [ρ],[σ]⊴[τ],
and let us show that [ρ]▽[σ]⊴[τ].
We know that ρ/τ and σ/τ are garbage,
and we are to show that ((ρ⊔σ)⇓t′)/τ
is garbage.
Note that (ρ⊔σ)⇓t′⊑ρ⊔σ
as a consequence of the fact that the sieve is a prefix (Lem. 35).
So in particular ((ρ⊔σ)⇓t′)/τ⊑(ρ⊔σ)/τ.
Given that any prefix of a garbage derivation is garbage (Prop. 9),
it suffices to show that (ρ⊔σ)/τ is garbage.
But (ρ⊔σ)/τ≡ρ/τ⊔σ/τ
so we conclude by the fact that the join of garbage is garbage (Prop. 9).
5. 1.5
Top element.
Since F(t′,t) is finite,
its elements are {[τ1],…,[τn]}.
It suffices to take ⊤:=[τ1]▽…▽[τn]
as the top element.
6. 1.6
Meet.
Let [ρ],[σ]∈F(t′,t).
Note that the set L={[τ]∈F(t′,t)∣[τ]⊴[ρ] and [τ]⊴[σ]}
is finite because, as we have already proved, the set F(t′,t) is itself finite.
Then L={[τ1],…,[τn]}.
Take [ρ]△[σ]:=[τ1]▽…▽[τn].
It is straightforward to show that [ρ]△[σ]
thus defined is the greatest lower bound for {[ρ],[σ]}.
2. 2.
The set G(t′,t) forms an upper semilattice.
The semilattice structure of G(t′,t) is inherited from Dλ(t).
More precisely, [ρ]⊑[σ] is declared to hold if ρ⊑σ,
the bottom element is [ϵ], and the join is
[ρ]⊔[σ]=[ρ⊔σ].
Let us check that this is an upper semilattice:
2.1
Partial order.
The relation (⊑) is a partial order on G(t′,t) because it is already a partial order in Dλ(t).
2. 2.2
Bottom element.
It suffices to note that the empty derivation ϵ:t→β∗t
is t′-garbage, so [ϵ]∈G(t′,t)
is the least element.
3. 2.3
Join.
By Prop. 9 we know that if ρ and σ
are t′-garbage then ρ⊔σ is t′-garbage,
so [ρ]⊔[σ] is indeed the least upper bound
of {[ρ],[σ]}.
The derivation ρ1=ρ⇓t′
is t′-garbage-free.
This is as an immediate consequence of Prop. 14,
namely the result of sieving is always garbage-free.
3. 3.
The derivation ρ2=ρ/(ρ⇓t′) is garbage.
This is an immediate consequence of Lem. 40,
namely projection after a sieve is always garbage.
•
Uniqueness, modulo permutation equivalence.
Let ρ≡σ1,σ2
where σ1 is t′-garbage-free,
and σ2 is t′-garbage.
Then we argue that σ1≡ρ1 and σ2≡ρ2.
Since ρ1ρ2≡ρ≡σ1σ2
and sieving is compatible with permutation equivalence (Lem. 41)
we have that ρ1ρ2⇓t′≡σ1σ2⇓t′.
By Lem. 42, we know that trailing garbage does not affect sieving,
hence ρ1⇓t′≡σ1⇓t′.
Moreover, ρ1 and σ1 are garbage-free, which
by Prop. 14 means
that ρ1≡σ1.
This means that ρ1 is unique, modulo permutation equivalence.
Finally, since ρ1ρ2≡σ1σ2 and ρ1≡σ1,
we have that ρ1ρ2/ρ1≡σ1σ2/σ1,
that is ρ2≡σ2.
This means that ρ2 is unique, modulo permutation equivalence.
Lemma 44
Let t′⋉src(ρ)=src(σ).
Then [(ρ⊔σ)⇓t′]=[ρ⇓t′]▽[σ⇓t′].
Proof
Let:
[TABLE]
Note that α and β are garbage by Lem. 40
and hence γ is also garbage, as a consequence of
the facts that the join of garbage is garbage
and that the projection of garbage is garbage (Prop. 9).
Remark that, in general, AB⊔CD≡(A⊔C)(B/(C/A)⊔D/(A/C)).
Then the statement of this lemma is a consequence of the following chain of equalities:
[TABLE]
To prove Thm. 5.1,
let us check that ∫FG is well-defined,
that it is an upper semilattice,
and finally that Dλ(t)≃∫FG
are isomorphic as upper semilattices.
The Grothendieck construction ∫FG is well-defined.
This amounts to checking that G is indeed a lax 2-functor:
1.1
The mapping G is well-defined on objects.
Note that G([ρ])=G(t′/ρ,tgt(ρ)), which is a poset.
Moreover, the choice of the representative ρ of the equivalence class [ρ]
does not matter,
since if ρ and σ are permutation equivalent derivations,
then t′/ρ=t′/σ (by Prop. 8)
and tgt(ρ)=tgt(σ).
2. 1.2
The mapping G is well-defined on morphisms.
Let us check that given [ρ],[σ]∈F
such that [ρ]⊴[σ]
then
G([ρ]↪[σ]):G([ρ])→G([σ]) is a morphism of posets, i.e. a monotonic function.
First, we can see that it is well-defined,
since if [α]∈G([ρ])
then the image G([ρ])([α]↪[σ])=[ρα/σ]
is an element of G([σ]),
since
ρα/σ=(ρ/σ)(α/(σ/ρ))
is garbage, as it is the composition of garbage derivations (Prop. 9):
the derivation ρ/σ is garbage since [ρ]⊴[σ] (by definition),
and the derivation α/(σ/ρ) is garbage since α is garbage (Prop. 9).
Moreover, the choice of representative does not matter,
since if ρ1≡ρ2 and σ1≡σ2 and α1≡α2
then ρ1α1/σ1≡ρ2α2/σ2.
We are left to verify that G([ρ]↪[σ]) is monotonic.
Let [α],[β]∈G([ρ])
such that [α]⊑[β], and let us show that
G([ρ]↪[σ])([α])⊑G([ρ]↪[σ])([β]).
Indeed, α⊑β, so
ρα/σ=(ρ/σ)(α/(σ/ρ))⊑(ρ/σ)(β/(σ/ρ))=ρβ/σ.
3. 1.3
Identity.
Let [ρ]∈F.
Let us check that G([ρ]↪[ρ])=idG([ρ])
is the identity morphism.
Indeed, if [α]∈G([ρ]),
then G([ρ]↪[ρ])([α])=[ρα/ρ]=[α].
4. 1.4
Composition.
Let [ρ],[σ],[τ]∈F
such that [ρ]⊴[σ]⊴[τ].
Let us check that there is a 2-cell
G(([σ]↪[τ])∘([ρ]↪[σ]))⊑G([σ]↪[τ])∘G([ρ]↪[σ]).
Note that
([σ]↪[τ])∘([ρ]↪[σ]):[ρ]⊴[τ]
is a morphism in the upper semilattice F seen as a category.
Moreover, since it is a semilattice, there a unique morphism [ρ]⊴[τ],
namely [ρ]↪[τ], so we have that
([σ]↪[τ])∘([ρ]↪[σ])=[ρ]↪[τ].
Now if [α]∈G[ρ], then:
[TABLE]
so
G(([σ]↪[τ])∘([ρ]↪[σ]))⊑G([σ]↪[τ])∘G([ρ]↪[σ])
as required.
2. 2.
The Grothendieck construction ∫FG is an upper semilattice.
2.1
Partial order.
Recall that ∫FG is always poset
with the order given by (a,b)≤(a′,b′) if and only if
a⊴a′ and G(a↪a′)(b)⊑b′.
2. 2.2
Bottom element.
We argue that (⊥F,⊥G(⊥F)) is the bottom
element. Let ([ρ],[σ])∈∫FG.
Then clearly ⊥F⊴[ρ]. Moreover,
G([⊥F]↪[ρ])(⊥G)=[ϵ/ρ]=[ϵ]⊑[σ].
3. 2.3
Join.
Let us show that (a,b)∨(a′,b′)=(a▽a′,G(a↪(a▽a′))(b)⊔G(a′↪(a▽a′))(b′)).
is the least upper bound of {(a,b),(a′,b′)}.
2.3.1
Upper bound.
Let us show that (a,b)≤(a,b)∨(a′,b′).
Recall that (a,b)∨(a′,b′)=(a▽a,G(a↪(a∨a′))(b)⊔G(a′↪(a▽a′))(b′)).
First, we have a⊴a▽a′.
Moreover, G(a↪(a▽a′))(b)⊑G(a↪(a∨a′))(b)⊔G(a′↪(a▽a′))(b′), as required.
2. 2.3.2
Least upper bound.
Let (a,b)=([ρ],[σ])
and (a′,b′)=([ρ′],[σ′]).
Moreover, let ([ρ′′],[σ′′]) be an upper bound,
i.e. an element
such that ([ρ],[σ])≤([ρ′′],[σ′′])
and ([ρ′],[σ′])≤([ρ′′],[σ′′]).
Let us show that
([ρ],[σ])∨([ρ′],[σ′])≤([ρ′′],[σ′′]).
First note that [ρ]⊴[ρ′′] and [ρ′]⊴[ρ′′]
so [ρ]▽[ρ′]⊴[ρ′′].
Moreover, we know that:
[TABLE]
Let α:=(ρ⊔ρ′)⇓t′.
First we claim that α⊑ρσ⊔ρ′σ′.
Indeed, α=(ρ⊔ρ′)⇓t′⊑ρ⊔ρ′
by Lem. 35, and it is easy to check that
ρ⊔ρ′⊑ρσ⊔ρ′σ′.
What we have to check is the following inequality:
[TABLE]
Indeed:
[TABLE]
3. 3.
There is an isomorphism Dλ(t)≃∫FG of upper semilattices.
As stated, the isomorphism is given by:
[TABLE]
Note that φ and ψ are well-defined mappings, since their value does not
depend on the choice of representative, due, in particular, to the fact that sieving
is compatible with permutation equivalence (Lem. 41).
Let us check that φ and ψ are morphisms of upper semilatices,
and that they are mutual inverses:
3.1
φ** is a morphism of upper semilattices.**
Let us check the three conditions:
3.1.1
Monotonic.
Let [ρ]⊑[σ] in Dλ(t),
and let us show that the following inequality holds:
[TABLE]
We check the two conditions (by definition of ∫FG):
3.1.1.1
On the first hand,
[ρ⇓t′]⊴[σ⇓t′]
since
[TABLE]
Note that this is garbage by Lem. 40.
So by Prop. 9, (ρ⇓t′)/(σ⇓t′) is also garbage,
as required.
2. 3.1.1.2
On the other hand, let us show that
G([ρ⇓t′]↪[σ⇓t′])([ρ/(ρ⇓t′)])⊑σ/(σ⇓t′).
In fact:
[TABLE]
2. 3.1.2
Preserves bottom.
By definition:
φ(⊥Dλ(t))=([ϵ⇓t′],[ϵ/(ϵ⇓t′)])=([ϵ],[ϵ])=(⊥F,⊥G(⊥F)).
3. 3.1.3
Preserves joins.
Let [ρ],[σ]∈Dλ(t), and let us show that
φ([ρ]⊔[σ])=φ([σ])∨φ([σ]).
Indeed, note that:
[TABLE]
where
[TABLE]
and
[TABLE]
where
[TABLE]
It suffices to show that α=α′ and β=β′.
Let us show each separately:
3.1.3.1
Proof of α=α′.
The equality
α=[(ρ⊔σ)⇓t′]=[ρ⇓t′]▽[σ⇓t′]=α′
is an immediate consequence of Lem. 44.
2. 3.1.3.2
Proof of β=β′.
Note that:
[TABLE]
as required.
2. 3.2
ψ** is a morphism of upper semilattices.**
Let us check the three conditions:
3.2.1
Monotonic.
Let ([ρ1],[σ1])≤([ρ2],[σ2]) in ∫FG
and let us show that
ψ([ρ1],[σ1])⊑ψ([ρ2],[σ2])
in Dλ(t).
Indeed, we know that G([ρ1]↪[ρ2])([σ1])⊑[σ2],
that is to say ρ1σ1/ρ2⊑σ2.
Then:
[TABLE]
which means that ρ1σ1⊑ρ2σ2.
This immediately implies that
ψ([ρ1],[σ1])⊑ψ([ρ2],[σ2]).
2. 3.2.2
Preserves bottom.
Recall that the bottom element ⊥(∫FG)
is defined as (⊥F,⊥G(⊥F)), that is
([ϵ],[ϵ]).
Therefore ψ(⊥(∫FG))=[ϵ]=⊥Dλ(t).
3. 3.2.3
Preserves joins.
Let ([ρ1],[σ1]) and ([ρ2],[σ2])
be elements of ∫FG, and let us show that
ψ(([ρ1],[σ1])∨([ρ2],[σ2]))=ψ([ρ1],[σ1])⊔ψ([ρ2],[σ2])).
Let:
[TABLE]
First we claim that α⊑ρ1σ1⊔ρ2σ2.
This is because by Lem. 35
we know that α=(ρ1⊔ρ2)⇓t′⊑ρ1⊔ρ2.
Moreover, it is easy to check that
ρ1⊔ρ2⊑ρ1σ1⊔ρ2σ2.
Using this fact we have:
[TABLE]
as required.
3. 3.3
Left inverse: ψ∘φ=id.
Let [ρ]∈Dλ(t).
Then by Lem. 43:
[TABLE]
4. 3.4
Right inverse: φ∘ψ=id.
Let ([ρ],[σ])∈∫FG.
Note that
ρ is t′-garbage-free
and σ is t′-garbage,
so by Lem. 42
and Prop. 14
we know that ρσ⇓t′=ρ⇓t′≡ρ.
Hence:
[TABLE]
Bibliography35
The reference list from the paper itself. Each links out to its DOI / PubMed record.
1[1] Accattoli, B., Bonelli, E., Kesner, D., Lombardi, C.: A nonstandard standardization theorem. In: POPL ’14, San Diego, CA, USA, January 20-21, 2014. pp. 659–670 (2014)
2[2] Asperti, A., Lévy, J.: The cost of usage in the lambda-calculus. In: 28th Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2013, New Orleans, LA, USA, June 25-28, 2013. pp. 293–300 (2013)
3[3] Barendregt, H.P., Kennaway, J.R., Klop, J.W., Sleep, M.R.: Needed reduction and spine strategies for the lambda calculus. Information and Computation 75 (3), 191–231 (1987)
4[4] Barendregt, H.: The Lambda Calculus: Its Syntax and Semantics, vol. 103. Elsevier (1984)
5[5] Bernadet, A., Lengrand, S.J.: Non-idempotent intersection types and strong normalisation. ar Xiv preprint ar Xiv:1310.1622 (2013)
6[6] Boudol, G.: The lambda-calculus with multiplicities. In: CONCUR’93. pp. 1–6. Springer (1993)
7[7] Bucciarelli, A., Kesner, D., Della Rocca, S.R.: The inhabitation problem for non-idempotent intersection types. In: IFIP International Conference on Theoretical Computer Science. pp. 341–354. Springer (2014)
8[8] Bucciarelli, A., Kesner, D., Ventura, D.: Non-idempotent intersection types for the lambda-calculus. Logic Journal of the IGPL 25 (4), 431–464 (2017)