25.07.2014 Views

VDM-10 Language Manual

VDM-10 Language Manual

VDM-10 Language Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

✡✝<br />

| sc in set gps(gp)}};<br />

✆<br />

The externals field lists the state/instance variables that the operation will manipulate. The<br />

state/instance variables listed after the reserved word rd can only be read whereas the operation<br />

can both read and write the variables listed after wr.<br />

In <strong>VDM</strong>-SL these pre- and post-conditions the interpreter also creates new functions as with<br />

the pre- and post-conditions of operation definitions. However, if a specification contains a<br />

global state, the state is also part of the newly created functions. Thus, functions with the<br />

following signatures are created for operations with pre- and/or post-conditions 1 :<br />

✞<br />

pre_Op : InType * State +> bool<br />

✡✝<br />

post_Op : InType * OutType * State * State +> bool<br />

✆<br />

with the following exceptions:<br />

• If the operation does not take any arguments, the InType part of the signature is left<br />

out in both the pre Op and post Op signatures.<br />

• If the operation does not return a value, the OutType part is left out in the post Op<br />

signature.<br />

• If the specification does not define a state, the State part(s) of both signatures are left<br />

out.<br />

In the post Op signature, the first State part is for the old state, whereas the second<br />

State part is for the state after the operation call.<br />

For instance, consider the following specifications:<br />

✞<br />

module A<br />

definitions<br />

state St of<br />

n : nat<br />

end<br />

operations<br />

Op1 (a : nat) b :nat<br />

1 However, you should remember that these pre and post condition predicates for an operation are simply boolean<br />

functions and the state components are thus not changed by calling such a predicate.<br />

92

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

Saved successfully!

Ooh no, something went wrong!