On the Relative Usefulness of Fireballs Beniamino Accattoli

Claudio Sacerdoti Coen

INRIA, PARSIFAL team Universit` a di Bologna

Fireballs are a generalisation of values (in the sense of the call-by-value λ-calculus)

Outline Background Weak Call-by-Value λ-calculus Weak Call-by-Value Invariance, Revisited Fireballs Fireball Explosion How to Stop Worrying and Love the Bomb

The Invariance Thesis

Slot and van Emde Boas’ (Weak) Invariance Thesis:

Reasonable machines can simulate each other within a polynomially bounded overhead in time.

Long-standing problem: is λ-calculus a reasonable machine?

Bird’s Eye View

λ-Calculus

?

Turing Machines

Bird’s Eye View

Linear [A. & Dal Lago, RTA ’12]

λ-Calculus

Turing Machines

Bird’s Eye View

Linear [A. & Dal Lago, RTA ’12]

Turing Machines

λ-Calculus

?

Bird’s Eye View

Linear [A. & Dal Lago, RTA ’12]

Turing Machines

λ-Calculus Size Explosion Problem

Outline Background Weak Call-by-Value λ-calculus Weak Call-by-Value Invariance, Revisited Fireballs Fireball Explosion How to Stop Worrying and Love the Bomb

The Literature 1 Weak Call-by-Value λ-calculus is invariant. Blelloch & Greiner ’96; Sands & Gustavsson & Moran ’02; Dal Lago & Martini ’06.

Proof technique: simulation in a system with sharing. (Formalisms: abstract machines or graph reduction). Sands & al.: abstract machine with bilinear overhead. Bilinear = linear in 1. the number of β-steps, and 2. the size of the initial term (i.e. the input).

Schema of the Solution

Weak Call-by-Value λ-Calculus

Linear

RAM

Abstract Machine

Bilinear

The Literature 2

Strong Call-by-name λ-calculus is invariant. Accattoli & Dal Lago, CSL-LICS ’14.

Harder case, simple sharing is not enough. Proof technique: refined simulation with useful sharing Formalism: Linear substitution calculus aka explicit substitutions. Overhead: at least quadratic.

Schema of the Solutions

Strong Call-by-Name λ-Calculus Quadratic

RAM

Linear Substitution Calculus + Useful Sharing

Polynomial (linear?)

This Work Semi-strong Call-by-value λ-calculus is invariant. Semi-strong CBV = Weak CBV with open terms. Useful sharing is required. Proof technique: LSC + useful sharing + abstract machine. Main points: 1. Bilinear implementation λ → RAM; 2. Original combination of different techniques; (Practical values, distilleries, useful sharing);

3. Constant time implementation of useful sharing.

Outline Background Weak Call-by-Value λ-calculus Weak Call-by-Value Invariance, Revisited Fireballs Fireball Explosion How to Stop Worrying and Love the Bomb

Weak Call-by-Value Invariance, Revisited

Sands & al.’s result has been revisited last year. Decomposed in two works: 1. Distilling Abstract Machines. (Accattoli, Barenbaum, Mazza, ICFP 2014)

2. On the Value of Variables. (Accattoli & Sacerdoti Coen, WoLLIC 2014)

Distilling Abstract Machines Abstract machines = LSC + search of the redex.

Theorem The search of the redex is bilinear in the # of LSC steps. (for most CBN, CBV, and CBNeed machines in the literature)

Abstract machines = LSC + bilinear overhead. Two outcomes: 1. reasoning in the simpler LSC preserves complexity; 2. Principle for abstract machines.

Sands & al. Solution

Weak Call-by-Value λ-Calculus

Linear

RAM

Abstract Machine

Bilinear

Distilling Abstract Machines, ICFP 2014

Weak Call-by-Value λ-Calculus

RAM Bilinear

Weak Call-by-Value LSC

Bilinear

Abstract Machine

On the Value of Variables

Call-by-value schizophrenic literature: 1. Theoretical values = abstractions and variables. 2. Practical values = abstractions. The overhead in Weak CBV λ-calculus → Weak CBV LSC is: 1. Quadratic with theoretical values. 2. Linear with practical values.

Practical Values + Distillation

Weak Call-by-Value λ-Calculus

Bilinear

Bilinear

Linear

Weak Call-by-Value LSC

RAM

Bilinear

Abstract Machine

GLAM Leroy’s ZINC implements right-to-left CBV. GLAM = Global Leroy Abstract Machine. Global = just one global environments. Values are practical, i.e. are abstractions. Dump

Code

Stack

Env

Dump

Code

Stack

Env

D

ts

π

E

D : (t, π)

s



E

D : (t, π)

λx.s



E

D

t

λx.s : π

E

D

λx.t

v :π

E

β

D

t

π

[x v ]E

D

x

π

E

sub

D

E (x)α

π

E

Outline Background Weak Call-by-Value λ-calculus Weak Call-by-Value Invariance, Revisited Fireballs Fireball Explosion How to Stop Worrying and Love the Bomb

Extending CBV

Weak CBV key property: closed normal forms are values Adding free variables breaks the property. There are open normal forms that are not values, as x x. Problem: they block evaluation, as in (λy .δ) (x x) δ. Solution: generalizing values to fire-able terms, called fireballs.

The Fireball Calculus Language, extended with fireballs f : t, s, u v f

a | λx.t v |

:= := :=

x

|

|

λx.t

af . . . f | 1 {z n}

ts

n≥0

inert terms A

Right-to-left evaluation contexts: F

:=

h · i | Ff

| tF

Small-step Evaluation: Rule at Top Level (λx.t)f 7→f t{x f }

Contextual closure F hti →f F hsi iff t 7→f s

Key Property: →f normal forms are fireballs.

Open GLAM Open GLAM = kernel of Gr´egoire and Leroy’s machine (ICFP 2002). Open GLAM = GLAM + additional transition for free variables Dump

Code

Stack

Env

Dump

Code

Stack

Env

D

ts

π

E

D : (t, π)

s



E

D : (t, π)

λx.s



E

D

t

λx.s : π

E

D : (t, π)

a

π0

E

D

t

(a, π 0 ) : π

E

D

λx.t

f :π

E

β

D

t

π

[x f ]E

D

x

π

E

sub

D

E (x)α

π

E

Outline Background Weak Call-by-Value λ-calculus Weak Call-by-Value Invariance, Revisited Fireballs Fireball Explosion How to Stop Worrying and Love the Bomb

Size Explosion

Open terms bring a malicious behavior, called size explosion. Inert terms can grow exponentially with the number of β-steps. ⇒ A single substitution step can take exponential time. Key point: Substituting inert terms cannot create β-redexes.

Size Explosion

Fireball Calculus

Exponential!

Exponential!

Linear

Fireball LSC

RAM

Bilinear

Open GLAM

Outline Background Weak Call-by-Value λ-calculus Weak Call-by-Value Invariance, Revisited Fireballs Fireball Explosion How to Stop Worrying and Love the Bomb

Useful Sharing Remedy against size explosion: useful sharing. Complex definition (omitted). Surprisingly simple implementation. Intuitions (= the relative usefulness of fireballs): 1. Do a substitution step only when it creates a β-redex; 2. Therefore, never substitute inert terms, and 3. Substitute values only when the stack is non-empty. Complication: values have to include variables, i.e. are theoretical.

GLAMOUr The Useful Open GLAM, or GLAMOUr. Every term t in a π or E is labeled with l ∈ {λ, A}. Invariants: t λ unfolds (in E ) to an abstraction. t A unfolds (in E ) to a inert term. Dump

Code

Stack

Env

Dump

Code

Stack

Env

D

ts

π

E

D : (t, π)

s



E

D : (t, π) D : (t, π)

λx.s



a

π

E

0

D

E

l

E

t

λ



E

0 A



E

(λx.s)

D

t

(a, π )

β

D

t

π

usub

D



tl : π

E1 [x

s λ ]E2

[x

t l ]E

D

λx.t

t :π

D

x

tl : π

E1 [x

s λ ]E2

D : (t, π)

x



E1 [x

s λ ]E2

D

t

xλ : π

E1 [x

s λ ]E2

D : (t, π)

x

π0

E1 [x

s A ]E2

D

t

(x, π 0 )A : π

E1 [x

s A ]E2

Usefulness is tested in constant time, as it is coded by labels.

Semi-Strong CBV is Invariant

Fireball Calculus

Quadratic

Quadratic

Useful Fireball LSC

RAM Bilinear

Bilinear

GLAMOUr

Unchaining GLAMOUr

The quadratic overhead is due to theoretical values. Theoretical values are reintroduced by usefulness. A further unchaining optimization brings back practical values. The overhead becomes linear.

Final Result: Linear Overhead

Fireball Calculus

Bilinear

Linear

Unchaining Useful Fireball LSC

RAM Bilinear

Bilinear

Unchaining

GLAMOUr

Conclusions

Useful Sharing: Theoretically born concept, surprisingly relevant in practice. The GLAMOUr can be expon. faster than the Open GLAM. Strong improvement over Gr´ egoire and Leroy’s machine (their machine is used in the implementation of Coq). Abstract and sharp decomposition of call-by-value. Fireballs open the way to a new theory of call-by-value. (CBV Bohm theorem?).

THANKS!

On the Relative Usefulness of Fireballs

Inert terms can grow exponentially with the number of β-steps. ⇒ A single substitution step can take exponential time. Key point: Substituting inert terms cannot ...

225KB Sizes 1 Downloads 221 Views

Recommend Documents

On the Relative Usefulness of Fireballs
Abstract—In CSL-LICS 2014, Accattoli and Dal Lago [1] showed that there is an implementation of the ordinary (i.e. strong, pure, call-by-name) λ-calculus into ...

Further Evidence on the Usefulness of Real-Time ...
is quite surprising as one might expect the cumulative effect that the combination of inefficiency, .... Needless to say, the findings of this illustration suggest that there is much to be learned via analysis ... Monetary Economics 50, 525—546.

Perspective on the relative insignificance of increasing ...
long-term records of yield, (ii) data from key controlled-[CO2] experiments, and (iii) records of past .... attainable, and potential yield can increase with irrigation.

On modeling the relative fitness of storage
Dec 19, 2007 - This dissertation describes the steps necessary to build a relative fitness ...... retention, and availability (e.g., “What's the disaster recovery plan?

On modeling the relative fitness of storage (data ...
Nov 27, 2007 - V WorkloadMix model testing on Postmark samples. 251. W WorkloadMix model testing on ... A.4 Bandwidth relative error CDFs: Per-application summary . . . . . . . . . . . . . . . . . . . . 19 ... D.1 Performance graphs: FitnessBuffered

ON CRITICAL POINTS OF THE RELATIVE ...
Feb 7, 2018 - |x − y|N+2s dy. Then for every strict local extremal or non-degenerate critical point x0 of VΩ in Ω, there exists ε > 0 such that for every 0 < ε < ε there exist spherical-shaped surfaces with constant HΩ s curvature ... A.M. ha

Influence of temperature and relative humidity on ...
mallow and velvet leaf by Colletotrichum gloesporioides Noack. II.Some factors affec- ting germination and infection and their relationship to disease contribution ...

Exploring Factors That Affect Usefulness, Ease Of Use ... - Clute Institute
structural equation modeling. The results of this ..... 21.76% possessed a master's degree or were studying in the master's programs. Socioeconomically the ...

Coherence, Engagement and Usefulness as ...
NASA remote science team looking at geological data .... the “recovery” in timeslots 23-24). Here we ... sessions on track, again at a micro-moment level. This.

The Relative Importance of Aspects of Intellectual Capital for Software ...
The Relative Importance of Aspects of Intellectual Capital for Software ... 2School of Information Systems, Technology and Management ..... Human Resources. 1.

Visual perception of the relative phasing of human ... - Semantic Scholar
phase variability were used to generate computer displays of spheres oscillating either side to side in .... IIci and shown on an Apple 13-in. color display.

A Relative Rank Model of Gratitude - The University of Manchester
Imagine a person is helped by four friends for 5, 10, 15, and 20 min, respectively. The person ..... logical well-being above the Big Five facets. Personality and ...

ABSOLUTE RELATIVE
data-start data-100-start data--100-start. ABSOLUTE data-100-top data-top data-end data-100-end data--100-end. RELATIVE data-bottom data--100-top.

The Relative Importance of Aspects of Intellectual Capital for Software ...
used in the development of software today. It covers the ... IC is an increasingly important resource for companies ... ious models and indicators of IC [20, 19, 10].

Usefulness of C-reactive protein, serum amyloid A ...
using commercial Analytical Profile Index (API) tests. (API-Staph, API-Strep, ... software. The significance of differences was set at P. 0.05 and P. 0.01. 3. Results.

A note on the relative efficiency of property-liability ...
the direct mail companies, only a relatively small proportion of total premium ... Qmong the innovations are automated accounting systems and direct billing, .... l 3 We estimated the equations by using the AVETRAN program, developed by ...

Independence on Relative Probability Spaces and ...
the Social Sciences and Humanities Research Council of Canada as well as the ... (Harvard Business School working paper 92-011), and ``An Interpretation of ..... conditional probabilities induced on the information sets by imposing small.