Definitions-Formal Specification Methods in Software Development-Lecture Slides, Slides of Software Development Methodologies

This lecture was delivered by Sharman Munjha Jadeja at Birla Institute of Technology and Science for Formal Specification Methods in Software Development course. It includes: Definitions, Introduction, Z, Notation, Declaration, Guest, Room, Abbreviations, English, Scots

Typology: Slides

2011/2012

Uploaded on 07/09/2012

chand
chand ๐Ÿ‡ฎ๐Ÿ‡ณ

4.4

(7)

31 documents

1 / 20

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Chapter No. 6
Definitions
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download Definitions-Formal Specification Methods in Software Development-Lecture Slides and more Slides Software Development Methodologies in PDF only on Docsity!

Chapter No. 6

Definitions

Introduction

  • A formal specification should contain a

significant amount of prose

  • This should relate the mathematical

objects to features of the design: system states, data structures, properties, and operations.

  • Of course, if the statements in the

mathematics are to be meaningful, then we must ensure that the objects concerned are properly defined.

Declaration

  • Simplest way to define object is to declare
  • If the object is a given set, or basic type, then we do by writing its name between brackets e.g. the declaration [Type]
  • The declaration

x : A introduces a new variable x, from the set A. If this set is not Z, the type of integers, then it must be defined elsewhere

Declaration

Example 6.1 : A hotel switchboard uses a software package to maintain a record of call charges to current guests. A formal specification of this system may be [Guest, Room] introduces two basic types to represent set of all guests and set of all rooms.

  • A variable of the type Guest is introduced by the following declaration: x : Guest

Abbreviations

Example 6.2 The abbreviation definition

Additive == { red, green, blue} introduces a set Additive, as another name for the set described in enumeration above

  • The names red, green, and blue must be

defined elsewhere,

  • If they are elements of type Colours, then

Additive is a constant of type ๏ Colours.

Abbreviations

Example 6.4 :

Let Person, represents the set of all people, we introduce abbreviations for the set of all people who take sugar in tea:

English == {p : Person | p drinks tea ๏ƒ™ p takes sugar}

And those who put salt on their porridge:

Scots == {q : Person | q eats porridge ๏ƒ™ q adds salt}

Generic Abbreviations

  • The simplest example is the definition of the empty set symbol
  • In a Z specification, there may be many empty sets, one for each type.
  • We must distinguish between empty sets of different types
  • No expression can have a value that belongs to more than one type.
  • To define the empty set of objects from S,

๏†[S] == { x : S | false } == { x : S | false ๏‚ท x}

Generic Abbreviations

Example 6.5 : For any set T, we may define the set of all non-empty subsets of T as: ๏ 1 T == { a : ๏ T | a ๏‚น ๏†}

  • We are happy to omit the brackets from the parameter list in the definition ๏ 1 {0, 1} = { {0}, {1}, {0, 1} }
  • A second generic symbol appears in the definition above: the ๏† symbol.
  • From the context, it is clear that this denotes the empty set of elements from T.

Axiomatic Definitions

  • A third form of definition includes a constraint upon the object being introduced.
  • It is an axiom for the object.
  • An axiomatic definition takes the form

declaration x : S predicate p

where the predicate expresses the constraints upon the object or objects introduced in the declaration.

Axiomatic Definitions

Example 6.8 We may use an axiomatic definition to define set of natural numbers

๏Ž : ๏ ๏š

๏€ข z : ๏š ๏‚ท z ๏ƒŽ ๏Ž ๏ƒ› z ๏‚ณ 0

Example 6.9 We may define constant maxsize as follows:

maxsize : ๏Ž

maxsize ๏€พ o

Generic Definitions

Example 6.12 : The generic non-empty power set constructor defined using an abbreviation in Example 6.5 may also be defined using a generic definition:

[X] ๏ 1 : ๏(๏ X) ๏ 1 = { s : ๏ X | s ๏‚น ๏† }

Brackets around generic parameter are optional: the forms ๏ 1 [s] and ๏ 1 s are equally acceptable.

Generic Definitions

Example 6.13: We can use a generic

definition to define the subset symbol:

[X] _ ๏ƒ _ : ๏ X ๏‚ซ ๏ X

๏€ข s, t : ๏ X ๏‚ท s ๏ƒ t ๏ƒ› ๏€ข x : X ๏‚ท x ๏ƒŽ s ๏ƒž x ๏ƒŽ t

Sets and Predicate

Example 6.15 We wish to formalize the predicate โ€œis a crowdโ€ upon sets of people. Where crowd is defined as the number of people more than 3. To do this, we introduce a set of sets

Formalization:

crowds : ๏ (๏ Person)

crowds = { s : ๏ Person | # s ๏‚ณ 3}

Sets and Predicate

Example 6.16 For a number of reasons, it is not a good idea to have Alice and Bill in the room at the same time. Thus, a set of people is safe if it contains Alice, or Bill, or neither, but not both. We may define safe as a property of sets of people

Formalization:

safe _ : ๏ (๏ Person)

๏€ข s : ๏ Person ๏‚ท safe s ๏ƒ› ๏€ก ({Alice, Bill} ๏ƒ s)