Lecture No. 08
Dated: 17-03-2025
NFA
1 → DFA
2 Construction
The algorithm is called the subset construction
. The transition table
3 of NFA
1 contains multiple states
meanwhile the DFA
2 contains single states
.
Therefore, each state
in DFA
2 corresponds to multiple states
in NFA
.1
Following are the operations
- \(\epsilon-closure(T)\) for
set
4 ofNFA
1states
reachable from someNFA
1state
\(s\) in \(T\) on \(\epsilon\) transitions alone. - \(move(T, a)\) for
set
4 ofNFA
1states
to which there is a transition on input \(a\) from somestate
\(s\) inNFA
1 in \(T\).
Subset Construction
Algorithm
Input:
Output:
DFA
1 \(D\)states
set
4 \(S^\prime\)- Alphabet \(\Sigma\)
- State
state
\(s_0^\prime = \epsilon-closure(s_0)\) - Final
state
\(F^\prime\) Transition table
3 \(S^\prime \times \Sigma ? S^\prime\)
\(S^\prime = \{s_0^\prime\}\) (unmarked)
while
(there is some unmarked state
in \(T\) in \(S^\prime\))
mark state
\(T\)
for
all \(a\) in \(\Sigma\) do
\(U = \epsilon-enclosure(move(T, a))\)
if
\(U\) not already in \(S^\prime\)
add \(U\) as unmarked state to \(S^\prime Dtran(T, a) = U\)
end if
end for
end while
\(F^\prime\):
for each DFA
1 state
\(S\)
if
\(S\) contains an NFA
1 final state
mark \(S\) as DFA
1 final state
end algorithm
Example
NFA
1 for \((a | b)^*abb\) with \(\Sigma = \{a, b\}\).
The start state
of DFA
1 is \(\epsilon-closure(0)\) which is \(A = \{0, 1, 2, 4, 7\}\). These are the states
which are reachable from \(0\) through \(\epsilon\) transitions.
According to algorithm, mark \(A\) and compute \(\epsilon-enclosure(move(A, a))\).
\(move(A, a)\) is the set
4 of state
in NFA
1 that have transitions on input \(a\) from members of \(A\).
Let
Thus
For input \(b\),
Let
Thus,
We continue this process with unmarked sets \(B\) and \(C\) until all sets
4 of DFA
2 are marked.
- \(A=\{0,1,2,4,7\}\)
- \(B=\{1,2,3,4,6,7,8\}\)
- \(C=\{1,2,4,5,6,7\}\)
- \(D=\{1,2,4,5,6,7,9\}\)
- \(E=\{1,2,4,5,6,7,10\}\)
\(A\) is starting state
as it contains \(0\) and \(E\) is the accepting state
because it contains \(10\).
State | Input symbol | |
---|---|---|
a | b | |
A | B | C |
B | B | D |
C | B | C |
D | B | E |
E | B | C |