1 Formal Models for Transactions: Petri Nets Roberto Bruni Dipartimento di Informatica Università...
-
date post
20-Dec-2015 -
Category
Documents
-
view
216 -
download
0
Transcript of 1 Formal Models for Transactions: Petri Nets Roberto Bruni Dipartimento di Informatica Università...
1
Formal Models for Transactions: Petri Nets
Roberto BruniDipartimento di Informatica Università di Pisa
Models and Languages for Coordination and Orchestration
IMT- Institutions Markets Technologies - Alti Studi Lucca
2
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Contents Orchestration with Petri Nets Transactions with Zero Safe Nets From BizTalk to Zero Safe Nets
3
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Contents Orchestration with Petri Nets Transactions with Zero Safe Nets From BizTalk to Zero Safe Nets
4
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Petri Nets Place/Transition Petri nets [Petri 1962]
Well-known model of concurrency Theory / Applications
Well-supported by a large community Academy / Industry
Well-developed tools http://www.daimi.au.dk/PetriNets
A media for conveying ideas to non-expert Suggestive graphical presentation
5
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Foundational Model of Concurrency
Basic monoidal structure of states A graph whose set of nodes is a monoid Precursor of most modern models and calculi of
concurrency Monoidal structure of computations
Essentially multiset rewriting Framework for studying issues of
Causality, concurrency, conflict Event structures and domain Deadlock, liveness, boundedness Reachability, coverability, invariants
6
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
General-purpose Model of (Concurrent) Computation
Algebraic representations of data, states, transitions, steps, computations
Basic rewriting system later generalized by Term rewriting, graph rewriting, term-graph rewriting,
concurrent constraint models A framework where to mix concurrency with other
features Data types, time, probability, dynamic reconfiguration,
read-without-consuming, negative preconditions, objects, Semantic framework for encoding other models
and languages Useful in studying and comparing expressiveness issues
7
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Practical Specification Language
Standard theory and notation Simple and natural graphical
representation Exploited in many heterogeneous areas Supported by tools of “industrial quality” Suitable for concurrent orchestration!
8
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Terminology and Notation Places a,b,c,… classes of resources Transitions t,t’,… basic activities Tokens instances of a resource class Markings u,v,w,… multisets of resources
Multiset union uw Empty marking Places are unary markings a Multiset inclusion (e.g. 2a3c 3ab3c)
Pre-sets t resources necessary to execute t multiset fetched by the execution of t
Post-sets t resources produced by t We write t:uv for t=u and t=v
9
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Formal Definition A P/T Petri net is a graph N=(S,T,pre,post,u0)
S is the set of markings (is the free monoid over the set of places S) Nodes of the graph
T is the set of transitions Arcs of the graph
pre:T S assigns pre-sets to transitions pre(t) = t Source map of the graph
post:T S assigns post-sets to transitions post(t) = t
Target map of the graph u0 is the initial marking
10
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Graphically
a2a1
a5 a4
a3
2
2
places are circlestransitions are boxesweighted arcs model pre-/post-sets
t1 t2
t3
t4
t5
11
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Enabling A transition t is enabled in the
marking u if t u
Meaning that there exists u’ such that u=u’t
If t is enabled in u, it means that the system has enough resources to
execute t
12
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Firing
The execution of t is called a firing t can
first fetch the resources in its pre-set and then release fresh resources according to its
post-set the system moves
from the state u = u’ t to the state v = u’ t
the firing is usually written u [t v
13
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Steps A multiset of transition i niti is enabled in
the marking u if there exists u’ such that u = u’ i ni
ti Several transitions that are concurrently
enabled can fire concurrently their concurrent execution is called a step
from u = u’ i niti
to v = u’ i niti
Usually written u [i niti v
14
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Example: Step Sequencesa2a1
a5 a4
a3
2
2t1 t2
t3
t4
t5
t1:a5a1
t2:2a1a4 a22a5
t3:a2a3
t4:a3a2
t5:a3a4
4a12a2
15
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Example: Step Sequencesa2a1
a5 a4
a3
2
2t1 t2
t3
t4
t5
t1:a5a1
t2:2a1a4 a22a5
t3:a2a3
t4:a3a2
t5:a3a4
4a12a2 [2t3 4a12a3
16
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Example: Step Sequencesa2a1
a5 a4
a3
2
2t1 t2
t3
t4
t5
t1:a5a1
t2:2a1a4 a22a5
t3:a2a3
t4:a3a2
t5:a3a4
4a12a2 [2t3 4a12a3 [t4t5 4a1a2a4
17
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Example: Step Sequencesa2a1
a5 a4
a3
2
2t1 t2
t3
t4
t5
t1:a5a1
t2:2a1a4 a22a5
t3:a2a3
t4:a3a2
t5:a3a4
4a12a2 [2t3 4a12a3 [t4t5 4a1a2a4 [t2 2a12a2 2a5
18
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Operational Semantics We can describe concurrent computations
by means of three simple inference rules:
aS
aNa[reflexivity]
t:uvT
uNv[firing]
uNv u’Nv’
uu’Nvv’[parallel composition]
uNv vNw
uNw[sequential composition]uNw*
19
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Basic Properties Proposition
There is a step sequence leading from u to v iff uNv
Decidable properties termination reachability coverability
*
20
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
An Algebra of Computations
We can use proof terms to denote computations:
aS
a:aNa[reflexivity]
t:uvT
t:uNv[firing]
:uNv :u’Nv’
:uu’Nvv’[parallel composition]
:uNv :vNw
;:uNw[sequential composition]
associativecommutativeunit :N
monoid homomorphismidentities u:uNu
21
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Example: Step Sequencesa2a1
a5 a4
a3
2
2t1 t2
t3
t4
t5
t1:a5a1
t2:2a1a4 a22a5
t3:a2a3
t4:a3a2
t5:a3a4
4a12a2 [2t3 4a12a3 [t4t5 4a1a2a4 [t2 2a12a2 2a5
(4a12t3);(4a1t4t5);(2a1a2t2)
idle resources
activities
: 4a12a2 2a12a2 2a5
22
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Basic Facts About Concurrency
idling monoid homomorphism
Suppose t:uv and t’:u’v’ t;v = t = u;t
Idle steps are immaterial tt’: uu’Nvv’ // concurrent execution tt’ = (t;v)(u’;t’) = (tu’);(vt’) // t precedes t’ tt’ = (u;t)(t’;v) = (ut’);(tv’) // t’ precedes t
If two activities can be executed concurrently, they can be executed in any order The vice versa is not true
Take t:aa and t’:aa t;t’ and t’;t are very different from tt’
23
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Token Philosophies This semantics follows the so-called
Collective Token Philosophy (CTPh) Any two tokens in the same place are
indistinguishable one from the other computationally equivalent
Other semantics follow the Individual Token Philosophy (ITPh) Any token carries its own history
tokens have unique origins fetching one token makes an activity causally
dependent from the activities that produced it such analysis can be important for recovery purposes,
detecting intrusions, increase parallelism, …
24
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Process Semantics Non-sequential behaviour of nets
Causality and concurrency within a single run Runs are described by Processes = (P,)
A process net P acyclic net pre-/post-sets are just sets, not multisets transitions have disjoint pre-sets transition have disjoint post-sets
A net morphism :PN places to places transitions to transitions
25
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Example
a2a1
a5 a4
a3
2
2t1 t2
t3
t4
t5
Graphically is rendered by a suitable labeling (herewe use colours for simplicity)
a1 a1 a1 a1 a4 a2
26
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Example
a2a1
a5 a4
a3
2
2t1 t2
t3
t4
t5
t3t2
a3a5a5 a2
a1 a1 a1 a1 a4 a2
27
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Example
t5t1
a4a1
a2a1
a5 a4
a3
2
2t1 t2
t3
t4
t5
t3t2
a3a5a5 a2
a1 a1 a1 a1 a4 a2
28
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Example: Process 1
t2
a5a5 a2
a5 a4
a3
2
2t1 t2
t3
t4
t5
a2a1
t5t1
a4a1
t3t2
a3a5a5 a2
a1 a1 a1 a1 a4 a2 the last firing of t2 causally depends on all other events
29
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Example: Process 2
Now there are two disjoint activities!
a5 a4
a3
2
2t1 t2
t3
t4
t5
a2a1
t2
a5a5 a2
t5t1
a4a1
t3t2
a3a5a5 a2
a1 a1 a1 a1 a4 a2
30
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
FOURTH HOMEWORK
Using the algebra of computations that we have seen: write the expression associated with 1
( 2a1t2t3 ) ; ...
write the expression associated with 2
show that the two expressions can be proved equal to
( t2 ; a2a5t1 ) ( 2a1t3 ; 2a1t5 ; t2 )
31
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Concatenable Processes Each process defines
an initial marking u -image of the set of places with no antecedents – minimal places
and a final marking v -image of the set of places with no successors – maximal places
:uv Can processes be composed analogously to CTPh runs?
In general there is some ambiguity The correspondence between final places of the first process and
initial places of the second process must be fixed Concatenable processes come equipped with suitable
orders on minimal / maximal places of P The orders concern places that are mapped to the same place of N
unique source of ambiguity
32
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Concatenable Processes: Graphically
a’1 a’2 a’n’ b’1 b’2 b’m’
superscripts denote order on minimal placessubscripts denote order on maximal places
d’1 d’2 d’k’
a1 a2 an b1 b2 bm d1 d2 dk
: namb…kd n’a’m’b’…k’d’
a,b,…dare places of N
33
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Composing Concatenable Processes
Idle computations any place is both minimal and maximal (no
transitions) minimal and maximal orders coincide
Parallel composition 12 juxtaposition (NOT COMMUTATIVE) the orders in the result are obtained by assuming that
places of the first process precede places of the second process
Sequential composition 1;2 maximal places of 1 are merged with minimal places
of 2 according to their orders
34
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Symmetries Special concatenable processes allow to rearrange
the orders of minimal and maximal places called symmetries : uv vu
(note that uv = vu) no real computation the order of minimal places differs from that of maximal
places symmetries are important to generate all possible
causal dependencies arising from different combination of minimal and maximal places during composition
35
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Unfolding Semantics Instrumental in giving denotational semantics to nets
a unique prime event structure that faithfully represent causality, concurrency and conflict between all possible events that can be generated from the net
unfolding approximations can be used for verification Unfolding combines all processes in a unique
structure non-deterministic exploration of computation space define a nondeterministic net U(N) together with a net
morphism from U(N) to N acyclic, no backward conflicts, pre-/post-sets are sets places are tokens, transitions are events
36
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
a
Example: Three Processes
b
t s
t
a
r
a
c
s
r
c
b
t
t
a
a
s
r
c
b
a
a
s
r
c
b
1 2 3 N
37
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
c
Example: Unfolding I
b
t s
r
a
c
a
s
r
b
t
a
ra
t
r
38
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
a
c
Example: Unfolding II
b
t s
r
a
c
t
t
a
a
s
r
b
#
co
r
r
Three relations: : Causalityco : Concurrency# : Conflict
39
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Unfolding Construction Immediate precedence
<0 = { (a,t) | a•t} {(t,a) | at•} Causal dependence
is the transitive closure of <0 Binary Conflict
# is the minimal symmetric relation that is hereditary w.r.t. and contains #0 defined by: s#0t iff st •s•t
Concurrency co(x,y) iff (x<y y<x x#y) we also write co(X) iff for all x,yX we have
co(x,y)
Note that and # have empty intersection
40
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Unfolding Construction:Notation
Places of U(N) a,n,H
a is the corresponding place in N n is a positive natural number introduced to distinguish
tokens with the same history H is the history of the place
either the empty set or a single event (the transition that generated the token)
Transitions of U(N) (events) t,H
t is the corresponding transition in N H is the history of the event (the set of fetched tokens)
41
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
b
t s
r
a
c
x1 = a,1, x2 = b,1,
e1 = t,{x1}
x3 = a,1,{e1} e3 = r,{x1,x4}
e2 = s,{x2}
x4 = c,1,{e2}
re4 = r,{x3,x4}
re6 = r,{x5,x4}
Unfolding Construction:Example
e5 = t,{x3}
x5 = a,1,{e5}
42
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Unfolding Construction:Inference Rules
The net U(N) is the minimal net generated by the two rules below
ka u0
a,k, SU(N) initial marking of U(N)
t:iai jnjbj T ={ai,ki,Hi}i SU(N) co()
e=t,TU(N) ={bj,m,{e} | 1 m nj}j SU(N)
pre(e)= post(e)=
43
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
Unfolding Construction:Remarks
The condition co() depends exclusively on the histories Hi and cannot be altered by successive firings
Histories can be completely cabled inside the tokens so that it is not necessary to re-compute them at every firing (as in memoizing or dynamic programming)
Histories retain concurrent information, not just sequential Each token / event is generated exactly once
It can be referred several times successively
Several occurrences of the second rule can be applied concurrently
The unfolding can be implemented as a distributed algorithm
44
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
References I Kommunikation mit automaten (PhD Thesis,
Institut fur Instrumentelle Mathematik, Bonn 1962) C.A. Petri
Petri nets: an introduction (EATCS Monograph on TCS, Springer Verlag 1985)
W. Reisig Petri nets are monoids (Information and
Computation 88(2):105-155, Academic Press 1990) J. Meseguer, U. Montanari
45
Roberto Bruni @ IMT Lucca 12 April 2005
Models and Languages for Coordination and Orchestration
InstitutionsMarketsTechnologies
IMT
References II The non-sequential behaviour of Petri nets
(Information and Computation 57:125-147, Academic Press 1983)
U. Goltz, W. Reisig Petri nets, event structures and domains, part I
(Theoretical Computer Science 13:85-108, 1981) M. Nielsn, G. Plotkin, G. Winskel
Configuration structures (Proc. LICS’95, IEEE, pp.199-209)
R.J. van Glabbeek, G.D. Plotkin