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.

Chapter 6. Expressions<br />

✞<br />

state sigma of<br />

numbers : seq of nat<br />

index : nat<br />

inv mk_sigma(numbers, index) ==<br />

index not in set elems numbers<br />

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

end<br />

✡✝<br />

✆<br />

For an example of the use of old names, consider the <strong>VDM</strong>++/<strong>VDM</strong>-RT instance variables<br />

defined as:<br />

✞<br />

✡✝<br />

instance variables<br />

numbers: seq of nat := [];<br />

index : nat := 1;<br />

inv index not in set elems numbers;<br />

✆<br />

We can define an operation that increases the variable index in an implicit manner:<br />

✞<br />

✡✝<br />

IncIndex()<br />

ext wr index : nat<br />

post index = index˜ + 1<br />

✆<br />

The operation IncIndex manipulates the variable index, indicated with the ext wr<br />

clause. In the post condition, the new value of index is equal to the old value of index<br />

plus 1. (See more about operations in section 12).<br />

For a simple example of module/class names, suppose that a function called build rel is<br />

defined (and exported) in a module/class called CGRel as follows:<br />

✞<br />

types<br />

Cg = | | | | | |<br />

| | | | | ;<br />

CompatRel = map Cg to set of Cg<br />

functions<br />

✡✝<br />

build_rel : set of (Cg * Cg) -> CompatRel<br />

build_rel (s) == {|->}<br />

69<br />

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

Saved successfully!

Ooh no, something went wrong!