4> . -r' ' ; ( , i ~ An Approach to Structuring for the - - PowerPoint PPT Presentation

4 r i an approach to structuring for the vdm
SMART_READER_LITE
LIVE PREVIEW

4> . -r' ' ; ( , i ~ An Approach to Structuring for the - - PowerPoint PPT Presentation

4> . -r' ' ; ( , i ~ An Approach to Structuring for the VDM Specification Language Stephen Bear Fli;' HEWLETT HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT PACKARD ~ REQUIREMENTS Allow a large


slide-1
SLIDE 1

·

4> .

  • r'
' ;

(

, i

slide-2
SLIDE 2

An Approach to Structuring for the VDM Specification Language Stephen Bear

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

Fli;' HEWLETT

~

PACKARD

slide-3
SLIDE 3

REQUIREMENTS

  • Allow a large specification to be split into person

sized units, in a natural way.

  • Allow an individual module, or an incomplete group
  • f modules to be checked.
  • Limit interference between separate units.
  • Provide a detailed semantic definition

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

SB31

Fli;- HEWLETT

~

PACKARD

slide-4
SLIDE 4

CONSTRAINTS

  • It must be possible to compare the semantics of a

specification given in the core language with the semantics of a specification given using the structuring constructs.

  • so we use the same basic mathematical machinery.
  • The definition of the structuring constructs must

preserve the semantics of the core language.

  • so we do not extend the core language.

SB32

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

Flin- HEWLETT

~

PACKARD

slide-5
SLIDE 5

A CHOICE

  • Use simple unsophisticated mathematics

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

S868

Flin- HEWLETT

~

PACKARD

slide-6
SLIDE 6

OVERVIEW OF MODULES

  • As in STC VDM, the basic specification unit is a

MODULE.

  • A module encapsulates a collection of related types,

values, functions and operations.

  • Operations within a module may interact by updating

values of a shared state.

  • A module is similar to an algebraic ADT.

It defines a state type which may be used in other modules.

  • A module is an object.

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

S833

Flio- HEWLETT

~

PACKARD

slide-7
SLIDE 7

MODULE SYNTAX Module

::

intf: Interface body: {Definitions}

Module

  • -

description of constructs provided by,

  • -
  • r used by, the module

Definitions

  • -

collection of definitions written in end the core language, but using constructs introduced by the interface

SB34

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

Flin- HEWLETT

~

PACKARD

slide-8
SLIDE 8

OVERVIEW OF IMPORT-EXPORT CONSTRUCTS

  • A module may EXPORT constructs.
  • Exported constructs may be imported and used

by another module.

  • A group of modules may import constructs from

each other.

  • A construct which is not exported is "hidden". A

hidden construct may not be refered to by any other module.

S935

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

Flin- HEWLETT

~

PACKARD

slide-9
SLIDE 9

INTERFACE - EXPORT CLAUSE Interface

::

id : Id exp : ModSig

m

ModSig

::

types : Name -> [TypeDef]

m values : Name -> [Type}

m

fns : Name -> [FnType] m

  • pns : Name -> [OpSig]

Names of constructs with optional syntactic description

S936

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

Flii- HEWLETT

~

PACKARD

slide-10
SLIDE 10

FULL CONCRETE SYNTAX FOR EXPORT Module INTEGER STACK exports types INTEGER_STACK

  • perations

POP 0 0> INTEGER using INTEGER_STACK PUSH (INTEGER) using INTEGER_STACK definitions end

5837

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

rh;'

HEWLETT

~

PACKARD

slide-11
SLIDE 11

CONCRETE SYNTAX WITH IMPLICIT STATE TYPE Module INTEGER STACK exports

  • perations

POP 0 0> INTEGER PUSH (INTEGER) definitions end If an operation exported by module M does not specify the state type explicitly, then the state type is M and the type is implicitly imported.

SB38

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

Flin- HEWLETT

~

PACKARD

slide-12
SLIDE 12

LIGHTWEIGHT SYNTAX Module INTEGER STACK exports

  • perations

POP, PUSH definitions end POP 0 0> INTEGER PUSH (INTEGER) Signatures provided by the definitions need not be repeated in the export clause.

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

SB39

Fli;' HEWLETT

~

PACKARD

slide-13
SLIDE 13

INTERFACE - IMPORT CLAUSE Interface

::

id : Id

m imp : Id -> Mod Sig exp : ModSig

  • Id of module providing imported constructs
  • Syntactic description of constructs

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

SB40

Flin- HEWLETT

~

PACKARD

slide-14
SLIDE 14

IMPLICIT STATE TYPE Module SYMBOL TABLE end imports from INTEGER_STACK

  • perations

POP 0 0> INTEGER PUSH (INTEGER) If an operation imported from a module M does not specify the state tpe explicitly, then the name of the state type is also M and the type is implicitly imported.

SB41

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

rh;'

HEWLETT

~

PACKARD

slide-15
SLIDE 15

LIGHTWEIGHT SYNTAX Module INTEGER STACK

Exports

end Operations POP 0 0> INTEGER PUSH (INTEGER) Module SYMBOL TABLE

imports from INTEGER_STACK Operations POP, PUSH

end If a document contains a module which exports a construct and another which imports it, then the signatures need to be repeated. HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

S842

FliDW HEWLETT

~

PACKARD

slide-16
SLIDE 16

Name:: prefix

: local NAMES seq1 of Id : Id module INTEGER_STACK exports

  • perations POP, PUSH

end Names reflect module structure directly - the prefix indicates where the construct is defined. The full name of POP is INTEGER STACK. POP

SB43

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

r,~

HEWLETT

~

PACKARD

slide-17
SLIDE 17

NAMES OF IMPORTED CONSTRUCTS Module INTEGER STACK exports

  • perations POP, PUSH

end Module SYMBOL TABLE imports from INTEGER_STACK

  • perations POP, PUSH

end

  • The full name of a construct is not changed if it is

imported.

  • In both modules the full names of POP and PUSH are

INTEGER STACK.POP INTEGER STACK.PUSH

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

SB44

Fli;- HEWLETT

~

PACKARD

slide-18
SLIDE 18

SEMANTICS OF THE CORE LANGUAGE

  • The semantics of the core language is given in terms
  • f models"
  • A model is a mapping which gives a denotation to a

named construct.

INTEGER_STACK -->

POP --> PUSH -->

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

SB45

Fli"

;'

HEWLETT

~

PACKARD

slide-19
SLIDE 19

MODELS OF A SPECIFICATION A model may - or may not - satisfy a specification definitions

RED->

BLUE -> type RED = - -

  • type BLUE = - - -

RED -> BLUE ->

SB46

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

F/i'n- HEWLETT

~

PACKARD

slide-20
SLIDE 20

SEMANTICS OF A SPECIFICATION

  • The models which satisfy a specification are picked
  • ut by a relation

is-a-model-of C

MODELS x Definitions

  • The semantics of a specification is defined to be the

set of all models which satisfy the specification. [[spec]] ~ { M 6 MODELS I M is-a-model-of spec}

  • Defining this relation is a non-trivial task

SS47

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

F/,-n- HEWLETT

~

PACKARD

slide-21
SLIDE 21

UNDEFINED CONSTRUCTS ARE UNDETERMINED

RED->

SOR-> 0

RED->

SQR->~

UE -> BLUE ->

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT RED->

SOR-> D

BLUE ->

SS48

Fli;' HEWLETT

~

PACKARD

slide-22
SLIDE 22

MODELS MAY CONTAIN JUNK

  • ME [[spec]] A n (j dom (m) ==> m u [n->v] 6- [[spec]]

RED-> RED-> SQR->

BLUE -> BLUE ->

  • For any two specifications S, T, if [[S]] is non-empty

it contains models which provide denotations for constructs defined or used by T.

SB49

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

F/£;' HEWLETT

~

PACKARD

slide-23
SLIDE 23

module COLOURS exports types RED, BLUE definitions end module COLOURED_BOXES imports from COLOURS types RED, BLUE definitions

RED_BOX = box of RED BLUE_BOX - box of BLUE

end

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

S950

Flin- HEWLETT

~

PACKARD

slide-24
SLIDE 24

MODELS OF COLOURED BOXES

RED->

RED BOX-> BLUE->

RED->

RED BOX->

LUE_BOX->

RED -> BLUE -> RED BOX-> BLUE

BOX->

~-~

~

  • ~

RED->

RED_BOX->

BLUE -> BLUE BOX-> HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT UE -> BLUE BOX->

SB51

rh;'

HEWLETT

~

PACKARD

slide-25
SLIDE 25

MODELS OF COLOURS

RED->

RED BOX-> BLUE->

RED->

RED BOX->

LUE_BOX->

RED -> BLUE -> BLUE BOX->

r------'----------->---

RED->

BLUE -> HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT RED BOX-> UE -> CIRCLE ->

  • 5852

Flin- HEWLETT

~

PACKARD

slide-26
SLIDE 26

MODELS OF THE COMPLETE DOCUMENT RED ->

RED_BOX ->

BLUE -> BLUE BOX-> [[Document]].6. [[COLOURS]] (\ [[COLOURED_BOXES]]

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

5853

Fhdi HEWLETT

~

PACKARD

slide-27
SLIDE 27

OVERVIEW OF PARAMETERISATION

  • A module may be paramerised by formal parameters
  • types, values, functions or operations.
  • Within the parameterised module, the formal parameters

may be used like any other construct.

  • A parameterised module may be INSTANTIATED within

another module. Formal parameters are replaced by actual parameters.

  • Within the instantiating module, the newly instantiated

constructs may be used like any other construct.

5854

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

Fli-;' HEWLETT

~

PACKARD

slide-28
SLIDE 28

INTERFACE - PARAMETER CLAUSE Interface::

id : Id

par: ModSig

imp: Id !1!.>ModSig

exp : ModSig Syntactic description of formal parameters

  • types, values, functions or operations.

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

SB55

rli~

HEWLETT

~

PACKARD

slide-29
SLIDE 29

PARAMETERISED MODULE Module SORT parameters types ITEM functions ARE_ORDERED (ITEM,ITEM) --> Boolean exports functions DO_SORT (seq of ITEM) --> seq of ITEM end Within a parameterised module, formal parameters may be used like any other constructs.

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

5856

Flin- HEWLETT

~

PACKARD

slide-30
SLIDE 30

INSTANTIATION Interface:: id : Id

part: ModSig imp: Id ~>

ModSig inst ; Id ll!.> Instance exp : ModSig Instance::

mod: Id view: Id !1l.> Name

sig : ModSig An instance of a parameterised module may be created

  • instantiated - by another module

SB57

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

rhn- HEWLETT

~

PACKARD

slide-31
SLIDE 31

INSTANTIATION OF SORT Module SORT parameters types ITEM functions ARE_ORDERED (ITEM, ITEM) --> Boolean exports functions DO_SORT (seq of ITEM) --> seq of ITEM end Module MAILING LIST instantiates

INTEGER_SORT as new SORT

(ITEM --> INTEGER, ARE_ORDERED --> GE) Functions DO_SORT (seq of INTEGER) --> seq of INTEGER end

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

SB58

Fli;- HEWLETT

~

PACKARD

slide-32
SLIDE 32

NAMES OF INSTANTIATED CONSTRUCTS

  • Suppose that a parameterised module defines a type

T. Then the full name is P.T

  • If a module M creates an instance I of P

module M instantiates I as new P (- - - ) type T The full name of the instantiated construct is M.I.T

S859

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

Flin- HEWLETT

~

PACKARD

slide-33
SLIDE 33

Module MAILING LIST instantiates

INTEGER_SORT as new SORT

(ITEM --> INTEGER, ..

.)

Functions DO_SORT (seq of INTEGER) --> seq of INTEGER ADDRESS SORT as new SORT (ITEM --> ADDRESS, .. .) Functions DO_SORT (seq of ADDRESSS) --> seq of ADDRESS end

  • MAILlNG_LlST.INTEGER_SORT.DO_SORT
  • MAILlNG_LlST.ADDRESS_SORT.DO_SORT

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

SB

GO

Flin- HEWlETT

~

PACKARD

slide-34
SLIDE 34

Module COLOURED BOX parameters type COLOUR exports type SHAPE definitions SHAPE = Box of COLOUR end Module BOXES instantiater

RED_BOX is new COLOURED_BOX

(COLOUR -->RED) type SHAPE end

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

5861

F/£DW HEWLETT

~

PACKARD

slide-35
SLIDE 35

MODELS OF COLOURED_BOX COLOUR --> COLOUR --> SHAPE --> SHAPE --> COLOUR --> SHAPE -->

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

COLOUR --> SHAPE -->

5B62

Flin- HEWLETT

~

PACKARD

slide-36
SLIDE 36

RED --> RED_BOX.SHAPE

  • -> ~

MODELS OF BOXES RED BOX.SHAPE

  • ->

RED --> RED --> RED_BOX.SHAPE

  • ->

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

RED -->

RED_BOX SHAPE

  • -> e

SB63

Fli;' HEWLETT

~

PACKARD

slide-37
SLIDE 37

MODELS OF AN INSTANTIATION

  • The models of the parameterised module and the

instantiating module can not be compared direclty.

  • Models of the instantiation.

R

Name -------------------- . Name rng R<J Mp rng R<J Mi VAL Mi is a model of the instantiation iff there is a model Mp of the parameterised module such that the diagram commutes.

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

SB64

Fli;' HEWLETT

~

PACKARD

slide-38
SLIDE 38

MODELS OF THE INSTANTIATION RED --> RED_SOX.SHAPE

  • ->

RED --> RED SOX.SHAPE

  • ->

RED --> RED_SOX.SHAPE

  • ->

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

RED --> RED BOX SHAPE

  • ->

SB65

Fli;' HEWLETT

~

PACKARD

slide-39
SLIDE 39

MODELS OF THE DOCUMENT RED --> RED_BOX.SHAPE

  • ->

[[document]] = [[BOXES]] f\ [[instantiate (COLOURED_BOX)]] HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

SB66

Fli·;- HEWLETT

~

PACKARD

slide-40
SLIDE 40

SUMMARY

  • A specification may be defined as a collection of

(parameterized) modules.

  • Modules define types - decomposition by types is an

established approach.

  • The semantics of structuring is defined in terms of the

core language.

  • The semantics of the core language has not been

changed.

SB67

HPLABS - INFORMATION SYSTEMS CENTRE SOFTWARE ENGINEERING DEPARTMENT

Fli;- HEWLETT

~

PACKARD