Close
Register
Close Window

CS4114 Formal Languages Spring 2021

Chapter 3 Finite Acceptors

Show Source |    | About   «  3.3. DFA exercises 2   ::   Contents   ::   3.5. NFA exercises  »

3.4. NFA: Non-Deterministic Finite Automata

3.4.1. Non-Deterministic Finite Automata

Lots of times we have to make decisions. Sometimes, once we make the decision, we cannot undo it. Sometimes, we can go back, change our minds, make the other choice. But even then, we still had to spend the time investigating the false path.

Imagine that when we came to a decision point, we could clone ourselves, follow both paths, and then just “become” the version that turns out to be the better choice. Wouldn’t that be a hugely powerful upgrade to our lives?

That gets into some pretty complicated philosophy in real life. But in the world of Finite Automata, the concept of nondeterminism turns out to be something that we can make quite concrete. In this module, we study what it means to make an FA nondeterministic, and whether it really even matters in the end.

Settings

Proficient Saving... Error Saving
Server Error
Resubmit

3.4.2. NFA vs. DFA: Which is more powerful?

Settings

Proficient Saving... Error Saving
Server Error
Resubmit

Now we are ready for the main event: Proving that every NFA can be converted to a DFA, and therefore the two machine types are equally powerful. We do this using Proof by Construction: We have an algorithm that converts any NFA to an equivalent DFA.

Theorem 3.4.1 and Proof

Theorem: Given some NFA \(M_N = (Q_N, \Sigma, \delta_N, q_0, F_N)\), there exists a DFA \(M_D = (Q_D, \Sigma, \delta_D, q_0, F_D)\) such that \(L(M_N) = L(M_D)\).

Proof: We can use an algorithm to convert \(M_N\) to \(M_D\).

  • \(Q_D = 2^{Q_N}\) (the powerset of \(Q_N\))

  • \(F_D = \{Q\in Q_D \mid \exists q_i \in Q \mathrm{with} q_i \in F_N \}\)

    Interpretation: A state \(q_D\) in \(M_D\) is final if any of the states from \(M_N\) in the subset that \(q_D\) corresponds to is final.

  • \(\delta_D : Q_D \times \Sigma \rightarrow Q_D\)

Algorithm to construct \(M_D\)

  1. The start state for \(M_D\) is \(\{q_0\} \cup \mathrm{closure}(q_0)\). (“Closure” of \(q_0\) is a set of states defined as \(q_0\) plus all states reachable from \(q_0\) by \(\lambda\) transitions.)

  2. While there is an edge to add (that is, while our DFA is missing a transition from \(\delta_D\)):

    1. Choose a state \(A = \{q_i, q_j, ..., q_k\}\) with a missing edge for \(a \in \Sigma\)

    2. Compute \(B = \delta^{*}(q_i, a) \cup \delta^{*}(q_j, a) \cup \ldots \cup \delta^{*}(q_k, a)\)

    3. Add state \(B\) to \(M_D\) if it doesn’t already exist

    4. Add an edge from \(A\) to \(B\) with label \(a\)

  3. Identify final states.

    For a state in \(Q_D\), if any of its base \(Q_N\) states are final, then it is final.

  4. If \(\lambda \in L(M_N)\), then make the start state final.

Intuition: Given a state in \(M_N\) and a character, you can get to some subset of the states in \(M_N\). Consider that to be a state in \(M_D\). There are only so many subsets of the set of \(M_N\) states: the members of the powerset of \(M_D\) states.

3.4.3. NFA to DFA Conversion Example

Settings

Proficient Saving... Error Saving
Server Error
Resubmit

3.4.4. Conclusions

Adding the non-determinism capability to DFAs does not result in any new capability to accept languages. The set of languages that can be accepted by a NFA is exactly the same set of languages that can be accepted by a DFA. We proved this constructively: Every DFA is automatically an NFA without nondeterminism, so DFAs obviously cannnot accept languages that NFAs cannot. And any NFA can be converted using an algorithm to a DFA. So NFAs cannot accept languages that DFAs cannot.

So, is the NFA a useful concept? Why introduce them at all? First, it was not obvious to start that they add no new power in terms of new languages that can be accepted. Second, NFAs tend to be “simpler” to understand than the equivalent DFA. See the result of the conversion example, and decide for yourself which one is easier for you to deduce the corresponding language. Or, try writing the DFA for the language from scratch as a DFA. Third, we will introduce some other conversion algorithms over the course of the semester that are easier to understand if the target is a NFA instead of a DFA.

   «  3.3. DFA exercises 2   ::   Contents   ::   3.5. NFA exercises  »

nsf
Close Window