0% found this document useful (0 votes)
7 views18 pages

Lec 3

Uploaded by

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

Lec 3

Uploaded by

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

FORMAL METHODS

Week 2
Lecture 3
Lecturer: Maira Zulfiqar
Finite state machine (FSM)
• Finite state machine (FSM) is a term used by programmers,
mathematicians, engineers and other professionals to
describe a mathematical model for any system that has a
limited number of conditional states of being

Example

A practical example of a finite state machine is a set of buttons


on a video game controller that are connected to a specific set of
actions within the game. When a user inputs hitting certain
buttons, the system knows to implement the actions that
correspond.
Finite state machine (FSM)
The makeup of a finite state machine consists of the
following:
– A set of potential input events.
– A set of probable output events that correspond to the potential input
events.
– A set of expected states the system can exhibit.
• While transition, the automata can either move to the next
state or stay in the same state.
• FA has two states: accept state or reject state. When the input
string is successfully processed and the automata reached its
final state then it will accept.
Finite state machine (FSM)
A finite automata consists of following:
Q: finite set of states
∑: finite set of input symbol
q0: initial state
F: final state
δ: Transition function
Transition function can be define as
• δ: Q x ∑ →Q
FA is characterized into two ways:
• DFA (finite automata)
• NDFA (non deterministic finite automata)
DFA
• DFA stands for Deterministic Finite Automata.
Deterministic refers to the uniqueness of the
computation. In DFA, the input character goes to one
state only. DFA doesn't accept the null move that
means the DFA cannot change state without any input
character.
• DFA has five tuples {Q, ∑, q0, F, δ}
Deterministic Finite Automata
• Q: set of all states
∑: finite set of input symbol where δ: Q x ∑
→Q
q0: initial state
F: final state
δ: Transition function
Deterministic Finite Automata
• Example
• See an example of deterministic finite
automata:
• Q = {q0, q1, q2}
• ∑ = {0, 1}
• q0 = {q0}
• F = {q3}
Non Deterministic Finite Automata
• NDFA refer to the Non Deterministic Finite
Automata. It is used to transit the any number
of states for a particular input. NDFA accepts
the NULL move that means it can change state
without reading the symbols.
• NDFA also has five states same as DFA. But
NDFA has different transition function.
• Transition function of NDFA can be defined as:
• δ: Q x ∑ →2Q
Non Deterministic Finite Automata
• Example
• See an example of non deterministic finite
automata:
• Q = {q0, q1, q2}
• ∑ = {0, 1}
• q0 = {q0}
• F = {q3}
Real world examples
Coin-operated turnstile
• States: locked, unlocked
• Transitions: pointing a coin in the slot will unlock
the turnstile, pushing the arm of the unlocked
turnstile will let the costumer pass and lock the
turnstile again
Traffic Light
• States: Red, Yellow, Green
• Transitions: After a given time, Red will change to
Green, Green to Yellow, and Yellow to Red
Formal Specification
A formal specification language is usually
composed of three primary components or in
mathematical term we can say that it consists
of two sets syntax and semantics and a set of
relation.
• Syntax
• Sematic
• Relation
Types of Formal Specification: Z
language
• Z is a formal specification language was
developed by Abrial at Oxford University in
the early 1980s.
• It is used for the formal specification of
software and is a model-oriented approach.
• An explicit model of the state of an abstract
machine is given,
• and the operations are defined in terms of
the effect on the state. It includes a
mathematical notation
The Z Specification Language
• The schema calculus is a powerful means of
decomposing a specification into smaller pieces
or schemas.
• This helps to make Z specification highly
readable, as each individual schema is small in
size.
• Mathematical data types are used to model the
data in a system, and these data types obey
mathematical laws.
• Z has been successfully applied in industry,
Example: a simple counter

• Types
MESSAGE:=OK|Error
Counter State space schema

Counter declare two variables of natural numbers for


value and limit and has an invariant that value is less
than equal limit.
Increment operation schema for
counter
The B-Method
• The B-Technologies consist of three components:
• 1. a method for software development, namely
the B-Method
• 2. a supporting set of tools, namely the BToolkit;
• 3. a generic program for symbol manipulation,
namely the B-Tool (from which the B-Toolkit is
derived).
The B-Method is a model-oriented approach and is
closely related to the Z specification language.
The Vienna Development Method
• VDM was developed by a research team at the
IBM research laboratory in Vienna.
• VDM is a model-oriented approach and this
means that an explicit model of the state of an
abstract machine is given, and operations are
defined in terms of the state.
• Operations may act on the system state,
taking inputs and producing outputs as well as
a new system state
The Vienna Development Method
• VDM uses keywords to distinguish different
parts of the specification, e.g. preconditions,
post-conditions, as introduced by the
keywords pre and post, respectively.
• VDM specifications are structured into
modules, with a module containing the
module name, parameters, types, operations,
etc

You might also like