Professional Documents
Culture Documents
Methods
Faculty(APGDST)@ncst.ernet.in
Deficiencies of less
formal approaches
Contradictions
Ambiguities
Vagueness
Incompleteness
Formal methods
in SE
What to formalize?
Models of requirements knowledge (so we
can reason)
Specifications of requirements (so we can
document precisely)
Specifications of program design (verify
correctness)
Why formalize?
Removes ambiguity and improves
precision
Verify that the requirements have been
met
Continues….
Why people do not formalize?
Formal methods tend to be
low level (too much detail)
Formal methods concentrate
Operational
specification is an executable
abstraction
Good for rapid prototyping
State-based
view program as data
structures and states
Use pre and post conditions to
specify procedures
Examples include VDM and Z
Continues…
Algebraic
view program as data
structures and operations
Operations are defined
CLEAR
Formal Method
Concepts
Data invariant
A condition that holds true for the
duration of the program
State
The stored data that the system
accesses and alters
Operations
Action that takes place in a system
Has preconditions and postconditions
Precondition circumstances under
which operation is valid
Postcondition what happens when a
operation is complete
Example
Computer memory block
handler
Files in a computer are
composed of memory blocks
The system will maintain a set
{n:N | n < 3}
# {C++, Pascal, Ada, COBOL, Java}=5
Set Operators
12 ∈ {6, 1, 12, 27}, 11 ∉ {6, 1, 12, 27}
A ⊂ B , A ∩ B, φ ∩ B, φ ∪ B, {1,2} Χ {1,2,3}
Continues…
Logical Operators
∧ and, ∨ or, ¬ Not, ⇒ implies
Universal quantification
∀ For all
Sequences
e.g. {(1,Kumar),(2,Gopal), (3,Seeta)}
head, tail, last, front
Applying
Mathematical
Notation
used, free: P BLOCKS
BlockQueue : seq P BLOCK
Data Variant:
Used ∩ free = φ ∧
Used ∩ free = AllBlocks ∧
used ∧
∀ I, j : dom BlockQueue * i ≠ j
⇒ BlockQueue i ∩ BlockQueue j = φ
Block Operations
Precondition
#BlockQueue > 0
Post condition
used’ = used \ head BlockQueue∧
free’ =free ∪ head BlockQueue ∧