mechanising session types onwards and upwards
play

Mechanising Session Types Onwards and Upwards Francisco Ferreira - PowerPoint PPT Presentation

Mechanising Session Types Onwards and Upwards Francisco Ferreira and Lorenzo Gheri (joint work with David Castro, and Nobuko Yoshida) 2019 ABCD Meeting The First Step Do a case study: Language Primitives and Type Discipline for


  1. Mechanising Session Types Onwards and Upwards Francisco Ferreira and Lorenzo Gheri (joint work with David Castro, and Nobuko Yoshida) 2019 ABCD Meeting

  2. The First Step • Do a case study: • Language Primitives and Type Discipline for Structured Communication-Based Programming Revisited, by Yoshida and Vasconcelos.

  3. The send receive system and its cousin the relaxed and the revisited system.

  4. The send receive system and its cousin the relaxed and the revisited system.

  5. The send receive system and its cousin the relaxed and the revisited system. This is the first step. Spoiler: Multiparty session types are next.

  6. What do we have? • A proof of type preservation formalised in Coq using ssreflect . • A library to implement locally nameless with multiple name scopes and handle environments in a versatile way. • We have a TACAS 2020 submission describing our tool. • We built some in-team expertise (i.e. we learned some hard lessons while struggling to finish the proof).

  7. What did we mechanise?

  8. A tale of three systems • We set out to represent the three systems described in the paper: • The Honda, Vasconcelos, Kubo system from ESOP’98

  9. A tale of three systems • We set out to represent the three systems described in the paper: • The Honda, Vasconcelos, Kubo system from ESOP’98 • Its naïve but ultimately unsound extension

  10. A tale of three systems • We set out to represent the three systems described in the paper: • The Honda, Vasconcelos, Kubo system from ESOP’98 • Its naïve but ultimately unsound extension • Its revised system inspired by Gay and Hole in Acta Informatica

  11. The Send Receive System P ::= request a ( k ) in P session request | accept a ( k ) in P session acceptance | k ![˜ e ]; P data sending | k ?(˜ x ) in P data reception | k ✁ l ; P label selection | k ✄ { l 1 : P 1 [ ] · · · [ ] l n : P n } label branching | throw k [ k ′ ]; P channel sending | catch k ( k ′ ) in P channel reception | if e then P else Q conditional branch | P | Q parallel composition | inact inaction | ( ν u ) P name/channel hiding | def D in P recursion e ˜ | X [˜ k ] process variables e ::= c constant | e + e ′ | e − e ′ | e × e | not ( e ) | . . . operators x 1 ˜ x n ˜ D ::= X 1 (˜ k 1 ) = P 1 and · · · and X n (˜ k n ) = P n declaration for recursion

  12. The Send Receive System P ::= request a ( k ) in P session request | accept a ( k ) in P session acceptance | k ![˜ e ]; P data sending | k ?(˜ x ) in P data reception | k ✁ l ; P label selection | k ✄ { l 1 : P 1 [ ] · · · [ ] l n : P n } label branching | throw k [ k ′ ]; P channel sending | catch k ( k ′ ) in P channel reception | if e then P else Q conditional branch | P | Q parallel composition | inact inaction | ( ν u ) P name/channel hiding | def D in P recursion e ˜ | X [˜ k ] process variables e ::= c constant | e + e ′ | e − e ′ | e × e | not ( e ) | . . . operators x 1 ˜ x n ˜ D ::= X 1 (˜ k 1 ) = P 1 and · · · and X n (˜ k n ) = P n declaration for recursion

  13. The Send Receive System P ::= request a ( k ) in P session request | accept a ( k ) in P session acceptance We consider terms up-to | k ![˜ e ]; P data sending α -conversion | k ?(˜ x ) in P data reception | k ✁ l ; P label selection | k ✄ { l 1 : P 1 [ ] · · · [ ] l n : P n } label branching | throw k [ k ′ ]; P channel sending | catch k ( k ′ ) in P channel reception | if e then P else Q conditional branch | P | Q parallel composition | inact inaction | ( ν u ) P name/channel hiding | def D in P recursion e ˜ | X [˜ k ] process variables e ::= c constant | e + e ′ | e − e ′ | e × e | not ( e ) | . . . operators x 1 ˜ x n ˜ D ::= X 1 (˜ k 1 ) = P 1 and · · · and X n (˜ k n ) = P n declaration for recursion

  14. The Send Receive System P ::= request a ( k ) in P session request | accept a ( k ) in P session acceptance We consider terms up-to | k ![˜ e ]; P data sending α -conversion | k ?(˜ x ) in P data reception | k ✁ l ; P label selection | k ✄ { l 1 : P 1 [ ] · · · [ ] l n : P n } label branching | throw k [ k ′ ]; P channel sending | catch k ( k ′ ) in P channel reception | if e then P else Q conditional branch | P | Q parallel composition Then we cannot distinguish: | inact inaction k?(x) in inact | ( ν u ) P name/channel hiding and | def D in P recursion k?(y) in inact e ˜ | X [˜ k ] process variables e ::= c constant | e + e ′ | e − e ′ | e × e | not ( e ) | . . . operators x 1 ˜ x n ˜ D ::= X 1 (˜ k 1 ) = P 1 and · · · and X n (˜ k n ) = P n declaration for recursion

  15. α -conversion curse or Blessing? ( throw k [ k ′ ]; P 1 ) | ( catch k ( k ′ ) in P 2 ) → P 1 | P 2 • The original system depends crucially on names

  16. α -conversion curse or Blessing? ( throw k [ k ′ ]; P 1 ) | ( catch k ( k ′ ) in P 2 ) → P 1 | P 2 • The original system depends crucially on names

  17. α -conversion curse or Blessing? ( throw k [ k ′ ]; P 1 ) | ( catch k ( k ′ ) in P 2 ) → P 1 | P 2 • The original system depends crucially on names This is a bound variable.

  18. α -conversion curse or Blessing? ( throw k [ k ′ ]; P 1 ) | ( catch k ( k ′ ) in P 2 ) → P 1 | P 2 • The original system depends crucially on names This is a bound variable. • If α -conversion is built in, this rule collapses to: ( throw k [ k ′ ]; P 1 ) | ( catch k ( k ′′ ) in P 2 ) → P 1 | P 2 [ k ′ /k ′′ ]

  19. The Naïve Representation

  20. The Naïve Representation • It “ looks like ” the original Send Receive system.

  21. The Naïve Representation • It “ looks like ” the original Send Receive system. • You start suspecting is wrong when defining the reduction relation.

  22. The Naïve Representation • It “ looks like ” the original Send Receive system. • You start suspecting is wrong when defining the reduction relation. • You know there is a problem when the proof fails.

  23. We have to discuss Adequacy • I see this problem in one of two ways: • Either, we require proofs of adequacy. • Or we consider the meaning of the mechanisation “first- class”.

  24. We have to discuss Adequacy • I see this problem in one of two ways: • Either, we require proofs of adequacy. • Or we consider the meaning of the mechanisation “first- class”.

  25. We have to discuss Adequacy 18 pages dedicated to the proof for the STLC! • I see this problem in one of two ways: • Either, we require proofs of adequacy. • Or we consider the meaning of the mechanisation “first- class”.

  26. We have to discuss Adequacy • I see this problem in one of two ways: • Either, we require proofs of adequacy. • Or we consider the meaning of the mechanisation “first- class”.

  27. We have to discuss Adequacy • I see this problem in one of two ways: • Either, we require proofs of adequacy. • Or we consider the meaning of the mechanisation “first- class”.

  28. The Revisited system • Now we distinguish between the endpoints of channels. • It can be represented with LN-variables and names.

  29. Four kinds of atoms

  30. Four kinds of atoms

  31. Four kinds of atoms

  32. Four kinds of atoms

  33. Four kinds of atoms

  34. Typing environments • Store their assumptions in a unique order (easy to compare) • Only store unique assumptions (easy to split) • They come with many lemmas (less induction proofs)

  35. Typing environments • Store their assumptions in a unique order (easy to compare) • Only store unique assumptions (easy to split) • They come with many lemmas These are generic enough and easy to (less induction proofs) use. #artefact

  36. Subject Reduction Theorem 3.3 (Subject Reduction) If Θ ; Γ ⊢ P ⊲ ∆ with ∆ balanced and P → ∗ Q , then Θ ; Γ ⊢ Q ⊲ ∆ ′ and ∆ ′ balanced. Is straightforward to represent:

  37. We have a tech report and a repository for the proof. • The code for the proof can be found at: • https://github.com/emtst/ • We have a technical report: • Engineering the Meta-Theory of Session Types • at: https://www.doc.ic.ac.uk/research/technicalreports/2019/ DTRS19-4.pdf

  38. Onwards and Upwards

  39. We are moving to Multiparty Session Types • Lessons learned: • Doing a complete calculus just to have a similar calculus to the literature takes a lot of effort. • Locally nameless worked well. Particularly/Even with the multiple name scopes. • Mechanising proof is great, but if one squints mechanisation is akin to very careful implementation.

  40. MPST • There’s four of us now: David, Francisco, Lorenzo, and Nobuko. • We are mechanising the meta-theory of multiparty session types. • We will build upon our locally nameless and environment implementation. • We plan to extract certified implementations from the proofs.

  41. Certified MPST Multiparty Compatibility in Communicating Automata: Characterisation and Synthesis of Global Session Types Deniélou, Yoshida, 2013

  42. Certified MPST We want Scribble-style protocol specifications Featherweight Scribble, Neykova, Yoshida, 2019

  43. Certified MPST We also want to reason We want Scribble-style about concurrent protocol specifications programs.

Recommend


More recommend