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.

Chapter 6. Expressions<br />

Semantics: Assuming e is of function type the expression pre (e,e1,...,en) is true if and<br />

only if the pre-condition of e is true for arguments e1,...,em where m is the arity of the<br />

pre-condition of e. If e is not a function or m > n then the result is true. If e has no<br />

pre-condition then the expression equals true.<br />

Examples: Consider the functions f and g defined below<br />

✞<br />

f : nat * nat -> nat<br />

f(m,n) == m div n<br />

pre n 0;<br />

✡✝<br />

g (n: nat) sqrt: nat<br />

pre n >= 0<br />

post sqrt * sqrt n<br />

✆<br />

Then the expression<br />

✞<br />

✡✝<br />

pre_(let h in set {f,g,lambda mk_(x,y): nat * nat & x div y}<br />

in h, 1,0,-1)<br />

✆<br />

is equal to<br />

• false if h is bound to f since this equates to pre f(1,0);<br />

• true if h is bound to g since this equates to pre g(1);<br />

• true if h is bound to lambda mk (x,y):nat * nat & x div y since there is<br />

no pre-condition defined for this function.<br />

Note that however h is bound, the last argument (-1) is never used.<br />

71

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

Saved successfully!

Ooh no, something went wrong!