0% found this document useful (0 votes)
30 views51 pages

PDA To Upload

Pumping lemma for context-free grammars (CFGs) states that if a string in a CFG language is longer than a certain length, it can be broken into five parts where the middle part repeats. The parts must meet certain size and language membership conditions. The pumping lemma is used to prove languages are not context-free and to prove languages are infinite in size. It breaks strings into five parts: the initial substring, the middle substring to be pumped, and the remaining substring.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views51 pages

PDA To Upload

Pumping lemma for context-free grammars (CFGs) states that if a string in a CFG language is longer than a certain length, it can be broken into five parts where the middle part repeats. The parts must meet certain size and language membership conditions. The pumping lemma is used to prove languages are not context-free and to prove languages are infinite in size. It breaks strings into five parts: the initial substring, the middle substring to be pumped, and the remaining substring.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 51

Pumping lemma for CFG

Pumping Lemma for CFG


Pumping Lemma
for Context-Free Languages
• Pumping Lemma:
Let G = (V, T, P, S) be a CFG in CNF, and let n = 2|V|. If z is a string in L(G) and |z| 
n, then there exist substrings u, v, w, x and y in T* such that z=uvwxy and:

– |vx|  1 (i.e., |v| + |x|  1, or, non-null)


– |vwx|  n (the loop in generating this substring)
– uviwxiy are in L(G), for all i  0

– Note: u or y could be of any length, may be ε


– vwx is in the middle, of size >0
– Note the difference with Regular Language pumping lemma
Pumping lemma for context free grammar is used for

a)Proving certain languages are not context free

b) Proving language is infinite

c) Both (a) and (b)

d) None of these
• Answer:A
Pumping lemma for context free language breaks the strings into

a)Two parts

b) Three parts

c) Five parts

d) Six parts
• Answer:five parts
CSE322
Representation of Pushdown Automata
&
Description and Model of Pushdown Automata

Lecture #30
• A finite automaton cannot accept L, i.e. strings of the form a^nb^n, as it has to
remember the number of a's in a string and so it will require an infinite number of
states.

• This difficulty can be avoided by adding an auxiliary memory in the form of a 'stack' (In
a stack we add the elements in a linear way. While removing the elements we follow
the last-in-first-out (LIFO) basis. i.e. the most recently added element is removed first.)

• The a's in the given string are added to the stack. When the symbol b is encountered in
the input string, an a is removed from the stack.

• Thus the matching of number of c's and the number of b's is accomplished. This type of
arrangement where a finite automaton has a stack leads to the generation of a
pushdown automaton.
• Which of the following automata takes stack
as auxiliary storage?
a) Finite automata
b) Push down automata
c) Turing machine
d) All of the mentioned
Pushdown Automata

• Adding additional auxiliary memory to Finite Automaton; in


form of ‘ Stack’ ; is Pushdown Automaton.
• While removing the elements LIFO ( Last In First Out) basis.
• Has Read only Input Tape
• An input Alphabet
• Finite state control
• Set of final states
• Initial state
• In Addition to this has Stack “Pushdown Store”.
• It is a Read Write Pushdown Store, as element added to PDA
or removed from PDA
• PDA is in some state and on reading an input symbol and the
topmost symbol in PDA, it moves to a new state and
writes(adds) a string of symbol in PDA.
Pushdown Automata
Pushdown automata are for context-free
languages what finite automata are for regular
languages.

PDAs are recognizing automata that have a


single stack (= memory):
Last-In First-Out pushing and popping

Difference: PDAs are inherently nondeterministic.


(They are not practical machines.)
The transition a Push down automaton makes is
additionally dependent upon the:

a) stack
b) input tape
c) terminals
d) none of the mentioned
A DPDA is a PDA in which:

a) No state p has two outgoing transitions


b) More than one state can have two or more outgoing
transitions
c) Atleast one state has more than one transitions
d) None of the mentioned
Statement: For every CFL, G, there exists a PDA M such
that L(G) = L(M) and vice versa.
a) true
b) false
If the PDA does not stop on an accepting state and the stack is not
empty, the string is:

a) rejected
b) goes into loop forever
c) both (a) and (b)
d) none of the mentioned
A pushdown automata can be defined as: (Q, ∑, G, q0,
z0, A, d)
What does the symbol z0 represents?
a) an element of G
b) initial stack symbol
c) top stack alphabet
d) all of the mentioned
Answer: d
Explanation: z0 is the initial stack symbol, is an
element of G. Other symbols like d represents the
transition function of the machine.
Which of the following correctly recognize the symbol ‘|-‘ in context to
PDA?
a) Moves
b) transition function
c) or/not symbol
d) none of the mentioned
Answer: a
Explanation: Using this notation, we can define moves
and further acceptance of a string by the machine.
For a counter automaton, with the symbols A and Z0, the
string on the stack is always in the form of __________
a) A
b) AnZ0, n>=0
c) Z0An, n>=0
d) None of the mentioned
Answer: b
Explanation:The possible change in the stack contents
is a change in the number of A’s on the stack.
The instantaneous PDA is has the following elements
a) State
b) Unconsumed input
c) Stack content
d) All of the mentioned
A PDA machine configuration (p, w, y) can be correctly represented as:
a) (current state, unprocessed input, stack content)
b) (unprocessed input, stack content, current state)
c) (current state, stack content, unprocessed input)
d) none of the mentioned
Answer: a
Explanation: A machine configuration is an element of
K×Σ*×Γ*.
(p,w,γ) = (current state, unprocessed input, stack content).
Example 7.2
A push down automata is said to be _________ if it has atmost one
transition around all configurations.
a) Finite
b) Non regular
c) Non-deterministic
d) Deterministic
Answer: d
Explanation: DPDA or Deterministic Push down automata
has atmost one transition applicable to each configuration.
A language is accepted by a push down automata if it
is:
a) regular
b) context free
c) both (a) and (b)
d) none of the mentioned
Answer: c
Explanation: All the regular languages are the subset to
context free languages and thus can be accepted using
push down automata.
`

You might also like