Petri Charts: an Alternative Technique for Hierarchical Net Construction. Tom Holvoet and Pierre Verbaeten. Dept. of Computer Science. K.U.Leuven, Belgium.
Petri Charts: an Alternative Technique for Hierarchical Net Construction Tom Holvoet and Pierre Verbaeten Dept. of Computer Science K.U.Leuven, Belgium
Abstract In this paper, we present a new formalismfor modelling concurrent systems, called Petri charts, which is based on Petri nets and statechart principles. It aims at bene ting from the power of both methods in order to provide a modelling method that has substantial expressive power and abstraction functionalities, which are necessary for introducing a formal method into the eld of modelling real-world applications. Intuitively, one can say that Petri charts enhance Petri nets by introducing depth: a place (transition) may be re ned by a subnet, retaining the original place (transition) as a super-place (super-transition). Besides being a high-level modelling technique, Petri charts allow to combine net re nements and net composition operators, two mechanisms for modular development of Petri nets. Basic formal de nitions and the Petri chart method are presented. We also de ne a transformation on Petri charts yielding Petri nets. It enables the reuse the available research results in the area of P/T nets, which is an important bene t.
1 Introduction / Motivation Several methods have been proposed for modelling (complex) concurrent systems. One method is Petri nets. They oer a formalism that has the advantage of being simple, powerful, and they have a substantial theoretical baggage, since they have been the subject of intensive research for many years. Abstraction and modularisation are two ways that have been proposed for developing nets for large systems. Abstraction aims at modelling a system at different levels of detail (\vertical development"). The abstraction mechanism can be subdivided into two categories: local transformations { net re nements, emphasising on the re nement of isolated net elements (places/transitions) { and global transformations { general behaviour-oriented net morphisms, Research Assistant
of the Belgian Fund for Scienti c Research
such as abstraction morphisms ([4]) and vicinity respecting net morphisms ([3]). Modularisation can be viewed as a \horizontal development technique". Several system entities are identi ed and separately modeled. These modules are then interrelated as to constitute one overall system model. This can be realised by net composition mechanisms ([1]). Combining abstraction and modularisation would yield an interesting net development technique which, to our knowledge, has not explicitly been researched yet. Another method for modelling concurrent systems is statecharts. It is based on state diagrams, where depth is introduced by re ning states by state diagrams, retaining the original states as superstates, and orthogonal states allow the description of independent (concurrent) parts of the system. In this paper, we present Petri charts. Petri charts are a natural adoption of statechart principles in the theory of Petri nets. Depth is introduced by allowing the re nement of a place (transition) by a subnet without eliminating the original place (transition). The re nement net is inserted and suitably interconnected with the parent net. The main deliverables of Petri charts are that: they bene t from the abstraction mechanisms of statecharts, based on hierarchical development; they enable the combination of net re nement and composition techniques in a clean and natural way; they can reuse the available research results in the domain of Petri nets { this is important since it implies that we do not to have to start from scratch. In Section 2, we present some basic de nitions and properties of Petri charts. We show how Petri charts theory can rely on Petri net research in section 3, by de ning a mapping which transforms a Petri chart
onto a (non-hierarchical) P/T net. Finally, Section 4 elaborates on an behaviour-preserving Petri chart construction, a formally justi ed way of system modelling.
2 Petri Charts Petri charts arose from combining Petri nets with statechart principles. Statecharts have been proposed by D. Harel as a formalism for specifying and designing complex systems. As he states in [5], one can say: \statecharts = state-diagrams + depth + orthogonality + broadcast-communication". The introduction of orthogonal states allows the description of independent (concurrent) parts of the model. Depth is achieved by re ning states by state-diagrams, retaining the original states as super-states. To make the analogy, we could say: \Petri charts = Petri nets + depth" (aspects of concurrency are an intrinsic property of nets). Re ning a place (transition) by a re nement net, with-holding the original place (transition), results in a hierarchical construction technique, similar to the one of statecharts. An example should give a rst clue on what Petri charts are like. The example in Figure 1 shows a Petri chart with two levels. At one level, it is similar to a Petri net consisting of two places (sp en cp) and two transitions (st en ct). At another level, considering the re nement of cp and ct, we obtain a more detailed model. A Petri chart is a bipartite graph, consisting of places and transitions. Places (transitions) are either simple places (simple transitions) or chart places (chart transitions). A chart place (chart transition) is a Petri chart component that is re ned by a Petri chart (these Petri charts may act independently). An arrow whose origin is a chart place identi es a ow relation between a set of nal subplaces (darkly shaded) of the chart place and a transition. The idea is that the subplaces represent substates of the original place. This freedom of choice for token extraction from nal subplaces may be restricted by additional arrows between nal subplaces and the original arrow. It allows to specify in more detail what substates the chart place should be in before the transition can re. E.g. in Figure 1, the chart transition ct can re if a token is present in sp5 and another token is present in either sp3, sp4 or sp5. The activity of a Petri chart resembles that of Petri nets (P/T-nets with weighted arrows and in nite capacities). Transitions constitute the active part of a Petri chart. A transition may re when to-
cp
ct
st2
sp1 st1 st3 sp4
sp3 sp2
sp6 st7
st5
2
st9 sp8
sp7
st4 sp5
st8 st11
st6
st10
2
st
sp
Figure 1: A simple Petri chart kens are available from the input places of the transition. A simple transition appropriately shifts tokens to the transition output places; a chart transition enables one of the transition input transitions (lightly shaded), and shifts tokens to the output places as soon as one of the ouput transitions (darkly shaded) has red. In the example of Figure 1, the only transition that can re is st1, inserting a token in sp3. In this new situation, either st2 or tc can re. When tc res, tokens are removed from sp3 and sp5 and either st5 or st6 can re. If eventually st9 or st10 res, a token is inserted into sp. St then res by inserting a token into sp1 and sp2; and so on.
Basic De nitions We will now provide some basic de nitions for Petri charts. First we de ne what the underlying graph of a Petri chart is like. It is a recursive de nition. Actually, almost all de nitions and properties will include recursion due to the hierarchical nature of Petri charts.
De nition 2.1 A Petri chart Gestalt is a triplet C = (P ; T ; F ), where 1. P is the set of places, P = SP [ CP , the union of simple places and chart places, with 8cp 2 CP : cp is a quadruplet (D ; I ; O ; F ), where (a) D is a Petri chart Gestalt, D = (P cp ; T cp ; F cp ), (b) I P cp , O P cp , the initial resp. C
C
C
C
C
C
C
C
cp
cp
cp
cp
cp
cp
D
D
D
cp
cp
D
nal subplaces of cp,
(c) F
cp
F j( C
(F j (
cp;cp )
D
) I ) [ (O ), i.e. the ow relation between C
cp;cp
cp
cp
the input and output transitions of the place and the initial resp. nal subplaces; 2. T is the set of transitions, T = ST [ CT , the union of simple transitions and chart C
C
C
C
transitions, with 8ct 2 CT : ct is a triplet (D ; I ; O ), where (a) D is a Petri chart Gestalt, D = (P ct ; T ct ; F ct ), (b) I T ct , O T ct , the initial resp. nal subtransitions of ct; 3. F (P T ) [ (T P ), the ow relation of the Petri chart. We de ne: 1. 8p 2 P : p = ft 2 T : (t; p) 2 F g, and p = ft 2 T : (p; t) 2 F g, the pre-set resp. post-set of p, 2. 8t 2 T : t = fp 2 P : (p; t) 2 F g, and t = fp 2 P : (t; p) 2 F g, the pre-set resp. post-set of t; C
ct
ct
ct
ct
ct
ct
C
D
D
D
ct
D
C
C
D
C
C
C
C
C
C
C
C
C
C
C
C
2
Petri chart activity is based on a token game. The formal instrument for describing the presence of tokens in places is the marking of a Petri chart.
De nition 2.3 A marking in a Petri chart is a set of functions: 1. M : P ! IN 2. 8cp 2 CP : C
C
C
M : P ! IN and 8cp0 2 CP : M 0 : P 0 ! IN cp
cp
cp
and so on, 3. 8ct 2 CT : C
ct
ct
ct
C
C
C
C
C
with: 1. 8cc 2 CT [ CP : (a) D , the corresponding Petri chart, is a weighted Petri chart with weight function W cc : F cc ! IN 0 , (b) and if cc 2 CP , a weight function W : F ! IN 0. 2. 8f = (t; cp) 2 F ; cp 2 CP : C
C
cc
D
D
C
cc
cc
X
C
f0
C
=(f;p0 )2Fcp
W (f 0 ) = W (f) cp
C
(the input arrow of a chart place is exhaustively subdivided into input arrows of initial places) 3. 8f = (cp; t) 2 F ; cp 2 CP :
X
C
f0
C
=(f;p0 )2Fcp
W (f ) W (f) cp
0
C
We write S W(f) to denote the weight S of f (f 2
F [ 2 C (F cp [ F [ : : :) [ 2 C (F ct [ F [ : : :)) according to its respective weight function (W ; W cp ; W ; W ct ; : : :). 2 C
cp
cp
D
CP
ct
C
D
cp
D
ct
CT
D
ct
ct
and so on. We write S M(p) to denote the marking of p (p 2 P [ (P cc [ P [ : : :)) according to its respective marking function (M ; M cc ; M ; : : :). 2 cc
cc
D
C
De nition 2.2 A Weighted Petri chart (or Petri chart for short) is a Petri chart Gestalt C = (P ; T ; F ), with a weight function W : F ! IN 0 ,
cp
M : P ! IN and 8ct0 2 CT : M 0 : P 0 ! IN
C
Arrows can be annotated with a weight, indicating the number of tokens to be shifted on transition ring (similar to weights in Petri nets), resulting in weighted Petri charts.
cp
cc
D
The initial marking of a Petri chart is denoted by M0 . A pair < C; M0 > is called a Petri chart system (also abbreviated Petri chart). The set of Petri chart systems is denoted by PC (the set of P/T-nets is denoted by PT ). Other de nitions can easily be adopted from the eld of Petri nets, such as actionlabeled Petri charts, [M0> (the set of reachable markings), M[e>M 0 (M 0 is the marking followed by M when a transition labeled with event e res), and so on. In order to de ne transition enabledness in Petri charts, we de ne an additional function, called the available marking. Intuitively, the available marking of a simple place equals its marking, the available marking of a chart place for a given output arrow is the amount of tokens that can be extracted from the nal subplaces of the chart place.
De nition 2.4 The available marking in a Petri chart is a set of functions: AM : P [ (P F ) ! IN 1. AM(p): p 2 SP ) = M(p) P p 2 CP ) = 0 2 p AM(p0 ) 2. AM(p,f), f = (p,t): p 2 SP ) = M(p) p 2 CP ) = C
C
C
C
C
p
O
C
X
f 0 =(p0 ;f )
C
min(AM(p0 ; f 0 ); W(f 0 ))
+ min ( W(f) ?
X
f0
=(p0 ;f )
W(f 0 ) ;
X f 0 =(p0 ;f )
max ( AM(p0 ; f) ? W(f 0 ) ; 0 )
+
X
p0
with
2
69f 0 =(p0 ;f )
AM(p0 )
)
Before de ning enabledness, we should say that a chart transition res in three phases. First, if the preconditions to re are allowed, the chart transition is in state \starting to re". As soon as one of its initial transitions has red, it is in state \ ring", until one of its nal transitions res (returning into state \idle").
De nition 2.5 Enabledness. 1. t 2 T is enabled in C , 8f = (p; t) 2 F : AM(p; f) W(f) 2. let t 2 CT , t = ( (P | ; T{z; F }) ; I ; O ): C
C
C
t
t
D
t
t
t
t
(a) t 2 I ) t' is enabled , t' is enabled in D and t is in state \starting to re" (b) t0 2 T n I ) t' is enabled , t' is enabled in D 0
t
t
t
t
t
2
then be analyzed either through Petri chart de nitions or through the corresponding P/T-net, relying on Petri net research. Keeping this goal in mind, we should ensure a stringent behaviour compatibility between a Petri chart and the P/T-net after transformation. This behaviour compatibility should be thought of as a kind of behavioural bisimilarity. Every activity in a Petri chart should have a corresponding activity of its transformed counter-part resulting in similar states, and vice versa. The transformation, however, will merely be used for theoretical purposes (for de ning Petri chart properties, for analyzing its behaviour, and so on), since the resulting P/T-net grows fast as the level of hierarchy of the Petri chart increases. This fact also indicates the enhanced expressive power that Petri charts oer compared to P/T-nets. The transformation operator, called level-out, is de ned as level-out = level-out-place level-outtrans, i.e. the composition of an operator yielding a Petri chart without chart transitions { level-out-trans { and level-out-place, transforming a Petri chart without chart transitions into a P/T-net. level?out : PC ! PT level?out?trans : PC ! PCj C =; level?out?place : PCj C =; ! PT Due to space limits, we restrict ourselves to illustrating the transformation operator instead of providing a thorough formal de nition. Let us level out the Petri chart presented in Figure 1. Applying level-out-trans would yield the Petri chart given in Figure 2. A new transition, starting, is added (representing the start of the ring of the chart transition t) and the ow relation is correspondingly adopted. Performing the level-out-place on this intermediate Petri chart results in a P/T-net (see Figure 3), which is basically constructed by replicating the transition t that depends on nal subplaces of the chart place. The replication stems from the choice of preconditions of t among the nal subplaces. This transformation can be used to provide de nitions and properties for Petri charts based on de nitions and properties of the corresponding Petri net. CT
A thorough de nition for the ring rule is omitted here due to lack of space. We rely on the reader's intuition since it is rather obvious how tokens are shifted. Similar to Petri nets, we can de ne properties on Petri charts, such as liveness and boundedness. Property S 2.1 A Petri chart C is called live if 8t 2 T [ ( 2 C [ C T cc [ : : :); 8M 2 [M0>: 9M 0 2 [M> such that t is enabled. 2 C
cc
CP
CT
D
Property 2.2 A Petri chart C is called bounded if 9m 2 IN : 8p 2 P : M(p) < m, and 8cc 2 CP [ CT : D is bounded. 2 3 Reusing Petri Net Research Results C
C
C
cc
Petri nets make a good formalism for modelling concurrent systems, and they come with a substantial theoretical baggage. Being able to reuse Petri net research in the area Petri charts implies an unmistakable advantage. For that purpose, we de ne a transformation operator on Petri charts, yielding Petri nets, in particular weighted P/T-nets with in nite capacities. The behaviour and properties of a Petri chart model can
CT
4 Petri Chart Construction Petri charts are presented in this paper as a exible formalism for modelling concurrent systems. Dierent levels of detail of the model can be considered
cp
st2
st5
sp1 st1 st3
sp3
sp4
2 st6
st4 sp5
2
st
init
st8 st11
st10
Figure 4: A well-consuming Petri chart
sp
Figure 2: The result of level-out-trans on the Petri chart example. st2
st5
sp6 st7
sp1 st1 st3
sp3 sp2
sp4
st9 sp8
sp7
starting st6
st4 sp5 starting
st8 st11
st10
2 starting st
cp
st9 sp8
sp7
starting
sp2
sp6 st7
sp
one here. We consider a \behaviour-preserving re nement of a simple place by a well-consuming Petri chart". A well-consuming Petri chart is a particular Petri chart, consisting of one simple place, and one chart place, with an additional behavioural restriction.
De nition 4.1 A well-consuming Petri chart is a Petri chart system with
1. SP = finitg; CP = fcpg; CT = ;;
Figure 3: The result of level-out-place on the obtained Petri chart. depending on whether chart components are considered unre ned simple places and transitions or re ned components. Modelling a system using Petri charts is a topdown, step-wise re nement development technique. We can distinguish between two Petri chart construction methods, which dier by at what point behaviour and other formal properties are analysed. The rst method is initially only interested in the top-down development of a model. To obtain a more detailed model, simple places and simple transitions may be replaced by respective chart components and suitably interconnected with the original net. Formal (structural and behavioural) analysis is performed on an entire model, e.g. by analysing the corresponding Petri net. Another method uses stepwise analysis through behaviour-preserving re nements. The idea of this method is similar to the idea of behaviour-preserving re nement of Petri nets: depending on properties of the original net and the subnet, properties can be deduced for the resulting re ned net. An example is a \behaviour-preserving re nement1 of a transition by a well-formed block". This and other re nements that have been de ned in the context of Petri nets can easily be reformulated for Petri charts, allowing the reuse of the associated behaviour-preservation rules. However, alternative behaviour-preserving re nements can be de ned for Petri charts. We will present 1 For an overview of behaviour-preserving net re nements, the reader is referred to [2].
C
C
C
M(init) = 1 2. F is such that t = finitg or fcpg; t = finitg or fcpg 3. 8M 2 [M0>; 8M 0 2 [M>: M 0cp > M(p) ) 8M 00 2 [M 0 >: 8op 2 O : 9M 000 2 [M 00>: M 000(op) = M 0 (op) + (M 0 (p) ? M(p)) C
cp
2 Intuitively, a Petri chart is called well-consuming if every token input in the chart place can be withdrawn from any nal subplace. An example is presented in Figure 4. We can use well-consuming Petri charts to de ne a behaviour-preserving re nement of a simple place: we replace a simple place sp of a Petri chart C by the chart place cp of a well-consuming Petri chart D, interconnected as in the well-consuming Petri chart (notation: C[sp=D]). This yields a step-wise re nement method with intermediate analysis of the obtained model. The following result can be used for behaviour-preserving Petri chart construction.
Theorem 4.1 Let C be a Petri chart, sp 2 SP a simple place, and D a well-consuming Petri chart with chart place cp, with jspj = jcpj and jsp j = jcpj, C
with the same weights for corresponding arrows between the transitions and the chart place cp in D and between the transitions and the simple place sp in C. Then we have: 1. C and D are live ) C[sp=D] is live;
harbour
boat
refined boat
free sailing
moor
harbour moor free
... ...
sailing
... ...
occupied composition
Figure 5: A composition of two simple transitions 2. C is m-bounded, D is m'-bounded ) C[sp=D] is max(m,m')-bounded; 3. C[sp=D] is bounded , C and D are bounded.
2 Another issue on constructing a Petri chart model concerns the combination of re nements and composition. Besides net re nements, where the Petri chart hierarchy is based on, composition of Petri nets have also been proposed as a modularization mechanism: several parts of a system are modeled separately, and they are composed as to model the cooperation between the dierent entities. It is a way to describe synchronisation and communication between the entities. Petri charts can be used to combine re nements and composition operators. Let us illustrate what we mean. Consider two entities, a boat and a harbour, e.g. each modeled by a Petri chart. In order to synchronise the activity of a boat mooring and the harbour becoming occupied, we describe a composition by transition merging, depicted in Figure 5. If at this point, we want to re ne our model to introduce more details, we could choose to re ne the moor transition by a Petri chart (modelling the entering of the boat in the harbour and either anchouring or tying it with cables, resulting in the Petri chart in Figure 6. The composition description for a re ned boat and a harbour is still valid, which would not be possible with
at Petri nets.
5 Conclusion In this paper we introduced Petri charts, a formalism for modelling concurrent systems that combines Petri nets and statechart principles. The Petri chart method allows hierarchical development of models and reasoning upon a model at dierent levels of abstraction. The transformation from Petri charts onto P/T-nets oers the possibility to reuse research results from the domain of Petri nets in the Petri chart formalism. Another deliverable is that Petri charts
occupied composition
Figure 6: A composition of a chart transition and a simple transition constitutes the basics for a development method that combines the ideas of net re nement and net composition. The idea for developing Petri charts arose from research concerning PN-TOX [6], a paradigm and development environment for concurrent objectoriented programming using Petri net concurrency speci cations. Modelling object cooperation through composition of the net representation of objects and using inheritance yields a good situation for applying the combination of net re nement and net composition, where Petri charts play an essential role. Here, we presented some basic de nitions and properties, and one example of behaviour-preserving Petri chart re nement. However, a lot of topics need to be researched in order to establish Petri charts as a complete formalism(structural and behavioural properties, equivalence relations, and so on). The transformation of Petri charts onto Petri nets is assumed to play an important role in that research.
6 References [1] L. Bernardinello and F. De Cindio. A Survey of Basic Net Models and Modular Net Classes. In Advances in Petri Nets '92, pages 304{351, 1992. [2] W. Brauer, R. Gold, and W. Vogler. A Survey of Behaviour and Equivalence Preserving Re nements of Petri Nets. In Advances in Petri Nets '90, pages 1{46, 1990. [3] J. Desel. Vicinity Respecting Net Morphisms. In Advances in Petri Nets '90, pages 165{185, 1990. [4] J. Desel. On Abstractions of Nets. In Advances in Petri Nets '91, pages 78{92, 1991. [5] D. Harel. Statechart: a Visual Formalism For Complex Systems. Science of Computer Programming, 8:231{274, 1987. [6] T. Holvoet and P. Verbaeten. PN-TOX: a Paradigm and Development Environment for Object Concurrency Speci cations. In Workshop on Object-Oriented Programming and Models of Concurrency, ICATPN'95, Turin, Italy, 1995. To appear.