0% found this document useful (0 votes)
37 views7 pages

Unit 4 - Pda-Basics

The document provides an overview of pushdown automata (PDA) including: - PDAs extend finite automata with a stack, allowing them to recognize context-free languages. - PDAs are formally defined by a 7-tuple including states, input symbols, stack symbols, and transitions. - Configurations describe the PDA's state, remaining input, and stack contents at each step. - Languages recognized depend on whether the PDA reaches an accept state or empties its stack. - An example PDA is given that recognizes the language of strings with an equal number of a's and b's.

Uploaded by

sakshipowar144
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)
37 views7 pages

Unit 4 - Pda-Basics

The document provides an overview of pushdown automata (PDA) including: - PDAs extend finite automata with a stack, allowing them to recognize context-free languages. - PDAs are formally defined by a 7-tuple including states, input symbols, stack symbols, and transitions. - Configurations describe the PDA's state, remaining input, and stack contents at each step. - Languages recognized depend on whether the PDA reaches an accept state or empties its stack. - An example PDA is given that recognizes the language of strings with an equal number of a's and b's.

Uploaded by

sakshipowar144
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/ 7

THEORY OF COMPUTATION LECTURE

NOTES

UNIT 4 (10 Lectures)

Pushdown Automata: Definition Formal Definition of Pushdown Automata, A Graphical Notation for PDA‟s,
Instantaneous Descriptions of a PDA,
Languages of PDA: Acceptance by Final State, Acceptance by Empty Stack, From Empty Stack to Final State, From
Final State to Empty Stack
Equivalence of PDA‟s and CFG‟s: From Grammars to Pushdown Automata, From PDA‟s to Grammars
Deterministic Pushdown Automata: Definition of a Deterministic PDA, Regular Languages and Deterministic
PDA‟s, DPDA‟s and Context-Free Languages, DPDA‟s and Ambiguous Grammars
Properties of Context-Free Languages: Normal Forms for Context-Free Grammars, The Pumping Lemma for
Context-Free Languages, Closure Properties of Context-Free Languages, Decision Properties of CFL‟s

Push down automata:


Regular language can be charaterized as the language accepted by finite automata. Similarly, we can
characterize the context-free language as the langauge accepted by a class of machines called "Pushdown
Automata" (PDA). A pushdown automation is an extension of the NFA.

It is observed that FA have limited capability. (in the sense that the class of languages accepted or
characterized by them is small). This is due to the "finite memory" (number of states) and "no external memory"
involved with them. A PDA is simply an NFA augmented with an "external stack memory". The addition of a
stack provides the PDA with a last-in, first-out memory management cpapability. This "Stack" or "pushdown
store" can be used to record a potentially unbounded information. It is due to this memory management
capability with the help of the stack that a PDA can overcome the memory limitations that prevents a FA to

accept many interesting languages like . Although, a PDA can store an unbounded amount of
information on the stack, its access to the information on the stack is limited. It can push an element onto the
top of the stack and pop off an element from the top of the stack. To read down into the stack the top elements
must be popped off and are lost. Due to this limited access to the information on the stack, a PDA still has
some limitations and cannot accept some other interesting languages.
As shown in figure, a PDA has three components: an input tape with read only head, a finite control and a
pushdown store.

The input head is read-only and may only move from left to right, one symbol (or cell) at a time. In each step,
the PDA pops the top symbol off the stack; based on this symbol, the input symbol it is currently reading, and
its present state, it can push a sequence of symbols onto the stack, move its read-only head one cell (or
symbol) to the right, and enter a new state, as defined by the transition rules of the PDA.

PDA are nondeterministic, by default. That is, - transitions are also allowed in which the PDA can pop and
push, and change state without reading the next input symbol or moving its read-only head. Besides this, there
may be multiple options for possible next moves.

Formal Definitions : Formally, a PDA M is a 7-tuple M =


where,

 is a finite set of states,


 is a finite set of input symbols (input alphabets),
 is a finite set of stack symbols (stack alphabets),

 is a transition function from to subset of

 is the start state

 , is the initial stack symbol, and

 , is the final or accept states.

Explanation of the transition function, :

If, for any , . This means intitutively that whenever the


PDA is in state q reading input symbol a and z on top of the stack, it can nondeterministically for any i,

 go to state
 pop z off the stack

 push onto the stack (where ) (The usual convention is that if , then

will be at the top and at the bottom.)


 move read head right one cell past the current symbol a.

If a = , then means intitutively that whenver the PDA is in


state q with z on the top of the stack regardless of the current input symbol, it can nondeterministically for any
i, ,

 go to state
 pop z off the stack

 push onto the stack, and


 leave its read-only head where it is.
State transition diagram : A PDA can also be depicted by a state transition diagram. The labels on the arcs
indicate both the input and the stack operation. The transition

for and is depicted by

Final states are indicated by double circles and the start state is indicated by an arrow to it from nowhere.

Configuration or Instantaneous Description (ID) :

A configuration or an instantaneous description (ID) of PDA at any moment during its computation is an
element of describing the current state, the portion of the input remaining to be read (i.e.
under and to the right of the read head), and the current stack contents. Only these three elements can
affect the computation from that point on and, hence, are parts of the ID.

The start or inital configuartion (or ID) on input is . That is, the PDA always starts in its
start state, with its read head pointing to the leftmost input symbol and the stack containing only the
start/initial stack symbol, .

The "next move relation" one figure describes how the PDA can move from one configuration to another
in one step.

Formally,

iff
'a' may be or an input symbol.

Let I, J, K be IDs of a PDA. We define we write I K, if ID I can become K after exactly i moves. The

relations and define as follows

IK

I J if such that I K and K J

I J if such that I J.
That is, is the reflexive, transitive closure of . We say that I J if the ID J follows from the ID I in
zero or more moves.

( Note : subscript M can be dropped when the particular PDA M is understood. )

Language accepted by a PDA M

There are two alternative definiton of acceptance as given below.

1. Acceptance by final state :

Consider the PDA . Informally, the PDA M is said to accept its input by final
state if it enters any final state in zero or more moves after reading its entire input, starting in the start
configuration on input .

Formally, we define L(M), the language accepted by final state to be

{ | for some and }

2. Acceptance by empty stack (or Null stack) : The PDA M accepts its input by empty stack if starting in the
start configuration on input , it ever empties the stack w/o pushing anything back on after reading the entire
input. Formally, we define N(M), the language accepted by empty stack, to be

{ | for some }

Note that the set of final states, F is irrelevant in this case and we usually let the F to be the empty set i.e. F =
Q.

Example 1 : Here is a PDA that accepts the language .

, and consists of the following transitions


The PDA can also be described by the adjacent transition diagram.

Informally, whenever the PDA M sees an input a in the start state with the start symbol z on the top of the

stack it pushes a onto the stack and changes state to . (to remember that it has seen the first 'a'). On state

if it sees anymore a, it simply pushes it onto the stack. Note that when M is on state , the symbol on the

top of the stack can only be a. On state if it sees the first b with a on the top of the stack, then it needs to
start comparison of numbers of a's and b's, since all the a's at the begining of the input have already been
pushed onto the stack. It start this process by popping off the a from the top of the stack and enters in state q3

(to remember that the comparison process has begun). On state , it expects only b's in the input (if it sees
any more a in the input thus the input will not be in the proper form of anbn). Hence there is no more on input a

when it is in state . On state it pops off an a from the top of the stack for every b in the input. When it
sees the last b on state q3 (i.e. when the input is exaushted), then the last a from the stack will be popped off
and the start symbol z is exposed. This is the only possible case when the input (i.e. on -input ) the PDA M

will move to state which is an accept state.


we can show the computation of the PDA on a given input using the IDs and next move relations. For example,
following are the computation on two input strings.

Let the input be aabb. we start with the start configuration and proceed to the subsequent IDs using the
transition function defined

( using transition 1 )

( using transition 2 )

( using transition 3 )
( using transition 4 ), ( using transition 5 ) , is final state. Hence , accept. So the
string aabb is rightly accepted by M

we can show the computation of the PDA on a given input using the IDs and next move relations. For example,
following are the computation on two input strings.

i) Let the input be aabab.

No further move is defined at this point.

Hence the PDA gets stuck and the string aabab is not accepted.

Example 2 : We give an example of a PDA M that accepts the set of balanced strings of parentheses [] by
empty stack.
The PDA M is given below.

where is defined as

Informally, whenever it sees a [, it will push the ] onto the stack. (first two transitions), and whenever it sees a ]
and the top of the stack symbol is [, it will pop the symbol [ off the stack. (The third transition). The fourth
transition is used when the input is exhausted in order to pop z off the stack ( to empty the stack) and accept.
Note that there is only one state and no final state. The following is a sequence of configurations leading to the
acceptance of the string [ [ ] [ ] ] [ ].

Equivalence of acceptance by final state and empty stack.

It turns out that the two definitions of acceptance of a language by a PDA - accpetance by final state and empty
stack- are equivalent in the sense that if a language can be accepted by empty stack by some PDA, it can also
be accepted by final state by some other PDA and vice versa. Hence it doesn't matter which one we use, since

You might also like