L02 VDM Structure Q
L02 VDM Structure Q
VDM++ Structure
Refs
1. Lecture Note CSC264 Modelling and Computation, Steve Riddle, John Fitzgerald, Maciej Koutny.
2. John Fitzgerald, et.al, Validate Designs for OO Systems, Springer, 2005.
3. CSK group, VDMTools User Manual (VDM++) ver 1.1, 2007
• What is VDM++
• VDM++ Class Structure
– Data Definitions
– Functions & Operations definition
– Dynamic Behaviour
• Backus-Naur Form
• The syntax of a
class is described
as (CSK, 2006):
`class', identifier
(class body),
`end', identifier
types
amount = nat;
Syntax
access, identifier, ‘=’, type,
[‘inv’, pattern, ‘==’, expression, ‘;’]
private identifier =
nat|nat1|int|rat|real|bool|char|token
|<identifier>|set of ‘type’|seq of ‘type’
|map ‘typei’ to ‘typej’| type1 * type2 *…*typeN
|identifier :: identifier1:’type’ … identifierN:’type’;
Example
• What is VDM++
• VDM++ Class Structure
– Data Definitions
– Functions & Operations definition
– Dynamic Behaviour
• Backus-Naur Form
• Function
– takes input parameters and produce results, with
no reference to instance variables of the objects.
– Function returns a function as result or a function
can takes functions as arguments
• Operation
– take inputs and returns a result, but may read or
modify instance variables.
– can manipulate both the global variables
and any local variables.
returnBook:() ==
returnDate := date.getDate()
…
thread
periodic(24)(returnBook)
…
The operation returnBook() is executed periodically by the
BorrowRecord's thread, and is used to determine the returnDate
instance variable
Oct 30, 2023 19
Backus-Naur Form (BNF).
• Before we go further, the VDM++ syntax define by using BNF:
Symbol Description
meta non-terminal symbols written in lower case letters (possibly including space)
identifier It is of the form α -> β where α is a Non-Terminal Symbol which can be replaced by β which is a
string of Terminal Symbols (or can be non-terminal sysmbols)
; terminal symbol to denote the end of a rule
- denotes subtraction from a set of terminal symbols, e.g., character -(`"') denotes all characters
excepting the double quote character