ASE Lesson1 Formal Specification PDF
ASE Lesson1 Formal Specification PDF
1.0 Introduction
In the Second Week of Advanced Software Engineering course, you will learn how
to find the formal specification in software development process as well as where
you are going to apply formal specification in the development stage. And also you
will learn the techniques of formal specification and how they remove areas of
doubt in a specification and avoid some problems of language misinterpretation.
The principal value of using formal methods in the software process is that it
forces an analysis of the system requirements at an early stage. Correcting errors
at this stage is cheaper than modifying a delivered system.
Learning outcomes
Formal methods are used to refer to any activities that rely on mathematical
representations of software including formal system specification, specification
analysis and proof, transformational development, and program verification. All of
these activities are dependent on a formal specification of the software.
I. An algebraic approach
System is described in terms of operations and their relationship.
Table 1.1 shows examples of the languages developed for each of these
models. You can see from this table the most of these languages were
developed in the 1980s.
This describes the data and operation that can be accessed through the sub-
system interface. You can therefore define a sub-systems interface
specification by combining the specification of the objects that make up the
interface.
<SPECIFICATION NAME>
sort <name>
Imports<LIST OF SPECIFICATION NAMES>
Operation signatures setting out the names and the types of the parameters to
the operations defined over the sort
Introduction
An Introduction declares the sort (the type name) of the entity being
specified. A sort is the name of a set of objectives with common
characteristics. It is similar to a type in a programming language. The
introduction may also include an ‘imports’ declaration, where the names of
specification defining other sorts are declared. Importing a specification
makes these sorts available for use.
Signature
The signature part defines the syntax of the interface to the object class or
abstract data type. The names of the operations that are defined, the
number and sorts of their parameters, and the sort of operation results are
described in the signature.
Axioms
The axioms part defines the semantics of the operations by defining a set of
axioms that characterize the behaviour of the abstract data type. These
axioms relate the operations used to construct entities of the defined sort
with operations used to inspect its values.
LIST (Elem)
sort List
imports INTEGER
Create List
Cons(List, Elem) List
Head(List) Elem
Length(List) Integer
Tail(List) List
• Constructor operations
This creates or modify entities of the sort defined in the specification.
Typically, these are given names such as Create, Update, Add or, in this
case, Cons, meaning construct.
• Inspection operations
This evaluates attributes of the sort defined in the specification.
Typically, these are given names such as Eval or Get.
Container
contents : N
capacity : N
Contents”< capacity
Schema invariant
• Each Z schema has an invariant part which defines conditions that are
always true.
• For the insulin pump schema it is always true that
The dose must be less than or equal to the capacity of the insulin
reservoir,
No single dose may be more than 4 units of insulin and the total
delivered in a time period must not exceed 25 units of insulin.
This is a safety constraint;
Display2! shows the amount of insulin to be delivered.
State invariants
R2 = Reading?
Dose< insulin_available
Insulin_available < capacity
//The cumulative dose of insulin delivered is set to zero once every 24
hours
Clock? = 000000 cumulative_dose = 0
//If the cumulative does exceeds the limit then operation is suspended
Cumulative dose > max_daily_dose ^ status = error ^
Run Schema
INSULIN_PUMP_STATE
switch? = auto_
status = running v status = warning
Insulin_available > max_single_dose
cumulative_dose < max_daily_dose
//1. If the computed insulin dose is zero, don’t deliver any insulin
CompDose = 0 dose! = 0
V
//2. The maximum daily dose would be exceed if the computed dose was
delivered so the insulin dose is set to the difference between the maximum
allowed daily dose and the cumulative dose delivered so far
r1’ = r2
r0’ = r1
SUGAR OK schema
r2 < r1 CompDose = 0
Summary
In this chapter we discussed about formal specification techniques
that can be used to add details to a system requirements
specification in detail such as how we use algebraic techniques for
interface specification, and describe the use of model – based
techniques for behavioural specification, and also how to apply
model – based techniques for behavioural specification.