PDA-6 Tuple Machine
PDA-6 Tuple Machine
Dr Fareeha Anwar
1
Finite Automata
2
The Stack Model
3
Pushdown Automata
• Informally a pushdown automata (PDA) is an
NFA + Stack
state
control
a a b ca a
x
y
z
5
Example (cont.)
6
Transition function of a PDA
• In NFA a transition function is determined
according to:
1. A current state
2. An input letter
• In PDA we move according to
1. A current state
2. An input letter
3. A letter on top of the stack
• The transition function output is a state and a
letter to be written into the stack. 8
Formal Definition of PDA
• A pushdown automaton is a 6-tuple:
(Q, , , , q0, F)
,x→y
• The diagram for the PDA is: q q’
10
Possible transition functions
• (q,,x) = (q',y)
– move without reading a symbol from the input
• (q,,) = (q',y)
– move without reading a symbol from the stack
• (q, ,x) = (q',)
– move without pushing a symbol to the stack
• (q, , ) = (q,y)
– push y ,x→y
• (q, , x) = (q,) q q’
– popx
11
Example:
• Change the stack:
(q,,x) = (q',y)
,x→y
q q’
x y
z z
12
Example:
• Popping the stack:
(q,,x) = (q', )
,x→
q q’
x
z z
13
Example:
• Pushing the stack:
(q,,) = (q', y)
,→y
q q’
y
x x
z z
14
Example:
• No change:
(q,,x) = (q', x)
(q,,) = (q', )
,x→x
q q’
,→
x x
z z
15
Example of a PDA
• A state diagram for a PDA that recognizes
{ambn | m=n0}
20
Non Determinism in PDA
23
Non Determinism in PDA
• A PDA is called deterministic iff it holds the
following three conditions:
– for each qQ, a and x, |(q,a,x)| 1
– for each qQ and x, if (q,,x) then for each
, (q, , x)=
– for each qQ and , if (q,,) then for
each x, (q, ,x)=
,→$ 0,→0
q0 q1 1,→1
c,→
0,0→
q3 q2 1,1→
,$→
25
Example of Nondeterministic PDA
• This PDA recognizes {wwR | w{0,1}* }
• A nondeterminism is a must here.
,→$ 0,→0
q0 q1 1,→1
,→
0,0→
q3 q2 1,1→
,$→
26
The Power of PDA
• What is the power of a PDA? Can it recognize
all context-free languages? Is it stronger?
• Proof:
– We show that if L is CFL then a PDA recognizes it.
– We show that is a PDA recognizes L then L is CFL.