VDM-10 Language Manual
VDM-10 Language Manual
VDM-10 Language Manual
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 19<br />
Static Semantics<br />
<strong>VDM</strong> specifications that are syntactically correct according to the syntax rules do not necessarily<br />
obey the typing and scoping rules of the language. The well-formedness of a <strong>VDM</strong> specification<br />
can be checked by the static semantics checker. In the Toolbox such a static semantics checker (for<br />
programming languages this is normally referred to as a type checker) is also present.<br />
In general, it is not statically decidable whether a given <strong>VDM</strong> specification is well-formed<br />
or not. The static semantics for the <strong>VDM</strong> languages differs from the static semantics of other<br />
languages in the sense that it only rejects specifications which are definitely not well-formed, and<br />
only accepts specifications which are definitely well-formed. Thus, the static semantics for the<br />
<strong>VDM</strong> languages attach a well-formedness grade to a <strong>VDM</strong> specification. Such a well-formedness<br />
grade indicates whether a specification is definitely well-formed, definitely not-well-formed, or<br />
possibly well-formed.<br />
In the Toolbox this means that the static semantics checker can be called for either possible<br />
correctness or definite correctness. However, it should be noted that only very simple specifications<br />
will be able to pass the definite well-formedness check. Thus, for practical use the possible wellformedness<br />
is most useful.<br />
The difference between a possibly well-formedness check and a definite well-formedness check<br />
can be illustrated by the following fragment of a <strong>VDM</strong> specification:<br />
✞<br />
✡✝<br />
if a = true<br />
then a + 1<br />
else not a<br />
where a has the type nat | bool (the union type of nat and bool). The reader can easily<br />
see that this expression is ill-formed if a is equal to true because then it will be impossible to<br />
add one to a. However, since such expressions can be arbitrarily complex this can in general not<br />
be checked statically. In this particular example possible well-formedness will yield true while<br />
definite well-formedness will yield false.<br />
✆<br />
165