14

Reachability test in Petri nets by Gröbner bases

  • Upload
    jku

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Reachability Test in Petri Netsby Gr�obner BasesOlga Caprotti� Alois Ferschaz Hoon Hong��Research Institute for Symbolic ComputationJohannes Kepler Universit�a, A-4020 Linz, AUSTRIAfocaprott,[email protected] Institut f�ur Angewandte InformatikUniversit�at Wien Lenaugasse 2/8, A-1080 Vienna, [email protected] 1995AbstractIn this paper we describe a decision procedure for the reachability problem in the class of PetriNets that can be represented as a commutative semigroup with the set of places as generators, and thetransition �ring rules notated as polynomials. Given two markings represented as power products, anda Petri Net represented as a set of polynomials, reachability can be interpreted as congruence modulo apolynomial ideal. The G�obner Bases algorithm is reviewed and then used as canonical simpli�er for thisequivalence.Keywords: Petri Nets, Reachability Problem, Equality Problem, Canonical Algebraic Simpli�cation,Knuth-Bendix Algorithm, Gr�obner Bases Algorithm.1 IntroductionThis paper will treat the reachability problem as suggested in [2] by devising a canonical simpli�er for theequivalence relation induced on the set of markings by reachability. The class of Petri Nets for which thedecision algorithm applies is the class of reversible cyclic Petri Nets. For the others, the algorithm is just asemi-decision procedure which guarantees un-reachability.The reachability problem is known to be decidable [3], but it requires at least exponential time and space[4] in the general case. 1

In the next section, we de�ne the reachability problem in the theory of Petri Nets. Section 3 will reviewthe well-known results relative to the Gr�obner basis method. Section 4 will describe how to transform areachability problem into a problem in polynomial ideal theory and will give a procedure to decide it. Finally,an example will show the e�ectivity of the method presented.2 Reachability in Petri NetsA Petri Net, P = (P; T; F;w; �(0)), is a tuple de�ned by:P , the set fp1; p2; : : : png of places,T , the set ft1; t2; : : : tmg of transitions,F � (P � T ) [ (T � P ), the input-output relation,w : F 7! IN+, an assignment of weights w((p; t)) to arcs (p; t) 2 F ,�(0), an initial marking, (generated by the marking functionM : P 7! IN0).A transition t 2 T is enabled in some marking � i� 8p 2 I(t), �(p) � w((p; t)) in �. (I(t) denotes the set ofinput-places of t 2 T ). E(�) is the set of all transitions enabled in �. When a transition t 2 T �res in �, itcreates a new marking �0, such that 8p 2 I(t) [O(t) �0(p) = �(p)�w((p; t)) +w((t; p)). (O(t) denotes theset of output-places of t 2 T ). The �ring of t in the marking �(i) is denoted by �(i) t! �(i+1).De�nition 1 (Reachable Marking) A marking �(j) is reachable from a marking �(i) in the PN P i�there exists a sequence of transitions � = (tk; tl; : : : ; tm) such that:�(i) tk! �(i+1) tl! : : : tm! �(j):For short, we denote that the marking �(j) is reachable from a marking �(i) by �(i) �! �(j), where � =(tk; tl; : : :) is also called a �ring sequence. The set of all markings reachable from �(0) is denoted by R(�(0)),the set of all possible �ring sequences in Pis written as �(P ; �(0)).The problem of �nding for a given �(i) whether �(i) 2 R(�(0)) is known as the reachability problem for PetriNets.In this paper we shall primarily look at the reachability problem for reversible Petri nets 1:A reversible Petri Net is a Petri Net, P = (P; T; F;w; �(0)) where F = F f [ F b, F f denoting the forward ow relation, and F b = (F f )�1 denoting the backward ow relation, derived by reversing the direction of1Note that this is not related to the classical de�nition of reversibility, which requires for each marking �(i) 2 R(�(0)) thereexists a �ring sequence � s.t. �(i) �! �(0). 2

arcs in F f . A transition t 2 T is enabled in some marking � in forward mode i� 8p 2 I(t), (p; t) 2 F f ,�(p) � w((p; t)) in �, and in backward mode i� 8p 2 O(t), (p; t) 2 F b, �(p) � w((p; t)) in �. An enabledtransition can �re in the respective mode, creating a new marking accordingly.3 Review of the Theory of Gr�obner basesIn this section we give a self-contained review of the main results of the theory of Gr�obner bases, see [2, ?]for a detailed exposition . We assume that the reader is familiar with the concept of polynomial over a �eld.Let �� T � T be an equivalence relation on a decidable set T .De�nition 2 (Canonical Simpli�er) An algorithm S, with inputs and outputs in T , is a canonical sim-pli�er for � on T i� for all f , g 2 T :(1) S(f) � f and(2) if f � g then S(f) = S(g):Therefore, if a canonical simpli�er S is given, the decision problem f � g, is reduced to checking thesyntactical equivalence S(f) = S(g). One can also show that if the equivalence relation � is decidable thenthere exists a canonical simpli�er S for �. In this paper, we will reduce the reachability problem in the classof reversible and cyclic Petri Nets to the problem of deciding congruence modulo a polynomial ideal. Forthis case, the canonical simpli�cation algorithm employs the \Gr�obner basis" algorithm described in [1].We will �rst �x some notational conventions that we will adopt throughout.K[x1; : : : ; xn] ring of polynomials in n variables over K, a �eld.f; g; h; k polynomials in K[x1; : : : ; xn].F ;G �nite subsets of K[x1; : : : ; xn].s; t; u power products of the form xe11 � � �xenn , e1; : : : ; en 2 IN .Ideal(F) ideal generated by F = fPhifi j hi 2 K[x1; : : : ; xn]; fi 2 Fg.The goal of this section is to provide a canonical simpli�er for the congruence modulo the polynomial idealIdeal(F), denoted by �F and de�ned by:De�nition 3 (Congruence �F) For all F , f , g:f �F g i� f � g 2 Ideal(F):Let <T be a total order on the power products satisfying the two properties:3

(T1) 1 <T t for all t 6= 1,(T2) if s <T t then s � u <T t � u.Such an ordering is called \admissible'. One example of admissible ordering is the lexicographical orderinduced by the variable order x < y:1 <T x <T x2 <T : : : <T y <T xy <T x2y <T : : : <T y2 <T xy2 <T : : :Let <T be an arbitrary but �xed admissible ordering. Then, with respect to the ordering <T , it is possibleto de�ne:cf(g; t) coe�cient of t in g.lpp(f) leading power product, maximal power product with nonzerocoe�cient in f .lcf(f) leading coe�cient, coe�cient of lpp(f).The primary notion of reduction (modulo F) of a polynomial g is a generalization of the polynomial division.De�nition 4 (Reduction modulo F) g reduces to h (modulo F), denoted by g !F h, i� there exist apolynomial f 2 F and a power product u such that:cf(g; u � lpp(f)) 6= 0 and h = g � cf(g; u � lpp(f))lcf(f) � u � f:Then the following lemma states the connection between congruence and reduction.Lemma 1 For all F , f , g: f �F g iff f �$Fgwhere �$F be the re exive, transitive and symmetric closure of !F .De�nition 5 (Normal Form modulo F) h is a normal form of f (modulo F), denoted by f �!F h, i�there exists a sequence of reductions of length � 0 such that:f !F : : :!F hand h does not reduce (modulo F) any further.In general, normal forms modulo an arbitrary F are not unique. Sets of polynomials which have the propertyof ensuring the uniqueness of the normal forms have a special name.De�nition 6 (Gr�obner basis) G is a Gr�obner basis i� for all g, h1, h2:if g �!G h1 and g �!G h2, then h1 = h2. 4

Gr�obner bases are computationally interesting because many problems in polynomial ideal theory can besolved algorithmically by using the following property called classical characterization of Gr�obner bases:Lemma 2 G is a Gr�obner basis i� for all f , g:f �G g i� there exists h such that f �!G h and g �!G hBy the GB algorithm, known in the literature as \Buchberger algorithm" or \Gr�obner bases" algorithm, wecan �nd for any set F , a Gr�obner basis G such that Ideal(F) = Ideal(G). The algorithm is based on thenotion of S-polynomial of two polynomials.De�nition 7 (S-polynomial of f1 and f2) The S-polynomial corresponding to f1 and f2 is:SPol(f1; f2) := lcm(lpp(f1); lpp(f2)lpp(f1) � f1 � lcf(f1)lcf(f2) � lcm(lpp(f1); lpp(f2)lpp(f2) � f2:The correctness of the GB algorithm relies on the algorithmic characterization of Gr�obner bases.Theorem 1 F is a Gr�obner basis i� for all f1, f2 2 F ; SPol(f1; f2) �!F 0.The Gr�obner basis algorithm takes as input a set of polynomials and an admissible term ordering and returnsa set of polynomials which is a Gr�obner basis for the input set, namely it generates the same ideal. Thealgorithm can be modi�ed in various ways in order to achieve better performances and a lot of research hasbeen done for �nding the \best" ordering and the best reduction strategy. Anyway, in its most essentialform, it has the following simple structure GB (F ;<T ;G)Input: F a set of polynomials.<T an admissible term ordering.Output: G a Gr�obner basis such that Ideal(F) = Ideal(G).(1) [Initialization.]G := F ;B := f(f1; f2) j f1; f2 2 G; f1 6= f2g;(2) [Loop.]While B 6= ; do(2.1) (f1; f2) := a pair in B;(2.2) B := B n f(f1; f2)g;(2.3) h := NORMAL FORM(G; SPol(f1; f2)); 5

(2.4) if h 6= 0 then(2.a) B := B [ f(g; h) j g 2 Gg;(2.b) G := G [ fhg;(3) [Return.]Return G.Now, consider the problem of deciding congruence modulo a polynomial ideal:given: F , f and g,decide: f �F g modulo Ideal(F).Suppose that G is the Gr�obner basis of the ideal generated by F , then instead of deciding f �F g, we candecide f �G g. By Lemma 2, this is equivalent to testing whether the normal forms of F and g modulo G aresyntactically identical. Hence, the algorithm that computes the normal form of F (modulo G) is a canonicalsimpli�er for the congruence �F modulo Ideal(F), if G is the Gr�obner basis of Ideal(F).In the next section, we will show that the reachability problem can, in some cases, be transformed into theproblem of deciding congruence modulo a polynomial ideal.4 Translation of ReachabilityThe decision method for verifying reachability is based on the fact that there exists a way of translatingplaces and transitions into power products (more generally, one may consider generators of a commutativesemigroup) such that the reachability problem becomes a problem in polynomial ideal theory.Informally, if one assigns a variable (generator) to each place of a reversible Petri Net, then a transitioncan be viewed as a polynomial. If the net is not reversible, then we must keep track of the direction of thetransitions and we should emply rewrite rules instead of polynomials. The power products of this polynomialinvolve the variables corresponding to the input/output places with degree de�ned by the respective arc'sweight. Markings can also be interpreted as power products, namely by taking the marking vector as degreevector of the power product describing the set of all places.Once this transformation is done, the reachability problem in a Petri Net PN between a marking �(i) and amarking �(j) is the problem of deciding whether the power product of �(i) rewrites, using the rules de�nedby the transitions in PN , to the power product of �(j).In order to show the main idea, let us apply the algebraic transformation to a very simple example. Considerthe Petri Net: 6

p

2

t

1

1

2

2 2

p

p

p pt

1

2

3

4 5

1

2Firstly, we have to assign variables to the places p1; p2; : : : ; p5 in the Petri Net: say, x1; x2; : : : ; x5 respectively.The transitions correspond to the polynomials:(f1) x21x2 � x3x24(f2) x24 � x25The initial marking �(i) of the net is described by the power product: x31x2x5. A marking that corresponds toa power product obtained by a sequence of reductions modulo f1 and f2 from x31x2x5, is reachable from theinitial marking. For instance, x31x2x5� (x1x5)f1 = x1x3x24x5, hence the marking corresponding to x1x3x24x5is reachable from the initial marking by transition t1.Now we formally de�ne how to transform the problem of reachability in a reversible Petri Net, to a problemin polynomial ideal theory that can be decided by an application of the Gr�obner basis algorithm.De�nition 8 (Polynomial Translation of PN) Given a reversible PN, P = (P; T; F;w; �0) with n placesin P and m transitions in T , we associate, for 1 � i � n and 1 � j � m:(1) to each place pi 2 P , a variable xi;(2) to each transition tj 2 T , a polynomial fj : xe11 xe22 : : :xenn � xd11 xd22 : : :xdnn , whereei = 8><>: w((pi; tj)) if (pi; tj) 2 F0 otherwise (input degree vector)di =8><>: w((tj ; pi)) if (tj ; pi) 2 F0 otherwise (output degree vector):The algorithm that performs this translation is straightforward. We may do better than simply translatingthe PN by computing the Gr�obner basis of the set of polynomial translations of the transitions. This hasthe advantage that the set of polynomials associated with the PN has a \nice" behavior with respect to thereachability problem, in fact, it is a canonical simpli�er for the induced equivalence.7

TRANSLATE (P;T; F;w;GP)Input: P the set of places of P. T the set of transitions of P. F the input-output relation of P. w the weightfunction of P.Output: GP is the Gr�obner basis (wrt >P) of the polynomial translation FP .(1) [Translate the places.]Assign variable xi to each place pi in P .(2) [Translate the transitions.]Assign polynomial fj to each transition tj in T .(3) [Compute the Gr�obner basis.]FP := ffj j fj is the pol. translation of tj 2 TgGB(FP ;>P ;GP);(4) [Return.]Return GP.Moreover, the polynomial translation after the Gr�obner basis computation still corresponds to a PN becausethe generated polynomials are of the same form as the polynomials arising from the translation.Lemma 3 Let F be a set of polynomials of the form fi : m(1)i � m(2)i , where m(1)i and m(2)i are powerproducts. Then, also the polynomials in the Gr�obner basis of F with respect to some admissible ordering,are of the same form.Proof. We have to show that the polynomials that arise from the computation of the Gr�obner basis ofF are of the special form fi : m(1)i � m(2)i , where m(1)i and m(2)i are power products. Let us consider theS-polynomials of a pair fi and fj :SPol(f1; f2) = u1 � (m(1)i �m(2)i )� u2 � (m(1)j �m(2)j );where u1 �m(1)i = u2 �m(1)j , and u1 u2 are power products. This gives:SPol(f1; f2) = �u1 �m(2)i + u2 �m(2)jwhich is either the zero polynomial or again of the form we want. It remains to show that the reductionsalso preserve this form. This is straightforward if we consider that a reduction modulo polynomials of theabove form, is basically like a S-polynomial computation where u1 = 1.As example, the polynomial translation for the con ict free net:8

p 1 t 1 p 3

t 3 p 5

t 4 p 6 t 6

p 8 t 8

p 7 t 7t 5p 4t 2p 2consists of the set of polynomials:F = fx1 � x3; x2 � x4; x3x4 � x5; x5 � x6; x5 � x7; x6 � x8; x7 � x8; x8 � x1x2g:Their Gr�obner basis, wrt the lexicographical order, is the set:G = fx1 � x3; x2 � x4; x3x4 � x8; x5 � x8; x6 � x8; x7 � x8gwhich corresponds to the PN:2

t1

t3

p3p

1

p5

1

1

1

1

p41

p6

p7

p8

1

1

t2p2

1

t4

t5

t6

1

1

1

1In the same way as we have translated the PN, we may translate a marking.De�nition 9 (Polynomial Translation of a Marking) Given a reversible and cyclic PN, P = (P; T; F;w; �0),the polynomial translation of a marking � (generated by a marking function M : P ! IN0), is a a powerproduct m : xM(p1)1 xM(p2)2 : : :xM(pn)n , where x1; : : : ; xn is the polynomial translation of the places of P.Since, in a symmetric and cyclic PN, reachability is re exive and symmetric (if �(j) is reachable from �(i),then also �(i) is reachable from �(j)), we may de�ne an algebraic equivalence relation �P on the set ofmarkings, induced by reachability, by:�(i)�P�(j) i� �(j) is reachable from �(i):Let P be a symmetric and cyclic PN. Consider the set FP of polynomials fj associated to the P as describedabove. If we �x a variable ordering, say x1 < x2 < : : : < xn, and an admissible term ordering, say <P , we can9

speak of reduction modulo FP and of Gr�obner basis GP of FP . Let mi, mj be the polynomial translationsof markings �(i), �(j) in a PN described by polynomials FP . Then, it holds:�(i)�P�(j) i� mi �$FPmj :By the results presented in Section 3, we obtain the following result.Corollary 1 Let FP be the polynomial translation of P , GP be its Gr�obner basis with respect to an admissibleordering, and �(j) �(i) markings in P . Then:�(i)�P�(j) i� there exists m such that mi �!GP m and mi �!GP m;where mi and mj are the polynomial translations of �(j), �(i).In view of the corollary, we can formulate a decision algorithm for the reachability equivalence �P in thePN P as described below. It takes as input a canonical translation of a PN, a pair of markings and returns\yes" when one marking is reachable from the other or returns \no" in the opposite case. We observe thatthe Gr�obner basis computation is carried out only one time for the PN under consideration, after that, anyreachability question in this net can be answered by this decision algorithm.REACHABLE (GP ; �(i); �(j);u)Input: GP is the Gr�obner basis of a polynomial translation FP wrt >P .�(i); �(j) are markings of PN .Output: u is `yes' if �(i) is reachable from �(j) in PN and is `no' otherwise.(1) [Polynomial Translation.]Translate �(i) and �(j) to polynomials pi and pj .(2) [Canonical Simpli�cation.]Compute qi and qj, the normal form modulo GP of pi and pj.(3) [Return.]If qi is syntactical identical to qj, return \yes" otherwise return \no".The algorithm needs Buchberger's GB algorithm in order to transform the set of polynomials correspondingto the given Petri Net, to a Gr�obner basis, hence, it uses this Gr�obner basis as canonical simpli�er fordeciding reachability. 10

5 MAPLE SimulationConsider the reversible Petri Net:1

2

1

t1

t2

t3

p2

p1

p3

p5

1

1 1

1

p4

1

1

1

1The polynomial translations of the transitions are:p1 : x1x4 � x23x4; p2 : x2x4 � x3x4; p3 : x4 � x5:We ask whether the marking corresponding to x51x2x33x34x25 is reachable from the marking corresponding tox51x22x23x54. Here below is the simulation of the algorithm REACHABLE by the computer algebra systemMAPLE, [?].At �rst, we input the set of polynomials to the system.> p1:= x1*x4 - x3^2*x4; p1 := x1 x4 � x3 2 x4> p2 := x2*x4 - x3*x4; p2 := x2 x4 � x3 x4> p3 := x4 - x5; p3 := x4 � x5We call F the set of these polynomials.> F := [p1,p2,p3]; F := [ x1 x4 � x3 2 x4 ; x2 x4 � x3 x4 ; x4 � x5 ]Then, we must specify the variable ordering. This is done in MAPLE by a list (decreasing order):11

> T := [x1,x2,x3,x4,x5]; T := [ x1 ; x2 ; x3 ; x4 ; x5 ]Using a MAPLE package called \grobner", it is possible to compute the Gr�obner basis just by calling afunction gbasis. gbasis requires as parameters the set of polynomials, the variable ordering and the termordering. In this case, we use the purely lexicographical ordering, speci�ed by plex.> G := gbasis(F,T,plex);G := [ x5 x1 � x5 x3 2; x5 x2 � x5 x3 ; x4 � x5 ]MAPLE answers with the Gr�obner basis: g1 : x5x1 � x5x23;g2 : x5x2 � x5x3;g3 : x3x4 � x5:Using the same package, it is possible to compute the normal form modulo a Gr�obner basis by invoking thefunction normalf with the polynomial, the Gr�obner basis, and the orderings. In this case, let us check themarkings to which the polynomials x51x2x33x34x25 and x51x22x23x54 correspond:> q1 := normalf(x1^5*x2*x3^3*x4^3*x5^2,G,T,plex);q1 := x5 5 x1 7> q2 := normalf(x1^5*x2^2*x3^2*x4^5,G,T,plex);q2 := x5 5 x1 7As the normal forms modulo the Gr�obner basis are identical, one marking is reachable from the other.6 ExtensionsThe decision method that we have described is complete for reversible Petri Net. In such case, it will answerwhether, in the petri net at hand, there is a �ring sequence of transitions for the given pair of markings. Inthis section, we analyse the possibility of extending the method to a broader class of PNs, that includes alsonon-reversible nets.The �rst observation is that the method presented is a semi-decision algorithm for the general net. Namely,given a PN and given two markings, if the algorithms returns \no", then there is no �ring sequence connectingthe markings. If the algorithm answers \yes", then we have to additionally check if the �ring sequence existsin the original net (remember that the alg. works over the canonical translation of the net).In order to exemplify the problem, let us consider this simple PN:12

p t

p

1

2

4

p

pt3

5

2

t41

t 3

p

t5

p6The set of polynomial translations is:F = fx1 � x2; x2 � x3; x3 � x4x5; x4 � x6; x5 � x6g:Their Gr�obner basis with respect to the purely lexicographical ordering given by the variable ordering:x6 < x5 < x4 < x3 < x2 < x1, is:G = fx1 � x26; x2 � x26; x3 � x26; x4 � x6; x5 � x6g:Choosing this ordering produces reductions which are compatible with the direction of transitions in theoriginal net. This canonical net looks as follows.

p

t

p

1

2

4p

t

3

5

2

t

4

1 t3

pt5

p6

pNow, we may check reachability between p2 and p1. REACHABLE will answer a�rmatively because thenormal form of their polynomials translation, x26 is the same for both. But, by looking at the original net,we can immediately see that there can be no �ring sequence connecting p1 and p2. Moreover, REACHABLEanswers positively also when queried about reachability among the polynomial markings x2 and x4x5 al-though this is true only in one direction: x4x5 is reachable from x2, but not vice-versa. On the other hand,if we ask whether the polynomial marking x1x6 is reachable from x2, REACHABLE reports the correctnegative answer.More research needs to be done investigating the possibility of checking the positive answers given byREACHABLE. This involves a study on which admissible ordering to choose for the polynomial translationand on strategies for choosing reductions while computing the normal forms.13

7 Concluding DiscussionThe main property of a canonical simpli�er is that, no matter which kind of reduction it applies, eventuallythe unique normal form will be reached. In this sense, compared to the indeterminism inherent in thereachability problem, the algorithmwe have presented behaves as a deterministic one for the case of reversiblePNs.We should also point out that, although the computation of the Gr�obner basis could be very time consuming,in the case of sets of polynomials arising from translations of PNs, the complexity is lower because the degreesare generally linear and the polynomials are very short.Some work has also been done in extending this approach to the general case but more insight is still neededfor devising a complete decision algorithm.References[1] B. Buchberger. An algorithm for �nding a basis for the residue class ring of a zero-dimensional polynomialideal (German). PhD thesis, Univ. Innsbruck, Dept. of Math., Innsbruck, Austria, 1965.[2] B. Buchberger. Gr�obner Bases: An Algorithmic Method in Polynomial Ideal Theory. In N.K. Bose,editor, Multidimensional Systems Theory, pages 184{232. D. Reidel Publishing Company, Dordrecht-Boston-Lancaster, 1985.[3] S. R. Kosaraju. Decidability of reachability in vector addition systems. In Proc. of 14th Annual ACMSymposium on Theory of Computing, San Francisco, California, Mai 5 - 7, 1982, pages 267 { 281, 1982.[4] E. Mayr. An algorithm for the general petri net reachability problem. SIAM Journal of Computing,13(3):441 { 460, 1984.14