Title: Functional Specification Software Specification Lecture 41
1Functional Specification Software
SpecificationLecture 41
- Prepared by
- Stephen M. Thebaut, Ph.D.
- University of Florida
2Overview
- Any program behavior can be represented entirely
by a mathematical function in its effect on data. - The domain of a program function corresponds to
an initial data state that is transformed into a
final data state by the program. - Functional specification scales well and is used
in Cleanroom Software Development.
Software Engineering, 6th Edition. Chapter 19
3Cleanroom Software Development
- Developed in the 70s and 80s by Harlan Mills,
et al. - The name is derived from the Cleanroom process
in semiconductor fabrication. - The philosophy is defect avoidance rather than
defect removal. - Emphasizes precise, logical expression and a
systematic process for developing correct
programs.
Software Engineering, 6th Edition. Chapter 19
4Cleanroom Software Development (contd)
- A software development process based on
- Incremental development (if appropriate)
- Formal specification
- Static verification using correctness arguments
- Statistical testing to certify program
reliability - NO defect testing!
Software Engineering, 6th Edition. Chapter 19
5The Cleanroom Process
Software Engineering, 6th Edition. Chapter 19
6Cleanroom Process Teams
- Specification team responsible for developing
and maintaining the system specification. - Development team responsible for developing and
verifying the software. The software is NOT
executed or even compiled during this process. - Certification team responsible for developing a
set of statistical tests to measure reliability
after development.
Software Engineering, 6th Edition. Chapter 19
7Cleanroom Process Evaluation
- Results at IBM and elsewhere have been very
impressive with very few discovered faults in
delivered systems. - Independent assessment shows that the
(steady-state) process is no more expensive than
other approaches.
Software Engineering, 6th Edition. Chapter 19
8What is a Function? (A Brief Tutorial)
- Sets and Relations
- Functions
- Conditional Rules
- Recursive Functions
- Lists
- Assignment Functions
Software Engineering, 6th Edition. Chapter 19
9Sets and Relations
- A set is any well-defined collection of objects,
called members or elements. - The relation of membership between a member, m,
and a set, S, is written - m ? S
- If m is not a member of S, we write
- m ? S
Software Engineering, 6th Edition. Chapter 19
10Sets and Relations (contd)
- A relation, r, is a set whose members (if any)
are all ordered pairs. - The set composed of the first member of each pair
is called the domain of r and is denoted D(r).
Members of D(r) are called arguments of r. - The set composed of the second member of each
pair is called the range of r and is denoted
R(r). Members of R(r) are called values of r.
Software Engineering, 6th Edition. Chapter 19
11Functions
- A function, f, is a relation such that for each x
? D(f), there exists a unique element - (x, y) ? f.
- (We often express this as y f(x), where y is
the unique value corresponding to x in the
function f.) - It is the uniqueness of y that distinguishes a
function from other relations.
Software Engineering, 6th Edition. Chapter 19
12Functions (contd)
- It is often convenient to define a function by
giving its domain and a rule for calculating the
corresponding value for each argument in the
domain. For example - f (x, y) x?0,1, y x 3x 2
Software Engineering, 6th Edition. Chapter 19
13Conditional Rules
- Conditional rules are a sequence of (predicate ?
rule) pairs separated by vertical bars and
enclosed in parentheses - ( p1 ? r1 p2 ? r2 ... pk ? rk )
- Its meaning is evaluate predicates p1, p2, ...,
pk in order for the first predicate, pi, which
evaluates to true, if any, use the rule ri if no
predicate evaluates to true, the rule is
undefined. (Note that ? ? ?.)
Software Engineering, 6th Edition. Chapter 19
14Conditional Rules (contd)
- The conditional rule above is read if p1 then
use r1 else if p2 then use r2 ... else if pk
then use rk. For example - f ((x, y) (x divisible by 2 ? y x/2
- x divisible by 3 ? y
x/3 - true
? y x) - Note that true ? r has the effect of if all
else fails, use r.
Software Engineering, 6th Edition. Chapter 19
15Recursive Functions
- A recursive function is a function that is
defined by using the function itself in the rule
that defines it. For example - oddeven(x) (x?0,1 ? x
- xgt1 ?
oddeven(x-2) - xlt0 ?
oddeven(x2)) - Exercise 1 define the factorial function
recursively.
Software Engineering, 6th Edition. Chapter 19
16Lists
- A list is a sequence of items which are all
members of a single set, called an alphabet. - Any computing process must eventually be
represented by, and be described in terms of
operations on, a list. - The empty list, denoted by ?, is a sequence of no
items. - The fundamental relationship in lists is between
members of the alphabet and a list.
Software Engineering, 6th Edition. Chapter 19
17List Operations and Semantics
- The first item, say a, of a non-empty list, say
L, is written - a head(L), L ? ?
- A non-empty list L with its first member removed
is written - tail(L)
- Note that tail(L) may be the empty list, and that
a ? (a).
Software Engineering, 6th Edition. Chapter 19
18List Operations and Semantics (contd)
- Two fundamental operations in lists are (1)
adding a new item, a, to the head of a list L,
written - a L
- and (2) concatenating two lists L and M, written
- LM
Software Engineering, 6th Edition. Chapter 19
19Assignment Functions
- Initial and final state space conditions may be
explicitly represented using assignment
functions. - For example, in a program with data space x, y,
z, the assignment statement x ?? y corresponds to
a set of ordered pairs of the form - ((x, y, z), (y, y, z))
- The assignment function representing a program
consisting of this statement is - x, y, z ?? y, y, z
final variable values
initial variable values
Software Engineering, 6th Edition. Chapter 19
20Assignment Functions (contd)
- Likewise, the function
- f (x?0 y?0 ? x, y ?? xy, 0)
- specifies a program for which the final value of
x is the sum of the initial values of x and y and
the final value of y is 0 if x and y are both
initially ? 0 otherwise the program does not
terminate (since f is not defined in this case). - Can you design a program, P, such that P f ?
Software Engineering, 6th Edition. Chapter 19
21Exercise 2
- For each of the following, give appropriate
assignment functions for the program behavior
described. - Set variable MAX to the maximum value of two
integers, A and B. - Set variable MIN to the minimum value in the
unsorted, non-empty array A1N. - Set variable SUM to the sum of the elements in
array A1N.
Software Engineering, 6th Edition. Chapter 19
22Exercise 2 (contd)
- Given three arrays A1N, B1N, and C1N,
set each element of A equal to the sum of the
corresponding elements of B and C. - Set variable NPRIME to true if N is prime and to
false otherwise. - Set variable Y to the greatest common divisor of
integers A and B.
Software Engineering, 6th Edition. Chapter 19
23Exercise 2 (contd)
- Set variable R to the remainder of dividing A by
D. - Set variable I to the index of the first instance
of Y in the array A1N. - Perform integer subtraction using the arithmetic
primitive "subtract 1" and a while loop. Let M
be the minuend, S be the subtrahend, and D be the
difference. Assume that the subtrahend is
nonnegative.
Software Engineering, 6th Edition. Chapter 19
24Sample Solutions
- Set variable MAX to the maximum value of two
integers, A and B. - (AgtB ? A, B, MAX ?? A, B, A
- true ? A, B, MAX ?? A, B,
B)
Software Engineering, 6th Edition. Chapter 19
25Sample Solutions (contd)
- Set variable MIN to the minimum value in the
unsorted, non-empty array A1N. - (MIN, A ?? FIND_MIN(A), A)
- where
- FIND_MIN(A) (tail(A)? ? head(A)
- true ? LESS(head(A),
FIND_MIN(tail(A)))) - where
- LESS(X,Y) (X?Y ? X true ? Y)
Software Engineering, 6th Edition. Chapter 19
26Functional Specification Software
SpecificationLecture 41
- Prepared by
- Stephen M. Thebaut, Ph.D.
- University of Florida