Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf ·...

139
Session Types and Linear Logic and Lightweight Applications of Session Types in Java Bernardo Toninho and Raymond Hu University College London, March 7, 2017 Bernardo Toninho mrg.doc.ic.ac.uk # 1/36

Transcript of Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf ·...

Page 1: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Session Types and Linear Logicand

Lightweight Applications of Session Types in Java

Bernardo Toninho and Raymond Hu

University College London,March 7, 2017

Bernardo Toninho mrg.doc.ic.ac.uk # 1/36

Page 2: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

IntroductionConcurrent Processes

I Coordination of multiple simultaneously executing agents.I Programming Models: Shared-Memory vs Message-PassingI Hard to reason about:

I DeadlocksI Data racesI Concurrent interleavings make behaviour hard to predictI . . . and also hard to replicate (e.g. testing).

Bernardo Toninho mrg.doc.ic.ac.uk 2/36

Page 3: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

IntroductionA Concurrency-Theoretic Approach: Session Types

Structuring CommunicationI Communication without structure is hard to reason about.I Structure communication around the concept of a session.I Predetermined sequences of interactions along a (session) channel:

I “Input a number, output a string and terminate.”I “Either output or input a number.”

Session-based StructuringI Specify communication behaviour as sessions.I Check that programs adhere to specification (session fidelity).

Bernardo Toninho mrg.doc.ic.ac.uk 3/36

Page 4: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

IntroductionA Concurrency-Theoretic Approach: Session Types

Structuring CommunicationI Communication without structure is hard to reason about.I Structure communication around the concept of a session.I Predetermined sequences of interactions along a (session) channel:

I “Input a number, output a string and terminate.”I “Either output or input a number.”

Session-based StructuringI Specify communication behaviour as sessions.I Check that programs adhere to specification (session fidelity).

Bernardo Toninho mrg.doc.ic.ac.uk 3/36

Page 5: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

IntroductionA Concurrency-Theoretic Approach: Session Types

Session Types [Honda93]I Types are descriptions of communication behaviour, assigned to channels.I A way of guaranteeing communication discipline, statically.I A linear typing discipline for π-calculus processes.I Intrinsic notion of duality: Send/Receive, Offer choice/Select

Syntax

P,Q ::= x〈y〉.P | x(y).P | x .`; P | x .case{`i : Pi}i∈I | (νx)P | 0 | (P | Q)

S,T ::= !S.T | ?S.T | ⊕ {`i : Ti}i∈I | N {`i : Ti}i∈I

A pair of processes interacting on dual sessions is deadlock-free!

Bernardo Toninho mrg.doc.ic.ac.uk 4/36

Page 6: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

IntroductionA Concurrency-Theoretic Approach: Session Types

Session Types [Honda93]I Types are descriptions of communication behaviour, assigned to channels.I A way of guaranteeing communication discipline, statically.I A linear typing discipline for π-calculus processes.I Intrinsic notion of duality: Send/Receive, Offer choice/Select

Syntax

P,Q ::= x〈y〉.P | x(y).P | x .`; P | x .case{`i : Pi}i∈I | (νx)P | 0 | (P | Q)

S,T ::= !S.T | ?S.T | ⊕ {`i : Ti}i∈I | N {`i : Ti}i∈I

A pair of processes interacting on dual sessions is deadlock-free!

Bernardo Toninho mrg.doc.ic.ac.uk 4/36

Page 7: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

IntroductionA Concurrency-Theoretic Approach: Session Types

Session Types [Honda93]I Types are descriptions of communication behaviour, assigned to channels.I A way of guaranteeing communication discipline, statically.I A linear typing discipline for π-calculus processes.I Intrinsic notion of duality: Send/Receive, Offer choice/Select

Syntax

P,Q ::= x〈y〉.P | x(y).P | x .`; P | x .case{`i : Pi}i∈I | (νx)P | 0 | (P | Q)

S,T ::= !S.T | ?S.T | ⊕ {`i : Ti}i∈I | N {`i : Ti}i∈I

A pair of processes interacting on dual sessions is deadlock-free!

Bernardo Toninho mrg.doc.ic.ac.uk 4/36

Page 8: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

IntroductionA Concurrency-Theoretic Approach: Session Types

Session Types [Honda93]I Types are descriptions of communication behaviour, assigned to channels.I A way of guaranteeing communication discipline, statically.I A linear typing discipline for π-calculus processes.I Intrinsic notion of duality: Send/Receive, Offer choice/Select

Syntax

P,Q ::= x〈y〉.P | x(y).P | x .`; P | x .case{`i : Pi}i∈I | (νx)P | 0 | (P | Q)

S,T ::= !S.T | ?S.T | ⊕ {`i : Ti}i∈I | N {`i : Ti}i∈I

A pair of processes interacting on dual sessions is deadlock-free!

Bernardo Toninho mrg.doc.ic.ac.uk 4/36

Page 9: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

IntroductionA Concurrency-Theoretic Approach: Session Types

Session Types [Honda93]I Types are descriptions of communication behaviour, assigned to channels.I A way of guaranteeing communication discipline, statically.I A linear typing discipline for π-calculus processes.I Intrinsic notion of duality: Send/Receive, Offer choice/Select

Syntax

P,Q ::= x〈y〉.P | x(y).P | x .`; P | x .case{`i : Pi}i∈I | (νx)P | 0 | (P | Q)

S,T ::= !S.T | ?S.T | ⊕ {`i : Ti}i∈I | N {`i : Ti}i∈I

A pair of processes interacting on dual sessions is deadlock-free!

Bernardo Toninho mrg.doc.ic.ac.uk 4/36

Page 10: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

IntroductionA Concurrency-Theoretic Approach: Session Types

Session Types [Honda93]I Types are descriptions of communication behaviour, assigned to channels.I A way of guaranteeing communication discipline, statically.I A linear typing discipline for π-calculus processes.I Intrinsic notion of duality: Send/Receive, Offer choice/Select

Syntax

P,Q ::= x〈y〉.P | x(y).P | x .`; P | x .case{`i : Pi}i∈I | (νx)P | 0 | (P | Q)

S,T ::= !S.T | ?S.T | ⊕ {`i : Ti}i∈I | N {`i : Ti}i∈I

A pair of processes interacting on dual sessions is deadlock-free!

Bernardo Toninho mrg.doc.ic.ac.uk 4/36

Page 11: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

IntroductionSession Types and Linear Logic

Linear Logic [Girard87]I A marriage of classical dualities and constructivism.I A logic of resources and interaction.I Resource independence captures non-determinism/concurrency.I Connected to concurrency early on [Abramsky93,BellinScott94]

Session Types and ILL [CairesPfenning01]I Its possible to interpret session types as linear logic propositions.I Linear logic proofs as process typing derivations.I Proof dynamics as process dynamics.

Bernardo Toninho mrg.doc.ic.ac.uk 5/36

Page 12: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

IntroductionSession Types and Linear Logic

Linear Logic [Girard87]I A marriage of classical dualities and constructivism.I A logic of resources and interaction.I Resource independence captures non-determinism/concurrency.I Connected to concurrency early on [Abramsky93,BellinScott94]

Session Types and ILL [CairesPfenning01]I Its possible to interpret session types as linear logic propositions.I Linear logic proofs as process typing derivations.I Proof dynamics as process dynamics.

Bernardo Toninho mrg.doc.ic.ac.uk 5/36

Page 13: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

IntroductionSession Types and Linear Logic

Why does it matter?I Good metalogical properties map to good program properties.I Progress, session fidelity, type preservation “for free”.I Reasoning built-in.I Much more compositional than traditional approaches (i.e. extensibility).

Bernardo Toninho mrg.doc.ic.ac.uk 6/36

Page 14: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

IntroductionRoadmap

1. Basic interpretation2. Enriching the type structure (dependent types and polymorphism)3. Reasoning Techniques: Logical equivalence, type isomorphisms and proof

conversions.4. Multiparty session types.

Bernardo Toninho mrg.doc.ic.ac.uk 7/36

Page 15: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL Interpretation

Key IdeasI Session Types as Intuitionistic Linear Propositions.I Sequent calculus rules as π-calculus typing rules.I Cut reduction as process reduction.

Propositions

A,B ::= A⊗ B | A( B | 1 | A N B | A⊕ B | !A

SequentsI Duality of offering (right rules) and using (left rules) a session.I Proof composition (cut) as process composition.I Identity as forwarding/renaming.

Bernardo Toninho mrg.doc.ic.ac.uk 8/36

Page 16: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL Interpretation

Key IdeasI Session Types as Intuitionistic Linear Propositions.I Sequent calculus rules as π-calculus typing rules.I Cut reduction as process reduction.

Propositions

A,B ::= A⊗ B | A( B | 1 | A N B | A⊕ B | !A

SequentsI Duality of offering (right rules) and using (left rules) a session.I Proof composition (cut) as process composition.I Identity as forwarding/renaming.

Bernardo Toninho mrg.doc.ic.ac.uk 8/36

Page 17: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL Interpretation

Key IdeasI Session Types as Intuitionistic Linear Propositions.I Sequent calculus rules as π-calculus typing rules.I Cut reduction as process reduction.

Propositions

A,B ::= A⊗ B | A( B | 1 | A N B | A⊕ B | !A

SequentsI Duality of offering (right rules) and using (left rules) a session.I Proof composition (cut) as process composition.I Identity as forwarding/renaming.

Bernardo Toninho mrg.doc.ic.ac.uk 8/36

Page 18: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationJudgmental Principles

Typing Judgment

Γ︷ ︸︸ ︷

u1:

A1, . . . ,

um:

Am;

∆︷ ︸︸ ︷

x1:

A1, . . . ,

xn:

An =⇒

P :: x :

A

Process P provides A along x if composed with sessions in ∆ and Γ.

Identity as Renaming

Γ;

x :

A =⇒ A

Bernardo Toninho mrg.doc.ic.ac.uk 9/36

Page 19: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationJudgmental Principles

Typing Judgment

Γ︷ ︸︸ ︷u1:A1, . . . ,um:Am;

∆︷ ︸︸ ︷x1:A1, . . . , xn:An =⇒ P :: x :A

Process P provides A along x if composed with sessions in ∆ and Γ.

Identity as Renaming

Γ;

x :

A =⇒

[x ↔ z] :: z:

A

Bernardo Toninho mrg.doc.ic.ac.uk 9/36

Page 20: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationJudgmental Principles

Typing Judgment

Γ︷ ︸︸ ︷u1:A1, . . . ,um:Am;

∆︷ ︸︸ ︷x1:A1, . . . , xn:An =⇒ P :: x :A

Process P provides A along x if composed with sessions in ∆ and Γ.

Cut as CompositionΓ; ∆ =⇒

P :: x :

A Γ; ∆′,

x :

A =⇒

Q :: z:

C

Γ; ∆,∆′ =⇒

(νx)(P | Q) :: z:

Ccut

Parallel composition of P, offering x :A and Q, using x :A.

Identity as Renaming

Γ;

x :

A =⇒ A

Bernardo Toninho mrg.doc.ic.ac.uk 9/36

Page 21: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationJudgmental Principles

Typing Judgment

Γ︷ ︸︸ ︷u1:A1, . . . ,um:Am;

∆︷ ︸︸ ︷x1:A1, . . . , xn:An =⇒ P :: x :A

Process P provides A along x if composed with sessions in ∆ and Γ.

Cut as CompositionΓ; ∆ =⇒ P :: x :A Γ; ∆′,

x :

A =⇒

Q :: z:

C

Γ; ∆,∆′ =⇒

(νx)(P | Q) :: z:

Ccut

Parallel composition of P, offering x :A and Q, using x :A.

Identity as Renaming

Γ;

x :

A =⇒

[x ↔ z] :: z:

A

Bernardo Toninho mrg.doc.ic.ac.uk 9/36

Page 22: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationJudgmental Principles

Typing Judgment

Γ︷ ︸︸ ︷u1:A1, . . . ,um:Am;

∆︷ ︸︸ ︷x1:A1, . . . , xn:An =⇒ P :: x :A

Process P provides A along x if composed with sessions in ∆ and Γ.

Cut as CompositionΓ; ∆ =⇒ P :: x :A Γ; ∆′, x :A =⇒ Q :: z:C

Γ; ∆,∆′ =⇒

(νx)(P | Q) :: z:

Ccut

Parallel composition of P, offering x :A and Q, using x :A.

Identity as Renaming

Γ;

x :

A =⇒

[x ↔ z] :: z:

A

Bernardo Toninho mrg.doc.ic.ac.uk 9/36

Page 23: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationJudgmental Principles

Typing Judgment

Γ︷ ︸︸ ︷u1:A1, . . . ,um:Am;

∆︷ ︸︸ ︷x1:A1, . . . , xn:An =⇒ P :: x :A

Process P provides A along x if composed with sessions in ∆ and Γ.

Cut as CompositionΓ; ∆ =⇒ P :: x :A Γ; ∆′, x :A =⇒ Q :: z:C

Γ; ∆,∆′ =⇒ (νx)(P | Q) :: z:Ccut

Parallel composition of P, offering x :A and Q, using x :A.

Identity as Renaming

Γ;

x :

A =⇒

[x ↔ z] :: z:

A

Bernardo Toninho mrg.doc.ic.ac.uk 9/36

Page 24: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationJudgmental Principles

Typing Judgment

Γ︷ ︸︸ ︷u1:A1, . . . ,um:Am;

∆︷ ︸︸ ︷x1:A1, . . . , xn:An =⇒ P :: x :A

Process P provides A along x if composed with sessions in ∆ and Γ.

Cut as CompositionΓ; ∆ =⇒ P :: x :A Γ; ∆′, x :A =⇒ Q :: z:C

Γ; ∆,∆′ =⇒ (νx)(P | Q) :: z:Ccut

Parallel composition of P, offering x :A and Q, using x :A.

Identity as Renaming

Γ;

x :

A =⇒

[x ↔ z] :: z:

ABernardo Toninho mrg.doc.ic.ac.uk 9/36

Page 25: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationJudgmental Principles

Typing Judgment

Γ︷ ︸︸ ︷u1:A1, . . . ,um:Am;

∆︷ ︸︸ ︷x1:A1, . . . , xn:An =⇒ P :: x :A

Process P provides A along x if composed with sessions in ∆ and Γ.

Identity as Renaming

Γ; x :A =⇒ [x ↔ z] :: z:A

Bernardo Toninho mrg.doc.ic.ac.uk 9/36

Page 26: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Multiplicative ConjunctionΓ; ∆ =⇒

P1 :: y :

A Γ; ∆′ =⇒

P2 :: x :

B

Γ; ∆,∆′ =⇒

(νy)x〈y〉.(P1 | P2) :: x :

A⊗ B⊗R

Γ; ∆,

y :

A,

x :

B =⇒

Q :: z:

C

Γ; ∆,

x :

A⊗ B =⇒

x(y).Q :: z:

C⊗L

Proof Reduction

Γ; ∆,∆′ =⇒ (νx)((νy)x〈y〉.(P1 | P2) | x(y).Q) :: z:C

−→ Γ; ∆,∆′ =⇒ (νx)(νy)(P1 | P2 | Q) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 10/36

Page 27: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Multiplicative ConjunctionΓ; ∆ =⇒ P1 :: y :A Γ; ∆′ =⇒ P2 :: x :B

Γ; ∆,∆′ =⇒

(νy)x〈y〉.(P1 | P2) :: x :

A⊗ B⊗R

Γ; ∆,

y :

A,

x :

B =⇒

Q :: z:

C

Γ; ∆,

x :

A⊗ B =⇒

x(y).Q :: z:

C⊗L

Proof Reduction

Γ; ∆,∆′ =⇒ (νx)((νy)x〈y〉.(P1 | P2) | x(y).Q) :: z:C

−→ Γ; ∆,∆′ =⇒ (νx)(νy)(P1 | P2 | Q) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 10/36

Page 28: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Multiplicative ConjunctionΓ; ∆ =⇒ P1 :: y :A Γ; ∆′ =⇒ P2 :: x :B

Γ; ∆,∆′ =⇒ (νy)x〈y〉.(P1 | P2) :: x :A⊗ B⊗R

Γ; ∆,

y :

A,

x :

B =⇒

Q :: z:

C

Γ; ∆,

x :

A⊗ B =⇒

x(y).Q :: z:

C⊗L

Proof Reduction

Γ; ∆,∆′ =⇒ (νx)((νy)x〈y〉.(P1 | P2) | x(y).Q) :: z:C

−→ Γ; ∆,∆′ =⇒ (νx)(νy)(P1 | P2 | Q) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 10/36

Page 29: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Multiplicative ConjunctionΓ; ∆ =⇒ P1 :: y :A Γ; ∆′ =⇒ P2 :: x :B

Γ; ∆,∆′ =⇒ (νy)x〈y〉.(P1 | P2) :: x :A⊗ B⊗R

Γ; ∆,

y :

A,

x :

B =⇒

Q :: z:

C

Γ; ∆,

x :

A⊗ B =⇒

x(y).Q :: z:

C⊗L

Proof Reduction

Γ; ∆,∆′ =⇒ (νx)((νy)x〈y〉.(P1 | P2) | x(y).Q) :: z:C

−→ Γ; ∆,∆′ =⇒ (νx)(νy)(P1 | P2 | Q) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 10/36

Page 30: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Multiplicative ConjunctionΓ; ∆ =⇒ P1 :: y :A Γ; ∆′ =⇒ P2 :: x :B

Γ; ∆,∆′ =⇒ (νy)x〈y〉.(P1 | P2) :: x :A⊗ B⊗R

Γ; ∆, y : A, x : B =⇒ Q :: z:C

Γ; ∆,

x :

A⊗ B =⇒

x(y).Q :: z:

C⊗L

Proof Reduction

Γ; ∆,∆′ =⇒ (νx)((νy)x〈y〉.(P1 | P2) | x(y).Q) :: z:C

−→ Γ; ∆,∆′ =⇒ (νx)(νy)(P1 | P2 | Q) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 10/36

Page 31: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Multiplicative ConjunctionΓ; ∆ =⇒ P1 :: y :A Γ; ∆′ =⇒ P2 :: x :B

Γ; ∆,∆′ =⇒ (νy)x〈y〉.(P1 | P2) :: x :A⊗ B⊗R

Γ; ∆, y : A, x : B =⇒ Q :: z:C

Γ; ∆, x :A⊗ B =⇒ x(y).Q :: z:C⊗L

Proof Reduction

Γ; ∆,∆′ =⇒ (νx)((νy)x〈y〉.(P1 | P2) | x(y).Q) :: z:C

−→ Γ; ∆,∆′ =⇒ (νx)(νy)(P1 | P2 | Q) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 10/36

Page 32: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Multiplicative ConjunctionΓ; ∆ =⇒ P1 :: y :A Γ; ∆′ =⇒ P2 :: x :B

Γ; ∆,∆′ =⇒ (νy)x〈y〉.(P1 | P2) :: x :A⊗ B⊗R

Γ; ∆, y : A, x : B =⇒ Q :: z:C

Γ; ∆, x :A⊗ B =⇒ x(y).Q :: z:C⊗L

Proof Reduction

Γ; ∆,∆′ =⇒ (νx)((νy)x〈y〉.(P1 | P2) | x(y).Q) :: z:C

−→ Γ; ∆,∆′ =⇒ (νx)(νy)(P1 | P2 | Q) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 10/36

Page 33: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Multiplicative ConjunctionΓ; ∆ =⇒ P1 :: y :A Γ; ∆′ =⇒ P2 :: x :B

Γ; ∆,∆′ =⇒ (νy)x〈y〉.(P1 | P2) :: x :A⊗ B⊗R

Γ; ∆, y : A, x : B =⇒ Q :: z:C

Γ; ∆, x :A⊗ B =⇒ x(y).Q :: z:C⊗L

Proof Reduction

Γ; ∆,∆′ =⇒ (νx)((νy)x〈y〉.(P1 | P2) | x(y).Q) :: z:C

−→ Γ; ∆,∆′ =⇒ (νx)(νy)(P1 | P2 | Q) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 10/36

Page 34: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Linear ImplicationΓ; ∆,

y :

A =⇒

P :: x :

B

Γ; ∆ =⇒

x(y).P :: x :

A( B(R

Γ; ∆ =⇒

Q1 :: y :

A Γ; ∆′,

x :

B =⇒

Q2 :: z:

C

Γ; ∆,∆′,

x :

A( B =⇒

(νy)x〈y〉.(Q1 | Q2) :: z:

C(L

Linear Implication as input. Reduction is the same as for ⊗.

Bernardo Toninho mrg.doc.ic.ac.uk 11/36

Page 35: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Linear ImplicationΓ; ∆, y : A =⇒ P :: x :B

Γ; ∆ =⇒

x(y).P :: x :

A( B(R

Γ; ∆ =⇒

Q1 :: y :

A Γ; ∆′,

x :

B =⇒

Q2 :: z:

C

Γ; ∆,∆′,

x :

A( B =⇒

(νy)x〈y〉.(Q1 | Q2) :: z:

C(L

Linear Implication as input. Reduction is the same as for ⊗.

Bernardo Toninho mrg.doc.ic.ac.uk 11/36

Page 36: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Linear ImplicationΓ; ∆, y : A =⇒ P :: x :B

Γ; ∆ =⇒ x(y).P :: x :A( B(R

Γ; ∆ =⇒

Q1 :: y :

A Γ; ∆′,

x :

B =⇒

Q2 :: z:

C

Γ; ∆,∆′,

x :

A( B =⇒

(νy)x〈y〉.(Q1 | Q2) :: z:

C(L

Linear Implication as input. Reduction is the same as for ⊗.

Bernardo Toninho mrg.doc.ic.ac.uk 11/36

Page 37: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Linear ImplicationΓ; ∆, y : A =⇒ P :: x :B

Γ; ∆ =⇒ x(y).P :: x :A( B(R

Γ; ∆ =⇒

Q1 :: y :

A Γ; ∆′,

x :

B =⇒

Q2 :: z:

C

Γ; ∆,∆′,

x :

A( B =⇒

(νy)x〈y〉.(Q1 | Q2) :: z:

C(L

Linear Implication as input. Reduction is the same as for ⊗.

Bernardo Toninho mrg.doc.ic.ac.uk 11/36

Page 38: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Linear ImplicationΓ; ∆, y : A =⇒ P :: x :B

Γ; ∆ =⇒ x(y).P :: x :A( B(R

Γ; ∆ =⇒ Q1 :: y :A Γ; ∆′, x :B =⇒ Q2 :: z:C

Γ; ∆,∆′,

x :

A( B =⇒

(νy)x〈y〉.(Q1 | Q2) :: z:

C(L

Linear Implication as input. Reduction is the same as for ⊗.

Bernardo Toninho mrg.doc.ic.ac.uk 11/36

Page 39: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Linear ImplicationΓ; ∆, y : A =⇒ P :: x :B

Γ; ∆ =⇒ x(y).P :: x :A( B(R

Γ; ∆ =⇒ Q1 :: y :A Γ; ∆′, x :B =⇒ Q2 :: z:C

Γ; ∆,∆′, x :A( B =⇒ (νy)x〈y〉.(Q1 | Q2) :: z:C(L

Linear Implication as input. Reduction is the same as for ⊗.

Bernardo Toninho mrg.doc.ic.ac.uk 11/36

Page 40: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Linear ImplicationΓ; ∆, y : A =⇒ P :: x :B

Γ; ∆ =⇒ x(y).P :: x :A( B(R

Γ; ∆ =⇒ Q1 :: y :A Γ; ∆′, x :B =⇒ Q2 :: z:C

Γ; ∆,∆′, x :A( B =⇒ (νy)x〈y〉.(Q1 | Q2) :: z:C(L

Linear Implication as input. Reduction is the same as for ⊗.

Bernardo Toninho mrg.doc.ic.ac.uk 11/36

Page 41: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Multiplicative Unit

Γ; · =⇒

0 :: x :

11R

Γ; ∆ =⇒

Q :: z:

C

Γ; ∆,

x :

1 =⇒

Q :: z:

C1L

Proof Reduction

Γ; ∆ =⇒ (νx)(0 | Q) :: z:C

≡ Γ; ∆ =⇒ Q :: z:C

Multiplicative Unit as Termination

Bernardo Toninho mrg.doc.ic.ac.uk 12/36

Page 42: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Multiplicative Unit

Γ; · =⇒ 0 :: x :11R

Γ; ∆ =⇒

Q :: z:

C

Γ; ∆,

x :

1 =⇒

Q :: z:

C1L

Proof Reduction

Γ; ∆ =⇒ (νx)(0 | Q) :: z:C

≡ Γ; ∆ =⇒ Q :: z:C

Multiplicative Unit as Termination

Bernardo Toninho mrg.doc.ic.ac.uk 12/36

Page 43: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Multiplicative Unit

Γ; · =⇒ 0 :: x :11R

Γ; ∆ =⇒

Q :: z:

C

Γ; ∆,

x :

1 =⇒

Q :: z:

C1L

Proof Reduction

Γ; ∆ =⇒ (νx)(0 | Q) :: z:C

≡ Γ; ∆ =⇒ Q :: z:C

Multiplicative Unit as Termination

Bernardo Toninho mrg.doc.ic.ac.uk 12/36

Page 44: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Multiplicative Unit

Γ; · =⇒ 0 :: x :11R

Γ; ∆ =⇒ Q :: z:C

Γ; ∆,

x :

1 =⇒

Q :: z:

C1L

Proof Reduction

Γ; ∆ =⇒ (νx)(0 | Q) :: z:C

≡ Γ; ∆ =⇒ Q :: z:C

Multiplicative Unit as Termination

Bernardo Toninho mrg.doc.ic.ac.uk 12/36

Page 45: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Multiplicative Unit

Γ; · =⇒ 0 :: x :11R

Γ; ∆ =⇒ Q :: z:C

Γ; ∆, x :1 =⇒ Q :: z:C1L

Proof Reduction

Γ; ∆ =⇒ (νx)(0 | Q) :: z:C

≡ Γ; ∆ =⇒ Q :: z:C

Multiplicative Unit as Termination

Bernardo Toninho mrg.doc.ic.ac.uk 12/36

Page 46: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Multiplicative Unit

Γ; · =⇒ 0 :: x :11R

Γ; ∆ =⇒ Q :: z:C

Γ; ∆, x :1 =⇒ Q :: z:C1L

Proof Reduction

Γ; ∆ =⇒ (νx)(0 | Q) :: z:C

≡ Γ; ∆ =⇒ Q :: z:C

Multiplicative Unit as Termination

Bernardo Toninho mrg.doc.ic.ac.uk 12/36

Page 47: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Multiplicative Unit

Γ; · =⇒ 0 :: x :11R

Γ; ∆ =⇒ Q :: z:C

Γ; ∆, x :1 =⇒ Q :: z:C1L

Proof Reduction

Γ; ∆ =⇒ (νx)(0 | Q) :: z:C

≡ Γ; ∆ =⇒ Q :: z:C

Multiplicative Unit as Termination

Bernardo Toninho mrg.doc.ic.ac.uk 12/36

Page 48: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Additive ConjunctionΓ; ∆ =⇒

P1 :: x :

A Γ; ∆ =⇒

P2 :: x :

B

Γ; ∆ =⇒

x .case(P1,P2) :: x :

A N BNR

Γ; ∆,

x :

A =⇒

Q :: z:

C

Γ; ∆,

x :

A N B =⇒

x .inl; Q :: z:

CNL1

Proof Reduction

Γ; ∆,∆′ =⇒ (νx)(x .case(P1,P2) | x .inl; Q) :: z:C

−→ Γ; ∆,∆′ =⇒ (νx)(P1 | Q) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 13/36

Page 49: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Additive ConjunctionΓ; ∆ =⇒ P1 :: x :A Γ; ∆ =⇒ P2 :: x :B

Γ; ∆ =⇒

x .case(P1,P2) :: x :

A N BNR

Γ; ∆,

x :

A =⇒

Q :: z:

C

Γ; ∆,

x :

A N B =⇒

x .inl; Q :: z:

CNL1

Proof Reduction

Γ; ∆,∆′ =⇒ (νx)(x .case(P1,P2) | x .inl; Q) :: z:C

−→ Γ; ∆,∆′ =⇒ (νx)(P1 | Q) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 13/36

Page 50: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Additive ConjunctionΓ; ∆ =⇒ P1 :: x :A Γ; ∆ =⇒ P2 :: x :B

Γ; ∆ =⇒ x .case(P1,P2) :: x :A N BNR

Γ; ∆,

x :

A =⇒

Q :: z:

C

Γ; ∆,

x :

A N B =⇒

x .inl; Q :: z:

CNL1

Proof Reduction

Γ; ∆,∆′ =⇒ (νx)(x .case(P1,P2) | x .inl; Q) :: z:C

−→ Γ; ∆,∆′ =⇒ (νx)(P1 | Q) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 13/36

Page 51: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Additive ConjunctionΓ; ∆ =⇒ P1 :: x :A Γ; ∆ =⇒ P2 :: x :B

Γ; ∆ =⇒ x .case(P1,P2) :: x :A N BNR

Γ; ∆,

x :

A =⇒

Q :: z:

C

Γ; ∆,

x :

A N B =⇒

x .inl; Q :: z:

CNL1

Proof Reduction

Γ; ∆,∆′ =⇒ (νx)(x .case(P1,P2) | x .inl; Q) :: z:C

−→ Γ; ∆,∆′ =⇒ (νx)(P1 | Q) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 13/36

Page 52: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Additive ConjunctionΓ; ∆ =⇒ P1 :: x :A Γ; ∆ =⇒ P2 :: x :B

Γ; ∆ =⇒ x .case(P1,P2) :: x :A N BNR

Γ; ∆, x :A =⇒ Q :: z:C

Γ; ∆,

x :

A N B =⇒

x .inl; Q :: z:

CNL1

Proof Reduction

Γ; ∆,∆′ =⇒ (νx)(x .case(P1,P2) | x .inl; Q) :: z:C

−→ Γ; ∆,∆′ =⇒ (νx)(P1 | Q) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 13/36

Page 53: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Additive ConjunctionΓ; ∆ =⇒ P1 :: x :A Γ; ∆ =⇒ P2 :: x :B

Γ; ∆ =⇒ x .case(P1,P2) :: x :A N BNR

Γ; ∆, x :A =⇒ Q :: z:C

Γ; ∆, x :A N B =⇒ x .inl; Q :: z:CNL1

Proof Reduction

Γ; ∆,∆′ =⇒ (νx)(x .case(P1,P2) | x .inl; Q) :: z:C

−→ Γ; ∆,∆′ =⇒ (νx)(P1 | Q) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 13/36

Page 54: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Additive ConjunctionΓ; ∆ =⇒ P1 :: x :A Γ; ∆ =⇒ P2 :: x :B

Γ; ∆ =⇒ x .case(P1,P2) :: x :A N BNR

Γ; ∆, x :A =⇒ Q :: z:C

Γ; ∆, x :A N B =⇒ x .inl; Q :: z:CNL1

Proof Reduction

Γ; ∆,∆′ =⇒ (νx)(x .case(P1,P2) | x .inl; Q) :: z:C

−→ Γ; ∆,∆′ =⇒ (νx)(P1 | Q) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 13/36

Page 55: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Additive DisjunctionΓ; ∆ =⇒

P :: x :

A

Γ; ∆ =⇒

x .inl; P :: x :

A⊕ B⊕R1

Γ; ∆,

x :

A =⇒

Q1 :: z:

C Γ; ∆,

x :

B =⇒

Q2 :: z:

C

Γ; ∆,

x :

A⊕ B =⇒

x .case(Q1,Q2) :: z:

C⊕L

Same proof reductions as N.

Bernardo Toninho mrg.doc.ic.ac.uk 14/36

Page 56: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Additive DisjunctionΓ; ∆ =⇒ P :: x :A

Γ; ∆ =⇒

x .inl; P :: x :

A⊕ B⊕R1

Γ; ∆,

x :

A =⇒

Q1 :: z:

C Γ; ∆,

x :

B =⇒

Q2 :: z:

C

Γ; ∆,

x :

A⊕ B =⇒

x .case(Q1,Q2) :: z:

C⊕L

Same proof reductions as N.

Bernardo Toninho mrg.doc.ic.ac.uk 14/36

Page 57: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Additive DisjunctionΓ; ∆ =⇒ P :: x :A

Γ; ∆ =⇒ x .inl; P :: x :A⊕ B⊕R1

Γ; ∆,

x :

A =⇒

Q1 :: z:

C Γ; ∆,

x :

B =⇒

Q2 :: z:

C

Γ; ∆,

x :

A⊕ B =⇒

x .case(Q1,Q2) :: z:

C⊕L

Same proof reductions as N.

Bernardo Toninho mrg.doc.ic.ac.uk 14/36

Page 58: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Additive DisjunctionΓ; ∆ =⇒ P :: x :A

Γ; ∆ =⇒ x .inl; P :: x :A⊕ B⊕R1

Γ; ∆,

x :

A =⇒

Q1 :: z:

C Γ; ∆,

x :

B =⇒

Q2 :: z:

C

Γ; ∆,

x :

A⊕ B =⇒

x .case(Q1,Q2) :: z:

C⊕L

Same proof reductions as N.

Bernardo Toninho mrg.doc.ic.ac.uk 14/36

Page 59: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Additive DisjunctionΓ; ∆ =⇒ P :: x :A

Γ; ∆ =⇒ x .inl; P :: x :A⊕ B⊕R1

Γ; ∆, x :A =⇒ Q1 :: z:C Γ; ∆, x :B =⇒ Q2 :: z:C

Γ; ∆,

x :

A⊕ B =⇒

x .case(Q1,Q2) :: z:

C⊕L

Same proof reductions as N.

Bernardo Toninho mrg.doc.ic.ac.uk 14/36

Page 60: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

Additive DisjunctionΓ; ∆ =⇒ P :: x :A

Γ; ∆ =⇒ x .inl; P :: x :A⊕ B⊕R1

Γ; ∆, x :A =⇒ Q1 :: z:C Γ; ∆, x :B =⇒ Q2 :: z:C

Γ; ∆, x :A⊕ B =⇒ x .case(Q1,Q2) :: z:C⊕L

Same proof reductions as N.

Bernardo Toninho mrg.doc.ic.ac.uk 14/36

Page 61: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationJudgmental Principles for Exponential

Persistent CutΓ; · =⇒

P :: x :

A Γ,

u:

A; ∆ =⇒

Q :: z:

C

Γ; ∆ =⇒

(νu)(!u(x).P | Q) :: z:

Ccut!

Parallel composition of P, offering x :A and Q, using u:A persistently.

CopyΓ,

u:

A; ∆,

x :

A =⇒

P :: z:

C

Γ,

u:

A; ∆ =⇒

(νx)u〈x〉.Q :: z:

Ccopy

Proof Reduction

Γ; ∆ =⇒ (νu)(!u(x).P | (νx)u〈x〉.Q) :: z:C

−→ Γ; ∆ =⇒ (νu)(!u(x).P | (νx)(P | Q)) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 15/36

Page 62: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationJudgmental Principles for Exponential

Persistent CutΓ; · =⇒ P :: x :A Γ,u:A; ∆ =⇒ Q :: z:C

Γ; ∆ =⇒

(νu)(!u(x).P | Q) :: z:

Ccut!

Parallel composition of P, offering x :A and Q, using u:A persistently.

CopyΓ,

u:

A; ∆,

x :

A =⇒

P :: z:

C

Γ,

u:

A; ∆ =⇒

(νx)u〈x〉.Q :: z:

Ccopy

Proof Reduction

Γ; ∆ =⇒ (νu)(!u(x).P | (νx)u〈x〉.Q) :: z:C

−→ Γ; ∆ =⇒ (νu)(!u(x).P | (νx)(P | Q)) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 15/36

Page 63: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationJudgmental Principles for Exponential

Persistent CutΓ; · =⇒ P :: x :A Γ,u:A; ∆ =⇒ Q :: z:C

Γ; ∆ =⇒ (νu)(!u(x).P | Q) :: z:Ccut!

Parallel composition of P, offering x :A and Q, using u:A persistently.

CopyΓ,

u:

A; ∆,

x :

A =⇒

P :: z:

C

Γ,

u:

A; ∆ =⇒

(νx)u〈x〉.Q :: z:

Ccopy

Proof Reduction

Γ; ∆ =⇒ (νu)(!u(x).P | (νx)u〈x〉.Q) :: z:C

−→ Γ; ∆ =⇒ (νu)(!u(x).P | (νx)(P | Q)) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 15/36

Page 64: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationJudgmental Principles for Exponential

Persistent CutΓ; · =⇒ P :: x :A Γ,u:A; ∆ =⇒ Q :: z:C

Γ; ∆ =⇒ (νu)(!u(x).P | Q) :: z:Ccut!

Parallel composition of P, offering x :A and Q, using u:A persistently.

CopyΓ,

u:

A; ∆,

x :

A =⇒

P :: z:

C

Γ,

u:

A; ∆ =⇒

(νx)u〈x〉.Q :: z:

Ccopy

Proof Reduction

Γ; ∆ =⇒ (νu)(!u(x).P | (νx)u〈x〉.Q) :: z:C

−→ Γ; ∆ =⇒ (νu)(!u(x).P | (νx)(P | Q)) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 15/36

Page 65: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationJudgmental Principles for Exponential

Persistent CutΓ; · =⇒ P :: x :A Γ,u:A; ∆ =⇒ Q :: z:C

Γ; ∆ =⇒ (νu)(!u(x).P | Q) :: z:Ccut!

Parallel composition of P, offering x :A and Q, using u:A persistently.

CopyΓ,

u:

A; ∆,

x :

A =⇒

P :: z:

C

Γ,

u:

A; ∆ =⇒

(νx)u〈x〉.Q :: z:

Ccopy

Proof Reduction

Γ; ∆ =⇒ (νu)(!u(x).P | (νx)u〈x〉.Q) :: z:C

−→ Γ; ∆ =⇒ (νu)(!u(x).P | (νx)(P | Q)) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 15/36

Page 66: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationJudgmental Principles for Exponential

Persistent CutΓ; · =⇒ P :: x :A Γ,u:A; ∆ =⇒ Q :: z:C

Γ; ∆ =⇒ (νu)(!u(x).P | Q) :: z:Ccut!

Parallel composition of P, offering x :A and Q, using u:A persistently.

CopyΓ,u:A; ∆, x :A =⇒ P :: z:C

Γ,

u:

A; ∆ =⇒

(νx)u〈x〉.Q :: z:

Ccopy

Proof Reduction

Γ; ∆ =⇒ (νu)(!u(x).P | (νx)u〈x〉.Q) :: z:C

−→ Γ; ∆ =⇒ (νu)(!u(x).P | (νx)(P | Q)) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 15/36

Page 67: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationJudgmental Principles for Exponential

Persistent CutΓ; · =⇒ P :: x :A Γ,u:A; ∆ =⇒ Q :: z:C

Γ; ∆ =⇒ (νu)(!u(x).P | Q) :: z:Ccut!

Parallel composition of P, offering x :A and Q, using u:A persistently.

CopyΓ,u:A; ∆, x :A =⇒ P :: z:C

Γ,u:A; ∆ =⇒ (νx)u〈x〉.Q :: z:Ccopy

Proof Reduction

Γ; ∆ =⇒ (νu)(!u(x).P | (νx)u〈x〉.Q) :: z:C

−→ Γ; ∆ =⇒ (νu)(!u(x).P | (νx)(P | Q)) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 15/36

Page 68: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationJudgmental Principles for Exponential

Persistent CutΓ; · =⇒ P :: x :A Γ,u:A; ∆ =⇒ Q :: z:C

Γ; ∆ =⇒ (νu)(!u(x).P | Q) :: z:Ccut!

Parallel composition of P, offering x :A and Q, using u:A persistently.

CopyΓ,u:A; ∆, x :A =⇒ P :: z:C

Γ,u:A; ∆ =⇒ (νx)u〈x〉.Q :: z:Ccopy

Proof Reduction

Γ; ∆ =⇒ (νu)(!u(x).P | (νx)u〈x〉.Q) :: z:C

−→ Γ; ∆ =⇒ (νu)(!u(x).P | (νx)(P | Q)) :: z:C

Bernardo Toninho mrg.doc.ic.ac.uk 15/36

Page 69: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

ExponentialΓ; · =⇒

P :: y :

A

Γ; · =⇒

!x(y).P :: x :

!A!R

Γ,

u:

A; ∆ =⇒

P :: z:

C

Γ; ∆,

x :

!A =⇒

P{x/u} :: z:

C!L

Proof reduction transforms a cut into a cut! (struct. equivalence).

Bernardo Toninho mrg.doc.ic.ac.uk 16/36

Page 70: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

ExponentialΓ; · =⇒ P :: y :A

Γ; · =⇒

!x(y).P :: x :

!A!R

Γ,

u:

A; ∆ =⇒

P :: z:

C

Γ; ∆,

x :

!A =⇒

P{x/u} :: z:

C!L

Proof reduction transforms a cut into a cut! (struct. equivalence).

Bernardo Toninho mrg.doc.ic.ac.uk 16/36

Page 71: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

ExponentialΓ; · =⇒ P :: y :A

Γ; · =⇒ !x(y).P :: x :!A!R

Γ,

u:

A; ∆ =⇒

P :: z:

C

Γ; ∆,

x :

!A =⇒

P{x/u} :: z:

C!L

Proof reduction transforms a cut into a cut! (struct. equivalence).

Bernardo Toninho mrg.doc.ic.ac.uk 16/36

Page 72: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

ExponentialΓ; · =⇒ P :: y :A

Γ; · =⇒ !x(y).P :: x :!A!R

Γ,

u:

A; ∆ =⇒

P :: z:

C

Γ; ∆,

x :

!A =⇒

P{x/u} :: z:

C!L

Proof reduction transforms a cut into a cut! (struct. equivalence).

Bernardo Toninho mrg.doc.ic.ac.uk 16/36

Page 73: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

ExponentialΓ; · =⇒ P :: y :A

Γ; · =⇒ !x(y).P :: x :!A!R

Γ,u:A; ∆ =⇒ P :: z:C

Γ; ∆,

x :

!A =⇒

P{x/u} :: z:

C!L

Proof reduction transforms a cut into a cut! (struct. equivalence).

Bernardo Toninho mrg.doc.ic.ac.uk 16/36

Page 74: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationPropositions

ExponentialΓ; · =⇒ P :: y :A

Γ; · =⇒ !x(y).P :: x :!A!R

Γ,u:A; ∆ =⇒ P :: z:C

Γ; ∆, x :!A =⇒ P{x/u} :: z:C!L

Proof reduction transforms a cut into a cut! (struct. equivalence).

Bernardo Toninho mrg.doc.ic.ac.uk 16/36

Page 75: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationMetatheory

Operational Correspondence and Subject ReductionIf Γ; ∆ =⇒ P :: z:A and P → P ′ then ∃Q such that Γ; ∆ =⇒ Q :: z:A and P ′ ≡ Q.

Global Progress

live(P) , (νx)(Q | R) with Q ≡ π.Q′ or Q ≡ [x ↔ y ]

If ` P :: x :1 and live(P) then ∃Q such that P → Q.

Much stronger property than in classical session types, “for free”!

Bernardo Toninho mrg.doc.ic.ac.uk 17/36

Page 76: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationMetatheory

Operational Correspondence and Subject ReductionIf Γ; ∆ =⇒ P :: z:A and P → P ′ then ∃Q such that Γ; ∆ =⇒ Q :: z:A and P ′ ≡ Q.

Global Progress

live(P) , (νx)(Q | R) with Q ≡ π.Q′ or Q ≡ [x ↔ y ]

If ` P :: x :1 and live(P) then ∃Q such that P → Q.

Much stronger property than in classical session types, “for free”!

Bernardo Toninho mrg.doc.ic.ac.uk 17/36

Page 77: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationSummary

I Linear Propositions as Session Types.I Intuitionistic proofs as session-typed processes.I Process reduction maps to proof conversion.

I . . . but not all proof conversions are process reductions!

Bernardo Toninho mrg.doc.ic.ac.uk 18/36

Page 78: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

ILL InterpretationSummary

I Linear Propositions as Session Types.I Intuitionistic proofs as session-typed processes.I Process reduction maps to proof conversion.I . . . but not all proof conversions are process reductions!

Bernardo Toninho mrg.doc.ic.ac.uk 18/36

Page 79: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Richer Type TheoriesMotivation

Session TypesI Only express simple communication patterns.I No interesting properties of exchanged data.I No sophisticated properties of processes.

Answers from LogicI Enrich the logic/types: Quantifiers, ModalitiesI Dependent Session Types [Toninho et al.11]I Polymorphic Session Types [Perez et al.11, Wadler11]I Internalisation in a linear monad [Toninho et al.12]

Bernardo Toninho mrg.doc.ic.ac.uk 19/36

Page 80: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Richer Type TheoriesMotivation

Session TypesI Only express simple communication patterns.I No interesting properties of exchanged data.I No sophisticated properties of processes.

Answers from LogicI Enrich the logic/types: Quantifiers, ModalitiesI Dependent Session Types [Toninho et al.11]I Polymorphic Session Types [Perez et al.11, Wadler11]I Internalisation in a linear monad [Toninho et al.12]

Bernardo Toninho mrg.doc.ic.ac.uk 19/36

Page 81: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Richer Type TheoriesWhere are we?

Dependent Session Types [Toninho et al.11, Pfenning et al.11]I Two new types: ∀x :τ.A and ∃x :τ.AI Parametric in the language of types τ .

I ∀x :τ.A - Input a term M : τ , continue as A(M).I ∃x :τ.A - Output a term M : τ , continue as A(M).I If τs are dependent: proof communication.I With affirmation and proof irrelevance: proof certificates.

indexersimple , !(file( file⊗ 1)

indexerdspec , !(∀f :file.pdf(f )( ∃g:file.pdf(g)⊗ agree(f ,g)⊗ 1)

indexerirrev , !(∀f :file.[pdf(f )]( ∃g:file.[pdf(g)]⊗ [agree(f ,g)]⊗ 1)

Bernardo Toninho mrg.doc.ic.ac.uk 20/36

Page 82: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Richer Type TheoriesWhere are we?

Dependent Session Types [Toninho et al.11, Pfenning et al.11]I Two new types: ∀x :τ.A and ∃x :τ.AI Parametric in the language of types τ .I ∀x :τ.A - Input a term M : τ , continue as A(M).I ∃x :τ.A - Output a term M : τ , continue as A(M).

I If τs are dependent: proof communication.I With affirmation and proof irrelevance: proof certificates.

indexersimple , !(file( file⊗ 1)

indexerdspec , !(∀f :file.pdf(f )( ∃g:file.pdf(g)⊗ agree(f ,g)⊗ 1)

indexerirrev , !(∀f :file.[pdf(f )]( ∃g:file.[pdf(g)]⊗ [agree(f ,g)]⊗ 1)

Bernardo Toninho mrg.doc.ic.ac.uk 20/36

Page 83: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Richer Type TheoriesWhere are we?

Dependent Session Types [Toninho et al.11, Pfenning et al.11]I Two new types: ∀x :τ.A and ∃x :τ.AI Parametric in the language of types τ .I ∀x :τ.A - Input a term M : τ , continue as A(M).I ∃x :τ.A - Output a term M : τ , continue as A(M).I If τs are dependent: proof communication.I With affirmation and proof irrelevance: proof certificates.

indexersimple , !(file( file⊗ 1)

indexerdspec , !(∀f :file.pdf(f )( ∃g:file.pdf(g)⊗ agree(f ,g)⊗ 1)

indexerirrev , !(∀f :file.[pdf(f )]( ∃g:file.[pdf(g)]⊗ [agree(f ,g)]⊗ 1)

Bernardo Toninho mrg.doc.ic.ac.uk 20/36

Page 84: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Richer Type TheoriesWhere are we?

Dependent Session Types [Toninho et al.11, Pfenning et al.11]I Two new types: ∀x :τ.A and ∃x :τ.AI Parametric in the language of types τ .I ∀x :τ.A - Input a term M : τ , continue as A(M).I ∃x :τ.A - Output a term M : τ , continue as A(M).I If τs are dependent: proof communication.I With affirmation and proof irrelevance: proof certificates.

indexersimple , !(file( file⊗ 1)

indexerdspec , !(∀f :file.pdf(f )( ∃g:file.pdf(g)⊗ agree(f ,g)⊗ 1)

indexerirrev , !(∀f :file.[pdf(f )]( ∃g:file.[pdf(g)]⊗ [agree(f ,g)]⊗ 1)

Bernardo Toninho mrg.doc.ic.ac.uk 20/36

Page 85: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Richer Type TheoriesWhere are we?

Dependent Session Types [Toninho et al.11, Pfenning et al.11]I Two new types: ∀x :τ.A and ∃x :τ.AI Parametric in the language of types τ .I ∀x :τ.A - Input a term M : τ , continue as A(M).I ∃x :τ.A - Output a term M : τ , continue as A(M).I If τs are dependent: proof communication.I With affirmation and proof irrelevance: proof certificates.

indexersimple , !(file( file⊗ 1)

indexerdspec , !(∀f :file.pdf(f )( ∃g:file.pdf(g)⊗ agree(f ,g)⊗ 1)

indexerirrev , !(∀f :file.[pdf(f )]( ∃g:file.[pdf(g)]⊗ [agree(f ,g)]⊗ 1)

Bernardo Toninho mrg.doc.ic.ac.uk 20/36

Page 86: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Richer Type TheoriesWhere are we?

Dependent Session Types [Toninho et al.11, Pfenning et al.11]I Two new types: ∀x :τ.A and ∃x :τ.AI Parametric in the language of types τ .I ∀x :τ.A - Input a term M : τ , continue as A(M).I ∃x :τ.A - Output a term M : τ , continue as A(M).I If τs are dependent: proof communication.I With affirmation and proof irrelevance: proof certificates.

indexersimple , !(file( file⊗ 1)

indexerdspec , !(∀f :file.pdf(f )( ∃g:file.pdf(g)⊗ agree(f ,g)⊗ 1)

indexerirrev , !(∀f :file.[pdf(f )]( ∃g:file.[pdf(g)]⊗ [agree(f ,g)]⊗ 1)

Bernardo Toninho mrg.doc.ic.ac.uk 20/36

Page 87: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Richer Type TheoriesWhere are we?

Polymorphism and Parametricity [Perez et al.11, Wadler11]I Second-order quantification (∀X .A and ∃X .A).I Communication of session types / abstract protocols.I Relational parametricity results in the style of System F.

Monadic Integration [Toninho et al.12]I M : {Γ; ∆ ` z:A}, type of an open process P (construct {P}).I Process construct bind(M, z.Q):

I Evaluate M to a (suspended) process {P}.I Run underlying process P in parallel with Q.

I Higher-Order Sessions, e.g.: ∀x :{z:A}.∀y :{z:B}.A⊗ B

Bernardo Toninho mrg.doc.ic.ac.uk 21/36

Page 88: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Richer Type TheoriesWhere are we?

Polymorphism and Parametricity [Perez et al.11, Wadler11]I Second-order quantification (∀X .A and ∃X .A).I Communication of session types / abstract protocols.I Relational parametricity results in the style of System F.

Monadic Integration [Toninho et al.12]I M : {Γ; ∆ ` z:A}, type of an open process P (construct {P}).I Process construct bind(M, z.Q):

I Evaluate M to a (suspended) process {P}.I Run underlying process P in parallel with Q.

I Higher-Order Sessions, e.g.: ∀x :{z:A}.∀y :{z:B}.A⊗ B

Bernardo Toninho mrg.doc.ic.ac.uk 21/36

Page 89: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Richer Type TheoriesWhere are we?

Polymorphism and Parametricity [Perez et al.11, Wadler11]I Second-order quantification (∀X .A and ∃X .A).I Communication of session types / abstract protocols.I Relational parametricity results in the style of System F.

Monadic Integration [Toninho et al.12]I M : {Γ; ∆ ` z:A}, type of an open process P (construct {P}).I Process construct bind(M, z.Q):

I Evaluate M to a (suspended) process {P}.I Run underlying process P in parallel with Q.

I Higher-Order Sessions, e.g.: ∀x :{z:A}.∀y :{z:B}.A⊗ B

Bernardo Toninho mrg.doc.ic.ac.uk 21/36

Page 90: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof Conversions and Type IsomorphismsIntroduction

Proof ConversionsI Process reductions map to principal cut reductions.I What about the remaining proof conversions?I Can we understand them in concurrency theoretic terms?

ApproachWe decompose proof conversions into three classes:I Computational Conversions (i.e. principal cut conversions).I Cut Conversions (i.e. permutting two cuts in a proof).I Commuting Conversions (i.e. commutting inference rules).

First two correspond to reductions and structural equivalences.

Bernardo Toninho mrg.doc.ic.ac.uk 22/36

Page 91: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof Conversions and Type IsomorphismsIntroduction

Proof ConversionsI Process reductions map to principal cut reductions.I What about the remaining proof conversions?I Can we understand them in concurrency theoretic terms?

ApproachWe decompose proof conversions into three classes:I Computational Conversions (i.e. principal cut conversions).I Cut Conversions (i.e. permutting two cuts in a proof).I Commuting Conversions (i.e. commutting inference rules).

First two correspond to reductions and structural equivalences.

Bernardo Toninho mrg.doc.ic.ac.uk 22/36

Page 92: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof ConversionsCommuting Conversions

Commuting Conversions induce a congruence 'c on typed processes

⊗L/⊗L Commuting Conversion

x :A⊗ B, z:C ⊗ D =⇒ x(y).z(w).P 'c z(w).x(y).P :: v :E

Commuting (input) prefixes appears, at first, counterintuitive.

Typed Contextual EquivalenceIn any well-typed context, we cannot distinguish the two processes:

(νx)(νz)(x(y).z(w).P | Rx | Sz) ∼= (νx)(νz)(z(w).x(y).P | Rx | Sz) :: v :E

Actions along x and z are not observable.

Bernardo Toninho mrg.doc.ic.ac.uk 23/36

Page 93: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof ConversionsCommuting Conversions

Commuting Conversions induce a congruence 'c on typed processes

⊗L/⊗L Commuting Conversion

x :A⊗ B, z:C ⊗ D =⇒ x(y).z(w).P 'c z(w).x(y).P :: v :E

Commuting (input) prefixes appears, at first, counterintuitive.

Typed Contextual EquivalenceIn any well-typed context, we cannot distinguish the two processes:

(νx)(νz)(x(y).z(w).P | Rx | Sz) ∼= (νx)(νz)(z(w).x(y).P | Rx | Sz) :: v :E

Actions along x and z are not observable.

Bernardo Toninho mrg.doc.ic.ac.uk 23/36

Page 94: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof ConversionsTyped Contextual Equivalence

Typed Contextual EquivalenceI How to define this equivalence in a tractable way?I Typed Contextual Bisimilarity.

Contextual BisimilarityI Contextual: For all typed contexts. . .I Typed bisimilarity on closed processes:

I P ∼ Q :: x :A( B iff Px(y)→ P ′ implies Q

x(y)⇒ Q′ and ∀R.· =⇒ R :: y :A we have(νy)(P | R) ∼ (νy)(Q | R) :: x :B

I P ∼ Q :: x :C iff P τ→ P ′ implies Q ⇒ Q′ and P ′ ∼ Q′ :: x :C.I . . .

Bernardo Toninho mrg.doc.ic.ac.uk 24/36

Page 95: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof ConversionsTyped Contextual Equivalence

Typed Contextual EquivalenceI How to define this equivalence in a tractable way?I Typed Contextual Bisimilarity.

Contextual BisimilarityI Contextual: For all typed contexts. . .I Typed bisimilarity on closed processes:

I P ∼ Q :: x :A( B iff Px(y)→ P ′ implies Q

x(y)⇒ Q′ and ∀R.· =⇒ R :: y :A we have(νy)(P | R) ∼ (νy)(Q | R) :: x :B

I P ∼ Q :: x :C iff P τ→ P ′ implies Q ⇒ Q′ and P ′ ∼ Q′ :: x :C.I . . .

Bernardo Toninho mrg.doc.ic.ac.uk 24/36

Page 96: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof ConversionsIssue

⊗L/⊗L Conversion Revisited

(νx)(νz)(x(y).z(w).P | Rx | Sz) ∼ (νx)(νz)(z(w).x(y).P | Rx | Sz) :: v :E?

I Suppose input along x matches an output in Rx on the left proc.

I How do we know the right side process can match it?I What if Sz never outputs to z?I Requires termination!

Termination and BisimilarityI Can we develop a uniform solution?I Inspiration from functional “world”: Linear Logical Relations!

Bernardo Toninho mrg.doc.ic.ac.uk 25/36

Page 97: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof ConversionsIssue

⊗L/⊗L Conversion Revisited

(νx)(νz)(x(y).z(w).P | Rx | Sz) ∼ (νx)(νz)(z(w).x(y).P | Rx | Sz) :: v :E?

I Suppose input along x matches an output in Rx on the left proc.I How do we know the right side process can match it?I What if Sz never outputs to z?

I Requires termination!

Termination and BisimilarityI Can we develop a uniform solution?I Inspiration from functional “world”: Linear Logical Relations!

Bernardo Toninho mrg.doc.ic.ac.uk 25/36

Page 98: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof ConversionsIssue

⊗L/⊗L Conversion Revisited

(νx)(νz)(x(y).z(w).P | Rx | Sz) ∼ (νx)(νz)(z(w).x(y).P | Rx | Sz) :: v :E?

I Suppose input along x matches an output in Rx on the left proc.I How do we know the right side process can match it?I What if Sz never outputs to z?I Requires termination!

Termination and BisimilarityI Can we develop a uniform solution?I Inspiration from functional “world”: Linear Logical Relations!

Bernardo Toninho mrg.doc.ic.ac.uk 25/36

Page 99: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof ConversionsIssue

⊗L/⊗L Conversion Revisited

(νx)(νz)(x(y).z(w).P | Rx | Sz) ∼ (νx)(νz)(z(w).x(y).P | Rx | Sz) :: v :E?

I Suppose input along x matches an output in Rx on the left proc.I How do we know the right side process can match it?I What if Sz never outputs to z?I Requires termination!

Termination and BisimilarityI Can we develop a uniform solution?I Inspiration from functional “world”: Linear Logical Relations!

Bernardo Toninho mrg.doc.ic.ac.uk 25/36

Page 100: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof ConversionsTermination and Bisimilarity

Linear Logical Relations [Perez et al. 12]I Termination: Inductively defined unary predicate.I Contextual Bisimulation: Co-inductively defined binary relation.

Logical PredicateI Terminating by construction.I Inductive on typing derivations: L[Γ; ∆ ` T ]

I P ∈ L[Γ; y :A,∆ ` T ] if ∀R ∈ L[y : A].(νy)(R | P) ∈ L[Γ; ∆ ` T ].I Base case is inductive on types:

I P ∈ L[z:A( B] , if Pz(y)⇒ P ′ then ∀Q ∈ L[y :A].(νy)(P ′ |Q)∈L[z:B]

I . . .

Typing implies TerminationIf Γ; ∆ ` P :: T then P ∈ L[Γ; ∆ ` T ].

Bernardo Toninho mrg.doc.ic.ac.uk 26/36

Page 101: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof ConversionsTermination and Bisimilarity

Linear Logical Relations [Perez et al. 12]I Termination: Inductively defined unary predicate.I Contextual Bisimulation: Co-inductively defined binary relation.

Logical PredicateI Terminating by construction.I Inductive on typing derivations: L[Γ; ∆ ` T ]

I P ∈ L[Γ; y :A,∆ ` T ] if ∀R ∈ L[y : A].(νy)(R | P) ∈ L[Γ; ∆ ` T ].

I Base case is inductive on types:I P ∈ L[z:A( B] , if P

z(y)⇒ P ′ then ∀Q ∈ L[y :A].(νy)(P ′ |Q)∈L[z:B]I . . .

Typing implies TerminationIf Γ; ∆ ` P :: T then P ∈ L[Γ; ∆ ` T ].

Bernardo Toninho mrg.doc.ic.ac.uk 26/36

Page 102: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof ConversionsTermination and Bisimilarity

Linear Logical Relations [Perez et al. 12]I Termination: Inductively defined unary predicate.I Contextual Bisimulation: Co-inductively defined binary relation.

Logical PredicateI Terminating by construction.I Inductive on typing derivations: L[Γ; ∆ ` T ]

I P ∈ L[Γ; y :A,∆ ` T ] if ∀R ∈ L[y : A].(νy)(R | P) ∈ L[Γ; ∆ ` T ].I Base case is inductive on types:

I P ∈ L[z:A( B] , if Pz(y)⇒ P ′ then ∀Q ∈ L[y :A].(νy)(P ′ |Q)∈L[z:B]

I . . .

Typing implies TerminationIf Γ; ∆ ` P :: T then P ∈ L[Γ; ∆ ` T ].

Bernardo Toninho mrg.doc.ic.ac.uk 26/36

Page 103: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof ConversionsTermination and Bisimilarity

Linear Logical Relations [Perez et al. 12]I Termination: Inductively defined unary predicate.I Contextual Bisimulation: Co-inductively defined binary relation.

Logical PredicateI Terminating by construction.I Inductive on typing derivations: L[Γ; ∆ ` T ]

I P ∈ L[Γ; y :A,∆ ` T ] if ∀R ∈ L[y : A].(νy)(R | P) ∈ L[Γ; ∆ ` T ].I Base case is inductive on types:

I P ∈ L[z:A( B] , if Pz(y)⇒ P ′ then ∀Q ∈ L[y :A].(νy)(P ′ |Q)∈L[z:B]

I . . .

Typing implies TerminationIf Γ; ∆ ` P :: T then P ∈ L[Γ; ∆ ` T ].

Bernardo Toninho mrg.doc.ic.ac.uk 26/36

Page 104: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof ConversionsTermination and Bisimilarity

Typed BisimilarityI Relational generalization of the predicate.I Inductive on typing derivations: Γ; ∆ ` PRQ :: T

I If Γ; ∆, y :A ` PRQ :: T then ∀R. ` R :: y :A, Γ; ∆ ` (νy)(P |R)R(νy)(Q |R) :: T .

I Base case is inductive/coinductive on types:I ` PRQ :: x :A( B iff P

x(y)→ P ′ implies Qx(y)⇒ Q′ and ∀R.· ` R :: y :A we have

` (νy)(P | R)R(νy)(Q | R) :: x :BI . . .

I ≈ is the largest such relation.

Soundness of Commuting ConversionsIf Γ; ∆ ` P 'c Q :: T then Γ; ∆ ` P ≈ Q :: T

Bernardo Toninho mrg.doc.ic.ac.uk 27/36

Page 105: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof ConversionsTermination and Bisimilarity

Typed BisimilarityI Relational generalization of the predicate.I Inductive on typing derivations: Γ; ∆ ` PRQ :: T

I If Γ; ∆, y :A ` PRQ :: T then ∀R. ` R :: y :A, Γ; ∆ ` (νy)(P |R)R(νy)(Q |R) :: T .I Base case is inductive/coinductive on types:

I ` PRQ :: x :A( B iff Px(y)→ P ′ implies Q

x(y)⇒ Q′ and ∀R.· ` R :: y :A we have` (νy)(P | R)R(νy)(Q | R) :: x :B

I . . .

I ≈ is the largest such relation.

Soundness of Commuting ConversionsIf Γ; ∆ ` P 'c Q :: T then Γ; ∆ ` P ≈ Q :: T

Bernardo Toninho mrg.doc.ic.ac.uk 27/36

Page 106: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof ConversionsTermination and Bisimilarity

Typed BisimilarityI Relational generalization of the predicate.I Inductive on typing derivations: Γ; ∆ ` PRQ :: T

I If Γ; ∆, y :A ` PRQ :: T then ∀R. ` R :: y :A, Γ; ∆ ` (νy)(P |R)R(νy)(Q |R) :: T .I Base case is inductive/coinductive on types:

I ` PRQ :: x :A( B iff Px(y)→ P ′ implies Q

x(y)⇒ Q′ and ∀R.· ` R :: y :A we have` (νy)(P | R)R(νy)(Q | R) :: x :B

I . . .I ≈ is the largest such relation.

Soundness of Commuting ConversionsIf Γ; ∆ ` P 'c Q :: T then Γ; ∆ ` P ≈ Q :: T

Bernardo Toninho mrg.doc.ic.ac.uk 27/36

Page 107: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Proof ConversionsTermination and Bisimilarity

Typed BisimilarityI Relational generalization of the predicate.I Inductive on typing derivations: Γ; ∆ ` PRQ :: T

I If Γ; ∆, y :A ` PRQ :: T then ∀R. ` R :: y :A, Γ; ∆ ` (νy)(P |R)R(νy)(Q |R) :: T .I Base case is inductive/coinductive on types:

I ` PRQ :: x :A( B iff Px(y)→ P ′ implies Q

x(y)⇒ Q′ and ∀R.· ` R :: y :A we have` (νy)(P | R)R(νy)(Q | R) :: x :B

I . . .I ≈ is the largest such relation.

Soundness of Commuting ConversionsIf Γ; ∆ ` P 'c Q :: T then Γ; ∆ ` P ≈ Q :: T

Bernardo Toninho mrg.doc.ic.ac.uk 27/36

Page 108: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Type IsomorphismsDefinition and Validation

Type Isomorphism (A ' B)Types A and B are iso. if there are proofs πA of B ` A and πB of A ` B, composingin both direction to identity.

Session Type Isomorphisms (A 'S B)Session types A and B are iso. if there are processes P and Q:I x :A ` P :: y :B and y :B ` Q :: x :A.I x :A ` (νy)(P | Q) ≈ [x ↔ z] :: z:A.I y :B ` (νx)(Q | P) ≈ [y ↔ z] :: z:B.

Validating IsomorphismsIf A ' B then A 'S B.

Bernardo Toninho mrg.doc.ic.ac.uk 28/36

Page 109: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Type IsomorphismsDefinition and Validation

Type Isomorphism (A ' B)Types A and B are iso. if there are proofs πA of B ` A and πB of A ` B, composingin both direction to identity.

Session Type Isomorphisms (A 'S B)Session types A and B are iso. if there are processes P and Q:I x :A ` P :: y :B and y :B ` Q :: x :A.

I x :A ` (νy)(P | Q) ≈ [x ↔ z] :: z:A.I y :B ` (νx)(Q | P) ≈ [y ↔ z] :: z:B.

Validating IsomorphismsIf A ' B then A 'S B.

Bernardo Toninho mrg.doc.ic.ac.uk 28/36

Page 110: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Type IsomorphismsDefinition and Validation

Type Isomorphism (A ' B)Types A and B are iso. if there are proofs πA of B ` A and πB of A ` B, composingin both direction to identity.

Session Type Isomorphisms (A 'S B)Session types A and B are iso. if there are processes P and Q:I x :A ` P :: y :B and y :B ` Q :: x :A.I x :A ` (νy)(P | Q) ≈ [x ↔ z] :: z:A.I y :B ` (νx)(Q | P) ≈ [y ↔ z] :: z:B.

Validating IsomorphismsIf A ' B then A 'S B.

Bernardo Toninho mrg.doc.ic.ac.uk 28/36

Page 111: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Type IsomorphismsDefinition and Validation

Type Isomorphism (A ' B)Types A and B are iso. if there are proofs πA of B ` A and πB of A ` B, composingin both direction to identity.

Session Type Isomorphisms (A 'S B)Session types A and B are iso. if there are processes P and Q:I x :A ` P :: y :B and y :B ` Q :: x :A.I x :A ` (νy)(P | Q) ≈ [x ↔ z] :: z:A.I y :B ` (νx)(Q | P) ≈ [y ↔ z] :: z:B.

Validating IsomorphismsIf A ' B then A 'S B.

Bernardo Toninho mrg.doc.ic.ac.uk 28/36

Page 112: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Summary

So far:I Explored a logical interpretation of session-based concurrencyI Explain concurrency theoretic concepts using logicI Map logical phenomena to concurrency theoryI Clean and elegant reasoning through logic.

Not in this talk:I AsynchronyI ParametricityI Inductive, Coinductive and Recursive Session Types.

Bernardo Toninho mrg.doc.ic.ac.uk 29/36

Page 113: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesMotivation and Basic Concepts

I Session types specify interaction between exactly two endpoints.I Cannot precisely capture protocols with more than two parties.

I Generalise to multiparty session types [Honda et al.08]:

I Global types specify a global choreography.I Local types specify the protocol for each participant.I Local types are generated mechanically from global types.I Duality is generalised to consistency to ensure deadlock-freedom.

Bernardo Toninho mrg.doc.ic.ac.uk 30/36

Page 114: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesMotivation and Basic Concepts

I Session types specify interaction between exactly two endpoints.I Cannot precisely capture protocols with more than two parties.I Generalise to multiparty session types [Honda et al.08]:

I Global types specify a global choreography.I Local types specify the protocol for each participant.

I Local types are generated mechanically from global types.I Duality is generalised to consistency to ensure deadlock-freedom.

Bernardo Toninho mrg.doc.ic.ac.uk 30/36

Page 115: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesMotivation and Basic Concepts

I Session types specify interaction between exactly two endpoints.I Cannot precisely capture protocols with more than two parties.I Generalise to multiparty session types [Honda et al.08]:

I Global types specify a global choreography.I Local types specify the protocol for each participant.I Local types are generated mechanically from global types.I Duality is generalised to consistency to ensure deadlock-freedom.

Bernardo Toninho mrg.doc.ic.ac.uk 30/36

Page 116: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesGlobal Types

Global Types

G ::= p→ q : (T ).G

| p→ q : {`j :Gj}j∈J

| µt .G | t| end

2-Buyer Protocol

G2B , B1→ S : (str).S→ B1 : (int).S→ B2 : (int).

B1→ B2 : (int).B2→ S : {ok : B2→ S : (str).endquit : end}

Bernardo Toninho mrg.doc.ic.ac.uk 31/36

Page 117: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesGlobal Types

Global Types

G ::= p→ q : (T ).G

| p→ q : {`j :Gj}j∈J

| µt .G | t| end

2-Buyer Protocol

G2B , B1→ S : (str).S→ B1 : (int).S→ B2 : (int).

B1→ B2 : (int).B2→ S : {ok : B2→ S : (str).endquit : end}

Bernardo Toninho mrg.doc.ic.ac.uk 31/36

Page 118: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesGlobal Types

Global Types

G ::= p→ q : (T ).G

| p→ q : {`j :Gj}j∈J

| µt .G | t| end

2-Buyer Protocol

G2B , B1→ S : (str).S→ B1 : (int).S→ B2 : (int).

B1→ B2 : (int).B2→ S : {ok : B2→ S : (str).endquit : end}

Bernardo Toninho mrg.doc.ic.ac.uk 31/36

Page 119: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesGlobal Types

Global Types

G ::= p→ q : (T ).G

| p→ q : {`j :Gj}j∈J

| µt .G | t| end

2-Buyer Protocol

G2B , B1→ S : (str).S→ B1 : (int).S→ B2 : (int).

B1→ B2 : (int).B2→ S : {ok : B2→ S : (str).endquit : end}

Bernardo Toninho mrg.doc.ic.ac.uk 31/36

Page 120: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesGlobal Types

Global Types

G ::= p→ q : (T ).G

| p→ q : {`j :Gj}j∈J

| µt .G | t| end

2-Buyer Protocol

G2B , B1→ S : (str).S→ B1 : (int).S→ B2 : (int).

B1→ B2 : (int).B2→ S : {ok : B2→ S : (str).endquit : end}

Bernardo Toninho mrg.doc.ic.ac.uk 31/36

Page 121: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesLocal Types and Projection

Local Types

S,T ::= p!(T ); S | p?(T ); S | ⊕ p{li :Ti}i∈I | N p{li :Ti}i∈I | end

Projection

s→ r:(T ).G′ � p =

r!(T ); (G′ � p) if p = ss?(T ); (G′ � p) if p = rG′ � p otherwise

s→ r:{lj :Gj}j∈J � p =

⊕ r{lj :Gj � p}j∈J if p = sN s{lj :Gj � p}j∈J if p = rG1 � p ∀i , j ∈ J.Gi � p = Gj � p

end � p = end

Bernardo Toninho mrg.doc.ic.ac.uk 32/36

Page 122: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesLocal Types and Projection

Local Types

S,T ::= p!(T ); S | p?(T ); S | ⊕ p{li :Ti}i∈I | N p{li :Ti}i∈I | end

Projection

s→ r:(T ).G′ � p =

r!(T ); (G′ � p) if p = ss?(T ); (G′ � p) if p = rG′ � p otherwise

s→ r:{lj :Gj}j∈J � p =

⊕ r{lj :Gj � p}j∈J if p = sN s{lj :Gj � p}j∈J if p = rG1 � p ∀i , j ∈ J.Gi � p = Gj � p

end � p = end

Bernardo Toninho mrg.doc.ic.ac.uk 32/36

Page 123: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesLocal Types and Projection

Local Types

S,T ::= p!(T ); S | p?(T ); S | ⊕ p{li :Ti}i∈I | N p{li :Ti}i∈I | end

Projection

s→ r:(T ).G′ � p =

r!(T ); (G′ � p) if p = ss?(T ); (G′ � p) if p = rG′ � p otherwise

s→ r:{lj :Gj}j∈J � p =

⊕ r{lj :Gj � p}j∈J if p = sN s{lj :Gj � p}j∈J if p = rG1 � p ∀i , j ∈ J.Gi � p = Gj � p

end � p = end

Bernardo Toninho mrg.doc.ic.ac.uk 32/36

Page 124: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesLocal Types and Projection

Local Types

S,T ::= p!(T ); S | p?(T ); S | ⊕ p{li :Ti}i∈I | N p{li :Ti}i∈I | end

Projection

s→ r:(T ).G′ � p =

r!(T ); (G′ � p) if p = ss?(T ); (G′ � p) if p = rG′ � p otherwise

s→ r:{lj :Gj}j∈J � p =

⊕ r{lj :Gj � p}j∈J if p = sN s{lj :Gj � p}j∈J if p = rG1 � p ∀i , j ∈ J.Gi � p = Gj � p

end � p = end

Bernardo Toninho mrg.doc.ic.ac.uk 32/36

Page 125: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesLocal Types and Projection

Local Types

S,T ::= p!(T ); S | p?(T ); S | ⊕ p{li :Ti}i∈I | N p{li :Ti}i∈I | end

Projection

s→ r:(T ).G′ � p =

r!(T ); (G′ � p) if p = ss?(T ); (G′ � p) if p = rG′ � p otherwise

s→ r:{lj :Gj}j∈J � p =

⊕ r{lj :Gj � p}j∈J if p = sN s{lj :Gj � p}j∈J if p = rG1 � p ∀i , j ∈ J.Gi � p = Gj � p

end � p = end

Bernardo Toninho mrg.doc.ic.ac.uk 32/36

Page 126: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesLocal Types and Projection

Local Types

S,T ::= p!(T ); S | p?(T ); S | ⊕ p{li :Ti}i∈I | N p{li :Ti}i∈I | end

Projection

s→ r:(T ).G′ � p =

r!(T ); (G′ � p) if p = ss?(T ); (G′ � p) if p = rG′ � p otherwise

s→ r:{lj :Gj}j∈J � p =

⊕ r{lj :Gj � p}j∈J if p = sN s{lj :Gj � p}j∈J if p = rG1 � p ∀i , j ∈ J.Gi � p = Gj � p

end � p = end

Bernardo Toninho mrg.doc.ic.ac.uk 32/36

Page 127: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesLocal Types and Projection

Local Types

S,T ::= p!(T ); S | p?(T ); S | ⊕ p{li :Ti}i∈I | N p{li :Ti}i∈I | end

Projection

s→ r:(T ).G′ � p =

r!(T ); (G′ � p) if p = ss?(T ); (G′ � p) if p = rG′ � p otherwise

s→ r:{lj :Gj}j∈J � p =

⊕ r{lj :Gj � p}j∈J if p = sN s{lj :Gj � p}j∈J if p = rG1 � p ∀i , j ∈ J.Gi � p = Gj � p

end � p = end

Bernardo Toninho mrg.doc.ic.ac.uk 32/36

Page 128: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesLocal Types and Projection

Local Types

S,T ::= p!(T ); S | p?(T ); S | ⊕ p{li :Ti}i∈I | N p{li :Ti}i∈I | end

Projection

s→ r:(T ).G′ � p =

r!(T ); (G′ � p) if p = ss?(T ); (G′ � p) if p = rG′ � p otherwise

s→ r:{lj :Gj}j∈J � p =

⊕ r{lj :Gj � p}j∈J if p = sN s{lj :Gj � p}j∈J if p = rG1 � p ∀i , j ∈ J.Gi � p = Gj � p

end � p = end

Bernardo Toninho mrg.doc.ic.ac.uk 32/36

Page 129: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesProjection and Properties

Projecting 2-Buyer Protocol

G2B , B1→ S : (str).S→ B1 : (int).S→ B2 : (int).

B1→ B2 : (int).B2→ S : {ok : B2→ S : (str).endquit : end}

TB1 , G2B � B1 = S!(str); S?(int); B2!(int); endTB2 , G2B � B2 = S?(int); B1?(int); ⊕ S{ok : S!(str); end,quit : end}TS , G2B � S = B1?(str); B1!(int); B2!(int); N B2{ok : B2?(str); end,quit : end}

Processes implementing a complete multiparty session projected from a globaltype are deadlock-free.

Bernardo Toninho mrg.doc.ic.ac.uk 33/36

Page 130: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesProjection and Properties

Projecting 2-Buyer Protocol

G2B , B1→ S : (str).S→ B1 : (int).S→ B2 : (int).

B1→ B2 : (int).B2→ S : {ok : B2→ S : (str).endquit : end}

TB1 , G2B � B1 = S!(str); S?(int); B2!(int); endTB2 , G2B � B2 = S?(int); B1?(int); ⊕ S{ok : S!(str); end,quit : end}TS , G2B � S = B1?(str); B1!(int); B2!(int); N B2{ok : B2?(str); end,quit : end}

Processes implementing a complete multiparty session projected from a globaltype are deadlock-free.

Bernardo Toninho mrg.doc.ic.ac.uk 33/36

Page 131: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesProjection and Properties

Projecting 2-Buyer Protocol

G2B , B1→ S : (str).S→ B1 : (int).S→ B2 : (int).

B1→ B2 : (int).B2→ S : {ok : B2→ S : (str).endquit : end}

TB1 , G2B � B1 = S!(str); S?(int); B2!(int); endTB2 , G2B � B2 = S?(int); B1?(int); ⊕ S{ok : S!(str); end,quit : end}TS , G2B � S = B1?(str); B1!(int); B2!(int); N B2{ok : B2?(str); end,quit : end}

Processes implementing a complete multiparty session projected from a globaltype are deadlock-free.

Bernardo Toninho mrg.doc.ic.ac.uk 33/36

Page 132: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesProjection and Properties

Projecting 2-Buyer Protocol

G2B , B1→ S : (str).S→ B1 : (int).S→ B2 : (int).

B1→ B2 : (int).B2→ S : {ok : B2→ S : (str).endquit : end}

TB1 , G2B � B1 = S!(str); S?(int); B2!(int); endTB2 , G2B � B2 = S?(int); B1?(int); ⊕ S{ok : S!(str); end,quit : end}TS , G2B � S = B1?(str); B1!(int); B2!(int); N B2{ok : B2?(str); end,quit : end}

Processes implementing a complete multiparty session projected from a globaltype are deadlock-free.

Bernardo Toninho mrg.doc.ic.ac.uk 33/36

Page 133: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesProjection and Properties

Projecting 2-Buyer Protocol

G2B , B1→ S : (str).S→ B1 : (int).S→ B2 : (int).

B1→ B2 : (int).B2→ S : {ok : B2→ S : (str).endquit : end}

TB1 , G2B � B1 = S!(str); S?(int); B2!(int); endTB2 , G2B � B2 = S?(int); B1?(int); ⊕ S{ok : S!(str); end,quit : end}TS , G2B � S = B1?(str); B1!(int); B2!(int); N B2{ok : B2?(str); end,quit : end}

Processes implementing a complete multiparty session projected from a globaltype are deadlock-free.

Bernardo Toninho mrg.doc.ic.ac.uk 33/36

Page 134: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesProjection and Properties

Projecting 2-Buyer Protocol

G2B , B1→ S : (str).S→ B1 : (int).S→ B2 : (int).

B1→ B2 : (int).B2→ S : {ok : B2→ S : (str).endquit : end}

TB1 , G2B � B1 = S!(str); S?(int); B2!(int); endTB2 , G2B � B2 = S?(int); B1?(int); ⊕ S{ok : S!(str); end,quit : end}TS , G2B � S = B1?(str); B1!(int); B2!(int); N B2{ok : B2?(str); end,quit : end}

Processes implementing a complete multiparty session projected from a globaltype are deadlock-free.

Bernardo Toninho mrg.doc.ic.ac.uk 33/36

Page 135: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesProjection and Properties

Projecting 2-Buyer Protocol

G2B , B1→ S : (str).S→ B1 : (int).S→ B2 : (int).

B1→ B2 : (int).B2→ S : {ok : B2→ S : (str).endquit : end}

TB1 , G2B � B1 = S!(str); S?(int); B2!(int); endTB2 , G2B � B2 = S?(int); B1?(int); ⊕ S{ok : S!(str); end,quit : end}TS , G2B � S = B1?(str); B1!(int); B2!(int); N B2{ok : B2?(str); end,quit : end}

Processes implementing a complete multiparty session projected from a globaltype are deadlock-free.

Bernardo Toninho mrg.doc.ic.ac.uk 33/36

Page 136: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Multiparty Session TypesProjection and Properties

Projecting 2-Buyer Protocol

G2B , B1→ S : (str).S→ B1 : (int).S→ B2 : (int).

B1→ B2 : (int).B2→ S : {ok : B2→ S : (str).endquit : end}

TB1 , G2B � B1 = S!(str); S?(int); B2!(int); endTB2 , G2B � B2 = S?(int); B1?(int); ⊕ S{ok : S!(str); end,quit : end}TS , G2B � S = B1?(str); B1!(int); B2!(int); N B2{ok : B2?(str); end,quit : end}

Processes implementing a complete multiparty session projected from a globaltype are deadlock-free.

Bernardo Toninho mrg.doc.ic.ac.uk 33/36

Page 137: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Conclusion

Summary:I Explored a logical interpretation of session-based concurrencyI Explain concurrency theoretic concepts using logic, and vice-versa.I Clean and elegant reasoning through logic.

Coming Up:I More on Multiparty Session Types.I Implementation and practical considerations.

Bernardo Toninho mrg.doc.ic.ac.uk 34/36

Page 138: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Thank you!Questions?

Bernardo Toninho mrg.doc.ic.ac.uk 35/36

Page 139: Session Types and Linear Logic and Lightweight ...mrg.doc.ic.ac.uk/talks/ucl-mar2017/talk.pdf · Introduction A Concurrency-Theoretic Approach: Session Types Structuring Communication

Session Types and Linear Logicand

Lightweight Applications of Session Types in Java

Bernardo Toninho and Raymond Hu

University College London,March 7, 2017

Bernardo Toninho mrg.doc.ic.ac.uk 36/36