Vienna Development Method - VDM Features - Basic Types: Numeric, Character, Token and Quote Types

Basic Types: Numeric, Character, Token and Quote Types

VDM-SL includes basic types modelling numbers and characters as follows:

Basic Types
bool Boolean datatype false, true
nat natural numbers (including zero) 0, 1, 2, 3, ...
nat1 natural numbers (excluding zero) 1, 2, 3, 4, ...
int integers ..., -3, -2, -1, 0, 1, 2, 3, ...
rat rational numbers a/b, where a and b are integers, b is not 0
real real numbers ...
char characters A, B, C, ...
token structureless tokens ...
the quote type containing the value ...

Data types are defined to represent the main data of the modelled system. Each type definition introduces a new type name and gives a representation in terms of the basic types or in terms of types already introduced. For example, a type modelling user identifiers for a log-in management system might be defined as follows:

types UserId = nat

For manipulating values belonging to data types, operators are defined on the values. Thus, natural number addition, subtraction etc. are provided, as are Boolean operators such as equality and inequality. The language does not fix a maximum or minimum representable number or a precision for real numbers. Such constraints are defined where they are required in each model by means of data type invariants—Boolean expressions denoting conditions that must be respected by all elements of the defined type. For example a requirement that user identifiers must be no greater than 9999 would be expressed as follows (where <= is the “less than or equal to” Boolean operator on natural numbers):

UserId = nat inv uid == uid <= 9999

Since invariants can be arbitrarily complex logical expressions, and membership of a defined type is limited to only those values satisfying the invariant, type correctness in VDM-SL is not automatically decidable in all situations.

The other basic types include char for characters. In some cases, the representation of a type is not relevant to the model’s purpose and would only add complexity. In such cases, the members of the type may be represented as structureless tokens. Values of token types can only be compared for equality – no other operators are defined on them. Where specific named values are required, these are introduced as quote types. Each quote type consists of one named value of the same name as the type itself. Values of quote types (known as quote literals) may only be compared for equality.

For example, in modelling a traffic signal controller, it may be convenient to define values to represent the colours of the traffic signal as quote types:

, , ,

Read more about this topic:  Vienna Development Method, VDM Features

Famous quotes containing the words basic, token, quote and/or types:

    Southerners, whose ancestors a hundred years ago knew the horrors of a homeland devastated by war, are particularly determined that war shall never come to us again. All Americans understand the basic lessons of history: that we need to be resolute and able to protect ourselves, to prevent threats and domination by others.
    Jimmy Carter (James Earl Carter, Jr.)

    He made for the door, automatically resuming his glasses and leaving in front of her, on the floor, his right slipper in token of his speedy return. Then, his desire exposed and his eyes wicked behind their strong lenses, he attempted to push her toward the bed.
    Vladimir Nabokov (1899–1977)

    That’s the nice thing about this job. You get to quote yourself shamelessly. If you don’t, Larry Speakes will.
    Ronald Reagan (b. 1911)

    Our major universities are now stuck with an army of pedestrian, toadying careerists, Fifties types who wave around Sixties banners to conceal their record of ruthless, beaverlike tunneling to the top.
    Camille Paglia (b. 1947)