Processing math: 100%

1.Non-Deterministic Finite Acceptor (1)§

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

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

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).

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 union of two languages: L= << ?? >>.

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!

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.

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.

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

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:

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).

Class(DFA) == Class(NFA) Proof

We can use an algorithm to convert MN to MD.

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.

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.

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

So, why NFA?

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