Example. Example of the subset construction [017V]
In order to get a thorough intuition for the subset construction we will see how it acts on a sample NFA\varepsilon M over \Sigma ={\mathopen {}\left \{a,b\right \}\mathclose {}} which we draw below:
The states of \mathcal {P}{\mathopen {}\left (M\right )\mathclose {}} are all the subsets of Q_{M}:
Q_{\mathcal {P}{\mathopen {}\left (M\right )\mathclose {}}} = {\mathopen {}\left \{ \varnothing , {\mathopen {}\left \{q_0\right \}\mathclose {}}, {\mathopen {}\left \{q_1\right \}\mathclose {}}, {\mathopen {}\left \{q_2\right \}\mathclose {}}, {\mathopen {}\left \{q_0,q_1\right \}\mathclose {}}, {\mathopen {}\left \{q_0,q_2\right \}\mathclose {}}, {\mathopen {}\left \{q_1,q_2\right \}\mathclose {}}, {\mathopen {}\left \{q_0,q_1,q_2\right \}\mathclose {}} \right \}\mathclose {}}The starting state of \mathcal {P}{\mathopen {}\left (M\right )\mathclose {}} is the set of states reachable from q_0 via the empty string:
s_{\mathcal {P}{\mathopen {}\left (M\right )\mathclose {}}} = {\mathopen {}\left \{q_0,q_1,q_2\right \}\mathclose {}}The accepting states of \mathcal {P}{\mathopen {}\left (M\right )\mathclose {}} are all the sets of states containing an accepting state of M:
F_{\mathcal {P}{\mathopen {}\left (M\right )\mathclose {}}} = {\mathopen {}\left \{ {\mathopen {}\left \{q_2\right \}\mathclose {}}, {\mathopen {}\left \{q_2,q_0\right \}\mathclose {}}, {\mathopen {}\left \{q_2,q_1\right \}\mathclose {}}, {\mathopen {}\left \{q_2,q_1,q_0\right \}\mathclose {}} \right \}\mathclose {}}We then describe the transition function of \mathcal {P}{\mathopen {}\left (M\right )\mathclose {}} by means of a table:
| S | \delta _{\mathcal {P}{\mathopen {}\left (M\right )\mathclose {}}}{\mathopen {}\left (S,a\right )\mathclose {}} | \delta _{\mathcal {P}{\mathopen {}\left (M\right )\mathclose {}}}{\mathopen {}\left (S,b\right )\mathclose {}} |
|---|---|---|
| \varnothing | \varnothing | \varnothing |
| {\mathopen {}\left \{q_0\right \}\mathclose {}} | {\mathopen {}\left \{q_0,q_1,q_2\right \}\mathclose {}} | {\mathopen {}\left \{q_2\right \}\mathclose {}} |
| {\mathopen {}\left \{q_1\right \}\mathclose {}} | {\mathopen {}\left \{q_1\right \}\mathclose {}} | \varnothing |
| {\mathopen {}\left \{q_2\right \}\mathclose {}} | \varnothing | {\mathopen {}\left \{q_2\right \}\mathclose {}} |
| {\mathopen {}\left \{q_0,q_1\right \}\mathclose {}} | {\mathopen {}\left \{q_0,q_1,q_2\right \}\mathclose {}} | {\mathopen {}\left \{q_2\right \}\mathclose {}} |
| {\mathopen {}\left \{q_0,q_2\right \}\mathclose {}} | {\mathopen {}\left \{q_0,q_1,q_2\right \}\mathclose {}} | {\mathopen {}\left \{q_2\right \}\mathclose {}} |
| {\mathopen {}\left \{q_1,q_2\right \}\mathclose {}} | {\mathopen {}\left \{q_1\right \}\mathclose {}} | {\mathopen {}\left \{q_2\right \}\mathclose {}} |
| {\mathopen {}\left \{q_0,q_1,q_2\right \}\mathclose {}} | {\mathopen {}\left \{q_0,q_1,q_2\right \}\mathclose {}} | {\mathopen {}\left \{q_2\right \}\mathclose {}} |
All in all, we have the following DFA:
As you can see, the resulting DFA is kind of strange and has many redundant states. But it does accept the desired language.