ArticlePDF Available
M. Marin, A. Cr˘aciun (Eds.):
Working Formal Methods Symposium 2019 (FROM 2019)
EPTCS 303, 2019, pp. 92–106, doi:10.4204/EPTCS.303.7
c
B. Aman & G. Ciobanu
This work is licensed under the
Creative Commons Attribution License.
Probabilities in Session Types
Bogdan Aman Gabriel Ciobanu
Romanian Academy, Institute of Computer Science, Ias¸i, Romania
Alexandru Ioan Cuza University of Ias¸i, Faculty of Computer Science, Romania
bogdan.aman@iit.academiaromana-is.ro gabriel@info.uaic.ro
This paper deals with the probabilistic behaviours of distributed systems described by a process
calculus considering both probabilistic internal choices and nondeterministic external choices. For
this calculus we define and study a typing system which extends the multiparty session types in order
to deal also with probabilistic behaviours. The calculus and its typing system are motivated and
illustrated by a running example.
1 Introduction
Probabilities allow uncertainty to be described in quantitative terms. If there are no uncertainties about
how a system behaves, then its expected behaviour has a 100% chance of occurring, while any other
behaviour would have no chance (i.e., 0% chance). Regarding the possible behaviours of a system,
people working in artificial intelligence have used probability distributions over a set of events [9]. In
such an approach, the probabilities assigned to behaviours are real numbers from [0,1]rather than values
in {0,1}. In [5], the authors made explicitly the assumption that probabilities are distributed over a
restricted set of events, each of them corresponding to an equivalence class of events. We adapt these
ideas to the framework of multiparty session types, and introduce probabilities assigned to actions and
label selections.
An important feature of a probabilistic model is given by the distinction between nondeterministic
and probabilistic choices [18]. The nondeterministic choices refer to the choices made by an external
process, while probabilistic choices are choices made internally by the process (not under control of an
external process). Intuitively, a probabilistic choice is given by a set of alternative transitions, where
each transition has a certain probability of being selected; moreover, the sum of all these probabilities
(for each choice) is 1. To clarify the difference between nondeterministic and probabilistic choices, we
consider a variant of the two-buyers-seller protocol [14] depicted in Figure 1. Two buyers (Alice and Bob)
wish to buy an expensive book (out of several possible ones) from a Seller by combining their money
(in various amounts depending on the amount of cash Alice is willing to pay). The communications
between them can be described in several steps. Firstly, Alice sends (out of several choices) a book title
(a string) or an ISBN (a number) to the Seller. The fact that Alice chooses which book she wants to
buy by sending the book title or book ISBN is an example of a probabilistic choice, because it is under
her control and preference (this is why in Figure 1 we added probabilities to the possible choices of
Alice regarding the book). Then, Alice waits for an answer regarding the quote of the book. This is a
nondeterministic choice, because the choice of the answer received by Alice is out of her control. This
is due to the fact that the Seller may provide different quotes depending on the buying history of Alice
and existing discounts. Next, Seller sends back a quote (an integer) to Alice and Bob.Alice tells Bob
how much she can contribute (an integer). Depending on the contribution of Alice,Bob notifies Seller
whether it accepts the quote or not. If Bob accepts, he sends his home or office address (a string), and
awaits from the Seller a delivery date when the requested book will be received.
B. Aman & G. Ciobanu
93
Alice Seller Bob
[Link] [Link]
p11:title1
p21 :quote1quote1
p31 :quote
1p41 :ok1
homeAddress
p51 :date1
p52 :date2
p42 :ok2
officeAddress
p61 :date1
p62 :date2
p43 :quit
Branch
p32 :quote′′
1
:
p12 :ISBN1
:
p13:title2
:
Probabilistic
choice
Figure 1: Dotted lines stand for probabilistic choices pi j, dashed lines for branching, solid lines for
deterministic choices, while double headed dotted lines for session initialization.
One goal of the current research lines is to use a formal approach to describe in a rigorous way
how distributed systems should behave, and then to design these systems properly in order to satisfy
the behavioural constraints. In the last few years the focus has moved towards the quantitative study
of the distributed systems behaviour to be able to solve problems that are not solvable by deterministic
approaches (e.g., leader election problem [7]).
Probabilistic modelling is usually used to represent and quantify uncertainty in the study of dis-
tributed systems. Several probabilistic process calculi have been considered in the literature: probabilis-
tic CCS [10], probabilistic CSP [15], probabilistic ACP [2], probabilistic asynchronous
π
-calculus [11],
PEPA [12]. The basic idea of these probabilistic process calculi is to include a probabilistic choice
operator. Essentially, there are two possibilities of extending such an approach: either to replace nonde-
terministic choices by probabilistic choices, or to allow both probabilistic and nondeterministic choices.
In this paper we consider the second alternative, and allow probabilistic choices made internally by
the communicating processes (sending a value or a label), and also nondeterministic choices controlled
by an external process (receiving a value or a label). Notice that in our operational semantics we impose
that for each received value/label, the continuation of a nondeterministic choice is unique; thus, the
corresponding execution turns out to be completely deterministic. We use a probabilistic extension of the
process calculus presented in [14], a calculus which is also an extension of the
π
-calculus [16] for which
the papers [11, 20] present a probabilistic approach. For this calculus we define and study a typing system
by extending the multiparty session types with both nondeterministic and probabilistic behaviours.
Session types [13, 19] and multiparty session types [14] provide a typed foundation for the design of
communication-based systems. The main intuition behind session types is that a communication-based
application exhibits a structured sequence of interactions. Such a structure is abstracted as a type through
an intuitive syntax which is used to validate programs. Session types are terms of a process algebra that
also contains a selection construct (an internal choice among a set of branches), a branching construct
94
Probabilities in Session Types
(an external choice offered to the environment) and recursion. Session types are able to guarantee several
properties in a session: (i) interactions never lead to a communication error (communication safety); (ii)
channels are used linearly (linearity) and are deadlock-free (progress); (iii) the communication sequence
follows a declared scenario (session fidelity, predictability).
While many communication patterns can be captured through such sessions, there are cases where
basic multiparty session types are not able to capture interactions which involve internal probabilistic
choices of the participants. Probabilities are used in the design and verification of complex systems in
order to quantify unreliable or unpredictable behaviour, but also taken also into account when analyz-
ing quantitative properties (measuring somehow the success level of the protocol). Overall, we study
the nondeterministic and probabilistic choices in the framework of multiparty session types in order to
understand better the quantitative aspects of uncertainty that might arise in communicating processes.
In the following, Section 2 presents the syntax and semantics of our probabilistic process calculus,
and motivates the key ideas by using the two-buyers-seller protocol. Section 3 explains the global and
local types, and the connection between them. Section 4 describes the new typing system and presents
the main results. Section 5 concludes and discusses some related probabilistic approaches involving
typing systems.
2 Probabilistic Multiparty Session Processes
The most natural way to define a probabilistic extension of a process calculus consists of adding proba-
bilistic information to some actions [8]. Probabilities are not attached to some actions, while others have
probabilities (see [20]). When modelling the probabilistic behaviour of a distributed system, we should
be able to model the fact that either the system or the environment chooses between several alternative
behaviours. Moreover, when modelling such a system we should avoid to ‘approximate’ the nonde-
terministic choice by a probabilistic distribution (very often a uniform distribution is used). For these
reasons, we define a probabilistic extension of the process calculus used in [14] that combines both non-
deterministic and probabilistic behaviours. We actually define a calculus that puts together probabilistic
internal choices (sending a value and selecting a label) with nondeterministic external choices (receiving
a value and branching a process by using a selected value). In this setting, the nondeterministic actions
of a process use information (values and labels) provided only by probability actions. The type system
for this calculus is inspired from the synchronous multiparty session types [3]. As far as we know, our
approach is new among the existing models used to formalize multiparty processes in the framework of
multiparty session types.
2.1 Syntax
In what follows we use our variant of the two-buyers-seller protocol to illustrate some of the syntactic
constructs defined afterwards.
Example 1. Let us note that the book to buy represents the choice of Alice, and so she sends the title
of a book (a string) or an ISBN (a ten digit number). Since this is under her control and preference, it
represents an example of a probabilistic choice.
Alice =0.3 : as!hWar and Peace′′i;Alice1+0.5 : as!hThe Art of War′′i;Alice2
+0.2 : as!h0195014766i;Alice3.
Here ‘as’ denotes the channel used for the communication between Alice and the Seller. Actually, chan-
nels ‘as’ and ‘ab’ are used by Alice to communicate with Seller and with Bob, while channel ‘bs’ is used
B. Aman & G. Ciobanu
95
by Bob to communicate with Seller. We denote by Alicei(1i3) the different behaviours of Alice after
she sent her book choice. We use this index notation to keep track of the behaviours for each participant,
to simplify the syntax and make it easier to read. The detailed description of all participants can be
found in Example 3.
When receiving the book orders, the Seller expects the buyers sending him either a string representing
a title of the book or a number representing an ISBN. This behaviour is nondeterministic depending on
the received information: Seller =as?(title :string);Seller1+as?(ISBN :nat);Seller2.
Informally, a session is a series of interactions between multiple parties serving as a unit of conversation.
A session is established via a shared name representing a public interaction point, and consists of series
of communication actions performed on fresh session channels. The syntax for processes is based on
user-defined processes [14] extended with probabilistic choices. The syntax is presented in Table 1,
where we use: probabilities p1,p2,...; shared names a,b,n,... and session names x,y,...; channels
s,t,...; expressions e,ei,...; labels l,li,..., participants q,.... We use symbols qto name participants
despite the fact that they are in reality numbers.
Processes P ::=a[n]( ˜s).P(multicast session request)
pa[q]( ˜s).P(session acceptance)
p
iI
pi:s!h˜eii;P
i(value sending)
p
iI
s?(˜xi:˜
Si);P
i(˜
Sk6=˜
St, for k,tI,k6=t) (value reception)
ps!hh ˜sii;P(session delegation)
ps?(( ˜s));P(session reception)
p
iI
pi:sli;P
i(lk6=lt, for k,tI,k6=t)(label selection)
ps{li:P
i}iI(lk6=lt, for k,tI,k6=t)(label branching)
pif ethen Pelse Q(conditional branch)
pP|Q(parallel)
p0(inaction)
p(
ν
n)P(hiding)
p
µ
X.P(recursion)
pX(variable)
Expressions e ::=vpeand epnot ep...
Values v ::=aptrue pf alse p...
Sorts S ::=bool |nat |... (value types)
Table 1: Syntax
Excepting the primitives for value sending, value receiving and label selection, all the other con-
structs are from [14]. The process a[n]( ˜s).Psends along channel aa request to start a new session using
the channels ˜swith participants 1 ... n, where it participates as 1 and continues as P. Its dual a[q]( ˜s).P
engages in a new session as participant q. The communications taking place inside an established ses-
sion are performed using the next six primitives: sending/receiving a value, session delegation/reception,
and selection/branching. By using the delegation/reception pair, a process delegates to another one the
capability to participate in a session by passing the channels associated with the session. The conditional
branching establishes the continuation of an evolution based on the truth value of an expression e. It is
worth mentioning that the internal choices (sending a value and selecting a label) are probabilistically
chosen, while the receiving values represent a nondeterministic choice (as external choice). The condi-
tional branch, parallel and inaction are standard. A sequence of parallel composition is written ΠiP
i. The
96
Probabilities in Session Types
syntax (
ν
n)Pmakes the name nlocal to P. Interaction which can be repeated unboundedly is realized
by recursion; as in [4], we do not use arguments when defining recursion. We often omit writing 0at the
end of processes (e.g., s!h˜eii;0is written as s!h˜eii).
The notions of identifiers (bound and free), process variables (bound and free), channels, alpha equiv-
alence
α
and substitution are standard. The bound identifiers are ˜sin multicast session request, session
acceptance and session reception, ˜xjin value reception and nin hiding, while the bound process variable
is Xin recursion. fv(P)and fn(P)denote the sets of free process variables and free identifiers of P,
respectively.
2.2 Operational Semantics
Structural equivalence for processes is the least equivalence relation satisfying the following equations:
P|0P P |QQ|P(P|Q)|RP|(Q|R)
(
ν
n)P|Q(
ν
n)(P|Q)if n/fn(Q) (
ν
n)(
ν
n)P(
ν
n)(
ν
n)P
(
ν
n)00
µ
X.00pi:P+pj:Qpj:Q+pi:P P +QQ+P.
We define the operational semantics in such a way that it distinguishes between probabilistic choices
made internally by a process and nondeterministic choices made externally. This distinction allows us to
reason about the evolutions of the system in which the nondeterministic actions of a process use only the
data send by the probability actions. The operational semantics is given by a reduction relation denoted
by PrQ(meaning Preduces to Qwith probability r) representing the smallest relation generated by
the rules of Table 2 (where evmeans that expression eis evaluated to value v).
a[n]( ˜s).P
1|Πq∈{2..n}a[q]( ˜s).P
q1(
ν
˜s)Πq∈{1..n}P
q(LI NK)
iI
pi:s!h˜eii;P
i|
jJ
s?(˜xj:˜
Sj);PjpiP
i|Pj{˜vi/˜xj}( ˜ei˜vi,˜vj:˜
Sj) (CO M)
s!hh ˜sii;P|s?(( ˜s));Q1P|Q(DELEG)
iI
pi:sli;P
i|s{lj:Pj}jJpiP
i|Pj(jJ) (LA B EL)
if ethen Pelse Q1P(etrue) (IFT)
if ethen Pelse Q1Q(ef alse) (IFF)
µ
X.P1P{
µ
X.P/X}(CA LL)
PpPimplies (
ν
n)Pp(
ν
n)P(SC OPE)
PpPand Q6→ implies P|QpP|Q(PAR1)
PpPand QqQimplies P|Qp·qP|Q(PAR2)
PPand PpQand QQimplies PpQ(STRUCT)
Table 2: Operational Semantics
Rule (LI NK) describes a session initiation among n parties, generating |˜s|fresh multiparty session
channels. For simplicity, we consider that this rule has probability 1; a normalization based on the pos-
sible reachable processes in one step is eventually needed (as done in [8]). Rules (CO M), (DELEG) and
(LA B EL) are used to communicate values, session channels and labels. The values to be communicated
in the rules (COM) and (LABE L) are chosen probabilistically, a fact illustrated by adding the probability
of the consumed action to the transition of the reduction relation. In both rules (COM) and (LABE L), the
choice of the continuation process to be executed after sending or selecting is probabilistic, while when
receiving or branching is nondeterministic. Inspired by [1], we add the conditions ˜
Sk6=˜
St(meaning that
the types of ˜xkand ˜xtare different ) and lk6=lt(meaning that lkand ltare different) in the rules (COM) and
(LA B EL) to indicate that each value and label leads to a unique continuation. This means that a process
B. Aman & G. Ciobanu
97
of the form s?(x:S);P+s?(x:S).Qis not possible in our syntax. Thus, the probability of the transition
is equal with the probability of the sending/selecting process. It could be noticed from (LINK ), (COM )
and (LA BEL) that the calculus is synchronous; this choice is made in order to simplify the presentation.
The rules (IFT) and (IFF) choose which branch to take depending on the truth value of ei. The rules
(SC O PE) and (STRUC T) are standard. Rule (PAR2) is used to compose the evolutions of parallel pro-
cesses, while rule (PAR1) is used to compose concurrent processes that are able to evolve with processes
that are not able to evolve. In rule (PAR1), Q6→ means that the process Qis not able to evolve by means
of any rule (we say that Qis a stuck process). Negative premises are used to denote the fact that passing
to a new step is performed based on the absence of actions. The use of negative premises does not lead
to an inconsistent set of rules. The following example illustrates how and when the rule (PAR1) is used.
Example 2 (cont.).Let us consider the process P =Alice |Seller |Bob, where Alice and Seller have the
definitions from Example 1, while Bob can have any form. By applying a (COM) rule, we could have
Alice |Seller 0.2Alice3|Seller2{0195014766/ISBN}
In order to illustrate the evolution of P, we need to add also Bob to the above reduction. Notice that
during this step Bob is not able to interact neither with Alice nor with Seller. This is done by using the
rule (PAR1), and so obtaining P 0.2Alice3|Seller2{0195014766/ISBN} | Bob .
Example 3 (cont.).Let us consider an instance of the two-buyers-seller protocol in which Alice wants
to buy one of the following two books:
Title: “War and Peace” / ISBN: 0140447938;
Title: “The Art of War” / ISBN: 0195014766.
Firstly, Alice sends to Sellera book identifier (title or ISBN), namely with probability 0.3the book title
“War and Peace”, with probability 0.5the book title “The Art of War”, and with probability 0.2the ISBN
0195014766 of the latter book. Then Alice waits for Seller to send a quote to both her and Bob. Alice
tells Bob how much she can contribute (based on certain probabilities and the book she actually wants).
For example, for the book “War and Peace” she is willing to participate with either quote/2or quote/3
with the same probability 0.5. We now describe formally the behaviour of Alice as a process:
Alice d e f
=a[3](ab,as,bs).
0.3 : as!hWar and Peace′′i;as?(quote :nat);
0.5 : ab!hquote/2i.P
1+0.5 : ab!hquote/3i.P
1
+0.5 : as!hThe Art of War′′ i;as?(quote :nat);
0.4 : ab!hquote/2i.P
1+0.2 : ab!hquote/3i.P
1+0.4 : ab!hquote/4i.P
1
+0.2 : as!h0195014766i;as?(quote :nat);
0.4 : ab!hquote/2i.P
1+0.2 : ab!hquote/3i.P
1+0.4 : ab!hquote/4i.P
1
Notice that the price options for the second book (searched either by title or ISBN) are the same; however,
this is just a coincidence and not a requirement in our calculus. By using probabilities, it is possible to
describe executions that may return different prices for the same title sold by the same Seller, but possibly
printed by different publishers.
Using this process (behaviour) of Alice, we can find answers to questions like:
What is the probability that Alice buys ”The Art of War“ with quote/3?
This means that Alice needs to execute
0.5 : as!hThe Art of War′′ i;as?(quote :nat);0.2 : ab!hquote/3i.P
1
with probability 0.5×0.2=0.1, or to execute
0.2 : as!h0195014766i;as?(quote :nat);0.2 : ab!hquote/3i.P
1
with probability 0.2×0.2=0.04. Thus we get:
98
Probabilities in Session Types
Answer: 0.5×0.2+0.2×0.2=0.14.
What is the most probable choice made by Alice?
Answer: ”The Art of War“ with quote/2and quote/4, with probability 0.7×0.4=0.28.
Alice is willing to contribute partially to the quote, contribution that is probabilistically chosen out of
several possibilities, depending on the book Alice intends to purchase. In process P
1, Alice may perform
the remaining transactions with Seller and Bob.
3 Global and Local Types
In what follows, the notion of probability already presented in the previous section scales up to the
global types. Since the probabilities are static, the global types just need to check if the probabilities
to execute certain actions are the desired ones. Usually session types lead to a unique description of a
distributed system by means of processes. If we would simply incorporate probabilities in the session
types as done for processes, this would be too restrictive as the slightest perturbation of the probabilities
in the processes can make the system failing the prescribed behaviour. This is why in what follows we
use probabilistic intervals in session types, allowing for several processes to be considered behavioural
equivalent by having the same type.
3.1 Global Types
The global types G,G,...presented in Table 3 describe the global behaviour of a probabilistic multiparty
session process. In what follows we use probabilistic intervals
δ
having one of the following forms
(c,d),[c,d],(c,d]or [c,d], where c,d[0,1]and cd. For simplicity, we write
δ
=c,dwith
⌊∈ {[,(}and {],)}. In what follows, we use also the addition of intervals defined as: if
δ
1=c1,d1
and
δ
2=c2,d2then
δ
1+
δ
2=min(c1+c2,1),min(d1+d2,1). If
δ
= [c,c], we use the shorthand
notation
δ
=c.
Global G ::=
iI
q
δ
iq:khSii.Gi(probValues)
pq1q:khT@pi.G(delegation)
p
iI
q
δ
iq:k{li:Gi}(probBranching)
pG,G(parallel)
p
µ
t.G(recursive)
pt(variable)
pend (end)
Sorts S ::=bool |nat |... (value types)
Table 3: Syntax of Global Types
Type
iI
q
δ
iq:khSii.Gistates that a participant qsends with a probability in the interval
δ
ia
message of type Sito a participant qthrough the channel k, and then the interactions described by Gi
take place. We assume that in each communication qqwe have q6=q, i.e. we prohibit reflexive
interactions. Type q1q:khT@pi.Gdenotes the delegation of a session channel of type T(called
local type) with role p(written as T@p). The local types are discussed in detail later.
Type
iI
q
δ
iq:k{li:Gi}says that participant qsends with a probability in the interval
δ
ione label
on channel kto another participant q. If liis sent, evolution described by type Gitakes place. Type G,G
B. Aman & G. Ciobanu
99
represents concurrent runs of processes specified by Gand G. Type
µ
t.Gis a recursive type, where type
variable tis guarded in the standard way (they only appear under some prefix). Similar to the approach
presented in [4], we overload the notation
µ
as it is easy to see from the context if it precedes a process
or a type. Type end represents the termination of a process; we identify both G,end and end,Gwith G.
In a probabilistic choice, identically behaved branches can be replaced by a single branch with a
behaviour having the sum of the probabilities of the individual branches.
Remark 1. If all the possible interactions communicate the same types (all Siare identical), all select the
same branch (all liare identical), and the continuations after communications respect the same global
type (all Giare identical), then the global systems can be simplified by using the following rules:
iI
q
δ
iq:khSii.Giis the same as q iI
δ
iq:khSi.G whenever S =Siand G =Gifor all i;
iI
q
δ
iq:k{li:Gi}is the same as q iI
δ
iq:k{li:Gi}whenever all liare equal.
This means that if iI
δ
i=1, then global types may contain only probabilities equal to 1, namely a form
similar to the global types in multiparty session types from [14]. Therefore, for the processes of this
particular type, all the results presented in [14] hold.
Example 4 (cont.).Using the previous remark, the following is a global type of the two-buyers-seller
protocol of Example 1:
Alice 0.7,0.9Seller :ashstringi.G1+Alice 0.15,0.25Seller :ashnati.G1, where
G1=Seller 1Alice :ashinti.Seller 1Bob :bshinti.
Alice 1Bob :abhinti. Bob 0.18,0.22Seller :bs{ok1:Bob 1Seller :bshstringi.
Seller 1Bob :bshdatei.end}
+Bob 0.27,0.31Seller :bs{ok2:Bob 1Seller :bshstringi.
Seller 1Bob :bshdatei.end}
+Bob 0.45,0.52Seller :bs{quit.end}.
This global type for Alice is due to the fact that even if she has different book titles that she wants
to buy, the global type only records the type of the sent value (namely a string). Also, the fact that she
behaves in a similar manner after sending the title, the global type can be reduced to a simpler form
(according to the above remark).
Example 5. Let us consider now that Alice decided that, instead of the books “War and Peace” and
“The Art of War”, she wants the books “Peter Pan” and “Robinson Crusoe”, and she is willing to pay
different amount from the quote. More exactly,
Alice de f
=a[3](ab,as,bs).
0.15 : as!hPeter Pan′′i;as?(quote :nat); 1 : ab!hquote/3i.P
1
+0.65 : as!hRobinson Crusoe′′i;as?(quote :nat); 0.35 : ab!hquote/3i.P
1+0.65 : ab!hquote/4i.P
1
+0.2 : as!h1593080115i;as?(quote :nat); 0.45 : ab!hquote/2i.P
1+0.55 : ab!hquote/4i.P
1.
It is worth mentioning that the two-buyers-seller protocol in which Alice is described by this definition
is well-typed using the same global type (the one from Example 4) as the initial protocol of Example 1.
Therefore, several different processes may have the same global type.
3.2 Local Types
Local types T,T,... presented in Table 4 describe the local behaviour of processes, acting as a link
between global types and processes.
100
Probabilities in Session Types
Local T ::=
iI
δ
i:k!hSii.Ti(send)
p
iI
k?(Si).Ti(receive)
pk!hT@qi.T(sessionDelegation)
pk?(T@q).T(sessionReceive)
pk {
δ
i:(li:Ti)}iI(selection)
pk&{li:Ti}iI(branching)
p
µ
t.T(recursive)
pt(variable)
pend (end)
Sorts S ::=bool |nat |... (value types)
Table 4: Syntax of Local Types
Type
iI
δ
i:k!hSii.Tirepresents the behaviour of sending with probability in the interval
δ
ia value of
type Si, and then behaving as described by type Ti. Similarly,
iI
k?(Si).Tiis for nondeterministic receiv-
ing, and then continuing as described by local type Ti. The type k!hT@qi.Trepresents the behaviour
of delegating a session of type T@q, while k?(T@q).Tdescribes the behaviour of receiving a session
of type T@q. Type k {
δ
i:(li:Ti)}iIdescribes a branching: it waits for |I|options, and behaves as
type Tiif the i-th label is selected with probability in the interval
δ
i. Type k&{li:Ti}iIrepresents the
behaviour which nondeterministically selects one of the tags (say li), and then behaves as Ti. The rest is
the same as for the global types, demanding type variables to occur guarded by a prefix. For simplicity,
as done in [14], the local types do not contain the parallel composition.
Example 6. The following is a local type for the process Alice presented in Example 3:
0.7,0.9:as!hstringi.as?(int).1 : ab!hinti.T1+0.15,0.25:as!hnati.as?(int).1 : ab!hinti.T1,
where T1is the local type of process P
1from the definition of Alice.
We define the projection of a global type to a local type for each participant.
Definition 1. The projection for a participant q appearing in a global type G, written G q, is inductively
given as:
(q11q2:khT@pi.G)q=
k!hT@pi.(Gq)if q =q16=q2
k?(T@p).(Gq)if q =q26=q1
Gq if q 6=q1and q 6=q2
;
(
iI
q1
δ
iq2:khSii.Gi)q=
iI
δ
i:k!hSii.(Giq)if q =q16=q2
iI
k?(Si).(Giq)if q =q26=q1
G1q if q 6=q1and q 6=q2
i,jJ,Giq=Gjq
;
(
iI
q1
δ
iq2:k{li:Gi})q=
k {
δ
i:(li:Giq)}iIif q =q16=q2
k&{li:Giq}iIif q =q26=q1
G1q if q 6=q1and q 6=q2
i,jJ,Giq=Gjq
;
B. Aman & G. Ciobanu
101
(G1,G2)q=(Giq if q Giand q /Gj,i6=j {1,2}
end if q /G1and q /G2
;
(
µ
t.G)q=(
µ
t.(Gq)if G q6=end or G q6=t
end otherwise ;
tq=tend q=end.
When none of the side conditions hold, the projection is undefined.
Remark 2. Regarding the check of linear usage of channels, the verification is similar to the one per-
formed in [14], noting that the probabilistic and nondeterministic choices are treated similar to the
branching in [14]. However, due to the use of synchronous communications, the sequence of interactions
follows more strictly the one of the global behaviour description, resulting in a simpler linear property
than in [14]. It should be said that in the branching clause, the projections of those participants different
from q1and q2should generate an identical local type (otherwise undefined).
Hereafter we assume that global types are well-formed, i.e. Gqis defined for all qoccurring in G.
4 Probabilistic Multiparty Session Types
We introduce a typing system with the purpose of typing efficiently the probabilistic behaviours of our
processes. This typing system uses a map from shared names to either their sorts (S,S,...), or to a
special sort hGiused to type sessions. Since a type is inferred for each participant, we use notation T@q
(called located type) to represent a local type Tassigned to a participant q. Using these, we define
Γ::=/0 |Γ,x:S|Γ,a:hGi | Γ,X: ::=/0 |,˜s:{T@q}qI.
A sorting (Γ,Γ,...)is a finite map from names to sorts, and from process variables to sequences of
sorts and types. Typing (,,...)records linear usage of session channels by assigning a family of
located types to a vector of session channels. pid(G)stands for the set of participants occurring in G,
while sid(G)stands for the number of session channels in G. We write ˜s:T@qfor a singleton typing
˜s:{T@q}. Given two typings and , their disjoint union is denoted by ,(by assuming that their
domains contain disjoint sets of session channels).
The type assignment system for processes is given in Table 5. We use the judgement ΓPsaying
that “under the environment Γ, process Phas typing ”. The rules (TNAME),(TBOOL) and (TOR) are for
typing names and expressions. The rules (T MCAST) and (TMAC C) are for typing the session request and
session accept, respectively. The type for ˜sis the projection on participant qof the declared global type G
for ain Γ. It could be noticed that in rule (TMCAS T) the projection is made on the participant requesting
the session, while in (TMACC) the projection is made for each of the (n1)accepting participants. The
local type (Gq)@qmeans that the participant qhas Gq(namely the projection of Gonto q) as its
local type. The condition |˜s|=sid(G)ensures that the number of session channels meets those in G.
The rules (TSEND) and (TREC EIVE) are for sending and receiving values, respectively. As these
rules require probabilistic and nondeterministic choices, the rules should check all the possible choices
with respect to Γ. Since one of the channels appearing in ˜s(say k) is used for communication, we
record kby using the name s[k]as part of the typed process. In both rules, qin ˜s:Ti@qensures that each
P
irepresents (being inferred as) the behaviour for participant q, and its domain should be ˜s. Then the
relevant type prefixes
iI
δ
i:k!h˜
Sii;Ti@qfor the output and
iI
k?(˜
Si);Ti@qfor the input are composed in
the session environment (as conclusion). The rules (TSDELEG) and (T SRECEI VE) are for delegation of
102
Probabilities in Session Types
Γ,x:Sx:SΓtrue,false :bool (TNA ME), (TBOOL)
end only
Γ0
Γei:bool
Γe1or e2:bool (TEND ), (TOR)
Γa:hGiΓP,˜s:(G1)@1 {1,...,n}=pid(G)|˜s|=sid(G)
Γa[n]( ˜s).P(TMCAST)
Γa:hGiΓP,˜s:(Gq)@q q pid(G)q6=1|˜s|=sid(G)
Γa[q]( ˜s).P(TMAC CEP T)
i.Γ˜ei:˜
Sii.ΓP
i,˜s:Ti@qiIpi=1pi
δ
i
Γ
iI
pi:s[k]!h˜eii;P
i,˜s:
iI
δ
i:k!h˜
Sii;Ti@q(TSEND)
i.Γ,˜xi:˜
SiP
i,˜s:Ti@q
Γ
iI
s[k]?(˜xi:˜
Si);P
i,˜s:
iI
k?(˜
Si);Ti@q(TRECE IVE)
ΓP,˜s:T@q
Γs[k]!hh˜
tii;P,˜s:k!h˜
T@qi;T@q,˜
t:T@q(TSDELEG)
ΓP,˜s:T@q,˜
t:T@q
Γs[k]?((˜
t));P,˜s:k?(T@q);T@q(TSRECE IV E)
i.ΓP
i,˜s:Ti@qiIpi=1pi
δ
i
Γ
iI
pi:s[k]li;P
i,˜s:k {
δ
i:(li:Ti)}iI@q(TSELECT)
j.ΓPj,˜s:Tj@q
Γs[k]{lj;Pj}jJ,˜s:k&{lj:Tj}jJ@q(TBR ANC H)
ΓP Γ Q
ΓP|Q,
Γebool ΓP Γ Q
Γif ethen Pelse Q(TCONC), (TIF)
Γ,a:hGi P
Γ(
ν
a)P
ΓP,˜s:{Ti@i}iI
Γ(
ν
˜s)P(TNRES), (TCRES)
end only
Γ,X:X,
Γ,X:P
Γ
µ
X.P(TVAR), (TREC)
Table 5: Typing System
a session and its dual. They are similar to the rules (TSEN D) and (TRECE IV E), except that here a vector
of session channels is communicated instead of values. The carried type Tis located, making sure that
the receiver takes the role of a specific participant (here q) in the delegated multiparty session. It should
be noticed that in rule (TSDELEG) the type of ˜
t:T@qdoes not appear in the type of P, while it appears
in rule (TSREC EIV E) meaning that it uses the channels of P. The rules (TSELECT) and (TBR ANC H)
are for typing selection and branching, respectively. Similar to (TSEND) and (TR ECE IVE), these rules
employ probabilistic and nondeterministic choices, respectively. This means that the rules should check
all the possible choices with respect to Γ.
The rule (TCONC) composes two processes if their local types are disjoint. The rules (TIF), (TEND),
(TR EC) and (T VAR) are standard. The rules (TN RES) and (TCRES) represent the restriction rules for
shared names and channel names, respectively. In (TEN D), end only means that contains only end
types.
As processes interact, their dynamics is formalized as in [14] by a reduction relation on typing :
B. Aman & G. Ciobanu
103
˜s:{
iI
δ
i:k!h˜
Sii;Ti@q1,
jJ
k?(˜
Sj);Tj@q2}
δ
k1
˜s:{Tk1@q1,Tk2@q2,...}, for k1I,k2Jand Sk1=Sk2;
˜s:{k!hT@qi;T@q,, k?(T@q);T′′@q′′} 1˜s:{T@q,T′′ @q′′}
˜s:{k {
δ
i:(li:Ti)}iI@q1,k&{lj:Tj}jJ@q2,...}
δ
k1
˜s:{Tk1@q1,Tk2@q2,...}, for k1I,k2Jand Sk1=Sk2;
,p,′′ if p′′.
The first rule corresponds to sending/receiving a value of type ˜
Sjby the participant q, while the second
rule corresponds to session delegation. The third rule illustrates the choice and reception of a label ljby
the participant q. The last rule is used to compose typings when only a part of a typing changes.
We present two basic properties of our type system: substitution and weakening. The substitution
plays a central role in proving type preservation, while weakening allows introducing new entries in a
typing.
Lemma 1.
(1) (substitution) Γ,˜x:SPand Γ˜v:S imply ΓP{˜v/˜x}.
(2) (type weakening) Whenever ΓPis derivable, then its weakening is also derivable,
namely ΓP,for disjoint , where contains only end.
Proof. The proof is rather standard, similar to that presented in [14].
We now prove that our probabilistic typing system is sound, namely its type-checking rules prove
only terms that are valid with respect to both structural congruence and operational semantics. In what
follows, by inverting a rule we describe how the (sub)processes of a well-typed process can be typed.
This is a basic property that is used in some papers when reasoning by induction on the structure of
processes (see [4] and [14], for instance).
Theorem 1 (type preservation under equivalence).ΓPand P Pimply ΓP.
Proof. The proof is by induction on , showing (in both ways) that if one side has a typing, then the
other side has the same typing.
Case P|0P.
Assume ΓP|0. By inverting the rule (TCONC), we obtain ΓP1and Γ02,
where 1,2=. By inverting the rule (TEND), 2is only end and 2is such that dom(1)
dom(2) = /0. Then, by weakening, we get that ΓP, where =1,2.
Assume ΓP. By rule (TEN D), it holds that Γ0, where is only end and dom()
dom() = /0. By applying rule (TCONC), we obtain ΓP|0,, and for =/0 we obtain
ΓP|0, as required.
The remaining cases are proved in a similar manner.
According to the following theorem, if a well-typed process takes a reduction step of any kind, the
resulting process is also well-typed.
Theorem 2 (type preservation under reduction).
ΓPand P piPimply ΓP, where =or
δ
iwith pi
δ
i.
104
Probabilities in Session Types
Proof. By induction on the derivation of PpiP. There is a case for each operational semantics rule,
and for each operational semantics rule we consider each typing system rule generating ΓP.
Case (COM ):
iI
pi:s!h˜eii;P
i|
jJ
s?(˜xj);PjpiP
i|Pj{˜vi/˜xj}.
By assumption, Γ
iI
pi:s!h˜eii;P
i|
jJ
s?(˜xj);Pj. By inverting the rule (TCONC), we get
Γ
iI
pi:s!h˜eii;P
i1,Γ
jJ
s?(˜xj);Pj2with =1,2. Since these can be inferred only
from (TSE ND) and (TR ECE IVE ), we know that 1=
1,˜s:
iI
δ
i:k!h˜
Sii;Ti@q1and 2=
2,˜s:
jJ
k?h˜
Sji;Tj@q2. By inverting the rules (T SEN D ) and (TREC EIV E), we get that i.Γ˜ei:˜
Si,
iIpi=1, pi
δ
i,i.ΓP
i
1,˜s:Ti@q1and j.Γ,˜xj:˜
SjPj
2,˜s:Tj@q2. Assuming that
eiviand knowing that i.Γ˜ei:˜
Si, it implies that i.Γ˜vi:˜
Si. From Γ˜vi:˜
Siand Γ,˜xj:˜
Sj
Pj
2,˜s:Tj@q2, by applying the substitution part of Lemma 1, we get that ΓPj{vi/xj}
2,˜s:
Tj@q2. By applying the rule (TCONC), we get ΓP
i|Pj{vi/xj}
1,˜s:Ti@q1,
2,˜s:Tj@q2.
Using the reduction on types, we get
δ
i, where =
1,˜s:Ti@q1,
2,˜s:Tj@q2and pi
δ
i.
Case (DELEG): s!hh ˜sii;P|s?(( ˜s));Q1P|Q.
By assumption, Γs!hh ˜sii;P|s?(( ˜s));Q. By inverting the rule (TCONC), we get that Γ
s!hh ˜sii;P1,Γs?(( ˜s));Q2with =1,2. Since these can be inferred only from (TS DE-
LEG) and (TSRECEIVE ), we know that 1=
1,˜s:k!h˜
T@qi;T@q,˜
t:T@qand 2=
2,˜s:
k?(T@q);T′′@q′′. By inverting the rules (TSDELEG) and (TS REC EIV E), we get that Γ
P
1,˜s:T@qand ΓQ
2,˜s:T′′@q′′,˜
t:T@q. By applying the rule (TCONC), we get
ΓP|Q
1,˜s:T@q,
2,˜s:T′′@q,˜
t:T@q′′. By using the reduction on types, we get that
1, where =
1,˜s:T@q,
2,˜s:T′′@q′′ ,˜
t:T@q.
The remaining cases are proved in a similar manner.
A corollary of the type preservation result is the probabilistic-error freedom. An error is reached
when a process performs an action that violates the constraints prescribed by its type. To formulate
this property of probabilistic-error freedom, we extend the syntax by including a process error, while
the reduction rules for processes are extended as below. This is done to accommodate the fact that the
processes with value sending and label selection in which the sum of all probabilities is different from 1
generate an error.
iI
pi:s!h˜eii;P
i|
jJ
s?(˜xj:˜
Sj);Pj1error (if
iI
pi6=1) (ECOM)
iI
pi:sli;P
i|s{lj:Pj}jJ1error (if
iI
pi6=1) (ELABE L)
Table 6: Extending Operational Semantics with Rules for error
Theorem 3 (probabilistic-error freedom).If ΓPand P piP, then P6=error.
Proof. We assume that P6=error, and proceed by case analysis on the reduction PpiP. If the last
reduction is by one of the rules of Table 2 then P6=error since these rules do not introduce error
processes. Also, by using Theorem 2, we are able to show that ΓPfor some (obtained by some
reduction from ).
B. Aman & G. Ciobanu
105
The only reductions introducing error processes are provided by the rules of Table 6. We consider
only one case (as the other is treated in a similar manner). Consider the rule (ECOM) applied to Phaving
the form
iI
pi:s!h˜eii;P
i|
jJ
s?(˜xj:˜
Sj);Pj. Then by (EC O M) we have
iI
pi6=1. By hypothesis, Pis
well-typed. By using the typing rules (TSEND) and (TREC EI VE) of Table 5, process Pcan be typed by
using the condition
iI
pi=1 which contradicts the fact that rule (ECOM) can be applied. The fact that
none of the reductions introducing errors can be applied means that the result holds.
By the correspondence between local types and global types given in Section 3.2, these results guar-
antee that interactions between typed processes follow exactly the interactions specified in a global type.
5 Conclusion
We have defined and studied a typing system extending the (synchronous version of) multiparty ses-
sion types to deal also with probabilistic and nondeterministic choices. We proposed a process calculus
considering both the probabilistic internal choices (sending a value and selecting a label) with the non-
deterministic external choices (receiving a value and branching a process by using a selected value). We
used a system inspired from the synchronous calculus presented in [3], but avoiding the use (and typing)
of queues presented in [3]. The calculus from [3] has been modified in [6] and [17] by using channels
with roles, and so eliminating the need to use the notation T@qfor delegation. However, we feel that
this notation for delegation makes the rules easier to read; thus, we keep it in our typing system.
The approach presented in this paper has attractive properties and features. It retains the classical
approach (type system), and it is specified in such a way to satisfy the axioms of a standard probability
theory for computing the probability of a behaviour. As far as we know, in the field of session types there
is no other related work.
Several formal tools have been proposed for probabilistic reasoning. Some approaches concern the
use of probabilistic logics. In [5], terms are assigned probabilistically to types via probabilistic type
judgements, and from an intuitionistic typing system is derived a probabilistic logic as a subsytem [21].
In [20] there are proposed two semantics of a probabilistic variant of the
π
-calculus. For these, the
types are used to identify a class of nondeterministic probabilistic behaviours which can preserve the
compositionality of the parallel operator in the framework of event structures. The authors claim to per-
form an initial step towards a good typing discipline for probabilistic name passing by employing Segala
automata [18] and probabilistic event structures. In comparison with them, we simplify the approach and
work directly with processes, giving a probabilistic typing in the context of multiparty session types.
References
[1] A. Aldini & M. Bravetti (2000): An Asynchronous Calculus for Generative-Reactive Probabilistic Systems.
Technical Report UBLCS-2000-3, University of Bologna. Available at https://disi.unibo.it/it/
ricerca/technical-report/2000/pdfs/2000-03.ps.gz.
[2] S. Andova (1999): Process Algebra with Probabilistic Choice. In:
Formal Methods for Real-Time and
Probabilistic Systems, 5th International AMAST Workshop, ARTS’99, Bamberg, Germany, May 26-28,
1999. Proceedings
, pp. 111–129, doi:10.1007/3-540-48778-6_7.
[3] A. Bejleri & N. Yoshida (2009): Synchronous Multiparty Session Types.
Electronic Notes in Theoretical
Computer Science
241, pp. 3–33, doi:10.1016/j.entcs.2009.06.002.
106
Probabilities in Session Types
[4] L. Bocchi, W. Yang & N. Yoshida (2014): Timed Multiparty Session Types. In:
CONCUR 2014 - Concur-
rency Theory - 25th International Conference, Rome, Italy, September 2-5, 2014. Proceedings
, pp. 419–434,
doi:10.1007/978-3- 662- 44584- 6_29.
[5] R. Cooper, S. Dobnik, S. Lappin & S. Larsson (2014): A Probabilistic Rich Type Theory for Semantic Inter-
pretation. In:
Proceedings of the EACL 2014 Workshop on Type Theory and Natural Language Semantics
(TTNLS)
, Association for Computational Linguistics, Gothenburg, Sweden, pp. 72–79, doi:10.3115/v1/
W14-1409.
[6] M. Coppo, M. Dezani-Ciancaglini, N. Yoshida & L. Padovani (2016): Global Progress for Dynamically
Interleaved Multiparty Sessions.
Mathematical Structures in Computer Science
26(2), pp. 238–302, doi:10.
1017/S0960129514000188.
[7] Y. Deng (2015): Semantics of Probabilistic Processes: An Operational Approach. Springer Publishing
Company, Incorporated, doi:10.1007/978-3-662-45198-4.
[8] R. J. van Glabbeek, S. A. Smolka & B. Steffen (1995): Reactive, Generative and Stratified Models of Proba-
bilistic Processes.
Information and Computation
121(1), pp. 59–80, doi:10.1006/inco.1995.1123.
[9] J. Y. Halpern (2003): Reasoning About Uncertainty. MIT Press, Cambridge, MA, USA.
[10] H. A. Hansson (1994): Time and Probability in Formal Design of Distributed Systems. Elsevier Science Inc.,
New York, NY, USA.
[11] O. M. Herescu & C. Palamidessi (2000): Probabilistic Asynchronous
π
-Calculus. In:
Foundations of Soft-
ware Science and Computation Structures, Third International Conference, FOSSACS 2000, Held as Part of
the Joint European Conferences on Theory and Practice of Software,ETAPS 2000, Berlin, Germany, March
25 - April 2, 2000, Proceedings
, pp. 146–160, doi:10.1007/3-540-46432-8_10.
[12] J. Hillston (1996): A Compositional Approach to Performance Modelling. Cambridge University Press, New
York, NY, USA, doi:10.1017/CBO9780511569951.
[13] K. Honda (1993): Types for Dyadic Interaction. In:
CONCUR ’93, 4th International Conference on Con-
currency Theory, Hildesheim, Germany, August 23-26, 1993, Proceedings
, pp. 509–523, doi:10.1007/
3-540- 57208- 2_35.
[14] K. Honda, N. Yoshida & M. Carbone (2016): Multiparty Asynchronous Session Types.
Journal of the ACM
63(1), pp. 9:1–9:67, doi:10.1145/2827695.
[15] G. Lowe (1993): Probabilities and Priorities in Timed CSP. Ph.D. thesis, University of Oxford, UK. Avail-
able at http://ora.ox.ac.uk/objects/uuid:cfec28d9-aa50-46f3-a664-eb5fbe97b261.
[16] R. Milner (1999): Communicating and Mobile Systems - the
π
-calculus. Cambridge University Press.
[17] A. Scalas, O. Dardha, R. Hu & N. Yoshida (2017): A Linear Decomposition of Multiparty Sessions for Safe
Distributed Programming. In:
31st European Conference on Object-Oriented Programming, ECOOP 2017,
June 19-23, 2017, Barcelona, Spain
, pp. 24:1–24:31, doi:10.4230/LIPIcs.ECOOP.2017.24.
[18] R. Segala & N. A. Lynch (1995): Probabilistic Simulations for Probabilistic Processes.
Nordic Journal of
Computing
2(2), pp. 250–273.
[19] K. Takeuchi, K. Honda & M. Kubo (1994): An Interaction-based Language and its Typing System. In:
PARLE ’94: Parallel Architectures and Languages Europe, 6th International PARLE Conference, Athens,
Greece, July 4-8, 1994, Proceedings
, pp. 398–413, doi:10.1007/3-540-58184-7_118.
[20] D. Varacca & N. Yoshida (2007): Probabilistic
π
-Calculus and Event Structures.
Electronic Notes in Theo-
retical Computer Science
190(3), pp. 147–166, doi:10.1016/j.entcs.2007.07.009.
[21] J. H. Warrell (2016): A Probabilistic Dependent Type System based on Non-Deterministic Beta Reduction.
CoRR
abs/1602.06420. Available at http://arxiv.org/abs/1602.06420.
... The use of a probabilistic approach can be more realistic and helpful in analyzing the communication-centric systems. The use of probabilities in session types was presented recently in some articles [8][9][10][11][12][13][14]. ...
... Regarding the use of probabilities in session types, there are only a few articles to mention. According to the authors of a recent article [14]: "To the best of our knowledge, Aman and Ciobanu [8,19] are the only ones who studied the concept of choreography and probabilities". In [9], other authors present a probabilistic variant of binary session types by enriching the type system with fixed probabilities. ...
Article
Full-text available
In this article, we introduce and study a new kind of multiparty session type for a probabilistic process calculus that incorporates two forms of choice: probabilistic and nondeterministic. The main novelty of our approach is the use of interval probabilities in a type system in order to deal with uncertainty in a probabilistic process calculus. We present a decidable proof system that ensures deadlock freedom, type preservation and type safety, even when several types can be assigned to a process. The new typing system represents a conservative extension of the standard typing system based on multiparty session types (removing the probabilities from processes does not affect their well-typedness). We also define a probabilistic bisimulation between processes that are typed by using the same sorting and typing.
... Nevertheless, there is a scarcity of research on probabilistic aspects of choreographic programming. To the best of our knowledge, Aman and Ciobanu [4,5] are the only ones who studied the concept of choreography and probabilities. Their work augments multiparty session types (type abstractions for communicating systems that use the concept of choreography) with a probabilistic internal choice similar to the one used by our choreographic branching. ...
Preprint
Full-text available
We present a choreographic framework for modelling and analysing concurrent probabilistic systems based on the PRISM model-checker. This is achieved through the development of a choreography language, which is a specification language that allows to describe the desired interactions within a concurrent system from a global viewpoint. Using choreographies gives a clear and complete view of system interactions, making it easier to understand the process flow and identify potential errors, which helps ensure correct execution and improves system reliability. We equip our language with a probabilistic semantics and then define a formal encoding into the PRISM language and discuss its correctness. Properties of programs written in our choreographic language can be model-checked by the PRISM model-checker via their translation into the PRISM language. Finally, we implement a compiler for our language and demonstrate its practical applicability via examples drawn from the use cases featured in the PRISM website.
... Another very interesting line of work is the one about imperative calculi, like the one on which tools like EasyCrypt are based [7,6]. Recently, there have been attempts at incepting some form of probabilistic behaviour into session types, either by allowing for probabilistic internal choice in multiparty sessions [4], or by enriching the type system itself, by making it quantitative in nature [31]. The system πDIBLL is certainly more similar to the former, in that randomization does not affect the type structure but only the process structure. ...
Preprint
Full-text available
A system of session types is introduced as induced by a Curry Howard correspondence applied to Bounded Linear Logic, and then extending the thus obtained type system with probabilistic choices and ground types. The obtained system satisfies the expected properties, like subject reduction and progress, but also unexpected ones, like a polynomial bound on the time needed to reduce processes. This makes the system suitable for modelling experiments and proofs from the so-called computational model of cryptography.
Article
Session types provide a formal type system to define and verify communication protocols between message-passing processes. In order to analyze randomized systems, recent works have extended session types with probabilistic type constructors. Unfortunately, all the proposed extensions only support constant probabilities which limits their applicability to real-world systems. Our work addresses this limitation by introducing probabilistic refinement session types which enable symbolic reasoning for concurrent probabilistic systems in a core calculus we call PReST. The type system is carefully designed to be a conservative extension of refinement session types and supports both probabilistic and regular choice type operators. We also implement PReST in a prototype which we use for validating probabilistic concurrent programs. The added expressive power leads to significant challenges, both in the meta theory and implementation of PReST, particularly with type checking: it requires reconstructing intermediate types for channels when type checking probabilistic branching expressions. The theory handles this by semantically quantifying refinement variables in probabilistic typing rules, a deviation from standard refinement type systems. The implementation relies on a bi-directional type checker that uses an SMT solver to reconstruct the intermediate types minimizing annotation overhead and increasing usability. To guarantee that probabilistic processes are almost-surely terminating, we integrate cost analysis into our type system to obtain expected upper bounds on recursion depth. We evaluate PReST on a wide variety of benchmarks from 4 categories: (i) randomized distributed protocols such as Itai and Rodeh's leader election, bounded retransmission, etc., (ii) parametric Markov chains such as random walks, (iii) probabilistic analysis of concurrent data structures such as queues, and (iv) distributions obtained by composing uniform distributions using operators like max, and sum. Our experiments show that the PReST type checker scales to large programs with sophisticated probabilistic distributions.
Article
Session types guarantee that message-passing processes adhere to predefined communication protocols. Prior work on session types has focused on deterministic languages but many message-passing systems, such as Markov chains and randomized distributed algorithms, are probabilistic. To implement and analyze such systems, this article develops the meta theory of probabilistic session types with an application focus on automatic expected resource analysis. Probabilistic session types describe probability distributions over messages and are a conservative extension of intuitionistic (binary) session types. To send on a probabilistic channel, processes have to utilize internal randomness from a probabilistic branching or external randomness from receiving on a probabilistic channel. The analysis for expected resource bounds is smoothly integrated with the type system and is a variant of automatic amortized resource analysis. Type inference relies on linear constraint solving to automatically derive symbolic bounds for various cost metrics. The technical contributions include the meta theory that is based on a novel nested multiverse semantics and a type-reconstruction algorithm that allows flexible mixing of different sources of randomness without burdening the programmer with complex type annotations. The type system has been implemented in the language NomosPro with linear-time type checking. Experiments demonstrate that NomosPro is applicable in different domains such as cost analysis of randomized distributed algorithms, analysis of Markov chains, probabilistic analysis of amortized data structures and digital contracts. NomosPro is also shown to be scalable by (i) implementing two broadcast and a bounded retransmission protocol where messages are dropped with a fixed probability, and (ii) verifying the limiting distribution of a Markov chain with 64 states and 420 transitions.
Chapter
We propose a typing system based on multiparty session types and probabilistic interactions. We define a probabilistic process calculus using nondeterministic external choices and probabilistic internal choices. Interval probability (a generalization of traditional probability using pairs of lower and upper probabilities) are used for global and local types. We introduce a decidable proof system involving interval probability to represent and quantify the uncertain behaviour of concurrent processes. This proof system ensures type preservation and safety, even when the use of probabilities allows a process to be considered well-typed for several types. Additionally, processes remain well-typed after removing their probabilities.
Preprint
Session types guarantee that message-passing processes adhere to predefined communication protocols. Prior work on session types has focused on deterministic languages but many message-passing systems, such as Markov chains and randomized distributed algorithms, are probabilistic. To model and analyze such systems, this article introduces probabilistic session types and explores their application in automatic expected resource analysis. Probabilistic session types describe probability distributions over messages and are a conservative extension of intuitionistic (binary) session types. To send on a probabilistic channel, processes have to utilize internal randomness from a probabilistic branching expression or external randomness from receiving on a probabilistic channel. The analysis for expected resource bounds is integrated with the type system and is a variant of automatic amortized resource analysis. It can automatically derive symbolic bounds for different cost metrics by reducing type inference to linear constraint solving. The technical contributions include the meta theory that is based on a novel nested multiverse semantics and a type-reconstruction algorithm that allows flexible mixing of different sources of randomness without burdening the programmer with type annotations. The type system has been implemented in the language PRast. Experiments demonstrate that PRast is applicable in different domains such as resource analysis of randomized distributed algorithms, verification of limiting distributions in Markov chains, and analysis of probabilistic digital contracts.
Article
Full-text available
A multiparty session forms a unit of structured communication among many participants which follow communication sequences specified as a global type. When a process is engaged in two or more sessions simultaneously, different sessions can be interleaved and can interfere at runtime. Previous work on multiparty session types has ignored session interleaving, providing a limited progress property ensured only within a single session, by assuming non-interference among different sessions and by forbidding delegation. This paper develops, besides a more traditional, compositional communication type system, a novel static interaction type system for global progress in dynamically interleaved and interfered multiparty sessions. The interaction type system infers causalities of channels making sure that processes do not get stuck at intermediate stages of sessions also in presence of delegation.
Book
Full-text available
This book discusses the semantic foundations of concurrent systems with nondeterministic and probabilistic behaviour. Particular attention is given to clarifying the relationship between testing and simulation semantics and characterising bisimulations from metric, logical, and algorithmic perspectives. Besides presenting recent research outcomes in probabilistic concurrency theory, the book exemplifies the use of many mathematical techniques to solve problems in computer science, which is intended to be accessible to postgraduate students in Computer Science and Mathematics. It can also be used by researchers and practitioners either for advanced study or for technical reference.
Conference Paper
Full-text available
We propose a typing theory, based on multiparty session types, for modular verification of real-time choreographic interactions. To model real-time implementations, we introduce a simple calculus with delays and a decidable static proof system. The proof system ensures type safety and time-error freedom, namely processes respect the prescribed timing and causalities between interactions. A decidable condition on timed global types guarantees time-progress for validated processes with delays, and gives a sound and complete characterisation of a new class of CTAs with general topologies that enjoys progress and liveness.
Article
Full-text available
We introduce three models of probabilistic processes, namely, reactive, generative, and stratified. These models are investigated within the context of PCCS, an extension of Milner′s SCCS in which each summand of a process summation expression is guarded by a probability and the sum of these probabilities is 1. For each model, we present a structural operational semantics of PCCS and a notion of bisimulation equivalence which we prove to be a congruence. We also show that the models form a hierarchy: the reactive model is derivable from the generative model by abstraction from the relative probabilities of different actions, and the generative model is derivable from the stratified model by abstraction from the purely probabilistic branching structure. Moreover, the classical nonprobabilistic model is derivable from each of these models by abstraction from all probabilities.
Conference Paper
Full-text available
We propose an extension of the asynchronous π-calculus with a notion of random choice. We define an operational semantics which distinguishes between probabilistic choice, made internally by the process, and nondeterministic choice, made externally by an adversary scheduler. This distinction will allow us to reason about the probabilistic correctness of algorithms under certain schedulers. We show that in this language we can solve the electoral problem, which was proved not possible in the asynchronous π-calculus. Finally, we show an implementation of the probabilistic asynchronous π-calculus in a Java-like language.
Conference Paper
Several probabilistic simulation relations for probabilistic systems are defined and evaluated according to two criteria: compositionality and preservation of “interesting” properties. Here, the interesting properties of a system are identified with those that are expressible in an untimed version of the Timed Probabilistic concurrent Computation Tree Logic (TPCTL) of Hansson. The definitions are made, and the evaluations carried out, in terms of a general labeled transition system model for concurrent probabilistic computation. The results cover weak simulations, which abstract from internal computation, as well as strong simulations, which do not.
Article
Communication is a central elements in software development. As a potential typed foundation for structured communication-centered programming, session types have been studied over the past decade for a wide range of process calculi and programming languages, focusing on binary (two-party) sessions. This work extends the foregoing theories of binary session types to multiparty, asynchronous sessions, which often arise in practical communication-centered applications. Presented as a typed calculus for mobile processes, the theory introduces a new notion of types in which interactions involving multiple peers are directly abstracted as a global scenario. Global types retain the friendly type syntax of binary session types while specifying dependencies and capturing complex causal chains of multiparty asynchronous interactions. A global type plays the role ofashared agreement among communication peers and isusedas a basis of efficient type-checking through its projection onto individual peers. The fundamental properties of the session type discipline, such as communication safety, progress, and session fidelity, are established for general n-party asynchronous interactions.
Article
We introduce Probabilistic Dependent Type Systems (PDTS) via a functional language based on a subsystem of intuitionistic type theory including dependent sums and products, which is expanded to include stochastic functions. We provide a sampling-based semantics for the language based on non-deterministic beta reduction. Further, we derive a probabilistic logic from the PDTS introduced as a direct result of the Curry-Howard isomorphism. The probabilistic logic derived is shown to provide a universal representation for finite discrete distributions.