• Nem Talált Eredményt

Binary Petri nets

In document Parallel approach of algorithms (Pldal 111-117)

Animation 3.4: A pattern that ''draws horizontal lines''

W. Zielonka: Safe executions of recognizable trace languages by asynchronous automata, Logic at Botik '89, Symposium on Logical Foundations of Computer Science, LNCS 363 (1989), 278-289

5. fejezet - Petri nets

5.2. Binary Petri nets

In this section we show the simplest Petri nets. First we define these, so-called elementary or binary Petri nets in a formal way.

Definition: A Petri net is a directed bipartite graph (G = (N,E)) with the following properties. The nodes (vertices) of the graph are the places (P, denoted by circles and/or ellipses in figures) and the transitions (T, denoted by rectangles in figures), formally P∪T = N (where P∩T = {}). The edges of the (di)graph E⊆P×T∪T×P, i.e., they may go from places to transitions and from transitions to places. It is usual to define the neighbourhood of a node n by the nodes that are directly connected to the node n, formally:

•t = {p | (p,t)∈E}, i.e., the preconditions of transition t are the input places of t, i.e., the places from where there is an edge to t;

t• = {p | (t,p)∈E}, i.e., the postconditions of the transition t are the output places of the transition t;

•p = {t | (t,p)∈E}, i.e., the input transitions of p are the transitions from which there are edges to p;

p• = {t | (p,t)∈E}, i.e., the output transitions of p are the transitions having in-edge from p.

A transition t is called a source transition if •t = {}; and transition t is called a sink transition if t•; = {}.

The semantics of a binary Petri net is the following:

The configuration (global state or marking) of a binary Petri net is defined as a function of the form P→{0,1}.

Thus the configuration of an elementary Petri net can be described as a binary vector of dimension |P|: the elements of the vector are assigned to the places of the system in a bijective way. The value 1 in the vector means that the given place has a token, while 0 means that the given place has not any token. Usually the initial

configuration is given by the Petri net, i.e., it is given which places having tokens and which have not, initially.

Then the dynamics of the system can be given along the discrete time scale as follows: we say that transition t is enabled (in the given configuration of the system), if each of the places of ·t having a token and none of the places of t· having any tokens. There can be several enabled transitions at the same time, and it can happen that none of the transitions are enabled in a given configuration. Then the development (the change of the global state) of the system is given as follows: let us choose (in a non-deterministic manner) an enabled transition t.

Let the tokens be deleted from its input places and let a token appear in each out place of t. This step is called the firing (switching) of transition t. The new token distribution (the configuration) determines the enabled transitions, etc. The steps that the system makes one after the other define the so-called firing sequences.

We note here that the source transitions are always enabled.

Typical examples for using Petri nets are the modelling of parallel/distributed/concurrent systems. We continue with some simple examples.

Example (binary Petri net with sequential run)

Let 3 places and 2 transitions in a Petri net graph be as it is shown in Figure 5.1. Then, in configuration (1,0,0) only the first transition is enabled, the second is not. After firing the first transition the configuration of the system will be (0,1,0). Now the first transition is not enabled, but the second one is enabled. In this way the two transitions are firing in a sequential manner. After the firing of the second transition the system enters to the (global) state (0,0,1) and there is no more enabled transition.

5.1. ábra - Petri net with sequential run with initial marking.

Example (binary Petri net with simultaneous run)

Let the graph and the initial marking of a Petri net be given as it is in Figure 5.2. Transitions 1 and 2 are enabled; they can be fired in any order (or in a parallel way). Until these two transition are fired, no other transition is enabled, and thus they are also synchronized. After both of these transitions have been fired, the marking will be (0,1,0,1,0) enabling transition 3. By firing transition 3 the only token of the system will be at place 5 by enabling only transition 4. After its firing the initial configuration (1,0,1,0,0) is obtained. This system models a deterministic parallel run: the parallel branches are activated by transition 4 and their run is finished by transition 3.

5.2. ábra - A parallel run in Petri net with initial marking.

Example (modelling conflict situation with binary Petri net)

Consider the Petri net that is given in Figure 5.3 (both its graph and its initial marking). Then both the transitions 1 and 2 are enabled. Whatever is chosen to fire, none of them will be enabled after the firing. These two transitions are in a conflict situation. It is not possible to fire both of them, only one (any) of them. This system models a non-deterministic choice.

5.3. ábra - Conflict situation, modelling a non-deterministic choice.

Typical interpretations of Petri nets are, for example, to see the input places, the transitions and the output places as data/signal, computing steps, output data/signals; or preconditions, events and postconditions; or needed resources, task/job and released resources; or conditions, clause in logic and conclusion(s), respectively.

There are some properties of the Petri nets that depend on the initial configuration, they are called behavioural properties. However there are properties that are independent of the initial marking, they depend only on the graph of the net, these properties are called structural properties.

Definitions: Let a Petri net and its initial marking be given. The system is contact-free if it has the following property. If every input place of transition t has a token, then t is enabled, i.e., in all these cases the condition that the output places of t are empty is automatically fulfilled.

Example (a contact-free binary Petri net and its work)

Let the system have 2 places and 3 transitions: transition A and B have input place "place 1" and output place

"place 2"; transition C has input place "place 2" and output place "place 1". Let the initial marking be (1,0), i.e, the only token at place 1. According to this both transitions A and B are enabled. Any of them may fire resulting the configuration having a token only at place 2, and thus none of these two transitions are enabled after this firing. At the same time transition C become enabled, and after its firing the initial marking is obtained. In this example transitions A and B are concurrent to each other.

The next result holds for contact-free systems.

Theorem: Let a Petri net and its initial marking be given. Then a contact-free system can be constructed such that the possible states of this system have a bijective mapping to the states of the original system (and also the possible firing of these nets have a bijective mapping to each other). We say that the two systems are configuration-equivalent.

In connection to Petri nets the following questions and problems are arisen and we can solve/answer them (we can analyse the following properties of the modelled systems by the help of Petri nets):

Definition: The reachability problem: can a given marking be obtained from the initial marking by any firing sequence?

The covering problem: can a marking be obtained from the initial marking by any firing sequence such that all given places have tokens (all other places are not important in this problem, some of them may have or may not have any tokens).

These problems can be solved using the concept reachability tree. If the initial marking of a Petri net is given, then we can construct the tree (graph) such that its nodes are the possible markings of the net, and its edges show how the system develops from a marking to another one by switching an enabled transition (thus transitions are assigned to the edges). The root of the tree is the initial marking. Since there are finitely many enabled transitions in every configuration of the system, a node can have only finitely many children node. It is enough to put only those markings into the tree that were not there already. Since, at the case of binary nets, the number of possible markings of as net is finite, the reachability tree is obtained after a finitely many steps and the solution of the above problems can be read out from this tree.

As an example, let us see the reachability tree of the Petri net shown in Figure 5.2. Figure 5.4 shows the tree (we have presented the states that are already in the tree in a crossed way and with grey colour).

5.4. ábra - Example for reachability graph.

Definition: The equivalence problem: there are two Petri nets given (with the same number of places, in an appropriately fixed order) with their initial markings, are the sets of reachable markings (vectors) are the same?

The containment problem: there are two Petri nets given (with the same number of places) with their initial configurations, does the set of possible states (vectors) of the second system contain the set of possible states of the first system?

By the help of the reachability tree all the possible markings of a system can be described and thus, by doing it for both systems, these problems can be solved.

The liveness problem, that is closely connected to, e.g., the deadlock-freeness property of operating systems, is the following:

Definition: There are various degrees of the liveness properties. Let a Petri net and its initial marking be given:

the transition t is

- (L0) dead if it is not element of any firing sequence.

- (L1) potentially firable if there is a firing sequence that contains it.

- (L2) arbitrarily often firable if for every positive value of k, there is a firing sequence such that t is enabled at least k times.

- (L3) infinitely often firing if there is an (infinite) firing sequence that contains t infinitely many times.

- (L4) always firable (or simply live) if for every reachable marking there is a firing sequence such that in the end of this sequence t is enabled.

A Petri net is always firable/infinitely often firing/arbitrarily often firable/potentially firable if it holds for every of its transitions, respectively.

It can be seen that among the liveness properties the last one, the always firable, fulfils the strongest condition.

Further, the following hierarchy of these properties can easily be checked: every always firable transition/Petri net is also infinitely often firing. Every infinitely often firing transition/Petri net is also arbitrarily often firable.

Further, every arbitrarily often firable transition/Petri net is also potentially firable transition/Petri net.

Example (potentially firable Petri net)

Let the Petri net be given with the initial marking as it is shown in Animation 5.1. Then there can be two (maximal long) firing sequence and both of them are shown in the animation. Both of them are of finite length.

The first sequence contains all the transitions: 13524. Then, we can say that every transition is potentially firable, and thus the Petri net itself so. Since we have only finitely many (finite) firing sequences, there is no arbitrarily often firable transition. Thus the Petri net itself is not potentially firable; and conditions (L3) and (L4) are also not fulfilled (by any transitions and by the net itself).

In document Parallel approach of algorithms (Pldal 111-117)