Non deterministic Finite Automata NFA
🤖 Formal Definition of NFA
An NFA (Nondeterministic Finite Automaton) is a theoretical machine used to recognize regular languages, like a DFA, but it allows multiple transitions for the same input or even no input at all (ε-transitions).
📘 An NFA is defined as a 5-tuple:
Where:
| Symbol | Description |
|---|---|
| A finite set of states | |
| A finite set called the input alphabet | |
| The transition function: | |
| (a set of states) | |
| The initial state, | |
| The set of accepting states, |
💡 Key Differences from DFA:
| DFA | NFA |
|---|---|
| Only one transition per input | Multiple transitions possible |
| No ε-transitions | ε-transitions allowed |
| Deterministic | Nondeterministic – many possible paths |
| Easier to implement | Easier to design, but converted to DFA for implementation |
🧪 Example NFA
Let’s construct an NFA that accepts all strings over that end with '01'.
The language L= { 01,101,1101,001,11001,0101,11101,0001,1001,00101,…….}
✨ NFA Description:
-
States:
-
Alphabet:
-
Initial state:
-
Accepting state:
🚀 Transitions:
-
From :
-
On 0, go to or (nondeterministic choice)
-
On 1, go to
-
-
From :
-
On 1, go to
-
-
From :
-
No transitions (final state)
-
🌟 How It Works:
This NFA allows multiple paths. It guesses the position where '0' is second last and checks for '1' immediately after.
If there is any computational path that accepts a string, then the machine accepts the string
Two ways to think about NFAs:
- Magic “Oracle”, which always picks the correct path to take
- Try all possible paths
✅ In Summary:
An NFA is a machine where for a given state and input, the next state is not uniquely determined.It accepts a string if any one computation path ends in an accepting state.

Comments
Post a Comment