Close
Close Window

| About   «  0.3. Deterministic Finite Acceptors   ::   Contents   ::   1.2. Minimizing the Number of States in a DFA  »

1.1. Non-Deterministic Finite Acceptor

1.1.1. Non-Deterministic Finite Acceptor (1)

Define a NFA (or NDFA) as (Q,Σ,δ,q0,F) where

  • Q is a finite set of states

  • Σ is the input alphabet (a finite set)

  • q0 is the initial state (q0Q)

  • FQ is a set of final states

  • δ:Q×(Σ{λ})2Q (2Q here means the power set of Q)

<<Hmmm… How is this different from a DFA?>>

1.1.2. Non-Deterministic Finite Acceptor (2)

The specific difference from a DFA is that, while the result of δ for the DFA is some state qQ, the result of δ for the NFA is any subset of Q.

Transitions to a null subset is a failed path.

Non-deterministic means that it allows choices. From a state on input b, δ might include transitions to more than one state.

Another difference:
We allow λ transitions (a free ride to another state).

1.1.3. NFA Example 1

Created with Raphaël 2.1.2
q0
q1
q3
q2
a
b
b
a
a
In this example, δ(q0,a)= << ?? >>.
(So, δ is no longer meets the mathematical definition of a function!)

Hopefully this one is easy to understand: Two disjoint paths, effectively giving us the union of two languages: L= << ?? >>.

1.1.4. NFA Example 2

L={(ab)nn>0}{anbn>0}.

Created with Raphaël 2.1.2
q0
q1
q3
q5
q2
q4
q6
λ
a
b
b
a
a
λ
λ
A simple “go this way or go the other way”.
Unfortunately, they are not always so simple to understand!

1.1.5. Accepting a String

Definition: qjδ(qi,w) if/only if there exists some walk from qi to qj labeled w.

From previous example:
δ(q0,ab)= << ?? >>.
δ(q0,aba)= << ?? >>.

For an NFA M, L(M)={wΣδ(q0,w)F}. << What does this mean? >>

NFA accepts a string if it completes processing in a final state. However for an NFA, the string is accepted if any processing path gets us to end in a final state. It does not matter that there are paths where w can go wrong. What matters is that there is at least one way for w to be right.

1.1.6. Why nondeterminism?

It makes it “easier” to describe a FA.
<< What might “easier” mean? >>

From a performance point of view, to determine if a string is accepted can take a LONG time to try out all possibilities. But, all that we care about right now is existance, not performance.

Hypothesis: Nondeterminism allows us to accept more languages.

1.1.7. Which is more powerful?

Created with Raphaël 2.1.2
q0
q2
q1
b
a
b
a

Can this NFA be converted to a DFA?

Created with Raphaël 2.1.2
q0
q1,q2
q0,q2
a
b
a

1.1.8. Key Question

Does non-determinism increase the collection of languages that can be accepted? That is, can any language be accepted by an NFA that has no DFA that accepts it?

Here is a bit of intution that might give some insight:

  • Nondeterminism gives branches. If we are trying to create a non-determinism simulator in a computer, we can simulate it by alternating between all of the branches, pushing each branch forward by a step. This will eventually terminate.

1.1.9. Key Theorem

Theorem: Given an NFA MN=(QN,Σ,δN,q0,FN), there exists a DFA MD=(QD,Σ,δD,q0,FD) such that L(MN)=L(MD).

1.1.10. Class(DFA) == Class(NFA) Proof

We can use an algorithm to convert MN to MD.

  • QD=2QN << What does this mean? How big is this set of states? >>

    [Right here, this is what I consider the key insight. Given a state in MN and a symbol Σ, you can get to some subset of the states in MN. Consider THAT to be a state in MD.]

  • FD={QQD qiQ with qiFN} << What does this mean?? >>

  • δD:QD×ΣQD << What does this mean?? >>

    Of course this begs the question: HOW?

1.1.11. Algorithm to construct MD (1)

  1. Start state is {q0}closure(q0)

    What does closure(q) mean?

    The set of states reachable from q with λ transitions.

1.1.12. Algorithm to construct MD (2)

  1. Start state is {q0}closure(q0)

  2. While missing a transition in δD:

    1. Choose a state A={qi,qj,...,qk} with missing edge for aΣ

    2. Compute B=δ(qi,a)δ(qj,a)δ(qk,a)

    3. Add state B if it doesn’t exist

    4. Add edge from A to B with label a

  3. Identify final states

  4. If λL(MN), then make the start state final.

1.1.13. Example: NFA to DFA

1 / 12 Settings
<<<>>>

Let's see a step-by-step conversion of an NFA to a DFA.

Created with Raphaël 2.1.2
q0
q1
q2
q3
q4
q5
q6
a
b
λ
a
a
λ
b
λ
Proficient Saving... Error Saving
Server Error
Resubmit

1.1.14. So, why NFA?

Conclusion: NFA adds no new capability. So why bother with the idea?

  • First, it wasn’t obvious that they are the same. NFA is a useful concept.

  • NFA tend to be “smaller” and “simpler” than the equivalent DFA. (At least morphologically, but perhaps the language of a NFA is hard to grasp.)

  • We will see times when it is easier to see a conversion from something to a NFA, and we know that this can always be converted in turn to a DFA.

   «  0.3. Deterministic Finite Acceptors   ::   Contents   ::   1.2. Minimizing the Number of States in a DFA  »

Close Window