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 />

✞<br />

✡✝<br />

|| (stmt1, stmt2, ..., stmtn)<br />

✆<br />

and it represents the execution of the component statements stmti in an arbitrary (nondeterministic)<br />

order. However, it should be noted that the component statements are not<br />

executed simultaneously. Notice that the interpreter will use an underdetermined 4 semantics<br />

even though this construct is called a non-deterministic statement.<br />

Examples: Using the <strong>VDM</strong>-SL state definition<br />

✞<br />

✡✝<br />

state St of<br />

x:nat<br />

y:nat<br />

l:seq1 of nat<br />

end<br />

or the <strong>VDM</strong>++ instance variables<br />

✞<br />

✡✝<br />

instance variables<br />

x:nat;<br />

y:nat;<br />

l:seq1 of nat;<br />

we can use the non-deterministic statement to effect a bubble sort:<br />

✞<br />

✡✝<br />

Sort: () ==> ()<br />

Sort () ==<br />

while x < y do<br />

||(BubbleMin(), BubbleMax());<br />

✆<br />

✆<br />

✆<br />

Here BubbleMin “bubbles” the minimum value in the subsequence l(x,...,y) to the<br />

head of the subsequence and BubbleMax “bubbles” the maximum value in the subsequence<br />

l(x,...,y) to the last index in the subsequence. BubbleMin works by first iterating<br />

through the subsequence to find the index of the minimum value. The contents of this index<br />

are then swapped with the contents of the head of the list, l(x).<br />

✞<br />

BubbleMin : () ==> ()<br />

BubbleMin () ==<br />

4 Even though the user of the interpreter does not know the order in which these statements are executed they are always<br />

executed in the same order unless the seed option is used.<br />

1<strong>10</strong>

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

Saved successfully!

Ooh no, something went wrong!