Formal Definition
A Nondeterministic Finite Automaton is a 5-tuple , where
- is a finite set of states
- is a finite alphabet
- : is the transition function
- is the start state
- is the set of accept states
Let be an NFA and a string over the alphabet . Then we say that accepts if we can write as , where each is a member of and a sequence of states exists in with three conditions:
- , for
Note
Unlike Deterministic Computation where the next state is determined to be a specific state, Nondeterministic Machine has several choices that exists for the next state at any point.
Nondeterminism is a generalization of determinism → every deterministic finite automaton is automatically a nondeterministic finite automaton
DFA vs NFA
| Deterministic Finite Automaton (DFA) | Nondeterministic Finite Automation (NFA) |
|---|---|
| Every state always has exactly one exiting transition arrow for each symbol in the alphabet | States may have 0, 1, or many exiting arrows for each alphabet symbol |
| Labels on the transition arrows are symbols from the alphabet | May have arrows labeled with members of the alphabet or |
Computation of NFA
- Start: The process begins in the start state .
- Read: The machine reads the input string symbols one by one from left to right.
- Move: After reading a symbol, it follows the transition to a new state.
- The current state has multiple ways to proceed → the machine “splits” into multiple copies of itself and follows all the possibilities in parallel
- Each takes one of the possible ways to proceed and continues as before
- Output: After the last symbol is read, the machine accepts the string if any of the copies have an accept state in the final stage; otherwise, the machine rejects the input.
Equivalence of NFAs and DFAs
- DFAs and NFAs recognize the same class of languages
- Say that two machines are equivalent if they recognize the same language
Every NFA Has an Equivalent DFA
Proof by Construction
Let be the NFA recognizing some language .
Construct a DFA recognizing .
-
Every state of is a set of states of
Recall that is the set of subsets of -
For and , let
If is a state of , it is also a set of states of
When reads a symbol in state , it shows where takes each state in , it shows where takes each state in
Because each state may go to a set of states, we take the union of all these sets.The notation standards for the union of the sets for each possible in
-
starts in the state corresponding to the collection containing just the start state of -
The machine accepts if one of the possible states that could be in at this point is an accept state.