A Nonstandard Standardization Theorem Beniamino Accattoli1 Eduardo Bonelli2 Carlos Lombardi 2,3 1 Carnegie
Delia Kesner3
Mellon University and Universit` a di Bologna
2 Univ.
Nac. de Quilmes and CONICET
3 Universit´ e
Paris-Diderot and CNRS
Outline
Standardization Explicit Substitutions Orthogonality and the Linear Substitution Calculus Proof Nets and Partial Standardization Orders Advertisement and Conclusions
Sorting Pick any vector of integers: 3, 1, 8, 6, 12, 4 It can always be sorted by swapping elements: 3, 1, 8, 6, 12, 4 1, 3, 8, 6, 12, 4 ... 1, 3, 4, 6, 8, 12 Remark that 1. Any two elements are comparable. 2. Swapping is linear and does not change the elements.
What is standardization about? I
Rough Idea: Standardization = Sorting redexes. R R
R
t →1 →2 . . . →k s ... Rσ(1) Rσ(2) Rσ(k) t → → ... → s with respect to an order ≺ (typically the left-to-right order). I
Standard derivation = ≺-ordered derivation.
I
Way subtler than sorting: 1. Redex creation ⇒ elements may not be comparable. 2. Swapping is non-linear: it may duplicate/erase redexes. 3. Swapping changes the elements.
Standardization and λ-calculus I
β-reduction: (λx.t)s →β t{x/s}.
I
λ-calculus does not come with an evaluation strategy.
I
Non-deterministic but confluent (unique result, if any).
Theorem (Standardization) Pick your favourite, arbitrary derivation d : t →∗β s. 1. Existence: it can be ordered wrt the left-to-right order. 2. Uniqueness: any sequence of swaps gives the same result. I
Completeness: non-standard derivations can be discarded.
I
Existence = Termination, Uniqueness = Confluence.
Leftmost Reduction, Normalization, and PL I
A further concept: Leftmost Reduction Strategy →leftmost : Reduce the leftmost redex at each step
I
More abstractly: leftmost = ≺-minimum.
I
→leftmost is standard (by minimality).
I
Normalization Thm: →leftmost reaches a normal form, if any.
I
More abstractly: ≺-minimum strategies are normalizing.
I
Plotkin’s Approach: 1. Standardization: calculus
programming language.
2. Idea: Abstract machines implement ≺-minimum strategies. 3. Justifications: completeness and normalization.
Outline
Standardization Explicit Substitutions Orthogonality and the Linear Substitution Calculus Proof Nets and Partial Standardization Orders Advertisement and Conclusions
Explicit Substitutions
I
λ-calculus is based on substitution (noted t{x/s}).
I
Implementations delay it, doing it lazily and partially.
I
Explicit Substitutions tried to close the gap: 1. Statically: a new constructor t[x/s] for delayed subst. 2. Dynamically: small-step operational semantics (λx.t)s →β t{x/s} becomes (λx.t)s
→B
t[x/s] →∗s t{x/s}
Ordinary Explicit Substitutions
(λx.t)s
→B
(tu)[x/s] →@ (λx.t)[x/s] →λ x[x/s] →var y [x/s] →gc
t[x/s] t[x/s]u[x/s] λx.t[x/s] s y
I
Substitutions percolate through the term structure;
I
Commuting with applications and abstractions;
I
Substituting only when facing variables.
This Paper
I
Natural expectation: Abstract Machines = ≺-minimum Strategies for ES.
I
No such Plotkin’s-style-theorem in the literature.
I
ES calculi are complex, non-orthogonal systems.
I
Standardization is out of scope.
I
This paper: a standardization theory for ES.
Outline
Standardization Explicit Substitutions Orthogonality and the Linear Substitution Calculus Proof Nets and Partial Standardization Orders Advertisement and Conclusions
Syntactic Orthogonality I
Syntactic Orthogonality: redexes cannot overlap.
I
Most standardization proofs rely on synt. orthogonality.
I
No ES calculus is syntactically orthogonal.
I
Example, consider the following reduction rules: (λx.t)s →B t[x/s] (tu)[x/s] →@ t[x/s]u[x/s] They induce a critical pair: (λx.t)[y /u]s[y /u]
@←
( (λx.t)s )[y /u] →B t[x/s][y /u]
Semantic Orthogonality I
Syntactic Orthogonality implies Semantical Orthogonality: s
P
s1 R/P
R
s2
P/R
t
aka parallel moves, or cube property, or residual system. I
Abstract Standardization relies on semantical orthogonality. [Gonthier, L´evy, and Melli`es, LICS ’91] [Melli` es PhD thesis, ’96]
I
No ordinary ES calculus is semantically orthogonal either.
A Nonstandard Calculus of ES
I
Linear logic and ES are related decompositions of λ-calculus. [Kesner and co-authors, LICS ’97, FOSSACS 2000,...]
I
Research culminated in the Linear Substitution Calculus. (next slide)
I
It is a calculus at a distance, where Distance = Use of contexts
I
No commutative rule, way simpler meta-theory.
I
Variation over calculi by Milner, De Bruijn, and Nederpelt.
Linear Substitution Calculus (LSC) I
Language: t, s, u
I
x
|
λx.t
|
ts
|
t[x/s]
One-Hole Contexts and Lists of substitutions contexts: C L
I
:=
:= :=
[·] | Ct | tC [·] | L[x/t]
| λx.C
| C [x/t] | t[x/C ]
Rewriting rules (closed by contexts C [·]): Beta at a Distance L[λx.t]s →dB L[t[x/s]] Linear Substitution C [x][x/s] →ls C [s][x/s] Garbage Collection t[x/s] →gc t
if x ∈ / fv(t)
Distance 1 I
Rule at a distance: L[λx.t]s →dB L[t[x/s]] (λx.t)[·/·] . . . [·/·] s →dB t[x/s][·/·] . . . [·/·]
I
Traditionally a configuration like: (λx.t)[y /s] u is not a redex, as it is blocked by [y /s].
I
Here, instead, it is a redex.
Distance 2 I
The substitution rules at a distance: C [x][x/s] →ls C [s][x/s] t[x/s] →gc t are the ordinary rules: x[x/s] →var y [x/s] →gc
if x ∈ / fv(t)
s y
integrating the commutative rules via contexts: (tu)[x/s] →@ t[x/s]u[x/s] (λx.t)[x/s] →λ λx.t[x/s] I
Distance
simpler proof of SN for LL [A., RTA 2013].
I
Implementable using pointers (vs de Bruijn indexes).
Features The Linear Substitution Calculus has many nice properties: I
Bisimilar to linear logic proof nets;
I
Expresses naturally 1. Linear head reduction (LHR) = Game semantics eval. 2. Weak LHR = π-calculus evaluation = KAM
I
...
I
As any other ES-calculus it is not syntactically orthogonal...
I
...but it is the first semantically orthogonal ES-calculus.
Left-to-Right Standardization For the LSC we provide: I
A left-to-right standardization theorem.
I
Proved by means of Melli` es axiomatics.
I
Simpler approaches as Plotkin’s or Takahashi’s do not work.
I
A notion of leftmost reduction →leftmost .
I
A proof that →leftmost is standard and normalising.
I
Weak linear head reduction (π and KAM) is standard.
I
Plotkin’s approach successfully lifted to ES.
Outline
Standardization Explicit Substitutions Orthogonality and the Linear Substitution Calculus Proof Nets and Partial Standardization Orders Advertisement and Conclusions
Inception of the LSC
I
LSC = algebraic copy of linear logic proof nets.
I
Every term t translates to a proof net Pt .
I
Every proof net P can be read back as a term tP .
I
Different terms may translate to the same proof net.
I
Proof nets are a syntactic quotient.
I
Dynamically: PN and LSC are behaviourally isomorphic.
Proof Nets Strong Bisimulation LSC terms and proof nets satisfy: s
t
t
s
Pt
Ps
⇒ Pt
and t
t
s
Pt
P0
⇒ ∃s s.t. Pt
P0
Strong Bisimulation: one step to one step, and viceversa.
The Graphical Equivalence I
The quotient is given by the following equivalence: t[x/s][y /u] ∼ t[y /u][x/s] (λx.t)[y /s] ∼ λx.t[y /s] (ts)[x/u] ∼ t[x/u]s
if x ∈ / fv(u) and y ∈ / fv(s) if x ∈ / fv(s) if x ∈ / fv(s)
I
Proof Nets = LSC/∼.
I
∼ preserves redexes and residuals.
I
∼ is a behavioural isomorphism of the LSC with itself.
I
The problem is that: t[x/s][y /u] ∼ t[y /u][x/s] does not preserve left-to-right derivations.
Partial Standardization Orders I
A standardization order ≺ validating: t[x/s][y /u] ∼ t[y /u][x/s] is necessarily partial.
I
Abstract standardization for partial orders exists (Melli` es).
I
But is very delicate and complex.
I
Standard derivations are up to swaps of incomparable elem.
I
Total Orders: Standardization = Term. & Conf. of swaps.
I
Partial Orders: Standardization = Term. & Conf. modulo.
The Nonstandard Standardization Theorem I
We define a partial box order validating ∼.
I
Based on the notion of explicit box for ! in linear logic.
I
The order satisfies only Melli`es’ axioms for existence.
I
We prove uniqueness in a novel abstract way.
I
Argument: the box embeds into the left-to-right order.
I
Main Result:
Theorem If t →∗∼ s then there is a box standard derivation from t to s that is unique up to swaps of incomparable elements. I
Note: modulo at two levels, Reduction (→∼ ) and Standardization (swaps).
Linear Head Reduction
I
LHR is non-deterministic, but it has the diamond property: s
s1
s2
t
Thus its non-determinism is harmless. I
It is not left-to-right standard.
I
We provide an original proof that it is box standard (next slide).
Co-Inductive External Redexes I
LHR picks ≺-minimal redexes.
I
Total order ⇒ ≺-minimum strategy is standard.
I
Partial order ⇒ ≺-minimal strategy may not be standard.
I
One has to pick special ≺-minimal redexes, called external.
I
Melli`es definition of external redexes is complex.
I
We provide a new co-inductive characterisation. A redex is external if 1) it is ≺-minimal and 2) its eventual residual is external
Outline
Standardization Explicit Substitutions Orthogonality and the Linear Substitution Calculus Proof Nets and Partial Standardization Orders Advertisement and Conclusions
Advertisement I
Reviewers: what is the connection with PL?
I
Abstract machines for call-by-name/value/need: B. Accattoli, P. Barenbaum, D. Mazza. Distilling Abstract Machines.
I
Another work: B. Accattoli, U. Dal Lago. Beta Reduction is Invariant, Indeed. solves a long-standing open problem using standardization.
I
Leftmost reduction is invariant wrt Turing machines.
I
Proved via leftmost reduction for the LSC.
Conclusions
I
A semantically orthogonal ES calculus.
I
A left-to-right stand. thm, lifting Plotkin’s approach to ES.
I
Standardization for a calculus modulo, via a partial order.
I
New light on the abstract theory.
I
General Perspective: Standard Derivations = Abstract Machine Hidden Inside the Calculus Itself
THANKS!