NFA: Non-deterministic finite automata. A 5-tuple (Q, \Sigma, \delta, q_0, F), where
Example: DFA v.s. NFA
This is a DFA that recognizes
10
over \Sigma = \{ 0 , 1 \}
This is an NFA that does the same thing more succinctly.
Suppose we want to recognize \{ 10, 00, 11 \}, the NFA is simply:
The union operation of three automata is way simpler in NFAs than DFAs, and NFAs are just simpler and less cluttered.
Example: Write an NFA that accepts strings where the 3rd-to-last digit is 0. (\Sigma = \{ 0, 1 \})
This NFA can be read as non-deterministically “guessing” to the accepting path.
Example: { w | w starts with
01
, has even # of 1s, and ends with0
}
- Notice how we do everything sequentially rather than branching with \epsilon.
Example:
L = { w | w has a # of 1s divisible by 3}
Q: How do we create a DFA to recognize the complement of L?
A: Simply flip the accepting states.
- \bar{L} = U - L
- U = \Sigma^*
Observations:
- This only works for DFA, not NFA.
Strategies for Flipping an NFA:
We can turn any NFA into a DFA.
Steps:
Q: Turn this NFA into a DFA.
A:
Observations:
a | b | |
---|---|---|
1 | \phi | { 2 } |
2 | { 2, 3 } | { 3 } |
3 | { 1, 3 } | \phi |
{ 1, 3 } | \phi \cup { 1, 3 } = { 1, 3 } | \phi \cup { 2 } = { 2 } |
{ 2 } | { 2, 3 } | { 3 } |
{ 3 } | { 1, 3 } | \phi |
{ 2, 3 } | { 1, 2, 3 } | { 3 } |
{ 1, 2, 3 } | { 1, 2, 3 } | { 2, 3 } |
Q: Which ones are accepting?
Q: How many states can the resulting DFA have?
With the transition table, the DFA can now be constructed, starting at state { 1, 3 }.