200 likes | 552 Views
NFA DFA. Subset Construction. Convert an NFA to DFA using the subset construction. Each state of the DFA is a set of states of the NFA. The initial state of the DFA is the -closure of the initial state of the NFA. CLOSE{0}={0, 1, 3}=S 0.
E N D
NFA DFA Subset Construction
Each state of the DFA is a set of states of the NFA. The initial state of the DFA is the -closure of the initial state of the NFA. CLOSE{0}={0, 1, 3}=S0
Determine the transition function of the DFA on all inputs. Begin with the initial state S0, and determine the transition on input a. CLOSE{0} = {0, 1, 3} = S0 (S0, a) = CLOSE{1, 2}
The e-closure of the set {1, 2} is {1, 2, 3} This is a new state in the DFA, call it S1. CLOSE{0} = {0, 1, 3} = S0 (S0, a) = CLOSE{1, 2} = {1, 2, 3} = S1
With the initial state S0, determine the transition on input b. CLOSE{0} = {0, 1, 3} = S0 (S0, a) = CLOSE{1, 2} = {1, 2, 3} = S1 (S0, b) = CLOSE{3}
The -closure of the set {3} is {1, 3}. This is a new state in the DFA, call it S2. CLOSE{0} = {0, 1, 3} = S0 (S0, a) = CLOSE{1, 2} = {1, 2, 3} = S1 (S0, b) = CLOSE{3} = {1, 3} = S2
Determine the transition function of the DFA from state S1 on inputs a and b. On a there is no where to go in the NFA, so we create a “sink“(“trap”) state for DFA. (S0, a) = CLOSE{1, 2} = {1, 2, 3} = S1 (S0, b) = CLOSE{3} = {1, 3} = S2 (S1, a) = CLOSE{} == S3
Determine the transition function of the DFA from state S1 on inputs a and b. On b there is a transition to an existing state S2. (S0, a) = CLOSE{1, 2} = {1, 2, 3} = S1 (S0, b) = CLOSE{3} = {1, 3} = S2 (S1, a) = CLOSE{} == S3 (S1, b) = CLOSE{3} = {1, 3} = S2
Determine the transition from state S2 on inputs a and b. (S0, a) = CLOSE{1, 2} = {1, 2, 3} = S1 (S0, b) = CLOSE{3} = {1, 3} = S2 (S1, a) = CLOSE{} = = S3 (S1, b) = CLOSE{3} = {1, 3} = S2 (S2, a) = CLOSE{} = = S3 (S2, b) = CLOSE{3} = {1, 3} = S2
Determining the transition from state S2 on inputs a and b is easy;from the empty set of states there are no transitions in the NFA. Inthe DFA this is represented by a transition from the empty setback to itself.
The final states of the DFA are determined from the final states of the NFA. State 3 was the only final state in the NFA. Any set of NFA states containing a final state is a final state in the DFA.