defunctionalized interpreters for call by need evaluation
play

Defunctionalized Interpreters for Call-by-Need Evaluation Olivier - PowerPoint PPT Presentation

Defunctionalized Interpreters for Call-by-Need Evaluation Olivier Danvy, University of Aarhus Kevin Millikin, Google Johan Munk, Arctic Lake Systems Ian Zerny, University of Aarhus Sendai, Japan FLOPS 2010 Motivation Formal semantics: why?


  1. Defunctionalized Interpreters for Call-by-Need Evaluation Olivier Danvy, University of Aarhus Kevin Millikin, Google Johan Munk, Arctic Lake Systems Ian Zerny, University of Aarhus Sendai, Japan FLOPS 2010

  2. Motivation Formal semantics: why? ◮ Understanding linguistic features ◮ Proving programs correct or equivalent ◮ Proving language properties ◮ Proving implementations, analyses or transformations correct Formal semantics: which kind? ◮ Denotational? ◮ Operational? Big step? Small step? ◮ Axiomatic? Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 2 / 18

  3. Foundations of this work Semantic artifacts can be inter-derived mechanically, and the inter-derivation is worthwhile: ◮ it can yield simpler semantics, and ◮ it can yield new semantics. Here: call by need. Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 3 / 18

  4. Call-by-need evaluation ◮ Demand-driven computation ◮ Memoization of intermediate results Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 4 / 18

  5. Semantics for call-by-need evaluation ◮ Store-based: results are saved in the global store ◮ Storeless: results are saved in the term itself Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 5 / 18

  6. Syntactic theories of call by need ◮ Different opinions — the POPL’95 affair ◮ The call-by-need lambda-calculus by Ariola and Felleisen (JFP’97) ◮ The call-by-need lambda-calculus by Maraist, Odersky and Wadler (JFP’98) Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 6 / 18

  7. Syntactic theories of call by need ◮ Different opinions — the POPL’95 affair ◮ The call-by-need lambda-calculus by Ariola and Felleisen (JFP’97) ◮ The call-by-need lambda-calculus by Maraist, Odersky and Wadler (JFP’98) ◮ Appearances can be deceiving: The standard reduction is common to both Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 6 / 18

  8. Syntactic theories of call by need ◮ Different opinions — the POPL’95 affair ◮ The call-by-need lambda-calculus by Ariola and Felleisen (JFP’97) ◮ The call-by-need lambda-calculus by Maraist, Odersky and Wadler (JFP’98) ◮ Appearances can be deceiving: The standard reduction is common to both ◮ It is our starting point Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 6 / 18

  9. Outline 1. The call-by-need λ -calculus 2. Deriving an abstract machine and a natural semantics Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 7 / 18

  10. The call-by-name λ let -calculus Terms ∋ T ::= x | λ x . T | T T | let x be T in T Values ∋ V ::= λ x . T Eval Cont ∋ E ::= [ ] | E T | let x be T in E Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 8 / 18

  11. The call-by-name λ let -calculus Terms ∋ T ::= x | λ x . T | T T | let x be T in T Values ∋ V ::= λ x . T Eval Cont ∋ E ::= [ ] | E T | let x be T in E ( λ z . z z ) (( λ y . y ) ( λ x . x )) �→ name Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 8 / 18

  12. The call-by-name λ let -calculus Terms ∋ T ::= x | λ x . T | T T | let x be T in T Values ∋ V ::= λ x . T Eval Cont ∋ E ::= [ ] | E T | let x be T in E ( λ z . z z ) (( λ y . y ) ( λ x . x )) �→ name let z be ( λ y . y ) ( λ x . x ) in z z �→ name Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 8 / 18

  13. The call-by-name λ let -calculus Terms ∋ T ::= x | λ x . T | T T | let x be T in T Values ∋ V ::= λ x . T Eval Cont ∋ E ::= [ ] | E T | let x be T in E ( λ z . z z ) (( λ y . y ) ( λ x . x )) �→ name let z be ( λ y . y ) ( λ x . x ) in z z �→ name let z be ( λ y . y ) ( λ x . x ) in (( λ y . y ) ( λ x . x )) z �→ name Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 8 / 18

  14. The call-by-name λ let -calculus Terms ∋ T ::= x | λ x . T | T T | let x be T in T Values ∋ V ::= λ x . T Eval Cont ∋ E ::= [ ] | E T | let x be T in E ( λ z . z z ) (( λ y . y ) ( λ x . x )) �→ name let z be ( λ y . y ) ( λ x . x ) in z z �→ name let z be ( λ y . y ) ( λ x . x ) in (( λ y . y ) ( λ x . x )) z �→ name let z be ( λ y . y ) ( λ x . x ) in ( let y be λ x . x in y ) z �→ name Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 8 / 18

  15. The call-by-name λ let -calculus Terms ∋ T ::= x | λ x . T | T T | let x be T in T Values ∋ V ::= λ x . T Eval Cont ∋ E ::= [ ] | E T | let x be T in E ( λ z . z z ) (( λ y . y ) ( λ x . x )) �→ name let z be ( λ y . y ) ( λ x . x ) in z z �→ name let z be ( λ y . y ) ( λ x . x ) in (( λ y . y ) ( λ x . x )) z �→ name let z be ( λ y . y ) ( λ x . x ) in ( let y be λ x . x in y ) z �→ name let z be ( λ y . y ) ( λ x . x ) in let y be λ x . x in y z �→ name Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 8 / 18

  16. The call-by-name λ let -calculus Terms ∋ T ::= x | λ x . T | T T | let x be T in T Values ∋ V ::= λ x . T Eval Cont ∋ E ::= [ ] | E T | let x be T in E ( λ z . z z ) (( λ y . y ) ( λ x . x )) �→ name let z be ( λ y . y ) ( λ x . x ) in z z �→ name let z be ( λ y . y ) ( λ x . x ) in (( λ y . y ) ( λ x . x )) z �→ name let z be ( λ y . y ) ( λ x . x ) in ( let y be λ x . x in y ) z �→ name let z be ( λ y . y ) ( λ x . x ) in let y be λ x . x in y z �→ name let z be ( λ y . y ) ( λ x . x ) in let y be λ x . x in ( λ x . x ) z �→ name Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 8 / 18

  17. The call-by-name λ let -calculus Terms ∋ T ::= x | λ x . T | T T | let x be T in T Values ∋ V ::= λ x . T Eval Cont ∋ E ::= [ ] | E T | let x be T in E ( λ z . z z ) (( λ y . y ) ( λ x . x )) �→ name let z be ( λ y . y ) ( λ x . x ) in z z �→ name let z be ( λ y . y ) ( λ x . x ) in (( λ y . y ) ( λ x . x )) z �→ name let z be ( λ y . y ) ( λ x . x ) in ( let y be λ x . x in y ) z �→ name let z be ( λ y . y ) ( λ x . x ) in let y be λ x . x in y z �→ name let z be ( λ y . y ) ( λ x . x ) in let y be λ x . x in ( λ x . x ) z �→ name let z be ( λ y . y ) ( λ x . x ) in let y be λ x . x in let x be z in x �→ name Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 8 / 18

  18. The call-by-name λ let -calculus Terms ∋ T ::= x | λ x . T | T T | let x be T in T Values ∋ V ::= λ x . T Eval Cont ∋ E ::= [ ] | E T | let x be T in E ( λ z . z z ) (( λ y . y ) ( λ x . x )) �→ name let z be ( λ y . y ) ( λ x . x ) in z z �→ name let z be ( λ y . y ) ( λ x . x ) in (( λ y . y ) ( λ x . x )) z �→ name let z be ( λ y . y ) ( λ x . x ) in ( let y be λ x . x in y ) z �→ name let z be ( λ y . y ) ( λ x . x ) in let y be λ x . x in y z �→ name let z be ( λ y . y ) ( λ x . x ) in let y be λ x . x in ( λ x . x ) z �→ name let z be ( λ y . y ) ( λ x . x ) in let y be λ x . x in let x be z in x �→ name let z be ( λ y . y ) ( λ x . x ) in let y be λ x . x in let x be z in z �→ name Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 8 / 18

  19. The call-by-name λ let -calculus Terms ∋ T ::= x | λ x . T | T T | let x be T in T Values ∋ V ::= λ x . T Eval Cont ∋ E ::= [ ] | E T | let x be T in E ( λ z . z z ) (( λ y . y ) ( λ x . x )) �→ name let z be ( λ y . y ) ( λ x . x ) in z z �→ name let z be ( λ y . y ) ( λ x . x ) in (( λ y . y ) ( λ x . x )) z �→ name let z be ( λ y . y ) ( λ x . x ) in ( let y be λ x . x in y ) z �→ name let z be ( λ y . y ) ( λ x . x ) in let y be λ x . x in y z �→ name let z be ( λ y . y ) ( λ x . x ) in let y be λ x . x in ( λ x . x ) z �→ name let z be ( λ y . y ) ( λ x . x ) in let y be λ x . x in let x be z in x �→ name let z be ( λ y . y ) ( λ x . x ) in let y be λ x . x in let x be z in z �→ name let z be ( λ y . y ) ( λ x . x ) in let y be λ x . x in let x be z in ( λ y . y ) ( λ x . x ) . . . Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 8 / 18

  20. The call-by-need λ let -calculus Terms ∋ T ::= x | λ x . T | T T | let x be T in T Values ∋ V ::= λ x . T Eval Cont ∋ E ::= [ ] | E T | let x be T in E | let x be E in E [ x ] Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 9 / 18

  21. The call-by-need λ let -calculus Terms ∋ T ::= x | λ x . T | T T | let x be T in T Values ∋ V ::= λ x . T Eval Cont ∋ E ::= [ ] | E T | let x be T in E | let x be E in E [ x ] ( λ z . z z ) (( λ y . y ) ( λ x . x )) �→ need Olivier Danvy ( danvy@cs.au.dk ) Defunctionalized Interpreters for Call-by-Need Evaluation FLOPS’10 9 / 18

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend