Consider the following NFA
Q = states = {1,2,3,4,5} Start state: { 1 } Accepting state(s): { 5 }
Now construct an equivalent DFA.
Q/ = states for the DFA Some states in Q/: Empty set, {1}, {2}, {3}, {4}, {5}, {1,2}, {1,3}, ..., {1,2,3,4,5}
The ε-closure of a set of states, R, of the NFA will be denoted by E(R).
E(R) = R ∪ { q | there is an r in R with an ε transition to q } In the example, E({1}) = {1} ∪ { 2 } = {1,2}
a | b | |
---|---|---|
{1,2} | ||
For example,
DFA state {1,2} From 1, we have a path from 1 to 3 labeled 'a': 1 a 3 a path from 1 to 4 labeled ε 'a': 1 ε 2 'a' 4 a path from 1 to 5 labeled ε 'a': 1 ε 3 'a' 5 From 2, we have a path from 2 to 4 labeled 'a': 2 'a' 4 a path from 2 to 5 labeled 'a': 3 'a' 5 So altogether we can reach {3,4,5} from {1,2} on input 'a'
a | b | |
---|---|---|
{1,2} | {3,4,5} | |
a | b | |
---|---|---|
{1,2} | {3,4,5} | ∅ |
DFA state {3,4,5}, input 'a' From 3, we have no transition paths labeled 'a' From 4, a path from 4 to 5 labeled 'a': 4 a 5 From 5, there are no transition paths labeled 'a' So altogether we can reach {5} from {3,4,5} on input 'a' DFA state {3,4,5}, input 'b' From state 3, a path from 3 to 4 labeled 'b': 3 b 4 From state 4, a path from 4 to 5 labeled 'b': 4 b 5 From 5, there are no transition paths labeled 'b' So altogether we can reach {4,5} from {3,4,5} on input 'b'
Filling in the table we get:
a | b | |
---|---|---|
{1,2} | {3,4,5} | ∅ |
{3,4,5} | {5} | {4,5} |
The final states of the DFA are the sets that contain 5 since that is the only final state of the NFA.
The final table and corresponding DFA state diagram are:
a | b | |
---|---|---|
{1,2} | {3,4,5} | ∅ |
{3,4,5} | {5} | {4,5} |
{5} | ∅ | ∅ |
{4,5} | {5} | {5} |
∅ | ∅ | ∅ |