You are on page 1of 22

CHAPTER-4

Pushdown Automata (PDA)


Compiled by MF
2014 E.C

1
Pushdown Automata
• A pushdown automata is a way to implement a context-free
grammar in a similar way we design a DFA for a regular
grammar.
• A DFA can remember a finite amount of information, but a PDA
can remember an infinite amount of information.
• Basically, a PDA is “Finite State Machine”+ a “Stack”
• A pushdown automaton is simply an NFA augmented with an
"external stack memory". The addition of stack is used to provide
a last-in-first-out memory management capability to Pushdown
automata.
• Pushdown automata can store an unbounded amount of
information on the stack.

2
Cont….
PDA Components
• A push down automata has three components:
1. Input tape: The input tape is divided in many cells or
symbols. The input head is read-only and may only move
from left to right, one symbol at a time.
2. Finite control: The finite control has some pointer which
points the current symbol which is to be read.
3. Stack: The stack is a structure in which we can push and
remove the items from one end only. It has an infinite size.
In PDA, the stack is used to store the items temporarily.
• A PDA is more powerful than FA.
• Any language which can be acceptable by FA can also be acceptable
by PDA.
• PDA also accepts a class of language which even cannot be accepted
by FA. Thus PDA is much more superior to FA. 4
Cont…
 The stack head scans the top symbol of stack.

 A stack does two operations:


– PUSH: a new symbol is added at the top

– POP: the top symbol is read and removed

 A PDA may or may not read a input symbol, but it has to read the top
of the stack in every transition.

 A PDA can push an element onto the top of the stack and pop off an
element from the top of the stack.

 To read an element into the stack, the top elements must be popped off

and are lost.


Formal definition of PDA
• A pushdown automaton (PDA) is a seven-tuple:
M = (Q, Σ, Г, δ, q0, z0, F)
Q A finite set of states
Σ A finite input alphabet
Г A finite stack alphabet
q0 The initial/starting state, q0 is in Q
z0 A starting stack symbol, is in Г // need not always
remain at the bottom of stack
F A set of final/accepting states, which is a subset of Q
δ A transition function, where
δ: Q x (Σ U {ε}) x Г –> finite subsets of Q x Г*
6
Cont…
• Transition function of PDA is denoted as
: (q, a, x) =(p, y) , which specified transaction in PDA
is function of three components.
1. q is Present state of PDA
2. a is symbol of input alphabet, a being read by PDA
3. x is symbol at top of stack.
4. P is next state
5. Y is push/Pop
• (current state, input symbol, top of stack)
= (Next state, Push/Pop/Skip) 7
Cont…
• In every transaction i.e (q, a, x) =(p, y) ,
– PDA enters into new state P or remain into the
same state p=q
– If a= , then no symbol is consumed
– If y=zx, symbol z is PUSHED into the stack at the
top
– If y= , symbol x at the top of the stack is POPED
– If y=x, no change of symbol at the top of the stack.

8
Representation of PDA
• The nodes correspond to the states of the PDA.
• An arrow labeled start indicates the start state
• Doubly circled states are accepting.
• If (q; a; X) contains a pair (p; a),
then there is an arc from q to p labeled a;

• The only thing that the diagram does not tell us is which
stack symbol is the start symbol. Conventionally, it is Z.

9
Transition diagram of PDA
• The following diagram shows a transition in a
PDA from a state q1, to state q2, labled as “a, b/c”

10
Example of PDA:
• Define the push down automata for the language
L= where Q={q0, q1}, Σ={a, b ={a, z} and
is given by
(q0, a, z) = {q0, az} ··· push first a

(q0, a, a) = {q0, aa} ··· push further a’s

(q0, b, a) = {q1, } ··· start popping a’s

(q1, b, a) = {q1, } ··· pop further a’s

(q1, , z) = {q1, } ··· accept

11
Cont…

12
Chapter-5
Turing Machine
2014 E.C
Alan Mathison Turing

• Alan Turing was one of the founding fathers of


CS.
– His computer model , the Turing Machine, was
inspiration of the electronic computer that came two
decades later.

– Invented the “Turing Test” used in AI

14
Cont…
• So far, we have learned about FA and PDA.
• Finite Automata(FA): it is a good device with small amount of
limited memory, relatively simple control.
• Push-down Automata (PDA): is a stack based automation.
• But both have limitations for even simple tasks, too restrict as
general purpose computers.
• Turing machine (TM) is more powerful device than either of FA
and PDA.
• Turing machine is essentially a finite automata but it has an
unlimited memory.
• TM is a type 0 acceptor or recognizer as per Chomsky hierarchy of
formal language.
• TM accepts type 0 language i.e Recursively Enumerable
Language (REL)
A Thinking Machine
• First Goal of Turing’s Machine:
– A model that can compute anything that a human can
compute.

• Before invention of electronic computers the term


“computer” actually referred to a person whose line of
work is to calculate numerical quantities!
• Turing’s Thesis:
– Any “algorithm” can be carried out by one of his machines
16
Turing Machine
• Turing machine is a model of general purpose computer.

• A Turing machine can do everything that a real computer can


do.

• The Turing machine model uses an infinite tape as its


unlimited memory.

• It has a tape head that can read and write symbols and move
around on the tape.

• Initially the tape contains only the input string and is blank
everywhere else. 17
• If the machine needs to store information, it may write this
information on the tape.

• To read the information that it has written, the machine can


move its head back over it.

• The machine continues computing until it decides to produce


an output.

• The outputs accept and reject are obtained by entering


designated accepting and rejecting states.

• If it doesn't enter an accepting or a rejecting state, it will go


18
on forever, never halting.
Modeling of Turing Machine
 Turing machine is a FA connected to read-write head with the
following components:
1. Infinite Tape

2. Read-write head

3. Control Unit
Formal definition of Turning Machine
• End Of Chapter

21
End of chapter

22

You might also like