0% found this document useful (0 votes)
64 views17 pages

Formal Methods for Software Engineers

Formal methods in SE lecture no 2 that is helpful for SE Students

Uploaded by

esra bilgic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views17 pages

Formal Methods for Software Engineers

Formal methods in SE lecture no 2 that is helpful for SE Students

Uploaded by

esra bilgic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Formal Methods in

Software Engineering
Credit Hours: 3+0

1 Formal Methods in Software Engineering


What are Formal Methods?
 Formal Language Specification Formal Methods
centred around a notation known as a formal
specification language.
Formal Semantics
 Mathematical base allows precise notions.
 Unambiguous.
 Allows consistency, correctness, specification and
implementation to be expressed.
Increase Human Understanding of Specified System.

&
Allow the possibility of formal reasoning and
development.

2 Formal Methods in Software Engineering


Three Levels of Formal Methods
1. Requirements Only
2. No Analysis/Proof
LEVEL 0 3. Cost effective
Formal Specification
1. Produce a
program in a more
formal manner
2. Use proofs of properties or
LEVEL 1 refinements from formal
specification
Formal Verification
3. Costly

1. Use theorem prover


2. Fully formal machine-
checked proofs.
3. Expensive, hard and
LEVEL 2 often costly
Theorem Provers 4. Formally prove the entire
system.
3 Formal Methods in Software Engineering
Use in the Design Process
 Specification
Description of system to be developed at any
level of detail desired.

Formal specification can be used:


1. to guide further development.
2. verify requirements of system are completely and
accurately specified.

4 Formal Methods in Software Engineering


Use in the Design Process
 Development
Formal specification can be used as a guide to
progress the development of the actual system.

Model-Orientated Specification
Observed behaviour of actual system compared to
behaviour of specification.

Property-Orientated Specification
Preconditions and postconditions may be able to become
assertions in executable code of system.

5 Formal Methods in Software Engineering


Use in the Design Process
 Verification
Formal specification can be used to prove certain
properties of specification and hence the
developed system.
Human-Directed Proof
Understand the system better
Mathematical-style proofs
Handwritten using a natural language
Automated Proof
Produce proofs using automated means
Automated Theorem Proving
Model Checking

6 Formal Methods in Software Engineering


Weakness of natural language specifications

Withdraw:
“Receives a requested amount to withdraw from the
bank account and, if there are sufficient funds in the
account, meets the request.
Returns a boolean value indicating success or failure
of the attempt to withdraw money from the account.”

Natural language descriptions do not have a fixed meaning,


they are ambiguous.

These notations do not have a fixed semantics


7 Formal Methods in Software Engineering
Incomplete specifications

A specification can be considered incomplete when the


behaviour is not completely defined.

Withdraw:
“Receives a requested amount to withdraw from the bank
account and, if there are sufficient funds in the account,
meets the request.
Returns a boolean value indicating success or failure of
the attempt to withdraw money from the account.”

8 Formal Methods in Software Engineering


Inconsistent specifications

A specification is inconsistent when it contains within it


contradictions.

Withdraw:
“Receives a requested amount to withdraw from the bank
account and, if there are sufficient funds in the account,
meets the request.
Returns a boolean value indicating success or failure of
the attempt to withdraw money from the account.”

OVERDRAFT?
9 Formal Methods in Software Engineering
Formal languages

It is desirable to use a specification notation with a fixed,


unambiguous, semantics.

Notations that have a fixed semantics are known as formal


notations, or formal languages.

A fixed semantics is achieved by defining a language in a


completely unambiguous way using a mathematical
framework.

10 Formal Methods in Software Engineering


Formal Methods

initial formal specification

A formal method
1st transformation includes a proof
system for
demonstrating that
2nd transformation each transformation
preserves the formal
meaning captured in
nth transformation the previous step.

final program
11 Formal Methods in Software Engineering
Advantages of formal methods
• formal specifications can help considerably in generating suitable
test cases;
• the discipline required in producing a formal specification allows
for feedback on system specifications at early development
stages, increasing confidence that the specification accurately
captures the real system requirements;
• important properties of the initial specification can be checked
mathematically and incorporated as run-time checks in the final
program;
• proofs can help uncover design errors as soon as they are made,
rather than having to wait for testing of the final implementation;
• a proof of program correctness can be constructed that is a much
more robust method of achieving program correctness than is
testing alone.
12 Formal Methods in Software Engineering
Critical Analysis
1. Full formalisation considered:
too difficult
too time-consuming
too expensive
given
1. Expressiveness of languages involved
2. Complexity of systems to be modelled.

2. A good Human-Directed Proof requires high level of


mathematical sophistication and expertise.

3. Automated-proof requires “guidance”.

13 Formal Methods in Software Engineering


Advantages of Formal Methods
 Formal methods treat system components as
mathematical objects and provide
mathematical models to describe and predict
the observable properties and behaviors of
these objects.
 There are several advantages to using formal
methods for the specification and analysis of
real-time systems.
 the early discovery of ambiguities, inconsistencies
and incompleteness in informal requirements
 the automatic or machine-assisted analysis of the
correctness of specifications with respect to
requirements
 the evaluation of design alternatives without
14 expensive prototyping
Formal Methods in Software Engineering
Formal Specification Methods
 Logic
 Z, VDM, First order logic, temporal logic
 State Machines
 Finite state machines, communicating state
machines, extended state machines
 State Chart, Objectime, Automata

 Petri Nets

15 Formal Methods in Software Engineering


Conclusions
 Formal Methods are:
Mathematically based techniques for the specification,
development and verification of software and hardware
systems.

 Formal Methods can be used:


To varying extents and locations throughout the design
process.

 Sometimes considered to be:


Too expensive, difficult and time consuming.

16 Formal Methods in Software Engineering


Assignment no 1
Formal Methods in Software Engineering
Objective
• To apply formal methods techniques to a simplified system.
Task:
1. Choose a simple system: Select a small, well-defined system (e.g., a vending
machine, a traffic light controller).
2. Develop formal specifications: Use a formal method of your choice (e.g., state
machines, Z, VDM) to specify the system's behavior.
3. Analyze specifications: Identify any inconsistencies, ambiguities, or
incompleteness in the specifications.
4. Evaluate advantages and challenges: Discuss the benefits and drawbacks of
using formal methods for this system.
Deliverables:
• Formal specifications for the system.
• A brief analysis of the specifications.
• A discussion of the advantages and challenges.

17 Formal Methods in Software Engineering

You might also like