Refinements for Session-typed Concurrency Josh Acay & Frank - - PowerPoint PPT Presentation

refinements for session typed concurrency
SMART_READER_LITE
LIVE PREVIEW

Refinements for Session-typed Concurrency Josh Acay & Frank - - PowerPoint PPT Presentation

Refinements for Session-typed Concurrency Josh Acay & Frank Pfenning May 4, 2016 1 Message-passing Concurrency Processes represented as nodes Channels between processes as edges Each channel is provided by a specific


slide-1
SLIDE 1

Refinements for Session-typed Concurrency

Josh Acay & Frank Pfenning

1 May 4, 2016

slide-2
SLIDE 2

Message-passing Concurrency

  • Processes represented as nodes
  • Channels between processes as edges
  • Each channel is “provided” by a specific

process (P provides c, Q provides d etc.)

P c Q d R e

2 May 4, 2016

slide-3
SLIDE 3

Message-passing Concurrency

  • Processes compute internally
  • Exchange messages along channels

P c Q d R e

3 May 4, 2016

slide-4
SLIDE 4

Message-passing Concurrency

  • Processes compute internally
  • Exchange messages along channels

P c Q d R e 3

3 May 4, 2016

slide-5
SLIDE 5

Message-passing Concurrency

  • Processes compute internally
  • Exchange messages along channels

P c Q d R e 3 “aaa”

3 May 4, 2016

slide-6
SLIDE 6

Message-passing Concurrency

  • Processes compute internally
  • Exchange messages along channels

P c Q d R e 3 “aaa” end

3 May 4, 2016

slide-7
SLIDE 7

Message-passing Concurrency

  • Processes compute internally
  • Exchange messages along channels

P c Q d 3 “aaa”

3 May 4, 2016

slide-8
SLIDE 8

Message-passing Concurrency

  • Processes can also send channels they own

P c Q d R e

4 May 4, 2016

slide-9
SLIDE 9

Message-passing Concurrency

  • Processes can also send channels they own

P c Q d R e e

4 May 4, 2016

slide-10
SLIDE 10

Message-passing Concurrency

  • Processes can also send channels they own

P c Q d e R e

4 May 4, 2016

slide-11
SLIDE 11

Linear Session-types

  • Don’t want to send int if expecting string
  • Don’t try to receive if other process is not

sending

  • Assign types to each channel from provider’s

perspective

P c : B Q

d : int ⊃ string ∧ A

R e : 1

5 May 4, 2016

slide-12
SLIDE 12

Linear Session-types

  • Don’t want to send int if expecting string
  • Don’t try to receive if other process is not

sending

  • Assign types to each channel from provider’s

perspective

P c : B Q 3 R e : 1

d : string ∧ A 5 May 4, 2016

slide-13
SLIDE 13

Linear Session-types

  • Don’t want to send int if expecting string
  • Don’t try to receive if other process is not

sending

  • Assign types to each channel from provider’s

perspective

P c : B Q 3 “aaa” R e : 1

d : A 5 May 4, 2016

slide-14
SLIDE 14

Linear Session-types

  • Don’t want to send int if expecting string
  • Don’t try to receive if other process is not

sending

  • Assign types to each channel from provider’s

perspective

P c : B Q 3 “aaa” end R e : 1

d : A 5 May 4, 2016

slide-15
SLIDE 15

Linear Session-types

  • Don’t want to send int if expecting string
  • Don’t try to receive if other process is not

sending

  • Assign types to each channel from provider’s

perspective

P c : B Q 3 “aaa”

d : A 5 May 4, 2016

slide-16
SLIDE 16

Linear Session Types

  • Example interface specification:

1 Terminate &{labi:Ai}i External choice (receive) between labi, continue as Ai A –o B Receive channel of type A, continue as B τ ⊃ B Receive value of type τ, continue as B

⊕{labi:Ai}i Internal choice (send) between labi, continue as Ai

A ⊗ B Send channel of type A, continue as B τ ∧ B Send value of type τ, continue as B

queue = &{enq: A –o queue, deq: ⊕{none: 1, some: A ⊗ queue}}

* where A is some predetermined type

6 May 4, 2016

slide-17
SLIDE 17

Implementation of Queues

queue = &{enq: A –o queue, deq: ⊕{none: 1, some: A ⊗ queue}} empty : queue q ← empty = case q enq x ← recv q ; e ← empty ; q ← elem x e deq q.none ; close q elem : A –o queue –o queue q ← elem x r = case q enq y ← recv q ; r.enq ; send r y ; q ← elem x r deq q.some ; send q x ; q ← r

7 May 4, 2016

slide-18
SLIDE 18

Intersections and Unions

  • Allows describing more interesting behavior
  • Intersection of two types: A ⊓ B

– c : A ⊓ B if channel c offers both behaviors

  • Union of two types: A ⊔ B

– c : A ⊔ B if channel c offers either behavior

8 May 4, 2016

slide-19
SLIDE 19

Refinement Types

  • What if we want to track more properties of

queues? Empty, non-empty, even length?

  • We can define them in the base system:

empty-queue = &{enq: A –o nonempty-queue, deq: ⊕{none: 1}} nonempty-queue = &{enq: A –o nonempty-queue, deq: ⊕{some: A ⊗ queue}}

9 May 4, 2016

slide-20
SLIDE 20

Refinement Types

  • But we need intersections and unions to write

interesting programs

queue A = empty-queue ⊔ nonempty-queue empty : empty-queue elem : (A –o queue –o nonempty-queue) concat : (empty-queue –o empty-queue –o empty-queue) ⊓ (queue –o nonempty-queue –o nonempty-queue) ⊓ (nonempty-queue –o queue –o nonempty-queue)

10 May 4, 2016

slide-21
SLIDE 21

Decidability of Type-checking

  • Algorithmic system that is easy to translate to

code

  • Prove sound and complete with respect to the
  • riginal system
  • Partial implementation in Haskell

11 May 4, 2016

slide-22
SLIDE 22

Type Safety

  • Progress

– Deadlock freedom in concurrent setting – At least one process can make progress if the configuration is well-typed

  • Preservation [currently in progress]

– Session fidelity in concurrent setting – Processes obey session-types

12 May 4, 2016