Communication in Petri nets Kamal Lodaya work in progress with Ramchandra Phawade The Institute of Mathematical Sciences, Chennai February 2010
Petri nets - introduction Mathematical model. Widely used to study operating systems with concurrent processes. Example There are two processes Process 1 and Process 2. Both need a Resource to run. Process 1 Process 2 1. Ready to run. 2. Wait for resource. 3. Get resource and perform action. 4. Return resource and ready to run again. 1. Ready to run. 2. Wait for resource. 3. Get resource and perform action. 4. Return resource and ready to run again.
Petri nets - example Process 1 Resource Process 2 p 1 p 3 t 1 t 3 p 2 r 1 p 4 t 2 t 4 Figure: An example Petri net representing two processes
Petri nets - example Process 1 Resource Process 2 p 1 p 3 t 1 t 3 p 2 r 1 p 4 t 2 t 4 Figure: An example Petri net representing two processes
Petri nets - example Process 1 Resource Process 2 p 1 p 3 t 1 t 3 r 1 p 2 p 4 t 2 t 4 Figure: An example Petri net representing two processes
Petri nets - example Process 1 Resource Process 2 p 1 p 3 t 1 t 3 r 1 p 2 p 4 t 2 t 4 Figure: An example Petri net representing two processes
Petri nets - example Process 1 Resource Process 2 p 1 p 3 t 1 t 3 p 2 r 1 p 4 t 2 t 4 Figure: An example Petri net representing two processes
Petri nets - example Process 1 Resource Process 2 p 1 p 3 t 1 t 3 p 2 r 1 p 4 t 2 t 4 Figure: An example Petri net representing two processes
Petri nets - example Process 1 Resource Process 2 p 1 p 3 t 1 t 3 p 2 r 1 p 4 t 2 t 4 Figure: An example Petri net representing two processes
Petri nets - example Process 1 Resource Process 2 p 1 p 3 t 1 t 3 p 2 r 1 p 4 t 2 t 4 Figure: An example Petri net representing two processes
Petri nets - example Process 1 Resource Process 2 p 1 p 3 t 1 t 3 p 2 r 1 p 4 t 2 t 4 Figure: An example Petri net representing two processes
Reachability problem Starting from t 1 p 1 t 2 p 2 r 1 p 3 p 4, can we reach? t 1 p 1 p 2 t 2 r 1 p 3 p 4 t 4 t 4 t 3 t 3 M i = M f = 1 0 1 0 1 0 1 0 1 0
Formal definitions (P, T, pre, post, M 0 ); pre, post : (P T) N; M 0 : P N A transition can be fired at marking M provided there are enough tokens in all its input places. This firing results in the new marking M : M t M. M (p) = M(p) Pre(p, t) + Post(p, t) for all p P. A firing sequence σ = t 1 t r is enabled at marking M 0 if M 0 t 1 M1 M r 1 t r Mr and each t i is enabled at M i 1. A maximal firing sequence: keep firing until you cannot any more. So one needs to consider infinite words over a finite alphabet. The (deadlock) language accepted by a Petri net is its set of maximal firing sequences.
Problems Given a Petri net system and a final marking M f, the reachability problem is to determine if there exists a firing σ sequence σ enabled at M 0 such that M 0 Mf. The coverability problem given M f is to determine if there is a firing sequence enabled at M 0 which reaches a marking which has in every place p at least as many tokens as M f (p). The boundedness problem is to determine if there exists a bound b such that the system is b-bounded: no reachable marking has more than b tokens in any place. E.W.Mayr gave an algorithm for the reachability problem in 1981/1984. S.R.Kosaraju and J.L. Lambert simplified the proofs in 1982 and 1992. Exact complexity of the reachability problem is not known. C.Rackoff showed that coverability and boundedness can be solved using exponential space.
Logic Note: we usually use labels on the transitions in the net (a function l : T A) so that we talk of abstract actions. The usual temporal logics which do not allow expressing numbers of tokens in places have decidable satisfiability. Even very simple temporal logics which allow expressing the number of tokens in places are undecidable. But Petri nets are widely used for modelling (for example, the central processing unit of the Control Data CDC 6400). There are tools available which allow checking linear algebraic properties (algorithms use Parikh vectors of firing sequences).
1-bounded Petri nets Specific properties satisfied by some nets can be exploited to get better algorithms. If we consider 1-bounded systems, we still deal with infinite words over an alphabet We have succinct representation of shuffles of words dictated by the structure of the net, not by the number of tokens in the markings. This was analyzed by Mazurkiewicz using alphabet-induced shuffles of words which he called traces. A subclass called elementary net systems was defined by Nielsen, Rozenberg and Thiagarajan for this analysis. Hmm...
Can we explain Petri s nets to Johan s dean? Theorem (Kleene) There is a syntax of (regular expressions) which is equivalent to finite automata. r ::= a A r 1 ; r 2 r 1 + r 2 r ω The last two model IF-THEN-ELSE and WHILE-DO but are more general. The expressions have the following semantics: Lang(a) = {a} Lang(r 1 ; r 2 ) = {w 1 w 2 w 1 Lang(r 1 ), w 2 Lang(r 2 )} Lang(r 1 + r 2 ) = Lang(r 1 ) Lang(r 2 ) Lang(r ω ) = {w 1 w 2 i, w i Lang(r)} In a talk in Chennai (ICLA 09), Moshe Vardi narrated an experience that people in industry prefer regular expressions to finite automata. Is there such a syntax for 1-bounded Petri net systems?
Shuffle with synchronization Consider the syntax r e ::= a A r 1 ; r 2 r 1 + r 2 r ω ::= r e 1 e 2 sync J (e 1, e 2 ), J A e 1 [ρ], ρ : A A Where the semantics is: Lang(e 1 e 2 ) = {w w is a shuffle of w 1, w 2 ; w 1 Lang(e 1 ), w 2 Lang(e 2 )} Lang(sync J (e 1, e 2 )) = {(w 10 w 20 )a 1... a n (w 1n w 2n ), i, w 1i J = w 2i J = ǫ, {a 1,...,a n } J, w 10 a 1... a n w 1n Lang(e 1 ), w 20 a 1... a n w 2n Lang(e 2 )} Lang(e 1 [ρ]) = {ρ(t 1 )...ρ(t n ) t 1... t n Lang(e 1 )} For more details on shuffling, ask Hans van Ditmarsch.
Examples Modulo counting example: sync {j} ((j; j) ω, (j; j; j) ω ) Threshold counting example: sync {j1,j 2 }((p(j 1 + n; a; j 2 )) ω, (a(j 1 + n; p; j 2 )) ω )[j/j 1, j/j 2 ] Note the difference with: sync {j} ((p(j + n; a; j)) ω, (a(j + n; p; j)) ω ) Note: synchronized shuffle says something about communication, garbled with the concurrency. Best, Devillers and Koutny developed a syntax where the synchronization is an operation by itself. Hmm...?
Syntax matches systems Theorem (Grabowski) The languages defined by the above syntax are exactly the languages accepted by labelled 1-bounded Petri net systems. The proof of the converse heavily uses the renaming operation. Theorem (Zielonka) Labelled 1-bounded Petri nets can be thought of as some number of finite automata synchronizing on joint transitions. The proof begins by assuming a decomposition of the net into components, and uses difficult ideas of history update.
Unbounded shuffle Consider the syntax r e ::= a A r 1 ; r 2 r 1 + r 2 r ω ::= r e 1 e 2 e1 α sync J(e 1, e 2 ) e 1 [ρ] Where the semantics is: Lang(e α 1 ) = {w w is a shuffle of w 1,...,w n ; n 1, w 1,...,w n Lang(e 1 )} Theorem (Garg and Ragunath) This syntax matches the languages of Petri net systems. The proof assumes a decomposition of the net into components. No normal form theorem analogous to Zielonka s theorem is known.
Concurrency versus communication The syntax emphasizes the concurrency, modelled as shuffle. Synchronizing two unbounded length words (generated by the Kleene power) introduces the need for counting. Renaming makes the synchronization too powerful: difficult to say what matches with what. Allows talking about individual transitions in the guise of abstract actions, this is what is used in the proofs. Can we limit the syntax to avoid this? Can we make communication unambiguous?
Unambiguous communication Consider the syntax s ::= a A s 1 ; s 2 c ::= s usync J (c 1, c 2 ), J A e ::= c 1 c2 ω e 1 e 2 The unambiguous J-synchronization of c 1 and c 2 is defined only if for every letter in J, there is at most one occurrence when synchronizing two words from Lang(c 1 ) and Lang(c 2 ). (Note: Is this pointing as described by Gärdenfors?) All synchronizations are inside Kleene powers. No renaming: the communication you ask for, you get. Theorem A restriction of this syntax matches the languages accepted by live and safe marked graphs (nets where transitions are directly connected to each other and places play no role). Work in progress: identifying the restriction.
Unambiguous joint choices A subclass of nets called free choice systems only allows several processes to synchronize and make a joint choice (for example, two processes consider whether to synchronize on j 1 or j 2 and both of them make the same choice). Conjecture We can extend the above syntax to match the languages accepted by live and safe free choice systems.