Session Subtyping and Multiparty Compatibility using Circular - - PowerPoint PPT Presentation

session subtyping and multiparty compatibility using
SMART_READER_LITE
LIVE PREVIEW

Session Subtyping and Multiparty Compatibility using Circular - - PowerPoint PPT Presentation

Session Subtyping and Multiparty Compatibility using Circular Sequents 31st International Conference on Concurrency Theory (CONCUR 2020) Adapted for Mobility Reading group 22/10/2020. Ross Horne Computer Science, University of Luxembourg 1-4


slide-1
SLIDE 1

Session Subtyping and Multiparty Compatibility using Circular Sequents

31st International Conference on Concurrency Theory (CONCUR 2020) Adapted for Mobility Reading group 22/10/2020. Ross Horne

Computer Science, University of Luxembourg

1-4 September 2020

slide-2
SLIDE 2

Criticism 1: Deep Inference.

slide-3
SLIDE 3

Criticism 1: Deep Inference. “I must confess we were a little bit hampered by our lack of familiarity with the calculus of structures.”

slide-4
SLIDE 4

Criticism 1: Deep Inference. “I must confess we were a little bit hampered by our lack of familiarity with the calculus of structures.” The calculus of structures: Developed over the past 20 years. Enables the design of analytic proof systems for non-commutative

  • logics. It’s novelty is the use of deep inference

— rules can be applied in any context.

slide-5
SLIDE 5

Criticism 1: Deep Inference. “I must confess we were a little bit hampered by our lack of familiarity with the calculus of structures.” The calculus of structures: Developed over the past 20 years. Enables the design of analytic proof systems for non-commutative

  • logics. It’s novelty is the use of deep inference

— rules can be applied in any context. ⊢ C T ⊗ (U ` V) ⊢ C (T ⊗ U) ` V

slide-6
SLIDE 6

Criticism 1: Deep Inference. “I must confess we were a little bit hampered by our lack of familiarity with the calculus of structures.” The calculus of structures: Developed over the past 20 years. Enables the design of analytic proof systems for non-commutative

  • logics. It’s novelty is the use of deep inference

— rules can be applied in any context. ⊢ C T ⊗ (U ` V) ⊢ C (T ⊗ U) ` V The sequent calculus: The original analytic proof calculus of Gentzen. Published in 1934, so is widely understood. Rules are applied to the root connective of a formula selected from a sequence of formulae.

slide-7
SLIDE 7

Criticism 1: Deep Inference. “I must confess we were a little bit hampered by our lack of familiarity with the calculus of structures.” The calculus of structures: Developed over the past 20 years. Enables the design of analytic proof systems for non-commutative

  • logics. It’s novelty is the use of deep inference

— rules can be applied in any context. ⊢ C T ⊗ (U ` V) ⊢ C (T ⊗ U) ` V The sequent calculus: The original analytic proof calculus of Gentzen. Published in 1934, so is widely understood. Rules are applied to the root connective of a formula selected from a sequence of formulae. ⊢ T , U , Γ ⊢ T ` U , Γ ⊢ T , Γ ⊢ U , ∆ ⊢ T ⊗ U , Γ, ∆

slide-8
SLIDE 8

[Times]

T , U , Γ ⊢ T ⊗ U , Γ ⊢

[Par]

T , Γ1 ⊢ U , Γ2 ⊢ T ` U , Γ1 , Γ2 ⊢

[OK]

OK , OK , . . . OK ⊢

slide-9
SLIDE 9

[Times]

T , U , Γ ⊢ T ⊗ U , Γ ⊢

[Par]

T , Γ1 ⊢ U , Γ2 ⊢ T ` U , Γ1 , Γ2 ⊢

[OK]

OK , OK , . . . OK ⊢

[Join]

!λj;Tj , Γ ⊢ for all j ∈ I

  • i∈I

!λj;Ti , Γ ⊢

[Meet]

?λj;Tj , Γ ⊢ for some j ∈ I

  • i∈I

?λj;Ti , Γ ⊢

[Prefix]

T , U , Γ ⊢ !λ;T , ?λ;U , Γ ⊢

slide-10
SLIDE 10

[Times]

T , U , Γ ⊢ T ⊗ U , Γ ⊢

[Par]

T , Γ1 ⊢ U , Γ2 ⊢ T ` U , Γ1 , Γ2 ⊢

[OK]

OK , OK , . . . OK ⊢

[Join]

!λj;Tj , Γ ⊢ for all j ∈ I

  • i∈I

!λj;Ti , Γ ⊢

[Meet]

?λj;Tj , Γ ⊢ for some j ∈ I

  • i∈I

?λj;Ti , Γ ⊢

[Prefix]

T , U , Γ ⊢ !λ;T , ?λ;U , Γ ⊢

[Intr]

I ⊆ J Tk , Uk , Γ ⊢ for all k ∈ I

  • i∈I

!λi;Ti ,

  • j∈J

?λj;Uj , Γ ⊢

slide-11
SLIDE 11

Criticism 2: Session type systems should feature recursion.1

1Thanks to discussions with Mariangiola Dezani-Ciancaglini and Paola Giannini.

slide-12
SLIDE 12

Criticism 2: Session type systems should feature recursion.1 Observation 1: Most session calculi are restricted to a regular setting — a bounded number of single threaded participants.

1Thanks to discussions with Mariangiola Dezani-Ciancaglini and Paola Giannini.

slide-13
SLIDE 13

Criticism 2: Session type systems should feature recursion.1 Observation 1: Most session calculi are restricted to a regular setting — a bounded number of single threaded participants. Observation 2: In the regular setting, we can use equirecursion from type theory — fixed points are equivalent to their infinite unfoldings.

1Thanks to discussions with Mariangiola Dezani-Ciancaglini and Paola Giannini.

slide-14
SLIDE 14

Criticism 2: Session type systems should feature recursion.1 Observation 1: Most session calculi are restricted to a regular setting — a bounded number of single threaded participants. Observation 2: In the regular setting, we can use equirecursion from type theory — fixed points are equivalent to their infinite unfoldings. Observation 3: In proof theory, such regular recursive proofs are circular proofs.

1Thanks to discussions with Mariangiola Dezani-Ciancaglini and Paola Giannini.

slide-15
SLIDE 15

Criticism 2: Session type systems should feature recursion.1 Observation 1: Most session calculi are restricted to a regular setting — a bounded number of single threaded participants. Observation 2: In the regular setting, we can use equirecursion from type theory — fixed points are equivalent to their infinite unfoldings. Observation 3: In proof theory, such regular recursive proofs are circular proofs. Design choice: Apply an algorithmic approach to equirecursive subtyping, due to Pierce and Sangiorgi, to make proofs in the sequent calculus circular.

[Fix-µ]

[Θ ] [ µt.T , Γ] T µt.T/

t

  • , Γ ⊢

[Θ] µt.T , Γ ⊢

[Leaf]

[Θ ] [ Γ] Γ ⊢

1Thanks to discussions with Mariangiola Dezani-Ciancaglini and Paola Giannini.

slide-16
SLIDE 16

An Example

µu.(?λ1;u) ⊗ µv.(?λ2;v) ⊗ µt.(!λ1;t ∨ !λ2;t) ⊢ [Times] Abbreviations :

slide-17
SLIDE 17

An Example

U , V , T ⊢ [Fix-µ] µu.(?λ1;u) ⊗ µv.(?λ2;v) ⊗ µt.(!λ1;t ∨ !λ2;t) ⊢ [Times] Abbreviations : U = µu.(?λ1;u) V = µv.(?λ2;v) T = µt.(!λ1;t ∨ !λ2;t)

slide-18
SLIDE 18

An Example

[Γ] U , V , !λ1;T ∨ !λ2;T ⊢ [Join] U , V , T ⊢ [Fix-µ] µu.(?λ1;u) ⊗ µv.(?λ2;v) ⊗ µt.(!λ1;t ∨ !λ2;t) ⊢ [Times] Abbreviations : U = µu.(?λ1;u) V = µv.(?λ2;v) T = µt.(!λ1;t ∨ !λ2;t) Γ = U , V , T

slide-19
SLIDE 19

An Example

[Γ] U , V , !λ1;T ⊢ [Fix-µ] [Γ] U , V , !λ2;T ⊢ [Fix-µ] [Γ] U , V , !λ1;T ∨ !λ2;T ⊢ [Join] U , V , T ⊢ [Fix-µ] µu.(?λ1;u) ⊗ µv.(?λ2;v) ⊗ µt.(!λ1;t ∨ !λ2;t) ⊢ [Times] Abbreviations : U = µu.(?λ1;u) V = µv.(?λ2;v) T = µt.(!λ1;t ∨ !λ2;t) Γ = U , V , T

slide-20
SLIDE 20

An Example

[Γ′ ] [ Γ] ?λ1;U , V , !λ1;T ⊢ [Prefix] [Γ] U , V , !λ1;T ⊢ [Fix-µ] [Γ′′ ] [ Γ] U , ?λ2;V , !λ2;T ⊢ [Prefix] [Γ] U , V , !λ2;T ⊢ [Fix-µ] [Γ] U , V , !λ1;T ∨ !λ2;T ⊢ [Join] U , V , T ⊢ [Fix-µ] µu.(?λ1;u) ⊗ µv.(?λ2;v) ⊗ µt.(!λ1;t ∨ !λ2;t) ⊢ [Times] Abbreviations : U = µu.(?λ1;u) V = µv.(?λ2;v) T = µt.(!λ1;t ∨ !λ2;t) Γ = U , V , T Γ′ = U , V , !λ1;T Γ′′ = U , V , !λ2;T

slide-21
SLIDE 21

An Example

[Γ′ ] [ Γ] Γ ⊢ [Leaf] [Γ′ ] [ Γ] ?λ1;U , V , !λ1;T ⊢ [Prefix] [Γ] U , V , !λ1;T ⊢ [Fix-µ] [Γ′′ ] [ Γ] Γ ⊢ [Leaf] [Γ′′ ] [ Γ] U , ?λ2;V , !λ2;T ⊢ [Prefix] [Γ] U , V , !λ2;T ⊢ [Fix-µ] [Γ] U , V , !λ1;T ∨ !λ2;T ⊢ [Join] U , V , T ⊢ [Fix-µ] µu.(?λ1;u) ⊗ µv.(?λ2;v) ⊗ µt.(!λ1;t ∨ !λ2;t) ⊢ [Times] Abbreviations : U = µu.(?λ1;u) V = µv.(?λ2;v) T = µt.(!λ1;t ∨ !λ2;t) Γ = U , V , T Γ′ = U , V , !λ1;T Γ′′ = U , V , !λ2;T

slide-22
SLIDE 22

An Example

[Γ′ ] [ Γ] Γ ⊢ [Leaf] [Γ′ ] [ Γ] ?λ1;U , V , !λ1;T ⊢ [Prefix] [Γ] U , V , !λ1;T ⊢ [Fix-µ] [Γ′′ ] [ Γ] Γ ⊢ [Leaf] [Γ′′ ] [ Γ] U , ?λ2;V , !λ2;T ⊢ [Prefix] [Γ] U , V , !λ2;T ⊢ [Fix-µ] [Γ] U , V , !λ1;T ∨ !λ2;T ⊢ [Join] U , V , T ⊢ [Fix-µ] µu.(?λ1;u) ⊗ µv.(?λ2;v) ⊗ µt.(!λ1;t ∨ !λ2;t) ⊢ [Times] Abbreviations : U = µu.(?λ1;u) V = µv.(?λ2;v) T = µt.(!λ1;t ∨ !λ2;t) Γ = U , V , T Γ′ = U , V , !λ1;T Γ′′ = U , V , !λ2;T Multiparty Compatibility: Proves the following threads are multiparty compatible. µY.(?λ1;Y)

  • µZ.(?λ2;Z)
  • µX.(!λ1;X ⊕ !λ2;X)
slide-23
SLIDE 23

An Example

[Γ′ ] [ Γ] Γ ⊢ [Leaf] [Γ′ ] [ Γ] ?λ1;U , V , !λ1;T ⊢ [Prefix] [Γ] U , V , !λ1;T ⊢ [Fix-µ] [Γ′′ ] [ Γ] Γ ⊢ [Leaf] [Γ′′ ] [ Γ] U , ?λ2;V , !λ2;T ⊢ [Prefix] [Γ] U , V , !λ2;T ⊢ [Fix-µ] [Γ] U , V , !λ1;T ∨ !λ2;T ⊢ [Join] U , V , T ⊢ [Fix-µ] µu.(?λ1;u) ⊗ µv.(?λ2;v) ⊗ µt.(!λ1;t ∨ !λ2;t) ⊢ [Times] Abbreviations : U = µu.(?λ1;u) V = µv.(?λ2;v) T = µt.(!λ1;t ∨ !λ2;t) Γ = U , V , T Γ′ = U , V , !λ1;T Γ′′ = U , V , !λ2;T Multiparty Compatibility: Proves the following threads are multiparty compatible. µY.(?λ1;Y)

  • µZ.(?λ2;Z)
  • µX.(!λ1;X ⊕ !λ2;X)

Subtyping: Establishes the following subtype relation (U ⊗ V ≤ T iff U ⊗ V ⊗ T ⊢). µu.(?λ1;u)

µv.(?λ2;v) ≤ µt.(?λ1;t ∧ ?λ2;t)

slide-24
SLIDE 24

The Cut Elimination “Gold Mine” (again)

Theorem (cut elimination)

The rule

[Cut]

Γ1 , T ⊢ T , Γ2 ⊢ Γ1 , Γ2 ⊢ is admissible in Session.

slide-25
SLIDE 25

The Cut Elimination “Gold Mine” (again)

Theorem (cut elimination)

The rule

[Cut]

Γ1 , T ⊢ T , Γ2 ⊢ Γ1 , Γ2 ⊢ is admissible in Session.

Corollary (algorithmic subtyping)

Subtyping is a decidable preorder.

Theorem (algorithmic typing)

All instances of

[subsumption]

∆ ⊢ P : T T ≤ U ∆ ⊢ P : U can be pushed to the bottom of a type derivation.

Theorem (deadlock freedom)

Any race-free multiparty-compatible network satisfies deadlock freedom.

Corollary (substitution principle)

P can replace Q while preserving multiparty compatibility, whenever T ≤ U, where ⊢ P : T and ⊢ Q : U.

slide-26
SLIDE 26

Now I see! So, what cool things can you do?

slide-27
SLIDE 27

Owner: ?login page(app ID, scope); !deny ⊕ !authorise(name, password) Trusted App: !login page(app ID, scope); ?deny;!release + ?authorise(name, password);

  • recY. !release

⊕ !request(token); ?revoke + ?response(data);Y Resource:

  • recX. ?release

+ ?request(token); !revoke ⊕ !response(data);X

slide-28
SLIDE 28

Trusted App: !login page(app ID, scope); ?deny;!release + ?authorise(name, password); recY.!release ⊕ !request(token); ?revoke + ?response(data);Y

OAuth 2.0 Server: ?initiate(app ID, scope); !login page(app ID, scope); (?deny;!close;!release) + ?authorise(name, password); (!close;!release) ⊕ !authorisation code(code); ?exchange(app ID, secret, code); (!close;!release) ⊕ !access token(token) Untrusted App: !initiate(add ID, scope); ?close + ?authorisation code(code); !exchange(app ID, secret, code); ?close + ?access token(token);

  • recY. !request(token);

?revoke + ?response(data);Y

slide-29
SLIDE 29

Trusted App: !login page(app ID, scope); ?deny;!release + ?authorise(name, password); recY.!release ⊕ !request(token); ?revoke + ?response(data);Y

OAuth 2.0 Server: ?initiate(app ID, scope); !login page(app ID, scope); (?deny;!close;!release) + ?authorise(name, password); (!close;!release) ⊕ !authorisation code(code); ?exchange(app ID, secret, code); (!close;!release) ⊕ !access token(token) Untrusted App: !initiate(add ID, scope); ?close + ?authorisation code(code); !exchange(app ID, secret, code); ?close + ?access token(token);

  • recY. !request(token);

?revoke + ?response(data);Y

Untrusted App ⊗ OAuth Server ≤ Trusted App

slide-30
SLIDE 30

An application that delegates to an Oauth 2.0 server

Resource Untrusted App OAuth Server Owner

initiate(app ID,scope)

begin delegation login page(app ID, scope) authorize(name, password) end delegation authorisation code(code) exchange(app ID, secret, code) access token(token) request(token) response(data) recursion revoke choice at Resource

slide-31
SLIDE 31

Allowing the deputy to make a choice is useful

Resource Untrusted App OAuth Server Owner

initiate(app ID,scope)

begin delegation login page(app ID, scope) authorize(name, password) end delegation authorisation code(code) exchange(app ID, secret, code) access token(token) request(token) response(data) recursion revoke choice at Resource choice at Server no release choice at Server deny end delegation error release choice at Owner

slide-32
SLIDE 32

Internal delegation may liberate multiparty subtyping with roles.

Trusted App: Owner!login page(app ID, scope); ?deny;!release + Owner?authorise(name, password); recY.!release ⊕ Resource!request(token); ?revoke + Resource?response(data);Y

App?initiate(app ID, scope); App◦

  • ;

Owner!login page(app ID, scope); (?deny;•

  • App;!close;!release)

+ Owner?authorise(name, password);

  • App;

(!close;!release) ⊕ App!authorisation code(code); App?exchange(app ID, secret, code); (!close;!release) ⊕ App!access token(token) OAuth!initiate(add ID, scope);

  • OAuth; OAuth•
  • ;

?close + OAuth?authorisation code(code); OAuth!exchange(app ID, secret, code); ?close + OAuth?access token(token); recY.OAuth!request(token); ?revoke + Resource?response(data);Y

slide-33
SLIDE 33

Conclusion and discussion

Conclusion: Non-commutative logic + race-freedom provides us with rich notions of multiparty compatibility and subtyping.

slide-34
SLIDE 34

Conclusion and discussion

Conclusion: Non-commutative logic + race-freedom provides us with rich notions of multiparty compatibility and subtyping. Discussion: The follow has no global type, but is deadlock free and both “Kobayashi” and “Padovani” live (LIVE and LIVE+ respectively in POPL ’19). System Session verifies this (but only guarantees deadlock freedom without further modifications).

µX. (!λ1; X ⊕ !λ2) µY. (?λ1; Y + ?λ2) µX. (!λ3; X ⊕ !λ4) µY. (?λ3; Y + ?λ4)

slide-35
SLIDE 35

Conclusion and discussion

Conclusion: Non-commutative logic + race-freedom provides us with rich notions of multiparty compatibility and subtyping. Discussion: The follow has no global type, but is deadlock free and both “Kobayashi” and “Padovani” live (LIVE and LIVE+ respectively in POPL ’19). System Session verifies this (but only guarantees deadlock freedom without further modifications).

µX. (!λ1; X ⊕ !λ2) µY. (?λ1; Y + ?λ2) µX. (!λ3; X ⊕ !λ4) µY. (?λ3; Y + ?λ4)

Question for the Mobility Reading Group: What established extensions of global types allow the above to be typed and also guarantee livelock freedom (or, at least, deadlock freedom)?