0% found this document useful (0 votes)
12 views17 pages

Toc Unit I.3

Deterministic Finite Automata (DFA) and Nondeterministic Finite Automata (NFA) are computationally equivalent, meaning every NFA can be converted into a DFA that recognizes the same language. The conversion process, known as the Subset Construction Method, involves creating DFA states that correspond to subsets of NFA states, determining transitions based on reachable states, and identifying accept states. NFAs are particularly useful in applications such as regular expression matching and lexical analysis due to their flexibility in recognizing patterns.

Uploaded by

Ashish Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views17 pages

Toc Unit I.3

Deterministic Finite Automata (DFA) and Nondeterministic Finite Automata (NFA) are computationally equivalent, meaning every NFA can be converted into a DFA that recognizes the same language. The conversion process, known as the Subset Construction Method, involves creating DFA states that correspond to subsets of NFA states, determining transitions based on reachable states, and identifying accept states. NFAs are particularly useful in applications such as regular expression matching and lexical analysis due to their flexibility in recognizing patterns.

Uploaded by

Ashish Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

EQUIVALENCE OF NFA AND DFA

A fundamental result in automata theory is that Deterministic Finite Automata


(DFA) and Nondeterministic Finite Automata (NFA) are computationally
equivalent. This means that for every NFA, there exists a DFA that recognizes the
same language. While NFAs provide flexibility in construction, DFAs are easier to
implement, making this equivalence important in both theoretical and practical
applications.

Why Are They Equivalent?

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

The equivalence is demonstrated by showing how to convert an NFA into an


equivalent DFA. This process is called the Subset Construction Method.

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.

5. Using this method, we can systematically construct a DFA that behaves


identically to the NFA for all input strings.

Example: NFA to DFA Conversion

The conversion method will follow following steps -

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,

i) δ' ([q1,q2 ...qi], a) = δ (q1, a) U δ (q2, a) U .........(qi, a)

= [q1, q2, …. qk ] may be some state.

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.

Example 1 Determine the DFA from a given NFA.

M = ((q0, q1), (a, b), δ, q0, {q1}) with the state table diagram for δ given below.

Solution: Let the DFA M'= (Q', Σ, δ ', q0, F')

Now, the δ' function will be computed as follows -

As δ (q0, 0) = {q0, q1} δ` ([q0], 0) = [q0, q1]

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},0) = δ (q0, 0) U δ (q1, 0)

= {q0, q1} U ϕ
= {q0, q1}

So, δ' ([q0, q1], 0) = [q0, q1]

Similarly,

δ' ({q0, q1}, 1) = δ (q0,1) U δ (q1,1)

= {q1} U {q0, q1}

= {q0, q1}

So, δ' ([q0, q1], 1) = [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]}

We can even change the names of the states of DFA.

A = [q0]

B = [q1]

C= [q0, q1]

With these new names the DFA will be as in Fig. 1.10.2.


Example 2 Construct DFA equivalent to the NFA

M = ((p, q, r), (0, 1), δ, p {q, s}) Where & is defined in the following table.

Solution: To construct DFA,

δ {p, 0} = {q, s} new state generated

δ {p, 1} = {q}

δ {q, 0} = {r}

δ {q, 1} = {q, r} new state

δ {r, 0} = {s}

δ (r, 1) = {p}

δ (s, 0} = -

δ {s, 1} = {p}

δ {{q, s}, 0} = {r}

δ {{q, s}, 1} = {p, q, r} new state

8 {{q, r), 0} = {r, s} new state

δ {{q, r}, 1} = {p, q, r}

δ {{p, q, r}, 0} = {q, r, s} new state

δ {{p, q, r}, 1} = {p, q, r}

δ {{r, s), 0} = {s}

δ {{r, s), 1} = {p}

δ {{q, r, s}), 0} = {r, s}

δ {{q, r, s), 1} = {p, q, r}


The transition table is as shown below.

Example 2 Construct DFA equivalent to the given NFA.

Solution: The NFA M = {{p, q, r, s}, {0, 1}, δ (p), {s}}

The equivalent DFA will be constructed.

Continuing with the generated new states.


The final state F' = { [s], [p, q, r, s], [p, q, s], [p, r, s], [p, s] }

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]

δ ([p], b) = {p, q} = [p, q] → new state

δ ([q], a) = [r]

δ ([q], b) = [r]

δ ([r], a) = ϕ

δ ([r], b) = ϕ

The 8 transition on newly generated states

δ ([p, q], a) = {p, r} = [p, r] → new state

δ ([p, q], b) = {p, q, r) = [p, q, r] → new state

δ ([p, r], a) = {p} U ϕ = [p]

δ ([p, r], b) = {p, q} U i.e. [p, q]

δ ([p, q, r], a) = {p} U {r} U ϕ = [p, r]

δ ([p, q, r], b) = {p, q} U {r} U ϕ = {p, q, r} i.e. [p, q, r]


As no new state is getting generated in above transitions, the transition table can be
constructed as follows -

Assuming [p] as start state and [r] as final state

The states [p, r] and [p, q, r] are final states as they contain [r].

The DFA can be represented by the transition diagarm as shown -

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.

Solution: The strings in such a language are -

The NFA will be,


The transition table can be –

We will obtain the δ transitions on each input and state.

δ (q0, 0) = [q0]

δ (q0, 1) = [q0, q1] i.e. [q0, q1] → New state

δ (q1, 0) = [q2], δ (q1, 1) = [q2]

δ (q2, 0) = [qf], δ (q2, 1) = [qf]

δ ([q0, q1], 0) = {q0, q2}, = [q0, q2] i.e. New state

δ ([q0, q1], 1) = {q0, q1, q2} = [q0, q1, q2] → New state

δ ([q0, q2], 0) = {q0, qF} = {q0, qf} → New state

δ ([q0, q2], 1) = {q0, q1, 9f} = [q0, q1, qf] → New state

δ ([q0, q1, q2], 0) = {q0, q2, qf} → New state

δ ([q0, q1, q2], 1) = {q0, q1, q2, qf } → New state

δ ([q0, qf], 0) = [q0]

δ ([q0, qf], 1) = [q0, q1]

δ ([q0, q1, qf], 0) = [q0, q2]

δ ([q0, q1, qf], 1) = [q0, q1, q2]

δ ([q0, q2, qf], 0) = [q0, qf]

δ ([q0, q2, qf], 1) = [q0, q1, qf]

δ ([q0, q1, q2, qf], 0) = [q0, q2, qf]

δ ([q0, q1, q2, qf], 1) = [q0, q1, q2, 9f]


The transition table for above computation is as given below -

The states q1, q2 and qf are not reachable states. Hence they can be eliminated.

Example 6 Construct a non-deterministic finite automaton accepting the set of


strings over {a,b} ending in aba. Use it to construct a DFA accepting the same set of
strings.

Solution: NFA for accepting the strings ending with aba is,

The transition table will be


We will obtain 8 transitions for each input on each state.

δ (q0, a) = {q0, q1} = [q0, q1] new state.

δ (q0, b) = {q0}

δ (q1, a) = ϕ

δ (q1, b) = {q2}

δ (q2, a) = {q3}

δ (q2, b) = ϕ

δ (q3, a) = ϕ

δ (q3, b) = ϕ

The δ transitions on newly generated states is

δ ([q0, q1], a) = {q0, q1} i.e. [q0, q1]

δ ([q0, q1], b) = {q0, q2} = [q0, q2] new state

δ ([q0, q2], a) = {q0, q1, q3} = [q0, q1, q3] new state

δ ([q0, q2], b) = {q0}

δ ([q0, q1, q3], a) = [q0, q1]

δ ([q0, q1, q3], b) = [q0, q2]

As no new state is getting generated. We will build transition table is as follows -


The DFA will be as shown in Fig. 1.10.5

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

Solution: Refer similar example 1.10.2 by assuming p = a, q=b, r = c and s = d.

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.

Solution: The NFA will be designed using

r.e. = (0+1)* 01
The transition table will be as follows:

Refer example 6 for conversion of NFA to DFA.

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 2: Draw the transition table for all pair of states.

Step 3: Now split the transition table into two tables T1 and T2. T1 contains all final
states and T2 contains non-final states.

Step 4: Find the similar rows from T1 such that:

δ (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 6: Repeat step 3 and step 4 for table T2 also.

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 2: Draw the transition table for rest of the states.

Step 3:

Now divide rows of transition table into two sets as:

1. One set contains those rows, which start from non-final sates:

2. Other set contains those rows, which starts from final states.

Step 4: Set 1 has no similar rows so set 1 will be the same.

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:

Now it is the transition table of minimized DFA.

Transition diagram of minimized DFA:

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

Limitations of Finite Automata:


 FA can only count finite input.
 There is no finite auto ma that can find and recognize set of binary string of equal
Os & 1s.
 Set of strings over "(" and ")" & have balanced parenthesis.
 Input tape is read only and only memory it has is, state to state.
 It can have only string pattern.
 Head movement is in only one direction.

You might also like