VDM-10 Language Manual
VDM-10 Language Manual
VDM-10 Language Manual
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapter 11<br />
The State Definition (<strong>VDM</strong>-SL)<br />
If global variables are desired in a specification, it is possible to make a state definition. The<br />
components of the state definition can be considered the collection of global variables which can<br />
be referenced inside operations. A state in a module is initialised before any of the operation<br />
definitions (using that state) in a module can be used by the interpreter.<br />
Syntax:<br />
state definition = ‘state’, identifier, ‘of’, field list,<br />
[ invariant ], [ initialisation ], ‘end’, [ ‘;’ ] ;<br />
invariant = ‘inv’, invariant initial function ;<br />
initialisation = ‘init’, invariant initial function ;<br />
invariant initial function = pattern, ‘==’, expression ;<br />
Semantics: The state definition has the form:<br />
✞<br />
✡✝<br />
state ident of<br />
id1 : type1<br />
...<br />
idn : typen<br />
inv pat1 == invpred<br />
init pat2 == initpred<br />
end<br />
✆<br />
A state identifier idn is declared of a specific type typen. The invariant invpred is a<br />
boolean expression denoting a property which must hold for the state ident at all times.<br />
initpred denotes a condition which must hold initially. It should be noticed that in order<br />
to use the interpreter, it is necessary to have an initialisation predicate (if any of the operations<br />
using the state are to be executed). In addition the body of this initialisation predicate<br />
must be a binary equality expression with the name (which also must be used as the pattern)<br />
85