0% found this document useful (0 votes)
17 views20 pages

Se 008

The document discusses formal specification techniques. It describes how formal specifications can precisely specify a system and verify that a system is correctly implemented. It then discusses different formal methods like formal specification, specification analysis and proof, transformational development, and program verification. Finally, it discusses different formal specification techniques like algebraic specification and model-based specification.

Uploaded by

Anushka Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views20 pages

Se 008

The document discusses formal specification techniques. It describes how formal specifications can precisely specify a system and verify that a system is correctly implemented. It then discusses different formal methods like formal specification, specification analysis and proof, transformational development, and program verification. Finally, it discusses different formal specification techniques like algebraic specification and model-based specification.

Uploaded by

Anushka Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

LECTURE -8

SOFTWARE ENGINEERING
FORMAL SPECIFICATIONS

1
FORMAL SPECIFICATIONS
Formal specification techniques enable us to:
oprecisely specify a system
overify that a system is correctly implemented
We say a system is correctly implemented:
owhen it satisfies its specification
A formal technique is a mathematical method
Formal techniques can be used:
oto specify a hardware and/or software system

Formal techniques can also be used to:


overify whether a specification is realizable,
overify that an implementation satisfies its specification,
oprove properties of a system without necessarily running the
system, etc
2
FORMAL METHODS
Formal specification is part of a more general collection of
techniques that are known as ‘formal methods’.
These are all based on mathematical representation and
analysis of software.
Formal methods include
 Formal specification;
 Specification analysis and proof;
 Transformational development;
 Program verification.

3
ACCEPTANCE OF FORMAL METHODS
Formal methods have not become mainstream software
development techniques as was once predicted

oOther software engineering techniques have been successful


at increasing system quality. Hence the need for formal
methods has been reduced;

oMarket changes have made time-to-market rather than


software with a low error count the key factor. Formal
methods do not reduce time to market;

oThe scope of formal methods is limited. They are not well-


suited to specifying and analysing user interfaces and user
interaction;

oFormal methods are still hard to scale up to large systems.


4
USE OF FORMAL METHODS
o The principal benefits of formal methods are in reducing the
number of faults in systems.
o Consequently, their main area of applicability is in critical
systems engineering. There have been several successful
projects where formal methods have been used in this area.
o In this area, the use of formal methods is most likely to be
cost-effective because high system failure costs must be
avoided.

5
SPECIFICATION IN THE SOFTWARE PROCESS

o Specification and design are inextricably intermingled.


o Architectural design is essential to structure a specification and the
specification process.
o Formal specifications are expressed in a mathematical notation with
precisely defined vocabulary, syntax and semantics.

6
SPECIFICATION AND DESIGN

Increasing contractor involvement

Decreasing client involvement

User System
Architectural Formal High-level
requirements requirements
design specification design
definition specification

Specification

Design

7
SPECIFICATION IN THE SOFTWARE PROCESS

System
Formal
requirements
specification
specification
User High-level
requirements
design
definition

System Architectural
modelling design

8
USE OF FORMAL SPECIFICATION
o Formal specification involves investing more effort in the early phases
of software development.
o This reduces requirements errors as it forces a detailed analysis of the
requirements.
o Incompleteness and inconsistencies can be discovered and resolved.
o Hence, savings as made as the amount of rework due to requirements
problems is reduced.

9
COST PROFILE
The use of formal specification means that the cost profile of a
project changes

o There are greater up front costs as more time and effort are spent
developing the specification;

o However, implementation and validation costs should be reduced as the


specification process reduces errors and ambiguities in the requirements.

10
DEVELOPMENT COSTS WITH FORMAL
SPECIFICATION

Cost
Validation

Design and
implementation Validation
Design and
implementation
Specification

Specification

11
SPECIFICATION TECHNIQUES
Algebraic specification
 The system is specified in terms of its operations and their relationships.
Model-based specification
 The system is specified in terms of a state model that is constructed using
mathematical constructs such as sets and sequences. Operations are defined by
modifications to the system’s state.

Sequential Concurrent

Algebraic Larch (Guttag et al., 1993) Lotos (Bolognesi and


}, Brinksma, 1987)},
OBJ (Futatsugi et al.,
1985)}

Model-based Z (Spivey, 1992)} CSP (Hoare, 1985)}


VDM (Jones, 1980)} Petri Nets (Peterson, 1981)}
B (Abrial, 1996)}

12
SPECIFICATION TECHNIQUES
Algebraic specification
 The system is specified in terms of its operations and their relationships.
Model-based specification
 The system is specified in terms of a state model that is constructed
using mathematical constructs such as sets and sequences. Operations
are defined by modifications to the system’s state.

13
ALGEBRAIC SPECIFICATION
WRITING SPECIFICATION FOR LIST

LIST ( Elem )
sor t List
impor ts INTEGER

Definesalistwhereelementsare addedattheendandremo ved


fromthefront. The oper ationsare Create ,whichbr ingsanemptylist
intoe xistence ,Cons ,whichcreatesa ne wlistwithanaddedmember ,
Leng th,whiche valuatesthe listsiz e,Head,whiche valuatesthe front
elementof thelist,and Tail,whichcreatesa listb yremo vingthe headfrom
itsinputlist.Undefinedrepresentsanundefinedvalueof typeElem.

Create  List
Cons (List, Elem)  List
Head (List)  Elem
Length (List)  Integer
Tail (List)  List

Head (Create) = Undefined exception (empty list)


Head (Cons (L, v)) = if L = Create then v else Head (L)
Length (Create) = 0
Length (Cons (L, v)) = Leng th (L) + 1
Tail (Create ) = Create
Tail (Cons (L, v)) = if L = Create then Create else Cons (T ail (L), v)

14
ASSIGNEMENT 1

Write a note on Formal Methods and various


methods in use incorporating salient features of

Z, B, TLA, ALLOY, HOL, CSP, PI Calculus

15
ASSIGNMENT 2

Write Formal Specifications for following in B.

Use Pro B Model Checker

1. FIFO Order Broadcast


2. Local Order Broadcast
3. Causal Order Broadcast

16
FIFO ORDER ORDERING PROPERTIES(1)

E11 E1 E1
P1 2 3
M1 M
2

P2
E21 E2
M1 2

P3
E3 E3 E3
1 2 1
If a particular process broadcasts a message M1 before it broadcasts a
message M2 , then each recipient process delivers M1 before M2.

17
 Message M1 ( ) shows violation of FIFO order.
Local Order Ordering
Properties(2)
E11 E1 E1
P1 2 3
M1 M
2

P2
E21 E2 E2
M1 2 3

P3
E3 E3 E3
1 3 1
If a process delivers a message M1 before it broadcasts a message M2 ,
then each recipient process delivers M1 before M2.

18
 Message M1 ( ) shows violation of global causal ordering.
Causal Order Ordering
Properties(3)

Delivery order : M1,M2,M3,M4

P1
M1 M2 M3 M4

P2

P3

If the broadcast of a message M1 causally precedes the broadcast of a


message M2 , then no process delivers M2 unless it has previously
delivered M1.

 M1 é M2 M2 é M3 M1 é M2 & M2 é M3 G M1 é M319
20

You might also like