Graph Representation of Sessions and Pipelines for Structured Service Programming
Liang Zhao1,2
with Roberto Bruni1and Zhiming Liu2
1University of Pisa, Italy 2UNU-IIST, Macao SAR, China
FACS 2010
Zhao, et al. Graph Representation of CaSPiS 2010
Introduction
Traditional process calculi
successful in modeling concurrent systems, mobile systems modeling service systems?
Problem: low level communication primitives, complexity of analysis
Calculus of Sessions and Pipelines (CaSPiS)
Aspects: service autonomy, client-service interaction, orchestration Key notions: session (define interactions between two sides), pipeline (orchestrate the flow of data)
Sessions and pipelines can be nested.
Operational semantics: transition rules, silent transitions (reductions)
Zhao, et al. Graph Representation of CaSPiS 2010
Introduction
Motivation
hierarchical service system
S
D I
P1 s P2 P3
r
S P4
vs. textual expression: s
.
P1|
r(
s.
P2|
P3)|
rP4Zhao, et al. Graph Representation of CaSPiS 2010
Outline
1 The calculus CaSPiS Syntax
Operational semantics (reduction)
2 Algebra of hierarchical graphs Grammar and semantic model Graph transformation by DPO
3 Graph representation of CaSPiS Processes as designs
Graph transformation rules Soundness and completeness
Zhao, et al. Graph Representation of CaSPiS 2010
Outline
1 The calculus CaSPiS Syntax
Operational semantics (reduction)
2 Algebra of hierarchical graphs Grammar and semantic model Graph transformation by DPO
3 Graph representation of CaSPiS Processes as designs
Graph transformation rules Soundness and completeness
Zhao, et al. Graph Representation of CaSPiS 2010
Syntax
Syntax of CaSPiS
Process P
,
Q::=
M|
P|
Q|
s.
P|
s.
P|
rP| (ν
n)
P|
P>
Q Sum M::=
0| (?
x)
P| h
Vi
P| h
Vi
↑P|
M+
MValue V
::=
x|
cExample: P0
=
time.h
Ti|
time.(?
x)h
xi
↑ Structural Congruence(
P1|
P2)|
P3≡
c P1|(
P2|
P3)
M1+
M2≡
c M2+
M1(ν
n)
0≡
c 0r
(ν
n)
P≡
c(ν
n)(
rP) if
n6=
r. . .
Syntax Zhao, et al. Graph Representation of CaSPiS 2010
Semantics
Contexts
Dynamic operators:
(?
x)[ · ]
,[ · ] +
M, s.[ · ]
, P> [ · ]
Static contexts:[ · ]|
Q, r[·]
,(ν
x)[ · ]
,[ · ]|[ · ]
,. . .
Basic Reductions
(Sync): C
[
s.
P,
s.
Q] − → (ν
r)
C[
rP,
rQ]
(S-Sync): C
[
r(
P0|h
yiP),
r(?x)Q] − →
C[
r(
P0|
P),
rQ[y/x]](P-Sync): C
[(
P0|h
yiP) >
(?x)Q] − →
C[
Q[y/x]|((P0|
P) > (?
x)
Q)]
. . .
ExampleP0
=
time.h
Ti|
time.(?
x)h
xi
↑− →
P1= (ν
r)(
rh
Ti|
r(?
x)h
xi
↑)
− →
P2= (ν
r)(
r0|
rh
Ti
↑)
Operational semantics (reduction) Zhao, et al. Graph Representation of CaSPiS 2010
Outline
1 The calculus CaSPiS Syntax
Operational semantics (reduction)
2 Algebra of hierarchical graphs Grammar and semantic model Graph transformation by DPO
3 Graph representation of CaSPiS Processes as designs
Graph transformation rules Soundness and completeness
Zhao, et al. Graph Representation of CaSPiS 2010
Graph Grammar
Terms
Graph G
::=
0|
x|
l(~
x) |
G|
G| (ν
x)
G|
Dh~
xi
Design D::=
L~y[
G]
Free Node
Free node: not restricted or exposed Example: Ly
[(ν
x)
l(
x,
y)]h
zi
Type
Fixed Type: each node x , edges label l, design label L Well-typedness: l
(~
x)
, L~y[
G]h~
xi
Grammar and semantic model Zhao, et al. Graph Representation of CaSPiS 2010
Semantic Model
Interpretation of Terms G1
=
a(
y1)|
y2•y1 //a •y2
Order of Tentacles of (Hyper-)edges
.
•oo 1 l 2
OO
3 //
4?5?????•
.
• //l
OO //
;;
•
Grammar and semantic model Zhao, et al. Graph Representation of CaSPiS 2010
Semantic Model
Interpretation of Terms
G2
=
L(y1,y2)[
a(y1)|y2]h
x1,
x2i
• //a •
•x1
}}L11
•x2
!!L12
G3
=
L(y1,y2)[
a(y1)|y2]h
x1,
x2i |
L(y1,y2)[
y1|a(y2)]hx1,
x2i
• //a •
•x1
}}L1 1
aa
L2 1
•x2
!!L1 2
==
L2
• aoo • 2
L • //a •
•x1
>>
•x2
>>
L • aoo •
Grammar and semantic model Zhao, et al. Graph Representation of CaSPiS 2010
Semantic Model
Flat Design Edge
L(y1,y2)
[
a(
y1)|
y2]h
x1,
x2i
vs. F(y1,y2)[
a(
y1)|
y2]h
x1,
x2i
L • //a •
•x1
>>
•x2
•x1 //a •x2
Node Sharing
Kx
[
b(
x,
y)]h
zi|
Kx[
b(
x,
y)]h
zi
vs. Kx[(ν
y)
b(
x,
y)]h
zi|
Kx[(ν
y)
b(
x,
y)]h
zi
K • //b
@ @
@
•z
??
•y
K • //b
>>~~
~
K • //b //•
•z
>>
K • //b //•
Grammar and semantic model Zhao, et al. Graph Representation of CaSPiS 2010
Graph Transformation
Morphism and Pushout
Morphism: a mapping (m
:
G1− →
G2) that preserves types of nodes, labels and tentacles of edgesPushout: a square of (four) morphisms that commute
Double Pushout (DPO) Rules
R
:
GL←
mlGI→
mrGR, or simply GL|
GI|
GRGL
m1
GI
oo ml mr //
m2
GR
m3
G G00
m0l
oo m0r //G0
Direct derivation: G
⇒
RG0Derivation: a sequence of direct derivations, G
⇒
∗∆G0Graph transformation by DPO Zhao, et al. Graph Representation of CaSPiS 2010
Outline
1 The calculus CaSPiS Syntax
Operational semantics (reduction)
2 Algebra of hierarchical graphs Grammar and semantic model Graph transformation by DPO
3 Graph representation of CaSPiS Processes as designs
Graph transformation rules Soundness and completeness
Zhao, et al. Graph Representation of CaSPiS 2010
Graph Representation
Nil, Abstraction and Parallel composition
P //
• //• //Nil //
//
P .
• //• //Abs
OO //
Q ((Q QQ QQ Q • //JP K
vvmmmmmmm}}{{{
P • //JP K //
B B B
111 1111 //
• //• //Par
OO
//
• //JQK
FF | //|>>| //
J
0K J
(?x)PK J
P|QK
J
0K
def
= P
(p,i,o,t)[
i|
o|
t|
Nil(
p)]
J(?
x)
PK
def
= P
(p,i,o,t)[(ν{
p1,
x})
Abs(
p,
x,
p1,
i)| J
PKh
p1,
i,
o,
ti]
J
P|
QK
def
= P
(p,i,o,t)[(ν{
p1,
p2})
Par
(
p,
p1,
p2)| J
PKh
p1,
i,
o,
ti| J
QKh
p2,
i,
o,
ti]
Processes as designs Zhao, et al. Graph Representation of CaSPiS 2010
Graph Representation
Session and Pipeline
P S .r
• //• //• //Ses
OO //
Q ((Q QQ QQ QB B B • //JP K
}}{{{
vvmmmmmmm
""
P
• //JP K
000 0000
R
• //• //PipOO // ((
R ((R RR RR RR
""F FF
F
• //• //JQK
C!!C
C }}zzz
J
rPK J
P>QK
J
rPK
def
= P
(p,i,o,t)[
i|
t|S
(p,t)[(ν{
p1,
i1,
o1})
Ses
(
p,
r,
p1,
i1,
o1)| J
PKh
p1,
i1,
o1,
ti]h
p,
oi]
J
P>
QK
def
= P
(p,i,o,t)[(ν{
p1,
p2,
o1})
Pip(
p,
p1,
p2,
o1,
i,
o,
t)|
J
PKh
p1,
i,
o1,
ti|R
p[(ν{
i,
o,
t}) J
QKh
p,
i,
o,
ti]h
p2i]
Processes as designs Zhao, et al. Graph Representation of CaSPiS 2010
Graph Representation
An Example
D .time .T
• //• //Def
w //;;ww H$$H
H • //Con
OO //
uujjjjjjjj • //Nil
•p //Par
OO
i o t
I .
• //• //Inv
GG
//
~~}}}
• //Abs
55kk kk kk k //
uukkkkkkk • //Ret
OO //
• //Nil
BB
J
P0Kh
p,
i,
o,
ti
P0=
time.h
Ti|
time.(?
x)h
xi
↑Processes as designs Zhao, et al. Graph Representation of CaSPiS 2010
Graph Representation
Tagged Graph
A
D .time .T
• //• //Def
w //;;ww H$$H
H
• //Con
OO //
uujjjjjjjj • //Nil
•p //Par
OO
i o t
I .
• //• //Inv
GG
//
~~~~~
• //Abs
55kk kk kk k //
uulllllll • //Ret
OO //
• //Nil A
OO
BB
J
P0K
†
h
p,
i,
o,
ti
P0
=
time.h
Ti|
time.(?
x)h
xi
↑Processes as designs Zhao, et al. Graph Representation of CaSPiS 2010
Graph Transformation Rules
Do congruence processes have the same graph representation?
J
P1|
P2K
†vs.
J
P2|
P1K
†
∆
C: Rules for congruenceWhat is the relation between
J
PK
†and
J
QK
†with P
− →
Q?∆
R: Rules for reductionAuxiliary rules (tagging, garbage collection)
Rule for Congruence
•
• //Par
OO
•
•
•
•
•
• 1//Par 3OO
2
•
J
C[
P1|
P2] K
†
⇒ J
C[
P2|
P1] K
†
Graph transformation rules Zhao, et al. Graph Representation of CaSPiS 2010
Graph Transformation Rules
Rule for Congruence (Cont.)
Par //
C!!C C •
•
00
•
OO
•
Par
OO //•
•
• •
•
Par //
•
•
..
•
•
Par
{=={
{ //•
J
C[(
P1|
P2)|
P3] K
†
⇒ J
C[
P1|(
P2|
P3)] K
†
Rule for Congruence (Cont.)
•
•
Par
v;;v v
.
• //Res
{ //=={{•
• •
.
•
•
•
Res //
.
• //Par
OO //•
J
C[
P1|(ν
n)
P2] K
†
⇒ J
C[(ν
n)(
P1|
P2)] K
†
Graph transformation rules Zhao, et al. Graph Representation of CaSPiS 2010
Graph Transformation Rules
A
D .time .T
• //• //Def
w //;;ww H$$H
H
• //Con
OO //
uujjjjjjjj • //Nil
•p //Par
OO
i o t
I .
• //• //Inv
GG
//
~~~~~
• //Abs
55kk kk kk k //
uulllllll • //Ret
OO //
• //Nil A
OO
BB
A
D
.
• //• //Def
| //==||
}}zzz
•
//
A
I
• //• //Inv JJ
//
}}zzz •
//
A .
• • •
A
• • •
A
S
rvoo . .
• //• //Ses
OO //
||yyy
•
//
A
S
• //•||yyy//SesBB //
•
//
Graph transformation rules Zhao, et al. Graph Representation of CaSPiS 2010
Graph Transformation Rules
A
S
rvoo . .time .T
• //• //Ses
OO //
H$$H
H
• //Con
OO //
uujjjjjjjj • //Nil
•p //Par
OO
i o t
S .
• //• //Ses
AA//
~~}}}
• //Abs
55kk kk kk k //
uukkkkkkk • //Ret
OO //
• //Nil A
OO
BB
Garbage Collection Rule
.
Graph transformation rules Zhao, et al. Graph Representation of CaSPiS 2010
Graph Transformation Rules
A
S
rvoo . .T
• //• //Ses
OO //
F##F
F
• //Con
OO //
uukkkkkkk • //Nil
•p //Par
OO
i o t
S .
• //• //Ses
AA//
~~}}}
• //Abs
l 55l ll ll l //
uulllllll • //Ret
OO //
• //Nil A
OO
BB
Tagging Rule
A
S
.
• //• //Ses
OO //
}}zzz
•
S .
• //• //Ses
OO //
}}zzz
•
S . A
• //• //Ses
OO //
}}zzz
•
Graph transformation rules Zhao, et al. Graph Representation of CaSPiS 2010
Graph Transformation Rules
S rvoo . A
.T
• //• //Ses
OO //
F##F
F
• //Con
OO //
uukkkkkkk • //Nil
•p //Par
OO
i o t
S A
.
• //• //Ses
AA//
~~|||
• //Abs
l 55l ll ll l //
uukkkkkkk • //Ret
OO //
• //Nil
BB
J
P1K
†
h
p,
i,
o,
ti
P1
= (ν
r)(
rh
Ti|
r(?
x)h
xi
↑)
Graph transformation rules Zhao, et al. Graph Representation of CaSPiS 2010
Graph Transformation Rules
Rule for Reduction
S . A
.
• //• //Ses
OO //
O''O OO
O• • //Con
OO //
ttiiiiiiiii •
//
S A
.
• //• //Ses
BB //
O''O OO
O• • //Abs
OO //
}}|||
•
//
S . A
.n0
• //• //Ses
OO //
O''O OO
O
• •p •
p0
//
S A
.n
• //• //Ses
BB //
O''O OO
O
• •q •
q0
//
S . A
• //• //Ses
OO //
O''O OO
O
• •p
//
S A
.n
• //• //Ses
BB //
O''O OO
O
• •q
//
p/p0→p,q/q0→q;n/n0→n
Graph transformation rules Zhao, et al. Graph Representation of CaSPiS 2010
Graph Transformation Rules
S rvoo . A
• //• //Ses
OO //
""F FF
• //Nil
•p //Par
OO
i o t
S A
.T
• //• //Ses
AA//
~~|||
• //Ret
OO // • //Nil
BB
J
P2K
†
h
p,
i,
o,
ti
P2
= (ν
r)(
r0|
rh
Ti
↑)
Graph transformation rules Zhao, et al. Graph Representation of CaSPiS 2010
Soundness and Completeness
Theorem (soundness w.r.t. congruence)
J
PK
†
⇒
∗∆CG implies G
≡
dJ
QK
†for some Q
≡
cPTheorem (completeness w.r.t. congruence) P
≡
cQ impliesJ
PK
†
⇒
∗∆C
J
Q0
K
†and
J
QK
†
⇒
∗∆c
J
Q0
K
†for some Q0
Conjecture (soundness w.r.t. reduction)
J
PK
†
⇒
∗∆A
J
QK
†implies P
− →
∗Q difficulty: intermediate statesConjecture (completeness w.r.t. reduction) P
− →
Q impliesJ
PK
†
⇒
∗∆A
J
Q0
K
†for some Q0
≡
c Q difficulty: replicationsSoundness and completeness Zhao, et al. Graph Representation of CaSPiS 2010
Summary
What we have done
a graph algebra: grammar, semantic model
graph representation of CaSPiS processes (tagged graphs) graph transformation rules (DPO): congruence, reduction, auxiliary (tagging, garbage collection)
soundness and completeness of DPO rules w.r.t. congruence
Future Work
soundness and completeness of DPO rules w.r.t. reduction case study and implementation
Zhao, et al. Graph Representation of CaSPiS 2010