SlideShare a Scribd company logo
1 of 29
Formal Methods in Software
Engineering
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.
Formal Method definition
– A method is formal if it has a sound mathematical basis, typically given
by a formal specification language. This basis provides a means of
precisely defining notions like consistency, completeness, and more
relevantly specification, implementation and correctness.
• Correctness, the property that an abstract model fulfills a set of
well defined requirements.
• Consistency, to be consistent, facts stated in one place in a
specification should not be contradicted in another place.
• Used to specify programs, what the system is suppose to do.
• Used for constructing programs.
• Used to verify the program.
Why Formal Methods are required
 History of software
 Softwares encountered notorious bugs that were the
cause of financial lose and deaths of many people.
 Famous bugs are
 Therac-25
 Computerized radiation therapy machine called the Therac-25. Killed
many people, controller could not stop radiation due to software bug.
 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.
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
calculation problems. Intel had to take back all the
Pentiums, and it caused huge loss.
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.
• 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.
Testing Contd..
• Same is case with structural testing, white box testing.
• What is wrong with the following code?
How Formal Methods are developed?
• We develop models of system.
• With the help of models we will argue and
prove correctness of models.
• What is a model?
– An item, a structure, a style,….
– Lets play Dijkstra’s game to define a model.
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 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..
• What is the color of last ball?
• Difficult to answer
• Lets play the same game with different
number of balls.
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..
Dijkstra’s game contd..
• Mathematical models use functions.
• What is a function?
• Putting the balls in jar is a function
Conclusion from 2 and 3 balls game
• Depends on parity of white balls, even or odd
parity.
• Even number of white balls, last ball is black
color.
• Odd number of balls, last ball is of white.
• If we play with 100 balls, then can we argue or
prove our hypothesis?
• What is the color of last ball, given w white
balls and b black balls?
Mathematical model and its proof
F(b,w)=
2 black out,1 black in b-2+1, (b-1,w)
We reduce the number of black balls by 1 and we maintain the number
of white balls.
2 white out,1 black in w-2,b+1
We reduce the number of white balls by 2 and increase the number of
black balls by 1.
1 of each out,1 white in b-1,w-1+1,(w)
we reduce the number of black balls by 1 and maintain the number of
white balls.
 Total number of balls removed in each move is 1.
 Parity(even/odd number) of whit balls does not change.
 Yes we will say the parity of white balls determine the
outcome of the game.
 Hence hypothesis is correct.
Formal method steps
 We will define state based model for our computer
programs using formal methods.
1. Define the specifications of the system(Formal
specification).
2. Define abstract model specifications.
 Define the states of system (steps of a model)
 Define invariant(condition)
 Define set of operations for model to function.
 System/model operation is associated with two conditions
 Pre-condition
 Post condition
 Model verification and Implementation
 Make formal model and use tools to prove mechanically that formal
execution model satisfies formal requirements.
Written Requirement
Informal requirements expressed in English:
 A tank of cooling water shall be refilled when its low level
sensor comes on. Refilling consists of adding 9 units of
water to the tank.
 Notes:
> The maximum capacity of the tank is 10 units of water.
> From one reading of the water level to the next reading of the
water level, 1 unit of water will be used.
> The low level sensor comes on when the tank contains 1 unit of
water or less.
A Simple Formal Methods Example
Assigning Types
• The above statement contains several descriptions, including two key notions:
the water level in the tank and the water usage. Formally, these notions can be
modeled as follows (statements 1 and 2):
1 level is represented by a restricted integer type: a
number between 0 and 10, inclusive
2 usage is represented as the integer constant 1
• That is, level describes an amount of water that the tank may hold at any point
in time and usage describes the amount of water used during one cycle.
A Simple Formal Methods Example
Function Description
• The primary requirement is that 9 units of water will be added
to the tank whenever the level is less than or equal to 1. This
can be more precisely stated as (statement 3):
3 Function fill takes, as input, a water level and returns, as
output, a water level. Given an input of Lvl units of water,
fill returns Lvl +9, if Lvl is one or less, otherwise it returns Lvl.
• That is, we claim that fill(Lvl) accounts for any filling of water
in the tank.
A Simple Formal Methods Example
Properties
• A common sense property of this system is that, at
the next cycle, the new water level will be the
current water level, plus any amount that was added,
minus the amount that was used. That is, given Lvl
as the current level of water, the level at the next
cycle should be given by statement 4:
4 level = Lvl + fill(Lvl) - usage
A Simple Formal Methods Example
Properties (continued)
• One approach to checking this specification is to ensure that each reference to
a level of water is consistent with the definition of level, i.e., it should always be
a number between 0 and 10. It turns out that the specification for fill given in 3
above is consistent with the definition of level if the following two logical
statements are true:
5 FORALL levels Lvl
(Lvl <= 1) IMPLIES THAT
(0 <= Lvl + 9) AND
(Lvl + 9 <= 10)
6 FORALL levels Lvl
(0 <= Lvl + fill(Lvl) - usage) AND
(Lvl + fill(Lvl) - usage <= 10)
A Simple Formal Methods Example
Analysis by Proof
• The following statements (statements 5.1 and 5.2) constitute an informal
proof that the first FORALL statement (statement 5) is true:
• Property: “5” FORALL levels Lvl (Lvl <= 1) IMPLIES THAT
(0 <= Lvl + 9) AND (Lvl + 9 <= 10)
• Proof:
5.1 Lvl+9 >= 0 because Lvl >= 0 (and the sum of any two numbers greater than
zero is greater than zero)
5.2 Lvl+9 <= 10 because Lvl <=1 (and any number less than or equal to 1 plus 9 is
less than or equal to 10)
A Simple Formal Methods Example
Verification of Property #6?
• Property “6” FORALL levels Lvl
(0 <= Lvl + fill(Lvl) - usage) AND
(Lvl + fill(Lvl) - usage <= 10)
• Proof Attempts Fails!
• Counter-example*
– Consider the case when Lvl is 9:
Lvl + fill(Lvl) - 1 = Lvl + Lvl -1 = 9+9-1 = 17 (which is not <= 10)
• The specification is flawed and must be corrected.
A Simple Formal Methods Example
Correcting the Specification
• Upon closer examination, it is found that statement 4, our expression
for the water level at the next cycle, is in error:
4 level = Lvl + fill(Lvl) - usage (incorrect)
• This statement is inconsistent with the definition of fill because fill
returns the new level of water, not just the amount of water added.
The (corrected) expression for level, denoted by 4', is simply:
4' level = fill(Lvl) - usage (correct)
• The (corrected) FORALL statement (statement 6) is:
6' FORALL levels L:
(0 <= fill(Lvl) - usage) AND
(fill(Lvl) - usage <= 10) (correct)
A Simple Formal Methods Example
This Simple Example Illustrates:
• Formal Specification: Modeling informal English statements using
mathematical expressions
• Type Checking: Checking that all types of items are used
consistently (e.g., level)
• Stating Properties: Identifying and defining expected behavior of
the system (e.g., the expected new level in the tank)
• Proving Logical Conditions: Constructing logical proofs which
show that a given condition holds under all possible situations
A Simple Formal Methods Example

More Related Content

What's hot

Mca se chapter_9_formal_methods
Mca se chapter_9_formal_methodsMca se chapter_9_formal_methods
Mca se chapter_9_formal_methodsAman Adhikari
 
Software Testing Basics
Software Testing BasicsSoftware Testing Basics
Software Testing BasicsBelal Raslan
 
Software development life cycle (SDLC)
Software development life cycle (SDLC)Software development life cycle (SDLC)
Software development life cycle (SDLC)Simran Kaur
 
Chapter 01 software engineering pressman
Chapter 01  software engineering pressmanChapter 01  software engineering pressman
Chapter 01 software engineering pressmanRohitGoyal183
 
Software Engineering Layered Technology Software Process Framework
Software Engineering  Layered Technology Software Process FrameworkSoftware Engineering  Layered Technology Software Process Framework
Software Engineering Layered Technology Software Process FrameworkJAINAM KAPADIYA
 
formal verification
formal verificationformal verification
formal verificationToseef Aslam
 
Introduction to Software Engineering
Introduction to Software EngineeringIntroduction to Software Engineering
Introduction to Software EngineeringMajane Padua
 
Software Engineering ppt
Software Engineering pptSoftware Engineering ppt
Software Engineering pptshruths2890
 
Traditional Process Models
Traditional Process ModelsTraditional Process Models
Traditional Process ModelsAhsan Rahim
 
Software Engineering Process Models
Software Engineering Process Models Software Engineering Process Models
Software Engineering Process Models Satya P. Joshi
 
Design Concept software engineering
Design Concept software engineeringDesign Concept software engineering
Design Concept software engineeringDarshit Metaliya
 
Software project management- Software Engineering
Software project management- Software EngineeringSoftware project management- Software Engineering
Software project management- Software EngineeringMuhammad Yousuf Abdul Qadir
 
Formal Specification in Software Engineering SE9
Formal Specification in Software Engineering SE9Formal Specification in Software Engineering SE9
Formal Specification in Software Engineering SE9koolkampus
 

What's hot (20)

Mca se chapter_9_formal_methods
Mca se chapter_9_formal_methodsMca se chapter_9_formal_methods
Mca se chapter_9_formal_methods
 
Software Testing Basics
Software Testing BasicsSoftware Testing Basics
Software Testing Basics
 
Software development life cycle (SDLC)
Software development life cycle (SDLC)Software development life cycle (SDLC)
Software development life cycle (SDLC)
 
Software testing
Software testingSoftware testing
Software testing
 
Chapter 01 software engineering pressman
Chapter 01  software engineering pressmanChapter 01  software engineering pressman
Chapter 01 software engineering pressman
 
Software testing ppt
Software testing pptSoftware testing ppt
Software testing ppt
 
Cocomo model
Cocomo modelCocomo model
Cocomo model
 
Software requirements
Software requirementsSoftware requirements
Software requirements
 
SOFTWARE TESTING
SOFTWARE TESTINGSOFTWARE TESTING
SOFTWARE TESTING
 
Software Engineering Layered Technology Software Process Framework
Software Engineering  Layered Technology Software Process FrameworkSoftware Engineering  Layered Technology Software Process Framework
Software Engineering Layered Technology Software Process Framework
 
software engineering
software engineeringsoftware engineering
software engineering
 
formal verification
formal verificationformal verification
formal verification
 
Introduction to Software Engineering
Introduction to Software EngineeringIntroduction to Software Engineering
Introduction to Software Engineering
 
Software Engineering ppt
Software Engineering pptSoftware Engineering ppt
Software Engineering ppt
 
Traditional Process Models
Traditional Process ModelsTraditional Process Models
Traditional Process Models
 
Software Engineering Process Models
Software Engineering Process Models Software Engineering Process Models
Software Engineering Process Models
 
Design Concept software engineering
Design Concept software engineeringDesign Concept software engineering
Design Concept software engineering
 
Software project management- Software Engineering
Software project management- Software EngineeringSoftware project management- Software Engineering
Software project management- Software Engineering
 
Software Quality Metrics
Software Quality MetricsSoftware Quality Metrics
Software Quality Metrics
 
Formal Specification in Software Engineering SE9
Formal Specification in Software Engineering SE9Formal Specification in Software Engineering SE9
Formal Specification in Software Engineering SE9
 

Viewers also liked

Formal methods 4 - Z notation
Formal methods   4 - Z notationFormal methods   4 - Z notation
Formal methods 4 - Z notationVlad Patryshev
 
Formal methods 1 - introduction
Formal methods   1 - introductionFormal methods   1 - introduction
Formal methods 1 - introductionVlad Patryshev
 
Introduction to formal methods
Introduction to formal methodsIntroduction to formal methods
Introduction to formal methodsInzemamul Haque
 
Formal Verification Techniques
Formal Verification TechniquesFormal Verification Techniques
Formal Verification TechniquesDVClub
 
verification and validation
verification and validationverification and validation
verification and validationDinesh Pasi
 
OCL: Object Constraint Language
OCL: Object Constraint LanguageOCL: Object Constraint Language
OCL: Object Constraint Languageelliando dias
 
Using formal methods in Industrial Software Development
Using formal methods in Industrial Software DevelopmentUsing formal methods in Industrial Software Development
Using formal methods in Industrial Software DevelopmentRobert van Lieshout
 
A panel of recombinant monoclonal antibodies against zebrafish
A panel of recombinant monoclonal antibodies against zebrafishA panel of recombinant monoclonal antibodies against zebrafish
A panel of recombinant monoclonal antibodies against zebrafishShahnaz Yusaf
 
Ken Johnston - Big Bugs That Got Away - EuroSTAR 2010
Ken Johnston - Big Bugs That Got Away -  EuroSTAR 2010Ken Johnston - Big Bugs That Got Away -  EuroSTAR 2010
Ken Johnston - Big Bugs That Got Away - EuroSTAR 2010TEST Huddle
 
Formal methods 7 - category theory
Formal methods   7 - category theoryFormal methods   7 - category theory
Formal methods 7 - category theoryVlad Patryshev
 
A causal theory of knowing goldman
A causal theory of knowing goldmanA causal theory of knowing goldman
A causal theory of knowing goldmanGanesh Bharate
 
Industrial use of formal methods
Industrial use of formal methodsIndustrial use of formal methods
Industrial use of formal methodsJonathan Bowen
 
Promise 2011: "Selecting Discriminating Terms for Bug Assignment: A Formal An...
Promise 2011: "Selecting Discriminating Terms for Bug Assignment: A Formal An...Promise 2011: "Selecting Discriminating Terms for Bug Assignment: A Formal An...
Promise 2011: "Selecting Discriminating Terms for Bug Assignment: A Formal An...CS, NcState
 

Viewers also liked (20)

Formal methods 4 - Z notation
Formal methods   4 - Z notationFormal methods   4 - Z notation
Formal methods 4 - Z notation
 
Z specification
Z specificationZ specification
Z specification
 
Formal methods 1 - introduction
Formal methods   1 - introductionFormal methods   1 - introduction
Formal methods 1 - introduction
 
Introduction to formal methods
Introduction to formal methodsIntroduction to formal methods
Introduction to formal methods
 
Formal Verification Techniques
Formal Verification TechniquesFormal Verification Techniques
Formal Verification Techniques
 
Ch8.testing
Ch8.testingCh8.testing
Ch8.testing
 
verification and validation
verification and validationverification and validation
verification and validation
 
Logic Ppt
Logic PptLogic Ppt
Logic Ppt
 
OCL
OCL OCL
OCL
 
OCL: Object Constraint Language
OCL: Object Constraint LanguageOCL: Object Constraint Language
OCL: Object Constraint Language
 
(GFS) Google Dosya Sistemi
(GFS) Google Dosya Sistemi (GFS) Google Dosya Sistemi
(GFS) Google Dosya Sistemi
 
Using formal methods in Industrial Software Development
Using formal methods in Industrial Software DevelopmentUsing formal methods in Industrial Software Development
Using formal methods in Industrial Software Development
 
A panel of recombinant monoclonal antibodies against zebrafish
A panel of recombinant monoclonal antibodies against zebrafishA panel of recombinant monoclonal antibodies against zebrafish
A panel of recombinant monoclonal antibodies against zebrafish
 
Ken Johnston - Big Bugs That Got Away - EuroSTAR 2010
Ken Johnston - Big Bugs That Got Away -  EuroSTAR 2010Ken Johnston - Big Bugs That Got Away -  EuroSTAR 2010
Ken Johnston - Big Bugs That Got Away - EuroSTAR 2010
 
Formal methods 7 - category theory
Formal methods   7 - category theoryFormal methods   7 - category theory
Formal methods 7 - category theory
 
A causal theory of knowing goldman
A causal theory of knowing goldmanA causal theory of knowing goldman
A causal theory of knowing goldman
 
Swr
SwrSwr
Swr
 
Session3
Session3Session3
Session3
 
Industrial use of formal methods
Industrial use of formal methodsIndustrial use of formal methods
Industrial use of formal methods
 
Promise 2011: "Selecting Discriminating Terms for Bug Assignment: A Formal An...
Promise 2011: "Selecting Discriminating Terms for Bug Assignment: A Formal An...Promise 2011: "Selecting Discriminating Terms for Bug Assignment: A Formal An...
Promise 2011: "Selecting Discriminating Terms for Bug Assignment: A Formal An...
 

Similar to Formal Methods lecture 01

Introduction to formal methods lecture notes
Introduction to formal methods lecture notesIntroduction to formal methods lecture notes
Introduction to formal methods lecture notesJikAlvin
 
[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2
[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2
[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2Yo Halb
 
Going loopy - Introduction to Loops.pptx
Going loopy - Introduction to Loops.pptxGoing loopy - Introduction to Loops.pptx
Going loopy - Introduction to Loops.pptxAmy Nightingale
 
LecccccccccccccProgrammingLecture-09.pdf
LecccccccccccccProgrammingLecture-09.pdfLecccccccccccccProgrammingLecture-09.pdf
LecccccccccccccProgrammingLecture-09.pdfAmirMohamedNabilSale
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#Hawkman Academy
 
lab-8 (1).pptx
lab-8 (1).pptxlab-8 (1).pptx
lab-8 (1).pptxShimoFcis
 
Brixton Library Technology Initiative Week1 Recap
Brixton Library Technology Initiative Week1 RecapBrixton Library Technology Initiative Week1 Recap
Brixton Library Technology Initiative Week1 RecapBasil Bibi
 
CSC111-Chap_03.pdf
CSC111-Chap_03.pdfCSC111-Chap_03.pdf
CSC111-Chap_03.pdf2b75fd3051
 
Python Programming unit5 (1).pdf
Python Programming unit5 (1).pdfPython Programming unit5 (1).pdf
Python Programming unit5 (1).pdfjamvantsolanki
 
c++ Data Types and Selection
c++ Data Types and Selectionc++ Data Types and Selection
c++ Data Types and SelectionAhmed Nobi
 
Hub102 - JS - Lesson3
Hub102 - JS - Lesson3Hub102 - JS - Lesson3
Hub102 - JS - Lesson3Tiểu Hổ
 
Monte Carlo Simulation for project estimates v1.0
Monte Carlo Simulation for project estimates v1.0Monte Carlo Simulation for project estimates v1.0
Monte Carlo Simulation for project estimates v1.0PMILebanonChapter
 

Similar to Formal Methods lecture 01 (20)

Introduction to formal methods lecture notes
Introduction to formal methods lecture notesIntroduction to formal methods lecture notes
Introduction to formal methods lecture notes
 
[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2
[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2
[YIDLUG] Programming Languages Differences, The Underlying Implementation 1 of 2
 
Going loopy - Introduction to Loops.pptx
Going loopy - Introduction to Loops.pptxGoing loopy - Introduction to Loops.pptx
Going loopy - Introduction to Loops.pptx
 
LecccccccccccccProgrammingLecture-09.pdf
LecccccccccccccProgrammingLecture-09.pdfLecccccccccccccProgrammingLecture-09.pdf
LecccccccccccccProgrammingLecture-09.pdf
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
lab-8 (1).pptx
lab-8 (1).pptxlab-8 (1).pptx
lab-8 (1).pptx
 
Sudoku solver
Sudoku solverSudoku solver
Sudoku solver
 
TDD Training
TDD TrainingTDD Training
TDD Training
 
Brixton Library Technology Initiative Week1 Recap
Brixton Library Technology Initiative Week1 RecapBrixton Library Technology Initiative Week1 Recap
Brixton Library Technology Initiative Week1 Recap
 
Arrays
ArraysArrays
Arrays
 
CSC111-Chap_03.pdf
CSC111-Chap_03.pdfCSC111-Chap_03.pdf
CSC111-Chap_03.pdf
 
11 whiteboxtesting
11 whiteboxtesting11 whiteboxtesting
11 whiteboxtesting
 
Python Programming unit5 (1).pdf
Python Programming unit5 (1).pdfPython Programming unit5 (1).pdf
Python Programming unit5 (1).pdf
 
c++ Data Types and Selection
c++ Data Types and Selectionc++ Data Types and Selection
c++ Data Types and Selection
 
AutoTest.ppt
AutoTest.pptAutoTest.ppt
AutoTest.ppt
 
AutoTest.ppt
AutoTest.pptAutoTest.ppt
AutoTest.ppt
 
AutoTest.ppt
AutoTest.pptAutoTest.ppt
AutoTest.ppt
 
Hub102 - JS - Lesson3
Hub102 - JS - Lesson3Hub102 - JS - Lesson3
Hub102 - JS - Lesson3
 
Slide 6_Control Structures.pdf
Slide 6_Control Structures.pdfSlide 6_Control Structures.pdf
Slide 6_Control Structures.pdf
 
Monte Carlo Simulation for project estimates v1.0
Monte Carlo Simulation for project estimates v1.0Monte Carlo Simulation for project estimates v1.0
Monte Carlo Simulation for project estimates v1.0
 

Recently uploaded

MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedDelhi Call girls
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 

Recently uploaded (20)

MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 

Formal Methods lecture 01

  • 1. Formal Methods in Software Engineering
  • 2. 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.
  • 3. Formal Method definition – A method is formal if it has a sound mathematical basis, typically given by a formal specification language. This basis provides a means of precisely defining notions like consistency, completeness, and more relevantly specification, implementation and correctness. • Correctness, the property that an abstract model fulfills a set of well defined requirements. • Consistency, to be consistent, facts stated in one place in a specification should not be contradicted in another place. • Used to specify programs, what the system is suppose to do. • Used for constructing programs. • Used to verify the program.
  • 4. Why Formal Methods are required  History of software  Softwares encountered notorious bugs that were the cause of financial lose and deaths of many people.  Famous bugs are  Therac-25  Computerized radiation therapy machine called the Therac-25. Killed many people, controller could not stop radiation due to software bug.  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.
  • 5. 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 calculation problems. Intel had to take back all the Pentiums, and it caused huge loss.
  • 6. 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
  • 7. Testing • Black box testing – Test input versus output – Input • Two numbers – Output • average • White box testing – Test the structure of program. • Loops testing, condition testing
  • 8. "Testing can show the presence of errors, but not their absence." - Edsger Dijkstra
  • 9. 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.
  • 10. Testing Contd.. • Same is case with structural testing, white box testing. • What is wrong with the following code?
  • 11. How Formal Methods are developed? • We develop models of system. • With the help of models we will argue and prove correctness of models. • What is a model? – An item, a structure, a style,…. – Lets play Dijkstra’s game to define a model.
  • 12. 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 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?’”
  • 14. Dijkstra’s game contd.. • What is the color of last ball? • Difficult to answer • Lets play the same game with different number of balls.
  • 15. 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
  • 17. Dijkstra’s game contd.. • Mathematical models use functions. • What is a function? • Putting the balls in jar is a function
  • 18. Conclusion from 2 and 3 balls game • Depends on parity of white balls, even or odd parity. • Even number of white balls, last ball is black color. • Odd number of balls, last ball is of white. • If we play with 100 balls, then can we argue or prove our hypothesis? • What is the color of last ball, given w white balls and b black balls?
  • 19. Mathematical model and its proof F(b,w)= 2 black out,1 black in b-2+1, (b-1,w) We reduce the number of black balls by 1 and we maintain the number of white balls. 2 white out,1 black in w-2,b+1 We reduce the number of white balls by 2 and increase the number of black balls by 1. 1 of each out,1 white in b-1,w-1+1,(w) we reduce the number of black balls by 1 and maintain the number of white balls.  Total number of balls removed in each move is 1.  Parity(even/odd number) of whit balls does not change.  Yes we will say the parity of white balls determine the outcome of the game.  Hence hypothesis is correct.
  • 20. Formal method steps  We will define state based model for our computer programs using formal methods. 1. Define the specifications of the system(Formal specification). 2. Define abstract model specifications.  Define the states of system (steps of a model)  Define invariant(condition)  Define set of operations for model to function.  System/model operation is associated with two conditions  Pre-condition  Post condition  Model verification and Implementation  Make formal model and use tools to prove mechanically that formal execution model satisfies formal requirements.
  • 21. Written Requirement Informal requirements expressed in English:  A tank of cooling water shall be refilled when its low level sensor comes on. Refilling consists of adding 9 units of water to the tank.  Notes: > The maximum capacity of the tank is 10 units of water. > From one reading of the water level to the next reading of the water level, 1 unit of water will be used. > The low level sensor comes on when the tank contains 1 unit of water or less. A Simple Formal Methods Example
  • 22. Assigning Types • The above statement contains several descriptions, including two key notions: the water level in the tank and the water usage. Formally, these notions can be modeled as follows (statements 1 and 2): 1 level is represented by a restricted integer type: a number between 0 and 10, inclusive 2 usage is represented as the integer constant 1 • That is, level describes an amount of water that the tank may hold at any point in time and usage describes the amount of water used during one cycle. A Simple Formal Methods Example
  • 23. Function Description • The primary requirement is that 9 units of water will be added to the tank whenever the level is less than or equal to 1. This can be more precisely stated as (statement 3): 3 Function fill takes, as input, a water level and returns, as output, a water level. Given an input of Lvl units of water, fill returns Lvl +9, if Lvl is one or less, otherwise it returns Lvl. • That is, we claim that fill(Lvl) accounts for any filling of water in the tank. A Simple Formal Methods Example
  • 24. Properties • A common sense property of this system is that, at the next cycle, the new water level will be the current water level, plus any amount that was added, minus the amount that was used. That is, given Lvl as the current level of water, the level at the next cycle should be given by statement 4: 4 level = Lvl + fill(Lvl) - usage A Simple Formal Methods Example
  • 25. Properties (continued) • One approach to checking this specification is to ensure that each reference to a level of water is consistent with the definition of level, i.e., it should always be a number between 0 and 10. It turns out that the specification for fill given in 3 above is consistent with the definition of level if the following two logical statements are true: 5 FORALL levels Lvl (Lvl <= 1) IMPLIES THAT (0 <= Lvl + 9) AND (Lvl + 9 <= 10) 6 FORALL levels Lvl (0 <= Lvl + fill(Lvl) - usage) AND (Lvl + fill(Lvl) - usage <= 10) A Simple Formal Methods Example
  • 26. Analysis by Proof • The following statements (statements 5.1 and 5.2) constitute an informal proof that the first FORALL statement (statement 5) is true: • Property: “5” FORALL levels Lvl (Lvl <= 1) IMPLIES THAT (0 <= Lvl + 9) AND (Lvl + 9 <= 10) • Proof: 5.1 Lvl+9 >= 0 because Lvl >= 0 (and the sum of any two numbers greater than zero is greater than zero) 5.2 Lvl+9 <= 10 because Lvl <=1 (and any number less than or equal to 1 plus 9 is less than or equal to 10) A Simple Formal Methods Example
  • 27. Verification of Property #6? • Property “6” FORALL levels Lvl (0 <= Lvl + fill(Lvl) - usage) AND (Lvl + fill(Lvl) - usage <= 10) • Proof Attempts Fails! • Counter-example* – Consider the case when Lvl is 9: Lvl + fill(Lvl) - 1 = Lvl + Lvl -1 = 9+9-1 = 17 (which is not <= 10) • The specification is flawed and must be corrected. A Simple Formal Methods Example
  • 28. Correcting the Specification • Upon closer examination, it is found that statement 4, our expression for the water level at the next cycle, is in error: 4 level = Lvl + fill(Lvl) - usage (incorrect) • This statement is inconsistent with the definition of fill because fill returns the new level of water, not just the amount of water added. The (corrected) expression for level, denoted by 4', is simply: 4' level = fill(Lvl) - usage (correct) • The (corrected) FORALL statement (statement 6) is: 6' FORALL levels L: (0 <= fill(Lvl) - usage) AND (fill(Lvl) - usage <= 10) (correct) A Simple Formal Methods Example
  • 29. This Simple Example Illustrates: • Formal Specification: Modeling informal English statements using mathematical expressions • Type Checking: Checking that all types of items are used consistently (e.g., level) • Stating Properties: Identifying and defining expected behavior of the system (e.g., the expected new level in the tank) • Proving Logical Conditions: Constructing logical proofs which show that a given condition holds under all possible situations A Simple Formal Methods Example

Editor's Notes

  1. 8
  2. 9
  3. 10
  4. 11
  5. 12
  6. 13
  7. 14
  8. 15
  9. 16