Deterministic and Non Determinstic Push Down automata

 

1. Context-Free Languages and Their Automata

  • Context-Free Languages (CFLs) are those generated by Context-Free Grammars (CFGs).

  • They are more powerful than regular languages, which are generated by finite automata.

  • Why finite automata are not enough?

    • A finite automaton has only finite memory.

    • Some CFLs (like { aⁿbⁿ : n ≥ 0 }) require counting an unbounded number of symbols.

    • Some others (like palindromes { wwᴿ }) require storing a sequence and matching it in reverse.

This motivates a stronger machine: the Pushdown Automaton (PDA).

  • A PDA is like an NFA but with an extra stack memory.

  • The stack provides unbounded storage but in a restricted LIFO (Last-In-First-Out) way.


2. Nondeterministic Pushdown Automata (NPDA)

  • Definition: An NPDA is like a nondeterministic finite automaton (NFA) with an added stack.

  • The PDA can:

    1. Read the current input symbol (or ε = empty move).

    2. Look at the top of the stack.

    3. Based on these, decide nondeterministically what to do:

      • Push a symbol onto the stack,

      • Pop the stack,

      • Or leave it unchanged.

  • Key Result :

    • Every CFL can be recognized by some NPDA.

    • Every NPDA recognizes a CFL.

    • Thus, NPDA ⇔ CFL.

So, nondeterminism is crucial: with it, PDAs exactly capture the family of CFLs.


3. Deterministic Pushdown Automata (DPDA)

  • A DPDA is restricted:

    • For any given configuration (state, input symbol, top of stack), there must be at most one possible move.

    • No nondeterministic choices are allowed.

    • No simultaneous ε-move and input-move from the same configuration.

  • Observation:

    • DPDAs cannot recognize all CFLs.

    • Example: The language { aⁿbⁿcⁿ : n ≥ 0 } is not CFL at all. But even within CFLs:

      • { aⁿbⁿ : n ≥ 0 } is deterministic.

      • Palindromes { wwᴿ } require nondeterminism, so not recognized by DPDA.

  • Key Result :

    • DPDA languages = Deterministic CFLs (DCFLs).

    • DCFLs ⊂ CFLs (proper subset).


4. Why the Distinction Matters

  • For regular languages, DFA = NFA (deterministic and nondeterministic are equivalent).

  • For context-free languages, DPDA ≠ NPDA.

  • This asymmetry is one of the main conceptual differences between finite automata and pushdown automata.

  • Programming Languages:

    • Most programming languages are designed to be deterministic context-free languages (DCFLs).

    • This is important because parsers (like LR, LL parsers) are based on deterministic PDAs.


5. Summary Table

MachineMemoryDeterminismLanguage ClassNotes
DFA/NFA        None (finite states                only)EquivalentRegular     Languages        DFA = NFA            
NPDA        Stack (LIFO)Nondeterminism allowedCFLs        NPDA ⇔ CFG
DPDA         Stack (LIFO)Deterministic onlyDCFLs ⊂ CFLs        Not all CFLs are             DCFLs

Key Difference (NPDA vs DPDA)

  • NPDA: δ may give multiple possible next moves (nondeterministic choices).

  • DPDA: δ must give at most one move for each configuration.

Comments

Popular posts from this blog

Theory Of Computation PCCST302 KTU Semester 3 BTech 2024 Scheme

Non deterministic Finite Automata NFA

Formal Definition - Turing Machine