Petri net
A Petri net, also known as a place/transition net, is one of several mathematical modeling languages for the description of distributed systems. It is a class of discrete event dynamic system. A Petri net is a directed bipartite graph, in which the nodes represent transitions and places. The directed arcs describe which places are pre- and/or postconditions for which transitions. Some sources state that Petri nets were invented in August 1939 by Carl Adam Petri—at the age of 13—for the purpose of describing chemical processes.
Like industry standards such as UML activity diagrams, Business Process Model and Notation and event-driven process chains, Petri nets offer a graphical notation for stepwise processes that include choice, iteration, and concurrent execution. Unlike these standards, Petri nets have an exact mathematical definition of their execution semantics, with a well-developed mathematical theory for process analysis.
Petri net basics
A Petri net consists of places, transitions, and arcs. Arcs run from a place to a transition or vice versa, never between places or between transitions. The places from which an arc runs to a transition are called the input places of the transition; the places to which arcs run from a transition are called the output places of the transition.Graphically, places in a Petri net may contain a discrete number of marks called tokens. Any distribution of tokens over the places will represent a configuration of the net called a marking. In an abstract sense relating to a Petri net diagram, a transition of a Petri net may fire if it is enabled, i.e. there are sufficient tokens in all of its input places; when the transition fires, it consumes the required input tokens, and creates tokens in its output places. A firing is atomic, i.e. a single non-interruptible step.
Unless an execution policy is defined, the execution of Petri nets is nondeterministic: when multiple transitions are enabled at the same time, they will fire in any order.
Since firing is nondeterministic, and multiple tokens may be present anywhere in the net, Petri nets are well suited for modeling the concurrent behavior of distributed systems.
Formal definition and basic terminology
Petri nets are state-transition systems that extend a class of nets called elementary nets.Definition 1. A net is a triple where:
- and are disjoint finite sets of places and transitions, respectively.
- is a set of arcs.
Definition 3. An elementary net is a net of the form EN = where:
- N = is a net.
- C is such that C ⊆ P is a configuration.
- N = is a net.
- M : P → Z is a place multiset, where Z is a countable set. M extends the concept of configuration and is commonly described with reference to Petri net diagrams as a marking.
- W : F → Z is an arc multiset, so that the count for each arc is a measure of the arc multiplicity.
In the diagram of a Petri net, places are conventionally depicted with circles, transitions with long narrow rectangles and arcs as one-way arrows that show connections of places to transitions or transitions to places. If the diagram were of an elementary net, then those places in a configuration would be conventionally depicted as circles, where each circle encompasses a single dot called a token. In the given diagram of a Petri net, the place circles may encompass more than one token to show the number of times a place appears in a configuration. The configuration of tokens distributed over an entire Petri net diagram is called a marking.
In the top figure, the place p1 is an input place of transition t; whereas, the place p2 is an output place to the same transition. Let PN0 be a Petri net with a marking configured M0, and PN1 be a Petri net with a marking configured M1. The configuration of PN0 enables transition t through the property that all input places have sufficient number of tokens "equal to or greater" than the multiplicities on their respective arcs to t. Once and only once a transition is enabled will the transition fire. In this example, the firing of transition t generates a map that has the marking configured M1 in the image of M0 and results in Petri net PN1, seen in the bottom figure. In the diagram, the firing rule for a transition can be characterised by subtracting a number of tokens from its input places equal to the multiplicity of the respective input arcs and accumulating a new number of tokens at the output places equal to the multiplicity of the respective output arcs.
Remark 1. The precise meaning of "equal to or greater" will depend on the precise algebraic properties of addition being applied on Z in the firing rule, where subtle variations on the algebraic properties can lead to other classes of Petri nets; for example, algebraic Petri nets.
The following formal definition is loosely based on. Many alternative definitions exist.
Syntax
A Petri net graph is a 3-tuple, where- S is a finite set of places
- T is a finite set of transitions
- S and T are disjoint, i.e. no object can be both a place and a transition
- is a multiset of arcs, i.e. it assigns to each arc a non-negative integer arc multiplicity ; note that no arc may connect two places or two transitions.
The preset of a transition t is the set of its input places: ;
its postset is the set of its output places:. Definitions of pre- and postsets of places are analogous.
A marking of a Petri net is a multiset of its places, i.e., a mapping. We say the marking assigns to each place a number of tokens.
A Petri net is a 4-tuple, where
- is a Petri net graph;
- is the initial marking, a marking of the Petri net graph.
Execution semantics
- firing a transition in a marking consumes tokens from each of its input places, and produces tokens in each of its output places
- a transition is enabled in if there are enough tokens in its input places for the consumptions to be possible, i.e. if and only if.
We say that a marking is reachable from a marking in one step if ; we say that it is reachable from if, where is the reflexive transitive closure of ; that is, if it is reachable in 0 or more steps.
For a Petri net, we are interested in the firings that can be performed starting with the initial marking. Its set of reachable markings is the set
The reachability graph of is the transition relation restricted to its reachable markings. It is the state space of the net.
A firing sequence for a Petri net with graph and initial marking is a sequence of transitions such that. The set of firing sequences is denoted as.
Variations on the definition
As already remarked, a common variation is to disallow arc multiplicities and replace the bag of arcs W with a simple set, called the flow relation,.This doesn't limit expressive power as both can represent each other.
Another common variation, e.g. in, Desel and Juhás, is to allow capacities to be defined on places. This is discussed under extensions below.
Formulation in terms of vectors and matrices
The markings of a Petri net can be regarded as vectors of nonnegative integers of length.Its transition relation can be described as a pair of by matrices:
- , defined by
- , defined by
For any sequence of transitions, write for the vector that maps every transition to its number of occurrences in. Then, we have
- .
Mathematical properties of Petri nets
One thing that makes Petri nets interesting is that they provide a balance between modeling power and analyzability: many things one would like to know about concurrent systems can be automatically determined for Petri nets, although some of those things are very expensive to determine in the general case. Several subclasses of Petri nets have been studied that can still model interesting classes of concurrent systems, while these problems become easier.An overview of such decision problems, with decidability and complexity results for Petri nets and some subclasses, can be found in
Esparza and Nielsen.
Reachability
The reachability problem for Petri nets is to decide, given a Petri net N and a marking M, whether.Clearly, this is a matter of walking the reachability graph defined above, until either we reach the requested marking or we know it can no longer be found. This is harder than it may seem at first: the reachability graph is generally infinite, and it is not easy to determine when it is safe to stop.
In fact, this problem was shown to be EXPSPACE-hard years before it was shown to be decidable at all. Papers continue to be published on how to do it efficiently. In 2018, Czerwinski et al. improved the lower bound and showed that the problem is not ELEMENTARY.
While reachability seems to be a good tool to find erroneous states, for practical problems the constructed graph usually has far too many states to calculate. To alleviate this problem, linear temporal logic is usually used in conjunction with the tableau method to prove that such states cannot be reached. Linear temporal logic uses the semi-decision technique to find if indeed a state can be reached, by finding a set of necessary conditions for the state to be reached then proving that those conditions cannot be satisfied.
Liveness
Petri nets can be described as having different degrees of liveness. A Petri net is called -live if and only if all of its transitions are -live, where a transition is- dead, if it can never fire, i.e. it is not in any firing sequence in
- -live, if and only if it may fire, i.e. it is in some firing sequence in
- -live if it can fire arbitrarily often, i.e. if for every positive integer, it occurs at least times in some firing sequence in
- -live if it can fire infinitely often, i.e. if there is some fixed firing sequence in which for every positive integer, the transition occurs at least times,
- -live if it may always fire, i.e. it is -live in every reachable marking in
These definitions are in accordance with Murata's overview, which additionally uses -live as a term for dead.
Boundedness
A place in a Petri net is called k-bounded if it does not contain more than k tokens in all reachable markings, including the initial marking; it is said to be safe if it is 1-bounded; it is bounded if it is k-bounded for some k.A Petri net is called k-bounded, safe, or bounded when all of its places are.
A Petri net is called bounded if it is bounded for every possible initial marking.
Note that a Petri net is bounded if and only if its reachability graph is finite.
Boundedness is decidable by looking at covering, by constructing the Karp–Miller Tree.
It can be useful to explicitly impose a bound on places in a given net.
This can be used to model limited system resources.
Some definitions of Petri nets explicitly allow this as a syntactic feature.
Formally, Petri nets with place capacities can be defined as tuples, where is a Petri net, an assignment of capacities to places, and the transition relation is the usual one restricted to the markings in which each place with a capacity has at most that many tokens.
For example, if in the net N, both places are assigned capacity 2, we obtain a Petri net with place capacities, say N2; its reachability graph is displayed on the right.
Alternatively, places can be made bounded by extending the net. To be exact,
a place can be made k-bounded by adding a "counter-place" with flow opposite to that of the place, and adding tokens to make the total in both places k.
Discrete, continuous, and hybrid Petri nets
As well as for discrete events, there are Petri nets for continuous and hybrid discrete-continuous processes that are useful in discrete, continuous and hybrid control theory, and related to discrete, continuous and hybrid automata.Extensions
There are many extensions to Petri nets. Some of them are completely backwards-compatible with the original Petri net, some add properties that cannot be modelled in the original Petri net formalism. Although backwards-compatible models do not extend the computational power of Petri nets, they may have more succinct representations and may be more convenient for modeling. Extensions that cannot be transformed into Petri nets are sometimes very powerful, but usually lack the full range of mathematical tools available to analyse ordinary Petri nets.The term high-level Petri net is used for many Petri net formalisms that extend the basic P/T net formalism; this includes coloured Petri nets, hierarchical Petri nets such as Nets within Nets, and all other extensions sketched in this section. The term is also used specifically for the type of coloured nets supported by CPN Tools.
A short list of possible extensions:
- Additional types of arcs; two common types are:
- *a reset arc does not impose a precondition on firing, and empties the place when the transition fires; this makes reachability undecidable, while some other properties, such as termination, remain decidable;
- *an inhibitor arc imposes the precondition that the transition may only fire when the place is empty; this allows arbitrary computations on numbers of tokens to be expressed, which makes the formalism Turing complete and implies existence of a universal net.
- In a standard Petri net, tokens are indistinguishable. In a Coloured Petri net, every token has a value. In popular tools for coloured Petri nets such as CPN Tools, the values of tokens are typed, and can be tested and manipulated with a functional programming language. A subsidiary of coloured Petri nets are the well-formed Petri nets, where the arc and guard expressions are restricted to make it easier to analyse the net.
- Another popular extension of Petri nets is hierarchy; this in the form of different views supporting levels of refinement and abstraction was studied by Fehling. Another form of hierarchy is found in so-called object Petri nets or object systems where a Petri net can contain Petri nets as its tokens inducing a hierarchy of nested Petri nets that communicate by synchronisation of transitions on different levels. See for an informal introduction to object Petri nets.
- A vector addition system with states is an equivalent formalism to Petri nets. However, it can be superficially viewed as a generalisation of Petri nets. Consider a finite state automaton where each transition is labelled by a transition from the Petri net. The Petri net is then synchronised with the finite state automaton, i.e., a transition in the automaton is taken at the same time as the corresponding transition in the Petri net. It is only possible to take a transition in the automaton if the corresponding transition in the Petri net is enabled, and it is only possible to fire a transition in the Petri net if there is a transition from the current state in the automaton labelled by it.
- Prioritised Petri nets add priorities to transitions, whereby a transition cannot fire, if a higher-priority transition is enabled. Thus, transitions are in priority groups, and e.g. priority group 3 can only fire if all transitions are disabled in groups 1 and 2. Within a priority group, firing is still non-deterministic.
- The non-deterministic property has been a very valuable one, as it lets the user abstract a large number of properties. In certain cases, however, the need arises to also model the timing, not only the structure of a model. For these cases, timed Petri nets have evolved, where there are transitions that are timed, and possibly transitions which are not timed. A subsidiary of timed Petri nets are the stochastic Petri nets that add nondeterministic time through adjustable randomness of the transitions. The exponential random distribution is usually used to 'time' these nets. In this case, the nets' reachability graph can be used as a continuous time Markov chain.
- Dualistic Petri Nets is a Petri Net extension developed by E. Dawis, et al. to better represent real-world process. dP-Nets balance the duality of change/no-change, action/passivity, time/space, etc., between the bipartite Petri Net constructs of transformation and place resulting in the unique characteristic of transformation marking, i.e., when the transformation is "working" it is marked. This allows for the transformation to fire multiple times representing the real-world behavior of process throughput. Marking of the transformation assumes that transformation time must be greater than zero. A zero transformation time used in many typical Petri Nets may be mathematically appealing but impractical in representing real-world processes. dP-Nets also exploit the power of Petri Nets' hierarchical abstraction to depict Process architecture. Complex process systems are modeled as a series of simpler nets interconnected through various levels of hierarchical abstraction. The process architecture of a packet switch is demonstrated in, where development requirements are organized around the structure of the designed system.
Restrictions
Instead of extending the Petri net formalism, we can also look at restricting it, and look at particular types of Petri nets, obtained by restricting the syntax in a particular way. Ordinary Petri nets are the nets where all arc weights are 1. Restricting further, the following types of ordinary Petri nets are commonly used and studied:- In a state machine, every transition has one incoming arc, and one outgoing arc, and all markings have exactly one token. As a consequence, there can not be concurrency, but there can be conflict. Mathematically:
- In a marked graph, every place has one incoming arc, and one outgoing arc. This means, that there can not be conflict, but there can be concurrency. Mathematically:
- In a free choice net, every arc from a place to a transition is either the only arc from that place or the only arc to that transition, i.e. there can be both concurrency and conflict, but not at the same time. Mathematically:
- Extended free choice – a Petri net that can be transformed into an FC.
- In an asymmetric choice net, concurrency and conflict may occur, but not symmetrically. Mathematically:
Work flow nets
The WF-net transitions are assigned to tasks or activities, and places are assigned to the pre/post conditions.
The WF-nets have additional structural and operational requirements, mainly the addition of a single input place with no previous transitions, and output place with no following transitions. Accordingly, start and termination markings can be defined that represent the process status.
WF-nets have the soundness property, indicating that a process with a start marking of k tokens in its source place, can reach the termination state marking with k tokens in its sink place. Additionally, all the transitions in the process could fire.
A general sound WF-net is defined as being k-sound for every k > 0.
A directed path in the Petri net is defined as the sequence of nodes linked by the directed arcs. An elementary path includes every node in the sequence only once.
A well-handled Petri net is a net in which there are no fully distinct elementary paths between a place and a transition, i.e., if there are two paths between the pair of nodes then these paths share a node.
An acyclic well-handled WF-net is sound.
Extended WF-net is a Petri net that is composed of a WF-net with additional transition t. The sink place is connected as the input place of transition t and the source place as its output place. Firing of the transition causes iteration of the process.
WRI WF-net, is an extended acyclic well-handled WF-net.
WRI-WF-net can be built as composition of nets, i.e., replacing a transition within a WRI-WF-net with a subnet which is a WRI-WF-net. The result is also WRI-WF-net. WRI-WF-nets are G-sound, therefore by using only WRI-WF-net building blocks, one can get WF-nets that are G-sound by construction.
The Design structure matrix can model process relations, and be utilized for process planning. The DSM-nets are realization of DSM-based plans into workflow processes by Petri nets, and are equivalent to WRI-WF-nets. The DSM-net construction process ensures the soundness property of the resulting net.
Other models of concurrency
Other ways of modelling concurrent computation have been proposed, including process algebra, the actor model, and trace theory. Different models provide tradeoffs of concepts such as compositionality, modularity, and locality.An approach to relating some of these models of concurrency is proposed in the chapter by Winskel and Nielsen.