Lectures onType Theory
Chapter 59
Chapter 59Optional

Multiparty and Asynchronous Session Types

Prerequisites. Direct starred prerequisites: Chapter 21. No later core chapter depends on this route.

Three pairwise-dual channels need not compose into one coherent conversation. For three channels directed BA, CB, and AC, consider PA=kBA?(x);kAC!v;0,PB=kCB?(y);kBA!v;0,PC=kAC?(z);kCB!v;0. Every channel has one sender and one receiver with the same payload type, yet the parallel composition has three leading inputs and no step. Multiparty session types begin from a global protocol and project one local view per participant. Asynchronous execution adds queues, so the proof must also relate messages already sent to actions not yet received.

This chapter uses Honda, Yoshida, and Carbone for the historical global/local architecture and its motivating obstruction [HYC16]. It does not use their flawed projection argument as the owner of subject reduction. That theorem belongs to the repaired, mechanized calculus of Tirore, Bengtson, and Carbone [TBC25].

The repaired asynchronous calculus

Let p,q,r range over roles, k over explicit queue addresses, and sp over a session located at role p. The load-bearing process forms are P,Q::=0PQ(νss~)Psp[k]!e;Psp[k]?(x);Psp[k];Psp[k]{i:Pi}iIs[k]::h~. A tilde denotes a finite sequence: s~ is the located session family bound with s, and h~ is one queue’s item sequence. A queue item is a value, delegated endpoint, or label annotated by its sender. A send appends to s[k]; the matching receive consumes only the head item whose sender is the expected role. Session initiation creates the finite family of queues declared by the requester. Definitions, conditionals, and structural congruence complete the process dynamics.

Closed, contractive global and local types are G::=pq:kU.Gpq:k{i:Gi}iI::=μt.Gtend,T::=!kU.T?kU.T::=k{i:Ti}iIk&{i:Ti}iI::=μt.Ttend. The paper’s restriction on recursion rejects every subexpression μt0.μt1μtn.t0. This prevents projection from manufacturing an unguarded local loop.

Definition 59.1 — Projection and projectability

Projection is a partial function Gr. For a value action its defining equations are pq:kU.Gp=!kU.Gp,pq:kU.Gq=?kU.Gq,pq:kU.Gr=Gr(r{p,q}). For a nonempty branch pq:k{i:Gi}iI, the sender and receiver receive the corresponding internal and external choices. If r{p,q}, the projection is defined only when there is one local type T such that (PlainBranch)iI.Gir=T;pq:k{i:Gi}iIr=T. Thus this calculus uses plain common projection, not a full merge that unions different offered-label sets. Recursion is projected homomorphically when the guardedness restriction above is satisfied. A global type is projectable when this partial calculation is defined for every role occurring in it.

Definition 59.2 — Input and output dependencies

An action a has participants from(a),to(a) and address ch(a). Write II(a,b):=[to(a)=to(b)],IO(a,b):=[to(a)=from(b)],OO(a,b):=[from(a)=from(b)ch(a)=ch(b)]. The brackets denote truth values.

The dependency judgments on a nonempty action word are generated by II(a0,a1)InDep(a0,a1)IBase IO(a0,a1)InDep(a1,,an)InDep(a0,a1,,an)IStep, IO(a0,a1)OO(a0,a1)OutDep(a0,a1)OBase IO(a0,a1)OO(a0,a1)OutDep(a1,,an)OutDep(a0,a1,,an)OStep. Let a0,a¯,a1 be a segment of any trace of G with ch(a0)=ch(a1). The type G is linear when some subsequence of a¯ makes InDep(a0,a¯,a1) derivable and some, possibly different, subsequence makes OutDep(a0,a¯,a1) derivable. Both dependencies are required.

The global and local labelled semantics are asynchronous. A later interaction may move beneath an earlier one when it does not involve the blocked receiver; a local action may move beneath an output on a different queue address. With these rules, full projection both simulates and reflects global transitions. The pinned Coq development names the directions harmony_sound and harmony_complete.

Definition 59.3 — Unstuckness and coherence

Write G1 when the paper’s relaxed barb relation exposes label ; beneath a branch, it suffices that one continuation can perform . The predicate unstuck(G) is coinductively generated by the exact condition .G1G.GGunstuck(G). A global type is coherent exactly when it is projectable, linear, and unstuck. A local environment is coherent when it is the full projection of such a global type. A local-environment/queue-specification pair is coherent when some path function decomposes a coherent projected environment into precisely that pair.

The three global clauses are independent. Without projectability, a role absent from a choice can be asked to guess its continuation. Without linearity, two senders can race to put differently typed values at the same address. For the paper’s counterexample pq:k1{1:qr:k2Bool.end,2:pr:k2Bool.end}, the relaxed barb sees the second branch’s p-to-r action, but the true global semantics cannot move that action because its rule requires the same labelled move in every branch. This is a failure of unstuckness, not a wrong-queue-head definition. Sender and label agreement at concrete queue heads instead follows from queue typing and the coherent decomposition. In the mechanization the ingredients are represented by projectable, LinearCo, and goodG; the process typing judgment is OFT.

Write ΓDPCΔ;Q for the paper’s typing judgment: shared assumptions Γ, definitions D, process P, session/channel environment Δ, and queue specification Q, under the explicit channel inventory C. The rules type each process prefix against the corresponding local action and type each concrete queue against Q. Parallel composition splits linear session obligations; restriction checks a whole coherent session rather than hiding unrelated endpoints.

For example, the value-output rule and the matching queue rule have the following local shape; the omitted shared premises are unchanged. Γe:UΓDPCΔ,sp:T;QΓDsp[k]!e;PCΔ,sp:!kU.T;QTSend Γv:UΓDs[k]::h~CΔ;QΓDs[k]::(h~p!v)CΔ;Q(k,p,U)TQueue. A send step uses T-Send on the process before the step and T-Queue on the appended sender-tagged item afterward. The session environment advances from !kU.T to T, which is the send case used in the preservation proof.

Theorem 59.4 — Repaired subject reduction

Suppose ΓDPCΔ;Q, the runtime specification is coherent as Δ0, and PDP. Then there exist Δ1,Δ,Q such that the reduct is typed as ΓDPCΔ;Q, its runtime specification is coherent as Δ1, and either Δ0=Δ1 or Δ0Δ1 for one global interaction . The paper also proves structural-congruence preservation and the specialization to empty linear environments.

Proof of Theorem 59.4 — Repaired subject reduction

Proof. Induct on the process reduction. Send, delegation, and selection transfer a typed item to the corresponding queue; receive, session receive, and branch use queue typing and environment decomposition to identify the head item and advance its local action. Initiation uses full projection and the projection theorem to create the local family and empty queues. Conditional and definition steps use expression preservation and substitution. Contextual steps rebuild restriction or parallel typing; structural congruence uses its separate invariance theorem. For a communication that completes a global interaction, projection harmony and the coherent global witness—including its coinductive unstuckness premise—produce Δ0Δ1; administrative and one-sided queue steps leave Δ0 unchanged. Linearity gives the dependency fact needed when two actions mention the same explicit queue address. ◻

This theorem is subject_reduction_final in the pinned Coq source; its empty-context specialization is subject_reduction_empty, and structural invariance is OFT_cong. The printed theorem, proof dependencies, and identifiers all belong to the ECOOP 2025 calculus.

Corollary 59.5 — Communication safety

A typed process with coherent queues is not a communication-error structure, and every reduct remains so.

Proof of Corollary 59.5 — Communication safety

Proof. The paper first proves syntactic exclusion of error structures, then applies Theorem 59.4 after each step. The corresponding Coq identifiers are Error_struct,OFT_not_error_struct,OFT_not_error_sem. ◻

Communication safety excludes a wrong value type, sender, or label at a receive. It does not establish progress, general deadlock freedom, freedom from orphan messages, fair delivery, multiparty compatibility, termination, or liveness. A coherent typing premise can also be destroyed by manually assembling endpoints or queues not obtained from one admitted global type.

Exercise 59.1

★★☆ Give three small global types, each violating exactly one of projectability, linearity, and unstuckness. For the last, use the two-branch type displayed above: exhibit its relaxed barb and show why no matching true global transition exists.

A complete three-party execution

Use four distinct addresses k1,k2,k3,k4 for Gsale=BS:k1Item.SK:k2Debit.KS:k4{ok:SB:k3{done:end},no:SB:k3{done:end}}. Its projections are TB=!k1Item.k3&{done:end},TS=?k1Item.!k2Debit.k4&{ok:k3{done:end},no:k3{done:end}},TK=?k2Debit.k4{ok:end,no:end}. Abbreviate successive residuals by B0,B1,B2, S0,,S4, and K0,K1,K2, with B0=TB, S0=TS, K0=TK, and each successor obtained by deleting the displayed outer action. In queue order (k1,k2,k4,k3), the accepting execution is the following fully annotated trace: action(B,S,K)(q1,q2,q4,q3)initial(B0,S0,K0)(ϵ,ϵ,ϵ,ϵ)B!k1item(B1,S0,K0)(itemB,ϵ,ϵ,ϵ)S?k1item(B1,S1,K0)(ϵ,ϵ,ϵ,ϵ)S!k2debit(B1,S2,K0)(ϵ,debitS,ϵ,ϵ)K?k2debit(B1,S2,K1)(ϵ,ϵ,ϵ,ϵ)Kk4ok(B1,S2,K2)(ϵ,ϵ,okK,ϵ)S&k4ok(B1,S3,K2)(ϵ,ϵ,ϵ,ϵ)Sk3done(B1,S4,K2)(ϵ,ϵ,ϵ,doneS)B&k3done(B2,S4,K2)(ϵ,ϵ,ϵ,ϵ) Each row names the transition and advances exactly one residual type. A send appends a sender-tagged item; a receive checks and removes the head. The refusal branch has the same shape with no at k4. Every address is used by exactly one global action, so the same-address premise in definition 59.2 never arises and linearity holds vacuously. At the outer branch, both continuations project at B to the same k3&{done:end}. Equation (Plain-Branch) therefore proves projectability without importing a full-merge operator. The protocol deliberately does not tell B which bank branch was taken.

Exercise 59.2

★★☆ Extend both continuations of Gsale so that, after the done notification, B sends a receipt address to K. Give the three projections and insert both asynchronous queue steps in the displayed trace. Explain why extending only the ok continuation would violate (Plain-Branch) at B.

From protocols to choreographic programs

Pirouette changes the object of study from an asynchronous global protocol to a typed, executable choreography [HG21]. Its local language is a parameter, not silently assumed to be the lambda calculus. The interface requires decidable equality of locations; expressions with capture-avoiding substitution and its equations; a closed class of values that do not step; unique typing with variables, Booleans, exchange, weakening, strengthening, and substitution; and, for relative soundness, Boolean inversion, local preservation, and local progress.

Definition 59.6 — Pirouette choreography

Let p,q range over locations, e over local expressions, d over synchronization labels, and X over choreography variables. The load-bearing grammar is C::=retp(e)Xpeq;Cifp(e){C1}{C2}pdq;Cletlocalp(C1;C2)funlocalp(C)funglobal(C)applocalp(C,e)appglobal(C1,C2). A communication binds the received value as the newest local variable at q. A local function binds a local variable at its named location. A global function binds one choreography variable. Applying a global function performs a synchronization before capture-avoiding substitution of its choreography argument.

For three distinct locations A,B,C, set F:=funglobal(AitemB;X),V:=BdoneC;retC(0). The higher-order call has the complete principal calculation appglobal(F,V)GlobalAppAitemB;BdoneC;retC(0). The step substitutes V for X; the leading synchronization prevents one endpoint from entering the substituted choreography before the others have finished evaluating the global function and argument.

A choreography’s small-step semantics carries a block set: a location whose pending action is blocked cannot be used by an out-of-order step, while independent locations may compute or communicate past it. Communication is synchronous. A higher-order call performs a global synchronization before entering its body; that barrier is operational, not merely an EPP artifact.

The branch-knowledge obstruction is already visible in Cbranch:=ifA(b){AokB;B1C;retC(1)}{AnoB;B0C;retC(0)}. Projection gives B an offer from A before its branch-specific send. A hand-written endpoint that sends 1 immediately omits that offer. If the two selections are deleted from the choreography, projection at B must merge a send of 1 with a send of 0, and the partial merge is undefined. This is the deliberately faulty endpoint collection used by the executable comparison.

Theorem 59.7 — Pirouette relative type soundness

If the parameter local language has local preservation, choreography typing is preserved by a choreography step. If it additionally has Boolean inversion and local progress, every closed well-typed choreography is a value or can take a choreography step. Hence a sound local type system induces the relative soundness corollary.

Proof of Theorem 59.7 — Pirouette relative type soundness

Proof. For preservation, induct on the choreography step. Local computation uses local preservation; communication uses the local substitution law and the typing substitution lemma; selection preserves the chosen continuation; an out-of-order step rebuilds the surrounding construct because its block-set side condition keeps the active locations independent. For progress, inspect the leading construct. Local progress advances a nonvalue expression, Boolean inversion chooses a conditional branch, and closedness rules out a free procedure variable. The communication and selection forms synchronize when their local data are values. ◻

The source proves the preservation and progress clauses separately before combining them into relative type soundness [HG21].

Endpoint projection maps a choreography to one control program per nonempty finite set L of locations. A participant not deciding a branch projects the alternatives with a partial merge; merge retains their common behavior and combines compatible offers. Incompatible hand-written endpoints such as two observers expecting different unannounced branches have no common merge and are rejected. Write [[C]]L when every required endpoint merge is defined, [[C]]L for undefinedness, and nd for the report’s preorder that permits extra local nondeterminism. For a choreography C, write FCV(C) for its free choreography variables and FLVp(C) for the free local expression variables at location p, with the binders in definition 59.6 removing the variables they bind. Define PirExprClosed(C)FCV(C)=  p.FLVp(C)=. In the choreography typing judgment Γ;ΔC:τ, Γ assigns types to local expression variables at each location and Δ assigns types to choreography variables. Thus ;C:τ is the closed instance of that judgment; the separate predicate above records syntactic closedness, which endpoint projection preserves across reduction.

Theorem 59.8 — Pirouette projection card

For the technical-report calculus:

  1. Local completeness is a disjunction. A choreography step either induces the corresponding local control step at , or [[R]] and [[C2]]nd[[C1]]. Global completeness additionally assumes every location named in the step result R belongs to L, and retains its nd conclusion.

  2. Local soundness lowers the projected communication, selection, local, and synchronization cases. The synchronization case already assumes LN(C1)LandL. Global soundness uses the same coverage premise. If the projected system takes a step to Π, it produces C2,R with [[C2]]L, [[C2]]LndΠ, [[R]]=L, and C1C2. No additional endpoint-equivalence conclusion is asserted.

  3. Assume choreography typing has progress and preservation, L, LN(C)L, and PirExprClosed(C), with ;C:τ. If EPPL(C) has reached Π, then either every location in Π contains a value or Π takes a system step.

Proof of Theorem 59.8 — Pirouette projection card

Imported proof. The technical report proves local completeness and global completeness by induction on the choreography step, and proves soundness by induction on the projected-system step. Its deadlock-freedom argument combines that soundness simulation with choreography progress and preservation. The third clause retains all three boundary premises of the last Coq theorem: the location list is nonempty, every location in C occurs in that list, and PirExprClosed(C) holds. The result is deadlock freedom for systems reached from well-typed projection. It is not asynchronous queue liveness, arbitrary endpoint equivalence, failure recovery, or correctness of a network runtime. The exact theorem signatures and their substantial inductive proof development are imported from Hirsch and Garg’s endpoint projection metatheory [HG21]. ◻

Exercise 59.3

★★★ Write a three-location choreography in which one location chooses a Boolean branch and informs a second by selection. In both branches the informed location sends branch-specific data to a third location. Project all three endpoints. Then delete the selection and show exactly which merge is undefined at the sender.

Remark 59.9

The repaired MPST calculus connects one admitted global type to asynchronous local states and queues, proving subject reduction and communication safety under projectability, linearity, and unstuck coherence. Pirouette separately connects a synchronous choreographic program to projected control programs, relative to explicit local-language hypotheses. Both begin globally and end locally; their syntax, dynamics, and theorem conclusions remain distinct.

Chapter seminar

The Kappa corpus at artifacts/ch59-mpst-choreography/ represents the sale protocol as a finite global AST, projects all three roles, and replays its sender-tagged FIFO transitions. A separate choreography AST projects control programs, regenerates them after a source change, and rejects missing branch knowledge. These are executable finite models of the two worked examples, not mechanizations of either theorem card or executions of the pinned Coq developments.

Suggested first pass.

Do exercise 59.4, exercise 59.5 before exercise 59.7.

Exercise 59.4

★★☆ Derive all three projections of Gsale from the projection equations. At the outer bank choice, show the exact equality needed by Plain-Branch. Explain separately why linearity is vacuous rather than claiming that projectability establishes it.

Exercise 59.5

★★☆ For the accepting trace in section 59.2, prove by induction over its eight actions that each queue contains either no item or the unique sender-tagged item prescribed by the current outer local action. Identify the induction step that would fail if k2=k4.

Exercise 59.6

★★☆ Compare the MPST subject-reduction card with Pirouette global soundness. Name one premise and one conclusion that occur only on each side; then explain why neither theorem implies the other.

Exercise 59.7

★★★ Practical project.mpst-choreography-audit Run the corpus. Change one branch-specific value in the choreography and regenerate all endpoints. Then change only the corresponding hand-written sender endpoint and explain why comparison with the regenerated projection fails. Finally delete the informing selection and identify the undefined merge.

Search the book

Type to search the local edition.