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, \Sigma, q_0, F, f\}.
    • QQ: A finite set called the states.
    • Σ\Sigma: A finite set called the alphabet (input symbols).
    • ff: Q×ΣQ \times \Sigma: The transition function.
    • q0∈Qq_0 \in Q: The initial or start state.
    • F⊆QF \subseteq 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 (FF), the NFA accepts the input string.

Detailed Example 1: NFA Tracing

  • NFA Specification: Construct an NFA over Σ={0,1}\Sigma = \{0, 1\} that accepts strings ending in "001".
  • Trace of Input String "101001":
    1. Initial State: Processing starts with q1q_1 as the initial state. At this point, q1q_1 is the only active state.
    2. First Input Symbol (1): Upon reading '1' while in state q1q_1, the machine remains in q1q_1. The active state is still q1q_1.
    3. Second Input Symbol (0): Upon reading '0' while in state q1q_1, the machine can either remain at q1q_1 or transition to q2q_2. The active states now become the set ϕ={q1,q2}\phi = \{q_1, q_2\}.
    4. Third Input Symbol (1):
      • Upon reading '1' from active state q1q_1, it remains at q1q_1.
      • Upon reading '1' from active state q2q_2, the NFA aborts because there is no defined transition for '1' at q2q_2.
      • The remaining active state is q1q_1.
    5. Fourth Input Symbol (0): Upon reading '0' from active state q1q_1, the machine can either remain at q1q_1 or transition to q2q_2. The active states are now ϕ={q1,q2}\phi = \{q_1, q_2\}.
    6. Fifth Input Symbol (0):
      • Upon reading '0' from active state q1q_1, it either remains at q1q_1 or transitions to q2q_2.
      • Upon reading '0' from active state q2q_2, it transitions to q3q_3.
      • The active states are now ϕ={q1,q2,q3}\phi = \{q_1, q_2, q_3\}.
    7. Sixth Input Symbol (1):
      • Upon reading '1' from active state q1q_1, it remains at q1q_1.
      • Upon reading '1' from active state q2q_2, that branch aborts.
      • Upon reading '1' from active state q3q_3, it transitions to q4q_4.
      • The active states are now ϕ={q1,q4}\phi = \{q_1, q_4\}.
  • Conclusion: Since q4q_4 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 (QQ) / Input (\Sigma)ab
→1\rightarrow 12∅\emptyset
222, 3
33, 43
4∅\emptyset∅\emptyset
  • Note: The symbol →\rightarrow denotes the initial state.

Example 3: NFA Transition Table

State (QQ) / Input (\Sigma)01
→q1\rightarrow q_1q1,q2q_1, q_2q1q_1
q2q_2∅\emptysetq3q_3
q3q_3q4q_4∅\emptyset
q4q_4q4q_4q4q_4

NFAs with ϵ\epsilon-Transitions

  • Definition of ϵ\epsilon-Transition: This is a transition from one state to another state without consuming any additional input symbols from the string.
  • ϵ\epsilon-NFAs: These are defined as NFAs that contain at least one explicit ϵ\epsilon-transition.
  • Application: In specific configurations, an ϵ\epsilon-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?