A Graph Syntax for Processes and Services Alberto Lluch Lafuente (joint-work with Roberto Bruni and Fabio Gadducci) Department of Computer Science, University of Pisa Software Engineering for Service-Oriented Overlay Computers 6th Int’l Workshop on Web Services and Formal Methods Bologna, September 4-5, 2009
Goal statement The spirit of our research is ”to conciliate algebraic and graph-based specifications”
Goal statement The spirit of our research is ”to conciliate algebraic and graph-based specifications” In this work we propose a graph syntax to ”Equip algebraic specifications with a graphical representation that is ◮ Intuitive ◮ Easy to define ◮ Easy to prove correct
Running Example: Sagas We shall consider a simple language for transactions with ◮ sequential composition; ◮ parallel (split-join) composition; ◮ compensations; ◮ saga scoping. This example is inspired by the Nested Sagas of [BMM05].
Modelling Sagas with Graphs (sketch) sequential composition
Modelling Sagas with Graphs (sketch) sequential composition parallel composition
Modelling Sagas with Graphs (sketch) sequential composition parallel composition compensation
Modelling Sagas with Graphs (sketch) sequential composition parallel composition saga compensation
Modelling Sagas with a Process Calculus (sketch) task1 ; task2 ; task3
Modelling Sagas with a Process Calculus (sketch) task1 ; task2 ; task3 task1 | task2 | task3
Modelling Sagas with a Process Calculus (sketch) task1 ; task2 ; task3 task1 | task2 | task3 ordinary flow %compensation flow
Modelling Sagas with a Process Calculus (sketch) task1 ; task2 ; task3 task1 | task2 | task3 ordinary flow [ flow ] %compensation flow
Calculi vs Graphs Algebraic Graph-based elements ◮ Terms ◮ Graphs (diagrams) a | b flat, hierarchical, etc.
Calculi vs Graphs Algebraic Graph-based elements ◮ Terms ◮ Graphs (diagrams) a | b flat, hierarchical, etc. ◮ Operations vocabulary ◮ Graph compositions ·|· : W × W → W Union, tensor, etc.
Calculi vs Graphs Algebraic Graph-based elements ◮ Terms ◮ Graphs (diagrams) a | b flat, hierarchical, etc. ◮ Operations vocabulary ◮ Graph compositions ·|· : W × W → W Union, tensor, etc. ◮ Axioms ◮ Homomorphisms equivalence x | y ≡ y | x isomorphism, etc.
Calculi vs Graphs Algebraic Graph-based elements ◮ Terms ◮ Graphs (diagrams) a | b flat, hierarchical, etc. ◮ Operations vocabulary ◮ Graph compositions ·|· : W × W → W Union, tensor, etc. ◮ Axioms ◮ Homomorphisms equivalence x | y ≡ y | x isomorphism, etc. ◮ Rewrite rules ◮ Transformation rules dynamics a − → b
Main technical goal: mapping coherent wrt. equivalence graph1 flow1 a | b | [ c % d]
Main technical goal: mapping coherent wrt. equivalence graph1 flow1 a | b | [ c % d]
Main technical goal: mapping coherent wrt. equivalence graph1 flow1 a | b | [ c % d] congruent flow2 b | [ c % d ] | a
Main technical goal: mapping coherent wrt. equivalence graph1 flow1 a | b | [ c % d] congruent graph2 flow2 b | [ c % d ] | a
Main technical goal: mapping coherent wrt. equivalence graph1 flow1 a | b | [ c % d] isomorphic congruent graph2 flow2 b | [ c % d ] | a
Main technical problem: representation distance grammar, structural congruence, etc. very different syntax! adjacency matrix, tuples, sets, morphisms
Main technical problem: representation distance similar syntax solution: graph algebras similar syntax
Main application: encodings are facilitated graph1 flow1 a | b | [ c % d] congruent isomorphic flow2 graph2 textttb | [ c % d ] | a
Main application: encodings are facilitated graphterm1 graph1 W[ p q . flow1 b(p) | a(p) a ... | b | [ c % d] ] congruent isomorphic congruent flow2 graph2 graphterm2 W[ p q. textttb b(p) | [ c % d ] | a ... | a(p) ]
The syntax of the graph algebra G , H ::= 0 the empty graph
The syntax of the graph algebra G , H ::= 0 | x a node called x
The syntax of the graph algebra G , H ::= 0 | x | t ( x ) an (hyper)edge labelled with t attached to x for instance, a(p,q,r)
The syntax of the graph algebra G , H ::= 0 | x | t ( x ) | G | H parallel composition: disjoint union up to common nodes for instance, a(p,q,r) | a(p,q,r)
The syntax of the graph algebra G , H ::= 0 | x | t ( x ) | G | H parallel composition: disjoint union up to common nodes for instance, a(p,q,r) | a(p,q,r)
The syntax of the graph algebra G , H ::= 0 | x | t ( x ) | G | H | ( ν x ) G declaration of a new node x for instance, ( ν s) (a(p,s,r) | b(s,q,r))
The syntax of the graph algebra D ::= T x [ G ] G , H ::= 0 | x | t ( x ) | G | H | ( ν x ) G graph G with interface of type T exposing x for instance, S p , q , s [( ν r ) flow ( p , q , r , q , s )]
The syntax of the graph algebra D ::= T x [ G ] G , H ::= 0 | x | t ( x ) | G | H | ( ν x ) G | D � y � a nested graph attached to y for instance, D � a,b,c �
The syntax of the graph algebra D ::= T x [ G ] G , H ::= 0 | x | t ( x ) | G | H | ( ν x ) G | D � y � a nested graph attached to y for instance, D � a,b,c � , with D = S p , q , s [( ν r ) flow ( p , q , r , q , s )]
Identifying equivalent graphs The actual model of hierarchical graphs has some notion of hierarchical isomorphism.
Identifying equivalent graphs The actual model of hierarchical graphs has some notion of hierarchical isomorphism.
Identifying equivalent graphs Isomorphism is elegantly captured by structural axioms. G || H ≡ H || G (PARALLEL1) G || ( H || I ) ≡ ( G || H ) || I (PARALLEL2) is equivalent to
Identifying equivalent graphs Isomorphism is elegantly captured by structural axioms. G || H ≡ H || G (PARALLEL1) G || ( H || I ) ≡ ( G || H ) || I (PARALLEL2) G || 0 ≡ G (NODES1) ≡ ( ν x )( ν y ) G ( ν y )( ν x ) G (NODES2) ≡ ( ν x ) 0 0 (NODES5) ( ν y ) G { y / x } ≡ if y �∈ fn ( G ) ( ν x ) G (NODES3) L y [ G { y / x } ] L x [ G ] ≡ if | y | ∩ fn ( G ) = ∅ (NODES4) G || ( ν x ) H ≡ ( ν x )( G || H ) if x �∈ fn ( G ) (NODES5) L x [( ν y ) G ]( z ) ≡ ( ν y ) L x [ G ]( z ) if y �∈ | x | ∪ | z | (NODES6) x || G ≡ G if x ∈ fn ( G ) (NODES7) These axioms are rather standard and thus intuitive to those familiar with algebraic specifications.
Sagas encoding: sagas as calculus Let us assume the following syntax for our sagas language ::= | S ; S | S | S | [ P ] (sagas) S a ::= S % S | P ; P | P | P (processes) P with the usual following axioms holding ◮ associativity for sequential composition; ◮ associativity and commutativity for parallel composition.
Sagas encoding: key ideas I 1. Algebraic reading of the calculus ◮ Syntactical categories as Sorts ◮ Productions as Operators for instance ; : S × S → S S ::= S ; S ====> 2. Each sort becomes a design label Sagas sort S Process sort P
Sagas encoding: key ideas II 3. Each production becomes a derived operator def S p , q , r [( ν s )( X � p , s , r � | Y � s , q , r � )] X ; Y = 4. Some symbols should be material, i.e. represented by graph items like edges for instance, an activity
Sagas encoding: key ideas III 5. Some symbols should be immaterial. For instance, a material parallel operator yields non isomorphic graphs ( a | b ) | c a | ( b | c ) To capture associativity with iso we need something like
Sagas encoding: key ideas IV 6. Flattening dissolves composition frames. For instance, without flattening associativity is not captured by isomorphism ( a ; b ) ; c a ; ( b ; c ) With flattening of sagas we get in both cases.
Sagas encoding: main productions def X ; Y = S p , q , r [( ν s )( X � p , s , r � | Y � s , q , r � )]
Sagas encoding: main productions def X ; Y = S p , q , r [( ν s )( X � p , s , r � | Y � s , q , r � )] def X | Y = S p , q , r [ X � p , q , r � | Y � p , q , r � ]
Sagas encoding: main productions def X ; Y = S p , q , r [( ν s )( X � p , s , r � | Y � s , q , r � )] def X | Y = S p , q , r [ X � p , q , r � | Y � p , q , r � ] def X % Y = P p , q , r , s , t [ X � p , q , s � | Y � r , s , t � ]
Sagas encoding: main productions def X ; Y = S p , q , r [( ν s )( X � p , s , r � | Y � s , q , r � )] def X | Y = S p , q , r [ X � p , q , r � | Y � p , q , r � ] def [ X ] = def X % Y = S p , q , r [( ν s ) X � p , q , s , q , r � ] P p , q , r , s , t [ X � p , q , s � | Y � r , s , t � ]
Sagas encoding: coherence proof At the end we point at a result like Theorem Two sagas S and R are congruent exactly when they are isomorphic. ◮ The proof of soundness is reduced to show that in each axiom of the structural congruence the lhs and rhs are isomorphic, which is facilitated by the similarity of the axioms. def X | Y = S p , q , r [ X � p , q , r � | Y � p , q , r � ] par1 For instance, = S p , q , r [ Y � p , q , r � | X � p , q , r � ] def = Y | X ◮ The proof of completeness is done as usual by structural induction on the normal form of sagas terms. Still not easy, but at least we deal with similar notations.
Recommend
More recommend