Maps - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Maps

Description:

At the end of this lecture you should be able to: provide a definition of a VDM map; ... A map is a special sort of set, one which contains a set of maplets; ... – PowerPoint PPT presentation

Number of Views:71
Avg rating:3.0/5.0
Slides: 31
Provided by: aaron63
Category:
Tags: definition | maps | of

less

Transcript and Presenter's Notes

Title: Maps


1
Maps
Learning Outcomes
At the end of this lecture you should be able to
  • provide a definition of a VDM map
  • utilize and interpret map notation
  • make appropriate use of the VDM map operators
  • identify situations in which a map is an
    appropriate data type
  • write VDM specifications using maps.

2
Introduction
Computing systems often involve relating 2 types
of value together A map is a special sort of
set, one which contains a set of maplets Each
maplet connects an element of one set to an
element of another set The first set is
referred to as the domain, the second is referred
to as the range.
Yalmaz
Coffee
Aaron
VDM
Password
Name
Rajneet
Apple
Nkumu
RANGE
DOMAIN
3
Using the map type in VDM-SL
To declare a variable to be of type Map we use a
special arrow
DomainType
RangeType
For example, to declare a variable m that maps
characters to natural numbers we would write
m
Char
?
To declare a variable, users, that maps names to
passwords we could write
users
Name
Password
4
Notation
We can express this table as a map, which we will
call sensors
sensors
Sensor
Condition
sensors A ? ltlowgt, B ? ltnormalgt, C ? ltnormalgt,
D ? lthighgt, E ? ltnormalgt, F ? ltnormalgt
sensors ?
5
Map operators
m1 a ? 1, b ? 2, c ? 2, d ? 3, e ? 4 m2
a ? 2, f ? 1, c ? 7
The domain operator and the range operators
a, b, c, d, e
dom m1
1, 2, 3, 4
rng m1
a, f, c
dom m2
1, 2, 7
rng m2
6
Map operators
m1 a ? 1, b ? 2, c ? 2, d ? 3, e ? 4 m2
a ? 2, f ? 1, c ? 7 m3 f ? 2, g ?
6
The union operator, ?
a ? 1, b ? 2, c ? 2, d ? 3, e ? 4, f ? 2, g
? 6
m1 ? m3
m1 ? m2
undefined
undefined
m2 ? m3
7
Map operators
m1 a ? 1, b ? 2, c ? 2, d ? 3, e ? 4 m2
a ? 2, f ? 1, c ? 7 m3 f ? 2, g ?
6
The override operator,
a ? 2, b ? 2, c ? 7, d ? 3, e ? 4, f ? 1
m1 m2
m3 m2
f ? 1, g ? 6, a ? 2, c ? 7
8
Map operators
m1 a ? 1, b ? 2, c ? 2, d ? 3, e ? 4 m2
a ? 2, f ? 1, c ? 7 m3 f ? 2, g ?
6
a ? 1, c ? 2, e ? 4
f ? 1
?
9
Map operators
m1 a ? 1, b ? 2, c ? 2, d ? 3, e ? 4 m2
a ? 2, f ? 1, c ? 7 m3 f ? 2, g ?
6
b ? 2, d ? 3
a ? 2, c ? 7
f ? 2, g ? 6
10
Map operators
m1 a ? 1, b ? 2, c ? 2, d ? 3, e ? 4 m2
a ? 2, f ? 1, c ? 7 m3 f ? 2, g ?
6
b ? 2, c ? 2
f ? 1
?
11
Map operators
m1 a ? 1, b ? 2, c ? 2, d ? 3, e ? 4 m2
a ? 2, f ? 1, c ? 7 m3 f ? 2, g ?
6
a ? 1, d ? 3, e ? 4
a ? 2, c ? 7
f ? 2, g ? 6
12
Map operators
m1 a ? 1, b ? 2, c ? 2, d ? 3, e ? 4 m2
a ? 2, f ? 1, c ? 7 m3 f ? 2, g ?
6
Map Application
m1( d )
3
m2( f )
1
m3( f )
2
m3( x )
undefined
13
Specifying a high-security building
User name Password
14
UML Diagrams
15
The VDM-SL state specification
types
Name TOKEN Password TOKEN Signal
ltopen_doorgtlt activate_alarmgt
Employee
name Name password Password
state SecuritySys of
authorized
Employee-set ?
Name-set
inside
Only authorised employees can be inside the
building
inv mk-SecuritySys(a,i) ?
i ? dom a
init mk-SecuritySys(a,i) ?
a ? ? i
16
addEmployee(
) ext pre post
nameIn Name, passwordIn Password
wr
nameIn ? dom authorized
17
nameIn Name
removeEmployee(
) ext pre post
wr
inside Name-set
rd
nameIn ? dom authorized
? nameIn ? inside
18
enter(
) ext pre post
signal Signal
nameIn Name, passwordIn Password
rd
inside Name-set
wr
TRUE
?
?
( nameIn ? dom authorised ?
?
19
leave ( ) ext pre post
nameIn Name
signal Signal
inside Name-set
wr
TRUE
signal ltopen_doorgt
?
?
?
signal ltactivate_alarmgt
20
A robot monitoring system
WORKING
Sector A
Sector B
BROKEN
IDLE
21
(No Transcript)
22
types Name TOKEN Mode Sector Robot
ltworkinggtltidlegt ltbrokengt
ltAgtlt Bgt
name mode sector
Name
Mode
Sector
m ltworkinggt ? s ? nil
inv mk-Robot(-, m, s) ?
state RobotMonitor of
robots
inv mk-RobotMonitorSys(r) ?
? n ? dom r ? n r(n).name
init mk-RobotMonitorSys(r) ?
r ?
end
23
addRobot (
) ext pre post
nameIn Name
wr
nameIn ? dom robots
nameIn ? mk-Robot (nameIn, ltidlegt, nil)
24
removeRobot (
) ext pre post
nameIn Name
wr
?
nameIn ? dom robots
robots(nameIn).mode ? ltworkinggt
25
setToWork (
) ext pre post
nameIn Name, sectorIn Sector
wr
?
nameIn ? dom robots
robots(nameIn).mode ltidlegt

nameIn ? mk-Robot(nameIn, ltworkinggt, sectorIn
)
26
finishWork (
) ext pre post
nameIn Name
wr
?
nameIn ? dom robots
robots(nameIn).mode ltworking gt

nameIn ? mk-Robot(nameIn, ltidlegt, nil )
27
needsRepair (
) ext pre post
nameIn Name
wr
nameIn ? dom robots

nameIn ? mk-Robot(nameIn, ltbrokengt, nil )
28
fixed ( ) ext pre post
nameIn Name
wr
?
nameIn ? dom robots
robots(nameIn).mode ltbroken gt

29
inSector (
) ext pre post
sectorIn Sector
result Name-set
rd
TRUE
result
? ? ?
?
r.sector sectorIn
r ? rng robots
r.name
30
numberToRepair ( ) ext pre post
number ?
rd
TRUE
result
r
card ? ? ?
?
r.mode ltbrokengt
r ? rng robots
Write a Comment
User Comments (0)
About PowerShow.com