25.07.2014 Views

VDM-10 Language Manual

VDM-10 Language Manual

VDM-10 Language Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>VDM</strong>-<strong>10</strong> <strong>Language</strong> <strong>Manual</strong><br />

of the entire state on the left-hand side of the equality and the right-hand side must evaluate<br />

to a record value of the correct type. This enables the interpreter to evaluate the initpred<br />

condition. A simple example of an initialisation predicate is shown below:<br />

✞<br />

✡✝<br />

state St of<br />

x: nat<br />

y: nat<br />

l: seq1 of nat<br />

init s == s = mk_St(0,0,[1])<br />

end<br />

In the specification of both the invariant and the initial value the state must be manipulated<br />

as a whole, and this is done by referring to it as a record tagged with the state name (see the<br />

example). When a field in the state is manipulated in some operation, the field must however<br />

be referenced to directly by the field name without pre-fixing it with the state name.<br />

Examples: In the following example we create one state variable:<br />

✞<br />

types<br />

GroupName = | | | | | | | <br />

state GroupPhase of<br />

gps : map GroupName to set of Score<br />

inv mk_GroupPhase(gps) ==<br />

forall gp in set rng gps &<br />

(card gp = 4 and<br />

{forall sc in set gp & sc.won + sc.lost + sc.drawn init_sc({, ,<br />

, }),<br />

...})<br />

end<br />

functions<br />

✆<br />

init_sc : set of Team -> set of Score<br />

init_sc (ts) ==<br />

{ mk_Score (t,0,0,0,0) | t in set ts }<br />

✡✝<br />

✆<br />

In the invariant we state that each group has four teams, and no team plays more than three<br />

86

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!