0% found this document useful (0 votes)
65 views23 pages

Pushdown Automata

The document provides an overview of push down automata (PDA). It defines a PDA as a finite automata with an additional memory component in the form of a stack. This allows PDAs to recognize contexts-free languages. The key components of a PDA are described, including states, input/stack alphabets, transitions, and acceptance conditions. Common state operations like replace, push, pop and no change are explained. An example PDA is given to recognize the language {0^n 1^n} and its operation is demonstrated on an input string.

Uploaded by

Rajit Kuthiala
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)
65 views23 pages

Pushdown Automata

The document provides an overview of push down automata (PDA). It defines a PDA as a finite automata with an additional memory component in the form of a stack. This allows PDAs to recognize contexts-free languages. The key components of a PDA are described, including states, input/stack alphabets, transitions, and acceptance conditions. Common state operations like replace, push, pop and no change are explained. An example PDA is given to recognize the language {0^n 1^n} and its operation is demonstrated on an input string.

Uploaded by

Rajit Kuthiala
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/ 23

Push down automata (PDA).

Dr, 1
Overview

• Introduction to Push Down Automata (PDA)


• Implementation
• State Operations

2
Push down Automata (PDA)
• This is similar to the FSM, but has additional memory
• This memory uses a stack, which has two operations:
• Push (add a new symbol at the top) Used to manipulate the
• Pop (read and remove the top symbol) stacks from the states

PDA = Finite Automata + Memory (Stack)


From left to right 
Input a1 a2 a3 .. an

FSM
Stack

Structure of the Push Down Automaton


PDA cntd.
• A PDA is a septuple (7-tuple) system (Q,Σ,Г,δ,q0,Z0,F)
where:
• Q is a finite set of states {qi …., qn)
• Σ is an input alphabet (alphabet of the language);
• Г is a stack alphabet (stack-symbols denoted by Gamma);
• δ is the transition mapping from Q×(Σ ∪{ ε})×Г to finite
subsets of Q× Г *
• q0 in Q is the initial state (start state);
• Z0 in Г is a particular stack-symbol called the start
symbol;
• F: the set of final states (F ⊆ Q)
4
Conventions
used
• Lower cases are used for input symbols eg. a, b, c,…
•  is also allowed as a possible value

• Upper cases are used for stack symbols


• Eg. X, Y, Z, …

• Lower case letters at the end of the alphabets are used


for strings of input symbols eg. x, y, z, …

• The beginning Greek alphabets are used for strings of


stack symbols
5
• Eg.   …
Implementing
PDA
• This take into account a transition function with the
following arguments:
1. A state, in Q
2. An input symbol in Σ or 
3. A stack symbol Г
For every δ(q, a, z), this will contain (p, ) such that:
p = a state
  a string of stack symbols

In addition, a PDA having a state ‘q’, and ‘a’ at the front of


the input, and Z at the top of the stack implies:
change the state to p 6
Remove ‘a’ from the front of input
Replace Z on the top of the stack by ‘’
Implementing PDA
cntd.
Example.
To design a PDA which will accept the Language
{0n1n | n ≥ 1}
• The states in here shows:
• q= the start state (permitting zeros at the beginning)
• p = At least one 1 can proceed if the inputs are 1’s
•f = Final state (we will accept if the number of
1’s
matches the number of 0’s)
• Z0 = Start symbol (this marks the bottom of the
stark 7
• X= a marker that counts the number of 0’s in
the input
Implementing
PDA
Given the following input string 0 0 0 1 1 1

Does this satisfy the automaton?


String: from left to right
The following transitions apply: Stack: LIFO

δ(q, 0, Z0) = {(q, XZ0)}


Mapping (Replacement string)
δ(q, 0, X) = {(q, XX)}
Stay in state q since
the input = 0’s
:
Number of X on stack = the number
δ(q, 1, X) = {(p, )} of 0’s read from input
Change to state p
since the input =1’s When 1 is encountered, then we
pop one X from the stack

δ(p, 1, X) = {(p, )}


Pop one X per occurrence of 1
δ(p,  , Z0) = {(f, )}
8
Z0 at the top of stack
No input
a = input symbol or ᴧ; X = stack symbol
Transition function mapping each triple (qi , a, X), where qi = a state;

δ(q, 0, X) = {(q, XZ0)}

inputs

0 0 0 1 1 1

start
Criteria: All inputs are
completely consumed
Z0
δ
Z0 = top T1 T2 T3 T4 T5 T6
symbol and
also marks the X Z0
Bottom of the X accept
stack Z0 X X X
X
Marker to Push 0 X X Pop 1
X Z0
count the
number of Z0 Z0 Pop 1
zeros on the Z0 9
input Push 0 Pop 1
Push 0
State q State p
State
Operations
• Note that transitions of the PDA is the form:

a, x  y … a …
Input string

This implies that if “a” is seen in the input string, and there is an
“x” symbol on top of the stack,
“y” is then added and the “x” is removed

This applies to the operations (Replace, push, pop, No Change)

10
State Operations
(Replace)

Push symbol
Input symbol a, b  c

Top stack symbol

a, b  c
q1 q2
b c
Transition to state q 2 11
f
f
replace $
$
State Operation
(Push)

Push symbol
Input symbol a,  
c
Top stack symbol

a,  
q1 q2
c c
b b
Transition to state q 2 12
f f
push
$ $
State Operation
(Pop)

Push symbol
Input symbol a, b  

Top stack symbol

a, b  
q1 q2

b
Transition to state q 2 f 13
f
pop $
$
State Operation (No
change)

Push symbol
Input symbol a,  

Top stack symbol

a,  
q1 q2 Note: the Automaton will
 halts or rejects input if
b b there is an attempt to
Transition to state q2 f
perform a pop or replace
f operation on an empty 14
$
No change $ stack.
Condition for PDA acceptance or
rejection

• The PDA accepts if there is a computation such that:


• the computation path ends in an accept state, and
• all the inputs in the string is consumed.

• On the other hand, the PDA rejects if in all paths:


• the computation path ends in the non accepting state, and
• there is an incomplete computation path such that there is no
possible transition in the input and stack symbols.

15
Empty stack indicator
($)

• We place dollar sign ($) or Z0 as the case may be to


help indicate when the stack is empty.
• Discovering the sign again indicates the end of the
stack

16
Familiar
Example
• Consider the Machine to accept the PDA for the language {an bn | n ≥ 1}

: 17
.
Sequence of moves (Goes to
“˫”)
• To describe the sequence of moves of the previous
example, the following holds:
• (q0, 000111, Z0) ˫ (q0, 00111, 0Z0) ˫
• (q0,0111, 00Z0) ˫ (q0, 111, 000Z0) ˫
• (q1, 11, 00Z0) ˫ (q1, 1,0Z0) ˫
• (q1, , Z0) ˫ (q2, , Z0 )

• Therefore, (q0, 000111, Z0) ˫ (f, , Z0 )

18
Sequence of moves (Goes to
“˫”)
• In a situation where there is an extra 1 eg. 0001111 on
the input, this gives the following sequence:
• (q0, 0001111, Z0) ˫ (q0, 001111, 0Z0) ˫
• (q0,01111, 00Z0) ˫ (q0, 1111, 000Z0) ˫
• (q1, 111, 00Z0) ˫ (q1, 11, 0Z0) ˫ (q1, 1, Z0) ˫
• (f, , Z0)

Therefore, 0001111 is not accepted.

19
• Consider the Machine to accept the PDA for the language {an b2n | n ≥ 1}
• Consider the Machine to accept the PDA for the language {WcWr}
• Consider the Machine to accept the PDA for the language {WWr }
THANK
YOU!

20

You might also like