Intersections and Unions of Session Types Co sku Acay Frank - - PowerPoint PPT Presentation

intersections and unions of session types
SMART_READER_LITE
LIVE PREVIEW

Intersections and Unions of Session Types Co sku Acay Frank - - PowerPoint PPT Presentation

Intersections and Unions of Session Types Co sku Acay Frank Pfenning Carnegie Mellon University School of Computer Science ITRS 2016 C. Acay & F. Pfenning (CMU) Intersections and Unions of Session Types ITRS 2016 1 / 35 Overview


slide-1
SLIDE 1

Intersections and Unions of Session Types

Co¸ sku Acay Frank Pfenning

Carnegie Mellon University School of Computer Science

ITRS 2016

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 1 / 35

slide-2
SLIDE 2

Overview

1

Background Message-passing Concurrency Session Types Subtyping Configurations and Reduction

2

Intersections and Unions Intersection Types Union Types Reinterpreting Choice

3

Algorithmic System

4

Metatheory

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 2 / 35

slide-3
SLIDE 3

Plan

1

Background Message-passing Concurrency Session Types Subtyping Configurations and Reduction

2

Intersections and Unions Intersection Types Union Types Reinterpreting Choice

3

Algorithmic System

4

Metatheory

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 3 / 35

slide-4
SLIDE 4

Setting

Processes represented as nodes Channels go between processes and represented as edges Each channel is “provided” by a specific process (e.g. P provides c, Q provides d etc.): one-to-one correspondence between channels and processes P Q R S T

c d e f g

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 4 / 35

slide-5
SLIDE 5

Communication

Processes compute internally Exchange messages along channels P Q R

c d e

slide-6
SLIDE 6

Communication

Processes compute internally Exchange messages along channels P Q R

c d e 3

slide-7
SLIDE 7

Communication

Processes compute internally Exchange messages along channels P Q R

c d e 3 "aaa" end

slide-8
SLIDE 8

Communication

Processes compute internally Exchange messages along channels P Q R

c d e 3 "aaa" end

∗Note that communication is synchronous.

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 5 / 35

slide-9
SLIDE 9

Higher-order Messages

Processes can also send channels they own P Q R R

c d e e

slide-10
SLIDE 10

Higher-order Messages

Processes can also send channels they own P Q R R

c d e e e

slide-11
SLIDE 11

Higher-order Messages

Processes can also send channels they own P Q R R

c d e e e

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 6 / 35

slide-12
SLIDE 12

Session Types

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

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 7 / 35

slide-13
SLIDE 13

Session Types

Don’t want to send int if expecting string Don’t try to receive if other process is not sending Solution: Assign types to each channel

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 7 / 35

slide-14
SLIDE 14

Session Types

Don’t want to send int if expecting string Don’t try to receive if other process is not sending Solution: Assign types to each channel (from provider’s perspective).

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 7 / 35

slide-15
SLIDE 15

Session Types

Don’t want to send int if expecting string Don’t try to receive if other process is not sending Solution: Assign types to each channel (from provider’s perspective). P Q R

c : A d : int ⊃ string ∧ B d : string ∧ B d : B e : 1

slide-16
SLIDE 16

Session Types

Don’t want to send int if expecting string Don’t try to receive if other process is not sending Solution: Assign types to each channel (from provider’s perspective). P Q R

c : A d : int ⊃ string ∧ B d : string ∧ B d : B e : 1 3

slide-17
SLIDE 17

Session Types

Don’t want to send int if expecting string Don’t try to receive if other process is not sending Solution: Assign types to each channel (from provider’s perspective). P Q R

c : A d : int ⊃ string ∧ B d : string ∧ B d : B e : 1 3 "aaa"

slide-18
SLIDE 18

Session Types

Don’t want to send int if expecting string Don’t try to receive if other process is not sending Solution: Assign types to each channel (from provider’s perspective). P Q R

c : A d : int ⊃ string ∧ B d : string ∧ B d : B e : 1 3 "aaa" end

slide-19
SLIDE 19

Session Types

Don’t want to send int if expecting string Don’t try to receive if other process is not sending Solution: Assign types to each channel (from provider’s perspective). P Q R

c : A d : int ⊃ string ∧ B d : string ∧ B d : B e : 1 3 "aaa" end

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 7 / 35

slide-20
SLIDE 20

Why linear?

Sessions are resources: communicating along a channel consumes the

  • ld type

Contraction would violate type safety Weakening would work, but we keep things simple

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 8 / 35

slide-21
SLIDE 21

Linear Propositions as Session Types

1 send end and terminate A ⊗ B send channel of type A and continue as B τ ∧ B send value of type τ and continue as B ⊕{labk : Ak}k∈I send labi and continue as Ai for some i ∈ I A ⊸ B receive channel of type A and continue as B τ ⊃ B receive value of type τ and continue as B &{labk : Ak}k∈I receive labi and continue as Ai for some i ∈ I µt.At (equi-)recursive type

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 9 / 35

slide-22
SLIDE 22

Linear Propositions as Session Types

1 send end and terminate A ⊗ B send channel of type A and continue as B τ ∧ B send value of type τ and continue as B ⊕{labk : Ak}k∈I send labi and continue as Ai for some i ∈ I A ⊸ B receive channel of type A and continue as B τ ⊃ B receive value of type τ and continue as B &{labk : Ak}k∈I receive labi and continue as Ai for some i ∈ I µt.At (equi-)recursive type Example: Queue Interface

type queue = &{ enq : A -o queue , deg : +{none : 1, some : A * queue} }

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 9 / 35

slide-23
SLIDE 23

Proof Terms as Concurrent Processes

P, Q, R ::= x ← Px ; Qx cut (spawn) c ← d id (forward) close c | wait c ; P 1 send c (y ← Py) ; Q | x ← recv c ; Rx A ⊗ B, A ⊸ B c.lab ; P | case c of {labk → Qk}k∈I &{labk : Ak}k∈I, ⊕{labk : Ak}k∈I

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 10 / 35

slide-24
SLIDE 24

Example: An Implementation of Queues

type queue = &{ enq : A -o queue , deg : +{none : 1, some : A * queue} } empty : queue q <- empty = case q of 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 of enq -> y <- recv q; r.enq; send r y; q <- elem x r deq -> q.some; send q x; q <- r

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 11 / 35

slide-25
SLIDE 25

Process Typing

Typing judgement has the form Ψ ⊢η P :: (c : A) meaning “process P

  • ffers along channel c the session A under the context Ψ.” η tracks

recursive variables.

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 12 / 35

slide-26
SLIDE 26

Process Typing

Typing judgement has the form Ψ ⊢η P :: (c : A) meaning “process P

  • ffers along channel c the session A under the context Ψ.” η tracks

recursive variables. Some examples: c : A ⊢ d ← c :: (d : A) id Ψ ⊢ Pc :: (c : A) Ψ′, c : A ⊢ Qc :: (d : D) Ψ, Ψ′ ⊢ c ← Pc ; Qc :: (d : D) cut ∅ ⊢ close c :: (c : 1) 1R Ψ ⊢ P :: (d : A) Ψ, c : 1 ⊢ wait c ; P :: (d : A) 1L Ψ ⊢ P :: (d : A) Ψ′ ⊢ Q :: (c : B) Ψ, Ψ′ ⊢ send c (d ← Pd) ; Q :: (c : A ⊗ B) ⊗R

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 12 / 35

slide-27
SLIDE 27

Subtyping

Width and depth subtyping for n-ary choices Width: &{labk : Ak}k∈I ≤ &{labk : Ak}k∈J whenever J ⊆ I Depth: &{labk : Ak}k∈I ≤ &{labk : A′k}k∈I whenever Ai ≤ A′

i

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 13 / 35

slide-28
SLIDE 28

Subtyping

Width and depth subtyping for n-ary choices Width: &{labk : Ak}k∈I ≤ &{labk : Ak}k∈J whenever J ⊆ I Depth: &{labk : Ak}k∈I ≤ &{labk : A′k}k∈I whenever Ai ≤ A′

i

Defined coinductively because of recursive types

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 13 / 35

slide-29
SLIDE 29

Subtyping

Width and depth subtyping for n-ary choices Width: &{labk : Ak}k∈I ≤ &{labk : Ak}k∈J whenever J ⊆ I Depth: &{labk : Ak}k∈I ≤ &{labk : A′k}k∈I whenever Ai ≤ A′

i

Defined coinductively because of recursive types Introduced to process typing using subsumption: Ψ ⊢η P :: (c : A′) A′ ≤ A Ψ ⊢η P :: (c : A) SubR Ψ, c : A′ ⊢η P :: (d : B) A ≤ A′ Ψ, c : A ⊢η P :: (d : B) SubL

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 13 / 35

slide-30
SLIDE 30

Configurations

A processes by itself is not very useful in concurrent setting Need to be able to talk about interactions

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 14 / 35

slide-31
SLIDE 31

Configurations

A processes by itself is not very useful in concurrent setting Need to be able to talk about interactions Use a process configuration, which is simply a set of labelled processes: Ω = procc1(P1), . . . , proccn(Pn).

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 14 / 35

slide-32
SLIDE 32

Configurations

A processes by itself is not very useful in concurrent setting Need to be able to talk about interactions Use a process configuration, which is simply a set of labelled processes: Ω = procc1(P1), . . . , proccn(Pn). Typing judgement, | = Ω :: Ψ, imposes a tree structure (ensures linearity)

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 14 / 35

slide-33
SLIDE 33

Reduction

Configurations reduce by interaction. Some examples: id : procc(c ← d) ⊸ {c = d} cut : procc(x ← Px ; Qx) ⊸ {∃a.proca(Pa) ⊗ procc(Qa)}

  • ne

: procc(close c) ⊗ procd(wait c ; P) ⊸ {procd(P)}

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 15 / 35

slide-34
SLIDE 34

Plan

1

Background Message-passing Concurrency Session Types Subtyping Configurations and Reduction

2

Intersections and Unions Intersection Types Union Types Reinterpreting Choice

3

Algorithmic System

4

Metatheory

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 16 / 35

slide-35
SLIDE 35

Intersections and Unions

What if we want to track more properties of queues?

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 17 / 35

slide-36
SLIDE 36

Intersections and Unions

What if we want to track more properties of queues? Empty, non-empty, even length?

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 17 / 35

slide-37
SLIDE 37

Intersections and Unions

What if we want to track more properties of queues? Empty, non-empty, even length? These can be defined in the base system:

type empty -queue = &{ enq : A -o queue , deg : +{none : 1} } type nonempty -queue = &{ enq : A -o queue , deg : +{some : A * queue} }

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 17 / 35

slide-38
SLIDE 38

Intersections and Unions

What if we want to track more properties of queues? Empty, non-empty, even length? These can be defined in the base system:

type empty -queue = &{ enq : A -o queue , deg : +{none : 1} } type nonempty -queue = &{ enq : A -o queue , deg : +{some : A * queue} }

However, there is no way to properly track them!

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 17 / 35

slide-39
SLIDE 39

We cannot track multiple refinements.

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 18 / 35

slide-40
SLIDE 40

We cannot track multiple refinements. Consider

concat : queue -o queue -o queue that concatenates two queues. It has

many types but no most general type:

concat : empty -queue

  • o empty -queue
  • o empty -queue

concat : queue

  • o nonempty -queue
  • o nonempty -queue

concat : nonempty -queue

  • o queue
  • o nonempty -queue
  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 18 / 35

slide-41
SLIDE 41

Intersection Types

Intersection of two types: A ⊓ B c : A ⊓ B if channel c offers both behaviors simultaneously

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 19 / 35

slide-42
SLIDE 42

Intersection Types

Intersection of two types: A ⊓ B c : A ⊓ B if channel c offers both behaviors simultaneously Ψ ⊢η P :: (c : A) Ψ ⊢η P :: (c : B) Ψ ⊢η P :: (c : A ⊓ B) ⊓R Ψ, c : A ⊢η P :: (d : D) Ψ, c : A ⊓ B ⊢η P :: (d : D) ⊓L1 Ψ, c : B ⊢η P :: (d : D) Ψ, c : A ⊓ B ⊢η P :: (d : D) ⊓L2

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 19 / 35

slide-43
SLIDE 43

Intersections Solve the Previous Problem

We can now specify multiple behavioral properties:

concat : empty -queue

  • o empty -queue
  • o empty -queue

and queue

  • o nonempty -queue
  • o nonempty -queue

and nonempty -queue

  • o queue
  • o nonempty -queue
  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 20 / 35

slide-44
SLIDE 44

Union Types

Union of two types: A ⊔ B c : A ⊔ B if channel c offers either behavior

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 21 / 35

slide-45
SLIDE 45

Union Types

Union of two types: A ⊔ B c : A ⊔ B if channel c offers either behavior Dual to intersections

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 21 / 35

slide-46
SLIDE 46

Union Types

Union of two types: A ⊔ B c : A ⊔ B if channel c offers either behavior Dual to intersections Ψ ⊢η P :: (c : A) Ψ ⊢η P :: (c : A ⊔ B) ⊔R1 Ψ ⊢η P :: (c : B) Ψ ⊢η P :: (c : A ⊔ B) ⊔R2 Ψ, c : A ⊢η P :: (d : D) Ψ, c : B ⊢η P :: (d : D) Ψ, c : A ⊔ B ⊢η P :: (d : D) ⊔L

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 21 / 35

slide-47
SLIDE 47

Reasons for Adding Unions

Maintain the symmetry of the system Makes working with internal choice more convenient Interpretation of internal choice (we will explain later)

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 22 / 35

slide-48
SLIDE 48

Reasons for Adding Unions

Maintain the symmetry of the system Makes working with internal choice more convenient Interpretation of internal choice (we will explain later) We can also write things like:

type queue = empty -queue or nonempty -queue

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 22 / 35

slide-49
SLIDE 49

Reinterpreting Choice

Consider &{inl : A, inr : B}

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 23 / 35

slide-50
SLIDE 50

Reinterpreting Choice

Consider &{inl : A, inr : B} This type says: “I will act as A if you send me inl and I will act as B if you send me inr.”

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 23 / 35

slide-51
SLIDE 51

Reinterpreting Choice

Consider &{inl : A, inr : B} This type says: “I will act as A if you send me inl and I will act as B if you send me inr.” Interpreting and as ⊓ gives &{inl : A, inr : B} ≈ &{inl : A} ⊓ &{inr : B}.

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 23 / 35

slide-52
SLIDE 52

Reinterpreting Choice - General Case

Generalizing to n-ary choice and dualising gives: &{labk : Ak}k∈I

  • k∈I

&{labk : Ak} ⊕ {labk : Ak}k∈I

  • k∈I

⊕{labk : Ak} Easy to verify these definitions satisfy the typing rules.

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 24 / 35

slide-53
SLIDE 53

Reinterpreting Choice - General Case

Generalizing to n-ary choice and dualising gives: &{labk : Ak}k∈I

  • k∈I

&{labk : Ak} ⊕ {labk : Ak}k∈I

  • k∈I

⊕{labk : Ak} Easy to verify these definitions satisfy the typing rules. Suggests treating intersections and unions as implicit choice.

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 24 / 35

slide-54
SLIDE 54

Plan

1

Background Message-passing Concurrency Session Types Subtyping Configurations and Reduction

2

Intersections and Unions Intersection Types Union Types Reinterpreting Choice

3

Algorithmic System

4

Metatheory

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 25 / 35

slide-55
SLIDE 55

Algorithmic Subtyping

Idea: make ≤ ⊓L{1,2} and ≤ ⊔R{1,2} invertible so we can apply eagerly. A{1,2} ≤ B A1 ⊓ A2 ≤ B ≤ ⊓L{1,2} − → α, A1, A2 ⇒ β α, A1 ⊓ A2 ⇒ β ⇒ ⊓L A ≤ B{1,2} A ≤ B1 ⊔ B2 ≤ ⊔R{1,2} − → α ⇒ β, A1, A2 α ⇒ β, A1 ⊔ A2 ⇒ ⊔R

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 26 / 35

slide-56
SLIDE 56

Algorithmic Subtyping

Idea: make ≤ ⊓L{1,2} and ≤ ⊔R{1,2} invertible so we can apply eagerly. A{1,2} ≤ B A1 ⊓ A2 ≤ B ≤ ⊓L{1,2} − → α, A1, A2 ⇒ β α, A1 ⊓ A2 ⇒ β ⇒ ⊓L A ≤ B{1,2} A ≤ B1 ⊔ B2 ≤ ⊔R{1,2} − → α ⇒ β, A1, A2 α ⇒ β, A1 ⊔ A2 ⇒ ⊔R Also admits distributivity: (A1 ⊔ B) ⊓ (A2 ⊔ B) ≡ (A1 ⊓ A2) ⊔ B (A1 ⊔ A2) ⊓ B ≡ (A1 ⊓ B) ⊔ (A2 ⊓ B) Turns out to be necessary for soundness of algorithmic typing.

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 26 / 35

slide-57
SLIDE 57

Algorithmic Type Checking

Make ⊓L{1,2} and ⊔R{1,2} invertible so we can apply eagerly.

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 27 / 35

slide-58
SLIDE 58

Algorithmic Type Checking

Make ⊓L{1,2} and ⊔R{1,2} invertible so we can apply eagerly. Delay subtyping to id Label cut with it’s type

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 27 / 35

slide-59
SLIDE 59

Algorithmic Type Checking

Make ⊓L{1,2} and ⊔R{1,2} invertible so we can apply eagerly. Delay subtyping to id Label cut with it’s type

Ψ, c : A1,2 ⊢η P :: (d : D) Ψ, c : A1 ⊓ A2 ⊢η P :: (d : D) ⊓L1,2

→ Ψ, c : (α, A, B) η P :: (d : β) Ψ, c : (α, A ⊓ B) η P :: (d : β) ⊓L Ψ ⊢η P :: (c : A1,2) Ψ ⊢η P :: (c : A1 ⊔ A2) ⊔R1,2 → Ψ η P :: (c : A, B, α) Ψ η P :: (c : A ⊔ B, α) ⊔R

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 27 / 35

slide-60
SLIDE 60

Algorithmic Type Checking

Make ⊓L{1,2} and ⊔R{1,2} invertible so we can apply eagerly. Delay subtyping to id Label cut with it’s type

Ψ, c : A1,2 ⊢η P :: (d : D) Ψ, c : A1 ⊓ A2 ⊢η P :: (d : D) ⊓L1,2

→ Ψ, c : (α, A, B) η P :: (d : β) Ψ, c : (α, A ⊓ B) η P :: (d : β) ⊓L Ψ ⊢η P :: (c : A1,2) Ψ ⊢η P :: (c : A1 ⊔ A2) ⊔R1,2 → Ψ η P :: (c : A, B, α) Ψ η P :: (c : A ⊔ B, α) ⊔R α ⇒ β c : α η d ← c :: (d : β) id Ψ η Pc :: (c : A) Ψ′, c : A η Qc :: (d : α) Ψ, Ψ′ η c : A ← Pc ; Qc :: (d : α) cut

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 27 / 35

slide-61
SLIDE 61

Results

Theorem (Completeness of Algorithmic Subtyping)

Algorithmic subtyping is complete with respect to declarative subtyping.

Theorem (Equivalence of Algorithmic Typing)

Algorithmic typing is sound and complete with respect to declarative typing.

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 28 / 35

slide-62
SLIDE 62

Plan

1

Background Message-passing Concurrency Session Types Subtyping Configurations and Reduction

2

Intersections and Unions Intersection Types Union Types Reinterpreting Choice

3

Algorithmic System

4

Metatheory

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 29 / 35

slide-63
SLIDE 63

Type Safety

We have proved progress and preservation for the system extended with intersections and unions.

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 30 / 35

slide-64
SLIDE 64

Type Safety

We have proved progress and preservation for the system extended with intersections and unions. Progress → deadlock-freedom Type preservation → session fidelity

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 30 / 35

slide-65
SLIDE 65

Progress

Theorem (Progress)

If | = Ω :: Ψ then either

1 Ω −

→ Ω′ for some Ω′, or

2 Ω is poised∗.

Proof.

By induction on | = Ω :: Ψ followed by a nested induction on the typing of the root process. When two processes are involved, we also need inversion

  • n client’s typing.

∗A process is poised if it is waiting to communicate with its client.

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 31 / 35

slide-66
SLIDE 66

Type Preservation

Theorem (Preservation)

If | = Ω :: Ψ and Ω − → Ω′ then | = Ω′ :: Ψ.

Proof.

By inversion on Ω − → Ω′, followed by induction on the typing judgments

  • f the involved processes. Each branch requires a hand-rolled induction

hypothesis.

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 32 / 35

slide-67
SLIDE 67

Conclusion and Highlights

We introduced intersection and union types to a session-typed process calculus and demonstrated their usefulness. Unions work naturally. The elimination rule we give has been shown unsound in the presence of effects (even non-termination).

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 33 / 35

slide-68
SLIDE 68

Conclusion and Highlights

We introduced intersection and union types to a session-typed process calculus and demonstrated their usefulness. Unions work naturally. The elimination rule we give has been shown unsound in the presence of effects (even non-termination). More general than refinement system of Freeman and Pfenning

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 33 / 35

slide-69
SLIDE 69

Conclusion and Highlights

We introduced intersection and union types to a session-typed process calculus and demonstrated their usefulness. Unions work naturally. The elimination rule we give has been shown unsound in the presence of effects (even non-termination). More general than refinement system of Freeman and Pfenning Subtyping resembles Gentzen’s multiple conclusion calculus

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 33 / 35

slide-70
SLIDE 70

Conclusion and Highlights

We introduced intersection and union types to a session-typed process calculus and demonstrated their usefulness. Unions work naturally. The elimination rule we give has been shown unsound in the presence of effects (even non-termination). More general than refinement system of Freeman and Pfenning Subtyping resembles Gentzen’s multiple conclusion calculus Algorithmic typing mirrors subtyping

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 33 / 35

slide-71
SLIDE 71

Future Work

Simple: integrate a functional language, extend to shared channels and asynchronous communication

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 34 / 35

slide-72
SLIDE 72

Future Work

Simple: integrate a functional language, extend to shared channels and asynchronous communication More interesting: Add polymorphism and abstract types

Polymorphism is non-trivial with equirecursive types

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 34 / 35

slide-73
SLIDE 73

Future Work

Simple: integrate a functional language, extend to shared channels and asynchronous communication More interesting: Add polymorphism and abstract types

Polymorphism is non-trivial with equirecursive types

Applications other than refinements?

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 34 / 35

slide-74
SLIDE 74

The End

  • C. Acay & F. Pfenning (CMU)

Intersections and Unions of Session Types ITRS 2016 35 / 35