Non-Deterministic Finite Automata (NFA)
Introduction to Non-Deterministic Finite Automata
- Non-Deterministic Finite Automata (NFAs) refer to machines that can exist in multiple states at the same time.
- An NFA is defined as a 5-tuple: {Q,Σ,q0,F,f}.
- Q: A finite set called the states.
- Σ: A finite set called the alphabet (input symbols).
- f: Q×Σ: The transition function.
- q0∈Q: The initial or start state.
- F⊆Q: The set of final or accept state(s).
- A defining characteristic of the NFA is its ability to be in several states at once, as transitions can be non-deterministic.
Characteristics and Differences from DFA
- Initial State: Like a Deterministic Finite Automata (DFA), an NFA starts in exactly one initial state.
- Transition Flexibility: Each state in an NFA can have zero, one, or more outgoing transitions labeled with the same input symbol.
- Next State Choices: A primary difference between an NFA and a DFA is that the transition function in an NFA can lead to several states. This implies that several choices may exist for the next state at any given point during processing.
- Execution and Aborting: If an NFA is in a state where there is no transition defined for a specific input symbol, that branch of the computation aborts.
- Acceptance Criterion: If, at the end of the input sequence, at least one of the active states is a member of the set of final states (F), the NFA accepts the input string.
Detailed Example 1: NFA Tracing
- NFA Specification: Construct an NFA over Σ={0,1} that accepts strings ending in "001".
- Trace of Input String "101001":
- Initial State: Processing starts with q1 as the initial state. At this point, q1 is the only active state.
- First Input Symbol (1): Upon reading '1' while in state q1, the machine remains in q1. The active state is still q1.
- Second Input Symbol (0): Upon reading '0' while in state q1, the machine can either remain at q1 or transition to q2. The active states now become the set ϕ={q1,q2}.
- Third Input Symbol (1):
- Upon reading '1' from active state q1, it remains at q1.
- Upon reading '1' from active state q2, the NFA aborts because there is no defined transition for '1' at q2.
- The remaining active state is q1.
- Fourth Input Symbol (0): Upon reading '0' from active state q1, the machine can either remain at q1 or transition to q2. The active states are now ϕ={q1,q2}.
- Fifth Input Symbol (0):
- Upon reading '0' from active state q1, it either remains at q1 or transitions to q2.
- Upon reading '0' from active state q2, it transitions to q3.
- The active states are now ϕ={q1,q2,q3}.
- Sixth Input Symbol (1):
- Upon reading '1' from active state q1, it remains at q1.
- Upon reading '1' from active state q2, that branch aborts.
- Upon reading '1' from active state q3, it transitions to q4.
- The active states are now ϕ={q1,q4}.
- Conclusion: Since q4 is the final state and is included in the set of active states at the end of the input string, the string "101001" is accepted.
Example 2: NFA Transition Table
| State (Q) / Input (\Sigma) | a | b |
|---|
| →1 | 2 | ∅ |
| 2 | 2 | 2, 3 |
| 3 | 3, 4 | 3 |
| 4 | ∅ | ∅ |
- Note: The symbol → denotes the initial state.
Example 3: NFA Transition Table
| State (Q) / Input (\Sigma) | 0 | 1 |
|---|
| →q1 | q1,q2 | q1 |
| q2 | ∅ | q3 |
| q3 | q4 | ∅ |
| q4 | q4 | q4 |
NFAs with ϵ-Transitions
- Definition of ϵ-Transition: This is a transition from one state to another state without consuming any additional input symbols from the string.
- ϵ-NFAs: These are defined as NFAs that contain at least one explicit ϵ-transition.
- Application: In specific configurations, an ϵ-NFA can transition from an initial state to a final state without reading any symbol from the input string at all.
Questions & Discussion
- Prompts for String Generation:
- Can you give at least five (5) strings for the given NFA in Example 2?
- Can you give at least five (5) strings for the given NFA in Example 3?