compiler generation for substructural operational
play

Compiler Generation for Substructural Operational Semantics Anand - PowerPoint PPT Presentation

Compiler Generation for Substructural Operational Semantics Masters Thesis Presentation Compiler Generation for Substructural Operational Semantics Anand Subramanian <asubrama@andrew.cmu.edu> 2012-12-18 Thesis Committee: Frank


  1. Compiler Generation for Substructural Operational Semantics Masters Thesis Presentation Compiler Generation for Substructural Operational Semantics Anand Subramanian <asubrama@andrew.cmu.edu> 2012-12-18 Thesis Committee: ▸ Frank Pfenning, Chair ▸ Iliano Cervesato, Carnegie Mellon Qatar

  2. Compiler Generation for Substructural Operational Semantics Introduction Introduction This thesis explores the synthesis of compilers and virtual machines from semantic specification of programming languages in SSOS. Our methodology has been tested on an encoding of the semantics of C0 in CLF.

  3. Compiler Generation for Substructural Operational Semantics Introduction Specification Synthesis

  4. Compiler Generation for Substructural Operational Semantics Introduction Compiling and Executing a Program

  5. Compiler Generation for Substructural Operational Semantics Introduction Outline Introduction Thesis Part 1 Separation using DPS in S3OS Active Transitions in S3OS Thesis Part 2 S3OS-sko: Skolemized Destinations S3OS-comp: Mode-driven Erasure Thesis Part 3 (Optional) S3OS-VM Erasing Program Text Conclusion

  6. Compiler Generation for Substructural Operational Semantics Introduction SSOS ▸ SSOS specifies semantics of programming languages using state-transition rules encoded in a substructural logic.

  7. Compiler Generation for Substructural Operational Semantics Introduction SSOS ▸ SSOS specifies semantics of programming languages using state-transition rules encoded in a substructural logic. ▸ ∆ ↝ ∆ ′ ∆ and ∆ ′ are states, represented as multisets of resources.

  8. Compiler Generation for Substructural Operational Semantics Introduction SSOS ▸ SSOS specifies semantics of programming languages using state-transition rules encoded in a substructural logic. ▸ ∆ ↝ ∆ ′ ∆ and ∆ ′ are states, represented as multisets of resources. ▸ A program’s execution is simulated by setting up the initial state ∆ 0 with the program and its environment, and repeatedly applying SSOS rules. ∆ 0 ↝ ∆ 1 ↝ ∆ 2 ↝ ...

  9. Compiler Generation for Substructural Operational Semantics Introduction Transition Rules in CLF ▸ CLF is a logical framework based on intuitionistic lax linear logic.

  10. Compiler Generation for Substructural Operational Semantics Introduction Transition Rules in CLF ▸ CLF is a logical framework based on intuitionistic lax linear logic. ▸ Transitions are encoded using linear implication in the forward chaining fragment.

  11. Compiler Generation for Substructural Operational Semantics Introduction Transition Rules in CLF ▸ CLF is a logical framework based on intuitionistic lax linear logic. ▸ Transitions are encoded using linear implication in the forward chaining fragment. ▸ Transitions rules only mention the resources that are being rewritten, i.e.: ∆ , a 1 , a 2 ... a m ↝ ∆ , c 1 , c 2 ... c n can be encoded as: a 1 , a 2 ... a m ↝ c 1 , c 2 ... c n

  12. Compiler Generation for Substructural Operational Semantics Introduction SSOS Transition Rule Schema ▸ Active rule: active ↝ r 1 , r 2 ,..., r n

  13. Compiler Generation for Substructural Operational Semantics Introduction SSOS Transition Rule Schema ▸ Active rule: active ↝ r 1 , r 2 ,..., r n ▸ Latent rule: passive 1 ,passive 2 ,...,passive m ,latent ↝ r 1 , r 2 ,..., r n

  14. Compiler Generation for Substructural Operational Semantics Introduction SSOS Transition Rule Schema ▸ Active rule: active ↝ r 1 , r 2 ,..., r n ▸ Latent rule: passive 1 ,passive 2 ,...,passive m ,latent ↝ r 1 , r 2 ,..., r n ▸ Resources must be strictly classified as active, latent or passive.

  15. Compiler Generation for Substructural Operational Semantics Introduction SSOS Transition Rule Schema ▸ Active rule: active ↝ r 1 , r 2 ,..., r n ▸ Latent rule: passive 1 ,passive 2 ,...,passive m ,latent ↝ r 1 , r 2 ,..., r n ▸ Resources must be strictly classified as active, latent or passive.

  16. Compiler Generation for Substructural Operational Semantics Introduction SSOS Resources in CLF exp : type. dest : type. eval : exp -> dest -> type. ret : exp -> dest -> type. frame : type. cont : frame -> dest -> dest -> type.

  17. Compiler Generation for Substructural Operational Semantics Introduction Example ⟨ exp ⟩ ::= ⟨ numeric-constant ⟩ | ⟨ exp ⟩ ⟨ op ⟩ ⟨ exp ⟩ ⟨ op ⟩ ::= + | x | ...

  18. Compiler Generation for Substructural Operational Semantics Introduction Example ⟨ exp ⟩ ::= ⟨ numeric-constant ⟩ | ⟨ exp ⟩ ⟨ op ⟩ ⟨ exp ⟩ ⟨ op ⟩ ::= + | x | ... bin : type. op : type. op/+ : op. op/x : op. exp/num : bin -> exp. exp/op : exp -> op -> e x p -> exp.

  19. Compiler Generation for Substructural Operational Semantics Introduction Specification of Binary Operations ev/op : eval (exp/op E1 B E2) W -o { Exists x. eval E1 x * cont (f/op1 B E2) x W }. tr/op1 : ret V1 X * cont (f/op1 B E2) X W -o { Exists x. eval E2 x * cont (f/op2 V1 B) x W }. tr/op2/add : ret (exp/num N2) X * cont (f/op2 (exp/num N1) op/+) X W * !bin/add N1 N2 b0 N3 _ -o { ret (exp/num N3) W }.

  20. Compiler Generation for Substructural Operational Semantics Introduction Specification of Binary Operations ev/op : eval (exp/op E1 B E2) W -o { Exists x. eval E1 x * cont (f/op1 B E2) x W }. tr/op1 : ret V1 X * cont (f/op1 B E2) X W -o { Exists x. eval E2 x * cont (f/op2 V1 B) x W }. tr/op2/add : ret (exp/num N2) X * cont (f/op2 (exp/num N1) op/+) X W * !bin/add N1 N2 b0 N3 _ -o { ret (exp/num N3) W }.

  21. Compiler Generation for Substructural Operational Semantics Introduction Specification of Binary Operations ev/op : eval (exp/op E1 B E2) W -o { Exists x. eval E1 x * cont (f/op1 B E2) x W }. tr/op1 : ret V1 X * cont (f/op1 B E2) X W -o { Exists x. eval E2 x * cont (f/op2 V1 B) x W }. tr/op2/add : ret (exp/num N2) X * cont (f/op2 (exp/num N1) op/+) X W * !bin/add N1 N2 b0 N3 _ -o { ret (exp/num N3) W }.

  22. Compiler Generation for Substructural Operational Semantics Introduction Ripple Carry Adder bit : type. bin : type. bin/add : bin -> bin -> bit -> bin -> bit -> type. #mode bin/add + + + - -.

  23. Compiler Generation for Substructural Operational Semantics Introduction Ripple Carry Adder bit : type. bin : type. bin/add : bin -> bin -> bit -> bin -> bit -> type. #mode bin/add + + + - -. Implemented using backward chaining

  24. Compiler Generation for Substructural Operational Semantics Introduction Returning a canonical value ev/num : eval (exp/num N) W -o { ret (exp/num N) W }.

  25. Compiler Generation for Substructural Operational Semantics Thesis Part 1 Outline Introduction Thesis Part 1 Separation using DPS in S3OS Active Transitions in S3OS Thesis Part 2 S3OS-sko: Skolemized Destinations S3OS-comp: Mode-driven Erasure Thesis Part 3 (Optional) S3OS-VM Erasing Program Text Conclusion

  26. Compiler Generation for Substructural Operational Semantics Thesis Part 1 Thesis Statement 1 The substructural operational semantics of a programming language can be stated in such a way that the latent resources are of static provenance, and passive resources are dynamic values.

  27. Compiler Generation for Substructural Operational Semantics Thesis Part 1 Thesis Statement 1 The substructural operational semantics of a programming language can be stated in such a way that the latent resources are of static provenance, and passive resources are dynamic values. In such a form, the latent resources correspond to instructions synthesized from the program, and passive resources correspond to operands to these instructions.

  28. Compiler Generation for Substructural Operational Semantics Thesis Part 1 In pictures ..., ret (exp/num V1) X1 , cont X1 (f/op1 op/+ ...) W1 ,...

  29. Compiler Generation for Substructural Operational Semantics Thesis Part 1 In pictures ..., ret (exp/num V1) X1 , cont X1 (f/op1 op/+ ...) W1 ,... � tr/op1 ..., ret (exp/num V2) X2 , cont X2 (f/op1 op/x ...) W2 ,...

  30. Compiler Generation for Substructural Operational Semantics Thesis Part 1 In pictures ..., ret (exp/num V1) X1 , cont X1 (f/op1 op/+ ...) W1 ,... � tr/op1 ..., ret (exp/num V2) X2 , cont X2 (f/op1 op/x ...) W2 ,... � tr/op1 ..., ret (exp/num V3) X3 , cont X3 (f/op2 op/x ...) W3 ,...

  31. Compiler Generation for Substructural Operational Semantics Thesis Part 1 In pictures ..., ret (exp/num V1) X1 , cont X1 (f/op1 op/+ ...) W1 ,... � tr/op1 ..., ret (exp/num V2) X2 , cont X2 (f/op1 op/x ...) W2 ,... � tr/op1 ..., ret (exp/num V3) X3 , cont X3 (f/op2 op/x ...) W3 ,... � tr/op2/mul ..., ret (exp/num V4) X4 , cont X4 (f/op2 op/+ ...) W4 ,...

  32. Compiler Generation for Substructural Operational Semantics Thesis Part 1 In pictures ..., ret (exp/num V1) X1 , cont X1 (f/op1 op/+ ...) W1 ,... � tr/op1 ..., ret (exp/num V2) X2 , cont X2 (f/op1 op/x ...) W2 ,... � tr/op1 ..., ret (exp/num V3) X3 , cont X3 (f/op2 op/x ...) W3 ,... � tr/op2/mul ..., ret (exp/num V4) X4 , cont X4 (f/op2 op/+ ...) W4 ,... � tr/op2/add

  33. Compiler Generation for Substructural Operational Semantics Thesis Part 1 Contributions ▸ Separable SSOS (S3OS) ▸ Semicompositional S3OS (S4OS) ▸ Techniques to transform SSOS to S3OS and S4OS.

  34. Compiler Generation for Substructural Operational Semantics Thesis Part 1 Big Picture

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