Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views18 pages

Chapter 4 Pushdown Automata

Chapter 4 discusses Pushdown Automata (PDA), which are computational models that utilize a stack to recognize Context-Free Languages (CFLs). It highlights the differences between Context-Free Grammar and PDA, the formal definition of PDA, and its components, as well as acceptance methods and comparisons with Finite Automata. The chapter also covers deterministic and non-deterministic PDAs, properties of CFLs, and applications of PDAs in programming language syntax parsing and compiler construction.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views18 pages

Chapter 4 Pushdown Automata

Chapter 4 discusses Pushdown Automata (PDA), which are computational models that utilize a stack to recognize Context-Free Languages (CFLs). It highlights the differences between Context-Free Grammar and PDA, the formal definition of PDA, and its components, as well as acceptance methods and comparisons with Finite Automata. The chapter also covers deterministic and non-deterministic PDAs, properties of CFLs, and applications of PDAs in programming language syntax parsing and compiler construction.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Chapter 4: Pushdown Automata

(PDA)
Automata and Formal Language
Theory
Difference B/n Context Free Grammar and
Push Dawn Automata

Feature CFG PDA


Purpose Generates strings Accepts strings
Has a stack (limited
Memory No memory
memory)
Processes and checks
Direction Describes how to build strings
strings
Computational model (like
Form Set of rules
a machine)
What is a Pushdown Automaton?
• A type of automaton with a stack
• Recognizes Context-Free Languages
• PDA = FA + stack
Why Use a Stack?
• To handle nested structures (e.g. balanced
parentheses)
• Stack allows 'memory' of past inputs
Formal Definition of PDA
PDA has a 7-tuple:
• (Q, Σ, Γ, δ, q0, Z0, F)
• Q = states, Σ = input symbols, Γ = stack
symbols
• δ = transition function
• q0 = start state, Z0 = initial stack symbol, F =
final states
Components of PDA
Component Role
Input Tape Provides the string to process
Determines transitions and controls the
Finite Control
process
Provides memory for matching patterns
Stack
(e.g., parentheses, nested structures)
How PDA Works
• Reads input symbol
• Reads top of the stack
• Applies transition and changes state
• Can push or pop symbols on the stack
Example: PDA for aⁿbⁿ
• L = { aⁿbⁿ | n ≥ 1 }
• Steps:
1. Push 'a' on stack for each 'a'
2. Pop for each 'b'
3. Accept if stack is empty
Instantaneous Description
• ID is an informal notation of how a PDA
computes an input string and make a decision
that string is accepted or rejected
• Used to represent PDA state:
(q, w, γ)
q = current state
w = remaining input
γ = current stack contents
Turnstile Notation
• The ⊢ symbol represents one move of a PDA
(Push Down Automaton).
• It connects pairs of Instantaneous
Descriptions (IDs), showing transitions.
• The symbol ⊢* is used to describe a sequence
of moves (zero or more).
• Example:
(p, b, T) ⊢ (q, w, a)
Explanation:
• The PDA transitions from state p to state q.
• It consumes the input symbol 'b'.
• It replaces the top of the stack symbol 'T'
with new stack content 'a'.
• The input string becomes 'w' after the move.
Acceptance by PDA
• PDA can accept by:
1. Final state-the stack values are irrelevant as
long as we end up in a final state.
2. Empty stack- PDA accepts a string when , after
reading the entire string, the PDA has emptied
its stack.
• Both methods are valid
PDA vs Finite Automata
• FA has no memory (no stack)
• PDA has stack → handles more complex
languages
• FA ⊂ PDA in terms of power
Deterministic Push Down Automata (DPDA)

• Deterministic PDA has at most one transition


for each combination of input symbol, stack
symbol, and state.
• No state has multiple ε-transitions for the
same stack symbol.
• Recognizes a strict subset of CFLs.
Non-Deterministic Push Down Automata
(NPDA)
• Allows multiple transitions for the same input
and stack symbol.
• Uses ε-moves to change states without
reading input.
• Recognizes all CFLs (context-free languages).
• NPDA are more powerful than DPDA in terms
of the languages they can recognize.
Properties of Context-Free Languages (CFLs)

• CFLs are closed under union(Let L1 and L2 be


two context free languages, Then L1UL2 is also
context free language), concatenation, and
Kleene star.
• Not closed under intersection and
complementation.
• Every CFL can be accepted by a PDA.
• Can be generated using Context-Free
Grammars.
Applications of PDA
• Used in syntax parsing of programming
languages.
• Employed in compiler construction.
• Parsing nested structures like parentheses or
tags.
• Helps in processing structured text such as
XML/HTML.

You might also like