You are on page 1of 16

PETRI NETS

VL Formal Models
Armin Biere Martina Seidl
Petri Nets

 one of the most widely used modeling language for describing distributed systems
 formal basis for UML activity diagrams
 many theoretical results
 reachability
 liveness
 deadlocks
 many variants and extensions

1
Excursus: Labeled Transition System

A labeled transition system (LTS) A = (S , I, Σ, T ) consists of

 a set of states S
 a set of actions Σ
 a transition relation T ⊆ S × Σ × S
 initial states I ⊆ S

2
Excursus: Labeled Transition System

A labeled transition system (LTS) A = (S , I, Σ, T ) consists of

 a set of states S
 a set of actions Σ
 a transition relation T ⊆ S × Σ × S
 initial states I ⊆ S

LTS

 . . . are like automata but do not have finial states


⇒ describe possible / allowed streams of actions
 . . . are usually not complete and are not necessarily deterministic
 . . . are used for defining the operational semantics of petri nets (and other formalisms)

2
LTS: Example

3
Condition-Event Net (CEN)
most basic form of a petri net
Definition
A condition-event net N = (C, I, E, G) consists of

 conditions C (which are true if it contains a token)


 initial marking I ⊆ C
 events E
 dependence graph G ⊆ (C × E) ∪ ˙ (E × C)

Graphical representation

. . . condition without token . . . event

. . . condition with token


. . . excerpt of dependence graph
4
Pre- and Postconditions of an Event

Definition
Let N = (C, I, E, G) be a CEN. The preconditions G−1 (e) and the postconditions G(e) of an
event e ∈ E are defined as follows:

 G−1 (e) = {c | (c, e) ∈ G}


(informally: if an event e is enabeled, all preconditions of e have to be true)

 G(e) = {c | (e, c) ∈ G}
(informally: if event e has fired, all postconditions of e are true)

5
CEN Semantics as LTS
Definition
Let N = (C, I, E, G) be a CEN. The LTS L = (S , {I}, Σ, T ) consists of the following components:

 S = P(C)
state M ∈ S is also called a marking
 Σ=E
 (C1 , e, C2 ) ∈ T iff
1. G−1 (e) ⊆ C1
(preconditions of e are true)
2. G(e) ∩ C1 = ∅
(postconditions of e are false)
3. C2 = (C1 \G−1 (e)) ∪ G(e)
(state update: after e has fired, the preconditions of e are false and the postconditions are true)

6
Example: Producer Consumer

7
Deadlock
Let N = (C, I, E, G) be a CEN with LTS L = (S , {I}, Σ, T ).

An event e ∈ Σ in marking M ∈ S is enabled (i.e., it can fire) iff

{M 0 | (M, e, M 0 ) ∈ T } , ∅

8
Deadlock
Let N = (C, I, E, G) be a CEN with LTS L = (S , {I}, Σ, T ).

An event e ∈ Σ in marking M ∈ S is enabled (i.e., it can fire) iff

{M 0 | (M, e, M 0 ) ∈ T } , ∅

A marking M is a deadlock iff

 M is a “dead end” in the reachability graph of L


 ⇔ no event is enabled in marking M
 ⇔ all events are disabled
 ⇔ ∀e ∈ E : {M 0 | (M, e, M 0 ) ∈ T } = ∅

8
Deadlock
Let N = (C, I, E, G) be a CEN with LTS L = (S , {I}, Σ, T ).

An event e ∈ Σ in marking M ∈ S is enabled (i.e., it can fire) iff

{M 0 | (M, e, M 0 ) ∈ T } , ∅

A marking M is a deadlock iff

 M is a “dead end” in the reachability graph of L


 ⇔ no event is enabled in marking M
 ⇔ all events are disabled
 ⇔ ∀e ∈ E : {M 0 | (M, e, M 0 ) ∈ T } = ∅

A CEN N has a deadlock iff a marking that is a deadlock is reachable.

8
Place Transition Net (PTN)
Definition
A PTN N = (P, I, T, G, C) consists of

 places P
 initial marking I : P → N
 transitions T
˙ × P)
 connection graph G ⊆ (P × T ) ∪(T
 capacities C : P ∪˙ G → N ∪ {∞}
default value for places: ∞
default value for connections: 1

Graphical representation
. . . place with multiple tokens
like CEN, but places can have multiple tokens

9
PTN Semantics as LTS
Definition
Let N = (P, I, T, G, C) be a PTN. The LTS L = (S , {I}, Σ, T L ) consists of the following
components:

 states S = {M : P → N}
 a state M : P → N is also called a marking
 markings can also be written as elements of NP
 Σ=T
 (M1 , e, M2 ) ∈ T L iff
1. C((p, t)) ≤ M(p) ∀p ∈ G−1 (t)
(enough tokens in the preconditions of e)
2. C((t, q)) + M(q) ≤ C(q) ∀q ∈ G(t)
(enough space in the postconditions of e)
3. state update: ∀p ∈ P : M2 (p) = M1 (p) − M− (p) + M+ (p) where
 
 C((p, t)) p ∈ G−1 (t) C((t, p) p ∈ G(t))

 

M− (p) =  M+ (p) = 
 
0

 0

 10
Example: Place Transition Net

Remark: A marking M can also be written as element (va , vb ) ∈ N × N with


M(a) = va and M(b) = vb . a2
Examples: initial marking: a2 =
ˆ (2, 0), marking after e has fired: a1b2 =ˆ (1, 2) e
g
a a1b2
f e
2
2 a2b1 b4
e f
a1b3
f e g f
a2b2
e
b 2 a1b4
4 f
4 a2b3
11
Gas Station

Example by Reisig, 1992

cars leave
cars in filling
filling station
station exitway
cars in free
filling station freed pumps cashiers
cars enter
filling station
do free pumps
unfueled cars
at pump
drive up cars leave
to a pump pumps
tanks are fueled cars payment cars ready
filled at pump to leave

free spaces

12

You might also like