Introduction to�Formal Specifications
Prof. Indraneel Mukhopadhyay, PhD
What is Formal Specifications ?
What is Formal Specifications ?
A formal software specification is a statement expressed in a language whose vocabulary, syntax, and semantics are formally defined. The need for a formal semantic definition means that the specification languages cannot be based on natural language; it must be based on mathematics.
Formal Specification
?
?
?
V
Concise and Unambiguous
Point 1
V
Support formal Reasoning
Point 2
V
Provide basis for Verification
Point 3
Pros and Cons
PROS
CONS
Relational Notations
Relational Notations
State Oriented Notations
State-Oriented Notations
Specification Principles
Specification Principles
Specification Principles
Specification Principles
Specification Principles
Specification Principles
Some Specification Techniques
Specification Principles
(0<=X<=Y){ABS_VALUE[(WHAT(X)) 2-X]}<=E
Specification Principles
FI(0) = 0, FI(1) = 1,
FI(n) = FI(n-1) + FI(n-2),n>=1.
Specification Principles
Specification Principles
Specification Principles
Specification Principles
Axiomatic Specification
Axiomatic Specification
Some predicates are:
1. A>B and C>D
2. exists i, j, k in M...N: i 2 =j2 + k2
3. for-all i in 1...10, exists j in 1...10: squares (i)=j 2
Axiomatic Specification
Stages of axiomatic specification of a function:
Axiomatic Specification
Axiomatic Specification
Axiomatic Specification
function Search (X: INTEGER-ARRAY; Key: INTEGER) return INTEGER;
Pre: exists i in X'FIRST...X'LAST: X(i)=Key and for-all i,j in X'FIRST...X'LAST: i<=X(j)
Post: X''(Search (X, Key))=Key and X=X‘’
Error: Search (X, Key)=X'LAST + 1
X'' refers to the value of the array X after the function has been evaluated.
Formal Spec. Homework Problem
Consider a function that accepts an array and then returns the greatest member of the array and the index of that member in the original array. The original input is unchanged. If the array is empty, return an array index of -1. Assume that X’FIRST and X’LAST return the indices of the first and last array members, respectively.
End of Presentation