Lecture 10 & 11 - Chapter 5
Lecture 10 & 11 - Chapter 5
Pushdown Automata
Esubalew Alemneh
Contents
Introduction
Nondeterministic Pushdown Automata
Moves by NPDA
Transition Diagram
Instantaneous Description
Acceptance of strings by NFA
Push down Automata for CFGs
CFGs for Push down Automat
Deterministic Pushdown Automata and
Introduction
Push-Down Automata (PDA) is an abstract model of a machine –
Finite State Automata.
It has a finite set of states. However, in addition, it has a
pushdown stack. Moves of the PDA are as follows:
1. An input symbol is read and the top symbol on the stack is
read.
2. Based on both inputs, the machine enters a new state and
writes zero or more symbols onto the pushdown stack.
3. Acceptance of a string occurs if the stack is ever empty.
(Alternatively, acceptance can be if the PDA is in a final
state. Both models can be shown to be equivalent.)
3
Nondeterministic Pushdown Automata(NPDA)
An NPDA is a seven-tuple:
M = (Q, Σ, Г, δ, q0, z0, F)
Q - A finite set of states,
Σ - A finite input alphabet
Г - A finite stack alphabet,
Q0 - The initial/starting state, q0 is in Q
z0 - A starting stack symbol, is in Г
F -A set of final/accepting states, which is a subset of Q
δ - A transition function, where
δ: Q x (Σ U {ε}) x Г –> finite subsets of Q x Г*
4
Moves By NPDA
Consider the various parts of δ:
Q x (Σ U {ε}) x Г –> finite subsets of Q x Г*
Q & Г on the LHS means that at each step in a computation, a PDA
must consider its’ current state & the symbol on top of its’ stack.
Σ U {ε} on the LHS means that at each step in a computation, a PDA
may or may not consider the current input symbol, i.e., it may have
epsilon transitions.
6
Transition Graph
The nodes are labeled with states
The arcs are labeled as X,YV , where
X is the string processed
Y is the top element of the stack to be popped off
V is the symbol to be pushed onto stack
Example Transition graph of PDA for L(M) = {anbn:n>0}
Instantaneous Description (ID)
ID have the following format
( q, u , s )
Where,
o Q is Current state
o U is Remaining input
o S Current stack contents
A move from one move to another ID is denoted by , or
Thus (q, qw, bx) (p, w, yx) is possible iff (p, y) e δ (q, a, b)
Instantaneous Description (ID)…
Example: show how PDA for L(M) = {anbn:n>0} accepts
String w = a2b2
Answer
Count the number of a’s and b’s
M = ({q0, q1}, {a, b}, {0, 1, z0}, δ, q0, z0, {q1} ) where δ is;
18