Back - Formal Specification | Previous - Filing Subsystem | Next - Warehouse Stock Control


Tutorial Solutions - Weather Map

 

Let us suppose basic sets to be -

[AREA,TEMP]

Then in general -

³ temp : AREA �‹Ž TEMP

An example of which may be -

temp == {(b,10),(l,11),(d,11),(c,9),(f,10),(s,9),(h,6),(g,7),(w,8),(o,6)}

Where the regions are represented by their initial letter.

Source, domain, target, and range are hence - AREA, {b,l,d,c,f,s,h,g,w,o}, TEMP and (6,7,8,9,10,11} respectively.

plus_minus_2deg_12 = {10,11,12,13,14} ¨ temp

south_reg = temp © {b,d}

outer_reg = temp ± {w,o}

temp' = temp Å {(l,13),(s,11)}

The state schema may be written -

ÚÄWeathermapÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ temp : AREA �‹Ž TEMP
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ dom temp = {b,l,d,c,f,s,h,g,w,o}
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

ÚÄInitWeatherMapÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ Weathermap
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ temp = í
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

It helps to define the set -

Scotland == {b,l,d,c,f,s,h,g,w,o}

ÚÄUpdateÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ œWeathermap
³ reg? : AREA
³ deg? : Ÿ
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ reg? î Scotland
³ temp' = temp
Å {reg? šŽ deg?}
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

ÚÄLookUpÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ �Weathermap
³ reg? : AREA
³ deg! : Ÿ
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ reg? î Scotland
³ reg? šŽ deg! î temp
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

ÚÄRegionUnknownÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ �Weathermap
³ reg? : AREA
³ deg? : Ÿ
³ response! : REPORT
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ reg? Ï Scotland
³ response! = region_not_in_Scotland
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

RUpdate ¡ Update ˜ RegionUnknown

RLookUp ¡ LookUp ˜ RegionUnknown