Docsity

The Importance and Application of Formal Methods in Software Engineering, Slides of Software Engineering

Partial preview of the text

Download The Importance and Application of Formal Methods in Software Engineering and more Slides Software Engineering in PDF only on Docsity!

Formal Method

Formal method is branch of software engineering,

in which we analyze software systems.

Develop a program in a way that each step leads

to a final solution, follow proper method to make

sure that we do not take wrong steps.

The Encyclopedia of Software Engineering defines

formal methods in the following manner:

 Formal methods used in developing computer systems are

mathematically based techniques for describing system

properties. Such formal methods provide frameworks

within which people can specify, develop, and verify

systems in a systematic, rather than ad hoc manner.

Why Formal Methods are required

History of software

Softwares encountered notorious (infamous) bugs that were the cause of financial lose and deaths of many people. Famous bugs are  (^) Therac-  (^) computerized radiation therapy machine called the Therac-25.  (^) killed many people, controller could not stop radiation due to software bug, later on the problem was fixed, after killing many people life.  (^) AT & T long distance breakdown bug 1990  (^) ill placed break statement in the code,  (^) caused the 1/3rd of entire American network to go down for 9 hours.  (^) Loses to banks, for ATM and transactions

Why Formal Methods are required Patriot Missile Failure Gulf war  (^) this missile hit the own American troops a software defect in 1991.  (^) Killing 28 people and many injured Pentium bug  (^) software error in microcode of Pentium microprocessor, which resulted in error of floating point calculations problems.  (^) Intel had to take back all the Pentiums, and it caused huge loss of dollars.

Importance of formal methods in Software

This is what we are going to study in formal

methods.

Methods to ensure that software is

 (^) Correct Reliable

These two attributes deal with the software

quality.

To achieve software quality, we apply different

techniques.

Testing Verification Validation

Testing

Black box testing Test input versus output Input  (^) Two numbers Output  (^) average White box testing Test the structure of program.  (^) For loops testing, condition testing

"Testing can show the presence of errors, but not their absence."

  • Edsger Dijkstra

Testing contd..

In testing we develop test cases and define scenarios, it is not possible to have all scenarios. Program to show equalness of two strings. isEqual(“cat”,”dog”) expected false isEqual(“testing”,”testing”) expected true isEqual(“house”,”home”) expected false isEqual(“house”,”mouse”) expected false. No number of test cases assure this.

Mathematical Practices for Proving a statement

In mathematics ,to prove a theorem/statement, we

use counter (oppose) example to disprove the

theorem, (example that does not fulfill that theorem).

For example

All numbers are less than one thousand theorem # 01 Examples to prove this theorem  (^) 1<1000, 2<1000,  (^) 50<  (^) So and so far infinite examples it is not possible that proves the theorem. If the theorem is incorrect or correct ,to prove it, we can use the formal method.

Reliability

Obviously there is no guarantee in life but every one wants to have reliable software. A report was presented to President Bill Clinton in 1996 by committee of IT, in which they stated

 we know to write a software that works 95% of

the time, but do not know how to write software

that works for 100 % of the time, it is used.

If ,You fly in a plane 100 times plane crashes 5 times due to software error then ,will you travel through plane?

Dijkstra’s game

 Consider the following game to be played by a single person

with an urn/jar and as many w white balls and b black balls as

he needs.

 To begin with, an arbitrary (random) positive number of balls is

put into the urn and as long as the urn contains two or more

balls, the player repeats the following moves:

 (^) he shakes the urn and, without looking, he takes two balls from the urn;  (^) if those two balls have the same color  (^) he throws one black ball into the urn,  (^) otherwise he returns one white ball into the urn  (^) Because each move decreases the total number of balls into the urn by 1, the game is guaranteed to terminate after a finite number of moves and it is not difficult to see that the game ends with exactly 1 ball in the urn.

 The question is:

 (^) What can we say about the color of the final ball when we are given the initial contents of the urn?’”

Dijkstra’s game contd..

Dijkstra’s game contd..

One ball game The game will end without playing Two balls game Three different combinations of balls One Black, one white One White ,one white One Black, one black

two ball game Dijkstra’s game contd..