Skip to content

Lecture No. 08

Dated: 17-03-2025

NFA1DFA2 Construction

The algorithm is called the subset construction. The transition table3 of NFA1 contains multiple states meanwhile the DFA2 contains single states.
Therefore, each state in DFA2 corresponds to multiple states in NFA.1

Following are the operations

  • \(\epsilon-closure(T)\) for set4 of NFA1 states reachable from some NFA1 state \(s\) in \(T\) on \(\epsilon\) transitions alone.
  • \(move(T, a)\) for set4 of NFA1 states to which there is a transition on input \(a\) from some state \(s\) in NFA1 in \(T\).

Subset Construction

Algorithm

Input:

  • NFA1 \(N\)
  • states set4 \(S\)
  • Alphabet \(\Sigma\)
  • State state \(s_0\)
  • Final state \(F\)

Output:

  • DFA1 \(D\)
  • states set4 \(S^\prime\)
  • Alphabet \(\Sigma\)
  • State state \(s_0^\prime = \epsilon-closure(s_0)\)
  • Final state \(F^\prime\)
  • Transition table3 \(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 DFA1 state \(S\)
if \(S\) contains an NFA1 final state
mark \(S\) as DFA1 final state
end algorithm

Example

cs606_e_8_1.svg

NFA1 for \((a | b)^*abb\) with \(\Sigma = \{a, b\}\).

The start state of DFA1 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 set4 of state in NFA1 that have transitions on input \(a\) from members of \(A\).

\[2 \to 3\]
\[7 \to 8\]
\[\epsilon-enclosure(move(A, a)) = \epsilon-enclosure(\{3, 8\}) = \{1, 2, 3, 4, 6, 7, 8\}\]

Let

\[B = \{1, 2, 3, 4, 6, 7, 8\}\]

Thus

\[Dtran[A, a] = B\]

For input \(b\),

\[4 \to 5\]
\[C = \epsilon-closure(\{5\}) = \{1, 2, 4, 5, 6, 7\}\]

Let

\[C = \{1, 2, 4, 5, 6, 7\}\]

Thus,

\[Dtran[A, b] = C\]

We continue this process with unmarked sets \(B\) and \(C\) until all sets4 of DFA2 are marked.

  1. \(A=\{0,1,2,4,7\}\)
  2. \(B=\{1,2,3,4,6,7,8\}\)
  3. \(C=\{1,2,4,5,6,7\}\)
  4. \(D=\{1,2,4,5,6,7,9\}\)
  5. \(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\).

cs606_e_8_2.svg

State Input symbol
a b
A B C
B B D
C B C
D B E
E B C

References