church
play

Church call-by-name (x.e) e x e{x:=e x - PowerPoint PPT Presentation

T HE C ALL-BY-NEED L AMBDA C ALCULUS, R EVISITED Stephen Chang and Matthias Felleisen Northeastern University 26/3/2012 Church call-by-name (x.e) e x e{x:=e x } ()


  1. T HE C ALL-BY-NEED L AMBDA C ALCULUS, R EVISITED Stephen Chang and Matthias Felleisen Northeastern University 26/3/2012 �

  2. Church ��

  3. ��

  4. ��

  5. ��

  6. ��

  7. ��

  8. λ call-by-name (λx.e) e x → e{x:=e x } (β) �����

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

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

  11. call-by-need ��

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

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

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

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

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

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

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

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

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

  21. λ need λ need-af λ need-mow � � Ariola/Felleisen Maraist/Odersky/Wadler '94,'95,'97 '94,'95,'98 call-by-need → → @ λx e x λx e x x x (reshuffle) ��

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

  23. our λ need call-by-need λx e x x ���

  24. our λ need call-by-need λx e x x ���

  25. our λ need call-by-need λx "demand path" e x x ���

  26. our λ need call-by-need λx "demand path" e x x (β need ) ���

  27. O LD λ need : O PERATIONAL O VERVIEW 1) Find the next demanded variable. 2) Find its corresponding argument and evaluate it. 3) Substitute evaluated argument for demanded variable. ���

  28. O LD λ need : O PERATIONAL O VERVIEW 1) Find the next demanded variable. 2) Find its corresponding argument and evaluate it. 3) Substitute evaluated argument for demanded variable. ���

  29. O LD λ need : D EMAND C ONTEXTS D = [ ] | D e ���

  30. O LD λ need : D EMAND C ONTEXTS D = [ ] | D e ���

  31. O LD λ need : D EMAND C ONTEXTS D = [ ] | D e | (λx.D) e ���

  32. O LD λ need : D EMAND C ONTEXTS D = [ ] | D e | (λx.D) e ���

  33. O LD λ need : D EMAND C ONTEXTS D = [ ] | D e | (λx.D) e ���

  34. O LD λ need : D EMAND C ONTEXTS D = [ ] | D e | (λx.D) e binding structure ���

  35. O LD λ need : D EMAND C ONTEXTS D = [ ] | D e | B[D] binding structure B = [ ] | (λx.B) e ���

  36. O LD λ need : B INDING S TRUCTURE B = [ ] | (λx.B) e (λx.(λy.(λz. ...) e z ) e y ) e x ���

  37. O LD λ need : B INDING S TRUCTURE B = [ ] | (λx.B) e (λx.(λy.(λz. ...) e z ) e y ) e x ���

  38. O LD λ need : B INDING S TRUCTURE B = [ ] | (λx.B) e (λx.(λy.(λz. ...) e z ) e y ) e x ���

  39. O LD λ need : B INDING S TRUCTURE B = [ ] | (λx.B) e (λx.(λy.(λz. ...) e z ) e y ) e x @ λx e x @ λy e y @ λz e z ... ���

  40. O LD λ need : R ESHUFFLING OF B INDINGS B = [ ] | (λx.B) e (((λx.λy.λz. ...) e x ) e y ) e z @ @ e z @ e y λx e x λy λz ... ���

  41. O LD λ need : R ESHUFFLING OF B INDINGS B = [ ] | (λx.B) e (((λx.λy.λz. ...) e x ) e y ) e z @ @ e z @ e y λx e x λy λz ... ���

  42. O LD λ need : R ESHUFFLING OF B INDINGS B = [ ] | (λx.B) e (((λx.λy.λz. ...) e x ) e y ) e z @ @ e z @ e y λx e x λy λz ... ���

  43. O LD λ need : R ESHUFFLING OF B INDINGS B = [ ] | (λx.B) e ((λx.(λy.λz. ...) e y ) e x ) e z @ @ e z λx e x @ λy e y λz ... ���

  44. O LD λ need : R ESHUFFLING OF B INDINGS B = [ ] | (λx.B) e ((λx.(λy.λz. ...) e y ) e x ) e z @ @ e z λx e x @ λy e y λz ... ���

  45. O LD λ need : R ESHUFFLING OF B INDINGS B = [ ] | (λx.B) e (λx.((λy.λz. ...) e y ) e z ) e x @ λx e x @ @ e z λy e y λz ... ���

  46. O LD λ need : R ESHUFFLING OF B INDINGS B = [ ] | (λx.B) e (λx.((λy.λz. ...) e y ) e z ) e x @ λx e x @ @ e z λy e y λz ... ���

  47. O LD λ need : R ESHUFFLING OF B INDINGS B = [ ] | (λx.B) e (λx.(λy.(λz. ...) e z ) e y ) e x @ λx e x @ λy e y @ λz e z ... ���

  48. P ROBLEMS WITH O LD C ALL-BY-NEED C ALCULUS 1) Reshuffling rules. ���

  49. O LD λ need : O PERATIONAL O VERVIEW 1) Find the next demanded variable. 2) Find its corresponding argument and evaluate it. 3) Substitute evaluated argument for demanded variable. ���

  50. O LD λ need : O PERATIONAL O VERVIEW 1) Find the next demanded variable. 2) Find its corresponding argument and evaluate it. 3) Substitute evaluated argument for demanded variable. ���

  51. O LD λ need : O PERATIONAL O VERVIEW 1) Find the next demanded variable. 2) Find its corresponding argument and evaluate it. 3) Substitute evaluated argument for demanded variable. ���

  52. O LD λ need : D EREFERENCING (λx.(λy.(λz. ...) e z ) e y ) e x @ λx e x @ λy e y @ λz e z ... ���

  53. O LD λ need : D EREFERENCING (λx.(λy.(λz. y ) e z ) e y ) e x @ λx e x @ λy e y @ λz e z y ���

  54. O LD λ need : D EREFERENCING (λx.(λy.(λz. y ) e z ) v y ) e x @ λx e x @ λy v y @ λz e z y ���

  55. O LD λ need : D EREFERENCING (λx.(λy.(λz. y ) e z ) v y ) e x @ λx e x @ λy v y @ λz e z y (λy.D[y]) v → (λy.D[v]) v (deref) ���

  56. O LD λ need : D EREFERENCING (λx.(λy.(λz. v y ) e z ) v y ) e x @ λx e x @ λy v y @ λz e z v y (λy.D[y]) v → (λy.D[v]) v (deref) ���

  57. P ROBLEMS WITH O LD C ALL-BY-NEED C ALCULUS 1) Reshuffling rules. 2) Arguments and applications never go away. ���

  58. N EW λ need : H ANDLING A RBITRARY B INDING S TRUCTURE @ λx e x @ λy e y @ λz e z ... �������

  59. N EW λ need : H ANDLING A RBITRARY B INDING S TRUCTURE @ λx e x @ λy e y @ λz e z ... B = [ ] | (λx.B) e ���

  60. N EW λ need : H ANDLING A RBITRARY B INDING S TRUCTURE @ @ e z @ e y λx e x λy λz ... A = [ ] | ??? ���

  61. N EW λ need : H ANDLING A RBITRARY B INDING S TRUCTURE @ λx e x @ @ e z λy e y λz ... A = [ ] | ??? ���

  62. N EW λ need : H ANDLING A RBITRARY B INDING S TRUCTURE @ @ e z λx e x @ λy e y λz ... A = [ ] | ??? ���

  63. N EW λ need : H ANDLING A RBITRARY B INDING S TRUCTURE @ @ e z λx e x @ λy e y λz ... A = [ ] | (λx.A) e ���

  64. N EW λ need : H ANDLING A RBITRARY B INDING S TRUCTURE @ @ e z λx e x @ λy e y λz ... A = [ ] | (λx.A) e ���

  65. N EW λ need : H ANDLING A RBITRARY B INDING S TRUCTURE @ @ e z λx e x @ λy e y λz ... A = [ ] | (λx.A) e ���

  66. N EW λ need : H ANDLING A RBITRARY B INDING S TRUCTURE @ @ e z λx e x @ λy e y λz ... A = [ ] | A[(λx.A)] e ���

  67. N EW λ need : H ANDLING A RBITRARY B INDING S TRUCTURE @ @ e z λx e x @ λy e y λz ... A = [ ] | A[(λx.A)] e D = [ ] | D e | A[D] ���

  68. P ROBLEMS WITH O LD C ALL-BY-NEED C ALCULUS 1) Reshuffling rules. 2) Arguments and applications never go away. ���

  69. N EW λ need : S PLITTING C ONTEXTS @ @ e z @ e y λx e x λy λz ... ���

  70. N EW λ need : S PLITTING C ONTEXTS @ @ e z @ e y λx e x λy λz ... A[ ...] ���

  71. N EW λ need : S PLITTING C ONTEXTS @ @ e z @ e y λx e x λy λz D[y] A[D[y]] ���

  72. N EW λ need : S PLITTING C ONTEXTS @ @ e z @ e y λx e x λy λz D[y] A[D[y]] ���

  73. N EW λ need : S PLITTING C ONTEXTS @ @ e z @ e y λx e x λy λz D[y] ... (λy...D[y])...e y ... ���

  74. N EW λ need : S PLITTING C ONTEXTS @ @ e z @ e y λx e x λy λz D[y] ... (λy...D[y])...e y ... ���

  75. N EW λ need : S PLITTING C ONTEXTS @ @ e z @ e y λx e x λy λz D[y] ...A[λy...D[y] ] e y ... ���

  76. N EW λ need : S PLITTING C ONTEXTS @ @ e z @ e y λx e x λy λz D[y] ...A[λy...D[y] ] e y ... ���

  77. N EW λ need : S PLITTING C ONTEXTS @ @ e z @ e y λx e x λy λz D[y] ...A[λy. [D[y]]] e y ... = [ ] | A[λx. ] ���

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