Trying to simulate an NFA with a DFA is less straight-forward.
Warm-up: which of the following are equivalent to plain NFAs?
MultistartNFA: an NFA allowing more than one start stateSingleAcceptNFA: an NFA allowing only a single accept stateInjectiveNFA: an NFA for which the destination of each transition rule is either \(\emptyset\) or a singleton \(\{q_i\}\)NoLoopNFA: an NFA for which no transition rule is of the form \(q \stackrel{a}{\rightarrow} q\) for any \((q, a) \in Q \times \Sigma\)NoEpsilonNFA: an NFA with no \(\emptystring\) transitions.
Example processing the string 010110:
010110
Begin in the state(s) \(\{q_1\}\).
Read 0 and transition to state(s) \(\{q_1\}\).
010110
Read 1 and transition to state(s) \(\{q_1, q_2, q_3\}\).
010110
Read 0 and transition to state(s) \(\{q_1, q_3\}\).
010110
Read 1 and transition to state(s) \(\{q_1, q_2, q_3, q_4\}\).
010110
Read 1 and transition to state(s) \(\{q_1, q_2, q_3, q_4\}\).
010110
Read 0 and transition to state(s) \(\{q_1, q_3, q_4\}\).
010110
Since an accept state is highlighted, the NFA accepts the string.
What would a DFA need to keep track of in order to simulate this NFA?
To simulate an NFA with \(|Q|\) states operating on a string \(w\), how many distinct sets of states must we keep track of in the worst case?
There exist \(k\)-state NFAs for which the smallest equivalent DFA has \(2^k\) states!
Example near this bound:
\(k^\text{th}\)-to-last symbol NFA
Theorem: Every NFA-decidable language is DFA-decidable.
Proof (no \(\emptystring\) transitions)
For any \(R \subseteq Q_N\), define: \[ E(R) = \setbuild{q \in Q_N}{q \text{ is reachable from some $r \in R$ by a sequence of 0 or more $\emptystring$-transitions}} \]
Theorem: If a language is NFA-decidable, then it is also DFA-decidable.
Proof
This convention for handling \(\emptystring\)-transitions is not the only possible one!
Corollary: a language is DFA-decidable if and only if it is NFA-decidable.
A right-regular grammar (RRG) is a CFG whose rules are all of the form: \[ X \to a Y \qquad \text{or} \qquad X \to \emptystring \]
Theorem: Every DFA-decidable language is RRG-decidable (and thus CFG-decidable).
Given any DFA \(D\), we can convert it into RRG \(G\) such that \(L(G) = L(D).\) In other words \(G\) generates string \(w\) iff \(D\) accepts \(w\).
Construction Example:
Equivalent grammar \(G\): \[\begin{align*} P &\to \fragment{0T\;|\;} \fragment{1R} \\ T &\to 0R\;|\; 1P \\ R &\to 0P\;|\; 1R \\ P &\to \emptystring \\ T &\to \emptystring \end{align*}\]
Parse tree for \(0110\):
Derivation of \(0110\): \[ \fragment{P} \fragment{\yields 0T} \fragment{\yields 01P} \fragment{\yields 011R} \fragment{\yields 0110P} \fragment{\yields 0110} \]
Computation sequence accepting \(0011\): \[ p, t, p, r, p \]
A right-regular grammar (RRG) is a CFG whose rules are all of the form: \[ X \to a Y \qquad \text{or} \qquad X \to \emptystring \]
Theorem: Every DFA-decidable language is RRG-decidable (and thus CFG-decidable).
Given any DFA \(D\), we can convert it into RRG \(G\) such that \(L(G) = L(D).\) In other words \(G\) generates string \(w\) iff \(D\) accepts \(w\).
Proof
We now prove \(L(G) = L(D)\).