=Paper=
{{Paper
|id=Vol-3721/paper1
|storemode=property
|title=Some Petri Net Problems with Counterintuitive Solutions
|pdfUrl=https://ceur-ws.org/Vol-3721/paper1.pdf
|volume=Vol-3721
|authors=Piotr ChrzΔ
stowski-Wachtel,Piotr Ulanowski
|dblpUrl=https://dblp.org/rec/conf/apn/Chrzastowski-Wachtel24
}}
==Some Petri Net Problems with Counterintuitive Solutions==
Some Petri Net Problems with Counterintuitive Solutions
Piotr ChrzaΜ§stowski-Wachtel1,β , Piotr Ulanowski1,β
1
Institute of Informatics, University of Warsaw, Banacha 2, PL-02-097 Warszawa, Poland
Abstract
The first author has been giving a one-semester monograph lecture for decades at the Warsaw University. During
the lectures he has offered solving Petri net puzzles, as one of the ways to pass the course. Some of them are pretty
hard and counterintuitive. Despite the excellency of students at the Warsaw University, some of the puzzles were
solved by only a few of them. This paper is a joint paper with one of the current students (the second author),
who has solved the hardest puzzles in a convincing way.
1. Introduction
Petri nets are a very elegant framework to expose the problems of concurrent systems. They allow to
define problems in a comprehensible way and to focus on important issues like liveness or boundedness
of a given state. Some of the problems concerning liveness and boundedness are counterintuitive. They
offer deep didactic value to look for something that appears impossible at the first glance. Solving such
problems gives the students much satisfaction. The questionnaires filled anonymously after each course
give no doubt about it. But it also demonstrates good understanding of the subject, so such homework
can replace the final exam, if the originality of the solution leaves no doubt about the authorship. We
will demonstrate solutions for four problems:
1. Find a net and two markings: π and π β² such that
β’ π is live
β’ πβ² β₯ π
β’ π β² is not live
2. Find a net and two markings: π and π β² such that
β’ π is live and bounded
β’ πβ² β₯ π
β’ π β² is live and not bounded
3. Find a net and initial marking M such that
β’ π is live and bounded
β’ the reachability graph of π has two finals (two maximal strongly connected components).
4. Find a net and initial marking M such that
β’ π is live
β’ there exist two places π1 , π2 , such that they are both unbounded, but not simultaneously.
2. Definitions
Petri nets are triples β¨π, π, πΉ β©, where π and π are finite, nonempty and disjoint sets of places and
transitions respectively, while πΉ : π Γ π βͺ π Γ π β N is a function definining the structure of a Petri
net graph. We assume that if πΉ (π₯, π¦) = 0, then there is no edge in the graph between nodes π₯ and π¦.
A positive value means that the edge connecting π₯ and π¦ exists and denotes the capacity of the edge,
$ pch@mimuw.edu.pl (P. ChrzaΜ§stowski-Wachtel); pu429640@students.mimuw.edu.pl (P. Ulanowski)
Β© 2024 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0).
CEUR
ceur-ws.org
Workshop ISSN 1613-0073
Proceedings
so the number of tokens that will be passing along this arc and the direction of token flow. If for all
π₯, π¦ : πΉ (π₯, π¦) β€ 1, we call such a net simple.
A net is a P-system if the numbers of incoming and outgoing edges of any transition do not exceed
one. A net is a T-system if the numbers of incoming and outgoing edges of any place do not exceed one.
Letβs fix a net π© = β¨π, π, πΉ β©. A marking is a mapping from π to N. A transition π‘ β π is enabled at
marking π , if for all π β π : π (π) β₯ πΉ (π, π‘). An enabled transition at a given marking π can fire
changing π into π β² according to the rule: for all π β π : π β² (π) = π (π) β πΉ (π, π‘) + πΉ (π‘, π). Firing a
transition π‘ at π changing it to π β² is denoted by π [π‘β©π β² . The reachability set of π is the smallest
set of markings [π ] satisfying two conditions:
β’ π β [π ]
β’ if π β² β [π ] and βπ‘ β π and π β²β² such that π β² [π‘β©π β²β² then π β²β² β [π ].
The reachability graph πΊ(π ) of a marking M is a graph β¨π, πΈβ©, where π = [π ] and πΈ = {(π β² , π β²β² ) :
βπ‘ β π : π β² [π‘β©π β²β² }; in this case we presume that the edge between π β² and π β²β² is labeled by π‘. A
subgraph (π β² , πΈ β² ) is called a final of (π, πΈ) iff π β² β π, πΈ β² = πΈ β© (π β² Γ π β² ) is a maximal strongly
connected component, so any two nodes of π β² are connected by a path in πΊ(π ). If the set [π ] is finite,
then finals represent possible ultimate behaviors of a net after making possibly irreversible decisions,
during resolving conflicts with transition firings.
A place π at marking π is bounded, if there exists π β N such that βπ β² β [π ] : π β² (π) β€ π.
Otherwise we call such a place unbounded at π . A marking π is bounded if all places are bounded at
π (or, equivalently, the set [π ] is finite).
Marking π is live if βπ‘ β π : βπ β² β [π ] : βπ β²β² β [π β² ] : π‘ is enabled at π β²β² . A marking π is dead
if no transition is enabled at π .
A net is well formed, if there exists a live and bounded marking in it. A net is structurally bounded
if all markings are bounded. When a net is unbounded, we construct coverability graph following
the idea of Karp and Miller [KM69]. Whenever during the construction of the coverability graph a
marking bigger than some previously considered node on a path from π is created, we replace all the
coordinates, which are greater, by a symbol π to indicate the possibility of generating arbitrarily many
tokens. Additionaly we introduce ππ indicating the possibility of generating any odd number of tokens,
and ππ indicating the possibility of generating any even number of tokens.
For two markings π, π β² we say that π β€ π β² iff βπ β π : π (π) β€ π β² (π). We call a property
monotonic, if is is preserved under increasing a marking. Otherwise it is called non-monotonic.
We present now four problems with (subjectively) increasing difficulty. All of them seem at the first
glance to have no solution, but solutions indeed exist.
3. Non-monotonicity of liveness
Find a net and two markings: π and π β² such that
β’ π is live
β’ πβ² β₯ π
β’ π β² is not live
This is an old problem, proposed by the first author in the [PNB13] long ago, solved by many, including
[WR85]. Here we present the most compact solution consisting of a net with just two transitions and
one place. The marking of Figure 1 is live: invariantly the number of tokens on place π is odd, so one
can always increase the number of them by firing π‘1 , but if we increase the number of tokens in the
initial marking to 2, the marking is not live: we can fire π‘2 making a marking dead.
This problem has some important moral: When something goes well, adding some extra goods can
destroy wellness. Like it happens in real life, for instance with people who win a fortune on a lottery
give up their good jobs, lose friends and end up in disaster. Or in economics, when too much money
can trigger unnecessary investments, killing some well working parts of a system.
π‘1
3
π
2
π‘2
Figure 1: A live marking of a net solving the "Non-monotonicity of liveness" problem.
4. Non-monotonicity of boundedness for live nets
Find a net and two markings: π and π β² such that
β’ π is live and bounded
β’ πβ² β₯ π
β’ π β² is live and not bounded
This problem is much harder. In fact the first author has been puzzled with this problem by Teruel
[ET92], while working together on T-systems and P-systems in 1992. The hypothesis of Teruel was
that well-formed P-systems are struturally bounded, which would exclude the example satisfying
these requirements. Surprisingly, one of the solutions for this problem is a P-system, which makes the
hypothesis false.
The first author proposes this problem to the students, as stated, without a requirement that the net
should be a P-system. Maybe this makes the problem even harder. Anyway, the example presented
here on Figure 2 with only two places and four transitions is easily verifiable, as can be seen on the
coverability graphs. Notice that every transition can be rollbacked with an opposite transition. To
be precise, after firing π‘1 the net will restore its marking by firing π‘4 , and after firing π‘2 , the net will
restore its marking by firing π‘3 and vice versa. This means that every marking that can activate π‘1 and
π‘2 or π‘3 and π‘4 is live. This is because, after applying transitions in some order from such marking, you
can always return to the original marking by applying the corresponding opposite transitions in the
reverse order. This way, the net will restore a marking, from which it was possible to activate all the
transitions at some point. Notice that marking (0, 5) on Figure 2 can activate both π‘3 and π‘4 , so the net
with unbounded marking is live.
Mind that such an example cannot be found for free-choice nets (a consequence of the rank theorem)
[DE94].
Let us present another net on Figure 3 and Figure 4, which was discovered by the second author and
will serve as a basis of the solution of the next problem.
π‘1
2 π‘2 3
3 4 (2, 1)
π‘4 π‘1
π1 π2 (0, 4)
π‘3 π‘2 π‘3
(3, 0)
3 4
π‘4 π‘4 π‘1
2 3
(1, 3)
Figure 2: A bounded marking of a P-System net solving the "Non-monotonicity of boundedness for live nets"
problem, coverability graphs for bounded and unbounded markings
π‘2
π5
π7
π1 π3 10|0|10|10
π‘3
π2 π‘4 π‘1
01|1|10|10
π‘4 π‘3
π6 01|0|01|01
π4 π‘2
π‘1 10|1|01|01
Figure 3: A bounded marking of a net solving the "Non-monotonicity of boundedness for live nets" problem,
proposed by second author.
10|0|20|10
π‘1
01|1|20|10
π‘4 π‘3
01|0|11|01
π‘*4 π‘2
10|1|11|01
π‘1
01|ππ |11|01
π‘1 π‘2 π‘*3
10|ππ |11|01
π‘3 π‘4 π‘3 π‘4
10|ππ |20|10
π‘1
01|ππ |20|10
Figure 4: Coverability graph for not bounded marking * - Transitions with asterisk will fire only when ππ = 1
5. Two finals
Find a net and initial marking M such that
β’ π is live and bounded
β’ the coverability graph of π has two finals.
To find a net, whose coverability graph has two finals is a very easy task. But adding the requirement
of liveness can make the problem pretty hard.
Recently the first author communicated Devillers, who mentioned that the problem was first solved
probably by Best and Voss in [BV84].
The solution presented here was proposed by the second author. Mind that the initial marking is live
and bounded, and depending on the choice of the first transition to fire, we fall into two different finals,
which of course do not share any single marking. The presented reachablility graph leaves no doubt
that the problem is solved indeed: after the choice of the first transition to fire, the net falls into disjoint
cycles.
To approach this problem, one can start with a net that is modeling the flow of two processes rivaling
for an access to a critical section in a concurrent environment. One can add an additional restriction to
ensure liveness and eliminate starvation by enforcing on the processes to enter the critical section in an
interleaving sequence β one after the other. This scenario can be represented by the net in Figure 5
without the place π. Tokens in places π1 , π2 mean accordingly that the process is idle. Place π is
representing the binary semaphore. Tokens in ππ 1 and ππ 2 mean, that a specific process is in critical
section. Token in π means that one of the processes just released the semaphore and wants to become
idle.
With such a net, we can just add an asymmetry to the net with place π, which solves the given
problem. The solution can be seen on Figure 5.
Figure 5: A marking of a net solving the "Two finals" problem and coverability graph of this net. Values are
encoded accordingly π1 π2 |π|ππ 1 ππ 2 |π|π
6. Asynchronous unboundedness
Find a net and initial marking M such that
β’ π is live
β’ there exist two places π1 , π2 , such that they are both unbounded, but not simultaneously. In
other words: for every π β N there exists a marking π1 β [π ] with π1 (π1 ) > π, and there
exists a marking π2 β [π ] with π2 (π2 ) > π, but there exists a constant π such that for every
π β² β [π ] either π β² (π1 ) < π or π β² (π2 ) < π
The solution for this problem is presented on Figure 6. The net is composed of one net that was used
for solving the "Two Finals" problem and two nets that were created by the second author for the
"Non-monotonicity of boundedness for live nets" problem. By choosing non-deterministicly the first
transition π‘1 or π‘2 , the net will put two tokens either on π1 or on π2 accordingly, but it will be not
possible to achieve two tokens on both these places simultaneaously. As we showed earlier the upper
nets with their ππ being marked with two tokens are unbounded causing the place ππ to achieve any
number of tokens. All the three nets are live and taking/adding tokens from places ππ by other nets
wonβt affect their liveness in a long run. As a result weβve received a live net with places π1 and π2 that
fit the requirements of the problem.
π5 π5
π7 π7
π1 π1 π2 π1
π2 π2
π1 π6 π6 π2
π1 π2
π‘1 π‘2
π
ππ 1 ππ 2
π‘3 π‘4
π‘5 π π‘6
Figure 6: A marked net solving the "Asynchronous unboundedness" problem. Places π1 and π2 can gain any
number of tokens, but not at the same time. The marking is live.
7. Conclusions
All the presented solutions expose some interesting aspects of net behaviors. Having learned such
examples enriches understanding of different non-intuitive properties and interrelations between them.
Here the solution of the last example was merely a combination of two previous solutions. Usually
students find the last problem being the most difficult.
It is also nice to see that some standard problems from the concurrency theory, like mutex, give an
insight to non-trivial solutions of the presented Petri net problems.
References
[PNB13] Piotr Chrzastowski-Wachtel, Puzzle No 3, Petri Nets and Related Models, Newsletter No 13,
p22, 1983
[DE94] J.Desel, J,Esparza, Free Choice Petri Nets, Cambridge University Press, 1995.
[WR85] Wolgang Reisig, Petri Nets, an Introduction, Springer Verlag 1985.
[ET92] E. Teruel, private communication, 1992.
[BV84] E.Best, K.Voss, Free Choice Systems Have Home States Acta Informatica 21, pp. 89β100, 1984.
[KM69] R.Karp, R.Miller, Parallel program schemata. Computer and System Sciences, 1969