etaps 2019 awardyoshida/slides/shonan2019.pdf• [popl19] alceste scalas , nobuko yoshida: less is...

76

Upload: others

Post on 24-Jan-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 2: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

ETAPS 2019TEST-OF-TIME

AWARD

Language primitives and type discipline for structured communication-based programming’ by Kohei Honda,

Vasco T. Vasconcelos and Makoto Kubo

Page 3: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

POPL 2008 MOST INFLUENTIAL PAPER AWARD

Page 4: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

LICS 2018 TEST OF TIME AWARD

LICS’98

Page 5: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

http://mrg.doc.ic.ac.uk

Mob$%&'y Re,-./c1 G/o3p

Post-docs:Simon CASTELLAN

David CASTRO

Francisco FERREIRA

Raymond HU

Rumyana NEYKOVA

Nicholas NG

Alceste SCALAS

PhD Students:Assel ALTAYEVA

Juliana FRANCO

Eva GRAVERSEN

sqlab
sqlab
sqlab
sqlab
Page 6: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

www.scribble.org

Page 7: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 8: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Selected Publications [2018-2019]• [PLDI19] Alceste Scalas, NY, Elias Benussi: Verifying message-passing programs with dependent behavioural types.

• [CAV19] Julien Lange, NY: Verifying Asynchronous Interactions via Communicating Session Automata.

• [ECOOP19] Rupak Majumdar, Marcus Pirron, NY, and Damien Zufferey, Motion Session Types for Robotic Interactions

• [FoSSaCs19] Simon Castellan, NY: Causality in Linear Logic

• [ESOP19] Laura Bocchi, Maurizio Murgia, Vasco T. Vasconcelos, NY: Asynchronous Timed Session Types

• [POPL19] Simon Castellan, NY: Two Sides of the Same Coin: Session Types and Game Semantics

• [POPL19] David Castro, Raymond Hu, Sung-Shik Jongmans, Nicholas Ng, NY: Distributed Programming Using Role

Parametric Session Types in Go

• [POPL19] Alceste Scalas, Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited

• [POPL19] Bernardo Toninho, NY: Interconnectability of Session Based Logical Processes

• [ICSE18] Julien Lange, Nicholas Ng, Bernardo Toninho, NY: A Static Verification Framework for Message Passing in Go

using Behavioural Types

• [LICS18] Romain Demangeon, NY: Causal Computational Complexity of Distributed Processes

• [FoSSaCs18] Bernardo Toninho, Nobuko Yoshida: Depending On Session Typed Process

• [ESOP18] Malte Viering, Tzu-Chun Chen, Patrick Eugster, Raymond Hu, Lukasz Ziarek: A Typing Discipline for Statically

Verified Crash Failure Handling in Distributed Systems

• [ESOP18] Bernardo Toninho, NY: On Polymorphic Sessions And Functions: A Tale of Two (Fully Abstract) Encodings

• [CC18] Rumyana Neykova, Raymond Hu, NY, Fahd Abdeljallal: A Session Type Provider: Compile-time API Generation for

Distributed Protocols with Interaction Refinements in F#

Page 9: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Selected Publications [2018-2019]• [PLDI19] Alceste Scalas, NY, Elias Benussi: Verifying message-passing programs with dependent behavioural types.

• [CAV19] Julien Lange, NY: Verifying Asynchronous Interactions via Communicating Session Automata.

• [ECOOP19] Rupak Majumdar, Marcus Pirron, NY, and Damien Zufferey, Motion Session Types for Robotic Interactions

• [FoSSaCs19] Simon Castellan, NY: Causality in Linear Logic

• [ESOP19] Laura Bocchi, Maurizio Murgia, Vasco T. Vasconcelos, NY: Asynchronous Timed Session Types

• [POPL19] Simon Castellan, NY: Two Sides of the Same Coin: Session Types and Game Semantics

• [POPL19] David Castro, Raymond Hu, Sung-Shik Jongmans, Nicholas Ng, NY: Distributed Programming Using Role

Parametric Session Types in Go

• [POPL19] Alceste Scalas, Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited

• [POPL19] Bernardo Toninho, NY: Interconnectability of Session Based Logical Processes

• [ICSE18] Julien Lange, Nicholas Ng, Bernardo Toninho, NY: A Static Verification Framework for Message Passing in Go

using Behavioural Types

• [LICS18] Romain Demangeon, NY: Causal Computational Complexity of Distributed Processes

• [FoSSaCs18] Bernardo Toninho, Nobuko Yoshida: Depending On Session Typed Process

• [ESOP18] Malte Viering, Tzu-Chun Chen, Patrick Eugster, Raymond Hu, Lukasz Ziarek: A Typing Discipline for Statically

Verified Crash Failure Handling in Distributed Systems

• [ESOP18] Bernardo Toninho, NY: On Polymorphic Sessions And Functions: A Tale of Two (Fully Abstract) Encodings

• [CC18] Rumyana Neykova, Raymond Hu, NY, Fahd Abdeljallal: A Session Type Provider: Compile-time API Generation for

Distributed Protocols with Interaction Refinements in F#

Page 10: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 11: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 12: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 13: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 14: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 15: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 16: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 17: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 18: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 19: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Static verification framework for Go

Overview

Behavioural

Types

SSA IR

Go source code

Type inference

Model checking

mCRL2 model checker

Check safety and liveness

Termination checking

KITTeL termination prover

Address type $ program gap

Transform

and verify

1

2

3

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 19/46

Page 20: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Concurrency in Go

Goroutines

1 func main() {

2 ch := make(chan string)

3 go send(ch)

4 print(<-ch)

5 close(ch)

6 }

78 func send(ch chan string) {

9 ch <- "Hello Kent!"

10 }

go keyword + function call

Spawns function as goroutine

Runs in parallel to parent

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 20/46

Page 21: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Concurrency in Go

Channels

1 func main() {

2 ch := make(chan string)

3 go send(ch)

4 print(<-ch)

5 close(ch)

6 }

78 func send(ch chan string) {

9 ch <- "Hello Kent!"

10 }

Create new channelSynchronous by default

Receive from channel

Close a channel

No more values sent to it

Can only close once

Send to channel

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 21/46

Page 22: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Concurrency in Go

Channels

1 func main() {

2 ch := make(chan string)

3 go send(ch)

4 print(<-ch)

5 close(ch)

6 }

78 func send(ch chan string) {

9 ch <- "Hello Kent!"

10 }

Also select-case:Wait on multiple channeloperations

switch-case forcommunication

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 21/46

Page 23: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Concurrency in Go

Deadlock detection

1 func main() {

2 ch := make(chan string)

3 go send(ch)

4 print(<-ch)

5 close(ch)

6 }

78 func send(ch chan string) {

9 ch <- "Hello Kent!"

10 }

Send message thru channel

Print message on screen

Output:$ go run hello.go

Hello Kent!

$

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 22/46

Page 24: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Concurrency in Go

Deadlock detection

Missing ’go’ keyword

1 // import _ "net"

2 func main() {

3 ch := make(chan string)

4 send(ch) // Oops

5 print(<-ch)

6 close(ch)

7 }

89 func send(ch chan string) {

10 ch <- "Hello Kent!"

11 }

Only one (main) goroutine

Send without receive - blocks

Output:$ go run deadlock.go

fatal error: all goroutines

are asleep - deadlock!

$

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 23/46

Page 25: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Concurrency in Go

Deadlock detection

Missing ’go’ keyword

1 // import _ "net"

2 func main() {

3 ch := make(chan string)

4 send(ch) // Oops

5 print(<-ch)

6 close(ch)

7 }

89 func send(ch chan string) {

10 ch <- "Hello Kent!"

11 }

Go’s runtime deadlock detector

Checks if all goroutines areblocked (‘global’ deadlock)

Print message then crash

Some packages disable it(e.g. net)

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 23/46

Page 26: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Concurrency in Go

Deadlock detection

Missing ’go’ keyword

1 import _ "net" // unused

2 func main() {

3 ch := make(chan string)

4 send(ch) // Oops

5 print(<-ch)

6 close(ch)

7 }

89 func send(ch chan string) {

10 ch <- "Hello Kent"

11 }

Import unused, unrelated package

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 23/46

Page 27: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Concurrency in Go

Deadlock detection

Missing ’go’ keyword

1 import _ "net" // unused

2 func main() {

3 ch := make(chan string)

4 send(ch) // Oops

5 print(<-ch)

6 close(ch)

7 }

89 func send(ch chan string) {

10 ch <- "Hello Kent"

11 }

Only one (main) goroutine

Send without receive - blocks

Output:$ go run deadlock2.go

Hangs: Deadlock NOT detected

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 23/46

Page 28: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Our goal

Check liveness/safety properties in addition to global deadlocks

Apply process calculi techniques to Go

Use model checking to statically analyse Go programs

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 24/46

Page 29: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Behavioural type inference

Abstract Go communication as Behavioural Types

Behavioural

Types

SSA IR

Go source code

Type inference

Model checking

mCRL2 model checker

Check safety and liveness

Termination checking

KITTeL termination prover

Address type $ program gap

Transform

and verify

1

2

3

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 25/46

Page 30: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Infer Behavioural Types from Go program

Go source code

1 func main() {

2 ch := make(chan int)

3 go send(ch)

4 print(<-ch)

5 close(ch)

6 }

78 func send(c chan int) {

9 c <- 1

10 }

Behavioural Types

Types of CCS-like [Milner ’80]process calculus

Send/Receive

new (channel)

parallel composition (spawn)

Go-specific

Close channel

Select (guarded choice)

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 26/46

Page 31: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Infer Behavioural Types from Go program

Go source code

1 func main() {

2 ch := make(chan int)

3 go send(ch)

4 print(<-ch)

5 close(ch)

6 }

78 func send(c chan int) {

9 c <- 1

10 }

!

Inferred Behavioural Types

8>>>>>><

>>>>>>:

main() = (new ch);(sendhchi |ch;close ch),

send(ch) = ch

9>>>>>>=

>>>>>>;

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 26/46

Page 32: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Infer Behavioural Types from Go program

Go source code

1 func main() {

2 ch := make(chan int)

3 go send(ch)

4 print(<-ch)

5 close(ch)

6 }

78 func send(c chan int) {

9 c <- 1

10 }

Inferred Behavioural Types

8>>>>>><

>>>>>>:

main() = (new ch);(sendhchi |ch;close ch),

send(ch) = ch

9>>>>>>=

>>>>>>;

create channel

spawnreceiveclose

send

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 26/46

Page 33: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Infer Behavioural Types from Go program

1 func main() {

2 ch := make(chan int) // Create channel

3 go sendFn(ch) // Run as goroutine

4 x := recvVal(ch) // Function call

5 for i := 0; i < x; i++ {

6 print(i)

7 }

8 close(ch) // Close channel

9 }

10 func sendFn(c chan int) { c <- 3 } // Send to c

11 func recvVal(c chan int) int { return <-c } // Recv from c

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 27/46

Page 34: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Infer Behavioural Types from Go programpackage main

t0 = make chan int 0:int

go sendFn(t0)

t1 = recvVal(t0)

jump 3

0

t5 = p h i [0: 0:int , 1: t3] #i

t6 = t5 < t1

i f t6 go to 1 e l s e 2

3

t2 = print(t5)

t3 = t5 + 1:int

jump 3

1

t4 = close(t0)

r e t u r n

2

for.loopfor.done

func main.main()entry

return

send c <- 42: int

r e t u r n

0func main.sendFn(c)

entry

return

t0 = <-c

r e t u r n t0

0func main.recvVal(c)

entry

return

Block of instructionsFunction boundary

Package boundary

Analyse in

Static SingleAssignment

SSA representationof input program

Only inspect communication primitivesDistinguish between unique channels

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 28/46

Page 35: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Model checking behavioural types

From behavioural types to

model and property specification

Behavioural

Types

SSA IR

Go source code

Type inference

Model checking

mCRL2 model checker

Check safety and liveness

Termination checking

KITTeL termination prover

Address type $ program gap

Transform

and verify

1

2

3

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 29/46

Page 36: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Model checking behavioural types

M ✏ �

LTS model : inferred type + type semanticsSafety/liveness properties : µ-calculus formulae for LTSCheck with mCRL2 model checker

mCRL2 constraint: Finite control (no spawning in loops)

Global deadlock freedom

Channel safety (no send/close on closed channel)

Liveness (partial deadlock freedom)

Eventual receptionJulien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 30/46

Page 37: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Behavioural Types as LTS model

Standard CS semantics, i.e.

a;Ta�! T

Ta�! T 0 S

a�! S 0

T | S ⌧a�! T 0 | S 0 a;Ta�! T

Send on channel a Synchronise on a Receive on channel a

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 31/46

Page 38: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Behavioural Types as LTS model

Standard CS semantics, i.e.

a;Ta�! T

Ta�! T 0 S

a�! S 0

T | S ⌧a�! T 0 | S 0 a;Ta�! T

Send on channel a Synchronise on a Receive on channel a

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 31/46

Page 39: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Specifying properties of model

Barbs (predicates at each state) describe property at state

Concept from process calculi [Milner ’88, Sangiorgi ’92]

µ-calculus properties specified in terms of barbs

Barbs (T #o)Predicates of state/type T

Holds when T is ready tofire action o

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 32/46

Page 40: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Specifying properties of model

a;T #aT #a T 0 #aT | T 0 #⌧a

a;T #a

Ready to send Ready to synchronise Ready to receive

Barbs (T #o)Predicates of state/type T

Holds when T is ready tofire action o

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 33/46

Page 41: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Specifying properties of model

a;T #aT #a T 0 #aT | T 0 #⌧a

a;T #a

Ready to send Ready to synchronise Ready to receive

Barbs (T #o)Predicates of state/type T

Holds when T is ready tofire action o

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 33/46

Page 42: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 43: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 44: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 45: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 46: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 47: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 48: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 49: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Specifying properties of model

Given

LTS model from inferred behavioural types

Barbs of the LTS model

Express safety/liveness properties

As µ-calculus formulae

In terms of the model and the barbs

Global deadlock freedom

Channel safety (no send/close on closed channel)

Liveness (partial deadlock freedom)

Eventual reception

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 34/46

Page 50: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Property: Global deadlock freedom

(

^

a2A#a _ #a) =) hAitrue

If a channel a is ready to receive or send,

then there must be a next state (i.e. not stuck)

A = set of all initialised channels A = set of all labels

) Ready receive/send = not end of program.

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 35/46

Page 51: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Property: Global deadlock freedom

(

^

a2A#a _ #a) =) hAitrue

1 import _ "net" // unused

2 func main() {

3 ch := make(chan string)

4 send(ch) // Oops

5 print(<-ch)

6 close(ch)

7 }

89 func send(ch chan string) {

10 ch <- "Hello Kent"

11 }

Send (#ch: line 10)

No synchronisation

No more reduction

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 35/46

Page 52: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Property: Channel safety

(

^

a2A#a⇤) =) ¬(#a _ #clo a)

Once a channel a is closed (a⇤),it will not be sent to, nor closed again (clo a)

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 36/46

Page 53: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Property: Channel safety

(

^

a2A#a⇤) =) ¬(#a _ #clo a)

1 func main() {

2 ch := make(chan int)

3 go func(ch chan int) {

4 ch <- 1 // is ch closed?

5 }(ch)

6 close(ch)

7 <-ch

8 }

#clo ch when close(ch)

#ch⇤ fires after closedSend (#

ch: line 4)

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 36/46

Page 54: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Property: Liveness (partial deadlock freedom)

Liveness for Send/Receive

(

^

a2A#a _ #a) =) eventually (h⌧aitrue)

If a channel is ready to receive or send,

then eventually

it can synchronise (⌧a)

(i.e. there’s corresponding send for receiver/recv for sender)

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 37/46

Page 55: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Property: Liveness (partial deadlock freedom)

Liveness for Send/Receive

(

^

a2A#a _ #a) =) eventually (h⌧aitrue)

where:

eventually (�)def= µy. (� _ hAiy)

If a channel is ready to receive or send,

then for some reachable state

it can synchronise (⌧a)Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 37/46

Page 56: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Property: Liveness (partial deadlock freedom)

Liveness for Select

(

^

a2P(A)

#a) =) eventually (h{⌧a | a 2 a}itrue)

If one of the channels in select is ready to receive or send,

Then eventually it will synchronise (⌧a)

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 38/46

Page 57: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Property: Liveness (partial deadlock freedom)

Liveness for Select

(

^

a2P(A)

#a) =) eventually (h{⌧a | a 2 a}itrue)

P1 = select{a, b, ⌧.P} P1 is live if P is XP2 = select{a, b} P2 is not live ⇥R1 = a (P2 | R1) is live X

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 38/46

Page 58: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Property: Liveness (partial deadlock freedom)

Liveness for Select

(

^

a2P(A)

#a) =) eventually (h{⌧a | a 2 a}itrue)

P1 = select{a, b, ⌧.P} P1 is live if P is XP2 = select{a, b} P2 is not live ⇥R1 = a (P2 | R1) is live X

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 38/46

Page 59: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Property: Liveness (partial deadlock freedom)

(^

a2A#a _ #a) =) eventually (h⌧aitrue)

(^

a2P(A)

#a) =) eventually (h{⌧a | a 2 a}itrue)

1 func main() {

2 ch := make(chan int)

3 go looper() // !!!

4 <-ch // No matching send

5 }

6 func looper() {

7 for {

8 }

9 }

⇥ Runtime detector: Hangs

X Our tool: NOT live

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 39/46

Page 60: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Property: Liveness (partial deadlock freedom)

(^

a2A#a _ #a) =) eventually (h⌧aitrue)

(^

a2P(A)

#a) =) eventually (h{⌧a | a 2 a}itrue)

1 func main() {

2 ch := make(chan int)

3 go loopSend(ch)

4 <-ch

5 }

6 func loopSend(ch chan int) {

7 for i := 0; i < 10; i-- {

8 // Does not terminate

9 }

10 ch <- 1

11 }

What about this one?

Type: Live

Program: NOT live

Needs additional guarantees

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 39/46

Page 61: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Property: Eventual reception

(

^

a2A#a•) =) eventually (h⌧aitrue)

If an item is sent to a bu↵ered channel (a•),Then eventually it can be consumed/synchronised (⌧a)

(i.e. no orphan messages)

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 40/46

Page 62: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Termination checking

Addressing the program-type abstraction gap

Behavioural

Types

SSA IR

Go source code

Type inference

Model checking

mCRL2 model checker

Check safety and liveness

Termination checking

KITTeL termination prover

Address type $ program gap

Transform

and verify

1

2

3

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 41/46

Page 63: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Termination checking with KITTeL

Type inference does not consider program data

Type liveness 6= Program liveness if program non-terminating

Especially when involving iteration

) Check for loop termination

If terminates, type liveness = program liveness

Program terminates Program does not terminateType live X Program live ?Type not live ⇥ Program not live ⇥ Program not live

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 42/46

Page 64: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Tool: Godel-Checker

https://github.com/nickng/gospal

https://bitbucket.org/MobilityReadingGroup/godel-checker

GolangUK Conference 2017

Understanding Concurrency with Behavioural Types

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 43/46

Page 65: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Conclusion

Verification framework based onBehavioural Types

Behavioural types for Go concurrency

Infer types from Go source code

Model check types for safety/liveness

+ termination for iterative Go code

Behavioural types

SSA IR

Go source code

Type inference

Transform and verify

Modelchecking

Terminationchecking

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 44/46

Page 66: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

In the paper

See our paper for omitted topics in this talk:Behavioural type inference algorithmTreatment of bu↵ered (asynchronous) channelsThe select (non-deterministic choice) primitiveDefinitions of behavioural type semantics/barbs

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 45/46

Page 67: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Concurrency in Go Behavioural type inference Model checking behavioural types Termination checking Summary

Future and related work

Extend framework to support more safety propertiesDi↵erent verification approaches

Godel-Checker model checking [ICSE’18] (this talk)Gong type verifier [POPL’17]Choreography synthesis [CC’15]

Di↵erent concurrency issues (e.g. data races)

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 46/46

Page 68: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

1/18

Distributed Programming usingRole-Parametric Session Typesin Go

David Castro, Raymond Hu, Sung-Shik Jongmans,Nicholas Ng, Nobuko Yoshida

Page 69: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability
Page 70: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

http://mrg.doc.ic.ac.uk

Scribble-Go framework

User implementation(native Go programming)

Scribble-Go workflow

Role-parametric global protocol

Role-variant specific FSM

Transport-independent Endpoint API

Projection

Endpoint program

Typed API generation

Input protocol

using Scribble +Z3 SMT solver

1. Write a role-parametric global protocol2. Select endpoint role variant to implement (e.g. Fetcher)3. Use Scribble-Go to project and generate Endpoint API4. Implement endpoint (e.g. Fetcher[3]) using the Endpoint API

Page 71: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

http://mrg.doc.ic.ac.uk

Role variantRole variant are unique kinds of endpoints

{ M, F[1..n], Server }

If F[1] sends an extra requestHTTP HEAD to Server to get total sizeThen acts as a normal F

The role variants are:{ M, F[1], F[2..n], Server }

→ F[1] and F[2..n] are different endpointsInference of role variants (indices): formulated as SMT constraints for Z3

M

F

F

F

.

.

.

HTTP Server

n Fetchers

A concurrent file downloader (v2)

HTTP GET

HTTP HEAD

Page 72: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

http://mrg.doc.ic.ac.uk

Endpoint API generation and usageFSMs from local protocols → Message passing API● Fluent-style

● Every state is a unique type (struct)● Method calls (communication) returns next state

● Type information can be leveraged by IDEs● “dot-driven” content assist & auto complete

Page 73: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 1/4

Page 74: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Behavioural Types for Go

Type syntax

↵ := u | u | ⌧T , S := ↵;T | T � S | N{↵i ;Ti}i2I | (T | S) | 0

| (new a)T | close u;T | thui | bucnk | buf [u]closedT := {t(yi) = Ti}i2I in S

Types of a CCS-like process calculusAbstracts Go concurrency primitives

Send/Recv, new (channel), parallel composition (spawn)Go-specific: Close channel, Select (guarded choice)

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 2/4

Page 75: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Semantics of types

snd a;Ta�! T rcv a;T

a�! T tau ⌧ ;T⌧�! T

end close a;Tclo a���! T buf bacnk

clo a���! buf [a]closed cld buf [a]closeda⇤�! buf [a]closed

seli 2 {1, 2}

T1 � T2⌧�! Ti

bra↵j ;Tj

↵j�! Tj j 2 I

N{↵i ;Ti}i2I↵j�! Tj

parT

↵�! T 0

T | S ↵�! T 0 | Sseq

T↵�! T 0

T ; S↵�! T 0; S

term 0; S⌧�! S

com↵ 2 {a, a⇤, a•} T

↵�! T 0 S��! S 0 � 2 {•a, a}

T | S ⌧a�! T 0 | S 0

eqT ⌘↵ T 0 T

↵�! T 00

T 0 ↵�! T 00 defT {a/x} ↵�! T 0

t(x) = T

thai ↵�! T 0

closeT

clo a���! T 0 Sclo a���! S 0

T | S ⌧�! T 0 | S 0 ink < n

bacnk•a�! bacnk+1

outk � 1

bacnka•�! bacnk�1

Figure: Semantics of types.

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 3/4

Page 76: ETAPS 2019 AWARDyoshida/slides/Shonan2019.pdf• [POPL19] Alceste Scalas , Nobuko Yoshida: Less Is More: Multiparty Session Types Revisited • [POPL19] Bernardo Toninho, NY: Interconnectability

Barb predicates for types

a;T #a close a;T #clo aa;T #a buf [a]closed #a⇤

8i 2 {1, . . . , n} : ↵i #oiN{↵i ;T}i2{1,...,n} #{o1...on}

T #oT ;T 0 #o

T #a T 0 #a or T 0 #a⇤T | T 0 #⌧a

T {a/x} #o t(x) = T

thai #oT #a ↵i #a

T | N{↵i ; Si}i2I #⌧a

T #a or T #a⇤ ↵i #aT | N{↵i ; Si}i2I #⌧a

k < n

bacnk #•a

k � 1

bacnk #a•T #a T 0 #•a

T | T 0 #⌧a

T #a• ↵i #aT | N{↵i ; Si}i2I #⌧a

T #oT | T 0 #o

T #o a /2 fn(o)

(newn a);T #oT #o T ⌘ T 0

T #o

Figure: Barb predicates for types.

Julien Lange, Nicholas Ng, Bernardo Toninho, Nobuko YoshidaA Static Verification Framework for Message Passing in Go using Behavioural Types mrg.doc.ic.ac.uk 4/4