Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Non-Deterministic Finite Automata (continued)

Lecture notes by Dr. K S Sudeep

Theorem (previous class): For any NFA (non-deterministic finite automaton) N, there is an equivalent
DFA that recognizes the same language. (Or, every language recognized by an NFA can be recognized
by a DFA also.)

Proof:

Given an NFA N = (QN, Ʃ, 𝛿 N, q0 , FN}, we construct a DFA D (QD , Ʃ, 𝛿 D , q0 ’, FD ) as follows:

 Set of states QD = Set of all subsets of QN, also called power set of QN. It has 2n states if N has
n states. (Later we can remove all states that are not reachable from the initial state).
 Input alphabet Ʃ remains same. New set of accepting states FD corresponds to all subsets S of
QN such that S has at least one accepting state of N. Or we can say all subsets S such that S Ո
FN ≠ Ø.
[In other words, accepting states of D correspond to subsets that contain at least one
accepting state of N.
For example: If states of N are q0, q1, q2; and set of accepting states of N are {q1, q2},
Then {q1}, {q2}, {q1, q2}, {q0, q1}, {q0, q2}, {q0, q1, q2 } are all accepting states of the DFA
D that corresponds to this NFA.]
 𝛿 D (S, a) = Սq in S 𝛿 N(q,a)
For example, 𝛿 D({q1, q2}, 0) = 𝛿 N (q1, 0) U 𝛿 N (q2,0).
In the first conversion example we did in the previous class,
𝛿 (q01, 0) = 𝛿 N (q0, 0) U 𝛿 N (q1, 0) = {q0} U {} = {q0}
𝛿 (q01, 1) = 𝛿 N (q0, 1) U 𝛿 N (q1, 1) = {q0, q1} U {} = {q0, q1}.

Completing the proof:

1. If a string w is accepted by N, then it is accepted by D also.


Proof: A sequence of moves on D corresponds to all parallel branches of N merged together.
At the end of a string w, if N can be in any one of the states {q1, q2, …qk}, then DFA D is in the
state {q1, q2, ….qk}.
So if a string w is accepted by N, it means if we draw the branches of the computation tree,
then at the end of w, at least one branch goes to an accepting state qf in FN. It means qf is
among the possible states that we can be at the end of w. So in D, we will get to a state
corresponding to a subset that contains this state qf. By the way we have defined the accepting
states of D, any state that corresponds to a subset containing this state qf (which is an
accepting state of N) is an accepting state of D also.

2. If N says No on w, D also says No. (In other words, if a string w is accepted by D, it is accepted
by NFA N also).
Proof: If a sting w gets Yes answer on D, i.e., it ends in an accepting state S of D, it means on
N, it can be in any of the states of this subset S.
But since S is an accepting state of D, it means that at least one of the states of S is an accepting
state of N (that is how we defined accepting states on D).
This means at least one branch goes to an accepting state at the end of w on N.
So is accepted by N also. This completes the proof. (If N says no, D cannot say Yes).

NFA with epsilon moves:

Here, epsilon (ε) means no symbol. An epsilon move, or an arrow with ε marked on it, means the
NFA can make that move even without looking at the next symbol.

00: q0q0q0, q0q1(ε)  q2(0)q0(0)

\delta(q0, 0) = {q0, q1}, \delta{q0, 1} = {q1}

Can you give me one string that is NOT accepted by this NFA (with epsilon moves).

On input string 01:

execution possibility 1 (branch 1): q0(0)q0( ε )q1(1)q1

execution possibility 2: q0( ε )q1(0)q2(1)q2, accepts (says YES).

11: The only possibility is q0( ε )q1(1)q1(1)q1. It says NO.


NFA accepts the string (or says YES) to the string 01 because there is at least one branch of execution
that takes us to an accepting state, q2.

On input string 00: q0(0)q0( ε )q1(0)q2. 00 is also accepted.

If string was 111, does this NFA accept? The answer is No. Verify yourself.

We can always convert such an NFA with epsilon-moves to a normal NFA without ε-moves. For
example, in this one, on q0 if we see a 0, we can add an arrow to q1 also. On q0 on seeing a 1 also, we
can add an arrow to q1. We will complete the conversion in the next class.

You might also like