Module -2
Finite State Automata
Finite automata
Deterministic Finite automata (DFA)
Non-deterministic Finite automata (NFA)
NFA with epsilon transitions
NFA without epsilon transition
Conversion of NFA to DFA
Equivalence of NFA and DFA
Minimization of DFA
Finite Automata (FA)
An automaton is an abstract model of a digital computer
Mathematical model of a system with discrete inputs and
outputs
Example:
c
Working Principle of FA
Input Tape:
Inputs are written on a Input Tape
tape, read by automaton
but cannot change it String
Input tape is divided into
cells, each of which can Output
hold one symbol
Finite
Finite Automaton
Automaton or
Finite number of states
Control state transitions / [Control Unit]
changes
FSA Applications
Lexical analysis (Compiler) recognition of tokens
Thermostats (fridge)
Elevators
Train Track Switches
Text editing
Image compression
Computer Network
Representation of FA
A Finite Automaton (FA) is represented by a 5-tuple (Quintuple)
M = (Q, , S, F)
Where,
Q is the set of states (finite)
:Q Q is the transition function
S Q is the start state
F Q is the set of accept states
Q = {q0 , q1 } , = { a, b}
n(Q) = 2 , n( ) = 2
A x B = { (x, y) / x A,y B } - Cartesian Product of A and B
n(A x B) = n(A) . n(B)
Qx = { (q0, a), (q0, b), (q1, a), (q1, b) }
n(Q x ) = n(Q). n( ) = 2 . 2 = 4
:Q Q
:Q Q
Q Q
(q0, a) (q0, a ) = q1
(q0, b)
(q1, b ) = q0
(q1, a)
(q1, b)
(q0, a ) = q1
Transition Diagram
A directed graph associated with the vertices of the graph
corresponds to the states of Finite Automata
If there is a transition from state A to state B on input symbol 0
then there is an arc with label 0 is drawn from state A to state B
FA accepts a string, if the sequence of transitions
corresponding to the symbols of leads from the start state to
an accepting state
Example
q0 0,1
0 0
L(M) = {0, 1}*
1
q0 q1
1
L(M) = { w | w has an even number of 1s}
Checking acceptance of string using FA
11 1
0
0,1
1
0111 111 1
0 0
Read string left to right 1
The machine accepts a string if the process
ends in a double circle
To accept a string:
all the input string is scanned
and the last state is accepting
To reject a string:
all the input string is scanned
and the last state is non-accepting
head Initial Configuration
Input Tape
a b b a
Input String
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
Initial state
Scanning the Input
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
Input finished
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
accept
A Rejection Case
a b a
Input String
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
a b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
a b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
Input finished
a b a
a, b
reject
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
Another Rejection Case
Tape is empty
( )
Input Finished
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
reject
Language Accepted: L abba
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
Another Example
a a, b
q0 b q1 a, b q2
Accept trap state
state
a a b
Input String
a a, b
q0 b q1 a, b q2
a a b
a a, b
q0 b q1 a, b q2
a a b
a a, b
q0 b q1 a, b q2
Input finished
a a b
a a, b
accept
q0 b q1 a, b q2
A rejection case
b a b
Input String
a a, b
q0 b q1 a, b q2
b a b
a a, b
q0 b q1 a, b q2
b a b
a a, b
q0 b q1 a, b q2
Input finished
b a b
a a, b
q0 b q1 a, b q2
reject
Language Accepted: L {a b : n
n
0}
a a, b
q0 b q1 a, b q2
Example 1 String acceptance
1. Given a finite automata, M = ({q0, q1}, {0, 1}, , q0, {q1}) and
transition diagram as given below:
0 1
q0 q1 1
a) Check whether the input string 10101 is accepted by M or not.
b) Check whether the input string 101100 is accepted by M or
not.
Example 1 cont
a) 1 0 1 0 1 The string 10101 is accepted because it
q0 q1 q0 q1 q0 q1 ends in the final / acceptance state
Start Accepted
b) 1 0 1 1 0 0
q0 q1 q0 q1 q1 q0 q0
Start
Not accepted
The string 101100 is not accepted because it does not ends
in the final / acceptance state
Example 2
2. Given a finite automata, M = ({a, b, c, d}, {0, 1}, , a, {a}) and
transition table as given below:
0 1
a c b
b d a
c a d
d b c
a) Check whether the input string 110101 is accepted by M or not.
b) Check whether the string 110011 is accepted by M or not.