Post on 05-Nov-2021
Tutorial
1
Algebraic specifications of Abstract
Data Types Exceptional behavior on the erroneous
arguments
The Stack example
fmod STACK is sorts Stack NeStack Element . subsort NeStack < Stack . op emptystack : -> Stack . op push : Stack Element -> NeStack . op pop : NeStack -> Stack . op top : NeStack -> Element . var S : Stack . var X : Element . eq pop(push(S, X)) = S . eq top(push(S, X)) = X .
endfm
The List example
fmod LIST is sorts List NeList Element . subsort NeList < List . op nil : -> List . op _._ : Element List -> NeList . op head : NeList -> Element . op tail : NeList -> List . var L : List . var E : Element . eq head(E.L) = E . eq tail(E.L) = L .
endfm
The Queue example
fmod QUEUE is
sorts Queue NeQueue Element.
subsort NeQueue < Queue .
op emptyqueue : -> Queue .
op add : Queue Element -> NeQueue .
op remove : NeQueue -> Queue .
op front : NeQueue -> Element .
var X : Element .
var Q : Queue .
eq remove(add(Q, X)) = if Q == emptyqueue
then emptyqueue else add(remove(Q), X)
fi .
eq front(add(Q, X)) = if Q == emptyqueue
then X else front(Q)
fi .
endfm
Petri nets
• Definition
• Graphical structure
Definition Graphical structure
p1 p2
p3
p4
t1
t2
t3 t4
M1 = (1,0,0,1)
M2 = (0,1,0,1)
M3 = (0,0,1,0)
M4 = (0,0,0,1)
Source: The Petri Net Method, by Dr Chris Ling School of Computer Science & Software Engineering, Monash University
Reachability set
Reachability Graph
Matrix analysis
Source: System modelling with Petri nets, Andrea Bobbio, Istituto Elettrotecnico Nazionale Galileo Ferraris, Torino, Italy
II
Specification of data structures
• Algebraic specification
• Z notation
Z notation
• Full notation
– slides 20 – 21
• Short-hand notation (∆ schema)
– Slide 26
Recall State Schema
Operation Schema (full-notation)
Operation Schema (short-hand notation)
Z notation and Object-Z
• Writing Object-Z notation from Z notation and vice-versa
Z notation
Item is the formal generic parameter
Source: The Object-Z Specification Language, Graeme Smith, Software Verification Research Centre University of Queensland, with modification
Object-Z
Source: The Object-Z Specification Language, Graeme Smith, Software Verification Research Centre University of Queensland, with modification
Graph Transformations
• Graph rewrite rule
• Application of graph rewrite rule
– Slides 21-22, 25
Source:Bernhard Westfechtel Lehrstuhl für Informatik III, RWTH Aachen
Type Graph and Instance Graph
Account
balance
Bill
amount
Customer
name
To
Has
:Customer
name=C1
b1:Bill
amount=3
:Account
balance=5
:Account
balance=0
:Customer
name=C2
b2:Bill
amount=2
Pays
Pays Pays
To To
Has
Has
From From From
TG IG
These slides are strongly based on the paper entitled Graph Transformation and Visual Modeling Techniques by Reiko Heckel and Gregor Engels
Petri nets : mutual exclusion
Traffic light
Source: Petri nets, classical Petri nets: The basic model, prof.dr.ir. Will van der Aalst, Technische Universitat Eindoven, University of Technology
Petri nets: producer-consumer
Figure 5: Unbounded buffer
Source: System modelling with Petri nets, Andrea Bobbio, Istituto Elettrotecnico Nazionale Galileo Ferraris, Torino, Italy
Scenario: A token in p1 : P ready to produce Firing t1: P produces Firing t2: P sends produced object to buffer p5, ready to produce again A token in p3 : C ready to consume If an object is in p5, t3 fires and C consumes, C is then ready to consume again
Figure 6: Finite buffer
Source: System modelling with Petri nets, Andrea Bobbio, Istituto Elettrotecnico Nazionale Galileo Ferraris, Torino, Italy
The total number of tokens in p5 and p6 is constant and represents the total available buffer positions If a single token is assigned to p6: strictly sequential ordering of activities
III