Top Banner
Tutorial
31

Tutorial - Philadelphia University

Nov 05, 2021

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Tutorial - Philadelphia University

Tutorial

Page 2: Tutorial - Philadelphia University

1

Page 3: Tutorial - Philadelphia University

Algebraic specifications of Abstract

Data Types Exceptional behavior on the erroneous

arguments

Page 4: Tutorial - Philadelphia University

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

Page 5: Tutorial - Philadelphia University

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

Page 6: Tutorial - Philadelphia University

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

Page 7: Tutorial - Philadelphia University

Petri nets

• Definition

• Graphical structure

Page 8: Tutorial - Philadelphia University

Definition Graphical structure

Page 9: Tutorial - Philadelphia University

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

Page 10: Tutorial - Philadelphia University

Reachability Graph

Page 11: Tutorial - Philadelphia University

Matrix analysis

Source: System modelling with Petri nets, Andrea Bobbio, Istituto Elettrotecnico Nazionale Galileo Ferraris, Torino, Italy

Page 12: Tutorial - Philadelphia University

II

Page 13: Tutorial - Philadelphia University

Specification of data structures

• Algebraic specification

• Z notation

Page 14: Tutorial - Philadelphia University

Z notation

• Full notation

– slides 20 – 21

• Short-hand notation (∆ schema)

– Slide 26

Page 15: Tutorial - Philadelphia University

Recall State Schema

Page 16: Tutorial - Philadelphia University

Operation Schema (full-notation)

Page 17: Tutorial - Philadelphia University

Operation Schema (short-hand notation)

Page 18: Tutorial - Philadelphia University

Z notation and Object-Z

• Writing Object-Z notation from Z notation and vice-versa

Page 19: Tutorial - Philadelphia University

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

Page 20: Tutorial - Philadelphia University

Object-Z

Source: The Object-Z Specification Language, Graeme Smith, Software Verification Research Centre University of Queensland, with modification

Page 21: Tutorial - Philadelphia University

Graph Transformations

• Graph rewrite rule

• Application of graph rewrite rule

– Slides 21-22, 25

Page 22: Tutorial - Philadelphia University
Page 23: Tutorial - Philadelphia University
Page 24: Tutorial - Philadelphia University

Source:Bernhard Westfechtel Lehrstuhl für Informatik III, RWTH Aachen

Page 25: Tutorial - Philadelphia University

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

Page 26: Tutorial - Philadelphia University

Petri nets : mutual exclusion

Page 27: Tutorial - Philadelphia University

Traffic light

Source: Petri nets, classical Petri nets: The basic model, prof.dr.ir. Will van der Aalst, Technische Universitat Eindoven, University of Technology

Page 28: Tutorial - Philadelphia University

Petri nets: producer-consumer

Page 29: Tutorial - Philadelphia University

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

Page 30: Tutorial - Philadelphia University

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

Page 31: Tutorial - Philadelphia University

III