You are on page 1of 5

Non-Deterministic Finite Automata

Lecture notes by Dr. K S Sudeep

Consider this finite automaton N. It is slightly different from the ones we have seen till now.
From state q0, on seeing a 1, there are two options: either remain in q0 itself or go to state
q1. Also, on q1, there are no outgoing arrows at all, on any symbol.

This is an NFA, a Non-deterministic finite automaton. In general, it can have zero, one or more
(any finite number of) moves from a state q, on seeing an input symbol a.

Any DFA is an NFA also. A DFA is a special case of an NFA, where on every state and on every
symbol, there is exactly one possible next move.

In an NFA, the transition function 𝛿 can be thought of as a function from Q x Ʃ to the power
set of Q, which is the set of all subsets of Q, sometimes denoted as 2Q.

In the figure given above, (q0, 0) = {q0}, (q0, 1) = {q0, q1}, (q1, 0) = {} and (q1, 1) = {}.

On NFA, there could be many possible sequences of states (branches of computation) on a


given input string. For example, on the NFA given above, on input string 01, it can go two ways
as follows.
So when can we say that an NFA accepts a string w?

 A string w is accepted by an NFA N (N says Yes on w) if there is at least one branch of


computation on N that ends in an accepting state at the end of seeing all symbols of w.

So what is the language recognized by the above NFA? Or what are the strings on which it says Yes?

 All strings that end with a 1. (Verify yourself). For instance, we cannot get to q1 on string 0010
on N, no matter which sequence of arrows you follow. Whereas 10001 can get you to q1.

Another example:

NFA N1

0 can take us to q2, 00 can take us to q2.

Some other strings that are accepted are: 000, 001, 01, 11, 000011.

110, 00110, 1 etc are NOT accepted.

All possible branches of computation on 001 can be seen in the figure below.
There are two branches that goes all the way till the end of the string 001. One of them ends in q0 and
the other ends in q2. Since q2 is an accepting state, and since one of these branches of execution ends
in q2, the string 001 is accepted.

At the end of 00000000: we can be in q0, q1 or q2 (3 branches). So this string is also accepted.

So what is the language (complete set of strings) accepted by this NFA? [Exercise].

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

Proof idea: Just create as many states as there are subsets of the states of NFA N. And see from all
possible states in a subset, on seeing a symbol a, where all it can go.

NFA N

States of the corresponding DFA are the subsets of states of N: They are {} (or Ø), {q0 } or just q0, {q1 }
(or just q1 ) and {q0 , q1 } (we can call it q01 ).

Transition function 𝛿 is as follows (we will define the steps formally later):

0 1

{} (or Ø) Ø Ø

{q0 } q0 q0 q01

{q1 } Ø Ø

{q0 , q1 } q01 q0 q01


What we got above in the figure is a DFA A that corresponds to the NFA N. Accepting states in A are
all the states that correspond to subsets that contain any one accepting state of N.

Here, we can see that two states are ‘detached’ from the figure, as they are not reachable from the
starting state q0. In general, we can take a cue from this and draw only those states that are reachable
from the initial state. The remaining part (the part that contains q0 ) is exactly same as the DFA we gave
earlier for the same language.

Let us try another conversion, with the second NFA that we saw.

NFA N1

States and the transition function 𝛿 for the corresponding DFA are given below. Note that we are
ignoring all states that are not reachable from the initial state q0.

0 1

{q0 } q0 q012 q1

{ q1 } q1 Ø q2

{} or Ø Ø Ø

{q2 } q2 Ø Ø

{q0 , q1 , q2 } q012 q012 q12

{q1 , q2 } q12 Ø q2

The table ends here, as no other state is reachable from q0. Accepting states are q2 , q12 and q012. The
state diagram for this DFA D is given below.

You might also like