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

mechanising session types onwards and upwards
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Mechanising Session Types Onwards and Upwards

Francisco Ferreira and Lorenzo Gheri (joint work with David Castro, and Nobuko Yoshida)

2019 ABCD Meeting

slide-2
SLIDE 2

The First Step

  • Do a case study:
  • Language Primitives and Type Discipline for Structured

Communication-Based Programming Revisited, by Yoshida and Vasconcelos.

slide-3
SLIDE 3

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

slide-4
SLIDE 4

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

slide-5
SLIDE 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.

slide-6
SLIDE 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).

slide-7
SLIDE 7

What did we mechanise?

slide-8
SLIDE 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

slide-9
SLIDE 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
slide-10
SLIDE 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 revised system inspired by Gay and Hole in Acta

Informatica

  • Its naïve but ultimately unsound extension
slide-11
SLIDE 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 ✄ {l1 : P1[ ] · · · [ ]ln : Pn} 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 | X[˜ e˜ k] process variables e ::= c constant | e + e′ | e − e′ | e × e | not(e) | . . .

  • perators

D ::= X1(˜ x1˜ k1) = P1 and · · · and Xn(˜ xn˜ kn) = Pn declaration for recursion

slide-12
SLIDE 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 ✄ {l1 : P1[ ] · · · [ ]ln : Pn} 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 | X[˜ e˜ k] process variables e ::= c constant | e + e′ | e − e′ | e × e | not(e) | . . .

  • perators

D ::= X1(˜ x1˜ k1) = P1 and · · · and Xn(˜ xn˜ kn) = Pn declaration for recursion

slide-13
SLIDE 13

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 ✄ {l1 : P1[ ] · · · [ ]ln : Pn} 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 | X[˜ e˜ k] process variables e ::= c constant | e + e′ | e − e′ | e × e | not(e) | . . .

  • perators

D ::= X1(˜ x1˜ k1) = P1 and · · · and Xn(˜ xn˜ kn) = Pn declaration for recursion

We consider terms up-to α-conversion

slide-14
SLIDE 14

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 ✄ {l1 : P1[ ] · · · [ ]ln : Pn} 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 | X[˜ e˜ k] process variables e ::= c constant | e + e′ | e − e′ | e × e | not(e) | . . .

  • perators

D ::= X1(˜ x1˜ k1) = P1 and · · · and Xn(˜ xn˜ kn) = Pn declaration for recursion

We consider terms up-to α-conversion Then we cannot distinguish: k?(x) in inact and k?(y) in inact

slide-15
SLIDE 15

α-conversion curse or Blessing?

  • The original system depends crucially on names

(throw k[k′]; P1) | (catch k(k′) in P2) → P1 | P2

slide-16
SLIDE 16

α-conversion curse or Blessing?

  • The original system depends crucially on names

(throw k[k′]; P1) | (catch k(k′) in P2) → P1 | P2

slide-17
SLIDE 17

α-conversion curse or Blessing?

  • The original system depends crucially on names

(throw k[k′]; P1) | (catch k(k′) in P2) → P1 | P2

This is a bound variable.

slide-18
SLIDE 18

α-conversion curse or Blessing?

  • The original system depends crucially on names

(throw k[k′]; P1) | (catch k(k′) in P2) → P1 | P2

This is a bound variable.

  • If α-conversion is built in, this rule collapses to:

(throw k[k′]; P1) | (catch k(k′′) in P2) → P1 | P2[k′/k′′]

slide-19
SLIDE 19

The Naïve Representation

slide-20
SLIDE 20

The Naïve Representation

  • It “looks like” the original Send Receive system.
slide-21
SLIDE 21

The Naïve Representation

  • It “looks like” the original Send Receive system.
  • You start suspecting is wrong when defining the reduction

relation.

slide-22
SLIDE 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.
slide-23
SLIDE 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”.

slide-24
SLIDE 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”.

slide-25
SLIDE 25

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”.

18 pages dedicated to the proof for the STLC!

slide-26
SLIDE 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”.

slide-27
SLIDE 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”.

slide-28
SLIDE 28

The Revisited system

  • Now we distinguish between the endpoints of channels.
  • It can be represented with LN-variables and names.
slide-29
SLIDE 29

Four kinds of atoms

slide-30
SLIDE 30

Four kinds of atoms

slide-31
SLIDE 31

Four kinds of atoms

slide-32
SLIDE 32

Four kinds of atoms

slide-33
SLIDE 33

Four kinds of atoms

slide-34
SLIDE 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)

slide-35
SLIDE 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

(less induction proofs)

These are generic enough and easy to

  • use. #artefact
slide-36
SLIDE 36

Subject Reduction

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

Is straightforward to represent:

slide-37
SLIDE 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

slide-38
SLIDE 38

Onwards and Upwards

slide-39
SLIDE 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.

slide-40
SLIDE 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.
slide-41
SLIDE 41

Certified MPST

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

slide-42
SLIDE 42

Certified MPST

We want Scribble-style protocol specifications Featherweight Scribble, Neykova, Yoshida, 2019

slide-43
SLIDE 43

Certified MPST

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

slide-44
SLIDE 44

Certified MPST

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

slide-45
SLIDE 45

Mechanical Progress

  • We talked about the binary session types meta-theory proof

we formalised.

  • We talked about our current project and our future plans.
slide-46
SLIDE 46

Mechanical Progress

  • We talked about the binary session types meta-theory proof

we formalised.

  • We talked about our current project and our future plans.

Thanks for your kind attention! Questions?