{'fraction_non_alphanumeric': 0.035514228097692134, 'fraction_numerical': 0.007020688624990664, 'mean_word_length': 4.793812202509736, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Generation of Petri Nets Using Structural Property-Preserving Transformations

In this paper, we present an approach to the generation of Petri nets exhibiting desired structural and behavioral properties. Given a reference Petri net, we apply a collection of local refinement transformations, which extends the internal structure of the reference model. The correctness of applying these transformations is justified via Petri net morphisms and by the fact that transformations do not add new deadlocks to Petri nets. We have designed two Petri net refinement algorithms supporting the randomized and fixed generation of models. These algorithms have been implemented and evaluated within the environment of the Carassius Petri net editor. The proposed approach can be applied to evaluate and conduct experiments for algorithms operating with Petri nets.


Introduction
Petri nets are widely used to formally represent the behavior of distributed systems for their precise semantics, which helps to prove many crucial behavioral properties, including boundedness, deadlock-freeness, covering by place invariants, and others [1]. The automated verification of these properties is supported by different algorithms. For instance, covering by place invariants can be decided using linear algebraic techniques [2]. The software implementation of algorithms operating with Petri nets naturally requires the preparation of model sets that exhibit the specific structural and behavioral properties. Such sets of models are then used for the thorough evaluation of algorithms under development. Firstly, the manual generation of Petri nets with specific properties is a time-consuming activity. Moreover, if one has to prepare a particularly large-scale model, then there arises an additional task to verify the necessary properties of this model. The computational cost of such a verification can grow too fast due to the well-known state-explosion problem of distributed systems, when the number of reachable states grows exponentially compared to the size of a system model. In our paper, we propose an approach to the generation of Petri nets based on structural transformations. Firstly, a reference Petri net is constructed. This model has all the target structural and behavioral properties. Secondly, applying a collection of local transformations that extend the internal structure of a reference Petri net, we obtain a refinement exhibiting the same properties as an initial reference model. The general scheme of this approach is schematically shown in fig. 1, where a refinement is a result of applying k local transformations to a reference Petri net. Note that a refinement has the more sophisticated structure than a reference model. Transformations, considered in our study, are called local, since they change only the specific part of a model, while the rest of the model remains untouched. The mathematical framework of these transformations is responsible for preserving the structural and behavioral properties of a reference Petri net. In addition, the application of transformations requires only the local checks of structural constraints.

Fig. 1. Step-wise generation of a Petri net
We consider two generation schemes: fixed and randomized. Within the fixed generation of Petri nets, a specific sequence of transformations is applied to an initial reference model. Conversely, the randomized generation is a based on a non-deterministic choice of transformations. Thus, the main results of our paper are as follows: the algorithms for the fixed and randomized generation of Petri nets from a given reference model; the software implementation and evaluation of these algorithms within the environment of the Carassius Petri net editor [3]. The remainder of this paper is structured as follows. The next section discusses the related research. In Section 3, we define a class of Petri nets considered in our paper. Section 4 describes the mathematical framework behind a collection of structural transformations that are used to refine structural relations between abstract models and their refinements. Concerning our approach to the Petri net generation, a reference Petri net represents an abstract model. In addition, α-morphisms preserve the behavioral properties (reachable markings) as well as reflect them under the specific local requirements. Since the direct application of α-morphisms is rather difficult for the sophisticated constraints to be checked, a collection of local transformations proposed in [17] can be used to define α-morphisms systematically in a step-by-step way. These transformations are used in our study to generate Petri nets, which preserve the properties of an initial reference model. Correspondingly, the mathematical framework behind transformations, which provide the property preservation, is based on αmorphisms. The existing open-source Petri net editors, among the others, include Platform Independent Petri Net Editor [18,19], PNEditor [20], WoPeD [21,22], Wolfgang [23], Carassius [3]. They allow modeling, simulating and analyzing the behavior of Petri nets. The problem of the model generation has not been considered within these editors. In our study, we will extend the functionality of the Carassius Petri net editor to provide the generation of Petri nets with the desired structural and behavioral properties.

Elementary Net Systems
In our study, we consider the generation of elementary net systems (EN-systems). They form the fundamental class of Petri nets used to model the control-flow of distributed systems, while other aspects such as data and time are not considered. The structure of EN-systems is modeled using bipartite graphs with two kinds of nodes: places and transitions. Places in an EN-system can carry at most a single token. Thus, they can be interpreted as boolean conditions, truth values of those are changed by transition firings. Below we provide the formal definitions based on [15] concerning the structural and behavioral aspects of EN-systems. Let be a set. The set of all finite non-empty sequences over is denoted by , and * = ∪ }, where is the empty sequence. 2) • = ∈ | ( , ) ∈ } is the postset of .
The standard graphical notation is adopted: places are shown with circles, and transitions are shown with boxes.
In our work, we consider nets without self-loops, i.e., ∀ ∈ ∪ : • ∩ • = ∅ and isolated transitions, i.e., ∀ ∈ : |• | ≥ 1 and | •| ≥ 1 . is covered by sequential components if every place belongs to at least one sequential component. In this case, is state machine decomposable (SMD). Reachable markings in SMD-EN systems are free from contacts. State machine decomposability is a basic feature bridging the structural and behavioral properties of EN-systems [15]. The example shown in fig. 2 provides an SMD-EN system with three sequential components: A (dotted line), B (dashed line), and C (dash-dotted line). Sequential components A, B, C have independent parts (concurrent behavior) and synchronous transitions, e.g., transition , which will be executed by A and B simultaneously. Each token of a reachable marking in an SMD-EN system can be characterized by sequential components. For instance, a token in , shown in fig.  2, belongs to two of three sequential components: A and B.

Fig. 2. SMD-EN system with three sequential components
Further, we work with SMD-EN-systems unless otherwise stated explicitly. Thus, we omit the SMD abbreviation in their descriptions.

Refinement of EN-systems
In this section, we discuss the mathematical framework behind our approach to the generation of EN-systems using refinement transformations. Firstly, we consider -morphisms formalizing relations between abstract and refined EN-systems [16]. Secondly, we describe a set of local ENsystem transformations that induce corresponding -morphisms and define them in a step-wise manner [17].

Morphisms
A class of -morphisms has been introduced in [16] to formalize relations between an abstract ENsystem and its refinement, where subnets in a refined model can substitute places in an abstract model. Using the example shown in fig. 3, we briefly discuss the main intuition behindmorphisms. 160 An -morphism : → is a total surjective map from the set of nodes of a refined EN-system on the set of nodes of an abstract EN-system . Places in an abstract EN-system can be refined with \emph{acyclic} subnets in its refinement. For example, subnet ( ( )) refines place in shown in fig. 3. The refinement of places can also result in a split of transitions, e.g., transition in is split into two transitions, and , in , as shown in fig. 3. An -morphism : → is defined in terms of how transitions in are mapped to nodes in . If the image of transition in is also a transition in , then their neighborhoods should correspond as well. For instance, since the image of transition in shown in fig. 3 is transition in , the image of • • is • •. If the image of transition in is a place in , then the image of its neighborhood is this place as well. For instance, transitions in subnet ( ( )) are mapped to place in as well as their neighborhoods. These constraints combined with several other structural restrictions imposed on subnets in a refined EN-system, discussed in detail in [16], assure the main motivation behind -morphisms: a refinement should behave «in a similar way» as an abstract model does. Whenever there is a token in a place in abstract EN-system, there exists the possibility to fire a transition that puts a token into a corresponding subnet in a refined EN-system, s.t. the other input transitions remain disabled afterwards (see Lemma 1 in [16]). The direct application of -morphisms is rather difficult for their sophisticated structural constraints. An approach based on the subsequent application of local structural transformations [17] comes to the aid of this problem. It is discussed in the following section, where we redefine the refinement notion through these transformations.

Refinement Transformations
The main idea of structural transformations, defined in [17], lies in a step-by-step construction of a refined model from an abstract one. These transformations are called local because they change only a specific subnet in an initial model, while the rest of the model remains untouched. As shown in [17], every step of applying a transformation to an EN-system induces a corresponding -morphism from a transformed model to an initial one. Moreover, after a series of transformations is applied to an EN-system, there will be an -morphism from a result EN-system towards an initial EN-system. Fig. 4 shows the main idea of this approach, where R is a refinement obtained from A by a sequential application of k transformations, s.t. there is an -morphism : → , and R preserves the behavioral properties of A, especially the presence or absence of deadlocks.

Fig. 4. Refinement based on transformations and $\alpha$-morphisms
Structural transformations help us to reconsider the notion of a refinement without referring to the formal definition of -morphisms. In addition, within the framework of our approach to the Petri net generation, transformations play a crucial role. A reference model (see fig. 1) is an abstract ENsystem, and its refinement is a result of applying transformations. We next briefly consider the key aspects of refinement transformations, described in [17]. A transformation is a tuple = ( , , , ), where: 1) is the left part -a subnet to be transformed.

2)
is the right part -a subnet replacing .
Constraints and are structural and marking restrictions. They are responsible for corresponding -morphisms. The application of a transformation to an EN-system involves (1) finding a match for in according to , i.e., subnet ( ) with ⊆ ∪ and (2) replacing ( ) with according to . The result of applying to is denoted by ( , ). We write → ′ if ′ = ( , ) and the specification of an affected subnet is not important. The set of four refinement transformations = , , , } is described in Table 1, where we provide their constraints as well. Intuitively, adds concurrency, and introduce and extend choices, while adds a new transition into an initial model. Then we can define a refinement as an EN-system that is obtained by applying a sequence π ∈ * of refinement transformations to another EN-system, as formally given below. . Let us consider the example of applying transformation to place in the EN-system shown in fig. 2. According to Table 1, there are no specific restrictions imposed on a place in the left part of . Then, we can replace place with a subnet, corresponding to the right part of , as shown in fig. 5. Since is not marked, added places are also not marked. As proven in [17], refinement transformations do not introduce new deadlocks, unless they are already present in an initial EN-system, i.e., the deadlocks in a transformed EN-system are the inverse images of the deadlocks, present in an initial EN system (under the correspondingmorphism). Thus, the following proposition holds. Proposition 1: Let = ( , , , ) be an EN-system with = 1, 2 s.t. is a refinement of . If is deadlock-free, then is deadlock-free as well. Now we can proceed to the design and implementation of algorithms, which use the set of refinement transformations to generate EN-systems.

Generation Algorithms
In this section, we discuss two algorithms that support the automated generation of EN-systems, using the structural transformations, described in Table 1, according to Definition 3. The first algorithm corresponds to the generation of an EN-system by applying a fixed sequence of the refinement transformations to an initial model. The second algorithm corresponds to the randomized EN-system generation, parameterized with the probability of applying each transformation.

Fixed Generation of an EN-system
Algorithm 1 corresponds to a direct implementation of Definition 3. There is a fixed finite sequence, = . … ∈ * , of refinement transformation to be applied to an EN-system = ( , , , ).
If a current transformation can be applied to some subnet generated by ′ ∈ ′ ∪ ′, then we replace with a result of applying to . If a current transformation can be applied to different subnets, the choice is made non-deterministically (it may be determined by the specific implementation of Algorithm 1). Otherwise, if a current transformation cannot be applied to a subnet in , we skip it and pass on to the next transformation in a sequence . The correctness of the fixed generation algorithms follows from (a) the finitness of (the algorithm always terminates) and (b) Proposition 1, i.e., an obtained refinement preserves the deadlockfreeness of .

Randomized Generation of an EN-system
Within the randomized generation algorithm, presented in this paragraph (see Algorithm 2), a sequence of refinement transformations is not known in advance, as opposed to the fixed generation. A specific sequence of refinement transformations is constructed with respect to the parameters defined by a user.
The randomized generation parameters include: 1) The maximum size of a refinement -the number of places and transitions; 2) The maximum number of steps -the number of applied transformations; 3) The probability of choosing a specific refinement transformation -the value in the interval [0, 1]. Probabilities are set for the four refinement transformations, s.t. the sum of all four probabilities is equal to 1. Below we describe how the specific refinement transformation is chosen at each step of Algorithm 2. Firstly, we find a set of refinement transformations that can be applied to a given EN-system (function findApplicable( , ) ), according to constraints given in Table 1. Secondly, we normalize the probabilities of the applicable transformations in and obtain the values of ′ function. Then, by generating a random number , we choose the specific refinement transformation . Intuitively, we divide the interval [0, 1] into sub-intervals, according to the normalized probabilities of applicable refinement transformations, and check where the value of is. We assume to use the uniform distribution for the random number generation. The correctness of Algorithm 2 follows from the fact that (a) the total number of steps (the actual length of an applied transformation sequence) is bounded by the maximum size of a refinement and by the maximum number of steps that can be done; and from (b) Proposition 1, i.e., a constructed refinement preserves the deadlock-freeness of .

Example: the Fixed Refinement of an EN-System with a Deadlock
Here we consider an example of applying the fixed generation algorithm to the EN-system that has a deadlock (see fig. 6, where has the deadlock { } reachable from its initial marking , }).
Let = ∈ * be a sequence of refinement transformation to be applied to .

Fig. 6. EN-system with a deadlock
A possible result of applying to is provided in fig. 7, where we show transformations affecting disjoint subnets as a single step. It can be seen that none of the -elements in have been applied to , since there are no places with two or more input transitions. That is why they have been skipped in this example. What is more important is that the reachable deadlock { } have not been lost in the transformed EN-system. The inverse image of { } (under the corresponding -morphism, refer to fig. 4) in the transformed EN-system is also the reachable deadlock }, as formally proven in [17]. New deadlocks have not been introduced into the transformed EN-system.

Example: a Step in the Randomized Refinement of a Deadlock-Free EN-System
In this paragraph, we consider a step of Algorithm 2 in more detail. Given the EN-system shown in fig. 8 and the following probabilities: ( ) = 0.15 , ( ) = 0.10 , ( ) = 0.05, ( ) = 0.7, we will show how the choice of a refinement transformation is performed.
We start with finding the applicable transformations. Here we have that only , , and can be applied to the EN-system from fig. 8. Their normalized probabilities are: ( ) = 0.50 , ( ) = 0.33, and ( ) = 0.17.

Fig. 8. Deadlock-free EN-system
Then we generate a random number . Let = 0.73. We check where the value of is in the interval [0,1$ concerning the cumulative normalized probabilities (see fig. 9).

Fig. 9. Checking the placement of the random number
The value of is in the interval [0.5, 0.83], corresponding to the refinement transformation . Thus, we apply this transformation to the EN-system from fig. 8, and a possible result is shown in fig. 10, if we choose transition to be transformed. Then, according to Algorithm 2, we continue choosing refinement transformations, according to their probabilities, until we reach either the limit of the size or the limit of the total number of applied transformations.

Software Implementation and Evaluation
In this section, we describe details concerning the implementation of the two generation algorithms discussed in the previous section. We have evaluated the randomized generation algorithm using Petri net models for interaction patterns described in [24] as reference models. They provide a highly abstract view of typical asynchronous agent interactions, whereas a refinement of an interface pattern can be seen as the model of a specific system implementing this pattern.

Carassius Petri Net Editor
The Carassius software tool has been presented in [3]. It supports various modeling notations, including (communicating) finite state machines and Petri nets. The Carassius allows one to simulate Petri nets according to the transition firing rule, import and export files in different formats, visualize process behavior. Apart from that, the Carassius has a modular architecture, and it can be easily 166 extended with new features. For example, in [25], the authors have described an extension to the Carassius that supports the simulation of Petri nets with two special types of arcs: reset and inhibitor. The main window of the editor is shown in fig. 11. We have introduced the following features into the Carassius Petri net editor: 1) the internal storage of refinement transformations; 2) the choice and application of a single transformation to a given EN-system; 3) the generation of an EN-system by applying a fixed transformation sequence (Algorithm 1); 4) the generation of an EN-system by applying a randomly constructed transformation sequence (Algorithm 2).

Fig. 11. Carassius process model editor
The implementation of the generation algorithms has also been enriched with the possibility to «roll back» following a transformation sequence to check intermediate results.
The parameters necessary for the fixed and randomized generation are configured in the top panel.
A fixed transformation sequence (Algorithm 1 is constructed using a drop-down menu, where one may choose a transformation and assign the corresponding number of occurrences to it (see fig. 12).
The configuration of probabilities and other parameters of Algorithm 2 is shown in fig. 13. As described in the following paragraph, we have considered the application of Algorithm 2 to construct refinements of so-called interface patterns.

Evaluation: Randomized Refinement of Interaction Patterns
Modeling complex information systems is a rather difficult task due to the coordination of several interacting components. Service interaction patterns, introduced in the Business Process Management (BPM) community [26], provide generic solutions for designing composite systems with several interacting entities. The patterns give a highly abstract view of component interactions. The identification of the typical interface patterns and their modeling using Petri nets have been considered in [24], where the seven asynchronous interaction patterns have been discussed. The models of these patterns are shown in fig. 14. For instance, IP-4 describes the simple message exchange, when the first component sends a message to the second one, and the latter sends back an acknowledgment.

Fig. 14. Interaction patterns: reference models
We have used these interaction patterns to evaluate the randomized generation algorithm. Given an interface pattern, we apply Algorithm 2 and obtain a possible refinement of this pattern. A refinement of an interface pattern inherits its structural and behavioral properties. Intuitively, such a refinement represents a possible system model implementing an interaction pattern. The results of applying the randomized refinement to the interaction patterns with different parameters are provided in Table 2, where we show the number of places and transitions in the reference model and the obtained refinements. Correspondingly, we have considered five different cases: • the randomized refinement with equal probabilities for each transformation ( = 0.25); • the four cases when the probability of one transformation (0,67) outweighs the equal probabilities of the other three transformations (0,11). As it can be seen from Table 2, the number of places and transitions in the constructed refinements is consistent with transformation application probabilities. Within all transformations being equally probable, we do not observe notable differences in the number of places and transitions in the obtained refinements. However, when the place (transition) duplication has the highest probability, we have that the number of places (transitions) significantly outweighs the number of transitions (places) in the refinement. The predominance of the transition introduction ( ) and place split ( ) also does not lead to substantial differences in the number of places and transitions. The application of requires places with two more input transitions, which may not be present in the reference model. In addition, fig. 15 provides a possible result of applying ten refinement transformations to the interface pattern IP-1, where the transformations have equal probabilities.

Conclusions
In this paper, we have presented an approach to the generation of Petri nets using structural propertypreserving transformations. We have considered the generation of elementary net systems, which form the basic class of Petri nets. Elementary net systems reflect the control-flow of a process, while data and time aspects are ignored. Given a reference model, we apply a sequence of refinement transformations to obtain a Petri net with similar structural and behavioral properties valid for the reference Petri net. Refinement transformations extend a reference model by adding new places and transitions, i.e., make the structure of a reference model more sophisticated. The proposed approach can be applied for a complex evaluation of algorithms operating with Petri nets requiring the preparation of model sets containing Petri nets with the specific structural and behavioral properties. The correctness of applying these transformations is based on two observations. Firstly, the transformations induce morphisms between reference and transformed Petri nets. Secondly, the transformations do not introduce new deadlocks, unless they are already present in reference models. We have designed two algorithms supporting the automated generation of Petri nets with the help of structural property-preserving transformations. The fixed generation corresponds to the direct application of a fixed sequence of refinement transformations. Within the randomized generation, a user chooses the maximum size of a target model and sets the probability of applying each transformation. We have conducted a series of experiments to evaluate the developed algorithms using Petri net models of service interaction patterns. The experimental results confirm the consistency of the randomized generation algorithm, according to changes in the number of places and transitions with respect to probability values. These algorithms have also been implemented in the existing Carassius Petri net editor.
The main limitation to the proposed approach, based on transformations, is that it is impossible to generate a cyclic Petri net from a reference model without cycles. In the future, we plan to relax these constraints and to extend the collection of property-preserving transformations correspondingly. In this light, we also plan to develop a «designer» of structural Petri net transformations that will allow us to construct new transformations. Another direction for the future research is the development of property-preserving transformations for different extensions of Petri nets, including, e.g., colored Petri nets, where tokens can carry data, or timed Petri nets, where transitions are assigned firing time intervals. Note that certain extensions of Petri nets can also be «unfolded» to elementary net systems.