Module 1
Module 1
• q0 is the initial state from where any input is processed (q0 ∈ Q).
• Q = {a, b, c},
• Σ = {0, 1},
• q0={a},
• F={c}, and
a, b
a,b a,b
A B C
a, b
a,b a,b a, b
A B C D
– To accept null string () the only way to make initial state to both initial
state and final state.
12
Minimum number of states
There is an arrow to the start state The initial and final states are
q0 denoted by → and * respectively.
Nodes corresponding to final states
are marked with doubled circle
1
Non-deterministic Finite Automaton
In NDFA, for a particular input symbol, the machine can move to any combination
of the states in the machine. In other words, the exact state to which the
machine moves cannot be determined. Hence, it is called Non-deterministic
Automaton. As it has finite number of states, the machine is called Non-
deterministic Finite Machine or Nondeterministic Finite Automaton.
An NDFA can be represented by a 5-tuple (Q, Σ, δ, q0, F) where:
(Here the power set of Q (2𝑄) has been taken because in case of NDFA, from a
• Q = {a, b, c}
• Σ = {0, 1}
• q0 = {a}
• F={c} and
0 1
q1 q1 q2
the transition function δ is q2 q3 q2
q3 q2 q2
Final state F = {q2}.
q1 is the start state, and F = {q2}.
Example: Testing Membership
01011
Next
symbol
0 0,1
1 1
A B C
Start 0
Current
state
2
2
Example: Testing Membership
01011
Next
symbol
0 0,1
1 1
A B C
Start 0
Current
state
2
3
Example: Testing Membership
01011
Next
symbol
0 0,1
1 1
A B C
Start 0
Current
state
2
4
Example: Testing Membership
01011
Next
symbol
0 0,1
1 1
A B C
Start 0
Current
state
2
5
Example: Testing Membership
01011
Next
symbol
0 0,1
1 1
A B C
Start 0
Current
state
2
6
Example: Testing Membership
01011
Next
symbol
0 0,1
1 1
A B C
Start 0
Current
state
2
7
Example
Intuitively, δ(q, a) is the state entered by ε after reading symbol a while in state q.
The extended transition function is a function that takes a state q and a string
w and returns a state p (the state that the automaton reaches when starting in
state q and processing the sequence of inputs w )
δ^(q , w) – The state entered after reading string w having started in state q
Describes what happens when we start in any state and follow any sequence of inputs
23
Cont …
Formally:
1)δ^(q, ) = q, If we are in a state q and read no inputs, then we are still in state q
and
Suppose w is a string of the form xa; that is a is the last symbol of w, and x is the
string consisting of all but the last symbol Then: δˆ(q, w) =δ(δˆ(q, x), a)
To compute δˆ(q, w), first compute(q, x), the state that the automaton is in after
processing all but the last symbol of w
Then δˆ(q, w )is what we get by making a transition from state P on input a – the last
symbol of w.
Extension of δ to Strings
Example #1: 1
0
q0 q1 1
0
What is δ^(q0, 011)? Informally, it is the state entered by ε after
processing 011 having started in state q0.
Formally:
δ^(q0, 011) = δ (δ^(q0,01), 1)
= δ (δ (δ ^(q0,0), 1), 1)
= δ (δ (δ (δ ^(q0, ), 0), 1), 1)
= δ (δ (δ(q0,0), 1), 1)
= δ (δ (q1, 1), 1)
= δ (q1, 1)
= q1
Is 011 accepted? No, since δ^(q0, 011) = q1 is not a final state.
Conti
Example #2: 1
0
1
0
… 1
q2
q0 q1
0
What is δ(q0, 011)? Informally, it is the state entered by ε after processing 011
having started in state q0.
Formally:
δ(q0, 011) = δ (δ(q0,01), 1)
= δ (δ (δ (q0,0), 1), 1)
= δ (δ (q1, 1), 1)
= δ (q1, 1)
= q1
Is 011 accepted? No, since δ(q0, 011) = q1 is not a final state.
Language?
NDFA to DFA
Conversion
Problem Statement
Let X = (Qx, Σ, δx, q0, Fx) be an NDFA which accepts the language L(X). We have
to design an equivalent DFA Y = (Qy, Σ, δy, q0, Fy) such that L(Y) = L(X). The
following procedure converts the NDFA to its equivalent DFA:
Algorithm
Input: An NDFA
Step 2 Create a blank state table under possible input alphabets for the equivalent DFA.
Step 3 Mark the start state of the DFA by q0 (Same as the NDFA).
Step 4 Find out the combination of States {Q0, Q1,... , Qn} for each possible input
alphabet.
Step 5 Each time we generate a new DFA state under the input alphabet columns, we have to apply step 4 again,
otherwise go to step 6.
Step 6 The states which contain any of the final states of the NDFA are the final states of the equivalent DFA.
Example
Let us consider the NDFA shown in the figure below.
Using the above algorithm, we find its equivalent DFA. The state table of the DFA
is shown in below.
The state diagram of the DFA is as follows: