You are on page 1of 19

Push Down Automata

Chapter 14
Introduction
• We have seen different types of languages so far
– Regular Languages
– Nonregular Languages
– Context Free Languages
• The following Venn diagram shows the domains of each
of these languages

Languages

CFLs

Regular Langs

Finite Langs
Introduction
• Clearly the set of CFLs is larger as compared to
that of RLs
• We have two machines to recognize the RLs
• All the CFLs that are also RLs can also be
recognized by FAs and TGs
• What about the rest of CFLs?
• We need to have a new machine for them
Need for a Machine
• Sole requirement of a machine is not only the
language recognition
• But some other major purposes are also served by a
machine
• Machines provide great support in the analysis of the
languages through their formal graphical
representation
• They facilitate the discovery of important
characteristics about languages
• FA gave a thorough insight into the RLs (Union,
Intersection, Complement, Pumping Lemma etc.) all
need extensive support of FAs and TGs
Push Down Automata
• PDA are the new machines resulted by some
enhancement in the concept of FAs to recognize
Context Free Languages
• Different pictorial representation
• Enhanced recognition features (explicit results
about acceptance and rejection)
• Employ a stack data structure
PDA
• Elements
– INPUT TAPE
• Infinite
• Sequential (left to right)
• ∆ stands for blank and represents the end of string
– States
• START
START – Equivalent to – state of TG connected by Λ to any other state
– No incoming arrow
• ACCEPT
ACCEPT – Equivalent to a dead final state
– Once entered can’t be left
• REJECT
REJECT – Equivalent to non final dead state
– Once Entered can’t be left even
PDA
• Elements
– States
• READ
– Reads an input letter from the tape
– Directed edges show the path to move after a certain
character is read

b
Read the
next
input letter

PDA
• The FA accepts the language of all strings that end in a
b a a

- +
b

• The corresponding PDA would be


START

b
a
b READ READ


a
REJECT ACCEPT
PDA
• The edge from START state needs no label
because START reads no letter
• The ACCEPT and REJECT states are also
called halt states as once entered can’t be
left
PDA
• Example
– A language of strings with a double a
b a a,b
a
- +
b

a,b
b b

a
START READ READ READ
a ∆
∆ ∆
ACCEPT
REJECT REJECT
PUSHDOWN STACK
• Pushdown store
• Input letters are stored on a pushdown stack until
they are required again
• The operation PUSH adds a letter to the top of the
stack
• The POP operation pops the top letter
• Before the machine begins to process an input
string, the STACK is presumed to be empty
PUSHDOWN STACK
• When a letter is Popped each of the elements
below moves one position up
• The empty locations of the stack are filled with ∆ as
in case of the INPUT TAPE
• STACK has infinite length
• Only the top letter of the STACK can be read
• If the fourth letter is to be read then four POP
operations are needed
• Popping an empty stack gives a ∆
PDA
• New elements
– Operations
• PUSH
• POP

a
b
POP
PUSH a PUSH a

PDA STACK
• The edges out of a POP are labeled the same
way as in case of a read (one for each
character so far)
• The branching can occur at POP states only
i.e. the PUSH states have only a single
outgoing edge
• Nevertheless a PUSH state may have multiple
incoming edges
START
PDA

READ
a b

PUSH a POP READ POP a,b
b a ∆
∆,b a

REJECT REJECT ACCEPT REJECT

STACK
a a a b b b ∆ ∆ ∆ ∆ ∆ ∆ ∆ ∆

….
INPUT TAPE
PDA Vs. FAs
• Both the machines though have finite states but

PDAs have an unlimited storage capacity

• Besides PDAs can also keep a track of the

number of times a particular character has been

read or the number of times a particular state

has been visited


PDA: A Formal Definition
• A pushdown automaton, PDA is a collection of eight
things
– An alphabet  of input letters
– An input TAPE (infinite in one direction). The string of input
letters is placed on the TAPE starting at cell i. The rest of the
TAPE is filled with ∆.
– An alphabet Г of STACK characters
– A pushdown STACK (infinite in one direction). The STACK is
empty initially
– One START state that has only out-edges, no in-edges
– Halt states of two kinds: some ACCEPT and some REJECT.
Both of these have incoming edges but no outgoing edge
– Finitely many nonbranching PUSH states that introduce
characters onto the top of STACK.
– Finitely many branching states of two kinds (may be non
deterministic)
• READ states which read the next unused letter from the TAPE
• POP states which read the top character of the STACK
Practice Exercise…
• Language of all those strings that
contains aaa.
• Language of all those strings that
contains ab.
• amb2mcn where m,n are Natural
numbers.
• ambm+ncn whre m,n are natural
numbers.
Cont………
• amb3mcnd2nwhre m,n are natural
numbers.

You might also like