Вы находитесь на странице: 1из 13

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}=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 -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, CLOSE{1 2} = {1, {1 2, 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.

(S0, a) = CLOSE{1, 2} = {1, 2, 3} = S1 (S0, b) = CLOSE{3} = {1, 3} = S2

CLOSE{0} = {0, 1, 3} = S0

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) ( p ) 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. 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. In the DFA this is represented by a transition from the empty set b k to itself. back i lf

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.

NFA DFA RESULTAT

Вам также может понравиться