Graph Representation of Sessions and Pipelines for Structured Service Programming Liang Zhao1,2 with Roberto Bruni1 and Zhiming Liu2
2
1 University of Pisa, Italy UNU-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
P3
P2
r
S P4
vs. textual expression: s.P1 |r (s.P2 |P3 )|r P4 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
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 Sum Value
P, Q M V
::= M | P |Q | s.P | s.P | r P | (νn)P | P > Q ::= 0 | (?x )P | hV iP | hV i↑ P | M + M ::= x | c
Example: P0 = time.hT i|time.(?x )hx i↑ Structural Congruence
(P1 |P2 )|P3 M1 + M2 (νn)0 r (νn)P
Syntax
≡c ≡c ≡c ≡c ...
P1 |(P2 |P3 ) M2 + M1 0 (νn)(r P )
if n 6= r
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 [r P , r Q ] (S-Sync): C [r (P0 |hy iP ), r (?x )Q ] − → C [r (P0 |P ), r Q [y /x ]] (P-Sync): C [(P0 |hy iP ) > (?x )Q ] − → C [Q [y /x ]|((P0 |P ) > (?x )Q )]
... Example P0 − → P1 − → P2
= time.hT i|time.(?x )hx i↑ = (νr )(r hT i|r (?x )hx i↑ ) = (νr )(r 0|r hT i↑ )
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 Design
G D
::= 0 | x | l (~x ) | G|G | (νx )G | D h~x i ::= L~y [G]
Free Node Free node: not restricted or exposed Example: Ly [(νx )l (x , y )]hz i Type Fixed Type: each node x, edges label l, design label L Well-typedness: l (~x ), L~y [G]h~x i
Grammar and semantic model
Zhao, et al.
Graph Representation of CaSPiS
2010
Semantic Model Interpretation of Terms G1 = a(y1 )|y2
/
• y1
• y2
a
Order of Tentacles of (Hyper-)edges
O
O
.
. 2
•
o
1
??3 / • ?? ? 5 ?
l 4
Grammar and semantic model
•
/
l
Zhao, et al.
/• ;
Graph Representation of CaSPiS
2010
Semantic Model Interpretation of Terms G2 = L(y1 ,y2 ) [a(y1 )|y2 ]hx1 , x2 i L1 1
/
•
•
a
}
• x1
L1 2
!
• x2
G3 = L(y1 ,y2 ) [a(y1 )|y2 ]hx1 , x2 i | L(y1 ,y2 ) [y1 |a(y2 )]hx1 , x2 i L1 1
• x1
a
•
/
•
a
}
L2 1
L1 2
= •
Grammar and semantic model
a
o
•
!
• x2
L2 2
L
>
•
/
•
a
• x1 L
Zhao, et al.
> •
a
o
• x2
•
Graph Representation of CaSPiS
2010
Semantic Model Flat Design Edge L(y1 ,y2 ) [a(y1 )|y2 ]hx1 , x2 i vs. F(y1 ,y2 ) [a(y1 )|y2 ]hx1 , x2 i
>
L
/
•
a
• x1
/
• x1
•
• x2
a
• x2
Node Sharing Kx [b(x , y )]hz i|Kx [b(x , y )]hz i vs. Kx [(νy )b(x , y )]hz i|Kx [(νy )b(x , y )]hz i K
?•
•z K
•
/b@ @@ •y ~> ~ / ~
Grammar and semantic model
b
K
>
•
/b
/
•
•
/b
/
•
•z K
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 edges Pushout: a square of (four) morphisms that commute Double Pushout (DPO) Rules ml
mr
R : GL ← GI → GR, or simply GL|GI |GR
o
GL
ml
m1
GI
mr
o
ml0
GR
m3
m2
G
/
G00
mr0
/
G0
Direct derivation: G ⇒R G0 Derivation: a sequence of direct derivations, G ⇒∗∆ G0 Graph 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
/
/
/
O
.
P •
/
•
/
QQQ/ • mm/ JP K mQmQ { vmmm }{{QQ(
Abs
J0K
J(?x )P K
•
/
•
/
O
•
P
/
Par
•
/
/ 11BB F 11 B
1|1>
|| 1 /
JP K
JQ K
JP |Q K
def
J0K = P(p,i ,o,t ) [i |o|t |Nil (p)]
def J(?x )P K = P(p,i ,o,t ) [(ν{p1 , x }) Abs(p, x , p1 , i )|JP Khp1 , i , o, t i ] def
JP |Q K = P(p,i ,o,t ) [(ν{p1 , p2 }) Par (p, p1 , p2 )|JP Khp1 , i , o, t i|JQ Khp2 , i , o, t i ]
Processes as designs
Zhao, et al.
Graph Representation of CaSPiS
2010
/ / /
Graph Representation Session and Pipeline P •
/
•
O
.r
/
S •
/
P
/ / BQBQQ•Qmmm{ JP K Q m B { Q m vmm }{ Q(
"
/ JP K 000 / Pip R R / 00 ( • F F RR 0 FF" RRRR0( O
•
Ses
•
/
•
Jr P K
/
R •
/ JQK z CCC z ! }z
JP > Q K
def
Jr P K = P(p,i ,o,t ) [i |t |S(p,t ) [(ν{p1 , i1 , o1 }) Ses(p, r , p1 , i1 , o1 )|JP Khp1 , i1 , o1 , t i ]hp, oi] def
JP > Q K = P(p,i ,o,t ) [(ν{p1 , p2 , o1 }) Pip(p, p1 , p2 , o1 , i , o, t )| JP Khp1 , i , o1 , t i|Rp [(ν{i , o, t })JQ Khp, i , o, t i]hp2 i ] Processes as designs
Zhao, et al.
Graph Representation of CaSPiS
2010
Graph Representation An Example .T O ;.time G www / • / Def / • j/ Con / • / Nil H j jHjHj$ jj uj i B o t I kk5 .O kkk k k / • / Inv / • k/ Abs / • / Ret / • / Nil k ~}}} ukkkkk D
O
•
•p
/ Par
•
JP0 Khp, i , o, t i P0 = time.hT i|time.(?x )hx i↑
Processes as designs
Zhao, et al.
Graph Representation of CaSPiS
2010
Graph Representation Tagged Graph A
O
•
•p
/ Par
O
• A
.T O ;.time G www / • / Def / • j/ Con / • / Nil H j jHjHj$ jj uj i t o B I k5 . kkk O k k / • / Inv / • l/ Abs k / • / Ret / • / Nil l ~~~~ ulllll D
JP0 K† hp, i , o, t i P0 = time.hT i|time.(?x )hx i↑
Processes as designs
Zhao, et al.
Graph Representation of CaSPiS
2010
Graph Transformation Rules Do congruence processes have the same graph representation? JP1 |P2 K† vs. JP2 |P1 K†
∆C : Rules for congruence
What is the relation between JP K† and JQ K† with P − → Q?
∆R : Rules for reduction
Auxiliary rules (tagging, garbage collection) Rule for Congruence
O
• •
/ Par •
• •
•
/
3
Par 2
•
O
• 1
•
JC [P1 |P2 ]K† ⇒ JC [P2 |P1 ]K† Graph transformation rules
Zhao, et al.
Graph Representation of CaSPiS
2010
Graph Transformation Rules Rule for Congruence (Cont.)
O CC / • C! O
•
•
0
Par
/
•
.
•
Par
•
•
• {= {{ / • Par
•
•
•
•
/•
Par
JC [(P1 |P2 )|P3 ]K† ⇒ JC [P1 |(P2 |P3 )]K† Rule for Congruence (Cont.)
v; • vv
•
Par
•
=. {{ / Res { / •
•
•
•
.
Res
•
•
O
•
/ Par
/. /•
JC [P1 |(νn)P2 ]K† ⇒ JC [(νn)(P1 |P2 )]K† Graph transformation rules
Zhao, et al.
Graph Representation of CaSPiS
2010
Graph Transformation Rules .T O ;.time G www / • / Def / • j/ Con / • / Nil H j jHjHj$ jj uj i B o t I kk5 .O kkk k k / • / Inv / • l/ Abs / • / Ret / • / Nil l ~~~~ ulllll
A
D
O
•
/
•p
Par
O
•
A
A
D
•
A
•
I
= .J ||| / • / Def / • }zzz / • / Inv / • }zzz
Graph transformation rules
A
•
/
•
.
A
•
/
•
Zhao, et al.
•
A
•
/
•
A
•
rv
S
•
o
B .O
/ Ses |yyy
/
/ Ses |yyy
/
. •
/
/
S
/
•
•
Graph Representation of CaSPiS
2010
Graph Transformation Rules A
/
O
•
•p
/
rv
S
•
o /
A .O
O / • j/ Con H j jHjHj$ jj uj .time
Ses
O
• A
/
•
/
Nil
i
Par
.T
/
S •
/ Ses / • k/ Abs k ~}}} ukkkkk
k5 . kkk O kkk/ • / Ret /
B o
t
•
/ Nil
Garbage Collection Rule .
Graph transformation rules
Zhao, et al.
Graph Representation of CaSPiS
2010
Graph Transformation Rules A
/
O
•
/
•p
o
rv
S
/
A .O
•
O / • k/ Con F k ukkFFk# kk .T
Ses
/
O
/
A
B o
i S
•
Nil
Par
/
•
•
/ Ses / • l/ Abs l ~}}} ulllll
l5 . lll O lll/ • / Ret /
t
/
•
Nil
Tagging Rule A
•
O
.
/
S •
/ Ses z }zz
/
S •
Graph transformation rules
•
/
•
O
.
/ Ses z }zz
/
S •
Zhao, et al.
•
/•
O
.
/ Ses z }zz
A
/ •
Graph Representation of CaSPiS
2010
Graph Transformation Rules rv
S
/
O
•
•p
/
•
o
A .O
.T O / Ses / • k/ Con F k ukkFFk# kk A
•
•
/
Nil
B o
i
Par
/
ll5 .O lll l l / • / Ses / • k/ Abs / • / Ret k ~||| ukkkkk S
t
A
/
•
/
Nil
JP1 K† hp, i , o, t i
P1 = (νr )(r hT i|r (?x )hx i↑ )
Graph transformation rules
Zhao, et al.
Graph Representation of CaSPiS
2010
Graph Transformation Rules Rule for Reduction •
. A S B .O O / • / Ses O / • • i/ Con / • O ii iiOiOiOi' ti /
•
O / • / Ses O / • • / Abs / • OOO || O' }| / S
A
S •
.
A
.n 0
/ • / Ses O / • •p OOO O' S
•
B .O
A
/ • / Ses O / • •q OOO O'
•p 0
•
/
A S B .O / • / Ses O / • •p OOO O'
S
.n •
•q 0
/
A
/ • / Ses O / • •q OOO O'
p/p0 → p, q /q 0 → q ; n/n0 → n
Graph transformation rules
Zhao, et al.
Graph Representation of CaSPiS
2010
/
/
.n
Graph Transformation Rules S
/•
O
•
•p
/
rv
o /
A .O
A
/ FFF • "
Ses
•
Nil
i
Par
/
/
•
/ Ses ~|||
/ •
O
t
•
/ Nil
.T
A
S
B o
/
Ret
/
JP2 K† hp, i , o, t i
P2 = (νr )(r 0|r hT i↑ )
Graph transformation rules
Zhao, et al.
Graph Representation of CaSPiS
2010
Soundness and Completeness Theorem (soundness w.r.t. congruence)
JP K† ⇒∗∆C G implies G ≡d JQ K† for some Q ≡c P Theorem (completeness w.r.t. congruence) P ≡c Q implies JP K† ⇒∗∆C JQ 0 K† and JQ K† ⇒∗∆c JQ 0 K† for some Q 0 Conjecture (soundness w.r.t. reduction)
JP K† ⇒∗∆A JQ K† implies P − → ∗Q difficulty: intermediate states
Conjecture (completeness w.r.t. reduction) P− → Q implies JP K† ⇒∗∆A JQ 0 K† for some Q 0 ≡c Q difficulty: replications
Soundness 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