0% found this document useful (0 votes)
44 views3 pages

12.conversion of NDFA To DFA

Toc topics notes

Uploaded by

Shuwani Patel
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)
44 views3 pages

12.conversion of NDFA To DFA

Toc topics notes

Uploaded by

Shuwani Patel
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/ 3

Converting a Nondeterministic Finite Automaton (NFA) to a Deterministic Finite

Automaton (DFA) involves transforming the NFA, which may have multiple possible
transitions for a given input symbol, into a DFA, where each state has exactly one transition for
each input symbol. This process ensures that the DFA can simulate the behavior of the NFA
while adhering to the deterministic constraints.

Subset Construction Algorithm

The most common method for converting an NFA to a DFA is the subset construction
algorithm (also known as the powerset construction). Here's a step-by-step guide:

1. Define the Components of the NFA

Let's start with an NFA defined by:

 States: QNQ_NQN
 Input Alphabet: Σ\SigmaΣ
 Transition Function: δN:QN×Σ→2QN\delta_N: Q_N \times \Sigma \to 2^{Q_N}δN
:QN×Σ→2QN
 Initial State: q0Nq_{0N}q0N
 Accepting States: FNF_NFN

2. Create the DFA Components

The DFA will be defined as:

 States: Each state in the DFA corresponds to a subset of the states in the NFA.
 Input Alphabet: The same as the NFA's input alphabet.
 Transition Function: Defined based on the subsets of NFA states.
 Initial State: The subset containing the NFA's initial state and any states reachable via ε-
transitions.
 Accepting States: Any subset that contains at least one of the NFA's accepting states.

3. Initialize the DFA

 Initial State of the DFA: Compute the ε-closure of the initial state of the NFA. The ε-
closure of a state is the set of states reachable from it using only ε-transitions.

4. Build the DFA Transition Function

For each subset of NFA states (representing a DFA state):

 Compute the transitions for each input symbol. For an input symbol aaa, find the set of
states reachable from each state in the subset under aaa. This involves:
o For each state in the subset, look up the NFA transition function δN\delta_NδN to
determine the set of next states.
o Take the union of these sets to get the new subset of states.
o Compute the ε-closure of this new set of states to handle any ε-transitions.

5. Determine the Accepting States

 A subset of states in the DFA is an accepting state if it contains at least one accepting
state from the NFA.

6. Construct the DFA

 States: Each subset of NFA states corresponds to a state in the DFA.


 Transitions: For each DFA state and input symbol, use the subset transitions computed.
 Initial State: The ε-closure of the initial NFA state.
 Accepting States: Subsets containing NFA accepting states.

Example

Consider an NFA with:

 States: QN={q0,q1}Q_N = \{q_0, q_1\}QN={q0,q1}


 Input Alphabet: Σ={0,1}\Sigma = \{0, 1\}Σ={0,1}
 Transition Function (δN\delta_NδN):
o δN(q0,0)={q0,q1}\delta_N(q_0, 0) = \{q_0, q_1\}δN(q0,0)={q0,q1}
o δN(q0,1)={q0}\delta_N(q_0, 1) = \{q_0\}δN(q0,1)={q0}
o δN(q1,0)={}\delta_N(q_1, 0) = \{\}δN(q1,0)={}
o δN(q1,1)={q1}\delta_N(q_1, 1) = \{q_1\}δN(q1,1)={q1}
 Initial State: q0N=q0q_{0N} = q_0q0N=q0
 Accepting States: FN={q1}F_N = \{q_1\}FN={q1}

Subset Construction Steps:

1. Initial State of DFA:


o Initial DFA State=ε-closure({q0})={q0}\text{Initial DFA State} = \text{ε-
closure}(\{q_0\}) = \{q_0\}Initial DFA State=ε-closure({q0})={q0} (No ε-
transitions in this case).
2. Transitions:
o For DFA state {q0}\{q_0\}{q0}:
 On input 0: δN(q0,0)={q0,q1}\delta_N(q_0, 0) = \{q_0, q_1\}δN(q0
,0)={q0,q1}. So, the DFA transition for 0 from {q0}\{q_0\}{q0} is to
{q0,q1}\{q_0, q_1\}{q0,q1}.
 On input 1: δN(q0,1)={q0}\delta_N(q_0, 1) = \{q_0\}δN(q0,1)={q0}. So,
the DFA transition for 1 from {q0}\{q_0\}{q0} is to {q0}\{q_0\}{q0}.
o For DFA state {q0,q1}\{q_0, q_1\}{q0,q1}:
 On input 0: δN(q0,0)={q0,q1}\delta_N(q_0, 0) = \{q_0, q_1\}δN(q0
,0)={q0,q1} and δN(q1,0)={}\delta_N(q_1, 0) = \{\}δN(q1,0)={}. Union
is {q0,q1}\{q_0, q_1\}{q0,q1}.
On input 1: δN(q0,1)={q0}\delta_N(q_0, 1) = \{q_0\}δN(q0,1)={q0} and
δN(q1,1)={q1}\delta_N(q_1, 1) = \{q_1\}δN(q1,1)={q1}. Union is
{q0,q1}\{q_0, q_1\}{q0,q1}.
3. Accepting States:
o {q0,q1}\{q_0, q_1\}{q0,q1} contains q1q_1q1, so it is an accepting state.

Resulting DFA:

 States: {{q0},{q0,q1}}\{ \{q_0\}, \{q_0, q_1\} \}{{q0},{q0,q1}}


 Transition Function:
o δ({q0},0)={q0,q1}\delta(\{q_0\}, 0) = \{q_0, q_1\}δ({q0},0)={q0,q1}
o δ({q0},1)={q0}\delta(\{q_0\}, 1) = \{q_0\}δ({q0},1)={q0}
o δ({q0,q1},0)={q0,q1}\delta(\{q_0, q_1\}, 0) = \{q_0, q_1\}δ({q0,q1},0)={q0,q1}
o δ({q0,q1},1)={q0,q1}\delta(\{q_0, q_1\}, 1) = \{q_0, q_1\}δ({q0,q1},1)={q0,q1}
 Initial State: {q0}\{q_0\}{q0}
 Accepting States: {q0,q1}\{q_0, q_1\}{q0,q1}

This DFA simulates the behavior of the original NFA and accepts the same set of strings. The
subset construction algorithm provides a systematic way to create a DFA that recognizes the
same language as a given NFA.

You might also like