Push Down Automata - Formal Definition
Context-Free Languages and Pushdown Automata
Why PDAs?
-
CFGs describe context-free languages (CFLs) (e.g., programming languages via BNF).
-
We want an automaton model for CFLs.
-
Finite Automata (FA) are too weak:
-
FA have finite memory only.
-
Cannot handle unbounded counting.
-
Example:
-
Must count number of ’s to match with ’s.
-
is unbounded → impossible with finite memory.
Example:
-
Need to store a sequence of symbols.
-
Later, match them in reverse order.
-
Requires more than just counting.
Solution: Use a Stack
-
Stack = unlimited memory but restricted access:
-
Push → add symbol on top.
-
Pop → remove top symbol.
-
-
Provides exactly the extra power needed.
Pushdown Automata (PDA)
-
A PDA = Finite Automaton + Stack.
-
Can recognize all context-free languages.
-
Key idea: use the stack for counting and matching.
Stack = unbounded memory, last-in-first-out.
Pushdown Automaton (PDA) – Formal Definition
A Pushdown Automaton (PDA) is a 7-tuple
where:
-
Q – a finite set of states.
-
Σ – the input alphabet (finite set of symbols that the PDA can read from the input tape).
-
Γ – the stack alphabet (finite set of symbols that can be pushed to or popped from the stack).
-
δ – the transition function, defined as:
This means: given the current state, the current input symbol (or ε for empty move), and the top of the stack symbol, the PDA can move to a new state and replace the top of the stack with a string of stack symbols.
(The use of indicates nondeterminism: the machine may have multiple possible moves.)
-
q₀ ∈ Q – the start state.
-
Z₀ ∈ Γ – the initial stack symbol (marks the bottom of the stack).
-
F ⊆ Q – the set of accepting states.
Explanations
-
A PDA is like a Finite Automaton with memory, where the memory is provided by a stack.
-
At each step, the PDA looks at:
-
The current state.
-
The next input symbol (or ε if it decides to make an ε-move).
-
The symbol on the top of the stack.
Based on these, it decides:
-
Which state to move to.
-
How to modify the stack (pop, push, or replace).
-
-
The stack allows the PDA to keep track of potentially unbounded information (like counting nested parentheses), which a finite automaton cannot do.
-
Acceptance criteria:A string is accepted by a PDA if, after reading the entire input, one of the following holds:
-
Final state acceptance: The PDA ends in an accepting state, regardless of stack content.
-
Empty stack acceptance: The PDA empties its stack, regardless of the final state.
Simple Example
Language:
This is the classic non-regular language accepted by a PDA.
Idea:
-
Push every a onto the stack.
-
For every b, pop one a from the stack.
-
Accept if stack is empty at the end
Comments
Post a Comment