Professional Documents
Culture Documents
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
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
STACK
a a a b b b ∆ ∆ ∆ ∆ ∆ ∆ ∆ ∆
….
INPUT TAPE
PDA Vs. FAs
• Both the machines though have finite states but