VDM-10 Language Manual
VDM-10 Language Manual
VDM-10 Language Manual
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapter 3. Data Type Definitions<br />
total function type = discretionary type, ‘+>’, type ;<br />
discretionary type = type | ‘(’,‘)’ ;<br />
Equation: F = A +> B 7 or F = A -> B<br />
Constructors: In addition to the traditional function definitions the only way to construct functions<br />
is by the lambda expression: lambda pat1 : T1, ..., patn : Tn &<br />
body where the patj are patterns, the Tj are type expressions, and body is the body<br />
expression which may use the pattern identifiers from all the patterns.<br />
Operators:<br />
The syntax and semantics for the lambda expression are given in section 6.16.<br />
Operator Name Type<br />
f(a1,...,an) Function apply A1 * · · · * An → B<br />
f1 comp f2 Function composition (B → C) * (A → B) → (A → C)<br />
f ** n Function iteration (A → A) * nat → (A → A)<br />
t1 = t2 Equality A * A → bool<br />
t1 t2 Inequality A * A → bool<br />
Note that equality and inequality between type values should be used with great care. In<br />
<strong>VDM</strong> languages this corresponds to the mathematical equality (and inequality) which is not<br />
computable for infinite values like general functions. Thus, in the interpreter the equality is<br />
on the abstract syntax of the function value (see inc1 and inc2 below).<br />
Semantics of Operators:<br />
Operator Name<br />
Function apply<br />
Function composition<br />
Function iteration<br />
Semantics Description<br />
yields the result of applying the function f to the values<br />
of a j . See the definition of apply expressions in<br />
Section 6.12.<br />
it yields the function equivalent to applying first f2<br />
and then applying f1 to the result. f1, but not f2<br />
may be Curried.<br />
yields the funciton equivalent to applying f n times.<br />
n=0 yields the identity function which just returns the<br />
value of its parameter; n=1 yields the function itself.<br />
For n>1, the result of f must be contained in its parameter<br />
type.<br />
7 Note that the total function arrow can only be used in signatures of totally defined functions and thus not in a type<br />
definition.<br />
29