Toc Unit I.3
Toc Unit I.3
The equivalence of DFA and NFA is based on the fact that both automata types define
the same class of languages, known as regular languages. Although NFAs may have
multiple or ε-transitions, their behavior can always be simulated deterministically by a
DFA.
Proof of Equivalence
1. States: The states of the DFA correspond to subsets of the NFA’s states.
2. Start State: The start state of the DFA is the ε-closure of the NFA’s start state
(the set of all states reachable from the NFA’s start state using ε-transitions).
3. Transitions: For each subset of NFA states and input symbol, the DFA
transitions to the subset of states reachable from any state in the current subset.
4. Accept States: Any DFA subset that contains at least one of the NFA’s accept
states is an accept state for the DFA.
1) The start state of NFA M will be the start for DFA M'. Hence add q0 of NFA (start
state) to Q'. Then find the transitions from this start state.
2) For each state [q1, q2, q3, ... qi] in Q' the transitions for each input symbol Σ can be
obtained as,
ii) Add the state [q1, q2, .... qk] to DFA if it is not already added in Q'.
iii) Then find the transitions for every input symbol from Σ for state [q1, q2, ....,qk ].
If we get some state [q1, q2, ... qn ] which is not in Q' of DFA then add this state to
Q`.
iv) If there is no new state generating then stop the process after finding all the
transitions.
3) For the state [q1, q2, …. qn] ϵ Q' of DFA if any one state qi is a final state of NFA
then [q1, q2,......qn ] becomes a final state. Thus the set of all the final states ϵ F' of
DFA.
M = ((q0, q1), (a, b), δ, q0, {q1}) with the state table diagram for δ given below.
As in NFA the initial state is q0, the DFA will also contain the initial state [q0].
Let us draw the transition table for δ function for a given NFA.
From the transition table we can compute that there are [q0], [q1], [q0, q1] states for
its equivalent DFA. We need to compute the transition from state [q0, q1].
= {q0, q1} U ϕ
= {q0, q1}
Similarly,
= {q0, q1}
As in the given NFA q1 is a final state, then in DFA wherever q1 exists that state
becomes a final state. Hence in the DFA final states are [q1] and [q0, q1]. Therefore
set of final states F = {[q1], [q0, q1]}
A = [q0]
B = [q1]
C= [q0, q1]
M = ((p, q, r), (0, 1), δ, p {q, s}) Where & is defined in the following table.
δ {p, 1} = {q}
δ {q, 0} = {r}
δ {r, 0} = {s}
δ (r, 1) = {p}
δ (s, 0} = -
δ {s, 1} = {p}
The transition graph shows two disconnected parts. But part I will be accepted as final
DFA because it consists of start state and final states, in part II there is no start state.
Example 3 Convert the following NFA to a DFA
.
Solution: We will apply δ transitions on each state for each input.
δ ([p], a) = [p]
δ ([q], a) = [r]
δ ([q], b) = [r]
δ ([r], a) = ϕ
δ ([r], b) = ϕ
The states [p, r] and [p, q, r] are final states as they contain [r].
The states [q] and [r] are eliminated as they are dead states.
Example 5 Construct a DFA accepting binary strings such that the third symbol from
the right end is 1.
δ (q0, 0) = [q0]
δ ([q0, q1], 1) = {q0, q1, q2} = [q0, q1, q2] → New state
δ ([q0, q2], 1) = {q0, q1, 9f} = [q0, q1, qf] → New state
The states q1, q2 and qf are not reachable states. Hence they can be eliminated.
Solution: NFA for accepting the strings ending with aba is,
δ (q0, b) = {q0}
δ (q1, a) = ϕ
δ (q1, b) = {q2}
δ (q2, a) = {q3}
δ (q2, b) = ϕ
δ (q3, a) = ϕ
δ (q3, b) = ϕ
δ ([q0, q2], a) = {q0, q1, q3} = [q0, q1, q3] new state
The states q1, q2 and q3 are non-reachable. Hence they will be eliminated.
Example 7 Construct a DFA equivalent to the NFA. M=({a, b, c, d}, {0,1} δ, a {b,
d}) where δ is a defined as
Example 8 Construct NFA that accepts all string that end in 01. Give its transition
table and extended transition function for the input string 00101. Also construct a
DFA for the above NFA using subset construction method.
r.e. = (0+1)* 01
The transition table will be as follows:
OPTIMIZATION OF DFA
To optimize the DFA you have to follow the various steps. These are as follows:
Step 1: Remove all the states that are unreachable from the initial state via any set of
the transition of DFA.
Step 3: Now split the transition table into two tables T1 and T2. T1 contains all final
states and T2 contains non-final states.
δ (q, a) = p
δ (r, a) = p
That means, find the two states which have same value of a and b and remove one of
them.
Step 5: Repeat step 3 until there is no similar rows are available in the transition table
T1.
Step 7: Now combine the reduced T1 and T2 tables. The combined transition table is
the transition table of minimized DFA.
Example
Solution:
Step 1: In the given DFA, q2 and q4 are the unreachable states so remove them.
Step 3:
1. One set contains those rows, which start from non-final sates:
2. Other set contains those rows, which starts from final states.
Step 5: In set 2, row 1 and row 2 are similar since q3 and q5 transit to same state on 0
and 1. So skip q5 and then replace q5 by q3 in the rest.
Step 6: Now combine set 1 and set 2 as:
APPLICATIONS OF NFA:
When it comes to computer science, NFAs (Non-Deterministic Finite Automata) have
numerous applications in the field. NFAs are widely used in the industry for pattern
recognition, data mining, and even in natural language processing. The ability of
NFAs to recognize patterns in an input string makes them a valuable tool for solving
problems in computer science. In this section, we will explore some of the most
significant applications of NFAs in computer science.
1. Regular Expression Matching: One of the most common applications of an NFA is
to match regular expressions. Regular expressions are used to define patterns in text
and used in programming languages to search for specific strings. An NFA can be
constructed to accept a regular expression, and then it can be used to match the
expression with input strings.
2. Lexical Analysis: Lexical analysis is the process of converting input text into
tokens that can be used for further processing. This process is widely used in
compilers and interpreters. NFAs can be used to define the lexical structure of a
programming language and then used to generate the tokens for that language.
3. natural language Processing: In natural language processing, NFAs can be used to
recognize patterns in text. For example, an NFA can be used to identify named
entities in a sentence (such as names, places, and dates). This is useful in applications
such as sentiment analysis, machine translation, and speech recognition.
4. data mining: data mining is the process of discovering patterns in large data sets.
NFAs can be used to identify patterns in data sets, such as identifying sequences of
events or identifying similar items. For example, an NFA can be used to identify
patterns of user behavior on a website and then used to make recommendations to
other users.
5. Network Security: NFAs can also be used in network security applications. For
example, an NFA can be used to identify patterns in network traffic that may indicate
an attack or a security breach. This is useful in applications such as intrusion detection
and prevention systems.
APPLICATIONS OF DFA:
Vending Machines
Traffic Lights
Video Games
Text Parsing
Regular Expression Matching
CPU Controllers
Protocol Analysis
Natural Language Processing
Speech Recognition