behavioral types and logical frameworks an introduction
play

Behavioral Types and Logical Frameworks An Introduction Carsten Sch - PowerPoint PPT Presentation

Behavioral Types and Logical Frameworks An Introduction Carsten Sch urmann IT University of Copenhagen carsten@demtech.dk March 7, 2019 March 7, 2019 1 / 41 Motivation Buzzwords Concurrency Linear Logic Delegation


  1. Behavioral Types and Logical Frameworks An Introduction Carsten Sch¨ urmann IT University of Copenhagen carsten@demtech.dk March 7, 2019 March 7, 2019 1 / 41

  2. Motivation Buzzwords ◮ Concurrency ◮ Linear Logic ◮ Delegation ◮ Services ◮ Security March 7, 2019 2 / 41

  3. Motivating Example On a laptop not far from here ... You want to buy a book form and online store, but only if the price is right. March 7, 2019 3 / 41

  4. Motivating Example On a laptop not far from here ... You want to buy a book form and online store, but only if the price is right. Observations: ◮ More than one agent involved ◮ It is difficult to capture the invariant of such a system ◮ The “type” needs to capture the protocol of how messages are exchanged. March 7, 2019 3 / 41

  5. msc No! B S Buyer Seller Select book title Lookup price price Sorry March 7, 2019 4 / 41

  6. msc Yes! B S Buyer Seller Select book title Lookup price price Choose address address March 7, 2019 5 / 41

  7. Ingredients ◮ Concurrency Theory [Caires, Carbone, Gay, Honda, Yoshida] ◮ Logic [Pfenning, CS, Toninho, Wadler] ◮ Programming Languages [Pfenning, Montesi, Toninho] March 7, 2019 6 / 41

  8. Substructural Logical Frameworks “25 + 5 = 3 × 10” March 7, 2019 7 / 41

  9. Substructural Logical Frameworks “25 + 5 = 3 × 10” March 7, 2019 7 / 41

  10. Substructural Logical Frameworks “25 + 5 = 3 × 10” March 7, 2019 7 / 41

  11. Substructural Logical Frameworks “25 + 5 = 3 × 10” Concurrent LF [Cervesato et al. ’02] SSOS [Pfenning, Simmons ’13] Celf [Schack-Nielsen, CS’11] R1 : q ⊸ { d ⊗ d ⊗ n } . R2 : n ⊸ n ⊸ { d } . March 7, 2019 7 / 41

  12. Substructural Logical Frameworks “25 + 5 = 3 × 10” Concurrent LF [Cervesato et al. ’02] SSOS [Pfenning, Simmons ’13] Celf [Schack-Nielsen, CS’11] R1 : q ⊸ { d ⊗ d ⊗ n } . R2 : n ⊸ n ⊸ { d } . Observation ◮ Multi-formula premisses ◮ Multi-formula conclusions ◮ Multi-set rewriting March 7, 2019 7 / 41

  13. The Concurrent World is Substructural Substructural Logical Framework Dependently typed language for multi-set rewriting rules ⊗ Connective to group facts ⊸ Connective to express rewrite rules ∃ To create new evidence of facts Π To quantify over evidence of facts Substructural Operational Semantics Multi-set rewriting semantics ◮ Forward-Chaining Search ◮ Runs until quiescence ◮ All truth is ephemeral March 7, 2019 8 / 41

  14. Motivation The Central Questions of this Talk What happens if we shift from a process algebra view of concurrency/session types to a purely logical view? And how to do this shift? March 7, 2019 9 / 41

  15. 1 Linear Logic 2 Session Types -as- Judgments 3 Adding Choice 4 Substructual Logical Framework CLF 5 Programming with Session Types 6 Demo 7 Conclusion and Future Work March 7, 2019 10 / 41

  16. Linear Logic Linear Logic March 7, 2019 11 / 41

  17. Judgmental reconstruction Intuitionistic Logic Logic of truth. . Linear Logic Logic of ephemeral resources. . ∆ ⊢ A Linear Logic March 7, 2019 12 / 41

  18. Judgmental reconstruction Intuitionistic Logic Logic of truth. (Logic of facts). Linear Logic Logic of ephemeral resources. (Logic of food). ∆ ⊢ A Linear Logic March 7, 2019 12 / 41

  19. Judgmental reconstruction Intuitionistic Logic Logic of truth. (Logic of facts). Linear Logic Logic of ephemeral resources. (Logic of food). ∆ ⊢ A Important Properties: ◮ Cut-Elimination guarantees proof normalization ◮ Focusing limits proofs but not provability Linear Logic March 7, 2019 12 / 41

  20. Linear Logic – The Rules ∆ ⊢ C · ⊢ 1 1 R ∆ , 1 ⊢ C 1 L ∆ 1 ⊢ A ∆ 2 ⊢ B ∆ , A , B ⊢ C ⊗ R ∆ , A ⊗ B ⊢ C ⊗ L ∆ 1 , ∆ 2 ⊢ A ⊗ B ∆ , A ⊢ B ∆ 1 ⊢ A ∆ 2 , B ⊢ C ∆ ⊢ A ⊸ B ⊸ R ∆ 1 , ∆ 2 , A ⊸ B ⊢ C ⊸ L A ⊢ A init ∆ 1 ⊢ A ∆ 2 , A ⊢ C cut ∆ 1 , ∆ 2 ⊢ C Linear Logic March 7, 2019 13 / 41

  21. Linear Logic — Theorems Goes back to ... [Girard ’89] Theorem (Admissibility of init) For any formula A: A ⊢ A. Theorem (Admissibility of cut) If ∆ 1 ⊢ A and ∆ 2 , A ⊢ C then ∆ 1 , ∆ 2 ⊢ C. Linear Logic March 7, 2019 14 / 41

  22. Session Types -as- Judgments Session Types -as- Judgments March 7, 2019 15 / 41

  23. Linear Logic - Primitive Types ◮ Making Linear Logic practical ◮ τ ranges over strings, integers, ... Γ ⊢ τ inhabited Γ; ∆ ⊢ B ∧ R Γ; ∆ ⊢ τ ∧ B Γ , τ ; ∆ , B ⊢ C C ∧ L Γ; ∆ , τ ∧ B ⊢ Γ , τ ; ∆ ⊢ B τ ⊃ B ⊃ R Γ; ∆ ⊢ Γ ⊢ τ inhabited Γ; ∆ , B ⊢ C ⊃ L Γ; ∆ , τ ⊃ B ⊢ C Session Types -as- Judgments March 7, 2019 16 / 41

  24. Linear Logic - Primitive Types ◮ Making Linear Logic practical ◮ τ ranges over strings, integers, ... Γ ⊢ M : τ inhabited Γ; ∆ ⊢ T : B ∧ R Γ; ∆ ⊢ send � M � ; T : τ ∧ B Γ , x : τ ; ∆ , u : B ⊢ T : C Γ; ∆ , u : τ ∧ B ⊢ receive ( x ) [ u ]; T : C ∧ L Γ , x : τ ; ∆ ⊢ T : B Γ; ∆ ⊢ receive ( x ); T : τ ⊃ B ⊃ R Γ ⊢ M : τ inhabited Γ; ∆ , u : B ⊢ T : C ⊃ L Γ; ∆ , u : τ ⊃ B ⊢ send � M � [ u ]; T : C Session Types -as- Judgments March 7, 2019 16 / 41

  25. Encoding in a Substructural Logical Framework [Pfenning and Griffith ’15] Terms T 1R end 1L wait [ u ]; T ∧ R send � M � ; T ∧ L receive ( x ) [ u ]; T ⊃ R receive ( x ); T ⊃ L send � M � [ u ]; T ⊗ R, ⊗ L ... ⊸ R, ⊸ L ... Alternative: π -calculus [Caires & Pfenning ’10, Wadler ’12] Related: Classical version of linear logic [Wadler’12] Session Types -as- Judgments March 7, 2019 17 / 41

  26. Session Typing our Buyer Seller Example B S ⊢ string ∧ ( nat ⊃ 1) ( string ∧ ( nat ⊃ 1)) ⊢ 1 Comments ◮ B aka buyer ◮ S aka seller ◮ Denote the derivation of the judgment Session Types -as- Judgments March 7, 2019 18 / 41

  27. Buyer and Seller Example B S ⊢ string ∧ ( nat ⊃ 1) u:( string ∧ ( nat ⊃ 1)) ⊸ 1 ⊢ 1 = send � ”Harry potter” � ; Buyer B receive ( price ); end Seller S [ u ] = receive ( title ) [ u ]; send � $45 � [ u ]; wait [ u ]; end = cut B ( S [ u ]) . System C Session Types -as- Judgments March 7, 2019 19 / 41

  28. Adding Choice Adding Choice March 7, 2019 20 / 41

  29. Linear Logic – The Additives ∆ ⊢ A 1 ∆ ⊢ A 2 A 1 & A 2 & R ∆ ⊢ ∆ , A 1 ⊢ C C & L 1 ∆ , A 1 & A 2 ⊢ ∆ , A 2 ⊢ C C & L 2 ∆ , A 1 & A 2 ⊢ ∆ ⊢ A 1 ∆ ⊢ A 2 A 1 ⊕ A 2 ⊕ R 1 A 1 ⊕ A 2 ⊕ R 2 ∆ ⊢ ∆ ⊢ ∆ , A 1 ⊢ C ∆ , A 2 ⊢ C C ⊕ L ∆ , A 1 ⊕ A 2 ⊢ Adding Choice March 7, 2019 21 / 41

  30. Linear Logic – The Additives ∆ ⊢ T 1 : A 1 ∆ ⊢ T 2 : A 2 ∆ ⊢ offer (left ⇒ T 1 , right ⇒ T 2 ) : A 1 & A 2 & R ∆ , u : A 1 ⊢ T : C ∆ , u : A 1 & A 2 ⊢ left [ u ]; T : C & L 1 ∆ , u : A 2 ⊢ T : C ∆ , u : A 1 & A 2 ⊢ right [ u ]; T : C & L 2 ∆ ⊢ T : A 1 ∆ ⊢ T : A 2 ∆ ⊢ left; T : A 1 ⊕ A 2 ⊕ R 1 ∆ ⊢ right; T : A 1 ⊕ A 2 ⊕ R 2 ∆ , v : A 1 ⊢ T 1 : C ∆ , w : A 2 ⊢ T 2 : C ∆ , u : A 1 ⊕ A 2 ⊢ offer [ u ] (left ⇒ [ v ]; T 1 , right ⇒ [ w ]; T 2 ) : C ⊕ L Adding Choice March 7, 2019 21 / 41

  31. msc Yes! B = send � ”Harry Potter” � ; B S receive ( price ); Buyer Seller left; send (” Berlin ”); Select book end S = receive ( title ) [ u ]; title send � $45 � [ u ]; Lookup price offer[ u ]( left ⇒ price receive ( address ) [ u ]; wait [ u ]; Choose address end address right ⇒ wait [ u ]; end) Adding Choice March 7, 2019 22 / 41

  32. Substructual Logical Framework CLF Substructual Logical Framework CLF March 7, 2019 23 / 41

  33. Substructural Logics Lambek Logic Linear Logic Affine Logic Relevant Logic Intuitionistic Logic Substructual Logical Framework CLF March 7, 2019 24 / 41

  34. Substructural Logical Frameworks OLF LLF/CLF LF Substructual Logical Framework CLF March 7, 2019 25 / 41

  35. Substructural Logics A 1 , . . . , A m B 1 , . . . , B n name ◮ In LLF order matters [Girard ’89, Cervesato et al ’96] name : A 1 ⊗ · · · ⊗ A m ⊸ B 1 ⊗ · · · ⊗ B n ◮ In CLF order does not matter [Cervesato et al ’02] name : A 1 ⊗ · · · ⊗ A m ⊸ { B 1 ⊗ · · · ⊗ B n } Substructual Logical Framework CLF March 7, 2019 26 / 41

  36. Execution as Proof Search ◮ Proof search A . . . B corresponds to inhabitation of types. A ⊸ { B } ◮ All terms are equal modulo interleavings ◮ No leftovers in the multi-set allowed ◮ Lollimon [Lopez et al. ’05] ◮ Focusing [Andreoli ’92, Chaudhuri ’06, Miller ’05] Substructual Logical Framework CLF March 7, 2019 27 / 41

  37. Logical Framework CLF ◮ Focused version of Linear Logic [Andreoli ’92] ◮ Conservative Extension of LF [Honsell, Harper, Plotkin ’93] ◮ Types: A ::= P | S ⊸ A | Π x : S . A | A 1 & A 2 | { S } P ::= a | P N S ::= 1 | S 1 ⊗ S 2 | ! A | @ A | A | ∃ x : S 1 . S 2 ◮ Kinds: K ::= type | Π x : A . K We write A → B for Π x : A . B if x does not occur in B . Substructual Logical Framework CLF March 7, 2019 28 / 41

Recommend


More recommend