Polarised Intermediate Representation of Lambda - Gallium

Transcription

Polarised Intermediate Representation of Lambda - Gallium
1
Polarised Intermediate Representation
of Lambda Calculus with Sums
Guillaume Munch-Maccagnoni
Gabriel Scherer
University of Cambridge
Inria Paris-Rocquencourt
Abstractβ€”Manipulating πœ†-terms with extensional sums is
harder than with only pairs and functions. Following recent and
less recent developments in proof theory, we propose an untyped
representationβ€”an intermediate calculusβ€”for the πœ†-calculus with
sums, based on the following principles: 1) Computation is
described as the reduction of pairs of an expression and a
context; the context is represented inside-out, 2) Operations are
represented abstractly by their transition rule, 3) Positive and
negative expressions are respectively eager and lazy; this polarity
is an approximation of the type. We explain the approach from
the ground up, and we review the benefits.
A structure of alternating phases naturally emerges through
the study of normal forms, offering a reconstruction of focusing.
Considering further purity assumption, we obtain maximal multifocusing. As an application, we can deduce an algorithm to decide
the equivalence of normal forms in the simply-typed πœ†-calculus
with sums, and justify it with our intermediate calculus.
I. Introduction
The rewriting theory of πœ†-terms in the presence of extensional sums is sensibly more complex than with pairs
and functions alone. Witness the diversity of approaches to
decide the π›½πœ‚-equivalence in the simply-typed πœ†-calculus with
sums, proposed since 1995: based either on a non-immediate
rewriting theory (Ghani [21]; Lindley [38]) or on normalisation
by evaluation (Altenkirch, Dybjer, Hofmann and Scott [3];
Balat, di Cosmo and Fiore [6]). (In Figure 1 we recall the
simply-typed πœ†-calculus with sums in equational form, see
e.g. [19, 38].)
But, on the side of proof theory, sums become as simple
as products once cast into Gentzen’s sequent calculus [20],
perhaps because sequent calculus has an inherent symmetry
that reflects the categorical duality between sums and products.
For instance, commutations (Figure 2) are not needed (see e.g.
Girard [25]).
A. Abstract-machine-like calculi
Term syntaxes can benefit from the symmetry of sequent
calculus at the condition of following certain principles, among
which treating seriously the duality between expressions and
contexts, as discovered with Curien and Herbelin’s abstractmachine-like calculi [11]. These calculi evidence a correspondence between sequent calculus (Gentzen [20]), abstract
machines (Landin [32, 33]) and continuation-passing style
(Van Wijngaarden [53]). In particular they illustrate the links
that continuation-passing style has with categorical duality
April 2015.
𝑑, 𝑒, 𝑣 β©΄ π‘₯ | πœ†π‘₯.𝑑 | 𝑑 𝑒 | <𝑑; 𝑒> | πœ‹1 (𝑑) | πœ‹2 (𝑑) |
πœ„1 (𝑑) | πœ„2 (𝑑) | 𝛿(𝑑, π‘₯.𝑒, 𝑦.𝑣)
𝐴, 𝐡 β©΄ 𝑋 | 𝐴 β†’ 𝐡 | 𝐴 × π΅ | 𝐴 + 𝐡
(a) Terms and types
Ξ“ ⊒ 𝑑 ∢ 𝐴𝑖
β€”
Ξ“ ⊒ πœ„π‘– (𝑑) ∢ 𝐴1 + 𝐴2
β€”
Ξ“, π‘₯ ∢ 𝐴 ⊒ π‘₯ ∢ 𝐴
𝑖 ∈ {1, 2}
Ξ“ ⊒ 𝑑 ∢ 𝐴 1 + 𝐴2
Ξ“, π‘₯𝑖 ∢ 𝐴𝑖 ⊒ 𝑒𝑖 ∢ 𝐡 (βˆ€π‘–βˆˆ{1,2})
β€”
Ξ“ ⊒ 𝛿(𝑑, π‘₯1 .𝑒1 , π‘₯2 .𝑒2 ) ∢ 𝐡
Ξ“ βŠ’π‘‘βˆΆπ΄
Ξ“ βŠ’π‘’βˆΆπ΅
β€”
Ξ“ ⊒ <𝑑; 𝑒> ∢ 𝐴 × π΅
Ξ“, π‘₯ ∢ 𝐴 ⊒ 𝑑 ∢ 𝐡
β€”
Ξ“ ⊒ πœ†π‘₯.𝑑 ∢ 𝐴 β†’ 𝐡
Ξ“ ⊒ 𝑑 ∢ 𝐴1 × π΄ 2
β€”
Ξ“ ⊒ πœ‹π‘– (𝑑) ∢ 𝐴𝑖
𝑖 ∈ {1, 2}
Ξ“ βŠ’π‘‘βˆΆπ΄β†’π΅
Ξ“ βŠ’π‘’βˆΆπ΄
β€”
Ξ“ ⊒ 𝑑𝑒 ∢ 𝐡
(b) Typing rules
(πœ†π‘₯.𝑑) 𝑒 β‰ˆ 𝑑[𝑒/π‘₯]
πœ‹π‘– (<𝑑1 ; 𝑑2 >) β‰ˆ 𝑑𝑖
𝛿(πœ„π‘– (𝑑), π‘₯1 .𝑒1 , π‘₯2 .𝑒2 ) β‰ˆ 𝑒𝑖 [𝑑/π‘₯𝑖 ]
(c) 𝛽-reductions
𝑑 β‰ˆ πœ†π‘₯.(𝑑 π‘₯)
𝑑 β‰ˆ <πœ‹1 (𝑑); πœ‹2 (𝑑)>
𝑒[𝑑/𝑦] β‰ˆ 𝛿(𝑑, π‘₯1 .𝑒[πœ„1 (π‘₯1 )/𝑦], π‘₯2 .𝑒[πœ„2 (π‘₯2 )/𝑦])
(d) πœ‚-expansions
β€”
Figure 1: πœ†-calculus with sums
(Filinski [18]; Thielecke [52]; Selinger [49]) and with abstract machines (Reus and Streicher [51]; Ager, Biernacki,
Danvy, and Midtgaard [2]; Danvy and Millikin [14]). CurienHerbelin’s calculi are however set in classical logic and include
variants of Scheme’s call/cc control operator.
There are now abstract-machine-like calculi, with various
applications, by various authors, that are based on the same
technique [11, 54, 30, 5, 39, 12, 41, 43, 7, 17, 42, 50]. The first
goal of the article is to adapt the technique to the πœ†-calculus
with sums. (In this article we refer to this new calculus as
Lint .) We remove the full power of call/cc following an idea
of Herbelin [30]. In doing this adaptation, we first advocate
in Section II that the abstract-machine-like calculi can be
summarised via two principles:
the inside-out representation of contexts is primitive,
and:
language constructs are the abstract solutions of
equations given by their machine transitions.
These principles lead us to a first calculus in call-by-name
.
referred to in this article as L⊝
int
Following the latter idea, not all the constructs of the
πœ†-calculus with sums are given as primitives of Lint . But,
an axiom but as an external property, similar in status to
normalisation.
The polarised calculus Lint is introduced in Section III, and
it is a polarised abstract-machine-like calculus consistent with
Girard’s [23, 26, Section 12.B] and Liang and Miller’s [37]
suggestions for a polarised intuitionistic logic. Lint also determines an intuitionistic variant of Danos, Joinet and Schellinx’s
πœ‚
LK𝑝 [13]. It is also meant to be a direct language for (variants of) Levy’s Call-by-push-value models [35, 36], though a
precise correspondence will be the subject of another work.
In the article, we follow Curry’s style: the terms are not
annotated by their types. The polarity is therefore also the least
amount of information that has to be added to the calculus so
that the evaluation order is uniquely determined, before any
reference is made to the types. (We follow the same technique
as appeared previously in M.-M. [39, 43, 42].)
(πœ†π‘₯.𝑑) 𝑒 ≻ 𝑑[𝑒/π‘₯]
πœ‹π‘– (<𝑑1 ; 𝑑2 >) ≻ 𝑑𝑖
𝛿(πœ„π‘– (𝑑), π‘₯1 .𝑒1 , π‘₯2 .𝑒2 ) ≻ 𝑒𝑖 [𝑑/π‘₯𝑖 ]
(a) Main reductions
𝛿(𝑑, π‘₯1 .𝑒1 , π‘₯2 .𝑒2 ) 𝑣
≻ 𝛿(𝑑, π‘₯1 .(𝑒1 𝑣), π‘₯2 .(𝑒2 𝑣))
πœ‹π‘– (𝛿(𝑑, π‘₯1 .𝑒1 , π‘₯2 .𝑒2 )) ≻ 𝛿(𝑑, π‘₯1 .πœ‹π‘– (𝑒1 ), π‘₯2 .πœ‹π‘– (𝑒2 ))
𝛿𝑣 (𝛿(𝑑, π‘₯1 .𝑒1 , π‘₯2 .𝑒2 )) ≻ 𝛿(𝑑, π‘₯1 .𝛿𝑣 (𝑒1 ), π‘₯2 .𝛿𝑣 (𝑒2 ))
where 𝛿𝑣 (𝑑) = 𝛿(𝑑, 𝑦1 .𝑣1 , 𝑦2 .𝑣2 ).
(b) Commutations
β€”
Figure 2: Reduction relation for the πœ†-calculus with sums
they are all retrieved in a methodical way, as we will see.
Therefore we advocate that abstract-machine-like calculi should
be seen as intermediate calculi that reveal the hidden structure
of the termsβ€”an analogy with intermediate representations
used by compilers, which enable program transformation and
analysis. In fact, our principles synthesise (and inherit from)
continuation-passing style, defunctionalisation and direct style,
as we will see.
C. Focusing and untyped normal forms
Focalisation is formulated as the phenomenon by which
certain introduction rules hide cuts, as a consequence of
polarisation. Thus we formulate focalisation as a restriction on
the normalisation of proofs rather than on the structure of the
proofs. From our point of view, focused proofs are retrieved
through the study of normal forms.
Section IV shows that normal forms have a syntactic structure of alternating phases of constructors and abstractors. This
indeed corresponds to focused proof disciplines (Andreoli [4]):
in contrast with the lambda-calculus, Lint would systematically
use invertible rules for each connective’s abstractor, with noninvertible rules only on constructors. We build an πœ‚-equivalence
algorithm which is not type-directed, but inspects the syntactic
structure of normal forms, adapting existing techniques (Abel
and Coquand [10, 1]).
Variable and co-variable scoping fully determines independence of neighbouring phases: if reordering two fragments of a
normal form does not break any variable binding, it should be
semantically correct. This is immediate for abstractor phases
(which corresponds to the easy permutations of invertible
steps), yet requires explicit purity assumptions for constructor
phases, related to the associativity of composition.
Rewriting phases according to their dependencies corresponds to the idea of maximal multi-focusing [9, 8], a canonical
representation of focused derivations. We give a fairly uniform,
syntactic definition of canonical forms as normal forms of
phase-permuting and phase-merging rewriting relations. In
particular, π›½πœ‚-equivalence of typed πœ†-terms with sums can be
decided by comparing the untyped normal forms.
B. Intuitionistic polarisation
Recall that in the presence of fixed points and extensional
sums, any two πœ†-terms of the same type are equivalent, by a
diagonal argument involving the fixed point of the function
πœ†π‘₯.𝛿(π‘₯, 𝑦.πœ„2 (𝑦), 𝑦.πœ„1 (𝑦)) [34, 31, 16]. As a consequence, the
calculus from Figure 1 cannot be considered untyped.
Polarisation, introduced by Girard for classical logic [22],
is a well-studied mean to circumvent a similar degeneracy
that strikes Cartesian-closed categories in the presence of an
𝐴
isomorphism 𝐴 β‰… 𝑅𝑅 natural in 𝐴—by not requiring all the
axioms of a category in the first place. In fact, polarisation
relaxes the hypothesis that composition is associative, in a
meaningful way that admits a positive characterisation with
duploids [41, 43].
For our current matters, polarisation corresponds to the
hypothesis that:
an expression is either positive or negative depending
on the type; this polarity determines whether it
reduces strictly or lazily.
We can assume that such polarities are involved in the validity
of πœ‚-expansions in the πœ†-calculus with sums. Indeed, according
to Danos, Joinet and Schellinx [13] (although in the context
of classical sequent calculus), connectives can be distinguished
upon whether the πœ‚-expansion seems to force or to delay the
reduction. For instance, expanding 𝑒[𝑑/𝑦] into 𝛿(𝑑, π‘₯1 .𝑒[πœ„1 (π‘₯1 )/𝑦],
π‘₯2 .𝑒[ πœ„2 (π‘₯2 )/𝑦 ]) forces the evaluation of 𝑑. They show (with
πœ‚
LK𝑝 ) how by making the reduction match, for each connective,
the behaviour thus dictated by possible πœ‚-expansions, one
essentially finds back polarisation in the sense of Girard. This
is why declaring sums positive (strict) and functions negative
(lazy) ensures that πœ‚-expansions do not modify the evaluation
order.
Polarities only matter when call by value and call by
name differ. In the context of the pure πœ†-calculus, only nontermination can discriminate call by value from call by name.
Polarisation therefore suggests a novel approach to typed πœ†calculi where associativity of composition is not seen as
D. Notations
In the grammars that we define, a dot indicates that variables
before it are bound in what comes after. (For instance with
πœ‡(π‘₯⋅⋆).𝑐, the variables π‘₯ and ⋆ are bound in 𝑐.)
If ⊳ is a rewriting relation, then the compatible closure of
⊳ is denoted by β†’ and the compatible equivalence relation
(← βˆͺ β†’)βˆ— is denoted with ≃. Reductions are denoted with
⊳R and expansions with ⊳E . In this context we define ⊳RE ≝
⊳R βˆͺ ⊳E .
2
E. Acknowledgements
In other words, adjoint reductions state that the destructive
operations of πœ†-calculus are, by analogy with linear algebra,
adjoint to the constructions on contexts (Girard [24]). As
a consequence, they build the context inside-out, as in our
example:
The sections II and III are adapted from the first author’s
PhD thesis [41, Chapter I]β€”many thanks to Pierre-Évariste
Dagand and Olivier Danvy for their criticisms and suggestions.
The authors would like to thank the anonymous reviewers for
their comments. The first author gratefully acknowledges partial support from the ERC project Ecsym and from the French
National Research Agency (ANR-12-JS02-006-01, ANR-10BLAN-0213, ANR-11-BS02-0010).
βŸ¨π›Ώ((πœ†π‘₯.πœ„1 (𝑑)) 𝑒, 𝑦.𝑣, 𝑧.𝑀) β€– β‹†βŸ© ⊳R ⟨(πœ†π‘₯.πœ„1 (𝑑)) 𝑒 β€– [𝑦.𝑣|𝑧.𝑀]β‹…β‹†βŸ©
⊳R βŸ¨πœ†π‘₯.πœ„1 (𝑑) β€– 𝑒⋅[𝑦.𝑣|𝑧.𝑀]β‹…β‹†βŸ©
⊳R βŸ¨πœ„1 (𝑑[𝑒/π‘₯]) β€– [𝑦.𝑣|𝑧.𝑀]β‹…β‹†βŸ©
⊳R βŸ¨π‘£[𝑑[𝑒/π‘₯]/𝑦] β€– β‹†βŸ©
II. A Principled Introduction
to Abstract-Machine-Like Calculi
In this section we explain the principles behind abstractmachine-like calculi and review their advantages in relationship
to the study of πœ†-calculus with sums. We leave expansions aside
until Section III. This exposition complements Wadler’s introduction to term assignments for Gentzen’s classical sequent
calculus LK [54], Curien and the first author’s reconstruction
of LK from abstract machines [12], and Spiwak’s motivation
of abstract-machine-like calculi for the programming language
theory [50].
In this example, the context 𝑒⋅[𝑦.𝑣|𝑧.𝑀]⋅⋆ corresponds to the
expression with a hole 𝛿(β–‘ 𝑒, 𝑦.𝑣, 𝑧.𝑀) read from the inside to
the outside.
B. Solving equations for expressions
We would like to relate the evaluation of terms to their
normalisation. Notice that the reductions from Figure 1c are
not enough to normalize a term such as 𝛿(π‘₯, 𝑦1 .πœ†π‘§.𝑑, 𝑦2 .πœ†π‘§.𝑒) 𝑧.
Commutation rules (Figure 2), coming from natural deduction
in logic, are necessary to obtain the simpler form 𝛿(π‘₯, 𝑦1 .𝑑, 𝑦2 .𝑒).
A distinct solution, as we are going to see, is to represent the
various constructs of the abstract machine abstractlyβ€”as the
solutions to the equations given by their transition rules. Let
us explain this latter idea.
Let us rephrase reductions (1) and (2) as mappings from
stacks to commands:
A. Abstract machines
Abstract machines are defined by a grammar of expressions 𝑑,
a grammar of contexts 𝑒, and rewriting rules on pairs 𝑐 = βŸ¨π‘‘ β€– π‘’βŸ©
(commands). A command ⟨ 𝑑 β€– 𝑒 ⟩ represents the computation of 𝑑 in the context 𝑒. Intuitively, contexts correspond
to expressions with a hole: a distinguished variable β–‘ that
appears exactly once. For instance, the following extension
of the Krivine abstract machine decomposes a term such as
𝛿((πœ†π‘₯.πœ„1 (𝑑)) 𝑒, 𝑦.𝑣, 𝑧.𝑀) into the context 𝛿(β–‘, 𝑦.𝑣, 𝑧.𝑀) and the
redex (πœ†π‘₯.πœ„1 (𝑑)) 𝑒. The abstract machine therefore determines
an evaluation strategyβ€”here, call by nameβ€”for reductions in
Figure 1c.
The contexts are for now stacks 𝑆 of the following form:
𝑑 𝑒 ∢ 𝑆 ↦ βŸ¨π‘‘ β€– π‘’β‹…π‘†βŸ©
As explained by Curien and the first author [12], one can β€œread”
definitions off these mappings. A binder πœ‡ is introduced for the
purpose:
𝑑 𝑒 ≝ πœ‡β‹†.βŸ¨π‘‘ β€– π‘’β‹…β‹†βŸ©
βŸ¨πœ‡β‹†.𝑐 β€– π‘†βŸ© ⊳R 𝑐[𝑆 /⋆]
The symbol ⋆ represents the empty context. The reduction
relation ⊳R on commands is defined by two sets of reduction
rules:
β€’ Main reductions: Variables are substituted, pairs are projected and branches are selected:
In fact, any equation of the form (3), assuming that 𝑓 is
substitutive, can be solved in this way:
𝑓 βˆ— (𝑑) ≝ πœ‡β‹†.βŸ¨π‘‘ β€– 𝑓 (⋆)⟩
Let us pause on the idea of solving equations. This improved
wording has two purposes:
β€’ Emphasise the conscious step taken, to underline that
abstract-machine-like calculi do not serve as replacements
for πœ†-calculiβ€”one still has to determine which equations
are interesting to consider.
β€’ Making us comfortable with the fact that, later in Section III,
there may be two solutions, depending on the polarity.
The empty context ⋆ is now a context variable (or covariable) bound in πœ‡β‹†.𝑐 and is the only one that can be bound
by πœ‡. (Originally, the notation πœ‡ comes from Parigot’s πœ†πœ‡calculus [45], where different co-variables name the different
conclusions of a classical sequent. The idea of restricting to
a single co-variable for modelling intuitionistic sequents with
one conclusion is due to Herbelin [30].)
βŸ¨πœ†π‘₯.𝑑 β€– π‘’β‹…π‘†βŸ© ⊳R βŸ¨π‘‘[𝑒/π‘₯] β€– π‘†βŸ©
⟨<𝑑1 ; 𝑑2 > β€– πœ‹π‘– β‹…π‘†βŸ© ⊳R βŸ¨π‘‘π‘– β€– π‘†βŸ©
βŸ¨πœ„π‘– (𝑑) β€– [π‘₯1 .𝑒1 |π‘₯2 .𝑒2 ]β‹…π‘†βŸ© ⊳R βŸ¨π‘’π‘– [𝑑/π‘₯𝑖 ] β€– π‘†βŸ©
Adjoint reductions: Function applications, projections and
branching build up the context.
βŸ¨π‘‘ 𝑒 β€– π‘†βŸ© ⊳R βŸ¨π‘‘ β€– π‘’β‹…π‘†βŸ©
(1)
βŸ¨πœ‹π‘– (𝑒) β€– π‘†βŸ© ⊳R βŸ¨π‘’ β€– πœ‹π‘– β‹…π‘†βŸ©
βŸ¨π›Ώ(𝑑, π‘₯.𝑒, 𝑦.𝑣) β€– π‘†βŸ© ⊳R βŸ¨π‘‘ β€– [π‘₯.𝑒|𝑦.𝑣]β‹…π‘†βŸ©
(2)
Notice that these reductions define ⊳R as a deterministic
relation: if 𝑐 ⊳R 𝑐 β€² and 𝑐 ⊳R 𝑐 β€³ then 𝑐 β€² = 𝑐 β€³ .
The reductions that we call adjoint are all of the form:
βŸ¨π‘“ βˆ— (𝑑) β€– π‘†βŸ© ⊳R βŸ¨π‘‘ β€– 𝑓 (𝑆)⟩
𝛿(𝑑, π‘₯.𝑒, 𝑦.𝑣) ≝ πœ‡β‹†.βŸ¨π‘‘ β€– [π‘₯.𝑒|𝑦.𝑣]β‹…β‹†βŸ©
In words, destructors are represented abstractly by their transition rule in the machine. The expression πœ‡β‹†.𝑐 maps stacks
to commands thanks to the following reduction rule:
(𝑒 =) 𝑆 β©΄ ⋆ | 𝑒⋅𝑆 | πœ‹1 ⋅𝑆 | πœ‹2 ⋅𝑆 | [π‘₯.𝑒|𝑦.𝑣]⋅𝑆
β€’
𝛿(𝑑, π‘₯.𝑒, 𝑦.𝑣) ∢ 𝑆 ↦ βŸ¨π‘‘ β€– [π‘₯.𝑒|𝑦.𝑣]β‹…π‘†βŸ©
(3)
3
𝑑, 𝑒, 𝑣 β©΄ π‘₯ | πœ„π‘– (𝑑) | πœ‡β‹†.𝑐 | πœ‡(π‘₯⋅⋆).𝑐 | πœ‡<⋆.𝑐1 ; ⋆.𝑐2 >
(𝑒 =) 𝑆 β©΄ ⋆ | 𝑒⋅𝑆 | πœ‹π‘– ⋅𝑆 | [π‘₯.𝑒|𝑦.𝑣]⋅𝑆
𝑐 β©΄ βŸ¨π‘‘ β€– π‘’βŸ©
𝑖 ∈ {1, 2}
βŸ¨πœ‡β‹†.𝑐 β€– π‘†βŸ©
βŸ¨πœ‡(π‘₯⋅⋆).𝑐 β€– π‘‘β‹…π‘†βŸ©
βŸ¨πœ‡<⋆.𝑐1 ; ⋆.𝑐2 > β€– πœ‹π‘– β‹…π‘†βŸ©
βŸ¨πœ„π‘– (𝑑) β€– [π‘₯1 .𝑒1 |π‘₯2 .𝑒2 ]β‹…π‘†βŸ©
(a) Expressions, contexts, and commands
⊳R
⊳R
⊳R
⊳R
𝑐[𝑆 /⋆]
𝑐[𝑑/π‘₯, 𝑆 /⋆]
𝑐𝑖 [𝑆/⋆]
βŸ¨π‘’π‘– [𝑑/π‘₯] β€– π‘†βŸ©
(b) Reductions
πœ†π‘₯.𝑑
≝ πœ‡(π‘₯⋅⋆).βŸ¨π‘‘ β€– β‹†βŸ©
𝑑𝑒
≝ πœ‡β‹†.βŸ¨π‘‘ β€– π‘’β‹…β‹†βŸ©
<𝑑; 𝑒> ≝ πœ‡<⋆.βŸ¨π‘‘ β€– β‹†βŸ©; ⋆.βŸ¨π‘’ β€– β‹†βŸ©>
πœ‹π‘– (𝑑) ≝ πœ‡β‹†.βŸ¨π‘‘ β€– πœ‹π‘– β‹…β‹†βŸ©
𝛿(𝑑, π‘₯.𝑒, 𝑦.𝑣) ≝ πœ‡β‹†.βŸ¨π‘‘ β€– [π‘₯.𝑒|𝑦.𝑣]β‹…β‹†βŸ©
(c) Embedding the πœ†-calculus with sums
Ξ“ βŠ’π‘‘βˆΆπ΄
,
Ξ“βˆ£π‘’βˆΆπ΄ βŠ’Ξ”
,
where Ξ” = ⋆ ∢ 𝐡
βŸ¨π‘‘ β€– π‘’βŸ© ∢ (Ξ“ ⊒ Ξ”)
(d) Judgements
β€”
Ξ“, π‘₯ ∢ 𝐴 ⊒ π‘₯ ∢ 𝐴
Ξ“ ⊒ 𝑑 ∢ 𝐴𝑖
β€”
Ξ“ ⊒ πœ„π‘– (𝑑) ∢ 𝐴1 + 𝐴2
𝑖 ∈ {1, 2}
𝑐 ∢ (Ξ“ ⊒ ⋆ ∢ 𝐴)
β€”
Ξ“ ⊒ πœ‡β‹†.𝑐 ∢ 𝐴
β€”
Ξ“βˆ£β‹†βˆΆπ΄ βŠ’β‹†βˆΆπ΄
𝑐 ∢ (Ξ“ ⊒ ⋆ ∢ 𝐴)
𝑐 β€² ∢ (Ξ“ ⊒ ⋆ ∢ 𝐡)
β€”
Ξ“ ⊒ πœ‡<⋆.𝑐 ; ⋆.𝑐 β€² > ∢ 𝐴 × π΅
Ξ“ βŠ’π‘‘βˆΆπ΄
Ξ“βˆ£π‘’βˆΆπ΄ βŠ’Ξ”
β€”
βŸ¨π‘‘ β€– π‘’βŸ© ∢ (Ξ“ ⊒ Ξ”)
Ξ“ ∣ 𝑆 ∢ 𝐴𝑖 ⊒ Ξ”
β€”
Ξ“ ∣ πœ‹π‘– ⋅𝑆 ∢ 𝐴1 × π΄2 ⊒ Ξ”
𝑐 ∢ (Ξ“, π‘₯ ∢ 𝐴 ⊒ ⋆ ∢ 𝐡)
β€”
Ξ“ ⊒ πœ‡(π‘₯⋅⋆).𝑐 ∢ 𝐴 β†’ 𝐡
Ξ“βˆ£π‘† ∢𝐢 βŠ’Ξ”
Ξ“, π‘₯𝑖 ∢ 𝐴𝑖 ⊒ 𝑑𝑖 ∢ 𝐢 (βˆ€π‘–βˆˆ{1,2})
β€”
Ξ“ ∣ [π‘₯1 .𝑑1 |π‘₯2 .𝑑2 ]⋅𝑆 ∢ 𝐴1 + 𝐴2 ⊒ Ξ”
𝑖 ∈ {1, 2}
Ξ“ βŠ’π‘‘βˆΆπ΄
Ξ“βˆ£π‘† ∢𝐡 βŠ’Ξ”
β€”
Ξ“ ∣ 𝑑⋅𝑆 ∢ 𝐴 β†’ 𝐡 ⊒ Ξ”
(e) Typing of machines in Gentzen’s sequent calculus (wrong)
β€”
Figure 3: A first abstract-machine-like calculus with sums
C. Compatible reduction and its confluence
The category 𝑐 is no longer restricted to occur at the top
level: commands now have sub-commands. Therefore we can
define the compatible closure β†’R of ⊳R in an immediate way:
one has π‘Ž β†’R 𝑏 (for π‘Ž an expression, context, or command)
whenever 𝑏 is obtained from π‘Ž by applying ⊳R on one of its
sub-commands (possibly itself).
To relate this notion of compatible closure to the one of
πœ†-calculus, we however need a closure property similar to the
following one:
if βŸ¨π‘‘ β€– β‹†βŸ© β†’βˆ—R βŸ¨π‘‘β€² β€– β‹†βŸ© then βŸ¨πœ†π‘₯.𝑑 β€– β‹†βŸ© β†’βˆ—R βŸ¨πœ†π‘₯.𝑑′ β€– β‹†βŸ©
D. Typing of machines
The typing of abstract-machine-like calculi in Gentzen’s
sequent calculus is standard. (See Wadler [54], Curien and M.M. [12], for introductions.)
We introduce the type system for the calculus considered so
far in Figure 3e. The correspondence with sequent calculus is
not obtained yet:
1) Left-introduction rules cannot be performed on arbitrary
formulae; they stack.
2) The rule for [ π‘₯.𝑒 | 𝑦.𝑣 ]⋅𝑆 is still the one from natural
deduction.
(4)
The solution is again to introduce an abstract notation for πœ† by
solving the corresponding transition rule:
E. Solving equations for contexts
πœ†π‘₯.𝑑 ∢ 𝑒⋅𝑆 ↦ βŸ¨π‘‘[𝑒/π‘₯] β€– π‘†βŸ©
πœ†π‘₯.𝑑 ≝ πœ‡(π‘₯⋅⋆).βŸ¨π‘‘ β€– β‹†βŸ©
(⋆ βˆ‰ fv(𝑑))
(5)
The calculus in Figure 3 still fails to normalize terms without
using commutations, for instance in the following:
Thus we extend πœ‡ to match patterns on stacks:
βŸ¨πœ‡(π‘₯⋅⋆).𝑐 β€– π‘‘β‹…π‘†βŸ© ⊳R 𝑐[𝑑/π‘₯, 𝑆 /⋆]
βŸ¨π›Ώ(π‘₯, 𝑦1 .πœ†π‘§.𝑑, 𝑦2 .πœ†π‘§.𝑒) 𝑧 β€– β‹†βŸ© βŠ³βˆ—R ⟨π‘₯ β€– [𝑦1 .πœ†π‘§.𝑑|𝑦2 .πœ†π‘§.𝑑]β‹…π‘§β‹…β‹†βŸ©
Thanks to the abstract definition of πœ†, our streamlined definition
of compatible closure implies the clause (4):
The commutation on expressions is only rephrased as a similar
commutation on contexts.
Once again, let us describe the context [π‘₯.𝑒|𝑦.𝑣]⋅𝑆 as a pair
of mappings:
if βŸ¨π‘‘ β€– β‹†βŸ© β†’βˆ—R βŸ¨π‘‘β€² β€– β‹†βŸ© then πœ‡(π‘₯⋅⋆).βŸ¨π‘‘ β€– β‹†βŸ© β†’βˆ—R πœ‡(π‘₯⋅⋆).βŸ¨π‘‘β€² β€– β‹†βŸ©
For the same reason, pairs <𝑑; 𝑒> are represented abstractly as
a pair of transition rules:
<𝑑; 𝑒>
∢
πœ‹1 ⋅𝑆 ↦ βŸ¨π‘‘ β€– π‘†βŸ©
,
πœ„1 (π‘₯) ↦ βŸ¨π‘’ β€– π‘†βŸ©
πœ‹2 ⋅𝑆 ↦ βŸ¨π‘’ β€– π‘†βŸ©
,
πœ„2 (𝑦) ↦ βŸ¨π‘£ β€– π‘†βŸ©
This suggests that the branching context can be written abstractly, by introducing a new binder πœ‡:Μƒ
<𝑑; 𝑒> ≝ πœ‡<⋆.βŸ¨π‘‘ β€– β‹†βŸ©; ⋆.βŸ¨π‘’ β€– β‹†βŸ©>
We summarise in Figure 3 the calculus that we obtain so
far by adding πœ‡ to the abstract machine and by removing the
constructs that can be defined. It is easy to notice that one
has for all 𝑑, 𝑒, 𝑐: ⋆ ∈ fv(𝑒) and ⋆ ∈ fv(𝑐) but ⋆ βˆ‰ fv(𝑑). In
particular the proviso in (5) is always satisfied.
Thanks to the separation between expressions, contexts and
commands, we have a reduction ⊳R which is left-linear and
has no critical pair. As a consequence, β†’R is confluent,
by application of Tait and Martin-Löf’s parallel reduction
technique (see for instance Nipkow [44]). This argument will
hold for all the abstract-machine-like calculi of the article.
[π‘₯.𝑒|𝑦.𝑣]⋅𝑆 = πœ‡Μƒ[π‘₯.βŸ¨π‘’ β€– π‘†βŸ©|𝑦.βŸ¨π‘£ β€– π‘†βŸ©]
(6)
The stack πœ‡[π‘₯
Μƒ 1 .𝑐1 |π‘₯2 .𝑐2 ] is symmetric in shape to the constructor for pairs, and associates to any injection πœ„π‘– the appropriate
command 𝑐1 or 𝑐2 :
Μƒ 1 .𝑐1 |π‘₯2 .𝑐2 ]⟩ ⊳R 𝑐𝑖 [𝑑/π‘₯𝑖 ]
βŸ¨πœ„π‘– (𝑑) β€– πœ‡[π‘₯
(βˆ€π‘– ∈ {1, 2})
In fact, we only consider the contexts [π‘₯.𝑒 | 𝑦.𝑣]⋅⋆ in the
definition of branching:
𝛿(𝑑, π‘₯.𝑒, 𝑦.𝑣) ≝ πœ‡β‹†.βŸ¨π‘‘ β€– πœ‡Μƒ[π‘₯.βŸ¨π‘’ β€– β‹†βŸ©|𝑦.βŸ¨π‘£ β€– β‹†βŸ©]⟩
While 𝑆 was duplicated in (6), this definition is local.
4
(7)
L⊝
int consists in Figure 3 extended as follows:
|𝑦.𝑐 β€² ]
𝑆 β©΄ … | πœ‡[π‘₯.𝑐
Μƒ
𝑒 β©΄ 𝑆 | πœ‡π‘₯.𝑐
Μƒ
βŸ¨π‘‘ β€– πœ‡π‘₯.π‘βŸ©
Μƒ
⊳R 𝑐[𝑑/π‘₯]
βŸ¨πœ„π‘– (𝑑) β€– πœ‡[π‘₯
Μƒ 1 .𝑐1 |π‘₯2 .𝑐2 ]⟩ ⊳R 𝑐𝑖 [𝑑/π‘₯𝑖 ]
[π‘₯.𝑑|𝑦.𝑒]⋅𝑆 is removed from the grammar
[π‘₯.𝑑|𝑦.𝑒]⋅⋆ ≝ πœ‡Μƒ[π‘₯.βŸ¨π‘’ β€– β‹†βŸ©|𝑦.βŸ¨π‘£ β€– β‹†βŸ©]
(a) Stacks and contexts
(b) New reductions
(c) Definition of branching
𝑐 ∢ (Ξ“, π‘₯ ∢ 𝐴 ⊒ Ξ”)
β€”
Ξ“ ∣ πœ‡π‘₯.𝑐
Μƒ
∢𝐴 βŠ’Ξ”
𝑐 ∢ (Ξ“, π‘₯ ∢ 𝐴 ⊒ Ξ”)
𝑐 β€² ∢ (Ξ“, 𝑦 ∢ 𝐡 ⊒ Ξ”)
β€”
|𝑦.𝑐 β€² ] ∢ 𝐴 + 𝐡 ⊒ Ξ”
Ξ“ ∣ πœ‡[π‘₯.𝑐
Μƒ
Ξ“ βŠ’π‘‘βˆΆπ΄
Ξ“βˆ£π‘’βˆΆπ΅ βŠ’Ξ”
β€”
β€”
Ξ“ ∣ 𝑑⋅𝑒 ∢ 𝐴 β†’ 𝐡 ⊒ Ξ”
(d) New rules
Ξ“βˆ£π‘’βˆΆπ΄ βŠ’Ξ”
β€”
β€”
Ξ“ ∣ πœ‹1 ⋅𝑒 ∢ 𝐴 × π΅ ⊒ Ξ”
(e) Admissible rules
β€”
Figure 4: The calculus L⊝
int
We may as well consider the context πœ‡π‘₯.𝑐
Μƒ
which can be
used to represent an arbitrary mapping from expressions to
commands:
on arbitrary formulaeβ€”in particular, contexts 𝑒⋅𝑒 and πœ‹π‘– ⋅𝑒
corresponding to unrestricted left-introduction rules (Figure 4e)
can be defined, using πœ‡,Μƒ as the solutions to the following
equations:
βŸ¨π‘‘ β€– πœ‡π‘₯.π‘βŸ©
Μƒ
⊳R 𝑐[𝑑/π‘₯]
It is easy to see that a context πœ‡π‘₯.
Μƒ βŸ¨π‘’ β€– β‹†βŸ© behaves like the
expression with a hole (πœ†π‘₯.𝑒) β–‘. Now, the existence of the
command βŸ¨πœ‡β‹†.𝑐 β€– πœ‡π‘₯.𝑐
Μƒ β€² ⟩ shows that we cannot consider the
context πœ‡π‘₯.𝑐
Μƒ
among the grammar of stacks 𝑆, since we do not
want to introduce a critical pair in the reduction ⊳R . Therefore
we now make the contexts 𝑒 a strict superset of the stacks 𝑆—
we arrive at Curien and Herbelin’s characterisation of call by
name [11].
|𝑦.𝑐 β€² ] belongs to the syntactic category 𝑆
Notice that πœ‡[π‘₯.𝑐
Μƒ
of stacks. (It no longer describes stacks per se, but any context
against which the πœ‡ reduces.) We may criticise the call-byname bias for the first time, for introducing this arbitrary difference between πœ‡π‘₯.𝑐
Μƒ
and πœ‡[π‘₯
Μƒ 1 .𝑐1 |π‘₯2 .𝑐2 ], while we motivated
both in the same way.
The calculus L⊝
(Figure 4) summarises our development so
int
far. Since ⊳R is still without critical pairs, β†’R is still confluent.
βŸ¨π‘‘ β€– π‘’β‹…π‘’βŸ© ⊳R βŸ¨πœ‡β‹†.βŸ¨π‘‘ β€– π‘’β‹…β‹†βŸ© β€– π‘’βŸ©
βŸ¨π‘‘ β€– πœ‹π‘– β‹…π‘’βŸ© ⊳R βŸ¨πœ‡β‹†.βŸ¨π‘‘ β€– πœ‹π‘– β‹…β‹†βŸ© β€– π‘’βŸ©
The rules from Figure 4e are derivable modulo weakening of
the premiss 𝑒, which is admissible in the standard way. (For
simplicity we did not formulate L⊝
in the multiplicative style
int
with explicit weakening, which would let us state directly that
the unrestricted rules are derivable.)
In words, unrestricted left-introduction rules in L⊝
int hide
cuts. We call focalisation this phenomenon by which certain
introduction rules hide cuts. It is indeed responsible for the
shape of synchronous phases in focusing.
H. Inside-out contexts are primitive
Every context 𝑒 corresponds to a term with a hole E𝑒 [ ].
Thus, every command βŸ¨π‘‘ β€– π‘’βŸ© (or equivalently every expression
πœ‡β‹†.βŸ¨π‘‘ β€– π‘’βŸ©) corresponds to a πœ†-term E𝑒 [𝑑]. We map commands
to expressions as follows:
F. Commutation rules are redundant
The term 𝛿(π‘₯, 𝑦1 .πœ†π‘§.𝑑, 𝑦2 .πœ†π‘§.𝑒) 𝑧 now reduces as follows:
E⋆ β–‘ ≝ β–‘
Eπœ‹π‘– ⋅𝑆 β–‘ ≝ E𝑆 [πœ‹π‘– (β–‘)]
Eπœ‡π‘₯.βŸ¨π‘‘
E𝑉 ⋅𝑆 β–‘ ≝ E𝑆 [β–‘ 𝑉 ]
Μƒ
β€– π‘’βŸ© β–‘ ≝ (πœ†π‘₯.E𝑒 [𝑑]) β–‘
Eπœ‡Μƒ[π‘₯.βŸ¨π‘‘ β€– π‘’βŸ© | 𝑦.βŸ¨π‘’ β€– 𝑒′ ⟩] β–‘ ≝ 𝛿(β–‘, π‘₯.E𝑒 [𝑑], 𝑦.E𝑒′ [𝑒])
βŸ¨π›Ώ(π‘₯, 𝑦1 .πœ†π‘§.𝑑, 𝑦2 .πœ†π‘§.𝑒) 𝑧 β€– π‘†βŸ©
⊳R βŸ¨π›Ώ(π‘₯, 𝑦1 .πœ†π‘§.𝑑, 𝑦2 .πœ†π‘§.𝑒) β€– π‘§β‹…π‘†βŸ©
⊳R ⟨π‘₯ β€– πœ‡Μƒ[𝑦1 .βŸ¨πœ†π‘§.𝑑 β€– π‘§β‹…π‘†βŸ©|𝑦2 .βŸ¨πœ†π‘§.𝑒 β€– π‘§β‹…π‘†βŸ©]⟩
β†’βˆ—R ⟨π‘₯ β€– πœ‡Μƒ[𝑦1 .βŸ¨π‘‘ β€– π‘†βŸ©|𝑦2 .βŸ¨π‘’ β€– π‘†βŸ©]⟩
In words, a command βŸ¨π‘‘ β€– π‘’βŸ© is converted into an expression by
rewinding the adjoint reductions leading to 𝑒 and by expressing
πœ‡Μƒ as πœ† or 𝛿. The definition ensures that β–‘ appears exactly once
in E𝑒 [ ]β€”indeed an expression with a hole.
Conversely, in the presence of πœ‡,Μƒ any expression with a hole
𝐸[ ] can be represented as πœ‡π‘₯.
Μƒ ⟨𝐸[π‘₯] β€– β‹†βŸ© . Furthermore, the
latter gets, after reduction, the canonical form that we expect.
For instance, considering 𝐸1 [ ] ≝ (πœ†π‘₯.𝑑) β–‘ and 𝐸2 [ ] ≝ 𝛿(β–‘ 𝑑,
𝑦.𝑒, 𝑧.𝑣), we have:
In particular, βŸ¨π›Ώ(π‘₯, 𝑦1 .πœ†π‘§.𝑑, 𝑦2 .πœ†π‘§.𝑒) 𝑧 β€– β‹†βŸ© does not reduce into
βŸ¨π›Ώ(π‘₯, 𝑦1 .𝑑, 𝑦2 .𝑒) β€– β‹†βŸ© despite what commutation rules would
prescribe. However, they have the following common reduct:
⟨π‘₯ β€– πœ‡Μƒ[𝑦1 .βŸ¨π‘‘ β€– β‹†βŸ©|𝑦2 .βŸ¨π‘’ β€– β‹†βŸ©]⟩
The same happens with the two other commutation rules. In
other words, commutation rules are redundant in L⊝
int , and at
the same time L⊝
offers
a
novel
reduction
theory
compared
int
to the πœ†-calculus with sums and commutations. In particular,
normalisation in the proof theoretic sense is obtained with the
compatible closure (β†’R ) of evaluation (⊳R ).
βˆ—
Μƒ
πœ‡π‘₯.⟨𝐸
Μƒ
β€– β‹†βŸ©
1 [π‘₯] β€– β‹†βŸ© β†’R πœ‡π‘₯.βŸ¨π‘‘
βˆ—
πœ‡π‘₯.⟨𝐸
Μƒ
Μƒ ⟨π‘₯ β€– π‘‘β‹…πœ‡Μƒ[𝑦.βŸ¨π‘’ β€– β‹†βŸ©|𝑧.βŸ¨π‘£ β€– β‹†βŸ©]⟩
2 [π‘₯] β€– β‹†βŸ© β†’R πœ‡π‘₯.
where πœ‡π‘₯.βŸ¨π‘‘
Μƒ
Μƒ
Μƒ
β€– β‹†βŸ© and 𝑑⋅[πœ‡π‘¦.βŸ¨π‘’
β€– β‹†βŸ©|πœ‡π‘§.βŸ¨π‘£
β€– β‹†βŸ©] are the contexts
that we can expect to obtain from (πœ†π‘₯.𝑑) β–‘ and 𝛿(β–‘ 𝑑, 𝑦.𝑒, 𝑧.𝑣).
In fact, provided that we refine the definition of abstraction as
πœ†π‘₯.𝑑 ≝ πœ‡(𝑦⋅⋆). ⟨ 𝑦 β€– πœ‡π‘₯.βŸ¨π‘‘
Μƒ
β€– β‹†βŸ© ⟩ (as suggested for instance in
Espírito Santo [48]), one has for any context 𝑒:
G. Focalisation
Any proof in the propositional intuitionistic sequent calculus
derivation. Indeed, the typing rule
can be retrieved as an L⊝
int
for πœ‡Μƒ (Figure 4d) allows left-introduction rules to be performed
⟨E𝑒 [𝑑] β€– β‹†βŸ© β†’βˆ—R βŸ¨π‘‘ β€– π‘’βŸ©
5
(It might matter for rewriting purposes that the reduction is
actually a single parallel reduction step.)
In this sense, contexts are equivalent to expressions with a
hole. But we argue that inside-out contexts are more primitive.
β€’ When the reduction is directly defined on expressions 𝐸[𝑑],
an external propertyβ€”the so-called unique context lemmaβ€”
replaces the adjoint reductions in the role of reaching a main
reduction.
β€’ Above, it is more difficult to express inside-out contexts as
expressions with a hole than the contrary, because it requires
an external definition by induction.
Inside-out contexts reveal intermediate steps in the reduction,
which, once they are expressed as part of the formalism, render
such external properties and definitions unnecessary.
is equivalent to the standard πœ‚-expansion of sums:
𝐸[𝑑] ≃RE 𝛿(𝑑, π‘₯.𝐸[πœ„1 (π‘₯)], 𝑦.𝐸[πœ„2 (𝑦)])
(8)
In fact, the traditional πœ‚-expansions of sequent calculus suggests extensionality axioms that all have a regular shape:
𝑑 ⊳E πœ‡(π‘₯⋅⋆).βŸ¨π‘‘ β€– π‘₯β‹…β‹†βŸ©
𝑑 ⊳E πœ‡<⋆.βŸ¨π‘‘ β€– πœ‹1 β‹…β‹†βŸ©; ⋆.βŸ¨π‘‘ β€– πœ‹2 β‹…β‹†βŸ©>
𝑒 ⊳E πœ‡Μƒ[π‘₯.βŸ¨πœ„1 (π‘₯) β€– π‘’βŸ©|𝑦.βŸ¨πœ„2 (𝑦) β€– π‘’βŸ©]
(9)
However, the degeneracy of πœ†-calculus with extensional sums
and fixed points mentioned in Section I-B applies: in untyped
L⊝
, one has 𝑑 ≃RE 𝑒 for any two expressions 𝑑 and 𝑒 by an
int
immediate adaptation of Dougherty [16].
I. A parte: Defunctionalised CPS in direct style
C. Positive sums
The contexts πœ‡π‘₯.𝑐
Μƒ
are functional abstractions of the remainder of the computation, that is, per definition, continuations.
In fact, abstract-machine-like calculi could alternatively be
introduced as the continuity of continuation-passing-style semantics. Indeed, although inside-out contexts are considered in
term calculi since Herbelin’s study of the intuitionistic sequent
calculus [29], such an inverted representation appeared with
continuations as early as Wand [55].
Moreover, Danvy and Nielsen [15] recognised in Wand’s
technique an instance of Reynold’s defunctionalisation [46].
They also mention the β€œisomorphism” between expressions
with a hole and inside-out contexts. In addition, Ager, Biernacki, Danvy, and Midtgaard [2] show how to obtain abstract
machines from evaluators via CPS transformation, closure
conversion, and defunctionalisation.
Thus, in terms of continuation-passing style, abstractmachine-like calculi describe defunctionalised CPS, in direct
style (in the sense that the encodings of πœ†-calculi are local, like
in Figure 3c). But it is novel to affirm that the representation
of contexts inside-out can and should be taken as primitive,
since it is made possible by the idea of representing destructors
abstractly, as the adjoints of context constructors.
Positive sums, unlike the sums of L⊝
, are called by value. A
int
difference is therefore introduced, among expressions, between
values 𝑉 (such as πœ„1 (π‘₯)) and non-values (such as 𝑑 𝑒), as
follows:
β€’
βŸ¨π‘‰ β€– πœ‡π‘₯.π‘βŸ©
Μƒ
⊳R 𝑐[𝑉 /π‘₯]
β€’
,
The reduction of a non-value πœ‡β‹†.𝑐 (including 𝑑 𝑒) takes
precedence over the one defined by the context; in other
words every positive context is a stack.
As a consequence, the equation (9) no longer converts an
arbitrary context into a stack. In addition, it becomes equivalent
to the following πœ‚-expansion for sums restricted to values:
𝐸[𝑉 ] ≃RE 𝛿(𝑉 , π‘₯.𝐸[πœ„1 (π‘₯)], 𝑦.𝐸[πœ„2 (𝑦)])
Thus, when sums are positive, (as observed for the classical
sequent calculus [13],) the extensionality axiom does not
interfere with the order of evaluation.
D. The polarised calculus Lint
Lint is a polarised variant of L⊝
introduced in Figure 5. In
int
addition to the negative connectives β†’, × it proposes positive
pairs and sums (βŠ—, +).
a) Polarisation as a locally-determined strategy: Polarisation, unlike the call-by-value evaluation strategy, assigns
a strict evaluation to sums without changing the evaluation
. The evaluation order
order of the other connectives of L⊝
int
is determined at the level of each command by a polarity
πœ€ ∈ {⊝, +} assigned to every expression and every context,
impacting the reduction rules as follows:
III. Polarisation and Extensional Sums
A. Conversions on expressions vs. on commands
In this section, we consider extensionality principles formulated as expansions ⊳E defined, unlike ⊳R , on expressions and
on contexts. The following expansions are standard:
𝑑 ⊳E πœ‡β‹†.βŸ¨π‘‘ β€– β‹†βŸ©
The reduction of πœ‡Μƒ is restricted to values:
𝑒 ⊳E πœ‡π‘₯.⟨π‘₯
Μƒ
β€– π‘’βŸ© (π‘₯ βˆ‰ fv(𝑒))
They enunciate that one has 𝑑 ≃RE 𝑒 if and only if for all 𝑒,
βŸ¨π‘‘ β€– π‘’βŸ© ≃RE βŸ¨π‘’ β€– π‘’βŸ© (and symmetrically for contexts): there
is only one notion of equivalence which coincides between
expressions, contexts and commands.
B. Extensionality for sums with a regular shape
Converting, as described in Section II-H, contexts 𝑒 into
expressions with a hole 𝐸[ ] (and conversely) shows that the
following:
Negative polarity
Every expression is a value (CBN)
Positive polarity
Every context is a stack (CBV)
Polarities in this sense are similar to Danos, Joinet and
Schellinx’s [13] β€œπ‘‘/π‘žβ€ annotations on the classical sequent
calculusβ€”Lint in fact determines an intuitionistic variant of
πœ‚
their polarised classical logic LK𝑝 .
𝑒 ≃RE πœ‡Μƒ[π‘₯.βŸ¨πœ„1 (π‘₯) β€– π‘’βŸ©|𝑦.βŸ¨πœ„2 (𝑦) β€– π‘’βŸ©]
6
… : Main additions to Figure 4
πœ€β©΄βŠ|+
𝑑, 𝑒
(a) Polarities
Refer to the subscript/superscript convention in Section III-D
π‘‘βŠ , π‘’βŠ β©΄ π‘₯⊝ | πœ‡ βŠβ‹†.𝑐 | πœ‡(π‘₯πœ€ ⋅⋆).𝑐 | πœ‡<⋆.𝑐 ; ⋆.𝑐 β€² >
{ 𝑑+ , 𝑒+ β©΄ π‘₯+ | (𝑉 , π‘Š ) | πœ„π‘– (𝑉 ) | πœ‡+⋆.𝑐
π‘’βŠ β©΄ ⋆ | 𝑉 ⋅𝑆 | πœ‹π‘– ⋅𝑆 | πœ‡π‘₯
Μƒ ⊝.𝑐
𝑒
{ 𝑒 β©΄ ⋆ | πœ‡π‘₯
Μƒ +.𝑐 | πœ‡(π‘₯
Μƒ πœ€1 , π‘¦πœ€2 ).𝑐 | πœ‡[π‘₯
Μƒ πœ€1.𝑐 |π‘¦πœ€2.𝑐]
+
𝑉 , π‘Š β©΄ π‘₯+ | (𝑉 , π‘Š ) | πœ„π‘– (𝑉 ) | π‘‘βŠ
𝑐 β©΄ βŸ¨π‘‘ β€– π‘’βŸ©
𝑆
β©΄ ⋆ | 𝑉 ⋅𝑆 | πœ‹π‘– ⋅𝑆 | 𝑒+
(c) Expressions and values
(b) Commands
(d) Contexts and stacks
β€”
𝐴, 𝐡
𝐴⊝ , 𝐡⊝ β©΄ 𝑋 ⊝ | 𝐴 β†’ 𝐡 | 𝐴 × π΅
{ 𝐴+ , 𝐡+ β©΄ 𝑋+ | 𝐴 βŠ— 𝐡 | 𝐴 + 𝐡
β€”
Ξ“, π‘₯ ∢ 𝐴 ⊒ π‘₯ ∢ 𝐴
β€”
Ξ“βˆ£β‹†βˆΆπ΄ βŠ’β‹†βˆΆπ΄
π‘₯ ∢ 𝐴 stands for π‘₯πœ€ ∢ π΄πœ€
𝑐 ∢ (Ξ“, π‘₯ ∢ 𝐴 ⊒ Ξ”)
β€”
Ξ“ ∣ πœ‡π‘₯.𝑐
Μƒ
∢𝐴 βŠ’Ξ”
𝑐 ∢ (Ξ“ ⊒ ⋆ ∢ π΄πœ€ )
β€”
Ξ“ ⊒ πœ‡ πœ€ ⋆.𝑐 ∢ π΄πœ€
(e) Types
Ξ“ βŠ’π‘‘βˆΆπ΄
Ξ“βˆ£π‘’βˆΆπ΄ βŠ’Ξ”
β€”
βŸ¨π‘‘ β€– π‘’βŸ© ∢ (Ξ“ ⊒ Ξ”)
(f) Identity
𝑐 ∢ (Ξ“, π‘₯ ∢ 𝐴 ⊒ ⋆ ∢ 𝐡)
β€”
Ξ“ ⊒ πœ‡(π‘₯⋅⋆).𝑐 ∢ 𝐴 β†’ 𝐡
𝑐𝑖 ∢ (Ξ“ ⊒ ⋆ ∢ 𝐴𝑖 ) (βˆ€π‘–βˆˆ{1,2})
β€”
Ξ“ ⊒ πœ‡<⋆.𝑐1 ; ⋆.𝑐2 > ∢ 𝐴1 × π΄2
Ξ“ βŠ’π‘‰ ∢𝐴
Ξ“ βŠ’π‘Š ∢𝐡
β€”
Ξ“ ⊒ (𝑉 , π‘Š ) ∢ 𝐴 βŠ— 𝐡
Ξ“ ⊒ 𝑉 ∢ 𝐴𝑖
β€”
Ξ“ ⊒ πœ„π‘– (𝑉 ) ∢ 𝐴1 + 𝐴2
Ξ“ βŠ’π‘‰ ∢𝐴
Ξ“βˆ£π‘† ∢𝐡 βŠ’Ξ”
β€”
Ξ“ ∣ 𝑉 ⋅𝑆 ∢ 𝐴 β†’ 𝐡 ⊒ Ξ”
Ξ“ ∣ 𝑆 ∢ 𝐴𝑖 ⊒ Ξ”
β€”
Ξ“ ∣ πœ‹π‘– ⋅𝑆 ∢ 𝐴1 × π΄2 ⊒ Ξ”
𝑐 ∢ (Ξ“, π‘₯ ∢ 𝐴, 𝑦 ∢ 𝐡 ⊒ Ξ”)
β€”
Ξ“ ∣ πœ‡(π‘₯,
Μƒ 𝑦).𝑐 ∢ 𝐴 βŠ— 𝐡 ⊒ Ξ”
𝑐𝑖 ∢ (Ξ“, π‘₯𝑖 ∢ 𝐴𝑖 ⊒ Ξ”) (βˆ€π‘–βˆˆ{1,2})
β€”
Ξ“ ∣ πœ‡[π‘₯
Μƒ 1 .𝑐1 |π‘₯2 .𝑐2 ] ∢ 𝐴1 + 𝐴2 ⊒ Ξ”
(g) Logic
β€”
(π‘…πœ‡)Μƒ
⟨ π‘‰πœ€ β€– πœ‡π‘₯
Μƒ πœ€.π‘βŸ©
⊳R
𝑐[π‘‰πœ€ /π‘₯πœ€ ]
(π‘…πœ‡)
βŸ¨πœ‡ πœ€ ⋆.𝑐 β€– π‘†πœ€ ⟩
⊳R
𝑐[π‘†πœ€ /⋆]
(𝑅→)
βŸ¨πœ‡(π‘₯πœ€ ⋅⋆).𝑐 β€– π‘‰πœ€ β‹…π‘†βŸ©
⊳R
𝑐[π‘‰πœ€ /π‘₯πœ€ , 𝑆 /⋆]
⊳R
𝑐𝑖 [𝑆/⋆]
⊳R
𝑐[π‘‰πœ€1 /π‘₯πœ€1 , π‘Šπœ€2 /π‘¦πœ€2 ]
⊳R
𝑐𝑖 [π‘‰πœ€π‘– /π‘₯𝑖 𝑖 ]
(𝑅×𝑖 )
(π‘…βŠ—)
(𝑅+𝑖 )
βŸ¨πœ‡<⋆.𝑐1 ; ⋆.𝑐2 > β€– πœ‹π‘– β‹…π‘†βŸ©
πœ€1
πœ€2
⟨(π‘‰πœ€1 , π‘Šπœ€2 ) β€– πœ‡(π‘₯
Μƒ
, 𝑦 ).π‘βŸ©
πœ€
πœ€
βŸ¨πœ„π‘– (π‘‰πœ€π‘– ) β€– πœ‡[π‘₯
Μƒ 11.𝑐1 |π‘₯22.𝑐2 ]⟩
(πΈπœ‡)
(𝐸→)
(𝐸×)
(𝐸 πœ‡)Μƒ
(πΈβŠ—)
(𝐸+)
πœ€
π‘‘πœ€
π‘‘βŠ
π‘‘βŠ
π‘’πœ€
𝑒+
𝑒+
⊳E
⊳E
⊳E
⊳E
⊳E
⊳E
πœ‡ πœ€ ⋆.βŸ¨π‘‘πœ€ β€– β‹†βŸ©
πœ‡(π‘₯⋅⋆).βŸ¨π‘‘βŠ β€– π‘₯β‹…β‹†βŸ©
πœ‡<⋆.βŸ¨π‘‘βŠ β€– πœ‹1 β‹…β‹†βŸ©; ⋆.βŸ¨π‘‘βŠ β€– πœ‹2 β‹…β‹†βŸ©>
πœ‡π‘₯
Μƒ πœ€.⟨π‘₯πœ€ β€– π‘’πœ€ ⟩
πœ‡(π‘₯,
Μƒ 𝑦).⟨(π‘₯, 𝑦) β€– πœ‹βŠ ⟩
πœ‡Μƒ[π‘₯.βŸ¨πœ„1 (π‘₯) β€– 𝑒+ ⟩|𝑦.βŸ¨πœ„2 (𝑦) β€– 𝑒+ ⟩]
(i) Expansions
(h) Reductions
β€”
Figure 5: Lint : grammar (top) β€” simple types (middle) β€” conversions (bottom)
b) The subscript/superscript convention: The polarity of
an expression (π‘‘βŠ or 𝑑+ ) or a context (π‘’βŠ or 𝑒+ ) is defined in the
Figures 5c and 5d. Whenever necessary, the polarity annotation
is part of the grammar: that is variables (π‘₯⊝, π‘₯+), binders
(πœ‡ βŠβ‹†.𝑐, πœ‡+⋆.𝑐), and type variables (𝑋 ⊝, 𝑋+). These notations
conform to the following convention for polarity annotations:
β€’
β€’
What we show with Lint is that all the information relevant
for evaluation can be captured in a grammar, requiring no
complete inspection of the terms, thanks to appropriate polarity
annotations. We only needed to make sure that the conversion
rules are grammatically well defined despite the presence of
annotations, but this is easy to verify.
On the other hand, polarities are no types:
a polarity in superscript (π‘₯πœ€ ) indicates an annotation which
is part of the grammar,
a polarity in subscript (π‘‘πœ€ ) is not part of the grammar and
only asserts that the term has this polarity.
β€’
β€’
c) Polarisation as an approximation of types: A system
of simple types, which corresponds to an intuitionistic sequent
calculus, is provided on top of the Curry-style Lint . It is easy
to see that:
β€’
β€’
if one has Ξ“ ⊒ 𝑑 ∢ π΄πœ€ then 𝑑 has polarity πœ€,
if one has Ξ“ ∣ 𝑒 ∢ π΄πœ€ ⊒ Ξ” then 𝑒 has polarity πœ€.
like in the pure πœ† calculus, it is possible to define arbitrary
fixed-points, and in particular Lint is Turing-complete.
it is possible to obtain ill-formed commands βŸ¨π‘‘βŠ β€– 𝑒+ ⟩ by
reducing well-polarised (but ill-typed) commands such as
⊝
⊝
⟨ πœ‡(π‘₯ ⋅⋆).⟨π‘₯ β€– β‹†βŸ© β€– π‘‘βŠ ⋅𝑒+ ⟩ . (Such mixed commands do
not reduce, and the reader should not expect to see them
appear in the rest of the article.)
d) Confluence: Note that an expression is positive or
negative but not both, and only the empty context (⋆) is both
positive and negative. In particular, πœ‡+⋆.𝑐 is never a value, and
πœ‡π‘₯
Μƒ ⊝.𝑐 is never a stack. With this observation in mind, it is easy
to see that once again ⊳R has no critical pairs. Therefore β†’R
is confluent.
Therefore, for typeable terms, the type determines the order of
evaluation.
Now, calculating on terms together with their typing derivations is tediousβ€”it requires intimate knowledge of the properties of the type system (for instance subject reduction).
With more complex type systems than the simple types, such
properties can even be uncertain.
e) Adjoint equations: Since there are now two distinct
binders πœ‡ βŠβ‹†.𝑐 and πœ‡+⋆.𝑐, adjoint equations βŸ¨π‘“ βˆ— (𝑑) β€– 𝑆 ⟩ ⊳R
βŸ¨π‘‘ β€– 𝑓 (𝑆)⟩ for substitutive 𝑓 now have two solutions depending
7
π‘₯𝐴
πœ†π‘₯ .𝑑
(𝑑 𝑒𝐡 )𝐴
<𝑑; 𝑒>
πœ‹π‘– (𝑑)𝐴
πœ„π‘– (𝑑𝐴 )
𝛿(𝑑, π‘₯.𝑒, 𝑦.𝑣)𝐴
𝐴
and negative type variables 𝑋+, 𝑋 ⊝ of L⊒
. In Figure 6 we
int
define two translations:
≝ π‘₯πœ€
≝ πœ‡(π‘¦πœ€ ⋅⋆).βŸ¨π‘¦πœ€ β€– πœ‡π‘₯
Μƒ πœ€.βŸ¨π‘‘ β€– β‹†βŸ©βŸ©
πœ€
πœ€2
≝ πœ‡ ⋆.βŸ¨π‘’ β€– πœ‡π‘₯
Μƒ .βŸ¨π‘‘ β€– π‘₯πœ€2 β‹…β‹†βŸ©βŸ©
≝ πœ‡<⋆.βŸ¨π‘‘ β€– β‹†βŸ©; ⋆.βŸ¨π‘’ β€– β‹†βŸ©>
≝ πœ‡ πœ€ ⋆.βŸ¨π‘‘ β€– πœ‹π‘– β‹…β‹†βŸ©
≝† πœ‡+⋆.βŸ¨π‘‘ β€– πœ‡π‘₯
Μƒ +.βŸ¨πœ„π‘– (π‘₯+) β€– β‹†βŸ©βŸ©
πœ€
≝ πœ‡ ⋆.βŸ¨π‘‘ β€– πœ‡Μƒ[π‘₯.βŸ¨π‘’ β€– β‹†βŸ©|𝑦.βŸ¨π‘£ β€– β‹†βŸ©]⟩
⊒
NβŸ¦β‹…βŸ§ ∢ Lint β†’ Ξ›βŠ’
Proposition 1. 1) If Ξ“ ⊒L 𝑑 ∢ 𝐴 then 𝑑 ≃RE S⟦NβŸ¦π‘‘βŸ§βŸ§.
int
2) If Ξ“ βŠ’Ξ› 𝑑 ∢ 𝐴 then 𝑑 β‰ˆ N⟦SβŸ¦π‘‘βŸ§βŸ§.
⊒
3) If 𝑑 ≃RE 𝑒 in Lint then NβŸ¦π‘‘βŸ§ β‰ˆ NβŸ¦π‘’βŸ§.
(a) Definition in L⊒
of the operations of Ξ›βŠ’ , inducing a
int
⊒
⊒
translation SβŸ¦β‹…βŸ§ ∢ Ξ› β†’ Lint .
≝
≝
≝
≝
≝
≝
≝
≝
≝
≝
≝
Of course, it cannot be the case that 𝑑 β‰ˆ 𝑒 in Ξ›βŠ’ implies
, unless Lint identifies all expressions.
SβŸ¦π‘‘βŸ§ ≃RE SβŸ¦π‘’βŸ§ in L⊒
int
Indeed, one would have (πœ†π‘₯+.(π‘βŠ πœ†π‘Ž.π‘₯+))(𝑦 𝑧)+ ≃RE π‘βŠ πœ†π‘Ž.(𝑦 𝑧)+
in Lint . For 𝑦 = πœ†π‘§.𝑑+ and π‘βŠ = πœ†π‘§βŠ.πœ‡ βŠβ‹†.𝑐[(π‘§βŠ π‘Ž)+/𝑓 π‘₯+] when
𝑑+ and 𝑐 are arbitrary, this implies βŸ¨π‘‘+ β€– πœ‡π‘₯
Μƒ +.π‘βŸ© ≃RE 𝑐[𝑑+/𝑓 π‘₯+]β€”
where the focalising substitution [ 𝑒+/𝑓 π‘₯+ ] is defined using
focalisation in the sense of Section II-G:
π‘₯𝐴
NβŸ¦π‘βŸ§
πœ†π‘₯𝐴 .NβŸ¦π‘βŸ§
<NβŸ¦π‘βŸ§; NβŸ¦π‘ β€² ⟧>
πœ„π‘– (NβŸ¦π‘‰ ⟧)
E𝑒 [NβŸ¦π‘‘βŸ§]
β–‘
E𝑆 [πœ‹π‘– (β–‘)]
E𝑆 [β–‘ NβŸ¦π‘‰ ⟧]
(πœ†π‘₯𝐴 .NβŸ¦π‘βŸ§) β–‘
𝛿(β–‘, π‘₯𝐴 .NβŸ¦π‘βŸ§, 𝑦𝐡 .NβŸ¦π‘ β€² ⟧)
Definition 2. Unrestricted expressions and contexts are defined
as follows (in addition to πœ„π‘– (𝑑+ ) defined as in Figure 6a):
𝑑+ ⋅𝑒 ≝† πœ‡π‘₯
Μƒ ⊝.βŸ¨π‘‘+ β€– πœ‡π‘¦
Μƒ +.⟨π‘₯⊝ β€– 𝑦+β‹…π‘’βŸ©βŸ©
𝑉 β‹…π‘’βŠ ≝‑ πœ‡π‘₯
Μƒ ⊝.βŸ¨πœ‡ βŠβ‹†.⟨π‘₯⊝ β€– 𝑉 β‹…β‹†βŸ© β€– π‘’βŠ ⟩
πœ‹π‘– β‹…π‘’βŠ ≝‑ πœ‡π‘₯
Μƒ ⊝.βŸ¨πœ‡ βŠβ‹†.⟨π‘₯⊝ β€– πœ‹π‘– β‹…β‹†βŸ© β€– π‘’βŠ ⟩
(†: When 𝑑+ is not a value—‑: When π‘’βŠ is not a stack.)
⊒
(b) Translation NβŸ¦β‹…βŸ§ ∢ Lint β†’ Ξ›βŠ’
β€”
Figure 6: Translations between Ξ›βŠ’ and L⊒
int
Now let us call (𝛽) the following equation:
βŸ¨π‘‘+ β€– πœ‡π‘₯
Μƒ +.π‘βŸ© βŠ³π›½ 𝑐[𝑑+/𝑓 π‘₯+]
on the polarity of 𝑆:
βˆ—
πœ€
πœ€
For instance there are actually one version of branching 𝛿(𝑑,
π‘₯.𝑒, 𝑦.𝑣)πœ€ for each πœ€ ∈ {⊝, +}, only one of which is a value,
and similarly for function application: (𝑑 𝑒)πœ€ .
This splitting reflects the fact that according to polarisation,
𝛿(𝑑, π‘₯.𝑒, 𝑦.𝑣) is either strict or lazy depending on whether 𝑒 and
𝑣 are strict or lazy. This observation is not an artefact and has
several implications studied elsewhere:
β€’
(𝛽)
which is equivalent to the associativity of the composition in
Lint (See M.-M. [43]).
In Lint one can already derive modulo ≃RE all the conversions of Ξ›βŠ’ with the following restriction: the arguments of πœ†
and 𝛿 are restricted to values. Using (𝛽) one can substitute
positive variables, which are values, with arbitrary positive
expressions. Therefore:
𝑓 (𝑑) ≝ πœ‡ ⋆.βŸ¨π‘‘ β€– 𝑓 (⋆)⟩
β€’
⊒
SβŸ¦β‹…βŸ§ ∢ Ξ›βŠ’ β†’ Lint
These translations are well defined: if Ξ“ ⊒Lint 𝑑 ∢ 𝐴 then Ξ“ βŠ’Ξ›
NβŸ¦π‘‘βŸ§ ∢ 𝐴 and if Ξ“ βŠ’Ξ› 𝑑 ∢ 𝐴 then Ξ“ ⊒Lint SβŸ¦π‘‘βŸ§ ∢ 𝐴. In addition:
where 𝐴 has polarity πœ€ and 𝐡 has polarity πœ€2 .
†: when 𝑑𝐴 is not a value.
N⟦π‘₯𝐴 ⟧
NβŸ¦πœ‡π΄ ⋆.π‘βŸ§
NβŸ¦πœ‡(π‘₯𝐴 ⋅⋆).π‘βŸ§
NβŸ¦πœ‡<⋆.𝑐 ; ⋆.𝑐 β€² >⟧
NβŸ¦πœ„1 (𝑉 )⟧
NβŸ¦βŸ¨π‘‘ β€– π‘’βŸ©βŸ§
E⋆ β–‘
Eπœ‹π‘– ⋅𝑆 β–‘
E𝑉 ⋅𝑆 β–‘
Eπœ‡π‘₯Μƒ 𝐴 .𝑐 β–‘
Eπœ‡[π‘₯
Μƒ 𝐴 .𝑐 | 𝑦𝐡 .𝑐 β€² ] β–‘
,
Proposition 3. If 𝑑 β‰ˆ 𝑒 in Ξ›βŠ’ then SβŸ¦π‘‘βŸ§ ≃RE𝛽 SβŸ¦π‘’βŸ§ in L⊒
.
int
A programming language based on Lint would define the
polarity of an expression by a shallow inspection. Function
application would require an explicit annotation determining
the polarity of the result; such an information could be
synthesised during type inference. (M.-M. [42].)
One should not seek to model Lint in a category directly:
composition is not associative, but defines a pre-duploid.
(M.-M. [43].)
In fact, in (untyped) Lint extended with (𝛽), one can apply
the same diagonal argument as in Section III-B, and therefore
(𝛽) is incoherent in Lint , as we claimed. But, (𝛽) is compatible
with L⊒
in the following sense:
int
Lemma 4. Let 𝑑+ be an expression such that ⊒L 𝑑+ ∢ 𝐡+ .
int
There exists a closed value 𝑉+ such that βŸ¨π‘‘+ β€– β‹†βŸ© βŠ³βˆ—R βŸ¨π‘‰+ β€– β‹†βŸ©,
and therefore 𝑑+ ≃RE 𝑉+ .
Proof: This is a corollary of the adequacy lemma form M.M. [39], adapted to intuitionistic logic (as in [40]). Adapting
the polarised orthogonality-based realizability from [39] is
straightforward: any intuitionistic proof can be seen as a
classical proof. Now, the linearity restriction on ⋆ implies
in Section II-C,
⋆ βˆ‰ fv(𝑉+ ) as we already noticed for L⊝
int
therefore we can conclude 𝑑+ ≃RE 𝑉+ β€”in words, intuitionistic
computation is referentially transparent.
β– 
E. Relating Lint to the πœ†-calculus with sums
We relate typed restrictions of Lint (minus the positive pair
βŠ—) and the πœ†-calculus with sums. Let us denote with L⊒
int
and Ξ›βŠ’ the simply-typed Lint (without βŠ—) and πœ†-calculus with
sums, that is to say restricted by the typing judgements from
Figures 5 (minus the positive pair βŠ—) and 1 respectively. For
simplicity we will omit the typing judgements and may choose
to write explicit type annotations (à la Church). We give these
systems the same grammar of types by assuming that the set
of type variables 𝑋 of Ξ›βŠ’ coincides with the set of positive
Proposition 5. L⊒
satisfies (𝛽) whenever 𝑑+ is closed.
int
In a separate note, we prove that (𝛽) actually belongs to
the observational closure of ≃R . The technique, based on
8
example, βŸ¨πœ„1 (π‘₯⊝) β€– β‹†βŸ© (πΈπœ‡)-expands into the phase-separated
command βŸ¨πœ„1 (πœ‡βŠβ‹†.⟨π‘₯⊝ β€– β‹†βŸ©) β€– β‹†βŸ©.
polarised realizability, generalises beyond simple typesβ€”for
instance, extensions to second- and higher-order are immediate.
Polarisation therefore offers an approach to typed πœ†-calculi
where the associativity of composition is an external property
similar to normalisation. If we adopt this point of view, then it
is not surprising that the rewriting theory of the πœ†-calculus with
sums is complex, and that it is even computationally incoherent
in the presence of fixed-points.
Lemma 6. Any valid (β†’R )-normal form is (β†’Eβˆ— πœ‡,πœ‡Μƒ )-expansible
to a unique focused form 𝑓 .
B. Algorithmic equality for expansion rules
We define the algorithmic equality relation (≑A ) as a system
of inference rules on pairs of commands, which captures
extensional equivalence: (≑A ) decides (≃E ) on β†’R -normal
terms. If we worked on typed normal forms, we could perform
maximal type-directed πœ‚-expansion; for the sake of generality
and its intrinsic interest, we work with untyped normal forms.
The purely syntactic approch is to perform, in both commands
to be compared, the πœ‚-expansions for the abstractors that appear
in either commands. This untyped equivalence is inspired by
previous works [10, 1] that compute πœ‚-equivalence of πœ†-terms
by looking at the terms only, doing an πœ‚-expansion when either
term starts with a πœ†.
In Figure 8a we define (≑A ) by mutual recursion with a
sub-relation (≑A𝑁 ) that only relates 𝑅-normal forms.
We have omitted the symmetric counterparts of the abstractor rules. In the two last cases, we consider that (≑A ) is defined
on expressions and contexts as the congruence closure of (≑A )
on sub-commands. For example, πœ„1 (πœ‡β‹†.𝑐) ≑A 𝑑′ if and only if
𝑑′ is of the form πœ„1 (πœ‡β‹†.𝑐 β€² ) for some 𝑐 β€² such that 𝑐 ≑A 𝑐 β€² . We
use the term algorithmic because this equivalence is almost
syntax-directed. If both sides of the equivalence start with an
abstractor application, there is a non-syntax-directed choice of
which side to inspect first: for 𝑑, 𝑒 fixed there may be several
distinct derivations of 𝑑 ≑A 𝑒.
Notice that, whenever 𝑐1 is aβ†’R -normal form, then the substitutions involved in the definition of algorithm equivalence,
such as 𝑐1 [(π‘₯1 , π‘₯2 )/π‘₯+], are strongly normalizing as well. Indeed,
while the substitution may create new reduction opportunities,
for example in ⟨π‘₯+ β€– πœ‡(𝑦1 , 𝑦2 ).𝑐 β€² ⟩, those reductions would in
turn only create substitutions of variables for variables ([π‘₯1/𝑦1 ]
and [π‘₯2/𝑦2 ] in the example above), which do not produce any
new redexes.
IV. The Structure of Normal Forms
and Their Equivalence
This section studies the β†’R -normal forms of Lint . Their
equivalence can be defined and decided by equivalence relations that are more uniform than the rewriting-based approaches targeting πœ†-calculus.
A. The phase structure of normal forms
Figure 7a describes the syntax of valid R-normal forms,
where a constructor is never opposed to an abstractor for
another connective; for example βŸ¨πœ„1 (𝑑) β€– πœ‡(π‘₯,
Μƒ 𝑦).π‘βŸ© would be an
invalid normal form. A normal command of the form βŸ¨π‘‰+ β€– β‹†βŸ©
or ⟨π‘₯⊝ β€– π‘†βŠ ⟩ starts with a constructor, head computation is
finished. A command of the form ⟨π‘₯+ β€– 𝑒+ ⧡ πœ‡π‘₯
Μƒ +.π‘βŸ© (any 𝑒+ that
+
⊝
is not a πœ‡π‘₯
Μƒ .𝑐) or βŸ¨π‘‘βŠ ⧡ πœ‡ ⋆.𝑐 β€– β‹†βŸ© starts with an abstractor
whose computation is blocked by the lack of information on
the opposite side. We thus decompose the structure of normal
commands as a succession of phases, with constructor phases
𝑐 𝐢 and abstractor phases 𝑐 𝐷 . Remark that functions have
their constructor and abstractors inversed with respect to their
constructor and destructor in πœ† calculi: function introduction
πœ‡(π‘₯⋅⋆).𝑐 is an abstractor expression, while function application
𝑒⋅𝑒 is a context constructor.
Figure 7b describes the structure of phase-separated normal
forms. We call them focused forms. A focused form 𝑓 is a
focused command 𝑐 πœ™ for some phase variable πœ™, which is either
𝐢 or 𝐷—we will write πœ™Μ„ for the phase opposite to πœ™. A focused
command 𝑐 πœ™ is either a focused value 𝑉 πœ™ against ⋆, or a
focused stack 𝑆 πœ™ against some variable π‘₯. Constructor values
𝑉 𝐢 start with a head expression constructor, followed by other
head constructors until πœ‡ βŠβ‹†.𝑓 or a variable is reached, ending
the phase. Constructor stacks 𝑆 𝐢 are non-empty compositions
of stack constructors ended by a πœ‡π‘₯
Μƒ +.𝑓 . Abstractor values or
stacks are either a variable or ⋆, or a πœ‡-form that immediately
ends the phase. An informal way to think of focused commands,
which correspond to our intuition of normal sequent proofs, is
to see the focused command ⟨π‘₯ β€– 𝑆 πœ™ ⟩ as a β€œplay on π‘₯”, and
correspondingly βŸ¨π‘‰ πœ™ β€– β‹†βŸ© as a β€œplay on ⋆”.
This syntactic phase separation resembles focused proofs [4].
We work on an untyped calculus, so we cannot enforce that
phases be maximally long; but otherwise constructor phases
correspond to non-inversible, or synchronous rules, while
abstractor phases correspond to inversible, or asynchronous
inference rules.
Not all β†’R -normal forms are focused forms, as they may not
respect the constraint that phase change be explicitly marked
by a πœ‡-form. But a normal form can be easily rewritten into a
focused form: inserting a phase change is a valid expansion. For
Lemma 7. Soundness of algorithmic equivalence: if 𝑑 ≑A 𝑒
then 𝑑 ≃RE 𝑒.
C. Completeness of algorithmic equality on normal forms
Abel and Coquand [1] discuss the problem of transitivity
of their syntax-directed algorithmic equality: while it morally
captures our intuition of β€œgood” πœ‚-equivalences, it fails to
account for some seemingly-absurd equivalences that can be
derived on untyped terms, such as πœ†π‘₯.(𝑑 π‘₯) β‰ƒπœ‚ <πœ‹1 𝑑; πœ‹2 𝑑>, the
transitive combination of πœ†π‘₯.(𝑑 π‘₯) β‰ƒπœ‚ 𝑑 and 𝑑 β‰ƒπœ‚ <πœ‹1 𝑑; πœ‹2 𝑑>.
To accept those absurd equivalences, Abel and Coquand had
to extend their relation with type-incorrect rules such as:
𝑑 ≑A 𝑛 π‘₯ πœ‹1 𝑛 ≑A π‘Ÿ πœ‹2 π‘Ÿ ≑A 𝑠
β€”
πœ†π‘₯.(𝑑 π‘₯) ≑A <π‘Ÿ; 𝑠>
This change suffices to regain transitivity and capture untyped πœ‚-conversion. Unfortunately, this technique requires a
number of additional rules quadratic in the number of different
9
βŸ¨π‘‰+ β€– β‹†βŸ©
⟨π‘₯+ β€– 𝑒+ ⧡ πœ‡π‘₯
Μƒ +.π‘βŸ©
⊝
⟨π‘₯ β€– π‘†βŠ ⟩
βŸ¨π‘‘βŠ ⧡ πœ‡ βŠβ‹†.𝑐 β€– β‹†βŸ©
𝑓 = 𝑐 πœ™ β©΄ ⟨π‘₯ β€– 𝑆 πœ™ ⟩ | βŸ¨π‘‰ πœ™ β€– β‹†βŸ©
π‘‰πœ™
+
𝑉
{𝑉 𝐷
𝐢±
where
𝐢±
πœ™ β©΄ 𝐢 | 𝐷 (phase: constructors, abstractors)
β©΄ π‘₯ | (𝑉 , 𝑉 ) | πœ„1 (𝑉 ) | πœ„2 (𝑉 𝐢± )
β©΄ π‘₯⊝ | πœ‡(π‘₯⋅⋆).𝑓 | πœ‡<⋆.𝑓 ; ⋆.𝑓 >
𝐢
𝐢±
π‘†πœ™
𝑆𝐷
{𝑆 𝐢
𝑉 𝐢± β©΄ 𝑉 𝐢 | πœ‡ βŠβ‹†.𝑓
|𝑦.𝑓 ] | πœ‡(π‘₯,
β©΄ ⋆ | πœ‡[π‘₯.𝑓
Μƒ
Μƒ 𝑦).𝑓
β©΄ ⋆ | 𝑉 𝐢± ⋅𝑆 𝐢± | πœ‹π‘– ⋅𝑆 𝐢±
𝑆 𝐢± β©΄ 𝑆 𝐢 | πœ‡π‘₯
Μƒ +.𝑓
(a) ⊳R -normal forms
(b) Focused forms
β€”
Figure 7: Normal and focused forms
𝑐 β†’βˆ—R 𝑐1 (↛)
𝑐1 ≑A 𝑐1β€²
(β†š)𝑐1β€² β†βˆ—R 𝑐 β€²
𝑁
β€”
𝑐 ≑A 𝑐 β€²
𝑐[(π‘₯1 , π‘₯2 )/π‘₯+] ≑A 𝑐 β€² [(π‘₯1 , π‘₯2 )/π‘₯+]
β€”
⟨π‘₯+ β€– πœ‡(π‘₯1 , π‘₯2 ).π‘βŸ© ≑A 𝑐 β€²
A-pair
𝑁
𝑐[(π‘₯⋅⋆)/𝛼] ≑A 𝑐 β€² [(π‘₯⋅⋆)/⋆]
β€”
βŸ¨πœ‡(π‘₯⋅⋆).𝑐 β€– π›ΌβŸ© ≑A 𝑐 β€²
A-R
𝑐2 [πœ„2 π‘₯2 /π‘₯+] ≑A 𝑐 β€² [πœ„2 π‘₯2 /π‘₯+]
𝑐1 [πœ„1 π‘₯1 /π‘₯+] ≑A 𝑐 β€² [πœ„1 π‘₯1 /π‘₯+]
β€”
+
⟨π‘₯ β€– πœ‡[π‘₯
Μƒ 1 .𝑐1 |π‘₯2 .𝑐2 ]⟩ ≑A 𝑐 β€²
A-sum
𝑁
A-fun
𝑁
𝑐1 [πœ‹1 β‹… ⋆ /⋆] ≑A 𝑐 β€² [πœ‹1 β‹… ⋆ /⋆]
𝑐2 [πœ‹2 β‹… ⋆ /⋆] ≑A 𝑐 β€² [πœ‹2 β‹… ⋆ /⋆]
β€”
βŸ¨πœ‡<⋆.𝑐1 ; ⋆.𝑐2 > β€– β‹†βŸ© ≑A 𝑐 β€²
A-neg-pair
𝑁
πœ‹1𝐢 ≑A πœ‹2𝐢
β€”
⟨π‘₯⊝ β€– πœ‹1𝐢 ⟩ ≑A ⟨π‘₯⊝ β€– πœ‹2𝐢 ⟩
𝑉1𝐢 ≑A 𝑉2𝐢
β€”
βŸ¨π‘‰1𝐢 β€– β‹†βŸ© ≑A βŸ¨π‘‰2𝐢 β€– β‹†βŸ©
A-cocong
𝑁
A-cong
𝑁
(a) Algorithmic equivalence
𝑐[(π‘₯1 , π‘₯2 )/𝑉+ ] ≑A+ 𝑐 β€² [(π‘₯1 , π‘₯2 )/𝑉+ ]
A+pair
β€”
βŸ¨π‘‰+ β€– πœ‡(π‘₯1 , π‘₯2 ).π‘βŸ© ≑A+ 𝑐 β€²
𝑁
𝑐[(π‘₯⋅⋆)/π‘†βŠ ] ≑A+ 𝑐 β€² [(π‘₯⋅⋆)/π‘†βŠ ]
A+fun
β€”
βŸ¨πœ‡(π‘₯⋅⋆).𝑐 β€– π‘†βŠ ⟩ ≑A+𝑁 𝑐 β€²
𝑐1 [πœ„1 π‘₯1 /𝑉+ ] ≑A 𝑐 β€² [πœ„1 π‘₯1 /𝑉+ ]
𝑐2 [πœ„2 π‘₯1 /𝑉+ ] ≑A 𝑐 β€² [πœ„2 π‘₯1 /𝑉+ ]
A+sum
β€”
Μƒ 1 .𝑐1 |π‘₯2 .𝑐2 ]⟩ ≑A+ 𝑐 β€²
βŸ¨π‘‰+ β€– πœ‡[π‘₯
𝑁
𝑐1 [πœ‹1 ⋆ /π‘†βŠ ] ≑A+ 𝑐 β€² [πœ‹1 ⋆ /π‘†βŠ ]
𝑐1 [πœ‹2 ⋆ /π‘†βŠ ] ≑A+ 𝑐 β€² [πœ‹2 ⋆ /π‘†βŠ ]
A+negpair
β€”
βŸ¨πœ‡<⋆.𝑐1 ; ⋆.𝑐2 > β€– π‘†βŠ ⟩ ≑A+𝑁 𝑐 β€²
(b) Extended algorithm equality rules
βŸ¨πœ„1 (𝑦1 ) β€– β‹†βŸ© ≑A+ βŸ¨πœ„1 (𝑦1 ) β€– β‹†βŸ©
βŸ¨πœ„2 (𝑦1 ) β€– β‹†βŸ© ≑A+ βŸ¨πœ„2 (𝑦1 ) β€– β‹†βŸ©
𝑁
𝑁
β€”
⟨(π‘₯1 , π‘₯2 ) β€– β‹†βŸ© ≑A+𝑁 ⟨(π‘₯1 , π‘₯2 ) β€– πœ‡Μƒ[𝑦1 .⟨(π‘₯1 , π‘₯2 ) β€– β‹†βŸ©|𝑦2 .⟨(π‘₯1 , π‘₯2 ) β€– β‹†βŸ©]⟩
β€”
+
+
+
+
+
⟨π‘₯ β€– πœ‡(π‘₯1 , π‘₯2 ).⟨π‘₯ β€– β‹†βŸ©βŸ© ≑A+𝑁 ⟨π‘₯ β€– πœ‡Μƒ[𝑦1 .⟨π‘₯ β€– β‹†βŸ©|𝑦2 .⟨π‘₯ β€– β‹†βŸ©]⟩
β€”
+
+
+
+
(𝗅𝖾𝗍 (π‘₯1 , π‘₯2 ) 𝖻𝖾 π‘₯ 𝗂𝗇 π‘₯ ) ≑A+ 𝛿(π‘₯ , πœ„1 (𝑦1 ).π‘₯ , πœ„2 (𝑦2 ).π‘₯+)
𝑁
A+sum
A+pair
⟨(π‘₯1 , π‘₯2 ) β€– π‘¦β‹…β‹†βŸ© ≑A+ ⟨(π‘₯1 , π‘₯2 ) β€– π‘¦β‹…β‹†βŸ©
𝑁
A+pair
β€”
+
+
π‘₯
πœ‡(π‘₯
⟨ β€–
1 , π‘₯2 ).⟨(π‘₯1 , π‘₯2 ) β€– π‘¦β‹…β‹†βŸ©βŸ© ≑A+𝑁 ⟨π‘₯ β€– π‘¦β‹…β‹†βŸ©
β€”
A+fun
+
+
⟨π‘₯ β€– πœ‡(π‘₯1 , π‘₯2 ).⟨(π‘₯1 , π‘₯2 ) β€– β‹†βŸ©βŸ© ≑A+𝑁 βŸ¨πœ‡(𝑦⋅⋆).⟨π‘₯ β€– π‘¦β‹…β‹†βŸ© β€– β‹†βŸ©
β€”
(𝗅𝖾𝗍 (π‘₯1 , π‘₯2 ) 𝖻𝖾 π‘₯+ 𝗂𝗇 (π‘₯1 , π‘₯2 )) ≑A+ πœ†π‘¦.(π‘₯+ 𝑦)
𝑁
(c) Deriving (instances of) Abel and Coquand’s [1] transitivity rules from (≑A+ ).
β€”
Figure 8: Algorithmic equivalence
constructors of the language. Our richer syntax allows the
definition in Figure 8b of an extended algorithmic equivalence
(≑A+ ) without introducing any new rule, but by extending each
constructor rule A-fun, A-pair etc. in a simple (but potentially
type-incorrect) way.
The notation 𝑐[𝑑/𝑉 ] substitutes syntactic occurences of the
term 𝑉 by 𝑑; there is a unique context decomposition of 𝑐
into 𝑐 β€² [𝑉 ] with 𝑉 βˆ‰ 𝑐 β€² , and then 𝑐[𝑑/𝑉 ] is 𝑐 β€² [𝑑]. On valid
terms, this extended equivalence coincides with the previous
algorithmic equivalence. Indeed, in the case of a normal
command βŸ¨π‘‰+ β€– πœ‡(π‘₯1 , π‘₯2 ).π‘βŸ© for example, a valid 𝑉+ can only
be a variable π‘₯+, in which case the rule A-pair and A+pair
are identical. The extension only applies when 𝑉+ has a head
constructor that is not the pair, in which case the expression is
in normal form but invalid. Figure 8c shows that this extension
subsumes the rules of Abel and Coquand: we can derive their
instances.
Notice how the left-hand-side of the left premise of the topmost rule is obtained by the apparently-nonsensical substitution
⟨(π‘₯1 , π‘₯2 ) β€– β‹†βŸ©[πœ„1 𝑦1/(π‘₯1 , π‘₯2 )] produced by the extended sum rule
on an invalid command. We consider this baroque extension
10
only a curiosity of the meta-theory.
Lemma 8 (Soundness). 𝑑 ≑A+ 𝑒 implies 𝑑 ≃RE 𝑒.
Lemma 9 (Reflexivity). If 𝑑 is β†’R -normalizing then 𝑑 ≑A+ 𝑑.
Lemma 10 (Transitivity). If 𝑑1 ≑A+ 𝑑2 and 𝑑2 ≑A+ 𝑑3 then
𝑑1 ≑A+ 𝑑3 .
Lemma 11 (Completeness). If 𝑓 ≃RE 𝑓 β€² then 𝑓 ≑A+ 𝑓 β€² .
Theorem 12. If 𝑐1 and 𝑐2 are (β†’R )-normalizable commands,
then 𝑐1 ≃RE 𝑐2 if and only if 𝑐1 ≑A+ 𝑐2 .
D. Phase equivalence
Algorithmic equality demonstrates that the focused forms
are a suitable structure to compute (≃RE )-equivalence.
However, this (≃RE )-equivalence is more restrictive than
the usual π›½πœ‚-equivalences considered for πœ†-terms. For
example, 𝗅𝖾𝗍 𝑦+ 𝖻𝖾 π‘₯ 𝑉 𝗂𝗇 πœ„1 (π‘‘βŠ ) is not (≃RE )-equivalent to
πœ„1 (𝗅𝖾𝗍 𝑦+ 𝖻𝖾 π‘₯ 𝑉 𝗂𝗇 π‘‘βŠ )β€”intuitively, the applications of constructors may perform arbitrary effects and thus are not reorderable.
𝑐 πœ™ [ ] β©΄ ⟨π‘₯ β€– 𝑆 πœ™ [ ]⟩ | βŸ¨π‘‰ πœ™ [ ] β€– β‹†βŸ©
𝑉 𝐢 [ ] β©΄ (𝑉 𝐢± , 𝑉 𝐢± [ ]) | (𝑉 𝐢± [ ], 𝑉 𝐢± ) | πœ„π‘– (𝑉 𝐢± [ ])
π‘‰πœ™
{𝑉 𝐷 [ ] β©΄ πœ‡(π‘₯⋅⋆).[ ] | πœ‡<⋆.[ ]; ⋆.[ ]>
𝑉 𝐢± β©΄ 𝑉 𝐢 [ ] | πœ‡ βŠβ‹†.[ ]
𝑆 𝐷 β©΄ πœ‡[π‘₯.[
Μƒ
Μƒ 𝑦).[ ]
]|π‘₯.[ ]] | πœ‡(π‘₯,
π‘†πœ™
{𝑆 𝐢 β©΄ 𝑉 𝐢± [ ]⋅𝑆 𝐢± | 𝑉 𝐢± ⋅𝑆 𝐢± [ ] | πœ‹π‘– ⋅𝑆 𝐢± [ ]
𝑆 𝐢± β©΄ 𝑆 𝐢 [ ] | πœ‡π‘₯
Μƒ +.[ ]
β€”
Definition 15. We call phase equivalence the relation (≃P )
defined as the (closure of the) union of (≃P ) and (≃P ).
𝐢
E. Recovering π›½πœ‚-equivalence
Figure 9: Commutative contexts
We can strengthen the equational theory of the untyped
language, under the additional assumption that the terms are
pure and strongly normalising setting, by allowing identical
phases to be merged, and unused phases to be dropped. This
is the purpose of Section IV-E, which recovers a theory
equivalent to π›½πœ‚ for πœ†-calculus. As a first step, we study in this
section the reodering of independent phases. This is no stronger
than ( ≃RE ), but captures the global aspect of equivalence:
merging and weakening can then be defined locally.
We write 𝑐 πœ™ [ ], 𝑉 πœ™ [ ] and 𝑆 πœ™ [ ] for focused command
contexts (respectively value contexts, stack contexts) with one
or several holes, all in a position where a subcommand is
expected. We are interested in reordering 𝑐1 [𝑐2 [ ]] into 𝑐2 [𝑐1 [ ]].
Two command contexts 𝑐1 [ ] and 𝑐2 [ ] are independent, written
𝑐1 # 𝑐2 , if reodering them respects scope: the variables (and
⋆) of 𝑐1 bound by 𝑐1 are not free in 𝑐2 , and conversely.
Definition 13. We define the commutative contexts for focused
commands, values and stacks by the grammar of Figure 9.
For a given phase πœ™, we define the phase equivalence (≃Pπœ™ )
with the reordering:
πœ™
𝐷
Appendix A gives a rewriting relation to decide (≃P )equivalence, similarly to the preemptive rewriting of maximal
multi-focusing [9].
πœ™
𝑐2 [𝑐1 [ ]] ⊳Pπœ™ 𝑐1 [𝑐2 [ ]]
πœ™
when 𝑐1 # 𝑐2 .
Note that some abstractor commutative contexts, e.g.
⟨π‘₯+β€– πœ‡[π‘₯
Μƒ 1 .[ ]|π‘₯2 .[ ]]⟩, may have several holesβ€”phase reordering
may thus result in (de-)duplication. Constructor commutative
contexts have exactly one hole; for example, (𝑉 𝐢± , [ ]) and
([ ], 𝑉 𝐢± ) are both valid shapes for a commutative value
context, but we do not define ([ ], [ ]) as a commutative context.
One can relate this difference to the additive or multiplicative
status of connectives in linear logic, or to the syntactic idea that
control may flow into either branches of the sum elimination
construction. In particular, πœ‡[π‘₯.𝑓
Μƒ
1 | 𝑦.[ ]] is not a commutative
context, since 𝑐 [ ⟨π‘₯ β€– πœ‡[𝑦
Μƒ 1 .𝑓1 |𝑦2 .𝑓2 ]⟩ ] is very different from
Μƒ 1 .𝑓1 |𝑦2 .𝑐[𝑓 ]]⟩ in general.
⟨π‘₯ β€– πœ‡[𝑦
Lemma 14. (≃P𝐷 ) is derivable: if 𝑐1 ≃P𝐷 𝑐2 then 𝑐1 ≃RE 𝑐2 .
While (≃Pπœ™ ) is defined entirely on the structure of focused
normal forms, the intermediary (≃RE )-reasoning step used
to justify commutativity are free to disrespect this focused
structure. These exchanges between the normalized and the
non-normalized world are interesting and justify, we think,
studying first the dynamics of the system (or, said otherwise,
proof/type systems with a cut), and looking at their normal
forms only later, instead of starting with cut-free systems
directly.
11
If 𝜌 is a substitution from variables to variables, and 𝑉 πœ™ [ ]
(resp. 𝑆 πœ™ [ ]) is a focused context, we write 𝑉 πœ™ [𝜌[ ]] for the
focused context where each of the variables bound by 𝑉 πœ™ [ ]
that scope over its hole are renamed according to 𝜌, and only
those are in the domain of 𝜌. In particular, there exists a 𝜌 such
πœ™
πœ™
πœ™
πœ™
that 𝑉1 [𝜌[ ]] = 𝑉2 [ ] when 𝑉1 and 𝑉2 modulo renaming of
outgoing variablesβ€”for example πœ‡(π‘₯1 , π‘₯2 ).[ ] and πœ‡(π‘₯β€²1 , π‘₯β€²2 ).[ ].
Definition 16. We define the merging simplification (⊳M ) as
the smallest relation such that, for each pair of independent
πœ™
πœ™
commutative contexts 𝑐1 # 𝑐2 and substitution 𝜌 such that
πœ™
πœ™
πœ™ πœ™
πœ™
𝑐1 = 𝑐2 [𝜌], we have 𝑐1 [𝑐2 [𝑐3 ]] ⊳M 𝑐1 [𝜌[𝑐3 ]].
β†’M is normalizing, since it decreases strictly the size of the
command.
Definition 17. We define the weakening simplification (⊳W ) as
the smallest relation such that, whenever none of the variable
bound by the commutative context 𝑐[ ] over its hole are used
in 𝑓 , we have 𝑐[𝑓 ] ⊳W 𝑓 .
Note that commutative contexts of the form βŸ¨π‘‰ πœ™ [ ] β€– β‹†βŸ©
are neither mergeable nor weakenable, since all possible holes
of 𝑉 πœ™ [ ] shadow the variable ⋆, breaking the independence
requirement, and all pluggable commands 𝑓 use the variable
⋆, breaking the weakening requirement. Semantically it would
make no sense, of course, to claim something to the effect of
πœ„1 (πœ„1 (πœ‡β‹†.𝑐)) ≃M πœ„1 (πœ‡β‹†.𝑐) or πœ„1 (πœ‡β‹†.𝑓 ) ≃W 𝑓 , but we directly
recover this from Lint without having to break the uniformity
of our definitions.
We will write (≃REPMW ) the closure of the unions of (≃RE ),
(≃P ), (≃M ) and (≃W ). It is decidable on β†’R -normalizable
terms by normalizing by (β†’R ), then taking the (≃P )-normal
form, the β†’MW -normal form, and finally (≑A+ ) to decide
equivalences. We now prove that is sound and complete with
respect to (≃RE𝛽 ), which corresponds to the π›½πœ‚-equality of πœ†calculus as demonstrated in Section III-E.
Proposition 18. If 𝑑 ≃MW 𝑒 then 𝑑 ≃RE𝛽 𝑒.
Theorem 19. If 𝑑 ≃RE𝛽 𝑒, then 𝑑 ≃REPMW 𝑒.
This concludes our study of the normal forms. We have
demonstrated that the equivalence (≃RE𝛽 ), which corresponds
on typed terms to the natural equality of well-typed πœ†-terms,
can be re-defined (and decided) in a syntactically uniform way
based on sequences of constructor and abstractor phases.
References
[1] Andreas Abel and Thierry Coquand, Untyped Algorithmic Equality for
Martin-Löf’s Logical Framework with Surjective Pairs, Typed Lambda
Calculi and Applications (PaweΕ‚ Urzyczyn, ed.), Lecture Notes in Computer Science, vol. 3461, Springer Berlin Heidelberg, 2005, pp. 23–38
(English).
[2] Mads Sig Ager, Dariusz Biernacki, Olivier Danvy, and Jan Midtgaard, A
Functional Correspondence between Evaluators and Abstract Machines,
PPDP, 2003, pp. 8–19.
[3] Thorsten Altenkirch, Peter Dybjer, Martin Hofmann, and Philip Scott,
Normalization by evaluation for typed lambda calculus with coproducts,
Logic in Computer Science, 2001. Proceedings. 16th Annual IEEE
Symposium on, IEEE, 2001, pp. 303–310.
[4] Jean-Marc Andreoli, Logic Programming with Focusing Proof in Linear
Logic, Journal of Logic and Computation 2 (1992), no. 3, 297–347.
[5] Zena M Ariola, Aaron Bohannon, and Amr Sabry, Sequent calculi and
abstract machines, ACM Transactions on Programming Languages and
Systems (TOPLAS) 31 (2009), no. 4, 13.
[6] Vincent Balat, Roberto Di Cosmo, and Marcelo P. Fiore, Extensional
normalisation and type-directed partial evaluation for typed lambda
calculus with sums, POPL, 2004, pp. 64–76.
[7] Aloïs Brunel, Quantitative classical realizability, Information and Computation (2014).
[8] Kaustuv Chaudhuri, Stefan Hetzl, Dale Miller, et al., A Systematic
Approach to Canonicity in the Classical Sequent Calculus, 21st EACSL
Annual Conference on Computer Science Logic, vol. 16, 2012, pp. 183–
197.
[9] Kaustuv Chaudhuri, Dale Miller, and Alexis Saurin, Canonical sequent
proofs via multi-focusing, Fifth Ifip International Conference On Theoretical Computer Science–Tcs 2008, Springer, 2008, pp. 383–396.
[10] Thierry Coquand, Logical Frameworks, Cambridge University Press,
New York, NY, USA, 1991, pp. 255–279.
[11] Pierre-Louis Curien and Hugo Herbelin, The duality of computation,
ACM SIGPLAN Notices 35 (2000), 233–243.
[12] Pierre-Louis Curien and Guillaume Munch-Maccagnoni, The duality of
computation under focus, Proc. IFIP TCS, 2010, Extended version.
[13] Vincent Danos, Jean-Baptiste Joinet, and Harold Schellinx, A New
Deconstructive Logic: Linear Logic, Journal of Symbolic Logic 62 (3)
(1997), 755–807.
[14] Olivier Danvy and Kevin Millikin, A Rational Deconstruction of Landin’s
SECD Machine with the J Operator, Logical Methods in Computer
Science 4 (2008), no. 4.
[15] Olivier Danvy and Lasse R. Nielsen, Defunctionalization at Work,
Research Report BRICS RS-01-23, Department of Computer Science,
Aarhus University, Aarhus, Denmark, July 2001, Extended version of
an article presented at the Third International Conference on Principles
and Practice of Declarative Programming (PPDP 2001), Firenze, Italy,
September 5-7, 2001; most influential paper at PPDP 2001, 10 years
after.
[16] Daniel J. Dougherty, Some Lambda Calculi With Categorical Sums and
Products, Rewriting Techniques and Applications, 1993.
[17] Paul Downen and Zena M Ariola, The duality of construction, European
Symposium on Programming, Springer, 2014, pp. 249–269.
[18] Andrzej Filinski, Declarative Continuations and Categorical Duality,
Master’s thesis, DIKU, Computer Science Department, University of
Copenhagen, Aug 1989, DIKU Rapport 89/11.
[19] Marcelo Fiore, Roberto Di Cosmo, and Vincent Balat, Remarks on
isomorphisms in typed lambda calculi with empty and sum types, Logic
in Computer Science, 2002. Proceedings. 17th Annual IEEE Symposium
on, IEEE, 2002, pp. 147–156.
[20] Gerhard Gentzen, Untersuchungen über das logische Schließen, Mathematische Zeitschrift 39 (1935), 176–210,405–431.
[21] Neil Ghani, π›½πœ‚-equality for coproducts, Typed Lambda Calculi and
Applications, Springer, 1995, pp. 171–185.
[22] Jean-Yves Girard, A new constructive logic: Classical logic, Math. Struct.
Comp. Sci. 1 (1991), no. 3, 255–296.
[23] _ , On the Unity of Logic, Ann. Pure Appl. Logic 59 (1993), no. 3,
201–217.
[24] _ , Locus Solum: From the Rules of Logic to the Logic of Rules,
Mathematical Structures in Computer Science 11 (2001), 301–506.
[25] _ , Le Point Aveugle, Cours de logique, Tome I: Vers la Perfection, Vision des Sciences, Hermann, 2006, published subsequently in
English [27].
[26] _ , Le Point Aveugle, Cours de logique, Tome II: Vers
l’imperfection, Visions des Sciences, Hermann, 2007, published subsequently in English [27].
[27] _ , The Blind Spot: Lectures on Logic, European Mathematical
Society, 2011.
[28] Healfdene Goguen, Justifying Algorithms for Ξ²Ξ·-Conversion, Foundations
of Software Science and Computational Structures (Vladimiro Sassone,
ed.), Lecture Notes in Computer Science, vol. 3441, Springer Berlin
Heidelberg, 2005, pp. 410–424 (English).
12
[29] Hugo Herbelin, Lambda-calculus structure isomorphic to sequent calculus structure, CSL, CSL, 1994.
[30] Hugo Herbelin, C’est maintenant qu’on calcule, au cΕ“ur de la dualité,
2005, Habilitation thesis.
[31] Hagen Huwig and Axel Poigné, A Note on Inconsistencies Caused by
Fixpoints in a Cartesian Closed Category, Theor. Comput. Sci. 73 (1990),
no. 1, 101–112.
[32] Peter J. Landin, The mechanical evaluation of expressions, The Computer
Journal 6 (1964), no. 4, 308–320.
[33] _ , A correspondence between algol 60 and Church’s Lambdanotation, Commun. ACM 8 (1965), no. 2, 89–101 and 158–165.
[34] F. William Lawvere, Diagonal arguments and cartesian closed categories, Lecture Notes in Mathematics 92 (1969), 134–145.
[35] Paul Blain Levy, Call-By-Push-Value: A Functional/Imperative Synthesis,
Semantics Structures in Computation, vol. 2, Springer, 2004.
[36] _ , Adjunction models for call-by-push-value with stacks, Proc. Cat.
Th. and Comp. Sci., ENTCS, vol. 69, 2005.
[37] Chuck Liang and Dale Miller, Focusing and Polarization in Intuitionistic
Logic, CSL, 2007, pp. 451–465.
[38] Sam Lindley, Extensional rewriting with sums, Typed Lambda Calculi
and Applications, Springer, 2007, pp. 255–271.
[39] Guillaume Munch-Maccagnoni, Focalisation and Classical Realisability,
Proc. CSL ’09, LNCS, Springer-Verlag, 2009.
[40] _ , πœ†-calcul, machines et orthogonalité, Unpublished manuscript,
October 2011.
[41] _ , Syntax and Models of a non-Associative Composition of Programs and Proofs, Ph.D. thesis, Univ. Paris Diderot, 2013.
[42] _ , Formulae-as-Types for an Involutive Negation, Proceedings
of the joint meeting of the Twenty-Third EACSL Annual Conference
on Computer Science Logic and the Twenty-Ninth Annual ACM/IEEE
Symposium on Logic in Computer Science (CSL-LICS), 2014, To
appear.
[43] _ , Models of a Non-Associative Composition, FoSSaCS
(A. Muscholl, ed.), LNCS, vol. 8412, Springer, 2014, pp. 397–412.
[44] Tobias Nipkow, Higher-Order Critical Pairs, Proc. 6th IEEE Symp.
Logic in Computer Science, IEEE Press, 1991, pp. 342–349.
[45] Michel Parigot, Lambda-Mu-Calculus: An Algorithmic Interpretation of
Classical Natural Deduction, LPAR, 1992, pp. 190–201.
[46] John C. Reynolds, Definitional Interpreters for Higher-Order Programming Languages, Proceedings of 25th ACM National Conference (Boston,
Massachusetts), 1972, Reprinted in Higher-Order and Symbolic Computation 11(4):363-397, 1998, with a foreword [47], pp. 717–740.
[47] _ , Definitional Interpreters Revisited, Higher-Order and Symbolic
Computation 11 (1998), no. 4, 355–361.
[48] José Espírito Santo, Completing Herbelin’s programme, Typed Lambda
Calculi and Applications, Springer, 2007, pp. 118–132.
[49] Peter Selinger, Control Categories and Duality: On the Categorical
Semantics of the Lambda-Mu Calculus, Math. Struct in Comp. Sci. 11
(2001), no. 2, 207–260.
[50] Arnaud Spiwak, A dissection of L, Submitted, 2014.
[51] Thomas Streicher and Bernhard Reus, Classical Logic, Continuation
Semantics and Abstract Machines, J. Funct. Program. 8 (1998), no. 6,
543–572.
[52] Hayo Thielecke, Categorical Structure of Continuation Passing Style,
Ph.D. thesis, University of Edinburgh, 1997.
[53] Adriaan van Wijngaarden, Recursive definition of syntax and semantics,
Formal Language Description Languages for Computer Programming,
North Holland Publishing Company, 1966.
[54] Philip Wadler, Call-by-value is dual to call-by-name, SIGPLAN Not. 38
(2003), no. 9, 189–201.
[55] Mitchell Wand, Continuation-Based Program Transformation Strategies,
J. ACM 27 (1980), no. 1, 164–180.
Contents
I
Introduction
I-A
Abstract-machine-like calculi . . . .
I-B
Intuitionistic polarisation . . . . . .
I-C
Focusing and untyped normal forms
I-D
Notations . . . . . . . . . . . . . . .
I-E
Acknowledgements . . . . . . . . .
πœ™
πœ™
⟨π‘₯ β€– πœ‹ [βŸ¨π‘‰ [ ] β€– β‹†βŸ©]⟩
.
.
.
.
.
.
.
.
.
.
II
A Principled Introduction to Abstract-MachineLike Calculi
II-A
Abstract machines . . . . . . . . . . . .
II-B
Solving equations for expressions . . . .
II-C
Compatible reduction and its confluence
II-D
Typing of machines . . . . . . . . . . .
II-E
Solving equations for contexts . . . . .
II-F
Commutation rules are redundant . . .
II-G
Focalisation . . . . . . . . . . . . . . .
II-H
Inside-out contexts are primitive . . . .
II-I
A parte: Defunctionalised CPS in direct
style . . . . . . . . . . . . . . . . . . .
III
Polarisation and Extensional Sums
III-A
Conversions on expressions vs. on commands . . . . . . . . . . . . . . . . . .
III-B
Extensionality for sums with a regular
shape . . . . . . . . . . . . . . . . . . .
III-C
Positive sums . . . . . . . . . . . . . .
III-D
The polarised calculus Lint . . . . . . .
III-E
Relating Lint to the πœ†-calculus with sums
πœ™
πœ™
⟨π‘₯ β€– 𝑆 [βŸ¨π‘¦ β€– 𝑆2 [ ]⟩]⟩
1
1
2
2
2
3
πœ™
Μ„
πœ™
𝑐1 [𝑐 πœ™ [𝑐2 [ ]]]
≃LP
πœ™
πœ™
βŸ¨π‘‰ [⟨π‘₯ β€– 𝑆 [ ]⟩] β€– β‹†βŸ©
≃LP
πœ™
βŸ¨π‘¦ β€– 𝑆2 [⟨π‘₯ β€– 𝑆 [ ]⟩]⟩
⊳GP
𝑐1 [𝑐2 [𝑐 πœ™ [ ]]]
πœ™
πœ™
πœ™
Μ„
In the definitions above we assume commutativity and independence
of the reordered command contexts.
β€”
Figure 10: Focused equivalences
the only difference between (≃RE ) (which we deconstructed
as (β†’R )-normalization followed by algorithmic equivalence)
and (β‰ƒπ›½πœ‚ ) is the addition (≃P𝐢 ), reordering of independent
constructors.
Inspired by the work on multi-focusing [9], Figure 10 defines
two subrelations of (≃P ): a local phase equivalence (≃LP ),
permuting focused values and stacks inside a single phase,
and a global phase reordering (≃GP ). The global rewrite lets
a focused commutative context of phase πœ™ (which may be
only a fragment of a larger context) jump across another
context of opposite phase πœ™.Μ„ Note that it must jump into
another context of the same phase, and thus cannot split the πœ™-Μ„
context in twoβ€”we say that a focused context inside a focused
command is maximal if its the surrounding contexts are of the
opposite phase. This restriction is necessary for the rewrite to
be terminating: with the orientation of the reduction and this
restriction, the outermost maximal contexts grows bigger at
each rewrite step.
3
3
3
4
4
4
5
5
5
6
6
6
6
6
6
8
Lemma 20. (⊳GP ) is terminating.
Μ„
IV
The Structure of Normal Forms and Their Equivalence
IV-A
The phase structure of normal forms . .
IV-B
Algorithmic equality for expansion rules
IV-C
Completeness of algorithmic equality on
normal forms . . . . . . . . . . . . . .
IV-D
Phase equivalence . . . . . . . . . . . .
IV-E
Recovering π›½πœ‚-equivalence . . . . . . .
9
10
11
References
11
Appendix A: Phase Normal Forms
13
Appendix B: Proofs from Section IV
14
Note that the reordered 𝑐 πœ™ may be duplicated if 𝑐2 has
several holes. The termination order is thus the tree of sizes
of maximal contexts; the tree with the biggest element coming
first is the smaller. This is well-ordered if the total size of trees
arising from the rewrite of a given element is bounded. The
possible rewrites of a term of size 𝑁 are bounded in size by
2𝑁 (impossible worst case where all elements are duplicating
and get rewritten in a such a way that they do duplicate the
rest of the term).
The relations (≃LP ) and (⊳GP ) are not just subrelations:
combined, they subsume (≃P ).
9
9
9
Lemma 21. 𝑓1 ≃P 𝑓2 if and only if 𝑓1 ⊳GP βˆ— 𝑓1β€² and 𝑓2 ⊳GP βˆ—
𝑓2β€² with 𝑓1β€² ≃LP 𝑓2β€² .
Appendix A
Phase Normal Forms
This section proves that phase equivalence is decidable.
As (≃P𝐢 ) is not derivable, phase equivalence
relates terms that are not in (≃RE ). For example,
⊝ +
Μƒ +.π‘βŸ©) β€– ⋆ ⟩
≃P𝐢
we have
⟨ πœ„1 (πœ‡β‹† .⟨π‘₯ β€– 𝑉 β‹…πœ‡π‘¦
+
+
⊝
π‘₯
𝑉
β‹…
πœ‡π‘¦
Μƒ
.βŸ¨πœ„
(πœ‡β‹†
.𝑐)
β‹†βŸ©
.
We
wish
to
prove,
in
the
β€–
β€–
⟨
⟩
1
remainder of this section, that combining (≃P ) and the
algorithmic equivalence (≑A+ ) of the previous section (which
decides πœ‚-equivalences) captures the natural equivalence on
”effect-free” commands, and in particular coincides with the
(β‰ƒπ›½πœ‚ ) equivalence of the lambda-calculus. This implies that
13
The equivalence (≃LP ) is decidable and local, so it is
natural to manipulate terms up to this equivalence. One way
to do this is to introduce an explicit multi-focusing syntax
that performs a series of independent plays simultaneously
on different variables and optionally on ⋆; that corresponds
to a multi-let syntax (𝗅𝖾𝗍 π‘₯Μ„ 𝖻𝖾 𝑒 Μ„ 𝗂𝗇 𝑑) in some calculi, or to the
multi-case pattern-matching construct of Altenkirch et al. [3].
Another equivalent choice, which we adopt for simplicity, is
to pick an arbitrary order to order local phases.
Definition 22. We define βŒŠπ‘“ βŒ‹LP as an arbitrary choice of
representative in the (≃LP )-equivalence class of the focused
command 𝑓 . We will also write βŒŠπ‘“ βŒ‹GP for the unique (β†’GP )normal form of 𝑓 , and βŒŠπ‘“ βŒ‹P for βŒŠβŒŠπ‘“ βŒ‹GP βŒ‹LP . Finally, if 𝑐
is a (β†’R )-normalizable command, whose normal form has a
(unique) focused form 𝑓 , we will write βŒŠπ‘βŒ‹P for βŒŠπ‘“ βŒ‹P .
We just need to extend this result to prove that 𝑐 ≃RE
βŸ¨π‘‰+ β€– πœ‡(π‘₯1 , π‘₯2 ).𝑐[(π‘₯1 , π‘₯2 )/𝑉+ ]⟩:
𝑐
Appendix B
Proofs from Section IV
×
Proof of Lemma 6:
We deterministically rewrite any normal command 𝑐 into a
focused command βŸ¦π‘βŸ§ as follows:
βŸ¦βŸ¨π‘‰+ β€– β‹†βŸ©βŸ§
=
βŸ¨βŸ¦π‘‰+ βŸ§π‘‰+ β€– β‹†βŸ©
=
⟨π‘₯+ β€– βŸ¦π‘’+ βŸ§π‘’+ βˆ’πœ‡π‘₯Μƒ +.𝑐 ⟩
⟦⟨π‘₯+ β€– 𝑒+ ⟩⟧
⟦⟨π‘₯⊝ β€– π‘†βŠ ⟩⟧
=
⟨π‘₯⊝ β€– βŸ¦π‘†βŠ βŸ§π‘†βŠ ⟩
βŸ¦βŸ¨π‘‘βŠ β€– β‹†βŸ©βŸ§
=
βŸ¨βŸ¦π‘‘βŠβŸ§π‘‘βŠ β§΅πœ‡β‹†βŠ.𝑐 β€– β‹†βŸ©
⟦π‘₯+βŸ§π‘‰+
⟦(𝑉1 , 𝑉2 )βŸ§π‘‰+
βŸ¦πœ„1 𝑉 βŸ§π‘‰+
βŸ¦π‘‰+ βŸ§π‘‰
βŸ¦πœ‡ β‹†βŠ .π‘βŸ§π‘‰
βŸ¦π‘‘βŠβŸ§π‘‰
⟦π‘₯βŠβŸ§π‘‘βŠ β§΅πœ‡β‹†βŠ.𝑐
βŸ¦πœ‡(π‘₯ β‹… ⋆).π‘βŸ§π‘‘βŠ β§΅πœ‡β‹†βŠ.𝑐
=
=
=
=
=
β†’Eπœ‡
=
=
⊲ Rπœ‡ Μƒ
≃ EβŠ—
⊳ Rπœ‡ Μƒ
Proof of lemma 9.: By induction. To justify the induction
we need an induction measure that is strictly decreasing on, for
example,
𝑐[(π‘₯1 , π‘₯2 )/𝑉+ ] ≑A ⟨(π‘₯1 , π‘₯2 ) β€– πœ‡(π‘₯1 , π‘₯2 ).𝑐[(π‘₯1 , π‘₯2 )/𝑉+ ]⟩
β€”
βŸ¨π‘‰+ β€– πœ‡(π‘₯1 , π‘₯2 ).π‘βŸ© ≑A𝑁 βŸ¨π‘‰+ β€– πœ‡(π‘₯1 , π‘₯2 ).π‘βŸ©
π‘₯+
(βŸ¦π‘‰1 βŸ§π‘‰ , βŸ¦π‘‰2 βŸ§π‘‰ )
πœ„1 βŸ¦π‘‰ βŸ§π‘‰
βŸ¦π‘‰+ βŸ§π‘‰+
πœ‡ β‹†βŠ .βŸ¦π‘βŸ§
πœ‡ β‹†βŠ .βŸ¨βŸ¦π‘‘βŠ βŸ§π‘‘βŠ β§΅πœ‡β‹†βŠ.𝑐 β€– β‹†βŸ©
π‘₯⊝
πœ‡(π‘₯ β‹… ⋆).βŸ¦π‘βŸ§
As in the article of Abel and Coquand and in Goguen [28]
they reference, we simply need an induction measure that favors
abstractors over constructors, eg:
|βŸ¨π‘‰ β€– πœ‡π‘ž.π‘βŸ©|
Μƒ
|βŸ¨πœ‡π‘ž.𝑐 β€– π‘†βŸ©|
|βŸ¨π‘‰ [𝑐𝑖 ] β€– 𝑆[𝑐𝑗 ]⟩|
∢= 2.|𝑐|
∢= 2.|𝑐|
∢= Σ𝑖 |𝑐𝑖 | + Σ𝑗 |𝑐𝑗 | + 1
Remark then that the sum of the measures of the premises is
strictly inferior to the sum of the measures of its conclusion,
justifying building such derivations by induction.
β– 
To prove transitivity of the extended algorithmic equivalence,
we first need a lemma. Let us write βŒŠπ‘βŒ‹R for the β†’R -normal
form of 𝑐.
Lemma 23. Any derivation of βŒŠπ‘1 βŒ‹R ≑A+𝑁 βŒŠπ‘2 βŒ‹R can be
turned into a derivation of βŒŠπ‘1 [π‘ž/𝑉+ ]βŒ‹R ≑A+𝑁 βŒŠπ‘2 [π‘ž/𝑉+ ]βŒ‹R
(resp. βŒŠπ‘1 [π‘ž/π‘†βŠ ]βŒ‹R ≑A+𝑁 βŒŠπ‘2 [π‘ž/π‘†βŠ ]βŒ‹R ) of equal or smaller
height when π‘ž does not appear in 𝑐1 , 𝑐2 .
Proof of lemma 23.:
The proof goes by induction on the ( ≑A+𝑁 )-derivation,
with a strengthened induction hypothesis: for any substitution 𝜎, pattern π‘ž and value 𝑉+ (respectively stack π‘†βŠ ), any
derivation of βŒŠπ‘1 πœŽβŒ‹R ≑A+𝑁 βŒŠπ‘2 πœŽβŒ‹R can be turned into a
derivation of βŒŠπ‘1 [π‘ž/𝑉+ ]πœŽβŒ‹R ≑A+𝑁 βŒŠπ‘2 [π‘ž/𝑉+ ]βŒ‹R (respectively
βŒŠπ‘1 [π‘ž/π‘†βŠ ]πœŽβŒ‹R ≑A+𝑁 βŒŠπ‘2 [π‘ž/π‘†βŠ ]βŒ‹R ) of equal or smaller length,
when π‘ž does not appear in 𝑐1 , 𝑐2 or 𝜎.
Let us assume, for instance, that the last rules of our
assumption are of the following form:
βŒŠπ‘1 𝜎[π‘ž1/𝑉1 𝜎]βŒ‹R ≑A+𝑁 βŒŠπ‘2 𝜎[π‘ž1/𝑉1 𝜎]βŒ‹R
β€”
𝑐1 𝜎[π‘ž1/𝑉1 𝜎] ≑A+ 𝑐2 𝜎[π‘ž1/𝑉1 𝜎]
β€”
βŸ¨π‘‰1 𝜎 β€– πœ‡π‘ž1 .𝑐1 𝜎⟩ ≑A+𝑁 𝑐2 𝜎
⟨π‘₯+ β€– πœ‡π‘₯
Μƒ +.𝑐 β€³ ⟩
+
Μƒ +.𝑐 β€³ ⟩⟩
⟨π‘₯ β€– πœ‡(π‘₯1 , π‘₯2 ).⟨(π‘₯1 , π‘₯2 ) β€– πœ‡π‘₯
+
β€³
⟨π‘₯ β€– πœ‡(π‘₯1 , π‘₯2 ).𝑐 [(π‘₯1 , π‘₯2 )/π‘₯+]⟩
If we use this property with 𝑐 β€³ = 𝑐 β€² , we obtain
𝑐 β€² ≃RE ⟨π‘₯+ β€– πœ‡(π‘₯1 , π‘₯2 ).𝑐 β€² [(π‘₯1 , π‘₯2 )/π‘₯+]⟩
If we use it with ⟨π‘₯+ β€– πœ‡(π‘₯1 , π‘₯2 ).π‘βŸ© as a whole, we get:
≃RE
=
β†’RβŠ—
βŸ¨π‘‰+ β€– πœ‡π‘₯
Μƒ +.𝑐[π‘₯+/𝑉+ ]⟩
Μƒ +.𝑐[π‘₯+/𝑉+ ]⟩⟩
βŸ¨π‘‰+ β€– πœ‡(π‘₯1 , π‘₯2 ).⟨(π‘₯1 , π‘₯2 ) β€– πœ‡π‘₯
βŸ¨π‘‰+ β€– πœ‡(π‘₯1 , π‘₯2 ).𝑐[(π‘₯1 , π‘₯2 )/𝑉+ ]⟩
(Note that 𝑐[π‘₯+/𝑉+ ][(π‘₯1 , π‘₯2 )/π‘₯+] = 𝑐[(π‘₯1 , π‘₯2 )/𝑉+ ] because π‘₯
is assumed fresh in 𝑐 by the Barendregt convention)
β– 
βŸ¦β‹†βŸ§π‘†βŠ
=
⋆
βŸ¦π‘‰ β‹… π‘†βŸ§π‘†βŠ
=
βŸ¦π‘‰ βŸ§π‘‰ β‹… βŸ¦π‘†βŸ§π‘†
βŸ¦πœ‡π‘₯
Μƒ +.π‘βŸ§π‘†
=
πœ‡π‘₯.βŸ¦π‘βŸ§
Μƒ
πœ‡π‘₯.βŸ¨β‹†
Μƒ
βŸ¦π‘’+ βŸ§π‘†
β†’Eπœ‡Μƒ
β€– βŸ¦π‘’+ βŸ§π‘’+ βˆ’πœ‡π‘₯Μƒ +.𝑐 ⟩
βŸ¦β‹†βŸ§π‘’+ βˆ’πœ‡π‘₯Μƒ +.𝑐
=
⋆
βŸ¦πœ‡[π‘₯
Μƒ 1 .𝑐1 |π‘₯2 .𝑐2 ]βŸ§π‘’+ βˆ’πœ‡π‘₯Μƒ +.𝑐
=
πœ‡[π‘₯
Μƒ 1 .βŸ¦π‘1 ⟧ |π‘₯2 .βŸ¦π‘2 ⟧]
πœ‡(π‘₯,
Μƒ 𝑦).𝑐
=
πœ‡(π‘₯,
Μƒ 𝑦).βŸ¦π‘βŸ§
Note that the two ways to translate ⟨π‘₯+β€– β‹†βŸ©, as either βŸ¨π‘‰+ β€– β‹†βŸ©
or ⟨π‘₯+ β€– 𝑒+ ⧡ πœ‡π‘₯
Μƒ +.π‘βŸ©, give the same translation ⟨π‘₯+ β€– β‹†βŸ©.
β– 
Proof of lemma 7.: By induction on the derivation of
algorithmic equivalence. For example in the πœ‡(π‘₯, 𝑦) case, we
need to prove that ⟨π‘₯+ β€– πœ‡(π‘₯1 , π‘₯2 ).𝑐 ⟩ ≃RE 𝑐 β€² . Let us remark
that we have, for any command 𝑐 β€³ :
𝑐″
← Rπœ‡ Μƒ
≃ EβŠ•
β†’R
⟨π‘₯+ β€– πœ‡(π‘₯1 , π‘₯2 ).π‘βŸ©
+
+
⟨π‘₯ β€– πœ‡(π‘₯1 , π‘₯2 ).⟨π‘₯ β€– πœ‡(π‘₯1 , π‘₯2 ).π‘βŸ©[(π‘₯1 , π‘₯2 )/π‘₯ ]⟩
+
+
⟨π‘₯ β€– πœ‡(π‘₯1 , π‘₯2 ).⟨(π‘₯1 , π‘₯2 ) β€– πœ‡(π‘₯1 , π‘₯2 ).𝑐[(π‘₯1 , π‘₯2 )/π‘₯ ]⟩⟩
+
+
⟨π‘₯ β€– πœ‡(π‘₯1 , π‘₯2 ).𝑐[(π‘₯1 , π‘₯2 )/π‘₯ ]⟩
+
Then, to show that ⟨ π‘₯+ β€– πœ‡(π‘₯1 , π‘₯2 ).𝑐[(π‘₯1 , π‘₯2 )/π‘₯+] ⟩ and
⟨π‘₯+ β€– πœ‡(π‘₯1 , π‘₯2 ).𝑐 β€² [(π‘₯1 , π‘₯2 )/π‘₯+]⟩ are equivalent, it suffices to
show that 𝑐[(π‘₯1 , π‘₯2 )/π‘₯+] and 𝑐 β€² [(π‘₯1 , π‘₯2 )/π‘₯+] are equivalent, and
this is exactly our induction hypothesis.
β– 
Proof of lemma 8.: The proof is as for the non-extended
version. We used as an intermediate lemma the fact that,
for any 𝑐, we have 𝑐 ≃RE ⟨ π‘₯+ β€– πœ‡(π‘₯1 , π‘₯2 ).𝑐[(π‘₯1 , π‘₯2 )/π‘₯+] ⟩ .
14
We
have
to
find
a
derivation
for
βŒŠβŸ¨π‘‰1 β€– πœ‡π‘ž1 .𝑐1 ⟩[π‘ž/𝑉 ]πœŽβŒ‹R ≑A+𝑁 βŒŠπ‘2 [π‘ž/𝑉 ]πœŽβŒ‹R of equal and
smaller height. There are two possible cases for the structure of
βŒŠβŸ¨π‘‰1 β€– πœ‡π‘ž1 .𝑐1 ⟩[π‘ž/𝑉 ]πœŽβŒ‹R that is βŒŠβŸ¨π‘‰1 [π‘ž/𝑉 ]𝜎 β€– πœ‡π‘ž1 .𝑐1 [π‘ž/𝑉 ]πœŽβŸ©βŒ‹R :
either the constructor 𝑉1 [ π‘ž/𝑉 ]𝜎 does not match the
abstractor πœ‡π‘ž1 , and the β†’R -normal form is just
⟨ 𝑉1 [π‘ž/𝑉 ]𝜎 β€– πœ‡π‘ž1 .βŒŠπ‘1 [π‘ž/𝑉 ]πœŽβŒ‹R ⟩ , or it does, and we have
a head ⊳R -reduction to perform.
In the first case, let us write 𝑉1β€² for βŒŠπ‘‰1 [π‘ž/𝑉 ]βŒ‹R . We can
perform the following first steps of inference (with the top
sequent still to be proved).
Let us take 𝑆3β€² ∢= 𝑆3 [π‘ž1/𝑉1 ]. We build a derivation of the form:
βŒŠβŒŠπ‘1 [π‘ž/𝑉 ]πœŽβŒ‹R [π‘ž1/𝑉1 𝜎]βŒ‹R ≑A+𝑁 βŒŠβŒŠπ‘2 [π‘ž/𝑉 ]πœŽβŒ‹R [π‘ž1 /𝑉1 𝜎]βŒ‹R
β€”
βŒŠπ‘1 [π‘ž/𝑉 ]πœŽβŒ‹R [π‘ž1/𝑉1β€² 𝜎] ≑A+ βŒŠπ‘2 [π‘ž/𝑉 ]πœŽβŒ‹R [π‘ž1/𝑉1β€² 𝜎]
β€”
βŸ¨π‘‰1β€² 𝜎 β€– πœ‡π‘ž1 .βŒŠπ‘1 [π‘ž/𝑉 ]πœŽβŒ‹R ⟩ ≑A+ βŒŠπ‘2 [π‘ž/𝑉 ]πœŽβŒ‹R
𝑁
βŒŠπ‘1 [π‘ž1/𝑉1 ]βŒ‹R [π‘ž3 /βŒŠπ‘†3β€² βŒ‹R ] ≑A βŒŠπ‘3 [π‘ž1 /𝑉1 ]βŒ‹R [π‘ž3/βŒŠπ‘†3β€² βŒ‹R ]
β€”
βŒŠπ‘1 [π‘ž1 /𝑉1 ]βŒ‹R ≑A+𝑁 βŒŠβŸ¨πœ‡π‘ž3 .𝑐3 [π‘ž1/𝑉1 ] β€– 𝑆 β€²3 βŸ©βŒ‹R
β€”
𝑐1 [π‘ž1/𝑉1 ] ≑A+ βŸ¨πœ‡π‘ž3 .𝑐3 [π‘ž1/𝑉1 ] β€– 𝑆 β€²3 ⟩
β€”
βŸ¨π‘‰1 β€– πœ‡π‘ž1 .𝑐1 ⟩ ≑A+𝑁 βŸ¨πœ‡π‘ž3 .𝑐3 β€– 𝑆3 ⟩
Notice that βŒŠβŒŠπ‘1 [π‘ž/𝑉 ]πœŽβŒ‹R [π‘ž1/𝑉1β€² 𝜎]βŒ‹R is equal to
β€²
βŒŠβŒŠπ‘1 [π‘ž/𝑉 ]πœŽβŒ‹R [π‘ž1/𝑉1 𝜎]βŒ‹R . The top sequent is then proved
by induction hypothesis, using the larger substitution
𝜎[π‘ž1/𝑉1β€² 𝜎].
In the second case, we assume that 𝑉1 [π‘ž/𝑉 ]𝜎 starts with
the same head constructor as the pattern π‘ž1 . But we assumed
that βŸ¨π‘‰1 β€– πœ‡π‘ž1 .𝑐1 ⟩𝜎 was a normal form, so we know that 𝑉1 𝜎
and π‘ž1 do not match. If 𝑉1 𝜎 does not match π‘ž1 but 𝑉1 [π‘ž/𝑉 ]𝜎
does, the matching part is either brought by π‘ž (this means that
the occurence of 𝑉 in 𝑉1 is at the top) or the substitution
of 𝑉1 [π‘ž/𝑉 ] by 𝜎. But the latter is impossible, given that we
assumed that π‘ž does not appear in 𝜎. So we have that 𝑉1 = 𝑉 ,
and 𝑉1 [π‘ž/𝑉 ]𝜎 = 𝑉 [π‘ž/𝑉 ]𝜎 = π‘žπœŽ = π‘ž . In particular, we can
always 𝛼-rename π‘ž1 to be equal to π‘ž, and then we can prove
our goal
To conclude our proof, we need to prove the premise
𝑐1 [ π‘ž1/𝑉1 ][ π‘ž3/𝑆3β€² ] ≑A 𝑐3 [ π‘ž1/𝑉1 ][ π‘ž3/𝑆3β€² ] (we omit the β†’R normalization marks for readability of the notation). We build
it by induction hypothesis, using transitivity on two (≑A )
derivations of smaller height. The first is 𝑐1 [π‘ž1/𝑉1 ][π‘ž3/𝑆3β€² ] ≑A
𝑐2 [π‘ž1/𝑉1 ][π‘ž3/𝑆3β€² ], obtained from our hypothesis 𝑐1 [π‘ž1/𝑉1 ] ≑A
𝑐2 [π‘ž1/𝑉1 ] by applying the previous lemmaβ€”it is thus strictly
smaller than the derivation of βŸ¨π‘‰1 β€– πœ‡π‘ž1 .𝑐1 ⟩ ≑A𝑁 𝑐2 we had as
hypothesis. The second, 𝑐2 [π‘ž1/𝑉1 ][π‘ž3/𝑆3β€² ] ≑A 𝑐3 [π‘ž1/𝑉1 ][π‘ž3/𝑆3β€² ],
requires applying the technical lemma on our assumption
𝑐2 ≑A𝑁 ⟨ πœ‡π‘ž3 .𝑐3 β€– 𝑆3 ⟩ , to get a non-larger derivation
of 𝑐2 [ π‘ž1/𝑉1 ] ≑A ⟨ πœ‡π‘ž3 .𝑐3 [π‘ž1/𝑉1 ] β€– 𝑆3β€² ⟩ ; inspecting this
derivation, which starts with the same structure as the one
for 𝑐2 ≑A𝑁 βŸ¨πœ‡π‘ž3 .𝑐3 β€– 𝑆3 ⟩ , gives a non-larger derivation of
𝑐2 [π‘ž1/𝑉1 ][π‘ž3/𝑆3β€² ] ≑A 𝑐3 [π‘ž1/𝑉1 ][π‘ž3/𝑆3β€² ].
β– 
β€²
β€²
βŒŠβŸ¨π‘‰1 β€– πœ‡π‘ž1 .𝑐1 ⟩[π‘ž/𝑉 ]πœŽβŒ‹R ≑A+𝑁 βŒŠπ‘2 [π‘ž/𝑉 ]πœŽβŒ‹R
from our assumption
βŒŠπ‘1 𝜎[π‘ž1 /𝑉1 𝜎]βŒ‹R ≑A+𝑁 βŒŠπ‘2 𝜎[π‘ž1/𝑉1 𝜎]βŒ‹R
by the following equational reasoning:
=
𝑉1 =𝑉
=
π‘žβˆ‰πœŽ
=
π‘ž1 =π‘ž
=
=
(⊳R )
=
π‘žβˆ‰πœŽ
=
(π‘ž1 =π‘ž)∧(𝑉1 =𝑉 )
=
βŒŠβŸ¨π‘‰1 β€– πœ‡π‘ž1 .𝑐1 ⟩[π‘ž/𝑉 ]πœŽβŒ‹R ≑A+ βŒŠπ‘2 [π‘ž/𝑉 ]πœŽβŒ‹R
𝑁
βŒŠβŸ¨π‘‰1 [π‘ž/𝑉 ] β€– πœ‡π‘ž1 .𝑐1 [π‘ž/𝑉 ]βŸ©πœŽβŒ‹R ≑A+ βŒŠπ‘2 [π‘ž/𝑉 ]πœŽβŒ‹R
𝑁
βŒŠβŸ¨π‘ž β€– πœ‡π‘ž1 .𝑐1 [π‘ž/𝑉 ]βŸ©πœŽβŒ‹R ≑A+𝑁 βŒŠπ‘2 [π‘ž/𝑉 ]πœŽβŒ‹R
βŒŠβŸ¨π‘žπœŽ β€– πœ‡π‘ž1 .𝑐1 [π‘ž/𝑉 ]πœŽβŸ©βŒ‹R ≑A+𝑁 βŒŠπ‘2 [π‘ž/𝑉 ]πœŽβŒ‹R
Proof of lemma 11.: The proof goes by proving each
equation of ( ≃RE ) admissible for ( ≑A ). This is immediate
for ( β†’R )-reductions thanks to the rule A-R. For the expansions, we have for example the case ⟨ π‘₯+ β€– 𝑒+ ⟩ β†’EβŠ—
+
⟨ π‘₯ β€– πœ‡(π‘₯1 , π‘₯2 ).⟨(π‘₯1 , π‘₯2 ) β€– 𝑒+ ⟩ ⟩ which is proved by the
following inference.
⟨(π‘₯1 , π‘₯2 ) β€– 𝑒+ ⟩[(π‘₯1 , π‘₯2 )/π‘₯+] = ⟨π‘₯+ β€– 𝑒+ ⟩[(π‘₯1 , π‘₯2 )/π‘₯+]
β€”
+
+
⟨π‘₯ β€– πœ‡(π‘₯1 , π‘₯2 ).⟨(π‘₯1 , π‘₯2 ) β€– 𝑒+ ⟩⟩ ≑A ⟨π‘₯ β€– 𝑒+ ⟩
Note that we do not need to handle the case of the extensions
πΈπœ‡ and 𝐸 πœ‡,Μƒ only those that inspect value or stack constructors.
Indeed, putting a normal form into focused form, as described
in Lemma 6, normalizes the πΈπœ‡, πœ‡Μƒ structure: we have 𝑓 βŠ³πΈπœ‡,πœ‡Μƒ
𝑓 β€² only if 𝑓 = 𝑓 β€² .
β– 
βŒŠβŸ¨π‘ž β€– πœ‡π‘ž1 .𝑐1 [π‘ž/𝑉 ]πœŽβŸ©βŒ‹R ≑A+𝑁 βŒŠπ‘2 [π‘ž/𝑉 ]πœŽβŒ‹R
βŒŠβŸ¨π‘ž1 β€– πœ‡π‘ž1 .𝑐1 [π‘ž/𝑉 ]πœŽβŸ©βŒ‹R ≑A+𝑁 βŒŠπ‘2 [π‘ž/𝑉 ]πœŽβŒ‹R
βŒŠπ‘1 [π‘ž/𝑉 ]πœŽβŒ‹R ≑A+𝑁 βŒŠπ‘2 [π‘ž/𝑉 ]πœŽβŒ‹R
βŒŠπ‘1 𝜎[π‘ž/𝑉 𝜎]βŒ‹R ≑A+𝑁 βŒŠπ‘2 𝜎[π‘ž/𝑉 𝜎]βŒ‹R
βŒŠπ‘1 [π‘ž1/𝑉1 ]πœŽβŒ‹R ≑A+𝑁 βŒŠπ‘2 [π‘ž1 /𝑉1 ]πœŽβŒ‹R
Proof of lemma 14.: Consider for example the case 𝑐1 =
⟨π‘₯+ β€– πœ‡[𝑧
Μƒ 1 .[ ]1 |𝑧2 .[ ]2 ]⟩. Given an arbitrary 𝑐2 , let us define:
β– 
Proof of lemma 10.: Combining 𝑐1 ≑A 𝑐2 and 𝑐2 ≑A 𝑐3
gives the following series of relations: 𝑐1 β†’R 𝑐1β€² ≑A𝑁 𝑐2β€² ←R
𝑐2 β†’R 𝑐2β€³ ≑A𝑁 𝑐3β€² ←R 𝑐3 . By confluence of (β†’R ) we know
that 𝑐2β€² = 𝑐2β€³ (they are both normal forms), so we have to
prove transitivity with 𝑐1β€² ≑A𝑁 𝑐2β€² ≑A𝑁 𝑐3β€² . We need to inspect
both inference rules; the easy cases are when 𝑐2β€² starts with
an abstractor which guides the equivalence on both sides. The
more interesting cases arise when the abstractors guiding the
equivalence are in 𝑐1β€² or 𝑐3β€² . We detail one of those cases.
Suppose we have:
𝑐1 [π‘ž1/𝑉1 ] ≑A 𝑐2 [π‘ž1/𝑉1 ]
𝑐2 [π‘ž3 /𝑆3 ] ≑A 𝑐3 [π‘ž3/𝑆3 ]
β€”
β€”
βŸ¨π‘‰1 β€– πœ‡π‘ž1 .𝑐1 ⟩ ≑A𝑁 𝑐2
𝑐2 ≑A𝑁 βŸ¨πœ‡π‘ž3 .𝑐3 β€– 𝑆3 ⟩
15
𝑒+ ≝ πœ‡π‘₯
Μƒ +.𝑐2 [𝑐1 [ ]] = πœ‡π‘₯
Μƒ +.𝑐2 [⟨π‘₯+ β€– πœ‡[𝑧
Μƒ 1 .[ ]1 |𝑧2 .[ ]2 ]⟩]
Then we have:
𝑐2 [𝑐1 [ ]]
⊲Rπœ‡Μƒ ⟨π‘₯+ β€– 𝑒+ ⟩
β†’EβŠ• ⟨π‘₯+ β€– πœ‡Μƒ[𝑧1 .βŸ¨πœ„1 (𝑧1 ) β€– 𝑒+ ⟩|𝑧2 .βŸ¨πœ„2 (𝑧2 ) β€– 𝑒+ ⟩]⟩
βˆ— +
β†’Rπœ‡,βŠ•
Μƒ 1 .𝑐2 [ ]1 |𝑧1 .𝑐2 [ ]2 ]⟩
⟨π‘₯ β€– πœ‡[𝑧
Μƒ
=𝑐1 [𝑐2 [ ]]
This concludes the proof in the case 𝑐1
=
Μƒ 1 .[ ]|𝑧2 .[ ]] ⟩ . The other cases are rather similar.
⟨ π‘₯+ β€– πœ‡[𝑧
For example, if 𝑐1 = ⟨ π‘₯+ β€– πœ‡(𝑦
Μƒ 1 , 𝑦2 ).[ ] ⟩ , then again with
𝑒+ ∢= πœ‡π‘₯
Μƒ +.𝑐2 [𝑐1 [ ]] we have:
𝑐2 [𝑐1 [ ]]
⊲Rπœ‡Μƒ ⟨π‘₯+ β€– 𝑒+ ⟩
β†’EβŠ• ⟨π‘₯+ β€– πœ‡(𝑦
Μƒ 1 , 𝑦2 ).⟨(𝑦1 , 𝑦2 ) β€– 𝑒+ ⟩⟩
β†’Rπœ‡Μƒ ⟨π‘₯+ β€– πœ‡(𝑦
Μƒ 1 , 𝑦2 ).𝑐2 [⟨(𝑦1 , 𝑦2 ) β€– πœ‡(𝑦
Μƒ 1 , 𝑦2 ).[ ]⟩]⟩
β†’RβŠ— βˆ— ⟨π‘₯+ β€– πœ‡(𝑦
Μƒ 1 , 𝑦2 ).𝑐2 [ ]⟩
=𝑐1 [𝑐2 [ ]]
β– 
Proof of 18: We show that (≃M ) βŠ† (≃RE𝛽 ) and (≃W ) βŠ†
(≃RE𝛽 ) separately.
For (≃W ) βŠ† (≃RE𝛽 ) we have to show that if 𝑐[ ] is a
commutative context and 𝑓 uses no variable bound by 𝑐[ ] over
its hole(s), then 𝑐[𝑓 ] ≃RE𝛽 𝑓 . By case analysis on commutative
contexts, we see that 𝑐[ ] is necessarily of the form 𝑐 β€² [πœ‡π‘žΜƒ +.[]]
(𝑐 cannot bind ⋆ as 𝑓 necessarily uses it). We thus have
that 𝑐[𝑓 ] = 𝑐 β€² [ πœ‡π‘žΜƒ +.𝑓 ] ≃Rπœ‡ ⟨ πœ‡+⋆.𝑐 β€² [⋆] β€– πœ‡π‘₯
Μƒ +.⟨π‘₯+ β€– πœ‡π‘žΜƒ +.𝑓 ⟩ ⟩
for a fresh π‘₯. We now prove that, if 𝑓 does not use π‘ž, then
πœ‡π‘žΜƒ +.𝑓 ≃RE πœ‡π‘¦Μƒ +.𝑓 for a fresh 𝑦; this allows to conclude with
+
β€²
Μƒ +.⟨π‘₯+ β€– πœ‡π‘žΜƒ +.𝑓 ⟩⟩ ≃RE βŸ¨πœ‡+⋆.𝑐 β€² [⋆] β€– πœ‡π‘¦
Μƒ +.𝑓 ⟩ βŠ³π›½ 𝑓 .
βŸ¨πœ‡ ⋆.𝑐 [⋆] β€– πœ‡π‘₯
If πœ‡π‘žΜƒ +.𝑓 is of the form πœ‡π‘§
Μƒ +.𝑓 for some variable 𝑧, the result
is immediate by 𝛼-conversion.
If πœ‡π‘žΜƒ +.𝑓 is of the form πœ‡(𝑧
Μƒ 1 , 𝑧2 ).𝑓 where 𝑓 does not use 𝑧1
Μƒ 1 , 𝑧2 ).⟨(𝑧1 , 𝑧2 ) β€– πœ‡π‘¦Μƒ +.𝑓 ⟩
or 𝑧2 , then we have πœ‡(𝑧
Μƒ 1 , 𝑧2 ).𝑓 ≃Rπœ‡Μƒ πœ‡(𝑧
+
for some fresh 𝑦 , and this is the (πΈβŠ—)-expansion of πœ‡π‘¦
Μƒ +.𝑓 .
+
|𝑧.𝑓 ] where 𝑓 does not use 𝑧,
If πœ‡π‘žΜƒ .𝑓 is of the form πœ‡[𝑧.𝑓
Μƒ
|𝑧.𝑓 ] ≃R πœ‡Μƒ[𝑧.βŸ¨πœ„1 𝑧 β€– πœ‡π‘¦
Μƒ +.𝑓 ⟩|𝑧.βŸ¨πœ„2 𝑧 β€– πœ‡π‘¦
Μƒ +.𝑓 ⟩]
we have that πœ‡[𝑧.𝑓
Μƒ
+
for some fresh 𝑦 , and this is the (πΈβŠ•)-expansion of πœ‡π‘¦
Μƒ +.𝑓 .
For (≃M ) βŠ† (≃RE𝛽 ) , we have to prove that for any pair of
πœ™
πœ™
independent commutative contexts 𝑐1 # 𝑐2 and substitution 𝜌
πœ™ πœ™
πœ™
πœ™
πœ™
such that 𝑐1 = 𝑐2 [𝜌], we have 𝑐1 [𝑐2 [𝑓 ]] ≃RE𝛽 𝑐1 [𝜌[𝑓 ]] for any
focused command 𝑓 . Again by case analysis on commutative
contexts we see that 𝑐1 , 𝑐2 cannot bind ⋆: a context that binds
⋆ over its hole must necessarily have a free occurence of it,
and thus cannot be independent with (an 𝛼-renaming of) itself.
Thus 𝑐1 , 𝑐2 are of the form 𝑐 β€² [πœ‡π‘žΜƒ +1.[ ]], 𝑐 β€² [πœ‡π‘žΜƒ +2.[ ]] for π‘ž1 and π‘ž2
𝛼-equivalent through the variable-variable substitution 𝜌. We
prove that 𝑐 β€² [πœ‡π‘žΜƒ +1.𝑐 β€² [πœ‡π‘žΜƒ +2.𝑓 ]] ≃RE𝛽 𝑐 β€² [πœ‡π‘žΜƒ +1.𝑓 [π‘ž1/π‘ž2 ]] as follows
for some fresh π‘ž =𝛼 π‘ž1 =𝛼 π‘ž2 :
βŠ²π›½
𝑐 β€² [πœ‡π‘žΜƒ +1.𝑐 β€² [πœ‡π‘žΜƒ +2.𝑓 ]]
+ +
+
β€²
βŸ¨πœ‡ ⋆.𝑐 [⋆] β€– πœ‡π‘žΜƒ 1.βŸ¨πœ‡ ⋆.𝑐 [⋆] β€– πœ‡π‘žΜƒ 2.𝑓 ⟩⟩
+
β€²
Μƒ +.⟨π‘₯+ β€– πœ‡π‘žΜƒ +1.⟨π‘₯+ β€– πœ‡π‘žΜƒ +2.𝑓 ⟩⟩⟩
βŸ¨πœ‡ ⋆.𝑐 [⋆] β€– πœ‡π‘₯
≃E
πœ‡+⋆.𝑐 β€² [⋆] πœ‡π‘žΜƒ +.βŸ¨π‘ž+ β€– πœ‡π‘₯
Μƒ +.⟨π‘₯+ β€– πœ‡π‘žΜƒ +1.⟨π‘₯+ β€– πœ‡π‘žΜƒ +2.𝑓 ⟩⟩⟩
β€–
⟨
⟩
⊳R πœ‡ Μƒ
+ +
+
+
β€²
+ +
βŸ¨πœ‡ ⋆.𝑐 [⋆] β€– πœ‡π‘žΜƒ .βŸ¨π‘ž β€– πœ‡π‘žΜƒ 1.βŸ¨π‘ž β€– πœ‡π‘žΜƒ 2.𝑓 ⟩⟩⟩
βŸ¨πœ‡+⋆.𝑐 β€² [⋆] β€– πœ‡π‘žΜƒ +.𝑓 [π‘ž/π‘ž1 ][π‘ž/π‘ž2 ]⟩
βŸ¨πœ‡+⋆.𝑐 β€² [⋆] β€– πœ‡π‘žΜƒ +1.𝑓 [π‘ž1/π‘ž2 ]⟩
𝑐 β€² [𝑓 [π‘ž1/π‘ž2 ]]
⊲Rπœ‡
≃R
=𝛼
⊳R�
+
β€²
β– 
Proof of theorem 19.:
We have to show that
βŸ¨π‘‘+ β€– πœ‡π‘₯
Μƒ +.𝑐0 ⟩ ≃REPMW 𝑐0 [𝑑+/𝑓 π‘₯+ ]. The term 𝑑 is either of
16
the formπœ‡+⋆.𝑑0 , or it is a valueβ€”in which case the result
is immediate. Let us define 𝑐1 as the focused normal-form
of 𝑐0 , and 𝑑1 as the focused normal form of 𝑑0 . We also
define as 𝑑[ ] the command context, with holes expecting
contexts, such that 𝑑[⋆] = 𝑑1 and ⋆ βˆ‰ fv(𝑑), and as 𝑐[ ]
the command context, with holes expecting expressions, such
that 𝑐[π‘₯+] = 𝑐1 and π‘₯+ βˆ‰ fv(𝑐). We need to prove that
𝑐[πœ‡+⋆.𝑑[⋆]] ≃REPM βŸ¨πœ‡+⋆.𝑑[⋆] β€– πœ‡π‘₯
Μƒ +.𝑐[π‘₯+]⟩ , the latter being
+
+
(≃RE )-equivalent to 𝑑[πœ‡π‘₯
Μƒ .𝑐[π‘₯ ]].
The main idea of the proof is that 𝑐[ πœ‡+⋆.[ ] ] is
covered by (compositions of) commutative contexts
independent from 𝑑[ πœ‡π‘₯
Μƒ +.[ ] ]: it can be described as
a multi-hole context 𝑐[ β–‘1 ][ β–‘2 ] … [ ░𝑛 ] such that for
each family of values 𝑉1 , … , 𝑉𝑛 and each family of
holes 𝑖 ∈ [1; 𝑛], 𝑐[ 𝑉1 ] … [ π‘‰π‘–βˆ’1 ][ ░𝑖 ][ 𝑉𝑖+1 ] … [ 𝑉𝑛 ]
is a composition of commutative contexts so that
𝑐[ 𝑉1 ] … [ π‘‰π‘–βˆ’1 ][ πœ‡+⋆.𝑑 [πœ‡π‘₯
Μƒ +.⟨π‘₯+ β€– β‹†βŸ©] ][ 𝑉𝑖+1 ] … [ 𝑉𝑛 ] ≃P
+
+
𝑑 [πœ‡π‘₯
Μƒ .𝑐[𝑉1 ] … [π‘‰π‘–βˆ’1 ][πœ‡ ⋆.⟨π‘₯+ β€– β‹†βŸ©][𝑉𝑖+1 ] … [𝑉𝑛 ]].
Note that the commutation is possible because the contexts
are independent. Indeed, the commutative contexts of 𝑐[πœ‡+⋆.[ ]]
neither use π‘₯+ (by construction of 𝑑[ ]) nor bind it over its hole
(any expression binder could be 𝛼-renamed), and 𝑑[πœ‡π‘₯
Μƒ +.] does
not use ⋆ by construction, and cannot bind it over one of its
hole, for ⋆ would then be shadowed in 𝑑1 = 𝑑[⋆].
In the special case 𝑛 = 0, 𝑐[ ] is in fact a focused command
𝑐, and we have to show that 𝑑[πœ‡π‘₯
Μƒ +.𝑐] ≃REPMW 𝑐. This is
immediate by weakening simplification (⊳W ), as π‘₯+ is not used
in 𝑐 by construction.
Otherwise (𝑛 β‰₯ 1), by iteration on [1; 𝑛] we can reorder 𝑛
copies of 𝑑[πœ‡π‘₯+.[ ]] in front of 𝑐, obtaining the term:
Μƒ +1. … 𝑑 [πœ‡π‘₯
Μƒ +𝑛.𝑐 [πœ‡+⋆.⟨π‘₯1 β€– β‹†βŸ©] … [πœ‡+⋆.⟨π‘₯𝑛 β€– β‹†βŸ©]]]
𝑑 [πœ‡π‘₯
those copies can be merged, so this is (≃M )-equivalent to
𝑑[πœ‡π‘₯
Μƒ +.𝑐[π‘₯+]] as desired.
Note that there is no need to interleave merging and phase
reordering, as merging does not create new opportunities for
phase reordering. It is essential, however, to apply merging
on the maximally-reordered command, as reordering command
creates merging opportunities.
We remark that there is a fundamental asymmetry in the
proof technique that follows the asymmetry of the intuitionistic
restriction: we permute, duplicate and reorder the value context
𝑑[πœ‡π‘₯
Μƒ +.[ ]] rather than the control context 𝑐[πœ‡+⋆.[ ]], reyling on
a notion of ”purity” that would be invalid in the full classical
setting.
β–