The specific difference from a DFA is that, while the result of
δ for the DFA is some state q∈Q, 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
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)n∣n>0}∪{anb∣n>0}.
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?
q0
q2
q1
b
a
b
a
Can this NFA be converted to a DFA?
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:
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.
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.
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={Q∈QD∣∃qi∈Q with qi∈FN}
<< What does this mean?? >>
δD:QD×Σ→QD
<< What does this mean?? >>
Of course this begs the question: HOW?
Algorithm to construct MD (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)
Start state is {q0}∪closure(q0)
While missing a transition in δD:
Choose a state A={qi,qj,...,qk} with
missing edge for a∈Σ