THE CALL-BY-NEED LAMBDA CALCULUS, REVISITED

Σχετικά έγγραφα
Dynamic types, Lambda calculus machines Section and Practice Problems Apr 21 22, 2016

The λ-calculus. Lecturer: John Wickerson. Phil Wadler

C.S. 430 Assignment 6, Sample Solutions

2 Composition. Invertible Mappings

Lecture 2. Soundness and completeness of propositional logic

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation

The Simply Typed Lambda Calculus

Differential equations

Fourier Series. MATH 211, Calculus II. J. Robert Buchanan. Spring Department of Mathematics

Sequent Calculi for the Modal µ-calculus over S5. Luca Alberucci, University of Berne. Logic Colloquium Berne, July 4th 2008

About these lecture notes. Simply Typed λ-calculus. Types

Section 8.3 Trigonometric Equations

An Inventory of Continuous Distributions

Partial Trace and Partial Transpose

derivation of the Laplacian from rectangular to spherical coordinates

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

Παρουσίαση Διακήρυξης Αρναουτάκη & υποψηφίων περιφερειακών συμβούλων στο Ρέθυμνο σελίδα 18 ΡΕΘΕΜΝΙΩΤΙΚΗ. ÓÏÊ! H ÇìéóÝëçíïò èá êõìáôßæåé óôçν...

Rewrite semantics for guarded recursion with universal quantification over clocks

3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:

Econ 2110: Fall 2008 Suggested Solutions to Problem Set 8 questions or comments to Dan Fetter 1

Statistical Inference I Locally most powerful tests

Math221: HW# 1 solutions

Living and Nonliving Created by: Maria Okraska

Example Sheet 3 Solutions

From the finite to the transfinite: Λµ-terms and streams

Exercises 10. Find a fundamental matrix of the given system of equations. Also find the fundamental matrix Φ(t) satisfying Φ(0) = I. 1.

Case 1: Original version of a bill available in only one language.

Homework 3 Solutions

Μορφοποίηση υπό όρους : Μορφή > Μορφοποίηση υπό όρους/γραμμές δεδομένων/μορφοποίηση μόο των κελιών που περιέχουν/

Ζητήματα Τυποποίησης στην Ορολογία - ο ρόλος και οι δράσεις της Επιτροπής Ορολογίας ΤΕ21 του ΕΛΟΤ

Solution to Review Problems for Midterm III

Example of the Baum-Welch Algorithm

ΣΧΕΣΕΙΣ στην Northwind

Trace Semantics for Polymorphic References. GaLoP 16 April 3rd 2016

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

MATHEMATICS. 1. If A and B are square matrices of order 3 such that A = -1, B =3, then 3AB = 1) -9 2) -27 3) -81 4) 81

If we restrict the domain of y = sin x to [ π, π ], the restrict function. y = sin x, π 2 x π 2

Επίδραση της Συμβολαιακής Γεωργίας στην Χρηματοοικονομική Διοίκηση των Επιχειρήσεων Τροφίμων. Ιωάννης Γκανάς

LECTURE 2 CONTEXT FREE GRAMMARS CONTENTS

2. THEORY OF EQUATIONS. PREVIOUS EAMCET Bits.

Problem Set 3: Solutions

Parametrized Surfaces

If we restrict the domain of y = sin x to [ π 2, π 2

Fractional Colorings and Zykov Products of graphs

Πανεπιστήμιο Δυτικής Μακεδονίας. Τμήμα Μηχανικών Πληροφορικής & Τηλεπικοινωνιών. Ηλεκτρονική Υγεία

Αλγόριθμοι και πολυπλοκότητα NP-Completeness (2)

Πώς μπορεί κανείς να έχει έναν διερμηνέα κατά την επίσκεψή του στον Οικογενειακό του Γιατρό στο Ίσλινγκτον Getting an interpreter when you visit your

GREECE BULGARIA 6 th JOINT MONITORING

A summation formula ramified with hypergeometric function and involving recurrence relation

A Lambda Model Characterizing Computational Behaviours of Terms

Enforcing Secure Service Composition

Strain gauge and rosettes

ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ. ΕΠΛ342: Βάσεις Δεδομένων. Χειμερινό Εξάμηνο Φροντιστήριο 10 ΛΥΣΕΙΣ. Επερωτήσεις SQL

Research on vehicle routing problem with stochastic demand and PSO2DP algorithm with Inver2over operator

Γενική Φυσική. Κίνηση & συστήματα αναφοράς. Η κίνηση. Η κίνηση. Η κίνηση. Η κίνηση 24/9/2014. Κίνηση και συστήματα αναφοράς. Κωνσταντίνος Χ.

ΙΩΑΝΝΗ ΑΘ. ΠΑΠΑΪΩΑΝΝΟΥ

Elements of Information Theory

Solutions to Exercise Sheet 5

Writing for A class. Describe yourself Topic 1: Write your name, your nationality, your hobby, your pet. Write where you live.

Introduction to Type Theory February 2008 Alpha Lernet Summer School Piriapolis, Uruguay. Herman Geuvers Nijmegen & Eindhoven, NL

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

EU-Profiler: User Profiles in the 2009 European Elections

Written Examination. Antennas and Propagation (AA ) April 26, 2017.

Assalamu `alaikum wr. wb.

H Βιοηθική και η διδακτική της. Μυρτώ Δραγώνα-Μονάχου

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011

Technical Research Report, Earthquake Research Institute, the University of Tokyo, No. +-, pp. 0 +3,,**1. No ,**1

Ηλεκτρονικοί Υπολογιστές IV

b. Use the parametrization from (a) to compute the area of S a as S a ds. Be sure to substitute for ds!

Σχολή Εφαρμοσμένων Μαθηματικών και Φυσικών Επιστημών. Εθνικό Μετσόβιο Πολυτεχνείο. Thales Workshop, 1-3 July 2015

*❸341❸ ❸➈❽❻ ❸&❽❼➅❽❼❼➅➀*❶❹❻❸ ➅❽❹*➃❹➆❷❶*➈❹1➈. Pa X b P a µ b b a ➁❽❽❷➂➂%&'%➁❽➈❽)'%➁❽❽'*➂%➁❽➄,-➂%%%,❹❽➀➂'❹➄%,❹❽❹'&,➅❸%&❹-❽❻ ,❹❽➀➂'❹➄%,❹❽❹'&,➅❸%&❹-❽❻

Appendix to On the stability of a compressible axisymmetric rotating flow in a pipe. By Z. Rusak & J. H. Lee

AMENDMENTS 1-9. XM United in diversity XM. European Parliament 2015/2156(DEC) Draft report Ryszard Czarnecki. PE589.

Approximation of distance between locations on earth given by latitude and longitude

ΑΓΓΛΙΚΗ ΓΛΩΣΣΑ ΣΕ ΕΙΔΙΚΑ ΘΕΜΑΤΑ ΔΙΕΘΝΩΝ ΣΧΕΣΕΩΝ & ΟΙΚΟΝΟΜΙΑΣ

Appendix S1 1. ( z) α βc. dβ β δ β

Bayesian statistics. DS GA 1002 Probability and Statistics for Data Science.

ΕΛΕΓΧΟΣ ΚΑΙ ΤΡΟΦΟΔΟΤΗΣΗ ΜΕΛΙΣΣΟΚΟΜΕΙΟΥ ΑΠΟ ΑΠΟΣΤΑΣΗ

IMES DISCUSSION PAPER SERIES

Areas and Lengths in Polar Coordinates

PRESENTATION TITLE PRESENTATION SUBTITLE

The effect of curcumin on the stability of Aβ. dimers

ΕΠΙΧΕΙΡΗΣΙΑΚΗ ΑΛΛΗΛΟΓΡΑΦΙΑ ΚΑΙ ΕΠΙΚΟΙΝΩΝΙΑ ΣΤΗΝ ΑΓΓΛΙΚΗ ΓΛΩΣΣΑ

Ψηφιακή Οικονομία. Διάλεξη 11η: Markets and Strategic Interaction in Networks Mαρίνα Μπιτσάκη Τμήμα Επιστήμης Υπολογιστών

BECAUSE WE REALLY WANT TO KNOW WHAT YOU THINK ABOUT SCHOOL AND YOUR GARDEN. Fairly true If I decide to learn something hard, I can.

ST5224: Advanced Statistical Theory II

Block Ciphers Modes. Ramki Thurimella

ω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω

Second Order RLC Filters

9.09. # 1. Area inside the oval limaçon r = cos θ. To graph, start with θ = 0 so r = 6. Compute dr

Nowhere-zero flows Let be a digraph, Abelian group. A Γ-circulation in is a mapping : such that, where, and : tail in X, head in

Section 9.2 Polar Equations and Graphs

Robust Network Interdiction with Invisible Interdiction Assets

The ε-pseudospectrum of a Matrix

Solve the difference equation

Σχήματα McCarthy I. Το σχήμα McCarthy είναι ένα γενικότερο προγραμματιστικό σχήμα:

TMA4115 Matematikk 3

Physical DB Design. B-Trees Index files can become quite large for large main files Indices on index files are possible.

Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής

Transcript:

THE CALL-BY-NEED LAMBDA CALCULUS, REVISITED Stephen Chang and Matthias Felleisen Northeastern University 26/3/2012 1

Church 12

13

24

35

46

57

λ call-by-name (.e) e{x:= } (β) 68-69

λ call-by-name E[(.e) ] E[e{x:= }] (β) "leftmost-outermost" e E 70

λ v call-by-value E[(.e) v x ] E[e{x:=v x }] (β v ) "leftmost-outermost" e E v x 71

call-by-need 72

call-by-need 1) Evaluate argument only when needed. 73

call-by-need 1) Evaluate argument only when needed. 2) Evaluate argument at most once. 74

λ?? need call-by-need 1) Evaluate argument only when needed. 2) Evaluate argument at most once. 75

λ need-af Ariola/Felleisen '94,'95,'97? = λ need? = λ need-mow Maraist/Odersky/Wadler '94,'95,'98 call-by-need 1) Evaluate argument only when needed. 2) Evaluate argument at most once. 76

λ need-af Ariola/Felleisen '94,'95,'97 λ need λ need-mow Maraist/Odersky/Wadler '94,'95,'98 call-by-need 1) Evaluate argument only when needed. 2) Evaluate argument at most once. 77

λ need-af Ariola/Felleisen '94,'95,'97 λ need λ need-mow Maraist/Odersky/Wadler '94,'95,'98 call-by-need 78

λ need-af Ariola/Felleisen '94,'95,'97 λ need λ need-mow Maraist/Odersky/Wadler '94,'95,'98 call-by-need x 79

λ need-af Ariola/Felleisen '94,'95,'97 λ need λ need-mow Maraist/Odersky/Wadler '94,'95,'98 call-by-need x 80

λ need-af Ariola/Felleisen '94,'95,'97 λ need λ need-mow Maraist/Odersky/Wadler '94,'95,'98 call-by-need x 81

λ need-af Ariola/Felleisen '94,'95,'97 λ need λ need-mow Maraist/Odersky/Wadler '94,'95,'98 call-by-need x x (reshuffle) 92

λ need-af Ariola/Felleisen '94,'95,'97 λ need λ need-mow Maraist/Odersky/Wadler '94,'95,'98 call-by-need v x v x x v x (like β) 103

our λ need call-by-need x 104

our λ need call-by-need x 105

our λ need call-by-need x "demand path" 106

our λ need call-by-need x (β need ) "demand path" 107

OLD λ need : OPERATIONAL OVERVIEW 1) Find the next demanded variable. 2) Find its corresponding argument and evaluate it. 3) Substitute evaluated argument for demanded variable. 108

OLD λ need : OPERATIONAL OVERVIEW 1) Find the next demanded variable. 2) Find its corresponding argument and evaluate it. 3) Substitute evaluated argument for demanded variable. 109

OLD λ need : DEMAND CONTEXTS D = [ ] D e 110

OLD λ need : DEMAND CONTEXTS D = [ ] D e 111

OLD λ need : DEMAND CONTEXTS D = [ ] D e (.D) e 112

OLD λ need : DEMAND CONTEXTS D = [ ] D e (.D) e 113

OLD λ need : DEMAND CONTEXTS D = [ ] D e (.D) e 114

OLD λ need : DEMAND CONTEXTS D = [ ] D e (.D) e binding structure 115

OLD λ need : DEMAND CONTEXTS D = [ ] D e B[D] binding structure B = [ ] (.B) e 116

OLD λ need : BINDING STRUCTURE B = [ ] (.B) e (.(λy.(λz....) e z ) e y ) 117

OLD λ need : BINDING STRUCTURE B = [ ] (.B) e (.(λy.(λz....) e z ) e y ) 118

OLD λ need : BINDING STRUCTURE B = [ ] (.B) e (.(λy.(λz....) e z ) e y ) 119

OLD λ need : BINDING STRUCTURE B = [ ] (.B) e (.(λy.(λz....) e z ) e y ) λy λz... e z e y 130

OLD λ need : RESHUFFLING OF BINDINGS B = [ ] (.B) e (((.λy.λz....) ) e y ) e z λy λz... e y e z 131

OLD λ need : RESHUFFLING OF BINDINGS B = [ ] (.B) e (((.λy.λz....) ) e y ) e z λy λz... e y e z 132

OLD λ need : RESHUFFLING OF BINDINGS B = [ ] (.B) e (((.λy.λz....) ) e y ) e z λy λz... e y e z 133

OLD λ need : RESHUFFLING OF BINDINGS B = [ ] (.B) e ((.(λy.λz....) e y ) ) e z λy λz... e y e z 149

OLD λ need : RESHUFFLING OF BINDINGS B = [ ] (.B) e ((.(λy.λz....) e y ) ) e z λy λz... e y e z 150

OLD λ need : RESHUFFLING OF BINDINGS B = [ ] (.B) e (.((λy.λz....) e y ) e z ) λy λz... e z e y 161

OLD λ need : RESHUFFLING OF BINDINGS B = [ ] (.B) e (.((λy.λz....) e y ) e z ) λy λz... e z e y 162

OLD λ need : RESHUFFLING OF BINDINGS B = [ ] (.B) e (.(λy.(λz....) e z ) e y ) λy λz... e z e y 173

PROBLEMS WITH OLD CALL-BY-NEED CALCULUS 1) Reshuffling rules. 174

OLD λ need : OPERATIONAL OVERVIEW 1) Find the next demanded variable. 2) Find its corresponding argument and evaluate it. 3) Substitute evaluated argument for demanded variable. 175

OLD λ need : OPERATIONAL OVERVIEW 1) Find the next demanded variable. 2) Find its corresponding argument and evaluate it. 3) Substitute evaluated argument for demanded variable. 176

OLD λ need : OPERATIONAL OVERVIEW 1) Find the next demanded variable. 2) Find its corresponding argument and evaluate it. 3) Substitute evaluated argument for demanded variable. 177

OLD λ need : DEREFERENCING (.(λy.(λz....) e z ) e y ) λy λz... e z e y 178

OLD λ need : DEREFERENCING (.(λy.(λz. y ) e z ) e y ) λz y λy e z e y 179

OLD λ need : DEREFERENCING (.(λy.(λz. y ) e z ) v y ) λz y λy e z v y 190

OLD λ need : DEREFERENCING (.(λy.(λz. y ) e z ) v y ) λz y λy e z v y (λy.d[y]) v (λy.d[v]) v (deref) 191

OLD λ need : DEREFERENCING (.(λy.(λz. v y ) e z ) v y ) λz v y λy e z v y (λy.d[y]) v (λy.d[v]) v (deref) 202

PROBLEMS WITH OLD CALL-BY-NEED CALCULUS 1) Reshuffling rules. 2) Arguments and applications never go away. 203

NEW λ need : HANDLING ARBITRARY BINDING STRUCTURE λy λz... e z e y 204-205

NEW λ need : HANDLING ARBITRARY BINDING STRUCTURE λy λz... e z e y B = [ ] (.B) e 206

NEW λ need : HANDLING ARBITRARY BINDING STRUCTURE λy λz... e y e z A = [ ]??? 207

NEW λ need : HANDLING ARBITRARY BINDING STRUCTURE λy λz... e z e y A = [ ]??? 208

NEW λ need : HANDLING ARBITRARY BINDING STRUCTURE λy λz... e y e z A = [ ]??? 209

NEW λ need : HANDLING ARBITRARY BINDING STRUCTURE λy λz... e y e z A = [ ] (.A) e 210

NEW λ need : HANDLING ARBITRARY BINDING STRUCTURE λy λz... e y e z A = [ ] (.A) e 211

NEW λ need : HANDLING ARBITRARY BINDING STRUCTURE λy λz... e y e z A = [ ] (.A) e 212

NEW λ need : HANDLING ARBITRARY BINDING STRUCTURE λy λz... e y e z A = [ ] A[(.A)] e 213

NEW λ need : HANDLING ARBITRARY BINDING STRUCTURE λy λz... e y e z A = [ ] A[(.A)] e D = [ ] D e A[D] 214

PROBLEMS WITH OLD CALL-BY-NEED CALCULUS 1) Reshuffling rules. 2) Arguments and applications never go away. 215

NEW λ need : SPLITTING CONTEXTS λy λz... e y e z 216

NEW λ need : SPLITTING CONTEXTS λy λz... e y e z A[...] 217

NEW λ need : SPLITTING CONTEXTS λy λz D[y] e y e z A[D[y]] 218

NEW λ need : SPLITTING CONTEXTS λy λz D[y] e y e z A[D[y]] 219

NEW λ need : SPLITTING CONTEXTS λy λz D[y] e y e z... (λy...d[y])...e y... 220

NEW λ need : SPLITTING CONTEXTS λy λz D[y] e y e z... (λy...d[y])...e y... 221

NEW λ need : SPLITTING CONTEXTS λy λz D[y] e y e z...a[λy...d[y] ] e y... 222

NEW λ need : SPLITTING CONTEXTS λy λz D[y] e y e z...a[λy...d[y] ] e y... 223

NEW λ need : SPLITTING CONTEXTS λy λz D[y] e y e z...a[λy. [D[y]]] e y... = [ ] A[. ] 224

NEW λ need : SPLITTING CONTEXTS λy λz D[y] e y e z...a[λy. [D[y]]] e y... = [ ] A[. ] 225

NEW λ need : SPLITTING CONTEXTS λy λz D[y] e y e z [A[λy. [D[y]]] e y ] = [ ] A[. ] = [ ] A[ ] e 226

NEW λ need : SPLITTING CONTEXTS λy λz D[y] v y e z [A[λy. [D[y]]] v y ] = [ ] A[. ] = [ ] A[ ] e 237

NEW λ need : β need λy λz D[y] v y e z [A[λy. [D[y]]] v y ] [A[ [D[y]]{y:=v y }]] (β need) 238

NEW λ need : β need e z v y e z λy λz λz D[y] {y:=v y} D[y] [A[λy. [D[y]]] v y ] [A[ [D[y]]{y:=v y }]] (β need) 249

PROBLEMS WITH PREVIOUS CALL-BY-NEED CALCULUS 1) Reassociation rules. 2) Function calls not resolved. 250

NEW λ need : EVALUATING ARGUMENTS D = [ ] D e A[D] 251-252

NEW λ need : EVALUATING ARGUMENTS D = [ ] D e A[D] [A[λy. [D[y]]] D] 253

OTHER INTERESTING THINGS IN THE PAPER... Correspondence to Launchbury's (1993) machine semantics. 254-255

OTHER INTERESTING THINGS IN THE PAPER... Correspondence to Launchbury's (1993) machine semantics. Confluence, Standardization properties. 256

OTHER INTERESTING THINGS IN THE PAPER... Correspondence to Launchbury's (1993) machine semantics. Confluence, Standardization properties. Soundness with respect to observational equivalence. 257

Thanks! 258