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

where all the domain expressions di and range expressions ri are general expressions. The<br />

empty map must be written as {|->}.<br />

A map comprehension has the form:<br />

✞<br />

✡✝<br />

{ed |-> er | mbd1, ..., mbdn & P}<br />

where constructs mbd1, ..., mbdn are multiple bindings of variables from the expressions<br />

ed and er to sets (or types). The map comprehension constructs a mapping by evaluating<br />

the expressions ed and er on all the possible bindings for which the predicate P<br />

evaluates to true.<br />

✆<br />

Examples: Given that GroupG is equal to the map<br />

✞<br />

✡✝<br />

{ |-> mk_(2,1,0), |-> mk_(2,0,1),<br />

|-> mk_(1,0,2), |-> mk_(0,1,2) }<br />

✆<br />

then:<br />

{ t |-> let mk (w,d,-) = GroupG(t)<br />

in w * 3 + d<br />

| t in set dom GroupG}<br />

{ t |-> w * 3 + d<br />

| t in set dom GroupG, w,d,l:nat<br />

& mk (w,d,l) = GroupG(t)<br />

and w > l}<br />

≡ { |-> 7,<br />

|-> 6,<br />

|-> 3,<br />

|-> 1}<br />

≡ { |-> 7,<br />

|-> 6}<br />

6.<strong>10</strong> Tuple Constructor Expressions<br />

Syntax: expression = . . .<br />

| tuple constructor<br />

| . . . ;<br />

tuple constructor = ‘mk ’, ‘(’, expression, ‘,’, expression list, ‘)’ ;<br />

Semantics: The tuple constructor expression has the form:<br />

✞<br />

mk_(e1, e2, ..., en)<br />

✡✝<br />

✆<br />

where ei is a general expression. It can only be used by the equality and inequality operators.<br />

55

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

Saved successfully!

Ooh no, something went wrong!