session types in a nutshell
play

Session Types in a Nutshell Session Types structure a series of - PowerPoint PPT Presentation

Session Types in a Nutshell Session Types structure a series of interactions in a simple and concise syntax and ensure type safe communication . A Protocol Protocol: Buyer-Seller Alice Seller title Description: Alice buying a


  1. Session Types in a Nutshell “… Session Types structure a series of interactions in a simple and concise syntax and ensure type safe communication .”

  2. A Protocol � Protocol: Buyer-Seller Alice Seller title � Description: Alice buying a book quote ok Address Date quit

  3. Are we compatible?

  4. Are we compatible?

  5. What is a type safe communication ? Communication safety • No communication mismatch Session Fidelity • Communications follow the desired protocol Progress • No deadlock/stuck in a session

  6. Session ‐ based Distributed Programming in Java Raymond Hu, Nobuko Yoshida Kohei Honda

  7. Implementing Customer (4) SJSocket s = SJSocket.create( p, … ) ; protocol p { begin. s. request() ; ![ s. outwhile(…) { !<String>. s. send( ” PARIS/EUROSTAR ” ) ; ?(int) cost = s. receive() ; ]* } !{ if (…) { ACCEPT: { s. outbranch(ACCEPT) { !<Address>. s. send( … ) ; ?(Date) date = s. receive() ; } , } REJECT: { } } else { } s. outbranch(REJECT) { } } } Raymond Hu, Nobuko Yoshida, Kohei Honda 38

  8. : � ⇥⇤⌅⇧⌃ ⌥⌃� ' ⌃⌃ " ⌦⇧↵��� ⌦ �✏ ⌦⌃⇣� ⌘� �� ✓⌃↵↵�⇤ ◆�⌃↵ BC ��� D;,# ? ✓⌫ CD;9E � ⇠�⇥ ⌃� # ) ⇤ ⌦ ⌦ 6 ⇤↵ $ �⌦ 2 ⇤� ⌃⌦ ⇡⇢� ⇡✓⌧� : � 3<44<7 � 1 ⇤�⇣ ⇥�↵ ��⇤ ⇤� ⇡⇢� ⇡✓⌧� : � B? ✓⌫ CD48E � ✓✏��⌥⌥⇥⌃ � ◆⌃✏ $ ⇤⇥⇤⌅� AA

  9. �⇥ ⇤⌅⇥⇧ ⌃⇥⌥� ⌦↵� ��✏⇣⌘ ↵ ✓◆◆

  10. �↵⌅�⌥�⌫� ⇠�⇡��� ⇢ �⌫⌧⇡⇥⇧ ⌅ � �✏⌅���↵⌅ ⌃↵ ⌅⇥⇧ ��⌧⌧↵⌥ �⇧ ! �⌧ " ⌦� #$%& � ' ( � ) ⌦ %&*+ � , ↵� �⇥ ' - ⌥ �⌅ ⌅ � . ⌥⌧⇣↵�⌅ / ⌥↵ �� 012 0 � 32 � $ ✓◆◆✓⌘ � 4 ⌥⇥�⌅�↵⌧⌅⇡↵⌥ ⌥ 5 012 0 � 32 � $ "( � ) ⌦ % ◆ + � �✏⇥↵⇠⇠�� ⌅⇡ ��✏⇣ ⌥�⌥�⇧ � , ⌫�⇡↵ ! ⌅⇥⇡⇧ ��⌧⌧↵⌥ �⇧ ! �⌧ " ⌦ ) ⌦ $% ◆ *+ � 61

  11. �↵⌅�⌥�⌫� ⇠�⇡��� ⇢ �⌫⌧⇡⇥⇧ ⌅ � �✏⌅���↵⌅ ⌃↵ ⌅⇥⇧ ��⌧⌧↵⌥ �⇧ ! �⌧ " ⌦� #$%& � ' ( � ) ⌦ %&*+ � , ↵� �⇥ ' - ⌥ �⌅ ⌅ � . ⌥⌧⇣↵�⌅ / ⌥↵ �� 012 0 � 32 � $ ✓◆◆✓⌘ � 4 ⌥⇥�⌅�↵⌧⌅⇡↵⌥ ⌥ 5 012 0 � 32 � $ "( � ) ⌦ % ◆ + � �✏⇥↵⇠⇠�� ⌅⇡ ��✏⇣ ⌥�⌥�⇧ � , ⌫�⇡↵ ! ⌅⇥⇡⇧ ��⌧⌧↵⌥ �⇧ ! �⌧ " ⌦ ) ⌦ $% ◆ *+ � 6 �

  12. ���������������������� ‣ ������������������� ‣ ������������������ ‣ ��������������������������������������������� ‣ �������������������������������������������� ‣ ����������������� ‣ ������������������������������������������ ������������� ‣ �������������������������������������������� ‣ �������������������������������������������������������������

  13. ����������������

  14. �������������� �����������������������������

  15. Us ∈ M obility R esearch G roup http://mrg.doc.ic.ac.uk/

  16. �⇥⇤ ⌅ �⇧⌃⇤⌥ / � ⌥⌦⇤⌃ " ⌅⌦�⌦ �⌦ / ⇤ � ↵ 0 � 1 �⌥ 2 ⇤⇥� 3,44 � 5# - 6 ⇤ ⌥⌃ 7 � ⇧✏⌦⇣⌘ ⇥✓⇧⇤⌥⌦⌅◆⌥ ⌃�⌥✏⇥�✏⌥⇤ ◆ ⌥ ⇧⌃⇤⌥ / ⌦⌅ ⇥⇤ ⌅⌃ ⌥ ✏⌅⌘ �� ⌅⌘ ⇧⇤✓ ⌅⌘ & � �⇤ ⇣⌫�⌦⇠⇤ ⌃⇤⌅⌃ ⌥ ⌘ � ⇥ ⌅⌃� ⌅�⇣✓ ⇥ ⇠⌦⌅ ◆⌥ ⇠ ⇧ � $ ◆◆⌫⌃ $ ⌥⇤ ⌅⌘ ⌅⌫⌃ $ ⌥⇤ 3 ⇤ &  & ⇧✏ ✓⌃ # ⌃✏⇧⇠ ⌥⌦⌅⇤⌃ # ✏⌅⌘⇤⌥⌫ ' �⇤⌥ ⇥ ⇠⇤⌥ ⌃ # ⌃ �⇤⇣⇣⌦�⇤⌃ 7# �⌥ ⌅⌃⇠⌦��⇤⌘ / ⌦ $ ⌦ $ ⌫⌃�⇤⇤⌘ ⌅⇤� ' ⌥⇡⌃ & 8

  17. �⇥⇤ ⌅ �⇧⌃⇤⌥ / � ⌥⌦⇤⌃ " ⌅⌦�⌦ �⌦ / ⇤ 9

  18. OOI agent negotiation 1/5 I https://confluence.oceanobservatories.org/display/syseng/ CIAD+COI+OV+Negotiate+Protocol 11 / 42

  19. OOI agent negotiation 2/5 type <yml> "SAPDoc1" from "SAPDoc1.yml" as SAP; global protocol Negotiate(role Consumer as C, role Producer as P) { } 12 / 42

  20. OOI agent negotiation 3/5 (choice) type <yml> "SAPDoc1" from "SAPDoc1.yml" as SAP; global protocol Negotiate(role Consumer as C, role Producer as P) { propose(SAP) from C to P; choice at P { accept() from P to C; confirm() from C to P; } or { reject() from P to C; } or { propose(SAP) from P to C; } } 13 / 42

  21. OOI agent negotiation 4/5 type <yml> "SAPDoc1" from "SAPDoc1.yml" as SAP; global protocol Negotiate(role Consumer as C, role Producer as P) { propose(SAP) from C to P; choice at P { accept() from P to C; confirm() from C to P; } or { reject() from P to C; } or { propose(SAP) from P to C; choice at C { accept() from C to P; confirm() from P to C; } or { reject() from C to P; } or { propose(SAP) from C to P; } } } 14 / 42

  22. OOI agent negotiation 5/5 (recursion) type <yml> "SAPDoc1" from "SAPDoc1.yml" as SAP; global protocol Negotiate(role Consumer as C, role Producer as P) { propose(SAP) from C to P; rec X { choice at P { accept() from P to C; confirm() from C to P; } or { reject() from P to C; } or { propose(SAP) from P to C; choice at C { accept() from C to P; confirm() from P to C; } or { reject() from C to P; } or { propose(SAP) from C to P; continue X; } } 15 / 42

  23. Local protocol projection (Negotiation Consumer) // Projection for Consumer // Global propose(SAP) to P; propose(SAP) from C to P; rec START { rec START { choice at P { choice at P { accept() from P; accept() from P to C; confirm() to P; confirm() from C to P; } or { } or { reject() from P; reject() from P to C; } or { } or { propose(SAP) from P; propose(SAP) from P to C; choice at C { choice at C { accept() to P; accept() from C to P; confirm() from P; confirm() from P to C; } or { } or { reject() to P; reject() from C to P; } or { } or { propose(SAP) to P; propose(SAP) from C to P; continue START; continue START; } } } } } } 19 / 42

  24. FSM generation (Negotiation Consumer) 20 / 42

  25. Dynamic Monitoring [RV’13, COORDINATION’14, FMSD’15, LMCS’17, CC’17 ]

  26. Type Checking [OOPSLA’15, ECOOP’16, ECOOP’17, COORDINATION’17 ]

  27. Code Generation [CC’15, FASE’16, FASE’17 ]

  28. Synthesis [ICALP’13, POPL’15, CONCUR’15, TACAS’16, CC’16 ]

  29. ������������������������ ���������������������� �������������� ����������������� ��������������������

  30. ����������������������������

  31. ����������������������������

  32. �����������������������������

  33. Scribble – Proving a distributed design

  34. Background: session subtyping (ESOP’99) (ESOP’09) (PPDP’14) 3

  35. Background: session subtyping (ESOP’99) (ESOP’09) (PPDP’14) 3

  36. Background: session subtyping (ESOP’99) (ESOP’09) (PPDP’14) 3

  37. Background: session subtyping (ESOP’99) (ESOP’09) (PPDP’14) 3

Recommend


More recommend