0% found this document useful (0 votes)
41 views

Pushdown Automata

Pushdown automata (PDA) are computation models like finite automata (FA) but with an additional stack component. This allows PDA to recognize some non-regular languages that FA cannot. A PDA works like an NFA with the added ability to write and read symbols on a stack, providing unlimited memory. PDA and context-free grammars (CFG) are equivalent in specification power, allowing languages to be described in terms of either their generators (CFG) or recognizers (PDA).

Uploaded by

Orijit Nandy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Pushdown Automata

Pushdown automata (PDA) are computation models like finite automata (FA) but with an additional stack component. This allows PDA to recognize some non-regular languages that FA cannot. A PDA works like an NFA with the added ability to write and read symbols on a stack, providing unlimited memory. PDA and context-free grammars (CFG) are equivalent in specification power, allowing languages to be described in terms of either their generators (CFG) or recognizers (PDA).

Uploaded by

Orijit Nandy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Pushdown Automata

Pushdown Automata – p.1/25


Rationale

CFG are specification mechanisms, i.e., a


CFG generates a context-free language.
Pushdown-automata are recognizing
mechanisms, i.e., a PDA recognizes a
context-free languiage.
CFG are like regular expressions and PDA
are like FA.

Pushdown Automata – p.2/25


A new type of computation model

Pushdown automata, PDA, are a new type of


computation model
PDAs are like NFAs but have an extra
component called a stack
The stack provides additional memory beyond
the finite amount available in the control
The stack allows PDA to recognize some
nonregular languages

Pushdown Automata – p.3/25


PDA and CFG

PDA are equivalent in specification power


with CFG
This is useful because it gives us two options
for proving that a language is context-free:
1. construct a CFG that generates the language or
2. construct a PDA that recognizes the language

Pushdown Automata – p.4/25


Note

Some CFL are more easily described in terms of


their generators, whereas others are more easily
described in terms of their recognizers

Pushdown Automata – p.5/25


Schematic representation of a PDA

Figure 1 contrasts the schematic representations


of PDA and NFA :
Schematic of a PDA
Schematic of a NFA Input
r
Finite r Input Finite a a b b
a a b b Stack
Control Control r/w x y z

Figure 1: Schematic representations

Note: in Figure 1 r stands for read and w stands for write.

Pushdown Automata – p.6/25


More on PDA informal

A PDA can write symbols on the stack and


read them back later
Writing a symbol “pushes down" all the other
symbols on the stack
The symbol on the top of the stack can be
read and removed.
When the top symbol is removed the
remaining symbols move up

Pushdown Automata – p.7/25


Terminology

Writing a symbol on the stack is referred to as


pushing the symbol
Removing a symbol from the stack is referred
to as popping the symbol
All access to the stack may be done only at
the top

In other words: a stack is a “last-in fi rst-out" storage device

Pushdown Automata – p.8/25


Benefits of the stack

A stack can hold an unlimited amount of


information
A PDA can recognize a language like
because it can use the stack to
remember the number of s it has seen

Pushdown Automata – p.9/25


PDA recognizing
Informal algorithm:
1. Read symbols from the input. As each 0 is read push it onto the
stack
2. As soon as a 1 is read, pop a 0 off the stack for each 1 read
3. If input fi nishes when stack becomes empty accept; if stack
becomes empty while there is still input or input fi nishes while
stack is not empty reject

Pushdown Automata – p.10/25


Nature of PDA

PDA may be nondeterministic and this is a


crucial feature because nondeterminism adds
power
Some languages, such as do not
require nondeterminism, but other do. Such a
language is

Pushdown Automata – p.11/25


Toward PDA formalization
Formal defi nition of a PDA is similar to a NFA, except the stack
PDA my use different alphabets for input and stack, we will denote
them by and
Nondeterminism allows PDA to make transitions on empty input.
Hence we will use and
Domain of the PDA transition function is where is
the set of states
Since a PDA can write on the stack while performing
nondeterministic transitions the range of the PDA transition
function is

In conclusion:
Pushdown Automata – p.12/25
Definition 2.8

A pushdown automaton is a 6-tuple


where , , , and are finite
sets, and:
1. is a set of states
2. is the input alphabet
3. is the stack alphabet
4. is the transition function
5. is the start state
6. is the set of accept states

Pushdown Automata – p.13/25


PDA computation

A PDA computes as
follows:
inputs , where each
There are a sequence of states and a sequence
of strings that satisfy the conditions:
1. , , i.e., starts in the start state with empty stack
2. For we have where
and for some and , i.e.,
moves properly according to the state, stack, and input symbol
3. , i.e., an accept state occurs at the input end

Pushdown Automata – p.14/25


Example PDA

The PDA that recognizes the language


is where:
, , ,
is defi ned by the table:
0 1
$ $ $

Notation: means .

Pushdown Automata – p.15/25


Transition diagrams of PDA

We can use state transition diagrams to


describe PDA
Such diagrams are similar to state transition
diagrams used to describe finite automata
To show how PDA uses the stack we write
“ " to signify that the machine:
1. is reading from input
2. may replace the symbol on top of the stack
3. with the symbol
where any of may be

Pushdown Automata – p.16/25


Interpretation

If is , the machine makes this transaction


without reading any symbol from the input
If is , the machine makes this transaction
without popping any symbol from the stack
If is , the machine makes this transaction
without pushing any symbol on the stack

Pushdown Automata – p.17/25


Transition diagram of PDA

Figure 2 show the state transition diagram of


recognizing the language

Figure 2: Transition diagram for PDA

Pushdown Automata – p.18/25


Note 1

The formal definition of a PDA contains no


explicit mechanism for testing the empty stack
PDA in Figure 2 test empty stack by initially
placing a special symbol, $, on the stack
If ever it sees $ again on the stack, it knows
that the stack is effectively empty

This is the procedure we use to test empty stack

Pushdown Automata – p.19/25


Note 2

The PDA has no mechanism to test explicitly


the reaching of end of the input
The PDA in Figure 2 is able to achieve this
effect because the accept state takes effect
only when the machine is at the end of the
output

Thus, from now one we use the same mechanism


to test for the end of the input

Pushdown Automata – p.20/25


Example 2.10

This example provides the PDA that


recognizes the language
Informal description:
The PDA fi rst reads and push ’s on the stack
When this is done, it can match s with s or s
Since machine does not know in advance whether s are
matched with s or s, nondeterminism helps
Using nondeterminism the machine can guess: the machine has
two branches, one for each possible guess
If either of these branches match, that branch accepts and the
entire machine accepts
Pushdown Automata – p.21/25
recognizing
The transition diagram is in Figure 3

Figure 3: Transition diagram of PDA

Pushdown Automata – p.22/25


Example 2.11

This example provides the PDA that


recognizes the language .
Recall: means written backwards.

Pushdown Automata – p.23/25


Informal description
1. begins by pushing the symbols that are read onto the stack
2. At each point nondeterministically guesses that the middle of
the input has been reached
3. When middle of the word has reached the machine starts popping
off the stack for each symbol read, checking to see that what is
read and what is popped off is the same symbol
4. If the symbol read from the input and popped out from the stack is
the same and the stack empties as the same time as input is
fi nished, accept; otherwise reject

The transition diagram of is in Figure 4

Pushdown Automata – p.24/25


Transition diagram of PDA

Figure 4 shows the state transition diagram of


recognizing the language

Figure 4: Transition diagram for PDA

Pushdown Automata – p.25/25

You might also like