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:

M=(Q,Σ,δ,q0,F)M = (Q, \Sigma, \delta, q_0, F)

Where:

SymbolDescription
QQ
A finite set of states
Σ\Sigma
A finite set called the input alphabet
δ\delta
The transition function:
δ:Q×(Σ{ε})2Q\delta: Q \times (\Sigma \cup \{\varepsilon\}) \rightarrow 2^Q (a set of states)
q0q_0The initial state, q0Qq_0 \in Q
FF
The set of accepting states, FQF \subseteq Q

💡 Key Differences from DFA:

DFANFA
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 Σ={0,1}\Sigma = \{0,1\} that end with '01'.

In a given problem, the language accepts all strings ending with 01.

The language L= { 01,101,1101,001,11001,0101,11101,0001,1001,00101,…….}

✨ NFA Description:

  • States: Q={q0,q1,q2}Q = \{q_0, q_1, q_2\}

  • Alphabet: Σ={0,1}\Sigma = \{0,1\}

  • Initial state: q0q_0

  • Accepting state: F={q2}

🚀 Transitions:

  • From q0q_0:

    • On 0, go to q0q_0 or q1q_1 (nondeterministic choice)

    • On 1, go to q0q_0

  • From q1q_1:

    • On 1, go to q2q_2

  • From q2q_2:

    • 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

Popular posts from this blog

Theory Of Computation PCCST302 KTU Semester 3 BTech 2024 Scheme

Example DFAs University Questions