the beta cube
play

The Beta Cube a 1 , 2 Pablo Nogueira 2 us Gallego Arias 2 Alvaro - PowerPoint PPT Presentation

The Beta Cube a 1 , 2 Pablo Nogueira 2 us Gallego Arias 2 Alvaro Garc Emilio Jes 1 IMDEA Software Institute 2 Babel Research Group, Universidad Polit ecnica de Madrid ITU 2011, Kobenham 1 / 29 Context Reduction strategies for


  1. The Beta Cube ´ ıa 1 , 2 Pablo Nogueira 2 us Gallego Arias 2 Alvaro Garc´ Emilio Jes´ 1 IMDEA Software Institute 2 Babel Research Group, Universidad Polit´ ecnica de Madrid ITU 2011, Kobenham 1 / 29

  2. Context ◮ Reduction strategies for the pure (untyped) lambda calculus. . . 2 / 29

  3. Context ◮ Reduction strategies for the pure (untyped) lambda calculus. . . ◮ Normal Order, Applicative (Standard) Order [Barendregt 1984]. 2 / 29

  4. Context ◮ Reduction strategies for the pure (untyped) lambda calculus. . . ◮ Normal Order, Applicative (Standard) Order [Barendregt 1984]. ◮ Call-by-name, Call-by-value [Plotkin 1975] [Sestoft 2002]. 2 / 29

  5. Context ◮ Reduction strategies for the pure (untyped) lambda calculus. . . ◮ Normal Order, Applicative (Standard) Order [Barendregt 1984]. ◮ Call-by-name, Call-by-value [Plotkin 1975] [Sestoft 2002]. ◮ Head spine (he) [Sestoft 2002] (headNF in [Paulson 1996]). 2 / 29

  6. Context ◮ Reduction strategies for the pure (untyped) lambda calculus. . . ◮ Normal Order, Applicative (Standard) Order [Barendregt 1984]. ◮ Call-by-name, Call-by-value [Plotkin 1975] [Sestoft 2002]. ◮ Head spine (he) [Sestoft 2002] (headNF in [Paulson 1996]). ◮ Hybrid applicative order (ha) [Sestoft 2002]. 2 / 29

  7. Context ◮ Reduction strategies for the pure (untyped) lambda calculus. . . ◮ Normal Order, Applicative (Standard) Order [Barendregt 1984]. ◮ Call-by-name, Call-by-value [Plotkin 1975] [Sestoft 2002]. ◮ Head spine (he) [Sestoft 2002] (headNF in [Paulson 1996]). ◮ Hybrid applicative order (ha) [Sestoft 2002]. ◮ Hybrid normal order (hn) [Sestoft 2002]. 2 / 29

  8. Context ◮ Reduction strategies for the pure (untyped) lambda calculus. . . ◮ Normal Order, Applicative (Standard) Order [Barendregt 1984]. ◮ Call-by-name, Call-by-value [Plotkin 1975] [Sestoft 2002]. ◮ Head spine (he) [Sestoft 2002] (headNF in [Paulson 1996]). ◮ Hybrid applicative order (ha) [Sestoft 2002]. ◮ Hybrid normal order (hn) [Sestoft 2002]. ◮ Head reduction (hr) [Barendregt 1984]. 2 / 29

  9. Context ◮ Reduction strategies for the pure (untyped) lambda calculus. . . ◮ Normal Order, Applicative (Standard) Order [Barendregt 1984]. ◮ Call-by-name, Call-by-value [Plotkin 1975] [Sestoft 2002]. ◮ Head spine (he) [Sestoft 2002] (headNF in [Paulson 1996]). ◮ Hybrid applicative order (ha) [Sestoft 2002]. ◮ Hybrid normal order (hn) [Sestoft 2002]. ◮ Head reduction (hr) [Barendregt 1984]. ◮ . . . 2 / 29

  10. Context ◮ Reduction strategies for the pure (untyped) lambda calculus. . . ◮ Normal Order, Applicative (Standard) Order [Barendregt 1984]. ◮ Call-by-name, Call-by-value [Plotkin 1975] [Sestoft 2002]. ◮ Head spine (he) [Sestoft 2002] (headNF in [Paulson 1996]). ◮ Hybrid applicative order (ha) [Sestoft 2002]. ◮ Hybrid normal order (hn) [Sestoft 2002]. ◮ Head reduction (hr) [Barendregt 1984]. ◮ . . . ◮ . . . defined by sets of big-step rules. 2 / 29

  11. What are strategies useful for? ◮ Program optimization via partial evaluation. 3 / 29

  12. What are strategies useful for? ◮ Program optimization via partial evaluation. ◮ β -equivalence testers for typing rules in dependent types. 3 / 29

  13. What are strategies useful for? ◮ Program optimization via partial evaluation. ◮ β -equivalence testers for typing rules in dependent types. ◮ Interpreting universes in structural generic programming with dependent types. 3 / 29

  14. What are strategies useful for? ◮ Program optimization via partial evaluation. ◮ β -equivalence testers for typing rules in dependent types. ◮ Interpreting universes in structural generic programming with dependent types. ◮ . . . 3 / 29

  15. Pure lambda calculus reduction strategies (big-step) Call-by-name (cbn): cbn x → x cbn λ x . B → λ x . B �� �� �� �� cbn → M ′ ≡ λ x . B cbn [ N / x ] B → S M cbn M N → S �� �� �� �� → M ′ �≡ λ x . B cbn M → M ′ N cbn M N 4 / 29

  16. Pure lambda calculus reduction strategies (big-step) Call-by-name (cbn): Normal order (nor): nor cbn x → x x → x nor → B ′ B nor → λ x . B ′ cbn λ x . B λ x . B → λ x . B �� �� �� �� �� �� �� �� cbn → M ′ ≡ λ x . B cbn → M ′ ≡ λ x . B cbn nor [ N / x ] B → S [ N / x ] B → S M M nor cbn M N → S M N → S �� �� �� �� �� �� �� �� → M ′ �≡ λ x . B → M ′ �≡ λ x . B cbn cbn M ′ nor nor → M ′′ → N ′′ M M N → M ′′ N ′′ nor → M ′ N cbn M N M N Subsidiary Hybrid 4 / 29

  17. Pure lambda calculus reduction strategies (big-step) Call-by-name (cbn): Normal order (nor): nor cbn x → x x → x nor → B ′ B nor → λ x . B ′ cbn λ x . B λ x . B → λ x . B �� �� �� �� �� �� �� �� cbn → M ′ ≡ λ x . B cbn → M ′ ≡ λ x . B cbn nor [ N / x ] B → S [ N / x ] B → S M M nor cbn M N → S M N → S �� �� �� �� �� �� �� �� → M ′ �≡ λ x . B → M ′ �≡ λ x . B cbn cbn M ′ nor nor → M ′′ → N ′′ M M N → M ′′ N ′′ nor → M ′ N cbn M N M N Subsidiary Hybrid Hybrid reduces in more places than subsidiary! 4 / 29

  18. Pure lambda calculus reduction strategies (big-step) Rule Template: → B ′ B la var x abs → λ x . B ′ λ x . B st → x st → M ′ ≡ λ x . B → N ′ [ N ′ / x ] B su red M op 1 N ar 1 → S M N st → S → M ′ �≡ λ x . B M ′ op 2 → M ′′ → N ′ app M op 1 N ar 2 → M ′′ N ′ M N st 5 / 29

  19. Pure lambda calculus reduction strategies (big-step) Rule Template: → B ′ B la var x abs → λ x . B ′ λ x . B st → x st → M ′ ≡ λ x . B → N ′ [ N ′ / x ] B su red M op 1 N ar 1 → S M N st → S → M ′ �≡ λ x . B M ′ op 2 → M ′′ → N ′ app M op 1 N ar 2 → M ′′ N ′ M N st 5 / 29

  20. Pure lambda calculus reduction strategies (big-step) Rule Template (cbn): B id → B var x cbn abs λ x . B cbn → λ x . B → x → M ′ ≡ λ x . B red M cbn N id [ N / x ] B cbn → N → S M N cbn → S → M ′ �≡ λ x . B M ′ id → M ′ app M cbn N id → N → M ′ N M N cbn 5 / 29

  21. Pure lambda calculus reduction strategies (big-step) Rule Template (cbv): B id → B var x cbv abs λ x . B cbv → λ x . B → x → M ′ ≡ λ x . B → N ′ [ N ′ / x ] B cbv red M cbv N cbv → S M N cbv → S → M ′ �≡ λ x . B M ′ id → M ′ → N ′ app M cbv N cbv → M ′ N ′ M N cbv 5 / 29

  22. Pure lambda calculus reduction strategies (big-step) Rule Template (aor): → B ′ B aor var x aor abs → λ x . B ′ λ x . B aor → x → M ′ ≡ λ x . B → N ′ [ N ′ / x ] B aor red M aor N aor → S M N aor → S → M ′ �≡ λ x . B M ′ id → M ′ → N ′ app M aor N aor → M ′ N ′ M N aor 5 / 29

  23. Pure lambda calculus reduction strategies (big-step) Rule Template (nor): → B ′ B nor var x nor abs → λ x . B ′ λ x . B nor → x → M ′ ≡ λ x . B red M cbn N id [ N / x ] B nor → N → S M N nor → S → M ′ �≡ λ x . B M ′ nor → M ′′ → N ′ app M cbn N nor → M ′′ N ′ M N nor Use of op 1 and op 2 to accomodate hybrid strategies! 5 / 29

  24. The Beta Cube Parameters la , ar 1 and ar 2 are either recursive calls or identity. Interpreted as boolean switches: 6 / 29

  25. � � � � � � � � � � The Beta Cube Parameters la , ar 1 and ar 2 are either recursive calls or identity. Interpreted as boolean switches: la AOR CBV � � � � � � � � � � � � ar 1 � � 1 0 1 0 0 1 ( ⊑ ) � � � 1 1 0 0 1 0 � � � � ar 2 � � � � � � HE CBN 6 / 29

  26. � � � � � � � � � � The Beta Cube Parameters la , ar 1 and ar 2 are either recursive calls or identity. Interpreted as boolean switches: la AOR CBV 0 weakness 1 strength � � � � � � � � � � � � ar 1 � � 0 non-strictness 1 strictness 1 0 1 0 0 1 ( ⊑ ) � � � 1 1 0 0 1 0 � � � � ar 2 0 headness 1 non-headness � � � � � � HE CBN 6 / 29

  27. � � � � � � � � � � � � � � The Beta Cube Parameters la , ar 1 and ar 2 are either recursive calls or identity. Interpreted as boolean switches: la AOR CBV 0 weakness 1 strength � � � � � � � � � � � � ar 1 � � 0 non-strictness 1 strictness 1 0 1 0 0 1 ( ⊑ ) � � � 1 1 0 0 1 0 � � � � ar 2 0 headness 1 non-headness � � � � � � HE CBN nf wnf hnf whnf 6 / 29

  28. � � � � � � � � � � Axis of eval var x cbn abs λ x . B cbn → λ x . B → x → M ′ ≡ λ x . B red M cbn [ N / x ] B cbn → S M N cbn → S → M ′ �≡ λ x . B app M cbn → M ′ N M N cbn la strength AOR CBV � � � � � � � � � � ar 1 � � � strictness � 1 0 1 0 0 1 � � � 1 1 0 0 1 0 non-headness ar 2 � � � � � � �� �� �� �� � � � � HE CBN 7 / 29

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