[20pt] A note on two notions of compliance

A note on two notions of compliance
Massimo Bartoletti
University of Cagliari — BETTY COST Action
(joint work with T. Cimoli and G.M. Pinna)
Contracts
Many theories of contract for reactive systems:
I (Bravetti, Zavattaro)+
I Carpineti & Laneve,
I (Castagna, Gesbert, Padovani)+
I van der Aalst et al.
I ...
...each with different notions of:
I compliance / agreement
I subcontract / refinement
Goal: find a common semantic model:
concurrent multi-party games
Contract without games
tb
tb0
sb∗
sb
sb 0
ta
ta 0
sa∗
sa
A’s goal: consume a token at sb
B’s goal: have a token at sa
sa 0
Contracts without games
tb0
tb
sb∗
sb
sb 0
ta0
ta
sa∗
sa
sa 0
tb
sa∗ , sb
ta
sa∗ , sb∗
tb0
sa
ta
sa , sb 0
ta0
sb , sa 0
sa∗ , sb , sb0
Neither A nor B reach their goals
Contracts as multi-player games
tb
tb0
sb∗
sb
sb 0
ta
ta 0
sa∗
sa
A’s goal: consume a token at sb
B’s goal: have a token at sa
sa 0
Contracts as multi-player games
tb0
tb
sb∗
sb
sb 0
ta0
ta
sa∗
sa
sa 0
tb
sa∗ , sb
ta
sa∗ , sb∗
tb0
sa
ta
sa , sb 0
ta0
sb , sa 0
sa∗ , sb , sb0
A reaches her goal, B reaches his goal
A theory of agreements and protection
Contracts = Obligations + Objectives
I
Obligations = Event Structures
I
I
I
I
a set of events E ,
a conflict relation #
an enabling relation `
Objectives = functions Φ over sequences of events
Example:
I A’s obligations: ∅ ` a
I B’s obligations: {a} ` b
, if b ∈ σ
, if a ∈ σ
/ if a ∈ σ, b 6∈ σ
/ if b ∈ σ, a 6∈ σ
Contracts as games
Plays
C `e
e 6∈ C
C ∪ {e} conflict-free
e
C −−→ C ∪ {e}
Strategies
ΣA : finite plays → sets of events of A
such that:
e ∈ ΣA (σ)
=⇒
σe is a play
Winning strategies
A is innocent in σ iff:
∀i ≥ 0. ∀e of A.
e
e
σi −→ =⇒ ∃j ≥ i. σj −
6 −→
A wins in σ iff WAσ = ,, where


ΦAσ
WAσ =
/


,
if all participants are innocent in σ
if A is culpable in σ
otherwise
Σ is a winning strategy for A in C iff A wins in every fair
play of C which conforms to Σ.
Contracts as games — an example
A : ` a, ` a0 , a # a0
B : a ` b, a ` c, b # c
ΦA : , if gets b or c
/ otherwise
ΦB : , if gets a
/ otherwise
(
{a} if σ = ε
ΣA (σ) =
∅
if σ 6= ε
(
{b}
ΣB (σ) =
∅
b
a
c
∅
a’
0
{a }
A
{a, b}
{a}
{a, c}
hi
hai
ha bi
if a ∈ σ
if a ∈
6 σ
B
/
/
,
/
,
,
Agreement
A agrees on C iff
A has a winning strategy in C.
A
hi
hai
ha bi
B
/
/
,
/
,
,
Innocent strategies
A strategy ΣA for A is innocent iff:
ΣA (σ) = ∅ =⇒ A innocent in σ
The greatest innocent strategy is the eager strategy:
Σ!A (σ) = {e of A | σ ` e }
Traditionally: compliance = winning eager strategies
Session types (bi-party)
M
X
P, Q ::= 1 !ai ; Pi ?ai . Pi rec x. P x
i∈I
i∈I
Semantics
!a
!a ; P ⊕ Q →
− !a ; P
!a ; P −
→ P
?a
?a . P + Q −
→ P
P→
− P0
P kQ →
− P0 k Q
!a
?a
P−
→ P0
Q−
→ Q0
P kQ →
− P0 k Q0
Compliance in session types
P is compliant with Q iff
P | Q →∗ P 0 | Q 0 6→
implies
P0 = 0
Examples:
I
P = !a ⊕ !b
Q = ?a + ?b
I
P = !a ⊕ !b
Q = ?a.!c + ?b
I
P = rec X . !a ⊕ !b.X
Q = rec X . ?a.X + ?b.X
I
P = (!a.!c) ⊕ !b
Q = ?a + ?b
Session types as games
Def. CA (·) mapping from session types to event structures
Theorem.
P is compliant with Q
iff
the eager strategy is winning for A in CA (P) | CB (Q)
P = (!a.!c) ⊕ !b
Q = ?a + ?b
Thanks!