CCS Concepts: • Theory of computation → Verification by model checking; Probabilistic computation; Process calculi ; Type theory.
Additional Key Words and Phrases: multiparty session types, probabilistic processes, probabilistic model checking, type systems, safety, probabilistic deadlock-freedom and liveness.
ACM Reference Format:
Aleksander Junge, Leo Seojun Lee, Joseph Paulus, Nobuko Yoshida, and David Parker. 2026. Model Checking Probabilistic Multiparty Session Types. 1, 1 (November 2026), 108 pages. https://doi.org/10.1145/nnnnnnn.nnnnnnn
Introduction
Probabilistic model checking. Concurrent components have been deployed in many computing systems, from multicore architectures to web services to autonomous systems. Ensuring their safe and reliable execution is an essential requirement for the design and specification of system components, but it creates additional demand for verification, as components operate in uncertain environments. Probabilistic model checking [5 , 6 ] aims to automatically check whether components that exhibit uncertain (probabilistic) and nondeterministic behaviours satisfy given requirements,
Authors’ Contact Information: Aleksander Junge, aleksander.junge@cs.ox.ac.uk; Leo Seojun Lee, leo@leol.ee, University of Oxford, Oxford, UK; Joseph Paulus, joe.paulus@cs.ox.ac.uk; Nobuko Yoshida, nobuko.yoshida@cs.ox.ac.uk; David Parker, david.parker@cs.ox.ac.uk, University of Oxford, Oxford, UK.
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from permissions@acm.org.
© 2026 Copyright held by the owner/author(s). Publication rights licensed to ACM.
ACM XXXX-XXXX/2026/11-ART
https://doi.org/10.1145/nnnnnnn.nnnnnnn
, Vol. 1, No. 1, Article . Publication date: November 2026. usually specified by probabilistic extensions of temporal logics. Probability is used to quantify environmental uncertainty or randomisation, nondeterminism to represent decisions or concurrency.
Over the last two decades, probabilistic model checking tools (e.g., [3 , 25 , 26 , 37 ] ) have been actively developed and used for quantitative verification in a broad spectrum of application domains [38 ] .
Our aim is to lay the first groundwork connecting probabilistic multiparty session types to probabilistic model checking, so that session-typed systems benefit directly from advances in model checking techniques. Through a precise behavioural correspondence between probabilistic session types and a model checker’s input language, we analyse a spectrum of probabilistic properties of multiparty sessions, developing a static typing system that yields sound bounds on the probability of “good” behaviour — such as deadlock-freedom and liveness.
Multiparty Session Types (MPST) [30 , 31 ] are an extension of binary session types [29 , 55 ] , facilitating specification and verification of complex many-party interacting components. Historically, the MPST theory has been developed based on the top-down approach where the chief system architect first writes a multiparty protocol (called a global type ) between participants. This protocol is projected to a set of end-point (local ) types against which conformance of each component (participant) is checked. A collection of typed components then automatically satisfies qualitative properties such as type-safety, deadlock-freedom and liveness [65 ] .
More recently, Scalas and Yoshida [52 ] proposed generalised multiparty session types that do not require global types, but can enforce a desired property φ \varphi φ by directly checking that a set of local types satisfies φ \varphi φ . The bottom-up approach types a strictly larger set of processes: protocols beyond the reach of any global type — with asymmetric or emergent interaction structures that projection cannot express — as well as type-safe processes that may deadlock, run forever, or fail to progress. This “partial” nature is a natural fit with probabilistic model checking: rather than demanding the outright absence of deadlock or non-termination, tools such as PRISM and Storm quantify such behaviours — e.g., computing the probability of reaching a deadlock or of termination [3 , 28 ] .
Overview
We give an overview of the workflow in Figure 1 and explain each step below.
Figure 1. Overview of the probabilistic property verification procedure. In (a), given T i T_i T i and P i P_i P i (i ∈ { 1.. n } i \in\{1..n\} i ∈ { 1.. n } ) (1a) infer local type T i ′ T'_i T i ′ from process P i P_i P i ; (1b) check T i ′ ≤ T i T'_i \leq T_i T i ′ ≤ T i ; (2) translate T i T_i T i to PRISM and (3) model check whether { T i } i ∈ I \{T_i\}_{i \in I} { T i } i ∈ I satisfy the desired probabilistic property P \mathbb{P} P . In (b), directly verify the inferred types.
Step (1): Type checking. Following the bottom-up approach [52 ] , the first stage of our framework abstracts each process as a finite probabilistic session type T T T . This abstraction is necessary: communication safety of untyped session processes is undecidable, as we prove by encoding two-counter Minsky machines into sessions (Prop. 2.3). After inferring local types our toolchain supports two modes; either model check the types directly (Figure 1 b), or type check them against a type specification via subtyping before model checking (Figure 1 a).
Figure 2 shows a session (bottom-left) in which a worker u u u drives a counter held by s s s up or down, switching mode depending on its state. Following [20 ] , our calculus distinguishes data-dependent conditionals (if) from probabilistic choices (flip). Switching down fails with probability 0.1 0.1 0.1 , resulting in a deadlock, while switching up terminates successfully with probability 0.2 0.2 0.2 .
Figure 2. An infinite-state session (left; one column per counter value) and its finite typing context Δ i \Delta_i Δ i (right). The data-dependent decision by if becomes a nondeterministic choice over its two alternatives, while the probabilities of flip are preserved as edge annotations. Processes are shown bottom-left and their local types bottom-right. “μ \mu μ ” denotes recursion, ! / ? !/? ! / ? output/input, and ⊕ / & \oplus/\& ⊕ /& internal/external choice (see § 3 and § 4 ).
The unbounded counter gives rise to an infinite state space (left, with one column per counter value), preventing direct finite-state model checking. We instead infer local types that soundly over-approximate communication behaviour, following existing approaches that model check behavioural types as abstractions of processes [52 ] and programs [7 , 41 , 53 ] .
Typing replaces data-dependent conditionals with nondeterministic choices, accounting for the possible outcomes of tests whose values the types do not track, while retaining probability information from flips. In Figure 2 , this removes the need to track the unbounded counter: the types describe a finite model of the communication modes instead.
The resulting model is a finite Markov decision process (MDP), combining probabilistic choices with nondeterminism arising from both abstracted data and participant scheduling. We analyse it under the least favourable (adversarial) resolutions of nondeterminism, subject to our fairness assumptions. This accounts for the information lost through abstraction and yields sound lower bounds on the probabilities of properties of the original session. Type checking is decidable (Thm. 3.14), and the finite abstraction enables probabilistic model checking. For instance, this analysis establishes that the session in Figure 2 is deadlock-free with probability at least 9 / 14 ≈ 0.64 9/14 \approx0.64 9/14 ≈ 0.64 under every fair scheduler.
Step (2): Precise translation from session types into PRISM. To verify type-level properties automatically, we employ the PRISM [37 ] probabilistic model checker, a well-established tool which has been used to study a diverse range of applications [38 ] . Other popular probabilistic model checkers such as Storm [58 ] and the Modest Toolset [25 ] also support the PRISM language as input (the latter by converting first into the JANI [11 ] format).
To fill a gap between types and models, we encode session types into the PRISM modelling language and prove a precise (sound and complete) behavioural correspondence. Building on earlier approaches to model checking behavioural types [7 , 41 , 52 , 53 ] , we verify the translation itself by developing new bisimulation and operational correspondence relations for the PRISM semantics, precisely relating type-level behaviours to those of the generated models.
Step (3): Probabilistic property analysis and model checking. As the final step, we express the properties of typing contexts (§ 5.3 ) as specifications in Probabilistic Linear Temporal Logic (PLTL) and run PRISM to verify them. For deadlock-freedom and liveness this establishes lower bounds (§ 5.3 ), while for safety we get a yes/no answer.
There are two main challenges, both rooted in the nondeterminism of the type-level MDP. First, the probability of a set of paths is well-defined only relative to a scheduler : both the resolution of the abstracted data-dependent choices and the scheduling of parallel roles can change the probability of satisfying a given property. We define the probability of a set of paths under a fixed scheduler by standard means, using cylinder sets (Def. 4.7 ), and obtain lower bounds by taking the minimum over all fair schedulers (Def. 4.6 ); these minima then transfer to well-typed sessions (Theorems 4.26 and 4.27 ). The second challenge is that probabilistic deadlock-freedom and probabilistic liveness are quantified over fair schedulers only, while model checkers impose fairness on all nondeterministic choices uniformly—including the internal nondeterminism, which must remain unconstrained. We therefore characterise probabilistic deadlock-freedom as a safety property over finite paths that PRISM checks without any fairness constraint. Characterising liveness in this manner is more challenging: to do this, we introduce the notion of a weak almost-sure livelocked region , and prove that the maximum probability of reaching this region corresponds exactly to the minimum probability that the typing context is live (Theorem 6.5 ).
Contributions and Outline. To the best of our knowledge, this work is the first to propose a probabilistic extension of generalised (bottom-up) multiparty session types, to prove that a typing context yields sound lower bounds of probabilistic properties of typed session processes, and to translate session types into a probabilistic modelling language with proofs of soundness and completeness with respect to operational semantics. § 3 proposes a probabilistic multiparty session calculus (PROMT) as a conservative extension of synchronous multiparty session processes in [22 ] , with a single probabilistic construct flip(p){H ⇒ P | T ⇒ Q}, and proves that safety of sessions is undecidable (Proposition 2.3). § 4 proposes a probabilistic multiparty session typing system , introducing probabilistic subtyping (Def. 3.2 ), which widens data-dependent choices into nondeterministic sums, and the probabilistic merging operator (Def. 3.8 ), which reconciles the two outcomes of a flip. We further demonstrate that type checking is decidable (Theorem 3.14). § 5 proves subject reduction (type safety) (Theorem 4.1) and session fidelity (Theorem 4.4 ), interprets typing context reductions as finite MDPs with path probabilities relative to schedulers (Def. 4.6 ), and proves the main results: a typing context induces lower bounds on the probabilities of deadlock-freedom (Theorem 4.26 ) and liveness (Theorem 4.27 ) of the sessions it types, with their non-probabilistic counterparts as special cases. § 6 proposes a translation from session types to the PRISM language and proves sound and complete operational correspondence (Theorems 5.6 and 5.7). § 7 expresses safety, deadlock-freedom and liveness as PLTL specifications, reducing liveness to reachability of weak almost-sure livelocks (Theorem 6.5 ), benchmarks our toolchain ProSE on case studies from the PRISM homepage and related literature, and outlines a prototype implementation of steps (1a) and (1b) of Figure 1 . § 8 concludes with related work. Detailed proofs and additional examples are given in the appendices. Our artifact is explained in § 9 and available in [35 ] .
Probabilistic Multiparty Processes and Sessions
This section introduces the syntax and semantics of a probabilistic multiparty session calculus (PROMT-calculus). Since our focus is probabilistic verification , we base our calculus on the simplest multiparty session calculus [22 ] extended with a branching construct (external choice) which receives a message from different participants [51 ] and add a single new construct, flip ( p ) { H ⇒ P [ ] T ⇒ Q } \operatorname{flip}(p)\{\mathrm{H}\Rightarrow P \mathbin{[]} \mathrm{T}\Rightarrow Q\} flip ( p ) { H ⇒ P [ ] T ⇒ Q } .
Probability and nondeterminism. The calculus separates two sources of branching behaviour. Probability is introduced operationally by flip ( p ) { H ⇒ P [ ] T ⇒ Q } \operatorname{flip}(p)\{\mathrm{H}\Rightarrow P \mathbin{[]} \mathrm{T}\Rightarrow Q\} flip ( p ) { H ⇒ P [ ] T ⇒ Q } , whose two continuations are taken with complementary probabilities p p p and 1 − p 1-p 1 − p ; the reduction relation tracks these as explicit weights. Nondeterminism arises at the process level from the scheduling of parallel roles. The typed account of how nondeterminism is abstracted is deferred to § 4 .
Expressions ( e , e ′ , … ) (e,e',\ldots) ( e , e ′ , … ) are variables ( x , y , z , … ) (x,y,z,\ldots) ( x , y , z , … ) , a value v v v , which is either a natural number n n n , an integer i i i , or a Boolean true/false, or expressions built by applying operators such as neg, ¬ \neg ¬ and +.
e : : = t r u e ∣ f a l s e ∣ n ∣ i ∣ x ∣ e ∨ e ∣ ¬ e ∣ e + e ∣ succ ( e ) ∣ neg ( e ) ∣ e > e e ::= \mathrm{true}\mid\mathrm{false}\mid n\mid i\mid x\mid e\lor e\mid\neg e\mid e+e\mid\operatorname{succ}(e)\mid\operatorname{neg}(e)\mid e>e e ::= true ∣ false ∣ n ∣ i ∣ x ∣ e ∨ e ∣ ¬ e ∣ e + e ∣ succ ( e ) ∣ neg ( e ) ∣ e > e
Processes ( P , Q , R , … ) (P,Q,R,\ldots) ( P , Q , R , … ) and multiparty sessions ( M , M ′ , … ) (M,M',\ldots) ( M , M ′ , … ) are defined by the following syntax:
P , Q : : = 0 ∣ p ! ℓ ⟨ e ⟩ . P ∣ ∑ i ∈ I p i ? ℓ i ( x i ) . P i ∣ i f e t h e n P e l s e Q ∣ (nil, selection, branching, conditional) : : = flip ( p ) { H ⇒ P [ ] T ⇒ Q } ∣ μ X . P ∣ X (flip, recursion, proc variable) M , M ′ : : = p ◃ P ∣ M ∣ M ′ ∣ e r r o r (role, parallel composition, error) \begin{aligned}
P,Q &::= 0\mid p!\ell\langle e\rangle.P\mid\sum_{i\in I}p_i?\ell_i(x_i).P_i\mid\mathrm{if}\ e\ \mathrm{then}\ P\ \mathrm{else}\ Q \mid\quad&&\text{(nil, selection, branching, conditional)}\\
&\phantom{::=}\operatorname{flip}(p)\{\mathrm{H}\Rightarrow P\mathbin{[]}\mathrm{T}\Rightarrow Q\}\mid\mu X.P\mid X &&\text{(flip, recursion, proc variable)}\\
M,M'&::=p\triangleleft P\mid M\mid M'\mid\mathrm{error} &&\text{(role, parallel composition, error)}
\end{aligned} P , Q M , M ′ ::= 0 ∣ p ! ℓ ⟨ e ⟩ . P ∣ i ∈ I ∑ p i ? ℓ i ( x i ) . P i ∣ if e then P else Q ∣ ::= flip ( p ) { H ⇒ P [ ] T ⇒ Q } ∣ μ X . P ∣ X ::= p ◃ P ∣ M ∣ M ′ ∣ error (nil, selection, branching, conditional) (flip, recursion, proc variable) (role, parallel composition, error)
p , q , r , s , … p,q,r,s,\ldots p , q , r , s , … are participants (roles) from a countably infinite set. The nil 0 0 0 denotes termination; process p ! ℓ ⟨ e ⟩ . P p!\ell\langle e\rangle.P p ! ℓ ⟨ e ⟩ . P denotes the selection of label ℓ \ell ℓ and expression e e e communicating with participant p p p and continuing with behaviour P P P . Process ∑ i ∈ I p i ? ℓ i ( x i ) . P i \sum_{i\in I}p_i?\ell_i(x_i).P_i ∑ i ∈ I p i ? ℓ i ( x i ) . P i is branching (external choice) : for any i ∈ I ≠ ∅ i\in I\ne\varnothing i ∈ I = ∅ it can accept label ℓ i \ell_i ℓ i with a value bound to x i x_i x i from participant p i p_i p i , continuing as P i P_i P i . The sender p i p_i p i may vary across branches, allowing a single external choice to await messages from different participants. This follows the external choice in [50 , 51 ] , which can represent protocols in which a server accepts client updates in arbitrary order, as in session-typed models of federated learning. On the sending side, as p ! ℓ ⟨ e ⟩ . P p!\ell\langle e\rangle.P p ! ℓ ⟨ e ⟩ . P names its own target p p p , a role may also direct the branches of a flip or if statement to different participants. We often write p ? ℓ ( x ) . P p?\ell(x).P p ? ℓ ( x ) . P for a singleton branching, expand it as, e.g., p 1 ? ℓ 1 ( x 1 ) . P 1 + p 2 ? ℓ 2 ( x 2 ) . P 2 p_1?\ell_1(x_1).P_1+p_2?\ell_2(x_2).P_2 p 1 ? ℓ 1 ( x 1 ) . P 1 + p 2 ? ℓ 2 ( x 2 ) . P 2 , and omit the payloads, e.g., p 1 ? ℓ 1 . P 1 + p 2 ? ℓ 2 . P 2 p_1?\ell_1.P_1+p_2?\ell_2.P_2 p 1 ? ℓ 1 . P 1 + p 2 ? ℓ 2 . P 2 , when they are not needed. Conditional processes if e e e then P P P else Q Q Q and recursive processes μ X . P \mu X.P μ X . P are standard. We assume recursive processes are guarded , i.e., every recursive variable occurs under a prefix containing at least one input or output. Thus e.g. μ X . X \mu X.X μ X . X and μ X . i f e t h e n X e l s e Q \mu X.\mathrm{if}\ e\ \mathrm{then}\ X\ \mathrm{else}\ Q μ X . if e then X else Q are not valid, whereas μ X . p ! ℓ ⟨ e ⟩ . X \mu X.p!\ell\langle e\rangle.X μ X . p ! ℓ ⟨ e ⟩ . X is. We let p , p ′ , p ′ ′ p,p',p'' p , p ′ , p ′′ range over probabilities and introduce the flip construct flip ( p ) { H ⇒ P [ ] T ⇒ Q } \operatorname{flip}(p)\{\mathrm{H}\Rightarrow P\mathbin{[]}\mathrm{T}\Rightarrow Q\} flip ( p ) { H ⇒ P [ ] T ⇒ Q } which continues as P P P on heads and Q Q Q on tails; we syntactically constrain p ∈ ( 0 , 1 ) p\in(0,1) p ∈ ( 0 , 1 ) to the open unit interval, so that neither outcome of a flip is excluded.
Process P P P plays the participant p p p (denoted p ◃ P p\triangleleft P p ◃ P ) and can interact with other roles through parallel composition ∣ \mid ∣ , which we assume to be commutative and associative; we write ∏ i ∈ I p i ◃ P i \prod_{i\in I}p_i\triangleleft P_i ∏ i ∈ I p i ◃ P i for p 1 ◃ P 1 ∣ ⋯ ∣ p n ◃ P n p_1\triangleleft P_1\mid\cdots\mid p_n\triangleleft P_n p 1 ◃ P 1 ∣ ⋯ ∣ p n ◃ P n with I = { 1 , … , n } I=\{1,\ldots,n\} I = { 1 , … , n } . error denotes an error session.
Example 2.1 (Calculator service). A user u u u submits integers to a server s s s , which forwards the request to a calculator c c c ; the calculator may (depending on the size of the integer) occasionally produce an error. The three roles realise the session M = u ◃ P u ∣ s ◃ P s ∣ c ◃ P c M=u\triangleleft P_u\mid s\triangleleft P_s\mid c\triangleleft P_c M = u ◃ P u ∣ s ◃ P s ∣ c ◃ P c where P s , P c , P u P_s,P_c,P_u P s , P c , P u …
p ◃ flip ( p ) { H ⇒ P [ ] T ⇒ Q } ∣ M ⟶ p p ◃ P ∣ M p \mathrel{\triangleleft} \operatorname{flip}(p)\{\mathrm{H}\Rightarrow P \mathbin{[]}\mathrm{T}\Rightarrow Q\}\mid M \mathrel{\longrightarrow_{p}} p \mathrel{\triangleleft} P\mid M p ◃ flip ( p ) { H ⇒ P [ ] T ⇒ Q } ∣ M ⟶ p p ◃ P ∣ M
p ◃ flip ( p ) { H ⇒ P [ ] T ⇒ Q } ∣ M ⟶ 1 − p p ◃ Q ∣ M p \mathrel{\triangleleft} \operatorname{flip}(p)\{\mathrm{H}\Rightarrow P \mathbin{[]}\mathrm{T}\Rightarrow Q\}\mid M \mathrel{\longrightarrow_{1-p}} p \mathrel{\triangleleft} Q\mid M p ◃ flip ( p ) { H ⇒ P [ ] T ⇒ Q } ∣ M ⟶ 1 − p p ◃ Q ∣ M
e ↓ t r u e e\mathrel{\downarrow}\mathrm{true} e ↓ true
p ◃ if e then P else Q ∣ M ⟶ 1 p ◃ P ∣ M p \mathrel{\triangleleft}\operatorname{if}\ e\ \operatorname{then}\ P\ \operatorname{else}\ Q\mid M \mathrel{\longrightarrow_{1}} p\mathrel{\triangleleft}P\mid M p ◃ if e then P else Q ∣ M ⟶ 1 p ◃ P ∣ M
e ↓ f a l s e e\mathrel{\downarrow}\mathrm{false} e ↓ false
p ◃ if e then P else Q ∣ M ⟶ 1 p ◃ Q ∣ M p \mathrel{\triangleleft}\operatorname{if}\ e\ \operatorname{then}\ P\ \operatorname{else}\ Q\mid M \mathrel{\longrightarrow_{1}} p\mathrel{\triangleleft}Q\mid M p ◃ if e then P else Q ∣ M ⟶ 1 p ◃ Q ∣ M
j ∈ I ℓ = ℓ j p = p j e ↓ v p ◃ q ! ℓ ⟨ e ⟩ . P ∣ q ◃ ∑ i ∈ I p i ? ℓ i ( x i ) . Q i ∣ M ⟶ 1 p ◃ P ∣ q ◃ Q j { v / x j } ∣ M \begin{gathered}
j\in I\qquad\ell=\ell_j\qquad p=p_j\qquad e\mathrel{\downarrow}v\\
p\mathrel{\triangleleft}q!\ell\langle e\rangle.P\mid q\mathrel{\triangleleft}\sum_{i\in I}p_i?\ell_i(x_i).Q_i\mid M
\mathrel{\longrightarrow_{1}}
p\mathrel{\triangleleft}P\mid q\mathrel{\triangleleft}Q_j\{v/x_j\}\mid M
\end{gathered} j ∈ I ℓ = ℓ j p = p j e ↓ v p ◃ q ! ℓ ⟨ e ⟩ . P ∣ q ◃ i ∈ I ∑ p i ? ℓ i ( x i ) . Q i ∣ M ⟶ 1 p ◃ P ∣ q ◃ Q j { v / x j } ∣ M
∃ j ∈ I : p = p j , ∄ i ∈ I : p i = p ∧ ℓ i = ℓ p ◃ q ! ℓ ⟨ e ⟩ . P ∣ q ◃ ∑ i ∈ I p i ? ℓ i ( x i ) . Q i ∣ M ⟶ 1 error \begin{gathered}
\exists j\in I:p=p_j,\qquad\nexists i\in I:p_i=p\land\ell_i=\ell\\
p\mathrel{\triangleleft}q!\ell\langle e\rangle.P\mid q\mathrel{\triangleleft}\sum_{i\in I}p_i?\ell_i(x_i).Q_i\mid M
\mathrel{\longrightarrow_{1}}\operatorname{error}
\end{gathered} ∃ j ∈ I : p = p j , ∄ i ∈ I : p i = p ∧ ℓ i = ℓ p ◃ q ! ℓ ⟨ e ⟩ . P ∣ q ◃ i ∈ I ∑ p i ? ℓ i ( x i ) . Q i ∣ M ⟶ 1 error
M 1 ⇛ M 1 ′ M 1 ′ ⟶ p M 2 M 2 ⇛ M 2 ′ M 1 ⟶ p M 2 ′ \begin{gathered}
M_1\mathrel{\Rrightarrow}M'_1\qquad M'_1\mathrel{\longrightarrow_p}M_2\qquad M_2\mathrel{\Rrightarrow}M'_2\\
M_1\mathrel{\longrightarrow_p}M'_2
\end{gathered} M 1 ⇛ M 1 ′ M 1 ′ ⟶ p M 2 M 2 ⇛ M 2 ′ M 1 ⟶ p M 2 ′
P u = s ! incr ⟨ 1 ⟩ . μ X . c ? res ( x ) . s ! incr ⟨ x ⟩ . X P s = μ X . ( c ? error ( x ) . c ! incr ⟨ x ⟩ . X + u ? incr ( x ) . c ! incr ⟨ x ⟩ . X ) P_u=s!\operatorname{incr}\langle1\rangle.\mu X.c?\operatorname{res}(x).s!\operatorname{incr}\langle x\rangle.X
\qquad
P_s=\mu X.(c?\operatorname{error}(x).c!\operatorname{incr}\langle x\rangle.X+u?\operatorname{incr}(x).c!\operatorname{incr}\langle x\rangle.X) P u = s ! incr ⟨ 1 ⟩ . μ X . c ? res ( x ) . s ! incr ⟨ x ⟩ . X P s = μ X . ( c ? error ( x ) . c ! incr ⟨ x ⟩ . X + u ? incr ( x ) . c ! incr ⟨ x ⟩ . X )
P c = μ X . s ? incr ( x ) . if x < 2 8 then u ! res ⟨ succ ( x ) ⟩ . X else flip ( 0.8 ) { H ⇒ u ! res ⟨ succ ( x ) ⟩ . X [ ] T ⇒ s ! error ⟨ x ⟩ . X } P_c=\mu X.s?\operatorname{incr}(x).\operatorname{if}\ x<2^8\ \operatorname{then}\ u!\operatorname{res}\langle\operatorname{succ}(x)\rangle.X\ \operatorname{else}\ \operatorname{flip}(0.8)\{\mathrm{H}\Rightarrow u!\operatorname{res}\langle\operatorname{succ}(x)\rangle.X\mathbin{[]}\mathrm{T}\Rightarrow s!\operatorname{error}\langle x\rangle.X\} P c = μ X . s ? incr ( x ) . if x < 2 8 then u ! res ⟨ succ ( x )⟩ . X else flip ( 0.8 ) { H ⇒ u ! res ⟨ succ ( x )⟩ . X [ ] T ⇒ s ! error ⟨ x ⟩ . X }
The user loops, sending incr ⟨ e ⟩ \operatorname{incr}\langle e\rangle incr ⟨ e ⟩ and then awaits a result res ( x ) \operatorname{res}(x) res ( x ) from c c c , binding the result of the computation to x x x before recursing. The server waits for one of two external choices: (1) incr \operatorname{incr} incr from u u u , after which it sends incr ⟨ e ⟩ \operatorname{incr}\langle e\rangle incr ⟨ e ⟩ to c c c and loops; or (2) an error ( x ) \operatorname{error}(x) error ( x ) from the calculator c c c on a previous computation upon which it retries the calculation by sending incr ⟨ x ⟩ \operatorname{incr}\langle x\rangle incr ⟨ x ⟩ to c c c again. The calculator is accurate up to a certain integer size — if the input from s s s is smaller than 2 8 2^8 2 8 , c c c successfully increments x x x and forwards it to u u u , on the other hand if the number is greater than or equal, it has a 0.2 0.2 0.2 probability of sending error to s s s before recursing (and 0.8 0.8 0.8 probability of succeeding as before).
Reduction relations. We write e ↓ v e\mathrel{\downarrow}v e ↓ v when fully evaluating a closed expression e e e (one with no free variables) yields value v v v ; the rules are standard [22 Table 1] . The reduction relation for sessions is given in Figure 3 ; reductions ⟶ p \longrightarrow_p ⟶ p are annotated with a weight that tracks probabilistic reduction paths. The probabilistic rules are [r-head] and [r-tail], taken when a flip ( p ) { H ⇒ P [ ] T ⇒ Q } \operatorname{flip}(p)\{\mathrm{H}\Rightarrow P\mathbin{[]}\mathrm{T}\Rightarrow Q\} flip ( p ) { H ⇒ P [ ] T ⇒ Q } resolves—heads (weight p p p ) continuing as P P P , tails ( 1 − p ) (1-p) ( 1 − p ) as Q Q Q ; all other rules carry weight 1 1 1 and coincide with the non-probabilistic MPST calculus of [22 , 60 ] . Rules [r-t-if] and [r-f-if] fire once the guard e e e has evaluated to true or false. In [r-comm], a participant p p p selecting label ℓ \ell ℓ to q q q synchronises with q q q ’s matching branch (the one whose sender is p p p ), binding v v v to x j x_j x j in the continuation Q j Q_j Q j ; the weight is 1 1 1 , as the communication surely happens. Rule [r-err] is enabled when p p p and q q q can communicate but there’s a label mismatch, i.e. p p p sends a label ℓ \ell ℓ not expected by q q q . Rule [r-sc] closes reduction under the structural precongruence ⇛ \Rrightarrow ⇛ , defined by p ◃ μ X . P ∣ M ⇛ p ◃ P { μ X . P / X } ∣ M p\mathrel{\triangleleft}\mu X.P\mid M\Rrightarrow p\mathrel{\triangleleft}P\{\mu X.P/X\}\mid M p ◃ μ X . P ∣ M ⇛ p ◃ P { μ X . P / X } ∣ M and ∏ i ∈ I p i ◃ P i ⇛ ∏ j ∈ J p j ◃ P j \prod_{i\in I}p_i\mathrel{\triangleleft}P_i\Rrightarrow\prod_{j\in J}p_j\mathrel{\triangleleft}P_j ∏ i ∈ I p i ◃ P i ⇛ ∏ j ∈ J p j ◃ P j when I I I is a permutation of J J J ; we write ≡ \equiv ≡ for ( ⇛ ∪ ⇛ − 1 ) (\Rrightarrow\cup\Rrightarrow^{-1}) ( ⇛ ∪ ⇛ − 1 ) . We use ⟶ p ∗ \longrightarrow_p^* ⟶ p ∗ for the reflexive and transitive closure of ⟶ p ′ \longrightarrow_{p'} ⟶ p ′ , where p p p is the cumulative probability of that path, e.g. if M ⟶ p ′ M ′ ⟶ p ′ ′ M ′ ′ M\longrightarrow_{p'}M'\longrightarrow_{p''}M'' M ⟶ p ′ M ′ ⟶ p ′′ M ′′ then M ⟶ p ′ p ′ ′ M ′ ′ M\longrightarrow_{p'p''}M'' M ⟶ p ′ p ′′ M ′′ .
Figure 3. Reduction rules for PROMT-calculus
Example 2.2 (Reductions). We trace a reduction of the session M M M from Ex. 2.1. We abbreviate P u ′ = μ X . c ? res ( x ) . s ! incr ⟨ x ⟩ . X P'_u=\mu X.c?\operatorname{res}(x).s!\operatorname{incr}\langle x\rangle.X P u ′ = μ X . c ? res ( x ) . s ! incr ⟨ x ⟩ . X for the loop of u u u , and unfold recursion silently by [r-sc]:
u ◃ c ? res ( x ) . s ! incr ⟨ x ⟩ . P u ′ ∣ s ◃ c ! incr ⟨ 1 ⟩ . P s ∣ c ◃ P c ⟶ 1 u ◃ c ? res ( x ) . s ! incr ⟨ x ⟩ . P u ′ ∣ s ◃ P s ∣ c ◃ P c u\mathrel{\triangleleft}c?\operatorname{res}(x).s!\operatorname{incr}\langle x\rangle.P'_u\mid s\mathrel{\triangleleft}c!\operatorname{incr}\langle1\rangle.P_s\mid c\mathrel{\triangleleft}P_c
\mathrel{\longrightarrow_{1}}
u\mathrel{\triangleleft}c?\operatorname{res}(x).s!\operatorname{incr}\langle x\rangle.P'_u\mid s\mathrel{\triangleleft}P_s\mid c\mathrel{\triangleleft}P_c u ◃ c ? res ( x ) . s ! incr ⟨ x ⟩ . P u ′ ∣ s ◃ c ! incr ⟨ 1 ⟩ . P s ∣ c ◃ P c ⟶ 1 u ◃ c ? res ( x ) . s ! incr ⟨ x ⟩ . P u ′ ∣ s ◃ P s ∣ c ◃ P c
u ◃ c ? res ( x ) . s ! incr ⟨ x ⟩ . P u ′ ∣ s ◃ P s ∣ c ◃ if 1 < 2 8 then u ! res ⟨ 2 ⟩ . P c else ⋯ ⟶ 1 u ◃ c ? res ( x ) . s ! incr ⟨ x ⟩ . P u ′ ∣ s ◃ P s ∣ c ◃ u ! res ⟨ 2 ⟩ . P c u\mathrel{\triangleleft}c?\operatorname{res}(x).s!\operatorname{incr}\langle x\rangle.P'_u\mid s\mathrel{\triangleleft}P_s\mid c\mathrel{\triangleleft}\operatorname{if}\ 1<2^8\ \operatorname{then}\ u!\operatorname{res}\langle2\rangle.P_c\ \operatorname{else}\cdots
\mathrel{\longrightarrow_{1}}
u\mathrel{\triangleleft}c?\operatorname{res}(x).s!\operatorname{incr}\langle x\rangle.P'_u\mid s\mathrel{\triangleleft}P_s\mid c\mathrel{\triangleleft}u!\operatorname{res}\langle2\rangle.P_c u ◃ c ? res ( x ) . s ! incr ⟨ x ⟩ . P u ′ ∣ s ◃ P s ∣ c ◃ if 1 < 2 8 then u ! res ⟨ 2 ⟩ . P c else ⋯ ⟶ 1 u ◃ c ? res ( x ) . s ! incr ⟨ x ⟩ . P u ′ ∣ s ◃ P s ∣ c ◃ u ! res ⟨ 2 ⟩ . P c
u ◃ c ? res ( x ) . s ! incr ⟨ x ⟩ . P u ′ ∣ s ◃ P s ∣ c ◃ u ! res ⟨ 2 ⟩ . P c ⟶ 1 u ◃ c ? res ( x ) . s ! incr ⟨ x ⟩ . P u ′ ∣ s ◃ P s ∣ c ◃ P c u\mathrel{\triangleleft}c?\operatorname{res}(x).s!\operatorname{incr}\langle x\rangle.P'_u\mid s\mathrel{\triangleleft}P_s\mid c\mathrel{\triangleleft}u!\operatorname{res}\langle2\rangle.P_c
\mathrel{\longrightarrow_{1}}
u\mathrel{\triangleleft}c?\operatorname{res}(x).s!\operatorname{incr}\langle x\rangle.P'_u\mid s\mathrel{\triangleleft}P_s\mid c\mathrel{\triangleleft}P_c u ◃ c ? res ( x ) . s ! incr ⟨ x ⟩ . P u ′ ∣ s ◃ P s ∣ c ◃ u ! res ⟨ 2 ⟩ . P c ⟶ 1 u ◃ c ? res ( x ) . s ! incr ⟨ x ⟩ . P u ′ ∣ s ◃ P s ∣ c ◃ P c
u ◃ c ! incr ⟨ 2 ⟩ . P u ′ ∣ s ◃ P s ∣ c ◃ P c ⟶ 1 u ◃ P u ′ ∣ s ◃ P s ∣ c ◃ P c u\mathrel{\triangleleft}c!\operatorname{incr}\langle2\rangle.P'_u\mid s\mathrel{\triangleleft}P_s\mid c\mathrel{\triangleleft}P_c
\mathrel{\longrightarrow_{1}}
u\mathrel{\triangleleft}P'_u\mid s\mathrel{\triangleleft}P_s\mid c\mathrel{\triangleleft}P_c u ◃ c ! incr ⟨ 2 ⟩ . P u ′ ∣ s ◃ P s ∣ c ◃ P c ⟶ 1 u ◃ P u ′ ∣ s ◃ P s ∣ c ◃ P c
and the value loops back incremented. For larger inputs the calculator may error and the edges would carry a probability p ≠ 1 p\ne1 p = 1 .
However, our processes are too expressive to analyse directly. Indeed, the following result tells us that safety of (untyped) processes cannot be established in a sound and complete manner.
Proposition 2.3. (Proof in §A.1). It is undecidable to check safety of (untyped) sessions: no algorithm exists that, given an arbitrary session M M M , can decide whether M ̸ → ∗ e r r o r M \not\to^{*}\mathit{error} M → ∗ error .
Proof. We reduce the halting problem to the problem under consideration. A two-counter Minsky machine M \mathcal{M} M is encoded as a session ⟨ ⟨ M ⟩ ⟩ \langle\!\langle\mathcal{M}\rangle\!\rangle ⟨ ⟨ M ⟩ ⟩ that simulates it and reaches error exactly when M \mathcal{M} M reaches its HALT instruction; hence ⟨ ⟨ M ⟩ ⟩ \langle\!\langle\mathcal{M}\rangle\!\rangle ⟨ ⟨ M ⟩ ⟩ is safe iff M \mathcal{M} M does not halt. As halting is undecidable [46 ] , so is safety. □
This motivates a type system for PROMT: typing provides a decidable , sound criterion for safety (well-typed ⇒ \Rightarrow ⇒ safe), and safety alone forces incompleteness (safe ⇏ \nRightarrow ⇏ well-typed), irrespective of any further properties (deadlock-freedom and liveness) we wish to analyse. The abstraction by types allows us to check safety and other probabilistic properties in a tractable manner.
Probabilistic Multiparty Session Types and Typing System
Probabilistic Multiparty Session Types
We start by defining probabilistic multiparty session types, subtyping and merging. We then define their labelled transition relation, and properties of typing contexts.
Probabilistic Multiparty Session Types (T T T , T ′ T' T ′ , … \ldots … ) define a probabilistic communication specification for each participant. Sorts (or base types ) are ranged over by B B B , B ′ B' B ′ , … \ldots …
B : : = b o o l ∣ n a t ∣ i n t T : : = e n d ∣ ∑ i ∈ I ⨁ j ∈ J i p i , j : p j ! ℓ j ⟨ B j ⟩ . T i , j ∣ & i ∈ I p i ? ℓ i ( B i ) . T i ∣ μ t . T ∣ t \begin{aligned}
B &::= \mathit{bool} \mid\mathit{nat} \mid\mathit{int}\\
T &::= \mathit{end} \mid\sum_{i\in I}\bigoplus_{j\in J_i} p_{i,j}:p_j!\ell_j\langle B_j\rangle.T_{i,j} \mid\mathbin{\&}_{i\in I}p_i?\ell_i(B_i).T_i \mid\mu t.T \mid t
\end{aligned} B T ::= bool ∣ nat ∣ int ::= end ∣ i ∈ I ∑ j ∈ J i ⨁ p i , j : p j ! ℓ j ⟨ B j ⟩ . T i , j ∣ & i ∈ I p i ? ℓ i ( B i ) . T i ∣ μ t . T ∣ t
Sorts are boolean, naturals and integers; probabilistic multiparty session types are: type e n d \mathit{end} end denoting termination; type & i ∈ I p i ? ℓ i ( B i ) . T i \mathbin{\&}_{i\in I}p_i?\ell_i(B_i).T_i & i ∈ I p i ? ℓ i ( B i ) . T i denoting branching (external choice) for each i i i offering label ℓ i \ell_i ℓ i to p i p_i p i . For branching to be well-formed, we require each p i ? ℓ i p_i?\ell_i p i ? ℓ i be distinct and I ≠ ∅ I\ne\varnothing I = ∅ . Type ∑ i ∈ I ⨁ j ∈ J i p i , j : p j ! ℓ j ⟨ B j ⟩ . T i , j \sum_{i\in I}\bigoplus_{j\in J_i}p_{i,j}:p_j!\ell_j\langle B_j\rangle.T_{i,j} ∑ i ∈ I ⨁ j ∈ J i p i , j : p j ! ℓ j ⟨ B j ⟩ . T i , j denotes selection (internal choice) as a two-step resolution; the outer sum ∑ i ∈ I \sum_{i\in I} ∑ i ∈ I represents a non-deterministic choice over its summands ⨁ j ∈ J i p i , j : p j ! ℓ j ⟨ B j ⟩ . T i , j \bigoplus_{j\in J_i}p_{i,j}:p_j!\ell_j\langle B_j\rangle.T_{i,j} ⨁ j ∈ J i p i , j : p j ! ℓ j ⟨ B j ⟩ . T i , j , that each denote a discrete output distribution with a fixed probability p i , j ∈ ( 0 , 1 ] p_{i,j}\in(0,1] p i , j ∈ ( 0 , 1 ] assigned to outputting ℓ j ⟨ B j ⟩ \ell_j\langle B_j\rangle ℓ j ⟨ B j ⟩ to p j p_j p j and continuing as T i , j T_{i,j} T i , j . For selection to be well-formed we require I ≠ ∅ I\ne\varnothing I = ∅ , each p j ! ℓ j p_j!\ell_j p j ! ℓ j j ∈ J i j\in J_i j ∈ J i be distinct and ∑ j ∈ J i p i , j = 1 \sum_{j\in J_i}p_{i,j}=1 ∑ j ∈ J i p i , j = 1 for all i i i . We sometimes write ⨁ j ∈ J 1 p 1 , j : p j ! ℓ j ⟨ B j ⟩ . T 1 , j + ∑ i ∈ I ∖ { 1 } ⨁ j ∈ J i p i , j : p j ! ℓ j ⟨ B j ⟩ . T i , j \bigoplus_{j\in J_1}p_{1,j}:p_j!\ell_j\langle B_j\rangle.T_{1,j}+\sum_{i\in I\setminus\{1\}}\bigoplus_{j\in J_i}p_{i,j}:p_j!\ell_j\langle B_j\rangle.T_{i,j} ⨁ j ∈ J 1 p 1 , j : p j ! ℓ j ⟨ B j ⟩ . T 1 , j + ∑ i ∈ I ∖ { 1 } ⨁ j ∈ J i p i , j : p j ! ℓ j ⟨ B j ⟩ . T i , j for ∑ i ∈ I ⨁ j ∈ J i p i , j : p j ! ℓ j ⟨ B j ⟩ . T i , j \sum_{i\in I}\bigoplus_{j\in J_i}p_{i,j}:p_j!\ell_j\langle B_j\rangle.T_{i,j} ∑ i ∈ I ⨁ j ∈ J i p i , j : p j ! ℓ j ⟨ B j ⟩ . T i , j and often omit ∑ i ∈ I \sum_{i\in I} ∑ i ∈ I when ∣ I ∣ = 1 |I|=1 ∣ I ∣ = 1 . μ t . T \mu t.T μ t . T and t t t are recursive types and type variables , where T T T is guarded : every type variable occurs under a branching or selection prefix (so μ t . t \mu t.t μ t . t is excluded), ensuring contractiveness. We often omit e n d \mathit{end} end , base types B B B and the subscript 1 1 1 . We denote ftv ( T ) \operatorname{ftv}(T) ftv ( T ) as the set of free type variables in T T T , and call T T T closed if ftv ( T ) = ∅ \operatorname{ftv}(T)=\varnothing ftv ( T ) = ∅ . Hereafter we assume all types are closed and well-formed.
Example 3.1 (Calculator service continued). Consider again the user-server-calculator session from Example 2.1. Let p : T p:T p : T denote that participant p p p has type T T T , the session is typed as:
u : T u = μ t . ⊕ s ! i n c r ⟨ i n t ⟩ , & c ? r e s ( i n t ) . t u:T_u=\mu t.\ \oplus\ s!\mathit{incr}\langle\mathit{int}\rangle,\ \&c?\mathit{res}(\mathit{int}).t u : T u = μ t . ⊕ s ! incr ⟨ int ⟩ , & c ? res ( int ) . t
s : T s = μ t . & { c ? e r r o r ( i n t ) , ⊕ c ! i n c r ⟨ i n t ⟩ . t , u ? i n c r ( i n t ) , ⊕ c ! i n c r ⟨ i n t ⟩ . t } s:T_s=\mu t.\ \&\{c?\mathit{error}(\mathit{int}),\ \oplus c!\mathit{incr}\langle\mathit{int}\rangle.t,\ u?\mathit{incr}(\mathit{int}),\ \oplus c!\mathit{incr}\langle\mathit{int}\rangle.t\} s : T s = μ t . & { c ? error ( int ) , ⊕ c ! incr ⟨ int ⟩ . t , u ? incr ( int ) , ⊕ c ! incr ⟨ int ⟩ . t }
c : T c = μ t . & s ? i n c r ( i n t ) . ∑ { ⊕ u ! r e s ( i n t ) . t , ⊕ { 0.8 : u ! r e s ⟨ i n t ⟩ . t , 0.2 : s ! e r r o r ⟨ i n t ⟩ . t } } c:T_c=\mu t.\ \&s?\mathit{incr}(\mathit{int}).\sum\left\{\oplus u!\mathit{res}(\mathit{int}).t,\ \oplus\{0.8:u!\mathit{res}\langle\mathit{int}\rangle.t,\ 0.2:s!\mathit{error}\langle\mathit{int}\rangle.t\}\right\} c : T c = μ t . & s ? incr ( int ) . ∑ { ⊕ u ! res ( int ) . t , ⊕ { 0.8 : u ! res ⟨ int ⟩ . t , 0.2 : s ! error ⟨ int ⟩ . t } }
Note that the condition in the if-statement of P c P_c P c , depending on the size of the input x x x , is abstracted to a non-deterministic choice over the two output distributions — rendering safety, deadlock-freedom and liveness, undecidable at the process level (Prop. 2.3), decidable. Observe also that the choice of c c c is separated : within one distribution, the res branch answers u u u while the error branch targets s s s — expressible because our selections fix a participant per branch, not per choice.
Probabilistic subtyping. Subtyping T ≤ T ′ T \leq T' T ≤ T ′ allows a process typed by a smaller type T T T to stand in wherever one typed by T ′ T' T ′ is expected (the substitution principle [43 ] ): it narrows selections (fewer nondeterministic options) and widens branchings (more offered inputs), as the rules make precise.
Definition 3.2 (Probabilistic subtyping). Probabilistic subtyping ≤ \leq ≤ is the largest relation on session types (taken up to unfolding), coinductively defined by the rules below:
∀ i ∈ I : T i ≤ T i ′ ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T i ≤ ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T i ′ ∀ i ∈ I : T i ≤ T i ′ { p i } i ∈ I ∪ J = { p i } i ∈ I & i ∈ I ∪ J p i ? ℓ i ( B i ) . T i ≤ & i ∈ I p i ? ℓ i ( B i ) . T i ′ \frac{\forall i \in I : T_i \leq T'_i}{\bigoplus_{i\in I} p_i:p_i!\ell_i\langle B_i\rangle.T_i \leq\bigoplus_{i\in I} p_i:p_i!\ell_i\langle B_i\rangle.T'_i}
\qquad
\frac{\forall i \in I : T_i \leq T'_i \qquad\{p_i\}_{i\in I\cup J}=\{p_i\}_{i\in I}}{\mathbin{\&}_{i\in I\cup J}p_i? \ell_i(B_i).T_i \leq\mathbin{\&}_{i\in I}p_i?\ell_i(B_i).T'_i} ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T i ≤ ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T i ′ ∀ i ∈ I : T i ≤ T i ′ & i ∈ I ∪ J p i ? ℓ i ( B i ) . T i ≤ & i ∈ I p i ? ℓ i ( B i ) . T i ′ ∀ i ∈ I : T i ≤ T i ′ { p i } i ∈ I ∪ J = { p i } i ∈ I e n d ≤ e n d ∣ I ∣ ⋅ ∣ K ∣ > 1 ∀ i ∈ I : ∃ k ∈ K : ⨁ j ∈ J i p i , j : p j ! ℓ j ⟨ B j ⟩ . T i , j ≤ ⨁ j ∈ J p k , j : p j ! ℓ j ⟨ B j ⟩ . T k , j ′ ⨁ i ∈ I ⨁ j ∈ J i p i , j : p j ! ℓ j ⟨ B j ⟩ . T i , j ≤ ⨁ k ∈ K ⨁ j ∈ J p k , j : p j ! ℓ j ⟨ B j ⟩ . T k , j ′ \frac{}{ \mathsf{end}\leq\mathsf{end}}
\qquad
\frac{|I|\cdot|K|>1 \qquad\forall i\in I:\exists k\in K:\bigoplus_{j\in J_i}p_{i,j}:p_j!\ell_j\langle B_j\rangle.T_{i,j}\leq\bigoplus_{j\in J}p_{k,j}:p_j!\ell_j\langle B_j\rangle.T'_{k,j}}{\bigoplus_{i\in I}\bigoplus_{j\in J_i}p_{i,j}:p_j!\ell_j\langle B_j\rangle.T_{i,j}\leq\bigoplus_{k\in K}\bigoplus_{j\in J}p_{k,j}:p_j!\ell_j\langle B_j\rangle.T'_{k,j}} end ≤ end ⨁ i ∈ I ⨁ j ∈ J i p i , j : p j ! ℓ j ⟨ B j ⟩ . T i , j ≤ ⨁ k ∈ K ⨁ j ∈ J p k , j : p j ! ℓ j ⟨ B j ⟩ . T k , j ′ ∣ I ∣ ⋅ ∣ K ∣ > 1 ∀ i ∈ I : ∃ k ∈ K : ⨁ j ∈ J i p i , j : p j ! ℓ j ⟨ B j ⟩ . T i , j ≤ ⨁ j ∈ J p k , j : p j ! ℓ j ⟨ B j ⟩ . T k , j ′
The rules adapt the multiparty subtyping of [22 ] to fit our probabilistic types. [sub-end] relates end only to itself. [sub-&] is contravariant: the subtype may offer more inputs (I ∪ J I \cup J I ∪ J ) than the supertype (I I I ), as a process handling extra messages is safe where fewer are expected. As in the input subtyping rule [s-in] in [51 Def. 5] , we require the set of participants { p i } i ∈ I \{p_i\}_{i\in I} { p i } i ∈ I be identical to { p i } i ∈ I ∪ J \{p_i\}_{i\in I\cup J} { p i } i ∈ I ∪ J for downward-closure for typing context properties (Lemma C.2 and Cor. C.18). [sub-⊕] relates two selection distributions only when targets, labels, sorts, and probabilities coincide (changing any would be observable and break substitutability). Rule [sub-Σ] is less restrictive in comparison: every summand of the subtype must embed (via [sub-⊕]) into some summand of the supertype, so the supertype’s non-deterministic options cover the subtype’s; the premise ∣ I ∣ ⋅ ∣ K ∣ > 1 |I|\cdot|K|>1 ∣ I ∣ ⋅ ∣ K ∣ > 1 prevents degenerate derivations (closing coinductive derivation after 1 step of [sub-Σ]).
Lemma 3.3 (≤-preorder). (Proof in §B.3). ≤ \leq ≤ is reflexive and transitive.
Example 3.4 (Subtyping). Consider the following subprocess of some larger session:
P c o n d = P_{\mathit{cond}} = P cond = if x > 3 x > 3 x > 3 then p ! h i ⟨ t r u e ⟩ .0 p!\mathit{hi}\langle\mathit{true}\rangle.0 p ! hi ⟨ true ⟩ .0 else q ! b y e ⟨ 1 ⟩ .0 q!\mathit{bye}\langle1\rangle.0 q ! bye ⟨ 1 ⟩ .0 , where the types for the “then” and “else” branch are T t h e n = ⨁ p ! h i ⟨ b o o l ⟩ . e n d T_{\mathrm{then}}=\bigoplus p!\mathit{hi}\langle\mathit{bool}\rangle.\mathsf{end} T then = ⨁ p ! hi ⟨ bool ⟩ . end and T e l s e = ⨁ q ! b y e ⟨ i n t ⟩ . e n d T_{\mathrm{else}=\bigoplus q!\mathit{bye}\langle\mathit{int}\rangle.\mathsf{end}} T else = ⨁ q ! bye ⟨ int ⟩ . end . Then by [sub-Σ], we have T t h e n ≤ Σ { T t h e n , T e l s e } T_{\mathrm{then}}\leq\Sigma\{T_{\mathrm{then}},T_{\mathrm{else}}\} T then ≤ Σ { T then , T else } and T e l s e ≤ Σ { T t h e n , T e l s e } T_{\mathrm{else}}\leq\Sigma\{T_{\mathrm{then}},T_{\mathrm{else}}\} T else ≤ Σ { T then , T else } . Thus, by [t-sub] and [t-cond] (both introduced later), we are able to type P c o n d P_{\mathit{cond}} P cond with the common supertype T c o n d = Σ { T t h e n , T e l s e } T_{\mathit{cond}}=\Sigma\{T_{\mathrm{then}},T_{\mathrm{else}}\} T cond = Σ { T then , T else } .
Proposition 3.5 (≤-decidable). (Proof in §B.3). Given T 1 T_1 T 1 and T 2 T_2 T 2 , checking T 1 ≤ T 2 T_1\leq T_2 T 1 ≤ T 2 is decidable.
Definition 3.6 (≤-least upper-bound). ⊔ \sqcup ⊔ is a partial relation on session types with T 1 ⊔ T 2 = T T_1\sqcup T_2=T T 1 ⊔ T 2 = T defined exactly when T 1 ≤ T T_1\leq T T 1 ≤ T and T 2 ≤ T T_2\leq T T 2 ≤ T and ∀ T ′ : ( T 1 ≤ T ′ ∧ T 2 ≤ T ′ ) ⇒ T ≤ T ′ \forall T':(T_1\leq T'\land T_2\leq T')\Rightarrow T\leq T' ∀ T ′ : ( T 1 ≤ T ′ ∧ T 2 ≤ T ′ ) ⇒ T ≤ T ′ .
We write T 1 ⊔ T 2 T_1\sqcup T_2 T 1 ⊔ T 2 for any T T T such that T 1 ⊔ T 2 = T T_1\sqcup T_2=T T 1 ⊔ T 2 = T and note that T T T is unique up to mutual subtyping.
Definition 3.7 (Unfolding). We define unf ( μ t . T ) = T { μ t . T / t } \operatorname{unf}(\mu t.T)=T\{\mu t.T/t\} unf ( μ t . T ) = T { μ t . T / t } and unf ( T ) = T \operatorname{unf}(T)=T unf ( T ) = T otherwise.
Probabilistic merging. Subtyping allows us to type if-statements by widening the type sufficiently to accommodate both possible behaviours. Analogously, merging will allow us to reconcile the behaviour of both head and tail branches of a flip(p p p ) { H ⇒ ⋯ ∣ T ⇒ ⋯ } \{H\Rightarrow\cdots\mid T\Rightarrow\cdots\} { H ⇒ ⋯ ∣ T ⇒ ⋯ } .
Definition 3.8 (Probabilistic merge). The merge is the largest relation on session types, such that whenever T 1 ⊓ T 2 = T T_1 \sqcap T_2=T T 1 ⊓ T 2 = T the clauses below hold, with other cases being undefined:
[M-END] If unf ( T 1 ) = unf ( T 2 ) = e n d \operatorname{unf}(T_1)=\operatorname{unf}(T_2)=\mathsf{end} unf ( T 1 ) = unf ( T 2 ) = end then unf ( T ) = e n d \operatorname{unf}(T)=\mathsf{end} unf ( T ) = end
If unf ( T 1 ) = & i ∈ I q i ? ℓ i ( B i ) . T i and unf ( T 2 ) = & j ∈ J q j ? ℓ j ( B j ) . T j ′ with K = { k ∈ I ∩ J ∣ ∃ T : T k ⊔ T k ′ = T } and { q i } i ∈ I = { q j } j ∈ J = { q k } k ∈ K then unf ( T ) = & k ∈ K q k ? ℓ k ( B k ) . ( T k ⊔ T k ′ ) \text{If } \operatorname{unf}(T_1)=\mathbin{\&}_{i\in I}q_i?{\ell_i}(B_i).T_i\text{ and }\operatorname{unf}(T_2)=\mathbin{\&}_{j\in J}q_j?{\ell_j}(B_j).T'_j\text{ with }K=\{k\in I\cap J\mid\exists T:T_k\sqcup T'_k=T\}\\
\text{and }\{q_i\}_{i\in I}=\{q_j\}_{j\in J}=\{q_k\}_{k\in K}\text{ then }\operatorname{unf}(T)=\mathbin{\&}_{k\in K}q_k?{\ell_k}(B_k).(T_k\sqcup T'_k) If unf ( T 1 ) = & i ∈ I q i ? ℓ i ( B i ) . T i and unf ( T 2 ) = & j ∈ J q j ? ℓ j ( B j ) . T j ′ with K = { k ∈ I ∩ J ∣ ∃ T : T k ⊔ T k ′ = T } and { q i } i ∈ I = { q j } j ∈ J = { q k } k ∈ K then unf ( T ) = & k ∈ K q k ? ℓ k ( B k ) . ( T k ⊔ T k ′ )
If unf ( T 1 ) = ⨁ i ∈ I p i : q i ! ℓ i ⟨ B i ⟩ . T i and unf ( T 2 ) = ⨁ j ∈ J p j ′ : q j ! ℓ j ⟨ B j ⟩ . T j ′ with ∀ k ∈ I ∩ J : ∃ T : T k ⊔ T k ′ = T then unf ( T ) = ⨁ k ∈ I ∪ J p k ′ ′ : q k ! ℓ k ⟨ B k ⟩ . T k ′ ′ and for every k ∈ I ∪ J : k ∈ I ∖ J ⇒ p k ′ ′ = p ⋅ p k ∧ T k ′ ′ = T k k ∈ J ∖ I ⇒ p k ′ ′ = ( 1 − p ) ⋅ p k ′ ∧ T k ′ ′ = T k ′ k ∈ I ∩ J ⇒ p k ′ ′ = p ⋅ p k + ( 1 − p ) ⋅ p k ′ ∧ T k ′ ′ = T k ⊔ T k ′ \text{If }\operatorname{unf}(T_1)=\bigoplus_{i\in I}p_i:q_i!{\ell_i}\langle B_i\rangle.T_i\text{ and }\operatorname{unf}(T_2)=\bigoplus_{j\in J}p'_j:q_j!{\ell_j}\langle B_j\rangle.T'_j\text{ with }\forall k\in I\cap J:\exists T:T_k\sqcup T'_k=T\\
\text{then }\operatorname{unf}(T)=\bigoplus_{k\in I\cup J}p''_k:q_k!{\ell_k}\langle B_k\rangle.T''_k\text{ and for every }k\in I\cup J:\\
k\in I\setminus J\Rightarrow p''_k=p\cdot p_k\land T''_k=T_k\\
k\in J\setminus I\Rightarrow p''_k=(1-p)\cdot p'_k\land T''_k=T'_k\\
k\in I\cap J\Rightarrow p''_k=p\cdot p_k+(1-p)\cdot p'_k\land T''_k=T_k\sqcup T'_k If unf ( T 1 ) = i ∈ I ⨁ p i : q i ! ℓ i ⟨ B i ⟩ . T i and unf ( T 2 ) = j ∈ J ⨁ p j ′ : q j ! ℓ j ⟨ B j ⟩ . T j ′ with ∀ k ∈ I ∩ J : ∃ T : T k ⊔ T k ′ = T then unf ( T ) = k ∈ I ∪ J ⨁ p k ′′ : q k ! ℓ k ⟨ B k ⟩ . T k ′′ and for every k ∈ I ∪ J : k ∈ I ∖ J ⇒ p k ′′ = p ⋅ p k ∧ T k ′′ = T k k ∈ J ∖ I ⇒ p k ′′ = ( 1 − p ) ⋅ p k ′ ∧ T k ′′ = T k ′ k ∈ I ∩ J ⇒ p k ′′ = p ⋅ p k + ( 1 − p ) ⋅ p k ′ ∧ T k ′′ = T k ⊔ T k ′
If unf ( T 1 ) = ∑ i ∈ I T i and unf ( T 2 ) = ∑ j ∈ J T j ′ with ∣ I ∣ ⋅ ∣ J ∣ > 1 then unf ( T ) = ∑ ( i , j ) ∈ I × J T i , j where T i ⊓ p T j ′ = T i , j for all ( i , j ) ∈ I × J \text{If }\operatorname{unf}(T_1)=\sum_{i\in I}T_i\text{ and }\operatorname{unf}(T_2)=\sum_{j\in J}T'_j\text{ with }|I|\cdot|J|>1\text{ then }\operatorname{unf}(T)=\sum_{(i,j)\in I\times J}T_{i,j}\text{ where}\\
T_i\sqcap_p T'_j=T_{i,j}\text{ for all }(i,j)\in I\times J If unf ( T 1 ) = i ∈ I ∑ T i and unf ( T 2 ) = j ∈ J ∑ T j ′ with ∣ I ∣ ⋅ ∣ J ∣ > 1 then unf ( T ) = ( i , j ) ∈ I × J ∑ T i , j where T i ⊓ p T j ′ = T i , j for all ( i , j ) ∈ I × J
The above merging operator is analogous to the binary session operator T 1 ⊞ p T 2 T_1\boxplus_p T_2 T 1 ⊞ p T 2 of [34 ] , but extended to multiparty session types. By [m-end] type end is mergeable only with end. Merging of external choice [m-&] must preserve the participant sets and drops any branches indexed by p i ? ℓ i p_i?{\ell_i} p i ? ℓ i when i ∉ I ∩ J i\notin I\cap J i ∈ / I ∩ J (analogous to the contravariance of [sub-&]), or whose continuations T i T_i T i and T i ′ T'_i T i ′ have no common supertype — continuations are then typed by their least supertype T k ⊔ T k ′ T_k\sqcup T'_k T k ⊔ T k ′ . Rule [m-⊕] merges two selections, assigning to p i ! ℓ i ⟨ B i ⟩ . T i p_i!{\ell_i}\langle B_i\rangle.T_i p i ! ℓ i ⟨ B i ⟩ . T i in i ∈ I ∖ J i\in I\setminus J i ∈ I ∖ J (resp. i ∈ J ∖ I i\in J\setminus I i ∈ J ∖ I ) probability p ⋅ p i p\cdot p_i p ⋅ p i (resp. ( 1 − p ) ⋅ p i ′ (1-p)\cdot p'_i ( 1 − p ) ⋅ p i ′ ), while the probability for i ∈ I ∩ J i\in I\cap J i ∈ I ∩ J is given by the convex combination p ⋅ p i + ( 1 − p ) ⋅ p i ′ p\cdot p_i+(1-p)\cdot p'_i p ⋅ p i + ( 1 − p ) ⋅ p i ′ with continuations typed by the least upper bound T k ⊔ T k ′ T_k\sqcup T'_k T k ⊔ T k ′ . Finally, the rule [m-Σ] merges every selection combination, the product I × J I\times J I × J ensures every possible resolution of non-determinism is preserved; the side-condition ∣ I ∣ ⋅ ∣ J ∣ > 1 |I|\cdot|J|>1 ∣ I ∣ ⋅ ∣ J ∣ > 1 prevents degenerate derivations.
Notation 3.9 (Multi-way merge). We define \bigsqcap_{i\in I}(T_i,p_i) inductively as: T i T_i T i if p i = 1 p_i=1 p i = 1 and ∣ I ∣ = 1 |I|=1 ∣ I ∣ = 1 ; \bigsqcap_{i\in I}(T_i,p_i)=T_j\sqcap_{p_j}\bigsqcap_{i\in I\setminus\{j\}}(T_i,\frac{p_i}{1-p_j}) if j ∈ I ∧ p j ≠ 0 j\in I\land p_j\ne0 j ∈ I ∧ p j = 0 ; undefined otherwise.
Example 3.10 (Probabilistic merging). The non-deterministic choice in the type T c T_c T c of the calculator (Ex. 3.1) contains the selection distribution T c − e l s e = ⨁ { 0.8 : u ! r e s ⟨ i n t ⟩ . t , 0.2 : s ! e r r o r ⟨ i n t ⟩ . t } T_{c-\mathrm{else}}=\bigoplus\{0.8:u!\mathrm{res}\langle\mathrm{int}\rangle.t,\ 0.2:s!\mathrm{error}\langle\mathrm{int}\rangle.t\} T c − else = ⨁ { 0.8 : u ! res ⟨ int ⟩ . t , 0.2 : s ! error ⟨ int ⟩ . t } , which is the merge T 1 ⊓ 0.8 T 2 T_1\sqcap_{0.8}T_2 T 1 ⊓ 0.8 T 2 of T 1 = ⨁ 1 : u ! r e s ⟨ i n t ⟩ . t T_1=\bigoplus1:u!\mathrm{res}\langle\mathrm{int}\rangle.t T 1 = ⨁ 1 : u ! res ⟨ int ⟩ . t and T 2 = ⨁ 1 : s ! e r r o r ⟨ i n t ⟩ . t T_2=\bigoplus1:s!\mathrm{error}\langle\mathrm{int}\rangle.t T 2 = ⨁ 1 : s ! error ⟨ int ⟩ . t (with t t t of type T c T_c T c ). Since the label-role pairs u ! r e s u!\mathrm{res} u ! res and s ! e r r o r s!\mathrm{error} s ! error are disjoint, a single application of [m-⊕] suffices (as 0.8 = 0.8 ⋅ 1 0.8=0.8\cdot1 0.8 = 0.8 ⋅ 1 , 0.2 = 0.2 ⋅ 1 0.2=0.2\cdot1 0.2 = 0.2 ⋅ 1 and t = t t=t t = t , by the disjoint case of the statement).
Proposition 3.11 (Decidability of merge). (Proof in §B.3). For T 1 T_1 T 1 , T 2 T_2 T 2 and p ∈ ( 0 , 1 ) p\in(0,1) p ∈ ( 0 , 1 ) it is decidable whether T 1 ⊓ p T 2 T_1\sqcap_p T_2 T 1 ⊓ p T 2 is defined in time O ( ∣ T 1 ∣ ∣ T 2 ∣ ) O(|T_1||T_2|) O ( ∣ T 1 ∣∣ T 2 ∣ ) , and when defined the witness is computable in time O ( ( max { 2 , d } ) 2 ∣ T 1 ∣ ∣ T 2 ∣ log ( ∣ T 1 ∣ ∣ T 2 ∣ + 1 ) ) O((\max\{2,d\})^{2|T_1||T_2|}\log(|T_1||T_2|+1)) O (( max { 2 , d } ) 2∣ T 1 ∣∣ T 2 ∣ log ( ∣ T 1 ∣∣ T 2 ∣ + 1 )) where d d d is the max out-degree of the type graphs of T 1 T_1 T 1 , T 2 T_2 T 2 .
A typing context ( Δ , Δ ′ , … ) (\Delta,\Delta',\ldots) ( Δ , Δ ′ , … ) is a mapping from a participant to its type, representing behaviours of a multiparty session. Its behaviour (semantics) are defined by a labelled transition relation labelled with actions ( α , α ′ , … ) (\alpha,\alpha',\ldots) ( α , α ′ , … ) . Typing contexts and actions are defined as:
Δ : : = p : T ∣ Δ , Δ ′ α : : = p : q ! ℓ ⟨ B ⟩ ∣ p : q ? ℓ ( B ) ∣ ( p , q ) ℓ ∣ p : τ ∣ p : p \Delta::= \mathbf{p}:T\mid\Delta,\Delta'
\qquad
\alpha::= \mathbf{p}:\mathbf{q}!{\ell}\langle B\rangle\mid\mathbf{p}:\mathbf{q}?{\ell}(B)\mid(\mathbf{p},\mathbf{q}){\ell}\mid\mathbf{p}:\tau\mid\mathbf{p}:\mathbf{p} Δ ::= p : T ∣ Δ , Δ ′ α ::= p : q ! ℓ ⟨ B ⟩ ∣ p : q ? ℓ ( B ) ∣ ( p , q ) ℓ ∣ p : τ ∣ p : p
Action p : q ! ℓ ⟨ B ⟩ \mathbf{p}:\mathbf{q}!{\ell}\langle B\rangle p : q ! ℓ ⟨ B ⟩ is a selection from participant p \mathbf{p} p to q \mathbf{q} q with label ℓ \ell ℓ and type B B B ; action p : q ? ℓ ( B ) \mathbf{p}:\mathbf{q}?{\ell}(B) p : q ? ℓ ( B ) is branching at participant p \mathbf{p} p from q \mathbf{q} q with label ℓ \ell ℓ and type B B B ; and action ( p , q ) ℓ (\mathbf{p},\mathbf{q}){\ell} ( p , q ) ℓ is a communication between dual actions. p : τ \mathbf{p}:\tau p : τ and p : p \mathbf{p}:\mathbf{p} p : p denote nondeterministic and probabilistic internal choice respectively. We write Δ 1 ⪯ Δ 2 \Delta_1\preceq\Delta_2 Δ 1 ⪯ Δ 2 if dom ( Δ 1 ) = dom ( Δ 2 ) \operatorname{dom}(\Delta_1)=\operatorname{dom}(\Delta_2) dom ( Δ 1 ) = dom ( Δ 2 ) and ∀ p ∈ dom ( Δ 1 ) : Δ 1 ( p ) ⪯ Δ 2 ( p ) \forall p\in\operatorname{dom}(\Delta_1):\Delta_1(p)\preceq\Delta_2(p) ∀ p ∈ dom ( Δ 1 ) : Δ 1 ( p ) ⪯ Δ 2 ( p ) .
Semantics (Labelled Transition System) of typing contexts is defined in Figure 4 . We note that emitting a message decomposes into up to three steps: [CT-ND] resolves an internal non-deterministic choice among the summands of a Σ \Sigma Σ ; [CT-PROB] is an internal probabilistic reduction, resolving a participant p \mathbf{p} p at a proper output selection p : ⨁ i ∈ I p i : q ! ℓ i ⟨ B i ⟩ . T i \mathbf{p}:\bigoplus_{i\in I}p_i:\mathbf{q}!{\ell_i}\langle B_i\rangle.T_i p : ⨁ i ∈ I p i : q ! ℓ i ⟨ B i ⟩ . T i to the singleton selection of branch k k k , with probability p k p_k p k ; [CT-OUT] emits the message to q \mathbf{q} q with label ℓ k \ell_k ℓ k , sort B k B_k B k , and probability 1 1 1 . Rule [CT-IN] inputs label ℓ k \ell_k ℓ k with sort B k B_k B k at participant p \mathbf{p} p with probability $1; rule [CT-τ] synchronises a singleton selection with its dual branching; [CT-REC] is the standard rule for recursive types; and [CT-SC] is a context rule. We write:
Figure 4. Labelled transition system for typing contexts
Δ → ( p , q ) ℓ p Δ ′ \Delta\xrightarrow{(p,q)^\ell}_{p} \Delta' Δ ( p , q ) ℓ p Δ ′ iff ( p = 1 ∧ Δ → ( p , q ) ℓ 1 Δ ′ ) (p = 1 \land\Delta\xrightarrow{(p,q)^\ell}_{1} \Delta') ( p = 1 ∧ Δ ( p , q ) ℓ 1 Δ ′ ) or ∃ Δ ′ ′ : Δ → p Δ ′ ′ ∧ Δ ′ ′ → ( p , q ) ℓ 1 Δ ′ \exists\Delta^{\prime\prime}: \Delta\xrightarrow{p} \Delta^{\prime\prime} \land\Delta^{\prime\prime} \xrightarrow{(p,q)^\ell}_{1} \Delta' ∃ Δ ′′ : Δ p Δ ′′ ∧ Δ ′′ ( p , q ) ℓ 1 Δ ′ .
Δ → t Δ ′ \Delta\xrightarrow{t} \Delta' Δ t Δ ′ iff ∃ α ∈ { p : τ , p : p , ( p , q ) ℓ ∣ p , q , ℓ } : Δ → α t Δ ′ \exists\alpha\in\{p\colon\tau, p\colon p, (p,q)^\ell\mid p,q,\ell\}: \Delta\xrightarrow{\alpha}_{t} \Delta' ∃ α ∈ { p : τ , p : p , ( p , q ) ℓ ∣ p , q , ℓ } : Δ α t Δ ′ ; and Δ ⟶ Δ ′ \Delta\longrightarrow\Delta' Δ ⟶ Δ ′ iff ∃ t ∈ ( 0 ; 1 ] ∪ { n } : Δ → t Δ ′ \exists t \in(0;1]\cup\{n\}: \Delta\xrightarrow{t} \Delta' ∃ t ∈ ( 0 ; 1 ] ∪ { n } : Δ t Δ ′ ; and Δ → t Δ ′ \Delta\xrightarrow{t} \Delta' Δ t Δ ′ iff ∃ Δ ′ ′ : Δ → t Δ ′ ′ \exists\Delta^{\prime\prime}: \Delta\xrightarrow{t} \Delta^{\prime\prime} ∃ Δ ′′ : Δ t Δ ′′ (same for ⟶ t \longrightarrow_t ⟶ t and ⟶ \longrightarrow ⟶ ). These conventions also apply to α ⟶ p \alpha\longrightarrow_{p} α ⟶ p .
Δ 1 ⟶ p + Δ m \Delta_1 \longrightarrow^{+}_{p} \Delta_m Δ 1 ⟶ p + Δ m for the transitive closure : a sequence Δ 1 ⋯ ⟶ p m − 1 Δ m \Delta_1 \cdots\longrightarrow_{p_{m-1}} \Delta_m Δ 1 ⋯ ⟶ p m − 1 Δ m with m ≥ 2 m \ge2 m ≥ 2 and p = ∏ k = 1 m − 1 p k p = \prod_{k=1}^{m-1} p_k p = ∏ k = 1 m − 1 p k . The reflexive and transitive closure ⟶ ∗ \longrightarrow^{*} ⟶ ∗ additionally admits the empty path ( Δ ⟶ 1 ∗ Δ ) (\Delta\longrightarrow^{*}_{1} \Delta) ( Δ ⟶ 1 ∗ Δ ) .
Safety property. In a general typing system [52 ] , we type-check that a multiparty session M M M satisfies a safety property : whether its typing context only exchanges compatible labels.
Definition 3.12 (Safety). [52 Definition 4.1] φ \varphi φ is a safety property of Δ \Delta Δ iff, whenever φ ( Δ ) \varphi(\Delta) φ ( Δ ) : (1) φ ( ∅ ) \varphi(\varnothing) φ ( ∅ ) ; (2) Δ → p : q ! ℓ ⟨ B ⟩ 1 \Delta\xrightarrow{p:q!\ell\langle B\rangle}_{1} Δ p : q ! ℓ ⟨ B ⟩ 1 and Δ → q : p ? ℓ ( B ′ ) 1 \Delta\xrightarrow{q:p?\ell(B')}_{1} Δ q : p ? ℓ ( B ′ ) 1 imply Δ → ( p , q ) ℓ 1 \Delta\xrightarrow{(p,q)^\ell}_{1} Δ ( p , q ) ℓ 1 ; (3) Δ ⟶ Δ ′ \Delta\longrightarrow\Delta' Δ ⟶ Δ ′ implies φ ( Δ ′ ) \varphi(\Delta') φ ( Δ ′ ) We write safe ( Δ ) \operatorname{safe}(\Delta) safe ( Δ ) if φ ( Δ ) \varphi(\Delta) φ ( Δ ) holds for some safety property φ \varphi φ .
Def. 3.12(1) above states the empty context is considered safe, (2) defines that if Δ \Delta Δ contains the entries for selection at p p p to q q q and branching at q q q from p p p , then branching at q q q supports all of p p p ’s labels. Def. 3.12(3) states that a safety property must be preserved under reductions.
Example 3.13 (Semantics of types and safety). Consider the typing context Δ = u : T u , s : T s , c : T c \Delta= u : T_u, s : T_s, c : T_c Δ = u : T u , s : T s , c : T c of Example 3.1 . We consider two runs starting from Δ \Delta Δ :
Δ → ( u , s ) i n c r 1 ⋅ → ( s , c ) i n c r 1 ⋅ → c : τ n ⋅ → ( c , s ) e r r o r 0.2 ⋅ → ( s , c ) i n c r 1 ⋅ → c : τ n ⋅ → ( c , u ) r e s 1 Δ ⋯ \Delta\xrightarrow{(u,s)\,\mathrm{incr}}_{1} \cdot\xrightarrow{(s,c)\,\mathrm{incr}}_{1} \cdot\xrightarrow{c:\tau}_{n} \cdot\xrightarrow{(c,s)\,\mathrm{error}}_{0.2} \cdot\xrightarrow{(s,c)\,\mathrm{incr}}_{1} \cdot\xrightarrow{c:\tau}_{n} \cdot\xrightarrow{(c,u)\,\mathrm{res}}_{1} \Delta\cdots Δ ( u , s ) incr 1 ⋅ ( s , c ) incr 1 ⋅ c : τ n ⋅ ( c , s ) error 0.2 ⋅ ( s , c ) incr 1 ⋅ c : τ n ⋅ ( c , u ) res 1 Δ ⋯
Δ → ( u , s ) i n c r 1 ⋅ → ( s , c ) i n c r 1 ⋅ → c : τ n ⋅ → ( c , s ) e r r o r 0.2 ⋅ → ( s , c ) i n c r 1 ⋅ → c : τ n ⋅ → ( c , s ) e r r o r 0.2 ⋅ → ( s , c ) i n c r 1 ⋅ → c : τ n ⋅ → ( c , s ) e r r o r 0.2 ⋅ ⋯ \Delta\xrightarrow{(u,s)\,\mathrm{incr}}_{1} \cdot\xrightarrow{(s,c)\,\mathrm{incr}}_{1} \cdot\xrightarrow{c:\tau}_{n} \cdot\xrightarrow{(c,s)\,\mathrm{error}}_{0.2} \cdot\xrightarrow{(s,c)\,\mathrm{incr}}_{1} \cdot\xrightarrow{c:\tau}_{n} \cdot\xrightarrow{(c,s)\,\mathrm{error}}_{0.2} \cdot\xrightarrow{(s,c)\,\mathrm{incr}}_{1} \cdot\xrightarrow{c:\tau}_{n} \cdot\xrightarrow{(c,s)\,\mathrm{error}}_{0.2} \cdot\cdots Δ ( u , s ) incr 1 ⋅ ( s , c ) incr 1 ⋅ c : τ n ⋅ ( c , s ) error 0.2 ⋅ ( s , c ) incr 1 ⋅ c : τ n ⋅ ( c , s ) error 0.2 ⋅ ( s , c ) incr 1 ⋅ c : τ n ⋅ ( c , s ) error 0.2 ⋅ ⋯
The first run fails once then succeeds when the [CT-ND] step commits c c c ’s non-deterministic choice to the selection sending r e s \mathrm{res} res to u u u with probability 1 1 1 . The second fails indefinitely, a run of probability lim n → ∞ 0.2 n = 0 \lim_{n\to\infty} 0.2^n = 0 lim n → ∞ 0. 2 n = 0 (§ 5 ). Note the → c : τ n \xrightarrow{c:\tau}_{n} c : τ n steps carry no probability, and instead abstract over the x < 2 8 x < 2^8 x < 2 8 test in Example 3.1 .
Probabilistic Multiparty Session Typing System
We introduce the probabilistic multiparty session typing system. We define typing environments ( Γ , Γ ′ , … ) (\Gamma, \Gamma', \ldots) ( Γ , Γ ′ , … ) as a mapping from a variable to a sort for typing expressions and a process variable to a session type for typing recursive processes: Γ : : = ∅ ∣ Γ , x : B ∣ Γ , X : T \Gamma::= \emptyset\mid\Gamma, x : B \mid\Gamma, X : T Γ ::= ∅ ∣ Γ , x : B ∣ Γ , X : T . The judgements for typing expressions, processes and sessions are written as Γ ⊢ e : B \Gamma\vdash e : B Γ ⊢ e : B , Γ ⊢ P : T \Gamma\vdash P : T Γ ⊢ P : T , and ⊢ M : Δ \vdash M : \Delta ⊢ M : Δ , respectively. We omit the typing rules for expressions as they are standard and identical with the rules in [22 ] . Figure 5 defines the typing rules for processes and a session. With the exception of [T-FLIP], [T-SEL] and [B-SESS], the rules are standard and identical with the corresponding rules in [22 ] . Rule [T-FLIP] is the main rule for assigning probabilities with respect to p p p to types using the probabilistic merging operator in Def. 3.8. Rule [T-SEL] types a single selection with probability 1 1 1 . Rule [B-SESS] is identical with the bottom-up rule [B-SESS] in [60 Figure 5] where session M M M is typed by a safe typing context (note: [22 ] uses the top-down typing system).
Figure 5. Probabilistic multiparty session typing system
Theorem 3.14 (Decidability). Given session M M M and typing context Δ \Delta Δ , ⊢ M : Δ \vdash M : \Delta ⊢ M : Δ is decidable.
Proof. Type-checking reduces to deciding ≤ \le ≤ , ⊓ p \sqcap_p ⊓ p , and safe ( Δ ) \operatorname{safe}(\Delta) safe ( Δ ) (decidable by Props. B.2, 3.5 and 3.11). Proof is similar to [52 thm. 4.11] (Proof in §B.3). □
Properties of Probabilistic Multiparty Sessions
This section studies a range of probabilistic properties of probabilistic multiparty session types and processes, after proving subject reduction and session fidelity . See §C for proofs.
Subject Reduction and Session Fidelity Theorems
Without probabilities, subject reduction states that each process reduction is matched by a context transition. Flips complicate this: contexts have no flip transitions, since ⊓ p \sqcap_p ⊓ p compiled each flip into new distributions at typing time, so a single probabilistic step cannot preserve typing alone. Instead, we look at the weighted pair of outcomes, recombined through the merge (case (3) below).
Theorem 4.1 (Subject Reduction). Suppose ⊢ M : Δ \vdash M : \Delta ⊢ M : Δ . If M → p M 1 M \mathrel{\to_p} M_1 M → p M 1 , then depending on the top-level rule used to derive M → p M 1 M \mathrel{\to_p} M_1 M → p M 1 we have:
(1) [R-T-IF] or [R-F-IF] implies: ⊢ M 1 : Δ \vdash M_1 : \Delta ⊢ M 1 : Δ
(2) [R-COMM] implies ∃ Δ 1 \exists\Delta_1 ∃ Δ 1 such that M 1 : Δ 1 M_1 : \Delta_1 M 1 : Δ 1 and either Δ → 1 Δ 1 \Delta\mathrel{\to_1} \Delta_1 Δ → 1 Δ 1 or Δ → n → 1 Δ 1 \Delta\mathrel{\to_n} \mathrel{\to_1} \Delta_1 Δ → n → 1 Δ 1 .
(3) [R-HEAD] or [R-TAIL] implies ∃ p , T , { T i , M i } i ∈ { 1 , 2 } , Δ ′ \exists p, T, \{T_i, M_i\}_{i \in\{1,2\}}, \Delta' ∃ p , T , { T i , M i } i ∈ { 1 , 2 } , Δ ′ such that Δ = p : T , Δ ′ \Delta= p : T, \Delta' Δ = p : T , Δ ′ and M → 1 − p M 2 M \mathrel{\to_{1-p}} M_2 M → 1 − p M 2 with ⊢ M i : ( p : T i , Δ ′ ) \vdash M_i : (p : T_i, \Delta') ⊢ M i : ( p : T i , Δ ′ ) for i ∈ { 1 , 2 } i \in\{1,2\} i ∈ { 1 , 2 } and ( p : T 1 ⊓ p T 2 , Δ ′ ) ≤ Δ (p : T_1 \sqcap_p T_2, \Delta') \leq\Delta ( p : T 1 ⊓ p T 2 , Δ ′ ) ≤ Δ .
Proof. By induction on the derivation of M → p M 1 M \mathrel{\to_p} M_1 M → p M 1 ; see §C.2.
Case (1) covers data-dependent control-flow steps. In case (2) the context matches the communication, possibly after first committing its nondeterministic choice via → n \to_n → n . In case (3), as no context transition matches a flip, the statement instead mentions both outcomes, whose residual typings recombine into T 1 ⊓ p T 2 ≤ T T_1 \sqcap_p T_2 \leq T T 1 ⊓ p T 2 ≤ T . Case (3) is illustrated in Figure 6 : merging the typings at each frontier of a flip tree yields a context that is a subtype of Δ \Delta Δ (the composed chain follows by monotonicity of merging Lemma 4.20 ).
Figure 6. Subject reduction: The session M M M reduces probabilistically to one of M 3 , … , M 6 M_3,\ldots,M_6 M 3 , … , M 6 before p sends a message to q or r . Both M 4 , M 5 M_4, M_5 M 4 , M 5 (and likewise M 8 , M 9 M_8, M_9 M 8 , M 9 ) are typed by the same context. Thm. 4.1(3) states that merging the typings T 1 , T 2 T_1, T_2 T 1 , T 2 of a participant p across both outcomes of its flip always produces a subtype of its type in Δ \Delta Δ (T 1 ⊓ p T 2 ≤ T T_1 \sqcap_{\mathbf{p}} T_2 \leq T T 1 ⊓ p T 2 ≤ T ). Under the merged context (bottom), p holds a distribution over its sends.
Session fidelity (Thm. 4.4 (3)) recovers the resolving step’s probability as the total weight of the flip paths exposing that send: for ( p , q ) ℓ 2 (\mathbf{p},\mathbf{q})\ell_2 ( p , q ) ℓ 2 , 0.8 ⋅ 0.5 + 0.2 ⋅ 0.5 = 0.5 0.8 \cdot0.5 + 0.2 \cdot0.5 = 0.5 0.8 ⋅ 0.5 + 0.2 ⋅ 0.5 = 0.5 (bold edges). The resolved context mirrors Δ 4 \Delta_4 Δ 4 , which types both M 4 M_4 M 4 and M 5 M_5 M 5 .
Corollary 4.2 (Communication Safety). If ⊢ M : Δ \vdash M : \Delta ⊢ M : Δ , then M ̸ → ∗ error M \not\to^{*} \operatorname{error} M → ∗ error .
Session fidelity states the converse: typing context reductions must be matched by the process.
Notation 4.3 (Annotated session reductions). We write M → ( p , q ) ℓ 1 M ′ M \xrightarrow[(\mathbf{p},\mathbf{q})\ell]{1} M' M 1 ( p , q ) ℓ M ′ when M → 1 M ′ M \xrightarrow{1} M' M 1 M ′ is derived by top-level rule [r-comm] exchanging label ℓ \ell ℓ from p to q .
Theorem 4.4 (Session Fidelity).
(1) If ⊢ M : Δ \vdash M : \Delta ⊢ M : Δ then Δ → ( p , q ) ℓ 1 Δ ′ \Delta\xrightarrow[(\mathbf{p},\mathbf{q})\ell]{1} \Delta' Δ 1 ( p , q ) ℓ Δ ′ implies ∃ I : { M → ∗ p i M i → ( p , q ) ℓ 1 } i ∈ I \exists I : \{M \xrightarrow{*}_{p_i} M_i \xrightarrow[(\mathbf{p},\mathbf{q})\ell]{1}\}_{i\in I} ∃ I : { M ∗ p i M i 1 ( p , q ) ℓ } i ∈ I with ∑ i ∈ I p i = 1 \sum_{i\in I}p_i = 1 ∑ i ∈ I p i = 1
(2) If ⊢ P : T \vdash P : T ⊢ P : T then p : T → n p : T ′ \mathbf{p} : T \xrightarrow{n} \mathbf{p} : T' p : T n p : T ′ implies ∃ T ′ ′ : p : T → n p : T ′ ′ \exists T'' : \mathbf{p} : T \xrightarrow{n} \mathbf{p} : T'' ∃ T ′′ : p : T n p : T ′′ and ∃ I : { p ◃ P → ∗ p i p ◃ P i ∣ p ◃ P i ↛ } i ∈ I \exists I : \{\mathbf{p} \triangleleft P \xrightarrow{*}_{p_i} \mathbf{p} \triangleleft P_i \mid\mathbf{p} \triangleleft P_i \not\to\}_{i\in I} ∃ I : { p ◃ P ∗ p i p ◃ P i ∣ p ◃ P i → } i ∈ I with ∑ i ∈ I p i = 1 \sum_{i\in I}p_i = 1 ∑ i ∈ I p i = 1 and a set of types { T i ∣ ⊢ P i : T i } i ∈ I \{T_i \mid\vdash P_i : T_i\}_{i\in I} { T i ∣⊢ P i : T i } i ∈ I such that \bigsqcap_{i\in I}(T_i,p_i) \leq T''
(3) If ⊢ P : T \vdash P : T ⊢ P : T then p : T → p p : ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ \mathbf{p} : T \xrightarrow{p} \mathbf{p} : \bigoplus_{1:q!\ell\langle B\rangle.T'} p : T p p : ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ implies ∃ I : { p ◃ P → ∗ p i p ◃ q ! ℓ ⟨ e i ⟩ . P i } i ∈ I \exists I : \{\mathbf{p} \triangleleft P \xrightarrow{*}_{p_i} \mathbf{p} \triangleleft q!\ell\langle e_i\rangle.P_i\}_{i\in I} ∃ I : { p ◃ P ∗ p i p ◃ q ! ℓ ⟨ e i ⟩ . P i } i ∈ I with ∑ i ∈ I p i = p \sum_{i\in I}p_i = p ∑ i ∈ I p i = p and ⊢ P i : T ′ \vdash P_i : T' ⊢ P i : T ′ for all i ∈ I i \in I i ∈ I
(2) and (3) are easily lifted to ⊢ M : Δ \vdash M : \Delta ⊢ M : Δ through [ct-sc].
Proof. Corollary of a strengthened statement, proved by induction; see §C.2. □
Case (1) states that a context communication of probability 1 1 1 is realised by weighted paths M → ∗ p i M i M \xrightarrow{*}_{p_i} M_i M ∗ p i M i , each arriving where the communication fires surely, with ∑ i ∈ I p i = 1 \sum_{i\in I}p_i = 1 ∑ i ∈ I p i = 1 . Case (2) states that when the context commits its nondeterministic choice, the process resolves its flips down to leaves { P i } i ∈ I \{P_i\}_{i\in I} { P i } i ∈ I that reduce no further, and merging the leaf types at their path weights, \bigsqcap_{i\in I}(T_i,p_i) , recovers a subtype of the committed type. Analogously, case (3) guarantees that p ’s probabilistic transition to p : ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ \mathbf{p} : \bigoplus_{1:q!\ell\langle B\rangle.T'} p : ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ in the typing context corresponds to the probability of reducing to a leaf in { p ◃ q ! ℓ ⟨ e i ⟩ . P i } i ∈ I \{\mathbf{p} \triangleleft q!\ell\langle e_i\rangle.P_i\}_{i\in I} { p ◃ q ! ℓ ⟨ e i ⟩ . P i } i ∈ I , and that the continuation P i P_i P i is typed by T ′ T' T ′ . This is illustrated in Figure 6 , with the bold paths representing ( p , q ) ℓ 2 (\mathbf{p},\mathbf{q})\ell_2 ( p , q ) ℓ 2 with weights 0.4 + 0.1 = 0.5 0.4 + 0.1 = 0.5 0.4 + 0.1 = 0.5 .
Paths and Probabilities
To take probabilities into account, we formalise the notion of paths and the probability of obtaining a set of paths. Since typing contexts combine probabilistic choice with nondeterminism, such probabilities are well-defined only relative to a scheduler that resolves the nondeterminism. We therefore interpret a typing context as a finite Markov Decision Process (MDP), define the probability of a set of paths under a fixed scheduler by standard means [36 ] , and obtain lower bounds that transfer to well-typed sessions by taking the minimum over all (fair) schedulers § 5.4 .
A typing context can be seen as inducing a finite MDP — an LTS with nondeterministic and probabilistic state transitions. We distinguish between two sources of nondeterminism: (1); internal Σ \Sigma Σ resolutions p : ∑ i ∈ I T i → p : T i n p : T i \mathbf{p}: \sum_{i\in I} T_i \xrightarrow{\mathbf{p}:T_i}_n \mathbf{p}:T_i p : ∑ i ∈ I T i p : T i n p : T i , and (2); scheduling of parallel enabled roles — as separated choice means that a participant p \mathbf{p} p may be simultaneously waiting to receive from both q \mathbf{q} q and r \mathbf{r} r , and both being enabled, the scheduler must choose which pair gets to communicate, consider for instance Figure 7 — if r \mathbf{r} r is scheduled to send there is a 0.5 0.5 0.5 chance of deadlocking (r \mathbf{r} r sends stop to p \mathbf{p} p and both quit, leaving q \mathbf{q} q hanging), scheduling q \mathbf{q} q on the other hand sends go to p \mathbf{p} p and recurses. Thus scheduling of concurrently enabled participants may affect the probability of satisfying a property. Later, we will work with a restricted class of fair schedulers that cannot starve persistently enabled actions.
Figure 7. A deadlock dependent on scheduling.
Definition 4.5 (Path). A path ξ \xi ξ is a (potentially infinite) sequence of contexts Δ 1 ; Δ 2 ; ⋯ \Delta_1; \Delta_2; \cdots Δ 1 ; Δ 2 ; ⋯ such that for all i < ∣ ξ ∣ i < |\xi| i < ∣ ξ ∣ we have Δ i → p Δ i + 1 \Delta_i \xrightarrow{\mathbf{p}} \Delta_{i+1} Δ i p Δ i + 1 or Δ i → n Δ i + 1 \Delta_i \xrightarrow{\mathbf{n}} \Delta_{i+1} Δ i n Δ i + 1 . A path ξ \xi ξ is complete if it is either infinite or Δ ∣ ξ ∣ ↛ \Delta_{|\xi|} \not\to Δ ∣ ξ ∣ → . We write Ξ ( Δ ) \Xi(\Delta) Ξ ( Δ ) for the set of all complete paths starting from Δ \Delta Δ .
Definition 4.6 (Scheduler). A scheduler ϕ ∈ Φ Δ \phi\in\Phi^\Delta ϕ ∈ Φ Δ for typing context Δ \Delta Δ is a function mapping each finite path Δ 1 ; ⋯ ; Δ n \Delta_1; \cdots; \Delta_n Δ 1 ; ⋯ ; Δ n of Δ \Delta Δ with Δ n → \Delta_n \to Δ n → to a pair ( p , Δ ) (\mathbf{p}, \Delta) ( p , Δ ) , of a participant and an optional typing context, such that: (1) if ϕ ( Δ 1 ; ⋯ ; Δ n ) = ( p , ∅ ) \phi(\Delta_1; \cdots; \Delta_n) = (\mathbf{p}, \varnothing) ϕ ( Δ 1 ; ⋯ ; Δ n ) = ( p , ∅ ) , then either Δ n → p \Delta_n \xrightarrow{\mathbf{p}} Δ n p for some p \mathbf{p} p , or Δ n → ( p , q ) ℓ 1 \Delta_n \xrightarrow{(\mathbf{p},\mathbf{q})\ell}_1 Δ n ( p , q ) ℓ 1 for some q \mathbf{q} q and ℓ \ell ℓ ; and (2) if ϕ ( Δ 1 ; ⋯ ; Δ n ) = ( p , Δ n + 1 ) \phi(\Delta_1; \cdots; \Delta_n) = (\mathbf{p}, \Delta_{n+1}) ϕ ( Δ 1 ; ⋯ ; Δ n ) = ( p , Δ n + 1 ) , then Δ n → p n Δ n + 1 \Delta_n \xrightarrow{\mathbf{p}}_n \Delta_{n+1} Δ n p n Δ n + 1 .
Fixing a scheduler ϕ ∈ Φ Δ \phi\in\Phi^\Delta ϕ ∈ Φ Δ resolves all nondeterminism in the MDP of Δ \Delta Δ , inducing a Discrete-time Markov chain (DTMC) in which every transition carries a probability (the scheduler induced transitions can be seen to carry probability 1 1 1 ). The probability of a finite path is then the product of its transition probabilities; we write Ξ ϕ ( Δ ) \Xi_\phi(\Delta) Ξ ϕ ( Δ ) for the set of complete paths induced by ϕ \phi ϕ from Δ \Delta Δ . To lift finite-path probabilities to a measure on complete paths, we follow [36 ] and take cylinder sets as our basic events.
Definition 4.7 (Cylinder set). The cylinder set Cyl ( ξ ) \operatorname{Cyl}(\xi) Cyl ( ξ ) of a finite path ξ = Δ 1 ; ⋯ ; Δ n \xi= \Delta_1; \cdots; \Delta_n ξ = Δ 1 ; ⋯ ; Δ n of the DTMC induced by a scheduler ϕ \phi ϕ is the set of all complete paths in Ξ ϕ ( Δ 1 ) \Xi_\phi(\Delta_1) Ξ ϕ ( Δ 1 ) with prefix ξ \xi ξ ; in particular, if ξ \xi ξ is itself complete, then Cyl ( ξ ) = { ξ } \operatorname{Cyl}(\xi) = \{\xi\} Cyl ( ξ ) = { ξ } . We write P Δ 1 ϕ \mathbb{P}^{\phi}_{\Delta_1} P Δ 1 ϕ for the unique probability measure on the σ \sigma σ -algebra generated by the cylinder sets with P Δ 1 ϕ ( Cyl ( ξ ) ) = ∏ i = 1 n − 1 p i \mathbb{P}^{\phi}_{\Delta_1}(\operatorname{Cyl}(\xi)) = \prod_{i=1}^{n-1} p_i P Δ 1 ϕ ( Cyl ( ξ )) = ∏ i = 1 n − 1 p i , where each Δ i → p i Δ i + 1 \Delta_i \xrightarrow{p_i} \Delta_{i+1} Δ i p i Δ i + 1 ; measurable sets of paths are events .
For a predicate f f f on paths, we write P Δ ϕ ( f ) = P Δ ϕ ( { ξ ∈ Ξ ϕ ( Δ ) ∣ f ( ξ ) } ) \mathbb{P}^{\phi}_{\Delta}(f) = \mathbb{P}^{\phi}_{\Delta}(\{\xi\in\Xi_\phi(\Delta) \mid f(\xi)\}) P Δ ϕ ( f ) = P Δ ϕ ({ ξ ∈ Ξ ϕ ( Δ ) ∣ f ( ξ )}) for the probability of obtaining a path satisfying f f f under ϕ \phi ϕ from Δ \Delta Δ . For state predicate g g g we define ◊ g \Diamond g ◊ g to be the event of “eventually g g g ”, where ( ◊ g ) ( ξ ) ⟺ ∃ i ≤ ∣ ξ ∣ : g ( ξ [ i ] ) (\Diamond g)(\xi) \Longleftrightarrow\exists i \leq|\xi| : g(\xi[i]) ( ◊ g ) ( ξ ) ⟺ ∃ i ≤ ∣ ξ ∣ : g ( ξ [ i ]) .
Probabilistic Deadlock-Freedom and Liveness for Typing Contexts
In this section we define two properties of typing contexts, deadlock-freedom and the slightly stronger property of liveness . We first define the non-probabilistic version of each before introducing their probabilistic counterparts. A context Δ \Delta Δ is deadlocked if it has no transitions and some participant has a pending action. A context is deadlock-free if no deadlocked state is reachable.
Definition 4.8 (Deadlock-freedom).
(1) A context Δ \Delta Δ is deadlocked , written deadlock ( Δ ) \operatorname{deadlock}(\Delta) deadlock ( Δ ) , if Δ ↛ \Delta\not\to Δ → and ∃ p : Δ ( p ) ≠ end \exists p : \Delta(p) \ne\operatorname{end} ∃ p : Δ ( p ) = end .
(2) A context Δ \Delta Δ is deadlock-free , written df ( Δ ) \operatorname{df}(\Delta) df ( Δ ) , if Δ → ∗ Δ ′ \Delta\to^{*} \Delta' Δ → ∗ Δ ′ implies ¬ deadlock ( Δ ′ ) \neg\operatorname{deadlock}(\Delta') ¬ deadlock ( Δ ′ ) .
Before introducing the concept of liveness , we define what it means for a path to be fair , as our notion of liveness depends upon the scheduler being fair.
Definition 4.9 (Fair path). A complete path ξ \xi ξ is fair, written fair ( ξ ) \operatorname{fair}(\xi) fair ( ξ ) , if the following hold:
(1) ∀ p , q , ℓ \forall p,q,\ell ∀ p , q , ℓ : if ∀ i ∃ j ≥ i : Δ j → ( p , q ) ℓ 1 \forall i\ \exists j \ge i : \Delta_j \xrightarrow{(p,q)\ell}_1 ∀ i ∃ j ≥ i : Δ j ( p , q ) ℓ 1 then ∀ i ∃ n ≥ i : Δ n → ( p , q ) ℓ 1 Δ n + 1 \forall i\ \exists n \ge i : \Delta_n \xrightarrow{(p,q)\ell}_1 \Delta_{n+1} ∀ i ∃ n ≥ i : Δ n ( p , q ) ℓ 1 Δ n + 1
(2) ∀ p ∀ i \forall p\ \forall i ∀ p ∀ i : if Δ i → p : τ n \Delta_i \xrightarrow{p:\tau}_n Δ i p : τ n then ∃ n ≥ i : Δ n → p : τ n Δ n + 1 \exists n \ge i : \Delta_n \xrightarrow{p:\tau}_n \Delta_{n+1} ∃ n ≥ i : Δ n p : τ n Δ n + 1
(3) ∀ p ∀ i \forall p\ \forall i ∀ p ∀ i : if Δ i → p : ρ \Delta_i \xrightarrow{p:\rho} Δ i p : ρ then ∃ n ≥ i , p : Δ n → p : ρ p Δ n + 1 \exists n \ge i,\ p : \Delta_n \xrightarrow{p:\rho}_p \Delta_{n+1} ∃ n ≥ i , p : Δ n p : ρ p Δ n + 1
Intuitively, a path is fair if a participant p p p cannot be denied sending an enabled communication action indefinitely; and if p p p has an internal step to take then it will eventually do so.
A path is then live if any p p p with a pending input or output action along it eventually communicates — note that this does not require the communication partner to be immediately available.
Definition 4.10 (Live path). A path ξ \xi ξ is live , written live ( ξ ) \operatorname{live}(\xi) live ( ξ ) , if for every Δ i ∈ ξ \Delta_i \in\xi Δ i ∈ ξ :
(1) if Δ i → p : q ! ℓ ⟨ B ⟩ 1 \Delta_i \xrightarrow{p:q!\ell\langle B\rangle}_1 Δ i p : q ! ℓ ⟨ B ⟩ 1 , then ∃ n ≥ i : Δ n → ( p , q ) ℓ 1 Δ n + 1 \exists n \ge i : \Delta_n \xrightarrow{(p,q)\ell}_1 \Delta_{n+1} ∃ n ≥ i : Δ n ( p , q ) ℓ 1 Δ n + 1
(2) if Δ i → q : p ? ℓ ( B ) 1 \Delta_i \xrightarrow{q:p?\ell(B)}_1 Δ i q : p ? ℓ ( B ) 1 , then ∃ n ≥ i , r , ℓ ′ : Δ n → ( r , q ) ℓ ′ 1 Δ n + 1 \exists n \ge i,\ r,\ell' : \Delta_n \xrightarrow{(r,q)\ell'}_1 \Delta_{n+1} ∃ n ≥ i , r , ℓ ′ : Δ n ( r , q ) ℓ ′ 1 Δ n + 1
Definition 4.11 (Live contexts). Given a context Δ \Delta Δ , Δ \Delta Δ is live, written live ( Δ ) \operatorname{live}(\Delta) live ( Δ ) , if every complete path ξ ∈ Ξ ( Δ ) \xi\in\Xi(\Delta) ξ ∈ Ξ ( Δ ) that is fair is also live.
Example 4.12 (Non-liveness of the calculator service). Consider again the calculator service of Ex. 2.1, whose types are given in Ex. 3.1. The typing context formed by Δ = u : T u , s : T s , c : T c \Delta= u:T_u, s:T_s, c:T_c Δ = u : T u , s : T s , c : T c is not live according to Def. 4.11 . To see this, note that there is an infinite reduction path
Δ → ( u , s ) incr 1 ⋅ → ( s , c ) incr 1 ⋅ → τ n ⋅ → ( c , s ) error 0.2 ⋅ → ( s , c ) incr 1 ⋅ → τ n ⋅ → ( c , s ) error 0.2 ⋅ → ( s , c ) incr 1 ⋅ → τ n ⋅ → ( c , s ) error 0.2 ⋅ ⋯ \Delta\xrightarrow{(u,s)\operatorname{incr}}_1 \cdot\xrightarrow{(s,c)\operatorname{incr}}_1 \cdot\xrightarrow{\tau}_n \cdot\xrightarrow{(c,s)\operatorname{error}}_{0.2} \cdot\xrightarrow{(s,c)\operatorname{incr}}_1 \cdot\xrightarrow{\tau}_n \cdot\xrightarrow{(c,s)\operatorname{error}}_{0.2} \cdot\xrightarrow{(s,c)\operatorname{incr}}_1 \cdot\xrightarrow{\tau}_n \cdot\xrightarrow{(c,s)\operatorname{error}}_{0.2} \cdot\cdots Δ ( u , s ) incr 1 ⋅ ( s , c ) incr 1 ⋅ τ n ⋅ ( c , s ) error 0.2 ⋅ ( s , c ) incr 1 ⋅ τ n ⋅ ( c , s ) error 0.2 ⋅ ( s , c ) incr 1 ⋅ τ n ⋅ ( c , s ) error 0.2 ⋅ ⋯ where after u u u ’s initial message, u u u is waiting at u → u : c ? res ( int ) 1 u \xrightarrow{u:c?\operatorname{res}(\operatorname{int})}_1 u u : c ? res ( int ) 1 while s s s and c c c are communicating indefinitely, yet the probability of seeing this path is lim n → ∞ 0.2 n = 0 \lim_{n\to\infty} 0.2^n = 0 lim n → ∞ 0. 2 n = 0 .
Ex. 4.12 illustrates that for probabilistic programs, it would be desirable to have more permissive notions of the properties, admitting non-live (or deadlocking) paths so long as they have measure 0 0 0 — or indeed any quantifiable measure. We therefore measure both properties, asking: what probability of deadlock-freedom, and of liveness, can be guaranteed however the nondeterminism is resolved? Since the probability of an event is well-defined only relative to a scheduler (Defs. 4.6 and 4.7 ), we quantify over those schedulers that induce fair paths with probability 1 1 1 ;
Definition 4.13 (Fair schedulers). A scheduler ϕ \phi ϕ over Δ \Delta Δ is fair if ϕ ∈ Φ F Δ = { ϕ ∈ Φ ∣ P Δ ϕ ( fair ) = 1 } \phi\in\Phi_F^\Delta= \{\phi\in\Phi\mid\mathbb{P}_\Delta^\phi(\operatorname{fair}) = 1\} ϕ ∈ Φ F Δ = { ϕ ∈ Φ ∣ P Δ ϕ ( fair ) = 1 }
Definition 4.14 (Probabilistic deadlock-freedom and liveness). For a context Δ \Delta Δ , we define the minimum probability of deadlock-freedom and of liveness as
P df min ( Δ ) = 1 − max ϕ ∈ Φ F Δ P Δ ϕ ( ◊ deadlock ) P live min ( Δ ) = min ϕ ∈ Φ F Δ P Δ ϕ ( live ) \mathbb{P}_{\operatorname{df}}^{\min}(\Delta) = 1 - \max_{\phi\in\Phi_F^\Delta} \mathbb{P}_\Delta^\phi(\Diamond\operatorname{deadlock})
\qquad
\mathbb{P}_{\operatorname{live}}^{\min}(\Delta) = \min_{\phi\in\Phi_F^\Delta} \mathbb{P}_\Delta^\phi(\operatorname{live}) P df m i n ( Δ ) = 1 − ϕ ∈ Φ F Δ max P Δ ϕ ( ◊ deadlock ) P live m i n ( Δ ) = ϕ ∈ Φ F Δ min P Δ ϕ ( live )
Definition 4.15 (Almost-sure properties). Δ \Delta Δ is almost-surely deadlock-free , written asdf ( Δ ) \operatorname{asdf}(\Delta) asdf ( Δ ) , if P df min ( Δ ) = 1 \mathbb{P}_{\operatorname{df}}^{\min}(\Delta) = 1 P df m i n ( Δ ) = 1 , and almost-surely live , written aslive ( Δ ) \operatorname{aslive}(\Delta) aslive ( Δ ) , if P live min ( Δ ) = 1 \mathbb{P}_{\operatorname{live}}^{\min}(\Delta) = 1 P live m i n ( Δ ) = 1 .
Example 4.16 (Calculator service extended). Consider a refinement of the calculator service from Ex. 3.1 whose labelled transition system is given in Figure 8 . Δ 1 − 5 \Delta_{1-5} Δ 1 − 5 correspond to the original session from Ex. 3.1, but the 0.2 0.2 0.2 probability of an error occurring has been distributed into two
Figure 8. A refined calculator service Ex. 4.16 .
additional events now, (1); with probability 0.05 0.05 0.05 the error is critical and c c c informs s s s after which both quit, leaving u u u hanging (a deadlock, Δ 9 \Delta_9 Δ 9 ), (2); with probability 0.05 0.05 0.05 , c c c loses its connection (disconn ) to s s s , entering a retry loop (Δ 10 \Delta_{10} Δ 10 –Δ 11 \Delta_{11} Δ 11 ), eventually it may reconnect (Δ 12 \Delta_{12} Δ 12 ) but this is not guaranteed. Finally, s s s knows c c c is faulty, and will with probability 0.1 0.1 0.1 upgrade to a non-faulty mode, after which the 3 participants can communicate and remain live (Δ 6 \Delta_6 Δ 6 –Δ 8 \Delta_8 Δ 8 ). The table on the right side of Figure 8 gives P l i v e min ( Δ ) \mathbb{P}^{\min}_{\mathrm{live}}(\Delta) P live m i n ( Δ ) and P d f min ( Δ ) \mathbb{P}^{\min}_{\mathrm{df}}(\Delta) P df m i n ( Δ ) for each Δ \Delta Δ . Worthy of note is the probability of liveness is 0 0 0 in Δ 10 \Delta_{10} Δ 10 –Δ 11 \Delta_{11} Δ 11 , as there exists a fair path (retry indefinitely) that starves u u u — a fair adversarial scheduler can always pick the action Δ 10 → s : τ n Δ 11 \Delta_{10} \xrightarrow{s:\tau}_{n} \Delta_{11} Δ 10 s : τ n Δ 11 , keeping the region closed. The full type for Δ 1 \Delta_1 Δ 1 is given in Ex. C.1.
Example 4.17 (Separating examples). Figure 9 summarises the relationships between the properties of this section by exhibiting a few examples that fall into different categories of either partially or fully satisfying a property. The examples are numbered to match their regions in the diagram.
Figure 9. Relationships between the properties. Numbers identify examples in the right-hand panel which separate properties. For example, the typing context in 2 is safe and partially deadlock-free, but not live nor completely deadlock-free.
The properties are stable along subtyping : replacing a context by any subtype — as the verification workflow of Figure 1 does when checking an inferred context against a declared one — preserves every property of this section, qualitatively and in probability:
Proposition 4.18 (≤ \leq ≤ -monotonicity). (Proof in §C.3). Let Δ ≤ Δ ′ \Delta\leq\Delta' Δ ≤ Δ ′ and safe ( Δ ′ ) \operatorname{safe}(\Delta') safe ( Δ ′ ) , then:
(1) φ ( Δ ′ ) ⟹ φ ( Δ ) \varphi(\Delta') \Longrightarrow\varphi(\Delta) φ ( Δ ′ ) ⟹ φ ( Δ ) if φ ∈ { safe , df , live } \varphi\in\{\operatorname{safe},\operatorname{df},\operatorname{live}\} φ ∈ { safe , df , live } ; and (2) P d f min ( Δ ′ ) ≤ P d f min ( Δ ) \mathbb{P}^{\min}_{\mathrm{df}}(\Delta') \leq\mathbb{P}^{\min}_{\mathrm{df}}(\Delta) P df m i n ( Δ ′ ) ≤ P df m i n ( Δ ) and P l i v e min ( Δ ′ ) ≤ P l i v e min ( Δ ) \mathbb{P}^{\min}_{\mathrm{live}}(\Delta') \leq\mathbb{P}^{\min}_{\mathrm{live}}(\Delta) P live m i n ( Δ ′ ) ≤ P live m i n ( Δ ) .
Thus, properties model checked for Δ ′ \Delta' Δ ′ transfer to every subtype and, by [t-sub], to every session typed below it. On the other hand, widening to a supertype may weaken the bounds by admitting additional behaviours: the guarantees remain sound but need not be tight.
Example 4.19 (Bounds). To show how ≤ \leq ≤ may weaken bounds, consider first the session:
⊢ ( q ⊲ flip ( 0.5 ) { h ⇒ p ! m □ t ⇒ r ! m } ∣ p ⊲ q ? m ) : q : ⊕ { 0.5 : p ! m , 0.5 : r ! m } , p : q ? m \vdash(q \mathbin{\lhd} \operatorname{flip}(0.5)\{h\Rightarrow p!m \mathbin{\Box} t\Rightarrow r!m\} \mid p \mathbin{\lhd} q?m) : q : \oplus\{0.5 : p!m, 0.5 : r!m\},\ p : q?m ⊢ ( q ⊲ flip ( 0.5 ) { h ⇒ p ! m □ t ⇒ r ! m } ∣ p ⊲ q ? m ) : q : ⊕ { 0.5 : p ! m , 0.5 : r ! m } , p : q ? m
whose type is partially deadlock-free and live as shown in bullet 4 of Figure 9 . In this case the session and typing context LTS are isomorphic, and indeed their lower bounds are identical. Consider now what happens when q q q has an always-true if -statement over action p ! m p!m p ! m and its previous coinflip :
⊢ q ⊲ if true then p ! m else flip ( 0.5 ) { h ⇒ p ! m □ t ⇒ r ! m } ∣ p ⊲ q ? m \vdash\quad q \mathbin{\lhd} \text{if true then }p!m\text{ else }\operatorname{flip}(0.5)\{h\Rightarrow p!m \mathbin{\Box} t\Rightarrow r!m\}\mid p \mathbin{\lhd} q?m ⊢ q ⊲ if true then p ! m else flip ( 0.5 ) { h ⇒ p ! m □ t ⇒ r ! m } ∣ p ⊲ q ? m
: q : Σ { ⊕ { p ! m } , ⊕ { 0.5 : p ! m , 0.5 : r ! m } } , p : q ? m :\quad q : \Sigma\{\oplus\{p!m\},\ \oplus\{0.5 : p!m,0.5 : r!m\}\},\ p : q?m : q : Σ { ⊕ { p ! m } , ⊕ { 0.5 : p ! m , 0.5 : r ! m }} , p : q ? m
By [SUB-\succeq] the two branches have been widened to a nondeterministic choice (abstracting away the conditional used to make the choice), but the cost is obvious; while the session is clearly live the type still reports probability 0.5 0.5 0.5 of satisfying liveness , as an adversarial scheduler may always choose to pick the coinflip branch.
Finally, we note merging is also compatible with refinement:
Lemma 4.20 (⊓ \sqcap ⊓ -monotonicity). (Proof in §C.3). Suppose T i ≤ T i ′ T_i \leq T'_i T i ≤ T i ′ for i ∈ { 1 , 2 } i \in\{1,2\} i ∈ { 1 , 2 } and T 1 ′ ⊓ p T 2 ′ T'_1 \sqcap_p T'_2 T 1 ′ ⊓ p T 2 ′ is defined, then T 1 ⊓ p T 2 T_1 \sqcap_p T_2 T 1 ⊓ p T 2 is defined and T 1 ⊓ p T 2 ≤ T 1 ′ ⊓ p T 2 ′ T_1 \sqcap_p T_2 \leq T'_1 \sqcap_p T'_2 T 1 ⊓ p T 2 ≤ T 1 ′ ⊓ p T 2 ′ .
Hence, replacing its operands by subtypes can only strengthen the resulting bounds.
Probabilistic Deadlock-Freedom and Liveness for Multiparty Processes
In this section we transfer the bounds obtained in the previous section on Δ \Delta Δ back to sessions M M M typed as ⊢ M : Δ \vdash M : \Delta ⊢ M : Δ . We first adapt the definitions of § 5.2 and 4.3 from typing contexts to sessions, and then show that P d f min ( Δ ) \mathbb{P}^{\min}_{\mathrm{df}}(\Delta) P df m i n ( Δ ) and P l i v e min ( Δ ) \mathbb{P}^{\min}_{\mathrm{live}}(\Delta) P live m i n ( Δ ) bound the corresponding properties of M M M .
Definition 4.21 (Session paths). A (session) path ξ \xi ξ is a sequence M 1 ; M 2 ; ⋯ M_1; M_2; \cdots M 1 ; M 2 ; ⋯ with M i → p i M i + 1 M_i \xrightarrow{p_i} M_{i+1} M i p i M i + 1 for all i ∈ [ 1 , ∣ ξ ∣ ) i \in[1,|\xi|) i ∈ [ 1 , ∣ ξ ∣ ) ; complete if infinite or M ∣ ξ ∣ ↛ M_{|\xi|} \not\to M ∣ ξ ∣ → .
Definition 4.22 (Session scheduler). A scheduler ϕ ∈ Φ M \phi\in\Phi^M ϕ ∈ Φ M for session M M M is a function mapping each finite path M 1 ; ⋯ ; M n M_1; \cdots; M_n M 1 ; ⋯ ; M n of M M M with M n → M_n \to M n → to a participant p p p such that if ϕ ( M 1 ; ⋯ ; M n ) = p \phi(M_1;\cdots;M_n)=p ϕ ( M 1 ; ⋯ ; M n ) = p , then either M n ⟹ p ▹ P ∣ M ′ M_n \Longrightarrow p \mathbin{\triangleright} P \mathbin{|} M' M n ⟹ p ▹ P ∣ M ′ and p ▹ P → p p ▹ P ′ p \mathbin{\triangleright} P \to_p p \mathbin{\triangleright} P' p ▹ P → p p ▹ P ′ for some p p p , or M n → ( p , q ) ℓ 1 M_n \xrightarrow{(p,q)\ell}_1 M n ( p , q ) ℓ 1 for some q q q and ℓ \ell ℓ .
Complete paths Ξ ( M ) \Xi(M) Ξ ( M ) and Ξ ϕ ( M ) \Xi_\phi(M) Ξ ϕ ( M ) , and probability measure P M ϕ \mathbb{P}^{\phi}_M P M ϕ are as defined in Defs. 4.6 and 4.7.
Definition 4.23 (Fair session paths). A session path ξ \xi ξ is fair, written fair ( ξ ) \operatorname{fair}(\xi) fair ( ξ ) if:
(1) ∀ p , q \forall p,q ∀ p , q : if ∀ n ∃ m ≥ n , ℓ \forall n\,\exists m\ge n,\ell ∀ n ∃ m ≥ n , ℓ with M m → ( p , q ) ℓ M_m \xrightarrow{(p,q)\ell} M m ( p , q ) ℓ , then ∀ n ∃ m ≥ n \forall n\,\exists m\ge n ∀ n ∃ m ≥ n with M m → ( p , q ) ℓ M m + 1 M_m \xrightarrow{(p,q)\ell} M_{m+1} M m ( p , q ) ℓ M m + 1
(2) ∀ p ∀ n \forall p\,\forall n ∀ p ∀ n : if M n ⟹ p ▹ flip ( p ) { h ⇒ P ∣ t ⇒ Q } ∣ M ′ M_n \Longrightarrow p \mathbin{\triangleright} \operatorname{flip}(p)\{h\Rightarrow P \mathbin{|} t\Rightarrow Q\} \mathbin{|} M' M n ⟹ p ▹ flip ( p ) { h ⇒ P ∣ t ⇒ Q } ∣ M ′ or M n ⟹ p ▹ if e then P else Q ∣ M ′ M_n \Longrightarrow p \mathbin{\triangleright} \operatorname{if}\ e\ \operatorname{then}\ P\ \operatorname{else}\ Q \mathbin{|} M' M n ⟹ p ▹ if e then P else Q ∣ M ′ , then ∃ m > n \exists m>n ∃ m > n with M m ⟹ p ▹ P ∣ M ′ ′ M_m \Longrightarrow p \mathbin{\triangleright} P \mathbin{|} M'' M m ⟹ p ▹ P ∣ M ′′ or M m ⟹ p ▹ Q ∣ M ′ ′ M_m \Longrightarrow p \mathbin{\triangleright} Q \mathbin{|} M'' M m ⟹ p ▹ Q ∣ M ′′
Definition 4.24 (Live session paths). A session path ξ \xi ξ is live, written live ( ξ ) \operatorname{live}(\xi) live ( ξ ) if for every M n ∈ ξ M_n \in\xi M n ∈ ξ :
(1) if M n ⟹ p ▹ q ! ℓ ⟨ e ⟩ . P ∣ M ′ M_n \Longrightarrow p \mathbin{\triangleright} q!\ell\langle e\rangle.P \mathbin{|} M' M n ⟹ p ▹ q ! ℓ ⟨ e ⟩ . P ∣ M ′ , then ∃ m ≥ n \exists m\ge n ∃ m ≥ n with M m → ( p , q ) ℓ M m + 1 M_m \xrightarrow{(p,q)\ell} M_{m+1} M m ( p , q ) ℓ M m + 1
(2) if M n ⟹ q ▹ ∑ i ∈ I p i ? ℓ i ( x i ) . Q i ∣ M ′ M_n \Longrightarrow q \mathbin{\triangleright} \sum_{i\in I} p_i?\ell_i(x_i).Q_i \mathbin{|} M' M n ⟹ q ▹ ∑ i ∈ I p i ? ℓ i ( x i ) . Q i ∣ M ′ , then ∃ m ≥ n , j ∈ I \exists m\ge n,\,j\in I ∃ m ≥ n , j ∈ I with M m → ( p j , q ) ℓ j M m + 1 M_m \xrightarrow{(p_j,q)\ell_j} M_{m+1} M m ( p j , q ) ℓ j M m + 1
A session M M M is live, written live ( M ) \operatorname{live}(M) live ( M ) , if every fair complete ξ ∈ Ξ ( M ) \xi\in\Xi(M) ξ ∈ Ξ ( M ) is live; M M M is deadlock ( M ) \operatorname{deadlock}(M) deadlock ( M ) , if M ↛ M\not\to M → and ∃ p , P : M ⟹ p ▹ P ∣ M ′ \exists p,P: M\Longrightarrow p\mathbin{\triangleright}P\mathbin{|}M' ∃ p , P : M ⟹ p ▹ P ∣ M ′ with P ≠ 0 P\ne0 P = 0 ; and df ( M ) \operatorname{df}(M) df ( M ) if M → ∗ M ′ M\to^*M' M → ∗ M ′ implies ¬ deadlock ( M ′ ) \lnot\operatorname{deadlock}(M') ¬ deadlock ( M ′ ) .
Analogously to Def. 4.14, we define the lower bounds on these properties over all fair schedulers:
Definition 4.25 (Probabilistic properties of sessions).
P d f min ( M ) = 1 − max ϕ ∈ Φ F M P M ϕ ( ◊ deadlock ) P l i v e min ( M ) = min ϕ ∈ Φ F M P M ϕ ( live ) \mathbb{P}^{\min}_{\mathrm{df}}(M)=1-\max_{\phi\in\Phi^M_F}\mathbb{P}^{\phi}_M(\Diamond\operatorname{deadlock})
\qquad
\mathbb{P}^{\min}_{\mathrm{live}}(M)=\min_{\phi\in\Phi^M_F}\mathbb{P}^{\phi}_M(\operatorname{live}) P df m i n ( M ) = 1 − ϕ ∈ Φ F M max P M ϕ ( ◊ deadlock ) P live m i n ( M ) = ϕ ∈ Φ F M min P M ϕ ( live )
with asf ( M ) \operatorname{asf}(M) asf ( M ) and aslive ( M ) \operatorname{aslive}(M) aslive ( M ) as defined in Def. 4.15.
The main theorems of this paper follow, with proofs in §C: each property transfers from Δ \Delta Δ to M M M , qualitatively and in probability.
Theorem 4.26. (Proof in §C.4. ) If ⊢ M : Δ \vdash M:\Delta ⊢ M : Δ , then (1) df ( Δ ) \operatorname{df}(\Delta) df ( Δ ) implies df ( M ) \operatorname{df}(M) df ( M ) ; and (2) P d f min ( Δ ) ≤ P d f min ( M ) \mathbb{P}^{\min}_{\mathrm{df}}(\Delta)\le\mathbb{P}^{\min}_{\mathrm{df}}(M) P df m i n ( Δ ) ≤ P df m i n ( M )
Theorem 4.27 (Liveness). (Proof in §C.4). If M : Δ M : \Delta M : Δ , then (1) live ( Δ ) \operatorname{live}(\Delta) live ( Δ ) implies live ( M ) \operatorname{live}(M) live ( M ) ; (2) P l i v e min ( Δ ) ≤ P l i v e min ( M ) P_{\mathrm{live}}^{\min}(\Delta) \leq P_{\mathrm{live}}^{\min}(M) P live m i n ( Δ ) ≤ P live m i n ( M ) .
Corollary 4.28. If M : Δ M : \Delta M : Δ , then asf ( Δ ) \operatorname{asf}(\Delta) asf ( Δ ) implies asf ( M ) \operatorname{asf}(M) asf ( M ) and aslive ( Δ ) \operatorname{aslive}(\Delta) aslive ( Δ ) implies aslive ( M ) \operatorname{aslive}(M) aslive ( M ) .
Translating Probabilistic Multiparty Session Types into PRISM
This section presents the translation from probabilistic multiparty session types to the PRISM modelling language. We first introduce the syntax and semantics of the PRISM language (§ 6.1 ), before describing the translation function (§ 6.2 ). Finally, we show the correctness of this encoding with respect to the operational semantics of session types and of PRISM (§ 6.3 ).
PRISM Syntax and Operational Semantics
To enable a precise discussion, we first formally define the relevant subset of the PRISM language. We closely follow [14 , 57 ] , with modifications to syntax and a more precise discussion of states.
Definition 5.1 (PRISM Syntax). The syntax of PRISM models is given by
M , N : : = { C i } i ∈ I ∣ M ∥ N (module, composition) C : : = [ α ] g → ∑ i ∈ I p i : u i (command, with ∑ i ∈ I p i = 1 and p i ∈ [ 0 , 1 ] ) g , g ′ : : = ( x = v ) ∣ ¬ g ∣ g ∧ g ′ ∣ g ∨ g ′ (guard, update) u , u ′ : : = ( x ′ = v ) ∣ u ∧ u ′ v , v ′ : : = v + v ′ ∣ v − v ′ ∣ v × v ′ ∣ v ÷ v ′ ∣ x ∣ n ∈ Z (operations, variable, constant integer) \begin{aligned}
M,N &::= \{C_i\}_{i\in I} \mid M \mathbin{\|} N && \text{(module, composition)}\\
C &::= [\alpha]\,g \to\sum_{i\in I} p_i : u_i && \text{(command, with } \sum_{i\in I}p_i=1\text{ and }p_i\in[0,1]\text{)}\\
g,g' &::= (x=v) \mid\neg g \mid g\land g' \mid g\lor g' && \text{(guard, update)}\\
u,u' &::= (x'=v) \mid u\land u'\\
v,v' &::= v+v' \mid v-v' \mid v\times v' \mid v\div v' \mid x \mid n\in\mathbb{Z} && \text{(operations, variable, constant integer)}
\end{aligned} M , N C g , g ′ u , u ′ v , v ′ ::= { C i } i ∈ I ∣ M ∥ N ::= [ α ] g → i ∈ I ∑ p i : u i ::= ( x = v ) ∣ ¬ g ∣ g ∧ g ′ ∣ g ∨ g ′ ::= ( x ′ = v ) ∣ u ∧ u ′ ::= v + v ′ ∣ v − v ′ ∣ v × v ′ ∣ v ÷ v ′ ∣ x ∣ n ∈ Z (module, composition) (command, with i ∈ I ∑ p i = 1 and p i ∈ [ 0 , 1 ] ) (guard, update) (operations, variable, constant integer)
PRISM models are a composition of modules, each containing commands C i C_i C i . Each command has an action α \alpha α (potentially empty, denoted as α = ε \alpha=\varepsilon α = ε ), guard g g g , and updates u i u_i u i , each with probability p i p_i p i . Guards and updates operate on states throughout the execution of the model.
Definition 5.2. A state S S S is a mapping { x i ↦ n i } i ∈ I \{x_i\mapsto n_i\}_{i\in I} { x i ↦ n i } i ∈ I from variables x i x_i x i to constants n i n_i n i . Updates override mappings: S [ ( x ′ = n ) ] = ( S ∖ { x ↦ S ( x ) } ) ∪ { x ↦ n } S[(x'=n)]=(S\setminus\{x\mapsto S(x)\})\cup\{x\mapsto n\} S [( x ′ = n )] = ( S ∖ { x ↦ S ( x )}) ∪ { x ↦ n } . PRISM distinguishes equality from updates by denoting them as ( x = v ) (x=v) ( x = v ) and ( x ′ = v ) (x'=v) ( x ′ = v ) , respectively: in the latter, we update x x x , not x ′ x' x ′ . A state S S S is a state for model M M M if every x ∈ dom ( S ) x\in\operatorname{dom}(S) x ∈ dom ( S ) appears in some guard or update in M M M . We call ( M , S ) (M,S) ( M , S ) a model-state pair .
Notation 5.3. For tidiness, we treat zero- and false-valued variables differently: (1) for all x ∉ dom ( S ) x\notin\operatorname{dom}(S) x ∈ / dom ( S ) , we treat S ( x ) = 0 = f a l s e S(x)=0=\mathrm{false} S ( x ) = 0 = false ; and (2) S ∪ { x ↦ 0 } ≡ S ∪ { x ↦ f a l s e } ≡ S S\cup\{x\mapsto0\}\equiv S\cup\{x\mapsto\mathrm{false}\}\equiv S S ∪ { x ↦ 0 } ≡ S ∪ { x ↦ false } ≡ S . Hence we succinctly describe the state { x ↦ 42 , y ↦ 0 } \{x\mapsto42,y\mapsto0\} { x ↦ 42 , y ↦ 0 } as { x ↦ 42 } \{x\mapsto42\} { x ↦ 42 } . Here, we initialise integer variables to 0 and Booleans to false, so the initial state of any model is ∅ \varnothing ∅ . We write M M M as a shorthand for ( M , ∅ ) (M,\varnothing) ( M , ∅ ) .
We now define the semantics of the PRISM language. Following [14 ] , we first introduce a relation M ⇝ C M\rightsquigarrow C M ⇝ C (pronounced “M M M has command C C C ”) to capture the effects of composition. The rules for ⇝ \rightsquigarrow ⇝ are shown in Figure 10 . [M-MODULE] says a model with one module inherits its commands, while [m-\varepsilon] ensures that commands with empty actions are preserved. If M M M has action α \alpha α and N N N does not, [m\text{-}move] keeps M M M ’s command in their composition M ∥ N M \mathbin{\|} N M ∥ N . If both contain α \alpha α , [m\text{-}sync] synchronises them, executing both commands together. Based on this, we define the transition relation → α p \xrightarrow{\alpha}_{p} α p between model–state pairs (Figure 10 ). Its sole rule [s\text{-}step] does what we expect: if M M M has a command guarded by g g g , and state S S S satisfies g g g (S ⊢ g S \vdash g S ⊢ g ), then with probability p i p_i p i , we apply the update u i u_i u i . Since each probabilistic branch becomes a separate transition, we assume that no two enabled commands with more than one branch share an action, so that the distributions remain recoverable from → α p \xrightarrow{\alpha}_{p} α p . This is guaranteed by our encoding (§ 6.2.2 ). Similarly to typing contexts, we write → ∗ p \xrightarrow{*}_{p} ∗ p for the (probabilistic) reflexive, transitive closure.
Figure 10. Rules for ⇝ \rightsquigarrow ⇝ ([M-MODULE, ε \varepsilon ε , MOVE, SYNC]) and for model-state pairs ([S-STEP])
Translating Multiparty Session Type Semantics
Dealing with States
The main complexity for the encoding arises from the fact that session types are regarded as a term rewriting system, whereas PRISM is state-based . Thus, we must first determine how to map terms into states. To facilitate this, we will be translating each participant in the typing context into its own module, with variable S p S_p S p tracking p p p ’s current position in its type. We then compose these modules into a single model.
We inductively define the state space of a type T T T , written SS ( T ) \operatorname{SS}(T) SS ( T ) , as: SS ( e n d ) = 0 \operatorname{SS}(\mathrm{end})=0 SS ( end ) = 0 ; SS ( μ t . T ′ ) = SS ( T ′ ) \operatorname{SS}(\mu t.T')=\operatorname{SS}(T') SS ( μ t . T ′ ) = SS ( T ′ ) ; SS ( t ) = 0 \operatorname{SS}(t)=0 SS ( t ) = 0 ; SS ( & i ∈ I p i ? ℓ i ( B i ) . T i ) = 1 + ∑ i ∈ I SS ( T i ) \operatorname{SS}(\mathbin{\&}_{i\in I}p_i?\ell_i(B_i).T_i)=1+\sum_{i\in I}\operatorname{SS}(T_i) SS ( & i ∈ I p i ? ℓ i ( B i ) . T i ) = 1 + ∑ i ∈ I SS ( T i ) ; SS ( ⊕ 1 : q ! ℓ ⟨ B ⟩ . T ′ ) = 1 + SS ( T ′ ) \operatorname{SS}(\oplus1:q!\ell\langle B\rangle.T')=1+\operatorname{SS}(T') SS ( ⊕ 1 : q ! ℓ ⟨ B ⟩ . T ′ ) = 1 + SS ( T ′ ) for a committed selection (a single branch of probability 1 1 1 ); for a proper selection (∣ J ∣ ≥ 2 |J|\ge2 ∣ J ∣ ≥ 2 ), SS ( ⊕ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j ) = 1 + ∑ j ∈ J SS ( T j ′ ) \operatorname{SS}(\oplus_{j\in J}p_j:p_j!\ell_j\langle B_j\rangle.T_j)=1+\sum_{j\in J}\operatorname{SS}(T'_j) SS ( ⊕ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j ) = 1 + ∑ j ∈ J SS ( T j ′ ) , where T j ′ = ⊕ 1 : p j ! ℓ j ⟨ B j ⟩ . T j T'_j=\oplus1:p_j!\ell_j\langle B_j\rangle.T_j T j ′ = ⊕ 1 : p j ! ℓ j ⟨ B j ⟩ . T j denotes the committed selection for branch j j j ; and, for a proper sum (∣ I ∣ ≥ 2 |I|\ge2 ∣ I ∣ ≥ 2 ), SS ( ∑ i ∈ I ⊕ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ) = ∑ i ∈ I SS ( T i ′ ) \operatorname{SS}(\sum_{i\in I}\oplus_{j\in J_i}p_{(i,j)}:p_j!\ell_j\langle B_j\rangle.T_{(i,j)})=\sum_{i\in I}\operatorname{SS}(T'_i) SS ( ∑ i ∈ I ⊕ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ) = ∑ i ∈ I SS ( T i ′ ) , where T i ′ = ⊕ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) T'_i=\oplus_{j\in J_i}p_{(i,j)}:p_j!\ell_j\langle B_j\rangle.T_{(i,j)} T i ′ = ⊕ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) denotes the i i i -th summand of the sum (a singleton selection). Each variable S p S_p S p in the encoding of Δ = p : T , Δ ′ \Delta=p:T,\Delta' Δ = p : T , Δ ′ has a value between 0 0 0 and SS ( T ) \operatorname{SS}(T) SS ( T ) , inclusive, where S p = SS ( T ) S_p=\operatorname{SS}(T) S p = SS ( T ) represents the end state.
The counts mirror the type-level semantics, which resolves the nondeterministic choice between summands, the probabilistic choice between branches, and the communication itself by separate reductions. A branching needs only an entry state, from which the participant synchronises with the chosen sender. A committed selection similarly needs only an entry state, from which the participant synchronises with the recipient. A proper selection contributes an entry state, from which the participant commits to a branch probabilistically, moving to the entry state of the corresponding committed selection T j ′ T'_j T j ′ . A proper sum contributes an entry state from which a summand is picked nondeterministically. Recursion contributes no states, as we simply loop back to the state of the corresponding μ \mu μ -binding. Similarly, end also contributes no states, since all terminated participants share the single end state. The transitions between these states are made precise by the encoding below.
Encoding
We define an encoding from typing contexts into PRISM. We first present an inner encoding ⟦ ⋅ ⟧ \llbracket\cdot\rrbracket [ [ ⋅ ] ] , and then extend this with the closure module to give the final encoding ⟦ ⋅ ⟧ \llbracket\cdot\rrbracket [ [ ⋅ ] ] .
Inner top-level encoding { ⋅ } \{\cdot\} { ⋅ } . A typing context Δ \Delta Δ is translated as: { ∅ } = ∅ \{\varnothing\}=\varnothing { ∅ } = ∅ ; { Δ , Δ ′ } = { Δ } ∥ { Δ ′ } \{\Delta,\Delta'\}=\{\Delta\}\mathbin{\|}\{\Delta'\} { Δ , Δ ′ } = { Δ } ∥ { Δ ′ } , and { p : T } = ⟦ T ⟧ ( p , 0 , SS ( T ) , ∅ ) \{p:T\}=\llbracket T\rrbracket_{(p,0,\operatorname{SS}(T),\varnothing)} { p : T } = [ [ T ] ] ( p , 0 , SS ( T ) , ∅ ) , with the type-level encoding ⟦ T ⟧ ( p , n , m , f ) \llbracket T\rrbracket_{(p,n,m,f)} [ [ T ] ] ( p , n , m , f ) taking a type T T T being translated, participant p p p , current state n n n , end state m m m and a mapping f f f from variables to their state value.
Inner type-level encoding { ⋅ } ( p , n , m , f ) \{\cdot\}_{(p,n,m,f)} { ⋅ } ( p , n , m , f ) . The inner type-level encoding is presented in Figure 11 . Each reduction of the typing context LTS maps to exactly one PRISM transition, distinguished by its action label. For a proper sum (∣ I ∣ ≥ 2 |I|\ge2 ∣ I ∣ ≥ 2 ), the nondeterministic reduction p : τ ⟶ n \frac{p:\tau}{\longrightarrow}_{n} ⟶ p : τ n maps to an internal transition p : τ ⟶ 1 \frac{p:\tau}{\longrightarrow}_{1} ⟶ p : τ 1 (mirroring the type-level action p : τ p:\tau p : τ ) that picks a summand i ∈ I i\in I i ∈ I and moves to the entry state of the encoding of the singleton selection T i ⊕ T_i^\oplus T i ⊕ . For a proper selection, the probabilistic reduction → p p : : p \xrightarrow[\ p\ ]{p::p} p :: p p (rule [CT-PROB]) maps to an internal transition → p p : : p \xrightarrow[\ p\ ]{p::p} p :: p p in which p p p probabilistically picks a branch j ∈ J j \in J j ∈ J and moves to the entry state of the encoding of the committed selection T j T_j T j . For a committed selection, the communication → ( p , q ) ℓ 1 \xrightarrow{(p,q)\ell}_1 ( p , q ) ℓ 1 maps to the synchronisation → p : : q : : ℓ 1 \xrightarrow{p::q::\ell}_1 p :: q :: ℓ 1 that informs q q q of p p p ’s choice. Since participant names are unique, no other module has an action labelled p : : τ p::\tau p :: τ or p : : p p::p p :: p , so these transitions cannot synchronise and are therefore internal. For a branching, the receiver synchronises directly with the chosen sender in a single → q : : p : : ℓ 1 \xrightarrow{q::p::\ell}_1 q :: p :: ℓ 1 transition. For recursion μ t . T \mu t.T μ t . T , we extend the mapping with t ↦ n t \mapsto n t ↦ n and continue translating T T T (using f f f if a continuation is a variable). We refer to the two kinds of internal transitions produced by the encoding as follows: a
Figure 11. Inner Translation
∥ e n d ∥ ( p , n , m , f ) = ∅ ∥ t ∥ ( p , n , m , f ) = ∅ ∥ μ t . T ∥ ( p , n , m , f ) = ∥ T ∥ ( p , n , m , f ∪ { t ↦ n } ) \begin{aligned}
\lVert\mathsf{end}\rVert_{(p,n,m,f)} &= \varnothing
&
\lVert t\rVert_{(p,n,m,f)} &= \varnothing
&
\lVert\mu t.T\rVert_{(p,n,m,f)} &= \lVert T\rVert_{(p,n,m,f\cup\{t\mapsto n\})}
\end{aligned} ∥ end ∥ ( p , n , m , f ) = ∅ ∥ t ∥ ( p , n , m , f ) = ∅ ∥ μ t . T ∥ ( p , n , m , f ) = ∥ T ∥ ( p , n , m , f ∪ { t ↦ n })
∥ ⨁ i ∈ I ⨁ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ∥ ( p , n , m , f ) = ⋃ i ∈ I [ p : : τ ] ( S p = n ) → 1 : ( S p ′ = sel ( i ) ) ∪ ⋃ i ∈ I ⋃ T i ⊕ ∥ T i ⊕ ∥ ( p , sel ( i ) , m , f ) \begin{aligned}
\left\lVert\bigoplus_{i\in I}\bigoplus_{j\in J_i}p_{(i,j)}:p_j!\ell_j\langle B_j\rangle.T_{(i,j)}\right\rVert_{(p,n,m,f)}
&= \bigcup_{i\in I}\left[p::\tau\right](S_p=n)\to1:(S'_p=\operatorname{sel}(i))\\
&\qquad\cup\bigcup_{i\in I}\bigcup_{T_i^\oplus}\lVert T_i^\oplus\rVert_{(p,\operatorname{sel}(i),m,f)}
\end{aligned} i ∈ I ⨁ j ∈ J i ⨁ p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ( p , n , m , f ) = i ∈ I ⋃ [ p :: τ ] ( S p = n ) → 1 : ( S p ′ = sel ( i )) ∪ i ∈ I ⋃ T i ⊕ ⋃ ∥ T i ⊕ ∥ ( p , sel ( i ) , m , f )
where ∣ I ∣ ≥ 2 |I|\ge2 ∣ I ∣ ≥ 2 , T i ⊕ = ⨁ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) T_i^\oplus=\bigoplus_{j\in J_i}p_{(i,j)}:p_j!\ell_j\langle B_j\rangle.T_{(i,j)} T i ⊕ = ⨁ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) , sel ( i ) = n + 1 + ∑ i ′ < i S S ( T i ′ ⊕ ) \operatorname{sel}(i)=n+1+\sum_{i'<i}SS(T_{i'}^\oplus) sel ( i ) = n + 1 + ∑ i ′ < i S S ( T i ′ ⊕ )
∥ ⨁ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j ∥ ( p , n , m , f ) = [ p : : p ] ( S p = n ) → ∑ j ∈ J ( p j : ( S p ′ = com ( j ) ) ) ∪ ⋃ j ∈ J ∥ T j ′ ∥ ( p , com ( j ) , m , f ) \begin{aligned}
\left\lVert\bigoplus_{j\in J}p_j:p_j!\ell_j\langle B_j\rangle.T_j\right\rVert_{(p,n,m,f)}
&= \left[p::p\right](S_p=n)\to\sum_{j\in J}\left(p_j:(S'_p=\operatorname{com}(j))\right)\\
&\qquad\cup\bigcup_{j\in J}\lVert T_j^\prime\rVert_{(p,\operatorname{com}(j),m,f)}
\end{aligned} j ∈ J ⨁ p j : p j ! ℓ j ⟨ B j ⟩ . T j ( p , n , m , f ) = [ p :: p ] ( S p = n ) → j ∈ J ∑ ( p j : ( S p ′ = com ( j )) ) ∪ j ∈ J ⋃ ∥ T j ′ ∥ ( p , com ( j ) , m , f )
where T j ′ = ⨁ 1 : p j ! ℓ j ⟨ B j ⟩ . T j T_j^\prime=\bigoplus1:p_j! \ell_j\langle B_j\rangle.T_j T j ′ = ⨁ 1 : p j ! ℓ j ⟨ B j ⟩ . T j , com ( j ) = n + 1 + ∑ j ′ < j S S ( T j ′ ′ ) \operatorname{com}(j)=n+1+\sum_{j'<j}SS(T_{j'}^\prime) com ( j ) = n + 1 + ∑ j ′ < j S S ( T j ′ ′ )
∥ ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ ∥ ( p , n , m , f ) = [ p : : q : : ℓ ] ( S p = n ) → 1 : { S p ′ = m T ′ = e n d S p ′ = f ( t ) T ′ = t S p ′ = n + 1 otherwise ∪ ∥ T ′ ∥ ( p , n + 1 , m , f ) \begin{aligned}
\left\lVert\bigoplus1:q! \ell\langle B\rangle.T^\prime\right\rVert_{(p,n,m,f)}
&=\left[p::q::\ell\right](S_p=n)\to1:
\begin{cases}
S'_p=m & T'= \mathsf{end}\\
S'_p=f(t) & T'=t\\
S'_p=n+1 & \text{otherwise}
\end{cases}
\cup\lVert T^\prime\rVert_{(p,n+1,m,f)}
\end{aligned} ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ ( p , n , m , f ) = [ p :: q :: ℓ ] ( S p = n ) → 1 : ⎩ ⎨ ⎧ S p ′ = m S p ′ = f ( t ) S p ′ = n + 1 T ′ = end T ′ = t otherwise ∪ ∥ T ′ ∥ ( p , n + 1 , m , f )
∥ & i ∈ I p i ? ℓ i ( B i ) . T i ∥ ( p , n , m , f ) = ⋃ i ∈ I [ p i : : p : : ℓ i ] ( S p = n ) → 1 : { S p ′ = m T i = e n d S p ′ = f ( t ) T i = t S p ′ = next ( i ) otherwise ∪ ⋃ i ∈ I ∥ T i ∥ ( p , next ( i ) , m , f ) \begin{aligned}
\left\lVert\mathbin{\&}_{i\in I}p_i?\ell_i(B_i).T_i\right\rVert_{(p,n,m,f)}
&=\bigcup_{i\in I}\left[p_i::p::\ell_i\right](S_p=n)\to1:
\begin{cases}
S'_p=m & T_i=\mathsf{end}\\
S'_p=f(t) & T_i=t\\
S'_p=\operatorname{next}(i) & \text{otherwise}
\end{cases}
\cup\bigcup_{i\in I}\lVert T_i\rVert_{(p,\operatorname{next}(i),m,f)}
\end{aligned} ∥ & i ∈ I p i ? ℓ i ( B i ) . T i ∥ ( p , n , m , f ) = i ∈ I ⋃ [ p i :: p :: ℓ i ] ( S p = n ) → 1 : ⎩ ⎨ ⎧ S p ′ = m S p ′ = f ( t ) S p ′ = next ( i ) T i = end T i = t otherwise ∪ i ∈ I ⋃ ∥ T i ∥ ( p , next ( i ) , m , f )
where next ( i ) = n + 1 + ∑ i ′ < i S S ( T i ′ ) \operatorname{next}(i)=n+1+\sum_{i'<i}SS(T_{i'}) next ( i ) = n + 1 + ∑ i ′ < i S S ( T i ′ )
summand step is a transition labelled p : : τ p::\tau p :: τ , introduced for a proper sum, moving S p S_p S p from the entry state of the sum to the entry state of one of its summands T i ⊕ T_i^\oplus T i ⊕ with probability 1; a commitment step is a transition labelled p : : p p::p p :: p , introduced for a proper selection, moving S p S_p S p from the entry state of the selection to the entry state of one of its committed selections T j ′ T_j^\prime T j ′ with probability p j p_j p j . Summand steps resolve the nondeterministic choice (rule [CT-ND]), commitment steps resolve the probabilistic choice (rule [CT-PROB]), and synchronisations perform the communication (rule [CT-τ \tau τ ]). Commitment steps are the only commands with more than one branch, and at most one is enabled in any state per module, as each is guarded by a distinct entry state and never synchronises.
The inner encoding has slightly more transitions than needed since we treat each → p : : q : : ℓ \xrightarrow{p::q::\ell} p :: q :: ℓ transition as a communication, implicitly assuming both p p p and q q q participate. However, in some cases, only one of p p p or q q q contains this action, and [M-MOVE] permits such transitions to occur without synchronisation. Thus, we introduce a closure module that blocks these spurious transitions.
Definition 5.4. Let actions Δ ( p ) \operatorname{actions}_{\Delta}(p) actions Δ ( p ) be the set of actions in ⟦ p : Δ ( p ) ⟧ \llbracket p:\Delta(p)\rrbracket [ [ p : Δ ( p ) ] ] where actions Δ ( p ) = ∅ \operatorname{actions}_{\Delta}(p)=\varnothing actions Δ ( p ) = ∅ if p ∉ dom ( Δ ) p\notin\operatorname{dom}(\Delta) p ∈ / dom ( Δ ) . Define actions ( Δ ) = ⋃ p ∈ dom ( Δ ) actions Δ ( p ) \operatorname{actions}(\Delta)=\bigcup_{p\in\operatorname{dom}(\Delta)}\operatorname{actions}_{\Delta}(p) actions ( Δ ) = ⋃ p ∈ dom ( Δ ) actions Δ ( p ) . The closure module for Δ \Delta Δ is given by
closure ( Δ ) = { [ p : : q : : ℓ ] f a l s e → 1 : ( ) ∣ p : : q : : ℓ ∈ actions Δ ( p ) ⊕ actions Δ ( q ) } , \operatorname{closure}(\Delta)=\{[p::q::\ell]\ \mathsf{false}\to1:() \mid p::q::\ell\in\operatorname{actions}_{\Delta}(p)\mathbin{\oplus}\operatorname{actions}_{\Delta}(q)\}, closure ( Δ ) = {[ p :: q :: ℓ ] false → 1 : ( ) ∣ p :: q :: ℓ ∈ actions Δ ( p ) ⊕ actions Δ ( q )} ,
where ⊕ \oplus ⊕ is the symmetric difference , and the ( ) () ( ) denotes a dummy update that will never be applied. The final encoding ⟦ ⋅ ⟧ \llbracket\cdot\rrbracket [ [ ⋅ ] ] of contexts into PRISM models is defined by ⟦ Δ ⟧ = ( ∣ Δ ∣ ) ∥ closure ( Δ ) \llbracket\Delta\rrbracket= (|\Delta|) \mathbin{\|} \operatorname{closure}(\Delta) [ [ Δ ] ] = ( ∣Δ∣ ) ∥ closure ( Δ ) .
Example 5.5. Consider the calculator c : T c c : T_c c : T c from Example 3.1, for which SS ( T c ) = 6 \operatorname{SS}(T_c) = 6 SS ( T c ) = 6 . Figure 12 shows its state encoding. Each typing context reduction corresponds to exactly one PRISM transition. The recursion contributes no state, so the branching & s ? incr \&s?{\operatorname{incr}} & s ? incr is translated at state 0 with f = { t ↦ 0 } f = \{t \mapsto0\} f = { t ↦ 0 } . Then, receiving incr \operatorname{incr} incr from s s s moves S c S_c S c to state 1, which is the entry state of the nondeterministic sum. From there, a summand step picks one of the two summands nondeterministically, moving either to state 2, the singleton selection ⊕ u ! res . t \oplus u!{\operatorname{res}}.t ⊕ u ! res . t , or to state 3, the entry state of the probabilistic selection. From state 3, a commitment step moves to state 4 with probability 0.8 0.8 0.8 or to state 5 with probability 0.2 0.2 0.2 , the entry states of the two singleton selections ⊕ u ! res . t \oplus u!{\operatorname{res}}.t ⊕ u ! res . t and ⊕ s ! error . t \oplus s!{\operatorname{error}}.t ⊕ s ! error . t . Each singleton selection then synchronises with its recipient. As every continuation is the variable t t t , these synchronisations loop back to state f ( t ) = 0 f(t) = 0 f ( t ) = 0 . The end state 6 is never reached, since the calculator never terminates.
Figure 12. States in the encoding of c : T c c : T_c c : T c (Example 3.1). Points on the number line represent values of S c S_c S c , and arrows represent transitions, labelled with their action and probability. Unlabelled transitions have p = 1 p = 1 p = 1 .
The remaining participants u u u and s s s are encoded in a similar manner, yielding modules over S u S_u S u and S s S_s S s . The final encoding is then: ⟦ Δ ⟧ = ( ∣ c : T c ∣ ) ∥ ( ∣ u : T u ∣ ) ∥ ( ∣ s : T s ∣ ) ∥ closure ( Δ ) \llbracket\Delta\rrbracket= (|c : T_c|) \mathbin{\|} (|u : T_u|) \mathbin{\|} (|s : T_s|) \mathbin{\|} \operatorname{closure}(\Delta) [ [ Δ ] ] = ( ∣ c : T c ∣ ) ∥ ( ∣ u : T u ∣ ) ∥ ( ∣ s : T s ∣ ) ∥ closure ( Δ )
The resulting modules synchronise on the four actions u : : s : : incr u :: s :: \operatorname{incr} u :: s :: incr , s : : c : : incr s :: c :: \operatorname{incr} s :: c :: incr , c : : u : : res c :: u :: \operatorname{res} c :: u :: res and c : : s : : error c :: s :: \operatorname{error} c :: s :: error . Every action appears in both the sender’s and the receiver’s module, so the closure module is empty. Tracing part of an execution, we could have:
( ⟦ Δ ⟧ , { S c ↦ 0 , … } ) → 1 s : : c : : incr ( ⟦ Δ ⟧ , { S c ↦ 1 , … } ) → 1 c : : τ ( ⟦ Δ ⟧ , { S c ↦ 3 , … } ) → 0.8 c : : p ( ⟦ Δ ⟧ , { S c ↦ 4 , … } ) (1) (\llbracket\Delta\rrbracket,\{S_c \mapsto0,\ldots\}) \xrightarrow[\ 1\ ]{s::c::\operatorname{incr}} (\llbracket\Delta\rrbracket,\{S_c \mapsto1,\ldots\}) \xrightarrow[\ 1\ ]{c::\tau} (\llbracket\Delta\rrbracket,\{S_c \mapsto3,\ldots\}) \xrightarrow[\ 0.8\ ]{c::p} (\llbracket\Delta\rrbracket,\{S_c \mapsto4,\ldots\}) \tag*{(1)} ( [ [ Δ ] ] , { S c ↦ 0 , … }) s :: c :: incr 1 ( [ [ Δ ] ] , { S c ↦ 1 , … }) c :: τ 1 ( [ [ Δ ] ] , { S c ↦ 3 , … }) c :: p 0.8 ( [ [ Δ ] ] , { S c ↦ 4 , … }) (1)
Correctness
We now show that the encoding is sound (Theorem 5.6): every typing context reduction corresponds to a transition of the encoded model; and complete (Theorem 5.7): every PRISM transition corresponds to a typing context reduction. Detailed definitions and proofs are given in §D.
Soundness
For soundness, we must show that ( ⋅ ) (\cdot) ( ⋅ ) preserves behaviour under recursion unfolding: ( p : μ t . T ) (p : \mu t.T) ( p : μ t . T ) should be equivalent to ( p : T { μ t . T / t } ) (p : T\{\mu t.T/t\}) ( p : T { μ t . T / t }) (Lemma D.6). Though the two modules’ internal states and commands may differ, they should exhibit the same observable transition behaviour. This motivates use of bisimulation (Def. D.1) on model-state pairs ( M 1 , I 1 ) ∼ ( M 2 , I 2 ) (M_1,I_1) \sim(M_2,I_2) ( M 1 , I 1 ) ∼ ( M 2 , I 2 ) to define equivalence.
Theorem 5.6 (Translation soundness). (Proof in §D.1). Let Δ , Δ ′ \Delta,\Delta' Δ , Δ ′ be contexts.
(1) If Δ → p : : τ n Δ ′ \Delta\xrightarrow{p::\tau}_{n} \Delta' Δ p :: τ n Δ ′ , then there exists a state S S S such that ⟦ Δ ⟧ → p : : τ 1 ( ⟦ Δ ⟧ , S ) \llbracket\Delta\rrbracket\xrightarrow{p::\tau}_{1} (\llbracket\Delta\rrbracket,S) [ [ Δ ] ] p :: τ 1 ( [ [ Δ ] ] , S ) and ⟦ Δ ′ ⟧ ∼ ( ⟦ Δ ⟧ , S ) \llbracket\Delta'\rrbracket\sim(\llbracket\Delta\rrbracket,S) [ [ Δ ′ ] ] ∼ ( [ [ Δ ] ] , S ) .
(2) If Δ → p : : p p Δ ′ \Delta\xrightarrow{p::p}_{p} \Delta' Δ p :: p p Δ ′ , then there exists a state S S S such that ⟦ Δ ⟧ → p : : p p ( ⟦ Δ ⟧ , S ) \llbracket\Delta\rrbracket\xrightarrow{p::p}_{p} (\llbracket\Delta\rrbracket,S) [ [ Δ ] ] p :: p p ( [ [ Δ ] ] , S ) and ⟦ Δ ′ ⟧ ∼ ( ⟦ Δ ⟧ , S ) \llbracket\Delta'\rrbracket\sim(\llbracket\Delta\rrbracket,S) [ [ Δ ′ ] ] ∼ ( [ [ Δ ] ] , S ) .
(3) If Δ → ( p , q ) : : ℓ 1 Δ ′ \Delta\xrightarrow{(p,q)::\ell}_{1} \Delta' Δ ( p , q ) :: ℓ 1 Δ ′ , then there exists a state S S S such that ⟦ Δ ⟧ → p : : q : : ℓ 1 ( ⟦ Δ ⟧ , S ) \llbracket\Delta\rrbracket\xrightarrow{p::q::\ell}_{1} (\llbracket\Delta\rrbracket,S) [ [ Δ ] ] p :: q :: ℓ 1 ( [ [ Δ ] ] , S ) and ⟦ Δ ′ ⟧ ∼ ( ⟦ Δ ⟧ , S ) \llbracket\Delta'\rrbracket\sim(\llbracket\Delta\rrbracket,S) [ [ Δ ′ ] ] ∼ ( [ [ Δ ] ] , S ) .
Completeness
Completeness is the dual of soundness: every transition of the encoded model corresponds directly to a reduction of the typing context.
Theorem 5.7 (Translation completeness). (Proof in §D.1). For every context Δ \Delta Δ :
if [\![\Delta]\] \xrightarrow{p::\tau}_{1} ([\![\Delta]\], S) , then there exists Δ ′ \Delta' Δ ′ such that Δ → p : τ n Δ ′ \Delta\xrightarrow{p:\tau}_{n} \Delta' Δ p : τ n Δ ′ and ([\![\Delta]\], S) \sim[\![\Delta']\] ;
if [\![\Delta]\] \xrightarrow{p::p}_{p} ([\![\Delta]\], S) , then there exists Δ ′ \Delta' Δ ′ such that Δ → p p Δ ′ \Delta\xrightarrow{p}_{p} \Delta' Δ p p Δ ′ and ([\![\Delta]\], S) \sim[\![\Delta']\] ;
if [\![\Delta]\] \xrightarrow{p::q::\ell}_{1} ([\![\Delta]\], S) , then there exists Δ ′ \Delta' Δ ′ such that Δ → ( p , q ) ℓ 1 Δ ′ \Delta\xrightarrow{(p,q)\ell}_{1} \Delta' Δ ( p , q ) ℓ 1 Δ ′ and ([\![\Delta]\], S) \sim[\![\Delta']\] .
Model-Checking Probabilistic Multiparty Session Types in PRISM
With the encoding in place, we must now express the properties of § 4.3 as logical formulae to enable model checking. We use Probabilistic LTL (PLTL), the linear-time fragment of PCTL*, to specify and model check properties using the PRISM tool.
A brief introduction to PLTL. Due to space constraints, we opt for a brief presentation; a more principled discussion can be found in [6 , 9 ] . The syntax of our fragment of PLTL is given by
Φ : : = Pmin ( φ ) ∣ Pmax ( φ ) (lower- and upper-bound probability constructs) φ , ψ : : = a ∣ ¬ φ ∣ φ ∧ ψ ∣ φ ∨ ψ (atomic proposition, negation, conjunction, disjunction) ∣ □ φ ∣ ◊ φ (always, eventually) \begin{aligned}
\Phi&::= \operatorname{Pmin}(\varphi) \mid\operatorname{Pmax}(\varphi) && \text{(lower- and upper-bound probability constructs)}\\
\varphi,\psi&::= a \mid\neg\varphi\mid\varphi\land\psi\mid\varphi\lor\psi&& \text{(atomic proposition, negation, conjunction, disjunction)}\\
&\mid\square\varphi\mid\Diamond\varphi&& \text{(always, eventually)}
\end{aligned} Φ φ , ψ ::= Pmin ( φ ) ∣ Pmax ( φ ) ::= a ∣ ¬ φ ∣ φ ∧ ψ ∣ φ ∨ ψ ∣ □ φ ∣ ◊ φ (lower- and upper-bound probability constructs) (atomic proposition, negation, conjunction, disjunction) (always, eventually)
We write φ ⇒ ψ \varphi\Rightarrow\psi φ ⇒ ψ as a shorthand for ¬ φ ∨ ψ \neg\varphi\lor\psi ¬ φ ∨ ψ . We omit the next (X) and until (U) operators of PLTL, as they are not needed to express our properties.
Path π \pi π of a PRISM model M M M is a (potentially infinite) sequence of states S 1 ; S 2 ; ⋯ S_1; S_2; \cdots S 1 ; S 2 ; ⋯ such that ∀ i ∈ [ 1 , ∣ π ∣ ) : ( M , S i ) → ( M , S i + 1 ) \forall i \in[1, |\pi|) : (M, S_i) \to(M, S_{i+1}) ∀ i ∈ [ 1 , ∣ π ∣ ) : ( M , S i ) → ( M , S i + 1 ) . We call φ \varphi φ a path formula . Path formulae act on paths π \pi π of a model M M M , and we write π ⊨ φ \pi\models\varphi π ⊨ φ if π \pi π satisfies φ \varphi φ . The semantics of path formulae are given in Def. 6.1 .
Given a model M M M , Pmin ( φ ) \operatorname{Pmin}(\varphi) Pmin ( φ ) (resp. Pmax ( φ ) \operatorname{Pmax}(\varphi) Pmax ( φ ) ) tells us the minimum (resp. maximum ) probability of obtaining a path π \pi π of M M M such that π ⊨ φ \pi\models\varphi π ⊨ φ , across all possible schedulers. Since our PRISM models are MDPs, they contain both probabilistic choice (within the same action) and nondeterminism (over which action to fire, when multiple are available).
Definition 6.1 (Semantics of a path formula). Let π = S 1 ; S 2 ; ⋯ \pi= S_1; S_2; \cdots π = S 1 ; S 2 ; ⋯ be a path, and denote by π [ i . . ] \pi[i..] π [ i .. ] the subpath S i ; S i + 1 ; ⋯ S_i; S_{i+1}; \cdots S i ; S i + 1 ; ⋯ . The semantics of a path formula φ \varphi φ is given inductively:
π ⊨ a ⟺ S 1 ⊢ a \pi\models a \Longleftrightarrow S_1 \vdash a π ⊨ a ⟺ S 1 ⊢ a π ⊨ φ ∧ ψ ⟺ π ⊨ φ ∧ π ⊨ ψ \pi\models\varphi\land\psi\Longleftrightarrow\pi\models\varphi\land\pi\models\psi π ⊨ φ ∧ ψ ⟺ π ⊨ φ ∧ π ⊨ ψ π ⊨ φ ∨ ψ ⟺ π ⊨ φ ∨ π ⊨ ψ \pi\models\varphi\lor\psi\Longleftrightarrow\pi\models\varphi\lor\pi\models\psi π ⊨ φ ∨ ψ ⟺ π ⊨ φ ∨ π ⊨ ψ π ⊨ ¬ φ ⟺ π ⊭ φ \pi\models\neg\varphi\Longleftrightarrow\pi\not\models\varphi π ⊨ ¬ φ ⟺ π ⊨ φ π ⊨ □ φ ⟺ ∀ i ⋅ π [ i . . ] ⊨ φ \pi\models\square\varphi\Longleftrightarrow\forall i \cdot\pi[i..] \models\varphi π ⊨ □ φ ⟺ ∀ i ⋅ π [ i .. ] ⊨ φ π ⊨ ◊ φ ⟺ ∃ i ⋅ π [ i . . ] ⊨ φ \pi\models\Diamond\varphi\Longleftrightarrow\exists i \cdot\pi[i..] \models\varphi π ⊨ ◊ φ ⟺ ∃ i ⋅ π [ i .. ] ⊨ φ
The meaning of S 1 ⊢ a S_1 \vdash a S 1 ⊢ a will be explained in §6.1. The always and eventually operators originate from linear temporal logic ; informally, □ φ \square\varphi □ φ is true if φ \varphi φ is always true throughout the path, and ◊ φ \Diamond\varphi ◊ φ is true if φ \varphi φ eventually becomes true. Other operators are standard.
Defining Specifications
We define several PRISM labels – boolean expressions over state variables – to act as atomic propositions. For conciseness, we only give informal meanings here, though it is straightforward to express them as conjunctions or disjunctions of state variables (see §E).
Definition 6.2. Given an encoding [\![\Delta]\] , we define the labels (their names denoted with “quotes”):
S ⊢ “end” ⟺ ∀ p ∈ dom ( Δ ) : S ( S p ) = S S ( Δ ( p ) ) S \vdash\text{“end”} \Longleftrightarrow\forall p \in\operatorname{dom}(\Delta) : S(S_p) = SS(\Delta(p)) S ⊢ “end” ⟺ ∀ p ∈ dom ( Δ ) : S ( S p ) = S S ( Δ ( p ))
∀ p : : q : : ℓ ∈ actions λ ( p ) ∪ actions λ ( q ) : S ⊢ “send : p : : q : : ℓ ” ⟺ ( ( [ [ Δ ( p ) ] ] ) , S ) → p : : q : : ℓ \forall p::q::\ell\in\operatorname{actions}_{\lambda}(p) \cup\operatorname{actions}_{\lambda}(q) : S \vdash\text{“send : }p::q::\ell\text{”} \Longleftrightarrow(([\![\Delta(p)]\!]), S) \xrightarrow{p::q::\ell} ∀ p :: q :: ℓ ∈ actions λ ( p ) ∪ actions λ ( q ) : S ⊢ “send : p :: q :: ℓ ” ⟺ (([ [ Δ ( p )] ]) , S ) p :: q :: ℓ
∀ p , q ∈ dom ( Δ ) : S ⊢ “receive : p : : q ” ⟺ ∃ ℓ : ( ( [ [ Δ ( q ) ] ] ) , S ) → p : : q : : ℓ \forall p,q \in\operatorname{dom}(\Delta) : S \vdash\text{“receive : }p::q\text{”} \Longleftrightarrow\exists\ell: (([\![\Delta(q)]\!]), S) \xrightarrow{p::q::\ell} ∀ p , q ∈ dom ( Δ ) : S ⊢ “receive : p :: q ” ⟺ ∃ ℓ : (([ [ Δ ( q )] ]) , S ) p :: q :: ℓ
∀ p : : q : : ℓ ∈ actions λ ( p ) ∪ actions λ ( q ) : S ⊢ “receive : p : : q : : ℓ ” ⟺ ( ( [ [ Δ ( q ) ] ] ) , S ) → p : : q : : ℓ \forall p::q::\ell\in\operatorname{actions}_{\lambda}(p) \cup\operatorname{actions}_{\lambda}(q) : S \vdash\text{“receive : }p::q::\ell\text{”} \Longleftrightarrow(([\![\Delta(q)]\!]), S) \xrightarrow{p::q::\ell} ∀ p :: q :: ℓ ∈ actions λ ( p ) ∪ actions λ ( q ) : S ⊢ “receive : p :: q :: ℓ ” ⟺ (([ [ Δ ( q )] ]) , S ) p :: q :: ℓ
Additionally, PRISM has a built-in label “deadlock” such that S ⊢ “deadlock” ⟺ ( [ [ Δ ] ] , S ) ↛ S \vdash\text{“deadlock”} \Longleftrightarrow([\![\Delta]\!], S) \not\to S ⊢ “deadlock” ⟺ ([ [ Δ ] ] , S ) → .
The label “end” is true iff all participants are in the end state. “send :: p :: q :: ℓ \ell ℓ ” is true if p is able to send ℓ \ell ℓ to q, i.e. p is at the entry state of a committed selection and offers the synchronisation p :: q :: ℓ \ell ℓ ; and “receive :: p :: q :: ℓ \ell ℓ ” is true if q is able to receive ℓ \ell ℓ from p. Finally, “receive :: p :: q” is true if q is able to receive any label from p.
Fairness. The properties of Def. 4.14 are quantified over fair schedulers, whereas Pmin and Pmax quantify over all schedulers of the model. This restriction cannot be imposed directly, as PRISM applies fairness to all nondeterministic choices uniformly, including the internal nondeterminism ∑ i ∈ I T i ⟶ n T k \sum_{i\in I} T_i \mathrel{\longrightarrow_n} T_k ∑ i ∈ I T i ⟶ n T k , which must remain unconstrained. As we will soon see, we instead express deadlock-freedom and liveness through the reachability of their negations, for which the restriction to fair schedulers is unnecessary.
Safety and deadlock-freedom. Using the labels, we write the following property specifications :
safe ( Δ ) ⟺ Pmin ( □ ( ⋀ p : : q : : ℓ ∈ actions ( Δ ) ( “send :: p : : q : : ℓ ” ∧ “receive :: p : : q ” ) ⇒ “receive :: p : : q : : ℓ ” ) ) = 1 \operatorname{safe}(\Delta) \Longleftrightarrow\operatorname{Pmin}\left(\Box\left(\bigwedge_{p::q::\ell\in\operatorname{actions}(\Delta)}\left(\text{“send :: }p::q::\ell\text{”}\land\text{“receive :: }p::q\text{”}\right)\Rightarrow\text{“receive :: }p::q::\ell\text{”}\right)\right)=1 safe ( Δ ) ⟺ Pmin □ p :: q :: ℓ ∈ actions ( Δ ) ⋀ ( “send :: p :: q :: ℓ ” ∧ “receive :: p :: q ” ) ⇒ “receive :: p :: q :: ℓ ” = 1
df min ( Δ ) = 1 − Pmax ( ◊ ( “deadlock” ∧ ¬ “end” ) ) asdf ( Δ ) ⟺ df min ( Δ ) = 1 \operatorname{df}^{\min}(\Delta)=1-\operatorname{Pmax}\left(\Diamond\left(\text{“deadlock”}\land\neg\text{“end”}\right)\right)
\qquad
\operatorname{asdf}(\Delta)\Longleftrightarrow\operatorname{df}^{\min}(\Delta)=1 df m i n ( Δ ) = 1 − Pmax ( ◊ ( “deadlock” ∧ ¬ “end” ) ) asdf ( Δ ) ⟺ df m i n ( Δ ) = 1
In a safe context (Def. 3.12), if p has committed to sending ℓ \ell ℓ to q and q is ready to receive from p, then q must accept ℓ \ell ℓ . For deadlock-freedom, recall from Def. 4.8 that a deadlocked context is one that cannot reduce even though some participant has not ended. The path formula ◊ ( “deadlock” ∧ ¬ “end” ) \Diamond\left(\text{“deadlock”}\land\neg\text{“end”}\right) ◊ ( “deadlock” ∧ ¬ “end” ) holds exactly on the paths that reach such a state, so the specification computes 1 minus the maximal probability of deadlock across all schedulers. The following theorem shows that this maximum agrees with the maximum over fair schedulers of Def. 4.14.
Theorem 6.3. (Proof in §E.2). max ϕ ∈ Φ F P Δ ϕ ( ◊ deadlock ) = max ϕ ∈ Φ Δ P Δ ϕ ( ◊ deadlock ) \max_{\phi\in\Phi_F}\operatorname{P}^{\phi}_{\Delta}\left(\Diamond\text{deadlock}\right)=\max_{\phi\in\Phi_{\Delta}}\operatorname{P}^{\phi}_{\Delta}\left(\Diamond\text{deadlock}\right) max ϕ ∈ Φ F P Δ ϕ ( ◊ deadlock ) = max ϕ ∈ Φ Δ P Δ ϕ ( ◊ deadlock )
Intuitively, every deadlocking path is finite, and every finite complete path is fair. Admitting unfair schedulers therefore does not change the maximal probability of deadlock.
Liveness is trickier, as it is a property of infinite paths whose negation is not immediately a reachability event. We note that a context fails to be almost-surely live precisely when it can reach a region of states in which some participant can be kept pending forever while scheduling remains fair. We call this a weak almost-sure livelock , weak in that an actual livelock may only surface when the nondeterminism is resolved adversarially.
To define the weak almost-sure livelock region, we first define Pend p ( Δ ) \operatorname{Pend}_{p}(\Delta) Pend p ( Δ ) to be the set of states reachable from Δ \Delta Δ where p is nonterminated but has no enabled communication:
Pend p ( Δ ) = { Δ ′ ∈ ( Δ ⟶ ∗ Δ ′ ) ∣ Δ ′ ( p ) ≠ end , ∀ q , ℓ , p : Δ ′ ⟶ p ( p , q ) ℓ Δ ′ ′ ⟶ p ( q , p ) ℓ Δ ′ ′ ′ } . \operatorname{Pend}_{p}(\Delta)=\{\Delta'\in(\Delta\mathrel{\longrightarrow^{*}}\Delta')\mid\Delta'(p)\ne\operatorname{end},\ \forall q,\ell,p:\Delta'\mathrel{\mathop{\longrightarrow}\limits_{p}^{(p,q)\ell}}\Delta''\mathrel{\mathop{\longrightarrow}\limits_{p}^{(q,p)\ell}\Delta'''\}.} Pend p ( Δ ) = { Δ ′ ∈ ( Δ ⟶ ∗ Δ ′ ) ∣ Δ ′ ( p ) = end , ∀ q , ℓ , p : Δ ′ p ⟶ ( p , q ) ℓ Δ ′′ p ⟶ ( q , p ) ℓ Δ ′′′ } .
Writing Pend p \operatorname{Pend}_{p} Pend p for membership in Pend p ( Δ ) \operatorname{Pend}_{p}(\Delta) Pend p ( Δ ) , a fair path π \pi π is non-live iff π ⊨ ∀ F p e d o m ( Δ ) ◊ Pend p \pi\models\forall\operatorname{F}_{\mathrm{pedom}(\Delta)}\Diamond\operatorname{Pend}_{p} π ⊨ ∀ F pedom ( Δ ) ◊ Pend p (Lemma 9.9). Indeed, fairness resolves any remaining internal choices on such a pending suffix, leaving the participant permanently stuck.
Writing visited ( ξ ) = { Δ i ∣ ∃ i ≤ ∣ ξ ∣ : ξ [ i ] = Δ i } \operatorname{visited}(\xi)=\{\Delta_i\mid\exists i\leq|\xi|:\xi[i]=\Delta_i\} visited ( ξ ) = { Δ i ∣ ∃ i ≤ ∣ ξ ∣ : ξ [ i ] = Δ i } for the set of states visited along ξ \xi ξ , we define:
Definition 6.4 (Weak almost-sure livelock). The weak almost-surely livelocked region for p:
WASlivelock p ( Δ ) = { Δ ′ ∈ Pend p ( Δ ) ∣ ∃ ϕ ∈ Φ Δ ′ Δ : ∀ ξ ∈ Ξ ϕ ( Δ ′ ) : visited ( ξ ) ⊆ Pend p ( Δ ) } \operatorname{WASlivelock}_{p}(\Delta)=\{\Delta'\in\operatorname{Pend}_{p}(\Delta)\mid\exists\phi\in\Phi_{\Delta'}^{\Delta}:\forall\xi\in\Xi_{\phi}(\Delta'):\operatorname{visited}(\xi)\subseteq\operatorname{Pend}_{p}(\Delta)\} WASlivelock p ( Δ ) = { Δ ′ ∈ Pend p ( Δ ) ∣ ∃ ϕ ∈ Φ Δ ′ Δ : ∀ ξ ∈ Ξ ϕ ( Δ ′ ) : visited ( ξ ) ⊆ Pend p ( Δ )} and WASlivelock ( Δ ) = ⋃ p ∈ dom ( Δ ) WASlivelock p ( Δ ) \operatorname{WASlivelock}(\Delta)=\bigcup_{p\in\operatorname{dom}(\Delta)}\operatorname{WASlivelock}_{p}(\Delta) WASlivelock ( Δ ) = ⋃ p ∈ dom ( Δ ) WASlivelock p ( Δ ) .
For a limit property φ \varphi φ , the standard end-component reduction gives Pmin ( φ ) = 1 − Pmax ( ◊ ( ⋃ i ∈ I S i ) ) (\varphi)=1-\operatorname{Pmax}\left(\Diamond\left(\bigcup_{i\in I}S_i\right)\right) ( φ ) = 1 − Pmax ( ◊ ( ⋃ i ∈ I S i ) ) , where I indexes all end components ( S i , A i ) (S_i,A_i) ( S i , A i ) whose recurrent behaviour violates φ \varphi φ [6 Theorem 10.122(b)] . Applying this reduction with fairness incorporated yields (Proof in §E.2):
Theorem 6.5. (Proof in §E.2). Pmin l i v e ( Δ ) = min ϕ ∈ Φ Δ Δ P Δ ϕ ( l i v e ) = 1 − max ϕ ∈ Φ Δ Δ P Δ ϕ ( ◊ WASlivelock ) \operatorname{Pmin}_{\mathrm{live}}(\Delta)=\min_{\phi\in\Phi_{\Delta}^{\Delta}}\operatorname{P}^{\phi}_{\Delta}(\mathrm{live})=1-\max_{\phi\in\Phi_{\Delta}^{\Delta}}\operatorname{P}^{\phi}_{\Delta}\left(\Diamond\operatorname{WASlivelock}\right) Pmin live ( Δ ) = min ϕ ∈ Φ Δ Δ P Δ ϕ ( live ) = 1 − max ϕ ∈ Φ Δ Δ P Δ ϕ ( ◊ WASlivelock )
Then, membership of the livelocked region becomes an atomic proposition. We define the label
S ⊢ “livelock” ⟺ ∃ Δ ′ ∈ WASlivelock ( Δ ) : ( [ [ Δ ] ] , S ) ∼ [ [ Δ ′ ] ] S \vdash\text{“livelock”} \Longleftrightarrow\exists\Delta' \in\operatorname{WASlivelock}(\Delta) : ([\![\Delta]\!], S) \sim[\![\Delta']\!] S ⊢ “livelock” ⟺ ∃ Δ ′ ∈ WASlivelock ( Δ ) : ([ [ Δ ] ] , S ) ∼ [ [ Δ ′ ] ]
which, like the labels of Def. 6.2, is a finite disjunction over valuations of the state variables S p S_p S p . The implementation precomputes WASlivelock ( Δ ) \operatorname{WASlivelock}(\Delta) WASlivelock ( Δ ) by an end-component analysis of the context MDP (details in §E.1). By Theorem 6.5 , we then obtain the liveness specification:
P l i v e min ( Δ ) = 1 − P max ( ◊ “livelock” ) P_{\mathrm{live}}^{\min}(\Delta) = 1 - P_{\max}(\Diamond\ \text{“livelock”}) P live m i n ( Δ ) = 1 − P m a x ( ◊ “livelock” )
Since the right-hand side is a reachability query maximised over all schedulers, no fairness constraint needs to be imposed on PRISM, and Δ \Delta Δ is almost-surely live iff P max ( ◊ “livelock” ) = 0 P_{\max}(\Diamond\ \text{“livelock”}) = 0 P m a x ( ◊ “livelock” ) = 0 .
Complexity. The runtime cost of our verification approach is dominated by the weak almost-sure livelock precomputation as well as the PRISM model-checking. Writing ∣ Δ ∣ |\Delta| ∣Δ∣ for the total number of nodes in the syntax trees of the types in Δ \Delta Δ , we have (Proof in §E.2.1):
Theorem 6.6. Let N N N be the number of reachable states of [ [ Δ ] ] [\![\Delta]\!] [ [ Δ ] ] and R = { Δ ′ ∣ Δ → ∗ Δ ′ } R = \{ \Delta' \mid\Delta\mathrel{\to^{*}} \Delta' \} R = { Δ ′ ∣ Δ → ∗ Δ ′ } . Then safe ( Δ ) \operatorname{safe}(\Delta) safe ( Δ ) , P d f min ( Δ ) P_{\mathrm{df}}^{\min}(\Delta) P df m i n ( Δ ) and P l i v e min ( Δ ) P_{\mathrm{live}}^{\min}(\Delta) P live m i n ( Δ ) can be computed in time polynomial in N N N , R R R and ∣ Δ ∣ |\Delta| ∣Δ∣ .
Corollary 6.7. Let k = ∣ dom ( Δ ) ∣ k = |\operatorname{dom}(\Delta)| k = ∣ dom ( Δ ) ∣ . Then safe ( Δ ) \operatorname{safe}(\Delta) safe ( Δ ) , P d f min ( Δ ) P_{\mathrm{df}}^{\min}(\Delta) P df m i n ( Δ ) and P l i v e min ( Δ ) P_{\mathrm{live}}^{\min}(\Delta) P live m i n ( Δ ) can be computed in time O ( ∣ Δ ∣ O ( k ) ) O(|\Delta|^{O(k)}) O ( ∣Δ ∣ O ( k ) ) , i.e. exponential in the number of participants.
In practice, synchronous communication often tightly couples the reachable set, as can be seen in our empirical evaluation. For instance, the product of the state spaces of the ten participants of Multiparty Workers exceeds a million states, yet only 1222 of them are reachable (Table 1 ).
Table 1. Benchmark results for Prose. WASL is the precomputation of the weak almost-sure livelocked region (Def. 6.4 ). All benchmarked processes can be found in the /examples/ folder of the artifact [35 ] .
Example 6.8. We consider the calculator service in Example 3.1 for the final time, with the encoding given in Figure 12 . The label “end” requires all three state variables S u S_u S u , S s S_s S s and S c S_c S c to be at their end states, and, for instance, “send :: c :: s :: error” holds exactly when S c = 5 S_c = 5 S c = 5 in Figure 12 , while “receive :: c :: s” holds when S s S_s S s is at the entry state of the branching of T s T_s T s . PRISM reports that Δ \Delta Δ is safe and that no reachable state satisfies “deadlock”, since the context never stops, and so P d f min ( Δ ) = 1 P_{\mathrm{df}}^{\min}(\Delta) = 1 P df m i n ( Δ ) = 1 . The precomputed region WASlivelock ( Δ ) \operatorname{WASlivelock}(\Delta) WASlivelock ( Δ ) is empty: u u u may be left pending while s s s and c c c exchange error and incr (Example 4.12 ), but no fair scheduler can keep all paths in this region, as every commitment step of c c c leaves it with probability 0.8 0.8 0.8 . Hence “livelock” is the constant false and P l i v e min ( Δ ) = 1 P_{\mathrm{live}}^{\min}(\Delta) = 1 P live m i n ( Δ ) = 1 . The calculator is thus almost-surely deadlock-free and live.
For a negative case, consider the extended context Δ 1 \Delta_1 Δ 1 of Example 4.16 (Figure 8 ). Here PRISM finds exactly one state satisfying “deadlock” ∧ \land ∧ ¬“end”, namely the encoding of Δ 9 \Delta_9 Δ 9 , in which S s S_s S s and S c S_c S c are at their end states while S u S_u S u is at the entry state of the branching &c?res. The label “livelock” is the disjunction of the valuations encoding Δ 9 \Delta_9 Δ 9 , where u u u is pending forever because other participants have ended, and Δ 10 \Delta_{10} Δ 10 and Δ 11 \Delta_{11} Δ 11 , where u u u is pending while s s s and c c c exchange retry. PRISM returns 0.31 0.31 0.31 and 0.474 0.474 0.474 for the two Pmax queries, giving P d f min ( Δ 1 ) = 0.69 P_{\mathrm{df}}^{\min}(\Delta_1) = 0.69 P df m i n ( Δ 1 ) = 0.69 and P l i v e min ( Δ 1 ) = 0.526 P_{\mathrm{live}}^{\min}(\Delta_1) = 0.526 P live m i n ( Δ 1 ) = 0.526 .
Implementation and Performance Evaluation
We implement our encoding and property specifications in Prose, a tool for the verification of probabilistic multiparty session types. Prose has been implemented in roughly 2800 lines of OCaml. It accepts a typing context as its input, and outputs the probabilities of properties in §4.3. Prose is designed to be a self-contained, standalone toolkit for verifying types as abstractions of programs. Prose aims to be used in conjunction with real programs (such as Go or Scala programs) following the line of [7 , 41 , 53 ] which have applied model checkers for types to real programs.
We evaluate the efficiency of Prose through performance benchmarks. The experiments were run on a laptop with an Apple M4 processor and 16GB of RAM, with OCaml 5.2.1 and PRISM v4.10.1. We discard one warmup run, then repeat each measurement 30 times and report its mean and relative
standard error. For each benchmark process, we record the type-inference time and use the inferred typing context for subsequent measurements: translation into a PRISM model, precomputation of the weak almost-sure livelocked region (Def. 6.4 ), and separate PRISM invocations for the three properties of § 7.1 (safety, deadlock-freedom, and liveness). We also measure the end-to-end runtime, including inference and translation, with a single PRISM invocation checking all three properties.
As the translation function executes very quickly, each of its 30 data points is the mean time of 100 consecutive calls (resulting in a total of 3,000 function calls), to reduce the effect of measurement overhead.
Table 1 presents the results, along with the size (number of states and transitions) of each context MDP. The benchmark processes and their example type specifications are provided in the /examples/ folder of the accompanying artifact [35 ] ; measurements use freshly inferred contexts. In addition, the results of the verification process are included in §E.5 for completeness. Most contexts are verified end-to-end in around 0.6s, and Dining Phils. (DP) in around 1.3s, demonstrating that Prose is suitable for practical use. Translation cost is negligible (<1ms), and the livelock-region precomputation is cheap (<6ms) on all contexts but DP, as the algorithm enumerates its large context state space. This makes PRISM model-checking the dominating cost. Model checking the same PRISM encoding with Storm [58 ] yielded similar results. End-to-end runtimes are close to those for individual properties, as PRISM’s internal model construction, performed once per invocation, accounts for most of each runtime.
Comparison with model checking processes. To compare scalability of verifying session types and processes, we have measured verification times and deadlock-freedom probabilities of a simple factorial multiparty session M i M_i M i and its typing context Δ i \Delta_i Δ i (for each 1 ≤ i ≤ 30 1 \le i \le30 1 ≤ i ≤ 30 ). While verifying sessions is undecidable in general (Proposition 2.3), this particular session can be translated into a finite-state PRISM module with one variable keeping track of its current state and one integer variable per received variable and per sent payload. Figure 13 a shows for n ≥ 14 n \ge14 n ≥ 14 , the PRISM invocations for session verification exhausted the allocated Java heap space (the default allocation is 1 GB), and consequently did not finish execution.
Figure 13. Verification times and deadlock-freedom probabilities of the factorial session M n M_n M n which probabilistically produces an error; and its typing context Δ n \Delta_n Δ n , with varying values of n n n . The verification times are a mean of 10 consecutive runs. For n ≥ 14 n \ge14 n ≥ 14 , the PRISM invocation for session M n M_n M n ran out of memory.
Moreover, Figure 13 b shows that the deadlock-freedom probability obtained from Δ n \Delta_n Δ n is a lower bound of the precise deadlock-freedom probability of M n M_n M n , with both tending to 0 0 0 as n n n grows. As we describe in Example 4.19, the loss of precision comes from the conditional expressions in our calculus, which are typed as nondeterministic choice. See §E.6 for a more detailed explanation and the factorial processes and types.
Prototype implementation of Type Inference & Checking
We implement a prototype of the type system, with roughly 1,500 lines of Haskell (GHC 9.6.7) (type inference and subtype check in Figure 1 ). The tool takes as input a program: a list of named PROMPT processes in a plain-text surface syntax mirroring § 3 , each optionally paired with a specified local type T s p e c T_{\mathrm{spec}} T spec . The main challenge to inference is recursion: [T-REC] assumes the very type being inferred, while deriving a type for conditionals and flips requires knowledge of the type constructor of their branch types T 1 T_1 T 1 and T 2 T_2 T 2 (conditionals must compute the least upper bound of T 1 T_1 T 1 and T 2 T_2 T 2 with respect to ≤ \le ≤ , and flips the merge T 1 ⊓ p T 2 T_1 \sqcap_p T_2 T 1 ⊓ p T 2 ).
Consider P = μ X . q ! m . F P = \mu X.q!m.F P = μ X . q ! m . F where F = flip ( p ) { h ⇒ X □ t ⇒ r ! m .0 } F = \operatorname{flip}(p)\{h \Rightarrow X \mathbin{\Box} t \Rightarrow r!m.0\} F = flip ( p ) { h ⇒ X □ t ⇒ r ! m .0 } . To type F F F requires the type of X X X , but finding that type requires typing F F F . We handle this circularity by recording type constraints and solving them on a finite graph. For example let T X ? T_X^? T X ? denote the unknown type of P P P (and X X X ), and T F ? T_F^? T F ? the unknown type of F F F . Using the same type unknown T X ? T_X^? T X ? for the recursive process and its bound occurrences of X X X , the prototype seeks a solution of the equations: T X ? = ⨁ { 1 : q ! m . T F ? } T_X^? = \bigoplus\{1:q!m.T_F^?\} T X ? = ⨁ { 1 : q ! m . T F ? } and T F ? = T X ? ⊓ p ⨁ { 1 : r ! m . end } T_F^? = T_X^? \sqcap_p \bigoplus\{1:r!m.\operatorname{end}\} T F ? = T X ? ⊓ p ⨁ { 1 : r ! m . end } .
The first equation determines an output node for T X ? T_X^? T X ? with an edge to the node reserved for T F ? T_F^? T F ? , whose outgoing edges are still unknown. To infer them, the solver follows X X X to its binder and exposes the leading q ! m q!m q ! m , retaining the reference to T F ? T_F^? T F ? beneath that send, yielding: T F ? = ⨁ { 1 : q ! m . T F ? } ⊓ p ⨁ { 1 : r ! m . end } T_F^? = \bigoplus\{1:q!m.T_F^?\} \sqcap_p \bigoplus\{1:r!m.\operatorname{end}\} T F ? = ⨁ { 1 : q ! m . T F ? } ⊓ p ⨁ { 1 : r ! m . end } . As both constructors under ⊓ p \sqcap_p ⊓ p are revealed, we can merge to get: T F ? = ⨁ { p : q ! m . T F ? , ( 1 − p ) : r ! m . end } T_F^? = \bigoplus\{p:q!m.T_F^?,(1-p):r!m.\operatorname{end}\} T F ? = ⨁ { p : q ! m . T F ? , ( 1 − p ) : r ! m . end } . The q ! m q!m q ! m continuation reuses the recorded node for F F F instead of unfolding the definition again, closing the cycle. Reading this graph as a recursive type yields T i n f = ⨁ { 1 : q ! m . μ t . ⨁ { p : q ! m . t , ( 1 − p ) : r ! m . end } } T_{\mathrm{inf}} = \bigoplus\{1:q!m.\mu t.\bigoplus\{p:q!m.t,(1-p):r!m.\operatorname{end}\}\} T inf = ⨁ { 1 : q ! m . μ t . ⨁ { p : q ! m . t , ( 1 − p ) : r ! m . end }} .
The tool outputs, per process, the inferred local type T i n f T_{\mathrm{inf}} T inf , and optionally for each type specification a verdict of the subtype check T i n f ≤ T s p e c T_{\mathrm{inf}} \le T_{\mathrm{spec}} T inf ≤ T spec , displaying both types on failure; Figure 1 highlights the two workflows. Inferred types can also be exported to the input format of Prose, our types to model checker translation § 6 , connecting inference directly to the verification pipeline.
The graph construction and the Cartesian products in [M-Σ] can both incur exponential growth, in the number of graph nodes and output summands respectively. This is consistent with the O ( n 2 n ) O(n2^n) O ( n 2 n ) worst-case behaviour reported for bottom-up type inference in [60 Thm. 5.26] , where n = ∣ P ∣ n = |P| n = ∣ P ∣ ; the left-most column of Table 1 reports measured inference times for our benchmark programs.
Related Work and Conclusion
Probabilistic linear and binary session types. While many probabilistic concurrent models have been studied in process algebra (e.g., CCS [24 ] , CSP [21 , 44 ] and mobile process calculi [27 , 47 ] ), few works use behavioural types to control and analyse probabilistic communications. The work in [61 ] applies linear types developed in [8 , 64 ] to give a sound and complete correspondence between probabilistic processes and confusion-free event structures. Dal Lago and Giusti [39 ] develop a probabilistic binary (2-party) session calculus based on bounded linear logic, where typed processes execute within probabilistic polynomial time, enabling reasoning about cryptographic protocols.
Inverso et al. [34 ] propose a probabilistic type system which statically estimates an upper bound on the probability of typed processes reaching successful states, using the top-level probabilistic choice P ⊞ p Q P \boxplus_p Q P ⊞ p Q for processes and types. Dal Lago and Padovani [40 ] study almost-sure termination of a binary session calculus with the same process-level probabilistic choice; their types carry no probability annotations, but real-valued heights bounding the expected number of reduction steps. This property is qualitative, whereas we derive quantitative bounds. Both calculi [34 , 40 ] are built on the linear logic-based binary session type systems [13 ] , expressing only tree-like network topologies and enforcing total (100%) deadlock-freedom, and every choice is probabilistic: there is no nondeterministic choice corresponding to our sums. Neither work provides an implementation.
Das et al. [17 ] propose probabilistic resource-aware session types extended from intuitionistic linear logic-based deadlock-free session types [13 ] , implemented as the programming language NomosPro, which verifies representative probabilistic distributed algorithms with exact probability and resource bounds . Like our work, they provide both nondeterministic and probabilistic choice, and our flip construct and merging operator for types are inspired by NomosPro.
Our merge T 1 ⊓ p T 2 T_1 \sqcap_p T_2 T 1 ⊓ p T 2 (Def. 3.8 ) takes the convex combination of the outermost probabilities and takes the least upper bounds under ≤ \leq ≤ for continuations that have a common prefix. Where the weighted sums of [17 , 20 ] require these continuations to coincide, our merge accepts differing continuations whenever their join exists. E.g., consider a server that is equally likely to be healthy or degraded, acknowledging a request with probability 0.9 0.9 0.9 or 0.5 0.5 0.5 , and then signalling hi or lo:
T H = ⨁ { 0.9 : q ! o k . ⨁ q ! h i . e n d , 0.1 : q ! e r r . e n d } , T T = ⨁ { 0.5 : q ! o k . ⨁ q ! l o . e n d , 0.5 : q ! e r r . e n d } . T_{\mathrm{H}} = \bigoplus\{0.9:q!\mathrm{ok}.\bigoplus q!\mathrm{hi}.\mathrm{end},\ 0.1:q!\mathrm{err}.\mathrm{end}\},\quad T_{\mathrm{T}} = \bigoplus\{0.5:q!\mathrm{ok}.\bigoplus q!\mathrm{lo}.\mathrm{end},\ 0.5:q!\mathrm{err}.\mathrm{end}\}. T H = ⨁ { 0.9 : q ! ok . ⨁ q ! hi . end , 0.1 : q ! err . end } , T T = ⨁ { 0.5 : q ! ok . ⨁ q ! lo . end , 0.5 : q ! err . end } .
Then we have: T H ⊓ 0.5 T T = ⨁ { 0.7 : q ! o k . Σ { ⨁ q ! h i . e n d , ⨁ q ! l o . e n d } , 0.3 : q ! e r r . e n d } T_{\mathrm{H}} \sqcap_{0.5} T_{\mathrm{T}} = \bigoplus\{0.7:q!\mathrm{ok}.\mathop{\Sigma}\{\bigoplus q!\mathrm{hi}.\mathrm{end},\bigoplus q!\mathrm{lo}.\mathrm{end}\},\ 0.3:q!\mathrm{err}.\mathrm{end}\} T H ⊓ 0.5 T T = ⨁ { 0.7 : q ! ok . Σ { ⨁ q ! hi . end , ⨁ q ! lo . end } , 0.3 : q ! err . end } , while in [17 , 20 ] , this is undefined. The server remains typable despite its differing continuations: the probability of ok is retained exactly, while the subsequent choice between hi and lo is abstracted by nondeterminism. The work in [17 ] is extended to probabilistic refinement session types [20 ] , augmented by symbolic probabilities indexed by refinement variables, enabling parameterised probabilistic reasoning and analyses of expected resource costs. Their implementation reconstructs the intermediate types of channels with an SMT solver, verifying declared types, whereas type-checking in our system is decidable (Theorem 3.14). Their implementation of Lehmann and Rabin’s randomised dining philosophers [42 ] uses a coordinating process and an indexed ring, with refinement predicates tracking fork availability and ownership. Our multiparty formulation (Example B.1) expresses contention directly through separated external choice: each fork accepts requests from either neighbour, then awaits its holder’s release while rejecting competing requests. Ownership is captured by the session-type continuations, without refinement indices or a central process mediating fork acquisition.
None of the above calculi study probabilistic deadlock-freedom or liveness; processes with only partial deadlock-freedom are untypable.
Probabilistic multiparty session types (MPST) and choreographies. Aman and Ciobanu [1 , 2 ] extend MPST [30 , 31 ] with probability intervals on selections in global and local types. Their top-down approach checks conformance to interval-annotated global protocols. Our bottom-up approach [60 ] instead analyses locally typed sessions and establishes lower bounds on their probabilities of deadlock-freedom and liveness, including sessions for which these properties do not hold. on every fair execution. Blechschmidt et al. [10 ] propose a probabilistic mixed choice multiparty session π \pi π -calculus. Their refinement subtyping permits replacement of a channel by several channels implementing the same behaviour, differing from the standard subtyping relation defined between two local types. The works in [1 , 2 , 10 ] provide no implementation. Carbone and Veschetti [14 ] propose a probabilistic deadlock-free choreographic calculus with choices explicitly annotated by probabilities (akin to global types in [1, 2]), prove the correctness of its translation into PRISM, and compare outcomes of probabilistic measurements against the original PRISM case studies. Their language more closely resembles the PRISM language than our local types: a choreographic sending-receiving construct describes both endpoints of a communication at once, mapping directly to one action in PRISM, whereas we translate each participant of a typing context into its own PRISM module (§5.2.2), with a communication arising as a synchronisation between the sender’s and receiver’s modules. Proving that each reduction of the typing context corresponds to exactly one transition of the composed model ({xref}Thms. 5.6 and 5.7`) requires a closure module blocking spurious unsynchronised transitions and a bisimulation relating models under recursion unfolding, making our correctness proofs much more involved. No works above analyse probabilistic bounds for properties such as deadlock-freedom and liveness.
Model checking behavioural types and programs. We translate types rather than processes to the PRISM language because: (1) verification of session types is guaranteed to terminate, whereas even safety of processes is undecidable (Proposition 2.3); and (2) translating processes results in a far larger state space, as exact values of every variable must be tracked, making verification of types more efficient and scalable, as shown in Figure 13 and §E.6.
Model checking real-world programs has a long history [62 ] . Chaki et al. [16 ] are the first to propose model checking behavioural types (an abstraction of π \pi π -processes) developed in [33 ] . More recently, [52 ] applied mCRL2 [12 ] to verify multiparty session types, an approach subsequently extended to Go [41 ] and Scala [53 ] programs, and to distributed failures [7 ] . None of the above are probabilistic.
Beyond behavioural types, Enea et al. [19 ] verify fair almost-sure termination of randomized distributed algorithms such as Ben-Or’s consensus, using a proof rule combining martingale-based termination arguments with weak fairness, discharged by an SMT solver. Their deductive approach works directly on processes whose state spaces may grow unboundedly, beyond the reach of finite-state model checking; conversely, they establish termination with probability one, whereas we derive quantitative lower bounds on deadlock-freedom and liveness.
Conclusion. We have presented the first probabilistic multiparty session type theory for deriving probabilistic properties (probabilistic deadlock-freedom and liveness) of typed multiparty session processes. Our nondeterministic sums abstract data-dependent control, inducing lower bounds on probabilistic properties that hold under every fair adversarial scheduler. We have implemented the tool-chain PROSE based on the precise translation from session types to PRISM, and evaluated it on several case studies. Our future work includes the extension of the calculus with session delegations [31 , 52 ] , dynamically joining participants [15 , 18 ] and asynchronous sessions [51 ] . Our subtyping system is not precise in the sense of [22 , 23 , 45 ] . For example, ⊕ { 0.5 : p ! m } ⪯̸ { ⊕ { 0.5 : p ! m } , ⊕ { q ! m } } \oplus\{0.5 : \mathbf{p}!m\} \not\preceq\{\oplus\{0.5 : \mathbf{p}!m\}, \oplus\{q!m\}\} ⊕ { 0.5 : p ! m } ⪯ { ⊕ { 0.5 : p ! m } , ⊕ { q ! m }} , although the distribution on the left is a convex combination of the alternatives on the right. Investigating probabilistic bisimulations [54 ] to refine subtyping and minimise session types is another direction for future work. We also plan to analyse more advanced properties such as real-time session type specifications [32 , 63 ] , taking advantage of PRISM’s support for probabilistic timed automata.
Acknowledgements. We thank the POPL reviewers for their careful comments, encouragement and detailed suggestions. We thank Jake Masters for discussions and Kai Pischke for testing our artifact.
This work is supported by ARIA MSAI-PR01-P020 and MSAI-PR01-P029; and EPSRC EP/T006544/2, EP/T014709/2, EP/Z533749/1 and EP/Y005244/1; Horizon EU TaRDIS 101093006 (UKRI number 10066667); and a grant from the Simons Foundation.
Data Availability Statement
The implementation of PROSE, as well as scripts and instructions to reproduce the experimental results of this paper as well as the prototype for type-checking and type-inference are included as an artifact available on Zenodo [35 ] .
Disclosure of Use of AI in Research
We used OpenAI’s GPT-6 Astra [48 ] , accessed through Codex, to assist with the implementation of the type-inference prototype promt, and to generate regression tests and explore counterexamples. We additionally used Anthropic’s Claude Fable [4 ] , accessed through Claude Code, to assist with the implementation of PROSE and to generate benchmarking scripts. The authors directed this work and take responsibility for the implementation and reported results.
Appendix for Section 2
Proofs for sec:processes
Derived expressions. From the grammar in §2 we abbreviate, for a natural e e e and a numeral j j j :
pred ( e ) ≜ e + neg ( 1 ) e = 0 ≜ ¬ ( e > 0 ) e = j ≜ ¬ ( ( e > j ) ∨ ( j > e ) ) , \operatorname{pred}(e) \triangleq e + \operatorname{neg}(1) \qquad e = 0 \triangleq\neg(e > 0) \qquad e = j \triangleq\neg((e > j) \lor(j > e)), pred ( e ) ≜ e + neg ( 1 ) e = 0 ≜ ¬ ( e > 0 ) e = j ≜ ¬ (( e > j ) ∨ ( j > e )) ,
the decrement, the zero-test, and comparison against a fixed numeral.
Two-counter machines. A Minsky machine M \mathcal{M} M is a finite instruction list I 0 , … , I K I_0,\ldots,I_K I 0 , … , I K over counters c 1 , c 2 c_1,c_2 c 1 , c 2 , each instruction of the form "INCc r c_r c r ; goto j j j ", "DECJZc r ( j z , j n z ) _{c_r}(j_z,j_{nz}) c r ( j z , j n z ) " or "HALT". Configurations ( k , a , b ) ∈ { 0 , … , K } × N 2 (k,a,b) \in\{0,\ldots,K\} \times\mathbb{N}^2 ( k , a , b ) ∈ { 0 , … , K } × N 2 step by a standard reduction relation ⟶ M \longrightarrow_{\mathcal{M}} ⟶ M . The instruction pointer k k k is bounded, so the control is finite; the Turing power resides entirely in the unbounded nat counters a , b a,b a , b . M \mathcal{M} M halts if ( 0 , 0 , 0 ) ⟶ M ∗ ( k , ⋅ , ⋅ ) (0,0,0) \longrightarrow_{\mathcal{M}}^* (k,\cdot,\cdot) ( 0 , 0 , 0 ) ⟶ M ∗ ( k , ⋅ , ⋅ ) and I k = H A L T I_k = \mathrm{HALT} I k = HALT . Determining whether M \mathcal{M} M halts is undecidable [46 ] .
The encoding. We show how to encode a Minsky machine M \mathcal{M} M into a multiparty session ⟨ ⟨ M ⟩ ⟩ \langle\langle\mathcal{M}\rangle\rangle ⟨⟨ M ⟩⟩ . A controller c c c computes; a memory m m m echoes the live state ( k , a , b ) (k,a,b) ( k , a , b ) back each round (three nat messages, labels ℓ k , ℓ a , ℓ b \ell_k,\ell_a,\ell_b ℓ k , ℓ a , ℓ b ):
M e m ≜ c ! ℓ k ⟨ 0 ⟩ . c ! ℓ a ⟨ 0 ⟩ . c ! ℓ b ⟨ 0 ⟩ . μ Y . c ? ℓ k ( k ) . c ? ℓ a ( a ) . c ? ℓ b ( b ) . c ! ℓ k ⟨ k ⟩ . c ! ℓ a ⟨ a ⟩ . c ! ℓ b ⟨ b ⟩ . Y \mathit{Mem} \triangleq c!\ell_k\langle0\rangle.c!\ell_a\langle0\rangle.c!\ell_b\langle0\rangle.\mu Y.c?\ell_k(k).c?\ell_a(a).c?\ell_b(b).c!\ell_k\langle k\rangle.c!\ell_a\langle a\rangle.c!\ell_b\langle b\rangle.Y Mem ≜ c ! ℓ k ⟨ 0 ⟩ . c ! ℓ a ⟨ 0 ⟩ . c ! ℓ b ⟨ 0 ⟩ . μ Y . c ? ℓ k ( k ) . c ? ℓ a ( a ) . c ? ℓ b ( b ) . c ! ℓ k ⟨ k ⟩ . c ! ℓ a ⟨ a ⟩ . c ! ℓ b ⟨ b ⟩ . Y
C ≜ μ X . m ? ℓ k ( k ) . m ? ℓ a ( a ) . m ? ℓ b ( b ) . D i s p C \triangleq\mu X.m?\ell_k(k).m?\ell_a(a).m?\ell_b(b).\mathit{Disp} C ≜ μ X . m ? ℓ k ( k ) . m ? ℓ a ( a ) . m ? ℓ b ( b ) . Disp
D i s p ≜ if k = 0 then A 0 else ( ⋯ if k = K − 1 then A K − 1 else A K ) \mathit{Disp} \triangleq\text{if } k = 0 \text{ then } A_0 \text{ else } (\cdots\text{ if } k = K - 1 \text{ then } A_{K-1} \text{ else } A_K) Disp ≜ if k = 0 then A 0 else ( ⋯ if k = K − 1 then A K − 1 else A K )
where, the branch A j A_j A j realises instruction I j I_j I j for j ≤ K j \le K j ≤ K :
⟨ ⟨ INC c 1 ; goto j ⟩ ⟩ : A j ≜ m ! ℓ k ⟨ j ⟩ . m ! ℓ a ⟨ succ ( a ) ⟩ . m ! ℓ b ⟨ b ⟩ . X \langle\langle\text{INC}_{c_1};\text{ goto }j\rangle\rangle:\quad A_j \triangleq m!\ell_k\langle j\rangle.m!\ell_a\langle\operatorname{succ}(a)\rangle.m!\ell_b\langle b\rangle.X ⟨⟨ INC c 1 ; goto j ⟩⟩ : A j ≜ m ! ℓ k ⟨ j ⟩ . m ! ℓ a ⟨ succ ( a )⟩ . m ! ℓ b ⟨ b ⟩ . X
⟨ ⟨ INC c 2 ; goto j ⟩ ⟩ : A j ≜ m ! ℓ k ⟨ j ⟩ . m ! ℓ a ⟨ a ⟩ . m ! ℓ b ⟨ succ ( b ) ⟩ . X \langle\langle\text{INC}_{c_2};\text{ goto }j\rangle\rangle:\quad A_j \triangleq m!\ell_k\langle j\rangle.m!\ell_a\langle a\rangle.m!\ell_b\langle\operatorname{succ}(b)\rangle.X ⟨⟨ INC c 2 ; goto j ⟩⟩ : A j ≜ m ! ℓ k ⟨ j ⟩ . m ! ℓ a ⟨ a ⟩ . m ! ℓ b ⟨ succ ( b )⟩ . X
⟨ ⟨ DECJZ c 1 ( j z , j n z ) ⟩ ⟩ : A j ≜ if a = 0 then m ! ℓ k ⟨ j z ⟩ . m ! ℓ a ⟨ a ⟩ . m ! ℓ b ⟨ b ⟩ . X else m ! ℓ k ⟨ j n z ⟩ . m ! ℓ a ⟨ pred ( a ) ⟩ . m ! ℓ b ⟨ b ⟩ . X \langle\langle\text{DECJZ}_{c_1}(j_z,j_{nz})\rangle\rangle:\quad A_j \triangleq\text{if }a=0\text{ then }m!\ell_k\langle j_z\rangle.m!\ell_a\langle a\rangle.m!\ell_b\langle b\rangle.X\text{ else }m!\ell_k\langle j_{nz}\rangle.m!\ell_a\langle\operatorname{pred}(a)\rangle.m!\ell_b\langle b\rangle.X ⟨⟨ DECJZ c 1 ( j z , j n z )⟩⟩ : A j ≜ if a = 0 then m ! ℓ k ⟨ j z ⟩ . m ! ℓ a ⟨ a ⟩ . m ! ℓ b ⟨ b ⟩ . X else m ! ℓ k ⟨ j n z ⟩ . m ! ℓ a ⟨ pred ( a )⟩ . m ! ℓ b ⟨ b ⟩ . X
⟨ ⟨ DECJZ c 2 ( j z , j n z ) ⟩ ⟩ : A j ≜ if b = 0 then m ! ℓ k ⟨ j z ⟩ . m ! ℓ a ⟨ a ⟩ . m ! ℓ b ⟨ b ⟩ . X else m ! ℓ k ⟨ j n z ⟩ . m ! ℓ a ⟨ a ⟩ . m ! ℓ b ⟨ pred ( b ) ⟩ . X \langle\langle\text{DECJZ}_{c_2}(j_z,j_{nz})\rangle\rangle:\quad A_j \triangleq\text{if }b=0\text{ then }m!\ell_k\langle j_z\rangle.m!\ell_a\langle a\rangle.m!\ell_b\langle b\rangle.X\text{ else }m!\ell_k\langle j_{nz}\rangle.m!\ell_a\langle a\rangle.m!\ell_b\langle\operatorname{pred}(b)\rangle.X ⟨⟨ DECJZ c 2 ( j z , j n z )⟩⟩ : A j ≜ if b = 0 then m ! ℓ k ⟨ j z ⟩ . m ! ℓ a ⟨ a ⟩ . m ! ℓ b ⟨ b ⟩ . X else m ! ℓ k ⟨ j n z ⟩ . m ! ℓ a ⟨ a ⟩ . m ! ℓ b ⟨ pred ( b )⟩ . X
⟨ ⟨ HALT ⟩ ⟩ : A j ≜ m ! s t o p ⟨ 0 ⟩ .0 \langle\langle\text{HALT}\rangle\rangle:\quad A_j \triangleq m!\mathrm{stop}\langle0\rangle.0 ⟨⟨ HALT ⟩⟩ : A j ≜ m ! stop ⟨ 0 ⟩ .0
The session is ⟨ ⟨ M ⟩ ⟩ ≜ c ◃ C ∣ m ◃ M e m \langle\langle\mathcal{M}\rangle\rangle\triangleq c \triangleleft C \mid m \triangleleft\mathit{Mem} ⟨⟨ M ⟩⟩ ≜ c ◃ C ∣ m ◃ Mem . Its communication skeleton ranges over the finite label set { ℓ k , ℓ a , ℓ b , s t o p } \{\ell_k,\ell_a,\ell_b,\mathrm{stop}\} { ℓ k , ℓ a , ℓ b , stop } and all unboundedness sits in the nat payloads, so each role is typable with a finite-μ \mu μ local type.
The encoding faithfully simulates M \mathcal{M} M (Lemma A.1 ), and the sole label that can ever mismatch is s t o p \mathrm{stop} stop , emitted only by the HALT arm; so an error is reachable iff M \mathcal{M} M reaches the ( k , ⋅ , ⋅ ) (k,\cdot,\cdot) ( k , ⋅ , ⋅ ) for which I k = H A L T I_k=\mathrm{HALT} I k = HALT (shown below).
Dispatch configurations. For γ = ( k , a , b ) \gamma=(k,a,b) γ = ( k , a , b ) write D ( γ ) D(\gamma) D ( γ ) for the configuration with c c c poised at D i s p \mathit{Disp} Disp under { k , a , b } \{k,a,b\} { k , a , b } and m m m at its loop head awaiting the next triple from c c c :
D ( γ ) ≜ c ◃ D i s p { k , a , b } ∣ m ◃ c ? ℓ k ( k ′ ) . c ? ℓ a ( a ′ ) . c ? ℓ b ( b ′ ) . c ! ℓ k ⟨ k ′ ⟩ . c ! ℓ a ⟨ a ′ ⟩ . c ! ℓ b ⟨ b ′ ⟩ . Y . D(\gamma) \triangleq c \triangleleft\mathit{Disp}\{k,a,b\}\mid m \triangleleft c?\ell_k(k').c?\ell_a(a').c?\ell_b(b').c!\ell_k\langle k'\rangle.c!\ell_a\langle a'\rangle.c!\ell_b\langle b'\rangle.Y. D ( γ ) ≜ c ◃ Disp { k , a , b } ∣ m ◃ c ? ℓ k ( k ′ ) . c ? ℓ a ( a ′ ) . c ? ℓ b ( b ′ ) . c ! ℓ k ⟨ k ′ ⟩ . c ! ℓ a ⟨ a ′ ⟩ . c ! ℓ b ⟨ b ′ ⟩ . Y .
Lemma A.1 (Simulation). Let γ 0 ⟶ M γ 1 ⟶ M ⋯ \gamma_0 \longrightarrow_{\mathcal{M}} \gamma_1 \longrightarrow_{\mathcal{M}} \cdots γ 0 ⟶ M γ 1 ⟶ M ⋯ be the run of M \mathcal{M} M from γ 0 = ( 0 , 0 , 0 ) \gamma_0=(0,0,0) γ 0 = ( 0 , 0 , 0 ) . Then:
⟨ ⟨ M ⟩ ⟩ ⟶ 1 + D ( γ 0 ) \langle\langle\mathcal{M}\rangle\rangle\longrightarrow_1^+ D(\gamma_0) ⟨⟨ M ⟩⟩ ⟶ 1 + D ( γ 0 ) ;
if γ n = ( k , a , b ) \gamma_n=(k,a,b) γ n = ( k , a , b ) with I k ≠ H A L T I_k\ne\mathrm{HALT} I k = HALT and γ n ⟶ M γ n + 1 \gamma_n\longrightarrow_{\mathcal{M}}\gamma_{n+1} γ n ⟶ M γ n + 1 , then D ( γ n ) ⟶ 1 + D ( γ n + 1 ) D(\gamma_n)\longrightarrow_1^+D(\gamma_{n+1}) D ( γ n ) ⟶ 1 + D ( γ n + 1 ) with D ( γ n + 1 ) ≠ e r r o r D(\gamma_{n+1})\ne\mathrm{error} D ( γ n + 1 ) = error ;
if γ n = ( k , a , b ) \gamma_n=(k,a,b) γ n = ( k , a , b ) with I k = H A L T I_k=\mathrm{HALT} I k = HALT , then D ( γ n ) ⟶ 1 + e r r o r D(\gamma_n)\longrightarrow_1^+\mathrm{error} D ( γ n ) ⟶ 1 + error , and every maximal reduction from D ( γ n ) D(\gamma_n) D ( γ n ) reaches error.
Proof. (1) The three initial outputs of M e m \mathit{Mem} Mem (ℓ k ⟨ 0 ⟩ \ell_k\langle0\rangle ℓ k ⟨ 0 ⟩ , ℓ a ⟨ 0 ⟩ \ell_a\langle0\rangle ℓ a ⟨ 0 ⟩ , ℓ b ⟨ 0 ⟩ \ell_b\langle0\rangle ℓ b ⟨ 0 ⟩ , all addressed to c c c ) meet the matching inputs at the head of C C C by [R-COM]; C C C then stands at D i s p { 0 , 0 , 0 } \mathit{Disp}\{0,0,0\} Disp { 0 , 0 , 0 } , and unfolding μ Y \mu Y μ Y once leaves M e m \mathit{Mem} Mem at its loop head, together giving D ( γ 0 ) D(\gamma_0) D ( γ 0 ) . (2) Reachable configurations have k ≤ K k \le K k ≤ K , so the cascade selects A k A_k A k . That arm computes γ n + 1 \gamma_{n+1} γ n + 1 from γ n \gamma_n γ n using either ⟨ ⟨ I N C c r … ⟩ ⟩ \langle\langle\mathrm{INC}_{cr}\ldots\rangle\rangle ⟨⟨ INC cr … ⟩⟩ or ⟨ ⟨ D E C J Z c r … ⟩ ⟩ \langle\langle\mathrm{DECJZ}_{cr}\ldots\rangle\rangle ⟨⟨ DECJZ cr … ⟩⟩ and sends the result to m m m , which echoes it back to c c c , yielding D ( γ n + 1 ) D(\gamma_{n+1}) D ( γ n + 1 ) . Every message uses a label in { ℓ k , ℓ a , ℓ b } \{\ell_k,\ell_a,\ell_b\} { ℓ k , ℓ a , ℓ b } that its partner’s input offers, so [R-ERR] never applies on the segment.
(3) The cascade selects A k = m ! s t o p ⟨ 0 ⟩ .0 A_k = m!\mathrm{stop}\langle0\rangle.0 A k = m ! stop ⟨ 0 ⟩ .0 , so D ( γ n ) D(\gamma_n) D ( γ n ) reduces internally to c ◃ m ! s t o p ⟨ 0 ⟩ .0 ∣ m ◃ c ? ℓ k ( k ′ ) . ⋯ c \triangleleft m!\mathrm{stop}\langle0\rangle.0 \mathbin{|} m \triangleleft c?\ell_k(k').\cdots c ◃ m ! stop ⟨ 0 ⟩ .0 ∣ m ◃ c ? ℓ k ( k ′ ) . ⋯ . The memory offers a single input branch, from c c c on ℓ k \ell_k ℓ k : thus c c c is a partner (∃ j : p = p j \exists j : p = p_j ∃ j : p = p j ) but no branch carries s t o p \mathrm{stop} stop (∄ i : p i = c ∧ ℓ i = s t o p \nexists i : p_i = c \land\ell_i = \mathrm{stop} ∄ i : p i = c ∧ ℓ i = stop ), so [R-ERR] fires and the configuration reduces to error. No other reduction is available (both prefixes need a partner, and [R-COMM] is blocked by the label clash), and the preceding dispatch is deterministic, so every maximal reduction from D ( γ n ) D(\gamma_n) D ( γ n ) reaches error. □
Proposition 2.3. (Proof in §A.1). It is undecidable to check safety of (untyped) sessions: no algorithm exists that, given an arbitrary session M M M , can decide whether M ̸ ⟶ ∗ e r r o r M \not\longrightarrow^{*}\mathrm{error} M ⟶ ∗ error .
Proof. Via the encoding of §A.1 and Lemma A.1 . We show ⟨ ⟨ M ⟩ ⟩ \langle\langle M\rangle\rangle ⟨⟨ M ⟩⟩ is safe ⟺ M \Longleftrightarrow M ⟺ M does not halt.
(M M M does not halt) I.e. its run is infinite and no γ n = ( k , ⋅ , ⋅ ) \gamma_n = (k,\cdot,\cdot) γ n = ( k , ⋅ , ⋅ ) has I k = H A L T I_k = \mathrm{HALT} I k = HALT . By Lemma A.1 (1)–(2) and induction, every configuration reachable from ⟨ ⟨ M ⟩ ⟩ \langle\langle M\rangle\rangle ⟨⟨ M ⟩⟩ lies on a segment D ( γ n ) ⟶ 1 + D ( γ n + 1 ) D(\gamma_n) \longrightarrow^{+}_{1} D(\gamma_{n+1}) D ( γ n ) ⟶ 1 + D ( γ n + 1 ) , none of which reduces to error (the only label that could trigger [R-ERR] is s t o p \mathrm{stop} stop , emitted solely by a HALT arm, never selected). Hence ⟨ ⟨ M ⟩ ⟩ ̸ ⟶ ∗ e r r o r \langle\langle M\rangle\rangle\not\longrightarrow^{*}\mathrm{error} ⟨⟨ M ⟩⟩ ⟶ ∗ error : it is safe.
(M M M halts) Some reachable γ n = ( k , ⋅ , ⋅ ) \gamma_n = (k,\cdot,\cdot) γ n = ( k , ⋅ , ⋅ ) has I k = H A L T I_k = \mathrm{HALT} I k = HALT . By Lemma A.1 (1)–(2), ⟨ ⟨ M ⟩ ⟩ ⟶ 1 ∗ D ( γ n ) \langle\langle M\rangle\rangle\longrightarrow^{*}_{1}D(\gamma_n) ⟨⟨ M ⟩⟩ ⟶ 1 ∗ D ( γ n ) , and by (3) D ( γ n ) ⟶ 1 + e r r o r D(\gamma_n)\longrightarrow^{+}_{1}\mathrm{error} D ( γ n ) ⟶ 1 + error . Hence ⟨ ⟨ M ⟩ ⟩ ⟶ ∗ e r r o r \langle\langle M\rangle\rangle\longrightarrow^{*}\mathrm{error} ⟨⟨ M ⟩⟩ ⟶ ∗ error : it is unsafe.
Thus ⟨ ⟨ M ⟩ ⟩ ⟶ ∗ e r r o r \langle\langle M\rangle\rangle\longrightarrow^{*}\mathrm{error} ⟨⟨ M ⟩⟩ ⟶ ∗ error iff M M M halts. As M M M halting is undecidable, so is deciding ⟨ ⟨ M ⟩ ⟩ ⟶ ∗ e r r o r \langle\langle M\rangle\rangle\longrightarrow^{*}\mathrm{error} ⟨⟨ M ⟩⟩ ⟶ ∗ error , and hence safety. □
Appendix for Section 3
Derivation rules for merging
For the proofs of the appendix, we give an equivalent rule-based presentation of Def. 3.8 . The rules are read up to unfolding. Only [M-Σ] has merge premises, each relating two selection distributions and hence discharged by [M-⊕]. Thus merge derivations are finite ; continuation joins (⊔ \sqcup ⊔ ) refer to the independently defined least-upper-bound relation.
\begin{aligned}
&\text{[M-END]} && \mathrm{end}\sqcap_p\mathrm{end}=\mathrm{end}\\[4pt]
&\text{[M-\&]} && K=\{k\in I\cap J\mid\exists T:T_k\sqcup T'_k=T''\}\quad\{q_i\}_{i\in I}=\{q_j\}_{j\in J}=\{q_k\}_{k\in K}\\
&&&\bigwedge_{i\in I}q_i?\ell_i(B_i).T_i\sqcap_p\bigwedge_{j\in J}q_j?\ell_j(B_j).T'_j=\bigwedge_{k\in K}q_k?\ell_k(B_k).(T_k\sqcup T'_k)\\[4pt]
&\text{[M-\oplus]} && \forall k\in I\setminus J:p''_k=p\cdot p_k\land T''_k=T_k\\
&&&\forall k\in J\setminus I:p''_k=(1-p)\cdot p'_k\land T''_k=T'_k\\
&&&\forall k\in I\cap J:p''_k=p\cdot p_k+(1-p)\cdot p'_k\land T_k\sqcup T'_k=T''_k\\
&&&\bigoplus_{i\in I}p_i:q_i!\ell_i\langle B_i\rangle.T_i\sqcap_p\bigoplus_{j\in J}p'_j:q_j!\ell_j\langle B_j\rangle.T'_j=\bigoplus_{k\in I\cup J}p''_k:q_k!\ell_k\langle B_k\rangle.T''_k\\[4pt]
&\text{[M-\Sigma]} && |I|\cdot|J|>1\quad\forall(i,j)\in I\times J:T_i\sqcap_pT'_j=T_{i,j}\\
&&&\sum_{i\in I}T_i\sqcap_p\sum_{j\in J}T'_j=\sum_{(i,j)\in I\times J}T_{i,j}
\end{aligned}
With other cases being undefined.
Full dining philosophers example
Example B.1 (Dining philosophers). We consider the dining philosophers example with n n n philosophers, indices i ∈ Z n i\in\mathbb{Z}_n i ∈ Z n (all index arithmetic mod n n n ). Each philosopher P i P_i P i shares fork f i f_i f i with its left neighbour and f i + 1 f_{i+1} f i + 1 with its right neighbour, and reports to a shared food role when it is ready to eat.
P i = μ X . flip ( p ) { H ⇒ P ( f i , f i + 1 ) T ⇒ P ( f i + 1 , f i ) P_i=\mu X.\operatorname{flip}(p)
\begin{cases}
\mathrm{H}\Rightarrow P(f_i,f_{i+1})\\
\mathrm{T}\Rightarrow P(f_{i+1},f_i)
\end{cases} P i = μ X . flip ( p ) { H ⇒ P ( f i , f i + 1 ) T ⇒ P ( f i + 1 , f i )
P ( a , b ) = μ Y . a ! pick . ∑ { a ? free . b ! pick . { b ? notFree . a ! drop . X b ? free . food ! eat . a ! drop . b ! drop . X a ? notFree . Y P(a,b)=\mu Y.\,a!\operatorname{pick}.\sum
\begin{cases}
a?\operatorname{free}.b!\operatorname{pick}.\begin{cases}
b?\operatorname{notFree}.a!\operatorname{drop}.X\\
b?\operatorname{free}.\operatorname{food}!\operatorname{eat}.a!\operatorname{drop}.b!\operatorname{drop}.X
\end{cases}\\
a?\operatorname{notFree}.Y
\end{cases} P ( a , b ) = μ Y . a ! pick . ∑ ⎩ ⎨ ⎧ a ? free . b ! pick . { b ? notFree . a ! drop . X b ? free . food ! eat . a ! drop . b ! drop . X a ? notFree . Y
Philosopher P i P_i P i flips a coin to decide which fork to reach for first: on heads it runs P ( f i , f i + 1 ) P(f_i,f_{i+1}) P ( f i , f i + 1 ) , requesting f i f_i f i before f i + 1 f_{i+1} f i + 1 , and on tails the two are swapped—this randomisation breaks the symmetry that would otherwise deadlock [42 ] . The routine P ( a , b ) P(a,b) P ( a , b ) requests fork a a a ; on notFree \operatorname{notFree} notFree it retries the same fork, and on free \operatorname{free} free it requests the second fork b b b . If b b b answers notFree \operatorname{notFree} notFree it drops a a a and starts over; otherwise it holds both forks, signals food \operatorname{food} food , and releases them.
F i = μ X . ∑ { Q ( p i , p i − 1 ) Q ( p i − 1 , p i ) Q ( a , b ) = a ? pick . a ! free . μ Y . ∑ { a ? drop . X b ? pick . b ! notFree . Y Food = μ X . ∑ i ∈ Z n p i ? eat . X F_i=\mu X.\sum
\begin{cases}
Q(p_i,p_{i-1})\\
Q(p_{i-1},p_i)
\end{cases}
\qquad
Q(a,b)=a?\operatorname{pick}.a!\operatorname{free}.\mu Y.\sum
\begin{cases}
a?\operatorname{drop}.X\\
b?\operatorname{pick}.b!\operatorname{notFree}.Y
\end{cases}
\qquad
\operatorname{Food}=\mu X.\sum_{i\in\mathbb{Z}_n}p_i?\operatorname{eat}.X F i = μ X . ∑ { Q ( p i , p i − 1 ) Q ( p i − 1 , p i ) Q ( a , b ) = a ? pick . a ! free . μ Y . ∑ { a ? drop . X b ? pick . b ! notFree . Y Food = μ X . i ∈ Z n ∑ p i ? eat . X
Once a philosopher holds both f i f_i f i and f i + 1 f_{i+1} f i + 1 he sends eat \operatorname{eat} eat to food \operatorname{food} food , then puts both forks down and starts over.
Session types. We now give the type of each participant. The only bulky fragment is the continuation reached once the first fork has been granted, so we abbreviate it as T E T_E T E (the eat-attempt ) and let T P T_P T P name the type of the grab routine P ( a , b ) P(a,b) P ( a , b ) :
T E ( a , b ) = ⊕ b ! pick . & { b ? free . ⊕ food ! eat . ⊕ a ! drop . ⊕ b ! drop . t , b ? notFree . ⊕ a ! drop . t } T_E(a,b)=\oplus b!\operatorname{pick}.\&\{b?\operatorname{free}.\oplus\operatorname{food}!\operatorname{eat}.\oplus a!\operatorname{drop}.\oplus b!\operatorname{drop}.t,\ b?\operatorname{notFree}.\oplus a!\operatorname{drop}.t\} T E ( a , b ) = ⊕ b ! pick .& { b ? free . ⊕ food ! eat . ⊕ a ! drop . ⊕ b ! drop . t , b ? notFree . ⊕ a ! drop . t }
T P ( a , b ) = μ t ′ . ⊕ a ! pick . & { a ? free . T E ( a , b ) , a ? notFree . t ′ } T_P(a,b)=\mu t'.\oplus a!\operatorname{pick}.\&\{a?\operatorname{free}.T_E(a,b),\ a?\operatorname{notFree}.t'\} T P ( a , b ) = μ t ′ . ⊕ a ! pick .& { a ? free . T E ( a , b ) , a ? notFree . t ′ }
Here t t t is the philosopher’s outer loop, bound by the μ t \mu t μ t below, while t ′ t' t ′ in T P T_P T P is the local retry of the same first fork. The philosopher type is then the merge of the two flip orientations;
T p i = μ t . ( T P ( f i , f i + 1 ) ⊓ p T P ( f i + 1 , f i ) ) T_{p_i}=\mu t.(T_P(f_i,f_{i+1})\mathbin{\sqcap_p}T_P(f_{i+1},f_i)) T p i = μ t . ( T P ( f i , f i + 1 ) ⊓ p T P ( f i + 1 , f i ))
which collapses to a single tagged selection:
T p i = μ t . ⊕ { p : f i ! pick . & { f i ? free . T E ( f i , f i + 1 ) , f i ? notFree . T P ( f i , f i + 1 ) } 1 − p : f i + 1 ! pick . & { f i + 1 ? free . T E ( f i + 1 , f i ) , f i + 1 ? notFree . T P ( f i + 1 , f i ) } T_{p_i}=\mu t.\oplus
\begin{cases}
p:f_i!\operatorname{pick}.\&\{f_i?\operatorname{free}.T_E(f_i,f_{i+1}),\ f_i?\operatorname{notFree}.T_P(f_i,f_{i+1})\}\\
1-p:f_{i+1}!\operatorname{pick}.\&\{f_{i+1}?\operatorname{free}.T_E(f_{i+1},f_i),\ f_{i+1}?\operatorname{notFree}.T_P(f_{i+1},f_i)\}
\end{cases} T p i = μ t . ⊕ { p : f i ! pick .& { f i ? free . T E ( f i , f i + 1 ) , f i ? notFree . T P ( f i , f i + 1 )} 1 − p : f i + 1 ! pick .& { f i + 1 ? free . T E ( f i + 1 , f i ) , f i + 1 ? notFree . T P ( f i + 1 , f i )}
The two summands differ only by swapping f i ↔ f i + 1 f_i\leftrightarrow f_{i+1} f i ↔ f i + 1 . Dually, fork f i f_i f i offers pick to either neighbour and, once granted, refuses the other until the holder drops it; food simply awaits “eat” from every philosopher:
T Q ( a , b ) = ⊕ a ! free . μ t ′ . & { a ? drop . t ′ , b ? pick . ⊕ b ! notFree . t ′ } T_Q(a,b)=\oplus a!\operatorname{free}.\mu t'.\&\{a?\operatorname{drop}.t',\ b?\operatorname{pick}.\oplus b!\operatorname{notFree}.t'\} T Q ( a , b ) = ⊕ a ! free . μ t ′ .& { a ? drop . t ′ , b ? pick . ⊕ b ! notFree . t ′ }
T f i = μ t . & { p i ? pick . T Q ( p i , p i − 1 ) , p i − 1 ? pick . T Q ( p i − 1 , p i ) } T_{f_i}=\mu t.\&\{p_i?\operatorname{pick}.T_Q(p_i,p_{i-1}),\ p_{i-1}?\operatorname{pick}.T_Q(p_{i-1},p_i)\} T f i = μ t .& { p i ? pick . T Q ( p i , p i − 1 ) , p i − 1 ? pick . T Q ( p i − 1 , p i )}
T food = μ t . & i ∈ Z n p i ? eat . t T_{\operatorname{food}}=\mu t.\&_{i\in\mathbb{Z}_n}p_i?\operatorname{eat}.t T food = μ t . & i ∈ Z n p i ? eat . t
Proofs of statements in sec:types
Lemma 3.3 (≤-preorder). (Proof in §B.3). ≤ \le ≤ is reflexive and transitive.
Proof.
(1) (Reflexivity ) For any T T T , we have T ≤ T T\le T T ≤ T :
The identity relation Id = { ( T , T ) } \operatorname{Id}=\{(T,T)\} Id = {( T , T )} is closed under the rules of Def. 3.2 : the [sub-end], [sub-⊕ \oplus ⊕ ] and [sub-& \& & ] cases are immediate, each continuation obligation being again in Id \operatorname{Id} Id ; and for [sub-Σ \Sigma Σ ] (when ∣ I ∣ > 1 |I|>1 ∣ I ∣ > 1 ) the diagonal matching i ↦ i i\mapsto i i ↦ i discharges every summand via [sub-⊕ \oplus ⊕ ]. By coinduction Id ⊆ ≤ \operatorname{Id}\subseteq\le Id ⊆≤ , so T ≤ T T\le T T ≤ T .
(2) (transitivity ) Suppose T 1 ≤ T 2 T_1\le T_2 T 1 ≤ T 2 and T 2 ≤ T 3 T_2\le T_3 T 2 ≤ T 3 then T 1 ≤ T 3 T_1\le T_3 T 1 ≤ T 3 :
We proceed by case analysis on the rule used to derive T 1 ≤ T 2 T_1\le T_2 T 1 ≤ T 2 :
[sub-END]: T 1 ≤ T 2 T_1\le T_2 T 1 ≤ T 2 by [sub-END] implies T 1 = T 2 = end T_1=T_2=\operatorname{end} T 1 = T 2 = end . Thus T 2 ≤ T 3 T_2\le T_3 T 2 ≤ T 3 must be derived as end ≤ T 3 \operatorname{end}\le T_3 end ≤ T 3 , implying T 3 = end T_3=\operatorname{end} T 3 = end . As end ≤ end \operatorname{end}\le\operatorname{end} end ≤ end , T 1 ≤ T 3 T_1\le T_3 T 1 ≤ T 3 follows immediately. Footer: , Vol. 1, No. 1, Article . Publication date: November 2026.
∀ i ∈ I : T 1 , i ≤ T 2 , i ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 1 , i ≤ ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 2 , i \begin{gathered}
\forall i \in I : T_{1,i} \leq T_{2,i}\\
\bigoplus_{i\in I} p_i : p_i! \ell_i\langle B_i\rangle.T_{1,i} \leq\bigoplus_{i\in I} p_i : p_i! \ell_i\langle B_i\rangle.T_{2,i}
\end{gathered} ∀ i ∈ I : T 1 , i ≤ T 2 , i i ∈ I ⨁ p i : p i ! ℓ i ⟨ B i ⟩ . T 1 , i ≤ i ∈ I ⨁ p i : p i ! ℓ i ⟨ B i ⟩ . T 2 , i
i.e. T 2 = ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 2 , i T_2 = \bigoplus_{i\in I} p_i : p_i! \ell_i\langle B_i\rangle.T_{2,i} T 2 = ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 2 , i , there’s two cases to consider for the derivation of T 2 ≤ T 3 T_2 \leq T_3 T 2 ≤ T 3 : [\text{sub-⊕}] or [\text{sub-Σ}] with ∣ I ∣ = 1 |I| = 1 ∣ I ∣ = 1 : – T 2 ≤ T 3 T_2 \leq T_3 T 2 ≤ T 3 by [\text{sub-⊕}]:
∀ i ∈ I : T 2 , i ≤ T 3 , i ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 2 , i ≤ ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 3 , i \begin{gathered}
\forall i \in I : T_{2,i} \leq T_{3,i}\\
\bigoplus_{i\in I} p_i : p_i! \ell_i\langle B_i\rangle.T_{2,i} \leq\bigoplus_{i\in I} p_i : p_i! \ell_i\langle B_i\rangle.T_{3,i}
\end{gathered} ∀ i ∈ I : T 2 , i ≤ T 3 , i i ∈ I ⨁ p i : p i ! ℓ i ⟨ B i ⟩ . T 2 , i ≤ i ∈ I ⨁ p i : p i ! ℓ i ⟨ B i ⟩ . T 3 , i
now we can apply IH on T 1 , i ≤ T 2 , i T_{1,i} \leq T_{2,i} T 1 , i ≤ T 2 , i and T 2 , i ≤ T 3 , i T_{2,i} \leq T_{3,i} T 2 , i ≤ T 3 , i to get T 1 , i ≤ T 3 , i T_{1,i} \leq T_{3,i} T 1 , i ≤ T 3 , i for all i ∈ I i \in I i ∈ I and thus:
∀ i ∈ I : T 1 , i ≤ T 3 , i ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 1 , i ≤ ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 3 , i \begin{gathered}
\forall i \in I : T_{1,i} \leq T_{3,i}\\
\bigoplus_{i\in I} p_i : p_i! \ell_i\langle B_i\rangle.T_{1,i} \leq\bigoplus_{i\in I} p_i : p_i! \ell_i\langle B_i\rangle.T_{3,i}
\end{gathered} ∀ i ∈ I : T 1 , i ≤ T 3 , i i ∈ I ⨁ p i : p i ! ℓ i ⟨ B i ⟩ . T 1 , i ≤ i ∈ I ⨁ p i : p i ! ℓ i ⟨ B i ⟩ . T 3 , i
i.e. T 1 ≤ T 3 T_1 \leq T_3 T 1 ≤ T 3 as desired. – T 2 ≤ T 3 T_2 \leq T_3 T 2 ≤ T 3 by [\text{sub-Σ}]:
∀ i ∈ I : T 2 , i ≤ T 3 , i ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 2 , i ≤ ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 3 , i ∣ L ∣ ≥ 1 ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 2 , i ≤ ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 3 , i + ∑ l ∈ L T l ′ \begin{gathered}
\forall i \in I : T_{2,i} \leq T_{3,i}\\
\bigoplus_{i\in I} p_i : p_i! \ell_i\langle B_i\rangle.T_{2,i} \leq\bigoplus_{i\in I} p_i : p_i! \ell_i\langle B_i\rangle.T_{3,i} \qquad|L| \geq1\\
\bigoplus_{i\in I} p_i : p_i! \ell_i\langle B_i\rangle.T_{2,i} \leq\bigoplus_{i\in I} p_i : p_i! \ell_i\langle B_i\rangle.T_{3,i} + \sum_{l\in L} T'_l
\end{gathered} ∀ i ∈ I : T 2 , i ≤ T 3 , i i ∈ I ⨁ p i : p i ! ℓ i ⟨ B i ⟩ . T 2 , i ≤ i ∈ I ⨁ p i : p i ! ℓ i ⟨ B i ⟩ . T 3 , i ∣ L ∣ ≥ 1 i ∈ I ⨁ p i : p i ! ℓ i ⟨ B i ⟩ . T 2 , i ≤ i ∈ I ⨁ p i : p i ! ℓ i ⟨ B i ⟩ . T 3 , i + l ∈ L ∑ T l ′
To get T 1 ≤ T 3 T_1 \leq T_3 T 1 ≤ T 3 we apply IH on T 1 , i ≤ T 2 , i T_{1,i} \leq T_{2,i} T 1 , i ≤ T 2 , i and T 2 , i ≤ T 3 , i T_{2,i} \leq T_{3,i} T 2 , i ≤ T 3 , i to get for all i ∈ I : T 1 , i ≤ T 3 , i i \in I : T_{1,i} \leq T_{3,i} i ∈ I : T 1 , i ≤ T 3 , i and use this to derive T 1 ≤ T 3 T_1 \leq T_3 T 1 ≤ T 3 :
∀ i ∈ I : T 1 , i ≤ T 3 , i ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 1 , i ≤ ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 3 , i ∣ L ∣ ≥ 1 ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 1 , i ≤ ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 3 , i + ∑ l ∈ L T l ′ \begin{gathered}
\forall i \in I : T_{1,i} \leq T_{3,i}\\
\bigoplus_{i\in I} p_i : p_i! \ell_i\langle B_i\rangle.T_{1,i} \leq\bigoplus_{i\in I} p_i : p_i! \ell_i\langle B_i\rangle.T_{3,i} \qquad|L| \geq1\\
\bigoplus_{i\in I} p_i : p_i! \ell_i\langle B_i\rangle.T_{1,i} \leq\bigoplus_{i\in I} p_i : p_i! \ell_i\langle B_i\rangle.T_{3,i} + \sum_{l\in L} T'_l
\end{gathered} ∀ i ∈ I : T 1 , i ≤ T 3 , i i ∈ I ⨁ p i : p i ! ℓ i ⟨ B i ⟩ . T 1 , i ≤ i ∈ I ⨁ p i : p i ! ℓ i ⟨ B i ⟩ . T 3 , i ∣ L ∣ ≥ 1 i ∈ I ⨁ p i : p i ! ℓ i ⟨ B i ⟩ . T 1 , i ≤ i ∈ I ⨁ p i : p i ! ℓ i ⟨ B i ⟩ . T 3 , i + l ∈ L ∑ T l ′
∀ i ∈ I ∪ J : T 1 , i ≤ T 2 , i { p i } i ∈ I ∪ J = { p i } i ∈ I ∪ J ∪ K & i ∈ I ∪ J ∪ K p i ? ℓ i ( B i ) . T 1 , i ≤ & i ∈ I ∪ J p i ? ℓ i ( B i ) . T 2 , i \begin{gathered}
\forall i \in I \cup J : T_{1,i} \leq T_{2,i} \qquad\{p_i\}_{i\in I\cup J} = \{p_i\}_{i\in I\cup J\cup K}\\
\mathbin{\&}_{i\in I\cup J\cup K} p_i? \ell_i(B_i).T_{1,i} \leq\mathbin{\&}_{i\in I\cup J} p_i? \ell_i(B_i).T_{2,i}
\end{gathered} ∀ i ∈ I ∪ J : T 1 , i ≤ T 2 , i { p i } i ∈ I ∪ J = { p i } i ∈ I ∪ J ∪ K & i ∈ I ∪ J ∪ K p i ? ℓ i ( B i ) . T 1 , i ≤ & i ∈ I ∪ J p i ? ℓ i ( B i ) . T 2 , i
i.e. T 2 = & i ∈ I ∪ J p i ? ℓ i ( B i ) . T 2 , i T_2 = \mathbin{\&}_{i\in I\cup J} p_i? \ell_i(B_i).T_{2,i} T 2 = & i ∈ I ∪ J p i ? ℓ i ( B i ) . T 2 , i , then T 2 ≤ T 3 T_2 \leq T_3 T 2 ≤ T 3 could only be derived through [\text{sub-&}]:
∀ i ∈ I : T 2 , i ≤ T 3 , i { p i } i ∈ I = { p i } i ∈ I ∪ J & i ∈ I ∪ J p i ? ℓ i ( B i ) . T 2 , i ≤ & i ∈ I p i ? ℓ i ( B i ) . T 3 , i \begin{gathered}
\forall i \in I : T_{2,i} \leq T_{3,i} \qquad\{p_i\}_{i\in I} = \{p_i\}_{i\in I\cup J}\\
\mathbin{\&}_{i\in I\cup J} p_i? \ell_i(B_i).T_{2,i} \leq\mathbin{\&}_{i\in I} p_i? \ell_i(B_i).T_{3,i}
\end{gathered} ∀ i ∈ I : T 2 , i ≤ T 3 , i { p i } i ∈ I = { p i } i ∈ I ∪ J & i ∈ I ∪ J p i ? ℓ i ( B i ) . T 2 , i ≤ & i ∈ I p i ? ℓ i ( B i ) . T 3 , i
i.e. T 3 = & i ∈ I p i ? ℓ i ( B i ) . T 3 , i T_3 = \mathbin{\&}_{i\in I} p_i? \ell_i(B_i).T_{3,i} T 3 = & i ∈ I p i ? ℓ i ( B i ) . T 3 , i , we can apply IH on T 1 , i ≤ T 2 , i T_{1,i} \leq T_{2,i} T 1 , i ≤ T 2 , i and T 2 , i ≤ T 3 , i T_{2,i} \leq T_{3,i} T 2 , i ≤ T 3 , i to get T 1 , i ≤ T 3 , i T_{1,i} \leq T_{3,i} T 1 , i ≤ T 3 , i for all i ∈ I i \in I i ∈ I and use this to derive T 1 ≤ T 3 T_1 \leq T_3 T 1 ≤ T 3 as:
∀ i ∈ I : T 1 , i ≤ T 3 , i { p i } i ∈ I = { p i } i ∈ I ∪ J ∪ K & i ∈ I ∪ J ∪ K p i ? ℓ i ( B i ) . T 1 , i ≤ & i ∈ I p i ? ℓ i ( B i ) . T 3 , i \begin{gathered}
\forall i \in I : T_{1,i} \leq T_{3,i} \qquad\{p_i\}_{i\in I} = \{p_i\}_{i\in I\cup J\cup K}\\
\mathbin{\&}_{i\in I\cup J\cup K} p_i? \ell_i(B_i).T_{1,i} \leq\mathbin{\&}_{i\in I} p_i? \ell_i(B_i).T_{3,i}
\end{gathered} ∀ i ∈ I : T 1 , i ≤ T 3 , i { p i } i ∈ I = { p i } i ∈ I ∪ J ∪ K & i ∈ I ∪ J ∪ K p i ? ℓ i ( B i ) . T 1 , i ≤ & i ∈ I p i ? ℓ i ( B i ) . T 3 , i
where { p i } i ∈ I = { p i } i ∈ I ∪ J ∪ K \{p_i\}_{i\in I} = \{p_i\}_{i\in I\cup J\cup K} { p i } i ∈ I = { p i } i ∈ I ∪ J ∪ K follows transitively from the above.
∣ I ∣ ⋅ ∣ J ∣ > 1 ∀ i ∈ I : ∃ j ∈ J : T 1 , i ≤ T 2 , j ∑ i ∈ I T 1 , i ≤ ∑ j ∈ J T 2 , j \frac{|I|\cdot|J|>1\quad\forall i\in I:\exists j\in J:T_{1,i}\leq T_{2,j}}{\sum_{i\in I}T_{1,i}\leq\sum_{j\in J}T_{2,j}} ∑ i ∈ I T 1 , i ≤ ∑ j ∈ J T 2 , j ∣ I ∣ ⋅ ∣ J ∣ > 1 ∀ i ∈ I : ∃ j ∈ J : T 1 , i ≤ T 2 , j
Let T 2 ≤ T 3 T_2 \leq T_3 T 2 ≤ T 3 be derived by
∣ J ∣ ⋅ ∣ K ∣ > 1 ∀ j ∈ J : ∃ k ∈ K : T 2 , j ≤ T 3 , k ∑ j ∈ J T 2 , j ≤ ∑ k ∈ K T 3 , k \frac{|J|\cdot|K|>1\quad\forall j\in J:\exists k\in K:T_{2,j}\leq T_{3,k}}{\sum_{j\in J}T_{2,j}\leq\sum_{k\in K}T_{3,k}} ∑ j ∈ J T 2 , j ≤ ∑ k ∈ K T 3 , k ∣ J ∣ ⋅ ∣ K ∣ > 1 ∀ j ∈ J : ∃ k ∈ K : T 2 , j ≤ T 3 , k
Fix any i ∈ I i\in I i ∈ I . By the first premise there exists j ∈ J j\in J j ∈ J such that T 1 , i ≤ T 2 , j T_{1,i}\leq T_{2,j} T 1 , i ≤ T 2 , j . By the second premise there exists k ∈ K k\in K k ∈ K such that T 2 , j ≤ T 3 , k T_{2,j}\leq T_{3,k} T 2 , j ≤ T 3 , k . By the induction hypothesis, T 1 , i ≤ T 3 , k T_{1,i}\leq T_{3,k} T 1 , i ≤ T 3 , k . Since i i i was arbitrary, we have
∀ i ∈ I : ∃ k ∈ K : T 1 , i ≤ T 3 , k . \forall i\in I:\exists k\in K:T_{1,i}\leq T_{3,k}. ∀ i ∈ I : ∃ k ∈ K : T 1 , i ≤ T 3 , k .
Hence, by another application of [sub-Σ \Sigma Σ ],
∣ I ∣ ⋅ ∣ K ∣ > 1 ∀ i ∈ I : ∃ k ∈ K : T 1 , i ≤ T 3 , k ∑ i ∈ I T 1 , i ≤ ∑ k ∈ K T 3 , k \frac{|I|\cdot|K|>1\quad\forall i\in I:\exists k\in K:T_{1,i}\leq T_{3,k}}{\sum_{i\in I}T_{1,i}\leq\sum_{k\in K}T_{3,k}} ∑ i ∈ I T 1 , i ≤ ∑ k ∈ K T 3 , k ∣ I ∣ ⋅ ∣ K ∣ > 1 ∀ i ∈ I : ∃ k ∈ K : T 1 , i ≤ T 3 , k
and therefore T 1 ≤ T 3 T_1\leq T_3 T 1 ≤ T 3 .
Proposition B.2. Given a type context Δ \Delta Δ then safe ( Δ ) \operatorname{safe}(\Delta) safe ( Δ ) is decidable.
Proof. By Def. 3.12, safe ( Δ ) \operatorname{safe}(\Delta) safe ( Δ ) holds iff every context reachable from Δ \Delta Δ is a safe state (cf. [52 Lemma 4.4] ). The reachable set is finite: by inspection of Figure 4 , every transition—including the ⟶ n \longrightarrow_n ⟶ n of [ct-nd] resolving non-determinism and the probability-annotated [ct-out]—sends each component T p T_p T p to one of its ≤ ∣ T p ∣ \leq|T_p| ≤ ∣ T p ∣ subterms, so ∣ { Δ ′ ∣ Δ ⟶ ∗ Δ ′ } ∣ ≤ ∏ p ∈ dom ( Δ ) ∣ T p ∣ |\{\Delta' \mid\Delta\mathrel{\longrightarrow^*}\Delta'\}|\leq\prod_{p\in\operatorname{dom}(\Delta)}|T_p| ∣ { Δ ′ ∣ Δ ⟶ ∗ Δ ′ } ∣ ≤ ∏ p ∈ dom ( Δ ) ∣ T p ∣ . Whether a single Δ ′ \Delta' Δ ′ is a safe state is decidable, being a finite check of label compatibility over its offered actions (Def. 3.12). Enumerating the reachable set and checking each is therefore effective, so safe ( Δ ) \operatorname{safe}(\Delta) safe ( Δ ) is decidable. □
Proposition 3.5 (≤ \leq ≤ -decidable). (Proof in §B.3.) Given T 1 T_1 T 1 and T 2 T_2 T 2 , checking T 1 ≤ T 2 T_1\leq T_2 T 1 ≤ T 2 is decidable.
Proof. Inspired by [60 ] , we build a finite graph G ( T 1 , T 2 ) G(T_1,T_2) G ( T 1 , T 2 ) and decide T 1 ≤ T 2 T_1\leq T_2 T 1 ≤ T 2 by search. The nodes are pairs of sub-terms Sub ( T 1 ) × Sub ( T 2 ) \operatorname{Sub}(T_1)\times\operatorname{Sub}(T_2) Sub ( T 1 ) × Sub ( T 2 ) with root ( T 1 , T 2 ) (T_1,T_2) ( T 1 , T 2 ) ; since T 1 , T 2 T_1,T_2 T 1 , T 2 are regular, this set is of size O ( ∣ T 1 ∣ ∣ T 2 ∣ ) O(|T_1||T_2|) O ( ∣ T 1 ∣∣ T 2 ∣ ) . From a node ( U , V ) (U,V) ( U , V ) , unfold both components to expose their top constructors. The rules of Def. 3.2 are constructor-directed, so at most one applies, and its premises fix the successors: none for [sub-end]; one continuation pair ( T i , T i ′ ) (T_i,T'_i) ( T i , T i ′ ) per branch for [sub-⊕ \oplus ⊕ ], [sub-& \& & ]; and, for [sub-Σ \Sigma Σ ], for each subtype summand i ∈ I i\in I i ∈ I a matching supertype summand k ∈ K k\in K k ∈ K and its continuation pairs ( T k , j , T k , j ′ ) (T_{k,j},T'_{k,j}) ( T k , j , T k , j ′ ) . Every successor is a pair of subterms of the endpoints, so edges stay within the finite node set.
Call ( U , V ) (U,V) ( U , V ) inconsistent if, after unfolding, no rule applies: the top constructors clash or a side condition fails—for [sub-Σ \Sigma Σ ], some i ∈ I i\in I i ∈ I has no matching k ∈ K k\in K k ∈ K . Inconsistency of one node is decidable (a constructor comparison, plus for [sub-Σ \Sigma Σ ] a finite search over I × K I\times K I × K ).
The procedure computes the nodes reachable from ( T 1 , T 2 ) (T_1,T_2) ( T 1 , T 2 ) and reports T 1 ≤ T 2 T_1\leq T_2 T 1 ≤ T 2 iff none is inconsistent; it terminates as G G G is finite. For correctness, note that a reachability-closed set of nodes with no inconsistent member is exactly a relation closed under the rules, hence contained in ≤ \leq ≤ ; so
an inconsistency-free reachable set witnesses T 1 ≤ T 2 T_1 \leq T_2 T 1 ≤ T 2 . Conversely, a reachable inconsistent ( U , V ) (U,V) ( U , V ) admits no rule relating U U U and V V V , and its obligations descend from ( T 1 , T 2 ) (T_1,T_2) ( T 1 , T 2 ) , so ( T 1 , T 2 ) ∉ ≤ (T_1,T_2) \notin\leq ( T 1 , T 2 ) ∈ / ≤ . □ \square □
Lemma B.3 (T₁ ⊔ T₂ is decidable). Let T 1 , T 2 T_1,T_2 T 1 , T 2 be types and let d d d be the maximum out-degree of their finite type graphs. It is decidable whether T 1 ⊔ T 2 T_1 \sqcup T_2 T 1 ⊔ T 2 is defined in time O ( ∣ T 1 ∣ ∣ T 2 ∣ ) O(|T_1||T_2|) O ( ∣ T 1 ∣∣ T 2 ∣ ) . When defined, a witness is computable in time
O ( ( max { 2 , d } ) 2 ∣ T 1 ∣ ∣ T 2 ∣ log ( ∣ T 1 ∣ ∣ T 2 ∣ + 1 ) ) . O\left((\max\{2,d\})^{2|T_1||T_2|}\log(|T_1||T_2|+1)\right). O ( ( max { 2 , d } ) 2∣ T 1 ∣∣ T 2 ∣ log ( ∣ T 1 ∣∣ T 2 ∣ + 1 ) ) .
Proof. Here ∣ T ∣ |T| ∣ T ∣ counts all syntax-tree nodes. We begin by presenting the Algorithm .
TypeGraph ( T i ) = G ( T i ) = ( V i , E i , r i ) , i ∈ { 1 , 2 } . \operatorname{TypeGraph}(T_i)=G(T_i)=(V_i,E_i,r_i),\qquad i\in\{1,2\}. TypeGraph ( T i ) = G ( T i ) = ( V i , E i , r i ) , i ∈ { 1 , 2 } .
The vertices V i V_i V i are the occurrences of end, branching constructors, output distributions and non-singleton outer sums in the syntax of T i T_i T i (distinct occurrences of the same subterm remain distinct vertices). The set E i E_i E i contains edge occurrences, and r i ∈ V i r_i\in V_i r i ∈ V i is the root node of T i T_i T i .
We follow the type-graph notation of [60 ] . Recursion binders and variables contribute no separate vertices: the memoised function “head” resolves them to their constructor vertices. Each prefix is recorded on an edge to its continuation’s head; end has no outgoing edges.
We note that a proper sum has two graph levels:
u = ∑ i ∈ I T i ′ , T i ′ = ⨁ j ∈ J i p i , j ! ℓ j ⟨ B j ⟩ . u i , j , ∣ I ∣ > 1 , u=\sum_{i\in I}T'_i,\qquad T'_i=\bigoplus_{j\in J_i}p_{i,j}! \ell_j\langle B_j\rangle.u_{i,j},\qquad|I|>1, u = i ∈ I ∑ T i ′ , T i ′ = j ∈ J i ⨁ p i , j ! ℓ j ⟨ B j ⟩ . u i , j , ∣ I ∣ > 1 ,
u → i T i ′ → p i , j ! ℓ j ⟨ B j ⟩ u i , j , i ∈ I , j ∈ J i . u\xrightarrow{i}T'_i\xrightarrow{p_{i,j}!\ell_j\langle B_j\rangle}u_{i,j},\qquad i\in I,\ j\in J_i. u i T i ′ p i , j ! ℓ j ⟨ B j ⟩ u i , j , i ∈ I , j ∈ J i .
Thus V i V_i V i represents constructor subterm occurrences, rather than every node counted by ∣ T i ∣ |T_i| ∣ T i ∣ . Write od ( u ) \operatorname{od}(u) od ( u ) for the out-degree of a vertex u u u . For simplicity of presentation we identify a vertex with the type it represents. Equalities such as u = e n d u=\mathrm{end} u = end specify the constructor, while ancestor lookup uses vertex identities.
Align branching indices by participant, label and payload sort: shared indices denote the same prefix, with possibly different continuation vertices. For input vertices
u = & i ∈ I p i ? ℓ i ( B i ) . u i , v = & j ∈ J p j ? ℓ j ( B j ) . v j , u=\mathbin{\&}_{i\in I}p_i?\ell_i(B_i).u_i,\qquad v=\mathbin{\&}_{j\in J}p_j?\ell_j(B_j).v_j, u = & i ∈ I p i ? ℓ i ( B i ) . u i , v = & j ∈ J p j ? ℓ j ( B j ) . v j ,
define
Pts ( u ) = { p i ∣ i ∈ I } , Pts ( v ) = { p j ∣ j ∈ J } , \operatorname{Pts}(u)=\{p_i\mid i\in I\},\qquad\operatorname{Pts}(v)=\{p_j\mid j\in J\}, Pts ( u ) = { p i ∣ i ∈ I } , Pts ( v ) = { p j ∣ j ∈ J } ,
M ( u , v ) = { ( p k , ℓ k , B k , ( u k , v k ) ) ∣ k ∈ I ∩ J } . M(u,v)=\{(p_k,\ell_k,B_k,(u_k,v_k))\mid k\in I\cap J\}. M ( u , v ) = {( p k , ℓ k , B k , ( u k , v k )) ∣ k ∈ I ∩ J } .
Well-formed inputs have nonempty sender sets and distinct participant–label pairs, so M ( u , v ) M(u,v) M ( u , v ) retains each matching prefix. Set M ( u , v ) = ∅ M(u,v)=\varnothing M ( u , v ) = ∅ for other constructor pairs. The join dependency graph G ⊔ ( T 1 , T 2 ) G_{\sqcup}(T_1,T_2) G ⊔ ( T 1 , T 2 ) has vertex set V 1 × V 2 V_1\times V_2 V 1 × V 2 and edges
( u , v ) → p ? ℓ ( B ) ( u ′ , v ′ ) ⟺ ( p , ℓ , B , ( u ′ , v ′ ) ) ∈ M ( u , v ) . (u,v)\xrightarrow{p?\ell(B)}(u',v')\quad\Longleftrightarrow\quad(p,\ell,B,(u',v'))\in M(u,v). ( u , v ) p ? ℓ ( B ) ( u ′ , v ′ ) ⟺ ( p , ℓ , B , ( u ′ , v ′ )) ∈ M ( u , v ) .
For R ⊆ V 1 × V 2 R\subseteq V_1\times V_2 R ⊆ V 1 × V 2 , let Pts R ( u , v ) \operatorname{Pts}_R(u,v) Pts R ( u , v ) contain the senders of matching prefixes whose continuation pairs belong to R R R :
Pts R ( u , v ) = { p ∣ ( p , ℓ , B , ( u ′ , v ′ ) ) ∈ M ( u , v ) , ( u ′ , v ′ ) ∈ R } . \operatorname{Pts}_R(u,v)=\{p\mid(p,\ell,B,(u',v'))\in M(u,v),\ (u',v')\in R\}. Pts R ( u , v ) = { p ∣ ( p , ℓ , B , ( u ′ , v ′ )) ∈ M ( u , v ) , ( u ′ , v ′ ) ∈ R } .
An input pair ( u , v ) (u,v) ( u , v ) is consistent with respect to R R R exactly when
Pts ( u ) = Pts ( v ) = Pts R ( u , v ) ≠ ∅ . \operatorname{Pts}(u)=\operatorname{Pts}(v)=\operatorname{Pts}_R(u,v)\ne\varnothing. Pts ( u ) = Pts ( v ) = Pts R ( u , v ) = ∅ .
Selection pairs and ( e n d , e n d ) (\mathrm{end},\mathrm{end}) ( end , end ) are also consistent; all other constructor pairs are inconsistent. Algorithm 1 computes and stores M ( u , v ) M(u,v) M ( u , v ) once per input pair. Its counter c [ ( u , v ) , p ] c[(u,v),p] c [( u , v ) , p ] records the number of surviving matches from p p p ; a sender disappears only when its last match is removed. The list pred [ ( u ′ , v ′ ) ] \operatorname{pred}[(u',v')] pred [( u ′ , v ′ )] contains one occurrence of ( ( u , v ) , p ) ((u,v),p) (( u , v ) , p ) for each matching prefix from p p p whose continuation pair is ( u ′ , v ′ ) (u',v') ( u ′ , v ′ ) . The worklist Q Q Q contains pairs awaiting deletion, and Z Z Z records those already enqueued. Let R ∗ R_* R ∗ denote the relation R R R remaining after the deletion loop terminates, the fixed point reached by pruning inconsistent pairs. Pop removes and returns one queued pair, and ⋅ \cdot ⋅ denotes concatenation of predecessor lists.
For a relation R ⊆ V 1 × V 2 R \subseteq V_1 \times V_2 R ⊆ V 1 × V 2 whose pairs are consistent with respect to R R R , introduce one new vertex T u , v T_{u,v} T u , v for each ( u , v ) ∈ R (u,v) \in R ( u , v ) ∈ R . Construct the auxiliary graph H ^ R \widehat{\mathcal{H}}_R H R on the disjoint vertex sets
V 1 ⊎ V 2 ⊎ { T u , v ∣ ( u , v ) ∈ R } , V_1 \uplus V_2 \uplus\{T_{u,v} \mid(u,v) \in R\}, V 1 ⊎ V 2 ⊎ { T u , v ∣ ( u , v ) ∈ R } ,
retaining E 1 , E 2 E_1,E_2 E 1 , E 2 . Define its result vertices by constructor:
u = v = end ⟹ T u , v = end . u = v = \operatorname{end} \quad\Longrightarrow\quad T_{u,v} = \operatorname{end}. u = v = end ⟹ T u , v = end .
For selections, we use the tagged disjoint union I ⊎ J = ( { 1 } × I ) ∪ ( { 2 } × J ) I \uplus J = (\{1\} \times I) \cup(\{2\} \times J) I ⊎ J = ({ 1 } × I ) ∪ ({ 2 } × J ) :
u = ∑ i ∈ I T 1 , i ′ , v = ∑ j ∈ J T 2 , j ′ , T u , v = ∑ ( a , k ) ∈ I ⊎ J T a , k ′ . u = \sum_{i \in I} T'_{1,i}, \qquad v = \sum_{j \in J} T'_{2,j}, \qquad T_{u,v} = \sum_{(a,k) \in I \uplus J} T'_{a,k}. u = i ∈ I ∑ T 1 , i ′ , v = j ∈ J ∑ T 2 , j ′ , T u , v = ( a , k ) ∈ I ⊎ J ∑ T a , k ′ .
For input pairs, put
T u , v = & ( p , ℓ , B , ( u ′ , v ′ ) ) ∈ M ( u , v ) p ? ℓ ( B ) . T u ′ , v ′ . T_{u,v} = \mathbin{\&}_{(p,\ell,B,(u',v')) \in M(u,v)} p?\ell(B).T_{u',v'}. T u , v = & ( p , ℓ , B , ( u ′ , v ′ )) ∈ M ( u , v ) p ? ℓ ( B ) . T u ′ , v ′ .
For X ⊆ V ( G ) X \subseteq V(\mathcal{G}) X ⊆ V ( G ) , let G [ X ] \mathcal{G}[X] G [ X ] denote the induced subgraph, and put
Reach G ( r ) = { v ∣ r → ∗ G v } . \operatorname{Reach}_{\mathcal{G}}(r) = \{v \mid r \mathrel{\xrightarrow{\ast}_{\mathcal{G}}} v\}. Reach G ( r ) = { v ∣ r ∗ G v } .
When ( r 1 , r 2 ) ∈ R (r_1,r_2) \in R ( r 1 , r 2 ) ∈ R , define the result graph H R \mathcal{H}_R H R by Build ( R , G ( T 1 ) , G ( T 2 ) ) \operatorname{Build}(R,\mathcal{G}(T_1),\mathcal{G}(T_2)) Build ( R , G ( T 1 ) , G ( T 2 )) where
H R = H ^ R [ Reach H ^ R ( T r 1 , r 2 ) ] , r H R = T r 1 , r 2 \mathcal{H}_R = \widehat{\mathcal{H}}_R[\operatorname{Reach}_{\widehat{\mathcal{H}}_R}(T_{r_1,r_2})], \qquad r_{\mathcal{H}_R} = T_{r_1,r_2} H R = H R [ Reach H R ( T r 1 , r 2 )] , r H R = T r 1 , r 2
Thus the result contains only reachable result vertices and the original vertices needed by retained summands.
Given a result graph H R \mathcal{H}_R H R , we use the procedure Read below to read out the type T T T it denotes. The ancestor map A A A associates type vertices u , v u,v u , v with fresh typevariables t f r e s h t_{\mathrm{fresh}} t fresh . We note that for a non-singleton selection, the selection clause prints the sum vertex and its distribution vertices together, then recurses into continuations.
Read( u , A ) = (u,A) = ( u , A ) =
\begin{cases}
A(u), & u \in\operatorname{dom}(A),\\
\operatorname{end}, & u \notin\operatorname{dom}(A),\ u = \operatorname{end},\\
\mu t_{\mathrm{fresh}}.\mathbin{\&}_{k \in K} p_k?\ell_k(B_k).\operatorname{Read}(u_k,A[u \mapsto t_{\mathrm{fresh}}]), & u \notin\operatorname{dom}(A),\ u = \mathbin{\&}_{k \in K} p_k?\ell_k(B_k).u_k,\\
\mu t_{\mathrm{fresh}}.\sum_{i \in I \uplus\bigoplus_{j \in J_i} p_{i,j}:p_j!\ell_j\langle B_j\rangle.\operatorname{Read}(u_{i,j},A[u \mapsto t_{\mathrm{fresh}}]), & u \notin\operatorname{dom}(A),\\
\sum_{i \in I \uplus\bigoplus_{j \in J_i} p_{i,j}:p_j!\ell_j\langle B_j\rangle.u_{i,j}. &
\end{cases}}}
The uniform construction may introduce unused binders. They can be erased without changing the unfolding, since
t ∉ ftv ( T ) ⟹ unf ( μ t . T ) = T . t \notin\operatorname{ftv}(T) \quad\Longrightarrow\quad\operatorname{unf}(\mu t.T) = T. t ∈ / ftv ( T ) ⟹ unf ( μ t . T ) = T .
Correctness. Let
C = { ( u , v ) ∈ V 1 × V 2 ∣ ∃ T : u ≤ T ∧ v ≤ T } . C = \{(u,v) \in V_1 \times V_2 \mid\exists T : u \leq T \land v \leq T\}. C = {( u , v ) ∈ V 1 × V 2 ∣ ∃ T : u ≤ T ∧ v ≤ T } .
Algorithm 1 Computing T 1 ⊔ T 2 T_1 \sqcup T_2 T 1 ⊔ T 2 ; ∅ \varnothing ∅ denotes failure.
function Join ( T 1 , T 2 ) \operatorname{Join}(T_1,T_2) Join ( T 1 , T 2 )
( V i , E i , r i ) ← TypeGraph ( T i ) , i ∈ { 1 , 2 } (V_i,E_i,r_i) \leftarrow\operatorname{TypeGraph}(T_i),\ i \in\{1,2\} ( V i , E i , r i ) ← TypeGraph ( T i ) , i ∈ { 1 , 2 }
R ← V 1 × V 2 R \leftarrow V_1 \times V_2 R ← V 1 × V 2 ; Q ← ∅ Q \leftarrow\varnothing Q ← ∅
pred [ ( u , v ) ] ← ⟨ ⟩ ( ( u , v ) ∈ V 1 × V 2 ) \operatorname{pred}[(u,v)] \leftarrow\langle\rangle\quad((u,v) \in V_1 \times V_2) pred [( u , v )] ← ⟨ ⟩ (( u , v ) ∈ V 1 × V 2 )
for all ( u , v ) ∈ V 1 × V 2 (u,v) \in V_1 \times V_2 ( u , v ) ∈ V 1 × V 2 do
if u = v = end u=v=\operatorname{end} u = v = end or ( u = ∑ i ∈ I T 1 , i ′ ∧ v = ∑ j ∈ J T 2 , j ′ ) (u=\sum_{i\in I} T'_{1,i} \land v=\sum_{j\in J} T'_{2,j}) ( u = ∑ i ∈ I T 1 , i ′ ∧ v = ∑ j ∈ J T 2 , j ′ ) then
continue
else if u = & i ∈ I p i ? ℓ i ( B i ) . u i u=\mathbin{\&}_{i\in I} p_i?{\ell_i}(B_i).u_i u = & i ∈ I p i ? ℓ i ( B i ) . u i and v = & j ∈ J p j ? ℓ j ( B j ) . v j v=\mathbin{\&}_{j\in J}p_j?{\ell_j}(B_j).v_j v = & j ∈ J p j ? ℓ j ( B j ) . v j then
c [ ( u , v ) , p ] ← 0 ( p ∈ Pts ( u ) ) c[(u,v),p] \leftarrow0\quad(p \in\operatorname{Pts}(u)) c [( u , v ) , p ] ← 0 ( p ∈ Pts ( u ))
for all ( p , ℓ , B , ( u ′ , v ′ ) ) ∈ M ( u , v ) (p,\ell,B,(u',v')) \in M(u,v) ( p , ℓ , B , ( u ′ , v ′ )) ∈ M ( u , v ) do
c [ ( u , v ) , p ] ← c [ ( u , v ) , p ] + 1 c[(u,v),p] \leftarrow c[(u,v),p]+1 c [( u , v ) , p ] ← c [( u , v ) , p ] + 1
pred [ ( u ′ , v ′ ) ] ← pred [ ( u ′ , v ′ ) ] ⋅ ⟨ ( ( u , v ) , p ) ⟩ \operatorname{pred}[(u',v')] \leftarrow\operatorname{pred}[(u',v')] \cdot\langle((u,v),p)\rangle pred [( u ′ , v ′ )] ← pred [( u ′ , v ′ )] ⋅ ⟨(( u , v ) , p )⟩
end for
if Pts ( u ) ≠ Pts ( v ) ∨ Pts R ( u , v ) ≠ Pts ( u ) \operatorname{Pts}(u) \ne\operatorname{Pts}(v)\lor\operatorname{Pts}_{R}(u,v)\ne\operatorname{Pts}(u) Pts ( u ) = Pts ( v ) ∨ Pts R ( u , v ) = Pts ( u ) then
Q ← Q ∪ { ( u , v ) } Q \leftarrow Q\cup\{(u,v)\} Q ← Q ∪ {( u , v )}
end if
else
Q ← Q ∪ { ( u , v ) } Q \leftarrow Q\cup\{(u,v)\} Q ← Q ∪ {( u , v )}
end if
end for
Z ← Q Z \leftarrow Q Z ← Q
while Q ≠ ∅ Q\ne\varnothing Q = ∅ do
( u ′ , v ′ ) ← Pop ( Q ) ; R ← R ∖ { ( u ′ , v ′ ) } (u',v')\leftarrow\operatorname{Pop}(Q); R\leftarrow R\setminus\{(u',v')\} ( u ′ , v ′ ) ← Pop ( Q ) ; R ← R ∖ {( u ′ , v ′ )}
for all ( ( u , v ) , p ) ∈ pred [ ( u ′ , v ′ ) ] : ( u , v ) ∈ R ((u,v),p)\in\operatorname{pred}[(u',v')]: (u,v)\in R (( u , v ) , p ) ∈ pred [( u ′ , v ′ )] : ( u , v ) ∈ R do
c [ ( u , v ) , p ] ← c [ ( u , v ) , p ] − 1 c[(u,v),p]\leftarrow c[(u,v),p]-1 c [( u , v ) , p ] ← c [( u , v ) , p ] − 1
if c [ ( u , v ) , p ] = 0 ∧ ( u , v ) ∉ Z c[(u,v),p]=0\land(u,v)\notin Z c [( u , v ) , p ] = 0 ∧ ( u , v ) ∈ / Z then
Q ← Q ∪ { ( u , v ) } ; Z ← Z ∪ { ( u , v ) } Q\leftarrow Q\cup\{(u,v)\}; Z\leftarrow Z\cup\{(u,v)\} Q ← Q ∪ {( u , v )} ; Z ← Z ∪ {( u , v )}
end if
end for
end while
if ( r 1 , r 2 ) ∉ R (r_1,r_2)\notin R ( r 1 , r 2 ) ∈ / R then
return ∅ \varnothing ∅
end if
H R ← Build ( R , G ( T 1 ) , G ( T 2 ) ) H_R\leftarrow\operatorname{Build}(R,G(T_1),G(T_2)) H R ← Build ( R , G ( T 1 ) , G ( T 2 ))
return Read H R ( T r 1 , r 2 , ∅ ) \operatorname{Read}_{H_R}(T_{r_1,r_2},\varnothing) Read H R ( T r 1 , r 2 , ∅ )
end function
All constructors are read up to head unfolding. For ( u , v ) ∈ C (u,v)\in C ( u , v ) ∈ C , inversion gives compatible heads. If both are inputs, the branches of a common upper bound cover their common sender set and have continuations bounding both operand continuations. Thus
Pts ( u ) = Pts ( v ) = Pts C ( u , v ) ≠ ∅ . \operatorname{Pts}(u)=\operatorname{Pts}(v)=\operatorname{Pts}_{C}(u,v)\ne\varnothing. Pts ( u ) = Pts ( v ) = Pts C ( u , v ) = ∅ .
Whenever C ⊆ R C\subseteq R C ⊆ R , no member of C C C is inconsistent with respect to R R R . After initialisation and at deletion-loop boundaries, the reverse-dependency updates maintain, for every input pair ( u , v ) ∈ R (u,v)\in R ( u , v ) ∈ R ,
Pts R ( u , v ) = { p ∈ Pts ( u ) ∣ c [ ( u , v ) , p ] > 0 } . \operatorname{Pts}_{R}(u,v)=\{p\in\operatorname{Pts}(u)\mid c[(u,v),p]>0\}. Pts R ( u , v ) = { p ∈ Pts ( u ) ∣ c [( u , v ) , p ] > 0 } .
Thus only inconsistent pairs are enqueued, and deletion preserves C ⊆ R C\subseteq R C ⊆ R . Initially R = V 1 × V 2 R=V_1\times V_2 R = V 1 × V 2 , so C ⊆ R ∗ C\subseteq R_* C ⊆ R ∗ .
Every pair in R ∗ R_{\ast} R ∗ is consistent with respect to R ∗ R_{\ast} R ∗ . Coinduction on the auxiliary graph H ^ R ∗ \widehat{\mathcal{H}}_{R_{\ast}} H R ∗ gives
( u , v ) ∈ R ∗ ⟹ u ≤ T u , v ∧ v ≤ T u , v , (u,v) \in R_{\ast} \Longrightarrow u \leq T_{u,v} \land v \leq T_{u,v}, ( u , v ) ∈ R ∗ ⟹ u ≤ T u , v ∧ v ≤ T u , v ,
where each T u , v T_{u,v} T u , v denotes the type rooted at that vertex in H ^ R ∗ \widehat{\mathcal{H}}_{R_{\ast}} H R ∗ . Selections retain all operand summands; inputs retain matching branches with surviving continuation pairs and preserve the sender set. Hence R ∗ = C R_{\ast}=C R ∗ = C .
For leastness, let u ≤ T u \leq T u ≤ T and v ≤ T v \leq T v ≤ T . For selections, write
u = ∑ i ∈ I T 1 , i ′ , v = ∑ j ∈ J T 2 , j ′ , T = ∑ k ∈ K T k ′ ′ . u=\sum_{i\in I}T'_{1,i}, \qquad v=\sum_{j\in J}T'_{2,j}, \qquad T=\sum_{k\in K}T''_k. u = i ∈ I ∑ T 1 , i ′ , v = j ∈ J ∑ T 2 , j ′ , T = k ∈ K ∑ T k ′′ .
Inversion gives
∀ ( a , i ) ∈ I ⊎ J ∃ k ∈ K : T a , i ′ ≤ T k ′ ′ . \forall(a,i)\in I\uplus J\ \exists k\in K:\quad T'_{a,i}\leq T''_k. ∀ ( a , i ) ∈ I ⊎ J ∃ k ∈ K : T a , i ′ ≤ T k ′′ .
For inputs, write
T = & k ∈ K p k ! ℓ k ( B k ) . T k ′ . T=\mathbin{\&}_{k\in K}p_k!\ell_k(B_k).T'_k. T = & k ∈ K p k ! ℓ k ( B k ) . T k ′ .
Inversion gives
∀ k ∈ K ∃ ( u ′ , v ′ ) ∈ V 1 × V 2 : \forall k\in K\ \exists(u',v')\in V_1\times V_2: ∀ k ∈ K ∃ ( u ′ , v ′ ) ∈ V 1 × V 2 :
( p k , ℓ k , B k , ( u ′ , v ′ ) ) ∈ M ( u , v ) ∧ u ′ ≤ T k ′ ∧ v ′ ≤ T k ′ . (p_k,\ell_k,B_k,(u',v'))\in M(u,v)\ \land\ u'\leq T'_k\ \land\ v'\leq T'_k. ( p k , ℓ k , B k , ( u ′ , v ′ )) ∈ M ( u , v ) ∧ u ′ ≤ T k ′ ∧ v ′ ≤ T k ′ .
Hence each such ( u ′ , v ′ ) (u',v') ( u ′ , v ′ ) lies in C = R ∗ C=R_{\ast} C = R ∗ , and every input prefix of T T T occurs in T u , v T_{u,v} T u , v . By coinduction
u ≤ T ∧ v ≤ T ⟹ T u , v ≤ T . u\leq T\land v\leq T\Longrightarrow T_{u,v}\leq T. u ≤ T ∧ v ≤ T ⟹ T u , v ≤ T .
Restricting to vertices reachable from T r 1 , r 2 T_{r_1,r_2} T r 1 , r 2 preserves its unfolding, as does Read. The algorithm therefore returns a least upper bound exactly when one exists.
Complexity. By the graph construction, ∣ V i ∣ ≤ ∣ T i ∣ |V_i|\leq|T_i| ∣ V i ∣ ≤ ∣ T i ∣ and ∣ E i ∣ = O ( ∣ T i ∣ ) |E_i|=O(|T_i|) ∣ E i ∣ = O ( ∣ T i ∣ ) . For each pair ( u , v ) (u,v) ( u , v ) , matching branches, initialising sender counters, and constructing the result vertex takes O ( ( 1 + od ( u ) ) ( 1 + od ( v ) ) ) O((1+\operatorname{od}(u))(1+\operatorname{od}(v))) O (( 1 + od ( u )) ( 1 + od ( v ))) . Summing over the entire product graph gives
∑ u ∈ V 1 ∑ v ∈ V 2 O ( ( 1 + od ( u ) ) ( 1 + od ( v ) ) ) = O ( ( ∣ V 1 ∣ + ∣ E 1 ∣ ) ( ∣ V 2 ∣ + ∣ E 2 ∣ ) ) = O ( ∣ T 1 ∣ ∣ T 2 ∣ ) . \sum_{u\in V_1}\sum_{v\in V_2}O((1+\operatorname{od}(u))(1+\operatorname{od}(v)))
=O((|V_1|+|E_1|)(|V_2|+|E_2|))=O(|T_1||T_2|). u ∈ V 1 ∑ v ∈ V 2 ∑ O (( 1 + od ( u )) ( 1 + od ( v ))) = O (( ∣ V 1 ∣ + ∣ E 1 ∣ ) ( ∣ V 2 ∣ + ∣ E 2 ∣ )) = O ( ∣ T 1 ∣∣ T 2 ∣ ) .
Each pair is deleted at most once and each reverse dependency is processed at most once. Restricting to the root-reachable graph is linear in its size. Hence definedness and the shared witness graph are computed in O ( ∣ T 1 ∣ ∣ T 2 ∣ ) O(|T_1||T_2|) O ( ∣ T 1 ∣∣ T 2 ∣ ) time.
To read out the witness type, the terminal case is immediate. Otherwise each operand contains a branch node not represented in V i V_i V i , so ∣ V i ∣ ≤ ∣ T i ∣ − 1 |V_i|\leq|T_i|-1 ∣ V i ∣ ≤ ∣ T i ∣ − 1 . Hence
∣ V ( H ^ R ∗ ) ∣ ≤ ∣ V 1 ∣ ∣ V 2 ∣ + ∣ V 1 ∣ + ∣ V 2 ∣ ≤ ∣ T 1 ∣ ∣ T 2 ∣ − 1. |V(\widehat{\mathcal{H}}_{R_{\ast}})|\leq|V_1||V_2|+|V_1|+|V_2|\leq|T_1||T_2|-1. ∣ V ( H R ∗ ) ∣ ≤ ∣ V 1 ∣∣ V 2 ∣ + ∣ V 1 ∣ + ∣ V 2 ∣ ≤ ∣ T 1 ∣∣ T 2 ∣ − 1.
Along a readout path, each vertex contributes at most two constructor occurrences: a distribution may be emitted once under a selection join and once in its original context; ancestor lookup prevents further expansion. Thus the number of constructor occurrences along a path is at most
2 ∣ V ( H ^ R ∗ ) ∣ ≤ 2 ∣ T 1 ∣ ∣ T 2 ∣ . 2|V(\widehat{\mathcal{H}}_{R_{\ast}})|\leq2|T_1||T_2|. 2∣ V ( H R ∗ ) ∣ ≤ 2∣ T 1 ∣∣ T 2 ∣.
All out-degrees are at most d d d , except a selection-join vertex, whose out-degree is at most 2 d 2d 2 d . At most one such vertex occurs per path, contributing only a constant factor. Combining this branching bound with the depth bound, the readout has
O ( ( max { 2 , d } ) 2 ∣ T 1 ∣ ∣ T 2 ∣ ) O\left(\left(\max\{2,d\}\right)^{2|T_1||T_2|}\right) O ( ( max { 2 , d } ) 2∣ T 1 ∣∣ T 2 ∣ )
syntax nodes. The balanced ancestor map has size at most 2 ∣ T 1 ∣ ∣ T 2 ∣ 2|T_1||T_2| 2∣ T 1 ∣∣ T 2 ∣ , so each lookup or update costs O ( log ( ∣ T 1 ∣ ∣ T 2 ∣ + 1 ) ) O(\log(|T_1||T_2|+1)) O ( log ( ∣ T 1 ∣∣ T 2 ∣ + 1 )) . All remaining work is linear in the emitted syntax, giving the stated witness-construction bound.
Proposition 3.11 (Decidability of merge). (Proof in §B.3). For T 1 T_1 T 1 , T 2 T_2 T 2 and p ∈ ( 0 , 1 ) p \in(0,1) p ∈ ( 0 , 1 ) it is decidable whether T 1 ⊓ p T 2 T_1 \mathbin{\sqcap_p} T_2 T 1 ⊓ p T 2 is defined in time O ( ∣ T 1 ∣ ∣ T 2 ∣ ) O(|T_1||T_2|) O ( ∣ T 1 ∣∣ T 2 ∣ ) , and when defined the witness is computable in time O ( ( max { 2 , d } ) 2 ∣ T 1 ∣ ∣ T 2 ∣ log ( ∣ T 1 ∣ ∣ T 2 ∣ + 1 ) ) O((\max\{2,d\})^{2}|T_1||T_2|\log(|T_1||T_2|+1)) O (( max { 2 , d } ) 2 ∣ T 1 ∣∣ T 2 ∣ log ( ∣ T 1 ∣∣ T 2 ∣ + 1 )) where d d d is the max out-degree of the type graphs of T 1 , T 2 T_1,T_2 T 1 , T 2 .
Proof. Use Algorithm 2, with Join implemented by Lemma B.3 .
Termination: Guardedness makes head unfolding effective, and every Join call terminates. Only [m-Σ] calls Merge recursively; its arguments are output distributions, so these calls use [m-⊕] and cannot invoke [m-Σ] again. All loops are finite.
Correctness: Inspect the unfolded constructors, aligning prefix indices by participant and label.
[m-end] For ( e n d , e n d ) (\mathrm{end},\mathrm{end}) ( end , end ) , the algorithm returns e n d \mathrm{end} end .
[m-&] By Lemma B.3 , the algorithm computes exactly
K = { k ∈ I ∩ J ∣ B k = B k ′ ∧ T k ⊔ T k ′ is defined } , K=\{k\in I\cap J\mid B_k=B'_k\land T_k\sqcup T'_k\text{ is defined}\}, K = { k ∈ I ∩ J ∣ B k = B k ′ ∧ T k ⊔ T k ′ is defined } ,
with T k ′ ′ = T k ⊔ T k ′ T''_k=T_k\sqcup T'_k T k ′′ = T k ⊔ T k ′ for every k ∈ K k\in K k ∈ K . It succeeds precisely when
{ q i } i ∈ I = { q j } j ∈ J = { q k } k ∈ K , \{q_i\}_{i\in I}=\{q_j\}_{j\in J}=\{q_k\}_{k\in K}, { q i } i ∈ I = { q j } j ∈ J = { q k } k ∈ K ,
returning & k ∈ K q k ? ℓ k ( B k ) . T k ′ ′ \&_{k\in K}\ q_k?\ell_k(B_k).T''_k & k ∈ K q k ? ℓ k ( B k ) . T k ′′ .
[m-⊕] The algorithm succeeds precisely when
∀ k ∈ I ∩ J : B k = B k ′ ∧ T k ⊔ T k ′ is defined . \forall k\in I\cap J:\quad B_k=B'_k\land T_k\sqcup T'_k\text{ is defined}. ∀ k ∈ I ∩ J : B k = B k ′ ∧ T k ⊔ T k ′ is defined .
It returns ⨁ k ∈ I ∪ J p k ′ ′ : q k ! ℓ k ⟨ B k ′ ′ ⟩ . T k ′ ′ \bigoplus_{k\in I\cup J}p''_k:q_k!\ell_k\langle B''_k\rangle.T''_k ⨁ k ∈ I ∪ J p k ′′ : q k ! ℓ k ⟨ B k ′′ ⟩ . T k ′′ , with the weights and continuations prescribed by the rule. Since p ∈ ( 0 , 1 ) p\in(0,1) p ∈ ( 0 , 1 ) , every p k ′ ′ > 0 p''_k>0 p k ′′ > 0 and
∑ k ∈ I ∪ J p k ′ ′ = p ∑ i ∈ I p i + ( 1 − p ) ∑ j ∈ J p j ′ = 1. \sum_{k\in I\cup J}p''_k=p\sum_{i\in I}p_i+(1-p)\sum_{j\in J}p'_j=1. k ∈ I ∪ J ∑ p k ′′ = p i ∈ I ∑ p i + ( 1 − p ) j ∈ J ∑ p j ′ = 1.
[m-Σ] For T 1 = ∑ i ∈ I T i T_1=\sum_{i\in I}T_i T 1 = ∑ i ∈ I T i and T 2 = ∑ j ∈ J T j ′ T_2=\sum_{j\in J}T'_j T 2 = ∑ j ∈ J T j ′ , with ∣ I ∣ ∣ J ∣ > 1 |I||J|>1 ∣ I ∣∣ J ∣ > 1 , each recursive call is covered by [m-⊕]. Thus success is equivalent to
∀ ( i , j ) ∈ I × J : T i ⊓ p T j ′ is defined , \forall(i,j)\in I\times J:\quad T_i\sqcap_p T'_j\text{ is defined}, ∀ ( i , j ) ∈ I × J : T i ⊓ p T j ′ is defined ,
with result ∑ ( i , j ) ∈ I × J ( T i ⊓ p T j ′ ) \sum_{(i,j)\in I\times J}(T_i\sqcap_p T'_j) ∑ ( i , j ) ∈ I × J ( T i ⊓ p T j ′ ) .
All other constructor pairs are rejected. Hence the algorithm returns ∅ \varnothing ∅ exactly when the merge is undefined, and otherwise returns a witness.
Complexity results: Represent intermediate types by finite graphs, performing syntax readout only at the end. For the operand vertex sets V 1 , V 2 V_1,V_2 V 1 , V 2 , compute R ∗ R_* R ∗ and the full auxiliary graph H ^ R ∗ \widehat{H}_{R_*} H R ∗ once, as in Lemma B.3 , in O ( ∣ T 1 ∣ ∣ T 2 ∣ ) O(|T_1||T_2|) O ( ∣ T 1 ∣∣ T 2 ∣ ) time. Each continuation join is then a constant-time membership test and witness-vertex lookup. Each pair of summand distributions is processed once, so the remaining graph construction costs at most
∑ u ∈ V 1 ∑ v ∈ V 2 O ( ( 1 + od ( u ) ) ( 1 + od ( v ) ) ) = O ( ∣ T 1 ∣ ∣ T 2 ∣ ) . \sum_{u\in V_1}\sum_{v\in V_2}O((1+\operatorname{od}(u))(1+\operatorname{od}(v)))=O(|T_1||T_2|). u ∈ V 1 ∑ v ∈ V 2 ∑ O (( 1 + od ( u )) ( 1 + od ( v ))) = O ( ∣ T 1 ∣∣ T 2 ∣ ) .
This proves the definedness bound.
For syntax readout, the input and terminal cases inherit Lemma B.3 . For selection operands, ∣ V i ∣ ≤ ∣ T i ∣ − 1 |V_i|\leq|T_i|-1 ∣ V i ∣ ≤ ∣ T i ∣ − 1 , hence
∣ V ( H ^ R ∗ ) ∣ ≤ ∣ V 1 ∣ ∣ V 2 ∣ + ∣ V 1 ∣ + ∣ V 2 ∣ ≤ ∣ T 1 ∣ ∣ T 2 ∣ − 1. |V(\widehat{H}_{R_*})|\leq|V_1||V_2|+|V_1|+|V_2|\leq|T_1||T_2|-1. ∣ V ( H R ∗ ) ∣ ≤ ∣ V 1 ∣∣ V 2 ∣ + ∣ V 1 ∣ + ∣ V 2 ∣ ≤ ∣ T 1 ∣∣ T 2 ∣ − 1.
The LUB readout argument bounds each continuation path by ∣ V ( H ^ R ∗ ) ∣ + 1 |V(\widehat{H}_{R_*})|+1 ∣ V ( H R ∗ ) ∣ + 1 constructor occurrences: only the first distribution reached from a join may be emitted twice. Merge adds at most two initial vertices, of degrees at most d 2 d^2 d 2 for the sum and 2 d 2d 2 d for the merged distribution. The latter contributes a constant factor; the former adds one further factor of max { 2 , d } \max\{2,d\} max { 2 , d } . The readout therefore has O ( ( max { 2 , d } ) ∣ T 1 ∣ ∣ T 2 ∣ + 3 ) O((\max\{2,d\})^{|T_1||T_2|+3}) O (( max { 2 , d } ) ∣ T 1 ∣∣ T 2 ∣ + 3 ) nodes, with
∣ T 1 ∣ ∣ T 2 ∣ + 3 ≤ 2 ∣ T 1 ∣ ∣ T 2 ∣ ( ∣ T 1 ∣ , ∣ T 2 ∣ ≥ 2 ) . |T_1||T_2|+3 \le2|T_1||T_2| \qquad(|T_1|,|T_2| \ge2). ∣ T 1 ∣∣ T 2 ∣ + 3 ≤ 2∣ T 1 ∣∣ T 2 ∣ ( ∣ T 1 ∣ , ∣ T 2 ∣ ≥ 2 ) .
Ancestor-map operations contribute the same O ( log ( ∣ T 1 ∣ ∣ T 2 ∣ + 1 ) ) O(\log(|T_1||T_2|+1)) O ( log ( ∣ T 1 ∣∣ T 2 ∣ + 1 )) factor as in Lemma B.3 , giving the stated witness bound. □
Theorem 3.14 (Decidability). Given session M M M and typing context Δ \Delta Δ , ⊢ M : Δ \vdash M:\Delta ⊢ M : Δ is decidable.
Proof. ⊢ M : Δ \vdash M:\Delta ⊢ M : Δ is decidable for a given typing context Δ \Delta Δ , with supplied receive-sort and recursion-type annotations, by a single bidirectional traversal of M M M . Recursive-variable types come from these annotations: at [t-rec], μ X . P \mu X.P μ X . P synthesizes its annotation T X T_X T X after checking P P P against T X T_X T X under Γ , X : T X \Gamma,X:T_X Γ , X : T X ; the matching [t-var] reads T X T_X T X back from Γ \Gamma Γ .
The remaining rules other than [t-sub] are syntax-directed on M M M (Figure 5 ), and the traversal runs in two modes. In checking mode , a demanded type is supplied by a recursion annotation or session boundary. In synthesis mode , a type is produced from the process itself; this is used at leaves, prefixes, and the operands of conditionals and flips. Synthesis either returns a type or rejects; recursion variables are looked up in Γ \Gamma Γ , never unfolded.
For [t-cond], synthesize T 1 T_1 T 1 , T 2 T_2 T 2 and compute T 1 ⊔ T 2 T_1 \sqcup T_2 T 1 ⊔ T 2 using Lemma B.3 . At flip ( p ) { h ⇒ P 1 [ ] t ⇒ P 2 } \operatorname{flip}(p)\{h\Rightarrow P_1 \mathbin{[] }t\Rightarrow P_2\} flip ( p ) { h ⇒ P 1 [ ] t ⇒ P 2 } , the merge is not invertible, so the operands are likewise synthesised : the sub-traversals return T 1 T_1 T 1 , T 2 T_2 T 2 , and a witness of T 1 ⊓ p T 2 T_1 \sqcap_p T_2 T 1 ⊓ p T 2 is computable by Prop. 3.11. Undefined joins or merges cause rejection. Rule [t-sub] is discharged by a single subtyping check (Prop. 3.5) wherever a synthesized type meets a demanded one. The side-condition safe ( Δ ) \operatorname{safe}(\Delta) safe ( Δ ) of [b-sess] is decidable by Prop. B.2 .
Soundness follows from the rules; completeness for fixed annotations and sort choices follows by structural induction: the synthesized type lies below every derivable type, using the least-upper-bound property and Lemma 4.20 . Each traversal visits every syntactic node at most once and performs decidable operations; any remaining basic-sort choices range over a finite set. Hence typing respecting the supplied annotations is decidable (cf. the analogous argument in [52 Thm. 4.11] ). □
Appendix for Section 4
Examples for §4
Example C.1. The roles of Ex. 4.16 are typed as follows (payloads int; sub-types named for the repeated Q Q Q and the larger continuations, each within the scope of the μ t \mu t μ t of the type that uses it):
T u = ⊕ s ! incr ⟨ int ⟩ . μ t . & c ? res ( int ) . ⊕ s ! incr ⟨ int ⟩ . t T_u = \oplus s!\operatorname{incr}\langle\operatorname{int}\rangle.\mu t.\mathbin{\&}c?\operatorname{res}(\operatorname{int}).\oplus s!\operatorname{incr}\langle\operatorname{int}\rangle.t T u = ⊕ s ! incr ⟨ int ⟩ . μ t . & c ? res ( int ) . ⊕ s ! incr ⟨ int ⟩ . t
T s = μ t . & { c ? crit . end , c ? disconn . μ t ′ . ∑ { c ! retry . t ′ , c ! conn . T Q } , c ? err ( int ) . T Q , u ? incr ( int ) . T Q } T_s = \mu t.\mathbin{\&}\left\{c?\operatorname{crit}.\operatorname{end},\ c?\operatorname{disconn}.\mu t'.\sum\left\{c!\operatorname{retry}.t',\ c!\operatorname{conn}.T_Q\right\},\ c?\operatorname{err}(\operatorname{int}).T_Q,\ u?\operatorname{incr}(\operatorname{int}).T_Q\right\} T s = μ t . & { c ? crit . end , c ? disconn . μ t ′ . ∑ { c ! retry . t ′ , c ! conn . T Q } , c ? err ( int ) . T Q , u ? incr ( int ) . T Q }
T c = μ t . & { s ? upgrade . T u p , s ? incr ( int ) . ∑ { T f l i p , u ! res ⟨ int ⟩ . t } } T_c = \mu t.\mathbin{\&}\left\{s?\operatorname{upgrade}.T_{\mathrm{up}},\ s?\operatorname{incr}(\operatorname{int}).\sum\left\{T_{\mathrm{flip}},\ u!\operatorname{res}\langle\operatorname{int}\rangle.t\right\}\right\} T c = μ t . & { s ? upgrade . T up , s ? incr ( int ) . ∑ { T flip , u ! res ⟨ int ⟩ . t } }
where
T Q = ⊕ { 0.9 : c ! incr ⟨ int ⟩ . t , 0.1 : c ! upgrade . μ t ′ ′ . ⊕ c ! incr ( int ) . & u ? incr ( int ) . t ′ ′ } T_Q = \oplus\left\{0.9:c!\operatorname{incr}\langle\operatorname{int}\rangle.t,\ 0.1:c!\operatorname{upgrade}.\mu t''.\oplus c!\operatorname{incr}(\operatorname{int}).\mathbin{\&}u?\operatorname{incr}(\operatorname{int}).t''\right\} T Q = ⊕ { 0.9 : c ! incr ⟨ int ⟩ . t , 0.1 : c ! upgrade . μ t ′′ . ⊕ c ! incr ( int ) . & u ? incr ( int ) . t ′′ }
T u p = μ t ′ . & s ? incr ( int ) . ⊕ u ! res ⟨ int ⟩ . t ′ T_{\mathrm{up}} = \mu t'.\mathbin{\&}s?\operatorname{incr}(\operatorname{int}).\oplus u!\operatorname{res}\langle\operatorname{int}\rangle.t' T up = μ t ′ . & s ? incr ( int ) . ⊕ u ! res ⟨ int ⟩ . t ′
T f l i p = ⊕ { 0.8 : u ! res ⟨ int ⟩ . t , 0.1 : s ! err ⟨ int ⟩ . t , 0.05 : s ! crit . end , 0.05 : s ! disconn . μ t ′ ′ . & { s ? retry . t ′ ′ , s ? conn . t } } T_{\mathrm{flip}} = \oplus\left\{0.8:u!\operatorname{res}\langle\operatorname{int}\rangle.t,\ 0.1:s!\operatorname{err}\langle\operatorname{int}\rangle.t,\ 0.05:s!\operatorname{crit}.\operatorname{end},\ 0.05:s!\operatorname{disconn}.\mu t''.\mathbin{\&}\{s?\operatorname{retry}.t'',s?\operatorname{conn}.t\}\right\} T flip = ⊕ { 0.8 : u ! res ⟨ int ⟩ . t , 0.1 : s ! err ⟨ int ⟩ . t , 0.05 : s ! crit . end , 0.05 : s ! disconn . μ t ′′ . & { s ? retry . t ′′ , s ? conn . t } }
Proofs for §4.1
Lemma C.2 (Safety). The following properties hold:
(1) If safe ( Δ ′ , p : T ) \operatorname{safe}(\Delta',p:T) safe ( Δ ′ , p : T ) and T ⊑ p T 1 T \sqsubseteq_p T_1 T ⊑ p T 1 then safe ( Δ ′ , p : T 1 ) \operatorname{safe}(\Delta',p:T_1) safe ( Δ ′ , p : T 1 ) .
(2) If safe ( Δ ) \operatorname{safe}(\Delta) safe ( Δ ) and Δ = Δ ′ , Δ ′ ′ \Delta=\Delta',\Delta'' Δ = Δ ′ , Δ ′′ , then safe ( Δ ′ ) \operatorname{safe}(\Delta') safe ( Δ ′ ) .
Algorithm 2 Merge of T₁, T₂ at probability p ∈ (0, 1); returns a merged type, or ∅ if undefined.
1: function Merge(T₁, T₂, p)
2: T₁ ← unf(T₁); T₂ ← unf(T₂)
3: if T₁ = end and T₂ = end then
4: return end ▷ [M-END]
5: else if T₁ = &_{i∈I} qᵢ?ℓᵢ(Bᵢ).Tᵢ and T₂ = &_{j∈J} qⱼ?ℓⱼ(B′ⱼ).T′ⱼ then ▷ [M-&]
6: K ← ∅
7: for all k ∈ I ∩ J with Bₖ = B′ₖ do
8: T″ₖ ← Join(Tₖ, T′ₖ)
9: if T″ₖ ≠ ∅ then
10: K ← K ∪ {k}
11: end if
12: end for
13: if {qᵢ}ᵢ∈I ≠ {qⱼ}ⱼ∈J or {qₖ}ₖ∈K ≠ {qᵢ}ᵢ∈I then
14: return ∅
15: end if
16: return &_{k∈K} qₖ?ℓₖ(Bₖ).T″ₖ
17: else if T₁ = ⊕_{i∈I} pᵢ: qᵢ!ℓᵢ⟨Bᵢ⟩.Tᵢ and T₂ = ⊕_{j∈J} p′ⱼ: qⱼ!ℓⱼ⟨B′ⱼ⟩.T′ⱼ then ▷ [M-⊕]
18: for all k ∈ I ∩ J do
19: if Bₖ ≠ B′ₖ then
20: return ∅
21: end if
22: T″ₖ ← Join(Tₖ, T′ₖ)
23: if T″ₖ = ∅ then
24: return ∅
25: end if
26: (p″ₖ, B″ₖ) ← (p · pₖ + (1 − p) · p′ₖ, Bₖ)
27: end for
28: for all i ∈ I \ J do
29: (p″ᵢ, B″ᵢ, T″ᵢ) ← (p · pᵢ, Bᵢ, Tᵢ)
30: end for
31: for all j ∈ J \ I do
32: (p″ⱼ, B″ⱼ, T″ⱼ) ← ((1 − p) · p′ⱼ, B′ⱼ, T′ⱼ)
33: end for
34: return ⊕_{k∈I∪J} p″ₖ: qₖ!ℓₖ⟨B″ₖ⟩.T″ₖ
35: else if T₁ = ∑_{i∈I} Tᵢ and T₂ = ∑_{j∈J} T′ⱼ and |I| · |J| > 1 then ▷ [M-Σ]
36: for all (i, j) ∈ I × J do
37: T″_{i,j} ← Merge(Tᵢ, T′ⱼ, p)
38: if T″_{i,j} = ∅ then
39: return ∅
40: end if
41: end for
42: return ∑_{(i,j)∈I×J} T″_{i,j}
43: else
44: return ∅
45: end if
46: end function
(3) If safe(Δ \Delta Δ ) and Δ ′ ⪯ Δ \Delta^\prime\preceq\Delta Δ ′ ⪯ Δ , then safe(Δ ′ \Delta^\prime Δ ′ ).
Proof. We prove each case individually:
We use Item 3, established independently, and induct on the finite derivation of T 1 ⊓ p T 2 = T T_1 \sqcap_p T_2 = T T 1 ⊓ p T 2 = T . All types are read up to unfolding. First, the context reduction rules and the closure requirement of Def. 3.12 give
safe ( Δ ′ , p : ∑ i ∈ I T i ) ⟺ ∀ i ∈ I : safe ( Δ ′ , p : T i ) , \operatorname{safe}(\Delta',p:\sum_{i\in I}T_i)\Longleftrightarrow\forall i\in I:\operatorname{safe}(\Delta',p:T_i), safe ( Δ ′ , p : i ∈ I ∑ T i ) ⟺ ∀ i ∈ I : safe ( Δ ′ , p : T i ) ,
safe ( Δ ′ , p : ⨁ i ∈ I p i : q i ! ℓ i ⟨ B i ⟩ . T i ) ⟺ ∀ i ∈ I : safe ( Δ ′ , p : ⨁ 1 : q i ! ℓ i ⟨ B i ⟩ . T i ) , \operatorname{safe}\left(\Delta',p:\bigoplus_{i\in I}p_i:q_i!\ell_i\langle B_i\rangle.T_i\right)\Longleftrightarrow\forall i\in I:\operatorname{safe}\left(\Delta',p:\bigoplus1:q_i!\ell_i\langle B_i\rangle.T_i\right), safe ( Δ ′ , p : i ∈ I ⨁ p i : q i ! ℓ i ⟨ B i ⟩ . T i ) ⟺ ∀ i ∈ I : safe ( Δ ′ , p : ⨁ 1 : q i ! ℓ i ⟨ B i ⟩ . T i ) ,
where each T i T_i T i is a selection distribution. We proceed by case analysis on the last merge rule.
[m-END] T 1 = T = e n d T_1=T=\mathsf{end} T 1 = T = end , so the claim is immediate.
[m-&] Write
T 1 = & i ∈ I q i ? ℓ i ( B i ) . T 1 , i , T_1=\mathbin{\&}_{i\in I}q_i?\ell_i(B_i).T_{1,i}, T 1 = & i ∈ I q i ? ℓ i ( B i ) . T 1 , i ,
T = & k ∈ K q k ? ℓ k ( B k ) . ( T 1 , k ⊔ T 2 , k ) . T=\mathbin{\&}_{k\in K}q_k?\ell_k(B_k).(T_{1,k}\sqcup T_{2,k}). T = & k ∈ K q k ? ℓ k ( B k ) . ( T 1 , k ⊔ T 2 , k ) .
The rule gives
K ⊆ I , { q i } i ∈ I = { q k } k ∈ K , ∀ k ∈ K : T 1 , k ≤ T 1 , k ⊔ T 2 , k . K\subseteq I,\qquad\{q_i\}_{i\in I}=\{q_k\}_{k\in K},\qquad\forall k\in K:T_{1,k}\leq T_{1,k}\sqcup T_{2,k}. K ⊆ I , { q i } i ∈ I = { q k } k ∈ K , ∀ k ∈ K : T 1 , k ≤ T 1 , k ⊔ T 2 , k .
Hence T 1 ≤ T T_1\leq T T 1 ≤ T by [sub-&]. Applying Item 3 to
( Δ ′ , p : T 1 ) ≤ ( Δ ′ , p : T ) (\Delta',p:T_1)\leq(\Delta',p:T) ( Δ ′ , p : T 1 ) ≤ ( Δ ′ , p : T )
yields safe ( Δ ′ , p : T 1 ) \operatorname{safe}(\Delta',p:T_1) safe ( Δ ′ , p : T 1 ) .
[m-⊕] Write
T 1 = ⨁ i ∈ I p i : q i ! ℓ i ⟨ B i ⟩ . T 1 , i , T_1=\bigoplus_{i\in I}p_i:q_i!\ell_i\langle B_i\rangle.T_{1,i}, T 1 = i ∈ I ⨁ p i : q i ! ℓ i ⟨ B i ⟩ . T 1 , i ,
T = ⨁ k ∈ I ∪ J p k ′ ′ : q k ! ℓ k ⟨ B k ⟩ . T k ′ ′ . T=\bigoplus_{k\in I\cup J}p_k'':q_k!\ell_k\langle B_k\rangle.T_k''. T = k ∈ I ∪ J ⨁ p k ′′ : q k ! ℓ k ⟨ B k ⟩ . T k ′′ .
For every i ∈ I i\in I i ∈ I , the rule gives
p i ′ ′ ≥ p ⋅ p i > 0 , T 1 , i ≤ T i ′ ′ , p_i''\geq p\cdot p_i>0,\qquad T_{1,i}\leq T_i'', p i ′′ ≥ p ⋅ p i > 0 , T 1 , i ≤ T i ′′ ,
since T i ′ ′ T_i'' T i ′′ is either T 1 , i T_{1,i} T 1 , i or T 1 , i ⊔ T 2 , i T_{1,i}\sqcup T_{2,i} T 1 , i ⊔ T 2 , i . By the second safety equivalence above,
safe ( Δ ′ , p : ⨁ 1 : q i ! ℓ i ⟨ B i ⟩ . T i ′ ′ ) . \operatorname{safe}\left(\Delta',p:\bigoplus1:q_i!\ell_i\langle B_i\rangle.T_i''\right). safe ( Δ ′ , p : ⨁ 1 : q i ! ℓ i ⟨ B i ⟩ . T i ′′ ) .
Moreover, [sub-⊕] gives
⨁ 1 : q i ! ℓ i ⟨ B i ⟩ . T 1 , i ≤ ⨁ 1 : q i ! ℓ i ⟨ B i ⟩ . T i ′ ′ . \bigoplus1:q_i!\ell_i\langle B_i\rangle.T_{1,i}\leq\bigoplus1:q_i!\ell_i\langle B_i\rangle.T_i''. ⨁ 1 : q i ! ℓ i ⟨ B i ⟩ . T 1 , i ≤ ⨁ 1 : q i ! ℓ i ⟨ B i ⟩ . T i ′′ .
By Item 3, every committed alternative of T 1 T_1 T 1 is safe. The same equivalence therefore yields safe ( Δ ′ , p : T 1 ) \operatorname{safe}(\Delta',p:T_1) safe ( Δ ′ , p : T 1 ) .
[m-Σ] Here
T 1 = ∑ i ∈ I T 1 , i , T 2 = ∑ j ∈ J T 2 , j , T = ∑ ( i , j ) ∈ I × J T i , j ′ ′ , T_1=\sum_{i\in I}T_{1,i},\qquad T_2=\sum_{j\in J}T_{2,j},\qquad T=\sum_{(i,j)\in I\times J}T_{i,j}'', T 1 = i ∈ I ∑ T 1 , i , T 2 = j ∈ J ∑ T 2 , j , T = ( i , j ) ∈ I × J ∑ T i , j ′′ ,
with T 1 , i ⊓ p T 2 , j = T i , j ′ ′ T_{1,i}\sqcap_p T_{2,j}=T_{i,j}'' T 1 , i ⊓ p T 2 , j = T i , j ′′ . By the first safety equivalence,
∀ ( i , j ) ∈ I × J : safe ( Δ ′ , p : T i , j ′ ′ ) . \forall(i,j)\in I\times J:\operatorname{safe}(\Delta',p:T_{i,j}''). ∀ ( i , j ) ∈ I × J : safe ( Δ ′ , p : T i , j ′′ ) .
Fix any j ∈ J j\in J j ∈ J . Applying the induction hypothesis to each premise gives
∀ i ∈ I : safe ( Δ ′ , p : T 1 , i ) . \forall i\in I:\operatorname{safe}(\Delta',p:T_{1,i}). ∀ i ∈ I : safe ( Δ ′ , p : T 1 , i ) .
The first equivalence then gives safe ( Δ ′ , p : T 1 ) \operatorname{safe}(\Delta',p:T_1) safe ( Δ ′ , p : T 1 ) .
Write Δ = Δ ′ , Δ ′ ′ \Delta=\Delta',\Delta'' Δ = Δ ′ , Δ ′′ and suppose, towards a contradiction, ¬ safe ( Δ ′ ) \neg\operatorname{safe}(\Delta') ¬ safe ( Δ ′ ) . Since safe ( ⋅ ) \operatorname{safe}(\cdot) safe ( ⋅ ) is the largest safety property, and clause (3) of Def. 3.12 closes a safety property under all transitions, safe ( Δ 0 ) \operatorname{safe}(\Delta_0) safe ( Δ 0 ) holds iff every context reachable from Δ 0 \Delta_0 Δ 0 satisfies the compatibility clause (2); hence there is a finite sequence Δ ′ ⟶ ∗ Δ 1 ′ \Delta'\longrightarrow^*\Delta_1' Δ ′ ⟶ ∗ Δ 1 ′ with Δ 1 ′ \Delta_1' Δ 1 ′ violating clause (2), i.e. Δ 1 ′ → p : q ! ℓ ⟨ B ⟩ 1 \Delta_1'\mathrel{\xrightarrow{p:q!\ell\langle B\rangle}_1} Δ 1 ′ p : q ! ℓ ⟨ B ⟩ 1 and Δ 1 ′ → q : p ? ℓ ⟨ B ′ ⟩ 1 \Delta_1'\mathrel{\xrightarrow{q:p?\ell\langle B'\rangle}_1} Δ 1 ′ q : p ? ℓ ⟨ B ′ ⟩ 1 but Δ 1 ′ ̸ → ( p , q ) ℓ 1 \Delta_1'\mathrel{\not\xrightarrow{(p,q)\ell}_1} Δ 1 ′ ( p , q ) ℓ 1 . Framing each step by [ct-sc] (induction on the length of
Printed: Vol. 1, No. 1, Article . Publication date: November 2026. the sequence, Δ ′ ′ \Delta^{\prime\prime} Δ ′′ unchanged throughout) lifts it to Δ 1 ′ ′ → ∗ Δ 1 ′ ′ \Delta_1^{\prime\prime} \mathrel{\to^{*}} \Delta_1^{\prime\prime} Δ 1 ′′ → ∗ Δ 1 ′′ , and likewise lifts the two enabled actions to Δ 1 ′ , Δ ′ ′ \Delta_1^{\prime},\Delta^{\prime\prime} Δ 1 ′ , Δ ′′ . By safe ( Δ ′ , Δ ′ ′ ) \operatorname{safe}(\Delta^{\prime},\Delta^{\prime\prime}) safe ( Δ ′ , Δ ′′ ) and closure, safe ( Δ 1 ′ , Δ ′ ′ ) \operatorname{safe}(\Delta_1^{\prime},\Delta^{\prime\prime}) safe ( Δ 1 ′ , Δ ′′ ) , so clause (2) gives Δ 1 ′ , Δ ′ ′ → ( p , q ) ℓ 1 \Delta_1^{\prime},\Delta^{\prime\prime} \mathrel{\xrightarrow{(p,q)\ell}} 1 Δ 1 ′ , Δ ′′ ( p , q ) ℓ 1 . But its subjects p , q p,q p , q lie in dom ( Δ 1 ′ ) \operatorname{dom}(\Delta_1^{\prime}) dom ( Δ 1 ′ ) , and every rule of Figure 4 mentions only the entries of its acting participants, so the synchronisation restricts to Δ 1 ′ , Δ ′ ′ → ( p , q ) ℓ 1 \Delta_1^{\prime},\Delta^{\prime\prime} \mathrel{\xrightarrow{(p,q)\ell}} 1 Δ 1 ′ , Δ ′′ ( p , q ) ℓ 1 — a contradiction.
(3) Let
R = { Δ ′ ∣ ∃ Δ : Δ ′ ⪯ Δ and safe ( Δ ) } . R = \{ \Delta^{\prime} \mid\exists\Delta: \Delta^{\prime} \preceq\Delta\mathbin{\text{ and }} \operatorname{safe}(\Delta) \}. R = { Δ ′ ∣ ∃Δ : Δ ′ ⪯ Δ and safe ( Δ )} .
By reflexivity of ⪯ \preceq ⪯ (Lemma 3.3 ), R R R contains every safe context and ∅ \varnothing ∅ , giving condition (1) of Def. 3.12; we show R R R is a safety property, whence R ⊆ safe ( ⋅ ) R \subseteq\operatorname{safe}(\cdot) R ⊆ safe ( ⋅ ) and the claim follows. So let Δ ′ ∈ R \Delta^{\prime} \in R Δ ′ ∈ R , witnessed by Δ ′ ⪯ Δ \Delta^{\prime} \preceq\Delta Δ ′ ⪯ Δ with safe ( Δ ) \operatorname{safe}(\Delta) safe ( Δ ) . By synchronisation (Lemma C.14), Δ → n ∗ Δ ^ \Delta\mathrel{\to^{*}_{n}} \widehat{\Delta} Δ → n ∗ Δ with Δ ′ ⋉ Δ ^ \Delta^{\prime} \ltimes\widehat{\Delta} Δ ′ ⋉ Δ ; note safe ( Δ ^ ) \operatorname{safe}(\widehat{\Delta}) safe ( Δ ) by closure of safe ( Δ ) \operatorname{safe}(\Delta) safe ( Δ ) , and Δ ^ \widehat{\Delta} Δ equally witnesses Δ ′ ∈ R \Delta^{\prime} \in R Δ ′ ∈ R .
Compatibility (2). Suppose Δ ′ → p : q ! ℓ ⟨ B ⟩ 1 \Delta^{\prime} \mathrel{\xrightarrow{p:q!\ell\langle B\rangle}} 1 Δ ′ p : q ! ℓ ⟨ B ⟩ 1 and Δ ′ ′ → q : p ? ℓ 1 \Delta^{\prime\prime} \mathrel{\xrightarrow{q:p?\ell}} 1 Δ ′′ q : p ? ℓ 1 . By [CT-OUT] the former forces unf ( Δ ′ ( p ) ) \operatorname{unf}(\Delta^{\prime}(p)) unf ( Δ ′ ( p )) to be a singleton selection, so Δ ′ ( p ) ̸ → n \Delta^{\prime}(p) \not\to_n Δ ′ ( p ) → n and, by Def. C.12, Δ ′ ( p ) ⪯ Δ ^ ( p ) \Delta^{\prime}(p) \preceq\widehat{\Delta}(p) Δ ′ ( p ) ⪯ Δ ( p ) is by [SUB-⊕ \oplus ⊕ ]: unf ( Δ ^ ( p ) ) \operatorname{unf}(\widehat{\Delta}(p)) unf ( Δ ( p )) is the same singleton, and the output action is enabled at Δ ^ \widehat{\Delta} Δ . Moreover Δ ′ ( q ) ⪯ Δ ^ ( q ) \Delta^{\prime}(q) \preceq\widehat{\Delta}(q) Δ ′ ( q ) ⪯ Δ ( q ) is by [SUB-& \& & ], so unf ( Δ ^ ( q ) ) \operatorname{unf}(\widehat{\Delta}(q)) unf ( Δ ( q )) is a branching from p p p — nonempty by well-formedness — enabling some input at q q q from p p p . Clause (2) of safe ( Δ ^ ) \operatorname{safe}(\widehat{\Delta}) safe ( Δ ) then gives Δ ^ → ( p , q ) ℓ 1 \widehat{\Delta} \mathrel{\xrightarrow{(p,q)\ell}} 1 Δ ( p , q ) ℓ 1 ; in particular Δ ^ ( q ) \widehat{\Delta}(q) Δ ( q ) offers ( ℓ , B ) (\ell,B) ( ℓ , B ) , and by contravariance of [SUB-& \& & ] so does Δ ′ ( q ) \Delta^{\prime}(q) Δ ′ ( q ) , whence Δ ′ → ( p , q ) ℓ 1 \Delta^{\prime} \mathrel{\xrightarrow{(p,q)\ell}} 1 Δ ′ ( p , q ) ℓ 1 .
Closure (3). If Δ → α Δ 1 ′ \Delta\mathrel{\xrightarrow{\alpha}} \Delta_1^{\prime} Δ α Δ 1 ′ , then by one-step preservation (Lemma C.15) there is Δ ^ 1 \widehat{\Delta}_1 Δ 1 with Δ 1 ′ ⋉ Δ ^ 1 \Delta_1^{\prime} \ltimes\widehat{\Delta}_1 Δ 1 ′ ⋉ Δ 1 , reached from Δ ^ \widehat{\Delta} Δ by finitely many transitions; each preserves safety by closure, so safe ( Δ ^ 1 ) \operatorname{safe}(\widehat{\Delta}_1) safe ( Δ 1 ) , and Δ ^ 1 \widehat{\Delta}_1 Δ 1 witnesses Δ 1 ′ ∈ R \Delta_1^{\prime} \in R Δ 1 ′ ∈ R .
Lemma C.3 (Substitution Lemma).
If Γ , x : B ⊢ P : T \Gamma, x:B \vdash P:T Γ , x : B ⊢ P : T then Γ , y : B ⊢ P { y / x } : T \Gamma, y:B \vdash P\{y/x\}:T Γ , y : B ⊢ P { y / x } : T ; and
if Γ , x : B ⊢ P : T \Gamma, x:B \vdash P:T Γ , x : B ⊢ P : T and Γ ⊢ v : B \Gamma\vdash v:B Γ ⊢ v : B , then Γ ⊢ P { v / x } : T \Gamma\vdash P\{v/x\}:T Γ ⊢ P { v / x } : T . and
if Γ , X : T ′ ⊢ P : T \Gamma, X:T^{\prime} \vdash P:T Γ , X : T ′ ⊢ P : T and Γ ⊢ Q : T ′ \Gamma\vdash Q:T^{\prime} Γ ⊢ Q : T ′ , then Γ ⊢ P { Q / X } : T \Gamma\vdash P\{Q/X\}:T Γ ⊢ P { Q / X } : T .
Proof. Parts (1) and (2) are by straightforward induction on the typing derivation; the cases for the standard constructors follow [22 ] (see also [52 , 65 ] ). We show the one case specific to our calculus, [T-FLIP].
Case [T-FLIP]. By inversion, Γ , x : B ⊢ flip ( p ) { h ⇒ P 1 [ ] t ⇒ P 2 } : T \Gamma, x:B \vdash\operatorname{flip}(p)\{h\Rightarrow P_1 \mathbin{[]} t\Rightarrow P_2\}:T Γ , x : B ⊢ flip ( p ) { h ⇒ P 1 [ ] t ⇒ P 2 } : T gives T 1 , T 2 T_1,T_2 T 1 , T 2 with Γ , x : B ⊢ P i : T i \Gamma, x:B \vdash P_i:T_i Γ , x : B ⊢ P i : T i and T = T 1 ⊓ p T 2 T = T_1 \sqcap_p T_2 T = T 1 ⊓ p T 2 . By the IH, Γ ⊢ P i { v / x } : T i \Gamma\vdash P_i\{v/x\}:T_i Γ ⊢ P i { v / x } : T i for i = 1 , 2 i=1,2 i = 1 , 2 , so by [T-FLIP] Γ ⊢ flip ( p ) { h ⇒ P 1 { v / x } [ ] t ⇒ P 2 { v / x } } : T \Gamma\vdash\operatorname{flip}(p)\{h\Rightarrow P_1\{v/x\} \mathbin{[]} t\Rightarrow P_2\{v/x\}\}:T Γ ⊢ flip ( p ) { h ⇒ P 1 { v / x } [ ] t ⇒ P 2 { v / x }} : T , i.e. Γ ⊢ ( flip ( p ) { h ⇒ P 1 [ ] t ⇒ P 2 } ) { v / x } : T \Gamma\vdash(\operatorname{flip}(p)\{h\Rightarrow P_1 \mathbin{[]} t\Rightarrow P_2\})\{v/x\}:T Γ ⊢ ( flip ( p ) { h ⇒ P 1 [ ] t ⇒ P 2 }) { v / x } : T .
Part (3) is analogous, replacing value substitution by process substitution { Q / X } \{Q/X\} { Q / X } throughout. □ \square □
Lemma C.4 (Subject Precongruence). Suppose ⊢ M : Δ \vdash M:\Delta ⊢ M : Δ and M ⇛ M ′ M \Rrightarrow M^{\prime} M ⇛ M ′ . Then ⊢ M ′ : Δ \vdash M^{\prime}:\Delta ⊢ M ′ : Δ .
Proof. By induction on the derivation of M ⇛ M ′ M \Rrightarrow M^{\prime} M ⇛ M ′ .
Case p ◃ μ X . P ∣ M ′ ′ ⇛ p ◃ P { μ X . P / X } ∣ M ′ ′ p \mathrel{\triangleleft} \mu X.P \mid M^{\prime\prime} \Rrightarrow p \mathrel{\triangleleft} P\{\mu X.P/X\} \mid M^{\prime\prime} p ◃ μ X . P ∣ M ′′ ⇛ p ◃ P { μ X . P / X } ∣ M ′′ (recursion unfolding). By inversion of [B-SESS], ⊢ p ◃ μ X . P ∣ M ′ ′ : Δ \vdash p \mathrel{\triangleleft} \mu X.P \mid M^{\prime\prime}:\Delta ⊢ p ◃ μ X . P ∣ M ′′ : Δ gives Δ p : T ′ \Delta_p:T^{\prime} Δ p : T ′ with ⊢ μ X . P : T \vdash\mu X.P:T ⊢ μ X . P : T and ⊢ M ′ ′ : Δ ′ \vdash M^{\prime\prime}:\Delta^{\prime} ⊢ M ′′ : Δ ′ , and ⊢ μ X . P : T \vdash\mu X.P:T ⊢ μ X . P : T and ⊢ P : T \vdash P:T ⊢ P : T . Since also ⊢ μ X . P : T \vdash\mu X.P:T ⊢ μ X . P : T , Lemma C.3 (3) yields ⊢ P { μ X . P / X } : T \vdash P\{\mu X.P/X\}:T ⊢ P { μ X . P / X } : T . Recomposing with ⊢ M ′ ′ : Δ ′ \vdash M^{\prime\prime}:\Delta^{\prime} ⊢ M ′′ : Δ ′ by [B-SESS] gives ⊢ p ◃ P { μ X . P / X } ∣ M ′ ′ : Δ \vdash p \mathrel{\triangleleft} P\{\mu X.P/X\} \mid M^{\prime\prime}:\Delta ⊢ p ◃ P { μ X . P / X } ∣ M ′′ : Δ .
Case ∏ i ∈ I p i ▹ P i ⇛ ∏ j ∈ J p j ▹ P j \prod_{i\in I} p_i \triangleright P_i \Rrightarrow\prod_{j\in J} p_j \triangleright P_j ∏ i ∈ I p i ▹ P i ⇛ ∏ j ∈ J p j ▹ P j with I I I a permutation of J J J (parallel permutation). Immediate, as [B-SESS] types a session from the (unordered) set of its components, so both sides are typed by the same Δ \Delta Δ .
The remaining closure cases are immediate from the IH. □
Theorem C.5 (Type Inversion). The following statements hold:
(1) Γ ⊢ μ X . P : T \Gamma\vdash\mu X.P : T Γ ⊢ μ X . P : T implies ∃ T ′ : Γ , X : T ′ ⊢ P : T ′ \exists T^{\prime} : \Gamma, X : T^{\prime} \vdash P : T^{\prime} ∃ T ′ : Γ , X : T ′ ⊢ P : T ′ with T ′ ≤ T T^{\prime} \leq T T ′ ≤ T .
(2) Γ ⊢ f l i p ( p ) { h ⇒ P 1 ∥ t ⇒ P 2 } : T \Gamma\vdash\mathit{flip}(p)\{h \Rightarrow P_{1} \mathbin{\|} t \Rightarrow P_{2}\} : T Γ ⊢ flip ( p ) { h ⇒ P 1 ∥ t ⇒ P 2 } : T implies ∃ T 1 , T 2 . Γ ⊢ P 1 : T 1 \exists T_{1}, T_{2} . \Gamma\vdash P_{1} : T_{1} ∃ T 1 , T 2 .Γ ⊢ P 1 : T 1 and Γ ⊢ P 2 : T 2 \Gamma\vdash P_{2} : T_{2} Γ ⊢ P 2 : T 2 with T 1 ⊓ p T 2 ≤ T T_{1} \sqcap_{p} T_{2} \leq T T 1 ⊓ p T 2 ≤ T .
(3) Γ ⊢ p ! ℓ ⟨ e ⟩ . P : T \Gamma\vdash p!\ell\langle e\rangle.P : T Γ ⊢ p ! ℓ ⟨ e ⟩ . P : T implies Γ ⊢ e : B \Gamma\vdash e : B Γ ⊢ e : B and Γ ⊢ P : T ′ \Gamma\vdash P : T^{\prime} Γ ⊢ P : T ′ with ⊕ 1 : p ! ℓ ⟨ B ⟩ . T ′ ≤ T \oplus1 : p!\ell\langle B\rangle.T^{\prime} \leq T ⊕ 1 : p ! ℓ ⟨ B ⟩ . T ′ ≤ T .
(4) Γ ⊢ ∑ i ∈ I q i ? ℓ i ( x i ) . P i : T \Gamma\vdash\sum_{i \in I} q_{i}?\ell_{i}(x_{i}).P_{i} : T Γ ⊢ ∑ i ∈ I q i ? ℓ i ( x i ) . P i : T implies ∀ i ∈ I : ∃ T i . Γ , x i : B i ⊢ P i : T i \forall i \in I : \exists T_{i} . \Gamma, x_{i} : B_{i} \vdash P_{i} : T_{i} ∀ i ∈ I : ∃ T i .Γ , x i : B i ⊢ P i : T i with & i ∈ I q i ? ℓ i ( B i ) . T i ≤ T \mathbin{\&}_{i \in I} q_{i}?\ell_{i}(B_{i}).T_{i} \leq T & i ∈ I q i ? ℓ i ( B i ) . T i ≤ T
(5) Γ ⊢ if e then P 1 else P 2 : T \Gamma\vdash\text{if } e \text{ then } P_{1} \text{ else } P_{2} : T Γ ⊢ if e then P 1 else P 2 : T implies Γ ⊢ e : bool , Γ ⊢ P 1 : T ′ \Gamma\vdash e : \text{bool}, \Gamma\vdash P_{1} : T^{\prime} Γ ⊢ e : bool , Γ ⊢ P 1 : T ′ and Γ ⊢ P 2 : T ′ \Gamma\vdash P_{2} : T^{\prime} Γ ⊢ P 2 : T ′ with T ′ ≤ T T^{\prime} \leq T T ′ ≤ T .
(6) ⊢ ∏ i ∈ I p i ▹ P i : { p i : T i } i ∈ I \vdash\prod_{i \in I} p_{i} \triangleright P_{i} : \{p_{i} : T_{i}\}_{i \in I} ⊢ ∏ i ∈ I p i ▹ P i : { p i : T i } i ∈ I implies safe ( { p i : T i } i ∈ I ) \operatorname{safe}(\{p_{i} : T_{i}\}_{i \in I}) safe ({ p i : T i } i ∈ I ) and ∀ i ∈ I \forall i \in I ∀ i ∈ I we have ⊢ P i : T i \vdash P_{i} : T_{i} ⊢ P i : T i .
Proof. The proof follows as standard where subtyping is introduced by the application of the [t-sub] rule.
(1) Follows from [t-rec].
(2) Follows from [t-flip].
(3) Follows from [t-sel].
(4) Follows from [t-bra].
(5) Follows from [t-cond].
(6) Follows from [b-sess].
Theorem 4.1 (Subject Reduction). Suppose ⊢ M : Δ \vdash M : \Delta ⊢ M : Δ . If M ⟶ p M 1 M \longrightarrow_{p} M_{1} M ⟶ p M 1 , then depending on the top-level rule used to derive M ⟶ p M 1 M \longrightarrow_{p} M_{1} M ⟶ p M 1 we have:
(1) [r-t-if] or [r-f-if] implies: ⊢ M 1 : Δ \vdash M_{1} : \Delta ⊢ M 1 : Δ
(2) [r-comm] implies: ∃ Δ 1 \exists\Delta_{1} ∃ Δ 1 such that ⊢ M 1 : Δ 1 \vdash M_{1} : \Delta_{1} ⊢ M 1 : Δ 1 and either Δ ⟶ 1 Δ 1 \Delta\longrightarrow_{1} \Delta_{1} Δ ⟶ 1 Δ 1 or Δ ⟶ n ⟶ 1 Δ 1 \Delta\longrightarrow_{n} \longrightarrow_{1} \Delta_{1} Δ ⟶ n ⟶ 1 Δ 1 .
(3) [r-head] or [r-tail] implies ∃ p , T , { T i , M i } i ∈ { 1 , 2 } , Δ ′ \exists p, T, \{T_{i}, M_{i}\}_{i \in\{1,2\}}, \Delta^{\prime} ∃ p , T , { T i , M i } i ∈ { 1 , 2 } , Δ ′ such that Δ = p : T , Δ ′ \Delta= p : T, \Delta^{\prime} Δ = p : T , Δ ′ and M ⟶ 1 − p M 2 M \longrightarrow_{1-p} M_{2} M ⟶ 1 − p M 2 with ⊢ M i : ( p : T i , Δ ′ ) \vdash M_{i} : (p : T_{i}, \Delta^{\prime}) ⊢ M i : ( p : T i , Δ ′ ) for i ∈ { 1 , 2 } i \in\{1, 2\} i ∈ { 1 , 2 } and ( p : T 1 ⊓ p T 2 , Δ ′ ) ≤ Δ (p : T_{1} \sqcap_{p} T_{2}, \Delta^{\prime}) \leq\Delta ( p : T 1 ⊓ p T 2 , Δ ′ ) ≤ Δ .
Proof. By induction on the derivation M ⟶ p M 1 M \longrightarrow_{p} M_{1} M ⟶ p M 1 .
M = p ◃ f l i p ( p ) { h ⇒ P 1 ∥ t ⇒ P 2 } ∥ M ′ (2) M = p \triangleleft\mathit{flip}(p)\{h \Rightarrow P_{1} \mathbin{\|} t \Rightarrow P_{2}\} \mathbin{\|} M^{\prime} \tag*{(2)} M = p ◃ flip ( p ) { h ⇒ P 1 ∥ t ⇒ P 2 } ∥ M ′ (2)
M 1 = p ◃ P 1 ∥ M ′ (3) M_{1} = p \triangleleft P_{1} \mathbin{\|} M^{\prime} \tag*{(3)} M 1 = p ◃ P 1 ∥ M ′ (3)
(and ∃ M 2 : M 2 = p ◃ P 2 ∥ M ′ \exists M_{2} : M_{2} = p \triangleleft P_{2} \mathbin{\|} M^{\prime} ∃ M 2 : M 2 = p ◃ P 2 ∥ M ′ by [r-tail])
{#eq:3}
let Δ = ( p : T , Δ ′ ) \Delta= (p : T, \Delta^{\prime}) Δ = ( p : T , Δ ′ ) then:
∅ ⊢ f l i p ( p ) { h ⇒ P 1 ∥ t ⇒ P 2 } : T (4) \varnothing\vdash\mathit{flip}(p)\{h \Rightarrow P_{1} \mathbin{\|} t \Rightarrow P_{2}\} : T \tag*{(4)} ∅ ⊢ flip ( p ) { h ⇒ P 1 ∥ t ⇒ P 2 } : T (4)
since ⊢ M : Δ \vdash M : \Delta ⊢ M : Δ and applying case (6) of type inversion (Thm. C.5 )
To recover the typing of p p p we apply case (2) of Thm. C.5 :
∃ T 1 , T 2 : ⊢ P 1 : T 1 (5) \exists T_{1}, T_{2} : \vdash P_{1} : T_{1} \tag*{(5)} ∃ T 1 , T 2 :⊢ P 1 : T 1 (5)
⊢ P 2 : T 2 (6) \vdash P_{2} : T_{2} \tag*{(6)} ⊢ P 2 : T 2 (6)
T 1 ⊓ p T 2 ≤ T (7) T_{1} \sqcap_{p} T_{2} \leq T \tag*{(7)} T 1 ⊓ p T 2 ≤ T (7)
since safe ( p : T , Δ ′ ) \operatorname{safe}(p : T, \Delta^{\prime}) safe ( p : T , Δ ′ ) and by case (1) of Lemma C.2 we have:
⊢ M 1 : ( p : T 1 , Δ ′ ) (8) \vdash M_{1} : (p : T_{1}, \Delta^{\prime}) \tag*{(8)} ⊢ M 1 : ( p : T 1 , Δ ′ ) (8)
⊢ M 2 : ( p : T 2 , Δ ′ ) (9) \vdash M_{2} : (p : T_{2}, \Delta^{\prime}) \tag*{(9)} ⊢ M 2 : ( p : T 2 , Δ ′ ) (9)
Finally, since T 1 ⊓ p T 2 ≤ T T_1 \sqcap_p T_2 \leq T T 1 ⊓ p T 2 ≤ T , we get:
( p : T 1 ⊓ p T 2 , Δ ′ ) ≤ Δ (10) (p : T_1 \sqcap_p T_2, \Delta') \leq\Delta \tag*{(10)} ( p : T 1 ⊓ p T 2 , Δ ′ ) ≤ Δ (10)
M = p ▹ q ! ℓ ⟨ e ⟩ . P ∣ q ▹ ∑ i ∈ I p i ? ℓ i ( x i ) . Q i ∣ M ′ , (11) M = p \mathbin{\triangleright} q!\ell\langle e\rangle.P \mid q \mathbin{\triangleright} \mathop{\sum}_{i\in I} p_i?\ell_i(x_i).Q_i \mid M', \tag*{(11)} M = p ▹ q ! ℓ ⟨ e ⟩ . P ∣ q ▹ ∑ i ∈ I p i ? ℓ i ( x i ) . Q i ∣ M ′ , (11)
∃ j ∈ I : ∃ v : e ↓ v ∧ p = p j ∧ ℓ = ℓ j ∧ M 1 = p ▹ P ∣ q ▹ Q j { v / x j } ∣ M ′ (12) \exists j\in I : \exists v : e\mathrel{\downarrow}v \land p=p_j \land\ell=\ell_j \land M_1=p\mathbin{\triangleright}P \mid q\mathbin{\triangleright}Q_j\{v/x_j\}\mid M' \tag*{(12)} ∃ j ∈ I : ∃ v : e ↓ v ∧ p = p j ∧ ℓ = ℓ j ∧ M 1 = p ▹ P ∣ q ▹ Q j { v / x j } ∣ M ′ (12)
Let Δ = p : T p , q : T q , Δ ′ \Delta= p:T_p,q:T_q,\Delta' Δ = p : T p , q : T q , Δ ′ , then by case (6) of type inversion (Thm. C.5 ):
⊢ q ! ℓ ⟨ e ⟩ . P : T p ⊢ ∑ i ∈ I p i ? ℓ i ( x i ) . Q i : T q ∀ ( r : T r ) ∈ Δ ′ : ⊢ P r : T r safe ( Δ ) ⊢ M : Δ (13) \frac{
\vdash q!\ell\langle e\rangle.P:T_p \vdash\mathop{\sum}_{i\in I}p_i?\ell_i(x_i).Q_i:T_q \quad\forall(r:T_r)\in\Delta':\vdash P_r:T_r \quad\operatorname{safe}(\Delta)
}{
\vdash M:\Delta
} \tag*{(13)} ⊢ M : Δ ⊢ q ! ℓ ⟨ e ⟩ . P : T p ⊢ ∑ i ∈ I p i ? ℓ i ( x i ) . Q i : T q ∀ ( r : T r ) ∈ Δ ′ :⊢ P r : T r safe ( Δ ) (13)
To recover the typing of q q q , we apply case (4) of type inversion (Thm. C.5 ):
∀ i ∈ I x i : B i ⊢ Q i : T q , i ⊢ q ▹ ∑ i ∈ I p i ? ℓ i ( x i ) . Q i : & i ∈ I p i ? ℓ i ( B i ) . T q , i & i ∈ I p i ? ℓ i ( B i ) . T q , i ≤ T q \frac{
\forall i\in I\quad x_i:B_i\vdash Q_i:T_{q,i}
}{
\vdash q\mathbin{\triangleright}\mathop{\sum}_{i\in I}p_i?\ell_i(x_i).Q_i:\&_{i\in I}p_i?\ell_i(B_i).T_{q,i}
\quad
\&_{i\in I}p_i?\ell_i(B_i).T_{q,i}\leq T_q
} ⊢ q ▹ ∑ i ∈ I p i ? ℓ i ( x i ) . Q i : & i ∈ I p i ? ℓ i ( B i ) . T q , i & i ∈ I p i ? ℓ i ( B i ) . T q , i ≤ T q ∀ i ∈ I x i : B i ⊢ Q i : T q , i
⊢ q ▹ ∑ i ∈ I p i ? ℓ i ( x i ) . Q i : T q (14) \vdash q\mathbin{\triangleright}\mathop{\sum}_{i\in I}p_i?\ell_i(x_i).Q_i:T_q \tag*{(14)} ⊢ q ▹ ∑ i ∈ I p i ? ℓ i ( x i ) . Q i : T q (14)
where T q = & k ∈ K p k ? ℓ k ( B k ) . T q , k T_q=\&_{k\in K}p_k?\ell_k(B_k).T_{q,k} T q = & k ∈ K p k ? ℓ k ( B k ) . T q , k with K ⊆ I K\subseteq I K ⊆ I and T q , k ≤ T q , k ′ T_{q,k}\leq T'_{q,k} T q , k ≤ T q , k ′ for all k ∈ K k\in K k ∈ K (by [SUB-&]).
To recover the typing of p p p , we apply case (3) of type inversion (Thm. C.5 ):
⊢ P : T p , j ⊢ p ▹ q ! ℓ j ⟨ e ⟩ . P : ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ≤ T p \frac{
\vdash P:T_{p,j}
}{
\vdash p\mathbin{\triangleright}q!\ell_j\langle e\rangle.P:\oplus1:q!\ell_j\langle B\rangle.T_{p,j}
\quad
\oplus1:q!\ell_j\langle B\rangle.T_{p,j}\leq T_p
} ⊢ p ▹ q ! ℓ j ⟨ e ⟩ . P : ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ≤ T p ⊢ P : T p , j
⊢ p ▹ q ! ℓ j ⟨ e ⟩ . P : T p (15) \vdash p\mathbin{\triangleright}q!\ell_j\langle e\rangle.P:T_p \tag*{(15)} ⊢ p ▹ q ! ℓ j ⟨ e ⟩ . P : T p (15)
where T p T_p T p is a supertype of ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j \oplus1:q!\ell_j\langle B\rangle.T_{p,j} ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j , by either [SUB-\Sigma] or [SUB-\oplus]:
T p = ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ + ∑ m ∈ M ⊕ n ∈ N m p m , n : p m ! ℓ m ⟨ B m ⟩ . T m , n (16) T_p=\oplus1:q!\ell_j\langle B\rangle.T'_{p,j}+\mathop{\sum}_{m\in M}\mathop{\oplus}_{n\in N_m}p_{m,n}:p_m!\ell_m\langle B_m\rangle.T_{m,n} \tag*{(16)} T p = ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ + ∑ m ∈ M ⊕ n ∈ N m p m , n : p m ! ℓ m ⟨ B m ⟩ . T m , n (16)
or
T p = ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ (17) T_p=\oplus1:q!\ell_j\langle B\rangle.T'_{p,j} \tag*{(17)} T p = ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ (17)
in both cases T p , j ≤ T p , j ′ T_{p,j}\leq T'_{p,j} T p , j ≤ T p , j ′ ; note that in both shapes the j j j -branch is the singleton selection at 1 1 1 , [SUB-\oplus] preserving probabilities exactly — in particular T p T_p T p is always dirac (point mass 1 1 1 ) so no [CT-PROB] step arises.
We will now argue that the type context can either step as:
Δ → p : T p n ( p : ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ , q : T q , Δ ′ ) → ( p , q ) ℓ j 1 Δ 1 (18) \Delta\xrightarrow{p:T_p}_n (p:\oplus1:q!\ell_j\langle B\rangle.T'_{p,j},q:T_q,\Delta') \xrightarrow{(p,q)\ell_j}_1 \Delta_1 \tag*{(18)} Δ p : T p n ( p : ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ , q : T q , Δ ′ ) ( p , q ) ℓ j 1 Δ 1 (18)
(or directly):
Δ → ( p , q ) ℓ j 1 Δ 1 (19) \Delta\xrightarrow{(p,q)\ell_j}_1\Delta_1 \tag*{(19)} Δ ( p , q ) ℓ j 1 Δ 1 (19)
Firstly if T p = ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ + ∑ m ∈ M ⊕ n ∈ N m p m , n : p m ! ℓ m ⟨ B m ⟩ . T m , n T_p=\oplus1:q!\ell_j\langle B\rangle.T'_{p,j}+\mathop{\sum}_{m\in M}\mathop{\oplus}_{n\in N_m}p_{m,n}:p_m!\ell_m\langle B_m\rangle.T_{m,n} T p = ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ + ∑ m ∈ M ⊕ n ∈ N m p m , n : p m ! ℓ m ⟨ B m ⟩ . T m , n then
Δ → p : T p n ( p : ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ , q : T q , Δ ′ ) \Delta\xrightarrow{p:T_p}_n(p:\oplus1:q!\ell_j\langle B\rangle.T'_{p,j},q:T_q,\Delta') Δ p : T p n ( p : ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ , q : T q , Δ ′ )
as:
( ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ ) ∈ T p ∣ M ∣ + 1 > 1 p : T p → p : T p n p : ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ \frac{
(\oplus1:q!\ell_j\langle B\rangle.T'_{p,j})\in T_p \quad|M|+1>1
}{
p:T_p\xrightarrow{p:T_p}_n p:\oplus1:q!\ell_j\langle B\rangle.T'_{p,j}
} p : T p p : T p n p : ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ ( ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ ) ∈ T p ∣ M ∣ + 1 > 1
p : T p → p : T p n p : ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ p : T p , q : T q , Δ ′ → p : T p n ( p : ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ , q : T q , Δ ′ ) (20) \frac{
p:T_p\xrightarrow{p:T_p}_n p:\oplus1:q!\ell_j\langle B\rangle.T'_{p,j}
}{
p:T_p,q:T_q,\Delta'\xrightarrow{p:T_p}_n(p:\oplus1:q!\ell_j\langle B\rangle.T'_{p,j},q:T_q,\Delta')
} \tag*{(20)} p : T p , q : T q , Δ ′ p : T p n ( p : ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ , q : T q , Δ ′ ) p : T p p : T p n p : ⊕ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ (20)
We note that as safe ( Δ ) \operatorname{safe}(\Delta) safe ( Δ ) and safety propagates (Def. 3.12) we have safe ( p : ⨁ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ , q : T q ′ , Δ ′ ) \operatorname{safe}(\mathbf{p} : \bigoplus1:q!\ell_j\langle B\rangle.T'_{p,j}, q : T'_q,\Delta') safe ( p : ⨁ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ , q : T q ′ , Δ ′ ) . Next we show that:
( p : ⨁ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ , q : T q ′ , Δ ′ ) → ( p , q ) ℓ j 1 Δ 1 (21) (\mathbf{p} : \bigoplus1:q!\ell_j\langle B\rangle.T'_{p,j}, q : T'_q,\Delta') \xrightarrow{(p,q)\ell_j}_{1} \Delta_1 \tag*{(21)} ( p : ⨁ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ , q : T q ′ , Δ ′ ) ( p , q ) ℓ j 1 Δ 1 (21)
(which also covers the case when Δ → ( p , q ) ℓ j 1 Δ 1 \Delta\xrightarrow{(p,q)\ell_j}_{1} \Delta_1 Δ ( p , q ) ℓ j 1 Δ 1 directly). The output action is enabled at the singleton selection :
p : ⨁ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ → p : q ! ℓ j ⟨ B j ⟩ 1 p : T p , j ′ (22) p : \bigoplus1:q!\ell_j\langle B\rangle.T'_{p,j} \xrightarrow{p:q!\ell_j\langle B_j\rangle}_{1} p : T'_{p,j} \tag*{(22)} p : ⨁ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ p : q ! ℓ j ⟨ B j ⟩ 1 p : T p , j ′ (22)
by [CT-OUT] and, as we require a non-empty index-set K ≠ ∅ K \ne\varnothing K = ∅ for branching to be well-formed, the shape of T q = & k ∈ K p k ? ℓ k ( B k ) . T q , k ′ T_q = \mathbin{\&}_{k\in K}p_k?\ell_k(B_k).T'_{q,k} T q = & k ∈ K p k ? ℓ k ( B k ) . T q , k ′ from Equation (4) must include some label ℓ k \ell_k ℓ k , and thus a transition by [CT-IN] is enabled:
q : T q → q : p ? ℓ k ( B k ) 1 q : T q , k ′ (23) q : T_q \xrightarrow{q:p?\ell_k(B_k)}_{1} q : T'_{q,k} \tag*{(23)} q : T q q : p ? ℓ k ( B k ) 1 q : T q , k ′ (23)
by [CT-IN]
With both an output action from p p p to q q q and an input action at q q q from p p p enabled, safety (Def. 3.12) gives j ∈ K j \in K j ∈ K , so [CT-IN] fires at ℓ j \ell_j ℓ j :
q : T q → q : p ? ℓ j ( B j ) 1 q : T q , j ′ (24) q : T_q \xrightarrow{q:p?\ell_j(B_j)}_{1} q : T'_{q,j} \tag*{(24)} q : T q q : p ? ℓ j ( B j ) 1 q : T q , j ′ (24)
by [CT-IN]
giving derivation:
p : ⨁ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ → p : q ! ℓ j ⟨ B j ⟩ 1 p : T p , j ′ q : T q → q : p ? ℓ j ( B j ) 1 q : T q , j ′ p : ⨁ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ , q : T q → ( p , q ) ℓ j 1 p : T p , j ′ , q : T q , j ′ p : ⨁ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ , q : T q , Δ ′ → ( p , q ) ℓ j 1 p : T p , j ′ , q : T q , j ′ , Δ ′ (25) \frac{
\frac{
p : \bigoplus1:q!\ell_j\langle B\rangle.T'_{p,j}
\xrightarrow{p:q!\ell_j\langle B_j\rangle}_{1} p : T'_{p,j}
\quad
q : T_q \xrightarrow{q:p?\ell_j(B_j)}_{1} q : T'_{q,j}
}{p : \bigoplus1:q!\ell_j\langle B\rangle.T'_{p,j}, q : T_q \xrightarrow{(p,q)\ell_j}_{1} p : T'_{p,j}, q : T'_{q,j}}
}{p : \bigoplus1:q!\ell_j\langle B\rangle.T'_{p,j}, q : T_q,\Delta' \xrightarrow{(p,q)\ell_j}_{1} p : T'_{p,j}, q : T'_{q,j},\Delta'} \tag*{(25)} p : ⨁ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ , q : T q , Δ ′ ( p , q ) ℓ j 1 p : T p , j ′ , q : T q , j ′ , Δ ′ p : ⨁ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ , q : T q ( p , q ) ℓ j 1 p : T p , j ′ , q : T q , j ′ p : ⨁ 1 : q ! ℓ j ⟨ B ⟩ . T p , j ′ p : q ! ℓ j ⟨ B j ⟩ 1 p : T p , j ′ q : T q q : p ? ℓ j ( B j ) 1 q : T q , j ′ (25)
Again, as safety propagates we have safe ( Δ ′ , p : T p , j ′ , q : T q , j ′ ) \operatorname{safe}(\Delta', p : T'_{p,j}, q : T'_{q,j}) safe ( Δ ′ , p : T p , j ′ , q : T q , j ′ ) by Def. 3.12. The types T p , j ′ T'_{p,j} T p , j ′ and T q , j ′ T'_{q,j} T q , j ′ can be used to type the continuations of p p p and q q q :
⊢ P : T p , j ′ \vdash P : T'_{p,j} ⊢ P : T p , j ′ : since from Equation (5) we have ⊢ P : T p , j \vdash P : T_{p,j} ⊢ P : T p , j with T p , j ≤ T p , j ′ T_{p,j} \leq T'_{p,j} T p , j ≤ T p , j ′ , thus by subtyping:
⊢ P : T p , j T p , j ≤ T p , j ′ ⊢ P : T p , j ′ (26) \frac{\vdash P : T_{p,j}\quad T_{p,j}\leq T'_{p,j}}{\vdash P : T'_{p,j}} \tag*{(26)} ⊢ P : T p , j ′ ⊢ P : T p , j T p , j ≤ T p , j ′ (26)
by [T-SUB]
⊢ Q j { v / x j } : T q , j ′ \vdash Q_j\{v/x_j\} : T'_{q,j} ⊢ Q j { v / x j } : T q , j ′ : since from Equation (4) we have x j : B j ⊢ Q j : T q , j x_j : B_j \vdash Q_j : T_{q,j} x j : B j ⊢ Q j : T q , j with T q , j ≤ T q , j ′ T_{q,j} \leq T'_{q,j} T q , j ≤ T q , j ′ , thus by subtyping:
x j : B j ⊢ Q j : T q , j T q , j ≤ T q , j ′ x j : B j ⊢ Q j : T q , j ′ (27) \frac{x_j : B_j \vdash Q_j : T_{q,j}\quad T_{q,j}\leq T'_{q,j}}{x_j : B_j \vdash Q_j : T'_{q,j}} \tag*{(27)} x j : B j ⊢ Q j : T q , j ′ x j : B j ⊢ Q j : T q , j T q , j ≤ T q , j ′ (27)
by [T-SUB]
and since e ↓ v e \downarrow v e ↓ v with ⊢ v : B j \vdash v : B_j ⊢ v : B j we can apply Lemma C.3 to get ⊢ Q j { v / x j } : T q , j ′ \vdash Q_j\{v/x_j\} : T'_{q,j} ⊢ Q j { v / x j } : T q , j ′ . Thus we can use this Δ 1 = Δ ′ , p : T p , j ′ , q : T q , j ′ \Delta_1 = \Delta', p : T'_{p,j}, q : T'_{q,j} Δ 1 = Δ ′ , p : T p , j ′ , q : T q , j ′ to type M 1 M_1 M 1 :
∀ r ∈ Δ ′ : Γ ⊢ P r : T r ⊢ P : T p , j ′ ⊢ Q j : T q , j ′ safe ( Δ 1 ) ⊢ M 1 : Δ 1 (28) \frac{\forall r \in\Delta' : \Gamma\vdash P_r : T_r \quad\vdash P : T'_{p,j} \quad\vdash Q_j : T'_{q,j} \quad\operatorname{safe}(\Delta_1)}{\vdash M_1 : \Delta_1} \tag*{(28)} ⊢ M 1 : Δ 1 ∀ r ∈ Δ ′ : Γ ⊢ P r : T r ⊢ P : T p , j ′ ⊢ Q j : T q , j ′ safe ( Δ 1 ) (28)
by [B-SESS]
M = p ◃ if e then P 1 else P 2 ∣ M ′ (29) M = \mathbf{p} \triangleleft\text{if } e \text{ then } P_{1} \text{ else } P_{2} \mid M' \tag*{(29)} M = p ◃ if e then P 1 else P 2 ∣ M ′ (29)
M 1 = p ◃ P 1 ∣ M ′ (30) M_{1} = \mathbf{p} \triangleleft P_{1} \mid M' \tag*{(30)} M 1 = p ◃ P 1 ∣ M ′ (30)
As M → 1 M 1 M \to_{1} M_{1} M → 1 M 1 we will show ⊢ M 1 : Δ \vdash M_{1} : \Delta ⊢ M 1 : Δ . Let Δ = p : T , Δ ′ \Delta= \mathbf{p} : T, \Delta' Δ = p : T , Δ ′ , then by case (6) of type inversion (Thm. C.5):
⊢ if e then P 1 else P 2 : T safe ( Δ ) ∀ ( r : T r ) ∈ Δ ′ : ⊢ P r : T r ⊢ M : Δ (31) \frac{\vdash\text{if } e \text{ then } P_{1} \text{ else } P_{2} : T \quad\operatorname{safe}(\Delta) \quad\forall(r : T_{r}) \in\Delta' : \vdash P_{r} : T_{r}}{\vdash M : \Delta} \tag*{(31)} ⊢ M : Δ ⊢ if e then P 1 else P 2 : T safe ( Δ ) ∀ ( r : T r ) ∈ Δ ′ :⊢ P r : T r (31)
Next we apply case (5) of type inversion (Thm. C.5) to recover the typing of p \mathbf{p} p :
∅ ⊢ e : bool ∅ ⊢ P 1 : T ′ ∅ ⊢ P 2 : T ′ ∅ ⊢ if e then P 1 else P 2 : T ′ T ′ ≤ T ∅ ⊢ if e then P 1 else P 2 : T (32) \frac{\frac{\varnothing\vdash e : \operatorname{bool} \quad\varnothing\vdash P_{1} : T' \quad\varnothing\vdash P_{2} : T'}{\varnothing\vdash\text{if } e \text{ then } P_{1} \text{ else } P_{2} : T'} \quad T' \leq T}{\varnothing\vdash\text{if } e \text{ then } P_{1} \text{ else } P_{2} : T} \tag*{(32)} ∅ ⊢ if e then P 1 else P 2 : T ∅ ⊢ if e then P 1 else P 2 : T ′ ∅ ⊢ e : bool ∅ ⊢ P 1 : T ′ ∅ ⊢ P 2 : T ′ T ′ ≤ T (32)
as Γ ⊢ P 1 : T ′ \Gamma\vdash P_{1} : T' Γ ⊢ P 1 : T ′ with T ′ ≤ T T' \leq T T ′ ≤ T it’s easy to see that Γ ⊢ P 1 : T \Gamma\vdash P_{1} : T Γ ⊢ P 1 : T by [T-SUB] and thus:
∅ ⊢ P 1 : T ∀ ( r : T r ) ∈ Δ ′ : ∅ ⊢ P r : T r safe ( Δ ) ⊢ M 1 : Δ (33) \frac{\varnothing\vdash P_{1} : T \quad\forall(r : T_{r}) \in\Delta' : \varnothing\vdash P_{r} : T_{r} \quad\operatorname{safe}(\Delta)}{\vdash M_{1} : \Delta} \tag*{(33)} ⊢ M 1 : Δ ∅ ⊢ P 1 : T ∀ ( r : T r ) ∈ Δ ′ : ∅ ⊢ P r : T r safe ( Δ ) (33)
First we invert [R-SC] to get ∃ M ′ , M ′ ′ \exists M', M'' ∃ M ′ , M ′′ s.t:
M ⇒ M ′ M ′ → p M ′ ′ M ′ ′ ⇒ M 1 M → p M 1 (34) \frac{M \Rightarrow M' \quad M' \to_{p} M'' \quad M'' \Rightarrow M_{1}}{M \to_{p} M_{1}} \tag*{(34)} M → p M 1 M ⇒ M ′ M ′ → p M ′′ M ′′ ⇒ M 1 (34)
Since ⊢ M : Δ \vdash M : \Delta ⊢ M : Δ and M ⇒ M ′ M \Rightarrow M' M ⇒ M ′ we can apply Lemma C.4 to get:
⊢ M ′ : Δ (35) \vdash M' : \Delta \tag*{(35)} ⊢ M ′ : Δ (35)
The remainder of this case depends on the top-level rule used to derive M ′ → p M ′ ′ M' \to_{p} M'' M ′ → p M ′′ :
– by [R-T-IF], [R-F-IF]:
Since ⊢ M ′ : Δ \vdash M' : \Delta ⊢ M ′ : Δ we can apply IH on M ′ → 1 M ′ ′ M' \to_{1} M'' M ′ → 1 M ′′ to get:
⊢ M ′ ′ : Δ (36) \vdash M'' : \Delta \tag*{(36)} ⊢ M ′′ : Δ (36)
Finally, since ⊢ M ′ ′ : Δ \vdash M'' : \Delta ⊢ M ′′ : Δ and M ′ ′ ⇒ M 1 M'' \Rightarrow M_{1} M ′′ ⇒ M 1 we can apply Lemma C.4 to get:
⊢ M 1 : Δ (37) \vdash M_{1} : \Delta \tag*{(37)} ⊢ M 1 : Δ (37)
And the statement holds by case (1)
– by [R-COMM]:
Since ⊢ M ′ : Δ \vdash M' : \Delta ⊢ M ′ : Δ we can apply IH on M ′ → p M ′ ′ M' \to_{p} M'' M ′ → p M ′′ to get:
∃ Δ ′ , Δ 1 : Δ → n Δ ′ → 1 Δ 1 (or ∃ Δ 1 : Δ → 1 Δ 1 ) (38) \exists\Delta', \Delta_{1} : \Delta\to_{n} \Delta' \to_{1} \Delta_{1} \quad\text{(or } \exists\Delta_{1} : \Delta\to_{1} \Delta_{1}\text{)} \tag*{(38)} ∃ Δ ′ , Δ 1 : Δ → n Δ ′ → 1 Δ 1 (or ∃ Δ 1 : Δ → 1 Δ 1 ) (38)
with ⊢ M ′ ′ : Δ 1 \vdash M'' : \Delta_{1} ⊢ M ′′ : Δ 1
⊢ M ′ ′ : Δ 1 (39) \vdash M'' : \Delta_{1} \tag*{(39)} ⊢ M ′′ : Δ 1 (39)
finally by the subject precongruence Lemma C.4: ⊢ M 1 : Δ 1 \vdash M_{1} : \Delta_{1} ⊢ M 1 : Δ 1 . And the statement holds by case (2) – by [R-HEAD], [R-TAIL]: Since ⊢ M ′ : Δ \vdash M' : \Delta ⊢ M ′ : Δ we can apply IH on M ′ → p M ′ ′ M' \xrightarrow{p} M'' M ′ p M ′′ to get:
∃ p , M 2 , T 1 , T 2 , Δ ′ : Δ = p : T , Δ ′ (40) \exists p, M_2, T_1, T_2, \Delta' : \Delta= p : T, \Delta' \tag*{(40)} ∃ p , M 2 , T 1 , T 2 , Δ ′ : Δ = p : T , Δ ′ (40)
M ′ → 1 − p M 2 (41) M' \xrightarrow{1-p} M_2 \tag*{(41)} M ′ 1 − p M 2 (41)
⊢ M ′ ′ : ( p : T 1 , Δ ′ ) (42) \vdash M'' : (p : T_1, \Delta') \tag*{(42)} ⊢ M ′′ : ( p : T 1 , Δ ′ ) (42)
⊢ M 2 : ( p : T 2 , Δ ′ ) (43) \vdash M_2 : (p : T_2, \Delta') \tag*{(43)} ⊢ M 2 : ( p : T 2 , Δ ′ ) (43)
p : T 1 ⊓ p T 2 , Δ ′ ≤ Δ (44) p : T_1 \sqcap_p T_2, \Delta' \leq\Delta \tag*{(44)} p : T 1 ⊓ p T 2 , Δ ′ ≤ Δ (44)
Finally, we apply Lemma C.4 to get: ⊢ M 1 : ( p : T 1 , Δ ′ ) \vdash M_1 : (p : T_1, \Delta') ⊢ M 1 : ( p : T 1 , Δ ′ ) And the statement holds by case (3)
Remark C.1 (Path conventions for Lemma C.6 and Thm. C.7). We distinguish between the head and tail outcomes of a flip even when their targets coincide; structural unfolding does not create distinct paths. Path endpoints are read up to head unfolding, including for the empty path, whose weight is 1 1 1 .
Lemma C.6 (Process Inversion). Let ⊢ P : T \vdash P : T ⊢ P : T .
(1) If unf ( T ) = ⨁ i ∈ I ⨁ j ∈ J i p i , j : q j ! ℓ j ⟨ B j ⟩ . T i , j \operatorname{unf}(T) = \bigoplus_{i \in I} \bigoplus_{j \in J_i} p_{i,j} : q_j!\ell_j\langle B_j\rangle.T_{i,j} unf ( T ) = ⨁ i ∈ I ⨁ j ∈ J i p i , j : q j ! ℓ j ⟨ B j ⟩ . T i , j , then there exists i ∈ I i \in I i ∈ I such that, for every j ∈ J i j \in J_i j ∈ J i , letting
R_j = \left\{r \mathrel{\left|} p \triangleleft P \xrightarrow{p_r}^{*} p \triangleleft q_j!\ell_j\langle e_r\rangle.Q_r \right.\right\},
we have
(a) ∑ r ∈ R j p r = p i , j \sum_{r \in R_j} p_r = p_{i,j} ∑ r ∈ R j p r = p i , j ;
(b) ⊢ e r : B j \vdash e_r : B_j ⊢ e r : B j and ⊢ Q r : T i , j \vdash Q_r : T_{i,j} ⊢ Q r : T i , j for every r ∈ R j r \in R_j r ∈ R j .
(2) If unf ( T ) = & i ∈ I q i ? ℓ i ( B i ) . T i \operatorname{unf}(T) = \&_{i \in I} q_i?\ell_i(B_i).T_i unf ( T ) = & i ∈ I q i ? ℓ i ( B i ) . T i , let
R = \left\{r \mathrel{\left|} p \triangleleft P \xrightarrow{p_r}^{*} p \triangleleft\sum_{j \in J_r} q_j?\ell_j(x_{j,r}).Q_{j,r},\ J_r \supseteq I \right.\right\}.
Then
(a) ∑ r ∈ R p r = 1 \sum_{r \in R} p_r = 1 ∑ r ∈ R p r = 1 ;
(b) x i , r : B i ⊢ Q i , r : T i x_{i,r} : B_i \vdash Q_{i,r} : T_i x i , r : B i ⊢ Q i , r : T i for every i ∈ I i \in I i ∈ I and r ∈ R r \in R r ∈ R .
(3) If unf ( T ) = end \operatorname{unf}(T) = \operatorname{end} unf ( T ) = end , let
R = \left\{r \mathrel{\left|} p \triangleleft P \xrightarrow{p_r}^{*} p \triangleleft0 \right.\right\}.
Then ∑ r ∈ R p r = 1 \sum_{r \in R} p_r = 1 ∑ r ∈ R p r = 1 .
Proof. By lexicographic induction on the number of process constructors not beneath an input or output prefix and on the derivation height. The same induction gives finitely many maximal paths, all finite and ending at a send in the chosen J i J_i J i in case (1), a branching offering I I I in case (2), or 0 0 0 in case (3).
(1) unf ( T ) = ⨁ i ∈ I ⨁ j ∈ J i p i , j : q j ! ℓ j ⟨ B j ⟩ . T i , j \operatorname{unf}(T) = \bigoplus_{i \in I} \bigoplus_{j \in J_i} p_{i,j} : q_j!\ell_j\langle B_j\rangle.T_{i,j} unf ( T ) = ⨁ i ∈ I ⨁ j ∈ J i p i , j : q j ! ℓ j ⟨ B j ⟩ . T i , j . We define for each relevant j j j
\Pi_j(P) = \left\{r \mathrel{\left|} p \triangleleft P \xrightarrow{p_r}^{*} p \triangleleft q_j!\ell_j\langle e_r\rangle.Q_r \right.\right\} \tag*{(45)}
the set of reduction paths from p ◃ P p \triangleleft P p ◃ P that lead to a q j ! ℓ j q_j!\ell_j q j ! ℓ j prefixed send, where each r ∈ Π j ( P ) r \in\Pi_j(P) r ∈ Π j ( P ) determines a continuation Q r Q_r Q r , a payload e r e_r e r , and a path probability p r p_r p r .
⊢ e : B ⊢ Q : T ′ ⊢ q ! ℓ ⟨ e ⟩ . Q : ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ \frac{\vdash e : B \qquad\vdash Q : T'}{\vdash q!\ell\langle e\rangle.Q : \bigoplus1:q!\ell\langle B\rangle.T'} ⊢ q ! ℓ ⟨ e ⟩ . Q : ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ ⊢ e : B ⊢ Q : T ′
Here I = J 1 = { 1 } I=J_1=\{1\} I = J 1 = { 1 } up to reindexing; the only maximal path is empty, of weight 1. All claims follow from the premises.
unf ( T ′ ) = ∑ k ∈ K ⨁ j ∈ J k ′ p k , j ′ : q j ! ℓ j ⟨ B j ⟩ . T k , j ′ . \operatorname{unf}(T')=\sum_{k\in K}\bigoplus_{j\in J'_k}p'_{k,j}:q_j!\ell_j\langle B_j\rangle.T'_{k,j}. unf ( T ′ ) = k ∈ K ∑ j ∈ J k ′ ⨁ p k , j ′ : q j ! ℓ j ⟨ B j ⟩ . T k , j ′ .
For the witness k k k given by IH, [SUB-Σ \Sigma Σ ] and [SUB-⨁ \bigoplus ⨁ ] give i ∈ I i\in I i ∈ I with
J k ′ = J i , p k , j ′ = p i , j , T k , j ′ ≤ T i , j ( j ∈ J i ) . J'_k=J_i,\qquad p'_{k,j}=p_{i,j},\qquad T'_{k,j}\leq T_{i,j}\quad(j\in J_i). J k ′ = J i , p k , j ′ = p i , j , T k , j ′ ≤ T i , j ( j ∈ J i ) .
Thus
∑ r ∈ Π j ( P ) p r = p k , j ′ = p i , j , \sum_{r\in\Pi_j(P)}p_r=p'_{k,j}=p_{i,j}, r ∈ Π j ( P ) ∑ p r = p k , j ′ = p i , j ,
and, for every $r\in\Pi_j(P),
⊢ Q r : T k , j ′ T k , j ′ ≤ T i , j ⊢ Q r : T i , j . \frac{\vdash Q_r:T'_{k,j}\qquad T'_{k,j}\leq T_{i,j}}{\vdash Q_r:T_{i,j}}. ⊢ Q r : T i , j ⊢ Q r : T k , j ′ T k , j ′ ≤ T i , j .
Support and payload typing are unchanged.
Case [T-FLIP]. We have P = flip ( p ) { H ⇒ P 1 ∣ ∣ T ⇒ P 2 } P=\operatorname{flip}(p)\{H\Rightarrow P_1\mathbin{||}T\Rightarrow P_2\} P = flip ( p ) { H ⇒ P 1 ∣∣ T ⇒ P 2 } , ⊢ P b : T b \vdash P_b:T_b ⊢ P b : T b for b = 1 , 2 b=1,2 b = 1 , 2 , and T 1 ⊓ p T 2 = T T_1\sqcap_p T_2=T T 1 ⊓ p T 2 = T , where
unf ( T 1 ) = ∑ k ∈ I 1 ⨁ j ∈ J k ′ p k , j ′ : q j ! ℓ j ⟨ B j ⟩ . T k , j ′ , \operatorname{unf}(T_1)=\sum_{k\in I_1}\bigoplus_{j\in J'_k}p'_{k,j}:q_j!\ell_j\langle B_j\rangle.T'_{k,j}, unf ( T 1 ) = k ∈ I 1 ∑ j ∈ J k ′ ⨁ p k , j ′ : q j ! ℓ j ⟨ B j ⟩ . T k , j ′ ,
unf ( T 2 ) = ∑ l ∈ I 2 ⨁ j ∈ J l ′ ′ p l , j ′ ′ : q j ! ℓ j ⟨ B j ⟩ . T l , j ′ ′ . \operatorname{unf}(T_2)=\sum_{l\in I_2}\bigoplus_{j\in J''_l}p''_{l,j}:q_j!\ell_j\langle B_j\rangle.T''_{l,j}. unf ( T 2 ) = l ∈ I 2 ∑ j ∈ J l ′′ ⨁ p l , j ′′ : q j ! ℓ j ⟨ B j ⟩ . T l , j ′′ .
By IH, choose k ∈ I 1 k\in I_1 k ∈ I 1 and l ∈ I 2 l\in I_2 l ∈ I 2 with
∑ r 1 ∈ Π j ( P 1 ) p r 1 = p k , j ′ , ⊢ Q r 1 : T k , j ′ ( j ∈ J k ′ ) , \sum_{r_1\in\Pi_j(P_1)}p_{r_1}=p'_{k,j},\qquad\vdash Q_{r_1}:T'_{k,j}\quad(j\in J'_k), r 1 ∈ Π j ( P 1 ) ∑ p r 1 = p k , j ′ , ⊢ Q r 1 : T k , j ′ ( j ∈ J k ′ ) ,
∑ r 2 ∈ Π j ( P 2 ) p r 2 = p l , j ′ ′ , ⊢ Q r 2 : T l , j ′ ′ ( j ∈ J l ′ ′ ) , \sum_{r_2\in\Pi_j(P_2)}p_{r_2}=p''_{l,j},\qquad\vdash Q_{r_2}:T''_{l,j}\quad(j\in J''_l), r 2 ∈ Π j ( P 2 ) ∑ p r 2 = p l , j ′′ , ⊢ Q r 2 : T l , j ′′ ( j ∈ J l ′′ ) ,
for every corresponding path; outside these supports the path sets are empty. By the merge rules, take i = ( k , l ) i=(k,l) i = ( k , l ) , with J i = J k ′ ∪ J l ′ ′ J_i=J'_k\cup J''_l J i = J k ′ ∪ J l ′′ and
( p i , j , T i , j ) = { ( p ⋅ p k , j ′ , T k , j ′ ) , j ∈ J k ′ ∖ J l ′ ′ , ( p ⋅ p k , j ′ + ( 1 − p ) ⋅ p l , j ′ ′ , T k , j ′ ⊔ T l , j ′ ′ ) , j ∈ J k ′ ∩ J l ′ ′ , ( ( 1 − p ) ⋅ p l , j ′ ′ , T l , j ′ ′ ) , j ∈ J l ′ ′ ∖ J k ′ . (p_{i,j},T_{i,j})=
\begin{cases}
(p\cdot p'_{k,j},T'_{k,j}), & j\in J'_k\setminus J''_l,\\
(p\cdot p'_{k,j}+(1-p)\cdot p''_{l,j},T'_{k,j}\sqcup T''_{l,j}), & j\in J'_k\cap J''_l,\\
((1-p)\cdot p''_{l,j},T''_{l,j}), & j\in J''_l\setminus J'_k.
\end{cases} ( p i , j , T i , j ) = ⎩ ⎨ ⎧ ( p ⋅ p k , j ′ , T k , j ′ ) , ( p ⋅ p k , j ′ + ( 1 − p ) ⋅ p l , j ′′ , T k , j ′ ⊔ T l , j ′′ ) , (( 1 − p ) ⋅ p l , j ′′ , T l , j ′′ ) , j ∈ J k ′ ∖ J l ′′ , j ∈ J k ′ ∩ J l ′′ , j ∈ J l ′′ ∖ J k ′ .
Splitting paths by their first flip outcome gives
∑ r ∈ Π j ( P ) p r = p ∑ r 1 ∈ Π j ( P 1 ) p r 1 + ( 1 − p ) ∑ r 2 ∈ Π j ( P 2 ) p r 2 = p i , j . \sum_{r\in\Pi_j(P)}p_r
=p\sum_{r_1\in\Pi_j(P_1)}p_{r_1}
+(1-p)\sum_{r_2\in\Pi_j(P_2)}p_{r_2}
=p_{i,j}. r ∈ Π j ( P ) ∑ p r = p r 1 ∈ Π j ( P 1 ) ∑ p r 1 + ( 1 − p ) r 2 ∈ Π j ( P 2 ) ∑ p r 2 = p i , j .
Moreover,
T k , j ′ ≤ T i , j ( j ∈ J k ′ ) , T l , j ′ ′ ≤ T i , j ( j ∈ J l ′ ′ ) , T'_{k,j}\leq T_{i,j}\quad(j\in J'_k),\qquad
T''_{l,j}\leq T_{i,j}\quad(j\in J''_l), T k , j ′ ≤ T i , j ( j ∈ J k ′ ) , T l , j ′′ ≤ T i , j ( j ∈ J l ′′ ) ,
so ⊢ Q r : T i , j \vdash Q_r:T_{i,j} ⊢ Q r : T i , j by IH and [T-SUB]. Payload typing follows from IH, and every maximal path ends at a send in J i J_i J i .
Case [T-COND]. For P = if e then P 1 else P 2 P=\operatorname{if} e\operatorname{ then} P_1\operatorname{ else} P_2 P = if e then P 1 else P 2 , the closed guard selects P b P_b P b with probability 1 by [R-T-IF] or [R-F-IF]. Prefixing this step preserves path weights and endpoints; apply IH to ⊢ P b : T \vdash P_b:T ⊢ P b : T .
⊢ P ′ { μ X . P ′ / X } : T . \vdash P'\{\mu X.P'/X\} : T. ⊢ P ′ { μ X . P ′ / X } : T .
Guardedness makes the first induction component strictly smaller after unfolding. Apply IH and the weight-preserving correspondence of paths under head unfolding.
(2) unf ( T ) = & i ∈ I q i ? ℓ i ( B i ) . T i \operatorname{unf}(T) = \&_{i\in I}\,q_i?\ell_i(B_i).T_i unf ( T ) = & i ∈ I q i ? ℓ i ( B i ) . T i . Write Π \Pi Π for the path set in the statement.
P = ∑ i ∈ I q i ? ℓ i ( x i ) . Q i , x i : B i ⊢ Q i : T i ( i ∈ I ) . P = \sum_{i\in I}q_i?\ell_i(x_i).Q_i,\qquad x_i : B_i \vdash Q_i : T_i\quad(i\in I). P = i ∈ I ∑ q i ? ℓ i ( x i ) . Q i , x i : B i ⊢ Q i : T i ( i ∈ I ) .
The only maximal path is empty, of weight 1 1 1 .
Case [T-SUB]. We have ⊢ P : T ′ \vdash P : T' ⊢ P : T ′ , T ′ ≤ T T' \leq T T ′ ≤ T , and, by [SUB-&],
unf ( T ′ ) = & k ∈ K q k ? ℓ k ( B k ) . T k ′ , K ⊇ I , T i ′ ≤ T i ( i ∈ I ) . \operatorname{unf}(T') = \&_{k\in K}q_k?\ell_k(B_k).T'_k,\qquad K \supseteq I,\qquad T'_i \leq T_i\quad(i\in I). unf ( T ′ ) = & k ∈ K q k ? ℓ k ( B k ) . T k ′ , K ⊇ I , T i ′ ≤ T i ( i ∈ I ) .
By IH, every maximal path offers K K K , so the path set for K K K is exactly Π \Pi Π . Hence
∑ r ∈ Π p r = 1 , x i , r : B i ⊢ Q i , r : T i ′ T i ′ ≤ T i x i , r : B i ⊢ Q i , r : T i ( i ∈ I , r ∈ Π ) . \sum_{r\in\Pi}p_r = 1,\qquad
\frac{x_{i,r}:B_i\vdash Q_{i,r}:T'_i\quad T'_i\leq T_i}{x_{i,r}:B_i\vdash Q_{i,r}:T_i}\quad(i\in I,\ r\in\Pi). r ∈ Π ∑ p r = 1 , x i , r : B i ⊢ Q i , r : T i x i , r : B i ⊢ Q i , r : T i ′ T i ′ ≤ T i ( i ∈ I , r ∈ Π ) .
Case [T-FLIP]. We have P = flip ( p ) { h ⇒ P 1 ∥ t ⇒ P 2 } P = \operatorname{flip}(p)\{h\Rightarrow P_1\mathbin{\Vert}t\Rightarrow P_2\} P = flip ( p ) { h ⇒ P 1 ∥ t ⇒ P 2 } , ⊢ P b : T b \vdash P_b:T_b ⊢ P b : T b for b = 1 , 2 b=1,2 b = 1 , 2 , and T 1 ⊓ p T 2 = T T_1\sqcap_p T_2=T T 1 ⊓ p T 2 = T . By [M-&],
unf ( T 1 ) = & k ∈ I 1 q k ? ℓ k ( B k ) . T k ′ , unf ( T 2 ) = & l ∈ I 2 q l ? ℓ l ( B l ) . T l ′ ′ , I = { i ∈ I 1 ∩ I 2 ∣ T i ′ ⊔ T i ′ ′ is defined } , T i = T i ′ ⊔ T i ′ ′ . \begin{aligned}
\operatorname{unf}(T_1)&=\&_{k\in I_1}q_k?\ell_k(B_k).T'_k,\\
\operatorname{unf}(T_2)&=\&_{l\in I_2}q_l?\ell_l(B_l).T''_l,\\
I&=\{i\in I_1\cap I_2\mid T'_i\sqcup T''_i\text{ is defined}\},\qquad
T_i=T'_i\sqcup T''_i.
\end{aligned} unf ( T 1 ) unf ( T 2 ) I = & k ∈ I 1 q k ? ℓ k ( B k ) . T k ′ , = & l ∈ I 2 q l ? ℓ l ( B l ) . T l ′′ , = { i ∈ I 1 ∩ I 2 ∣ T i ′ ⊔ T i ′′ is defined } , T i = T i ′ ⊔ T i ′′ .
Let Π b \Pi_b Π b be the path set from IH for P b P_b P b . Every maximal path of P b P_b P b offers I b ⊇ I I_b\supseteq I I b ⊇ I ; splitting Π \Pi Π by its first flip outcome gives
∑ r ∈ Π p r = p ∑ r 1 ∈ Π 1 p r 1 + ( 1 − p ) ∑ r 2 ∈ Π 2 p r 2 = p + ( 1 − p ) = 1. \sum_{r\in\Pi}p_r
=p\sum_{r_1\in\Pi_1}p_{r_1}+(1-p)\sum_{r_2\in\Pi_2}p_{r_2}
=p+(1-p)=1. r ∈ Π ∑ p r = p r 1 ∈ Π 1 ∑ p r 1 + ( 1 − p ) r 2 ∈ Π 2 ∑ p r 2 = p + ( 1 − p ) = 1.
For every i ∈ I i\in I i ∈ I ,
T i ′ ≤ T i ′ ⊔ T i ′ ′ = T i , T i ′ ′ ≤ T i ′ ⊔ T i ′ ′ = T i . T'_i\leq T'_i\sqcup T''_i=T_i,\qquad
T''_i\leq T'_i\sqcup T''_i=T_i. T i ′ ≤ T i ′ ⊔ T i ′′ = T i , T i ′′ ≤ T i ′ ⊔ T i ′′ = T i .
Thus x i , r : B i ⊢ Q i , r : T i x_{i,r}:B_i\vdash Q_{i,r}:T_i x i , r : B i ⊢ Q i , r : T i on either kind of path, by IH and [T-SUB].
(3) unf ( T ) = end \operatorname{unf}(T)=\operatorname{end} unf ( T ) = end . Write Π end ( P ) \Pi_{\operatorname{end}}(P) Π end ( P ) for the path set in the statement.
Case [T-FLIP]. We have P = flip ( p ) { h ⇒ P 1 ∥ t ⇒ P 2 } P=\operatorname{flip}(p)\{h\Rightarrow P_1\mathbin{\Vert}t\Rightarrow P_2\} P = flip ( p ) { h ⇒ P 1 ∥ t ⇒ P 2 } , ⊢ P b : T b \vdash P_b:T_b ⊢ P b : T b for b = 1 , 2 b=1,2 b = 1 , 2 , and unf ( T 1 ) = unf ( T 2 ) = end \operatorname{unf}(T_1)=\operatorname{unf}(T_2)=\operatorname{end} unf ( T 1 ) = unf ( T 2 ) = end by [M-END]. By IH, every maximal path ends at 0 0 0 , and
∑ r ∈ Π end ( P ) p r = p ∑ r 1 ∈ Π end ( P 1 ) p r 1 + ( 1 − p ) ∑ r 2 ∈ Π end ( P 2 ) p r 2 = p + ( 1 − p ) = 1. \sum_{r\in\Pi_{\operatorname{end}}(P)}p_r
=p\sum_{r_1\in\Pi_{\operatorname{end}}(P_1)}p_{r_1}
+(1-p)\sum_{r_2\in\Pi_{\operatorname{end}}(P_2)}p_{r_2}
=p+(1-p)=1. r ∈ Π end ( P ) ∑ p r = p r 1 ∈ Π end ( P 1 ) ∑ p r 1 + ( 1 − p ) r 2 ∈ Π end ( P 2 ) ∑ p r 2 = p + ( 1 − p ) = 1.
Theorem C.7 (Session Fidelity full). Let ⊢ M : Δ \vdash M:\Delta ⊢ M : Δ , writing M = p ◃ P ∣ q ◃ Q ∣ M ′ M=p\triangleleft P\mid q\triangleleft Q\mid M' M = p ◃ P ∣ q ◃ Q ∣ M ′ in (1) and M = p ◃ P ∣ M ′ M=p\triangleleft P\mid M' M = p ◃ P ∣ M ′ in (2–3).
(1) If Δ = p : T p , q : T q , Δ ′ \Delta= p : T_p, q : T_q, \Delta' Δ = p : T p , q : T q , Δ ′ and Δ → ( p , q ) ℓ 1 p : T p ′ , q : T q ′ , Δ ′ \Delta\xrightarrow{(p,q)\ell}_1 p : T'_p, q : T'_q, \Delta' Δ ( p , q ) ℓ 1 p : T p ′ , q : T q ′ , Δ ′ , then there exist path sets R p , R q R_p, R_q R p , R q and corresponding processes P r , Q r ′ P_r, Q_{r'} P r , Q r ′ and sessions M r , r ′ M_{r,r'} M r , r ′ such that
(a) For every ( r , r ′ ) ∈ R p × R q (r,r') \in R_p \times R_q ( r , r ′ ) ∈ R p × R q , p ◃ P → r p , r ′ p ◃ P r p \triangleleft P \xrightarrow{r}_{p,r'} p \triangleleft P_r p ◃ P r p , r ′ p ◃ P r and q ◃ Q → r ′ p , r ′ q ◃ Q r ′ q \triangleleft Q \xrightarrow{r'}_{p,r'} q \triangleleft Q_{r'} q ◃ Q r ′ p , r ′ q ◃ Q r ′ , with p ◃ P r ∣ q ◃ Q r ′ ∣ M ′ → ( p , q ) ℓ 1 M r , r ′ p \triangleleft P_r \mid q \triangleleft Q_{r'} \mid M' \xrightarrow{(p,q)\ell}_1 M_{r,r'} p ◃ P r ∣ q ◃ Q r ′ ∣ M ′ ( p , q ) ℓ 1 M r , r ′ and ⊢ M r , r ′ : p : T p ′ , q : T q ′ , Δ ′ \vdash M_{r,r'} : p : T'_p, q : T'_{q}, \Delta' ⊢ M r , r ′ : p : T p ′ , q : T q ′ , Δ ′ ;
(b) ∑ r ∈ R p p r = ∑ r ′ ∈ R q p r ′ ′ = 1 \sum_{r\in R_p} p_r = \sum_{r'\in R_q} p_{r'}' = 1 ∑ r ∈ R p p r = ∑ r ′ ∈ R q p r ′ ′ = 1 .
(2) If Δ = p : T , Δ ′ \Delta= p : T, \Delta' Δ = p : T , Δ ′ and p : T → p : T n p : T ′ p : T \xrightarrow{p:T}_n p : T' p : T p : T n p : T ′ , then:
(a) If ∄ P ′ , p ′ : M ⟶ p ′ ( p ◃ P ′ ∣ M ′ ) \nexists P', p' : M \longrightarrow_{p'} (p \triangleleft P' \mid M') ∄ P ′ , p ′ : M ⟶ p ′ ( p ◃ P ′ ∣ M ′ ) , there exists T ′ T' T ′ such that p : T → p : T n p : T ′ p : T \xrightarrow{p:T}_n p : T' p : T p : T n p : T ′ and ⊢ M : p : T ′ , Δ ′ \vdash M : p : T', \Delta' ⊢ M : p : T ′ , Δ ′ ;
(b) Otherwise, there exist R R R , { ( P r , T r ) } r ∈ R \{(P_r, T_r)\}_{r\in R} {( P r , T r ) } r ∈ R , and T ′ T' T ′ such that (i) for every r ∈ R r \in R r ∈ R , p ◃ P → P r p , r p ◃ P r p \triangleleft P \xrightarrow{P_r}_{p,r} p \triangleleft P_r p ◃ P P r p , r p ◃ P r , with p ◃ P r ↛ p \triangleleft P_r \not\to p ◃ P r → and ⊢ p ◃ P r ∣ M ′ : p : T r , Δ ′ \vdash p \triangleleft P_r \mid M' : p : T_r, \Delta' ⊢ p ◃ P r ∣ M ′ : p : T r , Δ ′ ; (ii) ∑ r ∈ R p r = 1 \sum_{r\in R} p_r = 1 ∑ r ∈ R p r = 1 ; (iii) p : T → p : T n p : T ′ p : T \xrightarrow{p:T}_n p : T' p : T p : T n p : T ′ ; (iv) \bigsqcap_{r\in R}(T_r,p_r) \leq T' .
(3) If Δ = p : T , Δ ′ \Delta= p : T, \Delta' Δ = p : T , Δ ′ and p : T → p : T p p : ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ p : T \xrightarrow{p:T}_p p : \bigoplus1 : q!\ell\langle B\rangle.T' p : T p : T p p : ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ , then there exist R R R and { ( e r , P r ) } r ∈ R \{(e_r,P_r)\}_{r\in R} {( e r , P r ) } r ∈ R such that
(a) for every r ∈ R r \in R r ∈ R , p ◃ P → P r p , r p ◃ q ! ℓ ⟨ e r ⟩ . P r p \triangleleft P \xrightarrow{P_r}_{p,r} p \triangleleft q!\ell\langle e_r\rangle.P_r p ◃ P P r p , r p ◃ q ! ℓ ⟨ e r ⟩ . P r , with ⊢ p ◃ q ! ℓ ⟨ e r ⟩ . P r ∣ M ′ : p : ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ , Δ ′ \vdash p \triangleleft q!\ell\langle e_r\rangle.P_r \mid M' : p : \bigoplus1 : q!\ell\langle B\rangle.T', \Delta' ⊢ p ◃ q ! ℓ ⟨ e r ⟩ . P r ∣ M ′ : p : ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ , Δ ′ ;
(b) ∑ r ∈ R p r = p \sum_{r\in R} p_r = p ∑ r ∈ R p r = p .
Proof. By induction on the context-transition derivation, carrying an arbitrary unchanged context and its session components as a frame. By [b-sess],
safe ( Δ ) , ⊢ M ( r ) : Δ ( r ) ( r ∈ dom ( Δ ) ) . \operatorname{safe}(\Delta), \qquad\vdash M(r) : \Delta(r) \quad(r \in\operatorname{dom}(\Delta)). safe ( Δ ) , ⊢ M ( r ) : Δ ( r ) ( r ∈ dom ( Δ )) .
unf ( T p ) = ⨁ 1 : q ! ℓ k ⟨ B k ⟩ . T p ′ , \operatorname{unf}(T_p) = \bigoplus1 : q!\ell_k\langle B_k\rangle.T'_p, unf ( T p ) = ⨁ 1 : q ! ℓ k ⟨ B k ⟩ . T p ′ ,
unf ( T q ) = & i ∈ I q i ? ℓ i ( B i ) . T q , i ′ , \operatorname{unf}(T_q) = \mathbin{\&}_{i\in I} q_i?\ell_i(B_i).T'_{q,i}, unf ( T q ) = & i ∈ I q i ? ℓ i ( B i ) . T q , i ′ ,
k ∈ I , q k = p , ℓ = ℓ k , T q ′ = T q , k ′ . k \in I,\quad q_k = p,\quad\ell= \ell_k,\quad T'_q = T'_{q,k}. k ∈ I , q k = p , ℓ = ℓ k , T q ′ = T q , k ′ .
By Lemma C.6 , there are path sets R p , R q R_p, R_q R p , R q with
p ◃ P → P r p , r p ◃ P r , P r = q ! ℓ k ⟨ e r ⟩ . P r ′ , p \triangleleft P \xrightarrow{P_r}_{p,r} p \triangleleft P_r,\qquad P_r = q!\ell_k\langle e_r\rangle.P'_r, p ◃ P P r p , r p ◃ P r , P r = q ! ℓ k ⟨ e r ⟩ . P r ′ ,
q ◃ Q → Q r ′ p , r ′ q ◃ Q r ′ , Q r ′ = ∑ l ∈ L r ′ q l ? ℓ l ( x l , r ′ ) . Q l , r ′ , L r ′ ⊇ I , q \triangleleft Q \xrightarrow{Q_{r'}}_{p,r'} q \triangleleft Q_{r'},\qquad Q_{r'} = \sum_{l\in L_{r'}} q_l?\ell_l(x_{l,r'}).Q_{l,r'},\qquad L_{r'} \supseteq I, q ◃ Q Q r ′ p , r ′ q ◃ Q r ′ , Q r ′ = l ∈ L r ′ ∑ q l ? ℓ l ( x l , r ′ ) . Q l , r ′ , L r ′ ⊇ I ,
∑ r ∈ R p p r = ∑ r ′ ∈ R q p r ′ ′ = 1 , \sum_{r\in R_p} p_r = \sum_{r'\in R_q} p'_{r'} = 1, r ∈ R p ∑ p r = r ′ ∈ R q ∑ p r ′ ′ = 1 ,
⊢ e r : B k , ⊢ P r ′ : T p ′ , x k , r ′ : B k ⊢ Q k , r ′ : T q , k ′ . \vdash e_r : B_k,\qquad\vdash P'_r : T'_p,\qquad x_{k,r'} : B_k \vdash Q_{k,r'} : T'_{q,k}. ⊢ e r : B k , ⊢ P r ′ : T p ′ , x k , r ′ : B k ⊢ Q k , r ′ : T q , k ′ .
For each ( r , r ′ ) ∈ R p × R q (r,r') \in R_p \times R_q ( r , r ′ ) ∈ R p × R q , evaluation and Lemma C.3 give
e r ↓ v r , ⊢ v r : B k , ⊢ Q k , r ′ { v r / x k , r ′ } : T q , k ′ . e_r \downarrow v_r,\qquad\vdash v_r : B_k,\qquad\vdash Q_{k,r'}\{v_r/x_{k,r'}\} : T'_{q,k}. e r ↓ v r , ⊢ v r : B k , ⊢ Q k , r ′ { v r / x k , r ′ } : T q , k ′ .
Hence, by [r-comm],
p ◃ P r ∣ q ◃ Q r ′ ∣ M ′ → ( p , q ) ℓ k 1 M r , r ′ , p \triangleleft P_r \mid q \triangleleft Q_{r'} \mid M' \xrightarrow{(p,q)\ell_k}_1 M_{r,r'}, p ◃ P r ∣ q ◃ Q r ′ ∣ M ′ ( p , q ) ℓ k 1 M r , r ′ ,
M r , r ′ : = p ◃ P r ′ ∣ q ◃ Q k , r ′ { v r / x k , r ′ } ∣ M ′ . M_{r,r'} := p \triangleleft P'_r \mid q \triangleleft Q_{k,r'}\{v_r/x_{k,r'}\} \mid M'. M r , r ′ := p ◃ P r ′ ∣ q ◃ Q k , r ′ { v r / x k , r ′ } ∣ M ′ .
The given transition preserves safety by Def. 3.12; therefore [b-sess] gives
⊢ M r , r ′ : p : T p ′ , q : T q , k ′ , Δ ′ . \vdash M_{r,r'} : p : T'_p, q : T'_{q,k}, \Delta'. ⊢ M r , r ′ : p : T p ′ , q : T q , k ′ , Δ ′ .
p : ⨁ j ∈ J p j : q j ! ℓ j ⟨ B j ⟩ . T j → p : p k p k : ⨁ 1 : q k ! ℓ k ⟨ B k ⟩ . T k p : \bigoplus_{j\in J} p_j : q_j!\ell_j\langle B_j\rangle.T_j \xrightarrow{p:p_k} p_k : \bigoplus1:q_k!\ell_k\langle B_k\rangle.T_k p : j ∈ J ⨁ p j : q j ! ℓ j ⟨ B j ⟩ . T j p : p k p k : ⨁ 1 : q k ! ℓ k ⟨ B k ⟩ . T k
k ∈ J k \in J k ∈ J , p k ∈ ( 0 , 1 ) p_k \in(0,1) p k ∈ ( 0 , 1 ) .
The k k k -th path set from Lemma C.6 satisfies
p ◃ P ⟶ p r r p ◃ q k ! ℓ k ⟨ e r ⟩ . P r , ∑ r ∈ R p r = p k , p \triangleleft P \mathrel{\mathop{\longrightarrow}^{r}_{p_r}} p \triangleleft q_k!\ell_k\langle e_r\rangle.P_r,\qquad\sum_{r\in R}p_r=p_k, p ◃ P ⟶ p r r p ◃ q k ! ℓ k ⟨ e r ⟩ . P r , r ∈ R ∑ p r = p k ,
⊢ e r : B k , ⊢ P r : T k ( r ∈ R ) . \vdash e_r:B_k,\qquad\vdash P_r:T_k\qquad(r\in R). ⊢ e r : B k , ⊢ P r : T k ( r ∈ R ) .
By [t-sel], safety of the framed target, and [b-sess],
⊢ p ◃ q k ! ℓ k ⟨ e r ⟩ . P r ∣ M ′ : p : ⨁ 1 : q k ! ℓ k ⟨ B k ⟩ . T k , Δ ′ . \vdash p\triangleleft q_k!\ell_k\langle e_r\rangle.P_r\mid M' : p:\bigoplus1:q_k!\ell_k\langle B_k\rangle.T_k,\Delta'. ⊢ p ◃ q k ! ℓ k ⟨ e r ⟩ . P r ∣ M ′ : p : ⨁ 1 : q k ! ℓ k ⟨ B k ⟩ . T k , Δ ′ .
This is clause (3) with ( q , ℓ , p , T ) = ( q k , ℓ k , p k , T k ) (q,\ell,p,T)=(q_k,\ell_k,p_k,T_k) ( q , ℓ , p , T ) = ( q k , ℓ k , p k , T k ) .
T = ∑ i ∈ I ⨁ j ∈ J i p i , j : q j ! ℓ j ⟨ B j ⟩ . T i , j , ∣ I ∣ > 1 , T=\sum_{i\in I}\bigoplus_{j\in J_i}p_{i,j}:q_j!\ell_j\langle B_j\rangle.T_{i,j},\qquad|I|>1, T = i ∈ I ∑ j ∈ J i ⨁ p i , j : q j ! ℓ j ⟨ B j ⟩ . T i , j , ∣ I ∣ > 1 ,
T ( i ) : = ⨁ j ∈ J i p i , j : q j ! ℓ j ⟨ B j ⟩ . T i , j . T^{(i)}:=\bigoplus_{j\in J_i}p_{i,j}:q_j!\ell_j\langle B_j\rangle.T_{i,j}. T ( i ) := j ∈ J i ⨁ p i , j : q j ! ℓ j ⟨ B j ⟩ . T i , j .
(1) If clause (2a)’s hypothesis holds, then p ◃ P ⟶̸ p\triangleleft P\not\longrightarrow p ◃ P ⟶ . A locally irreducible process typed by a sum of selections is typable by one summand. This follows by induction on its typing derivation, allowing environments containing only process variables whose free occurrences are guarded. The [t-sel] case is immediate; [t-sub] uses [sub-Σ \Sigma Σ ] and [sub-⊕ \oplus ⊕ ]. For [t-rec], guardedness preserves local irreducibility of the body, and the induction hypothesis gives
Γ , X : T 0 ⊢ P 0 : T ∗ , T ∗ ≤ T 0 , \Gamma,X:T_0\vdash P_0:T_*,\qquad T_*\leq T_0, Γ , X : T 0 ⊢ P 0 : T ∗ , T ∗ ≤ T 0 ,
where T ∗ T_* T ∗ is a summand of unf ( T 0 ) \operatorname{unf}(T_0) unf ( T 0 ) . Replacing uses of X : T 0 X:T_0 X : T 0 by [t-var] and [t-sub] yields
\Gamma,X:T_*\vdash P_0:T_*\quad\Longrightarrow\quad\Gamma\vdash\mu X.P_0:T_*\quad\text{by \[t-rec\]}.
All other rules are excluded by the type shape, guardedness, or local irreducibility. Thus some i ∈ I i\in I i ∈ I satisfies ⊢ P : T ( i ) \vdash P:T^{(i)} ⊢ P : T ( i ) . Taking T ′ = T ( i ) T'=T^{(i)} T ′ = T ( i ) , [ct-nd], Def. 3.12, and [b-sess] give
p : T → p : p ′ n p : T ′ , ⊢ M : p : T ′ , Δ ′ . p:T\xrightarrow{p:p'}_n p:T',\qquad\vdash M:p:T',\Delta'. p : T p : p ′ n p : T ′ , ⊢ M : p : T ′ , Δ ′ .
(2) Otherwise, Lemma C.6 gives i ∈ I i\in I i ∈ I and disjoint path sets R j R_j R j such that
p ◃ P ⟶ p r r p ◃ q j ! ℓ j ⟨ e r ⟩ . Q r , ∑ r ∈ R j p r = p i , j , p\triangleleft P\mathrel{\mathop{\longrightarrow}^{r}_{p_r}}p\triangleleft q_j!\ell_j\langle e_r\rangle.Q_r,\qquad\sum_{r\in R_j}p_r=p_{i,j}, p ◃ P ⟶ p r r p ◃ q j ! ℓ j ⟨ e r ⟩ . Q r , r ∈ R j ∑ p r = p i , j ,
⊢ e r : B j , ⊢ Q r : T i , j ( j ∈ J i , r ∈ R j ) . \vdash e_r:B_j,\qquad\vdash Q_r:T_{i,j}\qquad(j\in J_i,\ r\in R_j). ⊢ e r : B j , ⊢ Q r : T i , j ( j ∈ J i , r ∈ R j ) .
Set
R : = ⋃ j ∈ J i R j , T ′ : = T ( i ) , R:=\mathbin{\mathop{\bigcup}_{j\in J_i}}R_j,\qquad T':=T^{(i)}, R := ⋃ j ∈ J i R j , T ′ := T ( i ) ,
P r : = q j ! ℓ j ⟨ e r ⟩ . Q r , T r : = ⨁ 1 : q j ! ℓ j ⟨ B j ⟩ . T i , j ( r ∈ R j ) . P_r:=q_j!\ell_j\langle e_r\rangle.Q_r,\qquad T_r:=\bigoplus1:q_j!\ell_j\langle B_j\rangle.T_{i,j}\qquad(r\in R_j). P r := q j ! ℓ j ⟨ e r ⟩ . Q r , T r := ⨁ 1 : q j ! ℓ j ⟨ B j ⟩ . T i , j ( r ∈ R j ) .
The four claims follow:
(a) By [t-sel], ⊢ P r : T r \vdash P_r:T_r ⊢ P r : T r . The full context p : T r , Δ ′ p:T_r,\Delta' p : T r , Δ ′ is reachable from Δ \Delta Δ by [ct-nd], followed by [ct-prob] if p i , j < 1 p_{i,j}<1 p i , j < 1 ; if p i , j = 1 p_{i,j}=1 p i , j = 1 , then J i = { j } J_i=\{j\} J i = { j } . Hence Def. 3.12 and [b-sess] give
⊢ p ◃ P r ∣ M ′ : p : T r , Δ ′ . \vdash p\triangleleft P_r\mid M':p:T_r,\Delta'. ⊢ p ◃ P r ∣ M ′ : p : T r , Δ ′ .
(b)
∑ r ∈ R p r = ∑ j ∈ J i ∑ r ∈ R j p r = ∑ j ∈ J i p i , j = 1. \sum_{r\in R}p_r=\sum_{j\in J_i}\sum_{r\in R_j}p_r=\sum_{j\in J_i}p_{i,j}=1. r ∈ R ∑ p r = j ∈ J i ∑ r ∈ R j ∑ p r = j ∈ J i ∑ p i , j = 1.
(c) p : T → p : T n p : T ′ p : T \xrightarrow{p:T}_{n} p : T' p : T p : T n p : T ′ by [CT-ND].
(d) By [M-⊕] and idempotence of ⊔ \sqcup ⊔ up to mutual subtyping,
⋃ r ∈ R ( T r , p r ) ⊑ ⨁ j ∈ J i ∑ r ∈ R j p r : q j ! ℓ j ⟨ B j ⟩ . T i , j = ⨁ j ∈ J i p i , j : q j ! ℓ j ⟨ B j ⟩ . T i , j = T ′ . \begin{aligned}
\bigcup_{r\in R}\left(T_r,p_r\right) \sqsubseteq\bigoplus_{j\in J_i}\sum_{r\in R_j}p_r:q_j!\ell_j\langle B_j\rangle.T_{i,j} \\
&= \bigoplus_{j\in J_i}p_{i,j}:q_j!\ell_j\langle B_j\rangle.T_{i,j}=T'.
\end{aligned} r ∈ R ⋃ ( T r , p r ) ⊑ j ∈ J i ⨁ r ∈ R j ∑ p r : q j ! ℓ j ⟨ B j ⟩ . T i , j = j ∈ J i ⨁ p i , j : q j ! ℓ j ⟨ B j ⟩ . T i , j = T ′ .
The path set is finite and its weights are positive, so the multi-way merge is well-defined.
p : T { μ t . T / t } → α n p : T 0 , p : μ t . T → α n p : T 0 . p:T\{\mu t.T/t\}\xrightarrow{\alpha}_{n}p:T_0,\qquad p:\mu t.T\xrightarrow{\alpha}_{n}p:T_0. p : T { μ t . T / t } α n p : T 0 , p : μ t . T α n p : T 0 .
Folded and unfolded types are mutually subtypes; thus [T-SUB], Lemma C.2, and [B-SESS] give
⊢ P : T { μ t . T / t } \vdash P:T\{\mu t.T/t\} ⊢ P : T { μ t . T / t } , safe ( p : T { μ t . T / t } , Δ ′ ) \operatorname{safe}(p:T\{\mu t.T/t\},\Delta') safe ( p : T { μ t . T / t } , Δ ′ ) , ⊢ M : p : T { μ t . T / t } , Δ ′ \vdash M:p:T\{\mu t.T/t\},\Delta' ⊢ M : p : T { μ t . T / t } , Δ ′ .
Apply IH to the premise with the same frame. In clause (2), lift its witness by [CT-REC]:
p : T { μ t . T / t } → p : T n p : T ′ ⟹ p : μ t . T → p : T n p : T ′ . p:T\{\mu t.T/t\}\xrightarrow{p:T}_{n}p:T' \Longrightarrow p:\mu t.T\xrightarrow{p:T}_{n}p:T'. p : T { μ t . T / t } p : T n p : T ′ ⟹ p : μ t . T p : T n p : T ′ .
All other conclusions, including clause (3), are unchanged.
Theorem 4.4 (Session Fidelity).
(1) If ⊢ M : Δ \vdash M:\Delta ⊢ M : Δ then Δ → ( p , q ) ℓ 1 Δ ′ \Delta\xrightarrow{(p,q)\ell}_{1}\Delta' Δ ( p , q ) ℓ 1 Δ ′ implies ∃ I : { M → ∗ p i M i → ( p , q ) ℓ 1 } i ∈ I \exists I:\{M\xrightarrow{*}_{p_i}M_i\xrightarrow{(p,q)\ell}_{1}\}_{i\in I} ∃ I : { M ∗ p i M i ( p , q ) ℓ 1 } i ∈ I with ∑ i ∈ I p i = 1 \sum_{i\in I}p_i=1 ∑ i ∈ I p i = 1
(2) If ⊢ P : T \vdash P:T ⊢ P : T then p : T → p : T n p:T\xrightarrow{p:T}_{n} p : T p : T n implies ∃ T ′ : p : T → p : T n p : T ′ \exists T':p:T\xrightarrow{p:T}_{n}p:T' ∃ T ′ : p : T p : T n p : T ′ and ∃ I : { p ⊲ P → ∗ p i p ⊲ P i ∣ p ⊲ P i ↛ } i ∈ I \exists I:\{p\mathbin{\lhd}P\xrightarrow{*}_{p_i}p\mathbin{\lhd}P_i\mid p\mathbin{\lhd}P_i\nrightarrow\}_{i\in I} ∃ I : { p ⊲ P ∗ p i p ⊲ P i ∣ p ⊲ P i ↛ } i ∈ I with ∑ i ∈ I p i = 1 \sum_{i\in I}p_i=1 ∑ i ∈ I p i = 1 and a set of types { T i ∣ ⊢ P i : T i } i ∈ I \{T_i\mid\vdash P_i:T_i\}_{i\in I} { T i ∣⊢ P i : T i } i ∈ I such that ∣ i ∈ I ( T i , p i ) ∣ ⊑ T ′ \lvert_{i\in I}(T_i,p_i)\rvert\sqsubseteq T' ∣ i ∈ I ( T i , p i )∣ ⊑ T ′
(3) If ⊢ P : T \vdash P:T ⊢ P : T then p : T → p p p : ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ p:T\xrightarrow{p}_{p}\,p:\bigoplus1:q!\ell\langle B\rangle.T' p : T p p p : ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ implies ∃ I : { p ⊲ P → ∗ p i p ⊲ q ! ℓ ⟨ e i ⟩ . P i } i ∈ I \exists I:\{p\mathbin{\lhd}P\xrightarrow{*}_{p_i}p\mathbin{\lhd}q!\ell\langle e_i\rangle.P_i\}_{i\in I} ∃ I : { p ⊲ P ∗ p i p ⊲ q ! ℓ ⟨ e i ⟩ . P i } i ∈ I with ∑ i ∈ I p i = p \sum_{i\in I}p_i=p ∑ i ∈ I p i = p and ⊢ P i : T ′ \vdash P_i:T' ⊢ P i : T ′ for all $i\in I
Proof. Corollary of Thm. C.7 □
Downward closure of properties
Lemma C.8 (Downward closure of ⊔ \sqcup ⊔ definedness).
T 1 ⊑ T 2 T_1\sqsubseteq T_2 T 1 ⊑ T 2 , T 1 ′ ⊑ T 2 ′ T'_1\sqsubseteq T'_2 T 1 ′ ⊑ T 2 ′ , T 2 ⊔ T 2 ′ d e f i n e d ⟹ T 1 ⊔ T 1 ′ d e f i n e d T_2\sqcup T'_2\ \mathit{defined}\Longrightarrow T_1\sqcup T'_1\ \mathit{defined} T 2 ⊔ T 2 ′ defined ⟹ T 1 ⊔ T 1 ′ defined .
Proof. By the proof of Lemma B.3 , two types admit a join whenever they have a common upper bound, the result follows by transitivity of ⊑ \sqsubseteq ⊑ . □
Lemma C.9 (Downward closure of merge definedness). Suppose T 1 ⊑ T 2 T_1\sqsubseteq T_2 T 1 ⊑ T 2 and T 1 ′ ⊑ T 2 ′ T'_1\sqsubseteq T'_2 T 1 ′ ⊑ T 2 ′ with T 2 ⊓ p T 2 ′ T_2\sqcap_p T'_2 T 2 ⊓ p T 2 ′ defined, then T 1 ⊓ p T 1 ′ T_1\sqcap_p T'_1 T 1 ⊓ p T 1 ′ defined
Proof. We proceed by induction on the finite derivation of T 2 ⊓ p T 2 ′ T_2\sqcap_p T'_2 T 2 ⊓ p T 2 ′ .
case [M-END]: By [SUB-END], T 1 = T 1 ′ = e n d T_1=T'_1=\mathsf{end} T 1 = T 1 ′ = end , so T 1 ⊓ p T 1 ′ = e n d T_1\sqcap_p T'_1=\mathsf{end} T 1 ⊓ p T 1 ′ = end by [M-END].
case [M-⊕]: Inverting [SUB-⊕] or [SUB-⊕], write
T 1 = ∑ a ∈ A T 1 , a , T 1 ′ = ∑ b ∈ B T 1 , b ′ , T_1=\sum_{a\in A}T_{1,a},\qquad T'_1=\sum_{b\in B}T'_{1,b}, T 1 = a ∈ A ∑ T 1 , a , T 1 ′ = b ∈ B ∑ T 1 , b ′ ,
where the summands are selection distributions, singleton sums are allowed, and
∀ a ∈ A : T 1 , a ⊑ T 2 , ∀ b ∈ B : T 1 , b ′ ⊑ T 2 ′ . \forall a\in A:T_{1,a}\sqsubseteq T_2,\qquad\forall b\in B:T'_{1,b}\sqsubseteq T'_2. ∀ a ∈ A : T 1 , a ⊑ T 2 , ∀ b ∈ B : T 1 , b ′ ⊑ T 2 ′ .
These comparisons use [sub-⊔], preserving the respective prefixes and probabilities. Let I , J I, J I , J index the branches of T 2 , T 2 ′ T_2, T'_2 T 2 , T 2 ′ . For every ( a , b , k ) ∈ A × B × ( I ∩ J ) (a,b,k) \in A \times B \times(I \cap J) ( a , b , k ) ∈ A × B × ( I ∩ J ) ,
T 1 , a , k ≤ T 2 , k , T 1 , b , k ′ ≤ T 2 , k ′ , T 2 , k ⊔ T 2 , k ′ defined . T_{1,a,k} \leq T_{2,k}, \qquad T'_{1,b,k} \leq T'_{2,k}, \qquad T_{2,k} \sqcup T'_{2,k}\ \text{defined}. T 1 , a , k ≤ T 2 , k , T 1 , b , k ′ ≤ T 2 , k ′ , T 2 , k ⊔ T 2 , k ′ defined .
Thus T 1 , a , k ⊔ T 1 , b , k ′ T_{1,a,k} \sqcup T'_{1,b,k} T 1 , a , k ⊔ T 1 , b , k ′ is defined by Lemma C.8, and [m-⊔] gives
∀ ( a , b ) ∈ A × B : T 1 , a ⊓ p T 1 , b ′ defined . \forall(a,b) \in A \times B:\quad T_{1,a} \sqcap_p T'_{1,b}\ \text{defined}. ∀ ( a , b ) ∈ A × B : T 1 , a ⊓ p T 1 , b ′ defined .
Apply [m-Σ] if ∣ A ∣ ⋅ ∣ B ∣ > 1 |A| \cdot|B| > 1 ∣ A ∣ ⋅ ∣ B ∣ > 1 ; otherwise the unique component is the required merge.
case [m-&]: Let I r , J r I_r, J_r I r , J r index the branches of T r , T r ′ T_r, T'_r T r , T r ′ for r ∈ { 1 , 2 } r \in\{1,2\} r ∈ { 1 , 2 } . Inverting [sub-&] gives
I 2 ⊆ I 1 , J 2 ⊆ J 1 , I_2 \subseteq I_1,\qquad J_2 \subseteq J_1, I 2 ⊆ I 1 , J 2 ⊆ J 1 ,
∀ i ∈ I 2 : T 1 , i ≤ T 2 , i , ∀ j ∈ J 2 : T 1 , j ′ ≤ T 2 , j ′ , \forall i \in I_2:\ T_{1,i} \leq T_{2,i},\qquad\forall j \in J_2:\ T'_{1,j} \leq T'_{2,j}, ∀ i ∈ I 2 : T 1 , i ≤ T 2 , i , ∀ j ∈ J 2 : T 1 , j ′ ≤ T 2 , j ′ ,
{ q i } i ∈ I 1 = { q i } i ∈ I 2 , { q j } j ∈ J 1 = { q j } j ∈ J 2 . \{q_i\}_{i\in I_1} = \{q_i\}_{i\in I_2},\qquad\{q_j\}_{j\in J_1} = \{q_j\}_{j\in J_2}. { q i } i ∈ I 1 = { q i } i ∈ I 2 , { q j } j ∈ J 1 = { q j } j ∈ J 2 .
Put
K r = { k ∈ I r ∩ J r ∣ T r , k ⊔ T r , k ′ defined } . K_r = \{k \in I_r \cap J_r \mid T_{r,k} \sqcup T'_{r,k}\ \text{defined}\}. K r = { k ∈ I r ∩ J r ∣ T r , k ⊔ T r , k ′ defined } .
By Lemma C.8, K 2 ⊆ K 1 K_2 \subseteq K_1 K 2 ⊆ K 1 . The participant conditions of the upper merge and the subtypings therefore give
{ q k } k ∈ K 2 ⊆ { q k } k ∈ K 1 ⊆ { q i } i ∈ I 1 = { q j } j ∈ J 1 = { q k } k ∈ K 2 . \{q_k\}_{k\in K_2} \subseteq\{q_k\}_{k\in K_1} \subseteq\{q_i\}_{i\in I_1} = \{q_j\}_{j\in J_1} = \{q_k\}_{k\in K_2}. { q k } k ∈ K 2 ⊆ { q k } k ∈ K 1 ⊆ { q i } i ∈ I 1 = { q j } j ∈ J 1 = { q k } k ∈ K 2 .
Hence { q k } k ∈ K 1 = { q i } i ∈ I 1 = { q j } j ∈ J 1 \{q_k\}_{k\in K_1} = \{q_i\}_{i\in I_1} = \{q_j\}_{j\in J_1} { q k } k ∈ K 1 = { q i } i ∈ I 1 = { q j } j ∈ J 1 , so [m-&] applies.
T r = ∑ i ∈ I r T r , i , T r ′ = ∑ j ∈ J r T r , j ′ ( r ∈ { 1 , 2 } ) , T_r = \sum_{i\in I_r} T_{r,i},\qquad T'_r = \sum_{j\in J_r} T'_{r,j}\qquad(r \in\{1,2\}), T r = i ∈ I r ∑ T r , i , T r ′ = j ∈ J r ∑ T r , j ′ ( r ∈ { 1 , 2 }) ,
allowing singleton sums. Inverting [sub-Σ] or [sub-⊔] gives
∀ a ∈ I 1 : ∃ i ∈ I 2 : T 1 , a ≤ T 2 , i , \forall a \in I_1:\ \exists i \in I_2:\ T_{1,a} \leq T_{2,i}, ∀ a ∈ I 1 : ∃ i ∈ I 2 : T 1 , a ≤ T 2 , i ,
∀ b ∈ J 1 : ∃ j ∈ J 2 : T 1 , b ′ ≤ T 2 , j ′ . \forall b \in J_1:\ \exists j \in J_2:\ T'_{1,b} \leq T'_{2,j}. ∀ b ∈ J 1 : ∃ j ∈ J 2 : T 1 , b ′ ≤ T 2 , j ′ .
For each ( a , b ) ∈ I 1 × J 1 (a,b) \in I_1 \times J_1 ( a , b ) ∈ I 1 × J 1 , choose such i , j i,j i , j . Since T 2 , i ⊓ p T 2 , j ′ T_{2,i} \sqcap_p T'_{2,j} T 2 , i ⊓ p T 2 , j ′ is defined by a premise of the given derivation, the induction hypothesis yields T 1 , a ⊓ p T 1 , b ′ T_{1,a} \sqcap_p T'_{1,b} T 1 , a ⊓ p T 1 , b ′ defined. Apply [m-Σ] if ∣ I 1 ∣ ⋅ ∣ J 1 ∣ > 1 |I_1| \cdot|J_1| > 1 ∣ I 1 ∣ ⋅ ∣ J 1 ∣ > 1 ; otherwise the unique component is the required merge.
Lemma 4.20 (⊓ \sqcap ⊓ -monotonicity)
(Proof in §C.3.) Suppose T i ≤ T i ′ T_i \leq T'_i T i ≤ T i ′ for i ∈ { 1 , 2 } i \in\{1,2\} i ∈ { 1 , 2 } and T 1 ′ ⊓ p T 2 ′ T'_1 \sqcap_p T'_2 T 1 ′ ⊓ p T 2 ′ is defined, then T 1 ⊓ p T 2 T_1 \sqcap_p T_2 T 1 ⊓ p T 2 is defined and T 1 ⊓ p T 2 ≤ T 1 ′ ⊓ p T 2 ′ T_1 \sqcap_p T_2 \leq T'_1 \sqcap_p T'_2 T 1 ⊓ p T 2 ≤ T 1 ′ ⊓ p T 2 ′ .
Proof. By Lemma C.9, T 1 ⊓ p T 2 T_1 \sqcap_p T_2 T 1 ⊓ p T 2 is defined. We use the following consequence of Lemma C.8, transitivity and the least-upper-bound property:
T a ≤ T a ′ , T b ≤ T b ′ , T a ′ ⊔ T b ′ defined ⟹ T a ⊔ T b defined ∧ T a ⊔ T b ≤ T a ′ ⊔ T b ′ . (46) \begin{aligned}
T_a &\leq T'_a,\qquad T_b \leq T'_b,\qquad T'_a \sqcup T'_b\ \text{defined}\\
&\Longrightarrow T_a \sqcup T_b\ \text{defined}\ \land\ T_a \sqcup T_b \leq T'_a \sqcup T'_b. \tag*{(46)}
\end{aligned} T a ≤ T a ′ , T b ≤ T b ′ , T a ′ ⊔ T b ′ defined ⟹ T a ⊔ T b defined ∧ T a ⊔ T b ≤ T a ′ ⊔ T b ′ . (46)
Indeed, T a ′ ⊔ T b ′ T'_a \sqcup T'_b T a ′ ⊔ T b ′ is a common upper bound of T a , T b T_a, T_b T a , T b .
We prove T 1 ⊓ p T 2 ≤ T 1 ′ ⊓ p T 2 ′ T_1 \sqcap_p T_2 \leq T'_1 \sqcap_p T'_2 T 1 ⊓ p T 2 ≤ T 1 ′ ⊓ p T 2 ′ by induction on the finite derivation of T 1 ′ ⊓ p T 2 ′ T'_1 \sqcap_p T'_2 T 1 ′ ⊓ p T 2 ′ .
T 1 ′ = ⨁ i ∈ I p i : p i ! ℓ i ⟨ B i ⟩ . T 1 , i ′ , T 2 ′ = ⨁ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T 2 , j ′ . T'_1 = \bigoplus_{i \in I} p_i : p_i! \ell_i \langle B_i\rangle.T'_{1,i},
\qquad
T'_2 = \bigoplus_{j \in J} p_j : p_j! \ell_j \langle B_j\rangle.T'_{2,j}. T 1 ′ = i ∈ I ⨁ p i : p i ! ℓ i ⟨ B i ⟩ . T 1 , i ′ , T 2 ′ = j ∈ J ⨁ p j : p j ! ℓ j ⟨ B j ⟩ . T 2 , j ′ .
Inverting [sub-⊕ \oplus ⊕ ] or [sub-Σ \Sigma Σ ] gives
T 1 = ∑ a ∈ A T 1 , a , T 2 = ∑ b ∈ B T 2 , b , T_1 = \sum_{a \in A} T_{1,a}, \qquad T_2 = \sum_{b \in B} T_{2,b}, T 1 = a ∈ A ∑ T 1 , a , T 2 = b ∈ B ∑ T 2 , b ,
∀ a ∈ A : T 1 , a ≤ T 1 ′ , ∀ b ∈ B : T 2 , b ≤ T 2 ′ , \forall a \in A : T_{1,a} \leq T'_1,\qquad\forall b \in B : T_{2,b} \leq T'_2, ∀ a ∈ A : T 1 , a ≤ T 1 ′ , ∀ b ∈ B : T 2 , b ≤ T 2 ′ ,
where all summands are selection distributions. Each summand comparison uses [sub-⊕ \oplus ⊕ ], preserving the respective prefixes and probabilities. Write T 1 , a , i T_{1,a,i} T 1 , a , i , T 2 , b , j T_{2,b,j} T 2 , b , j for their continuations. Fix ( a , b ) ∈ A × B (a,b) \in A \times B ( a , b ) ∈ A × B . The two distribution merges have the same prefixes and probabilities, and their continuations satisfy
k ∈ I ∖ J : T 1 , a , k ≤ T 1 , k ′ , k ∈ J ∖ I : T 2 , b , k ≤ T 2 , k ′ , k ∈ I ∩ J : T 1 , a , k ⊔ T 2 , b , k ≤ T 1 , k ′ ⊔ T 2 , k ′ . \begin{aligned}
k \in I \setminus J &: \quad T_{1,a,k} \leq T'_{1,k},\\
k \in J \setminus I &: \quad T_{2,b,k} \leq T'_{2,k},\\
k \in I \cap J &: \quad T_{1,a,k} \sqcup T_{2,b,k} \leq T'_{1,k} \sqcup T'_{2,k}.
\end{aligned} k ∈ I ∖ J k ∈ J ∖ I k ∈ I ∩ J : T 1 , a , k ≤ T 1 , k ′ , : T 2 , b , k ≤ T 2 , k ′ , : T 1 , a , k ⊔ T 2 , b , k ≤ T 1 , k ′ ⊔ T 2 , k ′ .
The first two comparisons follow from [sub-⊕ \oplus ⊕ ]; the third, including existence of the lower join, follows from (1). Thus [m-⊕ \oplus ⊕ ] and [sub-⊕ \oplus ⊕ ] give
T 1 , a ⊓ p T 2 , b ≤ T 1 ′ ⊓ p T 2 ′ . T_{1,a} \sqcap_{p} T_{2,b} \leq T'_1 \sqcap_{p} T'_2. T 1 , a ⊓ p T 2 , b ≤ T 1 ′ ⊓ p T 2 ′ .
If ∣ A ∣ ⋅ ∣ B ∣ > 1 |A| \cdot|B| > 1 ∣ A ∣ ⋅ ∣ B ∣ > 1 , [m-Σ \Sigma Σ ] and [sub-Σ \Sigma Σ ] therefore yield
T 1 ⊓ p T 2 = ∑ ( a , b ) ∈ A × B ( T 1 , a ⊓ p T 2 , b ) ≤ T 1 ′ ⊓ p T 2 ′ . T_1 \sqcap_{p} T_2 = \sum_{(a,b) \in A \times B} (T_{1,a} \sqcap_{p} T_{2,b}) \leq T'_1 \sqcap_{p} T'_2. T 1 ⊓ p T 2 = ( a , b ) ∈ A × B ∑ ( T 1 , a ⊓ p T 2 , b ) ≤ T 1 ′ ⊓ p T 2 ′ .
Otherwise, the unique component comparison is already the required inequality.
case [m-&]: Let I , J I,J I , J and I ′ , J ′ I',J' I ′ , J ′ be the respective branch sets of T 1 , T 2 T_1,T_2 T 1 , T 2 and T 1 ′ , T 2 ′ T'_1,T'_2 T 1 ′ , T 2 ′ . Inverting [sub-&] gives
I ′ ⊆ I , J ′ ⊆ J , I' \subseteq I,\qquad J' \subseteq J, I ′ ⊆ I , J ′ ⊆ J ,
∀ i ∈ I ′ : T 1 , i ≤ T 1 , i ′ , ∀ j ∈ J ′ : T 2 , j ≤ T 2 , j ′ . \forall i \in I' : T_{1,i} \leq T'_{1,i},\qquad\forall j \in J' : T_{2,j} \leq T'_{2,j}. ∀ i ∈ I ′ : T 1 , i ≤ T 1 , i ′ , ∀ j ∈ J ′ : T 2 , j ≤ T 2 , j ′ .
Put
K = { k ∈ I ∩ J ∣ T 1 , k ⊔ T 2 , k defined } , K = \{k \in I \cap J \mid T_{1,k} \sqcup T_{2,k}\text{ defined}\}, K = { k ∈ I ∩ J ∣ T 1 , k ⊔ T 2 , k defined } ,
K ′ = { k ∈ I ′ ∩ J ′ ∣ T 1 , k ′ ⊔ T 2 , k ′ defined } . K' = \{k \in I' \cap J' \mid T'_{1,k} \sqcup T'_{2,k}\text{ defined}\}. K ′ = { k ∈ I ′ ∩ J ′ ∣ T 1 , k ′ ⊔ T 2 , k ′ defined } .
By (1),
K ′ ⊆ K , ∀ k ∈ K ′ : T 1 , k ⊔ T 2 , k ≤ T 1 , k ′ ⊔ T 2 , k ′ . K' \subseteq K,\qquad\forall k \in K' : T_{1,k} \sqcup T_{2,k} \leq T'_{1,k} \sqcup T'_{2,k}. K ′ ⊆ K , ∀ k ∈ K ′ : T 1 , k ⊔ T 2 , k ≤ T 1 , k ′ ⊔ T 2 , k ′ .
Since both merges are defined, the side conditions of [m-&] and [sub-&] give
{ p k } k ∈ K = { p i } i ∈ I = { p i } i ∈ I ′ = { p k } k ∈ K ′ . \{p_k\}_{k \in K} = \{p_i\}_{i \in I} = \{p_i\}_{i \in I'} = \{p_k\}_{k \in K'}. { p k } k ∈ K = { p i } i ∈ I = { p i } i ∈ I ′ = { p k } k ∈ K ′ .
Hence [sub-&] yields
& k ∈ K p k ? ℓ k ( B k ) . ( T 1 , k ⊔ T 2 , k ) ≤ & k ∈ K ′ p k ? ℓ k ( B k ) . ( T 1 , k ′ ⊔ T 2 , k ′ ) , \&_{k \in K} p_k ? \ell_k(B_k).(T_{1,k} \sqcup T_{2,k})
\leq
\&_{k \in K'} p_k ? \ell_k(B_k).(T'_{1,k} \sqcup T'_{2,k}), & k ∈ K p k ? ℓ k ( B k ) . ( T 1 , k ⊔ T 2 , k ) ≤ & k ∈ K ′ p k ? ℓ k ( B k ) . ( T 1 , k ′ ⊔ T 2 , k ′ ) ,
which is precisely the required inequality by [m-&].
T 1 = ∑ a ∈ A T 1 , a , T 2 = ∑ b ∈ B T 2 , b , T_1 = \sum_{a \in A} T_{1,a},\qquad T_2 = \sum_{b \in B} T_{2,b}, T 1 = a ∈ A ∑ T 1 , a , T 2 = b ∈ B ∑ T 2 , b ,
T 1 ′ = ∑ i ∈ I T 1 , i ′ , T 2 ′ = ∑ j ∈ J T 2 , j ′ , T'_1 = \sum_{i \in I} T'_{1,i},\qquad T'_2 = \sum_{j \in J} T'_{2,j}, T 1 ′ = i ∈ I ∑ T 1 , i ′ , T 2 ′ = j ∈ J ∑ T 2 , j ′ ,
where ∣ I ∣ ⋅ ∣ J ∣ > 1 |I| \cdot|J| > 1 ∣ I ∣ ⋅ ∣ J ∣ > 1 . Inverting [SUB-Σ] or [SUB-⊕] gives
∀ a ∈ A : ∃ i ∈ I : T 1 , a ≤ T 1 , i ′ , \forall a \in A : \exists i \in I : T_{1,a} \leq T'_{1,i}, ∀ a ∈ A : ∃ i ∈ I : T 1 , a ≤ T 1 , i ′ ,
∀ b ∈ B : ∃ j ∈ J : T 2 , b ≤ T 2 , j ′ . \forall b \in B : \exists j \in J : T_{2,b} \leq T'_{2,j}. ∀ b ∈ B : ∃ j ∈ J : T 2 , b ≤ T 2 , j ′ .
Fix ( a , b ) ∈ A × B (a,b) \in A \times B ( a , b ) ∈ A × B and choose such i , j i,j i , j . The merge T 1 , i ′ ⊓ p T 2 , j ′ T'_{1,i} \sqcap_p T'_{2,j} T 1 , i ′ ⊓ p T 2 , j ′ is defined by a premise of the given derivation. Hence the induction hypothesis gives
T 1 , a ⊓ p T 2 , b ≤ T 1 , i ′ ⊓ p T 2 , j ′ . T_{1,a} \sqcap_p T_{2,b} \leq T'_{1,i} \sqcap_p T'_{2,j}. T 1 , a ⊓ p T 2 , b ≤ T 1 , i ′ ⊓ p T 2 , j ′ .
Thus every component of the lower merge is a subtype of some component of the upper merge. Since ( ∣ A ∣ ⋅ ∣ B ∣ ) ⋅ ( ∣ I ∣ ⋅ ∣ J ∣ ) > 1 (|A| \cdot|B|) \cdot(|I| \cdot|J|) > 1 ( ∣ A ∣ ⋅ ∣ B ∣ ) ⋅ ( ∣ I ∣ ⋅ ∣ J ∣ ) > 1 , [SUB-Σ] yields
∑ ( a , b ) ∈ A × B ( T 1 , a ⊓ p T 2 , b ) ≤ ∑ ( i , j ) ∈ I × J ( T 1 , i ′ ⊓ p T 2 , j ′ ) . \sum_{(a,b)\in A\times B} \left(T_{1,a} \sqcap_p T_{2,b}\right)
\leq
\sum_{(i,j)\in I\times J} \left(T'_{1,i} \sqcap_p T'_{2,j}\right). ( a , b ) ∈ A × B ∑ ( T 1 , a ⊓ p T 2 , b ) ≤ ( i , j ) ∈ I × J ∑ ( T 1 , i ′ ⊓ p T 2 , j ′ ) .
By [M-Σ], these are the required merges. If ∣ A ∣ ⋅ ∣ B ∣ = 1 |A| \cdot|B| = 1 ∣ A ∣ ⋅ ∣ B ∣ = 1 , the lower sum instead denotes its unique selection merge, derived by [M-⊕]; the same [SUB-Σ] application still applies.
Notation C.10 (Property Abbreviations). In the following we write sdf( Δ ) (\Delta) ( Δ ) if safe( Δ ) (\Delta) ( Δ ) and df( Δ ) (\Delta) ( Δ ) ; saslive( Δ ) (\Delta) ( Δ ) if safe( Δ ) (\Delta) ( Δ ) and aslive( Δ ) (\Delta) ( Δ ) ; and slive( Δ ) (\Delta) ( Δ ) if safe( Δ ) (\Delta) ( Δ ) and live( Δ ) (\Delta) ( Δ ) .
Lemma C.11 (Type context simulation). If Δ 0 ≤ Δ 0 ′ \Delta_0 \leq\Delta'_0 Δ 0 ≤ Δ 0 ′ and safe( Δ 0 ′ ) (\Delta'_0) ( Δ 0 ′ ) then Δ 0 ′ \Delta'_0 Δ 0 ′ can simulate Δ 0 \Delta_0 Δ 0 :
( 1 ) Δ 0 → ( p , q ) ℓ 1 Δ 1 implies ( a ) if Δ 0 ′ ( p ) ̸ → n then ∃ Δ 1 ′ ≥ Δ 1 such that Δ 0 ′ → ( p , q ) ℓ 1 Δ 1 ′ ; ( b ) if Δ 0 ′ ( p ) → n then ∃ Δ 0 ′ ′ ≥ Δ 0 and ∃ Δ 1 ′ ≥ Δ 1 such that Δ 0 ′ → n Δ 0 ′ ′ → ( p , q ) ℓ 1 Δ 1 ′ ; ( 2 ) Δ 0 → p : τ n Δ 1 implies ( a ) if Δ 0 ′ ( p ) ̸ → n then Δ 0 ′ ≥ Δ 1 ; ( b ) if Δ 0 ′ ( p ) → n then ∃ Δ 1 ′ ≥ Δ 1 such that Δ 0 ′ → p : τ n Δ 1 ′ ; ( 3 ) Δ 0 → p : p p Δ 1 implies ( a ) if Δ 0 ′ ( p ) ̸ → n then ∃ Δ 1 ′ ≥ Δ 1 such that Δ 0 ′ → p : p p Δ 1 ′ ; ( b ) if Δ 0 ′ ( p ) → n then ∃ Δ 0 ′ ′ ≥ Δ 0 and ∃ Δ 1 ′ ≥ Δ 1 such that Δ 0 ′ → n Δ 0 ′ ′ → p : p p Δ 1 ′ . \begin{aligned}
(1)\quad&\Delta_0 \xrightarrow{(p,q)\ell}_1 \Delta_1 \text{ implies}\\
&(a)\ \text{if }\Delta'_0(p) \not\to_n\text{ then }\exists\Delta'_1 \geq\Delta_1\text{ such that }\Delta'_0 \xrightarrow{(p,q)\ell}_1 \Delta'_1;\\
&(b)\ \text{if }\Delta'_0(p) \to_n\text{ then }\exists\Delta''_0 \geq\Delta_0\text{ and }\exists\Delta'_1 \geq\Delta_1\text{ such that }\Delta'_0 \to_n \Delta''_0 \xrightarrow{(p,q)\ell}_1 \Delta'_1;\\
(2)\quad&\Delta_0 \xrightarrow{p:\tau}_n \Delta_1 \text{ implies}\\
&(a)\ \text{if }\Delta'_0(p) \not\to_n\text{ then }\Delta'_0 \geq\Delta_1;\\
&(b)\ \text{if }\Delta'_0(p) \to_n\text{ then }\exists\Delta'_1 \geq\Delta_1\text{ such that }\Delta'_0 \xrightarrow{p:\tau}_n \Delta'_1;\\
(3)\quad&\Delta_0 \xrightarrow{p:p}_p \Delta_1 \text{ implies}\\
&(a)\ \text{if }\Delta'_0(p) \not\to_n\text{ then }\exists\Delta'_1 \geq\Delta_1\text{ such that }\Delta'_0 \xrightarrow{p:p}_p \Delta'_1;\\
&(b)\ \text{if }\Delta'_0(p) \to_n\text{ then }\exists\Delta''_0 \geq\Delta_0\text{ and }\exists\Delta'_1 \geq\Delta_1\text{ such that }\Delta'_0 \to_n \Delta''_0 \xrightarrow{p:p}_p \Delta'_1.
\end{aligned} ( 1 ) ( 2 ) ( 3 ) Δ 0 ( p , q ) ℓ 1 Δ 1 implies ( a ) if Δ 0 ′ ( p ) → n then ∃ Δ 1 ′ ≥ Δ 1 such that Δ 0 ′ ( p , q ) ℓ 1 Δ 1 ′ ; ( b ) if Δ 0 ′ ( p ) → n then ∃ Δ 0 ′′ ≥ Δ 0 and ∃ Δ 1 ′ ≥ Δ 1 such that Δ 0 ′ → n Δ 0 ′′ ( p , q ) ℓ 1 Δ 1 ′ ; Δ 0 p : τ n Δ 1 implies ( a ) if Δ 0 ′ ( p ) → n then Δ 0 ′ ≥ Δ 1 ; ( b ) if Δ 0 ′ ( p ) → n then ∃ Δ 1 ′ ≥ Δ 1 such that Δ 0 ′ p : τ n Δ 1 ′ ; Δ 0 p : p p Δ 1 implies ( a ) if Δ 0 ′ ( p ) → n then ∃ Δ 1 ′ ≥ Δ 1 such that Δ 0 ′ p : p p Δ 1 ′ ; ( b ) if Δ 0 ′ ( p ) → n then ∃ Δ 0 ′′ ≥ Δ 0 and ∃ Δ 1 ′ ≥ Δ 1 such that Δ 0 ′ → n Δ 0 ′′ p : p p Δ 1 ′ . Proof. By induction on the derivation of Δ 0 → α t Δ 1 \Delta_0 \xrightarrow{\alpha}_t \Delta_1 Δ 0 α t Δ 1 , with base cases [CT-ND], [CT-PROB] and [CT-τ] and inductive cases [CT-SC] and [CT-REC]:
k ∈ I ∣ I ∣ > 1 p : ∑ i ∈ I T i → p : τ n p : T k (48) \frac{k \in I \quad|I| > 1}{\mathbf{p} : \sum_{i\in I} T_i \xrightarrow{p:\tau}_{n} \mathbf{p} : T_k} \tag*{(48)} p : ∑ i ∈ I T i p : τ n p : T k k ∈ I ∣ I ∣ > 1 (48)
thus Δ 0 = p : ∑ i ∈ I T i \Delta_0 = \mathbf{p} : \sum_{i\in I} T_i Δ 0 = p : ∑ i ∈ I T i with ∣ I ∣ > 1 |I| > 1 ∣ I ∣ > 1 , and as Δ 0 ⪯ Δ 0 ′ \Delta_0 \preceq\Delta'_0 Δ 0 ⪯ Δ 0 ′ the only applicable rule is [SUB-Σ \Sigma Σ ], so Δ 0 ′ = p : ∑ j ∈ J T j ′ \Delta'_0 = \mathbf{p} : \sum_{j\in J} T'_j Δ 0 ′ = p : ∑ j ∈ J T j ′ where ∀ i ∈ I : ∃ j ∈ J : T i ⪯ T j ′ \forall i \in I : \exists j \in J : T_i \preceq T'_j ∀ i ∈ I : ∃ j ∈ J : T i ⪯ T j ′ — note J J J may well be a singleton, several summands of Δ 0 ( p ) \Delta_0(\mathbf{p}) Δ 0 ( p ) sharing the same supertype summand (Rem. C.2). – if Δ 0 ′ ( p ) ̸ → n \Delta'_0(\mathbf{p}) \not\xrightarrow{}_{n} Δ 0 ′ ( p ) n (case 2a) then J = { l } J = \{l\} J = { l } is a singleton, and in particular T k ⪯ T l ′ T_k \preceq T'_l T k ⪯ T l ′ , so Δ 1 = p : T k ⪯ p : T l ′ = Δ 1 ′ \Delta_1 = \mathbf{p} : T_k \preceq\mathbf{p} : T'_l = \Delta'_1 Δ 1 = p : T k ⪯ p : T l ′ = Δ 1 ′ and no step is needed; – if Δ 0 ′ ( p ) → n \Delta'_0(\mathbf{p}) \xrightarrow{}_{n} Δ 0 ′ ( p ) n (case 2b) then ∣ J ∣ > 1 |J| > 1 ∣ J ∣ > 1 ; picking l ∈ J l \in J l ∈ J with T k ⪯ T l ′ T_k \preceq T'_l T k ⪯ T l ′ ,
l ∈ J ∣ J ∣ > 1 p : ∑ j ∈ J T j ′ → p : τ n p : T l ′ (49) \frac{l \in J \quad|J| > 1}{\mathbf{p} : \sum_{j\in J} T'_j \xrightarrow{p:\tau}_{n} \mathbf{p} : T'_l} \tag*{(49)} p : ∑ j ∈ J T j ′ p : τ n p : T l ′ l ∈ J ∣ J ∣ > 1 (49)
with Δ 1 = p : T k ⪯ p : T l ′ = Δ 1 ′ \Delta_1 = \mathbf{p} : T_k \preceq\mathbf{p} : T'_l = \Delta'_1 Δ 1 = p : T k ⪯ p : T l ′ = Δ 1 ′ .
k ∈ J p k ∈ ( 0 ; 1 ) p : ⨁ j ∈ J p j : q j ! ℓ j ⟨ B j ⟩ . T j → p k p p : ⨁ 1 : q k ! ℓ k ⟨ B k ⟩ . T k (50) \frac{k \in J \quad p_k \in(0;1)}{\mathbf{p} : \bigoplus_{j\in J} p_j : q_j!\ell_j\langle B_j\rangle.T_j \xrightarrow{p_k}_{p} \mathbf{p} : \bigoplus1 : q_k!\ell_k\langle B_k\rangle.T_k} \tag*{(50)} p : ⨁ j ∈ J p j : q j ! ℓ j ⟨ B j ⟩ . T j p k p p : ⨁ 1 : q k ! ℓ k ⟨ B k ⟩ . T k k ∈ J p k ∈ ( 0 ; 1 ) (50)
thus Δ 0 = p : ⨁ j ∈ J p j : q j ! ℓ j ⟨ B j ⟩ . T j \Delta_0 = \mathbf{p} : \bigoplus_{j\in J} p_j : q_j!\ell_j\langle B_j\rangle.T_j Δ 0 = p : ⨁ j ∈ J p j : q j ! ℓ j ⟨ B j ⟩ . T j with ∣ J ∣ > 1 |J| > 1 ∣ J ∣ > 1 (as p k < 1 p_k < 1 p k < 1 and the branch probabilities sum to 1 1 1 ). From Δ 0 ( p ) ⪯ Δ 0 ′ ( p ) \Delta_0(\mathbf{p}) \preceq\Delta'_0(\mathbf{p}) Δ 0 ( p ) ⪯ Δ 0 ′ ( p ) , by either [SUB-⊕ \oplus ⊕ ] or [SUB-Σ \Sigma Σ ]: – by [SUB-⊕ \oplus ⊕ ] (case 3a): Δ 0 ′ ( p ) = ⨁ j ∈ J p j : q j ! ℓ j ⟨ B j ⟩ . T j ′ ′ \Delta'_0(\mathbf{p}) = \bigoplus_{j\in J} p_j : q_j!\ell_j\langle B_j\rangle.T''_j Δ 0 ′ ( p ) = ⨁ j ∈ J p j : q j ! ℓ j ⟨ B j ⟩ . T j ′′ with T j ⪯ T j ′ ′ T_j \preceq T''_j T j ⪯ T j ′′ for all j ∈ J j \in J j ∈ J — same labels, partners and probabilities — and Δ 0 ′ ( p ) ̸ → n \Delta'_0(\mathbf{p}) \not\xrightarrow{}_{n} Δ 0 ′ ( p ) n . Then [CT-PROB] at the same branch k k k gives
Δ 0 ′ → p k p p : ⨁ 1 : q k ! ℓ k ⟨ B k ⟩ . T k ′ ′ = : Δ 1 ′ (51) \Delta'_0 \xrightarrow{p_k}_{p} \mathbf{p} : \bigoplus1 : q_k!\ell_k\langle B_k\rangle.T''_k =: \Delta'_1 \tag*{(51)} Δ 0 ′ p k p p : ⨁ 1 : q k ! ℓ k ⟨ B k ⟩ . T k ′′ =: Δ 1 ′ (51)
with Δ 1 ⪯ Δ 1 ′ \Delta_1 \preceq\Delta'_1 Δ 1 ⪯ Δ 1 ′ by [SUB-⊕ \oplus ⊕ ] on the committed singletons, since T k ⪯ T k ′ ′ T_k \preceq T''_k T k ⪯ T k ′′ ; – by [SUB-Σ \Sigma Σ ] (case 3b): as in the [CT-ND] case, Δ 0 ′ \Delta'_0 Δ 0 ′ first commits by [CT-ND] to the summand Δ 0 ′ ′ ( p ) \Delta''_0(\mathbf{p}) Δ 0 ′′ ( p ) with Δ 0 ( p ) ⪯ Δ 0 ′ ′ ( p ) \Delta_0(\mathbf{p}) \preceq\Delta''_0(\mathbf{p}) Δ 0 ( p ) ⪯ Δ 0 ′′ ( p ) by [SUB-⊕ \oplus ⊕ ], so Δ 0 ⪯ Δ 0 ′ ′ \Delta_0 \preceq\Delta''_0 Δ 0 ⪯ Δ 0 ′′ , and the previous bullet applies to Δ 0 ′ ′ \Delta''_0 Δ 0 ′′ , giving Δ 0 ′ ′ → p k p Δ 1 ′ ⪰ Δ 1 \Delta''_0 \xrightarrow{p_k}_{p} \Delta'_1 \succeq\Delta_1 Δ 0 ′′ p k p Δ 1 ′ ⪰ Δ 1 .
Note that no probability slack arises: [SUB-⊕ \oplus ⊕ ] preserves the distribution exactly, so the supertype commits at precisely p k p_k p k .
p : ⨁ 1 : q ! ℓ k ⟨ B k ⟩ . T k → p : q ! ℓ k ⟨ B k ⟩ 1 p : T k q : & i ∈ I p i ? ℓ i ( B i ) . T i ′ → q : p k ? ℓ k ( B k ) 1 q : T k ′ p : ⨁ 1 : q ! ℓ k ⟨ B k ⟩ . T k , q : & i ∈ I p i ? ℓ i ( B i ) . T i ′ → ( p , q ) ℓ k 1 p : T k , q : T k ′ (52) \frac{
\begin{gathered}
\mathbf{p} : \bigoplus1 : q!\ell_k\langle B_k\rangle.T_k
\xrightarrow{p:q!\ell_k\langle B_k\rangle}_{1}
\mathbf{p} : T_k
\qquad
\mathbf{q} : \mathbin{\&}_{i\in I} p_i ?\ell_i(B_i).T'_i
\xrightarrow{q:p_k?\ell_k(B_k)}_{1}
\mathbf{q} : T'_k
\end{gathered}
}{
\mathbf{p} : \bigoplus1 : q!\ell_k\langle B_k\rangle.T_k,\ \mathbf{q} : \mathbin{\&}_{i\in I} p_i ?\ell_i(B_i).T'_i
\xrightarrow{(p,q)\ell_k}_{1}
\mathbf{p} : T_k,\ \mathbf{q} : T'_k
} \tag*{(52)} p : ⨁ 1 : q ! ℓ k ⟨ B k ⟩ . T k , q : & i ∈ I p i ? ℓ i ( B i ) . T i ′ ( p , q ) ℓ k 1 p : T k , q : T k ′ p : ⨁ 1 : q ! ℓ k ⟨ B k ⟩ . T k p : q ! ℓ k ⟨ B k ⟩ 1 p : T k q : & i ∈ I p i ? ℓ i ( B i ) . T i ′ q : p k ? ℓ k ( B k ) 1 q : T k ′ (52)
We have from Δ 0 ⪯ Δ 0 ′ \Delta_0 \preceq\Delta'_0 Δ 0 ⪯ Δ 0 ′ , componentwise: – Δ 0 ( q ) ⪯ Δ 0 ′ ( q ) \Delta_0(q) \preceq\Delta'_0(q) Δ 0 ( q ) ⪯ Δ 0 ′ ( q ) : by [SUB-& \& & ] then Δ 0 ′ ( q ) = & i ∈ I ′ p i ′ ? ℓ i ( B i ) . T i ′ ′ \Delta'_0(q) = \mathbin{\&}_{i\in I'} p'_i ?\ell_i(B_i).T''_i Δ 0 ′ ( q ) = & i ∈ I ′ p i ′ ? ℓ i ( B i ) . T i ′′ with I ′ ⊆ I I' \subseteq I I ′ ⊆ I and T i ′ ⪯ T i ′ ′ T'_i \preceq T''_i T i ′ ⪯ T i ′′ for all i ∈ I i \in I i ∈ I ; – Δ 0 ( p ) ⪯ Δ 0 ′ ( p ) \Delta_0(p) \preceq\Delta'_0(p) Δ 0 ( p ) ⪯ Δ 0 ′ ( p ) : the subtype is a committed singleton, so by [SUB-⊕ \oplus ⊕ ] the matching (summand of the) supertype is the same singleton ⨁ 1 : q ! ℓ k ⟨ B k ⟩ . T k ′ ′ \bigoplus1 : q!\ell_k\langle B_k\rangle.T''_k ⨁ 1 : q ! ℓ k ⟨ B k ⟩ . T k ′′ with T k ⪯ T k ′ ′ T_k \preceq T''_k T k ⪯ T k ′′ — a proper distribution is never a supertype of a singleton, as [SUB-⊕ \oplus ⊕ ] preserves probabilities exactly. By either [SUB-⊕ \oplus ⊕ ] directly or [SUB-Σ \Sigma Σ ] embedding the singleton into a sum, we consider each in turn:
by [SUB-⊕] (case 1a): Δ 0 ′ ( p ) = ⨁ 1 : q ! ℓ k ⟨ B k ⟩ . T k ′ ′ \Delta'_0(p)=\bigoplus1:q!\ell_k\langle B_k\rangle.T''_k Δ 0 ′ ( p ) = ⨁ 1 : q ! ℓ k ⟨ B k ⟩ . T k ′′ with Δ 0 ′ ( p ) ̸ → n \Delta'_0(p)\not\to_n Δ 0 ′ ( p ) → n , then as safe ( Δ 0 ′ ) \operatorname{safe}(\Delta'_0) safe ( Δ 0 ′ ) and p p p ’s (sole) output ℓ k \ell_k ℓ k towards q q q is enabled, q q q must be able to receive ℓ k \ell_k ℓ k , i.e. k ∈ I ′ k\in I' k ∈ I ′ :
Δ 0 ′ → ( p , q ) ℓ k 1 p : T k ′ ′ , q : T k ′ ′ = : Δ 1 ′ (53) \Delta'_0 \xrightarrow{(p,q)\ell_k}_1 p:T''_k,\ q:T''_k =:\Delta'_1 \tag*{(53)} Δ 0 ′ ( p , q ) ℓ k 1 p : T k ′′ , q : T k ′′ =: Δ 1 ′ (53)
with Δ 1 = p : T k , q : T k ′ ≤ Δ 1 ′ \Delta_1=p:T_k,\ q:T'_k\leq\Delta'_1 Δ 1 = p : T k , q : T k ′ ≤ Δ 1 ′ since T k ≤ T k ′ ′ T_k\leq T''_k T k ≤ T k ′′ and T k ′ ≤ T k ′ ′ T'_k\leq T''_k T k ′ ≤ T k ′′ ; this is clause (1a) with a lone synchronisation (p = 1 p=1 p = 1 );
by [SUB-Σ] (case 1b): first commit by [CT-ND] to the summand with ⨁ 1 : q ! ℓ k ⟨ B k ⟩ . T k ≤ ⨁ 1 : q ! ℓ k ⟨ B k ⟩ . T k ′ ′ \bigoplus1:q!\ell_k\langle B_k\rangle.T_k\leq\bigoplus1:q!\ell_k\langle B_k\rangle.T''_k ⨁ 1 : q ! ℓ k ⟨ B k ⟩ . T k ≤ ⨁ 1 : q ! ℓ k ⟨ B k ⟩ . T k ′′ , giving Δ 0 ′ → p : τ n Δ ′ ′ \Delta'_0\xrightarrow{p:\tau}_n\Delta'' Δ 0 ′ p : τ n Δ ′′ with Δ 0 ≤ Δ ′ ′ \Delta_0\leq\Delta'' Δ 0 ≤ Δ ′′ . As safety is preserved by → n \to_n → n (Def. 3.12), the previous bullet applies to Δ ′ ′ \Delta'' Δ ′′ , giving Δ ′ ′ → ( p , q ) ℓ k 1 Δ 1 ′ ≥ Δ 1 \Delta''\xrightarrow{(p,q)\ell_k}_1\Delta'_1\geq\Delta_1 Δ ′′ ( p , q ) ℓ k 1 Δ 1 ′ ≥ Δ 1 .
Δ s → α t Δ s ′ t ∈ { p , n } Δ s , r : T r → α t Δ s ′ , r : T r ′ (54) \frac{\Delta_s\xrightarrow{\alpha}_t\Delta'_s\quad t\in\{p,n\}}{\Delta_s,r:T_r\xrightarrow{\alpha}_t\Delta'_s,r:T'_r} \tag*{(54)} Δ s , r : T r α t Δ s ′ , r : T r ′ Δ s α t Δ s ′ t ∈ { p , n } (54)
so Δ 0 = Δ s , r : T r → α t Δ s ′ , r : T r ′ = Δ 1 \Delta_0=\Delta_s,r:T_r\xrightarrow{\alpha}_t\Delta'_s,r:T'_r=\Delta_1 Δ 0 = Δ s , r : T r α t Δ s ′ , r : T r ′ = Δ 1 . As ≤ \leq ≤ is componentwise, Δ 0 ′ = Δ s ′ ′ , r : T r ′ \Delta'_0=\Delta''_s,r:T'_r Δ 0 ′ = Δ s ′′ , r : T r ′ with T r ≤ T r ′ T_r\leq T'_r T r ≤ T r ′ and Δ s ≤ Δ s ′ ′ \Delta_s\leq\Delta''_s Δ s ≤ Δ s ′′ and by case 2 of Lemma C.2 safe ( Δ s ′ ′ ) \operatorname{safe}(\Delta''_s) safe ( Δ s ′′ ) . Since r r r is not a participant of α \alpha α (now one of ( p , q ) ℓ (p,q)\ell ( p , q ) ℓ , p : τ p:\tau p : τ , p : p p:p p : p ), the role p p p lies in dom ( Δ s ) \operatorname{dom}(\Delta_s) dom ( Δ s ) and the case split on Δ 0 ′ ( p ) = Δ s ′ ′ ( p ) \Delta'_0(p)=\Delta''_s(p) Δ 0 ′ ( p ) = Δ s ′′ ( p ) is that of the IH applied to Δ s ≤ Δ s ′ ′ \Delta_s\leq\Delta''_s Δ s ≤ Δ s ′′ ; re-framing each resulting transition and subtyping with r : T r r:T_r r : T r (r : T r ′ r:T'_r r : T r ′ resp.) preserves the statement, as T r ≤ T r ′ T_r\leq T'_r T r ≤ T r ′ .
p : T { μ t . T / t } → α t p : T ′ t ∈ { p , n } p : μ t . T → α t p : T ′ (55) \frac{p:T\{\mu t.T/t\}\xrightarrow{\alpha}_t p:T'\quad t\in\{p,n\}}{p:\mu t.T\xrightarrow{\alpha}_t p:T'} \tag*{(55)} p : μ t . T α t p : T ′ p : T { μ t . T / t } α t p : T ′ t ∈ { p , n } (55)
i.e. Δ 0 = p : μ t . T \Delta_0=p:\mu t.T Δ 0 = p : μ t . T and Δ 1 = p : T ′ \Delta_1=p:T' Δ 1 = p : T ′ . Since ≤ \leq ≤ is preserved under unfolding, p : T { μ t . T / t } ≤ Δ 0 ′ p:T\{\mu t.T/t\}\leq\Delta'_0 p : T { μ t . T / t } ≤ Δ 0 ′ , and the IH on the premise—same Δ 0 ′ \Delta'_0 Δ 0 ′ , same target Δ 1 \Delta_1 Δ 1 —gives the claim verbatim.
Definition C.12 (Synchronised subtyping). We write Δ ⋉ Δ ^ \Delta\ltimes\hat{\Delta} Δ ⋉ Δ ^ when Δ ≤ Δ ^ \Delta\leq\hat{\Delta} Δ ≤ Δ ^ , safe ( Δ ^ ) \operatorname{safe}(\hat{\Delta}) safe ( Δ ^ ) , and the supertype is committed wherever the subtype is:
∀ r ∈ dom ( Δ ) : Δ ( r ) ̸ → n ⇒ Δ ^ ( r ) ̸ → n . \forall r\in\operatorname{dom}(\Delta):\Delta(r)\not\to_n\mathrel{\Rightarrow}\hat{\Delta}(r)\not\to_n. ∀ r ∈ dom ( Δ ) : Δ ( r ) → n ⇒ Δ ^ ( r ) → n . Intuitively, Δ ^ \hat{\Delta} Δ ^ has resolved its non-determinism at least as far as Δ \Delta Δ has; the converse implication can fail, as a committed Δ ^ ( r ) \hat{\Delta}(r) Δ ^ ( r ) may factor a sum of Δ ( r ) \Delta(r) Δ ( r ) (Rem. C.2 ). Synchronised contexts enable exactly the same communications:
Lemma C.13 (Enabledness under synchronised subtyping (no phantoms)). Let Δ ⋉ Δ ^ \Delta\ltimes\hat{\Delta} Δ ⋉ Δ ^ . Then:
(1) ∀ p , q , ℓ : Δ ( p ) ̸ → n \forall p,q,\ell:\Delta(p)\not\to_n ∀ p , q , ℓ : Δ ( p ) → n implies Δ → ( p , q ) ℓ 1 \Delta\xrightarrow{(p,q)\ell}_1 Δ ( p , q ) ℓ 1 iff Δ ^ → ( p , q ) ℓ 1 \hat{\Delta}\xrightarrow{(p,q)\ell}_1 Δ ^ ( p , q ) ℓ 1
(2) ∀ p , p : Δ ( p ) ̸ → n \forall p,\mathsf{p}:\Delta(p)\not\to_n ∀ p , p : Δ ( p ) → n implies Δ → p : p p \Delta\xrightarrow{p:\mathsf{p}}_p Δ p : p p iff Δ ^ → p : p p \hat{\Delta}\xrightarrow{p:\mathsf{p}}_p Δ ^ p : p p
(3) ∀ r : Δ ^ ( r ) → n \forall r:\hat{\Delta}(r)\to_n ∀ r : Δ ^ ( r ) → n implies Δ ( r ) → n \Delta(r)\to_n Δ ( r ) → n .
Proof. (3) is the contrapositive of the condition in Def. C.12 . (1), (2): as Δ ( p ) ̸ → n \Delta(p)\not\to_n Δ ( p ) → n , by that condition Δ ^ ( p ) ̸ → n \hat{\Delta}(p)\not\to_n Δ ^ ( p ) → n too, so Δ ( p ) ≤ Δ ^ ( p ) \Delta(p)\leq\hat{\Delta}(p) Δ ( p ) ≤ Δ ^ ( p ) is by [SUB-⊕]: both carry the same branches with the same probabilities towards the same partners. (2) is immediate: one side is a proper distribution iff the other is, resolving the corresponding branch at the same p p p ; no partner is involved. For (1), both p p p -components are the same singleton selection, and by [SUB-&] the branches of Δ ^ ( q ) \hat{\Delta}(q) Δ ^ ( q ) are a subset of those of Δ ( q ) \Delta(q) Δ ( q ) :
(⇒) If Δ → ( p , q ) ℓ 1 \Delta\xrightarrow{(p,q)\ell}_1 Δ ( p , q ) ℓ 1 then Δ ^ ( p ) → p : q ! ℓ ⟨ B ⟩ 1 \hat{\Delta}(p)\xrightarrow{p:q!\ell\langle B\rangle}_1 Δ ^ ( p ) p : q ! ℓ ⟨ B ⟩ 1 , and safe ( Δ ^ ) \operatorname{safe}(\hat{\Delta}) safe ( Δ ^ ) (Def. 3.12) guarantees Δ ^ ( q ) → q : p ? ℓ ⟨ B ⟩ 1 \hat{\Delta}(q)\xrightarrow{q:p?\ell\langle B\rangle}_1 Δ ^ ( q ) q : p ? ℓ ⟨ B ⟩ 1 .
(⇐) If Δ ^ ( p , q ) ℓ → 1 \widehat{\Delta}^{(p,q)\ell} \mathrel{\xrightarrow{1}} Δ ( p , q ) ℓ 1 then Δ ( p ) → p : q ! ℓ ⟨ B ⟩ 1 \Delta(p) \mathrel{\xrightarrow{p:q!\ell\langle B\rangle}_{1}} Δ ( p ) p : q ! ℓ ⟨ B ⟩ 1 , and by contravariance of [sub-&], ℓ \ell ℓ is offered by q q q too: Δ ( q ) → q : p ? ℓ ( B ) 1 \Delta(q) \mathrel{\xrightarrow{q:p?\ell(B)}_{1}} Δ ( q ) q : p ? ℓ ( B ) 1 . □
Synchronisation
Lemma C.14 (Synchronisation). If Δ ≤ Δ ′ \Delta\leq\Delta' Δ ≤ Δ ′ and safe ( Δ ′ ) \operatorname{safe}(\Delta') safe ( Δ ′ ) then Δ ′ → ∗ n Δ ^ \Delta' \mathrel{\xrightarrow{*}_{n}} \widehat{\Delta} Δ ′ ∗ n Δ with Δ ⋉ Δ ^ \Delta\ltimes\widehat{\Delta} Δ ⋉ Δ .
Proof. Consider any p p p with Δ ( p ) ̸ → n \Delta(p) \not\mathrel{\to_n} Δ ( p ) → n but Δ ′ ( p ) → n \Delta'(p) \mathrel{\to_n} Δ ′ ( p ) → n . We must have Δ ′ ( p ) = ∑ i ∈ I T i \Delta'(p) = \sum_{i\in I} T_i Δ ′ ( p ) = ∑ i ∈ I T i with ∣ I ∣ > 1 |I| > 1 ∣ I ∣ > 1 (as Δ ′ ( p ) → n \Delta'(p) \mathrel{\to_n} Δ ′ ( p ) → n ), from [sub-Σ] we know ∃ i ∈ I : T i ≥ Δ ( p ) \exists i \in I : T_i \geq\Delta(p) ∃ i ∈ I : T i ≥ Δ ( p ) , committing to this T i T_i T i through a transition on [ct-nd] gives: Δ ′ → p : τ n Δ ′ ′ \Delta' \mathrel{\xrightarrow{p:\tau}_{n}} \Delta'' Δ ′ p : τ n Δ ′′ where Δ ≤ Δ ′ ′ \Delta\leq\Delta'' Δ ≤ Δ ′′ , safe ( Δ ′ ′ ) \operatorname{safe}(\Delta'') safe ( Δ ′′ ) (by Def. 3.12) and Δ ′ ′ ( p ) ̸ → n \Delta''(p) \not\mathrel{\to_n} Δ ′′ ( p ) → n . After at most ∣ dom ( Δ ) ∣ − 1 |\operatorname{dom}(\Delta)| - 1 ∣ dom ( Δ ) ∣ − 1 more steps Δ ′ ′ → ∗ n Δ ^ \Delta'' \mathrel{\xrightarrow{*}_{n}} \widehat{\Delta} Δ ′′ ∗ n Δ every such p p p is committed, giving Δ ⋉ Δ ^ \Delta\ltimes\widehat{\Delta} Δ ⋉ Δ . □
One-step preservation
Lemma C.15 (One-step preservation). Let Δ ⋉ Δ ^ \Delta\ltimes\widehat{\Delta} Δ ⋉ Δ and Δ → α Δ 1 \Delta\mathrel{\xrightarrow{\alpha}} \Delta_1 Δ α Δ 1 . Then there is Δ ^ 1 \widehat{\Delta}_1 Δ 1 with Δ 1 ⋉ Δ ^ 1 \Delta_1 \ltimes\widehat{\Delta}_1 Δ 1 ⋉ Δ 1 , where:
if α = ( p , q ) ℓ \alpha= (p,q)\ell α = ( p , q ) ℓ , then Δ ^ → ( p , q ) ℓ 1 ⋅ → ∗ n Δ ^ 1 \widehat{\Delta} \mathrel{\xrightarrow{(p,q)\ell}_{1}} \mathord{\cdot} \mathrel{\xrightarrow{*}_{n}} \widehat{\Delta}_1 Δ ( p , q ) ℓ 1 ⋅ ∗ n Δ 1 : the same communication, followed by nd-steps;
if α = r : τ \alpha= r:\tau α = r : τ , then either Δ ^ → r : τ n Δ ^ 1 \widehat{\Delta} \mathrel{\xrightarrow{r:\tau}_{n}} \widehat{\Delta}_1 Δ r : τ n Δ 1 or Δ ^ 1 = Δ ^ \widehat{\Delta}_1 = \widehat{\Delta} Δ 1 = Δ (no step; the factored situation of Rem. C.2);
if α = p : p \alpha= p:p α = p : p at probability p p p , then Δ ^ → p : p p Δ ^ 1 \widehat{\Delta} \mathrel{\xrightarrow{p:p}_{p}} \widehat{\Delta}_1 Δ p : p p Δ 1 : the same prob-step, at the same probability.
Proof. (1) A synchronisation fires only from a singleton selection, so Δ ( p ) ̸ → n \Delta(p) \not\mathrel{\to_n} Δ ( p ) → n and, by Def. C.12 , Δ ^ ( p ) ̸ → n \widehat{\Delta}(p) \not\mathrel{\to_n} Δ ( p ) → n ; Lemma C.11(1a) gives Δ ^ → ( p , q ) ℓ 1 Δ 1 ′ \widehat{\Delta} \mathrel{\xrightarrow{(p,q)\ell}_{1}} \Delta'_1 Δ ( p , q ) ℓ 1 Δ 1 ′ with Δ 1 ≤ Δ 1 ′ \Delta_1 \leq\Delta'_1 Δ 1 ≤ Δ 1 ′ , and Lemma C.14 re-synchronises Δ 1 ′ \Delta'_1 Δ 1 ′ to Δ ^ 1 \widehat{\Delta}_1 Δ 1 with Δ 1 ⋉ Δ ^ 1 \Delta_1 \ltimes\widehat{\Delta}_1 Δ 1 ⋉ Δ 1 (only the continuations at p p p and q q q may need committing). (2) By Lemma C.11[2 ] : if Δ ^ ( r ) → n \widehat{\Delta}(r) \mathrel{\to_n} Δ ( r ) → n , case (2b) gives Δ ^ → r : τ n Δ ^ 1 \widehat{\Delta} \mathrel{\xrightarrow{r:\tau}_{n}} \widehat{\Delta}_1 Δ r : τ n Δ 1 with Δ 1 ≤ Δ ^ 1 \Delta_1 \leq\widehat{\Delta}_1 Δ 1 ≤ Δ 1 ; otherwise case (2a) gives Δ 1 ≤ Δ ^ = : Δ ^ 1 \Delta_1 \leq\widehat{\Delta} =: \widehat{\Delta}_1 Δ 1 ≤ Δ =: Δ 1 . Synchronisation holds without further steps: the only component newly committed in Δ 1 \Delta_1 Δ 1 is r r r , and Δ ^ 1 ( r ) \widehat{\Delta}_1(r) Δ 1 ( r ) is committed (in (2b) by the step just taken, in (2a) by hypothesis); all other components are unchanged on both sides. (3) A prob-step p : p p:p p : p fires only from a ( Σ (\Sigma ( Σ -committed) proper distribution, so as in (1), Δ ^ ( p ) ̸ → n \widehat{\Delta}(p) \not\mathrel{\to_n} Δ ( p ) → n , and Lemma C.11(3a) gives Δ ^ → p : p p Δ ^ 1 \widehat{\Delta} \mathrel{\xrightarrow{p:p}_{p}} \widehat{\Delta}_1 Δ p : p p Δ 1 with Δ 1 ≤ Δ ^ 1 \Delta_1 \leq\widehat{\Delta}_1 Δ 1 ≤ Δ 1 . Synchronisation needs no further steps: only p p p changes, both sides becoming singleton selections, hence ̸ → n \not\mathrel{\to_n} → n ; all else is unchanged. □
Lock-step path
Corollary C.16 (Lock-step path). Let Δ 0 ≤ Δ 0 ′ \Delta_0 \leq\Delta'_0 Δ 0 ≤ Δ 0 ′ with safe ( Δ 0 ′ ) \operatorname{safe}(\Delta'_0) safe ( Δ 0 ′ ) , and let ξ = Δ 0 → α 1 Δ 1 → α 2 ⋯ \xi= \Delta_0 \mathrel{\xrightarrow{\alpha_1}} \Delta_1 \mathrel{\xrightarrow{\alpha_2}} \cdots ξ = Δ 0 α 1 Δ 1 α 2 ⋯ be a (finite or infinite) path. Then there is a path ξ ′ \xi' ξ ′ from Δ 0 ′ \Delta'_0 Δ 0 ′ and states Δ ^ 0 , Δ ^ 1 , … \widehat{\Delta}_0,\widehat{\Delta}_1,\ldots Δ 0 , Δ 1 , … along it—the stages of ξ ′ \xi' ξ ′ —with Δ i ⋉ Δ ^ i \Delta_i \ltimes\widehat{\Delta}_i Δ i ⋉ Δ i for all i i i and Δ 0 ′ → ∗ n Δ ^ 0 \Delta'_0 \mathrel{\xrightarrow{*}_{n}} \widehat{\Delta}_0 Δ 0 ′ ∗ n Δ 0 , such that the segment of ξ ′ \xi' ξ ′ from Δ ^ i \widehat{\Delta}_i Δ i to Δ ^ i + 1 \widehat{\Delta}_{i+1} Δ i + 1 is:
the same communication α i + 1 \alpha_{i+1} α i + 1 (at probability 1 1 1 ), followed by finitely many → n \to_n → n ;
the same prob-step α i + 1 = p : p \alpha_{i+1}=p:p α i + 1 = p : p , at the same probability;
at most one nd-step → n \to_n → n , if α i + 1 = r : τ \alpha_{i+1}=r:\tau α i + 1 = r : τ (taken iff Δ ^ i ( r ) → n \widehat{\Delta}_i(r) \mathrel{\to_n} Δ i ( r ) → n ).
In particular ξ \xi ξ and ξ ′ \xi' ξ ′ perform the same sequence of communications and prob-steps, with the same labels and probabilities; as all padding is by nd-steps, corresponding finite prefixes carry the same product of transition probabilities.
Proof. Lemma C.14 gives Δ 0 ′ → ∗ n Δ ^ 0 \Delta'_0 \mathrel{\xrightarrow{*}_{n}} \widehat{\Delta}_0 Δ 0 ′ ∗ n Δ 0 with Δ 0 ⋉ Δ ^ 0 \Delta_0 \ltimes\widehat{\Delta}_0 Δ 0 ⋉ Δ 0 ; iterating Lemma C.15 along ξ \xi ξ (cases (1)/(3)/(2) respectively) gives each segment and stage. □
Scheduler transfer along subtyping
Lemma C.17 (Scheduler transfer along subtyping). Let Δ ≤ Δ ′ \Delta\leq\Delta' Δ ≤ Δ ′ with safe ( Δ ′ ) \operatorname{safe}(\Delta') safe ( Δ ′ ) , and let ϕ ∈ Φ F Δ \phi\in\Phi_F^\Delta ϕ ∈ Φ F Δ be a fair scheduler. Then there exists a fair scheduler ϕ ′ ∈ Φ F Δ ′ \phi' \in\Phi_F^{\Delta'} ϕ ′ ∈ Φ F Δ ′ and a mapping ( ⋅ ) † : Ξ ϕ ( Δ ) → Ξ ϕ ′ ( Δ ′ ) (\cdot)^\dagger: \Xi_\phi(\Delta) \to\Xi_{\phi'}(\Delta') ( ⋅ ) † : Ξ ϕ ( Δ ) → Ξ ϕ ′ ( Δ ′ ) such that:
(measure-isomorphic) ( ⋅ ) † (\cdot)^\dagger ( ⋅ ) † is a bijection of Ξ ϕ ( Δ ) \Xi_\phi(\Delta) Ξ ϕ ( Δ ) onto Ξ ϕ ′ ( Δ ′ ) \Xi_{\phi'}(\Delta') Ξ ϕ ′ ( Δ ′ ) , and E ⊆ Ξ ϕ ( Δ ) E \subseteq\Xi_\phi(\Delta) E ⊆ Ξ ϕ ( Δ ) is an event iff E † E^\dagger E † is, with P Δ ϕ ( E ) = P Δ ′ ϕ ′ ( E † ) P^\phi_\Delta(E) = P^{\phi'}_{\Delta'}(E^\dagger) P Δ ϕ ( E ) = P Δ ′ ϕ ′ ( E † ) ;
(property-reflecting) ξ \xi ξ reaches a deadlocked context iff ξ † \xi^\dagger ξ † does; and if ξ † \xi^\dagger ξ † is live, then so is ξ \xi ξ .
Proof. Take any path of the DTMC induced by ϕ \phi ϕ : Δ → α 1 Δ 1 → α 2 ⋯ ∈ Ξ ϕ ( Δ ) \Delta\xrightarrow{\alpha_1} \Delta_1 \xrightarrow{\alpha_2} \cdots\in\Xi_{\phi}(\Delta) Δ α 1 Δ 1 α 2 ⋯ ∈ Ξ ϕ ( Δ ) . We map it to its lock-step path ξ ′ \xi' ξ ′ with stages Δ ^ i \hat{\Delta}_i Δ ^ i : Δ i ⋉ Δ ^ i \Delta_i \ltimes\hat{\Delta}_i Δ i ⋉ Δ ^ i (Cor. C.16), made unique by fixing a total order on participants and committing p → τ n p \xrightarrow{\tau}_{n} p τ n before q → τ n q \xrightarrow{\tau}_{n} q τ n if p ≺ q p \prec q p ≺ q ; we write ξ † = ξ ′ \xi^\dagger= \xi' ξ † = ξ ′ for this mapping. The scheduler ϕ ′ \phi' ϕ ′ then simply mirrors ϕ \phi ϕ ’s decisions through the correspondence, performing the canonical padding steps in between.
ξ ′ \xi' ξ ′ is fair. We discharge the three fairness requirements on ξ ′ \xi' ξ ′ from those on ξ \xi ξ . Throughout we use that internal enabledness is persistent : a participant at a proper sum (resp. proper distribution) can only move by its own nd-step (resp. prob-step), so it stays enabled until it moves.
i) (internal steps ) Suppose towards a contradiction that an internal step of r r r (r : τ r\mathord{:}\tau r : τ or r : p r\mathord{:}p r : p ) is enabled infinitely often but taken finitely often in ξ ′ \xi' ξ ′ ; by persistence, from some stage m m m on it is continuously enabled and r r r never moves in ξ ′ \xi' ξ ′ . Then r r r ’s step is eventually continuously enabled in ξ \xi ξ too (Lemma C.13 (2,3)) — for a prob-step, Δ i ( r ) \Delta_i(r) Δ i ( r ) may by [sub-Σ \Sigma Σ ] first be a factored proper sum (Rem. C.2 ), whose resolution fairness of ξ \xi ξ provides, absorbed in ξ ′ \xi' ξ ′ without movement (Lemma C.15(2)). By fairness of ξ \xi ξ , r r r then takes its step at some j ≥ m j \ge m j ≥ m , and Lemma C.15(2,3) mirrors it in ξ ′ \xi' ξ ′ — contradiction.
ii) (communication ) Suppose a = ( p , q ) ℓ a = (p,q)\ell a = ( p , q ) ℓ is enabled infinitely often in ξ ′ \xi' ξ ′ ; as ξ \xi ξ and ξ ′ \xi' ξ ′ share their communication sequence, it suffices that p p p communicates infinitely often in ξ \xi ξ . Suppose not: after its last communication, fairness of ξ ′ \xi' ξ ′ eventually resolves p p p ’s nd- and prob-steps, so from some stage N N N on Δ i ( p ) = Δ N ( p ) \Delta_i(p) = \Delta_N(p) Δ i ( p ) = Δ N ( p ) is a singleton selection, a branching, or end. There are infinitely many i ≥ N i \ge N i ≥ N with Δ ^ i → a 1 \hat{\Delta}_i \xrightarrow{a}_{1} Δ ^ i a 1 , where Δ ^ i ( p ) \hat{\Delta}_i(p) Δ ^ i ( p ) is a singleton selection; being its subtype, Δ N ( p ) \Delta_N(p) Δ N ( p ) is by [sub-⊕ \oplus ⊕ ] the same singleton, so Lemma C.13 (1) gives Δ i → a 1 \Delta_i \xrightarrow{a}_{1} Δ i a 1 . Thus a a a is enabled infinitely often in ξ \xi ξ , and fairness makes p p p communicate infinitely often — contradiction.
Finally, we note that images are complete paths — let ξ ∈ Ξ ϕ ( Δ ) \xi\in\Xi_{\phi}(\Delta) ξ ∈ Ξ ϕ ( Δ ) . If ξ \xi ξ is finite with Δ ∣ ξ ∣ ↛ \Delta_{|\xi|} \not\to Δ ∣ ξ ∣ → , then its final stage Δ ^ \hat{\Delta} Δ ^ satisfies Δ ∣ ξ ∣ ⋉ Δ ^ \Delta_{|\xi|} \ltimes\hat{\Delta} Δ ∣ ξ ∣ ⋉ Δ ^ , and Δ ^ ↛ \hat{\Delta} \not\to Δ ^ → : no nd-step by Def. C.12 (the supertype is committed wherever the subtype is, and Δ ∣ ξ ∣ \Delta_{|\xi|} Δ ∣ ξ ∣ enables no nd-step), and no probabilistic step or communication by Lemma C.13 (1,2). Hence ξ † \xi^\dagger ξ † is maximal. If ξ \xi ξ is infinite, we claim ξ † \xi^\dagger ξ † is infinite: ξ \xi ξ can contain no more than ∣ dom ( Δ ) ∣ |\operatorname{dom}(\Delta)| ∣ dom ( Δ ) ∣ consecutive nd-steps, so ξ \xi ξ performs infinitely many communications and probabilistic steps, each mirrored in ξ † \xi^\dagger ξ † by Cor. C.16. Finally, every complete path induced by ϕ ′ \phi' ϕ ′ from Δ ′ \Delta' Δ ′ is by construction the companion of a (unique) ϕ \phi ϕ -path, so ( ⋅ ) † (\cdot)^\dagger ( ⋅ ) † maps Ξ ϕ ( Δ ) \Xi_{\phi}(\Delta) Ξ ϕ ( Δ ) onto Ξ ϕ ′ ( Δ ′ ) \Xi_{\phi'}(\Delta') Ξ ϕ ′ ( Δ ′ ) .
The 2 claims of the lemma now follow:
By the closing paragraph above, ( ⋅ ) † (\cdot)^\dagger ( ⋅ ) † maps Ξ ϕ ( Δ ) \Xi_{\phi}(\Delta) Ξ ϕ ( Δ ) onto Ξ ϕ ′ ( Δ ′ ) \Xi_{\phi'}(\Delta') Ξ ϕ ′ ( Δ ′ ) ; moreover, the cylinder sets of the two DTMCs correspond: for a finite ϕ \phi ϕ -prefix ξ \xi ξ with companion ξ ′ \xi' ξ ′ , Cyl ( ξ ) † = Cyl ( ξ ′ ) \operatorname{Cyl}(\xi)^\dagger= \operatorname{Cyl}(\xi') Cyl ( ξ ) † = Cyl ( ξ ′ ) at equal probability, since the interleaved nd-padding carries probability 1 1 1 . We show injectivity as follows: Consider two ϕ \phi ϕ -induced paths ξ 1 \xi_1 ξ 1 and ξ 2 \xi_2 ξ 2 , they share the scheduler’s selection along their common prefix, so their first difference lies between outcomes of a single scheduled action — necessarily a prob-step, every other action having probability 1 1 1 — and by the lock-step correspondence (Cor. C.16) their images ξ 1 † \xi_1^\dagger ξ 1 † and ξ 2 † \xi_2^\dagger ξ 2 † perform the same probabilistic step, resolved the same way, at the corresponding stage, and hence differ as well.
Deadlock. If ξ \xi ξ ends in a deadlock Δ ∣ ξ ∣ \Delta_{|\xi|} Δ ∣ ξ ∣ , then as shown above ξ † \xi^\dagger ξ † ends in the stuck stage Δ ^ ⪰ Δ ∣ ξ ∣ \hat{\Delta} \succeq\Delta_{|\xi|} Δ ^ ⪰ Δ ∣ ξ ∣ , and the deadlock witness transfers: Δ ∣ ξ ∣ ( p ) ≠ e n d \Delta_{|\xi|}(p) \ne\mathrm{end} Δ ∣ ξ ∣ ( p ) = end gives Δ ^ ( p ) ≠ e n d \hat{\Delta}(p) \ne\mathrm{end} Δ ^ ( p ) = end , as [sub-E N D \mathrm{END} END ] relates end only to end. Conversely, suppose ξ † \xi^\dagger ξ † reaches a deadlocked context; being stuck, it is the endpoint of ξ † \xi^\dagger ξ † , i.e. its final stage Δ ^ \hat{\Delta} Δ ^ . Then ξ \xi ξ is finite: otherwise it performs infinitely many communications and prob-steps (bounded nd-runs, as above), each extending ξ † \xi^\dagger ξ † beyond Δ ^ \hat{\Delta} Δ ^ (Cor. C.16) — contradiction. Being complete, Δ ∣ ξ ∣ ⋉ Δ ^ \Delta_{|\xi|} \ltimes\hat{\Delta} Δ ∣ ξ ∣ ⋉ Δ ^ , and the witness transfers down: Δ ^ ( p ) ≠ e n d \hat{\Delta}(p) \ne\mathrm{end} Δ ^ ( p ) = end forces Δ ∣ ξ ∣ ( p ) ≠ e n d \Delta_{|\xi|}(p) \ne\mathrm{end} Δ ∣ ξ ∣ ( p ) = end by [sub-E N D \mathrm{END} END ]. Hence ξ \xi ξ ends deadlocked.
*Liveness. Suppose ξ † \xi^{\dagger} ξ † is live; we show every pending action along ξ \xi ξ is eventually resolved. If Δ i ( p ) → p : q ! ℓ ⟨ B ⟩ 1 \Delta_i(p) \xrightarrow{p:q!\ell\langle B\rangle}_{1} Δ i ( p ) p : q ! ℓ ⟨ B ⟩ 1 , then Δ i ( p ) \Delta_i(p) Δ i ( p ) is a singleton selection, so by ⋉ \ltimes ⋉ and [sub-⊕ \oplus ⊕ ] the stage Δ ^ i ( p ) \hat{\Delta}_i(p) Δ ^ i ( p ) is the same singleton and the output is pending in ξ † \xi^{\dagger} ξ † ; liveness of ξ † \xi^{\dagger} ξ † provides a communication of p p p at some later point, which lies in the shared communication sequence of the lock-step sequence, and hence occurs in ξ \xi ξ . If Δ i ( q ) → q : p ? ℓ ( B ) 1 \Delta_i(q) \xrightarrow{q:p?\ell(B)}_{1} Δ i ( q ) q : p ? ℓ ( B ) 1 , then by contravariance of [sub-& \& & ] the stage Δ ^ i ( q ) \hat{\Delta}_i(q) Δ ^ i ( q ) offers a (subset of q q q 's) input, pending in ξ † \xi^{\dagger} ξ † ; liveness of ξ † \xi^{\dagger} ξ † provides a communication involving q q q as receiver, shared with ξ \xi ξ likewise. Hence ξ \xi ξ is live.
Corollary C.18 (deadlock-freedom is downwards-closed). If Δ ⪯ Δ ′ \Delta\preceq\Delta' Δ ⪯ Δ ′ with sdf ( Δ ′ ) \operatorname{sdf}(\Delta') sdf ( Δ ′ ) then df ( Δ ) \operatorname{df}(\Delta) df ( Δ ) .
Proof. Suppose Δ ⟶ ∗ Δ n \Delta\longrightarrow^{*} \Delta_n Δ ⟶ ∗ Δ n with deadlock ( Δ n ) \operatorname{deadlock}(\Delta_n) deadlock ( Δ n ) ; extend this finite path to a complete path ξ \xi ξ , induced by a fair scheduler. By Lemma C.17(2), ξ † \xi^{\dagger} ξ † reaches a deadlocked context, contradicting df ( Δ ′ ) \operatorname{df}(\Delta') df ( Δ ′ ) . □ \square □
Corollary C.19 (liveness is downwards-closed). If Δ ⪯ Δ ′ \Delta\preceq\Delta' Δ ⪯ Δ ′ with slive ( Δ ′ ) \operatorname{slive}(\Delta') slive ( Δ ′ ) then live ( Δ ) \operatorname{live}(\Delta) live ( Δ ) .
Proof. Take any fair complete path ξ ∈ Ξ ( Δ ) \xi\in\Xi(\Delta) ξ ∈ Ξ ( Δ ) , induced by a fair scheduler. Then ξ † ∈ Ξ ϕ ′ ( Δ ′ ) \xi^{\dagger} \in\Xi_{\phi'}(\Delta') ξ † ∈ Ξ ϕ ′ ( Δ ′ ) is fair (Lemma C.17), hence live by live ( Δ ′ ) \operatorname{live}(\Delta') live ( Δ ′ ) , hence ξ \xi ξ is live by Lemma C.17(2). As ξ \xi ξ was arbitrary, live ( Δ ) \operatorname{live}(\Delta) live ( Δ ) . □ \square □
Proposition 4.18 (⪯ \preceq ⪯ -monotonicity). (Proof in §C.3). Let Δ ⪯ Δ ′ \Delta\preceq\Delta' Δ ⪯ Δ ′ and safe ( Δ ′ ) \operatorname{safe}(\Delta') safe ( Δ ′ ) , then: (1) φ ( Δ ′ ) ⟹ φ ( Δ ) \varphi(\Delta') \Longrightarrow\varphi(\Delta) φ ( Δ ′ ) ⟹ φ ( Δ ) if φ ∈ { safe , df , live } \varphi\in\{\operatorname{safe}, \operatorname{df}, \operatorname{live}\} φ ∈ { safe , df , live } ; and (2) P df min ( Δ ′ ) ≤ P df min ( Δ ) \mathbb{P}^{\min}_{\operatorname{df}}(\Delta') \le\mathbb{P}^{\min}_{\operatorname{df}}(\Delta) P df m i n ( Δ ′ ) ≤ P df m i n ( Δ ) and P live min ( Δ ′ ) ≤ P live min ( Δ ) \mathbb{P}^{\min}_{\operatorname{live}}(\Delta') \le\mathbb{P}^{\min}_{\operatorname{live}}(\Delta) P live m i n ( Δ ′ ) ≤ P live m i n ( Δ ) .
Proof. Each of (1) and (2) are proved in turn:
(1)
i) safe ( Δ ′ ) ⟹ safe ( Δ ) \operatorname{safe}(\Delta') \Longrightarrow\operatorname{safe}(\Delta) safe ( Δ ′ ) ⟹ safe ( Δ ) by Lemma C.2(3)
ii) df ( Δ ′ ) ⟹ df ( Δ ) \operatorname{df}(\Delta') \Longrightarrow\operatorname{df}(\Delta) df ( Δ ′ ) ⟹ df ( Δ ) by Cor. C.18
iii) live ( Δ ′ ) ⟹ live ( Δ ) \operatorname{live}(\Delta') \Longrightarrow\operatorname{live}(\Delta) live ( Δ ′ ) ⟹ live ( Δ ) by Cor. C.19
(2)
i) P df min ( Δ ′ ) ≤ P df min ( Δ ) \mathbb{P}^{\min}_{\operatorname{df}}(\Delta') \le\mathbb{P}^{\min}_{\operatorname{df}}(\Delta) P df m i n ( Δ ′ ) ≤ P df m i n ( Δ ) : take any fair ϕ ∈ Φ F Δ \phi\in\Phi_F^{\Delta} ϕ ∈ Φ F Δ and let ϕ ′ \phi' ϕ ′ , ( ⋅ ) † (\cdot)^{\dagger} ( ⋅ ) † be as in Lemma C.17. By case (2), a path reaches a deadlocked context iff its image does; with bijectivity (case (1)), the deadlock-reaching events on the two sides are therefore each other's images, and case (1) gives P Δ ′ ϕ ′ ( deadlock ) = P Δ ϕ ( deadlock ) \mathbb{P}_{\Delta'}^{\phi'}(\operatorname{deadlock}) = \mathbb{P}_{\Delta}^{\phi}(\operatorname{deadlock}) P Δ ′ ϕ ′ ( deadlock ) = P Δ ϕ ( deadlock ) . As ϕ ′ ∈ Φ F Δ ′ \phi' \in\Phi_F^{\Delta'} ϕ ′ ∈ Φ F Δ ′ ,
max ϕ ′ ′ ∈ Φ F Δ ′ P Δ ′ ϕ ′ ′ ( deadlock ) ≥ P Δ ′ ϕ ′ ( deadlock ) = P Δ ϕ ( deadlock ) , \max_{\phi'' \in\Phi_F^{\Delta'}} \mathbb{P}_{\Delta'}^{\phi''}(\operatorname{deadlock}) \ge\mathbb{P}_{\Delta'}^{\phi'}(\operatorname{deadlock}) = \mathbb{P}_{\Delta}^{\phi}(\operatorname{deadlock}), ϕ ′′ ∈ Φ F Δ ′ max P Δ ′ ϕ ′′ ( deadlock ) ≥ P Δ ′ ϕ ′ ( deadlock ) = P Δ ϕ ( deadlock ) ,
and as ϕ ∈ Φ F Δ \phi\in\Phi_F^{\Delta} ϕ ∈ Φ F Δ was arbitrary,
max ψ ∈ Φ F Δ ′ P Δ ′ ψ ( deadlock ) ≥ max ϕ ∈ Φ F Δ P Δ ϕ ( deadlock ) ; \max_{\psi\in\Phi_F^{\Delta'}} \mathbb{P}_{\Delta'}^{\psi}(\operatorname{deadlock}) \ge\max_{\phi\in\Phi_F^{\Delta}} \mathbb{P}_{\Delta}^{\phi}(\operatorname{deadlock}); ψ ∈ Φ F Δ ′ max P Δ ′ ψ ( deadlock ) ≥ ϕ ∈ Φ F Δ max P Δ ϕ ( deadlock ) ;
subtracting from 1 1 1 flips the inequality, giving P df min ( Δ ′ ) ≤ P df min ( Δ ) \mathbb{P}^{\min}_{\operatorname{df}}(\Delta') \le\mathbb{P}^{\min}_{\operatorname{df}}(\Delta) P df m i n ( Δ ′ ) ≤ P df m i n ( Δ ) .
ii) P live min ( Δ ′ ) ≤ P live min ( Δ ) \mathbb{P}^{\min}_{\operatorname{live}}(\Delta') \le\mathbb{P}^{\min}_{\operatorname{live}}(\Delta) P live m i n ( Δ ′ ) ≤ P live m i n ( Δ ) : take any fair ϕ ∈ Φ F Δ \phi\in\Phi_F^{\Delta} ϕ ∈ Φ F Δ and let ϕ ′ \phi' ϕ ′ , ( ⋅ ) † (\cdot)^{\dagger} ( ⋅ ) † be as in Lemma C.17. Write L = { ξ ∈ Ξ ϕ ( Δ ) ∣ live ( ξ ) } L = \{\xi\in\Xi_{\phi}(\Delta) \mid\operatorname{live}(\xi)\} L = { ξ ∈ Ξ ϕ ( Δ ) ∣ live ( ξ )} , L ′ = { ξ ′ ∈ Ξ ϕ ′ ( Δ ′ ) ∣ live ( ξ ′ ) } L' = \{\xi' \in\Xi_{\phi'}(\Delta') \mid\operatorname{live}(\xi')\} L ′ = { ξ ′ ∈ Ξ ϕ ′ ( Δ ′ ) ∣ live ( ξ ′ )} , and A = { ξ ∈ Ξ ϕ ( Δ ) ∣ live ( ξ † ) } A = \{\xi\in\Xi_{\phi}(\Delta) \mid\operatorname{live}(\xi^{\dagger})\} A = { ξ ∈ Ξ ϕ ( Δ ) ∣ live ( ξ † )} . Since ( ⋅ ) † (\cdot)^{\dagger} ( ⋅ ) † is a bijection of Ξ ϕ ( Δ ) \Xi_{\phi}(\Delta) Ξ ϕ ( Δ ) onto Ξ ϕ ′ ( Δ ′ ) \Xi_{\phi'}(\Delta') Ξ ϕ ′ ( Δ ′ ) (case (1)), A † = L ′ A^{\dagger} = L' A † = L ′ ; hence A A A is an event iff L ′ L' L ′ is—and L ′ L' L ′ is—with P Δ ϕ ( A ) = P Δ ′ ϕ ′ ( L ′ ) \mathbb{P}_{\Delta}^{\phi}(A) = \mathbb{P}_{\Delta'}^{\phi'}(L') P Δ ϕ ( A ) = P Δ ′ ϕ ′ ( L ′ ) by case (1). By case (2), live ( ξ † ) \operatorname{live}(\xi^{\dagger}) live ( ξ † ) implies live ( ξ ) \operatorname{live}(\xi) live ( ξ ) , i.e. A ⊆ L A \subseteq L A ⊆ L . As ϕ ′ \phi' ϕ ′ is one particular fair scheduler of Δ ′ \Delta' Δ ′ while P live min ( Δ ′ ) \mathbb{P}^{\min}_{\operatorname{live}}(\Delta') P live m i n ( Δ ′ ) is an infimum over all of them:
P live min ( Δ ′ ) ≤ P Δ ′ ϕ ′ ( L ′ ) = P Δ ϕ ( A ) ≤ P Δ ϕ ( L ) . \mathbb{P}^{\min}_{\operatorname{live}}(\Delta') \le\mathbb{P}_{\Delta'}^{\phi'}(L') = \mathbb{P}_{\Delta}^{\phi}(A) \le\mathbb{P}_{\Delta}^{\phi}(L). P live m i n ( Δ ′ ) ≤ P Δ ′ ϕ ′ ( L ′ ) = P Δ ϕ ( A ) ≤ P Δ ϕ ( L ) .
As ϕ ∈ Φ F Δ \phi\in\Phi_F^{\Delta} ϕ ∈ Φ F Δ was arbitrary, taking the infimum over ϕ \phi ϕ on the right yields P live min ( Δ ′ ) ≤ P live min ( Δ ) \mathbb{P}^{\min}_{\operatorname{live}}(\Delta') \le\mathbb{P}^{\min}_{\operatorname{live}}(\Delta) P live m i n ( Δ ′ ) ≤ P live m i n ( Δ ) . □ \square □
Proofs for sec:processproperties (Lower bounds on properties checked on transfer to M M M )
Definition C.20 (Distribution reduction semantics ). The internal distribution reductions on sessions and typing contexts, their lifting to distributions, and their reflexive–transitive closure and normalization are defined in Figure 14 . We denote by D M D_M D M and D Δ D_\Delta D Δ distributions over sessions M M M and typing contexts Δ \Delta Δ respectively, and lift singleton states M M M or Δ \Delta Δ to distributions D \mathcal{D} D in the expected way, as { M ↦ 1 } \{M \mapsto1\} { M ↦ 1 } and { Δ ↦ 1 } \{\Delta\mapsto1\} { Δ ↦ 1 } . We use D \mathcal{D} D to refer to either of D M D_M D M and D Δ D_\Delta D Δ when the statement is general enough to warrant it, and C C C to either of M M M or Δ \Delta Δ . We denote by dom ( D ) \operatorname{dom}(\mathcal{D}) dom ( D ) the finite positive support (domain) of D \mathcal{D} D .
Figure 14. Internal distribution reductions of sessions and typing contexts, their lifting to distributions, and normalization. Here C C C ranges over M M M and Δ \Delta Δ , and D D D over D M D_M D M and D Δ D_\Delta D Δ , respectively.
In the figure, D ⇏ \mathcal{D} \not\Rightarrow D ⇒ means ∄ D ′ , α : D ⇒ D ′ \nexists\mathcal{D}', \alpha: \mathcal{D} \Rightarrow\mathcal{D}' ∄ D ′ , α : D ⇒ D ′ and we say that D \mathcal{D} D is in “communication normal-form” D ⊨ C o m m N F \mathcal{D} \models\mathrm{CommNF} D ⊨ CommNF iff D ⇏ \mathcal{D} \not\Rightarrow D ⇒ and note that:
D ⊨ C o m m N F ⟺ ∀ C ∈ dom ( D ) : C ⊨ C o m m N F . \mathcal{D} \models\mathrm{CommNF} \Longleftrightarrow\forall C \in\operatorname{dom}(\mathcal{D}) : C \models\mathrm{CommNF}. D ⊨ CommNF ⟺ ∀ C ∈ dom ( D ) : C ⊨ CommNF .
Definition C.21 (Typing coupling ). We lift typing derivations ⊢ M : Δ \vdash M : \Delta ⊢ M : Δ to distributions on sessions and contexts as ⊢ γ D M : D Δ \vdash_\gamma D_M : D_\Delta ⊢ γ D M : D Δ iff the coupling γ : dom ( D M ) × dom ( D Δ ) → [ 0 ; 1 ] \gamma: \operatorname{dom}(D_M) \times\operatorname{dom}(D_\Delta) \to[0;1] γ : dom ( D M ) × dom ( D Δ ) → [ 0 ; 1 ] satisfies:
(1) ∀ M ′ ∈ dom ( D M ) : ∑ Δ ′ ∈ dom ( D Δ ) γ ( M ′ , Δ ′ ) = D M ( M ′ ) (2) ∀ Δ ′ ∈ dom ( D Δ ) : ∑ M ′ ∈ dom ( D M ) γ ( M ′ , Δ ′ ) = D Δ ( Δ ′ ) (3) ∀ M ′ ∈ dom ( D M ) : ∀ Δ ′ ∈ dom ( D Δ ) : γ ( M ′ , Δ ′ ) > 0 ⇒ ⊢ M ′ : Δ ′ \begin{aligned}
\text{(1)}\quad&\forall M' \in\operatorname{dom}(\mathcal{D}_M): \sum_{\Delta' \in\operatorname{dom}(\mathcal{D}_\Delta)} \gamma(M',\Delta') = \mathcal{D}_M(M')\\
\text{(2)}\quad&\forall\Delta' \in\operatorname{dom}(\mathcal{D}_\Delta): \sum_{M' \in\operatorname{dom}(\mathcal{D}_M)} \gamma(M',\Delta') = \mathcal{D}_\Delta(\Delta')\\
\text{(3)}\quad&\forall M' \in\operatorname{dom}(\mathcal{D}_M): \forall\Delta' \in\operatorname{dom}(\mathcal{D}_\Delta): \gamma(M',\Delta') > 0 \mathbin{\Rightarrow} \vdash M' : \Delta'
\end{aligned} (1) (2) (3) ∀ M ′ ∈ dom ( D M ) : Δ ′ ∈ dom ( D Δ ) ∑ γ ( M ′ , Δ ′ ) = D M ( M ′ ) ∀ Δ ′ ∈ dom ( D Δ ) : M ′ ∈ dom ( D M ) ∑ γ ( M ′ , Δ ′ ) = D Δ ( Δ ′ ) ∀ M ′ ∈ dom ( D M ) : ∀ Δ ′ ∈ dom ( D Δ ) : γ ( M ′ , Δ ′ ) > 0 ⇒ ⊢ M ′ : Δ ′
Definition C.22 (Internal-first schedulers). We define the set of internal-first schedulers over sessions or contexts C C C ;
Φ I C = { ϕ ∈ Φ I C | ∀ ξ ∈ Ξ ϕ ( C ) : ∀ i < ∣ ξ ∣ ∀ p , q , ℓ : ξ [ i ] → ( p , q ) ℓ 1 ξ [ i + 1 ] ⇒ ξ [ i ] ⊨ CommNF } , \Phi^{C}_{I} = \left\{ \phi\in\Phi^{C}_{I} \mathrel{\middle|} \forall\xi\in\Xi_{\phi}(C) : \forall i < |\xi| \ \forall p,q,\ell: \xi[i] \xrightarrow{(p,q)\ell}_{1} \xi[i+1] \mathbin{\Rightarrow} \xi[i] \models\operatorname{CommNF} \right\}, Φ I C = { ϕ ∈ Φ I C ∀ ξ ∈ Ξ ϕ ( C ) : ∀ i < ∣ ξ ∣ ∀ p , q , ℓ : ξ [ i ] ( p , q ) ℓ 1 ξ [ i + 1 ] ⇒ ξ [ i ] ⊨ CommNF } , i.e. schedulers that perform internal reductions before any communication. The set of fair internal-first schedulers is then: Φ I , F C = Φ I C ∩ Φ F C \Phi^{C}_{I,F} = \Phi^{C}_{I} \cap\Phi^{C}_{F} Φ I , F C = Φ I C ∩ Φ F C .
Notation C.23.
For a scheduler ϕ ∈ Φ I C \phi\in\Phi^{C}_{I} ϕ ∈ Φ I C , we write C ⇒ n f ϕ D C \xRightarrow[\mathrm{nf}]{\phi} \mathcal{D} C ϕ nf D for the distribution D \mathcal{D} D induced by ϕ \phi ϕ reducing C C C to normal-form.
For a scheduler ϕ ∈ Φ C \phi\in\Phi^{C} ϕ ∈ Φ C , we write ϕ ξ \phi_{\xi} ϕ ξ for the residual scheduler after executing ξ \xi ξ i.e. ϕ ξ = ϕ ( ξ ; ⋅ ) \phi_{\xi} = \phi(\xi;\cdot) ϕ ξ = ϕ ( ξ ; ⋅ ) .
Lemma C.24 (Internal normalization).
For all sessions M M M :
(a) ∀ ϕ ∈ Φ I M : ∃ D M : M ⇒ n f ϕ D M \forall\phi\in\Phi^{M}_{I} : \exists\mathcal{D}_M : M \xRightarrow[\mathrm{nf}]{\phi} \mathcal{D}_M ∀ ϕ ∈ Φ I M : ∃ D M : M ϕ nf D M
(b) ∀ ϕ , ϕ ′ ∈ Φ I M : ( M ⇒ n f ϕ D M ∧ M ⇒ n f ϕ ′ D M ′ ) ⇒ D M = D M ′ \forall\phi,\phi' \in\Phi^{M}_{I} : \left(M \xRightarrow[\mathrm{nf}]{\phi} \mathcal{D}_M \land M \xRightarrow[\mathrm{nf}]{\phi'} \mathcal{D}'_M\right) \mathbin{\Rightarrow} \mathcal{D}_M = \mathcal{D}'_M ∀ ϕ , ϕ ′ ∈ Φ I M : ( M ϕ nf D M ∧ M ϕ ′ nf D M ′ ) ⇒ D M = D M ′
For all contexts Δ \Delta Δ :
(a) ∀ ϕ ∈ Φ I Δ : ∃ D Δ : Δ ⇒ n f ϕ D Δ \forall\phi\in\Phi^{\Delta}_{I} : \exists\mathcal{D}_\Delta: \Delta\xRightarrow[\mathrm{nf}]{\phi} \mathcal{D}_\Delta ∀ ϕ ∈ Φ I Δ : ∃ D Δ : Δ ϕ nf D Δ
Proof. (1) (a) follows from guardedness of recursion (all recursive variables X X X must occur following some communication in its prefix). Hence since our types are regular, firing internal actions must eventually lead to a non-internal action. (b) Since both of ϕ \phi ϕ and ϕ ′ \phi' ϕ ′ are internal-first , and there’s no internal nondeterminism at the process-level, they can only differ up to permutation in their scheduling of the same set of internally enabled actions. (2) (a) Follows by an argument analogous to (1)(a) and from the fact that recursion in types are guarded. □
Lemma C.25 (Process inversion under internal normalization). For every participant p p p ,
⊢ P : T ∧ p ▹ P ⇒ n f D M ⇒ ∃ γ , ϕ ∈ Φ I p : T , D Δ : ( p : T ) ⇒ n f ϕ D Δ ∧ ⊢ γ D M : D Δ . \vdash P : T \land p \triangleright P \xRightarrow[\mathrm{nf}]{} \mathcal{D}_M \mathbin{\Rightarrow} \exists\gamma,\phi\in\Phi^{p:T}_{I},\mathcal{D}_\Delta: (p:T) \xRightarrow[\mathrm{nf}]{\phi} \mathcal{D}_\Delta\land\vdash_{\gamma} \mathcal{D}_M : \mathcal{D}_\Delta. ⊢ P : T ∧ p ▹ P nf D M ⇒ ∃ γ , ϕ ∈ Φ I p : T , D Δ : ( p : T ) ϕ nf D Δ ∧ ⊢ γ D M : D Δ . Proof. Put Δ 0 = p : T \Delta_0 = p : T Δ 0 = p : T . Singleton contexts are safe, so ⊢ p ▹ P : Δ 0 \vdash p \triangleright P : \Delta_0 ⊢ p ▹ P : Δ 0 by [b-sess].
(1) Δ 0 ⊨ CommNF \Delta_0 \models\operatorname{CommNF} Δ 0 ⊨ CommNF . Then unf ( T ) \operatorname{unf}(T) unf ( T ) is end, a branching, or a singleton selection. The merge and subtyping rules give
T 1 ⊓ p T 2 ≤ T ⇒ T b ≤ T ( b = 1 , 2 ) . T_1 \sqcap_p T_2 \leq T \mathbin{\Rightarrow} T_b \leq T \qquad(b = 1,2). T 1 ⊓ p T 2 ≤ T ⇒ T b ≤ T ( b = 1 , 2 ) . Hence Thm. 4.1(1,3) and [t-sub] preserve typing at Δ 0 \Delta_0 Δ 0 through every internal step. By [i-dist],
∀ M ′ ∈ dom ( D M ) : ⊢ M ′ : Δ 0 . \forall M' \in\operatorname{dom}(\mathcal{D}_M): \vdash M' : \Delta_0. ∀ M ′ ∈ dom ( D M ) :⊢ M ′ : Δ 0 . Choose any ϕ ∈ Φ I Δ 0 \phi\in\Phi^{\Delta_0}_{I} ϕ ∈ Φ I Δ 0 and set
D Δ = { Δ 0 ↦ 1 } , γ ( M ′ , Δ 0 ) = D M ( M ′ ) . \mathcal{D}_\Delta= \{\Delta_0 \mapsto1\}, \qquad\gamma(M',\Delta_0) = \mathcal{D}_M(M'). D Δ = { Δ 0 ↦ 1 } , γ ( M ′ , Δ 0 ) = D M ( M ′ ) . Then Δ 0 ⇒ n f ϕ D Δ \Delta_0 \xRightarrow[\mathrm{nf}]{\phi} \mathcal{D}_\Delta Δ 0 ϕ nf D Δ by [i-refl] and [i-nf], and both coupling marginals are immediate.
(2) Δ 0 ⊭ C o m m N F \Delta_0 \not\models\mathrm{Comm}_{\mathrm{NF}} Δ 0 ⊨ Comm NF . Then
unf ( T ) = ∑ i ∈ I ⨁ j ∈ J i p i , j : q j ! ℓ j ⟨ B j ⟩ . T i , j . \operatorname{unf}(T)=\sum_{i\in I}\bigoplus_{j\in J_i}p_{i,j}:q_j!\ell_j\langle B_j\rangle.T_{i,j}. unf ( T ) = i ∈ I ∑ j ∈ J i ⨁ p i , j : q j ! ℓ j ⟨ B j ⟩ . T i , j .
Reduce the session into its finite tree of normalized outcomes. Write R R R for the multiset of leaf occurrences (indexed by the unique path r r r that lead there), M r = p ◃ P r M_r=\mathbf{p}\triangleleft P_r M r = p ◃ P r for their endpoints, and p r p_r p r for their weights. Thus
D M ( M ′ ) = ∑ r ∈ R M r = M ′ p r . D_M(M')=\sum_{\substack{r\in R\\M_r=M'}}p_r. D M ( M ′ ) = r ∈ R M r = M ′ ∑ p r .
By Lemma C.6 , some i ∈ I i\in I i ∈ I gives
R = ⨄ j ∈ J i R j , ∑ r ∈ R j p r = p i , j , R=\mathbin{\biguplus}_{j\in J_i}R_j,\qquad\sum_{r\in R_j}p_r=p_{i,j}, R = ⨄ j ∈ J i R j , r ∈ R j ∑ p r = p i , j ,
where R j R_j R j contains the leaves exposing q j ! ℓ j q_j!\ell_j q j ! ℓ j . Put
T j ∗ : = ⨁ 1 : q j ! ℓ j ⟨ B j ⟩ . T i , j , Δ j : = p : T j ∗ . T_j^*:=\bigoplus1:q_j!\ell_j\langle B_j\rangle.T_{i,j},\qquad\Delta_j:=\mathbf{p}:T_j^*. T j ∗ := ⨁ 1 : q j ! ℓ j ⟨ B j ⟩ . T i , j , Δ j := p : T j ∗ .
The same inversion induction also gives the whole-endpoint typings
⊢ P r : T j ∗ ( j ∈ J i , r ∈ R j ) . \vdash P_r:T_j^*\qquad(j\in J_i,\ r\in R_j). ⊢ P r : T j ∗ ( j ∈ J i , r ∈ R j ) .
By [B-SESS],
⊢ M r : Δ j ( r ∈ R j ) . \vdash M_r:\Delta_j\qquad(r\in R_j). ⊢ M r : Δ j ( r ∈ R j ) .
Let ϕ \phi ϕ select summand i i i when ∣ I ∣ > 1 |I|>1 ∣ I ∣ > 1 , then schedule its probabilistic step when ∣ J i ∣ > 1 |J_i|>1 ∣ J i ∣ > 1 , extending it internal-first elsewhere. By [CT-REC], [I-ND], and [I-PROB],
Δ 0 ⟹ n f ϕ D Δ , D Δ = { Δ j ↦ p i , j } j ∈ J i . \Delta_0\mathrel{\mathop{\Longrightarrow}^{\phi}_{\mathrm{nf}}}D_\Delta,\qquad D_\Delta=\{\Delta_j\mapsto p_{i,j}\}_{j\in J_i}. Δ 0 ⟹ nf ϕ D Δ , D Δ = { Δ j ↦ p i , j } j ∈ J i .
Define
γ ( M ′ , Δ j ) : = ∑ r ∈ R j M r = M ′ p r . \gamma(M',\Delta_j):=\sum_{\substack{r\in R_j\\M_r=M'}}p_r. γ ( M ′ , Δ j ) := r ∈ R j M r = M ′ ∑ p r .
Its marginals are
∑ j ∈ J i γ ( M ′ , Δ j ) = ∑ r ∈ R M r = M ′ p r = D M ( M ′ ) , \sum_{j\in J_i}\gamma(M',\Delta_j)=\sum_{\substack{r\in R\\M_r=M'}}p_r=D_M(M'), j ∈ J i ∑ γ ( M ′ , Δ j ) = r ∈ R M r = M ′ ∑ p r = D M ( M ′ ) ,
∑ M ′ ∈ dom ( D M ) γ ( M ′ , Δ j ) = ∑ r ∈ R j p r = p i , j = D Δ ( Δ j ) . \sum_{M'\in\operatorname{dom}(D_M)}\gamma(M',\Delta_j)=\sum_{r\in R_j}p_r=p_{i,j}=D_\Delta(\Delta_j). M ′ ∈ dom ( D M ) ∑ γ ( M ′ , Δ j ) = r ∈ R j ∑ p r = p i , j = D Δ ( Δ j ) .
Moreover, γ ( M ′ , Δ j ) > 0 \gamma(M',\Delta_j)>0 γ ( M ′ , Δ j ) > 0 implies ⊢ M ′ : Δ j \vdash M':\Delta_j ⊢ M ′ : Δ j by the endpoint typings. Hence ⊢ γ D M : D Δ \vdash_\gamma D_M:D_\Delta ⊢ γ D M : D Δ .
Corollary C.26 (Session normalization correspondence).
\vdash M:\Delta\ \land\ M\mathrel{\Longrightarrow}_{\mathrm{nf}}D_M\ \Longrightarrow\ \exists\gamma,\phi\in\Phi^\mathord{\uparrow}_I,\ D_\Delta:\left(\Delta\mathrel{\mathop{\Longrightarrow}^{\phi}_{\mathrm{nf}}}D_\Delta\ \land\ \vdash_\gamma D_M:D_\Delta\right).
Lemma C.27 (Internal-first session schedulers).
∀ ϕ ∈ Φ F M : ∃ ϕ ′ ∈ Φ I , F M : ∀ prop ∈ { l i v e , d f } : P M ϕ ( prop ) = P M ϕ ′ ( prop ) . \forall\phi\in\Phi_F^M:\exists\phi'\in\Phi_{I,F}^M:\forall\operatorname{prop}\in\{\mathrm{live},\mathrm{df}\}:P_M^\phi(\operatorname{prop})=P_M^{\phi'}(\operatorname{prop}). ∀ ϕ ∈ Φ F M : ∃ ϕ ′ ∈ Φ I , F M : ∀ prop ∈ { live , df } : P M ϕ ( prop ) = P M ϕ ′ ( prop ) . Hence, for any property prop ∈ { l i v e , d f } \operatorname{prop}\in\{\mathrm{live},\mathrm{df}\} prop ∈ { live , df } :
min ϕ ∈ Φ F M P M ϕ ( prop ) = min ϕ ∈ Φ I , F M P M ϕ ( prop ) \min_{\phi\in\Phi_F^M}P_M^\phi(\operatorname{prop})=\min_{\phi\in\Phi_{I,F}^M}P_M^\phi(\operatorname{prop}) ϕ ∈ Φ F M min P M ϕ ( prop ) = ϕ ∈ Φ I , F M min P M ϕ ( prop )
Proof. Fix ϕ ∈ Φ F M \phi\in\Phi^{M}_{F} ϕ ∈ Φ F M . We show how to construct an “internal-first” scheduler ϕ ′ ∈ Φ I M \phi' \in\Phi^{M}_{I} ϕ ′ ∈ Φ I M with the same bounds as ϕ \phi ϕ as follows: Simulate ϕ \phi ϕ , performing internal reductions early in a fixed participant order until normal form, but revealing their outcomes to ϕ \phi ϕ only when it requests those steps (essentially ϕ ′ \phi' ϕ ′ is a bit ahead of ϕ \phi ϕ ). Retain ϕ ′ \phi' ϕ ′ s communication and error choices. Internal reductions commute with unrelated communications and preserve enabled errors; by Lemma C.24 , normalization is finite.
Couple ξ , ξ ′ \xi,\xi' ξ , ξ ′ using the same outcome for each participant’s successive flips. Revealing outcomes only upon replay preserves both marginal laws. Almost surely, ξ \xi ξ is fair, so every early internal step is eventually replayed. Thus the paths have the same local reductions (just shifted), communication sequence, and terminal outcome.
Normalization ensures internal fairness of ξ ′ \xi' ξ ′ . If a pair ( p , q ) (p,q) ( p , q ) were enabled infinitely often on ξ ′ \xi' ξ ′ but communicated only finitely often, p p p ’s output would eventually remain pending. That output is eventually exposed also in ξ \xi ξ , where the corresponding input prefixes of q q q recur or persist, contradicting fairness. Hence ϕ ′ ∈ Φ I , F M \phi' \in\Phi^{M}_{I,F} ϕ ′ ∈ Φ I , F M .
The shared reductions preserve liveness and deadlock-freedom, giving the probability equalities. The equality of infima follows from Φ I , F M ⊆ Φ F M \Phi^{M}_{I,F} \subseteq\Phi^{M}_{F} Φ I , F M ⊆ Φ F M . □
Lemma C.28 (Internal persistence). Suppose C → ∗ = D C \xrightarrow{*}_{=} D C ∗ = D . For every α = ( p , q ) ℓ \alpha=(p,q)^{\ell} α = ( p , q ) ℓ ,
C → 1 α ⟹ ∀ C ′ ∈ dom ( D ) : C ′ → 1 α . C \xrightarrow[\!1]{\alpha} \Longrightarrow\forall C' \in\operatorname{dom}(D): C' \xrightarrow[\!1]{\alpha}. C α 1 ⟹ ∀ C ′ ∈ dom ( D ) : C ′ α 1 .
Proof. An enabled communication exposes matching output and input prefixes at p , q p,q p , q (a singleton selection and a branching for contexts). Neither component admits an internal reduction, so internal steps leave both unchanged, modulo unfolding. The claim follows by induction through [i-dist] and the reflexive–transitive closure. □
Definition C.29 (1-step blocks). We say that a participant p p p is 1-step blocked in Δ \Delta Δ (denoted Blk p ( Δ ) \operatorname{Blk}_{p}(\Delta) Blk p ( Δ ) ) iff
Δ ( p ) ≠ e n d ∧ Δ ̸ → n ∧ ∄ p : Δ → p ∧ ∄ q , ℓ : ( Δ → 1 ( p , q ) ℓ ∨ Δ → 1 ( q , p ) ℓ ) \Delta(p) \ne\mathrm{end} \land\Delta\not\xrightarrow{n} \land\nexists p:\Delta\xrightarrow{p} \land\nexists q,\ell:\left(\Delta\xrightarrow[\!1]{(p,q)^{\ell}} \lor\Delta\xrightarrow[\!1]{(q,p)^{\ell}}\right) Δ ( p ) = end ∧ Δ n ∧ ∄ p : Δ p ∧ ∄ q , ℓ : ( Δ ( p , q ) ℓ 1 ∨ Δ ( q , p ) ℓ 1 )
analogously, Blk p ( M ) \operatorname{Blk}_{p}(M) Blk p ( M ) iff
( M ( p ) ⊨ C o m m N F ) ∧ M ( p ) ≠ 0 ∧ ∄ q , ℓ : ( M → 1 ( p , q ) ℓ ∨ M → 1 ( q , p ) ℓ ) \left(M(p) \models\mathrm{Comm}_{\mathrm{NF}}\right) \land M(p) \ne0 \land\nexists q,\ell:\left(M \xrightarrow[\!1]{(p,q)^{\ell}} \lor M \xrightarrow[\!1]{(q,p)^{\ell}}\right) ( M ( p ) ⊨ Comm NF ) ∧ M ( p ) = 0 ∧ ∄ q , ℓ : ( M ( p , q ) ℓ 1 ∨ M ( q , p ) ℓ 1 )
Lemma C.30 (Communication correspondence at normal forms). Suppose ⊢ M : Δ \vdash M:\Delta ⊢ M : Δ with M ⊨ C o m m N F M \models\mathrm{Comm}_{\mathrm{NF}} M ⊨ Comm NF and Δ ⊨ C o m m N F \Delta\models\mathrm{Comm}_{\mathrm{NF}} Δ ⊨ Comm NF , then:
(1) For every α = ( p , q ) ℓ \alpha=(p,q)^{\ell} α = ( p , q ) ℓ :
M → 1 α iff Δ → 1 α M \xrightarrow[\!1]{\alpha} \quad\text{iff}\quad\Delta\xrightarrow[\!1]{\alpha} M α 1 iff Δ α 1
∀ M ′ , Δ ′ : M → 1 α M ′ ∧ Δ → 1 α Δ ′ ⟹ ⊢ M ′ : Δ ′ . \forall M',\Delta':\ M \xrightarrow[\!1]{\alpha} M' \land\Delta\xrightarrow[\!1]{\alpha} \Delta' \Longrightarrow\vdash M':\Delta'. ∀ M ′ , Δ ′ : M α 1 M ′ ∧ Δ α 1 Δ ′ ⟹⊢ M ′ : Δ ′ .
(2) For every p ∈ dom ( Δ ) p \in\operatorname{dom}(\Delta) p ∈ dom ( Δ ) : M ( p ) ≡ 0 M(p) \equiv0 M ( p ) ≡ 0 iff unf ( Δ ( p ) ) = e n d \operatorname{unf}(\Delta(p))=\mathrm{end} unf ( Δ ( p )) = end .
Proof. By inversion of [b-sess], safe ( Δ ) \operatorname{safe}(\Delta) safe ( Δ ) and each local process is typed by its corresponding entry. We work up to head unfolding, using Lemma C.4 .
(1) Fix α = ( p , q ) ℓ \alpha=(p,q)^{\ell} α = ( p , q ) ℓ . If either side enables α \alpha α , inversion of [t-sel], [t-bra], and [t-sub] gives
M ≡ p ▶ q ! ℓ ⟨ e ⟩ . P ∣ q ◀ ∑ i ∈ I p i ? ℓ i ( x i ) . Q i ∣ M 0 , M \equiv p \mathbin{\blacktriangleright} q!\ell\langle e\rangle.P \mid q \mathbin{\blacktriangleleft} \sum_{i\in I} p_i?\ell_i(x_i).Q_i \mid M_0, M ≡ p ▶ q ! ℓ ⟨ e ⟩ . P ∣ q ◀ i ∈ I ∑ p i ? ℓ i ( x i ) . Q i ∣ M 0 ,
unf ( Δ ( p ) ) = ⊕ 1 : q ! ⟨ B ⟩ . T , \operatorname{unf}(\Delta(p))=\oplus\,1:q!\langle B\rangle.T, unf ( Δ ( p )) = ⊕ 1 : q ! ⟨ B ⟩ . T ,
unf ( Δ ( q ) ) = & j ∈ J p j ? ℓ j ( B j ) . T j , \operatorname{unf}(\Delta(q))=\&_{j\in J} p_j?\ell_j(B_j).T_j, unf ( Δ ( q )) = & j ∈ J p j ? ℓ j ( B j ) . T j ,
where, by [sub-⊕] and [sub-&],
J ⊆ I , { p j } j ∈ J = { p i } i ∈ I , J \subseteq I,\qquad\{p_j\}_{j\in J}=\{p_i\}_{i\in I}, J ⊆ I , { p j } j ∈ J = { p i } i ∈ I ,
⊢ e : B , ⊢ P : T , ∀ j ∈ J : x j : B j ⊢ Q j : T j . \vdash e : \mathrm{B},\qquad\vdash P : T,\qquad\forall j\in J:\ x_j:B_j\vdash Q_j:T_j. ⊢ e : B , ⊢ P : T , ∀ j ∈ J : x j : B j ⊢ Q j : T j .
If M M M enables α \alpha α , then p ∈ { p i } i ∈ I = { p j } j ∈ J p\in\{p_i\}_{i\in I}=\{p_j\}_{j\in J} p ∈ { p i } i ∈ I = { p j } j ∈ J . Thus Δ \Delta Δ enables an input at q q q from p p p ; together with its output at p p p , safety then gives
∃ j ∈ J : ( p j , ℓ j , B j ) = ( p , ℓ , B ) . \exists j\in J:\quad(p_j,\ell_j,B_j)=(p,\ell,B). ∃ j ∈ J : ( p j , ℓ j , B j ) = ( p , ℓ , B ) .
Hence Δ \Delta Δ enables α \alpha α by [ct-τ]. Conversely, a context α \alpha α -step supplies such a j ∈ J ⊆ I j\in J\subseteq I j ∈ J ⊆ I , so [r-comm] gives a session α \alpha α -step.
For any matching pair of steps, the branch j j j is unique by well-formedness, and the successors have the forms
M ′ ≡ p ▶ P ∣ q ◀ Q j { v / x j } ∣ M 0 , M' \equiv p\blacktriangleright P \mid q\blacktriangleleft Q_j\{v/x_j\}\mid M_0, M ′ ≡ p ▶ P ∣ q ◀ Q j { v / x j } ∣ M 0 ,
Δ ′ = Δ [ p ↦ T , q ↦ T j ] . \Delta'=\Delta[p\mapsto T,q\mapsto T_j]. Δ ′ = Δ [ p ↦ T , q ↦ T j ] .
By Lemma C.3 (2), ⊢ Q j { v / x j } : T j \vdash Q_j\{v/x_j\}:T_j ⊢ Q j { v / x j } : T j . Safety is preserved by Δ → α 1 Δ ′ \Delta\xrightarrow{\alpha}_1\Delta' Δ α 1 Δ ′ , and all other components retain their typings. Thus [b-sess] and Lemma C.4 give ⊢ M ′ : Δ ′ \vdash M':\Delta' ⊢ M ′ : Δ ′ .
(2) Since M ⊨ C o m m N F M\models\mathrm{CommNF} M ⊨ CommNF , each local process unfolds to 0 0 0 , an output, or an input. Typing inversion and the subtyping rules match these respectively with end, a singleton selection, or a branching. Therefore
M ( p ) ≡ 0 ⟺ unf ( Δ ( p ) ) = e n d . M(p)\equiv0\quad\Longleftrightarrow\quad\operatorname{unf}(\Delta(p))=\mathrm{end}. M ( p ) ≡ 0 ⟺ unf ( Δ ( p )) = end .
Corollary C.31 (1-step block correspondence). Suppose ⊢ M : Δ \vdash M:\Delta ⊢ M : Δ with M ⊨ C o m m N F M\models\mathrm{CommNF} M ⊨ CommNF and Δ ⊨ C o m m N F \Delta\models\mathrm{CommNF} Δ ⊨ CommNF then: B l k p ( M ) \mathrm{Blk}_p(M) Blk p ( M ) iff B l k p ( Δ ) \mathrm{Blk}_p(\Delta) Blk p ( Δ ) .
Lemma C.32 (Non-liveness as eventual permanent blocking). Let ξ \xi ξ be a complete fair path from C C C (for C C C either a session M M M or context Δ \Delta Δ ). Then
ξ ⊭ l i v e ⟺ ∃ p ∈ dom ( C ) : ∃ m ≥ 0 : ∀ k ≥ m : B l k p ( ξ [ k ] ) . \xi\not\models\mathrm{live}\quad\Longleftrightarrow\quad\exists p\in\operatorname{dom}(C):\ \exists m\ge0:\ \forall k\ge m:\ \mathrm{Blk}_p(\xi[k]). ξ ⊨ live ⟺ ∃ p ∈ dom ( C ) : ∃ m ≥ 0 : ∀ k ≥ m : Blk p ( ξ [ k ]) . Proof. For finite ξ \xi ξ , interpret ξ [ k ] = last ( ξ ) \xi[k]=\operatorname{last}(\xi) ξ [ k ] = last ( ξ ) whenever k > ∣ ξ ∣ k>|\xi| k > ∣ ξ ∣ ; these repetitions perform no reductions.
( ⇒ ) (\Rightarrow) ( ⇒ ) Suppose ξ ⊭ l i v e \xi\not\models\mathrm{live} ξ ⊨ live . There exist p p p and i i i such that an input or output pending at ξ [ i ] \xi[i] ξ [ i ] is never consumed. Its prefix therefore persists: at every subsequent position, p p p is nonterminated and has no internal reduction. Define:
E = { k ≥ i | ∃ q , ℓ : ( ξ [ k ] → ( p , q ) ℓ 1 ∨ ξ [ k ] → ( q , p ) ℓ 1 ) } . E=\left\{k\ge i\ \middle|\ \exists q,\ell:\left(\xi[k]\xrightarrow[(p,q)\ell]{1}\ \lor\ \xi[k]\xrightarrow[(q,p)\ell]{1}\right)\right\}. E = { k ≥ i ∃ q , ℓ : ( ξ [ k ] 1 ( p , q ) ℓ ∨ ξ [ k ] 1 ( q , p ) ℓ ) } . The fixed pending prefix admits finitely many partners and labels. If E E E were infinite, some serving communication label (respectively, participant pair for sessions) would be enabled infinitely often. Fairness would force a communication consuming that prefix, a contradiction. Hence E E E is finite. Choosing m > max ( E ∪ { i } ) m>\max(E\cup\{i\}) m > max ( E ∪ { i }) gives
∀ k ≥ m : B l k p ( ξ [ k ] ) . \forall k\ge m:\quad\mathrm{Blk}_p(\xi[k]). ∀ k ≥ m : Blk p ( ξ [ k ]) . This also covers finite paths, since their terminal states enable no reductions.
( ⇐ ) (\Leftarrow) ( ⇐ ) Suppose ∃ p , m : ∀ k ≥ m : B l k p ( ξ [ k ] ) \exists p,m:\ \forall k\ge m:\ \mathrm{Blk}_p(\xi[k]) ∃ p , m : ∀ k ≥ m : Blk p ( ξ [ k ]) . By the definition of blockedness and the process/type syntax, p p p has a pending input or output at ξ [ m ] \xi[m] ξ [ m ] . If that prefix were consumed at some step k ≥ m k\ge m k ≥ m , a communication involving p p p would be enabled at ξ [ k ] \xi[k] ξ [ k ] , contradicting B l k p ( ξ [ k ] ) \mathrm{Blk}_p(\xi[k]) Blk p ( ξ [ k ]) . Thus the prefix is never consumed, and ξ ⊭ l i v e \xi\not\models\mathrm{live} ξ ⊨ live . □
Definition C.33 (Normalization paths). For an internal-first scheduler ϕ \phi ϕ , define
Ξ ϕ n f ( C ) = { ξ [ 1.. n ] ∣ ξ ∈ Ξ ϕ ( C ) , ξ [ n ] ⊨ C o m m N F , ∀ i < n : ξ [ i ] ⊭ C o m m N F } . \Xi_{\phi}^{\mathrm{nf}}(C)=\{\xi[1..n]\mid\xi\in\Xi_{\phi}(C),\ \xi[n]\models\mathrm{Comm}_{\mathrm{NF}},\ \forall i<n:\xi[i]\not\models\mathrm{Comm}_{\mathrm{NF}}\}. Ξ ϕ nf ( C ) = { ξ [ 1.. n ] ∣ ξ ∈ Ξ ϕ ( C ) , ξ [ n ] ⊨ Comm NF , ∀ i < n : ξ [ i ] ⊨ Comm NF } . Thus Ξ ϕ n f ( C ) \Xi_{\phi}^{\mathrm{nf}}(C) Ξ ϕ nf ( C ) contains precisely the finite prefixes stopping at their first communication normal form. If C ⊨ C o m m N F C\models\mathrm{Comm}_{\mathrm{NF}} C ⊨ Comm NF , its only member is the one-state path C C C . We note that ∀ ϕ ∈ Φ I C : ∀ ξ ∈ Ξ ϕ ( C ) : ∃ ξ ′ ∈ Ξ ϕ n f ( C ) : ξ ′ ⪯ ξ \forall\phi\in\Phi^{C}_{I}: \forall\xi\in\Xi_{\phi}(C): \exists\xi'\in\Xi_{\phi}^{\mathrm{nf}}(C): \xi'\preceq\xi ∀ ϕ ∈ Φ I C : ∀ ξ ∈ Ξ ϕ ( C ) : ∃ ξ ′ ∈ Ξ ϕ nf ( C ) : ξ ′ ⪯ ξ .
Lemma C.34 (Fair scheduler comparison). Suppose ⊢ M : Δ \vdash M:\Delta ⊢ M : Δ . Then
∀ ϕ ∈ Φ I , F M : ∀ prop ∈ { l i v e , d f } : ∃ ϕ ′ ∈ Φ I , F Δ : \forall\phi\in\Phi^{M}_{I,F}:\ \forall\operatorname{prop}\in\{\mathrm{live},\mathrm{df}\}:\ \exists\phi'\in\Phi^{\Delta}_{I,F}: ∀ ϕ ∈ Φ I , F M : ∀ prop ∈ { live , df } : ∃ ϕ ′ ∈ Φ I , F Δ : P Δ ϕ ′ ( ¬ prop ) ≥ P M ϕ ( ¬ prop ) . \mathbb{P}^{\phi'}_{\Delta}(\neg\operatorname{prop})\geq\mathbb{P}^{\phi}_{M}(\neg\operatorname{prop}). P Δ ϕ ′ ( ¬ prop ) ≥ P M ϕ ( ¬ prop ) . Here ¬ d f \neg\mathrm{df} ¬ df denotes the event of reaching a deadlocked state.
Proof. Fix ϕ ∈ Φ I , F M \phi\in\Phi^{M}_{I,F} ϕ ∈ Φ I , F M and prop ∈ { l i v e , d f } \operatorname{prop}\in\{\mathrm{live},\mathrm{df}\} prop ∈ { live , df } .
Coupling. Construct paired histories h , g h,g h , g in rounds, starting from ( h , g ) = ( M , Δ ) (h,g)=(M,\Delta) ( h , g ) = ( M , Δ ) and maintaining ⊢ last ( h ) : last ( g ) \vdash\operatorname{last}(h):\operatorname{last}(g) ⊢ last ( h ) : last ( g ) . For each such pair, Lemma C.24 and Cor. C.26 give witnesses γ \gamma γ and ψ \psi ψ such that:
last ( h ) ⇒ n f ϕ h D M , last ( g ) ⇒ n f ψ D Δ , ⊢ γ D M : D Δ . \operatorname{last}(h)\mathrel{\Rightarrow^{\phi_h}_{\mathrm{nf}}}D_M,\qquad\operatorname{last}(g)\mathrel{\Rightarrow^{\psi}_{\mathrm{nf}}}D_{\Delta},\qquad\vdash_{\gamma}D_M:D_{\Delta}. last ( h ) ⇒ nf ϕ h D M , last ( g ) ⇒ nf ψ D Δ , ⊢ γ D M : D Δ .
A context scheduler resolves nondeterminism but cannot choose the outcomes of probabilistic reductions. We therefore normalize the context first under ψ \psi ψ , obtaining
s ∈ Ξ ψ n f ( last ( g ) ) , Δ ′ = last ( s ) ∈ dom ( D Δ ) , s\in\Xi_{\psi}^{\mathrm{nf}}(\operatorname{last}(g)),\qquad\Delta'= \operatorname{last}(s)\in\operatorname{dom}(D_{\Delta}), s ∈ Ξ ψ nf ( last ( g )) , Δ ′ = last ( s ) ∈ dom ( D Δ ) ,
then sample a compatible session path r ∈ Ξ ϕ h n f ( last ( h ) ) r\in\Xi_{\phi_h}^{\mathrm{nf}}(\operatorname{last}(h)) r ∈ Ξ ϕ h nf ( last ( h )) according to
Pr h , g ( r ∣ Δ ′ ) = γ ( last ( r ) , last ( s ) ) D Δ ( Δ ′ ) P last ( h ) ϕ h ( Cyl ( r ) ) D M ( last ( r ) ) . \Pr_{h,g}(r\mid\Delta')=
\frac{\gamma(\operatorname{last}(r),\operatorname{last}(s))}{D_{\Delta}(\Delta')}
\frac{\mathbb{P}^{\phi_h}_{\operatorname{last}(h)}(\operatorname{Cyl}(r))}
{D_M(\operatorname{last}(r))}. h , g Pr ( r ∣ Δ ′ ) = D Δ ( Δ ′ ) γ ( last ( r ) , last ( s )) D M ( last ( r )) P last ( h ) ϕ h ( Cyl ( r )) .
The coupling marginals and the partition into normalization cylinders give
∑ r ∈ Ξ ϕ h n f ( last ( h ) ) Pr h , g ( r ∣ Δ ′ ) = 1 , \sum_{r\in\Xi_{\phi_h}^{\mathrm{nf}}(\operatorname{last}(h))}
\Pr_{h,g}(r\mid\Delta')=1, r ∈ Ξ ϕ h nf ( last ( h )) ∑ h , g Pr ( r ∣ Δ ′ ) = 1 ,
∑ Δ ′ ∈ dom ( D Δ ) D Δ ( Δ ′ ) Pr h , g ( r ∣ Δ ′ ) = P last ( h ) ϕ h ( Cyl ( r ) ) . \sum_{\Delta'\in\operatorname{dom}(D_{\Delta})}
D_{\Delta}(\Delta')\Pr_{h,g}(r\mid\Delta')
=
\mathbb{P}^{\phi_h}_{\operatorname{last}(h)}(\operatorname{Cyl}(r)). Δ ′ ∈ dom ( D Δ ) ∑ D Δ ( Δ ′ ) h , g Pr ( r ∣ Δ ′ ) = P last ( h ) ϕ h ( Cyl ( r )) .
Append both normalization paths, identifying shared endpoints:
h ′ = h ; r , g ′ = g ; s . h'=h;r,\qquad g'=g;s. h ′ = h ; r , g ′ = g ; s .
Since γ ( last ( h ′ ) , last ( g ′ ) ) > 0 \gamma(\operatorname{last}(h'),\operatorname{last}(g'))>0 γ ( last ( h ′ ) , last ( g ′ )) > 0 , we have ⊢ last ( h ′ ) : last ( g ′ ) \vdash\operatorname{last}(h'):\operatorname{last}(g') ⊢ last ( h ′ ) : last ( g ′ ) . If a communication is enabled, append the step selected by ϕ ( h ′ ) \phi(h') ϕ ( h ′ ) and its matching context step, then repeat; Lemma C.30 preserves typing. Otherwise both paths terminate, since communication safety excludes error reductions.
The sampled history guides later context choices. This procedure gives a randomized context scheduler, whose choices are distributions over possible next actions (each weighted by the sum of Pr h , g ( r ∣ Δ ′ ) \Pr_{h,g}(r\mid\Delta') Pr h , g ( r ∣ Δ ′ ) over compatible session paths r r r that prescribe that action).
To get rid of this auxiliary randomness and extract a deterministic scheduler, let U 0 , U 1 , … U_0,U_1,\ldots U 0 , U 1 , … be independent random variables, each uniform on [ 0 , 1 ) [0,1) [ 0 , 1 ) and independent of the context’s own random draws; write U = ( U 0 , U 1 , … ) U=(U_0,U_1,\ldots) U = ( U 0 , U 1 , … ) . In round n n n , enumerate the possible session paths r 1 , … , r k r_1,\ldots,r_k r 1 , … , r k and set
p i = Pr h , g ( r i ∣ Δ ′ ) , I i = [ ∑ j < i p j , ∑ j ≤ i p j ] . (56) p_i=\Pr_{h,g}(r_i\mid\Delta'),\qquad I_i=\left[\sum_{j<i}p_j,\sum_{j\leq i}p_j\right]. \tag*{(56)} p i = h , g Pr ( r i ∣ Δ ′ ) , I i = [ j < i ∑ p j , j ≤ i ∑ p j ] . (56)
Select r = r i r = r_i r = r i when U n ∈ I i U_n \in I_i U n ∈ I i ; uniformity gives each path its required probability p i p_i p i .
For fixed u = ( u 0 , u 1 , … ) u = (u_0, u_1, \ldots) u = ( u 0 , u 1 , … ) , reconstruct h h h from the observed context history, starting at h = M h = M h = M . At each context normal-form endpoint Δ ′ \Delta' Δ ′ , the known h h h , g g g , Δ ′ \Delta' Δ ′ determine the intervals, and u n u_n u n selects the subsequent r r r . Then ϕ ( h ; r ) \phi(h;r) ϕ ( h ; r ) determines the communication, after which the fixed witnesses determine the next normalization policy. This procedure defines a deterministic ψ u ∈ Φ I A \psi_u \in\Phi_I^A ψ u ∈ Φ I A .
Each normalization is finite and each nonterminal round adds a communication, so iteration yields complete paired paths ( ξ M , ξ Δ ) (\xi_M, \xi_\Delta) ( ξ M , ξ Δ ) . The session marginal is P M ϕ \mathbb{P}_M^\phi P M ϕ ; conditional on U = u U = u U = u , the context marginal is P Δ ψ u \mathbb{P}_\Delta^{\psi_u} P Δ ψ u .
Fairness and failure. Let ( M n , Δ n ) (M_n, \Delta_n) ( M n , Δ n ) be the corresponding normal-form boundaries, repeating a terminal pair only for indexing. By construction and Cor. C.31,
⊢ M n : Δ n , ∀ p : Blk p ( M n ) ⟺ Blk p ( Δ n ) . \vdash M_n : \Delta_n,\qquad\forall\mathbf{p}:\operatorname{Blk}_{\mathbf{p}}(M_n) \Longleftrightarrow\operatorname{Blk}_{\mathbf{p}}(\Delta_n). ⊢ M n : Δ n , ∀ p : Blk p ( M n ) ⟺ Blk p ( Δ n ) .
Assume ξ M \xi_M ξ M is fair. Finite normalization satisfies the context’s internal fairness obligations. If α = ( p , q ) ℓ \alpha= (\mathbf{p},\mathbf{q})\ell α = ( p , q ) ℓ were enabled infinitely often on ξ Δ \xi_\Delta ξ Δ but performed only finitely often, Lemmas C.28 and C.30 would make α \alpha α enabled at infinitely many M n M_n M n . Choose such a boundary n 0 n_0 n 0 after all α \alpha α -steps. Then
unf ( Δ n 0 ( p ) ) = ⊕ 1 : q ! ℓ ⟨ B ⟩ . T . \operatorname{unf}(\Delta_{n_0}(\mathbf{p})) = \mathbin{\oplus} 1:\mathbf{q}!\ell\langle B\rangle.T. unf ( Δ n 0 ( p )) = ⊕ 1 : q ! ℓ ⟨ B ⟩ . T .
Only α \alpha α can consume this prefix. Session pair-fairness forces a later ( p , q ) (\mathbf{p},\mathbf{q}) ( p , q ) -communication, whose matching context step must therefore be α \alpha α , a contradiction. Thus ξ Δ \xi_\Delta ξ Δ is fair.
Corresponding terminal states are deadlocked together by Lemma C.30. For liveness, Lemma C.32 and the boundary invariant give
ξ M ⊭ l i v e ⟹ ∃ p , n 0 : ∀ n ≥ n 0 : Blk p ( Δ n ) . \xi_M \not\models\mathrm{live}\quad\Longrightarrow\quad\exists\mathbf{p}, n_0:\ \forall n \ge n_0:\operatorname{Blk}_{\mathbf{p}}(\Delta_n). ξ M ⊨ live ⟹ ∃ p , n 0 : ∀ n ≥ n 0 : Blk p ( Δ n ) .
No later communication involves p \mathbf{p} p , and internal steps preserve its pending prefix, so ξ Δ ⊭ l i v e \xi_\Delta\not\models\mathrm{live} ξ Δ ⊨ live .
Deterministic extraction. Since ϕ \phi ϕ is fair, the marginal identities and the pathwise implications above yield
E U [ P Δ ψ U ( f a i r ) ] = 1 , \mathbb{E}_U\left[\mathbb{P}_\Delta^{\psi_U}(\mathrm{fair})\right] = 1, E U [ P Δ ψ U ( fair ) ] = 1 ,
E U [ P Δ ψ U ( ¬ p r o p ) ] ≥ P M ϕ ( ¬ p r o p ) . \mathbb{E}_U\left[\mathbb{P}_\Delta^{\psi_U}(\neg\mathrm{prop})\right] \ge\mathbb{P}_M^\phi(\neg\mathrm{prop}). E U [ P Δ ψ U ( ¬ prop ) ] ≥ P M ϕ ( ¬ prop ) .
These expectations average over the deterministic schedulers ψ u \psi_u ψ u as u u u varies. Since probabilities are bounded by 1, the first equality implies that ψ u \psi_u ψ u is fair for almost every u u u by Def. 4.13. Among these fair schedulers, some has failure probability at least their average, hence at least the session’s. Taking that scheduler as ϕ ′ = ψ u \phi' = \psi_u ϕ ′ = ψ u proves the claim. □
Theorem 4.26
Theorem 4.26. (Proof in §C.4). If ⊢ M : Δ \vdash M : \Delta ⊢ M : Δ , then (1) df ( Δ ) \operatorname{df}(\Delta) df ( Δ ) implies df ( M ) \operatorname{df}(M) df ( M ) ; and (2) P d f min ( Δ ) ≤ P d f min ( M ) \mathbb{P}_{\mathrm{df}}^{\min}(\Delta) \le\mathbb{P}_{\mathrm{df}}^{\min}(M) P df m i n ( Δ ) ≤ P df m i n ( M ) .
Proof. (1) Suppose df ( Δ ) \operatorname{df}(\Delta) df ( Δ ) and M → ∗ M ′ M \to^{*} M' M → ∗ M ′ with deadlock ( M ′ ) \operatorname{deadlock}(M') deadlock ( M ′ ) . Commute independent internal steps to make this finite execution internal-first (possible by Lemma C.27 ).
At each normalization phase, the coupling supplied by Cor. C.26 satisfies
0 < D M k ( M k ) = ∑ Γ ∈ dom ( D Δ k ) γ k ( M k , Γ ) . 0 < \mathcal{D}_{M_k}(M_k) = \sum_{\Gamma\in\operatorname{dom}(\mathcal{D}_{\Delta_k})} \gamma_k(M_k,\Gamma). 0 < D M k ( M k ) = Γ ∈ dom ( D Δ k ) ∑ γ k ( M k , Γ ) .
Choose Δ k \Delta_k Δ k with γ k ( M k , Δ k ) > 0 \gamma_k(M_k,\Delta_k) > 0 γ k ( M k , Δ k ) > 0 . Then ⊢ M k : Δ k \vdash M_k : \Delta_k ⊢ M k : Δ k , and Lemma C.30 matches the next communication. Induction over these blocks yields
Δ → ∗ Δ ′ , ⊢ M ′ : Δ ′ , M ′ , Δ ′ ⊨ Comm N F . \Delta\to^{*} \Delta',\qquad\vdash M' : \Delta',\qquad M',\Delta' \models\operatorname{Comm}_{\mathrm{NF}}. Δ → ∗ Δ ′ , ⊢ M ′ : Δ ′ , M ′ , Δ ′ ⊨ Comm NF .
By Lemma C.30,
M ′ ↛ ⟹ Δ ′ ↛ , M' \not\to\quad\Longrightarrow\quad\Delta' \not\to, M ′ → ⟹ Δ ′ → ,
∃ p : M ′ ( p ) ≠ 0 ⟹ ∃ p : Δ ′ ( p ) ≠ end . \exists\mathbf{p}: M'(\mathbf{p}) \ne0 \quad\Longrightarrow\quad\exists\mathbf{p}: \Delta'(\mathbf{p}) \ne\operatorname{end}. ∃ p : M ′ ( p ) = 0 ⟹ ∃ p : Δ ′ ( p ) = end .
, Vol. 1, No. 1, Article . Publication date: November 2026. Thus deadlock(Δ ′ \Delta' Δ ′ ), contradicting df(Δ \Delta Δ ).
(2) Taking complements in Lemma C.34 , and using Lemma C.27 , gives
P d f min ( Δ ) ≤ min ψ ∈ Φ I , F P Δ ψ ( d f ) ≤ min ϕ ∈ Φ I , F M P M ϕ ( d f ) = P d f min ( M ) . \begin{aligned}
\mathbb{P}_{\mathrm{df}}^{\min}(\Delta) \le\min_{\psi\in\Phi_{I,F}} \mathbb{P}_{\Delta}^{\psi}(\mathrm{df}) \\
&\le\min_{\phi\in\Phi_{I,F}^{M}} \mathbb{P}_{M}^{\phi}(\mathrm{df}) = \mathbb{P}_{\mathrm{df}}^{\min}(M).
\end{aligned} P df m i n ( Δ ) ≤ ψ ∈ Φ I , F min P Δ ψ ( df ) ≤ ϕ ∈ Φ I , F M min P M ϕ ( df ) = P df m i n ( M ) .
Theorem 4.27 (Liveness). (Proof in §C.4.) If ⊢ M : Δ \vdash M : \Delta ⊢ M : Δ , then (1) live(Δ \Delta Δ ) implies live(M M M ); (2) P l i v e min ( Δ ) ≤ P l i v e min ( M ) \mathbb{P}_{\mathrm{live}}^{\min}(\Delta) \le\mathbb{P}_{\mathrm{live}}^{\min}(M) P live m i n ( Δ ) ≤ P live m i n ( M ) .
Proof. (1) Suppose live(Δ \Delta Δ ) and ¬ \lnot ¬ live(M M M ). Then the pathwise rearrangement in the proof of Lemma C.27 gives a complete, fair, internal-first path ξ \xi ξ with ξ ⊭ \xi\not\models ξ ⊨ live from M M M .
Lift ξ \xi ξ by the support construction in Thm. 4.26 (1). The pathwise fairness argument in the proof of Lemma C.34 gives a complete fair context path ξ ′ \xi' ξ ′ with the same communications and corresponding normal-form boundaries
⊢ M k : Δ k , M k , Δ k ⊨ C o m m N F . \vdash M_k : \Delta_k,\qquad M_k,\Delta_k \models\mathrm{Comm}_{\mathrm{NF}}. ⊢ M k : Δ k , M k , Δ k ⊨ Comm NF .
Repeat terminal boundaries when necessary. By Lemma C.32 and Cor. C.31,
∃ p , k 0 : ∀ k ≥ k 0 : Blk p ( M k ) ∧ Blk p ( Δ k ) . \exists p,k_0 : \forall k \ge k_0 : \operatorname{Blk}_p(M_k) \land\operatorname{Blk}_p(\Delta_k). ∃ p , k 0 : ∀ k ≥ k 0 : Blk p ( M k ) ∧ Blk p ( Δ k ) .
No subsequent communication involves p p p , and internal steps leave its pending input or output unchanged. Hence ξ ′ ⊭ \xi' \not\models ξ ′ ⊨ live, contradicting live(Δ \Delta Δ ).
(2) Taking complements in Lemma C.34 , and using Lemma C.27 , gives
P l i v e min ( Δ ) ≤ min ψ ∈ Φ I , F P Δ ψ ( l i v e ) ≤ min ϕ ∈ Φ I , F M P M ϕ ( l i v e ) = P l i v e min ( M ) . \begin{aligned}
\mathbb{P}_{\mathrm{live}}^{\min}(\Delta) \le\min_{\psi\in\Phi_{I,F}} \mathbb{P}_{\Delta}^{\psi}(\mathrm{live}) \\
&\le\min_{\phi\in\Phi_{I,F}^{M}} \mathbb{P}_{M}^{\phi}(\mathrm{live}) = \mathbb{P}_{\mathrm{live}}^{\min}(M).
\end{aligned} P live m i n ( Δ ) ≤ ψ ∈ Φ I , F min P Δ ψ ( live ) ≤ ϕ ∈ Φ I , F M min P M ϕ ( live ) = P live m i n ( M ) .
Appendix for Section 5
Full proofs for soundness and completeness of PRISM translation
Soundness
Bisimulation allows us to write a coinductive proof.
Definition D.1. Let ( M 1 , I 1 ) (M_1,I_1) ( M 1 , I 1 ) and ( M 2 , I 2 ) (M_2,I_2) ( M 2 , I 2 ) be model-state pairs. A binary relation R \mathcal{R} R is a bisimulation if: (1) ( I 1 , I 2 ) ∈ R (I_1,I_2) \in\mathcal{R} ( I 1 , I 2 ) ∈ R , and (2) For all ( S 1 , S 2 ) ∈ R (S_1,S_2) \in\mathcal{R} ( S 1 , S 2 ) ∈ R , action α \alpha α and p ∈ [ 0 , 1 ] p \in[0,1] p ∈ [ 0 , 1 ] ,
( M 1 , S 1 ) → α p ( M 1 , S 1 ′ ) ⟹ ∃ S 2 ′ s.t. ( M 2 , S 2 ) → α p ( M 2 , S 2 ′ ) and ( S 1 ′ , S 2 ′ ) ∈ R ; (M_1,S_1) \xrightarrow{\alpha}_{p} (M_1,S'_1) \Longrightarrow\exists S'_2\ \text{s.t.}\ (M_2,S_2) \xrightarrow{\alpha}_{p} (M_2,S'_2)\ \text{and}\ (S'_1,S'_2) \in\mathcal{R}; ( M 1 , S 1 ) α p ( M 1 , S 1 ′ ) ⟹ ∃ S 2 ′ s.t. ( M 2 , S 2 ) α p ( M 2 , S 2 ′ ) and ( S 1 ′ , S 2 ′ ) ∈ R ; and
( M 2 , S 2 ) → α p ( M 2 , S 2 ′ ) ⟹ ∃ S 1 ′ s.t. ( M 1 , S 1 ) → α p ( M 1 , S 1 ′ ) and ( S 1 ′ , S 2 ′ ) ∈ R . (M_2,S_2) \xrightarrow{\alpha}_{p} (M_2,S'_2) \Longrightarrow\exists S'_1\ \text{s.t.}\ (M_1,S_1) \xrightarrow{\alpha}_{p} (M_1,S'_1)\ \text{and}\ (S'_1,S'_2) \in\mathcal{R}. ( M 2 , S 2 ) α p ( M 2 , S 2 ′ ) ⟹ ∃ S 1 ′ s.t. ( M 1 , S 1 ) α p ( M 1 , S 1 ′ ) and ( S 1 ′ , S 2 ′ ) ∈ R . We say ( M 1 , I 1 ) (M_1,I_1) ( M 1 , I 1 ) and ( M 2 , I 2 ) (M_2,I_2) ( M 2 , I 2 ) are bisimilar if such a relation R \mathcal{R} R exists, and write ( M 1 , I 1 ) ∼ ( M 2 , I 2 ) (M_1,I_1) \sim(M_2,I_2) ( M 1 , I 1 ) ∼ ( M 2 , I 2 ) .
To show two model-state pairs are bisimilar, we define a relation R \mathcal{R} R and verify it satisfies the bisimulation conditions.
Defining R \mathcal{R} R is challenging as we do not have the necessary mechanism to reason about the reductions available from a given state, nor are we able to relate states together according to this mechanism.
To solve the first issue, we introduce a source function (Def. D.2). This, combined with Proposition D.3 , precisely identifies the location of a state within its encoding, and identifies the reductions available from it. For the second issue, we introduce a novel unfold correspondence relation (Def. D.4 ) that relates equivalent partial types of μ t . T \mu t.T μ t . T and T { μ t . T / t } T\{\mu t.T/t\} T { μ t . T / t } . Using these, we define a binary relation
source p : T = source ( p , 0 , ∅ ) ′ ( T ) ∪ { { S p ↦ SS ( T ) } ↦ ( end , ∅ ) } \operatorname{source}_{p:T} = \operatorname{source}'_{(p,0,\varnothing)}(T) \cup\left\{ \{S_p \mapsto\operatorname{SS}(T)\} \mapsto(\operatorname{end},\varnothing) \right\} source p : T = source ( p , 0 , ∅ ) ′ ( T ) ∪ { { S p ↦ SS ( T )} ↦ ( end , ∅ ) }
source ( p , n , f ) ′ ( end ) = ∅ \operatorname{source}'_{(p,n,f)}(\operatorname{end}) = \varnothing source ( p , n , f ) ′ ( end ) = ∅
source ( p , n , f ) ′ ( t ) = ∅ \operatorname{source}'_{(p,n,f)}(t) = \varnothing source ( p , n , f ) ′ ( t ) = ∅
source ( p , n , f ) ′ ( μ t . T ) = source ( p , n , f ∪ { t ↦ { S p ↦ n } } ) ′ ( T ) \operatorname{source}'_{(p,n,f)}(\mu t.T) = \operatorname{source}'_{(p,n,f\cup\{t\mapsto\{S_p\mapsto n\}\})}(T) source ( p , n , f ) ′ ( μ t . T ) = source ( p , n , f ∪ { t ↦ { S p ↦ n }}) ′ ( T )
source ( p , n , f ) ′ ( & i ∈ I p i ? ℓ i ( B i ) . T i ) = { { S p ↦ n } ↦ ( & i ∈ I p i ? ℓ i ( B i ) . T i , f ) } ∪ ⋃ i ∈ I source ( p , next ( i ) , f ) ′ ( T i ) \begin{aligned}
\operatorname{source}'_{(p,n,f)}\left(\mathbin{\&}_{i\in I}p_i? \ell_i(B_i).T_i\right)
={}&\left\{\{S_p\mapsto n\}\mapsto\left(\mathbin{\&}_{i\in I}p_i?\ell_i(B_i).T_i,f\right)\right\}\\
&\cup\bigcup_{i\in I}\operatorname{source}'_{(p,\operatorname{next}(i),f)}(T_i)
\end{aligned} source ( p , n , f ) ′ ( & i ∈ I p i ? ℓ i ( B i ) . T i ) = { { S p ↦ n } ↦ ( & i ∈ I p i ? ℓ i ( B i ) . T i , f ) } ∪ i ∈ I ⋃ source ( p , next ( i ) , f ) ′ ( T i )
where next ( i ) = n + 1 + ∑ i ′ ∈ I ∣ i ′ < i SS ( T i ′ ) \operatorname{next}(i)=n+1+\sum_{i'\in I\mid i'<i}\operatorname{SS}(T_{i'}) next ( i ) = n + 1 + ∑ i ′ ∈ I ∣ i ′ < i SS ( T i ′ )
source ( p , n , f ) ′ ( ⊕ 1 : p 1 ! ℓ ⟨ B ⟩ . T ) = { { S p ↦ n } ↦ ( ⊕ 1 : p 1 ! ℓ ⟨ B ⟩ . T , f ) } ∪ source ( p , n + 1 , f ) ′ ( T ) \begin{aligned}
\operatorname{source}'_{(p,n,f)}\left(\mathbin{\oplus}_{1:p_1! \ell\langle B\rangle.T}\right)
={}&\left\{\{S_p\mapsto n\}\mapsto\left(\mathbin{\oplus}_{1:p_1!\ell\langle B\rangle.T},f\right)\right\}\\
&\cup\operatorname{source}'_{(p,n+1,f)}(T)
\end{aligned} source ( p , n , f ) ′ ( ⊕ 1 : p 1 ! ℓ ⟨ B ⟩ . T ) = { { S p ↦ n } ↦ ( ⊕ 1 : p 1 ! ℓ ⟨ B ⟩ . T , f ) } ∪ source ( p , n + 1 , f ) ′ ( T )
source ( p , n , f ) ′ ( ⊕ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j ) = { { S p ↦ n } ↦ ( ⊕ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j , f ) } ∪ ⋃ j ∈ J source ( p , com ( j ) , f ) ′ ( T j ′ ) ( ∣ J ∣ ≥ 2 ) \begin{aligned}
\operatorname{source}'_{(p,n,f)}\left(\mathbin{\oplus}_{j\in J}p_j:p_j!\ell_j\langle B_j\rangle.T_j\right)
={}&\left\{\{S_p\mapsto n\}\mapsto\left(\mathbin{\oplus}_{j\in J}p_j:p_j!\ell_j\langle B_j\rangle.T_j,f\right)\right\}\\
&\cup\bigcup_{j\in J}\operatorname{source}'_{(p,\operatorname{com}(j),f)}(T'_j)
\qquad(|J|\ge2)
\end{aligned} source ( p , n , f ) ′ ( ⊕ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j ) = { { S p ↦ n } ↦ ( ⊕ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j , f ) } ∪ j ∈ J ⋃ source ( p , com ( j ) , f ) ′ ( T j ′ ) ( ∣ J ∣ ≥ 2 )
where T j ′ = ⊕ 1 : p j ! ℓ j ⟨ B j ⟩ . T j T'_j=\mathbin{\oplus}_{1:p_j! \ell_j\langle B_j\rangle.T_j} T j ′ = ⊕ 1 : p j ! ℓ j ⟨ B j ⟩ . T j
com ( j ) = n + 1 + ∑ j ′ < j SS ( T j ′ ′ ) \operatorname{com}(j)=n+1+\sum_{j'<j}\operatorname{SS}(T'_{j'}) com ( j ) = n + 1 + j ′ < j ∑ SS ( T j ′ ′ )
source ( p , n , f ) ′ ( ∑ i ∈ I ⊕ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ) = { { S p ↦ n } ↦ ( ∑ i ∈ I ⊕ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) , f ) } ∪ ⋃ i ∈ I source ( p , sel ( i ) , f ) ′ ( T i ⊕ ) ( ∣ I ∣ ≥ 2 ) \begin{aligned}
\operatorname{source}'_{(p,n,f)}\left(\sum_{i\in I}\mathbin{\oplus}_{j\in J_i}p_{(i,j)}:p_j!\ell_j\langle B_j\rangle.T_{(i,j)}\right)
={}&\left\{\{S_p\mapsto n\}\mapsto\left(\sum_{i\in I}\mathbin{\oplus}_{j\in J_i}p_{(i,j)}:p_j!\ell_j\langle B_j\rangle.T_{(i,j)},f\right)\right\}\\
&\cup\bigcup_{i\in I}\operatorname{source}'_{(p,\operatorname{sel}(i),f)}(T^\oplus_i)
\qquad(|I|\ge2)
\end{aligned} source ( p , n , f ) ′ ( i ∈ I ∑ ⊕ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ) = { { S p ↦ n } ↦ ( i ∈ I ∑ ⊕ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) , f ) } ∪ i ∈ I ⋃ source ( p , sel ( i ) , f ) ′ ( T i ⊕ ) ( ∣ I ∣ ≥ 2 )
where T i ⊕ = ⊕ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) T^\oplus_i=\mathbin{\oplus}_{j\in J_i}p_{(i,j)}:p_j!\ell_j\langle B_j\rangle.T_{(i,j)} T i ⊕ = ⊕ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j )
sel ( i ) = n + 1 + ∑ i ′ < i SS ( T i ′ ⊕ ) \operatorname{sel}(i)=n+1+\sum_{i'<i}\operatorname{SS}(T^\oplus_{i'}) sel ( i ) = n + 1 + i ′ < i ∑ SS ( T i ′ ⊕ )
between states of ( ∣ p : μ t . T ∣ ) (|p:\mu t.T|) ( ∣ p : μ t . T ∣ ) and ( ∣ p : T { μ t . T / t } ∣ ) (|p:T\{\mu t.T/t\}|) ( ∣ p : T { μ t . T / t } ∣ ) , and check using Proposition D.3 that it is indeed a bisimulation relation. See Lemma D.6 for details.
The rest of the proof proceeds as follows. We show that model-state pairs that enter the state space for a closed type behaves exactly like the closed type (Lemma D.7 ). We then use this to prove soundness of ( ∣ ⋅ ∣ ) (|\cdot|) ( ∣ ⋅ ∣ ) (Lemma D.8 ). Next, we define what it means to combine states (Def. D.9 ), using this to relate composition and bisimulation (Lemma D.13). This allows us to use Lemma D.8 to prove soundness of [ [ ⋅ ] ] [\![\cdot]\!] [ [ ⋅ ] ] .
Detailed proofs Taking a compositional approach, we first show that the inner encoding ( ∣ Δ ∣ ) (|\Delta|) ( ∣Δ∣ ) is sound with respect to the reductions of a single participant: the nondeterministic reductions → n \mathrel{\to_n} → n , the probabilistic reductions (with action p : p p:p p : p ) and the send/receive actions (Lemma D.8 ). We then use this result to demonstrate the soundness of [ [ Δ ] ] [\![\Delta]\!] [ [ Δ ] ] .
Definition D.2. The source of a state S S S within the module ( ∣ p : T ∣ ) (|p:T|) ( ∣ p : T ∣ ) , written source p : T ( S ) \operatorname{source}_{p:T}(S) source p : T ( S ) , is given in Figure 15 .
Figure 15. Definition of source p : T ( S ) \operatorname{source}_{p:T}(S) source p : T ( S ) .
The function outputs a pair source p : T ( S ) = ( T ′ , f ) \operatorname{source}_{p:T}(S)=(T',f) source p : T ( S ) = ( T ′ , f ) . The first element T ′ T' T ′ is an end, a proper sum ∑ ⊕ \sum\oplus ∑ ⊕ (with ∣ I ∣ ≥ 2 |I|\ge2 ∣ I ∣ ≥ 2 ), a proper selection ⊕ \oplus ⊕ (with ∣ J ∣ ≥ 2 |J|\ge2 ∣ J ∣ ≥ 2 ), a committed selection (a single branch of probability 1 1 1 ), or a branching & \mathbin{\&} & occurring as a partial type of T T T , representing the substructure of T T T associated with the state: every state of the encoding is the entry point of such a partial type. In particular, the state reached by nondeterministically picking a summand i i i of a proper sum is the entry point of the singleton selection T i ⊕ T^\oplus_i T i ⊕ , and the state reached by probabilistically committing a branch j j j of a proper selection is the entry point of the committed selection T j T_j T j . Finally, f f f maps variables to their corresponding states.
The following proposition says that source p : T ( S ) \operatorname{source}_{p:T}(S) source p : T ( S ) really does what we expect.
Proposition D.3. Let T T T be a type and S S S a state for ( ∣ p : T ∣ ) (\lvert p:T\rvert) (∣ p : T ∣) . Then:
(1) If source p : T ( S ) = ( e n d , ∅ ) \operatorname{source}_{p:T}(S)=(\mathop{\mathrm{end}},\varnothing) source p : T ( S ) = ( end , ∅ ) , then ( ( ∣ p : T ∣ ) , S ) ↛ ((\lvert p:T\rvert),S)\not\to ((∣ p : T ∣) , S ) → .
(2) If source p : T ( S ) = ( & i ∈ I p i ? ℓ i ( B i ) . T i , f ) \operatorname{source}_{p:T}(S)=(\mathbin{\&}_{i\in I}p_i? \ell_i(B_i).T_i,f) source p : T ( S ) = ( & i ∈ I p i ? ℓ i ( B i ) . T i , f ) , then ∀ i ∈ I : ( ( ∣ p : T ∣ ) , S ) → p i : : p : : ℓ i 1 ( ( ∣ p : T ∣ ) , S ′ ) \forall i\in I:((\lvert p:T\rvert),S)\xrightarrow{p_i::p::\ell_i}_{1}((\lvert p:T\rvert),S') ∀ i ∈ I : ((∣ p : T ∣) , S ) p i :: p :: ℓ i 1 ((∣ p : T ∣) , S ′ ) where S ′ = f ( t ) S'=f(t) S ′ = f ( t ) if T i = t T_i=t T i = t , and otherwise
source p : T ( S ′ ) = { ( e n d , ∅ ) if T i = e n d ( T ′ , f ∪ ⋃ k { t k ↦ S ′ } ) if T i = μ t 1 ⋯ μ t n . T ′ ( T i , f ) otherwise. \operatorname{source}_{p:T}(S')=
\begin{cases}
(\mathop{\mathrm{end}},\varnothing) & \text{if }T_i=\mathop{\mathrm{end}}\\
(T',f\cup\bigcup_k\{t_k\mapsto S'\}) & \text{if }T_i=\mu t_1\cdots\mu t_n.T'\\
(T_i,f) & \text{otherwise.}
\end{cases} source p : T ( S ′ ) = ⎩ ⎨ ⎧ ( end , ∅ ) ( T ′ , f ∪ ⋃ k { t k ↦ S ′ }) ( T i , f ) if T i = end if T i = μ t 1 ⋯ μ t n . T ′ otherwise. (3) If source p : T ( S ) = ( ∑ i ∈ I ⨁ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) , f ) \operatorname{source}_{p:T}(S)=\left(\sum_{i\in I}\bigoplus_{j\in J_i}p_{(i,j)}:p_j!\ell_j\langle B_j\rangle.T_{(i,j)},f\right) source p : T ( S ) = ( ∑ i ∈ I ⨁ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) , f ) with ∣ I ∣ ≥ 2 \lvert I\rvert\geq2 ∣ I ∣ ≥ 2 , then ∀ i ∈ I : ( ( ∣ p : T ∣ ) , S ) → p : : τ 1 ( ( ∣ p : T ∣ ) , S ′ ) \forall i\in I:((\lvert p:T\rvert),S)\xrightarrow{p::\tau}_{1}((\lvert p:T\rvert),S') ∀ i ∈ I : ((∣ p : T ∣) , S ) p :: τ 1 ((∣ p : T ∣) , S ′ ) with source p : T ( S ′ ) = ( T i ′ , f ) \operatorname{source}_{p:T}(S')=(T'_i,f) source p : T ( S ′ ) = ( T i ′ , f ) , where T i ′ = ⨁ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) T'_i=\bigoplus_{j\in J_i}p_{(i,j)}:p_j!\ell_j\langle B_j\rangle.T_{(i,j)} T i ′ = ⨁ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) .
(4) If source p : T ( S ) = ( ⨁ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j , f ) \operatorname{source}_{p:T}(S)=\left(\bigoplus_{j\in J}p_j:p_j!\ell_j\langle B_j\rangle.T_j,f\right) source p : T ( S ) = ( ⨁ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j , f ) with ∣ J ∣ ≥ 2 \lvert J\rvert\geq2 ∣ J ∣ ≥ 2 , then ∀ j ∈ J : ( ( ∣ p : T ∣ ) , S ) → p : : p j p j ( ( ∣ p : T ∣ ) , S ′ ) \forall j\in J:((\lvert p:T\rvert),S)\xrightarrow{p::p_j}_{p_j}((\lvert p:T\rvert),S') ∀ j ∈ J : ((∣ p : T ∣) , S ) p :: p j p j ((∣ p : T ∣) , S ′ ) with source p : T ( S ′ ) = ( T j ′ , f ) \operatorname{source}_{p:T}(S')=(T'_j,f) source p : T ( S ′ ) = ( T j ′ , f ) , where T j ′ = ⨁ 1 : p j ! ℓ j ⟨ B j ⟩ . T j T'_j=\bigoplus_{1:p_j! \ell_j\langle B_j\rangle.T_j} T j ′ = ⨁ 1 : p j ! ℓ j ⟨ B j ⟩ . T j .
(5) If source p : T ( S ) = ( ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ ′ , f ) \operatorname{source}_{p:T}(S)=(\bigoplus_{1:q!\ell\langle B\rangle.T'',f)} source p : T ( S ) = ( ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′′ , f ) , then ( ( ∣ p : T ∣ ) , S ) → p : : q : : ℓ 1 ( ( ∣ p : T ∣ ) , S ′ ) ((\lvert p:T\rvert),S)\xrightarrow{p::q::\ell}_{1}((\lvert p:T\rvert),S') ((∣ p : T ∣) , S ) p :: q :: ℓ 1 ((∣ p : T ∣) , S ′ ) where S ′ = f ( t ) S'=f(t) S ′ = f ( t ) if T ′ ′ = t T''=t T ′′ = t , and otherwise
source p : T ( S ′ ) = { ( e n d , ∅ ) if T ′ ′ = e n d ( T ′ , f ∪ ⋃ k { t k ↦ S ′ } ) if T ′ ′ = μ t 1 ⋯ μ t n . T ′ ( T ′ ′ , f ) otherwise. \operatorname{source}_{p:T}(S')=
\begin{cases}
(\mathop{\mathrm{end}},\varnothing) & \text{if }T''=\mathop{\mathrm{end}}\\
(T',f\cup\bigcup_k\{t_k\mapsto S'\}) & \text{if }T''=\mu t_1\cdots\mu t_n.T'\\
(T'',f) & \text{otherwise.}
\end{cases} source p : T ( S ′ ) = ⎩ ⎨ ⎧ ( end , ∅ ) ( T ′ , f ∪ ⋃ k { t k ↦ S ′ }) ( T ′′ , f ) if T ′′ = end if T ′′ = μ t 1 ⋯ μ t n . T ′ otherwise. Moreover, ( ( ∣ p : T ∣ ) , S ) ((\lvert p:T\rvert),S) ((∣ p : T ∣) , S ) cannot make any other transitions.
Proof. We walk through the recursive calls of source ( p , n , f ) ′ ( T ) \operatorname{source}'_{(p,n,f)}(T) source ( p , n , f ) ′ ( T ) and { ∣ T ∣ } ( p , n , m , f ′ ) \{\lvert T\rvert\}_{(p,n,m,f')} {∣ T ∣ } ( p , n , m , f ′ ) in parallel. In particular, by induction on the structure of T ′ T' T ′ , we show that we maintain the invariant that source ( p , n , f ) ′ ( T ′ ) \operatorname{source}'_{(p,n,f)}(T') source ( p , n , f ) ′ ( T ′ ) is called iff { ∣ T ′ ∣ } ( p , n , m , f ′ ) \{\lvert T'\rvert\}_{(p,n,m,f')} {∣ T ′ ∣ } ( p , n , m , f ′ ) is called, where f ( t ) = { S p ↦ f ′ ( t ) } f(t)=\{S_p\mapsto f'(t)\} f ( t ) = { S p ↦ f ′ ( t )} for all t t t . The result then follows as the transitions that ( ( ∣ p : T ∣ ) , { S p ↦ n } ) ((\lvert p:T\rvert),\{S_p\mapsto n\}) ((∣ p : T ∣) , { S p ↦ n }) can make is fully determined by the commands introduced in { ∣ T ∣ } ( p , n ′ , SS ( T ) , f ′ ) \{\lvert T\rvert\}_{(p,n',\operatorname{SS}(T),f')} {∣ T ∣ } ( p , n ′ , SS ( T ) , f ′ ) for some T ′ T' T ′ a partial type of T T T , and n ′ < n n'<n n ′ < n . By the invariant, the corresponding output of source p : T ( S ) \operatorname{source}_{p:T}(S) source p : T ( S ) is determined by the mappings added in source ( p , n ′ , f ) ′ ( T ′ ) \operatorname{source}'_{(p,n',f)}(T') source ( p , n ′ , f ) ′ ( T ′ ) , which adds the correct transitions since T ′ T' T ′ is the same on both sides.
Case T ′ = e n d T'=\mathop{\mathrm{end}} T ′ = end or t t t . Then both source ( p , n , f ) ′ ( T ′ ) \operatorname{source}'_{(p,n,f)}(T') source ( p , n , f ) ′ ( T ′ ) and { ∣ T ′ ∣ } ( p , n , m , f ′ ) \{\lvert T'\rvert\}_{(p,n,m,f')} {∣ T ′ ∣ } ( p , n , m , f ′ ) does not make any further recursive calls.
Case T ′ = μ t . T ′ ′ T'=\mu t.T'' T ′ = μ t . T ′′ . Then source ( p , n , f ) ′ ( μ t . T ′ ′ ) \operatorname{source}'_{(p,n,f)}(\mu t.T'') source ( p , n , f ) ′ ( μ t . T ′′ ) calls source ( p , n , f ∪ { t ↦ S p ↦ n } ) ′ ( T ′ ′ ) \operatorname{source}'_{(p,n,f\cup\{t\mapsto S_p\mapsto n\})}(T'') source ( p , n , f ∪ { t ↦ S p ↦ n }) ′ ( T ′′ ) and { ∣ μ t . T ′ ′ ∣ } ( p , n , m , f ′ ) \{\lvert\mu t.T''\rvert\}_{(p,n,m,f')} {∣ μ t . T ′′ ∣ } ( p , n , m , f ′ ) calls { ∣ T ′ ′ ∣ } ( p , n , m , f ′ ∪ { t ↦ n } ) \{\lvert T''\rvert\}_{(p,n,m,f'\cup\{t\mapsto n\})} {∣ T ′′ ∣ } ( p , n , m , f ′ ∪ { t ↦ n }) , and the invariant is maintained by the induction hypothesis.
Case T ′ = ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ ′ T'=\bigoplus_{1:q!\ell\langle B\rangle.T''} T ′ = ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′′ . Then source ( p , n , f ) ′ ( T ′ ) \operatorname{source}'_{(p,n,f)}(T') source ( p , n , f ) ′ ( T ′ ) calls source ( p , n + 1 , f ) ′ ( T ′ ′ ) \operatorname{source}'_{(p,n+1,f)}(T'') source ( p , n + 1 , f ) ′ ( T ′′ ) and { ∣ T ′ ∣ } ( p , n , m , f ′ ) \{\lvert T'\rvert\}_{(p,n,m,f')} {∣ T ′ ∣ } ( p , n , m , f ′ ) calls { ∣ T ′ ′ ∣ } ( p , n + 1 , m , f ′ ) \{\lvert T''\rvert\}_{(p,n+1,m,f')} {∣ T ′′ ∣ } ( p , n + 1 , m , f ′ ) . Moreover, the entry mapping { S p ↦ n } \{S_p\mapsto n\} { S p ↦ n } added by source ( p , n , f ) ′ ( T ′ ) \operatorname{source}'_{(p,n,f)}(T') source ( p , n , f ) ′ ( T ′ ) corresponds exactly to the guard ( S p = n ) (S_p=n) ( S p = n ) of the p : : q : : ℓ p::q::\ell p :: q :: ℓ command. The invariant is therefore maintained by the induction hypothesis.
Case T ′ = ⨁ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j ′ ′ T'=\bigoplus_{j\in J}p_j:p_j!\ell_j\langle B_j\rangle.T''_j T ′ = ⨁ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j ′′ with ∣ J ∣ ≥ 2 \lvert J\rvert\geq2 ∣ J ∣ ≥ 2 . Then source ( p , n , f ) ′ ( T ′ ) \operatorname{source}'_{(p,n,f)}(T') source ( p , n , f ) ′ ( T ′ ) calls source ( p , com ( j ) , f ) ′ ( T j ′ ) \operatorname{source}'_{(p,\operatorname{com}(j),f)}(T'_j) source ( p , com ( j ) , f ) ′ ( T j ′ ) and { ∣ T ′ ∣ } ( p , n , m , f ′ ) \{\lvert T'\rvert\}_{(p,n,m,f')} {∣ T ′ ∣ } ( p , n , m , f ′ ) calls { ∣ T j ′ ∣ } ( p , com ( j ) , m , f ′ ) \{\lvert T'_j\rvert\}_{(p,\operatorname{com}(j),m,f')} {∣ T j ′ ∣ } ( p , com ( j ) , m , f ′ ) , with the same T j ′ = ⨁ 1 : p j ! ℓ j ⟨ B j ⟩ . T j ′ ′ T'_j=\bigoplus_{1:p_j! \ell_j\langle B_j\rangle.T''_j} T j ′ = ⨁ 1 : p j ! ℓ j ⟨ B j ⟩ . T j ′′ and com ( j ) = 1 + ∑ j ′ < j SS ( T j ′ ′ ) \operatorname{com}(j)=1+\sum_{j'<j}\operatorname{SS}(T'_{j'}) com ( j ) = 1 + ∑ j ′ < j SS ( T j ′ ′ ) on both sides, for all j ∈ J j\in J j ∈ J . Moreover, the entry mapping { S p ↦ n } \{S_p\mapsto n\} { S p ↦ n } added by source ( p , n , f ) ′ ( T ′ ) \operatorname{source}'_{(p,n,f)}(T') source ( p , n , f ) ′ ( T ′ ) corresponds exactly to the guard ( S p = n ) (S_p=n) ( S p = n ) of the p : : p p::p p :: p command, whose updates ( S p ′ = com ( j ) ) (S'_p = \operatorname{com}(j)) ( S p ′ = com ( j )) target the entry mappings added by source ( p , com ( j ) , f ) ′ ( T ′ j ) \operatorname{source}'_{(p,\operatorname{com}(j),f)}(T'^{\,j}) source ( p , com ( j ) , f ) ′ ( T ′ j ) . The invariant is therefore maintained by the induction hypothesis.
Case T ′ = ⨁ i ∈ I ⨁ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ T' = \bigoplus_{i\in I}\bigoplus_{j\in J_i} p_{(i,j)}:p_j!\ell_j\langle B_j\rangle.T'_{(i,j)} T ′ = ⨁ i ∈ I ⨁ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ with ∣ I ∣ ≥ 2 |I|\ge2 ∣ I ∣ ≥ 2 . Then source ( p , n , f ) ′ ( T ′ ) \operatorname{source}'_{(p,n,f)}(T') source ( p , n , f ) ′ ( T ′ ) calls source ( p , sel ( i ) , f ) ′ ( T i ⊕ ) \operatorname{source}'_{(p,\operatorname{sel}(i),f)}(T_i^{\oplus}) source ( p , sel ( i ) , f ) ′ ( T i ⊕ ) and { { T ′ } } ( p , n , m , f ) \{\!\{T'\}\!\}(p,n,m,f) { { T ′ } } ( p , n , m , f ) calls { { T i ⊕ } } ( p , sel ( i ) , m , f ) \{\!\{T_i^{\oplus}\}\!\}(p,\operatorname{sel}(i),m,f) { { T i ⊕ } } ( p , sel ( i ) , m , f ) , with the same T i ⊕ = ⨁ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ T_i^{\oplus}=\bigoplus_{j\in J_i}p_{(i,j)}:p_j!\ell_j\langle B_j\rangle.T'_{(i,j)} T i ⊕ = ⨁ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ and sel ( i ) = n + 1 + ∑ i ′ < i SS ( T i ′ ′ ) \operatorname{sel}(i)=n+1+\sum_{i'<i}\operatorname{SS}(T'_{i'}) sel ( i ) = n + 1 + ∑ i ′ < i SS ( T i ′ ′ ) on both sides, for all i ∈ I i\in I i ∈ I . Moreover, the entry mapping { S p ↦ n } \{S_p\mapsto n\} { S p ↦ n } added by source ( p , n , f ) ′ ( T ′ ) \operatorname{source}'_{(p,n,f)}(T') source ( p , n , f ) ′ ( T ′ ) corresponds exactly to the guard ( S p = n ) (S_p=n) ( S p = n ) of the ∣ I ∣ |I| ∣ I ∣ p : : τ p::\tau p :: τ commands, whose updates ( S p ′ = sel ( i ) ) (S'_p=\operatorname{sel}(i)) ( S p ′ = sel ( i )) target the entry mappings added by source ( p , sel ( i ) , f ) ′ ( T i ⊕ ) \operatorname{source}'_{(p,\operatorname{sel}(i),f)}(T_i^{\oplus}) source ( p , sel ( i ) , f ) ′ ( T i ⊕ ) . The invariant is therefore maintained by the induction hypothesis.
Case T ′ = & i ∈ I p i ? ℓ i ( B i ) . T i ′ ′ T'=\mathbin{\&}_{i\in I}p_i?\ell_i(B_i).T''_i T ′ = & i ∈ I p i ? ℓ i ( B i ) . T i ′′ . Similar to the committed selection case: the only mapping added by source ( p , n , f ) ′ ( T ′ ) \operatorname{source}'_{(p,n,f)}(T') source ( p , n , f ) ′ ( T ′ ) for the node itself is { S p ↦ n } \{S_p\mapsto n\} { S p ↦ n } , corresponding to the guard ( S p = n ) (S_p=n) ( S p = n ) of the ∣ I ∣ |I| ∣ I ∣ branching commands, and the recursive calls source ( p , next ( i ) , f ) ′ ( T i ′ ′ ) \operatorname{source}'_{(p,\operatorname{next}(i),f)}(T''_i) source ( p , next ( i ) , f ) ′ ( T i ′′ ) and { { T i ′ } } ( p , next ( i ) , m , f ) \{\!\{T'_i\}\!\}(p,\operatorname{next}(i),m,f) { { T i ′ } } ( p , next ( i ) , m , f ) share the same next ( i ) = n + 1 + ∑ i ′ ∈ I ∣ i ′ < i SS ( T i ′ ′ ′ ) \operatorname{next}(i)=n+1+\sum_{i'\in I\mid i'<i}\operatorname{SS}(T''_{i'}) next ( i ) = n + 1 + ∑ i ′ ∈ I ∣ i ′ < i SS ( T i ′ ′′ ) .
Finally, we conclude by noting that ∣ p : T ∣ \lvert p:T\lvert ∣ p : T ∣ calls { { T } } ( p , 0 , SS ( T ) , ∅ ) \{\!\{T\}\!\}(p,0,\operatorname{SS}(T),\varnothing) { { T } } ( p , 0 , SS ( T ) , ∅ ) and source p : T \operatorname{source}_{p:T} source p : T calls source ( p , 0 , ∅ ) ′ ( T ) \operatorname{source}'_{(p,0,\varnothing)}(T) source ( p , 0 , ∅ ) ′ ( T ) , so the invariant holds in the beginning. □ \square □
As mentioned above, we define a relation to relate partial types of μ t . T \mu t.T μ t . T and T { μ t . T / t } T\{\mu t.T/t\} T { μ t . T / t } . We do this through a series of rules that build up equivalent types modulo unrolling of t t t .
Definition D.4. The unfold correspondence of two partial types with respect to T T T and t t t , written ⊑ T , t \sqsubseteq_{T,t} ⊑ T , t , is the least relation satisfying the following rules.
T ′ ⊑ T , t T ′ \frac{T'\sqsubseteq_{T,t}T'}{ } T ′ ⊑ T , t T ′ t ⊑ T , t μ t . T \frac{t\sqsubseteq_{T,t}\mu t.T}{ } t ⊑ T , t μ t . T t ′ ≠ t T 1 ⊑ T , t T 2 μ t ′ . T 1 ⊑ T , t μ t ′ . T 2 \frac{t'\ne t\qquad T_1\sqsubseteq_{T,t}T_2}{\mu t'.T_1\sqsubseteq_{T,t}\mu t'.T_2} μ t ′ . T 1 ⊑ T , t μ t ′ . T 2 t ′ = t T 1 ⊑ T , t T 2 ∀ i ∈ I , j ∈ J i : T ( i , j ) ⊑ T , t T ( i , j ) ′ ⨁ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ⊑ T , t ⨁ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ \frac{\forall i\in I,\ j\in J_i:T_{(i,j)}\sqsubseteq_{T,t}T'_{(i,j)}}{ \bigoplus_{i\in I}\bigoplus_{j\in J_i}p_{(i,j)}:q_j!\ell_j\langle B_j\rangle.T_{(i,j)}\sqsubseteq_{T,t}\bigoplus_{i\in I}\bigoplus_{j\in J_i}p_{(i,j)}:q_j!\ell_j\langle B_j\rangle.T'_{(i,j)}} ⨁ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ⊑ T , t ⨁ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ ∀ i ∈ I , j ∈ J i : T ( i , j ) ⊑ T , t T ( i , j ) ′ ∀ i ∈ I : T i ⊑ T , t T i ′ & i ∈ I q i ? ℓ i ( B i ) . T i ⊑ T , t & i ∈ I q i ? ℓ i ( B i ) . T i ′ \frac{\forall i\in I:T_i\sqsubseteq_{T,t}T'_i}{ \mathbin{\&}_{i\in I}q_i?\ell_i(B_i).T_i\sqsubseteq_{T,t}\mathbin{\&}_{i\in I}q_i?\ell_i(B_i).T'_i} & i ∈ I q i ? ℓ i ( B i ) . T i ⊑ T , t & i ∈ I q i ? ℓ i ( B i ) . T i ′ ∀ i ∈ I : T i ⊑ T , t T i ′
Lemma D.5. For every type T T T , T ′ T' T ′ and variable t t t , T ′ ⊑ T , t T ′ { μ t . T / t } T'\sqsubseteq_{T,t}T'\{\mu t.T/t\} T ′ ⊑ T , t T ′ { μ t . T / t } .
Proof. We prove by induction on the structure of T ′ T' T ′ .
Case T ′ = end T'=\operatorname{end} T ′ = end . Follows directly from [uc-refl].
Case T ′ = t ′ T'=t' T ′ = t ′ . There are two further cases. If t ′ = t t'=t t ′ = t , then T ′ { μ t . T / t } = μ t . T T'\{\mu t.T/t\}=\mu t.T T ′ { μ t . T / t } = μ t . T , so we can apply [uc-t]. If t ′ ≠ t t'\ne t t ′ = t , then T ′ { μ t . T / t } = t ′ T'\{\mu t.T/t\}=t' T ′ { μ t . T / t } = t ′ , so we can apply [uc-refl].
Case T ′ = μ t ′ . T ′ ′ T'=\mu t'.T'' T ′ = μ t ′ . T ′′ . By the inductive hypothesis, we have T ′ ′ ⊑ T , t T ′ ′ { μ t . T / t } T''\sqsubseteq_{T,t}T''\{\mu t.T/t\} T ′′ ⊑ T , t T ′′ { μ t . T / t } . Similarly to the variable case, there are two cases. If t ′ = t t'=t t ′ = t , then T ′ { μ t . T / t } = μ t . T ′ ′ T'\{\mu t.T/t\}=\mu t.T'' T ′ { μ t . T / t } = μ t . T ′′ since t t t is rebound, and therefore we can apply [uc-refl] immediately. If t ′ ≠ t t'\ne t t ′ = t , then we have T ′ { μ t . T / t } = μ t ′ . ( T ′ ′ { μ t . T / t } ) T'\{\mu t.T/t\}=\mu t'.(T''\{\mu t.T/t\}) T ′ { μ t . T / t } = μ t ′ . ( T ′′ { μ t . T / t }) , and using the inductive hypothesis we can apply [uc-rec].
Case T ′ = ∑ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ T' = \sum_{i\in I}\bigoplus_{j\in J_i} p_{(i,j)}: q_j!\ell_j\langle B_j\rangle.T'_{(i,j)} T ′ = ∑ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ . By the inductive hypothesis, we have T ( i , j ) ′ ′ ⊑ T , t T ( i , j ) ′ ′ { μ t . T / t } T''_{(i,j)} \sqsubseteq_{T,t} T''_{(i,j)}\{\mu t.T/t\} T ( i , j ) ′′ ⊑ T , t T ( i , j ) ′′ { μ t . T / t } for all i ∈ I i \in I i ∈ I and j ∈ J i j \in J_i j ∈ J i . Thus T ′ { μ t . T / t } = ∑ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . ( T ( i , j ) ′ { μ t . T / t } ) T'\{\mu t.T/t\} = \sum_{i\in I}\bigoplus_{j\in J_i} p_{(i,j)}: q_j!\ell_j\langle B_j\rangle.(T'_{(i,j)}\{\mu t.T/t\}) T ′ { μ t . T / t } = ∑ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . ( T ( i , j ) ′ { μ t . T / t }) , so we can apply [uc-out].
Case T ′ = & i ∈ I q i ? ℓ i ( B i ) . T i ′ ′ T' = \mathbin{\&}_{i\in I} q_i?\ell_i(B_i).T''_i T ′ = & i ∈ I q i ? ℓ i ( B i ) . T i ′′ . Similarly to the above case, by the inductive hypothesis, we have T i ′ ′ ⊑ T , t T i ′ ′ { μ t . T / t } T''_i \sqsubseteq_{T,t} T''_i\{\mu t.T/t\} T i ′′ ⊑ T , t T i ′′ { μ t . T / t } for all i ∈ I i \in I i ∈ I . Note T ′ { μ t . T / t } = & i ∈ I q i ? ℓ i ( B i ) . ( T i ′ ′ { μ t . T / t } ) T'\{\mu t.T/t\} = \mathbin{\&}_{i\in I} q_i?\ell_i(B_i).(T''_i\{\mu t.T/t\}) T ′ { μ t . T / t } = & i ∈ I q i ? ℓ i ( B i ) . ( T i ′′ { μ t . T / t }) , so we can apply [uc-in]. □
Lemma D.6. For every type T T T , ( ∣ p : μ t . T ∣ ) ∼ ( ∣ p : T { μ t . T / t } ∣ ) (\lvert p : \mu t.T\rvert) \sim(\lvert p : T\{\mu t.T/t\}\rvert) (∣ p : μ t . T ∣) ∼ (∣ p : T { μ t . T / t }∣) .
Proof. Suppose S 1 S_1 S 1 and S 2 S_2 S 2 are states for ( ∣ p : μ t . T ∣ ) (\lvert p : \mu t.T\rvert) (∣ p : μ t . T ∣) and ( ∣ p : T { μ t . T / t } ∣ ) (\lvert p : T\{\mu t.T/t\}\rvert) (∣ p : T { μ t . T / t }∣) respectively, and let ( T 1 , f 1 ) = source p : μ t . T ( S 1 ) (T_1, f_1) = \operatorname{source}_{p:\mu t.T}(S_1) ( T 1 , f 1 ) = source p : μ t . T ( S 1 ) and similarly ( T 2 , f 2 ) = source p : T { μ t . T / t } ( S 2 ) (T_2, f_2) = \operatorname{source}_{p:T\{\mu t.T/t\}}(S_2) ( T 2 , f 2 ) = source p : T { μ t . T / t } ( S 2 ) .
Define a binary relation R \mathcal{R} R to be the greatest relation such that if ( S 1 , S 2 ) ∈ R (S_1,S_2) \in\mathcal{R} ( S 1 , S 2 ) ∈ R , then all of the following hold:
T 1 ⊑ T , t T 2 T_1 \sqsubseteq_{T,t} T_2 T 1 ⊑ T , t T 2 ;
for all t ′ ∈ dom ( f 1 ) ∩ dom ( f 2 ) t' \in\operatorname{dom}(f_1) \cap\operatorname{dom}(f_2) t ′ ∈ dom ( f 1 ) ∩ dom ( f 2 ) , ( f 1 ( t ′ ) , f 2 ( t ′ ) ) ∈ R (f_1(t'),f_2(t')) \in\mathcal{R} ( f 1 ( t ′ ) , f 2 ( t ′ )) ∈ R .
We will argue that R \mathcal{R} R is a bisimulation relation.
Take any ( S 1 , S 2 ) ∈ R (S_1,S_2) \in\mathcal{R} ( S 1 , S 2 ) ∈ R , and again let ( T 1 , f 1 ) = source p : μ t . T ( S 1 ) (T_1,f_1) = \operatorname{source}_{p:\mu t.T}(S_1) ( T 1 , f 1 ) = source p : μ t . T ( S 1 ) and ( T 2 , f 2 ) = source p : T { μ t . T / t } ( S 2 ) (T_2,f_2) = \operatorname{source}_{p:T\{\mu t.T/t\}}(S_2) ( T 2 , f 2 ) = source p : T { μ t . T / t } ( S 2 ) . By our definition of R \mathcal{R} R , both T 1 T_1 T 1 and T 2 T_2 T 2 must be end, a proper sum, a proper selection, a committed selection, or a branching (the latter four with the same participants, labels and basic types, and the same probabilities for sums and selections). In the first case, both ( ( ∣ p : μ t . T ∣ ) , S 1 ) ((\lvert p : \mu t.T\rvert),S_1) ((∣ p : μ t . T ∣) , S 1 ) and ( ( ∣ p : T { μ t . T / t } ∣ ) , S 2 ) ((\lvert p : T\{\mu t.T/t\}\rvert),S_2) ((∣ p : T { μ t . T / t }∣) , S 2 ) cannot make any transitions, so there is nothing to check.
For the sum case, suppose
T 1 = ∑ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ , T 2 = ∑ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ ′ , T_1 = \sum_{i\in I}\bigoplus_{j\in J_i} p_{(i,j)}: q_j!\ell_j\langle B_j\rangle.T'_{(i,j)}, \qquad T_2 = \sum_{i\in I}\bigoplus_{j\in J_i} p_{(i,j)}: q_j!\ell_j\langle B_j\rangle.T''_{(i,j)}, T 1 = i ∈ I ∑ j ∈ J i ⨁ p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ , T 2 = i ∈ I ∑ j ∈ J i ⨁ p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′′ ,
with ∣ I ∣ ≥ 2 |I| \ge2 ∣ I ∣ ≥ 2 . By Proposition D.3 (3), for every i ∈ I i \in I i ∈ I ,
( ( ∣ p : μ t . T ∣ ) , S 1 ) → p : : τ 1 ( ( ∣ p : μ t . T ∣ ) , S 1 ′ ) ((\lvert p : \mu t.T\rvert),S_1) \xrightarrow{p::\tau}_1 ((\lvert p : \mu t.T\rvert),S'_1) ((∣ p : μ t . T ∣) , S 1 ) p :: τ 1 ((∣ p : μ t . T ∣) , S 1 ′ )
with source p : μ t . T ( S 1 ′ ) = ( ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ , f 1 ) \operatorname{source}_{p:\mu t.T}(S'_1) = (\bigoplus_{j\in J_i} p_{(i,j)}: q_j!\ell_j\langle B_j\rangle.T'_{(i,j)},f_1) source p : μ t . T ( S 1 ′ ) = ( ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ , f 1 ) , and S 2 S_2 S 2 is able to make the matching transition
( ( ∣ p : T { μ t . T / t } ∣ ) , S 2 ) → p : : τ 1 ( ( ∣ p : T { μ t . T / t } ∣ ) , S 2 ′ ) ((\lvert p : T\{\mu t.T/t\}\rvert),S_2) \xrightarrow{p::\tau}_1 ((\lvert p : T\{\mu t.T/t\}\rvert),S'_2) ((∣ p : T { μ t . T / t }∣) , S 2 ) p :: τ 1 ((∣ p : T { μ t . T / t }∣) , S 2 ′ )
with source p : T { μ t . T / t } ( S 2 ′ ) = ( ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ ′ , f 2 ) \operatorname{source}_{p:T\{\mu t.T/t\}}(S'_2) = (\bigoplus_{j\in J_i} p_{(i,j)}: q_j!\ell_j\langle B_j\rangle.T''_{(i,j)},f_2) source p : T { μ t . T / t } ( S 2 ′ ) = ( ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′′ , f 2 ) . Since ( S 1 , S 2 ) ∈ R (S_1,S_2) \in\mathcal{R} ( S 1 , S 2 ) ∈ R , we have T 1 ⊑ T , t T 2 T_1 \sqsubseteq_{T,t} T_2 T 1 ⊑ T , t T 2 , which must be derived by [uc-refl] or [uc-out]; in either case T ( i , j ) ′ ⊑ T , t T ( i , j ) ′ ′ T'_{(i,j)} \sqsubseteq_{T,t} T''_{(i,j)} T ( i , j ) ′ ⊑ T , t T ( i , j ) ′′ for all j ∈ J i j \in J_i j ∈ J i , so applying [uc-out] relates the two singleton selections above. Therefore ( S 1 ′ , S 2 ′ ) ∈ R (S'_1,S'_2) \in\mathcal{R} ( S 1 ′ , S 2 ′ ) ∈ R . The opposite direction is symmetrical.
For the proper selection case, suppose
T 1 = ⨁ j ∈ J p j : q j ! ℓ j ⟨ B j ⟩ . T j ′ , T 2 = ⨁ j ∈ J p j : q j ! ℓ j ⟨ B j ⟩ . T j ′ ′ , T_1 = \bigoplus_{j\in J} p_j: q_j!\ell_j\langle B_j\rangle.T'_j, \qquad T_2 = \bigoplus_{j\in J} p_j: q_j!\ell_j\langle B_j\rangle.T''_j, T 1 = j ∈ J ⨁ p j : q j ! ℓ j ⟨ B j ⟩ . T j ′ , T 2 = j ∈ J ⨁ p j : q j ! ℓ j ⟨ B j ⟩ . T j ′′ ,
with ∣ J ∣ ≥ 2 |J| \ge2 ∣ J ∣ ≥ 2 . By Proposition D.3 (4), for every j ∈ J j \in J j ∈ J ,
( ( ∣ p : μ t . T ∣ ) , S 1 ) → p : : p j p j ( ( ∣ p : μ t . T ∣ ) , S 1 ′ ) ((\lvert p : \mu t.T\rvert),S_1) \xrightarrow{p::p_j}_{p_j} ((\lvert p : \mu t.T\rvert),S'_1) ((∣ p : μ t . T ∣) , S 1 ) p :: p j p j ((∣ p : μ t . T ∣) , S 1 ′ )
with source p : μ t . T ( S 1 ′ ) = ( ⨁ 1 : q j ! ℓ j ⟨ B j ⟩ . T j ′ , f 1 ) \operatorname{source}_{p:\mu t.T}(S'_1) = (\bigoplus1: q_j!\ell_j\langle B_j\rangle.T'_j,f_1) source p : μ t . T ( S 1 ′ ) = ( ⨁ 1 : q j ! ℓ j ⟨ B j ⟩ . T j ′ , f 1 ) , and S 2 S_2 S 2 is able to make the matching transition
( ( ∣ p : T { μ t . T / t } ∣ ) , S 2 ) → p : : p j p j ( ( ∣ p : T { μ t . T / t } ∣ ) , S 2 ′ ) ((\lvert p : T\{\mu t.T/t\}\rvert),S_2) \xrightarrow{p::p_j}_{p_j} ((\lvert p : T\{\mu t.T/t\}\rvert),S'_2) ((∣ p : T { μ t . T / t }∣) , S 2 ) p :: p j p j ((∣ p : T { μ t . T / t }∣) , S 2 ′ )
with source p : T { μ t . T / t } ( S 2 ′ ) = ( ⨁ 1 : q j ! ℓ j ⟨ B j ⟩ . T j ′ ′ , f 2 ) \operatorname{source}_{p:T\{\mu t.T/t\}}(S'_2) = (\bigoplus1: q_j!\ell_j\langle B_j\rangle.T''_j,f_2) source p : T { μ t . T / t } ( S 2 ′ ) = ( ⨁ 1 : q j ! ℓ j ⟨ B j ⟩ . T j ′′ , f 2 ) . Since ( S 1 , S 2 ) ∈ R (S_1,S_2) \in\mathcal{R} ( S 1 , S 2 ) ∈ R , we have T 1 ⊑ T , t T 2 T_1 \sqsubseteq_{T,t} T_2 T 1 ⊑ T , t T 2 , which must be derived by [uc-refl] or [uc-out]; in either case T j ′ ⊑ T , t T j ′ ′ T'_j \sqsubseteq_{T,t} T''_j T j ′ ⊑ T , t T j ′′ , so applying [uc-out] relates the two committed selections above. Therefore ( S 1 ′ , S 2 ′ ) ∈ R (S'_1,S'_2) \in\mathcal{R} ( S 1 ′ , S 2 ′ ) ∈ R also. The opposite direction is symmetrical. For the committed selection case, suppose
T 1 = ⨁ j 1 : q j ! ℓ j ⟨ B j ⟩ . T j ′ , T 2 = ⨁ j 1 : q j ! ℓ j ⟨ B j ⟩ . T j ′ ′ . T_1 = \bigoplus_{j} 1:q_j!\ell_j\langle B_j\rangle.T'_j,\qquad T_2 = \bigoplus_{j} 1:q_j!\ell_j\langle B_j\rangle.T''_j. T 1 = j ⨁ 1 : q j ! ℓ j ⟨ B j ⟩ . T j ′ , T 2 = j ⨁ 1 : q j ! ℓ j ⟨ B j ⟩ . T j ′′ .
By Proposition D.3 (5), the only possible transitions are
( ( ∣ p : μ t . T ∣ ) , S 1 ) → p : : q j : : ℓ j 1 ( ( ∣ p : μ t . T ∣ ) , S 1 ′ ) , ((|p:\mu t.T|),S_1)\xrightarrow{p::q_j::\ell_j}_1((|p:\mu t.T|),S'_1), (( ∣ p : μ t . T ∣ ) , S 1 ) p :: q j :: ℓ j 1 (( ∣ p : μ t . T ∣ ) , S 1 ′ ) ,
and
( ( ∣ p : T { μ t . T / t } ∣ ) , S 2 ) → p : : q j : : ℓ j 1 ( ( ∣ p : T { μ t . T / t } ∣ ) , S 2 ′ ) . ((|p:T\{\mu t.T/t\}|),S_2)\xrightarrow{p::q_j::\ell_j}_1((|p:T\{\mu t.T/t\}|),S'_2). (( ∣ p : T { μ t . T / t } ∣ ) , S 2 ) p :: q j :: ℓ j 1 (( ∣ p : T { μ t . T / t } ∣ ) , S 2 ′ ) .
We consider the possible cases of T j ′ T'_j T j ′ and T j ′ ′ T''_j T j ′′ . Again by Proposition D.3 :
If T j ′ = T j ′ ′ = e n d T'_j=T''_j=\mathrm{end} T j ′ = T j ′′ = end , source p : μ t . T ( S 1 ′ ) = source p : T { μ t . T / t } ( S 2 ′ ) = ( e n d , ∅ ) \operatorname{source}_{p:\mu t.T}(S'_1)=\operatorname{source}_{p:T\{\mu t.T/t\}}(S'_2)=(\mathrm{end},\varnothing) source p : μ t . T ( S 1 ′ ) = source p : T { μ t . T / t } ( S 2 ′ ) = ( end , ∅ ) .
If T j ′ = T j ′ ′ = t ′ T'_j=T''_j=t' T j ′ = T j ′′ = t ′ (potentially t ′ = t t'=t t ′ = t ), we have S 1 ′ = f 1 ( t ′ ) S'_1=f_1(t') S 1 ′ = f 1 ( t ′ ) and S 2 ′ = f 2 ( t ′ ) S'_2=f_2(t') S 2 ′ = f 2 ( t ′ ) . Hence by definition, ( S 1 ′ , S 2 ′ ) ∈ R (S'_1,S'_2)\in\mathcal{R} ( S 1 ′ , S 2 ′ ) ∈ R .
If T j ′ = μ t 1 ′ ⋯ μ t n ′ . T ′ T'_j=\mu t'_1\cdots\mu t'_n.T' T j ′ = μ t 1 ′ ⋯ μ t n ′ . T ′ and T j ′ ′ = μ t 1 ′ ′ ⋯ μ t n ′ ′ . T ′ ′ T''_j=\mu t''_1\cdots\mu t''_n.T'' T j ′′ = μ t 1 ′′ ⋯ μ t n ′′ . T ′′ , then source p : μ t . T ( S 1 ′ ) = ( T ′ , f 1 ∪ { t k ′ ↦ S 1 ′ } ) \operatorname{source}_{p:\mu t.T}(S'_1)=(T',f_1\cup\{t'_k\mapsto S'_1\}) source p : μ t . T ( S 1 ′ ) = ( T ′ , f 1 ∪ { t k ′ ↦ S 1 ′ }) and source p : T { μ t . T / t } ( S 2 ′ ) = ( T ′ ′ , f 2 ∪ { t k ′ ↦ S 2 ′ } ) \operatorname{source}_{p:T\{\mu t.T/t\}}(S'_2)=(T'',f_2\cup\{t'_k\mapsto S'_2\}) source p : T { μ t . T / t } ( S 2 ′ ) = ( T ′′ , f 2 ∪ { t k ′ ↦ S 2 ′ }) .
If T j ′ = t T'_j=t T j ′ = t and T j ′ ′ = μ t . T T''_j=\mu t.T T j ′′ = μ t . T , then source p : μ t . T ( S 1 ′ ) = ( T , { t ↦ S 1 ′ } ) \operatorname{source}_{p:\mu t.T}(S'_1)=(T,\{t\mapsto S'_1\}) source p : μ t . T ( S 1 ′ ) = ( T , { t ↦ S 1 ′ }) and source p : T { μ t . T / t } ( S 2 ′ ) = ( T , f 2 ∪ { t ↦ S 2 ′ } ) \operatorname{source}_{p:T\{\mu t.T/t\}}(S'_2)=(T,f_2\cup\{t\mapsto S'_2\}) source p : T { μ t . T / t } ( S 2 ′ ) = ( T , f 2 ∪ { t ↦ S 2 ′ }) .
Otherwise, we have source p : μ t . T ( S 1 ′ ) = ( T j ′ , f 1 ) \operatorname{source}_{p:\mu t.T}(S'_1)=(T'_j,f_1) source p : μ t . T ( S 1 ′ ) = ( T j ′ , f 1 ) and source p : T { μ t . T / t } ( S 2 ′ ) = ( T j ′ ′ , f 2 ) \operatorname{source}_{p:T\{\mu t.T/t\}}(S'_2)=(T''_j,f_2) source p : T { μ t . T / t } ( S 2 ′ ) = ( T j ′′ , f 2 ) , with T j ′ ⊑ T , t T j ′ ′ T'_j\sqsubseteq_{T,t}T''_j T j ′ ⊑ T , t T j ′′ by the definition of ⊑ T , t \sqsubseteq_{T,t} ⊑ T , t .
Thus, in all cases, ( S 1 ′ , S 2 ′ ) ∈ R (S'_1,S'_2)\in\mathcal{R} ( S 1 ′ , S 2 ′ ) ∈ R .
For the branching case, suppose T 1 = & i ∈ I q i ? ℓ i ( B i ) . T i ′ T_1=\mathbin{\&}_{i\in I}q_i?\ell_i(B_i).T'_i T 1 = & i ∈ I q i ? ℓ i ( B i ) . T i ′ , and T 2 = & i ∈ I q i ? ℓ i ( B i ) . T i ′ ′ T_2=\mathbin{\&}_{i\in I}q_i?\ell_i(B_i).T''_i T 2 = & i ∈ I q i ? ℓ i ( B i ) . T i ′′ . Here, by Proposition D.3 (2), for each i ∈ I i\in I i ∈ I both modules make the single transition
( ( ∣ p : μ t . T ∣ ) , S 1 ) → q i : : p : : ℓ i 1 ( ( ∣ p : μ t . T ∣ ) , S 1 ′ ) ((|p:\mu t.T|),S_1)\xrightarrow{q_i::p::\ell_i}_1((|p:\mu t.T|),S'_1) (( ∣ p : μ t . T ∣ ) , S 1 ) q i :: p :: ℓ i 1 (( ∣ p : μ t . T ∣ ) , S 1 ′ )
( ( ∣ p : T { μ t . T / t } ∣ ) , S 2 ) → q i : : p : : ℓ i 1 ( ( ∣ p : T { μ t . T / t } ∣ ) , S 2 ′ ) ((|p:T\{\mu t.T/t\}|),S_2)\xrightarrow{q_i::p::\ell_i}_1((|p:T\{\mu t.T/t\}|),S'_2) (( ∣ p : T { μ t . T / t } ∣ ) , S 2 ) q i :: p :: ℓ i 1 (( ∣ p : T { μ t . T / t } ∣ ) , S 2 ′ )
since the senders q i q_i q i , choices I I I , labels and basic types are the same on both sides. We then consider the different cases of T i ′ T'_i T i ′ and T i ′ ′ T''_i T i ′′ in exactly the same way as the committed selection case (D.1.1). Therefore we have ( S 1 ′ , S 2 ′ ) ∈ R (S'_1,S'_2)\in\mathcal{R} ( S 1 ′ , S 2 ′ ) ∈ R , and the opposite direction is symmetrical.
Finally, from the definition of ( ∣ ⋅ ∣ ) (|\cdot|) ( ∣ ⋅ ∣ ) , we have source p : μ t . T ( ∅ ) = ( T , { t ↦ ∅ } ) \operatorname{source}_{p:\mu t.T}(\varnothing)=(T,\{t\mapsto\varnothing\}) source p : μ t . T ( ∅ ) = ( T , { t ↦ ∅ }) and source p : T { μ t . T / t } ( ∅ ) = ( T { μ t . T / t } , ∅ ) \operatorname{source}_{p:T\{\mu t.T/t\}}(\varnothing)=(T\{\mu t.T/t\},\varnothing) source p : T { μ t . T / t } ( ∅ ) = ( T { μ t . T / t } , ∅ ) , so applying Lemma D.5 again, ( ∅ , ∅ ) ∈ R (\varnothing,\varnothing)\in\mathcal{R} ( ∅ , ∅ ) ∈ R . Hence R \mathcal{R} R is a bisimulation relation, and we can conclude ( ∣ p : μ t . T ∣ ) ∼ ( ∣ p : T { μ t . T / t } ∣ ) (|p:\mu t.T|)\sim(|p:T\{\mu t.T/t\}|) ( ∣ p : μ t . T ∣ ) ∼ ( ∣ p : T { μ t . T / t } ∣ ) . □
Lemma D.7. Let T , T ′ T,T' T , T ′ be (closed) types, and S S S a state for ( ∣ p : T ∣ ) (|p:T|) ( ∣ p : T ∣ ) such that source p : T ( S ) = ( T ′ , f ) \operatorname{source}_{p:T}(S)=(T',f) source p : T ( S ) = ( T ′ , f ) . Then ( ( ∣ p : T ∣ ) , S ) ∼ ( ∣ p : T ′ ∣ ) ((|p:T|),S)\sim(|p:T'|) (( ∣ p : T ∣ ) , S ) ∼ ( ∣ p : T ′ ∣ ) .
Proof. Let S 1 , S 2 S_1,S_2 S 1 , S 2 be states for ( ∣ p : T ∣ ) (|p:T|) ( ∣ p : T ∣ ) and ( ∣ p : T ′ ∣ ) (|p:T'|) ( ∣ p : T ′ ∣ ) , respectively. Let ( T 1 , f 1 ) = source p : T ( S 1 ) (T_1,f_1)=\operatorname{source}_{p:T}(S_1) ( T 1 , f 1 ) = source p : T ( S 1 ) and ( T 2 , f 2 ) = source p : T ′ ( S 2 ) (T_2,f_2)=\operatorname{source}_{p:T'}(S_2) ( T 2 , f 2 ) = source p : T ′ ( S 2 ) . We construct the bisimulation relation R \mathcal{R} R to be the greatest relation such that if ( S 1 , S 2 ) ∈ R (S_1,S_2)\in\mathcal{R} ( S 1 , S 2 ) ∈ R :
(1) T 1 = T 2 T_1=T_2 T 1 = T 2 ; and
(2) for all t ′ ∈ dom ( f 1 ) ∩ dom ( f 2 ) t'\in\operatorname{dom}(f_1)\cap\operatorname{dom}(f_2) t ′ ∈ dom ( f 1 ) ∩ dom ( f 2 ) , ( f 1 ( t ′ ) , f 2 ( t ′ ) ) ∈ R (f_1(t'),f_2(t'))\in\mathcal{R} ( f 1 ( t ′ ) , f 2 ( t ′ )) ∈ R .
We then use a similar structure as the proof of Lemma D.6 to argue that R \mathcal{R} R is a bisimulation relation. Notably, ( S , ∅ ) ∈ R (S,\varnothing)\in\mathcal{R} ( S , ∅ ) ∈ R . □
Lemma D.8.
(1) For every type T T T with p : T → n p : T ′ p:T\xrightarrow{n}p:T' p : T n p : T ′ , there exists a state S 1 S_1 S 1 such that
( ∣ p : T ∣ ) → p : : τ 1 ( ( ∣ p : T ∣ ) , S 1 ) ∼ ( ∣ p : T ′ ∣ ) . (|p:T|)\xrightarrow{p::\tau}_1((|p:T|),S_1)\sim(|p:T'|). ( ∣ p : T ∣ ) p :: τ 1 (( ∣ p : T ∣ ) , S 1 ) ∼ ( ∣ p : T ′ ∣ ) .
(2) For every type T T T and probability p p p with p : T → p p : T ′ p:T \xrightarrow{p} p:T' p : T p p : T ′ , there exists a state S 1 S_1 S 1 such that
( ∣ p : T ∣ ) → p : : p p ( ( ∣ p : T ∣ ) , S 1 ) ∼ ( ∣ p : T ′ ∣ ) . (\lvert p:T\rvert) \xrightarrow{p::p}_{p} ((\lvert p:T\rvert),S_1) \sim(\lvert p:T'\rvert). (∣ p : T ∣) p :: p p ((∣ p : T ∣) , S 1 ) ∼ (∣ p : T ′ ∣) .
(3) For every type T T T with p : T → p : q ! ℓ ⟨ B ⟩ 1 p : T ′ p:T \xrightarrow{p:q!\ell\langle B\rangle}_{1} p:T' p : T p : q ! ℓ ⟨ B ⟩ 1 p : T ′ , there exists a state S 1 S_1 S 1 such that
( ∣ p : T ∣ ) → p : : q : : ℓ 1 ( ( ∣ p : T ∣ ) , S 1 ) ∼ ( ∣ p : T ′ ∣ ) . (\lvert p:T\rvert) \xrightarrow{p::q::\ell}_{1} ((\lvert p:T\rvert),S_1) \sim(\lvert p:T'\rvert). (∣ p : T ∣) p :: q :: ℓ 1 ((∣ p : T ∣) , S 1 ) ∼ (∣ p : T ′ ∣) .
(4) For every type T T T with p : T → p : q ? ℓ ( B ) 1 p : T ′ p:T \xrightarrow{p:q?\ell(B)}_{1} p:T' p : T p : q ? ℓ ( B ) 1 p : T ′ , there exists a state S 1 S_1 S 1 such that
( ∣ p : T ∣ ) → q : : p : : ℓ 1 ( ( ∣ p : T ∣ ) , S 1 ) ∼ ( ∣ p : T ′ ∣ ) . (\lvert p:T\rvert) \xrightarrow{q::p::\ell}_{1} ((\lvert p:T\rvert),S_1) \sim(\lvert p:T'\rvert). (∣ p : T ∣) q :: p :: ℓ 1 ((∣ p : T ∣) , S 1 ) ∼ (∣ p : T ′ ∣) .
Proof.
(1) We proceed by induction on the derivation of the reduction.
Case [CT-ND]. Let T = ∑ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) T = \sum_{i\in I}\bigoplus_{j\in J_i} p(i,j):q_j!\ell_j\langle B_j\rangle.T_{(i,j)} T = ∑ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) with ∣ I ∣ > 1 \lvert I\rvert> 1 ∣ I ∣ > 1 . The reduction selects a summand k ∈ I k\in I k ∈ I , so that T ′ = ⨁ j ∈ J k p ( k , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( k , j ) T' = \bigoplus_{j\in J_k}p(k,j):q_j!\ell_j\langle B_j\rangle.T_{(k,j)} T ′ = ⨁ j ∈ J k p ( k , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( k , j ) . By the definition of ( ∣ ⋅ ∣ ) (\lvert\cdot\rvert) (∣ ⋅ ∣) , we have the summand step
( ∣ p : T ∣ ) → p : : τ 1 ( ( ∣ p : T ∣ ) , S 1 ) (\lvert p:T\rvert) \xrightarrow{p::\tau}_{1} ((\lvert p:T\rvert),S_1) (∣ p : T ∣) p :: τ 1 ((∣ p : T ∣) , S 1 )
with S 1 = { S p ↦ sel ( k ) } S_1=\{S_p\mapsto\operatorname{sel}(k)\} S 1 = { S p ↦ sel ( k )} , so source p : T ( S 1 ) = ( T k ⊕ , ∅ ) \operatorname{source}_{p:T}(S_1)=(T_k^\oplus,\varnothing) source p : T ( S 1 ) = ( T k ⊕ , ∅ ) . Since T T T is closed, so is T k ⊕ T_k^\oplus T k ⊕ , and we can apply Lemma D.7 to conclude ( ( ∣ p : T ∣ ) , S 1 ) ∼ ( ∣ p : T k ⊕ ∣ ) ((\lvert p:T\rvert),S_1)\sim(\lvert p:T_k^\oplus\rvert) ((∣ p : T ∣) , S 1 ) ∼ (∣ p : T k ⊕ ∣) .
Case [CT-REC]. Suppose p : T { μ t . T / t } → p : : τ n p : T ′ p:T\{\mu t.T/t\}\xrightarrow{p::\tau}_{n}p:T' p : T { μ t . T / t } p :: τ n p : T ′ . By the inductive hypothesis, there exists a state S 1 S_1 S 1 such that
( ∣ p : T { μ t . T / t } ∣ ) → p : : τ 1 ( ( ∣ p : T { μ t . T / t } ∣ ) , S 1 ) ∼ ( ∣ p : T ′ ∣ ) . (\lvert p:T\{\mu t.T/t\}\rvert)\xrightarrow{p::\tau}_{1}((\lvert p:T\{\mu t.T/t\}\rvert),S_1)\sim(\lvert p:T'\rvert). (∣ p : T { μ t . T / t }∣) p :: τ 1 ((∣ p : T { μ t . T / t }∣) , S 1 ) ∼ (∣ p : T ′ ∣) .
We have ( ∣ p : μ t . T ∣ ) ∼ ( ∣ p : T { μ t . T / t } ∣ ) (\lvert p:\mu t.T\rvert)\sim(\lvert p:T\{\mu t.T/t\}\rvert) (∣ p : μ t . T ∣) ∼ (∣ p : T { μ t . T / t }∣) from Lemma D.6, and hence there must indeed exist a state S 1 ′ S'_1 S 1 ′ such that
( ∣ p : μ t . T ∣ ) → p : : τ 1 ( ( ∣ p : μ t . T ∣ ) , S 1 ′ ) ∼ ( ∣ p : T ′ ∣ ) . (\lvert p:\mu t.T\rvert)\xrightarrow{p::\tau}_{1}((\lvert p:\mu t.T\rvert),S'_1)\sim(\lvert p:T'\rvert). (∣ p : μ t . T ∣) p :: τ 1 ((∣ p : μ t . T ∣) , S 1 ′ ) ∼ (∣ p : T ′ ∣) .
(2) We proceed by induction on the derivation of the reduction.
Case [CT-PROB]. Let T = ⨁ j ∈ J p j : q j ! ℓ j ⟨ B j ⟩ . T j T=\bigoplus_{j\in J}p_j:q_j!\ell_j\langle B_j\rangle.T_j T = ⨁ j ∈ J p j : q j ! ℓ j ⟨ B j ⟩ . T j . The reduction selects a branch l ∈ J l\in J l ∈ J with p l ∈ ( 0 ; 1 ) p_l\in(0;1) p l ∈ ( 0 ; 1 ) (hence ∣ J ∣ ≥ 2 \lvert J\rvert\ge2 ∣ J ∣ ≥ 2 , i.e. T T T is a proper selection), so that p = p l p=p_l p = p l and T ′ = T l ′ = ⨁ 1 : q l ! ℓ l ⟨ B l ⟩ . T l T'=T'_l=\bigoplus1:q_l!\ell_l\langle B_l\rangle.T_l T ′ = T l ′ = ⨁ 1 : q l ! ℓ l ⟨ B l ⟩ . T l . We can assume T l T_l T l is closed (otherwise, instances of [CT-REC] can be applied to unfold the recursion). Then by the definition of ( ∣ ⋅ ∣ ) (\lvert\cdot\rvert) (∣ ⋅ ∣) , we have the commitment step
( ∣ p : T ∣ ) → p : : p p l ( ( ∣ p : T ∣ ) , S 1 ) (\lvert p:T\rvert)\xrightarrow{p::p}_{p_l}((\lvert p:T\rvert),S_1) (∣ p : T ∣) p :: p p l ((∣ p : T ∣) , S 1 )
with S 1 = { S p ↦ com ( l ) } S_1=\{S_p\mapsto\operatorname{com}(l)\} S 1 = { S p ↦ com ( l )} , so source p : T ( S 1 ) = ( T l ′ , ∅ ) \operatorname{source}_{p:T}(S_1)=(T'_l,\varnothing) source p : T ( S 1 ) = ( T l ′ , ∅ ) . Since T l ′ T'_l T l ′ is closed, we can apply Lemma D.7 to conclude ( ( ∣ p : T ∣ ) , S 1 ) ∼ ( ∣ p : T l ′ ∣ ) ((\lvert p:T\rvert),S_1)\sim(\lvert p:T'_l\rvert) ((∣ p : T ∣) , S 1 ) ∼ (∣ p : T l ′ ∣) .
Case [CT-REC]. Suppose p : T { μ t . T / t } → p : : p p p : T ′ p:T\{\mu t.T/t\}\xrightarrow{p::p}_{p}p:T' p : T { μ t . T / t } p :: p p p : T ′ . By the inductive hypothesis, there exists a state S 1 S_1 S 1 such that
( ∣ p : T { μ t . T / t } ∣ ) → p : : p p ( ( ∣ p : T { μ t . T / t } ∣ ) , S 1 ) ∼ ( ∣ p : T ′ ∣ ) . (\lvert p:T\{\mu t.T/t\}\rvert)\xrightarrow{p::p}_{p}((\lvert p:T\{\mu t.T/t\}\rvert),S_1)\sim(\lvert p:T'\rvert). (∣ p : T { μ t . T / t }∣) p :: p p ((∣ p : T { μ t . T / t }∣) , S 1 ) ∼ (∣ p : T ′ ∣) .
We have ( ∣ p : μ t . T ∣ ) ∼ ( ∣ p : T { μ t . T / t } ∣ ) (\lvert p:\mu t.T\rvert)\sim(\lvert p:T\{\mu t.T/t\}\rvert) (∣ p : μ t . T ∣) ∼ (∣ p : T { μ t . T / t }∣) from Lemma D.6, and hence there must indeed exist a state S 1 ′ S'_1 S 1 ′ such that
( ∣ p : μ t . T ∣ ) → p : : p p ( ( ∣ p : μ t . T ∣ ) , S 1 ′ ) ∼ ( ∣ p : T ′ ∣ ) . (\lvert p:\mu t.T\rvert)\xrightarrow{p::p}_{p}((\lvert p:\mu t.T\rvert),S'_1)\sim(\lvert p:T'\rvert). (∣ p : μ t . T ∣) p :: p p ((∣ p : μ t . T ∣) , S 1 ′ ) ∼ (∣ p : T ′ ∣) .
(3) We proceed by induction on the derivation of the reduction. Case [CT-OUT]. Let T = ⨁ i : q ! ℓ ⟨ B ⟩ . T ′ T = \bigoplus_{i: q!\ell\langle B\rangle.T'} T = ⨁ i : q ! ℓ ⟨ B ⟩ . T ′ be a committed selection, so that the reduction emits ℓ \ell ℓ to q q q with T ′ T' T ′ the continuation. We can assume T ′ T' T ′ is closed (otherwise, instances of [CT-REC] can be applied to unfold the recursion). Then by the definition of ( ∣ ⋅ ∣ ) (\lvert\cdot\rvert) (∣ ⋅ ∣) , we have the synchronisation
( ∣ p : T ∣ ) → p : : q : : ℓ 1 ( ( ∣ p : T ∣ ) , S 1 ) (\lvert p : T\rvert) \xrightarrow{p::q::\ell}_{1} ((\lvert p : T\rvert), S_{1}) (∣ p : T ∣) p :: q :: ℓ 1 ((∣ p : T ∣) , S 1 )
for a state S 1 S_{1} S 1 .
It therefore suffices to show that ( ( ∣ p : T ∣ ) , S 1 ) ∼ ( ∣ p : T ′ ∣ ) ((\lvert p : T\rvert), S_{1}) \sim(\lvert p : T'\rvert) ((∣ p : T ∣) , S 1 ) ∼ (∣ p : T ′ ∣) . We consider the two possible cases for T ′ T' T ′ .
(a) If T ′ = e n d T' = \mathrm{end} T ′ = end , then S 1 = { S p ↦ S S ( T ) } S_{1} = \{S_{p} \mapsto\mathrm{SS}(T)\} S 1 = { S p ↦ SS ( T )} . By the encoding, both ( ( ∣ p : T ∣ ) , S 1 ) ((\lvert p : T\rvert), S_{1}) ((∣ p : T ∣) , S 1 ) and ( ∣ p : e n d ∣ ) (\lvert p : \mathrm{end}\rvert) (∣ p : end ∣) cannot make any transitions, and hence they are bisimilar.
(b) Otherwise, S 1 = { S p ↦ 1 } S_{1} = \{S_{p} \mapsto1\} S 1 = { S p ↦ 1 } , so source p : T ( S 1 ) = ( T ′ , ∅ ) \operatorname{source}_{p:T}(S_{1}) = (T', \varnothing) source p : T ( S 1 ) = ( T ′ , ∅ ) . Since T ′ T' T ′ is closed, we can apply Lemma D.7 to conclude ( ( ∣ p : T ∣ ) , S 1 ) ∼ ( ∣ p : T ′ ∣ ) ((\lvert p : T\rvert), S_{1}) \sim(\lvert p : T'\rvert) ((∣ p : T ∣) , S 1 ) ∼ (∣ p : T ′ ∣) .
Case [CT-REC]. Suppose p : T { μ t . T / t } → p : q ! ℓ ⟨ B ⟩ 1 p : T ′ p : T\{\mu t.T/t\} \xrightarrow{p:q!\ell\langle B\rangle}_{1} p : T' p : T { μ t . T / t } p : q ! ℓ ⟨ B ⟩ 1 p : T ′ . By the inductive hypothesis, there exists a state S 1 S_{1} S 1 such that
( ∣ p : T { μ t . T / t } ∣ ) → p : : q : : ℓ 1 ( ( ∣ p : T { μ t . T / t } ∣ ) , S 1 ) ∼ ( ∣ p : T ′ ∣ ) . (\lvert p : T\{\mu t.T/t\}\rvert) \xrightarrow{p::q::\ell}_{1} ((\lvert p : T\{\mu t.T/t\}\rvert), S_{1}) \sim(\lvert p : T'\rvert). (∣ p : T { μ t . T / t }∣) p :: q :: ℓ 1 ((∣ p : T { μ t . T / t }∣) , S 1 ) ∼ (∣ p : T ′ ∣) .
We have ( ∣ p : μ t . T ∣ ) ∼ ( ∣ p : T { μ t . T / t } ∣ ) (\lvert p : \mu t.T\rvert) \sim(\lvert p : T\{\mu t.T/t\}\rvert) (∣ p : μ t . T ∣) ∼ (∣ p : T { μ t . T / t }∣) from Lemma D.6, and hence there must indeed exist a state S 1 ′ S'_{1} S 1 ′ such that
( ∣ p : μ t . T ∣ ) → p : : q : : ℓ 1 ( ( ∣ p : μ t . T ∣ ) , S 1 ′ ) ∼ ( ∣ p : T ′ ∣ ) . (\lvert p : \mu t.T\rvert) \xrightarrow{p::q::\ell}_{1} ((\lvert p : \mu t.T\rvert), S'_{1}) \sim(\lvert p : T'\rvert). (∣ p : μ t . T ∣) p :: q :: ℓ 1 ((∣ p : μ t . T ∣) , S 1 ′ ) ∼ (∣ p : T ′ ∣) .
(4) Analogous to (3), using [CT-IN] in place of [CT-OUT]. Here T = & i ∈ I q i ? ℓ i ( B i ) . T i T = \mathbin{\&}_{i\in I}q_i?\ell_i(B_i).T_i T = & i ∈ I q i ? ℓ i ( B i ) . T i and the reduction selects a branch k ∈ I k \in I k ∈ I with q = q k q = q_k q = q k , ℓ = ℓ k \ell= \ell_k ℓ = ℓ k and T ′ = T k T' = T_k T ′ = T k . By the definition of ( ∣ ⋅ ∣ ) (\lvert\cdot\rvert) (∣ ⋅ ∣) the receiver makes the single transition
( ∣ p : T ∣ ) → q k : : p : : ℓ k 1 ( ( ∣ p : T ∣ ) , S 1 ) , (\lvert p : T\rvert) \xrightarrow{q_k::p::\ell_k}_{1} ((\lvert p : T\rvert), S_{1}), (∣ p : T ∣) q k :: p :: ℓ k 1 ((∣ p : T ∣) , S 1 ) ,
and ( ( ∣ p : T ∣ ) , S 1 ) ∼ ( ∣ p : T k ∣ ) ((\lvert p : T\rvert), S_{1}) \sim(\lvert p : T_k\rvert) ((∣ p : T ∣) , S 1 ) ∼ (∣ p : T k ∣) follows exactly as in the send case: directly when T k = e n d T_k = \mathrm{end} T k = end , and otherwise by Lemma D.7 since source p : T ( S 1 ) = ( T k , ∅ ) \operatorname{source}_{p:T}(S_{1}) = (T_k, \varnothing) source p : T ( S 1 ) = ( T k , ∅ ) . The [CT-REC] case is identical, using Lemma D.6.
Definition D.9. Let S 1 S_{1} S 1 and S 2 S_{2} S 2 be states for a PRISM module M M M . Their union is given by
( S 1 ∪ S 2 ) ( x ) = { S 1 ( x ) if x ∈ dom ( S 1 ) , x ∉ dom ( S 2 ) S 2 ( x ) if x ∈ dom ( S 2 ) , x ∉ dom ( S 1 ) S 1 ( x ) if S 1 ( x ) = S 2 ( x ) undefined otherwise. (S_{1} \cup S_{2})(x) =
\begin{cases}
S_{1}(x) & \text{if } x \in\operatorname{dom}(S_{1}),\ x \notin\operatorname{dom}(S_{2}) \\
S_{2}(x) & \text{if } x \in\operatorname{dom}(S_{2}),\ x \notin\operatorname{dom}(S_{1}) \\
S_{1}(x) & \text{if } S_{1}(x) = S_{2}(x) \\
\text{undefined} & \text{otherwise.}
\end{cases} ( S 1 ∪ S 2 ) ( x ) = ⎩ ⎨ ⎧ S 1 ( x ) S 2 ( x ) S 1 ( x ) undefined if x ∈ dom ( S 1 ) , x ∈ / dom ( S 2 ) if x ∈ dom ( S 2 ) , x ∈ / dom ( S 1 ) if S 1 ( x ) = S 2 ( x ) otherwise.
Lemma D.10. Let Δ \Delta Δ and Δ ′ \Delta' Δ ′ be contexts with dom ( Δ ) ∩ dom ( Δ ′ ) = ∅ \operatorname{dom}(\Delta) \cap\operatorname{dom}(\Delta') = \varnothing dom ( Δ ) ∩ dom ( Δ ′ ) = ∅ , and suppose ( ( ∣ Δ ∣ ) , S 1 ) → α p ( ( ∣ Δ ∣ ) , S 1 ′ ) ((\lvert\Delta\rvert), S_{1}) \xrightarrow{\alpha}_{p} ((\lvert\Delta\rvert), S'_{1}) ((∣ Δ ∣) , S 1 ) α p ((∣ Δ ∣) , S 1 ′ ) for some states S 1 S_{1} S 1 and S 1 ′ S'_{1} S 1 ′ . Let S 2 S_{2} S 2 be a state for ( ∣ Δ ′ ∣ ) (\lvert\Delta'\rvert) (∣ Δ ′ ∣) .
(1) If α = p : : q : : ℓ \alpha= p::q::\ell α = p :: q :: ℓ and ( ( ∣ Δ ′ ∣ ) , S 2 ) → α p ′ ( ( ∣ Δ ′ ∣ ) , S 2 ′ ) ((\lvert\Delta'\rvert), S_{2}) \xrightarrow{\alpha}_{p'} ((\lvert\Delta'\rvert), S'_{2}) ((∣ Δ ′ ∣) , S 2 ) α p ′ ((∣ Δ ′ ∣) , S 2 ′ ) for some state S 2 ′ S'_{2} S 2 ′ , then
( ( ∣ Δ , Δ ′ ∣ ) , S 1 ∪ S 2 ) → α p ⋅ p ′ ( ( ∣ Δ , Δ ′ ∣ ) , S 1 ′ ∪ S 2 ′ ) . ((\lvert\Delta,\Delta'\rvert), S_{1} \cup S_{2}) \xrightarrow{\alpha}_{p\cdot p'} ((\lvert\Delta,\Delta'\rvert), S'_{1} \cup S'_{2}). ((∣ Δ , Δ ′ ∣) , S 1 ∪ S 2 ) α p ⋅ p ′ ((∣ Δ , Δ ′ ∣) , S 1 ′ ∪ S 2 ′ ) . (2) If α \alpha α is not present in ( ∣ Δ ′ ∣ ) (\lvert\Delta'\rvert) (∣ Δ ′ ∣) , then
( ( ∣ Δ , Δ ′ ∣ ) , S 1 ∪ S 2 ) → α p ( ( ∣ Δ , Δ ′ ∣ ) , S 1 ′ ∪ S 2 ) . ((\lvert\Delta,\Delta'\rvert), S_{1} \cup S_{2}) \xrightarrow{\alpha}_{p} ((\lvert\Delta,\Delta'\rvert), S'_{1} \cup S_{2}). ((∣ Δ , Δ ′ ∣) , S 1 ∪ S 2 ) α p ((∣ Δ , Δ ′ ∣) , S 1 ′ ∪ S 2 ) .
Proof. (1) Since α = p : : q : : ℓ \alpha= p :: q :: \ell α = p :: q :: ℓ , by construction only participants p p p and q q q can have transitions with this action. Furthermore, by assumption, there are no overlapping participants in Δ \Delta Δ and Δ ′ \Delta' Δ ′ . Thus, without loss of generality, we assume Δ \Delta Δ contains p p p and Δ ′ \Delta' Δ ′ contains q q q . By the definition of ( ∣ ⋅ ∣ ) (|\cdot|) ( ∣ ⋅ ∣ ) , each such command is deterministic, so we have
( ∣ Δ ∣ ) ⇝ [ α ] ( S p = n ) → 1 : ( S p ′ = n ′ ) (|\Delta|) \leadsto[\alpha]\ (S_p = n) \to1 : (S'_p = n') ( ∣Δ∣ ) ⇝ [ α ] ( S p = n ) → 1 : ( S p ′ = n ′ )
( ∣ Δ ′ ∣ ) ⇝ [ α ] ( S q = m ) → 1 : ( S q ′ = m ′ ) (|\Delta'|) \leadsto[\alpha]\ (S_q = m) \to1 : (S'_q = m') ( ∣ Δ ′ ∣ ) ⇝ [ α ] ( S q = m ) → 1 : ( S q ′ = m ′ )
for n = S 1 ( S p ) n = S_1(S_p) n = S 1 ( S p ) , m = S 2 ( S q ) m = S_2(S_q) m = S 2 ( S q ) with S 1 [ ( S p ′ = n ′ ) ] = S 1 ′ S_1[(S'_p = n')] = S'_1 S 1 [( S p ′ = n ′ )] = S 1 ′ and S 2 [ ( S q ′ = m ′ ) ] = S 2 ′ S_2[(S'_q = m')] = S'_2 S 2 [( S q ′ = m ′ )] = S 2 ′ . Note from this we have p = p ′ = 1 p = p' = 1 p = p ′ = 1 .
Applying [M-SYNC], we have
( ∣ Δ , Δ ′ ∣ ) ⇝ [ α ] ( S p = n ) ∧ ( S q = m ) → 1 : ( S p ′ = n ′ ) ∧ ( S q ′ = m ′ ) . (|\Delta, \Delta'|) \leadsto[\alpha]\ (S_p = n) \land(S_q = m) \to1 : (S'_p = n') \land(S'_q = m'). ( ∣Δ , Δ ′ ∣ ) ⇝ [ α ] ( S p = n ) ∧ ( S q = m ) → 1 : ( S p ′ = n ′ ) ∧ ( S q ′ = m ′ ) .
Hence by applying [S-STEP], we conclude
( ( ∣ Δ , Δ ′ ∣ ) , S 1 ∪ S 2 ) → p : : q : : ℓ 1 ( ( ∣ Δ , Δ ′ ∣ ) , S 1 ′ ∪ S 2 ′ ) , ((|\Delta, \Delta'|), S_1 \cup S_2) \xrightarrow[\ p::q::\ell\ ]{1} ((|\Delta, \Delta'|), S'_1 \cup S'_2), (( ∣Δ , Δ ′ ∣ ) , S 1 ∪ S 2 ) 1 p :: q :: ℓ (( ∣Δ , Δ ′ ∣ ) , S 1 ′ ∪ S 2 ′ ) ,
and p ⋅ p ′ = 1 p \cdot p' = 1 p ⋅ p ′ = 1 .
(2) By definition of ( ∣ ⋅ ∣ ) (|\cdot|) ( ∣ ⋅ ∣ ) , this transition does not access or modify variables in S 2 S_2 S 2 . So the result is immediate by applying [M-MOVE] followed by [S-STEP].
Lemma D.11. Let Δ = p : T , q : T ′ , Δ ′ \Delta= p : T, q : T', \Delta' Δ = p : T , q : T ′ , Δ ′ be a context, and α = p : : q : : ℓ \alpha= p :: q :: \ell α = p :: q :: ℓ . If ( ( ∣ p : T ∣ ) , S 1 ) → p α ( ( ∣ p : T ∣ ) , S 1 ′ ) ((|p : T|), S_1) \xrightarrow[\ p\ ]{\alpha} ((|p : T|), S'_1) (( ∣ p : T ∣ ) , S 1 ) α p (( ∣ p : T ∣ ) , S 1 ′ ) and ( ( ∣ q : T ′ ∣ ) , S 2 ) → 1 α ( ( ∣ q : T ′ ∣ ) , S 2 ′ ) ((|q : T'|), S_2) \xrightarrow[\ 1\ ]{\alpha} ((|q : T'|), S'_2) (( ∣ q : T ′ ∣ ) , S 2 ) α 1 (( ∣ q : T ′ ∣ ) , S 2 ′ ) ,
( [ [ Δ ] ] , S 1 ∪ S 2 ∪ S ) → p α ( [ [ Δ ] ] , S 1 ′ ∪ S 2 ′ ∪ S ) . ([[ \Delta]], S_1 \cup S_2 \cup S) \xrightarrow[\ p\ ]{\alpha} ([[ \Delta]], S'_1 \cup S'_2 \cup S). ([[ Δ ]] , S 1 ∪ S 2 ∪ S ) α p ([[ Δ ]] , S 1 ′ ∪ S 2 ′ ∪ S ) .
Proof. Let u 1 u_1 u 1 and u 2 u_2 u 2 be the updates performed in the two transitions, so that S 1 ′ = S 1 [ u 1 ] S'_1 = S_1[u_1] S 1 ′ = S 1 [ u 1 ] and S 2 ′ = S 2 [ u 2 ] S'_2 = S_2[u_2] S 2 ′ = S 2 [ u 2 ] . Examining the definition of ( ∣ ⋅ ∣ ) (|\cdot|) ( ∣ ⋅ ∣ ) , the updates must have the form
u 1 = ( S p ′ = n ′ ) u 2 = ( S q ′ = m ′ ) . u_1 = (S'_p = n') \qquad u_2 = (S'_q = m'). u 1 = ( S p ′ = n ′ ) u 2 = ( S q ′ = m ′ ) .
These are distinct variables, so u 1 ∧ u 2 u_1 \land u_2 u 1 ∧ u 2 is well-defined. Applying [M-SYNC] and [S-STEP], we have
( [ [ Δ ] ] , S 1 ∪ S 2 ∪ S ) → p α ( [ [ Δ ] ] , ( S 1 ∪ S 2 ∪ S ) [ u 1 ∧ u 2 ] ) . ([[ \Delta]], S_1 \cup S_2 \cup S) \xrightarrow[\ p\ ]{\alpha} ([[ \Delta]], (S_1 \cup S_2 \cup S)[u_1 \land u_2]). ([[ Δ ]] , S 1 ∪ S 2 ∪ S ) α p ([[ Δ ]] , ( S 1 ∪ S 2 ∪ S ) [ u 1 ∧ u 2 ]) .
Note S 1 S_1 S 1 and S 2 S_2 S 2 must be of the form
S 1 = { S p ↦ n } S 2 = { S q ↦ m } S_1 = \{S_p \mapsto n\} \qquad S_2 = \{S_q \mapsto m\} S 1 = { S p ↦ n } S 2 = { S q ↦ m }
and hence
( S 1 ∪ S 2 ∪ S ) [ u 1 ∧ u 2 ] = { S p ↦ n ′ , S q ↦ m ′ } ∪ S = S 1 [ u 1 ] ∪ S 2 [ u 2 ] ∪ S = S 1 ′ ∪ S 2 ′ ∪ S , \begin{aligned}
(S_1 \cup S_2 \cup S)[u_1 \land u_2] &= \{S_p \mapsto n', S_q \mapsto m'\} \cup S \\
&= S_1[u_1] \cup S_2[u_2] \cup S \\
&= S'_1 \cup S'_2 \cup S,
\end{aligned} ( S 1 ∪ S 2 ∪ S ) [ u 1 ∧ u 2 ] = { S p ↦ n ′ , S q ↦ m ′ } ∪ S = S 1 [ u 1 ] ∪ S 2 [ u 2 ] ∪ S = S 1 ′ ∪ S 2 ′ ∪ S ,
as required.
Lemma D.12. Let Δ = p : T , q : T ′ , Δ ′ \Delta= p : T, q : T', \Delta' Δ = p : T , q : T ′ , Δ ′ be a context. Further let S 1 S_1 S 1 and S 1 ′ S'_1 S 1 ′ be states of ( ∣ p : T ∣ ) (|p : T|) ( ∣ p : T ∣ ) , S 2 S_2 S 2 and S 2 ′ S'_2 S 2 ′ states of ( ∣ q : T ′ ∣ ) (|q : T'|) ( ∣ q : T ′ ∣ ) , and S S S a state of ( ∣ Δ ′ ∣ ) (|\Delta'|) ( ∣ Δ ′ ∣ ) . If
( [ [ Δ ] ] , S 1 ∪ S 2 ∪ S ) → p α ( [ [ Δ ] ] , S 1 ′ ∪ S 2 ′ ∪ S ) , ([[ \Delta]], S_1 \cup S_2 \cup S) \xrightarrow[\ p\ ]{\alpha} ([[ \Delta]], S'_1 \cup S'_2 \cup S), ([[ Δ ]] , S 1 ∪ S 2 ∪ S ) α p ([[ Δ ]] , S 1 ′ ∪ S 2 ′ ∪ S ) , with α = p : : q : : ℓ \alpha= p :: q :: \ell α = p :: q :: ℓ , then
( ( ∣ p : T ∣ ) , S 1 ) → p α ( ( ∣ p : T ∣ ) , S 1 ′ ) and ( ( ∣ q : T ′ ∣ ) , S 2 ) → 1 α ( ( ∣ q : T ′ ∣ ) , S 2 ′ ) . ((|p : T|), S_1) \xrightarrow[\ p\ ]{\alpha} ((|p : T|), S'_1) \text{ and } ((|q : T'|), S_2) \xrightarrow[\ 1\ ]{\alpha} ((|q : T'|), S'_2). (( ∣ p : T ∣ ) , S 1 ) α p (( ∣ p : T ∣ ) , S 1 ′ ) and (( ∣ q : T ′ ∣ ) , S 2 ) α 1 (( ∣ q : T ′ ∣ ) , S 2 ′ ) .
Proof. We first argue that α \alpha α must appear as an action in both ( ∣ p : T ∣ ) (|p : T|) ( ∣ p : T ∣ ) and ( ∣ q : T ′ ∣ ) (|q : T'|) ( ∣ q : T ′ ∣ ) . Suppose α ∈ actions Δ ( p ) \alpha\in\operatorname{actions}_{\Delta}(p) α ∈ actions Δ ( p ) but α ∉ actions Δ ( q ) \alpha\notin\operatorname{actions}_{\Delta}(q) α ∈ / actions Δ ( q ) . Note
⟦ Δ ⟧ = ( ∣ p : T ∣ ) ∥ ( ∣ q : T ′ ∣ ) ∥ ( Δ ′ ) ∥ closure ( Δ ) , \llbracket\Delta\rrbracket= (|p : T|) \mathbin{\|} (|q : T'|) \mathbin{\|} (\Delta') \mathbin{\|} \operatorname{closure}(\Delta), [ [ Δ ] ] = ( ∣ p : T ∣ ) ∥ ( ∣ q : T ′ ∣ ) ∥ ( Δ ′ ) ∥ closure ( Δ ) ,
and according to Def. 5.4,
closure ( Δ ) ⇝ [ α ] f a l s e → 1 : ( ) , \operatorname{closure}(\Delta) \leadsto[\alpha]\ \mathrm{false} \to1 : (), closure ( Δ ) ⇝ [ α ] false → 1 : ( ) ,
Hence the only commands of ⟦ Δ ⟧ \llbracket\Delta\rrbracket [ [ Δ ] ] with action α \alpha α are of the form
⟦ Δ ⟧ ⇝ [ α ] f a l s e ∧ g → 1 : u , \llbracket\Delta\rrbracket\leadsto[\alpha]\ \mathrm{false} \land g \to1 : u, [ [ Δ ] ] ⇝ [ α ] false ∧ g → 1 : u ,
and since S ⊬ f a l s e ∧ g S \nvdash\mathrm{false} \land g S ⊬ false ∧ g for any state S S S , ⟦ Δ ⟧ ̸ → α \llbracket\Delta\rrbracket\not\xrightarrow{\alpha} [ [ Δ ] ] α , which is a contradiction. The case where α ∉ actions Δ ( p ) \alpha\notin\operatorname{actions}_{\Delta}(p) α ∈ / actions Δ ( p ) and α ∈ actions Δ ( q ) \alpha\in\operatorname{actions}_{\Delta}(q) α ∈ actions Δ ( q ) is identical. Hence α \alpha α appears in both modules, and by the definition of ( ∣ ⋅ ∣ ) (| \cdot|) ( ∣ ⋅ ∣ ) each such command is deterministic:
( ∣ p : T ∣ ) ⇝ [ α ] ( S p = n ′ ) → 1 : ( S p ′ = n ′ ′ ) , (|p : T|) \leadsto[\alpha]\ (S_p = n') \to1 : (S'_p = n''), ( ∣ p : T ∣ ) ⇝ [ α ] ( S p = n ′ ) → 1 : ( S p ′ = n ′′ ) ,
( ∣ q : T ′ ∣ ) ⇝ [ α ] ( S q = m ′ ) → 1 : ( S q ′ = m ′ ′ ) , (|q : T'|) \leadsto[\alpha]\ (S_q = m') \to1 : (S'_q = m''), ( ∣ q : T ′ ∣ ) ⇝ [ α ] ( S q = m ′ ) → 1 : ( S q ′ = m ′′ ) ,
and furthermore by [M-sync] and [S-step],
⟦ Δ ⟧ ⇝ [ α ] ( S p = n ′ ) ∧ ( S q = m ′ ) → 1 : ( S p ′ = n ′ ′ ) ∧ ( S q ′ = m ′ ′ ) , \llbracket\Delta\rrbracket\leadsto[\alpha]\ (S_p = n') \land(S_q = m') \to1 : (S'_p = n'') \land(S'_q = m''), [ [ Δ ] ] ⇝ [ α ] ( S p = n ′ ) ∧ ( S q = m ′ ) → 1 : ( S p ′ = n ′′ ) ∧ ( S q ′ = m ′′ ) ,
S 1 ∪ S 2 ∪ S ⊢ ( S p = n ′ ) ∧ ( S q = m ′ ) , (57) S_1 \cup S_2 \cup S \vdash(S_p = n') \land(S_q = m'), \tag*{(57)} S 1 ∪ S 2 ∪ S ⊢ ( S p = n ′ ) ∧ ( S q = m ′ ) , (57)
S 1 ′ ∪ S 2 ′ ∪ S = ( S 1 ∪ S 2 ∪ S ) [ ( S p ′ = n ′ ′ ) ∧ ( S q ′ = m ′ ′ ) ] . S'_1 \cup S'_2 \cup S = (S_1 \cup S_2 \cup S)[(S'_p = n'') \land(S'_q = m'')]. S 1 ′ ∪ S 2 ′ ∪ S = ( S 1 ∪ S 2 ∪ S ) [( S p ′ = n ′′ ) ∧ ( S q ′ = m ′′ )] .
In particular p = 1 p = 1 p = 1 . Note that states are of the form
S 1 = { S p ↦ n } S 2 = { S q ↦ m } S_1 = \{S_p \mapsto n\} \qquad S_2 = \{S_q \mapsto m\} S 1 = { S p ↦ n } S 2 = { S q ↦ m }
and by (1), in fact n = n ′ n = n' n = n ′ and m = m ′ m = m' m = m ′ . Hence we can apply [S-step] to each of ( ( ∣ p : T ∣ ) , S 1 ) ((|p : T|), S_1) (( ∣ p : T ∣ ) , S 1 ) and ( ( ∣ q : T ′ ∣ ) , S 2 ) ((|q : T'|), S_2) (( ∣ q : T ′ ∣ ) , S 2 ) to arrive at the conclusion. □
Lemma D.13. Let Δ = p 1 : T 1 , ⋯ , p n : T n \Delta= p_1 : T_1, \cdots, p_n : T_n Δ = p 1 : T 1 , ⋯ , p n : T n and Δ ′ = p 1 : T 1 ′ , ⋯ , p n : T n ′ \Delta' = p_1 : T'_1, \cdots, p_n : T'_n Δ ′ = p 1 : T 1 ′ , ⋯ , p n : T n ′ . If ( ( ∣ p i : T i ∣ ) , S i ) ∼ ( ∣ p i : T i ′ ∣ ) ((|p_i : T_i|), S_i) \sim(|p_i : T'_i|) (( ∣ p i : T i ∣ ) , S i ) ∼ ( ∣ p i : T i ′ ∣ ) for all i i i , then ( ⟦ Δ ⟧ , S 1 ∪ ⋯ ∪ S n ) ∼ ⟦ Δ ′ ⟧ (\llbracket\Delta\rrbracket, S_1 \cup\cdots\cup S_n) \sim\llbracket\Delta' \rrbracket ( [ [ Δ ] ] , S 1 ∪ ⋯ ∪ S n ) ∼ [ [ Δ ′ ] ] .
Proof. For each i i i , let R i R_i R i be the bisimulation relation of ( ( ∣ p i : T i ∣ ) , S i ) ∼ ( ∣ p i : T i ′ ∣ ) ((|p_i : T_i|), S_i) \sim(|p_i : T'_i|) (( ∣ p i : T i ∣ ) , S i ) ∼ ( ∣ p i : T i ′ ∣ ) . We construct a binary relation
R = { ( ( T 1 ∪ ⋯ ∪ T n ) , ( T 1 ′ ∪ ⋯ ∪ T n ′ ) ) ∣ ∀ i ⋅ ( T i , T i ′ ) ∈ R i } . R = \{((T_1 \cup\cdots\cup T_n), (T'_1 \cup\cdots\cup T'_n)) \mid\forall i \cdot(T_i,T'_i) \in R_i\}. R = {(( T 1 ∪ ⋯ ∪ T n ) , ( T 1 ′ ∪ ⋯ ∪ T n ′ )) ∣ ∀ i ⋅ ( T i , T i ′ ) ∈ R i } .
where each S i S_i S i is a state for modules with participant p i p_i p i . We will show that R R R is a bisimulation relation for ( ⟦ Δ ⟧ , A ) (\llbracket\Delta\rrbracket, A) ( [ [ Δ ] ] , A ) and ⟦ Δ ′ ⟧ \llbracket\Delta' \rrbracket [ [ Δ ′ ] ] .
Let us take an arbitrary ( T 1 ∪ ⋯ ∪ T n , T 1 ′ ∪ ⋯ ∪ T n ′ ) ∈ R (T_1 \cup\cdots\cup T_n,T'_1 \cup\cdots\cup T'_n) \in R ( T 1 ∪ ⋯ ∪ T n , T 1 ′ ∪ ⋯ ∪ T n ′ ) ∈ R . Taking the shorthand T = T 1 ∪ ⋯ ∪ T n T = T_1 \cup\cdots\cup T_n T = T 1 ∪ ⋯ ∪ T n , now suppose ( ⟦ Δ ⟧ , T ) → α p ( ⟦ Δ ⟧ , T ′ ) (\llbracket\Delta\rrbracket,T) \xrightarrow{\alpha}_p (\llbracket\Delta\rrbracket,T') ( [ [ Δ ] ] , T ) α p ( [ [ Δ ] ] , T ′ ) for some T ′ T' T ′ . For the purposes of this proof, we use the notation
T [ i ↦ U ] = T 1 ∪ ⋯ ∪ T i − 1 ∪ U ∪ T i + 1 ∪ ⋯ ∪ T n T[i \mapsto U] = T_1 \cup\cdots\cup T_{i-1} \cup U \cup T_{i+1} \cup\cdots\cup T_n T [ i ↦ U ] = T 1 ∪ ⋯ ∪ T i − 1 ∪ U ∪ T i + 1 ∪ ⋯ ∪ T n
(i.e. T T T with the i i i -th union being changed to U U U ), and using the obvious generalisation to more mappings (e.g. T [ i ↦ U , j ↦ U ′ ] T[i \mapsto U, j \mapsto U'] T [ i ↦ U , j ↦ U ′ ] ). We now consider the possible cases of α \alpha α . Case α = p i : : τ \alpha= p_i :: \tau α = p i :: τ or α = p i : : p \alpha= p_i :: p α = p i :: p for some i i i . The transitions with these labels in the encoding are the internal steps (summand and commitment steps, respectively) of participant p i p_i p i , which do not synchronise (as participant names are unique, these actions appear only in p i p_i p i ’s module). So exactly one component caused the transition:
( ( ⟦ p i : T i ⟧ , T i ) → α p ( ⟦ p i : T i ⟧ , U i ) ((\llbracket p_i : T_i\rrbracket, T_i) \xrightarrow{\alpha}_{p} (\llbracket p_i : T_i\rrbracket, U_i) (( [ [ p i : T i ] ] , T i ) α p ( [ [ p i : T i ] ] , U i )
and T ′ = T [ i ↦ U i ] T' = T[i \mapsto U_i] T ′ = T [ i ↦ U i ] . Since ( T i , T i ′ ) ∈ R i (T_i,T'_i) \in\mathcal{R}_i ( T i , T i ′ ) ∈ R i , there exists a state U i ′ U'_i U i ′ with
( ⟦ p i : T i ′ ⟧ , T i ′ ) → α p ( ⟦ p i : T i ′ ⟧ , U i ′ ) (\llbracket p_i : T'_i\rrbracket, T'_i) \xrightarrow{\alpha}_{p} (\llbracket p_i : T'_i\rrbracket, U'_i) ( [ [ p i : T i ′ ] ] , T i ′ ) α p ( [ [ p i : T i ′ ] ] , U i ′ )
and ( U i , U i ′ ) ∈ R i (U_i,U'_i) \in\mathcal{R}_i ( U i , U i ′ ) ∈ R i . By Lemma D.10 , we have both
( ⟦ Δ ⟧ , T ) → α p ( ⟦ Δ ⟧ , T [ i ↦ U i ] ) (\llbracket\Delta\rrbracket,T) \xrightarrow{\alpha}_{p} (\llbracket\Delta\rrbracket,T[i \mapsto U_i]) ( [ [ Δ ] ] , T ) α p ( [ [ Δ ] ] , T [ i ↦ U i ])
and
( ⟦ Δ ′ ⟧ , T 1 ′ ∪ ⋯ ∪ T n ′ ) → α p ( ⟦ Δ ′ ⟧ , T ′ [ i ↦ U i ′ ] ) , (\llbracket\Delta'\rrbracket,T'_1 \cup\cdots\cup T'_n) \xrightarrow{\alpha}_{p} (\llbracket\Delta'\rrbracket,T'[i \mapsto U'_i]), ( [ [ Δ ′ ] ] , T 1 ′ ∪ ⋯ ∪ T n ′ ) α p ( [ [ Δ ′ ] ] , T ′ [ i ↦ U i ′ ]) ,
with ( T [ i ↦ U i ] , T ′ [ i ↦ U i ′ ] ) ∈ R (T[i \mapsto U_i],T'[i \mapsto U'_i]) \in\mathcal{R} ( T [ i ↦ U i ] , T ′ [ i ↦ U i ′ ]) ∈ R .
Case α = p i : : p j : : ℓ \alpha= p_i :: p_j :: \ell α = p i :: p j :: ℓ . Firstly, applying Lemma D.12, there must exist states U i U_i U i and U j U_j U j such that
( ⟦ p i : T i ⟧ , T i ) → α p ( ⟦ p i : T i ⟧ , U i ) (\llbracket p_i : T_i\rrbracket,T_i) \xrightarrow{\alpha}_{p} (\llbracket p_i : T_i\rrbracket,U_i) ( [ [ p i : T i ] ] , T i ) α p ( [ [ p i : T i ] ] , U i )
( ⟦ p j : T j ⟧ , T j ) → α 1 ( ⟦ p j : T j ⟧ , U j ) . (\llbracket p_j : T_j\rrbracket,T_j) \xrightarrow{\alpha}_{1} (\llbracket p_j : T_j\rrbracket,U_j). ( [ [ p j : T j ] ] , T j ) α 1 ( [ [ p j : T j ] ] , U j ) .
Since ( T i , T i ′ ) ∈ R i (T_i,T'_i) \in\mathcal{R}_i ( T i , T i ′ ) ∈ R i and similarly ( T j , T j ′ ) ∈ R j (T_j,T'_j) \in\mathcal{R}_j ( T j , T j ′ ) ∈ R j , there must also exist states U i ′ , U j ′ U'_i,U'_j U i ′ , U j ′ such that
( ⟦ p i : T i ′ ⟧ , T i ′ ) → α p ( ⟦ p i : T i ′ ⟧ , U i ′ ) (\llbracket p_i : T'_i\rrbracket,T'_i) \xrightarrow{\alpha}_{p} (\llbracket p_i : T'_i\rrbracket,U'_i) ( [ [ p i : T i ′ ] ] , T i ′ ) α p ( [ [ p i : T i ′ ] ] , U i ′ )
( ⟦ p j : T j ′ ⟧ , T j ′ ) → α 1 ( ⟦ p j : T j ′ ⟧ , U j ′ ) , (\llbracket p_j : T'_j\rrbracket,T'_j) \xrightarrow{\alpha}_{1} (\llbracket p_j : T'_j\rrbracket,U'_j), ( [ [ p j : T j ′ ] ] , T j ′ ) α 1 ( [ [ p j : T j ′ ] ] , U j ′ ) ,
with ( U i , U i ′ ) ∈ R i (U_i,U'_i) \in\mathcal{R}_i ( U i , U i ′ ) ∈ R i and ( U j , U j ′ ) ∈ R j (U_j,U'_j) \in\mathcal{R}_j ( U j , U j ′ ) ∈ R j . Applying Lemma D.11, we have
( ⟦ Δ ⟧ , T 1 ∪ ⋯ ∪ T n ) → α p ( ⟦ Δ ⟧ , T [ i ↦ U i , j ↦ U j ] ) (\llbracket\Delta\rrbracket,T_1 \cup\cdots\cup T_n) \xrightarrow{\alpha}_{p} (\llbracket\Delta\rrbracket,T[i \mapsto U_i,j \mapsto U_j]) ( [ [ Δ ] ] , T 1 ∪ ⋯ ∪ T n ) α p ( [ [ Δ ] ] , T [ i ↦ U i , j ↦ U j ])
( ⟦ Δ ′ ⟧ , T 1 ′ ∪ ⋯ ∪ T n ′ ) → α p ( ⟦ Δ ′ ⟧ , T ′ [ i ↦ U i ′ , j ↦ U j ′ ] ) , (\llbracket\Delta'\rrbracket,T'_1 \cup\cdots\cup T'_n) \xrightarrow{\alpha}_{p} (\llbracket\Delta'\rrbracket,T'[i \mapsto U'_i,j \mapsto U'_j]), ( [ [ Δ ′ ] ] , T 1 ′ ∪ ⋯ ∪ T n ′ ) α p ( [ [ Δ ′ ] ] , T ′ [ i ↦ U i ′ , j ↦ U j ′ ]) ,
with ( T [ i ↦ U i , j ↦ U j ] , T ′ [ i ↦ U i ′ , j ↦ U j ′ ] ) ∈ R (T[i \mapsto U_i,j \mapsto U_j],T'[i \mapsto U'_i,j \mapsto U'_j]) \in\mathcal{R} ( T [ i ↦ U i , j ↦ U j ] , T ′ [ i ↦ U i ′ , j ↦ U j ′ ]) ∈ R as required.
Hence, any transition in ( ⟦ Δ ⟧ , T 1 ∪ ⋯ ∪ T n ) (\llbracket\Delta\rrbracket,T_1 \cup\cdots\cup T_n) ( [ [ Δ ] ] , T 1 ∪ ⋯ ∪ T n ) can be matched with a transition in ( ⟦ Δ ′ ⟧ , T 1 ′ ∪ ⋯ ∪ T n ′ ) (\llbracket\Delta'\rrbracket,T'_1 \cup\cdots\cup T'_n) ( [ [ Δ ′ ] ] , T 1 ′ ∪ ⋯ ∪ T n ′ ) , with the resulting pair of states still in R \mathcal{R} R . The other direction is completely symmetrical. We conclude by observing that ( S 1 ∪ ⋯ ∪ S n , ∅ ) ∈ R (S_1 \cup\cdots\cup S_n,\varnothing) \in\mathcal{R} ( S 1 ∪ ⋯ ∪ S n , ∅ ) ∈ R , so R \mathcal{R} R is indeed a bisimulation relation, and ( ⟦ Δ ⟧ , S 1 ∪ ⋯ ∪ S n ) ∼ ⟦ Δ ′ ⟧ (\llbracket\Delta\rrbracket,S_1 \cup\cdots\cup S_n) \sim\llbracket\Delta'\rrbracket ( [ [ Δ ] ] , S 1 ∪ ⋯ ∪ S n ) ∼ [ [ Δ ′ ] ] . □
Theorem 5.6 (Translation soundness). (Proof in §D.1). Let Δ , Δ ′ \Delta,\Delta' Δ , Δ ′ be contexts.
(1) If Δ → τ n Δ ′ \Delta\xrightarrow{\tau}_{n} \Delta' Δ τ n Δ ′ , then there exists a state S S S such that ⟦ Δ ⟧ → p : : τ 1 ( ⟦ Δ ⟧ , S ) \llbracket\Delta\rrbracket\xrightarrow{p::\tau}_{1} (\llbracket\Delta\rrbracket,S) [ [ Δ ] ] p :: τ 1 ( [ [ Δ ] ] , S ) and ⟦ Δ ′ ⟧ ∼ ( ⟦ Δ ⟧ , S ) \llbracket\Delta'\rrbracket\sim(\llbracket\Delta\rrbracket,S) [ [ Δ ′ ] ] ∼ ( [ [ Δ ] ] , S ) .
(2) If Δ → p p Δ ′ \Delta\xrightarrow{p}_{p} \Delta' Δ p p Δ ′ , then exists a state S S S such that ⟦ Δ ⟧ → p : : p p ( ⟦ Δ ⟧ , S ) \llbracket\Delta\rrbracket\xrightarrow{p::p}_{p} (\llbracket\Delta\rrbracket,S) [ [ Δ ] ] p :: p p ( [ [ Δ ] ] , S ) and ⟦ Δ ′ ⟧ ∼ ( ⟦ Δ ⟧ , S ) \llbracket\Delta'\rrbracket\sim(\llbracket\Delta\rrbracket,S) [ [ Δ ′ ] ] ∼ ( [ [ Δ ] ] , S ) .
(3) If Δ → ( p , q ) ℓ 1 Δ ′ \Delta\xrightarrow{(p,q)\ell}_{1} \Delta' Δ ( p , q ) ℓ 1 Δ ′ , then exists a state S S S such that ⟦ Δ ⟧ → p : : q : : ℓ 1 ( ⟦ Δ ⟧ , S ) \llbracket\Delta\rrbracket\xrightarrow{p::q::\ell}_{1} (\llbracket\Delta\rrbracket,S) [ [ Δ ] ] p :: q :: ℓ 1 ( [ [ Δ ] ] , S ) and ⟦ Δ ′ ⟧ ∼ ( ⟦ Δ ⟧ , S ) \llbracket\Delta'\rrbracket\sim(\llbracket\Delta\rrbracket,S) [ [ Δ ′ ] ] ∼ ( [ [ Δ ] ] , S ) .
Proof. Let Δ = p 1 : T 1 , … , p n : T n \Delta= p_1 : T_1,\ldots,p_n : T_n Δ = p 1 : T 1 , … , p n : T n .
(1) Without loss of generality, we assume p = p 1 p = p_1 p = p 1 , so that Δ ′ = p 1 : T 1 ′ , p 2 : T 2 , … , p n : T n \Delta' = p_1 : T'_1,p_2 : T_2,\ldots,p_n : T_n Δ ′ = p 1 : T 1 ′ , p 2 : T 2 , … , p n : T n with
p 1 : T 1 → p 1 : : τ n p 1 : T 1 ′ . p_1 : T_1 \xrightarrow{p_1::\tau}_{n} p_1 : T'_1. p 1 : T 1 p 1 :: τ n p 1 : T 1 ′ .
Applying Lemma D.8 (1), there exists a state S 1 S_1 S 1 such that
( ⟦ p 1 : T 1 ⟧ ) → p 1 : : τ 1 ( ⟦ p 1 : T 1 ⟧ , S 1 ) ∼ ( ⟦ p 1 : T 1 ′ ⟧ ) . (\llbracket p_1 : T_1\rrbracket) \xrightarrow{p_1::\tau}_{1} (\llbracket p_1 : T_1\rrbracket,S_1) \sim(\llbracket p_1 : T'_1\rrbracket). ( [ [ p 1 : T 1 ] ] ) p 1 :: τ 1 ( [ [ p 1 : T 1 ] ] , S 1 ) ∼ ( [ [ p 1 : T 1 ′ ] ] ) .
By Lemma D.10 , this summand step does not involve the other components and lifts to
⟦ Δ ⟧ → p 1 : : τ 1 ( ⟦ Δ ⟧ , S 1 ) . \llbracket\Delta\rrbracket\xrightarrow{p_1::\tau}_{1} (\llbracket\Delta\rrbracket,S_1). [ [ Δ ] ] p 1 :: τ 1 ( [ [ Δ ] ] , S 1 ) .
Since ( ⟦ p i : T i ⟧ , ∅ ) ∼ ( ⟦ p i : T i ⟧ ) = ( ⟦ p i : T i ′ ⟧ ) (\llbracket p_i : T_i\rrbracket,\varnothing) \sim(\llbracket p_i : T_i\rrbracket) = (\llbracket p_i : T'_i\rrbracket) ( [ [ p i : T i ] ] , ∅ ) ∼ ( [ [ p i : T i ] ] ) = ( [ [ p i : T i ′ ] ] ) trivially for i ≥ 2 i \ge2 i ≥ 2 , we appeal to Lemma D.13 to conclude ( ⟦ Δ ⟧ , S 1 ) ∼ ⟦ Δ ′ ⟧ (\llbracket\Delta\rrbracket,S_1) \sim\llbracket\Delta'\rrbracket ( [ [ Δ ] ] , S 1 ) ∼ [ [ Δ ′ ] ] .
(2) Without loss of generality, we assume p = p 1 p = p_1 p = p 1 , so that Δ ′ = p 1 : T 1 ′ , p 2 : T 2 , … , p n : T n \Delta' = p_1 : T'_1,p_2 : T_2,\ldots,p_n : T_n Δ ′ = p 1 : T 1 ′ , p 2 : T 2 , … , p n : T n with
p 1 : T 1 → p 1 : : p p p 1 : T 1 ′ . p_1 : T_1 \xrightarrow{p_1::p}_{p} p_1 : T'_1. p 1 : T 1 p 1 :: p p p 1 : T 1 ′ .
Applying Lemma D.8 (2), there exists a state S 1 S_1 S 1 such that
( ⟦ p 1 : T 1 ⟧ ) → p 1 : : p p ( ⟦ p 1 : T 1 ⟧ , S 1 ) ∼ ( ⟦ p 1 : T 1 ′ ⟧ ) . (\llbracket p_1 : T_1\rrbracket) \xrightarrow{p_1::p}_{p} (\llbracket p_1 : T_1\rrbracket,S_1) \sim(\llbracket p_1 : T'_1\rrbracket). ( [ [ p 1 : T 1 ] ] ) p 1 :: p p ( [ [ p 1 : T 1 ] ] , S 1 ) ∼ ( [ [ p 1 : T 1 ′ ] ] ) .
By Lemma D.10 , this commitment step does not involve the other components and lifts to
⟦ Δ ⟧ → p p : : p ˙ p ( ⟦ Δ ⟧ , S 1 ) . \llbracket\Delta\rrbracket\xrightarrow[\ p\ ]{p::\dot{p}}_{p} (\llbracket\Delta\rrbracket, S_1). [ [ Δ ] ] p :: p ˙ p p ( [ [ Δ ] ] , S 1 ) .
Since ( ( ∣ p i : T i ∣ ) , ∅ ) ∼ ( ∣ p i : T i ∣ ) = ( ∣ p i : T i ′ ∣ ) ((|p_i:T_i|),\varnothing)\sim(|p_i:T_i|)=(|p_i:T'_i|) (( ∣ p i : T i ∣ ) , ∅ ) ∼ ( ∣ p i : T i ∣ ) = ( ∣ p i : T i ′ ∣ ) trivially for i ≥ 2 i\ge2 i ≥ 2 , we appeal to Lemma D.13 to conclude ( ⟦ Δ ⟧ , S 1 ) ∼ ⟦ Δ ′ ⟧ (\llbracket\Delta\rrbracket,S_1)\sim\llbracket\Delta'\rrbracket ( [ [ Δ ] ] , S 1 ) ∼ [ [ Δ ′ ] ] .
(3) Without loss of generality, we assume p = p 1 p=p_1 p = p 1 and q = p 2 q=p_2 q = p 2 , so that Δ ′ = p 1 : T 1 ′ , p 2 : T 2 ′ , p 3 : T 3 , ⋯ , p n : T n \Delta'=p_1:T'_1,p_2:T'_2,p_3:T_3,\cdots,p_n:T_n Δ ′ = p 1 : T 1 ′ , p 2 : T 2 ′ , p 3 : T 3 , ⋯ , p n : T n , and we have
⟦ Δ ⟧ = ( ∣ p 1 : T 1 ∣ ) ∥ ⋯ ∥ ( ∣ p n : T n ∣ ) ∥ closure ( Δ ) \llbracket\Delta\rrbracket=(|p_1:T_1|)\mathbin\Vert\cdots\mathbin\Vert(|p_n:T_n|)\mathbin\Vert\operatorname{closure}(\Delta) [ [ Δ ] ] = ( ∣ p 1 : T 1 ∣ ) ∥ ⋯ ∥ ( ∣ p n : T n ∣ ) ∥ closure ( Δ )
and
⟦ Δ ′ ⟧ = ( ∣ p 1 : T 1 ′ ∣ ) ∥ ( ∣ p 2 : T 2 ′ ∣ ) ∥ ( ∣ p 3 : T 3 ∣ ) ∥ ⋯ ∥ ( ∣ p n : T n ∣ ) ∥ closure ( Δ ′ ) . \llbracket\Delta'\rrbracket=(|p_1:T'_1|)\mathbin\Vert(|p_2:T'_2|)\mathbin\Vert(|p_3:T_3|)\mathbin\Vert\cdots\mathbin\Vert(|p_n:T_n|)\mathbin\Vert\operatorname{closure}(\Delta'). [ [ Δ ′ ] ] = ( ∣ p 1 : T 1 ′ ∣ ) ∥ ( ∣ p 2 : T 2 ′ ∣ ) ∥ ( ∣ p 3 : T 3 ∣ ) ∥ ⋯ ∥ ( ∣ p n : T n ∣ ) ∥ closure ( Δ ′ ) .
where closure ( Δ ) \operatorname{closure}(\Delta) closure ( Δ ) and closure ( Δ ′ ) \operatorname{closure}(\Delta') closure ( Δ ′ ) are the closure terms introduced in Def. 5.4 .
By [ct-τ \tau τ ], we must have p 1 : T 1 → p 1 : p 2 ! ℓ ⟨ B ⟩ 1 p 1 : T 1 ′ p_1:T_1\xrightarrow[p_1:p_2!\ell\langle B\rangle]{1}p_1:T'_1 p 1 : T 1 1 p 1 : p 2 ! ℓ ⟨ B ⟩ p 1 : T 1 ′ and p 2 : T 2 → p 2 : p 1 ? ℓ ( B ) 1 p 2 : T 2 ′ p_2:T_2\xrightarrow[p_2:p_1?\ell(B)]{1}p_2:T'_2 p 2 : T 2 1 p 2 : p 1 ? ℓ ( B ) p 2 : T 2 ′ . Applying Lemma D.8 (3, 4) to these reductions, there exist states S 1 , S 2 S_1,S_2 S 1 , S 2 such that
( ∣ p 1 : T 1 ∣ ) → p 1 : : p 2 : : ℓ 1 ( ( ∣ p 1 : T 1 ∣ ) , S 1 ) ∼ ( ∣ p 1 : T 1 ′ ∣ ) , (|p_1:T_1|)\xrightarrow[p_1::p_2::\ell]{1}((|p_1:T_1|),S_1)\sim(|p_1:T'_1|), ( ∣ p 1 : T 1 ∣ ) 1 p 1 :: p 2 :: ℓ (( ∣ p 1 : T 1 ∣ ) , S 1 ) ∼ ( ∣ p 1 : T 1 ′ ∣ ) ,
( ∣ p 2 : T 2 ∣ ) → p 1 : : p 2 : : ℓ 1 ( ( ∣ p 2 : T 2 ∣ ) , S 2 ) ∼ ( ∣ p 2 : T 2 ′ ∣ ) . (|p_2:T_2|)\xrightarrow[p_1::p_2::\ell]{1}((|p_2:T_2|),S_2)\sim(|p_2:T'_2|). ( ∣ p 2 : T 2 ∣ ) 1 p 1 :: p 2 :: ℓ (( ∣ p 2 : T 2 ∣ ) , S 2 ) ∼ ( ∣ p 2 : T 2 ′ ∣ ) .
We combine the sender’s and receiver’s synchronising steps through Lemma D.11 to get
⟦ Δ ⟧ → p 1 : p 2 : ℓ 1 ( ⟦ Δ ⟧ , S 1 ∪ S 2 ) . \llbracket\Delta\rrbracket\xrightarrow[p_1:p_2:\ell]{1}(\llbracket\Delta\rrbracket,S_1\cup S_2). [ [ Δ ] ] 1 p 1 : p 2 : ℓ ( [ [ Δ ] ] , S 1 ∪ S 2 ) .
Finally, we appeal to Lemma D.13 to conclude ( ⟦ Δ ⟧ , S 1 ∪ S 2 ) ∼ ⟦ Δ ′ ⟧ (\llbracket\Delta\rrbracket,S_1\cup S_2)\sim\llbracket\Delta'\rrbracket ( [ [ Δ ] ] , S 1 ∪ S 2 ) ∼ [ [ Δ ′ ] ] .
Completeness
We follow the approach for soundness by first considering ( ∣ ⋅ ∣ ) (|\cdot|) ( ∣ ⋅ ∣ ) (Lemma D.14 ) then generalising to ⟦ ⋅ ⟧ \llbracket\cdot\rrbracket [ [ ⋅ ] ] (Theorem 5.7).
Lemma D.14.
For every type T T T and state S S S with
( ∣ p : T ∣ ) → p : : τ 1 ( ( ∣ p : T ∣ ) , S ) , (|p:T|)\xrightarrow[p::\tau]{1}((|p:T|),S), ( ∣ p : T ∣ ) 1 p :: τ (( ∣ p : T ∣ ) , S ) , there exists T ′ T' T ′ such that p : T → τ n p : T ′ p:T\xrightarrow[\tau]{n}p:T' p : T n τ p : T ′ and ( ( ∣ p : T ∣ ) , S ) ∼ ( ∣ p : T ′ ∣ ) ((|p:T|),S)\sim(|p:T'|) (( ∣ p : T ∣ ) , S ) ∼ ( ∣ p : T ′ ∣ ) .
For every type T T T , state S S S and probability p p p with
( ∣ p : T ∣ ) → p : : p p ( ( ∣ p : T ∣ ) , S ) , (|p:T|)\xrightarrow[p::p]{p}((|p:T|),S), ( ∣ p : T ∣ ) p p :: p (( ∣ p : T ∣ ) , S ) , there exists T ′ T' T ′ such that p : T → p p p : T ′ p:T\xrightarrow[p]{p}p:T' p : T p p p : T ′ and ( ( ∣ p : T ∣ ) , S ) ∼ ( ∣ p : T ′ ∣ ) ((|p:T|),S)\sim(|p:T'|) (( ∣ p : T ∣ ) , S ) ∼ ( ∣ p : T ′ ∣ ) .
For every type T T T and state S ′ S' S ′ with
( ∣ p : T ∣ ) → p : : q : : ℓ 1 ( ( ∣ p : T ∣ ) , S ′ ) , (|p:T|)\xrightarrow[p::q::\ell]{1}((|p:T|),S'), ( ∣ p : T ∣ ) 1 p :: q :: ℓ (( ∣ p : T ∣ ) , S ′ ) , there exists T ′ T' T ′ such that p : T → p : q ! ℓ ⟨ B ⟩ 1 p : T ′ p:T\xrightarrow[p:q!\ell\langle B\rangle]{1}p:T' p : T 1 p : q ! ℓ ⟨ B ⟩ p : T ′ and ( ( ∣ p : T ∣ ) , S ′ ) ∼ ( ∣ p : T ′ ∣ ) ((|p:T|),S')\sim(|p:T'|) (( ∣ p : T ∣ ) , S ′ ) ∼ ( ∣ p : T ′ ∣ ) .
For every type T T T and state S ′ S' S ′ with
( ∣ p : T ∣ ) → q : : p : : ℓ 1 ( ( ∣ p : T ∣ ) , S ′ ) , (|p:T|)\xrightarrow[q::p::\ell]{1}((|p:T|),S'), ( ∣ p : T ∣ ) 1 q :: p :: ℓ (( ∣ p : T ∣ ) , S ′ ) , there exists T ′ T' T ′ such that p : T → p : q ? ℓ ( B ) 1 p : T ′ p:T\xrightarrow[p:q?\ell(B)]{1}p:T' p : T 1 p : q ? ℓ ( B ) p : T ′ and ( ( ∣ p : T ∣ ) , S ′ ) ∼ ( ∣ p : T ′ ∣ ) ((|p:T|),S')\sim(|p:T'|) (( ∣ p : T ∣ ) , S ′ ) ∼ ( ∣ p : T ′ ∣ ) .
Proof.
By Proposition D.3 , since ( p : T ) (p : T) ( p : T ) makes a summand step (labelled p : : τ p :: \tau p :: τ ) in the initial state, T T T must be of the form
T = μ t 1 . μ t 2 . ⋯ μ t n . ∑ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ T = \mu t_1.\mu t_2.\cdots\mu t_n.\sum_{i\in I}\bigoplus_{j\in J_i} p_{(i,j)}:q_j!\ell_j\langle B_j\rangle.T'_{(i,j)} T = μ t 1 . μ t 2 . ⋯ μ t n . i ∈ I ∑ j ∈ J i ⨁ p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′
with ∣ I ∣ > 1 |I| > 1 ∣ I ∣ > 1 . We proceed by induction on n n n , the number of μ \mu μ s before the sum (we will call this the μ \mu μ -depth).
Case n = 0 n = 0 n = 0 . Then T = ∑ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ T = \sum_{i\in I}\bigoplus_{j\in J_i} p_{(i,j)}:q_j!\ell_j\langle B_j\rangle.T'_{(i,j)} T = ∑ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ . The summand step corresponds to some summand k ∈ I k \in I k ∈ I , so S = { S p ↦ sel ( k ) } S = \{S_p \mapsto\operatorname{sel}(k)\} S = { S p ↦ sel ( k )} and source p : T ( S ) = ( T k ⊕ , ∅ ) \operatorname{source}_{p:T}(S) = (T_k^\oplus,\varnothing) source p : T ( S ) = ( T k ⊕ , ∅ ) , where T k ⊕ = ⨁ j ∈ J k p ( k , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( k , j ) ′ T_k^\oplus= \bigoplus_{j\in J_k}p_{(k,j)}:q_j!\ell_j\langle B_j\rangle.T'_{(k,j)} T k ⊕ = ⨁ j ∈ J k p ( k , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( k , j ) ′ . By [ct-nd], we have p : T → p : τ n p : T k ⊕ p:T \xrightarrow{p:\tau}_n p:T_k^\oplus p : T p : τ n p : T k ⊕ , and since T k ⊕ T_k^\oplus T k ⊕ is closed, we can apply Lemma D.7 to conclude ( ( p : T ) , S ) ∼ ( p : T k ⊕ ) ((p:T),S)\sim(p:T_k^\oplus) (( p : T ) , S ) ∼ ( p : T k ⊕ ) .
Case n = k + 1 n = k + 1 n = k + 1 . Then T = μ t . T ′ T = \mu t.T' T = μ t . T ′ , where T ′ T' T ′ has a μ \mu μ -depth of k k k . By Lemma D.6 and the definition of ∼ \sim ∼ , there must exist a state S 1 S_1 S 1 such that
( ( p : T ′ { μ t . T ′ / t } ) → p : τ 1 ( ( p : T ′ { μ t . T ′ / t } ) , S 1 ) ∼ ( ( p : T ) , S ) ) . \left(\left(p:T'\{\mu t.T'/t\}\right)\xrightarrow{p:\tau}_1\left(\left(p:T'\{\mu t.T'/t\}\right),S_1\right)\sim((p:T),S)\right). ( ( p : T ′ { μ t . T ′ / t } ) p : τ 1 ( ( p : T ′ { μ t . T ′ / t } ) , S 1 ) ∼ (( p : T ) , S ) ) .
Note p : T ′ { μ t . T ′ / t } p:T'\{\mu t.T'/t\} p : T ′ { μ t . T ′ / t } has a μ \mu μ -depth of k k k , so we can apply the induction hypothesis to obtain a type T ′ ′ T'' T ′′ such that
p : T ′ { μ t . T ′ / t } → p : τ n p : T ′ ′ , ( ( p : T ′ { μ t . T ′ / t } ) , S 1 ) ∼ ( p : T ′ ′ ) . p:T'\{\mu t.T'/t\}\xrightarrow{p:\tau}_n p:T'',\qquad\left(\left(p:T'\{\mu t.T'/t\}\right),S_1\right)\sim(p:T''). p : T ′ { μ t . T ′ / t } p : τ n p : T ′′ , ( ( p : T ′ { μ t . T ′ / t } ) , S 1 ) ∼ ( p : T ′′ ) .
By [ct-rec], p : T = p : μ t . T ′ → p : τ n p : T ′ ′ p:T=p:\mu t.T'\xrightarrow{p:\tau}_n p:T'' p : T = p : μ t . T ′ p : τ n p : T ′′ also, and since ∼ \sim ∼ is transitive, ( ( p : T ) , S ) ∼ ( p : T ′ ′ ) ((p:T),S)\sim(p:T'') (( p : T ) , S ) ∼ ( p : T ′′ ) as required.
By Proposition D.3 , since ( p : T ) (p:T) ( p : T ) makes a commitment step (labelled p : : ℘ p :: \mathord{\wp} p :: ℘ ) in the initial state, T T T must be of the form
T = μ t 1 . μ t 2 . ⋯ μ t n . ⨁ j ∈ J p j : q j ! ℓ j ⟨ B j ⟩ . T j ′ T = \mu t_1.\mu t_2.\cdots\mu t_n.\bigoplus_{j\in J}p_j:q_j!\ell_j\langle B_j\rangle.T'_j T = μ t 1 . μ t 2 . ⋯ μ t n . j ∈ J ⨁ p j : q j ! ℓ j ⟨ B j ⟩ . T j ′
with ∣ J ∣ ≥ 2 |J| \ge2 ∣ J ∣ ≥ 2 . We proceed by induction on the μ \mu μ -depth n n n .
Case n = 0 n = 0 n = 0 . Then T = ⨁ j ∈ J p j : q j ! ℓ j ⟨ B j ⟩ . T j ′ T = \bigoplus_{j\in J}p_j:q_j!\ell_j\langle B_j\rangle.T'_j T = ⨁ j ∈ J p j : q j ! ℓ j ⟨ B j ⟩ . T j ′ . The commitment step corresponds to some branch l ∈ J l\in J l ∈ J , so S = { S p ↦ com ( l ) } S=\{S_p\mapsto\operatorname{com}(l)\} S = { S p ↦ com ( l )} , p = p l p=p_l p = p l and source p : T ( S ) = ( T l ′ , ∅ ) \operatorname{source}_{p:T}(S)=(T'_l,\varnothing) source p : T ( S ) = ( T l ′ , ∅ ) , where T l ′ = ⨁ 1 : q l ! ℓ l ⟨ B l ⟩ . T l ′ T'_l=\bigoplus1:q_l!\ell_l\langle B_l\rangle.T'_l T l ′ = ⨁ 1 : q l ! ℓ l ⟨ B l ⟩ . T l ′ . Since ∣ J ∣ ≥ 2 |J|\ge2 ∣ J ∣ ≥ 2 and the probabilities are positive and sum to 1 1 1 , we have p l ∈ ( 0 ; 1 ) p_l\in(0;1) p l ∈ ( 0 ; 1 ) , so by [ct-prob], p : T → p : p l p p : T l ′ p:T\xrightarrow{p:p_l}_p p:T'_l p : T p : p l p p : T l ′ ; and since T l ′ T'_l T l ′ is closed, we can apply Lemma D.7 to conclude ( ( p : T ) , S ) ∼ ( p : T l ′ ) ((p:T),S)\sim(p:T'_l) (( p : T ) , S ) ∼ ( p : T l ′ ) .
Case n = k + 1 n = k + 1 n = k + 1 . Then T = μ t . T ′ T=\mu t.T' T = μ t . T ′ , where T ′ T' T ′ has a μ \mu μ -depth of k k k . By Lemma D.6 and the definition of ∼ \sim ∼ , there must exist a state S 1 S_1 S 1 such that
( ( p : T ′ { μ t . T ′ / t } ) → p : p p ( ( p : T ′ { μ t . T ′ / t } ) , S 1 ) ∼ ( ( p : T ) , S ) ) . \left(\left(p:T'\{\mu t.T'/t\}\right)\xrightarrow{p:p}_p\left(\left(p:T'\{\mu t.T'/t\}\right),S_1\right)\sim((p:T),S)\right). ( ( p : T ′ { μ t . T ′ / t } ) p : p p ( ( p : T ′ { μ t . T ′ / t } ) , S 1 ) ∼ (( p : T ) , S ) ) .
Note p : T ′ { μ t . T ′ / t } p:T'\{\mu t.T'/t\} p : T ′ { μ t . T ′ / t } has a μ \mu μ -depth of k k k , so we can apply the induction hypothesis to obtain a type T ′ ′ T'' T ′′ such that
p : T ′ { μ t . T ′ / t } → p : p p p : T ′ ′ , ( ( p : T ′ { μ t . T ′ / t } ) , S 1 ) ∼ ( p : T ′ ′ ) . p:T'\{\mu t.T'/t\}\xrightarrow{p:p}_p p:T'',\qquad\left(\left(p:T'\{\mu t.T'/t\}\right),S_1\right)\sim(p:T''). p : T ′ { μ t . T ′ / t } p : p p p : T ′′ , ( ( p : T ′ { μ t . T ′ / t } ) , S 1 ) ∼ ( p : T ′′ ) .
By [ct-rec], p : T = p : μ t . T ′ → p : p p p : T ′ ′ p:T=p:\mu t.T'\xrightarrow{p:p}_p p:T'' p : T = p : μ t . T ′ p : p p p : T ′′ also, and since ∼ \sim ∼ is transitive, ( ( p : T ) , S ) ∼ ( p : T ′ ′ ) ((p:T),S)\sim(p:T'') (( p : T ) , S ) ∼ ( p : T ′′ ) as required.
By Proposition D.3 , since ( p : T ) (p:T) ( p : T ) makes a synchronisation labelled p : : q : : ℓ p :: q :: \ell p :: q :: ℓ (with p p p the sender) in the initial state, T T T must be of the form
T = μ t 1 . μ t 2 . ⋯ μ t n . ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ ′ , T=\mu t_1.\mu t_2.\cdots\mu t_n.\bigoplus1:q!\ell\langle B\rangle.T'', T = μ t 1 . μ t 2 . ⋯ μ t n . ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′′ ,
a committed selection under n n n binders. We proceed by induction on the μ \mu μ -depth $n. Case n = 0 n = 0 n = 0 . Then T = ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ ′ T = \bigoplus1:q!\ell\langle B\rangle.T^{\prime\prime} T = ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′′ . By [ct-out], we have p : T → p : q ! ℓ ⟨ B ⟩ 1 p : T ′ ′ p : T \xrightarrow{p:q!\ell\langle B\rangle}_{1} p : T^{\prime\prime} p : T p : q ! ℓ ⟨ B ⟩ 1 p : T ′′ , and it is sufficient to show that ( ( ∣ p : T ∣ ) , S ′ ) ∼ ( ∣ p : T ′ ′ ∣ ) ((|p : T|), S^{\prime}) \sim(|p : T^{\prime\prime}|) (( ∣ p : T ∣ ) , S ′ ) ∼ ( ∣ p : T ′′ ∣ ) . We consider the two possible cases of T ′ ′ T^{\prime\prime} T ′′ .
(a) If T ′ ′ = e n d T^{\prime\prime} = \mathrm{end} T ′′ = end , then ( ( ∣ p : T ∣ ) , S ′ ) ↛ ((|p : T|), S^{\prime}) \not\to (( ∣ p : T ∣ ) , S ′ ) → and ( ∣ p : e n d ∣ ) ↛ (|p : \mathrm{end}|) \not\to ( ∣ p : end ∣ ) → . Hence ( ( ∣ p : T ∣ ) , S ′ ) ∼ ( ∣ p : T ′ ′ ∣ ) ((|p : T|), S^{\prime}) \sim(|p : T^{\prime\prime}|) (( ∣ p : T ∣ ) , S ′ ) ∼ ( ∣ p : T ′′ ∣ ) as required.
(b) Otherwise, S ′ = { S p ↦ 1 } S^{\prime} = \{S_{p} \mapsto1\} S ′ = { S p ↦ 1 } , and thus source p : T ( S ′ ) = ( T ′ ′ , ∅ ) \operatorname{source}_{p:T}(S^{\prime}) = (T^{\prime\prime}, \varnothing) source p : T ( S ′ ) = ( T ′′ , ∅ ) . Hence, we can apply Lemma D.7 to obtain the desired result.
Case n = k + 1 n = k + 1 n = k + 1 . Then T = μ t . T ′ T = \mu t.T^{\prime} T = μ t . T ′ , where T ′ T^{\prime} T ′ has a μ \mu μ -depth of k k k . By Lemma D.6 and the definition of ∼ \sim ∼ , there must exist a state S 1 S_{1} S 1 such that
( ∣ p : T ′ { μ t . T ′ / t } ∣ ) → p : : q : : ℓ 1 ( ( ∣ p : T ′ { μ t . T ′ / t } ∣ ) , S 1 ) ∼ ( ( ∣ p : T ∣ ) , S ′ ) . \left(|p : T^{\prime}\{\mu t.T^{\prime}/t\}|\right) \xrightarrow{p::q::\ell}_{1} \left(\left(|p : T^{\prime}\{\mu t.T^{\prime}/t\}|\right),S_{1}\right) \sim\left((|p : T|),S^{\prime}\right). ( ∣ p : T ′ { μ t . T ′ / t } ∣ ) p :: q :: ℓ 1 ( ( ∣ p : T ′ { μ t . T ′ / t } ∣ ) , S 1 ) ∼ ( ( ∣ p : T ∣ ) , S ′ ) .
Note p : T ′ { μ t . T ′ / t } p : T^{\prime}\{\mu t.T^{\prime}/t\} p : T ′ { μ t . T ′ / t } has a μ \mu μ -depth of k k k , so we can apply the induction hypothesis to obtain a type T ′ ′ T^{\prime\prime} T ′′ such that
p : T ′ { μ t . T ′ / t } → p : q ! ℓ ⟨ B ⟩ 1 p : T ′ ′ , ( ( ∣ p : T ′ { μ t . T ′ / t } ∣ ) , S 1 ) ∼ ( ∣ p : T ′ ′ ∣ ) . p : T^{\prime}\{\mu t.T^{\prime}/t\} \xrightarrow{p:q!\ell\langle B\rangle}_{1} p : T^{\prime\prime}, \qquad\left(\left(|p : T^{\prime}\{\mu t.T^{\prime}/t\}|\right),S_{1}\right) \sim(|p : T^{\prime\prime}|). p : T ′ { μ t . T ′ / t } p : q ! ℓ ⟨ B ⟩ 1 p : T ′′ , ( ( ∣ p : T ′ { μ t . T ′ / t } ∣ ) , S 1 ) ∼ ( ∣ p : T ′′ ∣ ) .
By [ct-rec], p : T = p : μ t . T ′ → p : q ! ℓ ⟨ B ⟩ 1 p : T ′ ′ p : T = p : \mu t.T^{\prime} \xrightarrow{p:q!\ell\langle B\rangle}_{1} p : T^{\prime\prime} p : T = p : μ t . T ′ p : q ! ℓ ⟨ B ⟩ 1 p : T ′′ also, and since ∼ \sim ∼ is transitive, ( ( ∣ p : T ∣ ) , S ′ ) ∼ ( ∣ p : T ′ ′ ∣ ) ((|p : T|),S^{\prime}) \sim(|p : T^{\prime\prime}|) (( ∣ p : T ∣ ) , S ′ ) ∼ ( ∣ p : T ′′ ∣ ) as required.
(4) Analogous to the above, with branching in place of the committed selection. Here T = μ t 1 ⋯ μ t n . & i ∈ I q i ? ℓ i ( B i ) . T i ′ T = \mu t_{1}\cdots\mu t_{n}. \&_{i\in I}\ q_{i}?\ell_{i}(B_{i}).T^{\prime}_{i} T = μ t 1 ⋯ μ t n . & i ∈ I q i ? ℓ i ( B i ) . T i ′ , and the single q : : p : : ℓ q::p::\ell q :: p :: ℓ transition selects a branch k ∈ I k \in I k ∈ I with q = q k q = q_{k} q = q k and ℓ = ℓ k \ell= \ell_{k} ℓ = ℓ k . By [ct-in], p : T → p : q ? ℓ ( B ) 1 p : T k ′ p : T \xrightarrow{p:q?\ell(B)}_{1} p : T^{\prime}_{k} p : T p : q ? ℓ ( B ) 1 p : T k ′ , and ( ( ∣ p : T ∣ ) , S ′ ) ∼ ( ∣ p : T k ′ ∣ ) ((|p : T|),S^{\prime}) \sim(|p : T^{\prime}_{k}|) (( ∣ p : T ∣ ) , S ′ ) ∼ ( ∣ p : T k ′ ∣ ) follows as in the send case (directly when T k ′ = e n d T^{\prime}_{k} = \mathrm{end} T k ′ = end , otherwise by Lemma D.7 since source p : T ( S ′ ) = ( T k ′ , ∅ ) \operatorname{source}_{p:T}(S^{\prime}) = (T^{\prime}_{k},\varnothing) source p : T ( S ′ ) = ( T k ′ , ∅ ) ). The μ \mu μ -depth induction uses Lemma D.6 exactly as above.
Theorem 5.7 (Translation completeness). (Proof in §D.1). For every context Δ \Delta Δ :
if [ [ Δ ] ] → p : : τ 1 ( [ [ Δ ] ] , S ) [\![\Delta]\!] \xrightarrow{p::\tau}_{1} ([\![\Delta]\!],S) [ [ Δ ] ] p :: τ 1 ([ [ Δ ] ] , S ) , then there exists Δ ′ \Delta^{\prime} Δ ′ such that Δ → p : : τ n Δ ′ \Delta\xrightarrow{p::\tau}_{n} \Delta^{\prime} Δ p :: τ n Δ ′ and ( [ [ Δ ] ] , S ) ∼ [ [ Δ ′ ] ] ([\![\Delta]\!],S) \sim[\![\Delta^{\prime}]\!] ([ [ Δ ] ] , S ) ∼ [ [ Δ ′ ] ] ;
if [ [ Δ ] ] → p : : p p ( [ [ Δ ] ] , S ) [\![\Delta]\!] \xrightarrow{p::p}_{p} ([\![\Delta]\!],S) [ [ Δ ] ] p :: p p ([ [ Δ ] ] , S ) , then there exists Δ ′ \Delta^{\prime} Δ ′ such that Δ → p : : p p Δ ′ \Delta\xrightarrow{p::p}_{p} \Delta^{\prime} Δ p :: p p Δ ′ and ( [ [ Δ ] ] , S ) ∼ [ [ Δ ′ ] ] ([\![\Delta]\!],S) \sim[\![\Delta^{\prime}]\!] ([ [ Δ ] ] , S ) ∼ [ [ Δ ′ ] ] ;
if [ [ Δ ] ] → p : : q : : ℓ 1 ( [ [ Δ ] ] , S ) [\![\Delta]\!] \xrightarrow{p::q::\ell}_{1} ([\![\Delta]\!],S) [ [ Δ ] ] p :: q :: ℓ 1 ([ [ Δ ] ] , S ) , then there exists Δ ′ \Delta^{\prime} Δ ′ such that Δ → ( p , q ) ℓ 1 Δ ′ \Delta\xrightarrow{(p,q)\ell}_{1} \Delta^{\prime} Δ ( p , q ) ℓ 1 Δ ′ and ( [ [ Δ ] ] , S ) ∼ [ [ Δ ′ ] ] ([\![\Delta]\!],S) \sim[\![\Delta^{\prime}]\!] ([ [ Δ ] ] , S ) ∼ [ [ Δ ′ ] ] .
Proof. Let Δ = p 1 : T 1 , … , p n : T n \Delta= p_{1} : T_{1}, \ldots, p_{n} : T_{n} Δ = p 1 : T 1 , … , p n : T n . Then, we have
[ [ Δ ] ] = ( ∣ p 1 : T 1 ∣ ) ∥ … ∥ ( ∣ p n : T n ∣ ) ∥ closure ( Δ ) , [\![\Delta]\!] = (|p_{1} : T_{1}|) \mathbin{\|} \ldots\mathbin{\|} (|p_{n} : T_{n}|) \mathbin{\|} \operatorname{closure}(\Delta), [ [ Δ ] ] = ( ∣ p 1 : T 1 ∣ ) ∥ … ∥ ( ∣ p n : T n ∣ ) ∥ closure ( Δ ) ,
where closure ( Δ ) \operatorname{closure}(\Delta) closure ( Δ ) is the closure term introduced in Def. 5.4. Since internal steps do not synchronise (as participant names are unique) and each internal command labelled p i : : τ p_{i} :: \tau p i :: τ or p i : : p p_{i} :: p p i :: p modifies only the variable S p i S_{p_{i}} S p i of the acting participant, every internal step is made by the single component of its acting participant.
(1) Without loss of generality, we let p = p 1 p = p_{1} p = p 1 . The summand step is labelled p 1 : : τ p_{1} :: \tau p 1 :: τ , and is therefore made by the component ( ∣ p 1 : T 1 ∣ ) (|p_{1} : T_{1}|) ( ∣ p 1 : T 1 ∣ ) :
( ∣ p 1 : T 1 ∣ ) → p 1 : : τ 1 ( ( ∣ p 1 : T 1 ∣ ) , S 1 ) , (|p_{1} : T_{1}|) \xrightarrow{p_{1}::\tau}_{1} ((|p_{1} : T_{1}|),S_{1}), ( ∣ p 1 : T 1 ∣ ) p 1 :: τ 1 (( ∣ p 1 : T 1 ∣ ) , S 1 ) ,
with the other components unchanged, so S = S 1 S = S_{1} S = S 1 . Applying Lemma D.14 (1) to this step, there must exist a type T 1 ′ T_{1}^{\prime} T 1 ′ such that
p 1 : T 1 → p 1 : : τ n p 1 : T 1 ′ , ( ( ∣ p 1 : T 1 ∣ ) , S 1 ) ∼ ( ∣ p 1 : T 1 ′ ∣ ) . p_{1} : T_{1} \xrightarrow{p_{1}::\tau}_{n} p_{1} : T_{1}^{\prime}, \qquad((|p_{1} : T_{1}|),S_{1}) \sim(|p_{1} : T_{1}^{\prime}|). p 1 : T 1 p 1 :: τ n p 1 : T 1 ′ , (( ∣ p 1 : T 1 ∣ ) , S 1 ) ∼ ( ∣ p 1 : T 1 ′ ∣ ) .
Let Δ ′ = p 1 : T 1 ′ , p 2 : T 2 , … , p n : T n \Delta^{\prime} = p_{1} : T_{1}^{\prime}, p_{2} : T_{2}, \ldots, p_{n} : T_{n} Δ ′ = p 1 : T 1 ′ , p 2 : T 2 , … , p n : T n . Then Δ → p 1 : : τ n Δ ′ \Delta\xrightarrow{p_{1}::\tau}_{n} \Delta^{\prime} Δ p 1 :: τ n Δ ′ by [ct-suc], and since ( ( ∣ p i : T i ∣ ) , ∅ ) ∼ ( ∣ p i : T i ∣ ) ((|p_{i} : T_{i}|),\varnothing) \sim(|p_{i} : T_{i}|) (( ∣ p i : T i ∣ ) , ∅ ) ∼ ( ∣ p i : T i ∣ ) trivially for i ≥ 2 i \ge2 i ≥ 2 , we appeal to Lemma D.13 to conclude ( [ [ Δ ] ] , S ) = ( [ [ Δ ] ] , S 1 ) ∼ [ [ Δ ′ ] ] ([\![\Delta]\!],S) = ([\![\Delta]\!],S_{1}) \sim[\![\Delta^{\prime}]\!] ([ [ Δ ] ] , S ) = ([ [ Δ ] ] , S 1 ) ∼ [ [ Δ ′ ] ] , as required. (2) Without loss of generality, we let p = p 1 p = p_1 p = p 1 . The commitment step is labelled p 1 : : p p_1 :: p p 1 :: p , and is therefore made by the component ( ∣ p 1 : T 1 ∣ ) (\lvert p_1 : T_1 \rvert) (∣ p 1 : T 1 ∣) :
( ∣ p 1 : T 1 ∣ ) → p 1 : : p p ( ( ∣ p 1 : T 1 ∣ ) , S 1 ) , (\lvert p_1 : T_1 \rvert) \xrightarrow{p_1::p}_{p} ((\lvert p_1 : T_1 \rvert), S_1), (∣ p 1 : T 1 ∣) p 1 :: p p ((∣ p 1 : T 1 ∣) , S 1 ) ,
with the other components unchanged, so S = S 1 S = S_1 S = S 1 . Applying Lemma D.14 (2) to this step, there must exist a type T 1 ′ T'_1 T 1 ′ such that
p 1 : T 1 → p 1 : p p p 1 : T 1 ′ , ( ( ∣ p 1 : T 1 ∣ ) , S 1 ) ∼ ( ∣ p 1 : T 1 ′ ∣ ) . p_1 : T_1 \xrightarrow{p_1:p}_{p} p_1 : T'_1,\qquad((\lvert p_1 : T_1 \rvert), S_1) \sim(\lvert p_1 : T'_1 \rvert). p 1 : T 1 p 1 : p p p 1 : T 1 ′ , ((∣ p 1 : T 1 ∣) , S 1 ) ∼ (∣ p 1 : T 1 ′ ∣) .
Let Δ ′ = p 1 : T 1 ′ , p 2 : T 2 , ⋯ , p n : T n \Delta' = p_1 : T'_1, p_2 : T_2, \cdots, p_n : T_n Δ ′ = p 1 : T 1 ′ , p 2 : T 2 , ⋯ , p n : T n . Then Δ → p 1 : p p Δ ′ \Delta\xrightarrow{p_1:p}_{p} \Delta' Δ p 1 : p p Δ ′ by [ct-sc], and since ( ( ∣ p i : T i ∣ ) , ∅ ) ∼ ( ∣ p i : T i ∣ ) = ( ∣ p i : T i ′ ∣ ) ((\lvert p_i : T_i \rvert), \varnothing) \sim(\lvert p_i : T_i \rvert) = (\lvert p_i : T'_i \rvert) ((∣ p i : T i ∣) , ∅ ) ∼ (∣ p i : T i ∣) = (∣ p i : T i ′ ∣) trivially for i ≥ 2 i \ge2 i ≥ 2 , we appeal to Lemma D.13 to conclude ( ( ⟦ Δ ⟧ ) , S ) = ( ( ⟦ Δ ⟧ ) , S 1 ) ∼ ⟦ Δ ′ ⟧ ((\llbracket\Delta\rrbracket), S) = ((\llbracket\Delta\rrbracket), S_1) \sim\llbracket\Delta'\rrbracket (( [ [ Δ ] ] ) , S ) = (( [ [ Δ ] ] ) , S 1 ) ∼ [ [ Δ ′ ] ] , as required.
(3) Without loss of generality, we let p = p 1 p = p_1 p = p 1 and q = p 2 q = p_2 q = p 2 . The synchronising step ⟦ Δ ⟧ → p 1 : : p 2 : : ℓ 1 ( ( ⟦ Δ ⟧ ) , S ) \llbracket\Delta\rrbracket\xrightarrow{p_1::p_2::\ell}_{1} ((\llbracket\Delta\rrbracket), S) [ [ Δ ] ] p 1 :: p 2 :: ℓ 1 (( [ [ Δ ] ] ) , S ) decomposes, by Lemma D.12, into
( ∣ p 1 : T 1 ∣ ) → p 1 : : p 2 : : ℓ 1 ( ( ∣ p 1 : T 1 ∣ ) , S 1 ′ ) , ( ∣ p 2 : T 2 ∣ ) → p 1 : : p 2 : : ℓ 1 ( ( ∣ p 2 : T 2 ∣ ) , S 2 ′ ) , (\lvert p_1 : T_1 \rvert) \xrightarrow{p_1::p_2::\ell}_{1} ((\lvert p_1 : T_1 \rvert), S'_1),\qquad
(\lvert p_2 : T_2 \rvert) \xrightarrow{p_1::p_2::\ell}_{1} ((\lvert p_2 : T_2 \rvert), S'_2), (∣ p 1 : T 1 ∣) p 1 :: p 2 :: ℓ 1 ((∣ p 1 : T 1 ∣) , S 1 ′ ) , (∣ p 2 : T 2 ∣) p 1 :: p 2 :: ℓ 1 ((∣ p 2 : T 2 ∣) , S 2 ′ ) ,
where S = S 1 ′ ∪ S 2 ′ S = S'_1 \cup S'_2 S = S 1 ′ ∪ S 2 ′ , with the sender ( ∣ p 1 : T 1 ∣ ) (\lvert p_1 : T_1 \rvert) (∣ p 1 : T 1 ∣) and the receiver ( ∣ p 2 : T 2 ∣ ) (\lvert p_2 : T_2 \rvert) (∣ p 2 : T 2 ∣) each transitioning from their initial states. Applying Lemma D.14 (3) to the sender’s step and (4) to the receiver’s step, there must exist types T 1 ′ T'_1 T 1 ′ and T 2 ′ T'_2 T 2 ′ such that
p 1 : T 1 → p 1 : p 2 ! ℓ ⟨ B ⟩ 1 p 1 : T 1 ′ , p 2 : T 2 → p 2 : p 1 ? ℓ ( B ) 1 p 2 : T 2 ′ , p_1 : T_1 \xrightarrow{p_1:p_2!\ell\langle B\rangle}_{1} p_1 : T'_1,\qquad
p_2 : T_2 \xrightarrow{p_2:p_1?\ell(B)}_{1} p_2 : T'_2, p 1 : T 1 p 1 : p 2 ! ℓ ⟨ B ⟩ 1 p 1 : T 1 ′ , p 2 : T 2 p 2 : p 1 ? ℓ ( B ) 1 p 2 : T 2 ′ ,
( ( ∣ p 1 : T 1 ∣ ) , S 1 ′ ) ∼ ( ∣ p 1 : T 1 ′ ∣ ) , ( ( ∣ p 2 : T 2 ∣ ) , S 2 ′ ) ∼ ( ∣ p 2 : T 2 ′ ∣ ) . ((\lvert p_1 : T_1 \rvert), S'_1) \sim(\lvert p_1 : T'_1 \rvert),\qquad
((\lvert p_2 : T_2 \rvert), S'_2) \sim(\lvert p_2 : T'_2 \rvert). ((∣ p 1 : T 1 ∣) , S 1 ′ ) ∼ (∣ p 1 : T 1 ′ ∣) , ((∣ p 2 : T 2 ∣) , S 2 ′ ) ∼ (∣ p 2 : T 2 ′ ∣) .
Let Δ ′ = p 1 : T 1 ′ , p 2 : T 2 ′ , p 3 : T 3 , ⋯ , p n : T n \Delta' = p_1 : T'_1, p_2 : T'_2, p_3 : T_3, \cdots, p_n : T_n Δ ′ = p 1 : T 1 ′ , p 2 : T 2 ′ , p 3 : T 3 , ⋯ , p n : T n . Then Δ → ( p 1 , p 2 ) ℓ 1 Δ ′ \Delta\xrightarrow{(p_1,p_2)\ell}_{1} \Delta' Δ ( p 1 , p 2 ) ℓ 1 Δ ′ by [ct-τ \tau τ ] and [ct-sc], and by Lemma D.13, we have ( ( ⟦ Δ ⟧ ) , S ) = ( ( ⟦ Δ ⟧ ) , S 1 ′ ∪ S 2 ′ ) ∼ ⟦ Δ ′ ⟧ ((\llbracket\Delta\rrbracket), S) = ((\llbracket\Delta\rrbracket), S'_1 \cup S'_2) \sim\llbracket\Delta'\rrbracket (( [ [ Δ ] ] ) , S ) = (( [ [ Δ ] ] ) , S 1 ′ ∪ S 2 ′ ) ∼ [ [ Δ ′ ] ] , as required.
Lemma D.15. For every command of the form
{ ∣ T ∣ } ( p , n , m , f ) ⇝ [ α ] ( S p = k ) ∧ g → i p i : u i , \{\lvert T\rvert\}_{(p,n,m,f)} \leadsto[\alpha]\ (S_p = k) \land g \to_i p_i : u_i, {∣ T ∣ } ( p , n , m , f ) ⇝ [ α ] ( S p = k ) ∧ g → i p i : u i , we must have n ≤ k < n + S S ( T ) n \le k < n + SS(T) n ≤ k < n + S S ( T ) .
Proof. We proceed by induction of the structure of T T T .
Case T = e n d T = \mathrm{end} T = end or t t t . Then { ∣ T ∣ } ( p , n , m , f ) = ∅ \{\lvert T\rvert\}_{(p,n,m,f)} = \varnothing {∣ T ∣ } ( p , n , m , f ) = ∅ , so the statement is trivial.
Case T = μ t . T ′ T = \mu t.T' T = μ t . T ′ . The commands in { ∣ T ∣ } ( p , n , m , f ) \{\lvert T\rvert\}_{(p,n,m,f)} {∣ T ∣ } ( p , n , m , f ) are exactly the commands in { ∣ T ′ ∣ } ( p , n , m , f ∪ { t ↦ n } ) \{\lvert T'\rvert\}_{(p,n,m,f\cup\{t\mapsto n\})} {∣ T ′ ∣ } ( p , n , m , f ∪ { t ↦ n }) , and S S ( T ) = S S ( T ′ ) SS(T) = SS(T') S S ( T ) = S S ( T ′ ) . Thus, we can apply the induction hypothesis on T ′ T' T ′ .
Case T = ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ T = \bigoplus_{1}:q!\ell\langle B\rangle.T' T = ⨁ 1 : q ! ℓ ⟨ B ⟩ . T ′ . Then we have S S ( T ) = 1 + S S ( T ′ ) SS(T) = 1 + SS(T') S S ( T ) = 1 + S S ( T ′ ) . By the definition of ( ∣ ⋅ ∣ ) (\lvert\cdot\rvert) (∣ ⋅ ∣) , the commands in { ∣ T ∣ } ( p , n , m , f ) \{\lvert T\rvert\}_{(p,n,m,f)} {∣ T ∣ } ( p , n , m , f ) are of the form
{ ∣ T ∣ } ( p , n , m , f ) ⇝ [ p : : q : : ℓ ] S p = n → 1 : u , \{\lvert T\rvert\}_{(p,n,m,f)} \leadsto[p :: q :: \ell]\ S_p = n \to1 : u, {∣ T ∣ } ( p , n , m , f ) ⇝ [ p :: q :: ℓ ] S p = n → 1 : u , along with the commands in { ∣ T ′ ∣ } ( p , n + 1 , m , f ) \{\lvert T'\rvert\}_{(p,n+1,m,f)} {∣ T ′ ∣ } ( p , n + 1 , m , f ) . Obviously n ∈ [ n , n + S S ( T ) ) n \in[n,n+SS(T)) n ∈ [ n , n + S S ( T )) , and by the induction hypothesis, every guard ( S p = k ) (S_p = k) ( S p = k ) in { ∣ T ′ ∣ } ( p , n + 1 , m , f ) \{\lvert T'\rvert\}_{(p,n+1,m,f)} {∣ T ′ ∣ } ( p , n + 1 , m , f ) has
n + 1 ≤ k < n + 1 + S S ( T ′ ) = n + S S ( T ) , n + 1 \le k < n + 1 + SS(T') = n + SS(T), n + 1 ≤ k < n + 1 + S S ( T ′ ) = n + S S ( T ) , and so k ∈ [ n , n + S S ( T ) ) k \in[n,n+SS(T)) k ∈ [ n , n + S S ( T )) as required.
Case T = ⨁ j ∈ J p j : q j ! ℓ j ⟨ B j ⟩ . T j ′ T = \bigoplus_{j \in J} p_j:q_j!\ell_j\langle B_j\rangle.T'_j T = ⨁ j ∈ J p j : q j ! ℓ j ⟨ B j ⟩ . T j ′ with ∣ J ∣ ≥ 2 |J| \ge2 ∣ J ∣ ≥ 2 . Then we have S S ( T ) = 1 + ∑ j ∈ J S S ( T j ′ ) \mathrm{SS}(T) = 1 + \sum_{j \in J}\mathrm{SS}(T'_j) SS ( T ) = 1 + ∑ j ∈ J SS ( T j ′ ) , where T j ′ = ⨁ 1 : q j ! ℓ j ⟨ B j ⟩ . T j ′ T'_j = \bigoplus_{1:q_j!\ell_j\langle B_j\rangle.T'_{j}} T j ′ = ⨁ 1 : q j ! ℓ j ⟨ B j ⟩ . T j ′ }. By the definition of ( ∣ ⋅ ∣ ) (|\cdot|) ( ∣ ⋅ ∣ ) , the commands in { { T } } ( p , n , m , f ) \{\!\{T\}\!\}_{(p,n,m,f)} { { T } } ( p , n , m , f ) are of the form
{ { T } } ( p , n , m , f ) ⇝ [ p : : p ] S p = n → ∑ j ∈ J p j : ( S p ′ = com ( j ) ) , \{\!\{T\}\!\}_{(p,n,m,f)} \leadsto[p :: p]\,S_p = n \to\sum_{j \in J}p_j : (S'_p = \operatorname{com}(j)), { { T } } ( p , n , m , f ) ⇝ [ p :: p ] S p = n → j ∈ J ∑ p j : ( S p ′ = com ( j )) ,
along with the commands in each of { { T j ′ } } ( p , com ( j ) , m , f ) \{\!\{T'_j\}\!\}_{(p,\operatorname{com}(j),m,f)} { { T j ′ } } ( p , com ( j ) , m , f ) , where com ( j ) = n + 1 + ∑ j ′ < j S S ( T j ′ ′ ) \operatorname{com}(j) = n + 1 + \sum_{j'<j}\mathrm{SS}(T'_{j'}) com ( j ) = n + 1 + ∑ j ′ < j SS ( T j ′ ′ ) . Obviously n ∈ [ n , n + S S ( T ) ) n \in[n,n+\mathrm{SS}(T)) n ∈ [ n , n + SS ( T )) . Furthermore, by the induction hypothesis, every guard ( S p = k ) (S_p = k) ( S p = k ) in { { T j ′ } } ( p , com ( j ) , m , f ) \{\!\{T'_j\}\!\}_{(p,\operatorname{com}(j),m,f)} { { T j ′ } } ( p , com ( j ) , m , f ) has
com ( j ) ≤ k < com ( j ) + S S ( T j ′ ) . \operatorname{com}(j) \le k < \operatorname{com}(j) + \mathrm{SS}(T'_j). com ( j ) ≤ k < com ( j ) + SS ( T j ′ ) .
Note com ( j ) ≥ n \operatorname{com}(j) \ge n com ( j ) ≥ n and, since the prefix sum covers all branches j ′ j' j ′ preceding j j j ,
com ( j ) + S S ( T j ′ ) ≤ n + 1 + ∑ j ∈ J S S ( T j ′ ) = n + S S ( T ) , \operatorname{com}(j) + \mathrm{SS}(T'_j) \le n + 1 + \sum_{j \in J}\mathrm{SS}(T'_j) = n + \mathrm{SS}(T), com ( j ) + SS ( T j ′ ) ≤ n + 1 + j ∈ J ∑ SS ( T j ′ ) = n + SS ( T ) ,
and so k ∈ [ n , n + S S ( T ) ) k \in[n,n+\mathrm{SS}(T)) k ∈ [ n , n + SS ( T )) as required.
Case T = ∑ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ T = \sum_{i \in I}\bigoplus_{j \in J_i}p_{(i,j)}:q_j!\ell_j\langle B_j\rangle.T'_{(i,j)} T = ∑ i ∈ I ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ with ∣ I ∣ ≥ 2 |I| \ge2 ∣ I ∣ ≥ 2 . Then we have S S ( T ) = 1 + ∑ i ∈ I S S ( T i ⊕ ) \mathrm{SS}(T) = 1 + \sum_{i \in I}\mathrm{SS}(T_i^\oplus) SS ( T ) = 1 + ∑ i ∈ I SS ( T i ⊕ ) , where T i ⊕ = ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ T_i^\oplus= \bigoplus_{j \in J_i}p_{(i,j)}:q_j!\ell_j\langle B_j\rangle.T'_{(i,j)} T i ⊕ = ⨁ j ∈ J i p ( i , j ) : q j ! ℓ j ⟨ B j ⟩ . T ( i , j ) ′ . By the definition of ( ∣ ⋅ ∣ ) (|\cdot|) ( ∣ ⋅ ∣ ) , the commands in { { T } } ( p , n , m , f ) \{\!\{T\}\!\}_{(p,n,m,f)} { { T } } ( p , n , m , f ) are of the form
{ { T } } ( p , n , m , f ) ⇝ [ p : : τ ] S p = n → 1 : ( S p ′ = sel ( i ) ) , \{\!\{T\}\!\}_{(p,n,m,f)} \leadsto[p :: \tau]\,S_p = n \to1 : (S'_p = \operatorname{sel}(i)), { { T } } ( p , n , m , f ) ⇝ [ p :: τ ] S p = n → 1 : ( S p ′ = sel ( i )) ,
along with the commands in each of { { T i ⊕ } } ( p , sel ( i ) , m , f ) \{\!\{T_i^\oplus\}\!\}_{(p,\operatorname{sel}(i),m,f)} { { T i ⊕ } } ( p , sel ( i ) , m , f ) , where sel ( i ) = n + 1 + ∑ i ′ < i S S ( T i ′ ⊕ ) \operatorname{sel}(i) = n + 1 + \sum_{i'<i}\mathrm{SS}(T_{i'}^\oplus) sel ( i ) = n + 1 + ∑ i ′ < i SS ( T i ′ ⊕ ) . Obviously n ∈ [ n , n + S S ( T ) ) n \in[n,n+\mathrm{SS}(T)) n ∈ [ n , n + SS ( T )) . Furthermore, by the induction hypothesis, every guard ( S p = k ) (S_p = k) ( S p = k ) in { { T i ⊕ } } ( p , sel ( i ) , m , f ) \{\!\{T_i^\oplus\}\!\}_{(p,\operatorname{sel}(i),m,f)} { { T i ⊕ } } ( p , sel ( i ) , m , f ) has
sel ( i ) ≤ k < sel ( i ) + S S ( T i ⊕ ) . \operatorname{sel}(i) \le k < \operatorname{sel}(i) + \mathrm{SS}(T_i^\oplus). sel ( i ) ≤ k < sel ( i ) + SS ( T i ⊕ ) .
Note sel ( i ) ≥ n \operatorname{sel}(i) \ge n sel ( i ) ≥ n and, since the prefix sum covers all summands i ′ i' i ′ preceding i i i ,
sel ( i ) + S S ( T i ⊕ ) ≤ n + 1 + ∑ i ∈ I S S ( T i ⊕ ) = n + S S ( T ) , \operatorname{sel}(i) + \mathrm{SS}(T_i^\oplus) \le n + 1 + \sum_{i \in I}\mathrm{SS}(T_i^\oplus) = n + \mathrm{SS}(T), sel ( i ) + SS ( T i ⊕ ) ≤ n + 1 + i ∈ I ∑ SS ( T i ⊕ ) = n + SS ( T ) ,
and so k ∈ [ n , n + S S ( T ) ) k \in[n,n+\mathrm{SS}(T)) k ∈ [ n , n + SS ( T )) as required.
Case T = & i ∈ I q i ! ℓ i ( B i ) . T i ′ T = \mathbin{\&}_{i \in I}q_i!\ell_i(B_i).T'_i T = & i ∈ I q i ! ℓ i ( B i ) . T i ′ . Then S S ( T ) = 1 + ∑ i ∈ I S S ( T i ′ ) \mathrm{SS}(T) = 1 + \sum_{i \in I}\mathrm{SS}(T'_i) SS ( T ) = 1 + ∑ i ∈ I SS ( T i ′ ) . The new commands have the single guard clause ( S p = n ) ∈ [ n , n + S S ( T ) ) (S_p = n) \in[n,n+\mathrm{SS}(T)) ( S p = n ) ∈ [ n , n + SS ( T )) , and the recursive commands in { { T i ′ } } ( p , next ( i ) , m , f ) \{\!\{T'_i\}\!\}_{(p,\operatorname{next}(i),m,f)} { { T i ′ } } ( p , next ( i ) , m , f ) , with next ( i ) = n + 1 + ∑ i ′ < i S S ( T i ′ ′ ) \operatorname{next}(i) = n + 1 + \sum_{i'<i}\mathrm{SS}(T'_{i'}) next ( i ) = n + 1 + ∑ i ′ < i SS ( T i ′ ′ ) , are bounded into [ n , n + S S ( T ) ) [n,n+\mathrm{SS}(T)) [ n , n + SS ( T )) in exactly the same way as the proper selection case. □
Appendix for Section 6
Computing the Weak Almost-Surely Livelocked Region
Throughout this section we fix Δ \Delta Δ to be the “initial” context, and participant p p p to be the one whose livelock region we are computing. As a refresher, Def. 6.4 places Δ ′ \Delta' Δ ′ in W A S l i v e l o c k p ( Δ ) \mathrm{WASlivelock}_p(\Delta) WASlivelock p ( Δ ) when
∃ ϕ ∈ Φ F Δ ′ : ∀ ξ ∈ Ξ ϕ ( Δ ′ ) : visited ( ξ ) ⊆ P e n d p ( Δ ) \exists\phi\in\Phi_F^{\Delta'} : \forall\xi\in\Xi_\phi(\Delta') : \operatorname{visited}(\xi) \subseteq\mathrm{Pend}_p(\Delta) ∃ ϕ ∈ Φ F Δ ′ : ∀ ξ ∈ Ξ ϕ ( Δ ′ ) : visited ( ξ ) ⊆ Pend p ( Δ )
This section shows how to compute, over the finite { Δ ′ ∣ Δ → ∗ Δ ′ } \{\Delta' \mid\Delta\mathrel{\to^*}\Delta'\} { Δ ′ ∣ Δ → ∗ Δ ′ } , the region W A S l i v e l o c k p ( Δ ) \mathrm{WASlivelock}_p(\Delta) WASlivelock p ( Δ ) .
Before outlining the approach we briefly outline the structure of the MDP we are dealing with, and define the notion of an end-component (shorthand; “EC”) as a tuple ( S , A ) (S,A) ( S , A ) .
Definition E.1 (Scheduler-available Actions). The scheduler-available actions (or just actions ) enabled at a state Δ ′ \Delta' Δ ′ are the transition labels of Figure 4 , with nondeterministic labels paired with their resolution state “Δ n \Delta_n Δ n ” (as these are determined by the scheduler):
Act ( Δ ′ ) : = { ( q , r ) ℓ ∣ Δ ′ → ( q , r ) ℓ 1 } ∪ { ( q : τ : Δ n ) ∣ Δ ′ → q : τ n Δ n } ∪ { q : p ∣ Δ ′ → q : p p k } . \operatorname{Act}(\Delta') := \{(q,r)^\ell\mid\Delta' \xrightarrow{(q,r)^\ell}_1 \} \cup\{(q:\tau:\Delta_n) \mid\Delta' \xrightarrow{q:\tau}_n \Delta_n\} \cup\{q:p \mid\Delta' \xrightarrow{q:p}_{p_k}\}. Act ( Δ ′ ) := {( q , r ) ℓ ∣ Δ ′ ( q , r ) ℓ 1 } ∪ {( q : τ : Δ n ) ∣ Δ ′ q : τ n Δ n } ∪ { q : p ∣ Δ ′ q : p p k } .
Definition E.2 (step function). The function step ( ⋅ , ⋅ ) \operatorname{step}(\cdot,\cdot) step ( ⋅ , ⋅ ) takes a state and a scheduler-available action and returns a function from states to distributions over states:
step ( Δ ′ , ( q : τ : Δ n ) ) ( Δ ′ ′ ) = 1 ⟺ Δ ′ → q : τ n Δ ′ ′ ∧ Δ ′ ′ = Δ n \operatorname{step}(\Delta',(\mathsf{q}:\tau:\Delta_n))(\Delta'') = 1 \Longleftrightarrow\Delta' \xrightarrow{\mathsf{q}:\tau}_{n} \Delta'' \land\Delta'' = \Delta_n step ( Δ ′ , ( q : τ : Δ n )) ( Δ ′′ ) = 1 ⟺ Δ ′ q : τ n Δ ′′ ∧ Δ ′′ = Δ n
step ( Δ ′ , q : p ) ( Δ ′ ′ ) = p ⟺ Δ ′ → q : p p k Δ ′ ′ \operatorname{step}(\Delta',\mathsf{q}:\mathsf{p})(\Delta'') = \mathsf{p} \Longleftrightarrow\Delta' \xrightarrow{\mathsf{q}:\mathsf{p}}_{p_k} \Delta'' step ( Δ ′ , q : p ) ( Δ ′′ ) = p ⟺ Δ ′ q : p p k Δ ′′
step ( Δ ′ , ( q , r ) ℓ ) ( Δ ′ ′ ) = 1 ⟺ Δ ′ → ( q , r ) ℓ 1 Δ ′ ′ \operatorname{step}(\Delta',(\mathsf{q},\mathsf{r})_{\ell})(\Delta'') = 1 \Longleftrightarrow\Delta' \xrightarrow{(\mathsf{q},\mathsf{r})_{\ell}}_{1} \Delta'' step ( Δ ′ , ( q , r ) ℓ ) ( Δ ′′ ) = 1 ⟺ Δ ′ ( q , r ) ℓ 1 Δ ′′
and step ( Δ ′ , α ) ( Δ ′ ′ ) = 0 \operatorname{step}(\Delta',\alpha)(\Delta'') = 0 step ( Δ ′ , α ) ( Δ ′′ ) = 0 otherwise, for α ∈ Act ( Δ ′ ) \alpha\in\operatorname{Act}(\Delta') α ∈ Act ( Δ ′ ) . Each step ( Δ ′ , α ) \operatorname{step}(\Delta',\alpha) step ( Δ ′ , α ) is a probability distribution: both communication and internal nondeterminism reach their target state with probability 1 1 1 , while a probabilistic action may reach a state at p < 1 p < 1 p < 1 .
Thus ( S , Act , step ) (S,\operatorname{Act},\operatorname{step}) ( S , Act , step ) is a finite MDP (where S = { Δ ′ ∣ Δ → ∗ Δ ′ } S = \{\Delta' \mid\Delta\to^{*} \Delta'\} S = { Δ ′ ∣ Δ → ∗ Δ ′ } ), whose schedulers select one enabled action per history, inducing the measures of Def. 4.7 .
Definition E.3 (End components). An end component (EC) of ( S , Act , step ) (S,\operatorname{Act},\operatorname{step}) ( S , Act , step ) is a pair ( S ′ , A ′ ) (S',A') ( S ′ , A ′ ) with the requirements: (1) ∅ ≠ S ′ ⊆ S \varnothing\ne S' \subseteq S ∅ = S ′ ⊆ S and for all Δ ′ ∈ S ′ \Delta' \in S' Δ ′ ∈ S ′ : ∅ ≠ A ′ ( Δ ′ ) ⊆ Act S ′ ( Δ ′ ) \varnothing\ne A'(\Delta') \subseteq\operatorname{Act}_{S'}(\Delta') ∅ = A ′ ( Δ ′ ) ⊆ Act S ′ ( Δ ′ ) where Act S ′ ( Δ ′ ) = { α ∈ Act ( Δ ′ ) ∣ supp ( step ( Δ ′ , α ) ) ⊆ S ′ } \operatorname{Act}_{S'}(\Delta') = \{\alpha\in\operatorname{Act}(\Delta') \mid\operatorname{supp}(\operatorname{step}(\Delta',\alpha)) \subseteq S'\} Act S ′ ( Δ ′ ) = { α ∈ Act ( Δ ′ ) ∣ supp ( step ( Δ ′ , α )) ⊆ S ′ } . (2) The induced graph ( S ′ , A ′ , step ) (S',A',\operatorname{step}) ( S ′ , A ′ , step ) is strongly connected.
Unions of overlapping ECs are ECs, so maximal ECs (MECs) partition S S S .
Using this notion of end-components , we outline the approach in two stages, (all lemmas and the correctness proof Proposition E.7 follow in §E.1.1);
Stage 1: closure
Let S 0 : = Pend p ( Δ ) S^0 := \operatorname{Pend}_{p}(\Delta) S 0 := Pend p ( Δ ) and S i + 1 : = { Δ ′ ∈ S i ∣ Act ( Δ ′ ) = ∅ ∨ ∃ α ∈ Act ( Δ ′ ) : supp ( step ( Δ ′ , α ) ) ⊆ S i } S^{i+1} := \{\Delta' \in S^i \mid\operatorname{Act}(\Delta') = \varnothing\lor\exists\alpha\in\operatorname{Act}(\Delta') : \operatorname{supp}(\operatorname{step}(\Delta',\alpha)) \subseteq S^i\} S i + 1 := { Δ ′ ∈ S i ∣ Act ( Δ ′ ) = ∅ ∨ ∃ α ∈ Act ( Δ ′ ) : supp ( step ( Δ ′ , α )) ⊆ S i } ; write S ∗ S^* S ∗ for the limit of this decreasing sequence and A ∗ ( Δ ′ ) : = { α ∣ supp ( step ( Δ ′ , α ) ) ⊆ S ∗ } A^*(\Delta') := \{\alpha\mid\operatorname{supp}(\operatorname{step}(\Delta',\alpha)) \subseteq S^*\} A ∗ ( Δ ′ ) := { α ∣ supp ( step ( Δ ′ , α )) ⊆ S ∗ } . Thus S ∗ ⊆ Pend p ( Δ ) S^* \subseteq\operatorname{Pend}_{p}(\Delta) S ∗ ⊆ Pend p ( Δ ) is the largest set whose every state is action-less or has an action whose reachable states are fully supported in S ∗ S^* S ∗ .
The result S ∗ S^* S ∗ consists of the union over all end-components ( S i , A i ) (S_i,A_i) ( S i , A i ) whose states are all pending, i.e. ⋃ i ∈ I S i \bigcup_{i\in I} S_i ⋃ i ∈ I S i where S i ⊆ Pend p ( Δ ) S_i \subseteq\operatorname{Pend}_{p}(\Delta) S i ⊆ Pend p ( Δ ) — (an actionless deadlocked state may be considered an EC, e.g. if extended with a self-loop , but in the following we treat them separately), along with any states S ¬ S C C ⊆ Pend p ( Δ ) S_{\neg\mathrm{SCC}} \subseteq\operatorname{Pend}_{p}(\Delta) S ¬ SCC ⊆ Pend p ( Δ ) that can reach ⋃ i ∈ I ( S i , A i ) \bigcup_{i\in I}(S_i,A_i) ⋃ i ∈ I ( S i , A i ) with probability 1 1 1 (but are not strongly-connected), i.e. S ∗ = S ¬ S C C ⊎ ⋃ i ∈ I ( S i , A i ) S^* = S_{\neg\mathrm{SCC}} \uplus\bigcup_{i\in I}(S_i,A_i) S ∗ = S ¬ SCC ⊎ ⋃ i ∈ I ( S i , A i ) .
Remark E.1. We note that excluding any state in the not strongly-connected part S ¬ S C C S_{\neg\mathrm{SCC}} S ¬ SCC from WASlivelock p ( Δ ) \operatorname{WASlivelock}_{p}(\Delta) WASlivelock p ( Δ ) does not change the probability of reaching in WASlivelock p ( Δ ) \operatorname{WASlivelock}_{p}(\Delta) WASlivelock p ( Δ ) , hence it will be excluded from the computed region as PRISM’s reachability will handle it. This will be proved in Lemma E.6. We will call the final computed region (that excludes S ¬ S C C S_{\neg\mathrm{SCC}} S ¬ SCC ) “ECWASlivelock p \operatorname{ECWASlivelock}_{p} ECWASlivelock p ”, and show (Prop. E.7):
max ϕ ∈ Φ Δ p P Δ ϕ ( ⋃ p ∈ dom ( Δ ) ECWASlivelock p ) = max ϕ ∈ Φ Δ P Δ ϕ ( WASlivelock ( Δ ) ) . \max_{\phi\in\Phi_{\Delta}^{p}} \mathbb{P}_{\Delta}^{\phi}\left(\bigcup_{p \in\operatorname{dom}(\Delta)} \operatorname{ECWASlivelock}_{p}\right) = \max_{\phi\in\Phi_{\Delta}} \mathbb{P}_{\Delta}^{\phi}(\operatorname{WASlivelock}(\Delta)). ϕ ∈ Φ Δ p max P Δ ϕ p ∈ dom ( Δ ) ⋃ ECWASlivelock p = ϕ ∈ Φ Δ max P Δ ϕ ( WASlivelock ( Δ )) .
Stage 2: pruning
Let ( S 1 , A 1 ) , … , ( S m , A m ) (S_1,A_1),\ldots,(S_m,A_m) ( S 1 , A 1 ) , … , ( S m , A m ) be the maximal end-components (MECs) of ( S 0 ∗ , A ∗ ∣ S 0 ∗ ) (S_0^*,A^*|_{S_0^*}) ( S 0 ∗ , A ∗ ∣ S 0 ∗ ) where S 0 ∗ : = S ∗ ∖ { Δ ′ ∣ Act ( Δ ′ ) = ∅ } S_0^* := S^* \setminus\{\Delta' \mid\operatorname{Act}(\Delta') = \varnothing\} S 0 ∗ := S ∗ ∖ { Δ ′ ∣ Act ( Δ ′ ) = ∅ } , we then compute ECWASlivelock p Δ \operatorname{ECWASlivelock}_{p}\Delta ECWASlivelock p Δ as
ECWASlivelock p Δ : = ⋃ i ≤ m prune ( S i , A i ) ∪ { Δ ′ ∈ S ∗ ∣ Act ( Δ ′ ) = ∅ } . \operatorname{ECWASlivelock}_{p}\Delta:= \bigcup_{i \le m}\operatorname{prune}(S_i,A_i) \cup\{\Delta' \in S^* \mid\operatorname{Act}(\Delta') = \varnothing\}. ECWASlivelock p Δ := i ≤ m ⋃ prune ( S i , A i ) ∪ { Δ ′ ∈ S ∗ ∣ Act ( Δ ′ ) = ∅ } .
the set of states that lie in Pend p \operatorname{Pend}_{p} Pend p , and which may be closed under fair scheduling (prune ( ⋅ , ⋅ ) \operatorname{prune}(\cdot,\cdot) prune ( ⋅ , ⋅ ) to be introduced soon). Note that deadlocked states bypass the fairness pass and join ECWASlivelock p \operatorname{ECWASlivelock}_{p} ECWASlivelock p directly as any path to a deadlocked state is trivially fair.
The algorithm prune ( ⋅ , ⋅ ) \operatorname{prune}(\cdot,\cdot) prune ( ⋅ , ⋅ ) run on each MEC ( S i , A i ) (S_i,A_i) ( S i , A i ) recursively removes states that can’t be visited infinitely often under a fair scheduler, and either re-decomposes the resulting states into new MECs and runs prune on these, or, returns S i S_i S i if every state of S i S_i S i can be visited infinitely often by a fair scheduler:
prune ( S , A ) : = n d : = ∅ ; p r o b : = ∅ ; c o m m : = ∅ f o r a l l Δ ′ ∈ S , α ∈ Act ( Δ ′ ) : (fairness obligations to discharge) i f α = ( q : τ , ⋅ ) t h e n n d : = n d ∪ { q } (clause 2 of Def. 4.9) i f α = q : p t h e n p r o b : = p r o b ∪ { q } (clause 3) i f α = ( q , r ) ℓ t h e n c o m m : = c o m m ∪ { ( q , r , ℓ ) } (clause 1) f o r a l l Δ ′ ∈ S , α ∈ A ( Δ ′ ) : (obligations dischargeable within the component) i f α = ( q : τ , ⋅ ) t h e n n d : = n d ∖ { q } i f α = q : p t h e n p r o b : = p r o b ∖ { q } i f α = ( q , r ) ℓ t h e n c o m m : = c o m m ∖ { ( q , r , ℓ ) } D : = { Δ ′ ∈ S ∣ ∃ α ∈ Act ( Δ ′ ) : ( α = ( q : τ , _ ) ∧ q ∈ n d ) ∨ ( α = q : p ∧ q ∈ p r o b ) ∨ ( α = ( q , r ) ℓ ∧ α ∈ c o m m ) } i f D = ∅ t h e n r e t u r n S e l s e r e t u r n ⋃ { prune ( S ′ , A ′ ) ∣ ( S ′ , A ′ ) a MEC of ( S ∖ D , A ∣ S ∖ D ) } \begin{aligned}
\operatorname{prune}(S,A)&:=\\
&\quad nd:=\varnothing;\quad prob:=\varnothing;\quad comm:=\varnothing\\
&\quad\mathbf{forall}\ \Delta' \in S,\ \alpha\in\operatorname{Act}(\Delta'):\qquad\text{(fairness obligations to discharge)}\\
&\qquad\mathbf{if}\ \alpha=(q:\tau,\cdot)\ \mathbf{then}\ nd:=nd\cup\{q\}\qquad\text{(clause 2 of Def. 4.9)}\\
&\qquad\mathbf{if}\ \alpha=q:p\ \mathbf{then}\ prob:=prob\cup\{q\}\qquad\text{(clause 3)}\\
&\qquad\mathbf{if}\ \alpha=(q,r)^\ell\ \mathbf{then}\ comm:=comm\cup\{(q,r,\ell)\}\qquad\text{(clause 1)}\\
&\quad\mathbf{forall}\ \Delta' \in S,\ \alpha\in A(\Delta'):\qquad\text{(obligations dischargeable within the component)}\\
&\qquad\mathbf{if}\ \alpha=(q:\tau,\cdot)\ \mathbf{then}\ nd:=nd\setminus\{q\}\\
&\qquad\mathbf{if}\ \alpha=q:p\ \mathbf{then}\ prob:=prob\setminus\{q\}\\
&\qquad\mathbf{if}\ \alpha=(q,r)^\ell\ \mathbf{then}\ comm:=comm\setminus\{(q,r,\ell)\}\\
&D:=\{\Delta'\in S\mid\exists\alpha\in\operatorname{Act}(\Delta'):\ (\alpha=(q:\tau,\_)\land q\in nd)\vee\\
&\qquad\qquad\qquad\qquad\qquad\qquad(\alpha=q:p\land q\in prob)\vee\\
&\qquad\qquad\qquad\qquad\qquad\qquad(\alpha=(q,r)^\ell\land\alpha\in comm)\}\\
&\quad\mathbf{if}\ D=\varnothing\ \mathbf{then\ return}\ S\\
&\quad\mathbf{else\ return}\ \bigcup\{\operatorname{prune}(S',A')\mid(S',A')\text{ a MEC of }(S\setminus D,A|_{S\setminus D})\}
\end{aligned} prune ( S , A ) := n d := ∅ ; p r o b := ∅ ; co mm := ∅ forall Δ ′ ∈ S , α ∈ Act ( Δ ′ ) : (fairness obligations to discharge) if α = ( q : τ , ⋅ ) then n d := n d ∪ { q } (clause 2 of Def. 4.9) if α = q : p then p r o b := p r o b ∪ { q } (clause 3) if α = ( q , r ) ℓ then co mm := co mm ∪ {( q , r , ℓ )} (clause 1) forall Δ ′ ∈ S , α ∈ A ( Δ ′ ) : (obligations dischargeable within the component) if α = ( q : τ , ⋅ ) then n d := n d ∖ { q } if α = q : p then p r o b := p r o b ∖ { q } if α = ( q , r ) ℓ then co mm := co mm ∖ {( q , r , ℓ )} D := { Δ ′ ∈ S ∣ ∃ α ∈ Act ( Δ ′ ) : ( α = ( q : τ , _ ) ∧ q ∈ n d ) ∨ ( α = q : p ∧ q ∈ p r o b ) ∨ ( α = ( q , r ) ℓ ∧ α ∈ co mm )} if D = ∅ then return S else return ⋃ { prune ( S ′ , A ′ ) ∣ ( S ′ , A ′ ) a MEC of ( S ∖ D , A ∣ S ∖ D )}
The first loop records the fairness obligations that the actions { α ∈ Act ( Δ ′ ) ∣ Δ ′ ∈ S } \{\alpha\in\operatorname{Act}(\Delta')\mid\Delta'\in S\} { α ∈ Act ( Δ ′ ) ∣ Δ ′ ∈ S } incur—the second loop then checks that each of these obligations can be discharged by some action in { α ∈ A ( Δ ′ ) ∣ Δ ′ ∈ S } \{\alpha\in A(\Delta')\mid\Delta'\in S\} { α ∈ A ( Δ ′ ) ∣ Δ ′ ∈ S } , pruning state set D D D whose members incur unfulfilled obligations. The resulting states S ∖ D S\setminus D S ∖ D may no longer be a single MEC, so we re-decompose it into MECs and rerun prune on each. Each recursive call strictly shrinks S S S , so prune terminates.
Correctness of the Computation
We use the following standard facts for finite MDPs:
Every EC is contained in a unique MEC [6 Notation 10.124] .
Every EC admits a scheduler that stays inside it on every path and visits every retained (state, action) pair infinitely often almost surely [6 Lemma 10.119 and its proof] .
Under every scheduler, the recurrent (state, action) pairs of almost every infinite path form an EC [6 Theorem 10.120] .
Finally, maximal reachability probabilities are attained by deterministic memoryless schedulers [6 Lemma 10.102] . Actionless states are handled separately; for reachability, they may equivalently be made absorbing.
Definition E.4 (Fair EC). An EC ( S , A ) (S,A) ( S , A ) is fair if there exists an infinite fair path using only actions in A A A and visiting every state of S S S infinitely often, or equivalently; every fairness obligation enabled somewhere in S S S , evaluated using the original Act \operatorname{Act} Act , has a discharging action somewhere in A A A .
Consequently, the recurrent scheduler above is almost surely fair whenever its EC is fair, since every enabled fairness obligation has a discharging action that recurs infinitely often.
Lemma E.5 (PRUNING IS SOUND AND LOSSLESS).
(1) Every EC returned by prune is fair, and
(2) S ⊆ ECWASliveblock p S\subseteq\operatorname{ECWASliveblock}_{p} S ⊆ ECWASliveblock p for every fair EC ( S , A ) (S,A) ( S , A ) of the context MDP with S ⊆ Pend p ( Λ ) S\subseteq\operatorname{Pend}_{p}(\Lambda) S ⊆ Pend p ( Λ ) .
Proof.
(1) prune returns a component only when D = ∅ D=\varnothing D = ∅ , so every obligation it incurs has a discharging action in the component. Hence it is fair. (2) Let ( S ′ , A ′ ) (S', A') ( S ′ , A ′ ) be a fair EC with S ′ ⊆ Pend p ( Δ ) S' \subseteq\operatorname{Pend}_{p}(\Delta) S ′ ⊆ Pend p ( Δ ) . Since every state of S ′ S' S ′ has an action in A ′ A' A ′ supported in S ′ S' S ′ , closure preserves ( S ′ , A ′ ) (S', A') ( S ′ , A ′ ) in ( S ∗ , A ∗ ) (S^*, A^*) ( S ∗ , A ∗ ) . Its states have actions, so it avoids the deadlocked carve-out and is contained in an initial MEC. Suppose a recursive call prune ( S , A ) \operatorname{prune}(S, A) prune ( S , A ) contains ( S ′ , A ′ ) (S', A') ( S ′ , A ′ ) , in both states and actions. If Δ ′ ∈ S ′ ∩ D \Delta' \in S' \cap D Δ ′ ∈ S ′ ∩ D , then Δ ′ \Delta' Δ ′ incurs an obligation with no discharge in A A A , whereas fairness supplies a discharging action in A ′ ( Δ ′ ′ ) ⊆ A ( Δ ′ ′ ) A'(\Delta'') \subseteq A(\Delta'') A ′ ( Δ ′′ ) ⊆ A ( Δ ′′ ) for some Δ ′ ′ ∈ S ′ \Delta'' \in S' Δ ′′ ∈ S ′ , a contradiction. Thus S ′ ∩ D = ∅ S' \cap D = \varnothing S ′ ∩ D = ∅ . All actions of A ′ A' A ′ remain supported in S ′ S' S ′ , so ( S ′ , A ′ ) (S', A') ( S ′ , A ′ ) remains an EC after restriction to S ∖ D S \setminus D S ∖ D . If D = ∅ D = \varnothing D = ∅ , the call returns S ⊇ S ′ S \supseteq S' S ⊇ S ′ . Otherwise, MEC containment places ( S ′ , A ′ ) (S', A') ( S ′ , A ′ ) in a child MEC, and following that child preserves the invariant. Since each nonterminal call strictly decreases S S S while retaining the nonempty set S ′ S' S ′ , this branch eventually returns a component containing S ′ S' S ′ . Hence S ′ ⊆ ECWASlivelock p S' \subseteq\operatorname{ECWASlivelock}_{p} S ′ ⊆ ECWASlivelock p .
Lemma E.6 (Absorption). If T ⊆ U ⊆ { Δ ′ ∣ Δ → ∗ Δ ′ } T \subseteq U \subseteq\{\Delta' \mid\Delta\to^* \Delta'\} T ⊆ U ⊆ { Δ ′ ∣ Δ → ∗ Δ ′ } and max ϕ ∈ Φ Δ ′ P Δ ′ ϕ ( T ) = 1 \max_{\phi\in\Phi_{\Delta'}} \mathbb{P}_{\Delta'}^\phi(T) = 1 max ϕ ∈ Φ Δ ′ P Δ ′ ϕ ( T ) = 1 for every Δ ′ ∈ U \Delta' \in U Δ ′ ∈ U , then max ϕ ∈ Φ Δ P Δ ϕ ( U ) = max ϕ ∈ Φ Δ P Δ ϕ ( T ) \max_{\phi\in\Phi_\Delta} \mathbb{P}_{\Delta}^\phi(U) = \max_{\phi\in\Phi_\Delta} \mathbb{P}_{\Delta}^\phi(T) max ϕ ∈ Φ Δ P Δ ϕ ( U ) = max ϕ ∈ Φ Δ P Δ ϕ ( T ) .
Proof. We apply the argument in the proof of [6 Theorem 10.15] to the Markov chain induced by ϕ \phi ϕ . Since T ⊆ U T \subseteq U T ⊆ U and T T T is reached almost surely after entering U U U , this gives the desired result. □
Proposition E.7 (Correctness of the computation). For every Δ \Delta Δ ,
max ϕ ∈ Φ Δ P Δ ϕ ( ⋃ p ∈ dom ( Δ ) ECWASlivelock p ) = max ϕ ∈ Φ Δ P Δ ϕ ( WASlivelock ( Δ ) ) . \max_{\phi\in\Phi_\Delta} \mathbb{P}_{\Delta}^{\phi}\left(\bigcup_{p \in\operatorname{dom}(\Delta)} \operatorname{ECWASlivelock}_{p}\right) = \max_{\phi\in\Phi_\Delta} \mathbb{P}_{\Delta}^{\phi}(\operatorname{WASlivelock}(\Delta)). ϕ ∈ Φ Δ max P Δ ϕ p ∈ dom ( Δ ) ⋃ ECWASlivelock p = ϕ ∈ Φ Δ max P Δ ϕ ( WASlivelock ( Δ )) .
Proof. By Lemma E.6 with T : = ⋃ p ∈ dom ( Δ ) ECWASlivelock p T := \bigcup_{p \in\operatorname{dom}(\Delta)} \operatorname{ECWASlivelock}_{p} T := ⋃ p ∈ dom ( Δ ) ECWASlivelock p and U : = WASlivelock ( Δ ) U := \operatorname{WASlivelock}(\Delta) U := WASlivelock ( Δ ) , it suffices to show, for every p ∈ dom ( Δ ) p \in\operatorname{dom}(\Delta) p ∈ dom ( Δ ) :
ECWASlivelock p ⊆ WASlivelock p ( Δ ) \operatorname{ECWASlivelock}_{p} \subseteq\operatorname{WASlivelock}_{p}(\Delta) ECWASlivelock p ⊆ WASlivelock p ( Δ )
every Δ ′ ∈ WASlivelock p ( Δ ) \Delta' \in\operatorname{WASlivelock}_{p}(\Delta) Δ ′ ∈ WASlivelock p ( Δ ) admits a scheduler reaching ECWASlivelock p \operatorname{ECWASlivelock}_{p} ECWASlivelock p almost surely.
(1) Every state of ECWASlivelock p \operatorname{ECWASlivelock}_{p} ECWASlivelock p lies in S ∗ ⊆ Pend p ( Δ ) S^* \subseteq\operatorname{Pend}_{p}(\Delta) S ∗ ⊆ Pend p ( Δ ) and is either actionless or belongs to an EC returned by prune \operatorname{prune} prune . An actionless state satisfies Def. 6.4 immediately. Otherwise, by Lemma E.5 (1) the returned EC is fair, and the EC recurrence property provides a fair scheduler whose every path remains in that EC. Thus ECWASlivelock p ⊆ WASlivelock p ( Δ ) \operatorname{ECWASlivelock}_{p} \subseteq\operatorname{WASlivelock}_{p}(\Delta) ECWASlivelock p ⊆ WASlivelock p ( Δ ) .
(2) Let Δ ′ ∈ WASlivelock p ( Δ ) \Delta' \in\operatorname{WASlivelock}_{p}(\Delta) Δ ′ ∈ WASlivelock p ( Δ ) , and take its witnessing scheduler ϕ ∈ Φ Δ ′ \phi\in\Phi_{\Delta'} ϕ ∈ Φ Δ ′ from Def. 6.4 . Every induced path remains in Pend p ( Δ ) \operatorname{Pend}_{p}(\Delta) Pend p ( Δ ) . By the EC limit property and fairness of ϕ \phi ϕ , almost every infinite induced path is fair and has a suffix using only the states and actions of its limit EC ( S lim , A lim ) (S_{\lim}, A_{\lim}) ( S l i m , A l i m ) . This suffix is fair and visits every state of S lim S_{\lim} S l i m infinitely often, so the limit EC is fair. Since S lim ⊆ Pend p ( Δ ) S_{\lim} \subseteq\operatorname{Pend}_{p}(\Delta) S l i m ⊆ Pend p ( Δ ) , Lemma E.5 (2) gives S lim ⊆ ECWASlivelock p S_{\lim} \subseteq\operatorname{ECWASlivelock}_{p} S l i m ⊆ ECWASlivelock p . Every finite complete induced path ends at an actionless pending state, which is included directly. Therefore
P Δ ′ ϕ ( ECWASlivelock p ) = 1. \mathbb{P}_{\Delta'}^{\phi}(\operatorname{ECWASlivelock}_{p}) = 1. P Δ ′ ϕ ( ECWASlivelock p ) = 1.
Since Φ Δ ′ ϕ ⊆ Φ Δ ′ \Phi_{\Delta'}^{\phi} \subseteq\Phi_{\Delta'} Φ Δ ′ ϕ ⊆ Φ Δ ′ , this establishes (ii), and Lemma E.6 yields the claimed equality.
Remark E.2 (Implementation). By Prop. E.7, Thm. 6.5 may be model checked with the label of §E.2 marking ⋃ p ECWASlivelock p \bigcup_{p} \operatorname{ECWASlivelock}_{p} ⋃ p ECWASlivelock p directly. The marked set may be a strict subset of WASlivelock ( Δ ) \operatorname{WASlivelock}(\Delta) WASlivelock ( Δ ) , but the two sets are reached with the same probability, which is all the theorem requires.
Proofs for §6.1
Lemma E.8 (Reachability insensitive to fairness). For any predicate f f f of typing contexts,
max ϕ ∈ Φ Δ A P Δ ϕ ( ◊ f ) = max ϕ ∈ Φ Δ A P Δ ϕ ( ◊ f ) . \max_{\phi\in\Phi_{\Delta}^{A}} \mathbb{P}_{\Delta}^{\phi}(\Diamond f) = \max_{\phi\in\Phi_{\Delta}^{A}} \mathbb{P}_{\Delta}^{\phi}(\Diamond f). ϕ ∈ Φ Δ A max P Δ ϕ ( ◊ f ) = ϕ ∈ Φ Δ A max P Δ ϕ ( ◊ f ) .
Proof. Apply [6 Lemma 10.131] . The cited lemma gives the equality and a fair scheduler attaining the maximum. □
Theorem 6.3. (Proof in §E.2). max ϕ ∈ Φ P Δ ϕ ( ◊ d e a d l o c k ) = max ϕ ∈ Φ Δ P Δ ϕ ( ◊ d e a d l o c k ) \max_{\phi\in\Phi} P_{\Delta}^{\phi}(\Diamond\ \mathrm{deadlock}) = \max_{\phi\in\Phi_{\Delta}} P_{\Delta}^{\phi}(\Diamond\ \mathrm{deadlock}) max ϕ ∈ Φ P Δ ϕ ( ◊ deadlock ) = max ϕ ∈ Φ Δ P Δ ϕ ( ◊ deadlock )
Proof. Apply Lemma E.8 with predicate f = d e a d l o c k f = \mathrm{deadlock} f = deadlock . □
For the arguments below, finite complete paths are extended by stuttering at their final state (self-loops); without introducing any new fairness obligation. We write Fair for the LTL encoding of our fairness conditions.
An enabled internal step persists until the corresponding participant takes it. Thus, together with communication fairness, this makes Fair a limit property (meaning only the set of states visited infinitely often determine its truth value). In the following proofs we will appeal to a few results from [6 ] that relies on limit properties of MDPs.
Lemma E.9 (Non-live path characterisation). For every fair complete path ξ \xi ξ from Δ \Delta Δ ,
¬ l i v e ( ξ ) ⟺ ξ ⊨ ⋁ p ∈ dom ( Δ ) □ ◊ B l k p \neg\mathrm{live}(\xi) \iff\xi\models\bigvee_{p\in\operatorname{dom}(\Delta)} \Box\Diamond\mathrm{Blk}_{p} ¬ live ( ξ ) ⟺ ξ ⊨ p ∈ dom ( Δ ) ⋁ □◊ Blk p
Moreover, for each p ∈ dom ( Δ ) p \in\operatorname{dom}(\Delta) p ∈ dom ( Δ ) : ξ ⊨ □ ◊ B l k p ⟺ ∃ j ≥ 0 : visited ( ξ [ j … ] ) ⊆ Pend p ( Δ ) \xi\models\Box\Diamond\mathrm{Blk}_{p} \iff\exists j \ge0 : \operatorname{visited}(\xi[j\ldots]) \subseteq\operatorname{Pend}_{p}(\Delta) ξ ⊨ □◊ Blk p ⟺ ∃ j ≥ 0 : visited ( ξ [ j … ]) ⊆ Pend p ( Δ ) .
Proof. Suppose that ξ \xi ξ is not live. Some participant p p p has an input or committed output that is never discharged. Since p p p is nonterminated and has no internal step at this input or committed output, B l k p \mathrm{Blk}_{p} Blk p holds forever from that point onwards.
Conversely, if B l k p \mathrm{Blk}_{p} Blk p holds permanently from some point, then p p p remains at a nonterminated input or committed output that is never discharged. Hence ξ \xi ξ is not live.
For the second equivalence, B l k p ( Δ ′ ) \mathrm{Blk}_{p}(\Delta') Blk p ( Δ ′ ) implies Δ ′ ∈ Pend p ( Δ ) \Delta' \in\operatorname{Pend}_{p}(\Delta) Δ ′ ∈ Pend p ( Δ ) directly. Conversely, suppose a fair suffix stays in Pend p ( Δ ) \operatorname{Pend}_{p}(\Delta) Pend p ( Δ ) . The participant p p p cannot communicate on this suffix. Fairness resolves any remaining internal choices: at most a nondeterministic resolution followed by a probabilistic selection. Thereafter, p p p is at an input or committed output and is permanently one-step blocked. □
Theorem 6.5. (Proof in §E.2). P l i v e min ( Δ ) = min ϕ ∈ Φ Δ P Δ ϕ ( l i v e ) = 1 − max ϕ ∈ Φ Δ P Δ ϕ ( ◊ W A S l i v e l o c k ) P_{\mathrm{live}}^{\min}(\Delta) = \min_{\phi\in\Phi_{\Delta}} P_{\Delta}^{\phi}(\mathrm{live}) = 1 - \max_{\phi\in\Phi_{\Delta}} P_{\Delta}^{\phi}(\Diamond\ \mathrm{WASlivelock}) P live m i n ( Δ ) = min ϕ ∈ Φ Δ P Δ ϕ ( live ) = 1 − max ϕ ∈ Φ Δ P Δ ϕ ( ◊ WASlivelock )
Proof. Let
G : = ⋃ p ∈ dom ( Δ ) E C W A S l i v e l o c k p , Ψ : = ( F a i r ⇒ ⋀ p ∈ dom ( Δ ) □ ◊ ¬ B l k p ) . G := \bigcup_{p\in\operatorname{dom}(\Delta)} \mathrm{ECWASlivelock}_{p}, \qquad\Psi:= \left(\mathrm{Fair} \Rightarrow\bigwedge_{p\in\operatorname{dom}(\Delta)} \Box\Diamond\neg\mathrm{Blk}_{p}\right). G := p ∈ dom ( Δ ) ⋃ ECWASlivelock p , Ψ := Fair ⇒ p ∈ dom ( Δ ) ⋀ □◊ ¬ Blk p .
The formula Ψ \Psi Ψ is a limit property.
We first identify its rejecting end components. For any fair EC ( S , A ) (S,A) ( S , A ) and participant p p p ,
S ⊆ Pend p ( Δ ) ⟺ ∀ Δ ′ ∈ S : B l k p ( Δ ′ ) . S \subseteq\operatorname{Pend}_{p}(\Delta) \iff\forall\Delta' \in S : \mathrm{Blk}_{p}(\Delta'). S ⊆ Pend p ( Δ ) ⟺ ∀ Δ ′ ∈ S : Blk p ( Δ ′ ) .
The right-to-left implication follows directly from the definitions. For the converse, take a fair path confined to ( S , A ) (S,A) ( S , A ) that visits every state of S S S infinitely often. Since S ⊆ Pend p ( Δ ) S \subseteq\operatorname{Pend}_{p}(\Delta) S ⊆ Pend p ( Δ ) , Lemma E.9 gives □ ◊ B l k p \Box\Diamond\mathrm{Blk}_{p} □◊ Blk p on this path. Every state of S S S recurs, so every state of S S S must satisfy B l k p \mathrm{Blk}_{p} Blk p .
¬ Ψ ≡ F a i r ∧ ⋁ p ∈ dom ( Δ ) ◊ □ B l k p . \neg\Psi\equiv\mathrm{Fair} \land\bigvee_{p\in\operatorname{dom}(\Delta)} \Diamond\Box\mathrm{Blk}_{p}. ¬Ψ ≡ Fair ∧ p ∈ dom ( Δ ) ⋁ ◊□ Blk p .
Consequently, the nonterminal ECs rejecting Ψ \Psi Ψ are precisely the fair ECs ( S , A ) (S,A) ( S , A ) with S ⊆ Pend p ( Δ ) S \subseteq\operatorname{Pend}_{p}(\Delta) S ⊆ Pend p ( Δ ) for some p ∈ dom ( Δ ) p \in\operatorname{dom}(\Delta) p ∈ dom ( Δ ) . By Lemma E.5 (1–2), the union of their state sets, together with the actionless pending states, is exactly G G G . It follows that
min ϕ ∈ Φ Δ P Δ ϕ ( { ξ ∈ Ξ ϕ ( Δ ) ∣ live ( ξ ) } ) = min ϕ ∈ Φ Δ P Δ ϕ ( Ψ ) = 1 − max ϕ ∈ Φ Δ P Δ ϕ ( G ) = 1 − max ϕ ∈ Φ Δ P Δ ϕ ( WASlivelock ( Δ ) ) . \begin{aligned}
\min_{\phi\in\Phi_{\Delta}} P_{\Delta}^{\phi}(\{\xi\in\Xi_{\phi}(\Delta)\mid\operatorname{live}(\xi)\})=\min_{\phi\in\Phi_{\Delta}}P_{\Delta}^{\phi}(\Psi) \\
&=1-\max_{\phi\in\Phi_{\Delta}}P_{\Delta}^{\phi}(G) \\
&=1-\max_{\phi\in\Phi_{\Delta}}P_{\Delta}^{\phi}(\operatorname{WASlivelock}(\Delta)).
\end{aligned} ϕ ∈ Φ Δ min P Δ ϕ ({ ξ ∈ Ξ ϕ ( Δ ) ∣ live ( ξ )}) = ϕ ∈ Φ Δ min P Δ ϕ ( Ψ ) = 1 − ϕ ∈ Φ Δ max P Δ ϕ ( G ) = 1 − ϕ ∈ Φ Δ max P Δ ϕ ( WASlivelock ( Δ )) .
The first equality follows from Lemma E.9 and [6 Theorem 10.134] ; the second follows from [6 Theorem 10.122(b)] ; and the third is Proposition E.7. The cited results also ensure that the minimum is attained. □
E.2.1 Complexity results. We write ∣ T ∣ |T| ∣ T ∣ for the number of nodes in the syntax tree of T T T , counting each branch as a node, and ∣ Δ ∣ = ∑ p ∈ dom ( Δ ) ∣ Δ ( p ) ∣ |\Delta|=\sum_{p\in\operatorname{dom}(\Delta)}|\Delta(p)| ∣Δ∣ = ∑ p ∈ dom ( Δ ) ∣Δ ( p ) ∣ . Following [6 Notation 10.88] , the size of an MDP is its number of transitions ( s , α , t ) (s,\alpha,t) ( s , α , t ) with positive probability.
Theorem 6.6. Let N N N be the number of reachable states of ⟦ Δ ⟧ \llbracket\Delta\rrbracket [ [ Δ ] ] and R = ∣ { Δ ′ ∣ Δ → ∗ Δ ′ } ∣ R=|\{\Delta'\mid\Delta\to^{*}\Delta'\}| R = ∣ { Δ ′ ∣ Δ → ∗ Δ ′ } ∣ . Then safe ( Δ ) \operatorname{safe}(\Delta) safe ( Δ ) , P d f min ( Δ ) P_{\mathrm{df}}^{\min}(\Delta) P df m i n ( Δ ) and P l i v e min ( Δ ) P_{\mathrm{live}}^{\min}(\Delta) P live m i n ( Δ ) can be computed in time polynomial in N N N , R R R and ∣ Δ ∣ |\Delta| ∣Δ∣ .
Proof. Let M \mathcal{M} M be the MDP of ⟦ Δ ⟧ \llbracket\Delta\rrbracket [ [ Δ ] ] restricted to its reachable states. At each state, each of the at most ∣ Δ ∣ |\Delta| ∣Δ∣ participants enables at most ∣ Δ ∣ |\Delta| ∣Δ∣ actions, each with at most ∣ Δ ∣ |\Delta| ∣Δ∣ successors, so M \mathcal{M} M has size at most N ∣ Δ ∣ 3 N|\Delta|^{3} N ∣Δ ∣ 3 and is built by exploration from the initial state. The context MDP C = ( { Δ ′ ∣ Δ → ∗ Δ ′ } , Act , step ) \mathcal{C}=(\{\Delta'\mid\Delta\to^{*}\Delta'\},\operatorname{Act},\operatorname{step}) C = ({ Δ ′ ∣ Δ → ∗ Δ ′ } , Act , step ) (used in the livelock computation in §E.1) has R R R states and thus size at most R ∣ Δ ∣ 3 R|\Delta|^{3} R ∣Δ ∣ 3 .
Livelock precomputation. We compute ECWAS livelock p \operatorname{ECWAS}_{\operatorname{livelock}}^{p} ECWAS livelock p for each participant p p p . Membership of Pend p ( Δ ) \operatorname{Pend}_{p}(\Delta) Pend p ( Δ ) is a local check at each state, and the closure sequence of Stage 1 stabilises after at most R R R steps. An MEC decomposition takes time O ( R ⋅ ( R + ∣ C ∣ ) ) O(R\cdot(R+|\mathcal{C}|)) O ( R ⋅ ( R + ∣ C ∣ )) [6 Lemma 10.126] . Apart from its recursive calls, each call of prune performs two loops and one MEC decomposition. The children of a call are MECs of S ∖ D S\setminus D S ∖ D with D ≠ ∅ D\ne\varnothing D = ∅ , so they are pairwise disjoint [6 Notation 10.124] and strictly smaller than S S S . Hence there are at most R R R calls at each recursion depth and at most R R R depths. The resulting label “livelock” is a disjunction of at most N N N valuations.
Model checking. Each label is evaluated at every state in time polynomial in N N N and ∣ Δ ∣ |\Delta| ∣Δ∣ . Safety requires P max ( ◊ ¬ ψ ) = 0 P^{\max}(\Diamond\neg\psi)=0 P m a x ( ◊ ¬ ψ ) = 0 for the safety formula ψ \psi ψ , which holds iff no reachable state violates ψ \psi ψ [6 Theorem 10.100] , and is decided by graph search. Deadlock-freedom and liveness are both maximum reachability queries, which are known to be computable in time polynomial in ∣ M ∣ |\mathcal{M}| ∣ M ∣ [6 Corollary 10.107] . □
Corollary 6.7. Let k = ∣ dom ( Δ ) ∣ k=|\operatorname{dom}(\Delta)| k = ∣ dom ( Δ ) ∣ . Then safe ( Δ ) \operatorname{safe}(\Delta) safe ( Δ ) , P d f min ( Δ ) P_{\mathrm{df}}^{\min}(\Delta) P df m i n ( Δ ) and P l i v e min ( Δ ) P_{\mathrm{live}}^{\min}(\Delta) P live m i n ( Δ ) can be computed in time ∣ Δ ∣ O ( k ) |\Delta|^{O(k)} ∣Δ ∣ O ( k ) , i.e. exponential in the number of participants.
Proof. Each S p S_{p} S p ranges over [ 0 , SS ( Δ ( p ) ) ] [0,\operatorname{SS}(\Delta(p))] [ 0 , SS ( Δ ( p ))] , and SS ( T ) ≤ ∣ T ∣ \operatorname{SS}(T)\le|T| SS ( T ) ≤ ∣ T ∣ by induction on T T T . Hence N ≤ ∏ p ∈ dom ( Δ ) ( SS ( Δ ( p ) ) + 1 ) ≤ ( ∣ Δ ∣ + 1 ) k N\le\prod_{p\in\operatorname{dom}(\Delta)}(\operatorname{SS}(\Delta(p))+1)\le(|\Delta|+1)^{k} N ≤ ∏ p ∈ dom ( Δ ) ( SS ( Δ ( p )) + 1 ) ≤ ( ∣Δ∣ + 1 ) k . Moreover, by induction on reduction, every type reachable from Δ \Delta Δ is a continuation, committed selection, summand or μ \mu μ -subterm of Δ ( p ) \Delta(p) Δ ( p ) whose free variables are replaced by their likewise closed μ \mu μ -binders, so p p p has at most ∣ Δ ( p ) ∣ |\Delta(p)| ∣Δ ( p ) ∣ reachable types and, with R R R as in Thm. 6.6, R ≤ ∣ Δ ∣ k R\le|\Delta|^{k} R ≤ ∣Δ ∣ k . Theorem 6.6 then gives time polynomial in ( ∣ Δ ∣ + 1 ) k (|\Delta|+1)^{k} ( ∣Δ∣ + 1 ) k . □
Definitions of PRISM Labels
We first define several functions that tell us the states in which certain transitions are available.
Definition E.10 (Enabled Output Labels).
EOL ( p , q , ℓ , Δ ) = EOL ′ ( p , q , ℓ , Δ ( p ) , 0 ) \operatorname{EOL}(p,q,\ell,\Delta)=\operatorname{EOL}'(p,q,\ell,\Delta(p),0) EOL ( p , q , ℓ , Δ ) = EOL ′ ( p , q , ℓ , Δ ( p ) , 0 )
EOL ′ ( p , q , ℓ , end , n ) = ∅ EOL ′ ( p , q , ℓ , t , n ) = ∅ \operatorname{EOL}'(p,q,\ell,\operatorname{end},n)=\varnothing\qquad\operatorname{EOL}'(p,q,\ell,t,n)=\varnothing EOL ′ ( p , q , ℓ , end , n ) = ∅ EOL ′ ( p , q , ℓ , t , n ) = ∅
EOL ′ ( p , q , ℓ , μ t . T , n ) = EOL ′ ( p , q , ℓ , T , n ) \operatorname{EOL}'(p,q,\ell,\mu t.T,n)=\operatorname{EOL}'(p,q,\ell,T,n) EOL ′ ( p , q , ℓ , μ t . T , n ) = EOL ′ ( p , q , ℓ , T , n )
EOL ′ ( p , q , ℓ , & i ∈ I p i ? ℓ i ( B i ) . T i , n ) = ⋃ i ∈ I EOL ′ ( p , q , ℓ , T i , next ( i ) ) \operatorname{EOL}'(p,q,\ell,\mathbin{\&}_{i\in I}p_i?{\ell_i}(B_i).T_i,n)=\bigcup_{i\in I}\operatorname{EOL}'(p,q,\ell,T_i,\operatorname{next}(i)) EOL ′ ( p , q , ℓ , & i ∈ I p i ? ℓ i ( B i ) . T i , n ) = i ∈ I ⋃ EOL ′ ( p , q , ℓ , T i , next ( i ))
EOL ′ ( p , q , ℓ , ⊕ 1 : q q ′ ! ⟨ B ⟩ . T , n ) = { n ∣ q ′ = q , ℓ ′ = ℓ } ∪ EOL ′ ( p , q , ℓ , T , n + 1 ) \operatorname{EOL}'(p,q,\ell,\mathbin{\oplus}_{1:q}q'!\langle B\rangle.T,n)=\{n\mid q'=q,\ \ell'=\ell\}\cup\operatorname{EOL}'(p,q,\ell,T,n+1) EOL ′ ( p , q , ℓ , ⊕ 1 : q q ′ ! ⟨ B ⟩ . T , n ) = { n ∣ q ′ = q , ℓ ′ = ℓ } ∪ EOL ′ ( p , q , ℓ , T , n + 1 )
EOL ′ ( p , q , ℓ , ⊕ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j , n ) = ⋃ j ∈ J EOL ′ ( p , q , ℓ , T j ′ , com ( j ) ) ( ∣ J ∣ ≥ 2 ) \operatorname{EOL}'(p,q,\ell,\mathbin{\oplus}_{j\in J}p_j:p_j!{\ell_j}\langle B_j\rangle.T_j,n)=\bigcup_{j\in J}\operatorname{EOL}'(p,q,\ell,T_j^{\prime},\operatorname{com}(j))\qquad(|J|\ge2) EOL ′ ( p , q , ℓ , ⊕ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j , n ) = j ∈ J ⋃ EOL ′ ( p , q , ℓ , T j ′ , com ( j )) ( ∣ J ∣ ≥ 2 )
EOL ′ ( p , q , ℓ , ∑ i ∈ I ⊕ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) , n ) = ⋃ i ∈ I EOL ′ ( p , q , ℓ , T i ⊕ , sel ( i ) ) ( ∣ I ∣ ≥ 2 ) \operatorname{EOL}'\left(p,q,\ell,\sum_{i\in I}\mathbin{\oplus}_{j\in J_i}p_{(i,j)}:p_j!{\ell_j}\langle B_j\rangle.T_{(i,j)},n\right)=\bigcup_{i\in I}\operatorname{EOL}'(p,q,\ell,T_i^{\oplus},\operatorname{sel}(i))\qquad(|I|\ge2) EOL ′ ( p , q , ℓ , i ∈ I ∑ ⊕ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) , n ) = i ∈ I ⋃ EOL ′ ( p , q , ℓ , T i ⊕ , sel ( i )) ( ∣ I ∣ ≥ 2 )
Definition E.11 (Enabled Branching).
EB ( p , q , Δ ) = EB ′ ( p , q , Δ ( q ) , 0 ) \operatorname{EB}(p,q,\Delta)=\operatorname{EB}'(p,q,\Delta(q),0) EB ( p , q , Δ ) = EB ′ ( p , q , Δ ( q ) , 0 )
EB ′ ( p , q , end , n ) = ∅ EB ′ ( p , q , t , n ) = ∅ EB ′ ( p , q , μ t . T , n ) = EB ′ ( p , q , T , n ) \operatorname{EB}'(p,q,\operatorname{end},n)=\varnothing\qquad\operatorname{EB}'(p,q,t,n)=\varnothing\qquad\operatorname{EB}'(p,q,\mu t.T,n)=\operatorname{EB}'(p,q,T,n) EB ′ ( p , q , end , n ) = ∅ EB ′ ( p , q , t , n ) = ∅ EB ′ ( p , q , μ t . T , n ) = EB ′ ( p , q , T , n )
EB ′ ( p , q , & i ∈ I p i ? ℓ i ( B i ) . T i , n ) = { { n } ∪ ⋃ i ∈ I EB ′ ( p , q , T i , next ( i ) ) if ∃ i ∈ I : p i = p ⋃ i ∈ I EB ′ ( p , q , T i , next ( i ) ) otherwise \operatorname{EB}'(p,q,\mathbin{\&}_{i\in I}p_i?{\ell_i}(B_i).T_i,n)=
\begin{cases}
\{n\}\cup\bigcup_{i\in I}\operatorname{EB}'(p,q,T_i,\operatorname{next}(i)) & \text{if }\exists i\in I:p_i=p\\
\bigcup_{i\in I}\operatorname{EB}'(p,q,T_i,\operatorname{next}(i)) & \text{otherwise}
\end{cases} EB ′ ( p , q , & i ∈ I p i ? ℓ i ( B i ) . T i , n ) = { { n } ∪ ⋃ i ∈ I EB ′ ( p , q , T i , next ( i )) ⋃ i ∈ I EB ′ ( p , q , T i , next ( i )) if ∃ i ∈ I : p i = p otherwise
EB ′ ( p , q , ⊕ 1 : q q ′ ! ⟨ B ⟩ . T , n ) = EB ′ ( p , q , T , n + 1 ) \operatorname{EB}'(p,q,\mathbin{\oplus}_{1:q}q'!\langle B\rangle.T,n)=\operatorname{EB}'(p,q,T,n+1) EB ′ ( p , q , ⊕ 1 : q q ′ ! ⟨ B ⟩ . T , n ) = EB ′ ( p , q , T , n + 1 )
EB ′ ( p , q , ⊕ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j , n ) = ⋃ j ∈ J EB ′ ( p , q , T j ′ , com ( j ) ) ( ∣ J ∣ ≥ 2 ) \operatorname{EB}'(p,q,\mathbin{\oplus}_{j\in J}p_j:p_j!{\ell_j}\langle B_j\rangle.T_j,n)=\bigcup_{j\in J}\operatorname{EB}'(p,q,T_j^{\prime},\operatorname{com}(j))\qquad(|J|\ge2) EB ′ ( p , q , ⊕ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j , n ) = j ∈ J ⋃ EB ′ ( p , q , T j ′ , com ( j )) ( ∣ J ∣ ≥ 2 )
EB ′ ( p , q , ∑ i ∈ I ⊕ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) , n ) = ⋃ i ∈ I EB ′ ( p , q , T i ⊕ , sel ( i ) ) ( ∣ I ∣ ≥ 2 ) \operatorname{EB}'\left(p,q,\sum_{i\in I}\mathbin{\oplus}_{j\in J_i}p_{(i,j)}:p_j!{\ell_j}\langle B_j\rangle.T_{(i,j)},n\right)=\bigcup_{i\in I}\operatorname{EB}'(p,q,T_i^{\oplus},\operatorname{sel}(i))\qquad(|I|\ge2) EB ′ ( p , q , i ∈ I ∑ ⊕ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) , n ) = i ∈ I ⋃ EB ′ ( p , q , T i ⊕ , sel ( i )) ( ∣ I ∣ ≥ 2 )
Definition E.12 (Enabled Branching Labels).
EBL ( p , q , ℓ , Δ ) = EBL ′ ( p , q , ℓ , Δ ( q ) , 0 ) \operatorname{EBL}(p,q,\ell,\Delta)=\operatorname{EBL}'(p,q,\ell,\Delta(q),0) EBL ( p , q , ℓ , Δ ) = EBL ′ ( p , q , ℓ , Δ ( q ) , 0 )
EBL ′ ( p , q , ℓ , end , n ) = ∅ EBL ′ ( p , q , ℓ , t , n ) = ∅ \operatorname{EBL}'(p,q,\ell,\operatorname{end},n)=\varnothing\qquad\operatorname{EBL}'(p,q,\ell,t,n)=\varnothing EBL ′ ( p , q , ℓ , end , n ) = ∅ EBL ′ ( p , q , ℓ , t , n ) = ∅
EBL ′ ( p , q , ℓ , μ t . T , n ) = EBL ′ ( p , q , ℓ , T , n ) \operatorname{EBL}'(p,q,\ell,\mu t.T,n)=\operatorname{EBL}'(p,q,\ell,T,n) EBL ′ ( p , q , ℓ , μ t . T , n ) = EBL ′ ( p , q , ℓ , T , n )
EBL ′ ( p , q , ℓ , & i ∈ I p i ? ℓ i ( B i ) . T i , n ) = { { n } ∪ ⋃ i ∈ I EBL ′ ( p , q , ℓ , T i , next ( i ) ) if ∃ i : p i = p ∧ ℓ i = ℓ ⋃ i ∈ I EBL ′ ( p , q , ℓ , T i , next ( i ) ) otherwise \operatorname{EBL}'(p,q,\ell,\mathbin{\&}_{i\in I}p_i?{\ell_i}(B_i).T_i,n)=
\begin{cases}
\{n\}\cup\bigcup_{i\in I}\operatorname{EBL}'(p,q,\ell,T_i,\operatorname{next}(i)) & \text{if }\exists i:p_i=p\land\ell_i=\ell\\
\bigcup_{i\in I}\operatorname{EBL}'(p,q,\ell,T_i,\operatorname{next}(i)) & \text{otherwise}
\end{cases} EBL ′ ( p , q , ℓ , & i ∈ I p i ? ℓ i ( B i ) . T i , n ) = { { n } ∪ ⋃ i ∈ I EBL ′ ( p , q , ℓ , T i , next ( i )) ⋃ i ∈ I EBL ′ ( p , q , ℓ , T i , next ( i )) if ∃ i : p i = p ∧ ℓ i = ℓ otherwise
EBL ′ ( p , q , ℓ , ⊕ 1 : q q ′ ! ⟨ B ⟩ . T , n ) = EBL ′ ( p , q , ℓ , T , n + 1 ) \operatorname{EBL}'(p,q,\ell,\mathbin{\oplus}_{1:q}q'!\langle B\rangle.T,n)=\operatorname{EBL}'(p,q,\ell,T,n+1) EBL ′ ( p , q , ℓ , ⊕ 1 : q q ′ ! ⟨ B ⟩ . T , n ) = EBL ′ ( p , q , ℓ , T , n + 1 )
EBL ′ ( p , q , ℓ , ⊕ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j , n ) = ⋃ j ∈ J EBL ′ ( p , q , ℓ , T j ′ , com ( j ) ) ( ∣ J ∣ ≥ 2 ) \operatorname{EBL}'(p,q,\ell,\mathbin{\oplus}_{j\in J}p_j:p_j!{\ell_j}\langle B_j\rangle.T_j,n)=\bigcup_{j\in J}\operatorname{EBL}'(p,q,\ell,T_j^{\prime},\operatorname{com}(j))\qquad(|J|\ge2) EBL ′ ( p , q , ℓ , ⊕ j ∈ J p j : p j ! ℓ j ⟨ B j ⟩ . T j , n ) = j ∈ J ⋃ EBL ′ ( p , q , ℓ , T j ′ , com ( j )) ( ∣ J ∣ ≥ 2 )
EBL ′ ( p , q , ℓ , ∑ i ∈ I ⊕ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) , n ) = ⋃ i ∈ I EBL ′ ( p , q , ℓ , T i ⊕ , sel ( i ) ) ( ∣ I ∣ ≥ 2 ) \operatorname{EBL}'\left(p,q,\ell,\sum_{i\in I}\mathbin{\oplus}_{j\in J_i}p_{(i,j)}:p_j!{\ell_j}\langle B_j\rangle.T_{(i,j)},n\right)=\bigcup_{i\in I}\operatorname{EBL}'(p,q,\ell,T_i^{\oplus},\operatorname{sel}(i))\qquad(|I|\ge2) EBL ′ ( p , q , ℓ , i ∈ I ∑ ⊕ j ∈ J i p ( i , j ) : p j ! ℓ j ⟨ B j ⟩ . T ( i , j ) , n ) = i ∈ I ⋃ EBL ′ ( p , q , ℓ , T i ⊕ , sel ( i )) ( ∣ I ∣ ≥ 2 )
Given these functions, we define the following labels, adopting the convention that an empty disjunction is false:
label “ e n d ” = ⋀ p ∈ dom ( Δ ) ( S p = SS ( Δ ( p ) ) ) \operatorname{label}\ “\mathit{end}”=\bigwedge_{p\in\operatorname{dom}(\Delta)}(S_p=\operatorname{SS}(\Delta(p))) label “ end ” = p ∈ dom ( Δ ) ⋀ ( S p = SS ( Δ ( p )))
∀ p , q ∈ dom ( Δ ) : label “ r e c e i v e : : p : : q ” = ⋁ n ∈ EB ( p , q , Δ ) ( S q = n ) \forall p,q\in\operatorname{dom}(\Delta):\operatorname{label}\ “\mathit{receive::p::q}”=\bigvee_{n\in\operatorname{EB}(p,q,\Delta)}(S_q=n) ∀ p , q ∈ dom ( Δ ) : label “ receive :: p :: q ” = n ∈ EB ( p , q , Δ ) ⋁ ( S q = n )
∀ p : : q : : ℓ ∈ actions ( Δ ) : label “ r e c e i v e : : p : : q : : ℓ ” = ⋁ n ∈ EBL ( p , q , ℓ , Δ ) ( S q = n ) \forall p::q::\ell\in\operatorname{actions}(\Delta):\operatorname{label}\ “\mathit{receive::p::q::\ell}”=\bigvee_{n\in\operatorname{EBL}(p,q,\ell,\Delta)}(S_q=n) ∀ p :: q :: ℓ ∈ actions ( Δ ) : label “ receive :: p :: q :: ℓ ” = n ∈ EBL ( p , q , ℓ , Δ ) ⋁ ( S q = n )
label “ s e n d : : p : : q : : ℓ ” = ⋁ n ∈ EOL ( p , q , ℓ , Δ ) ( S p = n ) \operatorname{label}\ “\mathit{send::p::q::\ell}”=\bigvee_{n\in\operatorname{EOL}(p,q,\ell,\Delta)}(S_p=n) label “ send :: p :: q :: ℓ ” = n ∈ EOL ( p , q , ℓ , Δ ) ⋁ ( S p = n )
By definition, these meet the specification given in Def. 6.2.
Typing Contexts Used for Benchmarking
auth.promt
s = (
b ? connect . flip 0.6 (
c ! login . a ? authorise . end
,
c ! cancel . e ! stop . end
)
+ b ? err . (mu t .
b ? retry . t
)
)
c = (
s ? login . a ! pass . end
+ s ? cancel . a ! quit . end
)
a = (
c ? pass . s ! authorise . end
+ c ? quit . end
)
b = flip 0.6 (
s ! connect . end
,
s ! err . (mu t .
s ! retry . t
)
)
dice.promt
(* Knuth-Yao dice protocol *)
p0 = flip 0.5 (
q0 ! l1 . end
,
q0 ! l2 . end
)
q0 = (
p0 ? l1 . (mu t .
p1 ! go . q3 ? redo . t
)
+ p0 ? l2 . (mu t .
p2 ! go . q6 ? redo . t
)
)
p1 = (mu t .
q0 ? go . flip 0.5 (
, q1 ! l3 . t
,
q1 ! l4 . t
)
)
q1 = (mu t .
(
p1 ? l3 . p3 ! go . t
+ p1 ? l4 . p4 ! go . t
)
)
p2 = (mu t .
q0 ? go . flip 0.5 (
q2 ! l5 . t
,
q2 ! l6 . t
)
)
q2 = (mu t .
(
p2 ? l5 . p5 ! go . t
+ p2 ? l6 . p6 ! go . t
)
)
p3 = (mu t .
q1 ? go . flip 0.5 (
q3 ! l1 . t
,
q3 ! d1 . end
)
)
q3 = (mu t .
(
p3 ? l1 . q0 ! redo . t
+ p3 ? d1 . dice1 ! done . end
)
)
p4 = q1 ? go . flip 0.5 (
q4 ! d2 . end
,
q4 ! d3 . end
)
q4 = (
p4 ? d2 . dice2 ! done . end
+ p4 ? d3 . dice3 ! done . end
)
p5 = q2 ? go . flip 0.5 (
q5 ! d4 . end
,
q5 ! d5 . end
)
q5 = (
p5 ? d4 . dice4 ! done . end
+ p5 ? d5 . dice5 ! done . end
)
p6 = (mu t .
q2 ? go . flip 0.5 (
q6 ! d6 . end
,
q6 ! l2 . end
)
)
q6 = (mu t .
(
p6 ? d6 . dice6 ! done . end
+ p6 ? l2 . q0 ! redo . t
)
)
dice1 = q3 ? done . (mu t .
dummy ! repeat . t
)
dice2 = q4 ? done . end
dice3 = q4 ? done . end
dice4 = q5 ? done . end
dice5 = q5 ? done . end
dice6 = q6 ? done . end
dummy = (mu t .
dice1 ? repeat . t
)
dining.promt
(* Three dining philosophers. After eating, release the second-picked
fork first, matching the supplied dining.ctx benchmark. *)
p0 = mu t .
flip 0.5 (
mu s . f0 ! pick . ( f0 ? notFree . s
+ f0 ? free . f1 ! pick . ( f1 ? notFree . f0 ! drop . t
+ f1 ? free . q ! eat . f1 ! drop . f0 ! drop . t ) )
,
mu s . f1 ! pick . ( f1 ? notFree . s
+ f1 ? free . f0 ! pick . ( f0 ? notFree . f1 ! drop . t
+ f0 ? free . q ! eat . f0 ! drop . f1 ! drop . t ) )
)
p1 = mu t .
flip 0.5 (
mu s . f1 ! pick . ( f1 ? notFree . s
+ f1 ? free . f2 ! pick . ( f2 ? notFree . f1 ! drop . t
+ f2 ? free . q ! eat . f2 ! drop . f1 ! drop . t ) )
,
mu s . f2 ! pick . ( f2 ? notFree . s
+ f2 ? free . f1 ! pick . ( f1 ? notFree . f2 ! drop . t
+ f1 ? free . q ! eat . f1 ! drop . f2 ! drop . t ) )
)
p2 = mu t .
flip 0.5 (
mu s . f2 ! pick . ( f2 ? notFree . s
+ f2 ? free . f0 ! pick . ( f0 ? notFree . f2 ! drop . t
+ f0 ? free . q ! eat . f0 ! drop . f2 ! drop . t ) )
,
mu s . f0 ! pick . ( f0 ? notFree . s
+ f0 ? free . f2 ! pick . ( f2 ? notFree . f0 ! drop . t
+ f2 ? free . q ! eat . f2 ! drop . f0 ! drop . t ) )
)
f0 = mu t .
p0 ? pick . p0 ! free . ( mu s . ( p0 ? drop . t
+ p2 ? pick . p2 ! notFree . s ) )
+ p2 ? pick . p2 ! free . ( mu s . ( p2 ? drop . t
+ p0 ? pick . p0 ! notFree . s ) )
f1 = mu t .
p1 ? pick . p1 ! free . ( mu s . ( p1 ? drop . t
+ p0 ? pick . p0 ! notFree . s ) )
+ p0 ? pick . p0 ! free . ( mu s . ( p0 ? drop . t
+ p1 ? pick . p1 ! notFree . s ) )
f2 = mu t .
p2 ? pick . p2 ! free . ( mu s . ( p2 ? drop . t
+ p1 ? pick . p1 ! notFree . s ) )
+ p1 ? pick . p1 ! free . ( mu s . ( p1 ? drop . t
+ p2 ? pick . p2 ! notFree . s ) )
q = mu t . p0 ? eat . t + p1 ? eat . t + p2 ? eat . t
example-4-16.promt
(* Example 4.16: extended calculator, with Int payloads.
Retry guard and reconnect value are illustrative; inference retains
both branches of if true. *)
u = s ! incr<1> . mu X .
c ? res(x : Int) . s ! incr<x> . X
s = mu X . (
c ? crit . end
+ c ? disconn . (mu R .
if true then
c ! retry . R
else
c ! conn . flip 0.9 (
c ! incr<0> . X,
c ! upgrade . c ! incr<0> . (mu U .
u ? incr(y : Int) . c ! incr<y> . U
)
)
)
+ c ? err(x : Int) . flip 0.9 (
c ! incr<x> . X,
c ! upgrade . c ! incr<x> . (mu U .
u ? incr(y : Int) . c ! incr<y> . U
)
)
+ u ? incr(x : Int) . flip 0.9 (
c ! incr<x> . X,
c ! upgrade . c ! incr<x> . (mu U .
u ? incr(y : Int) . c ! incr<y> . U
)
)
)
c = mu X . (
s ? upgrade . (mu U .
s ? incr(x : Int) . u ! res<succ(x)> . U
)
+ s ? incr(x : Int) . (
if x < 256 then
u ! res<succ(x)> . X
else
flip 0.8 (
u ! res<succ(x)> . X,
flip 0.5 (
s ! err<x> . X,
flip 0.5 (
s ! crit . end,
s ! disconn . (mu R .
s ? retry . R
+ s ? conn . X
)
)
)
)
)
)
)
)
)
)
)
gamblers-ruin.promt
(* Gambler walk: down with probability 0.4, up with probability 0.6. *)
w = (mu t .
flip 0.4 (
q ! down . flip 0.4 (
q ! down . o ! ruined . end
,
q ! up . t
)
,
q ! up . flip 0.6 (
q ! up . (mu s .
o ! won . s
)
,
q ! down . t
)
)
)
q = (mu t .
(
w ? down . (
w ? down . end
+ w ? up . t
)
+ w ? up . (
w ? up . end
+ w ? down . t
)
)
)
o = (
w ? ruined . end
+ w ? won . (mu t .
w ? won . t
)
)
leader-election.promt
(* Two-node randomised leader election. *)
n0 = (mu t .
flip 0.5 (
n1 ! zero . (
n1 ? zero . t
+ n1 ? one . end
)
,
n1 ! one . (
n1 ? zero . o ! leader0 . end
+ n1 ? one . t
)
)
)
n1 = (mu t .
(
n0 ? zero . flip 0.5 (
n0 ! zero . t
,
n0 ! one . o ! leader1 . end
)
+ n0 ? one . flip 0.5 (
n0 ! zero . end
,
n0 ! one . t
)
)
)
o = (
n0 ? leader0 . end
+ n1 ? leader1 . end
)
monty-hall-change.promt
(* Monty Hall: switch doors. Car probabilities are exactly 0.34, 0.33, 0.33. *)
car = flip 0.34 (
host ! l1 . end
,
flip 0.5 (
host ! l2 . end
,
host ! l3 . end
)
)
host = (
car ? l1 . flip 0.5 (
player ! l2 . player ? l1 . end
,
player ! l3 . player ? l1 . end
)
+ car ? l2 . player ! l3 . player ? l2 . end
+ car ? l3 . player ! l2 . player ? l3 . end
)
player = (
host ? l2 . host ! l3 . end
+ host ? l3 . host ! l2 . end
)
monty-hall-stay.promt
(* Monty Hall: stay with door 1. Car probabilities are exactly 0.34, 0.33, 0.33. *)
car = flip 0.34 (
host ! l1 . end
,
flip 0.5 (
host ! l2 . end
,
host ! l3 . end
)
)
host = (
car ? l1 . flip 0.5 (
player ! l2 . player ? l1 . end
,
player ! l3 . player ? l1 . end
)
+ car ? l2 . player ! l3 . player ? l2 . end
+ car ? l3 . player ! l2 . player ? l3 . end
)
player = (
host ? l2 . host ! l1 . end
+ host ? l3 . host ! l1 . end
)
multiparty-workers.promt
(* Three independent worker pipelines; Int values are illustrative. *)
starter = workerA1 ! datum<0> . workerA2 ! datum<0> . workerA3 ! datum<0> . end
workerA1 = starter ? datum(x1 : Int) . (mu t .
flip 0.5 (
workerB1 ! datum<x1> . workerC1 ? result(x2 : Int) . t
,
workerB1 ! stop . end
)
)
workerB1 = (mu t .
(
workerA1 ? datum(x1 : Int) . workerC1 ! datum<x1> . t
+ workerA1 ? stop . workerC1 ! stop . end
)
)
workerC1 = (mu t .
(
workerB1 ? datum(x1 : Int) . workerA1 ! result<x1> . t
+ workerB1 ? stop . end
)
)
workerA2 = starter ? datum(x1 : Int) . (mu t .
flip 0.5 (
workerB2 ! datum<x1> . workerC2 ? result(x2 : Int) . t
,
workerB2 ! stop . end
)
)
workerB2 = (mu t .
(
workerA2 ? datum(x1 : Int) . workerC2 ! datum<x1> . t
+ workerA2 ? stop . workerC2 ! stop . end
)
)
workerC2 = (mu t .
(
workerB2 ? datum(x1 : Int) . workerA2 ! result<x1> . t
+ workerB2 ? stop . end
)
)
workerA3 = starter ? datum(x1 : Int) . (mu t .
flip 0.5 (
workerB3 ! datum<x1> . workerC3 ? result(x2 : Int) . t
,
workerB3 ! stop . end
)
)
workerB3 = (mu t .
(
workerA3 ? datum(x1 : Int) . workerC3 ! datum<x1> . t
+ workerA3 ? stop . workerC3 ! stop . end
)
)
workerC3 = (mu t .
(
workerB3 ? datum(x1 : Int) . workerA3 ! result<x1> . t
+ workerB3 ? stop . end
)
)
rec-map-reduce.promt
(* Recursive map-reduce protocol; received Int values can be forwarded. *)
mapper = (mu t .
worker1 ! datum<0> . worker2 ! datum<0> . worker3 ! datum<0> . (
reducer ? continue(x1 : Int) . t
+ reducer ? stop . worker1 ! stop . worker2 ! stop . worker3 ! stop . end
)
)
worker1 = mapper ? datum(x1 : Int) . (mu t .
reducer ! result<x1> . (
mapper ? datum(x2 : Int) . t
+ mapper ? stop . end
)
)
worker2 = mapper ? datum(x1 : Int) . (mu t .
reducer ! result<x1> . (
mapper ? datum(x2 : Int) . t
+ mapper ? stop . end
)
)
worker3 = mapper ? datum(x1 : Int) . (mu t .
reducer ! result<x1> . (
mapper ? datum(x2 : Int) . t
+ mapper ? stop . end
)
)
reducer = (mu t .
worker1 ? result(x1 : Int) . worker2 ? result(x2 : Int) . worker3 ? result(x3 :
Int) . flip 0.4 (
mapper ! continue<x3> . t
,
mapper ! stop . end
)
)
rec-two-buyers.promt
(* Recursive two buyers. The query payload is Int (book identifier) instead of Str
. *)
alice = shop ! query<0> . shop ? price(x1 : Int) . (mu t .
flip 0.5 (
bob ! split<x1> . (
bob ? yes . shop ! buy . end
``
+ bob ? no . t
)
,
bob ! cancel . shop ! no . end
)
)
shop = alice ? query(x1 : Int) . alice ! price<x1> . (
alice ? buy . end
+ alice ? no . end
)
bob = (mu t .
(
alice ? split(x1 : Int) . flip 0.5 (
alice ! yes . end
,
alice ! no . t
)
+ alice ? cancel . end
)
)
**von-neumann-coin.promt**
(* Biased coin with probability 0.9 of heads, preserving the benchmark observer
loops. *)
f = (mu t .
flip 0.9 (
c ! heads . flip 0.9 (
c ! heads . t
,
c ! tails . (mu s .
o ! heads . s
)
)
,
c ! tails . flip 0.9 (
c ! heads . o ! tails . end
,
c ! tails . t
)
)
)
c = (mu t .
(
f ? heads . (
f ? heads . t
+ f ? tails . end
)
+ f ? tails . (
Table 2. Prose outputs on the typing contexts inferred from §E.4, used for benchmarking. DF and Liveness are the lower-bound probabilities of deadlock-freedom and liveness (minimised over all fair schedulers), rounded to two decimal points.
f ? heads . end
+ f ? tails . t
)
)
)
o = (
f ? heads . (mu t .
f ? heads . t
)
+ f ? tails . end
)
Results of Running Prose on Examples
Table 2 shows the results of running Prose on the typing contexts inferred from the examples given in §E.4. All probabilistic results are rounded to two decimal points.
Comparison With Model checking Sessions
Consider the following session M n M_n M n . For a given n n n , workers w i w_i w i (0 ≤ i < n 0 \le i < n 0 ≤ i < n ) each compute the factorial of i i i by querying worker w i − 1 w_{i-1} w i − 1 (except for w 0 w_0 w 0 , which always outputs 1) and multiplying the result by i i i . However, each worker may probabilistically produce an error; moreover, the probability of each worker producing an error is larger if the value received is at least 100. If a worker receives an error, it simply propagates it. Finally, the worker w n w_n w n requests the value of ( n − 1 ) (n - 1) ( n − 1 ) factorial. If w n w_n w n receives a result, it sends a message to the dummy worker d d d forever; if it receives an error, then it terminates, leaving the remaining workers waiting for a request that never arrives. Thus, the probability of deadlock-freedom P d f min ( M n ) P_{\mathrm{df}}^{\min}(M_n) P df m i n ( M n ) gives the probability of an execution where w n w_n w n receives a result.
P 0 = μ X . w 1 ? r e q . f l i p ( 0.7 ) { h ⇒ w 1 ! r e s ⟨ 1 ⟩ . X [ ] t ⇒ w 1 ! e r r . X } P_0 = \mu X.\,w_1? \mathrm{req}.\mathrm{flip}(0.7)\{h \Rightarrow w_1!\mathrm{res}\langle1\rangle.X \mathbin{[] } t \Rightarrow w_1!\mathrm{err}.X\} P 0 = μ X . w 1 ? req . flip ( 0.7 ) { h ⇒ w 1 ! res ⟨ 1 ⟩ . X [ ] t ⇒ w 1 ! err . X }
P i ∈ [ 1 , n − 1 ] = μ X . w i + 1 ? r e q . w i − 1 ! r e q . ( w i − 1 ? e r r . w i + 1 ! e r r . X + w i − 1 ? r e s ( x ) . i f x < 100 t h e n f l i p ( 0.7 ) { h ⇒ w i + 1 ! r e s ⟨ x ∗ i ⟩ . X [ ] t ⇒ w i + 1 ! e r r . X } e l s e f l i p ( 0.5 ) { h ⇒ w i + 1 ! r e s ⟨ x ∗ i ⟩ . X [ ] t ⇒ w i + 1 ! e r r . X } ) P_i \in[1,n-1] = \mu X.\,w_{i+1}?{\rm req}.w_{i-1}!{\rm req}. \\
\qquad(w_{i-1}?{\rm err}.w_{i+1}!{\rm err}.X \\
\qquad\quad+ w_{i-1}?{\rm res}(x). \\
\qquad\qquad{\rm if}\ x < 100\ {\rm then}\ {\rm flip}(0.7)\{h \Rightarrow w_{i+1}!{\rm res}\langle x * i\rangle.X \mathbin{[]} t \Rightarrow w_{i+1}!{\rm err}.X\} \\
\qquad\qquad{\rm else}\ {\rm flip}(0.5)\{h \Rightarrow w_{i+1}!{\rm res}\langle x * i\rangle.X \mathbin{[]} t \Rightarrow w_{i+1}!{\rm err}.X\}) P i ∈ [ 1 , n − 1 ] = μ X . w i + 1 ? req . w i − 1 ! req . ( w i − 1 ? err . w i + 1 ! err . X + w i − 1 ? res ( x ) . if x < 100 then flip ( 0.7 ) { h ⇒ w i + 1 ! res ⟨ x ∗ i ⟩ . X [ ] t ⇒ w i + 1 ! err . X } else flip ( 0.5 ) { h ⇒ w i + 1 ! res ⟨ x ∗ i ⟩ . X [ ] t ⇒ w i + 1 ! err . X })
P n = w n − 1 ! r e q . ( w n − 1 ? r e s ( x ) . μ X . d ! d o n e . X + w n − 1 ? e r r .0 ) P_n = w_{n-1}!{\rm req}.(w_{n-1}?{\rm res}(x).\mu X.d!{\rm done}.X + w_{n-1}?{\rm err}.0) P n = w n − 1 ! req . ( w n − 1 ? res ( x ) . μ X . d ! done . X + w n − 1 ? err .0 )
P d = μ X . w n ? d o n e . X P_d = \mu X.w_n?{\rm done}.X P d = μ X . w n ? done . X
M n = w 0 ◃ P 0 ∣ ⋯ ∣ w n ◃ P n ∣ d ◃ P d M_n = w_0 \triangleleft P_0 \mid\cdots\mid w_n \triangleleft P_n \mid d \triangleleft P_d M n = w 0 ◃ P 0 ∣ ⋯ ∣ w n ◃ P n ∣ d ◃ P d
This session is typable, with P i ∈ [ 1 , n − 1 ] P_i \in[1,n-1] P i ∈ [ 1 , n − 1 ] having the following type T i T_i T i .
T i = μ t . & w i + 1 ? r e q . ⊕ w i − 1 ! r e q . & { w i − 1 ? e r r . ⊕ w i + 1 ! e r r . t , T_i = \mu t.\ \&w_{i+1}?{\rm req}.\ \oplus w_{i-1}!{\rm req}.\ \&\{w_{i-1}?{\rm err}.\ \oplus w_{i+1}!{\rm err}.t, T i = μ t . & w i + 1 ? req . ⊕ w i − 1 ! req . & { w i − 1 ? err . ⊕ w i + 1 ! err . t ,
w i − 1 ! r e s ( i n t ) . ⊕ { 0.7 : w i + 1 ! r e s ⟨ i n t ⟩ . t , 0.3 : w i + 1 ! e r r . t } , w_{i-1}!{\rm res}({\rm int}).\ \oplus\{0.7:w_{i+1}!{\rm res}\langle{\rm int}\rangle.t,\ 0.3:w_{i+1}!{\rm err}.t\}, w i − 1 ! res ( int ) . ⊕ { 0.7 : w i + 1 ! res ⟨ int ⟩ . t , 0.3 : w i + 1 ! err . t } ,
⊕ { 0.5 : w i + 1 ! r e s ⟨ i n t ⟩ . t , 0.5 : w i + 1 ! e r r . t } } \oplus\{0.5:w_{i+1}!{\rm res}\langle{\rm int}\rangle.t,\ 0.5:w_{i+1}!{\rm err}.t\}\} ⊕ { 0.5 : w i + 1 ! res ⟨ int ⟩ . t , 0.5 : w i + 1 ! err . t }}
The non-deterministic sum ∑ \sum ∑ originates from the use of subtyping ([sub-Σ \Sigma Σ ]), which is necessary to type the conditional using [t-cond]: the test x < 100 x < 100 x < 100 is abstracted to a non-deterministic choice between the two output distributions (cf. Example 3.1). The types for other participants are obvious and are omitted.
We translate the sessions and their typing contexts into PRISM modules, allowing us to compare their efficiency and evaluate the quality of the lower bound obtained from the typing context. The PRISM definitions for the translated processes are presented in §E.7. We invoke PRISM with the explicit engine (-ex flag) for the session verification, since unlike the default hybrid engine it does not require integer variables to be bounded.
Figure 13 a shows a comparison of the time taken to verify deadlock-freedom probabilities of M n M_n M n and its typing context, with varying values of n n n . We observe that as n n n increases, the time taken for direct verification of sessions increases significantly faster than that of typing contexts. In fact, for n ≥ 14 n \ge14 n ≥ 14 , the PRISM invocations for session verifications ran out of the allocated Java heap space2 , and consequently did not finish execution.
This is due to the increased state space of processes: any integer variables used by processes need to be present in the state space for the module corresponding to that participant. In general, each integer variable can lie within a large range3 of values, and each new variable contributes to the product state of variables. By contrast, the typing system treats each variable simply as a member of the int sort, collapsing the state space required.
More generally, if we extend our calculus with a richer language of expressions e e e , checking properties for processes becomes undecidable due to the presence of conditionals and recursion (Proposition 2.3). However, checking safety, termination and deadlock-freedom for typing contexts has been proven decidable in the non-probabilistic setting [49 , 59 ] (which implies our probabilistic case).
The trade-off of verifying typing contexts is that we compute a lower bound (Theorem 4.26 ) of the deadlock-freedom probability, rather than the exact probability. The difference is due to the conditional x < 100 x < 100 x < 100 being abstracted to a non-deterministic choice in T i T_i T i : the worst-case scheduler always resolves it towards the distribution with the larger error probability 0.5 0.5 0.5 , whereas the session only takes this branch once the received value reaches 100. Figure 13 b shows a comparison of the deadlock-freedom probability obtained from M n M_n M n and its corresponding context: both tend to 0 0 0 as n n n grows, since every worker in the chain must succeed, with the lower bound from the typing context lying below the exact probability of the session.
PRISM Models for app:modelcheckingprocesses
An example model for n = 3 n = 3 n = 3 is given here; others are straightforward extensions. Our artifact includes scripts to generate the sessions and typing contexts (and hence these models) for other values of n n n .
module w0
w0 : int init 0;
w0_w1_err_unit : int init 0;
w0_w1_res_unit : int init 0;
[w1_w0] w0=0 -> 1:(w0'=1);
[w1_w0_req_unit] w0=1 -> 1:(w0'=2);
[] w0=2 -> 0.7:(w0'=3) + 0.3:(w0'=6);
[w0_w1] w0=3 -> 1:(w0'=4)&(w0_w1_res_unit'=1);
[w0_w1_res_unit] w0=4 -> 1:(w0'=5);
[] w0=5 -> 1:(w0'=0);
[w0_w1] w0=6 -> 1:(w0'=7)&(w0_w1_err_unit'=0);
[w0_w1_err_unit] w0=7 -> 1:(w0'=8);
[] w0=8 -> 1:(w0'=0);
endmodule
module w1
w1 : int init 0;
w1_w2_err_unit : int init 0;
w1_w2_res_unit : int init 0;
w1_x : int init 0;
[w2_w1] w1=0 -> 1:(w1'=1);
[w2_w1_req_unit] w1=1 -> 1:(w1'=2);
[w1_w0] w1=2 -> 1:(w1'=3);
[w1_w0_req_unit] w1=3 -> 1:(w1'=4);
[w0_w1] w1=4 -> 1:(w1'=5);
[w0_w1_res_unit] w1=5 -> 1:(w1'=10)&(w1_x'=w0_w1_res_unit);
[] (w1=10) & ((w1_x)<(100)) -> 1:(w1'=11);
[] (w1=10) & (!((w1_x)<(100))) -> 1:(w1'=18);
[] w1=11 -> 0.7:(w1'=12) + 0.3:(w1'=15);
[w1_w2] w1=12 -> 1:(w1'=13)&(w1_w2_res_unit'=(w1_x)*(1));
[w1_w2_res_unit] w1=13 -> 1:(w1'=14);
[] w1=14 -> 1:(w1'=0);
[w1_w2] w1=15 -> 1:(w1'=16)&(w1_w2_err_unit'=0);
[w1_w2_err_unit] w1=16 -> 1:(w1'=17);
[] w1=17 -> 1:(w1'=0);
[] w1=18 -> 0.5:(w1'=19) + 0.5:(w1'=22);
[w1_w2] w1=19 -> 1:(w1'=20)&(w1_w2_res_unit'=(w1_x)*(1));
[w1_w2_res_unit] w1=20 -> 1:(w1'=21);
[] w1=21 -> 1:(w1'=0);
[w1_w2] w1=22 -> 1:(w1'=23)&(w1_w2_err_unit'=0);
[w1_w2_err_unit] w1=23 -> 1:(w1'=24);
[] w1=24 -> 1:(w1'=0);
[w0_w1_err_unit] w1=5 -> 1:(w1'=6)&(w1_x'=w0_w1_err_unit);
[w1_w2] w1=6 -> 1:(w1'=7)&(w1_w2_err_unit'=0);
[w1_w2_err_unit] w1=7 -> 1:(w1'=8);
[] w1=8 -> 1:(w1'=0);
endmodule
module w2
w2 : int init 0;
w2_w3_err_unit : int init 0;
w2_w3_res_unit : int init 0;
w2_x : int init 0;
[w3_w2] w2=0 -> 1:(w2'=1);
[w3_w2_req_unit] w2=1 -> 1:(w2'=2);
[w2_w1] w2=2 -> 1:(w2'=3);
[w2_w1_req_unit] w2=3 -> 1:(w2'=4);
[w1_w2] w2=4 -> 1:(w2'=5);
[w1_w2_res_unit] w2=5 -> 1:(w2'=10)&(w2_x'=w1_w2_res_unit);
[] (w2=10) & ((w2_x)<(100)) -> 1:(w2'=11);
[] (w2=10) & (!((w2_x)<(100))) -> 1:(w2'=18);
[] w2=11 -> 0.7:(w2'=12) + 0.3:(w2'=15);
[w2_w3] w2=12 -> 1:(w2'=13)&(w2_w3_res_unit'=(w2_x)*(2));
[w2_w3_res_unit] w2=13 -> 1:(w2'=14);
[] w2=14 -> 1:(w2'=0);
[w2_w3] w2=15 -> 1:(w2'=16)&(w2_w3_err_unit'=0);
[w2_w3_err_unit] w2=16 -> 1:(w2'=17);
[] w2=17 -> 1:(w2'=0);
[] w2=18 -> 0.5:(w2'=19) + 0.5:(w2'=22);
[w2_w3] w2=19 -> 1:(w2'=20)&(w2_w3_res_unit'=(w2_x)*(2));
[w2_w3_res_unit] w2=20 -> 1:(w2'=21);
[] w2=21 -> 1:(w2'=0);
[w2_w3] w2=22 -> 1:(w2'=23)&(w2_w3_err_unit'=0);
[w2_w3_err_unit] w2=23 -> 1:(w2'=24);
[] w2=24 -> 1:(w2'=0);
[w1_w2_err_unit] w2=5 -> 1:(w2'=6)&(w2_x'=w1_w2_err_unit);
[w2_w3] w2=6 -> 1:(w2'=7)&(w2_w3_err_unit'=0);
[w2_w3_err_unit] w2=7 -> 1:(w2'=8);
[] w2=8 -> 1:(w2'=0);
endmodule
module w3
w3 : int init 0;
w3_x : int init 0;
[w3_w2] w3=0 -> 1:(w3'=1);
[w3_w2_req_unit] w3=1 -> 1:(w3'=2);
[w2_w3] w3=2 -> 1:(w3'=3);
[w2_w3_res_unit] w3=3 -> 1:(w3'=6)&(w3_x'=w2_w3_res_unit);
[w3_dummy] w3=6 -> 1:(w3'=7);
[w3_dummy_done_unit] w3=7 -> 1:(w3'=8);
[] w3=8 -> 1:(w3'=6);
[w2_w3_err_unit] w3=3 -> 1:(w3'=4)&(w3_x'=w2_w3_err_unit);
endmodule
module dummy
dummy : int init 0;
[w3_dummy] dummy=0 -> 1:(dummy '=1);
[w3_dummy_done_unit] dummy=1 -> 1:(dummy '=2);
[] dummy=2 -> 1:(dummy '=0);
endmodule
label "end" = (false) & (false) & (false) & (w3=4) & (false);
We check the probability of deadlock-freedom using the PLTL formula P min ( □ ( “deadlock” ⇒ “end” ) ) P_{\min}(\Box(\text{“deadlock”} \Rightarrow\text{“end”})) P m i n ( □ ( “deadlock” ⇒ “end” )) , i.e. the same specification as for typing contexts in § 7.1 .